@wirecat/drive-cli 0.71.0 → 0.72.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/README.md +150 -71
- package/contracts/wirecat.json +77 -8
- package/dist/bin/drive.js +2 -2
- package/dist/bundle/agent-23OB2NZP.js +46 -0
- package/dist/bundle/{all-profiles-3QJG2NAN.js → all-profiles-GXGDVNQJ.js} +67 -25
- package/dist/bundle/{anthropic-PSWTEU6G.js → anthropic-H5C4GQHC.js} +9 -9
- package/dist/bundle/{app-server-PVTA6ABR.js → app-server-EQ3UK4C7.js} +97 -79
- package/dist/bundle/{bun-LU5LP3JI.js → bun-DTJVSRY3.js} +2 -2
- package/dist/bundle/{bun-sqlite-PYMKLBRU.js → bun-sqlite-JIFY7MAE.js} +9 -9
- package/dist/bundle/chunk-2Q325BBD.js +353 -0
- package/dist/bundle/chunk-35FIJGTT.js +52 -0
- package/dist/bundle/{chunk-RWDKMU74.js → chunk-3FRQ6V4T.js} +3 -3
- package/dist/bundle/chunk-47L262VI.js +340 -0
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/{chunk-YVI5SQPY.js → chunk-4HPXWYTE.js} +1 -1
- package/dist/bundle/{chunk-QETR5HIZ.js → chunk-4IUNYYYL.js} +4385 -2684
- package/dist/bundle/{chunk-I4RWW3UD.js → chunk-4JS32SRX.js} +20 -5
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/{chunk-3N2OFXB5.js → chunk-55FH6IEL.js} +5 -5
- package/dist/bundle/{chunk-6TNNT2MQ.js → chunk-5BNMWSU2.js} +483 -176
- package/dist/bundle/{chunk-6XFIITOG.js → chunk-5H747A76.js} +5532 -3265
- package/dist/bundle/{chunk-MNLL5YLM.js → chunk-5KWCO56H.js} +2 -2
- package/dist/bundle/{chunk-GZ2D4KXG.js → chunk-5U3NCE5R.js} +35 -12
- package/dist/bundle/{chunk-CJLVYIOP.js → chunk-6CCO3JCM.js} +30 -21
- package/dist/bundle/{chunk-26DHFMGZ.js → chunk-6ZW2ZJYC.js} +2 -2
- package/dist/bundle/{chunk-COJSWDNU.js → chunk-75DAHQOV.js} +3 -3
- package/dist/bundle/{chunk-Q7DOMFJ4.js → chunk-77OBW43F.js} +6 -6
- package/dist/bundle/{chunk-FCS26CYQ.js → chunk-7EFM6AW3.js} +4 -4
- package/dist/bundle/{chunk-XMMFBPGC.js → chunk-A3S7QM5L.js} +3 -3
- package/dist/bundle/{chunk-ASMMG72J.js → chunk-AA4LKC6W.js} +244 -565
- package/dist/bundle/chunk-ASTKHB6B.js +3233 -0
- package/dist/bundle/{chunk-LXKYKRHD.js → chunk-BM6V7456.js} +8 -227
- package/dist/bundle/chunk-BO6EDBYJ.js +50 -0
- package/dist/bundle/{chunk-YPFWNVHV.js → chunk-BPA3R4KN.js} +2 -100
- package/dist/bundle/chunk-CIFE4KPX.js +2159 -0
- package/dist/bundle/chunk-CKB4XZZJ.js +730 -0
- package/dist/bundle/{chunk-RJOQH5YY.js → chunk-COJTCEZP.js} +111 -859
- package/dist/bundle/{chunk-FJH7DJWK.js → chunk-CWPYDT73.js} +6 -6
- package/dist/bundle/{chunk-BKSQBBYG.js → chunk-D4JNCXS7.js} +9 -9
- package/dist/bundle/chunk-DCPWZIOV.js +696 -0
- package/dist/bundle/{chunk-PRW6SYA3.js → chunk-DHMNCOQI.js} +313 -257
- package/dist/bundle/chunk-DOQMH4DC.js +280 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/{chunk-YJIGGUPI.js → chunk-DWRUOLBF.js} +4 -4
- package/dist/bundle/{chunk-6W763DZN.js → chunk-E3VWZC3K.js} +14 -13
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/{chunk-KGYVHPGE.js → chunk-EVG3AA5M.js} +2 -2
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/{chunk-Y2NWGNUB.js → chunk-FBEZSA76.js} +5 -5
- package/dist/bundle/{chunk-2BVVU7GG.js → chunk-FBQJN74J.js} +1 -1
- package/dist/bundle/{chunk-Z56QFOBR.js → chunk-FIZOPJYY.js} +1 -1
- package/dist/bundle/chunk-FNAYSZWK.js +783 -0
- package/dist/bundle/{chunk-GPQ44Y2R.js → chunk-FRCJHGZM.js} +2 -2
- package/dist/bundle/{chunk-35SCQ4VI.js → chunk-FTG5QBSD.js} +41 -33
- package/dist/bundle/{chunk-KYKW2W6X.js → chunk-FUDUXIVG.js} +1 -1
- package/dist/bundle/{chunk-NYECVHFH.js → chunk-G4NHRFS7.js} +755 -0
- package/dist/bundle/{chunk-FT3LN3HP.js → chunk-GIEZYBRC.js} +1 -1
- package/dist/bundle/chunk-GTPPUBYU.js +1876 -0
- package/dist/bundle/chunk-GU6ICH53.js +108 -0
- package/dist/bundle/{chunk-ACUAV6VX.js → chunk-GUMKKRE6.js} +107 -71
- package/dist/bundle/{chunk-KGERXYTV.js → chunk-GWCDOYSC.js} +1 -1
- package/dist/bundle/{chunk-OJSBWP3F.js → chunk-GXGSC622.js} +69 -7
- package/dist/bundle/chunk-HAGXTGJC.js +188 -0
- package/dist/bundle/{chunk-XF4EXO2C.js → chunk-IMAWQC5K.js} +6 -6
- package/dist/bundle/{chunk-HKY7X6NY.js → chunk-IVGVVSPW.js} +4 -4
- package/dist/bundle/{chunk-P7CUM5IB.js → chunk-J4NUHSM7.js} +1 -1
- package/dist/bundle/{chunk-MIA7P6FZ.js → chunk-K652FYCO.js} +6 -6
- package/dist/bundle/chunk-K6ZWNTXY.js +561 -0
- package/dist/bundle/{chunk-COOOO5B3.js → chunk-KF3ZBQJV.js} +4 -4
- package/dist/bundle/chunk-KFZCHJRT.js +80 -0
- package/dist/bundle/chunk-KLPFDFLI.js +221 -0
- package/dist/bundle/{chunk-EOEU3AZN.js → chunk-KP2XMCNT.js} +13 -13
- package/dist/bundle/{chunk-FP54WSIR.js → chunk-KWDZ3KVH.js} +4 -4
- package/dist/bundle/{chunk-QNRRK3CN.js → chunk-KX4C32WD.js} +2 -2
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/{chunk-2LHAVY4U.js → chunk-M2ZWYVWO.js} +1 -1
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/{chunk-3EBBLKIT.js → chunk-ML2QIWX2.js} +4 -4
- package/dist/bundle/{chunk-ZM63SUHG.js → chunk-MUFF2YTH.js} +2 -2
- package/dist/bundle/{chunk-2PUNKUYJ.js → chunk-N24YSLED.js} +9150 -9869
- package/dist/bundle/chunk-N4GTCPML.js +7 -0
- package/dist/bundle/{chunk-B5KSXHJ7.js → chunk-NBMGDRP4.js} +1 -1
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/{chunk-JDV7HNNQ.js → chunk-NNGA4QDR.js} +13 -26
- package/dist/bundle/{chunk-5DPV7X27.js → chunk-NTZWY5R3.js} +321 -0
- package/dist/bundle/chunk-O7CZZ36M.js +80 -0
- package/dist/bundle/{chunk-ICDCAQ6K.js → chunk-OAONP6KI.js} +13 -9
- package/dist/bundle/{chunk-WVDCCYS3.js → chunk-OESP4PHB.js} +17 -17
- package/dist/bundle/chunk-OHR6IZNH.js +116 -0
- package/dist/bundle/{chunk-4QNW4NK6.js → chunk-OLCU7Q2B.js} +1 -1
- package/dist/bundle/{chunk-SDKQNOL5.js → chunk-OLDQLEPA.js} +6 -6
- package/dist/bundle/{chunk-ZCR3IRZ2.js → chunk-OPIPG6AP.js} +16 -9
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/chunk-PRYMT3OG.js +30 -0
- package/dist/bundle/chunk-QDUIVMEW.js +36 -0
- package/dist/bundle/{chunk-ZZ32DXTH.js → chunk-QKBPCX7Y.js} +1 -1
- package/dist/bundle/{chunk-QXC6IEH6.js → chunk-QSLOACDT.js} +201 -423
- package/dist/bundle/{chunk-7PDHGZN4.js → chunk-QUZFDU4K.js} +4 -4
- package/dist/bundle/{chunk-3UGYFXH6.js → chunk-R32DHS6J.js} +187 -379
- package/dist/bundle/{chunk-6SJOTNHF.js → chunk-R57QUYBG.js} +6 -28
- package/dist/bundle/{chunk-UTO2GO4P.js → chunk-R64OSDOD.js} +45 -66
- package/dist/bundle/{chunk-GBKNJWOZ.js → chunk-RSPBVKOC.js} +8 -8
- package/dist/bundle/{chunk-HL52XXZX.js → chunk-SPNPJ3FZ.js} +3 -4
- package/dist/bundle/chunk-SQHDSIFL.js +388 -0
- package/dist/bundle/{chunk-YPNWIB6H.js → chunk-ST35FIUG.js} +3 -3
- package/dist/bundle/{chunk-37MAA6F2.js → chunk-STUPCKAA.js} +11 -2221
- package/dist/bundle/chunk-SZ7XJZGH.js +2231 -0
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/{chunk-X4TIMMKJ.js → chunk-TTPWKTVR.js} +1 -1
- package/dist/bundle/{chunk-TAFHYHKA.js → chunk-U7VEJ3CW.js} +45 -27
- package/dist/bundle/{chunk-6Y2BYFXQ.js → chunk-UC7JLE6J.js} +0 -7
- package/dist/bundle/{chunk-4HWJOU7N.js → chunk-UIQ35CA5.js} +1 -1
- package/dist/bundle/{chunk-SAKO3P4H.js → chunk-UJY26HW4.js} +1 -1
- package/dist/bundle/{chunk-D5TGYUVU.js → chunk-UWG3PRY7.js} +9 -60
- package/dist/bundle/{chunk-JZHBZOJR.js → chunk-VAR3MJU6.js} +3 -3
- package/dist/bundle/{chunk-GOWXXYEF.js → chunk-VPQSI5IU.js} +4 -4
- package/dist/bundle/{chunk-QFR2PNJN.js → chunk-VQPT3Y7W.js} +12 -12
- package/dist/bundle/{chunk-Z3KUSRCF.js → chunk-WMG3H2VK.js} +2 -2
- package/dist/bundle/{chunk-4PA4DHYV.js → chunk-X5BGAZC5.js} +6 -6
- package/dist/bundle/{chunk-2UUWXPOB.js → chunk-XC6TRWLZ.js} +3 -3
- package/dist/bundle/{chunk-OF422U5D.js → chunk-XQZEMRCU.js} +402 -402
- package/dist/bundle/{chunk-72C4YOCH.js → chunk-XZ7MO6EU.js} +7 -7
- package/dist/bundle/{chunk-SERXSCN3.js → chunk-YAIOEPKU.js} +337 -390
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/{chunk-RESDD3Q4.js → chunk-YWOLQEDV.js} +16 -3
- package/dist/bundle/{chunk-YMJ6IDGT.js → chunk-ZFDSJ5YJ.js} +38 -8
- package/dist/bundle/{chunk-HMS6EEQL.js → chunk-ZFUZEFU6.js} +3 -3
- package/dist/bundle/{chunk-TAUBRNC5.js → chunk-ZJKXSMXK.js} +72 -59
- package/dist/bundle/{chunk-22QQUKWA.js → chunk-ZKWT6HXT.js} +1 -1
- package/dist/bundle/chunk-ZPUY3COZ.js +250 -0
- package/dist/bundle/{cli-556DERZL.js → cli-2P5FW2RL.js} +201 -98
- package/dist/bundle/command-contract-BMQT2G5X.js +45 -0
- package/dist/bundle/{command-server-entry-AYLGNZWD.js → command-server-entry-KP2UDGLA.js} +36 -34
- package/dist/bundle/{decode-QU24MWMN.js → decode-K2JZ5D6V.js} +10 -10
- package/dist/bundle/{dispatch-4KODNOXV.js → dispatch-KOQZA74A.js} +10 -10
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/drive.js +11 -11
- package/dist/bundle/{echarts-BXX4OQWC.js → echarts-URO3QGCG.js} +2 -2
- package/dist/bundle/{embed-KG27KG3D.js → embed-JLIPWTNN.js} +10 -10
- package/dist/bundle/{embedder-IPAVUQUV.js → embedder-LUTDO3HS.js} +15 -15
- package/dist/bundle/entry-AVF6LMG7.js +25 -0
- package/dist/bundle/{failure-ESL7ETL4.js → failure-GJMQLM7O.js} +4 -4
- package/dist/bundle/first-run-VYTIEUDA.js +31 -0
- package/dist/bundle/first-screen-QVZPF7KL.js +45 -0
- package/dist/bundle/google-VX7IPACN.js +46 -0
- package/dist/bundle/{google-api-VCDBSNOW.js → google-api-RFXKRLL4.js} +88 -73
- package/dist/bundle/grants-4XWJFVD6.js +133 -0
- package/dist/bundle/hast-util-from-html-X2DCPS3T.js +10531 -0
- package/dist/bundle/hast-util-to-html-VP6XLPKJ.js +998 -0
- package/dist/bundle/hast-util-to-mdast-IZ5PRX72.js +2272 -0
- package/dist/bundle/{identity-LOWMVGZY.js → identity-FXPB5EMT.js} +7 -6
- package/dist/bundle/{instructions-2VECIDXF.js → instructions-IROIUVZI.js} +1 -1
- package/dist/bundle/{login-7GBONT7V.js → login-WIY5VQU7.js} +96 -81
- package/dist/bundle/{mcp-O6ACR2DX.js → mcp-NJIOKW3E.js} +2 -2
- package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-HEZF7KJ4.js} +137 -195
- package/dist/bundle/mdast-util-gfm-AQW6R6MG.js +925 -0
- package/dist/bundle/mdast-util-to-hast-DF2QVIRV.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-XYLXB3Z3.js +18 -0
- package/dist/bundle/meeting-combined-JUNV35GM.js +28 -0
- package/dist/bundle/meeting-model-XY4UNWWK.js +29 -0
- package/dist/bundle/{meeting-semantic-G7PFOKU7.js → meeting-semantic-62QNQMOM.js} +10 -10
- package/dist/bundle/{micromark-extension-gfm-GRL24TU6.js → micromark-extension-gfm-OE2GBORZ.js} +11 -78
- package/dist/bundle/{node-MPEQSFI3.js → node-IACCI2CW.js} +2 -2
- package/dist/bundle/{node-sqlite-OLQMAYB4.js → node-sqlite-WYIRC7C7.js} +10 -10
- package/dist/bundle/notes-search-DEDUJKSN.js +70 -0
- package/dist/bundle/oauth-HXBXF4VI.js +22 -0
- package/dist/bundle/{open-OXTE672W.js → open-H32B6BCT.js} +8 -8
- package/dist/bundle/{openai-EB3TPIZY.js → openai-VHMPJJUG.js} +22 -21
- package/dist/bundle/{process-F6TKXWWA.js → process-RNHPF5OK.js} +1 -1
- package/dist/bundle/{program-4IFDZ7FM.js → program-GYMJ3DDH.js} +275 -1148
- package/dist/bundle/{prompt-F5RRHPN2.js → prompt-TOG2CRCE.js} +8 -8
- package/dist/bundle/{reasons-UORHJDHK.js → reasons-TLFQ45YX.js} +6 -5
- package/dist/bundle/{recognize-DAVNZND3.js → recognize-GYGY45EY.js} +7 -7
- package/dist/bundle/remote-6XN2QLI5.js +35 -0
- package/dist/bundle/{rerank-CND2GVLZ.js → rerank-HJO3O4TW.js} +11 -11
- package/dist/bundle/{serve-ZHSPUIGX.js → serve-XPCNLHCR.js} +19 -19
- package/dist/bundle/server-UBJZ66XE.js +97 -0
- package/dist/bundle/{server-YMAK4LHC.js → server-WPT3NC5B.js} +89 -70
- package/dist/bundle/{services-ZILSFJ6E.js → services-253KKKVU.js} +109 -89
- package/dist/bundle/{sqlite-runtime-S5VPMZQH.js → sqlite-runtime-EZASGJXW.js} +9 -9
- package/dist/bundle/{start-CR6X25RT.js → start-UHI35JFL.js} +7 -7
- package/dist/bundle/{state-YFPHVIIJ.js → state-KJTSPFGK.js} +9 -9
- package/dist/bundle/{store-UODRT6X4.js → store-62J2H2A3.js} +36 -25
- package/dist/bundle/{store-CL4ZJZRI.js → store-G5B7T7M7.js} +38 -23
- package/dist/bundle/store-maintenance-command-C6T4YLVF.js +85 -0
- package/dist/bundle/surface-3OT64BHS.js +83 -0
- package/dist/bundle/tokens-EHYO6D2X.js +133 -0
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +11 -1
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/remote.d.ts.map +1 -1
- package/dist/commands/remote.js +8 -22
- package/dist/commands/remote.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +14 -4
- package/dist/commands/sync.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/first-screen.d.ts.map +1 -1
- package/dist/first-screen.js +2 -1
- package/dist/first-screen.js.map +1 -1
- package/dist/generated/manifest.d.ts +2 -1
- package/dist/generated/manifest.d.ts.map +1 -1
- package/dist/generated/manifest.js +782 -0
- package/dist/generated/manifest.js.map +1 -1
- package/dist/generated/types.d.ts +262 -58
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/google.d.ts.map +1 -1
- package/dist/google.js +5 -5
- package/dist/google.js.map +1 -1
- package/dist/model.d.ts +5 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/dist/policy-keys.js +1 -1
- package/dist/policy-keys.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +9 -4
- package/dist/program.js.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +6 -1
- package/dist/state.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +2 -7
- package/dist/store.js.map +1 -1
- package/dist/supported.d.ts +2 -2
- package/dist/supported.d.ts.map +1 -1
- package/dist/supported.js +2 -3
- package/dist/supported.js.map +1 -1
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +5 -2
- package/dist/sync.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/scenarios/find-decision.md +1 -1
- package/skills/drive-cli/SKILL.md +4 -2
- package/dist/bundle/chunk-J5Q5FS2N.js +0 -593
- package/dist/bundle/chunk-L46C6HQ7.js +0 -729
- package/dist/bundle/chunk-UDMNY63V.js +0 -899
- package/dist/bundle/chunk-VKE77B3F.js +0 -2
- package/dist/bundle/command-contract-VRTOAV6W.js +0 -43
- package/dist/bundle/entry-MVXQETWS.js +0 -25
- package/dist/bundle/first-run-4UVLW2WR.js +0 -31
- package/dist/bundle/first-screen-JAKAIINI.js +0 -41
- package/dist/bundle/google-22NXXJX5.js +0 -45
- package/dist/bundle/grants-MQMTVCRQ.js +0 -118
- package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +0 -2103
- package/dist/bundle/meeting-combined-LVP4AZKA.js +0 -27
- package/dist/bundle/meeting-model-RAY5XDXZ.js +0 -29
- package/dist/bundle/oauth-SGH2I2BY.js +0 -22
- package/dist/bundle/remote-D5EYYIAU.js +0 -35
- package/dist/bundle/server-DUVJWP3Q.js +0 -80
- package/dist/bundle/store-maintenance-command-DY5XIBWR.js +0 -72
- package/dist/bundle/tokens-AF7QOFOF.js +0 -118
|
@@ -19,16 +19,16 @@ import {
|
|
|
19
19
|
reference,
|
|
20
20
|
string,
|
|
21
21
|
variant
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GXGSC622.js";
|
|
23
23
|
import {
|
|
24
24
|
CliError,
|
|
25
25
|
isCliError
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-OLCU7Q2B.js";
|
|
27
27
|
import {
|
|
28
28
|
__name
|
|
29
29
|
} from "./chunk-ZVVMGPBJ.js";
|
|
30
30
|
|
|
31
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
31
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/types.js
|
|
32
32
|
var QUERY_LIMITS = {
|
|
33
33
|
bytes: 8192,
|
|
34
34
|
depth: 32,
|
|
@@ -72,328 +72,7 @@ function queryError(reason, span, alternative, context = {}, details = {}) {
|
|
|
72
72
|
__name(queryError, "queryError");
|
|
73
73
|
var walkQuery = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? [node] : node.clauses.flatMap(({ node: node2 }) => walkQuery(node2)), "walkQuery");
|
|
74
74
|
|
|
75
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
76
|
-
var timezoneOf = /* @__PURE__ */ __name((given) => {
|
|
77
|
-
const zone = given ?? Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC";
|
|
78
|
-
try {
|
|
79
|
-
new Intl.DateTimeFormat("en", { timeZone: zone }).format(0);
|
|
80
|
-
} catch {
|
|
81
|
-
queryError("query.invalid-timezone", { start: 0, end: 0 }, "use an IANA timezone such as Europe/Madrid");
|
|
82
|
-
}
|
|
83
|
-
return zone;
|
|
84
|
-
}, "timezoneOf");
|
|
85
|
-
var calendar = /* @__PURE__ */ __name((value, span) => {
|
|
86
|
-
if (!/^\d{4}-\d{2}-\d{2}$/u.test(value))
|
|
87
|
-
queryError("query.invalid-date", span, "use an ISO date such as 2026-10-01");
|
|
88
|
-
const year = Number(value.slice(0, 4)), month = Number(value.slice(5, 7)), day = Number(value.slice(8, 10));
|
|
89
|
-
const date = /* @__PURE__ */ new Date(0);
|
|
90
|
-
date.setUTCFullYear(year, month - 1, day);
|
|
91
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
92
|
-
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day)
|
|
93
|
-
queryError("query.invalid-date", span);
|
|
94
|
-
return date;
|
|
95
|
-
}, "calendar");
|
|
96
|
-
var dayBoundary = /* @__PURE__ */ __name((value, zone, next, span) => {
|
|
97
|
-
const date = calendar(value, span);
|
|
98
|
-
if (next)
|
|
99
|
-
date.setUTCDate(date.getUTCDate() + 1);
|
|
100
|
-
const wanted = date.getUTCFullYear() * 1e4 + (date.getUTCMonth() + 1) * 100 + date.getUTCDate();
|
|
101
|
-
const formatter = new Intl.DateTimeFormat("en-CA", {
|
|
102
|
-
timeZone: zone,
|
|
103
|
-
year: "numeric",
|
|
104
|
-
month: "2-digit",
|
|
105
|
-
day: "2-digit",
|
|
106
|
-
era: "short"
|
|
107
|
-
});
|
|
108
|
-
const dayAt = /* @__PURE__ */ __name((time) => {
|
|
109
|
-
const parts = formatter.formatToParts(time);
|
|
110
|
-
const value2 = /* @__PURE__ */ __name((name) => Number(parts.find((p) => p.type === name)?.value), "value");
|
|
111
|
-
const year = parts.find((p) => p.type === "era")?.value === "BC" ? 1 - value2("year") : value2("year");
|
|
112
|
-
return year * 1e4 + value2("month") * 100 + value2("day");
|
|
113
|
-
}, "dayAt");
|
|
114
|
-
let lo = date.getTime() - 2 * 864e5, hi = date.getTime() + 2 * 864e5;
|
|
115
|
-
while (lo < hi) {
|
|
116
|
-
const mid = Math.floor((lo + hi) / 2);
|
|
117
|
-
if (dayAt(mid) < wanted)
|
|
118
|
-
lo = mid + 1;
|
|
119
|
-
else
|
|
120
|
-
hi = mid;
|
|
121
|
-
}
|
|
122
|
-
if (dayAt(lo) !== wanted)
|
|
123
|
-
queryError("query.invalid-date", span, "this calendar day does not exist in the selected timezone");
|
|
124
|
-
return lo;
|
|
125
|
-
}, "dayBoundary");
|
|
126
|
-
var WALL = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/u;
|
|
127
|
-
var wallTime = /* @__PURE__ */ __name((value, zone, span) => {
|
|
128
|
-
const [, year, month, day, hour, minute, second = "0", fraction = "0"] = WALL.exec(value) ?? [];
|
|
129
|
-
if (year === void 0)
|
|
130
|
-
queryError("query.invalid-date", span, "use YYYY-MM-DDTHH:mm, with optional seconds");
|
|
131
|
-
const wanted = Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second), Number(fraction.padEnd(3, "0")));
|
|
132
|
-
const check = new Date(wanted);
|
|
133
|
-
if (check.getUTCDate() !== Number(day) || check.getUTCHours() !== Number(hour) || check.getUTCMinutes() !== Number(minute) || check.getUTCSeconds() !== Number(second))
|
|
134
|
-
queryError("query.invalid-date", span);
|
|
135
|
-
const formatter = new Intl.DateTimeFormat("en-CA", {
|
|
136
|
-
timeZone: zone,
|
|
137
|
-
year: "numeric",
|
|
138
|
-
month: "2-digit",
|
|
139
|
-
day: "2-digit",
|
|
140
|
-
hour: "2-digit",
|
|
141
|
-
minute: "2-digit",
|
|
142
|
-
second: "2-digit",
|
|
143
|
-
hourCycle: "h23"
|
|
144
|
-
});
|
|
145
|
-
const shown = /* @__PURE__ */ __name((instant) => {
|
|
146
|
-
const parts = Object.fromEntries(formatter.formatToParts(instant).map((part) => [part.type, Number(part.value)]));
|
|
147
|
-
return Date.UTC(parts.year ?? 0, (parts.month ?? 1) - 1, parts.day, parts.hour, parts.minute, parts.second) + (instant % 1e3 + 1e3) % 1e3;
|
|
148
|
-
}, "shown");
|
|
149
|
-
const found = /* @__PURE__ */ new Set();
|
|
150
|
-
for (const probe of [wanted - 864e5, wanted, wanted + 864e5]) {
|
|
151
|
-
const candidate = wanted - (shown(probe) - probe);
|
|
152
|
-
if (shown(candidate) === wanted)
|
|
153
|
-
found.add(candidate);
|
|
154
|
-
}
|
|
155
|
-
if (found.size !== 1)
|
|
156
|
-
queryError("query.invalid-date", span, "this local time is skipped or repeated by daylight saving; add an offset");
|
|
157
|
-
return [...found][0];
|
|
158
|
-
}, "wallTime");
|
|
159
|
-
var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/iu;
|
|
160
|
-
var zonedMoment = /* @__PURE__ */ __name((value, zone, span, { end = false } = {}) => {
|
|
161
|
-
if (/^\d{4}-\d{2}-\d{2}$/u.test(value))
|
|
162
|
-
return dayBoundary(value, zone, end, span) - (end ? 1 : 0);
|
|
163
|
-
if (!ZONED.test(value))
|
|
164
|
-
return wallTime(value, zone, span);
|
|
165
|
-
const time = Date.parse(value);
|
|
166
|
-
if (!/^\d{4}-\d{2}-\d{2}T/u.test(value) || !Number.isFinite(time))
|
|
167
|
-
queryError("query.invalid-date", span);
|
|
168
|
-
calendar(value.slice(0, 10), span);
|
|
169
|
-
return time;
|
|
170
|
-
}, "zonedMoment");
|
|
171
|
-
var AGO = /^(\d+)(m|h|d)$/u;
|
|
172
|
-
var MOMENT = /^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/u;
|
|
173
|
-
var AGO_MS = { m: 6e4, h: 36e5, d: 864e5 };
|
|
174
|
-
var dayOf = /* @__PURE__ */ __name((word, zone, now, span) => {
|
|
175
|
-
const today = new Intl.DateTimeFormat("en-CA", {
|
|
176
|
-
timeZone: zone,
|
|
177
|
-
year: "numeric",
|
|
178
|
-
month: "2-digit",
|
|
179
|
-
day: "2-digit"
|
|
180
|
-
}).format(now);
|
|
181
|
-
if (word === "today")
|
|
182
|
-
return today;
|
|
183
|
-
const date = calendar(today, span);
|
|
184
|
-
date.setUTCDate(date.getUTCDate() - 1);
|
|
185
|
-
return date.toISOString().slice(0, 10);
|
|
186
|
-
}, "dayOf");
|
|
187
|
-
var dateEndpoint = /* @__PURE__ */ __name((value, zone, side, inclusive, span, now = Date.now()) => {
|
|
188
|
-
if (value === "*")
|
|
189
|
-
return { inclusive };
|
|
190
|
-
const word = value.toLowerCase();
|
|
191
|
-
if (word === "today" || word === "yesterday")
|
|
192
|
-
return dateEndpoint(dayOf(word, zone, now, span), zone, side, inclusive, span);
|
|
193
|
-
const [, amount, unit] = AGO.exec(word) ?? [];
|
|
194
|
-
if (amount && unit)
|
|
195
|
-
return { time: now - Number(amount) * (AGO_MS[unit] ?? 0), inclusive };
|
|
196
|
-
if (/^\d{4}-\d{2}-\d{2}$/u.test(value))
|
|
197
|
-
return {
|
|
198
|
-
time: dayBoundary(value, zone, side === "lower" ? !inclusive : inclusive, span),
|
|
199
|
-
inclusive: side === "lower"
|
|
200
|
-
};
|
|
201
|
-
const [, day, hour, minute, second = "0", offset] = MOMENT.exec(value) ?? [];
|
|
202
|
-
if (day === void 0)
|
|
203
|
-
queryError("query.invalid-date", span, "use an ISO date, a date and time such as 2026-10-01T09:00 (optional seconds and offset), today, yesterday or 30m/2h/7d ago");
|
|
204
|
-
const moment = value.replace(" ", "T");
|
|
205
|
-
if (offset === void 0)
|
|
206
|
-
return { time: wallTime(moment, zone, span), inclusive };
|
|
207
|
-
calendar(day, span);
|
|
208
|
-
const time = Date.parse(moment);
|
|
209
|
-
if (!Number.isFinite(time) || Number(hour) > 23 || Number(minute) > 59 || Number(second) > 59)
|
|
210
|
-
queryError("query.invalid-date", span);
|
|
211
|
-
return { time, inclusive };
|
|
212
|
-
}, "dateEndpoint");
|
|
213
|
-
var dateRange = /* @__PURE__ */ __name((lower, upper, lowerInclusive, upperInclusive, zone, span, now = Date.now()) => {
|
|
214
|
-
const since = lower === upper && AGO.test(lower.toLowerCase());
|
|
215
|
-
const lo = dateEndpoint(lower, zone, "lower", lowerInclusive, span, now);
|
|
216
|
-
const hi = dateEndpoint(since ? "*" : upper, zone, "upper", upperInclusive, span, now);
|
|
217
|
-
return {
|
|
218
|
-
...lo.time === void 0 ? {} : { lower: lo.time },
|
|
219
|
-
...hi.time === void 0 ? {} : { upper: hi.time },
|
|
220
|
-
lower_inclusive: lo.inclusive,
|
|
221
|
-
upper_inclusive: hi.inclusive
|
|
222
|
-
};
|
|
223
|
-
}, "dateRange");
|
|
224
|
-
|
|
225
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/evaluate.js
|
|
226
|
-
var wordsOf = /* @__PURE__ */ __name((text) => text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [], "wordsOf");
|
|
227
|
-
var pattern = /* @__PURE__ */ __name((value) => new RegExp(`^${[...value].map((char) => char === "*" ? ".*" : char === "?" ? "." : char.replace(/[.+^${}()|[\]\\]/, "\\$&")).join("")}$`, "iu"), "pattern");
|
|
228
|
-
var present = /* @__PURE__ */ __name((value) => value !== void 0 && value !== null && value !== "", "present");
|
|
229
|
-
var matchOne = /* @__PURE__ */ __name((field, node, value, options) => {
|
|
230
|
-
if (!present(value))
|
|
231
|
-
return false;
|
|
232
|
-
if (node.operator === "wildcard" && node.value === "*")
|
|
233
|
-
return true;
|
|
234
|
-
const text = String(value);
|
|
235
|
-
switch (field.type) {
|
|
236
|
-
case "txt": {
|
|
237
|
-
const words = wordsOf(text);
|
|
238
|
-
if (node.operator === "wildcard")
|
|
239
|
-
return words.some((word) => pattern(node.value).test(word));
|
|
240
|
-
const wanted = wordsOf(node.value);
|
|
241
|
-
return words.some((_, at) => wanted.every((word, offset) => words[at + offset] === word));
|
|
242
|
-
}
|
|
243
|
-
case "num": {
|
|
244
|
-
const number2 = Number(value);
|
|
245
|
-
if (node.operator !== "range")
|
|
246
|
-
return number2 === Number(node.value);
|
|
247
|
-
const { value: lower, upper = "*", lower_inclusive: lowerInclusive, upper_inclusive: upperInclusive } = node;
|
|
248
|
-
return (lower === "*" || (lowerInclusive ? number2 >= Number(lower) : number2 > Number(lower))) && (upper === "*" || (upperInclusive ? number2 <= Number(upper) : number2 < Number(upper)));
|
|
249
|
-
}
|
|
250
|
-
case "time": {
|
|
251
|
-
const time = Date.parse(text);
|
|
252
|
-
const [lower, upper, lowerInclusive, upperInclusive] = node.operator === "range" ? [node.value, node.upper ?? "*", node.lower_inclusive ?? true, node.upper_inclusive ?? true] : [node.value, node.value, true, true];
|
|
253
|
-
const range = dateRange(lower, upper, lowerInclusive, upperInclusive, options.zone ?? "UTC", node.span, options.now);
|
|
254
|
-
return (range.lower === void 0 || (range.lower_inclusive ? time >= range.lower : time > range.lower)) && (range.upper === void 0 || (range.upper_inclusive ? time <= range.upper : time < range.upper));
|
|
255
|
-
}
|
|
256
|
-
default:
|
|
257
|
-
return node.operator === "wildcard" ? pattern(node.value).test(text) : text.toLowerCase() === node.value.toLowerCase();
|
|
258
|
-
}
|
|
259
|
-
}, "matchOne");
|
|
260
|
-
var matches = /* @__PURE__ */ __name((node, item, byName, options) => {
|
|
261
|
-
if (node.kind === "boolean") {
|
|
262
|
-
const by = /* @__PURE__ */ __name((occur) => node.clauses.filter((clause) => clause.occur === occur), "by");
|
|
263
|
-
const [must, should, mustNot] = [by("must"), by("should"), by("must_not")];
|
|
264
|
-
const holds = /* @__PURE__ */ __name((clause) => matches(clause.node, item, byName, options), "holds");
|
|
265
|
-
return must.every(holds) && !mustNot.some(holds) && (should.length === 0 || must.length > 0 || should.some(holds));
|
|
266
|
-
}
|
|
267
|
-
const field = byName.get(node.field);
|
|
268
|
-
if (!field)
|
|
269
|
-
throw new Error(`evaluate: no field "${node.field}"; validate the query first`);
|
|
270
|
-
if (field.relation !== void 0) {
|
|
271
|
-
if (!options.relation)
|
|
272
|
-
throw new Error(`evaluate: "${node.field}" is a relation; pass options.relation`);
|
|
273
|
-
return options.relation(node, item);
|
|
274
|
-
}
|
|
275
|
-
const value = item[node.field];
|
|
276
|
-
return Array.isArray(value) ? value.some((one) => matchOne(field, node, one, options)) : matchOne(field, node, value, options);
|
|
277
|
-
}, "matches");
|
|
278
|
-
var evaluate = /* @__PURE__ */ __name((ast, fields, item, options = {}) => matches(ast.root, item, new Map(fields.map((field) => [field.name, field])), options), "evaluate");
|
|
279
|
-
|
|
280
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/fields.js
|
|
281
|
-
var FIELD_TYPES = ["kw", "txt", "enum", "num", "time", "bool", "ref"];
|
|
282
|
-
var OPERATORS_BY_TYPE = {
|
|
283
|
-
kw: ["term", "phrase", "wildcard"],
|
|
284
|
-
txt: ["term", "phrase", "wildcard"],
|
|
285
|
-
enum: ["term"],
|
|
286
|
-
num: ["term", "range"],
|
|
287
|
-
time: ["term", "range"],
|
|
288
|
-
bool: ["term"],
|
|
289
|
-
ref: ["term", "phrase"]
|
|
290
|
-
};
|
|
291
|
-
var QUERY_BACKENDS = ["sql", "native"];
|
|
292
|
-
var unwrap = /* @__PURE__ */ __name((schema) => schema.wrapped ? unwrap(schema.wrapped) : schema, "unwrap");
|
|
293
|
-
var REFERENCE_SOURCE = reference.pipe[1].requirement.source;
|
|
294
|
-
var typeOf = /* @__PURE__ */ __name((schema) => {
|
|
295
|
-
const plain = unwrap(schema);
|
|
296
|
-
const actions = plain.pipe ?? [];
|
|
297
|
-
switch (plain.type) {
|
|
298
|
-
case "picklist":
|
|
299
|
-
return { type: "enum", values: (plain.options ?? []).map(String) };
|
|
300
|
-
case "number":
|
|
301
|
-
return { type: "num" };
|
|
302
|
-
case "boolean":
|
|
303
|
-
return { type: "bool" };
|
|
304
|
-
case "string":
|
|
305
|
-
if (actions.some((action) => action.type === "iso_timestamp"))
|
|
306
|
-
return { type: "time" };
|
|
307
|
-
if (actions.some((action) => action.requirement instanceof RegExp && action.requirement.source === REFERENCE_SOURCE))
|
|
308
|
-
return { type: "ref" };
|
|
309
|
-
return { type: "kw" };
|
|
310
|
-
case "array":
|
|
311
|
-
return plain.item ? typeOf(plain.item) : void 0;
|
|
312
|
-
default:
|
|
313
|
-
return void 0;
|
|
314
|
-
}
|
|
315
|
-
}, "typeOf");
|
|
316
|
-
var exampleOf = /* @__PURE__ */ __name((name, type, values) => ({
|
|
317
|
-
kw: `${name}:abc`,
|
|
318
|
-
txt: `${name}:word*`,
|
|
319
|
-
enum: `${name}:${values?.[0] ?? "x"}`,
|
|
320
|
-
num: `${name}>0`,
|
|
321
|
-
time: `${name}>=7d`,
|
|
322
|
-
bool: `${name}:true`,
|
|
323
|
-
ref: `${name}:"note:42"`
|
|
324
|
-
})[type], "exampleOf");
|
|
325
|
-
var queryFieldsOf = /* @__PURE__ */ __name((schema, annotations = {}) => {
|
|
326
|
-
const entries = unwrap(schema).entries ?? {};
|
|
327
|
-
const excluded = new Set(annotations.exclude ?? []);
|
|
328
|
-
const words = new Set(annotations.text ?? []);
|
|
329
|
-
const native = new Set(annotations.native ?? []);
|
|
330
|
-
const negatable = new Set(annotations.negatable ?? []);
|
|
331
|
-
const finish = /* @__PURE__ */ __name((field) => ({
|
|
332
|
-
...field,
|
|
333
|
-
operators: OPERATORS_BY_TYPE[field.type],
|
|
334
|
-
example: annotations.examples?.[field.name] ?? field.example ?? exampleOf(field.name, field.type, field.values),
|
|
335
|
-
...native.has(field.name) ? { native: true } : {},
|
|
336
|
-
...negatable.has(field.name) ? { negatable: true } : {},
|
|
337
|
-
...annotations.validate?.[field.name] ? { validate: annotations.validate[field.name] } : {}
|
|
338
|
-
}), "finish");
|
|
339
|
-
const own = Object.entries(entries).flatMap(([name, entry]) => {
|
|
340
|
-
if (excluded.has(name))
|
|
341
|
-
return [];
|
|
342
|
-
const found = typeOf(entry);
|
|
343
|
-
if (!found)
|
|
344
|
-
return [];
|
|
345
|
-
return [finish({ name, ...found, ...words.has(name) && found.type === "kw" ? { type: "txt" } : {} })];
|
|
346
|
-
});
|
|
347
|
-
const relations = Object.entries(annotations.relations ?? {}).map(([name, relation]) => finish({ name, ...relation }));
|
|
348
|
-
const states = annotations.states ? [
|
|
349
|
-
finish({
|
|
350
|
-
name: "is",
|
|
351
|
-
type: "enum",
|
|
352
|
-
values: Object.keys(annotations.states),
|
|
353
|
-
relation: Object.entries(annotations.states).map(([state, meaning]) => `${state}: ${meaning}`).join("; ")
|
|
354
|
-
})
|
|
355
|
-
] : [];
|
|
356
|
-
return [...own, ...relations, ...states];
|
|
357
|
-
}, "queryFieldsOf");
|
|
358
|
-
|
|
359
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/help.js
|
|
360
|
-
var shownOf = /* @__PURE__ */ __name((registry) => registry.backend === "native" ? registry.fields.filter((field) => field.native) : registry.fields, "shownOf");
|
|
361
|
-
var leftOut = /* @__PURE__ */ __name((fields) => fields.filter((field) => field.negatable).map((field) => field.name), "leftOut");
|
|
362
|
-
var has = /* @__PURE__ */ __name((fields, operator) => fields.some((field) => field.operators.includes(operator)), "has");
|
|
363
|
-
var syntaxOf = /* @__PURE__ */ __name((shown, backend) => [
|
|
364
|
-
"field:value",
|
|
365
|
-
...has(shown, "phrase") ? ['"a phrase"'] : [],
|
|
366
|
-
...has(shown, "wildcard") ? ["word*"] : [],
|
|
367
|
-
...backend === "native" ? ["terms joined by AND"] : ["AND OR NOT", "( )"],
|
|
368
|
-
...has(shown, "range") ? ["[a TO b] \xB7 > >= < <="] : []
|
|
369
|
-
].join(" \xB7 "), "syntaxOf");
|
|
370
|
-
var kindOf = /* @__PURE__ */ __name((field) => field.values ? `${field.type}: ${field.values.join("|")}` : `${field.type}: ${field.operators.join(", ")}`, "kindOf");
|
|
371
|
-
var fieldsHelp = /* @__PURE__ */ __name((registry, guide) => {
|
|
372
|
-
const shown = shownOf(registry);
|
|
373
|
-
const negatable = leftOut(shown);
|
|
374
|
-
const rows = shown.map((field) => [field.name, kindOf(field), field.example]);
|
|
375
|
-
const widths = [0, 1].map((at) => Math.max(...rows.map((row) => (row[at] ?? "").length)));
|
|
376
|
-
return [
|
|
377
|
-
"Fields:",
|
|
378
|
-
...rows.map(([name = "", kind = "", example = ""]) => ` ${name.padEnd(widths[0] ?? 0)} ${kind.padEnd(widths[1] ?? 0)} ${example}`.trimEnd()),
|
|
379
|
-
...registry.defaults && registry.defaults.length > 0 ? [`Defaults: ${registry.defaults.join(" ")} \u2014 name the field to change it`] : [],
|
|
380
|
-
...negatable.length > 0 ? [`Leave out: -${negatable[0]}:value or NOT ${negatable[0]}:value, for ${negatable.join(", ")}`] : [],
|
|
381
|
-
`Syntax: ${syntaxOf(shown, registry.backend)}`,
|
|
382
|
-
...guide ? [`Guide: ${guide}`] : []
|
|
383
|
-
].join("\n");
|
|
384
|
-
}, "fieldsHelp");
|
|
385
|
-
var queryDescription = /* @__PURE__ */ __name((registry) => {
|
|
386
|
-
const shown = shownOf(registry);
|
|
387
|
-
if (shown.length === 0)
|
|
388
|
-
return "field:value terms; this list filters by none yet, so any term is refused";
|
|
389
|
-
const negatable = leftOut(shown);
|
|
390
|
-
const terms = registry.backend === "native" ? `field:value terms joined by AND that narrow the list${negatable.length > 0 ? `; -field:value or NOT field:value leaves out what matches, for ${negatable.join(", ")} only` : ""}` : `field:value terms that narrow the list (Lucene: AND OR NOT, -field:value${has(shown, "range") ? ", [a TO b], > <" : ""})`;
|
|
391
|
-
const fields = shown.map((field) => field.values ? `${field.name} (${field.values.join("|")})` : field.name);
|
|
392
|
-
const defaults = registry.defaults?.length ? `; unless named: ${registry.defaults.join(" ")}` : "";
|
|
393
|
-
return `${terms}; fields: ${fields.join(", ")}; e.g. ${shown[0]?.example ?? ""}${defaults}`;
|
|
394
|
-
}, "queryDescription");
|
|
395
|
-
|
|
396
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/parser.js
|
|
75
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/parser.js
|
|
397
76
|
var whitespace = /* @__PURE__ */ __name((c) => /[ \t\n\r\u3000]/u.test(c), "whitespace");
|
|
398
77
|
var reserved = /* @__PURE__ */ new Set([
|
|
399
78
|
"+",
|
|
@@ -623,86 +302,407 @@ var parseLucene = /* @__PURE__ */ __name((text, { defaultField = "text", proximi
|
|
|
623
302
|
return { node: node2, ...modifier ? { modifier } : {} };
|
|
624
303
|
}
|
|
625
304
|
}
|
|
626
|
-
let node;
|
|
627
|
-
if (peek().kind === "(") {
|
|
628
|
-
const start2 = take().span.start;
|
|
629
|
-
node = query(field, implicit);
|
|
630
|
-
const end = expect(")").span.end;
|
|
631
|
-
node = { ...node, span: { start: start2, end } };
|
|
632
|
-
} else if (["[", "{"].includes(peek().kind)) {
|
|
633
|
-
const opening = take();
|
|
634
|
-
const lower = take();
|
|
635
|
-
if (!["rangeValue", "quoted"].includes(lower.kind))
|
|
636
|
-
fail("query.invalid-syntax", lower.span);
|
|
637
|
-
const separator = take();
|
|
638
|
-
if (separator.raw !== "TO")
|
|
639
|
-
fail("query.invalid-syntax", separator.span);
|
|
640
|
-
const upper = take();
|
|
641
|
-
if (!["rangeValue", "quoted"].includes(upper.kind))
|
|
642
|
-
fail("query.invalid-syntax", upper.span);
|
|
643
|
-
const closing = take();
|
|
644
|
-
if (!["]", "}"].includes(closing.kind))
|
|
645
|
-
fail("query.invalid-syntax", closing.span);
|
|
646
|
-
const decode = /* @__PURE__ */ __name((t) => decodeEscapes(t.kind === "quoted" ? t.raw.slice(1, -1) : t.raw, t.span, fail), "decode");
|
|
647
|
-
node = built({
|
|
648
|
-
kind: "predicate",
|
|
649
|
-
field,
|
|
650
|
-
operator: "range",
|
|
651
|
-
value: decode(lower),
|
|
652
|
-
upper: decode(upper),
|
|
653
|
-
lower_inclusive: opening.kind === "[",
|
|
654
|
-
upper_inclusive: closing.kind === "]",
|
|
655
|
-
span: { start: start ?? opening.span.start, end: closing.span.end }
|
|
656
|
-
});
|
|
657
|
-
} else {
|
|
658
|
-
const token = take();
|
|
659
|
-
if (!["term", "number", "quoted", "regex"].includes(token.kind))
|
|
660
|
-
fail("query.invalid-syntax", token.span);
|
|
661
|
-
const raw = ["term", "number"].includes(token.kind) ? token.raw : token.raw.slice(1, -1);
|
|
662
|
-
if (field === "fn")
|
|
663
|
-
fail("query.unsupported-operator", token.span, "interval functions are not supported");
|
|
664
|
-
const wildcard = ["term", "number"].includes(token.kind) && /(?<!\\)[*?]/u.test(raw);
|
|
665
|
-
node = built({
|
|
666
|
-
kind: "predicate",
|
|
667
|
-
field,
|
|
668
|
-
operator: token.kind === "regex" ? "regex" : token.kind === "quoted" ? "phrase" : wildcard ? "wildcard" : "term",
|
|
669
|
-
value: token.kind === "regex" || wildcard ? raw : decodeEscapes(raw, token.span, fail),
|
|
670
|
-
span: { start: start ?? token.span.start, end: token.span.end },
|
|
671
|
-
...implicit ? { implicit: true } : {}
|
|
672
|
-
});
|
|
305
|
+
let node;
|
|
306
|
+
if (peek().kind === "(") {
|
|
307
|
+
const start2 = take().span.start;
|
|
308
|
+
node = query(field, implicit);
|
|
309
|
+
const end = expect(")").span.end;
|
|
310
|
+
node = { ...node, span: { start: start2, end } };
|
|
311
|
+
} else if (["[", "{"].includes(peek().kind)) {
|
|
312
|
+
const opening = take();
|
|
313
|
+
const lower = take();
|
|
314
|
+
if (!["rangeValue", "quoted"].includes(lower.kind))
|
|
315
|
+
fail("query.invalid-syntax", lower.span);
|
|
316
|
+
const separator = take();
|
|
317
|
+
if (separator.raw !== "TO")
|
|
318
|
+
fail("query.invalid-syntax", separator.span);
|
|
319
|
+
const upper = take();
|
|
320
|
+
if (!["rangeValue", "quoted"].includes(upper.kind))
|
|
321
|
+
fail("query.invalid-syntax", upper.span);
|
|
322
|
+
const closing = take();
|
|
323
|
+
if (!["]", "}"].includes(closing.kind))
|
|
324
|
+
fail("query.invalid-syntax", closing.span);
|
|
325
|
+
const decode = /* @__PURE__ */ __name((t) => decodeEscapes(t.kind === "quoted" ? t.raw.slice(1, -1) : t.raw, t.span, fail), "decode");
|
|
326
|
+
node = built({
|
|
327
|
+
kind: "predicate",
|
|
328
|
+
field,
|
|
329
|
+
operator: "range",
|
|
330
|
+
value: decode(lower),
|
|
331
|
+
upper: decode(upper),
|
|
332
|
+
lower_inclusive: opening.kind === "[",
|
|
333
|
+
upper_inclusive: closing.kind === "]",
|
|
334
|
+
span: { start: start ?? opening.span.start, end: closing.span.end }
|
|
335
|
+
});
|
|
336
|
+
} else {
|
|
337
|
+
const token = take();
|
|
338
|
+
if (!["term", "number", "quoted", "regex"].includes(token.kind))
|
|
339
|
+
fail("query.invalid-syntax", token.span);
|
|
340
|
+
const raw = ["term", "number"].includes(token.kind) ? token.raw : token.raw.slice(1, -1);
|
|
341
|
+
if (field === "fn")
|
|
342
|
+
fail("query.unsupported-operator", token.span, "interval functions are not supported");
|
|
343
|
+
const wildcard = ["term", "number"].includes(token.kind) && /(?<!\\)[*?]/u.test(raw);
|
|
344
|
+
node = built({
|
|
345
|
+
kind: "predicate",
|
|
346
|
+
field,
|
|
347
|
+
operator: token.kind === "regex" ? "regex" : token.kind === "quoted" ? "phrase" : wildcard ? "wildcard" : "term",
|
|
348
|
+
value: token.kind === "regex" || wildcard ? raw : decodeEscapes(raw, token.span, fail),
|
|
349
|
+
span: { start: start ?? token.span.start, end: token.span.end },
|
|
350
|
+
...implicit ? { implicit: true } : {}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
if (proximity && peek().kind === "~" && node.kind === "predicate" && node.operator === "phrase") {
|
|
354
|
+
take();
|
|
355
|
+
const distance = take();
|
|
356
|
+
if (distance.kind !== "number" || !/^\d+$/u.test(distance.raw))
|
|
357
|
+
fail("query.invalid-syntax", distance.span, 'write the distance as a whole number: "a b"~3');
|
|
358
|
+
node = { ...node, slop: Number(distance.raw), span: { start: node.span.start, end: distance.span.end } };
|
|
359
|
+
}
|
|
360
|
+
if (peek().kind === "~")
|
|
361
|
+
fail("query.unsupported-operator", peek().span, node.kind === "predicate" && node.operator === "phrase" ? "proximity (~) is not supported \u2014 drop the ~ for the exact phrase, or join the words with AND" : "fuzzy matching (~) is not supported \u2014 use a prefix such as word* to catch word forms");
|
|
362
|
+
if (["^", "@"].includes(peek().kind))
|
|
363
|
+
fail("query.unsupported-operator", peek().span, "boost and minimum-should-match are not supported");
|
|
364
|
+
return { node, ...modifier ? { modifier } : {} };
|
|
365
|
+
}, "clause");
|
|
366
|
+
const root = query(defaultField, true);
|
|
367
|
+
expect("EOF");
|
|
368
|
+
if (defaultField === "none") {
|
|
369
|
+
const bare = walkQuery(root).find((node) => node.implicit);
|
|
370
|
+
if (bare)
|
|
371
|
+
queryError("query.bare-word", bare.span, `"${bare.value}" has no field; write field:value`, context, {
|
|
372
|
+
word: bare.value
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return { version: 1, language: "lucene-v1", root };
|
|
376
|
+
}, "parseLucene");
|
|
377
|
+
var implicitTextTerms = /* @__PURE__ */ __name((text) => {
|
|
378
|
+
const tokens = tokensOf(text);
|
|
379
|
+
if (tokens.some(({ kind }) => ["AND", "OR", "NOT", "+", "-", "!", "(", ")"].includes(kind)))
|
|
380
|
+
return /* @__PURE__ */ new Set();
|
|
381
|
+
return new Set(tokens.flatMap((token, index) => (token.kind === "term" || token.kind === "number") && ![":", "=", "<", ">", "<=", ">="].includes(tokens[index - 1]?.kind ?? "") && ![":", "=", "<", ">", "<=", ">="].includes(tokens[index + 1]?.kind ?? "") ? [token.span.start] : []));
|
|
382
|
+
}, "implicitTextTerms");
|
|
383
|
+
|
|
384
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/dates.js
|
|
385
|
+
var timezoneOf = /* @__PURE__ */ __name((given) => {
|
|
386
|
+
const zone = given ?? Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC";
|
|
387
|
+
try {
|
|
388
|
+
new Intl.DateTimeFormat("en", { timeZone: zone }).format(0);
|
|
389
|
+
} catch {
|
|
390
|
+
queryError("query.invalid-timezone", { start: 0, end: 0 }, "use an IANA timezone such as Europe/Madrid");
|
|
391
|
+
}
|
|
392
|
+
return zone;
|
|
393
|
+
}, "timezoneOf");
|
|
394
|
+
var calendar = /* @__PURE__ */ __name((value, span) => {
|
|
395
|
+
if (!/^\d{4}-\d{2}-\d{2}$/u.test(value))
|
|
396
|
+
queryError("query.invalid-date", span, "use an ISO date such as 2026-10-01");
|
|
397
|
+
const year = Number(value.slice(0, 4)), month = Number(value.slice(5, 7)), day = Number(value.slice(8, 10));
|
|
398
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
399
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
400
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
401
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day)
|
|
402
|
+
queryError("query.invalid-date", span);
|
|
403
|
+
return date;
|
|
404
|
+
}, "calendar");
|
|
405
|
+
var dayBoundary = /* @__PURE__ */ __name((value, zone, next, span) => {
|
|
406
|
+
const date = calendar(value, span);
|
|
407
|
+
if (next)
|
|
408
|
+
date.setUTCDate(date.getUTCDate() + 1);
|
|
409
|
+
const wanted = date.getUTCFullYear() * 1e4 + (date.getUTCMonth() + 1) * 100 + date.getUTCDate();
|
|
410
|
+
const formatter = new Intl.DateTimeFormat("en-CA", {
|
|
411
|
+
timeZone: zone,
|
|
412
|
+
year: "numeric",
|
|
413
|
+
month: "2-digit",
|
|
414
|
+
day: "2-digit",
|
|
415
|
+
era: "short"
|
|
416
|
+
});
|
|
417
|
+
const dayAt = /* @__PURE__ */ __name((time) => {
|
|
418
|
+
const parts = formatter.formatToParts(time);
|
|
419
|
+
const value2 = /* @__PURE__ */ __name((name) => Number(parts.find((p) => p.type === name)?.value), "value");
|
|
420
|
+
const year = parts.find((p) => p.type === "era")?.value === "BC" ? 1 - value2("year") : value2("year");
|
|
421
|
+
return year * 1e4 + value2("month") * 100 + value2("day");
|
|
422
|
+
}, "dayAt");
|
|
423
|
+
let lo = date.getTime() - 2 * 864e5, hi = date.getTime() + 2 * 864e5;
|
|
424
|
+
while (lo < hi) {
|
|
425
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
426
|
+
if (dayAt(mid) < wanted)
|
|
427
|
+
lo = mid + 1;
|
|
428
|
+
else
|
|
429
|
+
hi = mid;
|
|
430
|
+
}
|
|
431
|
+
if (dayAt(lo) !== wanted)
|
|
432
|
+
queryError("query.invalid-date", span, "this calendar day does not exist in the selected timezone");
|
|
433
|
+
return lo;
|
|
434
|
+
}, "dayBoundary");
|
|
435
|
+
var WALL = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/u;
|
|
436
|
+
var wallTime = /* @__PURE__ */ __name((value, zone, span) => {
|
|
437
|
+
const [, year, month, day, hour, minute, second = "0", fraction = "0"] = WALL.exec(value) ?? [];
|
|
438
|
+
if (year === void 0)
|
|
439
|
+
queryError("query.invalid-date", span, "use YYYY-MM-DDTHH:mm, with optional seconds");
|
|
440
|
+
const wanted = Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second), Number(fraction.padEnd(3, "0")));
|
|
441
|
+
const check = new Date(wanted);
|
|
442
|
+
if (check.getUTCDate() !== Number(day) || check.getUTCHours() !== Number(hour) || check.getUTCMinutes() !== Number(minute) || check.getUTCSeconds() !== Number(second))
|
|
443
|
+
queryError("query.invalid-date", span);
|
|
444
|
+
const formatter = new Intl.DateTimeFormat("en-CA", {
|
|
445
|
+
timeZone: zone,
|
|
446
|
+
year: "numeric",
|
|
447
|
+
month: "2-digit",
|
|
448
|
+
day: "2-digit",
|
|
449
|
+
hour: "2-digit",
|
|
450
|
+
minute: "2-digit",
|
|
451
|
+
second: "2-digit",
|
|
452
|
+
hourCycle: "h23"
|
|
453
|
+
});
|
|
454
|
+
const shown = /* @__PURE__ */ __name((instant) => {
|
|
455
|
+
const parts = Object.fromEntries(formatter.formatToParts(instant).map((part) => [part.type, Number(part.value)]));
|
|
456
|
+
return Date.UTC(parts.year ?? 0, (parts.month ?? 1) - 1, parts.day, parts.hour, parts.minute, parts.second) + (instant % 1e3 + 1e3) % 1e3;
|
|
457
|
+
}, "shown");
|
|
458
|
+
const found = /* @__PURE__ */ new Set();
|
|
459
|
+
for (const probe of [wanted - 864e5, wanted, wanted + 864e5]) {
|
|
460
|
+
const candidate = wanted - (shown(probe) - probe);
|
|
461
|
+
if (shown(candidate) === wanted)
|
|
462
|
+
found.add(candidate);
|
|
463
|
+
}
|
|
464
|
+
if (found.size !== 1)
|
|
465
|
+
queryError("query.invalid-date", span, "this local time is skipped or repeated by daylight saving; add an offset");
|
|
466
|
+
return [...found][0];
|
|
467
|
+
}, "wallTime");
|
|
468
|
+
var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/iu;
|
|
469
|
+
var zonedMoment = /* @__PURE__ */ __name((value, zone, span, { end = false } = {}) => {
|
|
470
|
+
if (/^\d{4}-\d{2}-\d{2}$/u.test(value))
|
|
471
|
+
return dayBoundary(value, zone, end, span) - (end ? 1 : 0);
|
|
472
|
+
if (!ZONED.test(value))
|
|
473
|
+
return wallTime(value, zone, span);
|
|
474
|
+
const time = Date.parse(value);
|
|
475
|
+
if (!/^\d{4}-\d{2}-\d{2}T/u.test(value) || !Number.isFinite(time))
|
|
476
|
+
queryError("query.invalid-date", span);
|
|
477
|
+
calendar(value.slice(0, 10), span);
|
|
478
|
+
return time;
|
|
479
|
+
}, "zonedMoment");
|
|
480
|
+
var AGO = /^(\d+)(m|h|d)$/u;
|
|
481
|
+
var MOMENT = /^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/u;
|
|
482
|
+
var AGO_MS = { m: 6e4, h: 36e5, d: 864e5 };
|
|
483
|
+
var dayOf = /* @__PURE__ */ __name((word, zone, now, span) => {
|
|
484
|
+
const today = new Intl.DateTimeFormat("en-CA", {
|
|
485
|
+
timeZone: zone,
|
|
486
|
+
year: "numeric",
|
|
487
|
+
month: "2-digit",
|
|
488
|
+
day: "2-digit"
|
|
489
|
+
}).format(now);
|
|
490
|
+
if (word === "today")
|
|
491
|
+
return today;
|
|
492
|
+
const date = calendar(today, span);
|
|
493
|
+
date.setUTCDate(date.getUTCDate() - 1);
|
|
494
|
+
return date.toISOString().slice(0, 10);
|
|
495
|
+
}, "dayOf");
|
|
496
|
+
var dateEndpoint = /* @__PURE__ */ __name((value, zone, side, inclusive, span, now = Date.now()) => {
|
|
497
|
+
if (value === "*")
|
|
498
|
+
return { inclusive };
|
|
499
|
+
const word = value.toLowerCase();
|
|
500
|
+
if (word === "today" || word === "yesterday")
|
|
501
|
+
return dateEndpoint(dayOf(word, zone, now, span), zone, side, inclusive, span);
|
|
502
|
+
const [, amount, unit] = AGO.exec(word) ?? [];
|
|
503
|
+
if (amount && unit)
|
|
504
|
+
return { time: now - Number(amount) * (AGO_MS[unit] ?? 0), inclusive };
|
|
505
|
+
if (/^\d{4}-\d{2}-\d{2}$/u.test(value))
|
|
506
|
+
return {
|
|
507
|
+
time: dayBoundary(value, zone, side === "lower" ? !inclusive : inclusive, span),
|
|
508
|
+
inclusive: side === "lower"
|
|
509
|
+
};
|
|
510
|
+
const [, day, hour, minute, second = "0", offset] = MOMENT.exec(value) ?? [];
|
|
511
|
+
if (day === void 0)
|
|
512
|
+
queryError("query.invalid-date", span, "use an ISO date, a date and time such as 2026-10-01T09:00 (optional seconds and offset), today, yesterday or 30m/2h/7d ago");
|
|
513
|
+
const moment = value.replace(" ", "T");
|
|
514
|
+
if (offset === void 0)
|
|
515
|
+
return { time: wallTime(moment, zone, span), inclusive };
|
|
516
|
+
calendar(day, span);
|
|
517
|
+
const time = Date.parse(moment);
|
|
518
|
+
if (!Number.isFinite(time) || Number(hour) > 23 || Number(minute) > 59 || Number(second) > 59)
|
|
519
|
+
queryError("query.invalid-date", span);
|
|
520
|
+
return { time, inclusive };
|
|
521
|
+
}, "dateEndpoint");
|
|
522
|
+
var dateRange = /* @__PURE__ */ __name((lower, upper, lowerInclusive, upperInclusive, zone, span, now = Date.now()) => {
|
|
523
|
+
const since = lower === upper && AGO.test(lower.toLowerCase());
|
|
524
|
+
const lo = dateEndpoint(lower, zone, "lower", lowerInclusive, span, now);
|
|
525
|
+
const hi = dateEndpoint(since ? "*" : upper, zone, "upper", upperInclusive, span, now);
|
|
526
|
+
return {
|
|
527
|
+
...lo.time === void 0 ? {} : { lower: lo.time },
|
|
528
|
+
...hi.time === void 0 ? {} : { upper: hi.time },
|
|
529
|
+
lower_inclusive: lo.inclusive,
|
|
530
|
+
upper_inclusive: hi.inclusive
|
|
531
|
+
};
|
|
532
|
+
}, "dateRange");
|
|
533
|
+
|
|
534
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/help.js
|
|
535
|
+
var shownOf = /* @__PURE__ */ __name((registry) => registry.backend === "native" ? registry.fields.filter((field) => field.native) : registry.fields, "shownOf");
|
|
536
|
+
var leftOut = /* @__PURE__ */ __name((fields) => fields.filter((field) => field.negatable).map((field) => field.name), "leftOut");
|
|
537
|
+
var has = /* @__PURE__ */ __name((fields, operator) => fields.some((field) => field.operators.includes(operator)), "has");
|
|
538
|
+
var syntaxOf = /* @__PURE__ */ __name((shown, backend) => [
|
|
539
|
+
"field:value",
|
|
540
|
+
...has(shown, "phrase") ? ['"a phrase"'] : [],
|
|
541
|
+
...has(shown, "wildcard") ? ["word*"] : [],
|
|
542
|
+
...backend === "native" ? ["terms joined by AND"] : ["AND OR NOT", "( )"],
|
|
543
|
+
...has(shown, "range") ? ["[a TO b] \xB7 > >= < <="] : []
|
|
544
|
+
].join(" \xB7 "), "syntaxOf");
|
|
545
|
+
var kindOf = /* @__PURE__ */ __name((field) => field.values ? `${field.type}: ${field.values.join("|")}` : `${field.type}: ${field.operators.join(", ")}`, "kindOf");
|
|
546
|
+
var fieldsHelp = /* @__PURE__ */ __name((registry, guide) => {
|
|
547
|
+
const shown = shownOf(registry);
|
|
548
|
+
const negatable = leftOut(shown);
|
|
549
|
+
const rows = shown.map((field) => [field.name, kindOf(field), field.example]);
|
|
550
|
+
const widths = [0, 1].map((at) => Math.max(...rows.map((row) => (row[at] ?? "").length)));
|
|
551
|
+
return [
|
|
552
|
+
"Fields:",
|
|
553
|
+
...rows.map(([name = "", kind = "", example = ""]) => ` ${name.padEnd(widths[0] ?? 0)} ${kind.padEnd(widths[1] ?? 0)} ${example}`.trimEnd()),
|
|
554
|
+
...registry.defaults && registry.defaults.length > 0 ? [`Defaults: ${registry.defaults.join(" ")} \u2014 name the field to change it`] : [],
|
|
555
|
+
...negatable.length > 0 ? [`Leave out: -${negatable[0]}:value or NOT ${negatable[0]}:value, for ${negatable.join(", ")}`] : [],
|
|
556
|
+
`Syntax: ${syntaxOf(shown, registry.backend)}`,
|
|
557
|
+
...guide ? [`Guide: ${guide}`] : []
|
|
558
|
+
].join("\n");
|
|
559
|
+
}, "fieldsHelp");
|
|
560
|
+
var queryDescription = /* @__PURE__ */ __name((registry) => {
|
|
561
|
+
const shown = shownOf(registry);
|
|
562
|
+
if (shown.length === 0)
|
|
563
|
+
return "field:value terms; this list filters by none yet, so any term is refused";
|
|
564
|
+
const negatable = leftOut(shown);
|
|
565
|
+
const terms = registry.backend === "native" ? `field:value terms joined by AND that narrow the list${negatable.length > 0 ? `; -field:value or NOT field:value leaves out what matches, for ${negatable.join(", ")} only` : ""}` : `field:value terms that narrow the list (Lucene: AND OR NOT, -field:value${has(shown, "range") ? ", [a TO b], > <" : ""})`;
|
|
566
|
+
const fields = shown.map((field) => field.values ? `${field.name} (${field.values.join("|")})` : field.name);
|
|
567
|
+
const defaults = registry.defaults?.length ? `; unless named: ${registry.defaults.join(" ")}` : "";
|
|
568
|
+
return `${terms}; fields: ${fields.join(", ")}; e.g. ${shown[0]?.example ?? ""}${defaults}`;
|
|
569
|
+
}, "queryDescription");
|
|
570
|
+
|
|
571
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/evaluate.js
|
|
572
|
+
var wordsOf = /* @__PURE__ */ __name((text) => text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [], "wordsOf");
|
|
573
|
+
var pattern = /* @__PURE__ */ __name((value) => new RegExp(`^${[...value].map((char) => char === "*" ? ".*" : char === "?" ? "." : char.replace(/[.+^${}()|[\]\\]/, "\\$&")).join("")}$`, "iu"), "pattern");
|
|
574
|
+
var present = /* @__PURE__ */ __name((value) => value !== void 0 && value !== null && value !== "", "present");
|
|
575
|
+
var matchOne = /* @__PURE__ */ __name((field, node, value, options) => {
|
|
576
|
+
if (!present(value))
|
|
577
|
+
return false;
|
|
578
|
+
if (node.operator === "wildcard" && node.value === "*")
|
|
579
|
+
return true;
|
|
580
|
+
const text = String(value);
|
|
581
|
+
switch (field.type) {
|
|
582
|
+
case "txt": {
|
|
583
|
+
const words = wordsOf(text);
|
|
584
|
+
if (node.operator === "wildcard")
|
|
585
|
+
return words.some((word) => pattern(node.value).test(word));
|
|
586
|
+
const wanted = wordsOf(node.value);
|
|
587
|
+
return words.some((_, at) => wanted.every((word, offset) => words[at + offset] === word));
|
|
588
|
+
}
|
|
589
|
+
case "num": {
|
|
590
|
+
const number2 = Number(value);
|
|
591
|
+
if (node.operator !== "range")
|
|
592
|
+
return number2 === Number(node.value);
|
|
593
|
+
const { value: lower, upper = "*", lower_inclusive: lowerInclusive, upper_inclusive: upperInclusive } = node;
|
|
594
|
+
return (lower === "*" || (lowerInclusive ? number2 >= Number(lower) : number2 > Number(lower))) && (upper === "*" || (upperInclusive ? number2 <= Number(upper) : number2 < Number(upper)));
|
|
673
595
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
node = { ...node, slop: Number(distance.raw), span: { start: node.span.start, end: distance.span.end } };
|
|
596
|
+
case "time": {
|
|
597
|
+
const time = Date.parse(text);
|
|
598
|
+
const [lower, upper, lowerInclusive, upperInclusive] = node.operator === "range" ? [node.value, node.upper ?? "*", node.lower_inclusive ?? true, node.upper_inclusive ?? true] : [node.value, node.value, true, true];
|
|
599
|
+
const range = dateRange(lower, upper, lowerInclusive, upperInclusive, options.zone ?? "UTC", node.span, options.now);
|
|
600
|
+
return (range.lower === void 0 || (range.lower_inclusive ? time >= range.lower : time > range.lower)) && (range.upper === void 0 || (range.upper_inclusive ? time <= range.upper : time < range.upper));
|
|
680
601
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if (["^", "@"].includes(peek().kind))
|
|
684
|
-
fail("query.unsupported-operator", peek().span, "boost and minimum-should-match are not supported");
|
|
685
|
-
return { node, ...modifier ? { modifier } : {} };
|
|
686
|
-
}, "clause");
|
|
687
|
-
const root = query(defaultField, true);
|
|
688
|
-
expect("EOF");
|
|
689
|
-
if (defaultField === "none") {
|
|
690
|
-
const bare = walkQuery(root).find((node) => node.implicit);
|
|
691
|
-
if (bare)
|
|
692
|
-
queryError("query.bare-word", bare.span, `"${bare.value}" has no field; write field:value`, context, {
|
|
693
|
-
word: bare.value
|
|
694
|
-
});
|
|
602
|
+
default:
|
|
603
|
+
return node.operator === "wildcard" ? pattern(node.value).test(text) : text.toLowerCase() === node.value.toLowerCase();
|
|
695
604
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
605
|
+
}, "matchOne");
|
|
606
|
+
var matches = /* @__PURE__ */ __name((node, item, byName, options) => {
|
|
607
|
+
if (node.kind === "boolean") {
|
|
608
|
+
const by = /* @__PURE__ */ __name((occur) => node.clauses.filter((clause) => clause.occur === occur), "by");
|
|
609
|
+
const [must, should, mustNot] = [by("must"), by("should"), by("must_not")];
|
|
610
|
+
const holds = /* @__PURE__ */ __name((clause) => matches(clause.node, item, byName, options), "holds");
|
|
611
|
+
return must.every(holds) && !mustNot.some(holds) && (should.length === 0 || must.length > 0 || should.some(holds));
|
|
612
|
+
}
|
|
613
|
+
const field = byName.get(node.field);
|
|
614
|
+
if (!field)
|
|
615
|
+
throw new Error(`evaluate: no field "${node.field}"; validate the query first`);
|
|
616
|
+
if (field.relation !== void 0) {
|
|
617
|
+
if (!options.relation)
|
|
618
|
+
throw new Error(`evaluate: "${node.field}" is a relation; pass options.relation`);
|
|
619
|
+
return options.relation(node, item);
|
|
620
|
+
}
|
|
621
|
+
const value = item[node.field];
|
|
622
|
+
return Array.isArray(value) ? value.some((one) => matchOne(field, node, one, options)) : matchOne(field, node, value, options);
|
|
623
|
+
}, "matches");
|
|
624
|
+
var evaluate = /* @__PURE__ */ __name((ast, fields, item, options = {}) => matches(ast.root, item, new Map(fields.map((field) => [field.name, field])), options), "evaluate");
|
|
625
|
+
|
|
626
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/fields.js
|
|
627
|
+
var FIELD_TYPES = ["kw", "txt", "enum", "num", "time", "bool", "ref"];
|
|
628
|
+
var OPERATORS_BY_TYPE = {
|
|
629
|
+
kw: ["term", "phrase", "wildcard"],
|
|
630
|
+
txt: ["term", "phrase", "wildcard"],
|
|
631
|
+
enum: ["term"],
|
|
632
|
+
num: ["term", "range"],
|
|
633
|
+
time: ["term", "range"],
|
|
634
|
+
bool: ["term"],
|
|
635
|
+
ref: ["term", "phrase"]
|
|
636
|
+
};
|
|
637
|
+
var QUERY_BACKENDS = ["sql", "native"];
|
|
638
|
+
var unwrap = /* @__PURE__ */ __name((schema) => schema.wrapped ? unwrap(schema.wrapped) : schema, "unwrap");
|
|
639
|
+
var REFERENCE_SOURCE = reference.pipe[1].requirement.source;
|
|
640
|
+
var typeOf = /* @__PURE__ */ __name((schema) => {
|
|
641
|
+
const plain = unwrap(schema);
|
|
642
|
+
const actions = plain.pipe ?? [];
|
|
643
|
+
switch (plain.type) {
|
|
644
|
+
case "picklist":
|
|
645
|
+
return { type: "enum", values: (plain.options ?? []).map(String) };
|
|
646
|
+
case "number":
|
|
647
|
+
return { type: "num" };
|
|
648
|
+
case "boolean":
|
|
649
|
+
return { type: "bool" };
|
|
650
|
+
case "string":
|
|
651
|
+
if (actions.some((action) => action.type === "iso_timestamp"))
|
|
652
|
+
return { type: "time" };
|
|
653
|
+
if (actions.some((action) => action.requirement instanceof RegExp && action.requirement.source === REFERENCE_SOURCE))
|
|
654
|
+
return { type: "ref" };
|
|
655
|
+
return { type: "kw" };
|
|
656
|
+
case "array":
|
|
657
|
+
return plain.item ? typeOf(plain.item) : void 0;
|
|
658
|
+
default:
|
|
659
|
+
return void 0;
|
|
660
|
+
}
|
|
661
|
+
}, "typeOf");
|
|
662
|
+
var exampleOf = /* @__PURE__ */ __name((name, type, values) => ({
|
|
663
|
+
kw: `${name}:abc`,
|
|
664
|
+
txt: `${name}:word*`,
|
|
665
|
+
enum: `${name}:${values?.[0] ?? "x"}`,
|
|
666
|
+
num: `${name}>0`,
|
|
667
|
+
time: `${name}>=7d`,
|
|
668
|
+
bool: `${name}:true`,
|
|
669
|
+
ref: `${name}:"note:42"`
|
|
670
|
+
})[type], "exampleOf");
|
|
671
|
+
var queryFieldsOf = /* @__PURE__ */ __name((schema, annotations = {}) => {
|
|
672
|
+
const entries = unwrap(schema).entries ?? {};
|
|
673
|
+
const excluded = new Set(annotations.exclude ?? []);
|
|
674
|
+
const words = new Set(annotations.text ?? []);
|
|
675
|
+
const native = new Set(annotations.native ?? []);
|
|
676
|
+
const negatable = new Set(annotations.negatable ?? []);
|
|
677
|
+
const finish = /* @__PURE__ */ __name((field) => ({
|
|
678
|
+
...field,
|
|
679
|
+
operators: OPERATORS_BY_TYPE[field.type],
|
|
680
|
+
example: annotations.examples?.[field.name] ?? field.example ?? exampleOf(field.name, field.type, field.values),
|
|
681
|
+
...native.has(field.name) ? { native: true } : {},
|
|
682
|
+
...negatable.has(field.name) ? { negatable: true } : {},
|
|
683
|
+
...annotations.validate?.[field.name] ? { validate: annotations.validate[field.name] } : {}
|
|
684
|
+
}), "finish");
|
|
685
|
+
const own = Object.entries(entries).flatMap(([name, entry]) => {
|
|
686
|
+
if (excluded.has(name))
|
|
687
|
+
return [];
|
|
688
|
+
const found = typeOf(entry);
|
|
689
|
+
if (!found)
|
|
690
|
+
return [];
|
|
691
|
+
return [finish({ name, ...found, ...words.has(name) && found.type === "kw" ? { type: "txt" } : {} })];
|
|
692
|
+
});
|
|
693
|
+
const relations = Object.entries(annotations.relations ?? {}).map(([name, relation]) => finish({ name, ...relation }));
|
|
694
|
+
const states = annotations.states ? [
|
|
695
|
+
finish({
|
|
696
|
+
name: "is",
|
|
697
|
+
type: "enum",
|
|
698
|
+
values: Object.keys(annotations.states),
|
|
699
|
+
relation: Object.entries(annotations.states).map(([state, meaning]) => `${state}: ${meaning}`).join("; ")
|
|
700
|
+
})
|
|
701
|
+
] : [];
|
|
702
|
+
return [...own, ...relations, ...states];
|
|
703
|
+
}, "queryFieldsOf");
|
|
704
704
|
|
|
705
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
705
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/validate.js
|
|
706
706
|
var inContext = /* @__PURE__ */ __name((context, run) => {
|
|
707
707
|
try {
|
|
708
708
|
run();
|
|
@@ -777,7 +777,7 @@ var validateQuery = /* @__PURE__ */ __name((ast, registry, options = {}) => {
|
|
|
777
777
|
}, "validateQuery");
|
|
778
778
|
var fieldsNamed = /* @__PURE__ */ __name((ast) => new Set(walkQuery(ast.root).map((node) => node.field)), "fieldsNamed");
|
|
779
779
|
|
|
780
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
780
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/query/registry.js
|
|
781
781
|
var describeQuery = /* @__PURE__ */ __name((registry) => ({
|
|
782
782
|
entity: registry.entity,
|
|
783
783
|
backend: registry.backend,
|