@wirecat/mail-cli 0.29.0 → 0.31.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 (105) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/bin/mail.js +2 -2
  3. package/dist/bundle/{all-profiles-Q4E2LPB4.js → all-profiles-XL62TNUO.js} +19 -29
  4. package/dist/bundle/{anthropic-S3N4JDJU.js → anthropic-3MSWVYCE.js} +2 -2
  5. package/dist/bundle/{app-server-E44CAPPI.js → app-server-RRNR5XFA.js} +45 -60
  6. package/dist/bundle/{bun-RDYA5FCZ.js → bun-E3F3PEQQ.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-FPVHKI24.js → bun-sqlite-UOFN77LO.js} +3 -3
  8. package/dist/bundle/{chunk-KBTVVHFP.js → chunk-3CJ4C6BB.js} +12 -12
  9. package/dist/bundle/{chunk-KTLJ6F2B.js → chunk-3V6J7VPF.js} +3 -3
  10. package/dist/bundle/{chunk-44IAJV2T.js → chunk-4BW5JACS.js} +16 -16
  11. package/dist/bundle/{chunk-UQZJ2GFQ.js → chunk-4ME2NHNJ.js} +2 -2
  12. package/dist/bundle/{chunk-NUHUTJTM.js → chunk-5YRR52NH.js} +1 -1
  13. package/dist/bundle/{chunk-ZIFB6KGQ.js → chunk-6UOUDIXL.js} +1575 -945
  14. package/dist/bundle/{chunk-WZNQ2P7H.js → chunk-7E7YXQ52.js} +1307 -1307
  15. package/dist/bundle/{chunk-45ET53MO.js → chunk-BKRIIZPV.js} +2 -2
  16. package/dist/bundle/{chunk-TXDA437R.js → chunk-BNP7WLDQ.js} +1 -1
  17. package/dist/bundle/{chunk-W32UQL5I.js → chunk-BS6WYCNZ.js} +32 -22
  18. package/dist/bundle/{chunk-WSHPLO4Q.js → chunk-BXMLIKUM.js} +147 -391
  19. package/dist/bundle/{chunk-BPHLFSUO.js → chunk-D6D6JLXG.js} +16 -16
  20. package/dist/bundle/{chunk-YRER6N3Y.js → chunk-DCR3IWC7.js} +38 -47
  21. package/dist/bundle/{chunk-KSFPMRH6.js → chunk-DDCDOBZS.js} +1 -1
  22. package/dist/bundle/{chunk-DMW6J2P3.js → chunk-DPDS6IZJ.js} +1 -1
  23. package/dist/bundle/{chunk-5PDWUD3W.js → chunk-DWBY7DMF.js} +1 -1
  24. package/dist/bundle/{chunk-IZEK7JI7.js → chunk-DZSS2IUK.js} +18 -2
  25. package/dist/bundle/{chunk-UUM7AF32.js → chunk-E3IOR37T.js} +2 -2
  26. package/dist/bundle/{chunk-5ZJ6IHVE.js → chunk-EMVLCION.js} +1 -1
  27. package/dist/bundle/{chunk-IKTBM64M.js → chunk-EV5SR3OC.js} +7 -7
  28. package/dist/bundle/{chunk-D4QALV67.js → chunk-FRXDSR45.js} +1 -1
  29. package/dist/bundle/{chunk-BDWOTD7E.js → chunk-FYP2M6IT.js} +80 -80
  30. package/dist/bundle/{chunk-ATJANIQR.js → chunk-GWKGZOSO.js} +2 -2
  31. package/dist/bundle/{chunk-MVGFB7IS.js → chunk-GXBNTKJW.js} +2 -2
  32. package/dist/bundle/{chunk-Z5D6CRY6.js → chunk-GZLCZU5B.js} +322 -11
  33. package/dist/bundle/{chunk-ZPVVSA5R.js → chunk-H2QTUZ3C.js} +1 -1
  34. package/dist/bundle/{chunk-FHQ32JKS.js → chunk-HZCINHHS.js} +1 -1
  35. package/dist/bundle/{chunk-7AO73MJZ.js → chunk-HZL3X4XR.js} +15 -15
  36. package/dist/bundle/{chunk-HKC6ZJA5.js → chunk-I3BQ2QIY.js} +12 -12
  37. package/dist/bundle/{chunk-PCYTU7HS.js → chunk-I5Y6Y7Q5.js} +1 -1
  38. package/dist/bundle/{chunk-7E4KECG4.js → chunk-ITU6K7LU.js} +1 -1
  39. package/dist/bundle/{chunk-RGIEG4XK.js → chunk-JLIVJSCF.js} +1 -1
  40. package/dist/bundle/{chunk-3AH7UEM6.js → chunk-JYGFEMTR.js} +1 -1
  41. package/dist/bundle/{chunk-3RBUACSJ.js → chunk-KPFB2VUY.js} +762 -353
  42. package/dist/bundle/{chunk-FOZXPSHA.js → chunk-LGDJDD5J.js} +3 -3
  43. package/dist/bundle/{chunk-2MTIGJHQ.js → chunk-MS5XYEYW.js} +14 -9
  44. package/dist/bundle/{chunk-DIOHJT2W.js → chunk-NEJU74O4.js} +6 -6
  45. package/dist/bundle/{chunk-FDGCTY6J.js → chunk-NUN7DBR4.js} +9 -9
  46. package/dist/bundle/{chunk-6B2BBL35.js → chunk-NV3WPD3B.js} +5 -5
  47. package/dist/bundle/{chunk-NWA7JS74.js → chunk-NYQPKZWL.js} +633 -370
  48. package/dist/bundle/{chunk-RFM3AAK5.js → chunk-OP5ZLH53.js} +57 -54
  49. package/dist/bundle/{chunk-VXHL3XI6.js → chunk-OXHQNEXU.js} +98 -6
  50. package/dist/bundle/{chunk-ODPYXNHI.js → chunk-P6CYVOL6.js} +1 -1
  51. package/dist/bundle/{chunk-YAQGWHMH.js → chunk-PIXFZZUZ.js} +6 -6
  52. package/dist/bundle/{chunk-KNTAOY5J.js → chunk-PZL7DHVJ.js} +7 -7
  53. package/dist/bundle/{chunk-MT5KDBOM.js → chunk-QANXOKYQ.js} +5 -5
  54. package/dist/bundle/{chunk-UH7FYLFL.js → chunk-QSXJ2BVQ.js} +4 -4
  55. package/dist/bundle/{chunk-VERUQQZS.js → chunk-QVGCHTTU.js} +10 -10
  56. package/dist/bundle/{chunk-PYOM4J73.js → chunk-S2QO6KUI.js} +2 -2
  57. package/dist/bundle/{chunk-7ESXP4TG.js → chunk-SQA5JI7Q.js} +1 -1
  58. package/dist/bundle/{chunk-PIKOQWTL.js → chunk-T72DWT37.js} +4 -4
  59. package/dist/bundle/{chunk-YSR2XBDO.js → chunk-THZHNCJP.js} +3 -3
  60. package/dist/bundle/{chunk-XEMARUGS.js → chunk-TUXNILKR.js} +7 -7
  61. package/dist/bundle/{chunk-FM4B357N.js → chunk-UFMR2TB3.js} +2 -2
  62. package/dist/bundle/{chunk-OLTJB5PW.js → chunk-WZGFC7D5.js} +1 -1
  63. package/dist/bundle/{command-contract-TMLXLGVT.js → command-contract-YRNKDQDL.js} +15 -15
  64. package/dist/bundle/{command-server-entry-PFUR2W7X.js → command-server-entry-A3FCP24M.js} +21 -21
  65. package/dist/bundle/{decode-SIVT4JWX.js → decode-FI2ISRNZ.js} +2 -2
  66. package/dist/bundle/{dist-YWSF5MHP.js → dist-NLOOZJ64.js} +15 -11
  67. package/dist/bundle/{echarts-CABLIXX7.js → echarts-PMAJUJFE.js} +2 -2
  68. package/dist/bundle/{embed-OHENS6RB.js → embed-OIMT6SAX.js} +3 -3
  69. package/dist/bundle/{embedder-JINT4Y4O.js → embedder-Q5IF5WIM.js} +6 -6
  70. package/dist/bundle/{first-run-LU2MAK2B.js → first-run-4L53QWOT.js} +6 -6
  71. package/dist/bundle/first-screen-ZPQLAAIS.js +34 -0
  72. package/dist/bundle/{instructions-3D22PA4T.js → instructions-ZJGGGXOA.js} +1 -1
  73. package/dist/bundle/mail.js +2 -2
  74. package/dist/bundle/{node-42G4RGMW.js → node-DCSOHRD6.js} +2 -2
  75. package/dist/bundle/{node-sqlite-KQZM5M3N.js → node-sqlite-7F77K5JA.js} +4 -4
  76. package/dist/bundle/{oauth-7BNCNKQV.js → oauth-LVPMEN6M.js} +4 -4
  77. package/dist/bundle/{open-ULOQOP7K.js → open-XM5LWEN6.js} +2 -2
  78. package/dist/bundle/{openai-O5AH6VGT.js → openai-H2LCGK22.js} +12 -12
  79. package/dist/bundle/{process-6D767IDN.js → process-MFC5VSPT.js} +1 -1
  80. package/dist/bundle/{program-OE7MFRMJ.js → program-ZQ43ZYKZ.js} +1327 -1089
  81. package/dist/bundle/{prompt-WN7EBVKT.js → prompt-3LZAZNQ4.js} +2 -2
  82. package/dist/bundle/{recognize-IX33XEXZ.js → recognize-GYQMHFY2.js} +1 -1
  83. package/dist/bundle/{remote-22N3FQUC.js → remote-P2MD5G64.js} +6 -6
  84. package/dist/bundle/{rerank-IGX4EFA2.js → rerank-A5X6THV6.js} +4 -4
  85. package/dist/bundle/{serve-XWIRR2QZ.js → serve-IEC3EUKS.js} +6 -6
  86. package/dist/bundle/{server-DBS4WC6T.js → server-3REPXFNI.js} +43 -41
  87. package/dist/bundle/server-E2QTFURI.js +67 -0
  88. package/dist/bundle/{sqlite-runtime-WFBTXXXJ.js → sqlite-runtime-AOLQGC5J.js} +3 -3
  89. package/dist/bundle/{state-4J5ERHJA.js → state-D3P5IXXA.js} +3 -3
  90. package/dist/bundle/{store-YRBX7XLM.js → store-DIN6OY3K.js} +13 -13
  91. package/dist/bundle/{store-YSP2NPRJ.js → store-MZCQXBVW.js} +19 -15
  92. package/dist/bundle/store-maintenance-command-UMVFI6M6.js +58 -0
  93. package/dist/commands/rules.d.ts.map +1 -1
  94. package/dist/commands/rules.js +73 -22
  95. package/dist/commands/rules.js.map +1 -1
  96. package/dist/mail/rules/apply.d.ts.map +1 -1
  97. package/dist/mail/rules/apply.js +1 -9
  98. package/dist/mail/rules/apply.js.map +1 -1
  99. package/dist/version.d.ts +1 -1
  100. package/dist/version.js +1 -1
  101. package/package.json +2 -2
  102. package/dist/bundle/chunk-VFRI6RF7.js +0 -76
  103. package/dist/bundle/first-screen-KZNLKRRQ.js +0 -34
  104. package/dist/bundle/server-D5OTVERP.js +0 -68
  105. package/dist/bundle/store-maintenance-command-SH6IB7S6.js +0 -58
@@ -20,10 +20,10 @@ import {
20
20
  providerLabel,
21
21
  providerNamed,
22
22
  queryError
23
- } from "./chunk-3RBUACSJ.js";
23
+ } from "./chunk-KPFB2VUY.js";
24
24
  import {
25
25
  fold
26
- } from "./chunk-D4QALV67.js";
26
+ } from "./chunk-FRXDSR45.js";
27
27
  import {
28
28
  CliError,
29
29
  isCliError,
@@ -33,1099 +33,7 @@ import {
33
33
  __name
34
34
  } from "./chunk-ZVVMGPBJ.js";
35
35
 
36
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/ref-arguments.js
37
- var TAKES = {
38
- chat: "a chat: chat:<provider>/<account>/<chat>, its id or its title",
39
- message: "a message: msg:<provider>/<account>/<chat>/<message>, or a chat and the message's id"
40
- };
41
- var article = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
42
- var wrongKind = /* @__PURE__ */ __name((text2, kind, takes) => new CliError("validation_error", `${text2} names ${article(kind)} ${kind}; this takes ${TAKES[takes]}`, {
43
- reason: "ref.wrong-kind"
44
- }), "wrongKind");
45
- var wrongProvider = /* @__PURE__ */ __name((text2, provider, kind) => {
46
- const entry = providerNamed(provider);
47
- const command = entry?.command;
48
- const opens = kind === "entity" ? void 0 : entry?.opens?.[kind];
49
- const how = command && opens ? `open it with ${command} <profile> ${opens} ${text2}` : "open it with its own CLI";
50
- const label2 = providerLabel(provider);
51
- return new CliError("validation_error", `${text2} is ${article(label2.toLowerCase())} ${label2} ${kind}; ${how}`, {
52
- reason: "ref.wrong-provider"
53
- });
54
- }, "wrongProvider");
55
- var chatReferenceOf = /* @__PURE__ */ __name((text2, provider, takes = "chat") => {
56
- const trimmed = text2.trim();
57
- if (!looksLikeReference(trimmed))
58
- return void 0;
59
- const reference = parseReference(trimmed);
60
- if (reference.type !== "chat" && reference.type !== "message")
61
- throw wrongKind(trimmed, reference.type, takes);
62
- if (reference.provider !== provider)
63
- throw wrongProvider(trimmed, reference.provider, reference.type);
64
- const found = {
65
- text: trimmed,
66
- provider: reference.provider,
67
- account: reference.account,
68
- chat: reference.chat,
69
- ...reference.type === "message" ? { message: reference.message } : {}
70
- };
71
- return found;
72
- }, "chatReferenceOf");
73
- var contactReferenceOf = /* @__PURE__ */ __name((text2, provider) => {
74
- const trimmed = text2.trim();
75
- if (!trimmed.startsWith("contact:"))
76
- return void 0;
77
- const reference = parseReference(trimmed);
78
- if (reference.type !== "contact")
79
- return void 0;
80
- if (provider !== void 0 && reference.provider !== provider)
81
- throw wrongProvider(trimmed, reference.provider, reference.type);
82
- return reference.id;
83
- }, "contactReferenceOf");
84
- var wrongAccount = /* @__PURE__ */ __name((reference, scope, profiles) => {
85
- 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}`;
86
- const others = profiles === void 0 ? "" : `. Profiles signed in to ${reference.account}: ${profiles.length > 0 ? profiles.join(", ") : "none here"}`;
87
- return new CliError("validation_error", `${reference.text} belongs to account ${reference.account}; ${here}${others}`, { reason: "ref.wrong-account" });
88
- }, "wrongAccount");
89
- var ensureAccount = /* @__PURE__ */ __name(async (reference, scope, profilesOn) => {
90
- if (scope.account !== void 0 && scope.account === reference.account)
91
- return;
92
- const profiles = await profilesOn?.(reference.account).catch(() => void 0);
93
- throw wrongAccount(reference, scope, profiles);
94
- }, "ensureAccount");
95
-
96
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
97
- var QUERY_VERSION = 1;
98
- var QUERY_LIMITS2 = {
99
- ...QUERY_LIMITS,
100
- pattern: 1024,
101
- states: 1e4,
102
- expansions: 1e4,
103
- candidates: 5e4,
104
- bodyBytes: 8388608,
105
- milliseconds: 2e3,
106
- work: 1e7
107
- };
108
- var SEARCH_QUERY = {
109
- command: "search",
110
- guide: "https://github.com/WireCatLabs/cli-core/blob/main/docs/search/query-language.md"
111
- };
112
- var MESSAGE_PARSING = { ...SEARCH_QUERY, proximity: true };
113
- var MOST_WORDS_APART = 50;
114
- function searchError(reason, span, alternative) {
115
- queryError(reason, span, alternative, SEARCH_QUERY);
116
- }
117
- __name(searchError, "searchError");
118
- var ANSWER_MS = 1e3;
119
- var searchTimeLimit = /* @__PURE__ */ __name((deadline, now = Date.now()) => deadline?.explicit ? Math.max(QUERY_LIMITS2.milliseconds, deadline.endsAt - now - ANSWER_MS) : void 0, "searchTimeLimit");
120
- function outOfTime(limitMs = QUERY_LIMITS2.milliseconds) {
121
- 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 });
122
- }
123
- __name(outOfTime, "outOfTime");
124
- var isQueryLimit = /* @__PURE__ */ __name((error) => isCliError(error) && (error.details.reason === "query.too-large" || error.details.reason === "query.time-limit"), "isQueryLimit");
125
- function exhausted(budget) {
126
- throw new CliError("validation_error", `search exceeded its ${budget} budget \u2014 narrow the chat or date range`, {
127
- reason: "query.too-large",
128
- budget,
129
- complete: false
130
- });
131
- }
132
- __name(exhausted, "exhausted");
133
- function tooWideTerm([term], budget) {
134
- if (term === void 0)
135
- exhausted(budget);
136
- const part = term.replace(/[*?]+/gu, " ").trim().split(/\s+/u).sort((a, b) => b.length - a.length)[0] ?? term;
137
- 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 });
138
- }
139
- __name(tooWideTerm, "tooWideTerm");
140
-
141
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
142
- var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
143
- var literal = /* @__PURE__ */ __name((c) => ({
144
- kind: "char",
145
- ranges: [[c.codePointAt(0) ?? 0, c.codePointAt(0) ?? 0]],
146
- negate: false
147
- }), "literal");
148
- var compileAutomaton = /* @__PURE__ */ __name((pattern, span = { start: 0, end: pattern.length }) => {
149
- if (pattern.length > QUERY_LIMITS2.pattern * 2)
150
- exhausted("pattern");
151
- const chars = [...pattern];
152
- if (chars.length > QUERY_LIMITS2.pattern)
153
- exhausted("pattern");
154
- let at = 0, depth = 0;
155
- const failure = /* @__PURE__ */ __name(() => searchError("query.invalid-regex", span, "use the supported Lucene regex subset"), "failure");
156
- const character = /* @__PURE__ */ __name(() => {
157
- if (at >= chars.length)
158
- return failure();
159
- return chars[at++];
160
- }, "character");
161
- const predefined = /* @__PURE__ */ __name(() => {
162
- if (chars[at] !== "\\")
163
- return void 0;
164
- const name = chars[at + 1] ?? "";
165
- let ranges;
166
- if (name.toLowerCase() === "d")
167
- ranges = [[48, 57]];
168
- if (name.toLowerCase() === "w")
169
- ranges = [
170
- [48, 57],
171
- [65, 90],
172
- [95, 95],
173
- [97, 122]
174
- ];
175
- if (name.toLowerCase() === "s")
176
- ranges = [
177
- [9, 10],
178
- [13, 13],
179
- [32, 32]
180
- ];
181
- if (ranges) {
182
- at += 2;
183
- return { kind: "char", ranges, negate: name === name.toUpperCase() };
184
- }
185
- if (/^[a-zA-Z]$/u.test(name))
186
- return failure();
187
- return void 0;
188
- }, "predefined");
189
- const escaped = /* @__PURE__ */ __name(() => {
190
- if (chars[at] === "\\")
191
- at++;
192
- return character();
193
- }, "escaped");
194
- const union = /* @__PURE__ */ __name(() => {
195
- if (++depth > QUERY_LIMITS2.depth)
196
- exhausted("pattern depth");
197
- const children = [concat()];
198
- while (chars[at] === "|") {
199
- at++;
200
- children.push(concat());
201
- }
202
- depth--;
203
- return children.length === 1 ? children[0] : { kind: "union", children };
204
- }, "union");
205
- const concat = /* @__PURE__ */ __name(() => {
206
- const children = [];
207
- do {
208
- children.push(repeat());
209
- } while (at < chars.length && ![")", "|", "&"].includes(chars[at] ?? ""));
210
- if (chars[at] === "&")
211
- searchError("query.unsupported-regex", span, "automaton intersection is not supported");
212
- return children.length === 1 ? children[0] : { kind: "concat", children };
213
- }, "concat");
214
- const repeat = /* @__PURE__ */ __name(() => {
215
- let child = simple();
216
- while (["?", "*", "+", "{"].includes(chars[at] ?? "")) {
217
- const op = character();
218
- let min = op === "+" ? 1 : 0, max = op === "?" ? 1 : null;
219
- if (op === "{") {
220
- const number = /* @__PURE__ */ __name(() => {
221
- const start2 = at;
222
- while (/^[0-9]$/u.test(chars[at] ?? ""))
223
- at++;
224
- if (at === start2)
225
- return failure();
226
- return Number(chars.slice(start2, at).join(""));
227
- }, "number");
228
- min = number();
229
- max = min;
230
- if (chars[at] === ",") {
231
- at++;
232
- max = chars[at] === "}" ? null : number();
233
- }
234
- if (character() !== "}" || max !== null && max < min)
235
- return failure();
236
- }
237
- if (min > QUERY_LIMITS2.states || max !== null && max > QUERY_LIMITS2.states)
238
- exhausted("automaton states");
239
- child = { kind: "repeat", child, min, max };
240
- }
241
- return child;
242
- }, "repeat");
243
- const simple = /* @__PURE__ */ __name(() => {
244
- const predefinedAtom = predefined();
245
- if (predefinedAtom)
246
- return predefinedAtom;
247
- const c = character();
248
- if (c === "~" || c === "<")
249
- searchError("query.unsupported-regex", span, "complement, named automata and numeric intervals are not supported");
250
- if (c === ".")
251
- return any;
252
- if (c === "#")
253
- return { kind: "empty" };
254
- if (c === "@")
255
- return { kind: "repeat", child: any, min: 0, max: null };
256
- if (c === '"') {
257
- const children = [];
258
- while (chars[at] !== '"')
259
- children.push(literal(character()));
260
- at++;
261
- return { kind: "concat", children };
262
- }
263
- if (c === "(") {
264
- if (chars[at] === ")") {
265
- at++;
266
- return { kind: "epsilon" };
267
- }
268
- if (chars[at] === "?")
269
- searchError("query.unsupported-regex", span, "JavaScript groups and lookaround are not Lucene operators");
270
- const child = union();
271
- if (character() !== ")")
272
- return failure();
273
- return child;
274
- }
275
- if (c === "[") {
276
- const negate = chars[at] === "^";
277
- if (negate)
278
- at++;
279
- const choices = [];
280
- do {
281
- const pre = predefined();
282
- if (pre) {
283
- choices.push(pre);
284
- continue;
285
- }
286
- const lo = escaped().codePointAt(0) ?? 0;
287
- let hi = lo;
288
- if (chars[at] === "-") {
289
- at++;
290
- hi = escaped().codePointAt(0) ?? 0;
291
- }
292
- if (hi < lo)
293
- return failure();
294
- choices.push({ kind: "char", ranges: [[lo, hi]], negate: false });
295
- } while (at < chars.length && chars[at] !== "]");
296
- if (character() !== "]")
297
- return failure();
298
- if (!negate)
299
- return { kind: "union", children: choices };
300
- const ranges = [];
301
- for (const choice of choices) {
302
- if (choice.kind !== "char" || choice.negate)
303
- searchError("query.unsupported-regex", span, "negative predefined classes inside a negated class are not supported");
304
- ranges.push(...choice.ranges);
305
- }
306
- return { kind: "char", ranges, negate: true };
307
- }
308
- if (c === "\\")
309
- return literal(character());
310
- return literal(c);
311
- }, "simple");
312
- const expression = chars.length === 0 ? { kind: "epsilon" } : union();
313
- if (at !== chars.length)
314
- return failure();
315
- const states = [];
316
- const state = /* @__PURE__ */ __name(() => {
317
- if (states.length >= QUERY_LIMITS2.states)
318
- exhausted("automaton states");
319
- states.push({ epsilon: [], edges: [] });
320
- return states.length - 1;
321
- }, "state");
322
- const epsilon = /* @__PURE__ */ __name((from, to) => {
323
- ;
324
- states[from].epsilon.push(to);
325
- }, "epsilon");
326
- const build = /* @__PURE__ */ __name((node, from, to) => {
327
- if (node.kind === "char") {
328
- ;
329
- states[from].edges.push({ to, atom: node });
330
- return;
331
- }
332
- if (node.kind === "empty")
333
- return;
334
- if (node.kind === "epsilon") {
335
- epsilon(from, to);
336
- return;
337
- }
338
- if (node.kind === "union") {
339
- for (const child of node.children)
340
- build(child, from, to);
341
- return;
342
- }
343
- if (node.kind === "concat") {
344
- let current2 = from;
345
- node.children.forEach((child, index) => {
346
- const next = index === node.children.length - 1 ? to : state();
347
- build(child, current2, next);
348
- current2 = next;
349
- });
350
- if (node.children.length === 0)
351
- epsilon(from, to);
352
- return;
353
- }
354
- let current = from;
355
- for (let i = 0; i < node.min; i++) {
356
- const next = state();
357
- build(node.child, current, next);
358
- current = next;
359
- }
360
- if (node.max === null) {
361
- epsilon(current, to);
362
- const end2 = state();
363
- build(node.child, current, end2);
364
- epsilon(end2, current);
365
- } else {
366
- for (let i = node.min; i < node.max; i++) {
367
- epsilon(current, to);
368
- const next = state();
369
- build(node.child, current, next);
370
- current = next;
371
- }
372
- epsilon(current, to);
373
- }
374
- }, "build");
375
- const start = state(), end = state();
376
- build(expression, start, end);
377
- return {
378
- states: states.length,
379
- test: /* @__PURE__ */ __name((text2, budget = { work: 0 }) => {
380
- const spend = /* @__PURE__ */ __name(() => {
381
- if (++budget.work > (budget.maxWork ?? QUERY_LIMITS2.work))
382
- exhausted("automaton work");
383
- }, "spend");
384
- const closure = /* @__PURE__ */ __name((initial) => {
385
- const stack = [...initial];
386
- while (stack.length) {
387
- const id = stack.pop();
388
- for (const next of states[id].epsilon) {
389
- spend();
390
- if (!initial.has(next)) {
391
- initial.add(next);
392
- stack.push(next);
393
- }
394
- }
395
- }
396
- return initial;
397
- }, "closure");
398
- let current = closure(/* @__PURE__ */ new Set([start]));
399
- for (const c of text2) {
400
- const point = c.codePointAt(0) ?? 0;
401
- const next = /* @__PURE__ */ new Set();
402
- for (const id of current)
403
- for (const edge of states[id].edges) {
404
- spend();
405
- const inside = edge.atom.ranges.some(([lo, hi]) => point >= lo && point <= hi);
406
- if (inside !== edge.atom.negate)
407
- next.add(edge.to);
408
- }
409
- current = closure(next);
410
- if (current.size === 0)
411
- return false;
412
- }
413
- return current.has(end);
414
- }, "test")
415
- };
416
- }, "compileAutomaton");
417
- var wildcardPattern = /* @__PURE__ */ __name((value) => {
418
- const chars = [...value];
419
- let pattern = "";
420
- for (let at = 0; at < chars.length; at++) {
421
- const c = chars[at];
422
- if (c === "\\") {
423
- const escaped = chars[++at];
424
- if (escaped === void 0)
425
- searchError("query.invalid-escape", { start: 0, end: value.length });
426
- pattern += /[|&?*+(){}[\].#@<>"~\\]/u.test(escaped) ? `\\${escaped}` : escaped;
427
- } else
428
- pattern += c === "*" ? ".*" : c === "?" ? "." : /[|&?*+(){}[\].#@<>"~\\]/u.test(c) ? `\\${c}` : c;
429
- }
430
- return pattern;
431
- }, "wildcardPattern");
432
- var FOLD_RANGE = 4096;
433
- 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");
434
- var classChar = /* @__PURE__ */ __name((point) => {
435
- const c = String.fromCodePoint(point);
436
- return /[\p{L}\p{N}]/u.test(c) ? c : `\\${c}`;
437
- }, "classChar");
438
- var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
439
- const chars = [...pattern.normalize("NFC")];
440
- let out = "";
441
- let at = 0;
442
- const literal2 = /* @__PURE__ */ __name((c) => {
443
- if (!/[\p{L}\p{N}\p{M}]/u.test(c))
444
- return c;
445
- const folded = fold(c);
446
- if (folded === "")
447
- return unfoldable(span, `"${c}"`);
448
- if ([...folded].length === 1 && /[\p{L}\p{N}]/u.test(folded))
449
- return folded;
450
- if (folded.includes('"'))
451
- return unfoldable(span, `"${c}"`);
452
- return `"${folded}"`;
453
- }, "literal");
454
- const characterClass = /* @__PURE__ */ __name(() => {
455
- const begin = at - 1;
456
- let negate = "";
457
- if (chars[at] === "^") {
458
- negate = "^";
459
- at++;
460
- }
461
- const kept2 = [];
462
- const points = /* @__PURE__ */ new Set();
463
- do {
464
- const start = at;
465
- if (chars[at] === "\\" && /^[a-zA-Z]$/u.test(chars[at + 1] ?? "")) {
466
- kept2.push(`\\${chars[at + 1]}`);
467
- at += 2;
468
- continue;
469
- }
470
- const escaped = /* @__PURE__ */ __name(() => {
471
- if (chars[at] === "\\")
472
- at++;
473
- return (chars[at++] ?? "").codePointAt(0) ?? 0;
474
- }, "escaped");
475
- const lo = escaped();
476
- let hi = lo;
477
- if (chars[at] === "-") {
478
- at++;
479
- hi = escaped();
480
- }
481
- if (at > chars.length) {
482
- out += chars.slice(begin).join("");
483
- return;
484
- }
485
- const single = /* @__PURE__ */ __name((point) => [...fold(String.fromCodePoint(point))], "single");
486
- if (hi < lo)
487
- kept2.push(chars.slice(start, at).join(""));
488
- else if (hi - lo >= FOLD_RANGE) {
489
- if (single(lo).join("") !== String.fromCodePoint(lo) || single(hi).join("") !== String.fromCodePoint(hi))
490
- unfoldable(span, `the range ${chars.slice(start, at).join("")}`);
491
- kept2.push(chars.slice(start, at).join(""));
492
- } else
493
- for (let point = lo; point <= hi; point++) {
494
- const folded = single(point);
495
- if (folded.length === 1)
496
- points.add(folded[0]?.codePointAt(0) ?? 0);
497
- else if (lo === hi)
498
- unfoldable(span, `"${String.fromCodePoint(point)}"`);
499
- }
500
- } while (at < chars.length && chars[at] !== "]");
501
- const sorted = [...points].sort((a, b) => a - b);
502
- const ranges = [];
503
- for (let i = 0; i < sorted.length; i++) {
504
- const first = sorted[i];
505
- while (sorted[i + 1] === sorted[i] + 1)
506
- i++;
507
- const last = sorted[i];
508
- ranges.push(last === first ? classChar(first) : `${classChar(first)}-${classChar(last)}`);
509
- }
510
- if (!kept2.length && !ranges.length)
511
- unfoldable(span, "the class");
512
- out += `[${negate}${kept2.join("")}${ranges.join("")}`;
513
- }, "characterClass");
514
- while (at < chars.length) {
515
- const c = chars[at++];
516
- if (c === "\\") {
517
- const next = chars[at++];
518
- if (next === void 0)
519
- out += c;
520
- else
521
- out += (next.codePointAt(0) ?? 0) < 128 ? `${c}${next}` : literal2(next);
522
- } else if (c === '"') {
523
- const end = chars.indexOf('"', at);
524
- if (end < 0) {
525
- out += chars.slice(at - 1).join("");
526
- break;
527
- }
528
- const folded = fold(chars.slice(at, end).join(""));
529
- if (folded.includes('"'))
530
- unfoldable(span, `"${chars.slice(at, end).join("")}"`);
531
- out += `"${folded}"`;
532
- at = end + 1;
533
- } else if (c === "[")
534
- characterClass();
535
- else
536
- out += literal2(c);
537
- }
538
- return out;
539
- }, "foldRegex");
540
-
541
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/search/trigrams.js
542
- var trigrams = /* @__PURE__ */ __name((term) => {
543
- const padded = ` ${term} `;
544
- const pieces = /* @__PURE__ */ new Set();
545
- for (let at = 0; at + 3 <= padded.length; at++)
546
- pieces.add(padded.slice(at, at + 3));
547
- return [...pieces];
548
- }, "trigrams");
549
-
550
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/resolve.js
551
- var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
552
- var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase().replaceAll("\u0451", "\u0435"), "foldName");
553
- var pickChat = /* @__PURE__ */ __name((reference, chats) => {
554
- const wanted = foldName(reference.trim());
555
- const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
556
- if (matches.length === 1 && matches[0])
557
- return matches[0];
558
- if (matches.length === 0)
559
- throw new CliError("not_found", `no chat matches "${reference}"`);
560
- throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
561
- }, "pickChat");
562
- var pickPerson = /* @__PURE__ */ __name((reference, people) => {
563
- const trimmed = reference.trim();
564
- const contact = contactReferenceOf(trimmed, people.provider);
565
- if (contact !== void 0) {
566
- const named = people.get(contact);
567
- if (named)
568
- return named;
569
- throw new CliError("not_found", `no person ${contact} in what this account has seen`);
570
- }
571
- const known = people.get(trimmed);
572
- if (known)
573
- return known;
574
- if (isId(trimmed))
575
- throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
576
- const wanted = foldName(trimmed.replace(/^@/, ""));
577
- const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
578
- const exact = everyone.filter((person) => namesOf(person).includes(wanted));
579
- const containing = everyone.filter((person) => namesOf(person).some((one) => one.includes(wanted)));
580
- if (exact.length === 1 && exact[0])
581
- return exact[0];
582
- if (containing.length === 1 && containing[0])
583
- return containing[0];
584
- if (containing.length === 0)
585
- throw new CliError("not_found", `nobody matches "${reference}"`);
586
- const matches = exact.length > 0 ? [...exact, ...containing.filter((person) => !exact.includes(person))] : containing;
587
- throw ambiguous(reference, "people", matches.map(({ id, name, username }) => ({ id, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
588
- }, "pickPerson");
589
- var namesOf = /* @__PURE__ */ __name((person, byAddress = false) => [person.alias, person.name, person.username, byAddress ? person.id : void 0].filter(isPresent).map(foldName), "namesOf");
590
- var chatNamesOf = /* @__PURE__ */ __name((chat) => [chat.title, chat.providerMetadata?.username].filter((one) => typeof one === "string" && one !== "").map(foldName), "chatNamesOf");
591
- var namePattern = /* @__PURE__ */ __name((pattern) => {
592
- const automaton = compileAutomaton(wildcardPattern(foldName(pattern.trim().replace(/^@/, ""))));
593
- return (names) => names.some((one) => automaton.test(one));
594
- }, "namePattern");
595
- var peopleMatching = /* @__PURE__ */ __name((pattern, people, { byAddress = false } = {}) => {
596
- const fits = namePattern(pattern);
597
- return people.filter((person) => fits(namesOf(person, byAddress)));
598
- }, "peopleMatching");
599
- var chatsMatching = /* @__PURE__ */ __name((pattern, chats) => {
600
- const fits = namePattern(pattern);
601
- return chats.filter((chat) => fits(chatNamesOf(chat)));
602
- }, "chatsMatching");
603
- var nearest = /* @__PURE__ */ __name((pattern, items, names, most = 5) => {
604
- const pieces = /* @__PURE__ */ __name((text2) => foldName(text2).split(/\s+/u).flatMap(trigrams), "pieces");
605
- const wanted = new Set(pieces(pattern.replace(/\\(.)/gu, "$1").replace(/[*?@]/gu, " ").trim()));
606
- if (wanted.size === 0)
607
- return [];
608
- return items.map((item) => ({
609
- item,
610
- score: names(item).flatMap(pieces).filter((piece) => wanted.has(piece)).length
611
- })).filter(({ score }) => score > 1).toSorted((a, b) => b.score - a.score).slice(0, most).map(({ item }) => item);
612
- }, "nearest");
613
- var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label2) => {
614
- const width = Math.max(...candidates.map(({ id }) => id.length));
615
- const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label2(candidate)}`).join("\n");
616
- return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
617
- ${lines}`, { candidates });
618
- }, "ambiguous");
619
- var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
620
-
621
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/record-fields.js
622
- var DECIMAL_PATTERN = "^[0-9]{1,16}(\\.[0-9]{1,6})?$";
623
- var SIGNED_DECIMAL = "^-?[0-9]{1,16}(\\.[0-9]{1,6})?$";
624
- var DAY = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$";
625
- 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})$";
626
- var text = /* @__PURE__ */ __name((description, maxLength = 2e3) => ({
627
- type: "string",
628
- minLength: 1,
629
- maxLength,
630
- ...description ? { description } : {}
631
- }), "text");
632
- var decimal = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: DECIMAL_PATTERN, description }), "decimal");
633
- var signedDecimal = /* @__PURE__ */ __name((description) => ({
634
- type: "string",
635
- pattern: SIGNED_DECIMAL,
636
- description
637
- }), "signedDecimal");
638
- var day = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: DAY, description }), "day");
639
- var instant = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: INSTANT, description }), "instant");
640
- var enumOf = /* @__PURE__ */ __name((values, description) => ({
641
- type: "string",
642
- enum: values,
643
- ...description ? { description } : {}
644
- }), "enumOf");
645
- var currency = { type: "string", pattern: "^[A-Za-z]{3}$", description: "ISO 4217 code" };
646
- var nullable = /* @__PURE__ */ __name((schema) => {
647
- if (schema.type === void 0)
648
- return schema;
649
- const types = typeof schema.type === "string" ? [schema.type] : [...schema.type];
650
- return {
651
- ...schema,
652
- type: types.includes("null") ? types : [...types, "null"],
653
- ...schema.enum ? { enum: [...schema.enum, null] } : {}
654
- };
655
- }, "nullable");
656
- var objectOf = /* @__PURE__ */ __name((properties, { required, description } = {}) => ({
657
- type: "object",
658
- ...description ? { description } : {},
659
- properties: Object.fromEntries(Object.entries(properties).map(([key, schema]) => [key, required?.includes(key) ? schema : nullable(schema)])),
660
- ...required?.length ? { required } : {},
661
- additionalProperties: true
662
- }), "objectOf");
663
- var arrayOf = /* @__PURE__ */ __name((item, maxItems, description) => ({
664
- type: "array",
665
- items: item,
666
- maxItems,
667
- description
668
- }), "arrayOf");
669
- var isObject = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isObject");
670
-
671
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/record-types.js
672
- var kept = /* @__PURE__ */ __name((description) => ({ description }), "kept");
673
- var PARTY = ["person", "organization"];
674
- var ORGANIZATION = ["organization"];
675
- var lineItem = objectOf({
676
- description: text("What the line is for; the product's name when left out", 2e3),
677
- quantity: decimal("A decimal, 1 when left out"),
678
- unit_price: decimal("A decimal in the parent's currency"),
679
- amount: decimal("A decimal in the parent's currency: quantity \xD7 unit price"),
680
- // Untyped: with options.lines text an invoice line's product is data, whatever v1 sent in it.
681
- product: { description: "The product record's external id in this account, read with options.lines products" },
682
- product_ref: { type: "string", pattern: "^product:[1-9][0-9]*$", description: "A product: ref of the store" }
683
- });
684
- var SMS_DIRECTIONS = ["in", "out"];
685
- var CALL_DIRECTIONS = ["in", "out", "missed"];
686
- var phoneFields = {
687
- phone: text("The other side's number as the phone shows it: read to E.164 with the store's phone_countries", 64),
688
- name: text("The other side's name as the phone shows it", 200)
689
- };
690
- var COUNTERPART = { counterpart: { targets: ["person"], linked: true } };
691
- var linesIn = /* @__PURE__ */ __name((table, parent) => ({ table, parent, references: { product: "product" }, refs: { product_ref: "product" } }), "linesIn");
692
- var dealFields = /* @__PURE__ */ __name((kind) => objectOf({
693
- title: text(`The ${kind}'s title`, 200),
694
- pipeline: text("The pipeline record's external id in this account", 512),
695
- stage: text("The stage's external id in that pipeline", 512),
696
- status: enumOf(DEAL_STATUSES, "Left out, the stage's outcome says it"),
697
- amount: decimal("A decimal in currency"),
698
- currency,
699
- close_date: day("When it is expected to close"),
700
- closed_date: day("When it was won or lost"),
701
- closed_reason: text("Why it was won or lost", 2e3),
702
- url: text("The source's page for it", 2e3)
703
- }, { required: ["title", "pipeline", "stage"] }), "dealFields");
704
- var RECORD_TYPES = {
705
- invoice: {
706
- table: "invoices",
707
- review: "proposal",
708
- update: "flag",
709
- tombstone: true,
710
- fields: objectOf({
711
- direction: enumOf(INVOICE_DIRECTIONS),
712
- number: text("The invoice's number", 80),
713
- currency,
714
- issue_date: day("The day it was issued"),
715
- due_date: day("The day it is due"),
716
- total: decimal("The printed total: refused when it is not the sum of the lines"),
717
- lines: arrayOf(lineItem, 500, "The invoice's lines")
718
- }),
719
- roles: {
720
- issuer: { targets: PARTY, v1: true, column: "issuer", pair: true },
721
- counterparty: { targets: PARTY, v1: true, column: "counterparty", pair: true },
722
- project: { targets: ["project"], v1: true, column: "project_id" },
723
- contract: { targets: ["contract"], column: "contract_id" },
724
- subscription: { targets: ["subscription"], column: "subscription_id" }
725
- },
726
- nested: { lines: linesIn("invoice_lines", "invoice_id") }
727
- },
728
- payment: {
729
- table: "payments",
730
- review: "proposal",
731
- update: "re-settle",
732
- tombstone: true,
733
- fields: objectOf({
734
- direction: enumOf(MONEY_DIRECTIONS),
735
- amount: decimal("A decimal in currency"),
736
- currency,
737
- date: day("The day it was paid"),
738
- reference: text("The payment's reference", 2e3)
739
- }),
740
- roles: {
741
- payer: { targets: PARTY, v1: true, column: "payer", pair: true },
742
- payee: { targets: PARTY, v1: true, column: "payee", pair: true },
743
- project: { targets: ["project"], v1: true, column: "project_id" },
744
- settles: { targets: ["invoice"], many: true, amount: true, v1: true },
745
- refund_of: { targets: ["payment"], column: "refund_of" },
746
- subscription: { targets: ["subscription"], column: "subscription_id" }
747
- }
748
- },
749
- person: {
750
- table: "persons",
751
- review: "identity",
752
- update: "in-place",
753
- tombstone: false,
754
- fields: objectOf({
755
- name: kept("The person's name"),
756
- email: kept("E-mail addresses, one or a list: an exact one links the record to the one person who has it"),
757
- phone: kept("Phone numbers, one or a list: an exact one, read to E.164, links like an e-mail"),
758
- position: kept("The job title, kept beside each member-of as its position: never the role")
759
- }),
760
- roles: { "member-of": { targets: ORGANIZATION, relationship: "member-of", kept: true } }
761
- },
762
- organization: {
763
- table: "organizations",
764
- review: "identity",
765
- update: "in-place",
766
- tombstone: true,
767
- fields: objectOf({
768
- name: kept("The organization's name"),
769
- 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")
770
- }),
771
- roles: {
772
- "customer-of": { targets: ORGANIZATION, relationship: "customer-of", kept: true },
773
- "partner-of": { targets: ORGANIZATION, relationship: "partner-of", kept: true }
774
- }
775
- },
776
- project: {
777
- table: "projects",
778
- review: "identity",
779
- update: "in-place",
780
- tombstone: true,
781
- fields: objectOf({
782
- name: kept("The project's name"),
783
- key: kept("The project's key: an existing project with it is this one"),
784
- description: kept("What the project is")
785
- }),
786
- roles: { organization: { targets: ORGANIZATION, column: "organization_id" } }
787
- },
788
- order: {
789
- table: "orders",
790
- review: "proposal",
791
- update: "re-propose",
792
- tombstone: true,
793
- fields: objectOf({
794
- number: text("The order's number at the supplier", 80),
795
- direction: enumOf(ORDER_DIRECTIONS, "purchase when left out; in a sale the owner is the supplier"),
796
- purpose: enumOf(ORDER_PURPOSES, "business when left out"),
797
- status: enumOf(ORDER_STATUSES, "placed when left out"),
798
- supplier_name: text("The shop or supplier as the source names it", 200),
799
- order_date: day("The day it was ordered"),
800
- fulfilled_date: day("The day it was delivered"),
801
- currency,
802
- total: decimal("With lines, their sum"),
803
- source_url: text("The order's page at the shop", 2e3),
804
- lines: arrayOf(lineItem, 500, "The order's lines")
805
- }),
806
- roles: {
807
- customer: { targets: PARTY, column: "customer", pair: true },
808
- supplier: { targets: PARTY, column: "supplier", pair: true },
809
- project: { targets: ["project"], column: "project_id" },
810
- contract: { targets: ["contract"], column: "contract_id" },
811
- deal: { targets: ["deal"], column: "deal_id" },
812
- invoice: { targets: ["invoice"], column: "invoice_id" },
813
- payment: { targets: ["payment"], column: "payment_id" }
814
- },
815
- nested: { lines: linesIn("order_lines", "order_id") }
816
- },
817
- product: {
818
- table: "catalog_items",
819
- review: "direct",
820
- update: "in-place",
821
- tombstone: true,
822
- fields: objectOf({
823
- kind: enumOf(CATALOG_KINDS, "product when left out"),
824
- name: text("The product's name", 200),
825
- sku: text("The supplier's code for it", 80),
826
- unit: text("hour, pcs, month: free text", 40),
827
- unit_price: decimal("A decimal in currency"),
828
- currency,
829
- description: text("What it is", 2e3),
830
- archived_date: day("No longer sold from this day")
831
- }, { required: ["name"] }),
832
- roles: { supplier: { targets: PARTY, column: "supplier", pair: true } }
833
- },
834
- contract: {
835
- table: "contracts",
836
- review: "valued-proposal",
837
- update: "re-propose",
838
- tombstone: true,
839
- fields: objectOf({
840
- name: text("The contract's name", 200),
841
- number: text("The contract's number", 80),
842
- kind: enumOf(CONTRACT_KINDS),
843
- status: enumOf(CONTRACT_STATUSES, "active when left out"),
844
- signed_date: day("The day it was signed"),
845
- effective_date: day("The day it starts"),
846
- expiration_date: day("The day it ends; open-ended when left out"),
847
- auto_renew: { type: "boolean", description: "Whether it renews itself" },
848
- renewal: { type: "string", pattern: "^[1-9][0-9]{0,2}-(day|week|month|year)$", description: "1-year" },
849
- notice_days: { type: "integer", minimum: 0, maximum: 3650, description: "Days of notice before it ends" },
850
- terms: text("Renewal, cancellation and other terms, as text", 2e4),
851
- value: decimal("A decimal in currency: the contract is then a proposal"),
852
- currency
853
- }, { required: ["name", "kind"] }),
854
- roles: {
855
- project: { targets: ["project"], column: "project_id" },
856
- deal: { targets: ["deal"], column: "deal_id" },
857
- party: { targets: PARTY, many: true, relationship: "related-to", kept: true },
858
- document: { targets: ["document"], many: true, kept: true }
859
- }
860
- },
861
- subscription: {
862
- table: "subscriptions",
863
- review: "proposal",
864
- update: "re-propose",
865
- tombstone: true,
866
- fields: objectOf({
867
- name: text("Its name; the product's when left out", 200),
868
- direction: enumOf(INVOICE_DIRECTIONS, "receivable: the owner bills it; payable: the owner pays it"),
869
- status: enumOf(SUBSCRIPTION_STATUSES),
870
- interval: { type: "string", pattern: "^[1-9][0-9]{0,2}-(day|week|month|year)$", description: "1-month" },
871
- start_date: day("The first day"),
872
- trial_end_date: day("The trial's last day"),
873
- next_renewal_date: day("The next renewal"),
874
- cancelled_date: day("The day it was cancelled"),
875
- end_date: day("The last day"),
876
- prices: arrayOf(objectOf({
877
- amount: decimal("A decimal in currency"),
878
- currency,
879
- effective_from: day("The day the price starts; the subscription's start when left out")
880
- }, { required: ["amount", "currency"] }), 100, "Its prices, each from a day; a price is never overwritten")
881
- }, { required: ["direction", "interval", "start_date"] }),
882
- roles: {
883
- supplier: { targets: PARTY, column: "supplier", pair: true },
884
- customer: { targets: PARTY, column: "customer", pair: true },
885
- product: { targets: ["product"], column: "catalog_item_id" },
886
- contract: { targets: ["contract"], column: "contract_id" },
887
- project: { targets: ["project"], column: "project_id" }
888
- },
889
- nested: { prices: { table: "subscription_prices", parent: "subscription_id" } }
890
- },
891
- wallet: {
892
- table: "financial_accounts",
893
- review: "direct",
894
- update: "in-place",
895
- tombstone: true,
896
- fields: objectOf({
897
- name: text("The account's name", 200),
898
- kind: enumOf(WALLET_KINDS, "bank when left out"),
899
- currency,
900
- institution: text("The bank, as text", 200),
901
- number_hint: text("The last 4 characters of its number; a whole IBAN or card number is refused", 4),
902
- opening_balance: signedDecimal("Kept in the record only: the owner sets the wallet's opening balance"),
903
- opening_date: day("The day of that balance")
904
- }, { required: ["name", "currency"] }),
905
- roles: { holder: { targets: PARTY, column: "holder", pair: true } }
906
- },
907
- transaction: {
908
- table: "financial_transactions",
909
- review: "proposal",
910
- update: "re-propose",
911
- tombstone: true,
912
- fields: objectOf({
913
- direction: enumOf(MONEY_DIRECTIONS),
914
- amount: decimal("A decimal above 0 in the wallet's currency"),
915
- currency,
916
- status: enumOf(TRANSACTION_STATUSES, "booked when left out"),
917
- date: day("The day the statement shows"),
918
- booked_date: day("The day it was booked; the statement day when left out"),
919
- description: text("As the statement says it", 2e3),
920
- counterparty_name: text("As the statement names the other side", 200),
921
- reference: text("The statement's reference", 200),
922
- splits: arrayOf(objectOf({
923
- amount: decimal("A decimal above 0"),
924
- category: text("Free text, such as rent", 200),
925
- note: text("A note", 2e3)
926
- }, { required: ["amount", "category"] }), 100, "Categories of its amount; what they leave is uncategorized")
927
- }, { required: ["direction", "amount", "date"] }),
928
- roles: {
929
- wallet: { targets: ["wallet"], required: true, column: "financial_account_id" },
930
- counterparty: { targets: PARTY, column: "counterparty", pair: true },
931
- payment: { targets: ["payment"], column: "payment_id" },
932
- project: { targets: ["project"], column: "project_id" }
933
- },
934
- nested: { splits: { table: "transaction_splits", parent: "transaction_id" } }
935
- },
936
- deal: {
937
- table: "deals",
938
- review: "direct",
939
- update: "in-place",
940
- tombstone: true,
941
- fields: dealFields("deal"),
942
- references: { pipeline: "pipeline" },
943
- roles: {
944
- organization: { targets: ORGANIZATION, column: "organization_id" },
945
- person: { targets: ["person"], many: true, relationship: "related-to", kept: true },
946
- project: { targets: ["project"], column: "project_id" }
947
- }
948
- },
949
- lead: {
950
- table: "leads",
951
- review: "direct",
952
- update: "in-place",
953
- tombstone: true,
954
- fields: dealFields("lead"),
955
- references: { pipeline: "pipeline" },
956
- roles: {
957
- organization: { targets: ORGANIZATION, column: "organization_id" },
958
- person: { targets: ["person"], many: true, relationship: "related-to", kept: true },
959
- project: { targets: ["project"], column: "project_id" },
960
- deal: { targets: ["deal"], column: "deal_id" }
961
- }
962
- },
963
- message: {
964
- table: "messages",
965
- review: "direct",
966
- update: "in-place",
967
- tombstone: true,
968
- importOnly: true,
969
- sheet: false,
970
- fields: objectOf({
971
- kind: enumOf(["sms"], "sms: a text message of the phone"),
972
- direction: enumOf(SMS_DIRECTIONS, "in: the other side wrote it; out: the owner did"),
973
- ...phoneFields,
974
- thread: text("The phone's thread id; the number when left out", 512),
975
- body: { type: "string", maxLength: 2e4, description: "The text" },
976
- sent_at: instant("When it was sent"),
977
- read: { type: "boolean", description: "An incoming message the owner opened" }
978
- }, { required: ["kind", "direction", "phone", "body", "sent_at"] }),
979
- roles: COUNTERPART
980
- },
981
- event: {
982
- table: "events",
983
- review: "direct",
984
- update: "in-place",
985
- tombstone: true,
986
- importOnly: true,
987
- sheet: false,
988
- fields: objectOf({
989
- kind: enumOf(["call"], "call: a phone call"),
990
- direction: enumOf(CALL_DIRECTIONS, "in, out, or missed: a call the owner did not take"),
991
- ...phoneFields,
992
- started_at: instant("When it rang"),
993
- duration: { type: "integer", minimum: 0, maximum: 604800, description: "Seconds talked; 0 when missed" }
994
- }, { required: ["kind", "direction", "phone", "started_at"] }),
995
- roles: COUNTERPART
996
- },
997
- document: {
998
- table: "documents",
999
- review: "direct",
1000
- update: "in-place",
1001
- tombstone: true,
1002
- importOnly: true,
1003
- fieldsBytes: 1048576,
1004
- fields: objectOf({
1005
- title: text("What the document is called; its external id when left out", 500),
1006
- text: { type: "string", maxLength: 1e6, description: "The text search reads" },
1007
- created_at: instant("When the source made it"),
1008
- updated_at: instant("When the source last changed it: what date: reads"),
1009
- url: text("Where the original is", 4096),
1010
- metadata: { type: "object", description: "Anything else the source knows about it, kept as sent" }
1011
- }, { required: ["text"] }),
1012
- roles: {
1013
- about: { targets: ["person", "organization", "deal", "event"], many: true }
1014
- }
1015
- },
1016
- pipeline: {
1017
- table: "pipelines",
1018
- review: "direct",
1019
- update: "in-place",
1020
- tombstone: false,
1021
- fields: objectOf({
1022
- kind: enumOf(DEAL_KINDS, "deal when left out"),
1023
- name: text("The pipeline's name", 80),
1024
- stages: arrayOf(objectOf({
1025
- external_id: text("The stage's id at the source", 512),
1026
- name: text("The stage's name", 80),
1027
- position: { type: "integer", minimum: 0, maximum: 1e3 },
1028
- outcome: enumOf(DEAL_STATUSES, "open when left out")
1029
- }, { required: ["external_id", "name"] }), 30, "The stages in order")
1030
- }, { required: ["name", "stages"] }),
1031
- roles: {},
1032
- nested: { stages: { table: "pipeline_stages", parent: "pipeline_id" } }
1033
- }
1034
- };
1035
- var isRecordType = /* @__PURE__ */ __name((type) => Object.hasOwn(RECORD_TYPES, type), "isRecordType");
1036
- var isBusinessType = /* @__PURE__ */ __name((type) => isRecordType(type) && RECORD_TYPES[type].review !== "identity" && type !== "document", "isBusinessType");
1037
- var isIdentityType = /* @__PURE__ */ __name((type) => typeof type === "string" && isRecordType(type) && RECORD_TYPES[type].review === "identity", "isIdentityType");
1038
- var RECORD_ENTITY_TYPES = Object.keys(RECORD_TYPES);
1039
- var RECORD_TABLES = Object.fromEntries(Object.entries(RECORD_TYPES).map(([type, spec]) => [type, spec.table]));
1040
- var decidedOf = /* @__PURE__ */ __name((types) => Object.fromEntries(Object.entries(types).flatMap(([type, spec]) => spec.review === "proposal" || spec.review === "valued-proposal" ? [[type, spec.table]] : [])), "decidedOf");
1041
- var DECIDED_TABLES = {
1042
- ...decidedOf(RECORD_TYPES),
1043
- subscription_price: "subscription_prices"
1044
- };
1045
- var WORD_BODY = "[a-z0-9][a-z0-9_-]{0,62}";
1046
- var TYPE_PATTERN = `^(${RECORD_ENTITY_TYPES.join("|")}|custom:${WORD_BODY})$`;
1047
- var TYPE_RULE = `a type is one of ${RECORD_ENTITY_TYPES.join(", ")} or custom:<name>`;
1048
- var rolesOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].roles), "rolesOf");
1049
- var roleOf = /* @__PURE__ */ __name((type, role) => {
1050
- if (!isRecordType(type))
1051
- return void 0;
1052
- const roles = RECORD_TYPES[type].roles;
1053
- return Object.hasOwn(roles, role) ? roles[role] : void 0;
1054
- }, "roleOf");
1055
- var nestedOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].nested ?? {}), "nestedOf");
1056
- var referencesOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].references ?? {}), "referencesOf");
1057
- var roleNames = /* @__PURE__ */ __name((types, keep) => [
1058
- ...new Set(types.flatMap((type) => rolesOf(type).flatMap(([name, role]) => keep(role) ? [name] : [])))
1059
- ], "roleNames");
1060
- var AMOUNT_ROLES = roleNames(RECORD_ENTITY_TYPES, (role) => role.amount);
1061
- var FIELD_REFERENCE_ROLES = roleNames(RECORD_ENTITY_TYPES, (role) => role.v1 && !role.many);
1062
- var hasV1Roles = /* @__PURE__ */ __name((type) => rolesOf(type).some(([, role]) => role.v1), "hasV1Roles");
1063
- var IDENTITY_TYPES = RECORD_ENTITY_TYPES.filter((type) => RECORD_TYPES[type].review === "identity");
1064
- var article2 = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
1065
-
1066
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/addresses.js
1067
- var EMAIL_ADDRESS = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u;
1068
- var isEmailAddress = /* @__PURE__ */ __name((value) => EMAIL_ADDRESS.test(value), "isEmailAddress");
1069
- var ROLE_ADDRESS_WORDS = {
1070
- noReply: ["noreply", "no-reply", "donotreply", "do-not-reply", "mailer-daemon", "bounce", "bounces"],
1071
- shared: [
1072
- "info",
1073
- "hello",
1074
- "hi",
1075
- "contact",
1076
- "contacts",
1077
- "support",
1078
- "help",
1079
- "helpdesk",
1080
- "service",
1081
- "sales",
1082
- "office",
1083
- "admin",
1084
- "team",
1085
- "billing",
1086
- "accounts",
1087
- "accounting",
1088
- "invoices",
1089
- "finance",
1090
- "hr",
1091
- "jobs",
1092
- "careers",
1093
- "press",
1094
- "media",
1095
- "marketing",
1096
- "partners",
1097
- "legal",
1098
- "privacy",
1099
- "security",
1100
- "abuse",
1101
- "postmaster",
1102
- "webmaster",
1103
- "mail",
1104
- "inbox",
1105
- "enquiries",
1106
- "inquiries",
1107
- "booking",
1108
- "reservations",
1109
- "orders",
1110
- "feedback",
1111
- "newsletter",
1112
- "notifications",
1113
- "alerts"
1114
- ]
1115
- };
1116
- var bare = /* @__PURE__ */ __name((word) => word.replace(/[.\-_]/gu, ""), "bare");
1117
- var NO_REPLY = new Set(ROLE_ADDRESS_WORDS.noReply.map(bare));
1118
- var ROLE = new Set([...ROLE_ADDRESS_WORDS.shared, ...ROLE_ADDRESS_WORDS.noReply].map(bare));
1119
- var localWord = /* @__PURE__ */ __name((address) => {
1120
- const local = address.trim().toLowerCase().split("@")[0] ?? "";
1121
- return bare(local.split("+")[0] ?? "");
1122
- }, "localWord");
1123
- var isRoleAddress = /* @__PURE__ */ __name((address) => ROLE.has(localWord(address)), "isRoleAddress");
1124
- var PERSON_LIKE = /* @__PURE__ */ new Set(["hr"]);
1125
- var isPersonLikeRoleAddress = /* @__PURE__ */ __name((address) => PERSON_LIKE.has(localWord(address)), "isPersonLikeRoleAddress");
1126
- var isNoReplyAddress = /* @__PURE__ */ __name((address) => NO_REPLY.has(localWord(address)), "isNoReplyAddress");
1127
-
1128
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
36
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
1129
37
  var PHONE_PLANS = [
1130
38
  {
1131
39
  country: "us",
@@ -1375,212 +283,1304 @@ var PHONE_PLANS = [
1375
283
  valid: "(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",
1376
284
  mobile: "7060\\d{5}|(?:60[1-8]|7(?:0[2-5]|19|[2379]\\d))\\d{6}"
1377
285
  },
1378
- {
1379
- country: "pl",
1380
- code: "48",
1381
- trunk: "",
1382
- lengths: [6, 7, 8, 9, 10],
1383
- valid: "(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",
1384
- mobile: "21(?:1[013-5]|2\\d|3[1-9])\\d{5}|(?:45|5[0137]|6[069]|7[2389]|88)\\d{7}"
286
+ {
287
+ country: "pl",
288
+ code: "48",
289
+ trunk: "",
290
+ lengths: [6, 7, 8, 9, 10],
291
+ valid: "(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",
292
+ mobile: "21(?:1[013-5]|2\\d|3[1-9])\\d{5}|(?:45|5[0137]|6[069]|7[2389]|88)\\d{7}"
293
+ },
294
+ {
295
+ country: "lt",
296
+ code: "370",
297
+ trunk: "[08]",
298
+ lengths: [8],
299
+ valid: "(?:[3469]\\d|52|[78]0)\\d{6}",
300
+ mobile: "6\\d{7}"
301
+ },
302
+ {
303
+ country: "lv",
304
+ code: "371",
305
+ trunk: "",
306
+ lengths: [8],
307
+ valid: "(?:[268]\\d|78|90)\\d{6}",
308
+ 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}"
309
+ },
310
+ {
311
+ country: "ee",
312
+ code: "372",
313
+ trunk: "",
314
+ lengths: [7, 8, 10],
315
+ valid: "8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",
316
+ 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}"
317
+ },
318
+ {
319
+ country: "fi",
320
+ code: "358",
321
+ trunk: "0",
322
+ lengths: [5, 6, 7, 8, 9, 10, 11, 12],
323
+ valid: "[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",
324
+ mobile: "4946\\d{2,6}|(?:4[0-8]|50)\\d{4,8}"
325
+ },
326
+ {
327
+ country: "se",
328
+ code: "46",
329
+ trunk: "0",
330
+ lengths: [6, 7, 8, 9, 10, 12],
331
+ valid: "(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",
332
+ mobile: "7[023689]\\d{7}"
333
+ },
334
+ {
335
+ country: "no",
336
+ code: "47",
337
+ trunk: "",
338
+ lengths: [5, 8],
339
+ valid: "(?:0|[2-9]\\d{3})\\d{4}",
340
+ mobile: "45(?:[0-24-9]\\d|3[0-57-9])\\d{4}|(?:4[016-8]|9\\d)\\d{6}"
341
+ },
342
+ {
343
+ country: "dk",
344
+ code: "45",
345
+ trunk: "",
346
+ lengths: [8],
347
+ valid: "[2-9]\\d{7}",
348
+ 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}"
349
+ },
350
+ {
351
+ country: "is",
352
+ code: "354",
353
+ trunk: "",
354
+ lengths: [7, 9],
355
+ valid: "(?:38\\d|[4-9])\\d{6}",
356
+ 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}"
357
+ },
358
+ {
359
+ country: "ua",
360
+ code: "380",
361
+ trunk: "0",
362
+ lengths: [9, 10],
363
+ valid: "[89]\\d{9}|[3-9]\\d{8}",
364
+ mobile: "790\\d{6}|(?:39|50|6[36-8]|7[1-357]|9[1-9])\\d{7}"
365
+ },
366
+ {
367
+ country: "by",
368
+ code: "375",
369
+ trunk: "0|80?",
370
+ lengths: [6, 7, 8, 9, 10, 11],
371
+ 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}",
372
+ mobile: "(?:2(?:5[5-79]|9[1-9])|(?:33|44)\\d)\\d{6}"
373
+ },
374
+ {
375
+ country: "ru",
376
+ code: "7",
377
+ trunk: "8",
378
+ lengths: [10, 14],
379
+ valid: "8\\d{13}|[347-9]\\d{9}",
380
+ mobile: "9\\d{9}"
381
+ },
382
+ {
383
+ country: "kz",
384
+ code: "7",
385
+ trunk: "8",
386
+ lengths: [10, 14],
387
+ valid: "8\\d{13}|[78]\\d{9}",
388
+ mobile: "7(?:0[0-25-8]|47|6[0-4]|7[15-8]|85)\\d{7}"
389
+ },
390
+ {
391
+ country: "ge",
392
+ code: "995",
393
+ trunk: "0",
394
+ lengths: [9],
395
+ valid: "(?:[3-57]\\d\\d|800)\\d{6}",
396
+ 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}"
397
+ },
398
+ {
399
+ country: "am",
400
+ code: "374",
401
+ trunk: "0",
402
+ lengths: [8],
403
+ valid: "(?:[1-489]\\d|55|60|77)\\d{6}",
404
+ mobile: "(?:33|4[1349]|55|77|88|9[13-9])\\d{6}"
405
+ },
406
+ {
407
+ country: "tr",
408
+ code: "90",
409
+ trunk: "0",
410
+ lengths: [7, 10, 12, 13],
411
+ valid: "4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",
412
+ 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}"
413
+ }
414
+ ];
415
+
416
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/phones.js
417
+ var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
418
+ var DEFAULT_PHONE_COUNTRIES = ["ru"];
419
+ var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
420
+ const countries = value.split(/[\s,]+/).map((one) => one.trim().toLowerCase()).filter(Boolean);
421
+ const unknown = countries.filter((one) => !PHONE_COUNTRIES.includes(one));
422
+ if (countries.length === 0 || unknown.length > 0)
423
+ throw new CliError("validation_error", `phone_countries takes country codes, ${unknown.length > 0 ? `not ${unknown.join(", ")}` : "at least one"}: ` + PHONE_COUNTRIES.join(", "));
424
+ return [...new Set(countries)];
425
+ }, "parsePhoneCountries");
426
+ var PLANS = new Map(PHONE_PLANS.map((plan) => [
427
+ plan.country,
428
+ {
429
+ code: plan.code,
430
+ trunk: plan.trunk ? new RegExp(`^(?:${plan.trunk})`) : null,
431
+ lengths: new Set(plan.lengths),
432
+ valid: new RegExp(`^(?:${plan.valid})$`),
433
+ mobile: plan.mobile === null ? null : new RegExp(`^(?:${plan.mobile})$`)
434
+ }
435
+ ]));
436
+ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
437
+ for (const country of countries) {
438
+ const plan = PLANS.get(country);
439
+ if (!plan)
440
+ continue;
441
+ const readings = [
442
+ ...plan.trunk?.test(digits) ? [digits.replace(plan.trunk, "")] : [],
443
+ digits,
444
+ ...digits.startsWith(plan.code) ? [digits.slice(plan.code.length)] : []
445
+ ];
446
+ for (const national of readings) {
447
+ if (!plan.lengths.has(national.length) || !plan.valid.test(national))
448
+ continue;
449
+ const mobile = plan.mobile?.test(national) ?? false;
450
+ if (anyType || mobile)
451
+ return { value: `+${plan.code}${national}`, national, mobile };
452
+ }
453
+ }
454
+ return void 0;
455
+ }, "nationalPhone");
456
+ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE_COUNTRIES } = {}) => {
457
+ const text2 = typed.trim();
458
+ if (!/^\+?[\d\s().\-–]+$/.test(text2))
459
+ return void 0;
460
+ const digits = text2.replace(/\(0\)/, "").replace(/\D/g, "").replace(/^00/, "");
461
+ if (digits.length < 7 || digits.length > 15)
462
+ return void 0;
463
+ const national = nationalPhone(digits, phoneCountries, { anyType: true });
464
+ const tail = national?.national ?? digits.replace(/^0+/, "");
465
+ return {
466
+ value: text2.startsWith("+") || /^00/.test(text2) ? `+${digits}` : national?.value ?? digits,
467
+ national: tail.length >= 8 ? tail : null
468
+ };
469
+ }, "typedPhone");
470
+ var e164Of = /* @__PURE__ */ __name((phone, region) => {
471
+ if (/^\s*(\+|00)/.test(phone))
472
+ return typedPhone(phone)?.value;
473
+ if (typedPhone(phone) === void 0)
474
+ return void 0;
475
+ if (region === void 0)
476
+ return null;
477
+ const digits = phone.replace(/\(0\)/, "").replace(/\D/g, "");
478
+ return nationalPhone(digits, [region], { anyType: true })?.value;
479
+ }, "e164Of");
480
+ var isMobilePhone = /* @__PURE__ */ __name((e164) => /^\+\d+$/.test(e164) && PHONE_COUNTRIES.some((country) => nationalPhone(e164.slice(1), [country], { anyType: false })?.value === e164), "isMobilePhone");
481
+ var BARE_INTERNATIONAL_PROVIDERS = ["telegram", "max", "whatsapp"];
482
+ var storedPhone = /* @__PURE__ */ __name((raw, provider) => {
483
+ if (/^\s*(\+|00)/.test(raw))
484
+ return typedPhone(raw)?.value;
485
+ if (!BARE_INTERNATIONAL_PROVIDERS.includes(provider))
486
+ return void 0;
487
+ const found = /^([1-9]\d{6,14})$/.exec(raw.trim());
488
+ return found ? `+${found[1]}` : void 0;
489
+ }, "storedPhone");
490
+
491
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/record-fields.js
492
+ var DECIMAL_PATTERN = "^[0-9]{1,16}(\\.[0-9]{1,6})?$";
493
+ var SIGNED_DECIMAL = "^-?[0-9]{1,16}(\\.[0-9]{1,6})?$";
494
+ var DAY = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$";
495
+ 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})$";
496
+ var text = /* @__PURE__ */ __name((description, maxLength = 2e3) => ({
497
+ type: "string",
498
+ minLength: 1,
499
+ maxLength,
500
+ ...description ? { description } : {}
501
+ }), "text");
502
+ var decimal = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: DECIMAL_PATTERN, description }), "decimal");
503
+ var signedDecimal = /* @__PURE__ */ __name((description) => ({
504
+ type: "string",
505
+ pattern: SIGNED_DECIMAL,
506
+ description
507
+ }), "signedDecimal");
508
+ var day = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: DAY, description }), "day");
509
+ var instant = /* @__PURE__ */ __name((description) => ({ type: "string", pattern: INSTANT, description }), "instant");
510
+ var enumOf = /* @__PURE__ */ __name((values, description) => ({
511
+ type: "string",
512
+ enum: values,
513
+ ...description ? { description } : {}
514
+ }), "enumOf");
515
+ var currency = { type: "string", pattern: "^[A-Za-z]{3}$", description: "ISO 4217 code" };
516
+ var nullable = /* @__PURE__ */ __name((schema) => {
517
+ if (schema.type === void 0)
518
+ return schema;
519
+ const types = typeof schema.type === "string" ? [schema.type] : [...schema.type];
520
+ return {
521
+ ...schema,
522
+ type: types.includes("null") ? types : [...types, "null"],
523
+ ...schema.enum ? { enum: [...schema.enum, null] } : {}
524
+ };
525
+ }, "nullable");
526
+ var objectOf = /* @__PURE__ */ __name((properties, { required, description } = {}) => ({
527
+ type: "object",
528
+ ...description ? { description } : {},
529
+ properties: Object.fromEntries(Object.entries(properties).map(([key, schema]) => [key, required?.includes(key) ? schema : nullable(schema)])),
530
+ ...required?.length ? { required } : {},
531
+ additionalProperties: true
532
+ }), "objectOf");
533
+ var arrayOf = /* @__PURE__ */ __name((item, maxItems, description) => ({
534
+ type: "array",
535
+ items: item,
536
+ maxItems,
537
+ description
538
+ }), "arrayOf");
539
+ var isObject = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isObject");
540
+
541
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/record-types.js
542
+ var kept = /* @__PURE__ */ __name((description) => ({ description }), "kept");
543
+ var PARTY = ["person", "organization"];
544
+ var ORGANIZATION = ["organization"];
545
+ var lineItem = objectOf({
546
+ description: text("What the line is for; the product's name when left out", 2e3),
547
+ quantity: decimal("A decimal, 1 when left out"),
548
+ unit_price: decimal("A decimal in the parent's currency"),
549
+ amount: decimal("A decimal in the parent's currency: quantity \xD7 unit price"),
550
+ // Untyped: with options.lines text an invoice line's product is data, whatever v1 sent in it.
551
+ product: { description: "The product record's external id in this account, read with options.lines products" },
552
+ product_ref: { type: "string", pattern: "^product:[1-9][0-9]*$", description: "A product: ref of the store" }
553
+ });
554
+ var SMS_DIRECTIONS = ["in", "out"];
555
+ var CALL_DIRECTIONS = ["in", "out", "missed"];
556
+ var phoneFields = {
557
+ phone: text("The other side's number as the phone shows it: read to E.164 with the store's phone_countries", 64),
558
+ name: text("The other side's name as the phone shows it", 200)
559
+ };
560
+ var COUNTERPART = { counterpart: { targets: ["person"], linked: true } };
561
+ var linesIn = /* @__PURE__ */ __name((table, parent) => ({ table, parent, references: { product: "product" }, refs: { product_ref: "product" } }), "linesIn");
562
+ var dealFields = /* @__PURE__ */ __name((kind) => objectOf({
563
+ title: text(`The ${kind}'s title`, 200),
564
+ pipeline: text("The pipeline record's external id in this account", 512),
565
+ stage: text("The stage's external id in that pipeline", 512),
566
+ status: enumOf(DEAL_STATUSES, "Left out, the stage's outcome says it"),
567
+ amount: decimal("A decimal in currency"),
568
+ currency,
569
+ close_date: day("When it is expected to close"),
570
+ closed_date: day("When it was won or lost"),
571
+ closed_reason: text("Why it was won or lost", 2e3),
572
+ url: text("The source's page for it", 2e3)
573
+ }, { required: ["title", "pipeline", "stage"] }), "dealFields");
574
+ var RECORD_TYPES = {
575
+ invoice: {
576
+ table: "invoices",
577
+ review: "proposal",
578
+ update: "flag",
579
+ tombstone: true,
580
+ fields: objectOf({
581
+ direction: enumOf(INVOICE_DIRECTIONS),
582
+ number: text("The invoice's number", 80),
583
+ currency,
584
+ issue_date: day("The day it was issued"),
585
+ due_date: day("The day it is due"),
586
+ total: decimal("The printed total: refused when it is not the sum of the lines"),
587
+ lines: arrayOf(lineItem, 500, "The invoice's lines")
588
+ }),
589
+ roles: {
590
+ issuer: { targets: PARTY, v1: true, column: "issuer", pair: true },
591
+ counterparty: { targets: PARTY, v1: true, column: "counterparty", pair: true },
592
+ project: { targets: ["project"], v1: true, column: "project_id" },
593
+ contract: { targets: ["contract"], column: "contract_id" },
594
+ subscription: { targets: ["subscription"], column: "subscription_id" }
595
+ },
596
+ nested: { lines: linesIn("invoice_lines", "invoice_id") }
597
+ },
598
+ payment: {
599
+ table: "payments",
600
+ review: "proposal",
601
+ update: "re-settle",
602
+ tombstone: true,
603
+ fields: objectOf({
604
+ direction: enumOf(MONEY_DIRECTIONS),
605
+ amount: decimal("A decimal in currency"),
606
+ currency,
607
+ date: day("The day it was paid"),
608
+ reference: text("The payment's reference", 2e3)
609
+ }),
610
+ roles: {
611
+ payer: { targets: PARTY, v1: true, column: "payer", pair: true },
612
+ payee: { targets: PARTY, v1: true, column: "payee", pair: true },
613
+ project: { targets: ["project"], v1: true, column: "project_id" },
614
+ settles: { targets: ["invoice"], many: true, amount: true, v1: true },
615
+ refund_of: { targets: ["payment"], column: "refund_of" },
616
+ subscription: { targets: ["subscription"], column: "subscription_id" }
617
+ }
1385
618
  },
1386
- {
1387
- country: "lt",
1388
- code: "370",
1389
- trunk: "[08]",
1390
- lengths: [8],
1391
- valid: "(?:[3469]\\d|52|[78]0)\\d{6}",
1392
- mobile: "6\\d{7}"
619
+ person: {
620
+ table: "persons",
621
+ review: "identity",
622
+ update: "in-place",
623
+ tombstone: false,
624
+ fields: objectOf({
625
+ name: kept("The person's name"),
626
+ email: kept("E-mail addresses, one or a list: an exact one links the record to the one person who has it"),
627
+ phone: kept("Phone numbers, one or a list: an exact one, read to E.164, links like an e-mail"),
628
+ position: kept("The job title, kept beside each member-of as its position: never the role")
629
+ }),
630
+ roles: { "member-of": { targets: ORGANIZATION, relationship: "member-of", kept: true } }
1393
631
  },
1394
- {
1395
- country: "lv",
1396
- code: "371",
1397
- trunk: "",
1398
- lengths: [8],
1399
- valid: "(?:[268]\\d|78|90)\\d{6}",
1400
- 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}"
632
+ organization: {
633
+ table: "organizations",
634
+ review: "identity",
635
+ update: "in-place",
636
+ tombstone: true,
637
+ fields: objectOf({
638
+ name: kept("The organization's name"),
639
+ 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")
640
+ }),
641
+ roles: {
642
+ "customer-of": { targets: ORGANIZATION, relationship: "customer-of", kept: true },
643
+ "partner-of": { targets: ORGANIZATION, relationship: "partner-of", kept: true }
644
+ }
1401
645
  },
1402
- {
1403
- country: "ee",
1404
- code: "372",
1405
- trunk: "",
1406
- lengths: [7, 8, 10],
1407
- valid: "8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",
1408
- 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}"
646
+ project: {
647
+ table: "projects",
648
+ review: "identity",
649
+ update: "in-place",
650
+ tombstone: true,
651
+ fields: objectOf({
652
+ name: kept("The project's name"),
653
+ key: kept("The project's key: an existing project with it is this one"),
654
+ description: kept("What the project is")
655
+ }),
656
+ roles: { organization: { targets: ORGANIZATION, column: "organization_id" } }
1409
657
  },
1410
- {
1411
- country: "fi",
1412
- code: "358",
1413
- trunk: "0",
1414
- lengths: [5, 6, 7, 8, 9, 10, 11, 12],
1415
- valid: "[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",
1416
- mobile: "4946\\d{2,6}|(?:4[0-8]|50)\\d{4,8}"
658
+ order: {
659
+ table: "orders",
660
+ review: "proposal",
661
+ update: "re-propose",
662
+ tombstone: true,
663
+ fields: objectOf({
664
+ number: text("The order's number at the supplier", 80),
665
+ direction: enumOf(ORDER_DIRECTIONS, "purchase when left out; in a sale the owner is the supplier"),
666
+ purpose: enumOf(ORDER_PURPOSES, "business when left out"),
667
+ status: enumOf(ORDER_STATUSES, "placed when left out"),
668
+ supplier_name: text("The shop or supplier as the source names it", 200),
669
+ order_date: day("The day it was ordered"),
670
+ fulfilled_date: day("The day it was delivered"),
671
+ currency,
672
+ total: decimal("With lines, their sum"),
673
+ source_url: text("The order's page at the shop", 2e3),
674
+ lines: arrayOf(lineItem, 500, "The order's lines")
675
+ }),
676
+ roles: {
677
+ customer: { targets: PARTY, column: "customer", pair: true },
678
+ supplier: { targets: PARTY, column: "supplier", pair: true },
679
+ project: { targets: ["project"], column: "project_id" },
680
+ contract: { targets: ["contract"], column: "contract_id" },
681
+ deal: { targets: ["deal"], column: "deal_id" },
682
+ invoice: { targets: ["invoice"], column: "invoice_id" },
683
+ payment: { targets: ["payment"], column: "payment_id" }
684
+ },
685
+ nested: { lines: linesIn("order_lines", "order_id") }
1417
686
  },
1418
- {
1419
- country: "se",
1420
- code: "46",
1421
- trunk: "0",
1422
- lengths: [6, 7, 8, 9, 10, 12],
1423
- valid: "(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",
1424
- mobile: "7[023689]\\d{7}"
687
+ product: {
688
+ table: "catalog_items",
689
+ review: "direct",
690
+ update: "in-place",
691
+ tombstone: true,
692
+ fields: objectOf({
693
+ kind: enumOf(CATALOG_KINDS, "product when left out"),
694
+ name: text("The product's name", 200),
695
+ sku: text("The supplier's code for it", 80),
696
+ unit: text("hour, pcs, month: free text", 40),
697
+ unit_price: decimal("A decimal in currency"),
698
+ currency,
699
+ description: text("What it is", 2e3),
700
+ archived_date: day("No longer sold from this day")
701
+ }, { required: ["name"] }),
702
+ roles: { supplier: { targets: PARTY, column: "supplier", pair: true } }
1425
703
  },
1426
- {
1427
- country: "no",
1428
- code: "47",
1429
- trunk: "",
1430
- lengths: [5, 8],
1431
- valid: "(?:0|[2-9]\\d{3})\\d{4}",
1432
- mobile: "45(?:[0-24-9]\\d|3[0-57-9])\\d{4}|(?:4[016-8]|9\\d)\\d{6}"
704
+ contract: {
705
+ table: "contracts",
706
+ review: "valued-proposal",
707
+ update: "re-propose",
708
+ tombstone: true,
709
+ fields: objectOf({
710
+ name: text("The contract's name", 200),
711
+ number: text("The contract's number", 80),
712
+ kind: enumOf(CONTRACT_KINDS),
713
+ status: enumOf(CONTRACT_STATUSES, "active when left out"),
714
+ signed_date: day("The day it was signed"),
715
+ effective_date: day("The day it starts"),
716
+ expiration_date: day("The day it ends; open-ended when left out"),
717
+ auto_renew: { type: "boolean", description: "Whether it renews itself" },
718
+ renewal: { type: "string", pattern: "^[1-9][0-9]{0,2}-(day|week|month|year)$", description: "1-year" },
719
+ notice_days: { type: "integer", minimum: 0, maximum: 3650, description: "Days of notice before it ends" },
720
+ terms: text("Renewal, cancellation and other terms, as text", 2e4),
721
+ value: decimal("A decimal in currency: the contract is then a proposal"),
722
+ currency
723
+ }, { required: ["name", "kind"] }),
724
+ roles: {
725
+ project: { targets: ["project"], column: "project_id" },
726
+ deal: { targets: ["deal"], column: "deal_id" },
727
+ party: { targets: PARTY, many: true, relationship: "related-to", kept: true },
728
+ document: { targets: ["document"], many: true, kept: true }
729
+ }
1433
730
  },
1434
- {
1435
- country: "dk",
1436
- code: "45",
1437
- trunk: "",
1438
- lengths: [8],
1439
- valid: "[2-9]\\d{7}",
1440
- 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}"
731
+ subscription: {
732
+ table: "subscriptions",
733
+ review: "proposal",
734
+ update: "re-propose",
735
+ tombstone: true,
736
+ fields: objectOf({
737
+ name: text("Its name; the product's when left out", 200),
738
+ direction: enumOf(INVOICE_DIRECTIONS, "receivable: the owner bills it; payable: the owner pays it"),
739
+ status: enumOf(SUBSCRIPTION_STATUSES),
740
+ interval: { type: "string", pattern: "^[1-9][0-9]{0,2}-(day|week|month|year)$", description: "1-month" },
741
+ start_date: day("The first day"),
742
+ trial_end_date: day("The trial's last day"),
743
+ next_renewal_date: day("The next renewal"),
744
+ cancelled_date: day("The day it was cancelled"),
745
+ end_date: day("The last day"),
746
+ prices: arrayOf(objectOf({
747
+ amount: decimal("A decimal in currency"),
748
+ currency,
749
+ effective_from: day("The day the price starts; the subscription's start when left out")
750
+ }, { required: ["amount", "currency"] }), 100, "Its prices, each from a day; a price is never overwritten")
751
+ }, { required: ["direction", "interval", "start_date"] }),
752
+ roles: {
753
+ supplier: { targets: PARTY, column: "supplier", pair: true },
754
+ customer: { targets: PARTY, column: "customer", pair: true },
755
+ product: { targets: ["product"], column: "catalog_item_id" },
756
+ contract: { targets: ["contract"], column: "contract_id" },
757
+ project: { targets: ["project"], column: "project_id" }
758
+ },
759
+ nested: { prices: { table: "subscription_prices", parent: "subscription_id" } }
1441
760
  },
1442
- {
1443
- country: "is",
1444
- code: "354",
1445
- trunk: "",
1446
- lengths: [7, 9],
1447
- valid: "(?:38\\d|[4-9])\\d{6}",
1448
- 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}"
761
+ wallet: {
762
+ table: "financial_accounts",
763
+ review: "direct",
764
+ update: "in-place",
765
+ tombstone: true,
766
+ fields: objectOf({
767
+ name: text("The account's name", 200),
768
+ kind: enumOf(WALLET_KINDS, "bank when left out"),
769
+ currency,
770
+ institution: text("The bank, as text", 200),
771
+ number_hint: text("The last 4 characters of its number; a whole IBAN or card number is refused", 4),
772
+ opening_balance: signedDecimal("Kept in the record only: the owner sets the wallet's opening balance"),
773
+ opening_date: day("The day of that balance")
774
+ }, { required: ["name", "currency"] }),
775
+ roles: { holder: { targets: PARTY, column: "holder", pair: true } }
1449
776
  },
1450
- {
1451
- country: "ua",
1452
- code: "380",
1453
- trunk: "0",
1454
- lengths: [9, 10],
1455
- valid: "[89]\\d{9}|[3-9]\\d{8}",
1456
- mobile: "790\\d{6}|(?:39|50|6[36-8]|7[1-357]|9[1-9])\\d{7}"
777
+ transaction: {
778
+ table: "financial_transactions",
779
+ review: "proposal",
780
+ update: "re-propose",
781
+ tombstone: true,
782
+ fields: objectOf({
783
+ direction: enumOf(MONEY_DIRECTIONS),
784
+ amount: decimal("A decimal above 0 in the wallet's currency"),
785
+ currency,
786
+ status: enumOf(TRANSACTION_STATUSES, "booked when left out"),
787
+ date: day("The day the statement shows"),
788
+ booked_date: day("The day it was booked; the statement day when left out"),
789
+ description: text("As the statement says it", 2e3),
790
+ counterparty_name: text("As the statement names the other side", 200),
791
+ reference: text("The statement's reference", 200),
792
+ splits: arrayOf(objectOf({
793
+ amount: decimal("A decimal above 0"),
794
+ category: text("Free text, such as rent", 200),
795
+ note: text("A note", 2e3)
796
+ }, { required: ["amount", "category"] }), 100, "Categories of its amount; what they leave is uncategorized")
797
+ }, { required: ["direction", "amount", "date"] }),
798
+ roles: {
799
+ wallet: { targets: ["wallet"], required: true, column: "financial_account_id" },
800
+ counterparty: { targets: PARTY, column: "counterparty", pair: true },
801
+ payment: { targets: ["payment"], column: "payment_id" },
802
+ project: { targets: ["project"], column: "project_id" }
803
+ },
804
+ nested: { splits: { table: "transaction_splits", parent: "transaction_id" } }
1457
805
  },
1458
- {
1459
- country: "by",
1460
- code: "375",
1461
- trunk: "0|80?",
1462
- lengths: [6, 7, 8, 9, 10, 11],
1463
- 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}",
1464
- mobile: "(?:2(?:5[5-79]|9[1-9])|(?:33|44)\\d)\\d{6}"
806
+ deal: {
807
+ table: "deals",
808
+ review: "direct",
809
+ update: "in-place",
810
+ tombstone: true,
811
+ fields: dealFields("deal"),
812
+ references: { pipeline: "pipeline" },
813
+ roles: {
814
+ organization: { targets: ORGANIZATION, column: "organization_id" },
815
+ person: { targets: ["person"], many: true, relationship: "related-to", kept: true },
816
+ project: { targets: ["project"], column: "project_id" }
817
+ }
1465
818
  },
1466
- {
1467
- country: "ru",
1468
- code: "7",
1469
- trunk: "8",
1470
- lengths: [10, 14],
1471
- valid: "8\\d{13}|[347-9]\\d{9}",
1472
- mobile: "9\\d{9}"
819
+ lead: {
820
+ table: "leads",
821
+ review: "direct",
822
+ update: "in-place",
823
+ tombstone: true,
824
+ fields: dealFields("lead"),
825
+ references: { pipeline: "pipeline" },
826
+ roles: {
827
+ organization: { targets: ORGANIZATION, column: "organization_id" },
828
+ person: { targets: ["person"], many: true, relationship: "related-to", kept: true },
829
+ project: { targets: ["project"], column: "project_id" },
830
+ deal: { targets: ["deal"], column: "deal_id" }
831
+ }
1473
832
  },
1474
- {
1475
- country: "kz",
1476
- code: "7",
1477
- trunk: "8",
1478
- lengths: [10, 14],
1479
- valid: "8\\d{13}|[78]\\d{9}",
1480
- mobile: "7(?:0[0-25-8]|47|6[0-4]|7[15-8]|85)\\d{7}"
833
+ message: {
834
+ table: "messages",
835
+ review: "direct",
836
+ update: "in-place",
837
+ tombstone: true,
838
+ importOnly: true,
839
+ sheet: false,
840
+ fields: objectOf({
841
+ kind: enumOf(["sms"], "sms: a text message of the phone"),
842
+ direction: enumOf(SMS_DIRECTIONS, "in: the other side wrote it; out: the owner did"),
843
+ ...phoneFields,
844
+ thread: text("The phone's thread id; the number when left out", 512),
845
+ body: { type: "string", maxLength: 2e4, description: "The text" },
846
+ sent_at: instant("When it was sent"),
847
+ read: { type: "boolean", description: "An incoming message the owner opened" }
848
+ }, { required: ["kind", "direction", "phone", "body", "sent_at"] }),
849
+ roles: COUNTERPART
1481
850
  },
1482
- {
1483
- country: "ge",
1484
- code: "995",
1485
- trunk: "0",
1486
- lengths: [9],
1487
- valid: "(?:[3-57]\\d\\d|800)\\d{6}",
1488
- 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}"
851
+ event: {
852
+ table: "events",
853
+ review: "direct",
854
+ update: "in-place",
855
+ tombstone: true,
856
+ importOnly: true,
857
+ sheet: false,
858
+ fields: objectOf({
859
+ kind: enumOf(["call"], "call: a phone call"),
860
+ direction: enumOf(CALL_DIRECTIONS, "in, out, or missed: a call the owner did not take"),
861
+ ...phoneFields,
862
+ started_at: instant("When it rang"),
863
+ duration: { type: "integer", minimum: 0, maximum: 604800, description: "Seconds talked; 0 when missed" }
864
+ }, { required: ["kind", "direction", "phone", "started_at"] }),
865
+ roles: COUNTERPART
1489
866
  },
1490
- {
1491
- country: "am",
1492
- code: "374",
1493
- trunk: "0",
1494
- lengths: [8],
1495
- valid: "(?:[1-489]\\d|55|60|77)\\d{6}",
1496
- mobile: "(?:33|4[1349]|55|77|88|9[13-9])\\d{6}"
867
+ document: {
868
+ table: "documents",
869
+ review: "direct",
870
+ update: "in-place",
871
+ tombstone: true,
872
+ importOnly: true,
873
+ fieldsBytes: 1048576,
874
+ fields: objectOf({
875
+ title: text("What the document is called; its external id when left out", 500),
876
+ text: { type: "string", maxLength: 1e6, description: "The text search reads" },
877
+ created_at: instant("When the source made it"),
878
+ updated_at: instant("When the source last changed it: what date: reads"),
879
+ url: text("Where the original is", 4096),
880
+ metadata: { type: "object", description: "Anything else the source knows about it, kept as sent" }
881
+ }, { required: ["text"] }),
882
+ roles: {
883
+ about: { targets: ["person", "organization", "deal", "event"], many: true }
884
+ }
1497
885
  },
1498
- {
1499
- country: "tr",
1500
- code: "90",
1501
- trunk: "0",
1502
- lengths: [7, 10, 12, 13],
1503
- valid: "4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",
1504
- 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}"
886
+ pipeline: {
887
+ table: "pipelines",
888
+ review: "direct",
889
+ update: "in-place",
890
+ tombstone: false,
891
+ fields: objectOf({
892
+ kind: enumOf(DEAL_KINDS, "deal when left out"),
893
+ name: text("The pipeline's name", 80),
894
+ stages: arrayOf(objectOf({
895
+ external_id: text("The stage's id at the source", 512),
896
+ name: text("The stage's name", 80),
897
+ position: { type: "integer", minimum: 0, maximum: 1e3 },
898
+ outcome: enumOf(DEAL_STATUSES, "open when left out")
899
+ }, { required: ["external_id", "name"] }), 30, "The stages in order")
900
+ }, { required: ["name", "stages"] }),
901
+ roles: {},
902
+ nested: { stages: { table: "pipeline_stages", parent: "pipeline_id" } }
903
+ }
904
+ };
905
+ var isRecordType = /* @__PURE__ */ __name((type) => Object.hasOwn(RECORD_TYPES, type), "isRecordType");
906
+ var isBusinessType = /* @__PURE__ */ __name((type) => isRecordType(type) && RECORD_TYPES[type].review !== "identity" && type !== "document", "isBusinessType");
907
+ var isIdentityType = /* @__PURE__ */ __name((type) => typeof type === "string" && isRecordType(type) && RECORD_TYPES[type].review === "identity", "isIdentityType");
908
+ var RECORD_ENTITY_TYPES = Object.keys(RECORD_TYPES);
909
+ var RECORD_TABLES = Object.fromEntries(Object.entries(RECORD_TYPES).map(([type, spec]) => [type, spec.table]));
910
+ var decidedOf = /* @__PURE__ */ __name((types) => Object.fromEntries(Object.entries(types).flatMap(([type, spec]) => spec.review === "proposal" || spec.review === "valued-proposal" ? [[type, spec.table]] : [])), "decidedOf");
911
+ var DECIDED_TABLES = {
912
+ ...decidedOf(RECORD_TYPES),
913
+ subscription_price: "subscription_prices"
914
+ };
915
+ var WORD_BODY = "[a-z0-9][a-z0-9_-]{0,62}";
916
+ var TYPE_PATTERN = `^(${RECORD_ENTITY_TYPES.join("|")}|custom:${WORD_BODY})$`;
917
+ var TYPE_RULE = `a type is one of ${RECORD_ENTITY_TYPES.join(", ")} or custom:<name>`;
918
+ var rolesOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].roles), "rolesOf");
919
+ var roleOf = /* @__PURE__ */ __name((type, role) => {
920
+ if (!isRecordType(type))
921
+ return void 0;
922
+ const roles = RECORD_TYPES[type].roles;
923
+ return Object.hasOwn(roles, role) ? roles[role] : void 0;
924
+ }, "roleOf");
925
+ var nestedOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].nested ?? {}), "nestedOf");
926
+ var referencesOf = /* @__PURE__ */ __name((type) => Object.entries(RECORD_TYPES[type].references ?? {}), "referencesOf");
927
+ var roleNames = /* @__PURE__ */ __name((types, keep) => [
928
+ ...new Set(types.flatMap((type) => rolesOf(type).flatMap(([name, role]) => keep(role) ? [name] : [])))
929
+ ], "roleNames");
930
+ var AMOUNT_ROLES = roleNames(RECORD_ENTITY_TYPES, (role) => role.amount);
931
+ var FIELD_REFERENCE_ROLES = roleNames(RECORD_ENTITY_TYPES, (role) => role.v1 && !role.many);
932
+ var hasV1Roles = /* @__PURE__ */ __name((type) => rolesOf(type).some(([, role]) => role.v1), "hasV1Roles");
933
+ var IDENTITY_TYPES = RECORD_ENTITY_TYPES.filter((type) => RECORD_TYPES[type].review === "identity");
934
+ var article = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
935
+
936
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/ref-arguments.js
937
+ var TAKES = {
938
+ chat: "a chat: chat:<provider>/<account>/<chat>, its id or its title",
939
+ message: "a message: msg:<provider>/<account>/<chat>/<message>, or a chat and the message's id"
940
+ };
941
+ var article2 = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
942
+ var wrongKind = /* @__PURE__ */ __name((text2, kind, takes) => new CliError("validation_error", `${text2} names ${article2(kind)} ${kind}; this takes ${TAKES[takes]}`, {
943
+ reason: "ref.wrong-kind"
944
+ }), "wrongKind");
945
+ var wrongProvider = /* @__PURE__ */ __name((text2, provider, kind) => {
946
+ const entry = providerNamed(provider);
947
+ const command = entry?.command;
948
+ const opens = kind === "entity" ? void 0 : entry?.opens?.[kind];
949
+ const how = command && opens ? `open it with ${command} <profile> ${opens} ${text2}` : "open it with its own CLI";
950
+ const label2 = providerLabel(provider);
951
+ return new CliError("validation_error", `${text2} is ${article2(label2.toLowerCase())} ${label2} ${kind}; ${how}`, {
952
+ reason: "ref.wrong-provider"
953
+ });
954
+ }, "wrongProvider");
955
+ var chatReferenceOf = /* @__PURE__ */ __name((text2, provider, takes = "chat") => {
956
+ const trimmed = text2.trim();
957
+ if (!looksLikeReference(trimmed))
958
+ return void 0;
959
+ const reference = parseReference(trimmed);
960
+ if (reference.type !== "chat" && reference.type !== "message")
961
+ throw wrongKind(trimmed, reference.type, takes);
962
+ if (reference.provider !== provider)
963
+ throw wrongProvider(trimmed, reference.provider, reference.type);
964
+ const found = {
965
+ text: trimmed,
966
+ provider: reference.provider,
967
+ account: reference.account,
968
+ chat: reference.chat,
969
+ ...reference.type === "message" ? { message: reference.message } : {}
970
+ };
971
+ return found;
972
+ }, "chatReferenceOf");
973
+ var contactReferenceOf = /* @__PURE__ */ __name((text2, provider) => {
974
+ const trimmed = text2.trim();
975
+ if (!trimmed.startsWith("contact:"))
976
+ return void 0;
977
+ const reference = parseReference(trimmed);
978
+ if (reference.type !== "contact")
979
+ return void 0;
980
+ if (provider !== void 0 && reference.provider !== provider)
981
+ throw wrongProvider(trimmed, reference.provider, reference.type);
982
+ return reference.id;
983
+ }, "contactReferenceOf");
984
+ var wrongAccount = /* @__PURE__ */ __name((reference, scope, profiles) => {
985
+ 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}`;
986
+ const others = profiles === void 0 ? "" : `. Profiles signed in to ${reference.account}: ${profiles.length > 0 ? profiles.join(", ") : "none here"}`;
987
+ return new CliError("validation_error", `${reference.text} belongs to account ${reference.account}; ${here}${others}`, { reason: "ref.wrong-account" });
988
+ }, "wrongAccount");
989
+ var ensureAccount = /* @__PURE__ */ __name(async (reference, scope, profilesOn) => {
990
+ if (scope.account !== void 0 && scope.account === reference.account)
991
+ return;
992
+ const profiles = await profilesOn?.(reference.account).catch(() => void 0);
993
+ throw wrongAccount(reference, scope, profiles);
994
+ }, "ensureAccount");
995
+
996
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
997
+ var QUERY_VERSION = 1;
998
+ var QUERY_LIMITS2 = {
999
+ ...QUERY_LIMITS,
1000
+ pattern: 1024,
1001
+ states: 1e4,
1002
+ expansions: 1e4,
1003
+ candidates: 5e4,
1004
+ bodyBytes: 8388608,
1005
+ milliseconds: 2e3,
1006
+ work: 1e7
1007
+ };
1008
+ var SEARCH_QUERY = {
1009
+ command: "search",
1010
+ guide: "https://github.com/WireCatLabs/cli-core/blob/main/docs/search/query-language.md"
1011
+ };
1012
+ var MESSAGE_PARSING = { ...SEARCH_QUERY, proximity: true };
1013
+ var MOST_WORDS_APART = 50;
1014
+ function searchError(reason, span, alternative) {
1015
+ queryError(reason, span, alternative, SEARCH_QUERY);
1016
+ }
1017
+ __name(searchError, "searchError");
1018
+ var ANSWER_MS = 1e3;
1019
+ var searchTimeLimit = /* @__PURE__ */ __name((deadline, now = Date.now()) => deadline?.explicit ? Math.max(QUERY_LIMITS2.milliseconds, deadline.endsAt - now - ANSWER_MS) : void 0, "searchTimeLimit");
1020
+ function outOfTime(limitMs = QUERY_LIMITS2.milliseconds) {
1021
+ 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 });
1022
+ }
1023
+ __name(outOfTime, "outOfTime");
1024
+ var isQueryLimit = /* @__PURE__ */ __name((error) => isCliError(error) && (error.details.reason === "query.too-large" || error.details.reason === "query.time-limit"), "isQueryLimit");
1025
+ function exhausted(budget) {
1026
+ throw new CliError("validation_error", `search exceeded its ${budget} budget \u2014 narrow the chat or date range`, {
1027
+ reason: "query.too-large",
1028
+ budget,
1029
+ complete: false
1030
+ });
1031
+ }
1032
+ __name(exhausted, "exhausted");
1033
+ function tooWideTerm([term], budget) {
1034
+ if (term === void 0)
1035
+ exhausted(budget);
1036
+ const part = term.replace(/[*?]+/gu, " ").trim().split(/\s+/u).sort((a, b) => b.length - a.length)[0] ?? term;
1037
+ 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 });
1038
+ }
1039
+ __name(tooWideTerm, "tooWideTerm");
1040
+
1041
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
1042
+ var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
1043
+ var literal = /* @__PURE__ */ __name((c) => ({
1044
+ kind: "char",
1045
+ ranges: [[c.codePointAt(0) ?? 0, c.codePointAt(0) ?? 0]],
1046
+ negate: false
1047
+ }), "literal");
1048
+ var compileAutomaton = /* @__PURE__ */ __name((pattern, span = { start: 0, end: pattern.length }) => {
1049
+ if (pattern.length > QUERY_LIMITS2.pattern * 2)
1050
+ exhausted("pattern");
1051
+ const chars = [...pattern];
1052
+ if (chars.length > QUERY_LIMITS2.pattern)
1053
+ exhausted("pattern");
1054
+ let at = 0, depth = 0;
1055
+ const failure = /* @__PURE__ */ __name(() => searchError("query.invalid-regex", span, "use the supported Lucene regex subset"), "failure");
1056
+ const character = /* @__PURE__ */ __name(() => {
1057
+ if (at >= chars.length)
1058
+ return failure();
1059
+ return chars[at++];
1060
+ }, "character");
1061
+ const predefined = /* @__PURE__ */ __name(() => {
1062
+ if (chars[at] !== "\\")
1063
+ return void 0;
1064
+ const name = chars[at + 1] ?? "";
1065
+ let ranges;
1066
+ if (name.toLowerCase() === "d")
1067
+ ranges = [[48, 57]];
1068
+ if (name.toLowerCase() === "w")
1069
+ ranges = [
1070
+ [48, 57],
1071
+ [65, 90],
1072
+ [95, 95],
1073
+ [97, 122]
1074
+ ];
1075
+ if (name.toLowerCase() === "s")
1076
+ ranges = [
1077
+ [9, 10],
1078
+ [13, 13],
1079
+ [32, 32]
1080
+ ];
1081
+ if (ranges) {
1082
+ at += 2;
1083
+ return { kind: "char", ranges, negate: name === name.toUpperCase() };
1084
+ }
1085
+ if (/^[a-zA-Z]$/u.test(name))
1086
+ return failure();
1087
+ return void 0;
1088
+ }, "predefined");
1089
+ const escaped = /* @__PURE__ */ __name(() => {
1090
+ if (chars[at] === "\\")
1091
+ at++;
1092
+ return character();
1093
+ }, "escaped");
1094
+ const union = /* @__PURE__ */ __name(() => {
1095
+ if (++depth > QUERY_LIMITS2.depth)
1096
+ exhausted("pattern depth");
1097
+ const children = [concat()];
1098
+ while (chars[at] === "|") {
1099
+ at++;
1100
+ children.push(concat());
1101
+ }
1102
+ depth--;
1103
+ return children.length === 1 ? children[0] : { kind: "union", children };
1104
+ }, "union");
1105
+ const concat = /* @__PURE__ */ __name(() => {
1106
+ const children = [];
1107
+ do {
1108
+ children.push(repeat());
1109
+ } while (at < chars.length && ![")", "|", "&"].includes(chars[at] ?? ""));
1110
+ if (chars[at] === "&")
1111
+ searchError("query.unsupported-regex", span, "automaton intersection is not supported");
1112
+ return children.length === 1 ? children[0] : { kind: "concat", children };
1113
+ }, "concat");
1114
+ const repeat = /* @__PURE__ */ __name(() => {
1115
+ let child = simple();
1116
+ while (["?", "*", "+", "{"].includes(chars[at] ?? "")) {
1117
+ const op = character();
1118
+ let min = op === "+" ? 1 : 0, max = op === "?" ? 1 : null;
1119
+ if (op === "{") {
1120
+ const number = /* @__PURE__ */ __name(() => {
1121
+ const start2 = at;
1122
+ while (/^[0-9]$/u.test(chars[at] ?? ""))
1123
+ at++;
1124
+ if (at === start2)
1125
+ return failure();
1126
+ return Number(chars.slice(start2, at).join(""));
1127
+ }, "number");
1128
+ min = number();
1129
+ max = min;
1130
+ if (chars[at] === ",") {
1131
+ at++;
1132
+ max = chars[at] === "}" ? null : number();
1133
+ }
1134
+ if (character() !== "}" || max !== null && max < min)
1135
+ return failure();
1136
+ }
1137
+ if (min > QUERY_LIMITS2.states || max !== null && max > QUERY_LIMITS2.states)
1138
+ exhausted("automaton states");
1139
+ child = { kind: "repeat", child, min, max };
1140
+ }
1141
+ return child;
1142
+ }, "repeat");
1143
+ const simple = /* @__PURE__ */ __name(() => {
1144
+ const predefinedAtom = predefined();
1145
+ if (predefinedAtom)
1146
+ return predefinedAtom;
1147
+ const c = character();
1148
+ if (c === "~" || c === "<")
1149
+ searchError("query.unsupported-regex", span, "complement, named automata and numeric intervals are not supported");
1150
+ if (c === ".")
1151
+ return any;
1152
+ if (c === "#")
1153
+ return { kind: "empty" };
1154
+ if (c === "@")
1155
+ return { kind: "repeat", child: any, min: 0, max: null };
1156
+ if (c === '"') {
1157
+ const children = [];
1158
+ while (chars[at] !== '"')
1159
+ children.push(literal(character()));
1160
+ at++;
1161
+ return { kind: "concat", children };
1162
+ }
1163
+ if (c === "(") {
1164
+ if (chars[at] === ")") {
1165
+ at++;
1166
+ return { kind: "epsilon" };
1167
+ }
1168
+ if (chars[at] === "?")
1169
+ searchError("query.unsupported-regex", span, "JavaScript groups and lookaround are not Lucene operators");
1170
+ const child = union();
1171
+ if (character() !== ")")
1172
+ return failure();
1173
+ return child;
1174
+ }
1175
+ if (c === "[") {
1176
+ const negate = chars[at] === "^";
1177
+ if (negate)
1178
+ at++;
1179
+ const choices = [];
1180
+ do {
1181
+ const pre = predefined();
1182
+ if (pre) {
1183
+ choices.push(pre);
1184
+ continue;
1185
+ }
1186
+ const lo = escaped().codePointAt(0) ?? 0;
1187
+ let hi = lo;
1188
+ if (chars[at] === "-") {
1189
+ at++;
1190
+ hi = escaped().codePointAt(0) ?? 0;
1191
+ }
1192
+ if (hi < lo)
1193
+ return failure();
1194
+ choices.push({ kind: "char", ranges: [[lo, hi]], negate: false });
1195
+ } while (at < chars.length && chars[at] !== "]");
1196
+ if (character() !== "]")
1197
+ return failure();
1198
+ if (!negate)
1199
+ return { kind: "union", children: choices };
1200
+ const ranges = [];
1201
+ for (const choice of choices) {
1202
+ if (choice.kind !== "char" || choice.negate)
1203
+ searchError("query.unsupported-regex", span, "negative predefined classes inside a negated class are not supported");
1204
+ ranges.push(...choice.ranges);
1205
+ }
1206
+ return { kind: "char", ranges, negate: true };
1207
+ }
1208
+ if (c === "\\")
1209
+ return literal(character());
1210
+ return literal(c);
1211
+ }, "simple");
1212
+ const expression = chars.length === 0 ? { kind: "epsilon" } : union();
1213
+ if (at !== chars.length)
1214
+ return failure();
1215
+ const states = [];
1216
+ const state = /* @__PURE__ */ __name(() => {
1217
+ if (states.length >= QUERY_LIMITS2.states)
1218
+ exhausted("automaton states");
1219
+ states.push({ epsilon: [], edges: [] });
1220
+ return states.length - 1;
1221
+ }, "state");
1222
+ const epsilon = /* @__PURE__ */ __name((from, to) => {
1223
+ ;
1224
+ states[from].epsilon.push(to);
1225
+ }, "epsilon");
1226
+ const build = /* @__PURE__ */ __name((node, from, to) => {
1227
+ if (node.kind === "char") {
1228
+ ;
1229
+ states[from].edges.push({ to, atom: node });
1230
+ return;
1231
+ }
1232
+ if (node.kind === "empty")
1233
+ return;
1234
+ if (node.kind === "epsilon") {
1235
+ epsilon(from, to);
1236
+ return;
1237
+ }
1238
+ if (node.kind === "union") {
1239
+ for (const child of node.children)
1240
+ build(child, from, to);
1241
+ return;
1242
+ }
1243
+ if (node.kind === "concat") {
1244
+ let current2 = from;
1245
+ node.children.forEach((child, index) => {
1246
+ const next = index === node.children.length - 1 ? to : state();
1247
+ build(child, current2, next);
1248
+ current2 = next;
1249
+ });
1250
+ if (node.children.length === 0)
1251
+ epsilon(from, to);
1252
+ return;
1253
+ }
1254
+ let current = from;
1255
+ for (let i = 0; i < node.min; i++) {
1256
+ const next = state();
1257
+ build(node.child, current, next);
1258
+ current = next;
1259
+ }
1260
+ if (node.max === null) {
1261
+ epsilon(current, to);
1262
+ const end2 = state();
1263
+ build(node.child, current, end2);
1264
+ epsilon(end2, current);
1265
+ } else {
1266
+ for (let i = node.min; i < node.max; i++) {
1267
+ epsilon(current, to);
1268
+ const next = state();
1269
+ build(node.child, current, next);
1270
+ current = next;
1271
+ }
1272
+ epsilon(current, to);
1273
+ }
1274
+ }, "build");
1275
+ const start = state(), end = state();
1276
+ build(expression, start, end);
1277
+ return {
1278
+ states: states.length,
1279
+ test: /* @__PURE__ */ __name((text2, budget = { work: 0 }) => {
1280
+ const spend = /* @__PURE__ */ __name(() => {
1281
+ if (++budget.work > (budget.maxWork ?? QUERY_LIMITS2.work))
1282
+ exhausted("automaton work");
1283
+ }, "spend");
1284
+ const closure = /* @__PURE__ */ __name((initial) => {
1285
+ const stack = [...initial];
1286
+ while (stack.length) {
1287
+ const id = stack.pop();
1288
+ for (const next of states[id].epsilon) {
1289
+ spend();
1290
+ if (!initial.has(next)) {
1291
+ initial.add(next);
1292
+ stack.push(next);
1293
+ }
1294
+ }
1295
+ }
1296
+ return initial;
1297
+ }, "closure");
1298
+ let current = closure(/* @__PURE__ */ new Set([start]));
1299
+ for (const c of text2) {
1300
+ const point = c.codePointAt(0) ?? 0;
1301
+ const next = /* @__PURE__ */ new Set();
1302
+ for (const id of current)
1303
+ for (const edge of states[id].edges) {
1304
+ spend();
1305
+ const inside = edge.atom.ranges.some(([lo, hi]) => point >= lo && point <= hi);
1306
+ if (inside !== edge.atom.negate)
1307
+ next.add(edge.to);
1308
+ }
1309
+ current = closure(next);
1310
+ if (current.size === 0)
1311
+ return false;
1312
+ }
1313
+ return current.has(end);
1314
+ }, "test")
1315
+ };
1316
+ }, "compileAutomaton");
1317
+ var wildcardPattern = /* @__PURE__ */ __name((value) => {
1318
+ const chars = [...value];
1319
+ let pattern = "";
1320
+ for (let at = 0; at < chars.length; at++) {
1321
+ const c = chars[at];
1322
+ if (c === "\\") {
1323
+ const escaped = chars[++at];
1324
+ if (escaped === void 0)
1325
+ searchError("query.invalid-escape", { start: 0, end: value.length });
1326
+ pattern += /[|&?*+(){}[\].#@<>"~\\]/u.test(escaped) ? `\\${escaped}` : escaped;
1327
+ } else
1328
+ pattern += c === "*" ? ".*" : c === "?" ? "." : /[|&?*+(){}[\].#@<>"~\\]/u.test(c) ? `\\${c}` : c;
1329
+ }
1330
+ return pattern;
1331
+ }, "wildcardPattern");
1332
+ var FOLD_RANGE = 4096;
1333
+ 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");
1334
+ var classChar = /* @__PURE__ */ __name((point) => {
1335
+ const c = String.fromCodePoint(point);
1336
+ return /[\p{L}\p{N}]/u.test(c) ? c : `\\${c}`;
1337
+ }, "classChar");
1338
+ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
1339
+ const chars = [...pattern.normalize("NFC")];
1340
+ let out = "";
1341
+ let at = 0;
1342
+ const literal2 = /* @__PURE__ */ __name((c) => {
1343
+ if (!/[\p{L}\p{N}\p{M}]/u.test(c))
1344
+ return c;
1345
+ const folded = fold(c);
1346
+ if (folded === "")
1347
+ return unfoldable(span, `"${c}"`);
1348
+ if ([...folded].length === 1 && /[\p{L}\p{N}]/u.test(folded))
1349
+ return folded;
1350
+ if (folded.includes('"'))
1351
+ return unfoldable(span, `"${c}"`);
1352
+ return `"${folded}"`;
1353
+ }, "literal");
1354
+ const characterClass = /* @__PURE__ */ __name(() => {
1355
+ const begin = at - 1;
1356
+ let negate = "";
1357
+ if (chars[at] === "^") {
1358
+ negate = "^";
1359
+ at++;
1360
+ }
1361
+ const kept2 = [];
1362
+ const points = /* @__PURE__ */ new Set();
1363
+ do {
1364
+ const start = at;
1365
+ if (chars[at] === "\\" && /^[a-zA-Z]$/u.test(chars[at + 1] ?? "")) {
1366
+ kept2.push(`\\${chars[at + 1]}`);
1367
+ at += 2;
1368
+ continue;
1369
+ }
1370
+ const escaped = /* @__PURE__ */ __name(() => {
1371
+ if (chars[at] === "\\")
1372
+ at++;
1373
+ return (chars[at++] ?? "").codePointAt(0) ?? 0;
1374
+ }, "escaped");
1375
+ const lo = escaped();
1376
+ let hi = lo;
1377
+ if (chars[at] === "-") {
1378
+ at++;
1379
+ hi = escaped();
1380
+ }
1381
+ if (at > chars.length) {
1382
+ out += chars.slice(begin).join("");
1383
+ return;
1384
+ }
1385
+ const single = /* @__PURE__ */ __name((point) => [...fold(String.fromCodePoint(point))], "single");
1386
+ if (hi < lo)
1387
+ kept2.push(chars.slice(start, at).join(""));
1388
+ else if (hi - lo >= FOLD_RANGE) {
1389
+ if (single(lo).join("") !== String.fromCodePoint(lo) || single(hi).join("") !== String.fromCodePoint(hi))
1390
+ unfoldable(span, `the range ${chars.slice(start, at).join("")}`);
1391
+ kept2.push(chars.slice(start, at).join(""));
1392
+ } else
1393
+ for (let point = lo; point <= hi; point++) {
1394
+ const folded = single(point);
1395
+ if (folded.length === 1)
1396
+ points.add(folded[0]?.codePointAt(0) ?? 0);
1397
+ else if (lo === hi)
1398
+ unfoldable(span, `"${String.fromCodePoint(point)}"`);
1399
+ }
1400
+ } while (at < chars.length && chars[at] !== "]");
1401
+ const sorted = [...points].sort((a, b) => a - b);
1402
+ const ranges = [];
1403
+ for (let i = 0; i < sorted.length; i++) {
1404
+ const first = sorted[i];
1405
+ while (sorted[i + 1] === sorted[i] + 1)
1406
+ i++;
1407
+ const last = sorted[i];
1408
+ ranges.push(last === first ? classChar(first) : `${classChar(first)}-${classChar(last)}`);
1409
+ }
1410
+ if (!kept2.length && !ranges.length)
1411
+ unfoldable(span, "the class");
1412
+ out += `[${negate}${kept2.join("")}${ranges.join("")}`;
1413
+ }, "characterClass");
1414
+ while (at < chars.length) {
1415
+ const c = chars[at++];
1416
+ if (c === "\\") {
1417
+ const next = chars[at++];
1418
+ if (next === void 0)
1419
+ out += c;
1420
+ else
1421
+ out += (next.codePointAt(0) ?? 0) < 128 ? `${c}${next}` : literal2(next);
1422
+ } else if (c === '"') {
1423
+ const end = chars.indexOf('"', at);
1424
+ if (end < 0) {
1425
+ out += chars.slice(at - 1).join("");
1426
+ break;
1427
+ }
1428
+ const folded = fold(chars.slice(at, end).join(""));
1429
+ if (folded.includes('"'))
1430
+ unfoldable(span, `"${chars.slice(at, end).join("")}"`);
1431
+ out += `"${folded}"`;
1432
+ at = end + 1;
1433
+ } else if (c === "[")
1434
+ characterClass();
1435
+ else
1436
+ out += literal2(c);
1505
1437
  }
1506
- ];
1438
+ return out;
1439
+ }, "foldRegex");
1507
1440
 
1508
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/phones.js
1509
- var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
1510
- var DEFAULT_PHONE_COUNTRIES = ["ru"];
1511
- var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
1512
- const countries = value.split(/[\s,]+/).map((one) => one.trim().toLowerCase()).filter(Boolean);
1513
- const unknown = countries.filter((one) => !PHONE_COUNTRIES.includes(one));
1514
- if (countries.length === 0 || unknown.length > 0)
1515
- throw new CliError("validation_error", `phone_countries takes country codes, ${unknown.length > 0 ? `not ${unknown.join(", ")}` : "at least one"}: ` + PHONE_COUNTRIES.join(", "));
1516
- return [...new Set(countries)];
1517
- }, "parsePhoneCountries");
1518
- var PLANS = new Map(PHONE_PLANS.map((plan) => [
1519
- plan.country,
1520
- {
1521
- code: plan.code,
1522
- trunk: plan.trunk ? new RegExp(`^(?:${plan.trunk})`) : null,
1523
- lengths: new Set(plan.lengths),
1524
- valid: new RegExp(`^(?:${plan.valid})$`),
1525
- mobile: plan.mobile === null ? null : new RegExp(`^(?:${plan.mobile})$`)
1526
- }
1527
- ]));
1528
- var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
1529
- for (const country of countries) {
1530
- const plan = PLANS.get(country);
1531
- if (!plan)
1532
- continue;
1533
- const readings = [
1534
- ...plan.trunk?.test(digits) ? [digits.replace(plan.trunk, "")] : [],
1535
- digits,
1536
- ...digits.startsWith(plan.code) ? [digits.slice(plan.code.length)] : []
1537
- ];
1538
- for (const national of readings) {
1539
- if (!plan.lengths.has(national.length) || !plan.valid.test(national))
1540
- continue;
1541
- const mobile = plan.mobile?.test(national) ?? false;
1542
- if (anyType || mobile)
1543
- return { value: `+${plan.code}${national}`, national, mobile };
1544
- }
1441
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/search/trigrams.js
1442
+ var trigrams = /* @__PURE__ */ __name((term) => {
1443
+ const padded = ` ${term} `;
1444
+ const pieces = /* @__PURE__ */ new Set();
1445
+ for (let at = 0; at + 3 <= padded.length; at++)
1446
+ pieces.add(padded.slice(at, at + 3));
1447
+ return [...pieces];
1448
+ }, "trigrams");
1449
+
1450
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/resolve.js
1451
+ var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
1452
+ var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase().replaceAll("\u0451", "\u0435"), "foldName");
1453
+ var pickChat = /* @__PURE__ */ __name((reference, chats) => {
1454
+ const wanted = foldName(reference.trim());
1455
+ const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
1456
+ if (matches.length === 1 && matches[0])
1457
+ return matches[0];
1458
+ if (matches.length === 0)
1459
+ throw new CliError("not_found", `no chat matches "${reference}"`);
1460
+ throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
1461
+ }, "pickChat");
1462
+ var pickPerson = /* @__PURE__ */ __name((reference, people) => {
1463
+ const trimmed = reference.trim();
1464
+ const contact = contactReferenceOf(trimmed, people.provider);
1465
+ if (contact !== void 0) {
1466
+ const named = people.get(contact);
1467
+ if (named)
1468
+ return named;
1469
+ throw new CliError("not_found", `no person ${contact} in what this account has seen`);
1545
1470
  }
1546
- return void 0;
1547
- }, "nationalPhone");
1548
- var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE_COUNTRIES } = {}) => {
1549
- const text2 = typed.trim();
1550
- if (!/^\+?[\d\s().\-–]+$/.test(text2))
1551
- return void 0;
1552
- const digits = text2.replace(/\(0\)/, "").replace(/\D/g, "").replace(/^00/, "");
1553
- if (digits.length < 7 || digits.length > 15)
1554
- return void 0;
1555
- const national = nationalPhone(digits, phoneCountries, { anyType: true });
1556
- const tail = national?.national ?? digits.replace(/^0+/, "");
1557
- return {
1558
- value: text2.startsWith("+") || /^00/.test(text2) ? `+${digits}` : national?.value ?? digits,
1559
- national: tail.length >= 8 ? tail : null
1560
- };
1561
- }, "typedPhone");
1562
- var e164Of = /* @__PURE__ */ __name((phone, region) => {
1563
- if (/^\s*(\+|00)/.test(phone))
1564
- return typedPhone(phone)?.value;
1565
- if (typedPhone(phone) === void 0)
1566
- return void 0;
1567
- if (region === void 0)
1568
- return null;
1569
- const digits = phone.replace(/\(0\)/, "").replace(/\D/g, "");
1570
- return nationalPhone(digits, [region], { anyType: true })?.value;
1571
- }, "e164Of");
1572
- var isMobilePhone = /* @__PURE__ */ __name((e164) => /^\+\d+$/.test(e164) && PHONE_COUNTRIES.some((country) => nationalPhone(e164.slice(1), [country], { anyType: false })?.value === e164), "isMobilePhone");
1573
- var BARE_INTERNATIONAL_PROVIDERS = ["telegram", "max", "whatsapp"];
1574
- var storedPhone = /* @__PURE__ */ __name((raw, provider) => {
1575
- if (/^\s*(\+|00)/.test(raw))
1576
- return typedPhone(raw)?.value;
1577
- if (!BARE_INTERNATIONAL_PROVIDERS.includes(provider))
1578
- return void 0;
1579
- const found = /^([1-9]\d{6,14})$/.exec(raw.trim());
1580
- return found ? `+${found[1]}` : void 0;
1581
- }, "storedPhone");
1471
+ const known = people.get(trimmed);
1472
+ if (known)
1473
+ return known;
1474
+ if (isId(trimmed))
1475
+ throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
1476
+ const wanted = foldName(trimmed.replace(/^@/, ""));
1477
+ const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
1478
+ const exact = everyone.filter((person) => namesOf(person).includes(wanted));
1479
+ const containing = everyone.filter((person) => namesOf(person).some((one) => one.includes(wanted)));
1480
+ if (exact.length === 1 && exact[0])
1481
+ return exact[0];
1482
+ if (containing.length === 1 && containing[0])
1483
+ return containing[0];
1484
+ if (containing.length === 0)
1485
+ throw new CliError("not_found", `nobody matches "${reference}"`);
1486
+ const matches = exact.length > 0 ? [...exact, ...containing.filter((person) => !exact.includes(person))] : containing;
1487
+ throw ambiguous(reference, "people", matches.map(({ id, name, username }) => ({ id, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
1488
+ }, "pickPerson");
1489
+ var namesOf = /* @__PURE__ */ __name((person, byAddress = false) => [person.alias, person.name, person.username, byAddress ? person.id : void 0].filter(isPresent).map(foldName), "namesOf");
1490
+ var chatNamesOf = /* @__PURE__ */ __name((chat) => [chat.title, chat.providerMetadata?.username].filter((one) => typeof one === "string" && one !== "").map(foldName), "chatNamesOf");
1491
+ var namePattern = /* @__PURE__ */ __name((pattern) => {
1492
+ const automaton = compileAutomaton(wildcardPattern(foldName(pattern.trim().replace(/^@/, ""))));
1493
+ return (names) => names.some((one) => automaton.test(one));
1494
+ }, "namePattern");
1495
+ var peopleMatching = /* @__PURE__ */ __name((pattern, people, { byAddress = false } = {}) => {
1496
+ const fits = namePattern(pattern);
1497
+ return people.filter((person) => fits(namesOf(person, byAddress)));
1498
+ }, "peopleMatching");
1499
+ var chatsMatching = /* @__PURE__ */ __name((pattern, chats) => {
1500
+ const fits = namePattern(pattern);
1501
+ return chats.filter((chat) => fits(chatNamesOf(chat)));
1502
+ }, "chatsMatching");
1503
+ var nearest = /* @__PURE__ */ __name((pattern, items, names, most = 5) => {
1504
+ const pieces = /* @__PURE__ */ __name((text2) => foldName(text2).split(/\s+/u).flatMap(trigrams), "pieces");
1505
+ const wanted = new Set(pieces(pattern.replace(/\\(.)/gu, "$1").replace(/[*?@]/gu, " ").trim()));
1506
+ if (wanted.size === 0)
1507
+ return [];
1508
+ return items.map((item) => ({
1509
+ item,
1510
+ score: names(item).flatMap(pieces).filter((piece) => wanted.has(piece)).length
1511
+ })).filter(({ score }) => score > 1).toSorted((a, b) => b.score - a.score).slice(0, most).map(({ item }) => item);
1512
+ }, "nearest");
1513
+ var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label2) => {
1514
+ const width = Math.max(...candidates.map(({ id }) => id.length));
1515
+ const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label2(candidate)}`).join("\n");
1516
+ return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
1517
+ ${lines}`, { candidates });
1518
+ }, "ambiguous");
1519
+ var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
1520
+
1521
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/addresses.js
1522
+ var EMAIL_ADDRESS = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u;
1523
+ var isEmailAddress = /* @__PURE__ */ __name((value) => EMAIL_ADDRESS.test(value), "isEmailAddress");
1524
+ var ROLE_ADDRESS_WORDS = {
1525
+ noReply: ["noreply", "no-reply", "donotreply", "do-not-reply", "mailer-daemon", "bounce", "bounces"],
1526
+ shared: [
1527
+ "info",
1528
+ "hello",
1529
+ "hi",
1530
+ "contact",
1531
+ "contacts",
1532
+ "support",
1533
+ "help",
1534
+ "helpdesk",
1535
+ "service",
1536
+ "sales",
1537
+ "office",
1538
+ "admin",
1539
+ "team",
1540
+ "billing",
1541
+ "accounts",
1542
+ "accounting",
1543
+ "invoices",
1544
+ "finance",
1545
+ "hr",
1546
+ "jobs",
1547
+ "careers",
1548
+ "press",
1549
+ "media",
1550
+ "marketing",
1551
+ "partners",
1552
+ "legal",
1553
+ "privacy",
1554
+ "security",
1555
+ "abuse",
1556
+ "postmaster",
1557
+ "webmaster",
1558
+ "mail",
1559
+ "inbox",
1560
+ "enquiries",
1561
+ "inquiries",
1562
+ "booking",
1563
+ "reservations",
1564
+ "orders",
1565
+ "feedback",
1566
+ "newsletter",
1567
+ "notifications",
1568
+ "alerts"
1569
+ ]
1570
+ };
1571
+ var bare = /* @__PURE__ */ __name((word) => word.replace(/[.\-_]/gu, ""), "bare");
1572
+ var NO_REPLY = new Set(ROLE_ADDRESS_WORDS.noReply.map(bare));
1573
+ var ROLE = new Set([...ROLE_ADDRESS_WORDS.shared, ...ROLE_ADDRESS_WORDS.noReply].map(bare));
1574
+ var localWord = /* @__PURE__ */ __name((address) => {
1575
+ const local = address.trim().toLowerCase().split("@")[0] ?? "";
1576
+ return bare(local.split("+")[0] ?? "");
1577
+ }, "localWord");
1578
+ var isRoleAddress = /* @__PURE__ */ __name((address) => ROLE.has(localWord(address)), "isRoleAddress");
1579
+ var PERSON_LIKE = /* @__PURE__ */ new Set(["hr"]);
1580
+ var isPersonLikeRoleAddress = /* @__PURE__ */ __name((address) => PERSON_LIKE.has(localWord(address)), "isPersonLikeRoleAddress");
1581
+ var isNoReplyAddress = /* @__PURE__ */ __name((address) => NO_REPLY.has(localWord(address)), "isNoReplyAddress");
1582
1582
 
1583
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/display-names.js
1583
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/display-names.js
1584
1584
  var QUOTES = [
1585
1585
  ['"', '"'],
1586
1586
  ["'", "'"],
@@ -1638,7 +1638,7 @@ var nameKey = /* @__PURE__ */ __name((name) => {
1638
1638
  }, "nameKey");
1639
1639
  var isReadable = /* @__PURE__ */ __name((shown) => shown !== null && READABLE.test(shown), "isReadable");
1640
1640
 
1641
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/counters.js
1641
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/counters.js
1642
1642
  var COUNTER_FIELDS = ["views", "reactions", "comments"];
1643
1643
  var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
1644
1644
  var counterValue = /* @__PURE__ */ __name((message, field) => {
@@ -1675,7 +1675,7 @@ var counterFreshness = /* @__PURE__ */ __name((states) => {
1675
1675
  return states.some((one) => one.freshness === "stale") ? "stale" : "fresh";
1676
1676
  }, "counterFreshness");
1677
1677
 
1678
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
1678
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
1679
1679
  var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
1680
1680
  var AUTHOR_MEASURES = [
1681
1681
  "messages",
@@ -1815,7 +1815,7 @@ var withoutUrls = /* @__PURE__ */ __name((text2) => text2.replace(/\S+/gu, (toke
1815
1815
  var rankingWords = /* @__PURE__ */ __name((text2) => withoutUrls(text2).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
1816
1816
  var rankingQuestion = /* @__PURE__ */ __name((text2) => withoutUrls(text2).includes("?"), "rankingQuestion");
1817
1817
 
1818
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/records.js
1818
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/records.js
1819
1819
  import { createHash } from "node:crypto";
1820
1820
  var RECORDS_SCHEMA_VERSION = 1;
1821
1821
  var RECORD_OPERATIONS = ["upsert", "delete"];
@@ -1987,7 +1987,7 @@ var fieldReferences = /* @__PURE__ */ __name((record, options = {}) => {
1987
1987
  return found;
1988
1988
  }, "fieldReferences");
1989
1989
 
1990
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/relation-role-labels.js
1990
+ // node_modules/.pnpm/@wirecat+cli-core@0.661.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_df14b19e105bc4fb805918d3d486e7fb/node_modules/@wirecat/cli-core/dist/domain/relation-role-labels.js
1991
1991
  var label = /* @__PURE__ */ __name((en, ru, es) => ({ en, ru, es }), "label");
1992
1992
  var ROLE_LABELS = {
1993
1993
  organization: {
@@ -2029,9 +2029,15 @@ var ROLE_LABELS = {
2029
2029
  };
2030
2030
 
2031
2031
  export {
2032
- chatReferenceOf,
2033
- wrongAccount,
2034
- ensureAccount,
2032
+ PHONE_COUNTRIES,
2033
+ DEFAULT_PHONE_COUNTRIES,
2034
+ parsePhoneCountries,
2035
+ nationalPhone,
2036
+ typedPhone,
2037
+ e164Of,
2038
+ isMobilePhone,
2039
+ BARE_INTERNATIONAL_PROVIDERS,
2040
+ storedPhone,
2035
2041
  QUERY_VERSION,
2036
2042
  QUERY_LIMITS2 as QUERY_LIMITS,
2037
2043
  SEARCH_QUERY,
@@ -2046,14 +2052,6 @@ export {
2046
2052
  compileAutomaton,
2047
2053
  wildcardPattern,
2048
2054
  foldRegex,
2049
- trigrams,
2050
- isId,
2051
- foldName,
2052
- pickChat,
2053
- pickPerson,
2054
- peopleMatching,
2055
- chatsMatching,
2056
- nearest,
2057
2055
  isObject,
2058
2056
  RECORD_TYPES,
2059
2057
  isRecordType,
@@ -2070,21 +2068,23 @@ export {
2070
2068
  FIELD_REFERENCE_ROLES,
2071
2069
  hasV1Roles,
2072
2070
  IDENTITY_TYPES,
2073
- article2 as article,
2071
+ article,
2072
+ chatReferenceOf,
2073
+ wrongAccount,
2074
+ ensureAccount,
2075
+ trigrams,
2076
+ isId,
2077
+ foldName,
2078
+ pickChat,
2079
+ pickPerson,
2080
+ peopleMatching,
2081
+ chatsMatching,
2082
+ nearest,
2074
2083
  isEmailAddress,
2075
2084
  ROLE_ADDRESS_WORDS,
2076
2085
  isRoleAddress,
2077
2086
  isPersonLikeRoleAddress,
2078
2087
  isNoReplyAddress,
2079
- PHONE_COUNTRIES,
2080
- DEFAULT_PHONE_COUNTRIES,
2081
- parsePhoneCountries,
2082
- nationalPhone,
2083
- typedPhone,
2084
- e164Of,
2085
- isMobilePhone,
2086
- BARE_INTERNATIONAL_PROVIDERS,
2087
- storedPhone,
2088
2088
  displayName,
2089
2089
  takeFallbacks,
2090
2090
  noFallbacks,