@wirecat/zoom-cli 0.70.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.
Files changed (180) hide show
  1. package/dist/answer-entities.d.ts +2 -0
  2. package/dist/answer-entities.d.ts.map +1 -1
  3. package/dist/answers.d.ts +56 -0
  4. package/dist/answers.d.ts.map +1 -1
  5. package/dist/bin/zm.js +2 -2
  6. package/dist/bundle/{all-profiles-GE2TFJJP.js → all-profiles-XFIPF4GF.js} +12 -12
  7. package/dist/bundle/answer-policy-AT6CDEE5.js +110 -0
  8. package/dist/bundle/{anthropic-FA6NHENI.js → anthropic-SSUBR3BC.js} +29 -13
  9. package/dist/bundle/{app-server-IRADMSNX.js → app-server-7DJHHF2F.js} +68 -56
  10. package/dist/bundle/{bun-ZYZGGCX5.js → bun-6HBYWQIX.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-Y24TUIGS.js → bun-sqlite-4L3Q55NB.js} +10 -6
  12. package/dist/bundle/{chunk-JULBAECW.js → chunk-23J2ANZ7.js} +16 -6
  13. package/dist/bundle/{chunk-4DSIWYGO.js → chunk-24OFZNRC.js} +39296 -24139
  14. package/dist/bundle/{chunk-LXXCLQCW.js → chunk-2MIBRVSV.js} +2 -2
  15. package/dist/bundle/{chunk-CHGUNZ3L.js → chunk-37NF5CBJ.js} +4 -4
  16. package/dist/bundle/chunk-3KRTEX5M.js +53 -0
  17. package/dist/bundle/{chunk-VNU5L37V.js → chunk-4SY67IUA.js} +34 -42
  18. package/dist/bundle/{chunk-XWQNJKTP.js → chunk-4XQWF3U2.js} +6 -6
  19. package/dist/bundle/{chunk-OAQLVV6W.js → chunk-4YIGXTBP.js} +3 -3
  20. package/dist/bundle/{chunk-RB33VTUW.js → chunk-5AELTC52.js} +810 -210
  21. package/dist/bundle/chunk-5MGICK47.js +1243 -0
  22. package/dist/bundle/{chunk-RRRJCHUC.js → chunk-5X4IY5JH.js} +4504 -1622
  23. package/dist/bundle/{chunk-EOSVN2ER.js → chunk-63QXCE5Z.js} +242 -242
  24. package/dist/bundle/{chunk-OE7EIP5L.js → chunk-6DCLZLGX.js} +1 -1
  25. package/dist/bundle/chunk-7GLJSJ7M.js +16 -0
  26. package/dist/bundle/{chunk-KM736RMJ.js → chunk-7IFO43Q5.js} +2 -2
  27. package/dist/bundle/{chunk-IWPXWGF7.js → chunk-7JYMGXLI.js} +44 -42
  28. package/dist/bundle/{chunk-LAG5O2FV.js → chunk-7OD3522V.js} +4162 -3769
  29. package/dist/bundle/{chunk-DCUWJITQ.js → chunk-7S4D5SM2.js} +60 -608
  30. package/dist/bundle/{chunk-3KC7C465.js → chunk-7SUWPMZG.js} +10 -15
  31. package/dist/bundle/{chunk-6IF5ZHDS.js → chunk-ADKMBXY4.js} +1 -1
  32. package/dist/bundle/{chunk-56OV5ASY.js → chunk-B3SILJBU.js} +18 -18
  33. package/dist/bundle/{chunk-CIZ25UPK.js → chunk-CANRIRNZ.js} +8241 -5553
  34. package/dist/bundle/{chunk-YUHM2OJM.js → chunk-CW46FWKW.js} +38 -123
  35. package/dist/bundle/{chunk-VSLDWT4E.js → chunk-D24OQAHM.js} +4 -4
  36. package/dist/bundle/{chunk-ZBKWRYRS.js → chunk-D5EUMWD5.js} +3 -3
  37. package/dist/bundle/{chunk-CSEBB4OP.js → chunk-DEPXZJ2V.js} +21 -150
  38. package/dist/bundle/{chunk-YJSPBUGB.js → chunk-DOCVEKP2.js} +51 -67
  39. package/dist/bundle/{chunk-V2E7QFZ3.js → chunk-EFF2XBHP.js} +2 -2
  40. package/dist/bundle/{chunk-XRFHQGOD.js → chunk-EG25AY4L.js} +1 -1
  41. package/dist/bundle/{chunk-FEM2JQN2.js → chunk-ELJUBPY4.js} +1 -1
  42. package/dist/bundle/{chunk-2U6SER67.js → chunk-ERJYJ36F.js} +2 -2
  43. package/dist/bundle/chunk-FSCPQQS5.js +244 -0
  44. package/dist/bundle/{chunk-BVWF4B33.js → chunk-H53WFZBN.js} +16 -139
  45. package/dist/bundle/{chunk-VJ5ZU4UF.js → chunk-I7CUMZD6.js} +3 -3
  46. package/dist/bundle/{chunk-OA37BWE5.js → chunk-IACWKZWS.js} +1 -1
  47. package/dist/bundle/{chunk-BSS6HX4O.js → chunk-IFBIXU6C.js} +2 -2
  48. package/dist/bundle/{chunk-UVPL7YAY.js → chunk-IU4DUUB3.js} +7 -7
  49. package/dist/bundle/{chunk-W7ZEEC4K.js → chunk-IXO4SCKE.js} +1 -1
  50. package/dist/bundle/{chunk-J3SKXICS.js → chunk-JAEPK457.js} +359 -765
  51. package/dist/bundle/{chunk-ZV3INEKM.js → chunk-JFPUYQSP.js} +5 -5
  52. package/dist/bundle/{chunk-ZS55EERO.js → chunk-JG4MNYG2.js} +1 -1
  53. package/dist/bundle/{chunk-IINZIP73.js → chunk-JRCH4YZP.js} +17 -10
  54. package/dist/bundle/{chunk-2JEM2YNV.js → chunk-JZ4XNNL7.js} +1 -1
  55. package/dist/bundle/chunk-K6HR6HCO.js +32 -0
  56. package/dist/bundle/{chunk-SNIY3JDN.js → chunk-KFZL67JP.js} +328 -60
  57. package/dist/bundle/{chunk-CEJJBZAE.js → chunk-KPIQXFNB.js} +375 -10
  58. package/dist/bundle/{chunk-M7VUXXGS.js → chunk-KWURWGGB.js} +137 -7
  59. package/dist/bundle/{chunk-M6JIXMQZ.js → chunk-LA6QUVGQ.js} +3 -2
  60. package/dist/bundle/{chunk-AISJCF7A.js → chunk-LLUNHAZ7.js} +4 -4
  61. package/dist/bundle/{chunk-KWRCP55G.js → chunk-LTWJM3ED.js} +17 -17
  62. package/dist/bundle/{chunk-IS3ZTT2Z.js → chunk-M3DMXDX6.js} +6 -6
  63. package/dist/bundle/{chunk-VW6BF6M7.js → chunk-MCPOZNWG.js} +1 -1
  64. package/dist/bundle/{chunk-L24UOUWG.js → chunk-MSQHSW4C.js} +2 -2
  65. package/dist/bundle/chunk-N4QNYWWG.js +71 -0
  66. package/dist/bundle/chunk-NMZQTYKJ.js +18 -0
  67. package/dist/bundle/{chunk-DNR4B5YV.js → chunk-OHCLQJOV.js} +3 -3
  68. package/dist/bundle/{chunk-MVOMLJYQ.js → chunk-OP5PGE2N.js} +4 -4
  69. package/dist/bundle/{chunk-QL7EMFIC.js → chunk-OY6N2ABP.js} +29 -23
  70. package/dist/bundle/chunk-PJWSGXOB.js +185 -0
  71. package/dist/bundle/{chunk-YTN2JN6N.js → chunk-QA6KIL7Q.js} +12 -8
  72. package/dist/bundle/{chunk-6HJFIMT7.js → chunk-QQUY4MZY.js} +1 -1
  73. package/dist/bundle/{chunk-ZSKE7N2U.js → chunk-QW7YTRV2.js} +3 -3
  74. package/dist/bundle/chunk-RJTGENHZ.js +109 -0
  75. package/dist/bundle/{chunk-RIPAUCKJ.js → chunk-RLCVPECY.js} +74 -67
  76. package/dist/bundle/{chunk-M7E44TMT.js → chunk-RN5SU2RN.js} +6 -6
  77. package/dist/bundle/{chunk-P3ASN72F.js → chunk-RX5CJ55S.js} +1 -1
  78. package/dist/bundle/{chunk-7QC4M4HS.js → chunk-RZUJMAMK.js} +4 -4
  79. package/dist/bundle/{chunk-OORMSM6O.js → chunk-S7SXSHRC.js} +21 -21
  80. package/dist/bundle/{chunk-SVF3NDAO.js → chunk-SXZGCD6E.js} +3 -3
  81. package/dist/bundle/{chunk-DXCTW3MV.js → chunk-T27IMG6X.js} +3 -1
  82. package/dist/bundle/{chunk-PV6OHXHN.js → chunk-TF2WKPNW.js} +18 -18
  83. package/dist/bundle/{chunk-X4ZF4XXI.js → chunk-U32VL3MA.js} +1 -1
  84. package/dist/bundle/{chunk-RQG5VOGH.js → chunk-U3NJBGLA.js} +3 -3
  85. package/dist/bundle/{chunk-WOIHSQAL.js → chunk-UVZLK3M4.js} +33 -9
  86. package/dist/bundle/chunk-VIV64MQM.js +779 -0
  87. package/dist/bundle/{chunk-2QFPVUM3.js → chunk-W3YTVEWV.js} +69 -6
  88. package/dist/bundle/{chunk-AUNW7N4I.js → chunk-WLVG4RBZ.js} +1 -1
  89. package/dist/bundle/{chunk-JRO2FWO2.js → chunk-WOAYHCM2.js} +1 -1
  90. package/dist/bundle/{chunk-RO3ZR4VP.js → chunk-WXTYYWZI.js} +13 -13
  91. package/dist/bundle/{chunk-RWIILYKW.js → chunk-WZGKHTA4.js} +2 -2
  92. package/dist/bundle/{chunk-GB5X3GBE.js → chunk-X2MP634F.js} +14 -5
  93. package/dist/bundle/{chunk-RGJ7OWHU.js → chunk-XPWZSW6Y.js} +61 -21
  94. package/dist/bundle/{chunk-D3PNCJD5.js → chunk-YVVJ6Y5C.js} +7 -7
  95. package/dist/bundle/chunk-ZHA56THL.js +2355 -0
  96. package/dist/bundle/{chunk-QO2KPU26.js → chunk-ZVFYGTGJ.js} +101 -44
  97. package/dist/bundle/{chunk-V5GRSOCZ.js → chunk-ZW5KHKMA.js} +5 -5
  98. package/dist/bundle/{cli-VRSQ7HAE.js → cli-IYYI7GAM.js} +215 -100
  99. package/dist/bundle/command-contract-TX7NSUBM.js +42 -0
  100. package/dist/bundle/command-server-entry-FXX4LJWF.js +171 -0
  101. package/dist/bundle/config-YKNM33J7.js +96 -0
  102. package/dist/bundle/{decode-523PUQMR.js → decode-SRGOOGBW.js} +6 -6
  103. package/dist/bundle/{dispatch-IZCAK47P.js → dispatch-OUHRPFUL.js} +11 -11
  104. package/dist/bundle/{dist-6WWKPEVW.js → dist-UZLNLAIO.js} +97 -56
  105. package/dist/bundle/{echarts-S5UMX2D3.js → echarts-7CM2MCMW.js} +2 -2
  106. package/dist/bundle/{embed-ODPDVHUK.js → embed-VEE56BOB.js} +7 -7
  107. package/dist/bundle/{embedder-PAXRBSZE.js → embedder-SZFYR543.js} +10 -10
  108. package/dist/bundle/{failure-R2OIHCE5.js → failure-MZBNM7M5.js} +3 -3
  109. package/dist/bundle/first-run-KWC7RKF2.js +29 -0
  110. package/dist/bundle/first-screen-DWKMNSEI.js +40 -0
  111. package/dist/bundle/{folders-ZXTOFY4T.js → folders-UQXRSDJJ.js} +5 -5
  112. package/dist/bundle/{instructions-DUB7E6C5.js → instructions-R7OHVAWH.js} +1 -1
  113. package/dist/bundle/{main-A7JSYQI6.js → main-EFUN2O3K.js} +21 -20
  114. package/dist/bundle/{mcp-M4QN2E7R.js → mcp-7KQUJNFN.js} +2 -2
  115. package/dist/bundle/{meetings-BDZQV3HR.js → meetings-5I2BDNTA.js} +9 -7
  116. package/dist/bundle/{node-E25KP53H.js → node-3N2JGZ7V.js} +2 -2
  117. package/dist/bundle/{node-sqlite-PHWDFZCP.js → node-sqlite-2UVEE2WM.js} +11 -7
  118. package/dist/bundle/{oauth-G2K46IYP.js → oauth-AYGD7UU3.js} +8 -8
  119. package/dist/bundle/{open-INWS5HIZ.js → open-3GUVDLGD.js} +6 -6
  120. package/dist/bundle/openai-NHCDLWWY.js +28 -0
  121. package/dist/bundle/{output-file-YGQYZCBJ.js → output-file-72JFXVHQ.js} +6 -6
  122. package/dist/bundle/{process-UJ2JHMJN.js → process-YAHHUFR5.js} +1 -1
  123. package/dist/bundle/{program-LYTGFV6L.js → program-OSZROCTK.js} +113 -118
  124. package/dist/bundle/{prompt-VTUCRCE4.js → prompt-HMCW4XQJ.js} +6 -6
  125. package/dist/bundle/{recognize-3CEPOW2F.js → recognize-VF5CA7EM.js} +5 -5
  126. package/dist/bundle/{remote-DRQEXEZL.js → remote-5C6VTPR2.js} +10 -8
  127. package/dist/bundle/{rerank-UL4KNNVN.js → rerank-ER7NEDOI.js} +8 -8
  128. package/dist/bundle/run-log-JKTLKXSK.js +124 -0
  129. package/dist/bundle/{serve-P5UWUOWQ.js → serve-QJWXJOM7.js} +10 -10
  130. package/dist/bundle/{server-M6XK2Y3X.js → server-KCIK3Y2P.js} +50 -48
  131. package/dist/bundle/server-LLGFDLLJ.js +75 -0
  132. package/dist/bundle/{services-4HRYNY62.js → services-LQMYJQG3.js} +121 -52
  133. package/dist/bundle/{speech-BBPBMFAO.js → speech-74GJQNQH.js} +20 -17
  134. package/dist/bundle/{state-GDSUNUSY.js → state-4XDGCHDF.js} +7 -7
  135. package/dist/bundle/{store-LBQ6FZP2.js → store-5Y5HK2L2.js} +28 -19
  136. package/dist/bundle/{store-VWLABMLF.js → store-Y56AHJ2Y.js} +64 -31
  137. package/dist/bundle/store-connection-4WI32AYU.js +89 -0
  138. package/dist/bundle/store-maintenance-command-PCXO5AH4.js +65 -0
  139. package/dist/bundle/{streaming-EJ3NM2C2.js → streaming-E5CR6HSR.js} +7 -7
  140. package/dist/bundle/{tokens-BE6CJMR5.js → tokens-E2QNVC4F.js} +7 -7
  141. package/dist/bundle/zm.js +34 -10
  142. package/dist/bundle/{zoom-app-YIEJLWCW.js → zoom-app-NVL7HEAX.js} +8 -8
  143. package/dist/contract-overrides.d.ts.map +1 -1
  144. package/dist/contract-overrides.js +0 -6
  145. package/dist/contract-overrides.js.map +1 -1
  146. package/dist/ingestion-search-commands.d.ts.map +1 -1
  147. package/dist/ingestion-search-commands.js +0 -10
  148. package/dist/ingestion-search-commands.js.map +1 -1
  149. package/dist/meeting-integration-commands.d.ts.map +1 -1
  150. package/dist/meeting-integration-commands.js +8 -6
  151. package/dist/meeting-integration-commands.js.map +1 -1
  152. package/dist/meeting-integration.d.ts +3 -1
  153. package/dist/meeting-integration.d.ts.map +1 -1
  154. package/dist/store-connection.d.ts.map +1 -1
  155. package/dist/store-connection.js +4 -3
  156. package/dist/store-connection.js.map +1 -1
  157. package/dist/unified-search.d.ts +4 -4
  158. package/dist/unified-search.d.ts.map +1 -1
  159. package/dist/unified-search.js +1 -24
  160. package/dist/unified-search.js.map +1 -1
  161. package/dist/version.d.ts +1 -1
  162. package/dist/version.js +1 -1
  163. package/package.json +4 -4
  164. package/skills/zoom-cli/SKILL.md +2 -2
  165. package/dist/bundle/answer-policy-GOXSDYDD.js +0 -104
  166. package/dist/bundle/chunk-5XWCBLUR.js +0 -27
  167. package/dist/bundle/chunk-AT2XKNFN.js +0 -342
  168. package/dist/bundle/chunk-GVT5363M.js +0 -35
  169. package/dist/bundle/chunk-VE2VNECR.js +0 -380
  170. package/dist/bundle/chunk-Y6C3N7YG.js +0 -12434
  171. package/dist/bundle/command-contract-RPRKHVU6.js +0 -41
  172. package/dist/bundle/config-QU6A6VIO.js +0 -90
  173. package/dist/bundle/first-run-NVTDR5VO.js +0 -28
  174. package/dist/bundle/first-screen-5RWZDWLK.js +0 -39
  175. package/dist/bundle/openai-T44ORVGQ.js +0 -25
  176. package/dist/bundle/run-log-UZAB5CWF.js +0 -118
  177. package/dist/bundle/server-F3NPVMS2.js +0 -72
  178. package/dist/bundle/store-connection-XEBFP56U.js +0 -83
  179. package/dist/bundle/store-maintenance-command-G43JN57J.js +0 -61
  180. /package/dist/bundle/{chunk-VOXIGICJ.js → chunk-YVNHQFLC.js} +0 -0
@@ -0,0 +1,2355 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ fold
5
+ } from "./chunk-7GLJSJ7M.js";
6
+ import {
7
+ CATALOG_KINDS,
8
+ CONTRACT_KINDS,
9
+ CONTRACT_STATUSES,
10
+ DEAL_KINDS,
11
+ DEAL_STATUSES,
12
+ INVOICE_DIRECTIONS,
13
+ MONEY_DIRECTIONS,
14
+ ORDER_DIRECTIONS,
15
+ ORDER_PURPOSES,
16
+ ORDER_STATUSES,
17
+ SUBSCRIPTION_STATUSES,
18
+ TRANSACTION_STATUSES,
19
+ WALLET_KINDS,
20
+ looksLikeReference,
21
+ parseReference,
22
+ providerLabel,
23
+ providerNamed
24
+ } from "./chunk-VIV64MQM.js";
25
+ import {
26
+ holdsCredential,
27
+ secretNamed
28
+ } from "./chunk-U32VL3MA.js";
29
+ import {
30
+ QUERY_LIMITS,
31
+ queryError
32
+ } from "./chunk-63QXCE5Z.js";
33
+ import {
34
+ CliError,
35
+ isCliError
36
+ } from "./chunk-ELJUBPY4.js";
37
+ import {
38
+ singleLine
39
+ } from "./chunk-6DCLZLGX.js";
40
+ import {
41
+ __name
42
+ } from "./chunk-ZVVMGPBJ.js";
43
+
44
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/record-fields.js
45
+ var DECIMAL_PATTERN = "^[0-9]{1,16}(\\.[0-9]{1,6})?$";
46
+ var SIGNED_DECIMAL = "^-?[0-9]{1,16}(\\.[0-9]{1,6})?$";
47
+ var DAY = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$";
48
+ var INSTANT = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(:[0-9]{2}(\\.[0-9]{1,9})?)?(Z|[+-][0-9]{2}:[0-9]{2})$";
49
+ var text = /* @__PURE__ */ __name((description, maxLength = 2e3) => ({
50
+ type: "string",
51
+ minLength: 1,
52
+ maxLength,
53
+ ...description ? { description } : {}
54
+ }), "text");
55
+ var decimal = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: DECIMAL_PATTERN, description }), "decimal");
56
+ var signedDecimal = /* @__PURE__ */ __name((description) => ({
57
+ type: "string",
58
+ pattern: SIGNED_DECIMAL,
59
+ description
60
+ }), "signedDecimal");
61
+ var day = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: DAY, description }), "day");
62
+ var instant = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: INSTANT, description }), "instant");
63
+ var enumOf = /* @__PURE__ */ __name((values, description) => ({
64
+ type: "string",
65
+ enum: values,
66
+ ...description ? { description } : {}
67
+ }), "enumOf");
68
+ var currency = { type: "string", pattern: "^[A-Za-z]{3}$", description: "ISO 4217 code" };
69
+ var nullable = /* @__PURE__ */ __name((schema) => {
70
+ if (schema.type === void 0)
71
+ return schema;
72
+ const types = typeof schema.type === "string" ? [schema.type] : [...schema.type];
73
+ return {
74
+ ...schema,
75
+ type: types.includes("null") ? types : [...types, "null"],
76
+ ...schema.enum ? { enum: [...schema.enum, null] } : {}
77
+ };
78
+ }, "nullable");
79
+ var objectOf = /* @__PURE__ */ __name((properties, { required, description } = {}) => ({
80
+ type: "object",
81
+ ...description ? { description } : {},
82
+ properties: Object.fromEntries(Object.entries(properties).map(([key, schema]) => [key, required?.includes(key) ? schema : nullable(schema)])),
83
+ ...required?.length ? { required } : {},
84
+ additionalProperties: true
85
+ }), "objectOf");
86
+ var arrayOf = /* @__PURE__ */ __name((item, maxItems, description) => ({
87
+ type: "array",
88
+ items: item,
89
+ maxItems,
90
+ description
91
+ }), "arrayOf");
92
+ var isObject = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isObject");
93
+ var typeOf = /* @__PURE__ */ __name((value) => {
94
+ if (Array.isArray(value))
95
+ return "array";
96
+ if (value === null)
97
+ return "null";
98
+ if (typeof value === "number")
99
+ return Number.isInteger(value) ? "integer" : "number";
100
+ if (typeof value === "string")
101
+ return "string";
102
+ if (typeof value === "boolean")
103
+ return "boolean";
104
+ return typeof value === "object" ? "object" : "other";
105
+ }, "typeOf");
106
+ var WHAT = {
107
+ string: "text",
108
+ integer: "a whole number",
109
+ boolean: "true or false",
110
+ array: "a list",
111
+ object: "an object",
112
+ null: "null"
113
+ };
114
+ var fieldError = /* @__PURE__ */ __name((schema, value, at = []) => {
115
+ const name = at.length ? `fields.${at.join(".")}` : "fields";
116
+ if (schema.type !== void 0) {
117
+ const allowed = typeof schema.type === "string" ? [schema.type] : schema.type;
118
+ if (!allowed.includes(typeOf(value)))
119
+ return { at, message: `${name} is ${allowed.map((one) => WHAT[one]).join(" or ")}` };
120
+ }
121
+ if (schema.enum && !schema.enum.includes(value))
122
+ return { at, message: `${name} is one of ${schema.enum.filter((one) => one !== null).join(", ")}` };
123
+ if (typeof value === "string") {
124
+ const length = [...value].length;
125
+ if (schema.minLength !== void 0 && length < schema.minLength)
126
+ return { at, message: `${name} takes at least ${schema.minLength} characters` };
127
+ if (schema.maxLength !== void 0 && length > schema.maxLength)
128
+ return { at, message: `${name} takes at most ${schema.maxLength} characters` };
129
+ if (schema.pattern !== void 0 && !new RegExp(schema.pattern, "u").test(value))
130
+ return { at, message: `${name} does not have the form ${schema.description ?? schema.pattern}` };
131
+ }
132
+ if (typeof value === "number") {
133
+ if (schema.minimum !== void 0 && value < schema.minimum)
134
+ return { at, message: `${name} is ${schema.minimum} or more` };
135
+ if (schema.maximum !== void 0 && value > schema.maximum)
136
+ return { at, message: `${name} is ${schema.maximum} or less` };
137
+ }
138
+ if (Array.isArray(value)) {
139
+ if (schema.maxItems !== void 0 && value.length > schema.maxItems)
140
+ return { at, message: `${name} holds at most ${schema.maxItems} items` };
141
+ if (schema.items)
142
+ for (const [index, item] of value.entries()) {
143
+ const found = fieldError(schema.items, item, [...at, index]);
144
+ if (found)
145
+ return found;
146
+ }
147
+ }
148
+ if (isObject(value)) {
149
+ for (const key of schema.required ?? [])
150
+ if (!Object.hasOwn(value, key))
151
+ return { at: [...at, key], message: `${name}.${key} is required` };
152
+ for (const [key, property] of Object.entries(schema.properties ?? {})) {
153
+ if (!Object.hasOwn(value, key))
154
+ continue;
155
+ const found = fieldError(property, value[key], [...at, key]);
156
+ if (found)
157
+ return found;
158
+ }
159
+ }
160
+ return void 0;
161
+ }, "fieldError");
162
+
163
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/record-types.js
164
+ var kept = /* @__PURE__ */ __name((description) => ({ description }), "kept");
165
+ var PARTY = ["person", "organization"];
166
+ var ORGANIZATION = ["organization"];
167
+ var lineItem = objectOf({
168
+ description: text("What the line is for; the product's name when left out", 2e3),
169
+ quantity: decimal("A decimal, 1 when left out"),
170
+ unit_price: decimal("A decimal in the parent's currency"),
171
+ amount: decimal("A decimal in the parent's currency: quantity \xD7 unit price"),
172
+ // Untyped: with options.lines text an invoice line's product is data, whatever v1 sent in it.
173
+ product: { description: "The product record's external id in this account, read with options.lines products" },
174
+ product_ref: { type: "string", pattern: "^product:[1-9][0-9]*$", description: "A product: ref of the store" }
175
+ });
176
+ var SMS_DIRECTIONS = ["in", "out"];
177
+ var CALL_DIRECTIONS = ["in", "out", "missed"];
178
+ var phoneFields = {
179
+ phone: text("The other side's number as the phone shows it: read to E.164 with the store's phone_countries", 64),
180
+ name: text("The other side's name as the phone shows it", 200)
181
+ };
182
+ var COUNTERPART = { counterpart: { targets: ["person"], linked: true } };
183
+ var linesIn = /* @__PURE__ */ __name((table, parent) => ({ table, parent, references: { product: "product" }, refs: { product_ref: "product" } }), "linesIn");
184
+ var dealFields = /* @__PURE__ */ __name((kind) => objectOf({
185
+ title: text(`The ${kind}'s title`, 200),
186
+ pipeline: text("The pipeline record's external id in this account", 512),
187
+ stage: text("The stage's external id in that pipeline", 512),
188
+ status: enumOf(DEAL_STATUSES, "Left out, the stage's outcome says it"),
189
+ amount: decimal("A decimal in currency"),
190
+ currency,
191
+ close_date: day("When it is expected to close"),
192
+ closed_date: day("When it was won or lost"),
193
+ closed_reason: text("Why it was won or lost", 2e3),
194
+ url: text("The source's page for it", 2e3)
195
+ }, { required: ["title", "pipeline", "stage"] }), "dealFields");
196
+ var RECORD_TYPES = {
197
+ invoice: {
198
+ table: "invoices",
199
+ review: "proposal",
200
+ update: "flag",
201
+ tombstone: true,
202
+ fields: objectOf({
203
+ direction: enumOf(INVOICE_DIRECTIONS),
204
+ number: text("The invoice's number", 80),
205
+ currency,
206
+ issue_date: day("The day it was issued"),
207
+ due_date: day("The day it is due"),
208
+ total: decimal("The printed total: refused when it is not the sum of the lines"),
209
+ lines: arrayOf(lineItem, 500, "The invoice's lines")
210
+ }),
211
+ roles: {
212
+ issuer: { targets: PARTY, v1: true, column: "issuer", pair: true },
213
+ counterparty: { targets: PARTY, v1: true, column: "counterparty", pair: true },
214
+ project: { targets: ["project"], v1: true, column: "project_id" },
215
+ contract: { targets: ["contract"], column: "contract_id" },
216
+ subscription: { targets: ["subscription"], column: "subscription_id" }
217
+ },
218
+ nested: { lines: linesIn("invoice_lines", "invoice_id") }
219
+ },
220
+ payment: {
221
+ table: "payments",
222
+ review: "proposal",
223
+ update: "re-settle",
224
+ tombstone: true,
225
+ fields: objectOf({
226
+ direction: enumOf(MONEY_DIRECTIONS),
227
+ amount: decimal("A decimal in currency"),
228
+ currency,
229
+ date: day("The day it was paid"),
230
+ reference: text("The payment's reference", 2e3)
231
+ }),
232
+ roles: {
233
+ payer: { targets: PARTY, v1: true, column: "payer", pair: true },
234
+ payee: { targets: PARTY, v1: true, column: "payee", pair: true },
235
+ project: { targets: ["project"], v1: true, column: "project_id" },
236
+ settles: { targets: ["invoice"], many: true, amount: true, v1: true },
237
+ refund_of: { targets: ["payment"], column: "refund_of" },
238
+ subscription: { targets: ["subscription"], column: "subscription_id" }
239
+ }
240
+ },
241
+ person: {
242
+ table: "persons",
243
+ review: "identity",
244
+ update: "in-place",
245
+ tombstone: false,
246
+ fields: objectOf({
247
+ name: kept("The person's name"),
248
+ email: kept("E-mail addresses, one or a list: an exact one links the record to the one person who has it"),
249
+ phone: kept("Phone numbers, one or a list: an exact one, read to E.164, links like an e-mail"),
250
+ position: kept("The job title, kept beside each member-of as its position: never the role")
251
+ }),
252
+ roles: { "member-of": { targets: ORGANIZATION, relationship: "member-of", kept: true } }
253
+ },
254
+ organization: {
255
+ table: "organizations",
256
+ review: "identity",
257
+ update: "in-place",
258
+ tombstone: true,
259
+ fields: objectOf({
260
+ name: kept("The organization's name"),
261
+ identifiers: kept("Strong identifiers, a list of {scheme, value}: scheme email, domain, tax-id:<cc> or registration:<cc>. One that another organization has links the record to it; any other item is kept as data")
262
+ }),
263
+ roles: {
264
+ "customer-of": { targets: ORGANIZATION, relationship: "customer-of", kept: true },
265
+ "partner-of": { targets: ORGANIZATION, relationship: "partner-of", kept: true }
266
+ }
267
+ },
268
+ project: {
269
+ table: "projects",
270
+ review: "identity",
271
+ update: "in-place",
272
+ tombstone: true,
273
+ fields: objectOf({
274
+ name: kept("The project's name"),
275
+ key: kept("The project's key: an existing project with it is this one"),
276
+ description: kept("What the project is")
277
+ }),
278
+ roles: { organization: { targets: ORGANIZATION, column: "organization_id" } }
279
+ },
280
+ order: {
281
+ table: "orders",
282
+ review: "proposal",
283
+ update: "re-propose",
284
+ tombstone: true,
285
+ fields: objectOf({
286
+ number: text("The order's number at the supplier", 80),
287
+ direction: enumOf(ORDER_DIRECTIONS, "purchase when left out; in a sale the owner is the supplier"),
288
+ purpose: enumOf(ORDER_PURPOSES, "business when left out"),
289
+ status: enumOf(ORDER_STATUSES, "placed when left out"),
290
+ supplier_name: text("The shop or supplier as the source names it", 200),
291
+ order_date: day("The day it was ordered"),
292
+ fulfilled_date: day("The day it was delivered"),
293
+ currency,
294
+ total: decimal("With lines, their sum"),
295
+ source_url: text("The order's page at the shop", 2e3),
296
+ lines: arrayOf(lineItem, 500, "The order's lines")
297
+ }),
298
+ roles: {
299
+ customer: { targets: PARTY, column: "customer", pair: true },
300
+ supplier: { targets: PARTY, column: "supplier", pair: true },
301
+ project: { targets: ["project"], column: "project_id" },
302
+ contract: { targets: ["contract"], column: "contract_id" },
303
+ deal: { targets: ["deal"], column: "deal_id" },
304
+ invoice: { targets: ["invoice"], column: "invoice_id" },
305
+ payment: { targets: ["payment"], column: "payment_id" }
306
+ },
307
+ nested: { lines: linesIn("order_lines", "order_id") }
308
+ },
309
+ product: {
310
+ table: "catalog_items",
311
+ review: "direct",
312
+ update: "in-place",
313
+ tombstone: true,
314
+ fields: objectOf({
315
+ kind: enumOf(CATALOG_KINDS, "product when left out"),
316
+ name: text("The product's name", 200),
317
+ sku: text("The supplier's code for it", 80),
318
+ unit: text("hour, pcs, month: free text", 40),
319
+ unit_price: decimal("A decimal in currency"),
320
+ currency,
321
+ description: text("What it is", 2e3),
322
+ archived_date: day("No longer sold from this day")
323
+ }, { required: ["name"] }),
324
+ roles: { supplier: { targets: PARTY, column: "supplier", pair: true } }
325
+ },
326
+ contract: {
327
+ table: "contracts",
328
+ review: "valued-proposal",
329
+ update: "re-propose",
330
+ tombstone: true,
331
+ fields: objectOf({
332
+ name: text("The contract's name", 200),
333
+ number: text("The contract's number", 80),
334
+ kind: enumOf(CONTRACT_KINDS),
335
+ status: enumOf(CONTRACT_STATUSES, "active when left out"),
336
+ signed_date: day("The day it was signed"),
337
+ effective_date: day("The day it starts"),
338
+ expiration_date: day("The day it ends; open-ended when left out"),
339
+ auto_renew: { type: "boolean", description: "Whether it renews itself" },
340
+ renewal: { type: "string", pattern: "^[1-9][0-9]{0,2}-(day|week|month|year)$", description: "1-year" },
341
+ notice_days: { type: "integer", minimum: 0, maximum: 3650, description: "Days of notice before it ends" },
342
+ terms: text("Renewal, cancellation and other terms, as text", 2e4),
343
+ value: decimal("A decimal in currency: the contract is then a proposal"),
344
+ currency
345
+ }, { required: ["name", "kind"] }),
346
+ roles: {
347
+ project: { targets: ["project"], column: "project_id" },
348
+ deal: { targets: ["deal"], column: "deal_id" },
349
+ party: { targets: PARTY, many: true, relationship: "related-to", kept: true },
350
+ document: { targets: ["document"], many: true, kept: true }
351
+ }
352
+ },
353
+ subscription: {
354
+ table: "subscriptions",
355
+ review: "proposal",
356
+ update: "re-propose",
357
+ tombstone: true,
358
+ fields: objectOf({
359
+ name: text("Its name; the product's when left out", 200),
360
+ direction: enumOf(INVOICE_DIRECTIONS, "receivable: the owner bills it; payable: the owner pays it"),
361
+ status: enumOf(SUBSCRIPTION_STATUSES),
362
+ interval: { type: "string", pattern: "^[1-9][0-9]{0,2}-(day|week|month|year)$", description: "1-month" },
363
+ start_date: day("The first day"),
364
+ trial_end_date: day("The trial's last day"),
365
+ next_renewal_date: day("The next renewal"),
366
+ cancelled_date: day("The day it was cancelled"),
367
+ end_date: day("The last day"),
368
+ prices: arrayOf(objectOf({
369
+ amount: decimal("A decimal in currency"),
370
+ currency,
371
+ effective_from: day("The day the price starts; the subscription's start when left out")
372
+ }, { required: ["amount", "currency"] }), 100, "Its prices, each from a day; a price is never overwritten")
373
+ }, { required: ["direction", "interval", "start_date"] }),
374
+ roles: {
375
+ supplier: { targets: PARTY, column: "supplier", pair: true },
376
+ customer: { targets: PARTY, column: "customer", pair: true },
377
+ product: { targets: ["product"], column: "catalog_item_id" },
378
+ contract: { targets: ["contract"], column: "contract_id" },
379
+ project: { targets: ["project"], column: "project_id" }
380
+ },
381
+ nested: { prices: { table: "subscription_prices", parent: "subscription_id" } }
382
+ },
383
+ wallet: {
384
+ table: "financial_accounts",
385
+ review: "direct",
386
+ update: "in-place",
387
+ tombstone: true,
388
+ fields: objectOf({
389
+ name: text("The account's name", 200),
390
+ kind: enumOf(WALLET_KINDS, "bank when left out"),
391
+ currency,
392
+ institution: text("The bank, as text", 200),
393
+ number_hint: text("The last 4 characters of its number; a whole IBAN or card number is refused", 4),
394
+ opening_balance: signedDecimal("Kept in the record only: the owner sets the wallet's opening balance"),
395
+ opening_date: day("The day of that balance")
396
+ }, { required: ["name", "currency"] }),
397
+ roles: { holder: { targets: PARTY, column: "holder", pair: true } }
398
+ },
399
+ transaction: {
400
+ table: "financial_transactions",
401
+ review: "proposal",
402
+ update: "re-propose",
403
+ tombstone: true,
404
+ fields: objectOf({
405
+ direction: enumOf(MONEY_DIRECTIONS),
406
+ amount: decimal("A decimal above 0 in the wallet's currency"),
407
+ currency,
408
+ status: enumOf(TRANSACTION_STATUSES, "booked when left out"),
409
+ date: day("The day the statement shows"),
410
+ booked_date: day("The day it was booked; the statement day when left out"),
411
+ description: text("As the statement says it", 2e3),
412
+ counterparty_name: text("As the statement names the other side", 200),
413
+ reference: text("The statement's reference", 200),
414
+ splits: arrayOf(objectOf({
415
+ amount: decimal("A decimal above 0"),
416
+ category: text("Free text, such as rent", 200),
417
+ note: text("A note", 2e3)
418
+ }, { required: ["amount", "category"] }), 100, "Categories of its amount; what they leave is uncategorized")
419
+ }, { required: ["direction", "amount", "date"] }),
420
+ roles: {
421
+ wallet: { targets: ["wallet"], required: true, column: "financial_account_id" },
422
+ counterparty: { targets: PARTY, column: "counterparty", pair: true },
423
+ payment: { targets: ["payment"], column: "payment_id" },
424
+ project: { targets: ["project"], column: "project_id" }
425
+ },
426
+ nested: { splits: { table: "transaction_splits", parent: "transaction_id" } }
427
+ },
428
+ deal: {
429
+ table: "deals",
430
+ review: "direct",
431
+ update: "in-place",
432
+ tombstone: true,
433
+ fields: dealFields("deal"),
434
+ references: { pipeline: "pipeline" },
435
+ roles: {
436
+ organization: { targets: ORGANIZATION, column: "organization_id" },
437
+ person: { targets: ["person"], many: true, relationship: "related-to", kept: true },
438
+ project: { targets: ["project"], column: "project_id" }
439
+ }
440
+ },
441
+ lead: {
442
+ table: "leads",
443
+ review: "direct",
444
+ update: "in-place",
445
+ tombstone: true,
446
+ fields: dealFields("lead"),
447
+ references: { pipeline: "pipeline" },
448
+ roles: {
449
+ organization: { targets: ORGANIZATION, column: "organization_id" },
450
+ person: { targets: ["person"], many: true, relationship: "related-to", kept: true },
451
+ project: { targets: ["project"], column: "project_id" },
452
+ deal: { targets: ["deal"], column: "deal_id" }
453
+ }
454
+ },
455
+ message: {
456
+ table: "messages",
457
+ review: "direct",
458
+ update: "in-place",
459
+ tombstone: true,
460
+ importOnly: true,
461
+ fields: objectOf({
462
+ kind: enumOf(["sms"], "sms: a text message of the phone"),
463
+ direction: enumOf(SMS_DIRECTIONS, "in: the other side wrote it; out: the owner did"),
464
+ ...phoneFields,
465
+ thread: text("The phone's thread id; the number when left out", 512),
466
+ body: { type: "string", maxLength: 2e4, description: "The text" },
467
+ sent_at: instant("When it was sent"),
468
+ read: { type: "boolean", description: "An incoming message the owner opened" }
469
+ }, { required: ["kind", "direction", "phone", "body", "sent_at"] }),
470
+ roles: COUNTERPART
471
+ },
472
+ event: {
473
+ table: "events",
474
+ review: "direct",
475
+ update: "in-place",
476
+ tombstone: true,
477
+ importOnly: true,
478
+ fields: objectOf({
479
+ kind: enumOf(["call"], "call: a phone call"),
480
+ direction: enumOf(CALL_DIRECTIONS, "in, out, or missed: a call the owner did not take"),
481
+ ...phoneFields,
482
+ started_at: instant("When it rang"),
483
+ duration: { type: "integer", minimum: 0, maximum: 604800, description: "Seconds talked; 0 when missed" }
484
+ }, { required: ["kind", "direction", "phone", "started_at"] }),
485
+ roles: COUNTERPART
486
+ },
487
+ pipeline: {
488
+ table: "pipelines",
489
+ review: "direct",
490
+ update: "in-place",
491
+ tombstone: false,
492
+ fields: objectOf({
493
+ kind: enumOf(DEAL_KINDS, "deal when left out"),
494
+ name: text("The pipeline's name", 80),
495
+ stages: arrayOf(objectOf({
496
+ external_id: text("The stage's id at the source", 512),
497
+ name: text("The stage's name", 80),
498
+ position: { type: "integer", minimum: 0, maximum: 1e3 },
499
+ outcome: enumOf(DEAL_STATUSES, "open when left out")
500
+ }, { required: ["external_id", "name"] }), 30, "The stages in order")
501
+ }, { required: ["name", "stages"] }),
502
+ roles: {},
503
+ nested: { stages: { table: "pipeline_stages", parent: "pipeline_id" } }
504
+ }
505
+ };
506
+ var isRecordType = /* @__PURE__ */ __name((type) => Object.hasOwn(RECORD_TYPES, type), "isRecordType");
507
+ var isBusinessType = /* @__PURE__ */ __name((type) => isRecordType(type) && RECORD_TYPES[type].review !== "identity", "isBusinessType");
508
+ var isIdentityType = /* @__PURE__ */ __name((type) => typeof type === "string" && isRecordType(type) && RECORD_TYPES[type].review === "identity", "isIdentityType");
509
+ var RECORD_ENTITY_TYPES = Object.keys(RECORD_TYPES);
510
+ var RECORD_TABLES = Object.fromEntries(Object.entries(RECORD_TYPES).map(([type, spec]) => [type, spec.table]));
511
+ var decidedOf = /* @__PURE__ */ __name((types) => Object.fromEntries(Object.entries(types).flatMap(([type, spec]) => spec.review === "proposal" || spec.review === "valued-proposal" ? [[type, spec.table]] : [])), "decidedOf");
512
+ var DECIDED_TABLES = {
513
+ ...decidedOf(RECORD_TYPES),
514
+ subscription_price: "subscription_prices"
515
+ };
516
+ var WORD_BODY = "[a-z0-9][a-z0-9_-]{0,62}";
517
+ var TYPE_PATTERN = `^(${RECORD_ENTITY_TYPES.join("|")}|custom:${WORD_BODY})$`;
518
+ var TYPE_RULE = `a type is one of ${RECORD_ENTITY_TYPES.join(", ")} or custom:<name>`;
519
+ var rolesOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].roles), "rolesOf");
520
+ var roleOf = /* @__PURE__ */ __name((type, role) => {
521
+ if (!isRecordType(type))
522
+ return void 0;
523
+ const roles = RECORD_TYPES[type].roles;
524
+ return Object.hasOwn(roles, role) ? roles[role] : void 0;
525
+ }, "roleOf");
526
+ var nestedOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].nested ?? {}), "nestedOf");
527
+ var referencesOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].references ?? {}), "referencesOf");
528
+ var roleNames = /* @__PURE__ */ __name((types, keep) => [
529
+ ...new Set(types.flatMap((type) => rolesOf(type).flatMap(([name, role]) => keep(role) ? [name] : [])))
530
+ ], "roleNames");
531
+ var AMOUNT_ROLES = roleNames(RECORD_ENTITY_TYPES, (role) => role.amount);
532
+ var FIELD_REFERENCE_ROLES = roleNames(RECORD_ENTITY_TYPES, (role) => role.v1 && !role.many);
533
+ var hasV1Roles = /* @__PURE__ */ __name((type) => rolesOf(type).some(([, role]) => role.v1), "hasV1Roles");
534
+ var IDENTITY_TYPES = RECORD_ENTITY_TYPES.filter((type) => RECORD_TYPES[type].review === "identity");
535
+ var article = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
536
+
537
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/addresses.js
538
+ var EMAIL_ADDRESS = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u;
539
+ var isEmailAddress = /* @__PURE__ */ __name((value) => EMAIL_ADDRESS.test(value), "isEmailAddress");
540
+ var ROLE_ADDRESS_WORDS = {
541
+ noReply: ["noreply", "no-reply", "donotreply", "do-not-reply", "mailer-daemon", "bounce", "bounces"],
542
+ shared: [
543
+ "info",
544
+ "hello",
545
+ "hi",
546
+ "contact",
547
+ "contacts",
548
+ "support",
549
+ "help",
550
+ "helpdesk",
551
+ "service",
552
+ "sales",
553
+ "office",
554
+ "admin",
555
+ "team",
556
+ "billing",
557
+ "accounts",
558
+ "accounting",
559
+ "invoices",
560
+ "finance",
561
+ "hr",
562
+ "jobs",
563
+ "careers",
564
+ "press",
565
+ "media",
566
+ "marketing",
567
+ "partners",
568
+ "legal",
569
+ "privacy",
570
+ "security",
571
+ "abuse",
572
+ "postmaster",
573
+ "webmaster",
574
+ "mail",
575
+ "inbox",
576
+ "enquiries",
577
+ "inquiries",
578
+ "booking",
579
+ "reservations",
580
+ "orders",
581
+ "feedback",
582
+ "newsletter",
583
+ "notifications",
584
+ "alerts"
585
+ ]
586
+ };
587
+ var bare = /* @__PURE__ */ __name((word) => word.replace(/[.\-_]/gu, ""), "bare");
588
+ var NO_REPLY = new Set(ROLE_ADDRESS_WORDS.noReply.map(bare));
589
+ var ROLE = new Set([...ROLE_ADDRESS_WORDS.shared, ...ROLE_ADDRESS_WORDS.noReply].map(bare));
590
+ var localWord = /* @__PURE__ */ __name((address) => {
591
+ const local = address.trim().toLowerCase().split("@")[0] ?? "";
592
+ return bare(local.split("+")[0] ?? "");
593
+ }, "localWord");
594
+ var isRoleAddress = /* @__PURE__ */ __name((address) => ROLE.has(localWord(address)), "isRoleAddress");
595
+ var PERSON_LIKE = /* @__PURE__ */ new Set(["hr"]);
596
+ var isPersonLikeRoleAddress = /* @__PURE__ */ __name((address) => PERSON_LIKE.has(localWord(address)), "isPersonLikeRoleAddress");
597
+ var isNoReplyAddress = /* @__PURE__ */ __name((address) => NO_REPLY.has(localWord(address)), "isNoReplyAddress");
598
+
599
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
600
+ var QUERY_VERSION = 1;
601
+ var QUERY_LIMITS2 = {
602
+ ...QUERY_LIMITS,
603
+ pattern: 1024,
604
+ states: 1e4,
605
+ expansions: 1e4,
606
+ candidates: 5e4,
607
+ bodyBytes: 8388608,
608
+ milliseconds: 2e3,
609
+ work: 1e7
610
+ };
611
+ var SEARCH_QUERY = {
612
+ command: "search",
613
+ guide: "https://github.com/WireCatLabs/cli-core/blob/main/docs/search/query-language.md"
614
+ };
615
+ var MESSAGE_PARSING = { ...SEARCH_QUERY, proximity: true };
616
+ var MOST_WORDS_APART = 50;
617
+ function searchError(reason, span, alternative) {
618
+ queryError(reason, span, alternative, SEARCH_QUERY);
619
+ }
620
+ __name(searchError, "searchError");
621
+ var ANSWER_MS = 1e3;
622
+ var searchTimeLimit = /* @__PURE__ */ __name((deadline, now = Date.now()) => deadline?.explicit ? Math.max(QUERY_LIMITS2.milliseconds, deadline.endsAt - now - ANSWER_MS) : void 0, "searchTimeLimit");
623
+ function outOfTime(limitMs = QUERY_LIMITS2.milliseconds) {
624
+ throw new CliError("timeout", `search stopped at its time limit of ${limitMs / 1e3}s \u2014 the query is valid; add chat: or date: to search less of the store`, { reason: "query.time-limit", budget: "time", limit_ms: limitMs, complete: false });
625
+ }
626
+ __name(outOfTime, "outOfTime");
627
+ var isQueryLimit = /* @__PURE__ */ __name((error) => isCliError(error) && (error.details.reason === "query.too-large" || error.details.reason === "query.time-limit"), "isQueryLimit");
628
+ function exhausted(budget) {
629
+ throw new CliError("validation_error", `search exceeded its ${budget} budget \u2014 narrow the chat or date range`, {
630
+ reason: "query.too-large",
631
+ budget,
632
+ complete: false
633
+ });
634
+ }
635
+ __name(exhausted, "exhausted");
636
+ function tooWideTerm([term], budget) {
637
+ if (term === void 0)
638
+ exhausted(budget);
639
+ const part = term.replace(/[*?]+/gu, " ").trim().split(/\s+/u).sort((a, b) => b.length - a.length)[0] ?? term;
640
+ throw new CliError("validation_error", `search exceeded its ${budget} budget: ${term} is checked word by word, and too many messages hold it \u2014 write *${part}* (any word holding it, read from the index), more of the word, or add chat: or date:`, { reason: "query.too-large", budget, term, complete: false });
641
+ }
642
+ __name(tooWideTerm, "tooWideTerm");
643
+
644
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/ref-arguments.js
645
+ var TAKES = {
646
+ chat: "a chat: chat:<provider>/<account>/<chat>, its id or its title",
647
+ message: "a message: msg:<provider>/<account>/<chat>/<message>, or a chat and the message's id"
648
+ };
649
+ var article2 = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
650
+ var wrongKind = /* @__PURE__ */ __name((text2, kind, takes) => new CliError("validation_error", `${text2} names ${article2(kind)} ${kind}; this takes ${TAKES[takes]}`, {
651
+ reason: "ref.wrong-kind"
652
+ }), "wrongKind");
653
+ var wrongProvider = /* @__PURE__ */ __name((text2, provider, kind) => {
654
+ const entry = providerNamed(provider);
655
+ const command = entry?.command;
656
+ const opens = kind === "entity" ? void 0 : entry?.opens?.[kind];
657
+ const how = command && opens ? `open it with ${command} <profile> ${opens} ${text2}` : "open it with its own CLI";
658
+ const label2 = providerLabel(provider);
659
+ return new CliError("validation_error", `${text2} is ${article2(label2.toLowerCase())} ${label2} ${kind}; ${how}`, {
660
+ reason: "ref.wrong-provider"
661
+ });
662
+ }, "wrongProvider");
663
+ var chatReferenceOf = /* @__PURE__ */ __name((text2, provider, takes = "chat") => {
664
+ const trimmed = text2.trim();
665
+ if (!looksLikeReference(trimmed))
666
+ return void 0;
667
+ const reference = parseReference(trimmed);
668
+ if (reference.type !== "chat" && reference.type !== "message")
669
+ throw wrongKind(trimmed, reference.type, takes);
670
+ if (reference.provider !== provider)
671
+ throw wrongProvider(trimmed, reference.provider, reference.type);
672
+ const found = {
673
+ text: trimmed,
674
+ provider: reference.provider,
675
+ account: reference.account,
676
+ chat: reference.chat,
677
+ ...reference.type === "message" ? { message: reference.message } : {}
678
+ };
679
+ return found;
680
+ }, "chatReferenceOf");
681
+ var contactReferenceOf = /* @__PURE__ */ __name((text2, provider) => {
682
+ const trimmed = text2.trim();
683
+ if (!trimmed.startsWith("contact:"))
684
+ return void 0;
685
+ const reference = parseReference(trimmed);
686
+ if (reference.type !== "contact")
687
+ return void 0;
688
+ if (provider !== void 0 && reference.provider !== provider)
689
+ throw wrongProvider(trimmed, reference.provider, reference.type);
690
+ return reference.id;
691
+ }, "contactReferenceOf");
692
+ var wrongAccount = /* @__PURE__ */ __name((reference, scope, profiles) => {
693
+ 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}`;
694
+ const others = profiles === void 0 ? "" : `. Profiles signed in to ${reference.account}: ${profiles.length > 0 ? profiles.join(", ") : "none here"}`;
695
+ return new CliError("validation_error", `${reference.text} belongs to account ${reference.account}; ${here}${others}`, { reason: "ref.wrong-account" });
696
+ }, "wrongAccount");
697
+ var ensureAccount = /* @__PURE__ */ __name(async (reference, scope, profilesOn) => {
698
+ if (scope.account !== void 0 && scope.account === reference.account)
699
+ return;
700
+ const profiles = await profilesOn?.(reference.account).catch(() => void 0);
701
+ throw wrongAccount(reference, scope, profiles);
702
+ }, "ensureAccount");
703
+
704
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
705
+ var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
706
+ var literal = /* @__PURE__ */ __name((c) => ({
707
+ kind: "char",
708
+ ranges: [[c.codePointAt(0) ?? 0, c.codePointAt(0) ?? 0]],
709
+ negate: false
710
+ }), "literal");
711
+ var compileAutomaton = /* @__PURE__ */ __name((pattern, span = { start: 0, end: pattern.length }) => {
712
+ if (pattern.length > QUERY_LIMITS2.pattern * 2)
713
+ exhausted("pattern");
714
+ const chars = [...pattern];
715
+ if (chars.length > QUERY_LIMITS2.pattern)
716
+ exhausted("pattern");
717
+ let at = 0, depth = 0;
718
+ const failure = /* @__PURE__ */ __name(() => searchError("query.invalid-regex", span, "use the supported Lucene regex subset"), "failure");
719
+ const character = /* @__PURE__ */ __name(() => {
720
+ if (at >= chars.length)
721
+ return failure();
722
+ return chars[at++];
723
+ }, "character");
724
+ const predefined = /* @__PURE__ */ __name(() => {
725
+ if (chars[at] !== "\\")
726
+ return void 0;
727
+ const name = chars[at + 1] ?? "";
728
+ let ranges;
729
+ if (name.toLowerCase() === "d")
730
+ ranges = [[48, 57]];
731
+ if (name.toLowerCase() === "w")
732
+ ranges = [
733
+ [48, 57],
734
+ [65, 90],
735
+ [95, 95],
736
+ [97, 122]
737
+ ];
738
+ if (name.toLowerCase() === "s")
739
+ ranges = [
740
+ [9, 10],
741
+ [13, 13],
742
+ [32, 32]
743
+ ];
744
+ if (ranges) {
745
+ at += 2;
746
+ return { kind: "char", ranges, negate: name === name.toUpperCase() };
747
+ }
748
+ if (/^[a-zA-Z]$/u.test(name))
749
+ return failure();
750
+ return void 0;
751
+ }, "predefined");
752
+ const escaped = /* @__PURE__ */ __name(() => {
753
+ if (chars[at] === "\\")
754
+ at++;
755
+ return character();
756
+ }, "escaped");
757
+ const union = /* @__PURE__ */ __name(() => {
758
+ if (++depth > QUERY_LIMITS2.depth)
759
+ exhausted("pattern depth");
760
+ const children = [concat()];
761
+ while (chars[at] === "|") {
762
+ at++;
763
+ children.push(concat());
764
+ }
765
+ depth--;
766
+ return children.length === 1 ? children[0] : { kind: "union", children };
767
+ }, "union");
768
+ const concat = /* @__PURE__ */ __name(() => {
769
+ const children = [];
770
+ do {
771
+ children.push(repeat());
772
+ } while (at < chars.length && ![")", "|", "&"].includes(chars[at] ?? ""));
773
+ if (chars[at] === "&")
774
+ searchError("query.unsupported-regex", span, "automaton intersection is not supported");
775
+ return children.length === 1 ? children[0] : { kind: "concat", children };
776
+ }, "concat");
777
+ const repeat = /* @__PURE__ */ __name(() => {
778
+ let child = simple();
779
+ while (["?", "*", "+", "{"].includes(chars[at] ?? "")) {
780
+ const op = character();
781
+ let min = op === "+" ? 1 : 0, max = op === "?" ? 1 : null;
782
+ if (op === "{") {
783
+ const number = /* @__PURE__ */ __name(() => {
784
+ const start2 = at;
785
+ while (/^[0-9]$/u.test(chars[at] ?? ""))
786
+ at++;
787
+ if (at === start2)
788
+ return failure();
789
+ return Number(chars.slice(start2, at).join(""));
790
+ }, "number");
791
+ min = number();
792
+ max = min;
793
+ if (chars[at] === ",") {
794
+ at++;
795
+ max = chars[at] === "}" ? null : number();
796
+ }
797
+ if (character() !== "}" || max !== null && max < min)
798
+ return failure();
799
+ }
800
+ if (min > QUERY_LIMITS2.states || max !== null && max > QUERY_LIMITS2.states)
801
+ exhausted("automaton states");
802
+ child = { kind: "repeat", child, min, max };
803
+ }
804
+ return child;
805
+ }, "repeat");
806
+ const simple = /* @__PURE__ */ __name(() => {
807
+ const predefinedAtom = predefined();
808
+ if (predefinedAtom)
809
+ return predefinedAtom;
810
+ const c = character();
811
+ if (c === "~" || c === "<")
812
+ searchError("query.unsupported-regex", span, "complement, named automata and numeric intervals are not supported");
813
+ if (c === ".")
814
+ return any;
815
+ if (c === "#")
816
+ return { kind: "empty" };
817
+ if (c === "@")
818
+ return { kind: "repeat", child: any, min: 0, max: null };
819
+ if (c === '"') {
820
+ const children = [];
821
+ while (chars[at] !== '"')
822
+ children.push(literal(character()));
823
+ at++;
824
+ return { kind: "concat", children };
825
+ }
826
+ if (c === "(") {
827
+ if (chars[at] === ")") {
828
+ at++;
829
+ return { kind: "epsilon" };
830
+ }
831
+ if (chars[at] === "?")
832
+ searchError("query.unsupported-regex", span, "JavaScript groups and lookaround are not Lucene operators");
833
+ const child = union();
834
+ if (character() !== ")")
835
+ return failure();
836
+ return child;
837
+ }
838
+ if (c === "[") {
839
+ const negate = chars[at] === "^";
840
+ if (negate)
841
+ at++;
842
+ const choices = [];
843
+ do {
844
+ const pre = predefined();
845
+ if (pre) {
846
+ choices.push(pre);
847
+ continue;
848
+ }
849
+ const lo = escaped().codePointAt(0) ?? 0;
850
+ let hi = lo;
851
+ if (chars[at] === "-") {
852
+ at++;
853
+ hi = escaped().codePointAt(0) ?? 0;
854
+ }
855
+ if (hi < lo)
856
+ return failure();
857
+ choices.push({ kind: "char", ranges: [[lo, hi]], negate: false });
858
+ } while (at < chars.length && chars[at] !== "]");
859
+ if (character() !== "]")
860
+ return failure();
861
+ if (!negate)
862
+ return { kind: "union", children: choices };
863
+ const ranges = [];
864
+ for (const choice of choices) {
865
+ if (choice.kind !== "char" || choice.negate)
866
+ searchError("query.unsupported-regex", span, "negative predefined classes inside a negated class are not supported");
867
+ ranges.push(...choice.ranges);
868
+ }
869
+ return { kind: "char", ranges, negate: true };
870
+ }
871
+ if (c === "\\")
872
+ return literal(character());
873
+ return literal(c);
874
+ }, "simple");
875
+ const expression = chars.length === 0 ? { kind: "epsilon" } : union();
876
+ if (at !== chars.length)
877
+ return failure();
878
+ const states = [];
879
+ const state = /* @__PURE__ */ __name(() => {
880
+ if (states.length >= QUERY_LIMITS2.states)
881
+ exhausted("automaton states");
882
+ states.push({ epsilon: [], edges: [] });
883
+ return states.length - 1;
884
+ }, "state");
885
+ const epsilon = /* @__PURE__ */ __name((from, to) => {
886
+ ;
887
+ states[from].epsilon.push(to);
888
+ }, "epsilon");
889
+ const build = /* @__PURE__ */ __name((node, from, to) => {
890
+ if (node.kind === "char") {
891
+ ;
892
+ states[from].edges.push({ to, atom: node });
893
+ return;
894
+ }
895
+ if (node.kind === "empty")
896
+ return;
897
+ if (node.kind === "epsilon") {
898
+ epsilon(from, to);
899
+ return;
900
+ }
901
+ if (node.kind === "union") {
902
+ for (const child of node.children)
903
+ build(child, from, to);
904
+ return;
905
+ }
906
+ if (node.kind === "concat") {
907
+ let current2 = from;
908
+ node.children.forEach((child, index) => {
909
+ const next = index === node.children.length - 1 ? to : state();
910
+ build(child, current2, next);
911
+ current2 = next;
912
+ });
913
+ if (node.children.length === 0)
914
+ epsilon(from, to);
915
+ return;
916
+ }
917
+ let current = from;
918
+ for (let i = 0; i < node.min; i++) {
919
+ const next = state();
920
+ build(node.child, current, next);
921
+ current = next;
922
+ }
923
+ if (node.max === null) {
924
+ epsilon(current, to);
925
+ const end2 = state();
926
+ build(node.child, current, end2);
927
+ epsilon(end2, current);
928
+ } else {
929
+ for (let i = node.min; i < node.max; i++) {
930
+ epsilon(current, to);
931
+ const next = state();
932
+ build(node.child, current, next);
933
+ current = next;
934
+ }
935
+ epsilon(current, to);
936
+ }
937
+ }, "build");
938
+ const start = state(), end = state();
939
+ build(expression, start, end);
940
+ return {
941
+ states: states.length,
942
+ test: /* @__PURE__ */ __name((text2, budget = { work: 0 }) => {
943
+ const spend = /* @__PURE__ */ __name(() => {
944
+ if (++budget.work > (budget.maxWork ?? QUERY_LIMITS2.work))
945
+ exhausted("automaton work");
946
+ }, "spend");
947
+ const closure = /* @__PURE__ */ __name((initial) => {
948
+ const stack = [...initial];
949
+ while (stack.length) {
950
+ const id = stack.pop();
951
+ for (const next of states[id].epsilon) {
952
+ spend();
953
+ if (!initial.has(next)) {
954
+ initial.add(next);
955
+ stack.push(next);
956
+ }
957
+ }
958
+ }
959
+ return initial;
960
+ }, "closure");
961
+ let current = closure(/* @__PURE__ */ new Set([start]));
962
+ for (const c of text2) {
963
+ const point = c.codePointAt(0) ?? 0;
964
+ const next = /* @__PURE__ */ new Set();
965
+ for (const id of current)
966
+ for (const edge of states[id].edges) {
967
+ spend();
968
+ const inside = edge.atom.ranges.some(([lo, hi]) => point >= lo && point <= hi);
969
+ if (inside !== edge.atom.negate)
970
+ next.add(edge.to);
971
+ }
972
+ current = closure(next);
973
+ if (current.size === 0)
974
+ return false;
975
+ }
976
+ return current.has(end);
977
+ }, "test")
978
+ };
979
+ }, "compileAutomaton");
980
+ var wildcardPattern = /* @__PURE__ */ __name((value) => {
981
+ const chars = [...value];
982
+ let pattern = "";
983
+ for (let at = 0; at < chars.length; at++) {
984
+ const c = chars[at];
985
+ if (c === "\\") {
986
+ const escaped = chars[++at];
987
+ if (escaped === void 0)
988
+ searchError("query.invalid-escape", { start: 0, end: value.length });
989
+ pattern += /[|&?*+(){}[\].#@<>"~\\]/u.test(escaped) ? `\\${escaped}` : escaped;
990
+ } else
991
+ pattern += c === "*" ? ".*" : c === "?" ? "." : /[|&?*+(){}[\].#@<>"~\\]/u.test(c) ? `\\${c}` : c;
992
+ }
993
+ return pattern;
994
+ }, "wildcardPattern");
995
+ var FOLD_RANGE = 4096;
996
+ 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");
997
+ var classChar = /* @__PURE__ */ __name((point) => {
998
+ const c = String.fromCodePoint(point);
999
+ return /[\p{L}\p{N}]/u.test(c) ? c : `\\${c}`;
1000
+ }, "classChar");
1001
+ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
1002
+ const chars = [...pattern.normalize("NFC")];
1003
+ let out = "";
1004
+ let at = 0;
1005
+ const literal2 = /* @__PURE__ */ __name((c) => {
1006
+ if (!/[\p{L}\p{N}\p{M}]/u.test(c))
1007
+ return c;
1008
+ const folded = fold(c);
1009
+ if (folded === "")
1010
+ return unfoldable(span, `"${c}"`);
1011
+ if ([...folded].length === 1 && /[\p{L}\p{N}]/u.test(folded))
1012
+ return folded;
1013
+ if (folded.includes('"'))
1014
+ return unfoldable(span, `"${c}"`);
1015
+ return `"${folded}"`;
1016
+ }, "literal");
1017
+ const characterClass = /* @__PURE__ */ __name(() => {
1018
+ const begin = at - 1;
1019
+ let negate = "";
1020
+ if (chars[at] === "^") {
1021
+ negate = "^";
1022
+ at++;
1023
+ }
1024
+ const kept2 = [];
1025
+ const points = /* @__PURE__ */ new Set();
1026
+ do {
1027
+ const start = at;
1028
+ if (chars[at] === "\\" && /^[a-zA-Z]$/u.test(chars[at + 1] ?? "")) {
1029
+ kept2.push(`\\${chars[at + 1]}`);
1030
+ at += 2;
1031
+ continue;
1032
+ }
1033
+ const escaped = /* @__PURE__ */ __name(() => {
1034
+ if (chars[at] === "\\")
1035
+ at++;
1036
+ return (chars[at++] ?? "").codePointAt(0) ?? 0;
1037
+ }, "escaped");
1038
+ const lo = escaped();
1039
+ let hi = lo;
1040
+ if (chars[at] === "-") {
1041
+ at++;
1042
+ hi = escaped();
1043
+ }
1044
+ if (at > chars.length) {
1045
+ out += chars.slice(begin).join("");
1046
+ return;
1047
+ }
1048
+ const single = /* @__PURE__ */ __name((point) => [...fold(String.fromCodePoint(point))], "single");
1049
+ if (hi < lo)
1050
+ kept2.push(chars.slice(start, at).join(""));
1051
+ else if (hi - lo >= FOLD_RANGE) {
1052
+ if (single(lo).join("") !== String.fromCodePoint(lo) || single(hi).join("") !== String.fromCodePoint(hi))
1053
+ unfoldable(span, `the range ${chars.slice(start, at).join("")}`);
1054
+ kept2.push(chars.slice(start, at).join(""));
1055
+ } else
1056
+ for (let point = lo; point <= hi; point++) {
1057
+ const folded = single(point);
1058
+ if (folded.length === 1)
1059
+ points.add(folded[0]?.codePointAt(0) ?? 0);
1060
+ else if (lo === hi)
1061
+ unfoldable(span, `"${String.fromCodePoint(point)}"`);
1062
+ }
1063
+ } while (at < chars.length && chars[at] !== "]");
1064
+ const sorted = [...points].sort((a, b) => a - b);
1065
+ const ranges = [];
1066
+ for (let i = 0; i < sorted.length; i++) {
1067
+ const first = sorted[i];
1068
+ while (sorted[i + 1] === sorted[i] + 1)
1069
+ i++;
1070
+ const last = sorted[i];
1071
+ ranges.push(last === first ? classChar(first) : `${classChar(first)}-${classChar(last)}`);
1072
+ }
1073
+ if (!kept2.length && !ranges.length)
1074
+ unfoldable(span, "the class");
1075
+ out += `[${negate}${kept2.join("")}${ranges.join("")}`;
1076
+ }, "characterClass");
1077
+ while (at < chars.length) {
1078
+ const c = chars[at++];
1079
+ if (c === "\\") {
1080
+ const next = chars[at++];
1081
+ if (next === void 0)
1082
+ out += c;
1083
+ else
1084
+ out += (next.codePointAt(0) ?? 0) < 128 ? `${c}${next}` : literal2(next);
1085
+ } else if (c === '"') {
1086
+ const end = chars.indexOf('"', at);
1087
+ if (end < 0) {
1088
+ out += chars.slice(at - 1).join("");
1089
+ break;
1090
+ }
1091
+ const folded = fold(chars.slice(at, end).join(""));
1092
+ if (folded.includes('"'))
1093
+ unfoldable(span, `"${chars.slice(at, end).join("")}"`);
1094
+ out += `"${folded}"`;
1095
+ at = end + 1;
1096
+ } else if (c === "[")
1097
+ characterClass();
1098
+ else
1099
+ out += literal2(c);
1100
+ }
1101
+ return out;
1102
+ }, "foldRegex");
1103
+
1104
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/search/trigrams.js
1105
+ var trigrams = /* @__PURE__ */ __name((term) => {
1106
+ const padded = ` ${term} `;
1107
+ const pieces = /* @__PURE__ */ new Set();
1108
+ for (let at = 0; at + 3 <= padded.length; at++)
1109
+ pieces.add(padded.slice(at, at + 3));
1110
+ return [...pieces];
1111
+ }, "trigrams");
1112
+
1113
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/resolve.js
1114
+ var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
1115
+ var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase().replaceAll("\u0451", "\u0435"), "foldName");
1116
+ var pickChat = /* @__PURE__ */ __name((reference, chats) => {
1117
+ const wanted = foldName(reference.trim());
1118
+ const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
1119
+ if (matches.length === 1 && matches[0])
1120
+ return matches[0];
1121
+ if (matches.length === 0)
1122
+ throw new CliError("not_found", `no chat matches "${reference}"`);
1123
+ throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
1124
+ }, "pickChat");
1125
+ var pickPerson = /* @__PURE__ */ __name((reference, people) => {
1126
+ const trimmed = reference.trim();
1127
+ const contact = contactReferenceOf(trimmed, people.provider);
1128
+ if (contact !== void 0) {
1129
+ const named = people.get(contact);
1130
+ if (named)
1131
+ return named;
1132
+ throw new CliError("not_found", `no person ${contact} in what this account has seen`);
1133
+ }
1134
+ const known = people.get(trimmed);
1135
+ if (known)
1136
+ return known;
1137
+ if (isId(trimmed))
1138
+ throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
1139
+ const wanted = foldName(trimmed.replace(/^@/, ""));
1140
+ const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
1141
+ const exact = everyone.filter((person) => namesOf(person).includes(wanted));
1142
+ const containing = everyone.filter((person) => namesOf(person).some((one) => one.includes(wanted)));
1143
+ if (exact.length === 1 && exact[0])
1144
+ return exact[0];
1145
+ if (containing.length === 1 && containing[0])
1146
+ return containing[0];
1147
+ if (containing.length === 0)
1148
+ throw new CliError("not_found", `nobody matches "${reference}"`);
1149
+ const matches = exact.length > 0 ? [...exact, ...containing.filter((person) => !exact.includes(person))] : containing;
1150
+ throw ambiguous(reference, "people", matches.map(({ id, name, username }) => ({ id, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
1151
+ }, "pickPerson");
1152
+ var namesOf = /* @__PURE__ */ __name((person, byAddress = false) => [person.alias, person.name, person.username, byAddress ? person.id : void 0].filter(isPresent).map(foldName), "namesOf");
1153
+ var chatNamesOf = /* @__PURE__ */ __name((chat) => [chat.title, chat.providerMetadata?.username].filter((one) => typeof one === "string" && one !== "").map(foldName), "chatNamesOf");
1154
+ var namePattern = /* @__PURE__ */ __name((pattern) => {
1155
+ const automaton = compileAutomaton(wildcardPattern(foldName(pattern.trim().replace(/^@/, ""))));
1156
+ return (names) => names.some((one) => automaton.test(one));
1157
+ }, "namePattern");
1158
+ var peopleMatching = /* @__PURE__ */ __name((pattern, people, { byAddress = false } = {}) => {
1159
+ const fits = namePattern(pattern);
1160
+ return people.filter((person) => fits(namesOf(person, byAddress)));
1161
+ }, "peopleMatching");
1162
+ var chatsMatching = /* @__PURE__ */ __name((pattern, chats) => {
1163
+ const fits = namePattern(pattern);
1164
+ return chats.filter((chat) => fits(chatNamesOf(chat)));
1165
+ }, "chatsMatching");
1166
+ var nearest = /* @__PURE__ */ __name((pattern, items, names, most = 5) => {
1167
+ const pieces = /* @__PURE__ */ __name((text2) => foldName(text2).split(/\s+/u).flatMap(trigrams), "pieces");
1168
+ const wanted = new Set(pieces(pattern.replace(/\\(.)/gu, "$1").replace(/[*?@]/gu, " ").trim()));
1169
+ if (wanted.size === 0)
1170
+ return [];
1171
+ return items.map((item) => ({
1172
+ item,
1173
+ score: names(item).flatMap(pieces).filter((piece) => wanted.has(piece)).length
1174
+ })).filter(({ score }) => score > 1).toSorted((a, b) => b.score - a.score).slice(0, most).map(({ item }) => item);
1175
+ }, "nearest");
1176
+ var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label2) => {
1177
+ const width = Math.max(...candidates.map(({ id }) => id.length));
1178
+ const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label2(candidate)}`).join("\n");
1179
+ return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
1180
+ ${lines}`, { candidates });
1181
+ }, "ambiguous");
1182
+ var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
1183
+
1184
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/display-names.js
1185
+ var QUOTES = [
1186
+ ['"', '"'],
1187
+ ["'", "'"],
1188
+ ["\xAB", "\xBB"],
1189
+ ["\u201C", "\u201D"],
1190
+ ["\u201E", "\u201C"],
1191
+ ["\u2018", "\u2019"],
1192
+ ["`", "`"]
1193
+ ];
1194
+ var READABLE = /[\p{L}\p{N}]/u;
1195
+ var PLACEHOLDERS = /* @__PURE__ */ new Set(["null", "undefined", "none", "\u0431\u0435\u0437 \u0438\u043C\u0435\u043D\u0438", "deleted account", "\u0443\u0434\u0430\u043B\u0451\u043D\u043D\u044B\u0439 \u0430\u043A\u043A\u0430\u0443\u043D\u0442"]);
1196
+ var unquoted = /* @__PURE__ */ __name((text2) => {
1197
+ let at = text2.replace(/\s+/gu, " ").trim();
1198
+ for (; ; ) {
1199
+ const pair = QUOTES.find(([open, close]) => at.length >= 2 && at.startsWith(open) && at.endsWith(close));
1200
+ if (pair === void 0)
1201
+ return at;
1202
+ at = at.slice(pair[0].length, at.length - pair[1].length).trim();
1203
+ }
1204
+ }, "unquoted");
1205
+ var given = /* @__PURE__ */ __name((value) => {
1206
+ const text2 = typeof value === "string" ? value.trim() : "";
1207
+ return text2 === "" ? void 0 : text2;
1208
+ }, "given");
1209
+ var displayName = /* @__PURE__ */ __name((name, fallbacks = {}) => {
1210
+ const unwrapped = typeof name === "string" ? unquoted(name) : "";
1211
+ const cleaned = PLACEHOLDERS.has(unwrapped.toLowerCase()) ? "" : unwrapped;
1212
+ if (READABLE.test(cleaned))
1213
+ return cleaned;
1214
+ const borrowed = fallbacks.name === void 0 || fallbacks.name === null ? null : displayName(fallbacks.name);
1215
+ if (borrowed !== null && READABLE.test(borrowed) && !borrowed.startsWith("@"))
1216
+ return borrowed;
1217
+ const username = given(fallbacks.username);
1218
+ return (username === void 0 ? void 0 : username.startsWith("@") ? username : `@${username}`) ?? given(fallbacks.phone) ?? given(fallbacks.email) ?? (cleaned === "" ? null : cleaned);
1219
+ }, "displayName");
1220
+ var present = /* @__PURE__ */ __name((value) => typeof value === "string" && value !== "" ? value : null, "present");
1221
+ var takeFallbacks = /* @__PURE__ */ __name((into, identity) => {
1222
+ const named = displayName(identity.name);
1223
+ if (into.name === null && isReadable(named) && !named?.startsWith("@"))
1224
+ into.name = named;
1225
+ into.username ??= present(identity.username);
1226
+ into.phone ??= present(identity.phone) ?? (identity.provider === "phone" ? identity.id : null);
1227
+ into.email ??= present(identity.email) ?? (identity.provider === "email" ? identity.id : null);
1228
+ return into;
1229
+ }, "takeFallbacks");
1230
+ var noFallbacks = /* @__PURE__ */ __name(() => ({ name: null, username: null, phone: null, email: null }), "noFallbacks");
1231
+ var nameKey = /* @__PURE__ */ __name((name) => {
1232
+ if (typeof name !== "string")
1233
+ return null;
1234
+ const unwrapped = unquoted(name);
1235
+ if (PLACEHOLDERS.has(unwrapped.toLowerCase()))
1236
+ return null;
1237
+ const words = foldName(unwrapped).split(/[^\p{L}\p{N}]+/u).filter((word) => word !== "");
1238
+ return words.length === 0 ? null : words.sort().join(" ");
1239
+ }, "nameKey");
1240
+ var isReadable = /* @__PURE__ */ __name((shown) => shown !== null && READABLE.test(shown), "isReadable");
1241
+
1242
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/counters.js
1243
+ var COUNTER_FIELDS = ["views", "reactions", "comments"];
1244
+ var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
1245
+ var counterValue = /* @__PURE__ */ __name((message, field) => {
1246
+ const value = field === "reactions" ? message.reactions?.total : message.providerMetadata?.[field];
1247
+ return validCounter(value) ? value : null;
1248
+ }, "counterValue");
1249
+ var counterObservationTime = /* @__PURE__ */ __name((observation, now) => {
1250
+ const at = Date.parse(observation.observedAt);
1251
+ if (!validCounter(observation.value) || !Number.isSafeInteger(at) || at < 0 || at > now || !["remote_fetch", "remote_update"].includes(observation.source))
1252
+ throw new CliError("validation_error", "counter observation needs a valid value, source and nonfuture observation time");
1253
+ if (observation.reactions && (!validCounter(observation.reactions.total) || observation.reactions.total !== observation.value))
1254
+ throw new CliError("validation_error", "reaction observation payload and total disagree");
1255
+ return at;
1256
+ }, "counterObservationTime");
1257
+ var observedCounters = /* @__PURE__ */ __name((message, observedAt, fields, source = "remote_fetch") => {
1258
+ const observations = {};
1259
+ for (const field of fields) {
1260
+ const value = counterValue(message, field);
1261
+ if (value !== null)
1262
+ observations[field] = {
1263
+ value,
1264
+ observedAt,
1265
+ source,
1266
+ ...field === "reactions" && message.reactions ? { reactions: message.reactions } : {}
1267
+ };
1268
+ }
1269
+ return { ...message, counterObservations: observations };
1270
+ }, "observedCounters");
1271
+ var counterFreshness = /* @__PURE__ */ __name((states) => {
1272
+ if (!states.length || states.every((one) => one.freshness === "unknown"))
1273
+ return "unknown";
1274
+ if (states.some((one) => one.freshness === "unknown"))
1275
+ return "partial";
1276
+ return states.some((one) => one.freshness === "stale") ? "stale" : "fresh";
1277
+ }, "counterFreshness");
1278
+
1279
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
1280
+ var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
1281
+ var AUTHOR_MEASURES = [
1282
+ "messages",
1283
+ "words",
1284
+ "reactions",
1285
+ "replies",
1286
+ "answers",
1287
+ "answer-time",
1288
+ "threads",
1289
+ "active-days"
1290
+ ];
1291
+ var CONTEXT = /* @__PURE__ */ new Set([
1292
+ "replies",
1293
+ "replies-from-others",
1294
+ "replies-from-others-per-message",
1295
+ "thread-size",
1296
+ "threads",
1297
+ "answers",
1298
+ "answer-time"
1299
+ ]);
1300
+ var needsRankingContext = /* @__PURE__ */ __name((options) => options.components.some((name) => CONTEXT.has(name)), "needsRankingContext");
1301
+ var presets = {
1302
+ helpful: { answers: 0.5, "replies-from-others": 0.25, reactions: 0.25 },
1303
+ active: { "active-days": 0.6, messages: 0.4 },
1304
+ engaging: { "reactions-per-message": 0.5, "replies-from-others-per-message": 0.5 }
1305
+ };
1306
+ function invalid(message) {
1307
+ throw new CliError("validation_error", message, { reason: "ranking.invalid" });
1308
+ }
1309
+ __name(invalid, "invalid");
1310
+ var rankingOptions = /* @__PURE__ */ __name((target, input) => {
1311
+ const measures = target === "messages" ? MESSAGE_MEASURES : AUTHOR_MEASURES;
1312
+ const { measure, score, weights: given2, minMessages } = input;
1313
+ const messageKind = input.messageKind ?? "all";
1314
+ if (!["all", "posts", "comments"].includes(messageKind))
1315
+ invalid("message_kind takes all, posts or comments");
1316
+ if (target === "messages" && minMessages !== void 0)
1317
+ invalid("min_messages applies to stats contacts top");
1318
+ if (minMessages !== void 0 && (!Number.isSafeInteger(minMessages) || minMessages < 1))
1319
+ invalid("min_messages takes a positive integer");
1320
+ if (measure !== void 0 && !measures.includes(measure))
1321
+ invalid(`--measure takes ${measures.join(", ")}`);
1322
+ if (measure !== void 0 && (score !== void 0 || given2 !== void 0))
1323
+ invalid("--measure cannot be combined with --score or --weights");
1324
+ if (score !== void 0 && !["helpful", "active", "engaging"].includes(score))
1325
+ invalid("--score takes helpful, active or engaging");
1326
+ if (target === "messages" && score !== void 0 && score !== "engaging")
1327
+ invalid("helpful and active scores apply to authors only");
1328
+ const scoring = score !== void 0 || given2 !== void 0;
1329
+ const preset = score;
1330
+ let weights = null;
1331
+ if (scoring) {
1332
+ let raw = given2 !== void 0 ? given2 : target === "messages" ? { reactions: 0.5, "replies-from-others": 0.5 } : presets[preset];
1333
+ if (typeof raw === "string") {
1334
+ try {
1335
+ raw = JSON.parse(raw);
1336
+ } catch {
1337
+ invalid("--weights takes a JSON object of component weights");
1338
+ }
1339
+ }
1340
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
1341
+ invalid("--weights takes a JSON object of component weights");
1342
+ const allowed = target === "messages" ? [...MESSAGE_MEASURES, "replies-from-others"] : [
1343
+ ...AUTHOR_MEASURES.filter((name) => name !== "answer-time"),
1344
+ "replies-from-others",
1345
+ "reactions-per-message",
1346
+ "replies-from-others-per-message"
1347
+ ];
1348
+ const entries = Object.entries(raw);
1349
+ for (const [name, weight] of entries) {
1350
+ if (!allowed.includes(name))
1351
+ invalid(`unknown ${target} score component: ${name}`);
1352
+ if (typeof weight !== "number" || !Number.isFinite(weight) || weight < 0)
1353
+ invalid(`weight for ${name} must be a finite nonnegative number`);
1354
+ }
1355
+ if (!entries.some(([, weight]) => weight > 0))
1356
+ invalid("--weights needs at least one positive weight");
1357
+ weights = Object.fromEntries(entries);
1358
+ }
1359
+ const selected = measure ?? (target === "messages" ? "reactions" : "messages");
1360
+ return {
1361
+ target,
1362
+ messageKind,
1363
+ minMessages: minMessages ?? (target === "contacts" && score === "engaging" ? 5 : 1),
1364
+ measure: scoring ? "score" : selected,
1365
+ order: !scoring && selected === "answer-time" ? "ascending" : "descending",
1366
+ weights,
1367
+ preset: scoring ? preset ?? "custom" : null,
1368
+ components: weights === null ? [selected] : Object.entries(weights).filter(([, weight]) => weight > 0).map(([name]) => name)
1369
+ };
1370
+ }, "rankingOptions");
1371
+ var rankingScore = /* @__PURE__ */ __name((raw, maxima, weights) => {
1372
+ const entries = Object.entries(weights).filter(([, weight]) => weight > 0);
1373
+ const scale = Math.max(...entries.map(([, weight]) => weight));
1374
+ const denominator = entries.reduce((sum2, [, weight]) => sum2 + weight / scale, 0);
1375
+ if (!Number.isFinite(scale) || scale <= 0 || !Number.isFinite(denominator) || denominator <= 0)
1376
+ return null;
1377
+ const normalized = {};
1378
+ const contributions = {};
1379
+ let sum = 0;
1380
+ for (const [name, weight] of entries) {
1381
+ const value = raw[name];
1382
+ const maximum = maxima[name];
1383
+ if (value == null || !Number.isFinite(value) || value < 0 || maximum === void 0 || !Number.isFinite(maximum) || maximum < value)
1384
+ return null;
1385
+ const part = maximum === 0 ? 0 : value / maximum;
1386
+ normalized[name] = part;
1387
+ contributions[name] = 100 * part * (weight / scale) / denominator;
1388
+ sum += contributions[name];
1389
+ }
1390
+ return { score: Math.min(100, sum), normalized, contributions };
1391
+ }, "rankingScore");
1392
+ var RANKING_TOKENIZER_VERSION = 1;
1393
+ var withoutUrls = /* @__PURE__ */ __name((text2) => text2.replace(/\S+/gu, (token) => {
1394
+ for (let offset = 0; ; ) {
1395
+ const marker = token.indexOf("://", offset);
1396
+ if (marker < 0)
1397
+ break;
1398
+ let start = marker;
1399
+ while (start > 0 && /[a-z0-9+.-]/iu.test(token[start - 1]))
1400
+ start--;
1401
+ if (/^[a-z][a-z0-9+.-]*$/iu.test(token.slice(start, marker)) && (start === 0 || !/\w/u.test(token[start - 1])))
1402
+ return token.slice(0, start);
1403
+ offset = marker + 3;
1404
+ }
1405
+ const folded = token.toLowerCase();
1406
+ for (let offset = 0; ; ) {
1407
+ const start = folded.indexOf("www.", offset);
1408
+ if (start < 0)
1409
+ break;
1410
+ if (start === 0 || !/\w/u.test(token[start - 1]))
1411
+ return token.slice(0, start);
1412
+ offset = start + 4;
1413
+ }
1414
+ return token;
1415
+ }), "withoutUrls");
1416
+ var rankingWords = /* @__PURE__ */ __name((text2) => withoutUrls(text2).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
1417
+ var rankingQuestion = /* @__PURE__ */ __name((text2) => withoutUrls(text2).includes("?"), "rankingQuestion");
1418
+
1419
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/records.js
1420
+ import { createHash } from "node:crypto";
1421
+
1422
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
1423
+ var PHONE_PLANS = [
1424
+ {
1425
+ country: "us",
1426
+ code: "1",
1427
+ trunk: "1",
1428
+ lengths: [10],
1429
+ valid: "[2-9]\\d{9}|3\\d{6}",
1430
+ mobile: null
1431
+ },
1432
+ {
1433
+ country: "ca",
1434
+ code: "1",
1435
+ trunk: "1",
1436
+ lengths: [7, 10],
1437
+ valid: "[2-9]\\d{9}|3\\d{6}",
1438
+ mobile: null
1439
+ },
1440
+ {
1441
+ country: "gb",
1442
+ code: "44",
1443
+ trunk: "0|180020",
1444
+ lengths: [7, 9, 10],
1445
+ valid: "[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",
1446
+ mobile: "7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}"
1447
+ },
1448
+ {
1449
+ country: "ie",
1450
+ code: "353",
1451
+ trunk: "0",
1452
+ lengths: [7, 8, 9, 10],
1453
+ valid: "(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",
1454
+ mobile: "8(?:22|[35-9]\\d)\\d{6}"
1455
+ },
1456
+ {
1457
+ country: "es",
1458
+ code: "34",
1459
+ trunk: "",
1460
+ lengths: [9],
1461
+ valid: "(?:400|[5-9]\\d\\d)\\d{6}",
1462
+ mobile: "96906(?:09|10)\\d\\d|(?:590(?:10[0-2]|600)|97390\\d)\\d{3}|(?:6\\d|7[1-48])\\d{7}"
1463
+ },
1464
+ {
1465
+ country: "pt",
1466
+ code: "351",
1467
+ trunk: "",
1468
+ lengths: [9],
1469
+ valid: "1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",
1470
+ mobile: "6(?:[06]92(?:30|9\\d)|[35]92(?:[049]\\d|3[034]))\\d{3}|(?:(?:16|6[0356])93|9(?:[1-36]\\d\\d|480))\\d{5}"
1471
+ },
1472
+ {
1473
+ country: "fr",
1474
+ code: "33",
1475
+ trunk: "0",
1476
+ lengths: [9],
1477
+ valid: "[1-9]\\d{8}",
1478
+ mobile: "(?:6(?:[0-24-8]\\d|3[0-8]|9[589])|7[3-9]\\d)\\d{6}"
1479
+ },
1480
+ {
1481
+ country: "be",
1482
+ code: "32",
1483
+ trunk: "0",
1484
+ lengths: [8, 9],
1485
+ valid: "4\\d{8}|[1-9]\\d{7}",
1486
+ mobile: "4[5-9]\\d{7}"
1487
+ },
1488
+ {
1489
+ country: "nl",
1490
+ code: "31",
1491
+ trunk: "0",
1492
+ lengths: [5, 6, 7, 8, 9, 10, 11],
1493
+ valid: "(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",
1494
+ mobile: "(?:6[1-58]|970\\d)\\d{7}"
1495
+ },
1496
+ {
1497
+ country: "lu",
1498
+ code: "352",
1499
+ trunk: "",
1500
+ lengths: [4, 5, 6, 7, 8, 9, 10, 11],
1501
+ valid: "35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",
1502
+ mobile: "6(?:[26][18]|5[1568]|7[189]|81|9[128])\\d{6}"
1503
+ },
1504
+ {
1505
+ country: "de",
1506
+ code: "49",
1507
+ trunk: "0",
1508
+ lengths: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1509
+ valid: "[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",
1510
+ mobile: "1(?:6[023]|7\\d)\\d{7,8}|15(?:[0-25-9]\\d\\d|3(?:10|33))\\d{6}"
1511
+ },
1512
+ {
1513
+ country: "at",
1514
+ code: "43",
1515
+ trunk: "0",
1516
+ lengths: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
1517
+ valid: "1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",
1518
+ mobile: "6(?:485|(?:5[0-3579]|6[013-9]|[7-9]\\d)\\d)\\d{3,9}"
1519
+ },
1520
+ {
1521
+ country: "ch",
1522
+ code: "41",
1523
+ trunk: "0",
1524
+ lengths: [9, 12],
1525
+ valid: "8\\d{11}|[2-9]\\d{8}",
1526
+ mobile: "(?:6[89]|7[235-9])\\d{7}"
1527
+ },
1528
+ {
1529
+ country: "li",
1530
+ code: "423",
1531
+ trunk: "0",
1532
+ lengths: [7, 9],
1533
+ valid: "[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",
1534
+ mobile: "(?:6(?:(?:4[5-9]|5\\d)\\d|6(?:[024-68]\\d|1[01]|3[7-9]|7[02]))\\d|7(?:[37-9]\\d|42|56))\\d{4}"
1535
+ },
1536
+ {
1537
+ country: "it",
1538
+ code: "39",
1539
+ trunk: "",
1540
+ lengths: [6, 7, 8, 9, 10, 11, 12],
1541
+ valid: "0\\d{5,11}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",
1542
+ mobile: "3[2-9]\\d{7,8}|(?:31|43)\\d{8}"
1543
+ },
1544
+ {
1545
+ country: "mt",
1546
+ code: "356",
1547
+ trunk: "",
1548
+ lengths: [8],
1549
+ valid: "3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",
1550
+ mobile: "(?:7(?:210|[79]\\d\\d)|9(?:[29]\\d\\d|69[67]|8(?:1[1-3]|89|97)))\\d{4}"
1551
+ },
1552
+ {
1553
+ country: "si",
1554
+ code: "386",
1555
+ trunk: "0",
1556
+ lengths: [5, 6, 7, 8],
1557
+ valid: "[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",
1558
+ mobile: "65(?:[178]\\d|5[56]|6[01])\\d{4}|(?:[37][01]|4[013]|51|6[489])\\d{6}"
1559
+ },
1560
+ {
1561
+ country: "hr",
1562
+ code: "385",
1563
+ trunk: "0",
1564
+ lengths: [7, 8, 9],
1565
+ valid: "[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",
1566
+ mobile: "9(?:(?:0[1-9]|[12589]\\d)\\d\\d|7(?:[0679]\\d\\d|5(?:[01]\\d|44|55|77|9[5-79])))\\d{4}|98\\d{6}"
1567
+ },
1568
+ {
1569
+ country: "ba",
1570
+ code: "387",
1571
+ trunk: "0",
1572
+ lengths: [8, 9],
1573
+ valid: "6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",
1574
+ mobile: "6040\\d{5}|6(?:03|[1-356]|44|7\\d)\\d{6}"
1575
+ },
1576
+ {
1577
+ country: "rs",
1578
+ code: "381",
1579
+ trunk: "0",
1580
+ lengths: [6, 7, 8, 9, 10, 11, 12],
1581
+ valid: "38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",
1582
+ mobile: "6(?:[0-689]|7\\d)\\d{6,7}"
1583
+ },
1584
+ {
1585
+ country: "me",
1586
+ code: "382",
1587
+ trunk: "0",
1588
+ lengths: [8, 9],
1589
+ valid: "(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",
1590
+ mobile: "6(?:[07-9]\\d|3[024]|6[0-25])\\d{5}"
1591
+ },
1592
+ {
1593
+ country: "mk",
1594
+ code: "389",
1595
+ trunk: "0",
1596
+ lengths: [8],
1597
+ valid: "[2-578]\\d{7}",
1598
+ mobile: "7(?:3555|(?:474|9[019]7)7)\\d{3}|7(?:[0-25-8]\\d\\d|3(?:[1-478]\\d|6[01])|4(?:2\\d|60|7[01578])|9(?:[2-4]\\d|5[01]|7[015]))\\d{4}"
1599
+ },
1600
+ {
1601
+ country: "al",
1602
+ code: "355",
1603
+ trunk: "0",
1604
+ lengths: [6, 7, 8, 9],
1605
+ valid: "(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",
1606
+ mobile: "6(?:[78][2-9]|9\\d)\\d{6}"
1607
+ },
1608
+ {
1609
+ country: "gr",
1610
+ code: "30",
1611
+ trunk: "",
1612
+ lengths: [10, 11, 12],
1613
+ valid: "5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",
1614
+ mobile: "68[57-9]\\d{7}|(?:69|94)\\d{8}"
1615
+ },
1616
+ {
1617
+ country: "cy",
1618
+ code: "357",
1619
+ trunk: "",
1620
+ lengths: [8],
1621
+ valid: "(?:[279]\\d|[58]0)\\d{6}",
1622
+ mobile: "9(?:10|[4-79]\\d)\\d{5}"
1623
+ },
1624
+ {
1625
+ country: "bg",
1626
+ code: "359",
1627
+ trunk: "0",
1628
+ lengths: [6, 7, 8, 9, 12],
1629
+ valid: "00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",
1630
+ mobile: "(?:43[07-9]|99[69]\\d)\\d{5}|(?:8[7-9]|98)\\d{7}"
1631
+ },
1632
+ {
1633
+ country: "ro",
1634
+ code: "40",
1635
+ trunk: "0",
1636
+ lengths: [6, 9],
1637
+ valid: "(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",
1638
+ mobile: "(?:630|702)0\\d{5}|(?:6(?:00|2\\d)|7(?:0[013-9]|1[0-3]|[2-7]\\d|8[03-8]|9[0-39]))\\d{6}"
1639
+ },
1640
+ {
1641
+ country: "md",
1642
+ code: "373",
1643
+ trunk: "0",
1644
+ lengths: [8],
1645
+ valid: "(?:[235-7]\\d|[89]0)\\d{6}",
1646
+ mobile: "562\\d{5}|(?:6\\d|7[16-9])\\d{6}"
1647
+ },
1648
+ {
1649
+ country: "hu",
1650
+ code: "36",
1651
+ trunk: "06",
1652
+ lengths: [8, 9],
1653
+ valid: "[235-7]\\d{8}|[1-9]\\d{7}",
1654
+ mobile: "(?:[257]0|3[01])\\d{7}"
1655
+ },
1656
+ {
1657
+ country: "sk",
1658
+ code: "421",
1659
+ trunk: "0",
1660
+ lengths: [6, 7, 9],
1661
+ valid: "[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",
1662
+ mobile: "909[1-9]\\d{5}|9(?:0[1-8]|1[0-24-9]|4[03-57-9]|5\\d)\\d{6}"
1663
+ },
1664
+ {
1665
+ country: "cz",
1666
+ code: "420",
1667
+ trunk: "",
1668
+ lengths: [9, 10, 11, 12],
1669
+ valid: "(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",
1670
+ mobile: "7060\\d{5}|(?:60[1-8]|7(?:0[2-5]|19|[2379]\\d))\\d{6}"
1671
+ },
1672
+ {
1673
+ country: "pl",
1674
+ code: "48",
1675
+ trunk: "",
1676
+ lengths: [6, 7, 8, 9, 10],
1677
+ valid: "(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",
1678
+ mobile: "21(?:1[013-5]|2\\d|3[1-9])\\d{5}|(?:45|5[0137]|6[069]|7[2389]|88)\\d{7}"
1679
+ },
1680
+ {
1681
+ country: "lt",
1682
+ code: "370",
1683
+ trunk: "[08]",
1684
+ lengths: [8],
1685
+ valid: "(?:[3469]\\d|52|[78]0)\\d{6}",
1686
+ mobile: "6\\d{7}"
1687
+ },
1688
+ {
1689
+ country: "lv",
1690
+ code: "371",
1691
+ trunk: "",
1692
+ lengths: [8],
1693
+ valid: "(?:[268]\\d|78|90)\\d{6}",
1694
+ mobile: "2333[0-8]\\d{3}|2(?:[0-24-9]\\d\\d|3(?:0[07]|[14-9]\\d|2[02-9]|3[0-24-9]))\\d{4}"
1695
+ },
1696
+ {
1697
+ country: "ee",
1698
+ code: "372",
1699
+ trunk: "",
1700
+ lengths: [7, 8, 10],
1701
+ valid: "8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",
1702
+ mobile: "(?:5\\d{5}|8(?:1(?:0(?:0(?:00|[178]\\d)|[3-9]\\d\\d)|(?:1(?:0[2-6]|1\\d)|[2-79]\\d\\d)\\d)|2(?:0(?:0(?:00|4\\d)|[1-7]\\d\\d)|(?:(?:[124-69]\\d|3[5-9])\\d|7(?:[0-79]\\d|8[013-9])|8(?:[2-6]\\d|7[01]))\\d)|[349]\\d{4}))\\d\\d|5(?:(?:[02]\\d|5[0-478])\\d|1(?:[0-8]\\d|95)|6(?:4[0-4]|5[1-589]))\\d{3}"
1703
+ },
1704
+ {
1705
+ country: "fi",
1706
+ code: "358",
1707
+ trunk: "0",
1708
+ lengths: [5, 6, 7, 8, 9, 10, 11, 12],
1709
+ valid: "[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",
1710
+ mobile: "4946\\d{2,6}|(?:4[0-8]|50)\\d{4,8}"
1711
+ },
1712
+ {
1713
+ country: "se",
1714
+ code: "46",
1715
+ trunk: "0",
1716
+ lengths: [6, 7, 8, 9, 10, 12],
1717
+ valid: "(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",
1718
+ mobile: "7[023689]\\d{7}"
1719
+ },
1720
+ {
1721
+ country: "no",
1722
+ code: "47",
1723
+ trunk: "",
1724
+ lengths: [5, 8],
1725
+ valid: "(?:0|[2-9]\\d{3})\\d{4}",
1726
+ mobile: "45(?:[0-24-9]\\d|3[0-57-9])\\d{4}|(?:4[016-8]|9\\d)\\d{6}"
1727
+ },
1728
+ {
1729
+ country: "dk",
1730
+ code: "45",
1731
+ trunk: "",
1732
+ lengths: [8],
1733
+ valid: "[2-9]\\d{7}",
1734
+ mobile: "(?:2[6-8]|37|6[78]|96)\\d{6}|(?:2[0-59]|3[0-689]|[457]\\d|6[0-69]|8[126-9]|9[1-47-9])[1-9]\\d{5}"
1735
+ },
1736
+ {
1737
+ country: "is",
1738
+ code: "354",
1739
+ trunk: "",
1740
+ lengths: [7, 9],
1741
+ valid: "(?:38\\d|[4-9])\\d{6}",
1742
+ mobile: "(?:38[589]\\d\\d|6(?:1[1-8]|2[0-6]|3[026-9]|4[014679]|5[0159]|6[0-69]|70|8[06-8]|9\\d)|7(?:5[057]|[6-9]\\d)|8(?:2[0-59]|[3-69]\\d|8[238]))\\d{4}"
1743
+ },
1744
+ {
1745
+ country: "ua",
1746
+ code: "380",
1747
+ trunk: "0",
1748
+ lengths: [9, 10],
1749
+ valid: "[89]\\d{9}|[3-9]\\d{8}",
1750
+ mobile: "790\\d{6}|(?:39|50|6[36-8]|7[1-357]|9[1-9])\\d{7}"
1751
+ },
1752
+ {
1753
+ country: "by",
1754
+ code: "375",
1755
+ trunk: "0|80?",
1756
+ lengths: [6, 7, 8, 9, 10, 11],
1757
+ valid: "(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",
1758
+ mobile: "(?:2(?:5[5-79]|9[1-9])|(?:33|44)\\d)\\d{6}"
1759
+ },
1760
+ {
1761
+ country: "ru",
1762
+ code: "7",
1763
+ trunk: "8",
1764
+ lengths: [10, 14],
1765
+ valid: "8\\d{13}|[347-9]\\d{9}",
1766
+ mobile: "9\\d{9}"
1767
+ },
1768
+ {
1769
+ country: "kz",
1770
+ code: "7",
1771
+ trunk: "8",
1772
+ lengths: [10, 14],
1773
+ valid: "8\\d{13}|[78]\\d{9}",
1774
+ mobile: "7(?:0[0-25-8]|47|6[0-4]|7[15-8]|85)\\d{7}"
1775
+ },
1776
+ {
1777
+ country: "ge",
1778
+ code: "995",
1779
+ trunk: "0",
1780
+ lengths: [9],
1781
+ valid: "(?:[3-57]\\d\\d|800)\\d{6}",
1782
+ mobile: "5(?:(?:(?:0555|1(?:[17]77|555))[5-9]|757(?:7[7-9]|8[01]))\\d|22252[0-4])\\d\\d|5(?:0(?:0(?:1[09]|70)|505)|1(?:0[01]0|1(?:07|33|51))|2(?:0[02]0|2[25]2)|3(?:0[03]0|3[35]3)|4(?:0[04]0|411)|5222|9000)[0-4]\\d{3}|(?:5(?:0(?:0(?:0\\d|1[12]|2[02]|3[0-6]|4[04]|5[05]|77|88|9[09])|(?:[14]\\d|77)\\d|22[02])|1(?:1(?:[03][01]|[124]\\d|5[02-6]|7[0-6])|4\\d\\d)|2(?:228|555)|3555|4(?:4(?:[02-9]\\d|14)|555)|5(?:[0157-9]\\d\\d|200|333|4(?:44|55))|6[89]\\d\\d|7(?:(?:[0147-9]\\d|22)\\d|5(?:00|[57]5))|8(?:0(?:[018]\\d|2[0-4])|5(?:55|8[89])|8(?:55|88))|9(?:090|[1-35-9]\\d\\d))|790\\d\\d)\\d{4}"
1783
+ },
1784
+ {
1785
+ country: "am",
1786
+ code: "374",
1787
+ trunk: "0",
1788
+ lengths: [8],
1789
+ valid: "(?:[1-489]\\d|55|60|77)\\d{6}",
1790
+ mobile: "(?:33|4[1349]|55|77|88|9[13-9])\\d{6}"
1791
+ },
1792
+ {
1793
+ country: "tr",
1794
+ code: "90",
1795
+ trunk: "0",
1796
+ lengths: [7, 10, 12, 13],
1797
+ valid: "4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",
1798
+ mobile: "5(?:61(?:011|61\\d)|82[2-5]\\d\\d)\\d{4}|5(?:[03-5]\\d|1[06]|24|6[24]|7[245]|9[46])\\d{7}"
1799
+ }
1800
+ ];
1801
+
1802
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/phones.js
1803
+ var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
1804
+ var DEFAULT_PHONE_COUNTRIES = ["ru"];
1805
+ var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
1806
+ const countries = value.split(/[\s,]+/).map((one) => one.trim().toLowerCase()).filter(Boolean);
1807
+ const unknown = countries.filter((one) => !PHONE_COUNTRIES.includes(one));
1808
+ if (countries.length === 0 || unknown.length > 0)
1809
+ throw new CliError("validation_error", `phone_countries takes country codes, ${unknown.length > 0 ? `not ${unknown.join(", ")}` : "at least one"}: ` + PHONE_COUNTRIES.join(", "));
1810
+ return [...new Set(countries)];
1811
+ }, "parsePhoneCountries");
1812
+ var PLANS = new Map(PHONE_PLANS.map((plan) => [
1813
+ plan.country,
1814
+ {
1815
+ code: plan.code,
1816
+ trunk: plan.trunk ? new RegExp(`^(?:${plan.trunk})`) : null,
1817
+ lengths: new Set(plan.lengths),
1818
+ valid: new RegExp(`^(?:${plan.valid})$`),
1819
+ mobile: plan.mobile === null ? null : new RegExp(`^(?:${plan.mobile})$`)
1820
+ }
1821
+ ]));
1822
+ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
1823
+ for (const country of countries) {
1824
+ const plan = PLANS.get(country);
1825
+ if (!plan)
1826
+ continue;
1827
+ const readings = [
1828
+ ...plan.trunk?.test(digits) ? [digits.replace(plan.trunk, "")] : [],
1829
+ digits,
1830
+ ...digits.startsWith(plan.code) ? [digits.slice(plan.code.length)] : []
1831
+ ];
1832
+ for (const national of readings) {
1833
+ if (!plan.lengths.has(national.length) || !plan.valid.test(national))
1834
+ continue;
1835
+ const mobile = plan.mobile?.test(national) ?? false;
1836
+ if (anyType || mobile)
1837
+ return { value: `+${plan.code}${national}`, national, mobile };
1838
+ }
1839
+ }
1840
+ return void 0;
1841
+ }, "nationalPhone");
1842
+ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE_COUNTRIES } = {}) => {
1843
+ const text2 = typed.trim();
1844
+ if (!/^\+?[\d\s().\-–]+$/.test(text2))
1845
+ return void 0;
1846
+ const digits = text2.replace(/\(0\)/, "").replace(/\D/g, "").replace(/^00/, "");
1847
+ if (digits.length < 7 || digits.length > 15)
1848
+ return void 0;
1849
+ const national = nationalPhone(digits, phoneCountries, { anyType: true });
1850
+ const tail = national?.national ?? digits.replace(/^0+/, "");
1851
+ return {
1852
+ value: text2.startsWith("+") || /^00/.test(text2) ? `+${digits}` : national?.value ?? digits,
1853
+ national: tail.length >= 8 ? tail : null
1854
+ };
1855
+ }, "typedPhone");
1856
+ var e164Of = /* @__PURE__ */ __name((phone, region) => {
1857
+ if (/^\s*(\+|00)/.test(phone))
1858
+ return typedPhone(phone)?.value;
1859
+ if (typedPhone(phone) === void 0)
1860
+ return void 0;
1861
+ if (region === void 0)
1862
+ return null;
1863
+ const digits = phone.replace(/\(0\)/, "").replace(/\D/g, "");
1864
+ return nationalPhone(digits, [region], { anyType: true })?.value;
1865
+ }, "e164Of");
1866
+ var BARE_INTERNATIONAL_PROVIDERS = ["telegram", "max", "whatsapp"];
1867
+ var storedPhone = /* @__PURE__ */ __name((raw, provider) => {
1868
+ if (/^\s*(\+|00)/.test(raw))
1869
+ return typedPhone(raw)?.value;
1870
+ if (!BARE_INTERNATIONAL_PROVIDERS.includes(provider))
1871
+ return void 0;
1872
+ const found = /^([1-9]\d{6,14})$/.exec(raw.trim());
1873
+ return found ? `+${found[1]}` : void 0;
1874
+ }, "storedPhone");
1875
+
1876
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/records.js
1877
+ var RECORDS_SCHEMA_VERSION = 1;
1878
+ var RECORD_OPERATIONS = ["upsert", "delete"];
1879
+ var LINE_OPTIONS = ["text", "products"];
1880
+ var WORD = `^${WORD_BODY}$`;
1881
+ var MAX_ID = 512;
1882
+ var MAX_FIELDS_BYTES = 65536;
1883
+ var MAX_RELATIONS = 100;
1884
+ var DECIMAL = DECIMAL_PATTERN;
1885
+ var REF = "^[a-z]+:[^\\s]{1,500}$";
1886
+ var fieldsDef = /* @__PURE__ */ __name((type) => `fields-${type}`, "fieldsDef");
1887
+ var RECORDS_ENVELOPE_SCHEMA = {
1888
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1889
+ title: "WireCat records envelope, version 1",
1890
+ description: "Records one source sends to the store. JSONL is the same model: the first line holds schema_version, source and options, each further line one record.",
1891
+ type: "object",
1892
+ required: ["schema_version", "source", "records"],
1893
+ additionalProperties: false,
1894
+ properties: {
1895
+ schema_version: { const: RECORDS_SCHEMA_VERSION },
1896
+ source: { $ref: "#/$defs/source" },
1897
+ options: { $ref: "#/$defs/options" },
1898
+ records: { type: "array", items: { $ref: "#/$defs/record" } }
1899
+ },
1900
+ $defs: {
1901
+ source: {
1902
+ type: "object",
1903
+ required: ["provider", "account", "batch_id"],
1904
+ additionalProperties: false,
1905
+ properties: {
1906
+ provider: { type: "string", pattern: WORD, description: "The system the records come from" },
1907
+ account: { type: "string", minLength: 1, maxLength: MAX_ID, description: "The account in that system" },
1908
+ batch_id: { type: "string", minLength: 1, maxLength: MAX_ID, description: "This import, for the receipt" }
1909
+ }
1910
+ },
1911
+ options: {
1912
+ type: "object",
1913
+ additionalProperties: false,
1914
+ properties: {
1915
+ lines: {
1916
+ enum: [...LINE_OPTIONS],
1917
+ description: "products: an invoice line's product (an external id) names its product; text, the default, keeps it as data. Order lines always read it, and product_ref (a product: ref) is read on every line."
1918
+ },
1919
+ phone_region: {
1920
+ type: "string",
1921
+ pattern: "^[A-Za-z]{2}$",
1922
+ description: "The country a person's phone without + is read in. Without it such a number is an identifier only when exactly one country of the store's phone_countries setting reads it as valid"
1923
+ }
1924
+ }
1925
+ },
1926
+ record: {
1927
+ type: "object",
1928
+ required: ["key", "type", "external_id", "operation"],
1929
+ additionalProperties: false,
1930
+ properties: {
1931
+ key: { type: "string", minLength: 1, maxLength: MAX_ID },
1932
+ type: { type: "string", pattern: TYPE_PATTERN },
1933
+ external_id: { type: "string", minLength: 1, maxLength: MAX_ID },
1934
+ operation: { enum: [...RECORD_OPERATIONS] },
1935
+ fields: {
1936
+ type: "object",
1937
+ description: "What the source says, as data: never secrets, never instructions"
1938
+ },
1939
+ revision: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER },
1940
+ relations: { type: "array", maxItems: MAX_RELATIONS, items: { $ref: "#/$defs/relation" } }
1941
+ },
1942
+ allOf: RECORD_ENTITY_TYPES.map((type) => ({
1943
+ if: { properties: { type: { const: type } }, required: ["type"] },
1944
+ // biome-ignore lint/suspicious/noThenProperty: JSON Schema's own if/then keyword, never awaited.
1945
+ then: { properties: { fields: { $ref: `#/$defs/${fieldsDef(type)}` } } }
1946
+ }))
1947
+ },
1948
+ relation: {
1949
+ type: "object",
1950
+ required: ["role"],
1951
+ additionalProperties: false,
1952
+ oneOf: [{ required: ["type", "external_id"] }, { required: ["ref"] }],
1953
+ properties: {
1954
+ role: { type: "string", pattern: WORD },
1955
+ type: { type: "string", pattern: TYPE_PATTERN },
1956
+ external_id: { type: "string", minLength: 1, maxLength: MAX_ID },
1957
+ ref: { type: "string", pattern: REF, description: "A store entity, such as organization:12" },
1958
+ as: {
1959
+ type: "string",
1960
+ pattern: WORD,
1961
+ description: "On a relationship role: the part the target plays, such as decision-maker"
1962
+ },
1963
+ amount: {
1964
+ type: "string",
1965
+ pattern: DECIMAL,
1966
+ description: "A settles relation's share of the payment, a decimal in its currency"
1967
+ }
1968
+ }
1969
+ },
1970
+ ...Object.fromEntries(RECORD_ENTITY_TYPES.map((type) => [fieldsDef(type), RECORD_TYPES[type].fields]))
1971
+ }
1972
+ };
1973
+ var wordPattern = new RegExp(WORD);
1974
+ var typePattern = new RegExp(TYPE_PATTERN);
1975
+ var decimalPattern = new RegExp(DECIMAL);
1976
+ var refPattern = new RegExp(REF);
1977
+ var escapePointer = /* @__PURE__ */ __name((segment) => String(segment).replaceAll("~", "~0").replaceAll("/", "~1"), "escapePointer");
1978
+ var pointerOf = /* @__PURE__ */ __name((...segments) => segments.map((s) => `/${escapePointer(s)}`).join(""), "pointerOf");
1979
+ var idText = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" && value.length <= MAX_ID && !value.includes("\0"), "idText");
1980
+ var extraKeys = /* @__PURE__ */ __name((value, allowed) => Object.keys(value).filter((key) => !allowed.includes(key)), "extraKeys");
1981
+ var secretIn = /* @__PURE__ */ __name((value, at) => {
1982
+ if (typeof value === "string")
1983
+ return holdsCredential(value) ? at : void 0;
1984
+ if (Array.isArray(value)) {
1985
+ for (const [index, item] of value.entries()) {
1986
+ const found = secretIn(item, [...at, index]);
1987
+ if (found)
1988
+ return found;
1989
+ }
1990
+ return void 0;
1991
+ }
1992
+ if (!isObject(value))
1993
+ return void 0;
1994
+ for (const [key, item] of Object.entries(value)) {
1995
+ if (secretNamed(key))
1996
+ return [...at, key];
1997
+ const found = secretIn(item, [...at, key]);
1998
+ if (found)
1999
+ return found;
2000
+ }
2001
+ return void 0;
2002
+ }, "secretIn");
2003
+ var targetTypeOf = /* @__PURE__ */ __name((relation) => relation.ref === void 0 ? String(relation.type) : relation.ref.slice(0, relation.ref.indexOf(":")), "targetTypeOf");
2004
+ var relationErrors = /* @__PURE__ */ __name((relations, at) => {
2005
+ if (relations === void 0)
2006
+ return [];
2007
+ if (!Array.isArray(relations) || relations.length > MAX_RELATIONS)
2008
+ return [invalid2(at, `relations is a list of at most ${MAX_RELATIONS}`)];
2009
+ return relations.flatMap((relation, index) => {
2010
+ const here = [...at, index];
2011
+ if (!isObject(relation))
2012
+ return [invalid2(here, "a relation is an object")];
2013
+ const extra = extraKeys(relation, ["role", "type", "external_id", "ref", "as", "amount"]);
2014
+ if (extra.length > 0)
2015
+ return [invalid2([...here, extra[0]], "a relation holds role, type, external_id, ref, as and amount")];
2016
+ if (typeof relation.role !== "string" || !wordPattern.test(relation.role))
2017
+ return [invalid2([...here, "role"], "a role is lowercase letters, digits, - and _")];
2018
+ if (relation.ref !== void 0) {
2019
+ if (relation.type !== void 0 || relation.external_id !== void 0)
2020
+ return [invalid2([...here, "ref"], "a relation names its target by ref, or by type and external_id")];
2021
+ if (typeof relation.ref !== "string" || !refPattern.test(relation.ref))
2022
+ return [invalid2([...here, "ref"], "a ref is a store reference, such as organization:12")];
2023
+ } else {
2024
+ if (typeof relation.type !== "string" || !typePattern.test(relation.type))
2025
+ return [invalid2([...here, "type"], TYPE_RULE)];
2026
+ if (!idText(relation.external_id))
2027
+ return [invalid2([...here, "external_id"], `an external id takes 1\u2013${MAX_ID} characters`)];
2028
+ }
2029
+ if (relation.as !== void 0 && (typeof relation.as !== "string" || !wordPattern.test(relation.as)))
2030
+ return [invalid2([...here, "as"], "as is lowercase letters, digits, - and _")];
2031
+ if (relation.amount !== void 0 && (typeof relation.amount !== "string" || !decimalPattern.test(relation.amount)))
2032
+ return [invalid2([...here, "amount"], 'an amount is a decimal string, such as "13000.00"')];
2033
+ if (relation.amount !== void 0 && !AMOUNT_ROLES.includes(relation.role))
2034
+ return [invalid2([...here, "amount"], `only a ${AMOUNT_ROLES.join(" or ")} relation carries an amount`)];
2035
+ return [];
2036
+ });
2037
+ }, "relationErrors");
2038
+ var typeErrors = /* @__PURE__ */ __name((record, at) => {
2039
+ if (record.operation !== "upsert" || !isRecordType(record.type))
2040
+ return [];
2041
+ const { type } = record;
2042
+ const wrong = fieldError(RECORD_TYPES[type].fields, record.fields);
2043
+ if (wrong)
2044
+ return [invalid2([...at, "fields", ...wrong.at], wrong.message)];
2045
+ const relations = record.relations ?? [];
2046
+ for (const [index, relation] of relations.entries()) {
2047
+ const here = [...at, "relations", index];
2048
+ const role = roleOf(type, relation.role);
2049
+ if (relation.as !== void 0 && !role?.relationship)
2050
+ return [
2051
+ invalid2([...here, "as"], `${article(type)} ${type}'s ${relation.role} is not a relationship: it takes no as`)
2052
+ ];
2053
+ if (role === void 0 || role.v1)
2054
+ continue;
2055
+ const target = targetTypeOf(relation);
2056
+ if (!role.targets.includes(target))
2057
+ return [
2058
+ invalid2(here, `${article(type)} ${type}'s ${relation.role} is ${role.targets.map((one) => `${article(one)} ${one}`).join(" or ")}`)
2059
+ ];
2060
+ if (!role.many && relations.some((other, before) => before < index && other.role === relation.role))
2061
+ return [invalid2(here, `${article(type)} ${type} has one ${relation.role}`, "record.relation-ambiguous")];
2062
+ }
2063
+ for (const [name, role] of rolesOf(type))
2064
+ if (role.required && !relations.some((relation) => relation.role === name))
2065
+ return [invalid2([...at, "relations"], `${article(type)} ${type} names its ${name} in relations`)];
2066
+ return [];
2067
+ }, "typeErrors");
2068
+ var invalid2 = /* @__PURE__ */ __name((at, message, code = "record.invalid") => ({
2069
+ pointer: pointerOf(...at),
2070
+ code,
2071
+ message
2072
+ }), "invalid");
2073
+ var recordErrors = /* @__PURE__ */ __name((record, index) => {
2074
+ const at = ["records", index];
2075
+ if (!isObject(record))
2076
+ return [invalid2(at, "a record is an object")];
2077
+ const key = typeof record.key === "string" ? record.key : void 0;
2078
+ const withKey = /* @__PURE__ */ __name((errors) => errors.map((error) => key === void 0 ? error : { ...error, key }), "withKey");
2079
+ const extra = extraKeys(record, ["key", "type", "external_id", "operation", "fields", "revision", "relations"]);
2080
+ if (extra.length > 0)
2081
+ return withKey([invalid2([...at, extra[0]], `a record has no ${extra[0]}`)]);
2082
+ if (!idText(record.key))
2083
+ return [invalid2([...at, "key"], `a key takes 1\u2013${MAX_ID} characters`)];
2084
+ if (typeof record.type !== "string" || !typePattern.test(record.type))
2085
+ return withKey([invalid2([...at, "type"], TYPE_RULE, "record.type")]);
2086
+ if (!idText(record.external_id))
2087
+ return withKey([invalid2([...at, "external_id"], `an external id takes 1\u2013${MAX_ID} characters`)]);
2088
+ if (!RECORD_OPERATIONS.includes(record.operation))
2089
+ return withKey([invalid2([...at, "operation"], "an operation is upsert or delete")]);
2090
+ if (record.revision !== void 0 && (typeof record.revision !== "number" || !Number.isSafeInteger(record.revision) || record.revision < 0))
2091
+ return withKey([invalid2([...at, "revision"], "a revision is a whole number, 0 or more")]);
2092
+ if (record.operation === "upsert" && !isObject(record.fields))
2093
+ return withKey([invalid2([...at, "fields"], "an upsert carries its fields as an object")]);
2094
+ if (record.fields !== void 0 && !isObject(record.fields))
2095
+ return withKey([invalid2([...at, "fields"], "fields is an object")]);
2096
+ if (record.fields !== void 0 && Buffer.byteLength(JSON.stringify(record.fields)) > MAX_FIELDS_BYTES)
2097
+ return withKey([invalid2([...at, "fields"], `fields take at most ${MAX_FIELDS_BYTES} bytes`, "record.too-large")]);
2098
+ const secret = record.fields === void 0 ? void 0 : secretIn(record.fields, [...at, "fields"]);
2099
+ if (secret)
2100
+ return withKey([
2101
+ invalid2(secret, "a secret never goes into the store: drop this field at the source", "record.secret-field")
2102
+ ]);
2103
+ const relations = relationErrors(record.relations, [...at, "relations"]);
2104
+ return withKey(relations.length > 0 ? relations : typeErrors(record, at));
2105
+ }, "recordErrors");
2106
+ var envelopeErrors = /* @__PURE__ */ __name((envelope, account) => {
2107
+ const header = headerErrors(envelope, account, ["records"]);
2108
+ if (header.length > 0)
2109
+ return header;
2110
+ if (!Array.isArray(envelope.records))
2111
+ return [invalid2(["records"], "records is a list", "envelope.invalid")];
2112
+ return [];
2113
+ }, "envelopeErrors");
2114
+ var headerErrors = /* @__PURE__ */ __name((envelope, account, more = []) => {
2115
+ if (!isObject(envelope))
2116
+ return [invalid2([], "an envelope is an object", "envelope.invalid")];
2117
+ const extra = extraKeys(envelope, ["schema_version", "source", "options", ...more]);
2118
+ if (extra.length > 0)
2119
+ return [invalid2([extra[0]], `an envelope has no ${extra[0]}`, "envelope.invalid")];
2120
+ if (envelope.schema_version !== RECORDS_SCHEMA_VERSION)
2121
+ return [
2122
+ invalid2(["schema_version"], `this build reads schema_version ${RECORDS_SCHEMA_VERSION}, not ${JSON.stringify(envelope.schema_version)}`, "envelope.schema-version")
2123
+ ];
2124
+ const { source } = envelope;
2125
+ if (!isObject(source))
2126
+ return [invalid2(["source"], "source is an object", "envelope.invalid")];
2127
+ const sourceExtra = extraKeys(source, ["provider", "account", "batch_id"]);
2128
+ if (sourceExtra.length > 0)
2129
+ return [
2130
+ invalid2(["source", sourceExtra[0]], "source holds provider, account and batch_id", "envelope.invalid")
2131
+ ];
2132
+ if (typeof source.provider !== "string" || !wordPattern.test(source.provider))
2133
+ return [invalid2(["source", "provider"], "a provider is lowercase letters, digits, - and _", "envelope.invalid")];
2134
+ if (!idText(source.account))
2135
+ return [invalid2(["source", "account"], `an account takes 1\u2013${MAX_ID} characters`, "envelope.invalid")];
2136
+ if (!idText(source.batch_id))
2137
+ return [invalid2(["source", "batch_id"], `a batch id takes 1\u2013${MAX_ID} characters`, "envelope.invalid")];
2138
+ if (source.account !== account)
2139
+ return [
2140
+ invalid2(["source", "account"], `the envelope is for account ${JSON.stringify(source.account)}, the import for ${JSON.stringify(account)}`, "envelope.account-mismatch")
2141
+ ];
2142
+ const { options } = envelope;
2143
+ if (options !== void 0) {
2144
+ if (!isObject(options))
2145
+ return [invalid2(["options"], "options is an object", "envelope.invalid")];
2146
+ const unknown = extraKeys(options, ["lines", "phone_region"]);
2147
+ if (unknown.length > 0)
2148
+ return [invalid2(["options", unknown[0]], "options holds lines and phone_region", "envelope.invalid")];
2149
+ if (options.phone_region !== void 0 && (typeof options.phone_region !== "string" || !PHONE_COUNTRIES.includes(options.phone_region.toLowerCase())))
2150
+ return [
2151
+ invalid2(["options", "phone_region"], `options.phone_region is one of ${PHONE_COUNTRIES.join(", ")}`, "envelope.invalid")
2152
+ ];
2153
+ if (options.lines !== void 0 && !LINE_OPTIONS.includes(options.lines))
2154
+ return [invalid2(["options", "lines"], `options.lines is ${LINE_OPTIONS.join(" or ")}`, "envelope.invalid")];
2155
+ }
2156
+ return [];
2157
+ }, "headerErrors");
2158
+ var canonical = /* @__PURE__ */ __name((value) => {
2159
+ if (Array.isArray(value))
2160
+ return value.map(canonical);
2161
+ if (!isObject(value))
2162
+ return value;
2163
+ return Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])]));
2164
+ }, "canonical");
2165
+ var recordFingerprint = /* @__PURE__ */ __name((fields, relations) => createHash("sha256").update(JSON.stringify(canonical({
2166
+ fields,
2167
+ relations: relations.map((relation) => [
2168
+ relation.role,
2169
+ ...relation.ref === void 0 ? [relation.type, relation.external_id] : [`ref=${relation.ref}`],
2170
+ ...relation.amount === void 0 ? [] : [relation.amount],
2171
+ ...relation.as === void 0 ? [] : [`as=${relation.as}`]
2172
+ ]).sort((a, b) => a.join("\0").localeCompare(b.join("\0")))
2173
+ }))).digest("hex"), "recordFingerprint");
2174
+ var BOM = "\uFEFF";
2175
+ var withoutBom = /* @__PURE__ */ __name((text2) => text2.startsWith(BOM) ? text2.slice(1) : text2, "withoutBom");
2176
+ var jsonLine = /* @__PURE__ */ __name((line) => {
2177
+ try {
2178
+ return JSON.parse(withoutBom(line));
2179
+ } catch {
2180
+ return line;
2181
+ }
2182
+ }, "jsonLine");
2183
+ var envelopeOfJsonl = /* @__PURE__ */ __name((text2) => {
2184
+ const lines = withoutBom(text2).split(/\r?\n/);
2185
+ const first = lines.findIndex((line) => line.trim() !== "");
2186
+ if (first < 0)
2187
+ return {};
2188
+ const header = jsonLine(lines[first]);
2189
+ const records = [];
2190
+ for (let at = first + 1; at < lines.length; at++) {
2191
+ const line = lines[at];
2192
+ if (line.trim() !== "")
2193
+ records.push(jsonLine(line));
2194
+ }
2195
+ return isObject(header) ? { ...header, records } : header;
2196
+ }, "envelopeOfJsonl");
2197
+ var envelopeOfText = /* @__PURE__ */ __name((text2) => {
2198
+ const clean = withoutBom(text2);
2199
+ const first = clean.split(/\r?\n/).find((line) => line.trim() !== "");
2200
+ const head = first === void 0 ? void 0 : jsonLine(first);
2201
+ if (isObject(head) && !Object.hasOwn(head, "records"))
2202
+ return envelopeOfJsonl(clean);
2203
+ return jsonLine(clean);
2204
+ }, "envelopeOfText");
2205
+ var fieldReferences = /* @__PURE__ */ __name((record, options = {}) => {
2206
+ if (record.operation !== "upsert" || !isRecordType(record.type))
2207
+ return [];
2208
+ const fields = record.fields ?? {};
2209
+ const found = [];
2210
+ for (const [key, type] of referencesOf(record.type))
2211
+ if (typeof fields[key] === "string")
2212
+ found.push({ role: `fields.${key}`, type, external_id: fields[key] });
2213
+ if (record.type === "invoice" && options.lines !== "products")
2214
+ return found;
2215
+ for (const [list, spec] of nestedOf(record.type)) {
2216
+ const items = fields[list];
2217
+ if (!Array.isArray(items))
2218
+ continue;
2219
+ for (const item of items)
2220
+ for (const [key, type] of Object.entries(spec.references ?? {}))
2221
+ if (isObject(item) && typeof item[key] === "string")
2222
+ found.push({ role: `fields.${list}.${key}`, type, external_id: item[key] });
2223
+ }
2224
+ return found;
2225
+ }, "fieldReferences");
2226
+
2227
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/domain/relation-role-labels.js
2228
+ var label = /* @__PURE__ */ __name((en, ru, es) => ({ en, ru, es }), "label");
2229
+ var ROLE_LABELS = {
2230
+ organization: {
2231
+ employee: label("Employee", "\u0421\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A", "Empleado"),
2232
+ contractor: label("Contractor", "\u041F\u043E\u0434\u0440\u044F\u0434\u0447\u0438\u043A", "Contratista"),
2233
+ founder: label("Founder", "\u041E\u0441\u043D\u043E\u0432\u0430\u0442\u0435\u043B\u044C", "Fundador"),
2234
+ owner: label("Owner", "\u0412\u043B\u0430\u0434\u0435\u043B\u0435\u0446", "Propietario"),
2235
+ manager: label("Manager", "\u0420\u0443\u043A\u043E\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C", "Directivo"),
2236
+ adviser: label("Adviser", "\u0421\u043E\u0432\u0435\u0442\u043D\u0438\u043A", "Asesor"),
2237
+ contact: label("Contact", "\u041A\u043E\u043D\u0442\u0430\u043A\u0442", "Contacto")
2238
+ },
2239
+ project: {
2240
+ owner: label("Owner", "\u0412\u043B\u0430\u0434\u0435\u043B\u0435\u0446", "Propietario"),
2241
+ manager: label("Manager", "\u0420\u0443\u043A\u043E\u0432\u043E\u0434\u0438\u0442\u0435\u043B\u044C", "Directivo"),
2242
+ contributor: label("Contributor", "\u0423\u0447\u0430\u0441\u0442\u043D\u0438\u043A", "Colaborador"),
2243
+ "client-contact": label("Client contact", "\u041A\u043E\u043D\u0442\u0430\u043A\u0442 \u043A\u043B\u0438\u0435\u043D\u0442\u0430", "Contacto del cliente"),
2244
+ approver: label("Approver", "\u0421\u043E\u0433\u043B\u0430\u0441\u0443\u044E\u0449\u0438\u0439", "Aprobador")
2245
+ },
2246
+ deal: {
2247
+ owner: label("Responsible", "\u041E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439", "Responsable"),
2248
+ contact: label("Contact", "\u041A\u043E\u043D\u0442\u0430\u043A\u0442", "Contacto"),
2249
+ "decision-maker": label("Decision-maker", "\u041F\u0440\u0438\u043D\u0438\u043C\u0430\u0435\u0442 \u0440\u0435\u0448\u0435\u043D\u0438\u0435", "Responsable de decidir"),
2250
+ influencer: label("Influencer", "\u0412\u043B\u0438\u044F\u0435\u0442 \u043D\u0430 \u0440\u0435\u0448\u0435\u043D\u0438\u0435", "Influye en la decisi\xF3n")
2251
+ },
2252
+ contract: {
2253
+ customer: label("Customer", "\u0417\u0430\u043A\u0430\u0437\u0447\u0438\u043A", "Cliente"),
2254
+ supplier: label("Supplier", "\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A", "Proveedor"),
2255
+ signatory: label("Signatory", "\u041F\u043E\u0434\u043F\u0438\u0441\u0430\u043D\u0442", "Firmante"),
2256
+ guarantor: label("Guarantor", "\u041F\u043E\u0440\u0443\u0447\u0438\u0442\u0435\u043B\u044C", "Garante")
2257
+ },
2258
+ related: {
2259
+ colleague: label("Colleague", "\u041A\u043E\u043B\u043B\u0435\u0433\u0430", "Colega"),
2260
+ adviser: label("Adviser", "\u0421\u043E\u0432\u0435\u0442\u043D\u0438\u043A", "Asesor"),
2261
+ investor: label("Investor", "\u0418\u043D\u0432\u0435\u0441\u0442\u043E\u0440", "Inversor"),
2262
+ mentor: label("Mentor", "\u041D\u0430\u0441\u0442\u0430\u0432\u043D\u0438\u043A", "Mentor"),
2263
+ family: label("Family", "\u0421\u0435\u043C\u044C\u044F", "Familia"),
2264
+ friend: label("Friend", "\u0414\u0440\u0443\u0433", "Amigo")
2265
+ }
2266
+ };
2267
+
2268
+ export {
2269
+ isObject,
2270
+ RECORD_TYPES,
2271
+ isRecordType,
2272
+ isBusinessType,
2273
+ isIdentityType,
2274
+ RECORD_ENTITY_TYPES,
2275
+ RECORD_TABLES,
2276
+ DECIDED_TABLES,
2277
+ WORD_BODY,
2278
+ rolesOf,
2279
+ roleOf,
2280
+ nestedOf,
2281
+ AMOUNT_ROLES,
2282
+ FIELD_REFERENCE_ROLES,
2283
+ hasV1Roles,
2284
+ IDENTITY_TYPES,
2285
+ article,
2286
+ isEmailAddress,
2287
+ ROLE_ADDRESS_WORDS,
2288
+ isRoleAddress,
2289
+ isPersonLikeRoleAddress,
2290
+ isNoReplyAddress,
2291
+ DEFAULT_PHONE_COUNTRIES,
2292
+ parsePhoneCountries,
2293
+ nationalPhone,
2294
+ typedPhone,
2295
+ e164Of,
2296
+ BARE_INTERNATIONAL_PROVIDERS,
2297
+ storedPhone,
2298
+ QUERY_VERSION,
2299
+ QUERY_LIMITS2 as QUERY_LIMITS,
2300
+ SEARCH_QUERY,
2301
+ MESSAGE_PARSING,
2302
+ MOST_WORDS_APART,
2303
+ searchError,
2304
+ searchTimeLimit,
2305
+ outOfTime,
2306
+ isQueryLimit,
2307
+ exhausted,
2308
+ tooWideTerm,
2309
+ compileAutomaton,
2310
+ wildcardPattern,
2311
+ foldRegex,
2312
+ chatReferenceOf,
2313
+ wrongAccount,
2314
+ ensureAccount,
2315
+ trigrams,
2316
+ isId,
2317
+ foldName,
2318
+ pickChat,
2319
+ pickPerson,
2320
+ peopleMatching,
2321
+ chatsMatching,
2322
+ nearest,
2323
+ displayName,
2324
+ takeFallbacks,
2325
+ noFallbacks,
2326
+ nameKey,
2327
+ isReadable,
2328
+ COUNTER_FIELDS,
2329
+ validCounter,
2330
+ counterValue,
2331
+ counterObservationTime,
2332
+ observedCounters,
2333
+ counterFreshness,
2334
+ MESSAGE_MEASURES,
2335
+ AUTHOR_MEASURES,
2336
+ needsRankingContext,
2337
+ rankingOptions,
2338
+ rankingScore,
2339
+ RANKING_TOKENIZER_VERSION,
2340
+ rankingWords,
2341
+ rankingQuestion,
2342
+ RECORDS_SCHEMA_VERSION,
2343
+ RECORD_OPERATIONS,
2344
+ RECORDS_ENVELOPE_SCHEMA,
2345
+ pointerOf,
2346
+ recordErrors,
2347
+ envelopeErrors,
2348
+ headerErrors,
2349
+ recordFingerprint,
2350
+ jsonLine,
2351
+ envelopeOfJsonl,
2352
+ envelopeOfText,
2353
+ fieldReferences,
2354
+ ROLE_LABELS
2355
+ };