@wirecat/cli-memo 0.131.40 → 0.131.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/memo.js +2 -2
- package/dist/bundle/{all-profiles-QFW2NKJY.js → all-profiles-ZBEW2K6Y.js} +5 -5
- package/dist/bundle/{anthropic-IARLHPYJ.js → anthropic-2OBFMS2B.js} +3 -3
- package/dist/bundle/{app-server-L4N5IWJF.js → app-server-2BPUD7XU.js} +35 -35
- package/dist/bundle/auto-NIATDHS4.js +86 -0
- package/dist/bundle/{bun-NWKIEX53.js → bun-4NGTZRHL.js} +2 -2
- package/dist/bundle/{bun-sqlite-HORFVNNY.js → bun-sqlite-INSVTXFN.js} +2 -2
- package/dist/bundle/{chunk-ATR65D7K.js → chunk-2IO2DEBO.js} +8 -8
- package/dist/bundle/{chunk-LL5HPYW5.js → chunk-2P54ZDQO.js} +7 -7
- package/dist/bundle/{chunk-ADMB7OK5.js → chunk-2XCXOI4F.js} +22 -4
- package/dist/bundle/{chunk-4EZK5PGX.js → chunk-42VOTRWE.js} +1 -1
- package/dist/bundle/{chunk-XF7TG5VK.js → chunk-4OYYJSRS.js} +50 -48
- package/dist/bundle/{chunk-A7M74RZH.js → chunk-5O3T7Z7F.js} +1286 -765
- package/dist/bundle/{chunk-5G3NNIJQ.js → chunk-67TMJCHI.js} +10 -10
- package/dist/bundle/{chunk-RZ3UQFLE.js → chunk-6BW7SC6A.js} +1 -1
- package/dist/bundle/{chunk-CB34NXQP.js → chunk-A2KU4HSF.js} +57 -56
- package/dist/bundle/{chunk-BWNNUEHG.js → chunk-CKLLVPTR.js} +1 -1
- package/dist/bundle/{chunk-XV7M6VWX.js → chunk-CZ2CX43P.js} +4 -4
- package/dist/bundle/{chunk-ZH43Q2JO.js → chunk-DA5YMQCB.js} +2 -2
- package/dist/bundle/{chunk-DNZH53VQ.js → chunk-E3P7PIR3.js} +3 -3
- package/dist/bundle/{chunk-OGHWLR5E.js → chunk-EKFHAT36.js} +1 -1
- package/dist/bundle/{chunk-NCC3RXUX.js → chunk-ELPCHMDA.js} +3 -3
- package/dist/bundle/{chunk-XAWB4WEC.js → chunk-F6UUS3OF.js} +1 -1
- package/dist/bundle/{chunk-756VKGKO.js → chunk-GECE7WJD.js} +2 -2
- package/dist/bundle/{chunk-KWGNPUIV.js → chunk-GHLLCV4E.js} +7 -7
- package/dist/bundle/{chunk-WU6PDHXY.js → chunk-HCMQGNZU.js} +5 -5
- package/dist/bundle/{chunk-QR5KWOZ2.js → chunk-HQQC5JRS.js} +4 -4
- package/dist/bundle/{chunk-EGQCBZVM.js → chunk-IAML53OZ.js} +2 -2
- package/dist/bundle/{chunk-AKSNCK5L.js → chunk-JWQWLMFP.js} +257 -257
- package/dist/bundle/{chunk-FTX3OPWV.js → chunk-KBOLP4OR.js} +27 -27
- package/dist/bundle/{chunk-YWWTEWX3.js → chunk-KHEFBWLH.js} +1 -1
- package/dist/bundle/{chunk-WHWACGZX.js → chunk-KKXXP5RY.js} +7 -7
- package/dist/bundle/{chunk-JGDZ3G4P.js → chunk-KVKO4X7K.js} +3 -3
- package/dist/bundle/{chunk-A7MXWBIX.js → chunk-LBMZ7SQI.js} +2 -2
- package/dist/bundle/{chunk-SRYOICSG.js → chunk-LJDBOXZN.js} +1 -1
- package/dist/bundle/{chunk-Z6OKSDP3.js → chunk-MWKPW3RU.js} +1 -1
- package/dist/bundle/{chunk-2SZEKYBN.js → chunk-NCBHNEWW.js} +1 -1
- package/dist/bundle/{chunk-M7UHHXSH.js → chunk-NP5FU56F.js} +1 -1
- package/dist/bundle/{chunk-FBREYLY5.js → chunk-O34QHLL5.js} +1 -1
- package/dist/bundle/{chunk-U5WIWLWM.js → chunk-O4I3BJPM.js} +6 -6
- package/dist/bundle/{chunk-W3SMUCMB.js → chunk-O6YTC7DC.js} +1 -1
- package/dist/bundle/{chunk-2YJBI3NK.js → chunk-OAIRZNL2.js} +1 -1
- package/dist/bundle/{chunk-WAZWM4KZ.js → chunk-OJX6GNQY.js} +20 -20
- package/dist/bundle/{chunk-UEG3BDCX.js → chunk-OYHQYCGJ.js} +4 -4
- package/dist/bundle/{chunk-G3IO2TLK.js → chunk-PRL227K7.js} +5 -5
- package/dist/bundle/{chunk-EGRI2NUT.js → chunk-QWNEZWGZ.js} +4 -4
- package/dist/bundle/{chunk-EQQWJM6B.js → chunk-QWNVEFWY.js} +5 -5
- package/dist/bundle/{chunk-KGXVJO2V.js → chunk-QWZUMUA7.js} +5 -5
- package/dist/bundle/{chunk-MLHRER2H.js → chunk-RHIQ34XW.js} +2 -2
- package/dist/bundle/{chunk-B4XRE67Q.js → chunk-RV4EBFH2.js} +17 -9
- package/dist/bundle/{chunk-OZF7QBTS.js → chunk-T4NH7JI6.js} +2 -2
- package/dist/bundle/{chunk-5HSR6U4Z.js → chunk-TBGBA45H.js} +1 -1
- package/dist/bundle/{chunk-6RAU7FD2.js → chunk-TCNOZZPS.js} +11 -11
- package/dist/bundle/{chunk-UGHYNVWQ.js → chunk-TWBJOORY.js} +1 -1
- package/dist/bundle/{chunk-EIFPQD57.js → chunk-TXU5T7VA.js} +1 -1
- package/dist/bundle/{chunk-TWC6UJD2.js → chunk-UCLNEOQS.js} +12 -12
- package/dist/bundle/{chunk-OSDA5EZW.js → chunk-UK2MCVKV.js} +327 -260
- package/dist/bundle/{chunk-ASVVDNAS.js → chunk-UX34ZUMK.js} +3 -3
- package/dist/bundle/{chunk-THIXDXP3.js → chunk-W7GJREIL.js} +2 -2
- package/dist/bundle/{chunk-KAU67PDK.js → chunk-WFA2ZLJB.js} +159 -150
- package/dist/bundle/{chunk-PAE2NZ7S.js → chunk-WG6AOUQW.js} +20 -20
- package/dist/bundle/{chunk-6E4DCMJ5.js → chunk-WSPCOSYD.js} +4 -4
- package/dist/bundle/{chunk-LXQQ7Q34.js → chunk-XUNIJW7V.js} +9 -9
- package/dist/bundle/{chunk-5HXLRQ4Q.js → chunk-YLJWCB6F.js} +43 -43
- package/dist/bundle/{command-contract-ZRJPMWWI.js → command-contract-EYE52WTH.js} +11 -11
- package/dist/bundle/{decode-MDCEP64X.js → decode-JVG6DJJV.js} +2 -2
- package/dist/bundle/{echarts-RFIQAWMT.js → echarts-4IS4IPI4.js} +2 -2
- package/dist/bundle/{embed-443F7XR4.js → embed-7CN33CQR.js} +3 -3
- package/dist/bundle/{embedder-VRDPZFWC.js → embedder-TZ345BZF.js} +6 -6
- package/dist/bundle/{entry-36KBOBA4.js → entry-5VZRNBLV.js} +4 -4
- package/dist/bundle/failure-KIFYUUO6.js +66 -0
- package/dist/bundle/{first-run-CYZSGJTG.js → first-run-EMHSBODF.js} +5 -5
- package/dist/bundle/{first-screen-UY54KNVU.js → first-screen-3PJ3HFLG.js} +12 -12
- package/dist/bundle/{instructions-RI2WFMBA.js → instructions-BTAYTZIS.js} +1 -1
- package/dist/bundle/{mcp-DHX4GF3A.js → mcp-I5KREUIV.js} +35 -35
- package/dist/bundle/memo.js +6 -6
- package/dist/bundle/{node-H7LWGE5H.js → node-FMT4QVUG.js} +2 -2
- package/dist/bundle/{node-sqlite-N4POELFM.js → node-sqlite-2RDIBVYM.js} +3 -3
- package/dist/bundle/{oauth-OOUASPSL.js → oauth-MF53KMXM.js} +4 -4
- package/dist/bundle/{open-2T52CQDG.js → open-WKKHNBXL.js} +2 -2
- package/dist/bundle/{openai-76CJYDRJ.js → openai-36KNG2DB.js} +7 -7
- package/dist/bundle/{process-7YATIAKW.js → process-F2FWK4Q4.js} +1 -1
- package/dist/bundle/{program-O4I2BGM2.js → program-W55Y6LL2.js} +376 -102
- package/dist/bundle/{prompt-MHD5EI75.js → prompt-2TR6X3TJ.js} +2 -2
- package/dist/bundle/{recognize-ARCD7XPJ.js → recognize-MOBCGUI7.js} +1 -1
- package/dist/bundle/{remote-OQ7TUXN3.js → remote-GARKVCO7.js} +4 -4
- package/dist/bundle/{rerank-422D4DZR.js → rerank-L3G7P3KX.js} +4 -4
- package/dist/bundle/{serve-ZOT62JRM.js → serve-ABRMEJ7P.js} +6 -6
- package/dist/bundle/server-NMRAFTY3.js +61 -0
- package/dist/bundle/server-VX3L42ED.js +48 -0
- package/dist/bundle/{server-HAZC3T7X.js → server-XLMROR5L.js} +50 -50
- package/dist/bundle/{state-KBW7BI2G.js → state-5N2RVH2Y.js} +3 -3
- package/dist/bundle/{store-KZY5FZPD.js → store-4ML7O47C.js} +9 -9
- package/dist/bundle/store-maintenance-command-O3OTXKNO.js +48 -0
- package/dist/bundle/update-OWKZLZTS.js +69 -0
- package/dist/discovery/command.d.ts.map +1 -1
- package/dist/discovery/command.js +3 -0
- package/dist/discovery/command.js.map +1 -1
- package/dist/doctor/command.d.ts +1 -1
- package/dist/examples.d.ts.map +1 -1
- package/dist/examples.js +19 -0
- package/dist/examples.js.map +1 -1
- package/dist/finance/deals-command.d.ts +22 -0
- package/dist/finance/deals-command.d.ts.map +1 -0
- package/dist/finance/deals-command.js +235 -0
- package/dist/finance/deals-command.js.map +1 -0
- package/dist/finance/finance.d.ts +1 -1
- package/dist/finance/finance.d.ts.map +1 -1
- package/dist/finance/finance.js +2 -0
- package/dist/finance/finance.js.map +1 -1
- package/dist/knowledge/project-status-command.d.ts.map +1 -1
- package/dist/knowledge/project-status-command.js +14 -7
- package/dist/knowledge/project-status-command.js.map +1 -1
- package/dist/mail/findings-command.d.ts.map +1 -1
- package/dist/mail/findings-command.js +9 -13
- package/dist/mail/findings-command.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +65 -0
- package/dist/program.js.map +1 -1
- package/dist/review/command.d.ts +40 -0
- package/dist/review/command.d.ts.map +1 -1
- package/dist/review/command.js +25 -1
- package/dist/review/command.js.map +1 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +18 -0
- package/dist/rows.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/skills/cli-memo/topics/money.md +6 -0
- package/skills/mail-triage/SKILL.md +8 -9
- package/dist/bundle/auto-24I3FBUW.js +0 -86
- package/dist/bundle/failure-QKFNHYKC.js +0 -66
- package/dist/bundle/server-EISBI6O6.js +0 -61
- package/dist/bundle/server-NNQ3YRBV.js +0 -48
- package/dist/bundle/store-maintenance-command-ZFQOMCLZ.js +0 -48
- package/dist/bundle/update-SAX5XN2C.js +0 -69
- /package/dist/bundle/{chunk-5VKETWNU.js → chunk-O3EZTSTN.js} +0 -0
|
@@ -83,6 +83,7 @@ import {
|
|
|
83
83
|
reminder,
|
|
84
84
|
scaleOf,
|
|
85
85
|
settledStatus,
|
|
86
|
+
snakeCase,
|
|
86
87
|
tagOf,
|
|
87
88
|
timezoneOf,
|
|
88
89
|
transcriptLanguage,
|
|
@@ -99,11 +100,11 @@ import {
|
|
|
99
100
|
validateQuery,
|
|
100
101
|
walkQuery,
|
|
101
102
|
zonedMoment
|
|
102
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-A2KU4HSF.js";
|
|
103
104
|
import {
|
|
104
105
|
holdsCredential,
|
|
105
106
|
secretNamed
|
|
106
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-42VOTRWE.js";
|
|
107
108
|
import {
|
|
108
109
|
DEFAULT_STEMMERS,
|
|
109
110
|
DEFAULT_STEMMERS_VERSION,
|
|
@@ -116,26 +117,26 @@ import {
|
|
|
116
117
|
fold,
|
|
117
118
|
normalize,
|
|
118
119
|
parseStemmers
|
|
119
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-GHLLCV4E.js";
|
|
120
121
|
import {
|
|
121
122
|
DEFAULT_TASK_CATEGORIES,
|
|
122
123
|
sharedConfigPath,
|
|
123
124
|
storedTaskCategories,
|
|
124
125
|
taskCategoriesReader
|
|
125
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-OYHQYCGJ.js";
|
|
126
127
|
import {
|
|
127
128
|
refuseOwnerStoreInTests,
|
|
128
129
|
storePath
|
|
129
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-F6UUS3OF.js";
|
|
130
131
|
import {
|
|
131
132
|
quietSqliteWarning,
|
|
132
133
|
storeCapable
|
|
133
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-QWNVEFWY.js";
|
|
134
135
|
import {
|
|
135
136
|
PRAGMAS,
|
|
136
137
|
TIME_LIMIT_FUNCTION,
|
|
137
138
|
TimeLimitReached
|
|
138
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-CKLLVPTR.js";
|
|
139
140
|
import {
|
|
140
141
|
array,
|
|
141
142
|
boolean,
|
|
@@ -185,7 +186,7 @@ import {
|
|
|
185
186
|
sql,
|
|
186
187
|
sqliteTable,
|
|
187
188
|
text
|
|
188
|
-
} from "./chunk-
|
|
189
|
+
} from "./chunk-TXU5T7VA.js";
|
|
189
190
|
import {
|
|
190
191
|
__commonJS,
|
|
191
192
|
__name,
|
|
@@ -9929,7 +9930,7 @@ var require_cjs = __commonJS({
|
|
|
9929
9930
|
}
|
|
9930
9931
|
});
|
|
9931
9932
|
|
|
9932
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
9933
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/account-store.js
|
|
9933
9934
|
var bindArea = /* @__PURE__ */ __name(({ keyed, whole }, account) => {
|
|
9934
9935
|
const methods = whole;
|
|
9935
9936
|
return Object.fromEntries(Object.keys(keyed).map((name) => [
|
|
@@ -10057,7 +10058,7 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
|
|
|
10057
10058
|
};
|
|
10058
10059
|
}, "bindAccount");
|
|
10059
10060
|
|
|
10060
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10061
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/locator.js
|
|
10061
10062
|
var SCHEME = "msg:";
|
|
10062
10063
|
var formatLocator = /* @__PURE__ */ __name(({ provider, account, chat: chat2, message: message2 }) => SCHEME + [provider, account, chat2, message2].map(encodeURIComponent).join("/"), "formatLocator");
|
|
10063
10064
|
var isLocator = /* @__PURE__ */ __name((reference2) => reference2.trim().startsWith(SCHEME), "isLocator");
|
|
@@ -10071,7 +10072,7 @@ var parseLocator = /* @__PURE__ */ __name((reference2) => {
|
|
|
10071
10072
|
return { provider, account, chat: chat2, message: message2 };
|
|
10072
10073
|
}, "parseLocator");
|
|
10073
10074
|
|
|
10074
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10075
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/references.js
|
|
10075
10076
|
var SIMPLE_REFERENCES = [
|
|
10076
10077
|
"note",
|
|
10077
10078
|
"document",
|
|
@@ -10086,6 +10087,9 @@ var SIMPLE_REFERENCES = [
|
|
|
10086
10087
|
"invoice",
|
|
10087
10088
|
"payment",
|
|
10088
10089
|
"order",
|
|
10090
|
+
"deal",
|
|
10091
|
+
"lead",
|
|
10092
|
+
"pipeline",
|
|
10089
10093
|
"entity"
|
|
10090
10094
|
];
|
|
10091
10095
|
var malformed = /* @__PURE__ */ __name((text6, shape) => new CliError("validation_error", `"${singleLine(text6)}" is not a reference \u2014 expected ${shape}`, {
|
|
@@ -10219,7 +10223,7 @@ var looksLikeReference = /* @__PURE__ */ __name((text6) => {
|
|
|
10219
10223
|
return match !== null && byPrefix.has(match[1]);
|
|
10220
10224
|
}, "looksLikeReference");
|
|
10221
10225
|
|
|
10222
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10226
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/providers.js
|
|
10223
10227
|
var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events"];
|
|
10224
10228
|
var MESSENGER_OPENS = { chat: "messages list", message: "messages show", contact: "contacts show" };
|
|
10225
10229
|
var PROVIDERS = [
|
|
@@ -10335,7 +10339,7 @@ var providerNamed = /* @__PURE__ */ __name((word2) => {
|
|
|
10335
10339
|
var kindIn = /* @__PURE__ */ __name((provider) => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind, "kindIn");
|
|
10336
10340
|
var kindOf = /* @__PURE__ */ __name((provider) => kindIn(provider) ?? "messages", "kindOf");
|
|
10337
10341
|
|
|
10338
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10342
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/query.js
|
|
10339
10343
|
var isBotProvider = /* @__PURE__ */ __name((provider) => provider.endsWith("-bot"), "isBotProvider");
|
|
10340
10344
|
var inSource = /* @__PURE__ */ __name((source2, provider) => source2 === "all" || source2 === "bots" && isBotProvider(provider) || source2 === "personal" && !isBotProvider(provider) || source2 === provider || providerNamed(source2)?.name === provider || isKind(source2) && kindOf(provider) === source2, "inSource");
|
|
10341
10345
|
var fail = /* @__PURE__ */ __name((message2) => {
|
|
@@ -10358,7 +10362,7 @@ var sourceOf = /* @__PURE__ */ __name((name, value, providers2) => {
|
|
|
10358
10362
|
return fail(`${name} takes ${[...sources, "messages", "mail"].join(", ")} \u2014 not "${value}"`);
|
|
10359
10363
|
}, "sourceOf");
|
|
10360
10364
|
|
|
10361
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10365
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/account-list.js
|
|
10362
10366
|
var ACCOUNT_GROUPS = "accountGroups";
|
|
10363
10367
|
var ACCOUNT_GROUPS_SETTING = "account_groups";
|
|
10364
10368
|
var GROUP_NAME = /^[a-z0-9][a-z0-9_-]*$/i;
|
|
@@ -10545,7 +10549,7 @@ var fitting = /* @__PURE__ */ __name((entries, kinds2, what, reasonOf2 = (kind4)
|
|
|
10545
10549
|
return { accounts: [...chosen.values()], skipped };
|
|
10546
10550
|
}, "fitting");
|
|
10547
10551
|
|
|
10548
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10552
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
|
|
10549
10553
|
var IndexBuilderOn = class {
|
|
10550
10554
|
static {
|
|
10551
10555
|
__name(this, "IndexBuilderOn");
|
|
@@ -10740,7 +10744,7 @@ function alias(table, alias2) {
|
|
|
10740
10744
|
}
|
|
10741
10745
|
__name(alias, "alias");
|
|
10742
10746
|
|
|
10743
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10747
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
|
|
10744
10748
|
var ENTITY_TABLES = {
|
|
10745
10749
|
account: "accounts",
|
|
10746
10750
|
attachment: "attachments",
|
|
@@ -10748,6 +10752,7 @@ var ENTITY_TABLES = {
|
|
|
10748
10752
|
calendar_entry: "calendar_entries",
|
|
10749
10753
|
chat: "chats",
|
|
10750
10754
|
conversation: "conversations",
|
|
10755
|
+
deal: "deals",
|
|
10751
10756
|
document: "documents",
|
|
10752
10757
|
document_picture: "documents",
|
|
10753
10758
|
email: "emails",
|
|
@@ -10759,6 +10764,7 @@ var ENTITY_TABLES = {
|
|
|
10759
10764
|
identity: "identities",
|
|
10760
10765
|
image: "attachments",
|
|
10761
10766
|
invoice: "invoices",
|
|
10767
|
+
lead: "leads",
|
|
10762
10768
|
meeting: "meetings",
|
|
10763
10769
|
meeting_transcript: "meeting_transcripts",
|
|
10764
10770
|
meeting_transcript_row: "meeting_transcript_rows",
|
|
@@ -10769,6 +10775,7 @@ var ENTITY_TABLES = {
|
|
|
10769
10775
|
organization: "organizations",
|
|
10770
10776
|
payment: "payments",
|
|
10771
10777
|
person: "persons",
|
|
10778
|
+
pipeline: "pipelines",
|
|
10772
10779
|
place: "places",
|
|
10773
10780
|
project: "projects",
|
|
10774
10781
|
tag: "canonical_tags",
|
|
@@ -10783,7 +10790,7 @@ var orphanPointers = /* @__PURE__ */ __name((database) => pointerPairs(database)
|
|
|
10783
10790
|
return { table, pointer, type, count, known: known2 };
|
|
10784
10791
|
}).filter(({ count }) => count > 0)), "orphanPointers");
|
|
10785
10792
|
|
|
10786
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10793
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
|
|
10787
10794
|
var canonicalTags = sqliteTable("canonical_tags", {
|
|
10788
10795
|
id: integer("id").primaryKey(),
|
|
10789
10796
|
name: text("name").notNull().unique(),
|
|
@@ -10792,7 +10799,7 @@ var canonicalTags = sqliteTable("canonical_tags", {
|
|
|
10792
10799
|
updatedAt: integer("updated_at").notNull()
|
|
10793
10800
|
});
|
|
10794
10801
|
|
|
10795
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10802
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
|
|
10796
10803
|
var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
|
|
10797
10804
|
sourceKey: text("source_key").notNull(),
|
|
10798
10805
|
collection: text("collection").notNull(),
|
|
@@ -10802,13 +10809,13 @@ var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
|
|
|
10802
10809
|
createdAt: integer("created_at").notNull()
|
|
10803
10810
|
}, (table) => [primaryKey({ columns: [table.sourceKey, table.collection] })]);
|
|
10804
10811
|
|
|
10805
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10812
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
|
|
10806
10813
|
var documentIndexPending = sqliteTable("document_index_pending", {
|
|
10807
10814
|
id: integer("id").notNull(),
|
|
10808
10815
|
indexableType: text("indexable_type").notNull()
|
|
10809
10816
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
10810
10817
|
|
|
10811
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10818
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
|
|
10812
10819
|
var tagRedirects = sqliteTable("tag_redirects", {
|
|
10813
10820
|
sourceId: integer("source_id").primaryKey().references(() => canonicalTags.id),
|
|
10814
10821
|
survivorId: integer("survivor_id").notNull().references(() => canonicalTags.id),
|
|
@@ -10834,7 +10841,7 @@ var tagConsolidations = sqliteTable("tag_consolidations", {
|
|
|
10834
10841
|
index("tag_consolidations_by_actor_type_actor_id").on(table.actorType, table.actorId)
|
|
10835
10842
|
]);
|
|
10836
10843
|
|
|
10837
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10844
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
|
|
10838
10845
|
var accounts = sqliteTable("accounts", {
|
|
10839
10846
|
id: integer("id").primaryKey(),
|
|
10840
10847
|
provider: text("provider").notNull(),
|
|
@@ -12160,6 +12167,108 @@ var orders = sqliteTable("orders", {
|
|
|
12160
12167
|
index("orders_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
12161
12168
|
index("orders_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById)
|
|
12162
12169
|
]);
|
|
12170
|
+
var pipelines = sqliteTable("pipelines", {
|
|
12171
|
+
id: integer("id").primaryKey(),
|
|
12172
|
+
accountId: integer("account_id").references(() => accounts.id),
|
|
12173
|
+
externalId: text("external_id"),
|
|
12174
|
+
kind: text("kind").notNull().default("deal"),
|
|
12175
|
+
name: text("name").notNull(),
|
|
12176
|
+
nameFolded: text("name_folded").notNull(),
|
|
12177
|
+
createdAt: integer("created_at").notNull(),
|
|
12178
|
+
updatedAt: integer("updated_at").notNull()
|
|
12179
|
+
}, (table) => [
|
|
12180
|
+
uniqueIndex("pipelines_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
|
|
12181
|
+
uniqueIndex("pipelines_by_name_folded_kind").on(table.nameFolded, table.kind).where(sql`account_id IS NULL`)
|
|
12182
|
+
]);
|
|
12183
|
+
var pipelineStages = sqliteTable("pipeline_stages", {
|
|
12184
|
+
id: integer("id").primaryKey(),
|
|
12185
|
+
pipelineId: integer("pipeline_id").notNull().references(() => pipelines.id),
|
|
12186
|
+
name: text("name").notNull(),
|
|
12187
|
+
nameFolded: text("name_folded").notNull(),
|
|
12188
|
+
position: integer("position").notNull(),
|
|
12189
|
+
outcome: text("outcome").notNull().default("open"),
|
|
12190
|
+
externalId: text("external_id"),
|
|
12191
|
+
createdAt: integer("created_at").notNull(),
|
|
12192
|
+
updatedAt: integer("updated_at").notNull()
|
|
12193
|
+
}, (table) => [
|
|
12194
|
+
unique().on(table.pipelineId, table.nameFolded),
|
|
12195
|
+
uniqueIndex("pipeline_stages_by_pipeline_id_external_id").on(table.pipelineId, table.externalId).where(sql`external_id IS NOT NULL`),
|
|
12196
|
+
index("pipeline_stages_by_pipeline_id_position").on(table.pipelineId, table.position)
|
|
12197
|
+
]);
|
|
12198
|
+
var deals = sqliteTable("deals", {
|
|
12199
|
+
id: integer("id").primaryKey(),
|
|
12200
|
+
title: text("title").notNull(),
|
|
12201
|
+
organizationId: integer("organization_id").references(() => organizations.id),
|
|
12202
|
+
projectId: integer("project_id").references(() => projects.id),
|
|
12203
|
+
stageId: integer("stage_id").notNull().references(() => pipelineStages.id),
|
|
12204
|
+
status: text("status").notNull(),
|
|
12205
|
+
currency: text("currency"),
|
|
12206
|
+
amount: integer("amount"),
|
|
12207
|
+
closeDate: text("close_date"),
|
|
12208
|
+
closedDate: text("closed_date"),
|
|
12209
|
+
rank: real("rank"),
|
|
12210
|
+
accountId: integer("account_id").references(() => accounts.id),
|
|
12211
|
+
externalId: text("external_id"),
|
|
12212
|
+
authorType: text("author_type").notNull(),
|
|
12213
|
+
authorId: integer("author_id").notNull(),
|
|
12214
|
+
model: text("model"),
|
|
12215
|
+
source: text("source").notNull(),
|
|
12216
|
+
metadata: text("metadata"),
|
|
12217
|
+
createdAt: integer("created_at").notNull(),
|
|
12218
|
+
updatedAt: integer("updated_at").notNull(),
|
|
12219
|
+
deletedAt: integer("deleted_at")
|
|
12220
|
+
}, (table) => [
|
|
12221
|
+
uniqueIndex("deals_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
|
|
12222
|
+
index("deals_by_organization_id").on(table.organizationId),
|
|
12223
|
+
index("deals_by_project_id").on(table.projectId),
|
|
12224
|
+
index("deals_by_stage_id").on(table.stageId),
|
|
12225
|
+
index("deals_by_author_type_author_id").on(table.authorType, table.authorId)
|
|
12226
|
+
]);
|
|
12227
|
+
var leads = sqliteTable("leads", {
|
|
12228
|
+
id: integer("id").primaryKey(),
|
|
12229
|
+
title: text("title").notNull(),
|
|
12230
|
+
organizationId: integer("organization_id").references(() => organizations.id),
|
|
12231
|
+
projectId: integer("project_id").references(() => projects.id),
|
|
12232
|
+
stageId: integer("stage_id").notNull().references(() => pipelineStages.id),
|
|
12233
|
+
status: text("status").notNull(),
|
|
12234
|
+
currency: text("currency"),
|
|
12235
|
+
amount: integer("amount"),
|
|
12236
|
+
closeDate: text("close_date"),
|
|
12237
|
+
closedDate: text("closed_date"),
|
|
12238
|
+
rank: real("rank"),
|
|
12239
|
+
dealId: integer("deal_id").references(() => deals.id),
|
|
12240
|
+
accountId: integer("account_id").references(() => accounts.id),
|
|
12241
|
+
externalId: text("external_id"),
|
|
12242
|
+
authorType: text("author_type").notNull(),
|
|
12243
|
+
authorId: integer("author_id").notNull(),
|
|
12244
|
+
model: text("model"),
|
|
12245
|
+
source: text("source").notNull(),
|
|
12246
|
+
metadata: text("metadata"),
|
|
12247
|
+
createdAt: integer("created_at").notNull(),
|
|
12248
|
+
updatedAt: integer("updated_at").notNull(),
|
|
12249
|
+
deletedAt: integer("deleted_at")
|
|
12250
|
+
}, (table) => [
|
|
12251
|
+
uniqueIndex("leads_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
|
|
12252
|
+
index("leads_by_organization_id").on(table.organizationId),
|
|
12253
|
+
index("leads_by_project_id").on(table.projectId),
|
|
12254
|
+
index("leads_by_stage_id").on(table.stageId),
|
|
12255
|
+
index("leads_by_deal_id").on(table.dealId),
|
|
12256
|
+
index("leads_by_author_type_author_id").on(table.authorType, table.authorId)
|
|
12257
|
+
]);
|
|
12258
|
+
var pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
|
|
12259
|
+
id: integer("id").primaryKey(),
|
|
12260
|
+
itemType: text("item_type").notNull(),
|
|
12261
|
+
itemId: integer("item_id").notNull(),
|
|
12262
|
+
pipelineId: integer("pipeline_id").notNull().references(() => pipelines.id),
|
|
12263
|
+
fromStageId: integer("from_stage_id").references(() => pipelineStages.id),
|
|
12264
|
+
toStageId: integer("to_stage_id").notNull().references(() => pipelineStages.id),
|
|
12265
|
+
changedAt: integer("changed_at").notNull()
|
|
12266
|
+
}, (table) => [
|
|
12267
|
+
index("pipeline_stage_changes_by_item_type_item_id").on(table.itemType, table.itemId),
|
|
12268
|
+
index("pipeline_stage_changes_by_pipeline_id").on(table.pipelineId),
|
|
12269
|
+
index("pipeline_stage_changes_by_from_stage_id").on(table.fromStageId),
|
|
12270
|
+
index("pipeline_stage_changes_by_to_stage_id").on(table.toStageId)
|
|
12271
|
+
]);
|
|
12163
12272
|
var records = sqliteTable("records", {
|
|
12164
12273
|
id: integer("id").primaryKey(),
|
|
12165
12274
|
accountId: integer("account_id").notNull().references(() => accounts.id),
|
|
@@ -12501,7 +12610,7 @@ var storeSettings = sqliteTable("store_settings", {
|
|
|
12501
12610
|
at: integer("at").notNull()
|
|
12502
12611
|
});
|
|
12503
12612
|
|
|
12504
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
12613
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
|
|
12505
12614
|
var ARMS = [
|
|
12506
12615
|
[
|
|
12507
12616
|
"message",
|
|
@@ -12628,7 +12737,7 @@ var drainInvolvementQueue = /* @__PURE__ */ __name((database, cap = QUEUE_CAP) =
|
|
|
12628
12737
|
return recomputed;
|
|
12629
12738
|
}, "drainInvolvementQueue");
|
|
12630
12739
|
|
|
12631
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
12740
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/mentions.js
|
|
12632
12741
|
import { domainToUnicode } from "node:url";
|
|
12633
12742
|
|
|
12634
12743
|
// node_modules/.pnpm/psl@1.15.0/node_modules/psl/dist/psl.mjs
|
|
@@ -22650,7 +22759,7 @@ var oa = /* @__PURE__ */ __name((e) => {
|
|
|
22650
22759
|
}, "oa");
|
|
22651
22760
|
var na = { parse: O, get: aa, isValid: oa };
|
|
22652
22761
|
|
|
22653
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
22762
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
|
|
22654
22763
|
var LINK = /https?:\/\/(?:(?:docs|drive|sheets|slides)\.google\.com|forms\.gle)(?:[/?#][^\s<>"'`]*)?/gi;
|
|
22655
22764
|
var ID = /^[\w-]{10,}$/;
|
|
22656
22765
|
var trimUrl = /* @__PURE__ */ __name((url) => {
|
|
@@ -22691,7 +22800,7 @@ var googleDocumentLinks = /* @__PURE__ */ __name((text6) => [...text6.matchAll(L
|
|
|
22691
22800
|
return { url, documentId: googleDocumentId(url) };
|
|
22692
22801
|
}), "googleDocumentLinks");
|
|
22693
22802
|
|
|
22694
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
22803
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
|
|
22695
22804
|
var PHONE_PLANS = [
|
|
22696
22805
|
{
|
|
22697
22806
|
country: "us",
|
|
@@ -23071,7 +23180,7 @@ var PHONE_PLANS = [
|
|
|
23071
23180
|
}
|
|
23072
23181
|
];
|
|
23073
23182
|
|
|
23074
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23183
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/phones.js
|
|
23075
23184
|
var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
|
|
23076
23185
|
var DEFAULT_PHONE_COUNTRIES = ["ru"];
|
|
23077
23186
|
var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
|
|
@@ -23112,7 +23221,7 @@ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
|
|
|
23112
23221
|
return void 0;
|
|
23113
23222
|
}, "nationalPhone");
|
|
23114
23223
|
|
|
23115
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23224
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/places.js
|
|
23116
23225
|
var BEFORE = [
|
|
23117
23226
|
[/^(?:ул\.?|улиц[аеыу]|улицей)$/iu, "\u0443\u043B\u0438\u0446\u0430"],
|
|
23118
23227
|
[/^(?:пр-т|просп\.?|проспект[аеу]?)$/iu, "\u043F\u0440\u043E\u0441\u043F\u0435\u043A\u0442"],
|
|
@@ -23372,7 +23481,7 @@ var findPlaces = /* @__PURE__ */ __name((text6) => {
|
|
|
23372
23481
|
return found2.sort((a, b) => a.start - b.start);
|
|
23373
23482
|
}, "findPlaces");
|
|
23374
23483
|
|
|
23375
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23484
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/mentions.js
|
|
23376
23485
|
var MENTION_KINDS = ["phone", "email", "url", "document", "person-name", "place"];
|
|
23377
23486
|
var MENTION_VERSIONS = {
|
|
23378
23487
|
phone: 1,
|
|
@@ -23562,7 +23671,7 @@ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE
|
|
|
23562
23671
|
};
|
|
23563
23672
|
}, "typedPhone");
|
|
23564
23673
|
|
|
23565
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23674
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/first-names.js
|
|
23566
23675
|
var RUSSIAN = "\u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440 \u0410\u043B\u0435\u043A\u0441\u0435\u0439 \u0410\u043D\u0430\u0442\u043E\u043B\u0438\u0439 \u0410\u043D\u0434\u0440\u0435\u0439 \u0410\u043D\u0442\u043E\u043D \u0410\u0440\u043A\u0430\u0434\u0438\u0439 \u0410\u0440\u0441\u0435\u043D\u0438\u0439 \u0410\u0440\u0442\u0451\u043C \u0410\u0440\u0442\u0435\u043C \u0410\u0440\u0442\u0443\u0440 \u0411\u043E\u0440\u0438\u0441 \u0412\u0430\u0434\u0438\u043C \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D \u0412\u0430\u043B\u0435\u0440\u0438\u0439 \u0412\u0430\u0441\u0438\u043B\u0438\u0439 \u0412\u0438\u043A\u0442\u043E\u0440 \u0412\u0438\u0442\u0430\u043B\u0438\u0439 \u0412\u043B\u0430\u0434\u0438\u043C\u0438\u0440 \u0412\u043B\u0430\u0434\u0438\u0441\u043B\u0430\u0432 \u0412\u0441\u0435\u0432\u043E\u043B\u043E\u0434 \u0412\u044F\u0447\u0435\u0441\u043B\u0430\u0432 \u0413\u0435\u043D\u043D\u0430\u0434\u0438\u0439 \u0413\u0435\u043E\u0440\u0433\u0438\u0439 \u0413\u043B\u0435\u0431 \u0413\u0440\u0438\u0433\u043E\u0440\u0438\u0439 \u0414\u0430\u043D\u0438\u0438\u043B \u0414\u0430\u043D\u0438\u043B\u0430 \u0414\u0435\u043D\u0438\u0441 \u0414\u043C\u0438\u0442\u0440\u0438\u0439 \u0415\u0432\u0433\u0435\u043D\u0438\u0439 \u0415\u0433\u043E\u0440 \u0418\u0432\u0430\u043D \u0418\u0433\u043E\u0440\u044C \u0418\u043B\u044C\u044F \u041A\u0438\u0440\u0438\u043B\u043B \u041A\u043E\u043D\u0441\u0442\u0430\u043D\u0442\u0438\u043D \u041B\u0435\u043E\u043D\u0438\u0434 \u041C\u0430\u043A\u0441\u0438\u043C \u041C\u0430\u0440\u0430\u0442 \u041C\u0430\u0442\u0432\u0435\u0439 \u041C\u0438\u0445\u0430\u0438\u043B \u041D\u0438\u043A\u0438\u0442\u0430 \u041D\u0438\u043A\u043E\u043B\u0430\u0439 \u041E\u043B\u0435\u0433 \u041F\u0430\u0432\u0435\u043B \u041F\u0451\u0442\u0440 \u041F\u0435\u0442\u0440 \u0420\u043E\u0434\u0438\u043E\u043D \u0420\u043E\u0441\u0442\u0438\u0441\u043B\u0430\u0432 \u0420\u0443\u0441\u043B\u0430\u043D \u0420\u0443\u0441\u0442\u0430\u043C \u0421\u0435\u043C\u0451\u043D \u0421\u0435\u043C\u0435\u043D \u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u0442\u0430\u043D\u0438\u0441\u043B\u0430\u0432 \u0421\u0442\u0435\u043F\u0430\u043D \u0422\u0438\u043C\u043E\u0444\u0435\u0439 \u0422\u0438\u043C\u0443\u0440 \u0424\u0451\u0434\u043E\u0440 \u0424\u0435\u0434\u043E\u0440 \u0424\u0438\u043B\u0438\u043F\u043F \u042D\u0434\u0443\u0430\u0440\u0434 \u042E\u0440\u0438\u0439 \u042F\u0440\u043E\u0441\u043B\u0430\u0432 \u042F\u043A\u043E\u0432 \u042D\u043B\u044C\u0434\u0430\u0440 \u0414\u0430\u0432\u0438\u0434 \u0417\u0430\u0445\u0430\u0440 \u0421\u0430\u0432\u0435\u043B\u0438\u0439 \u041C\u0438\u0440\u043E\u043D \u041F\u043B\u0430\u0442\u043E\u043D \u0414\u0435\u043C\u0438\u0434 \u0410\u0440\u0441\u0435\u043D \u041D\u0443\u0440\u043B\u0430\u043D \u0410\u043D\u0437\u043E\u0440 \u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440\u0430 \u0410\u043B\u0438\u043D\u0430 \u0410\u043B\u0438\u0441\u0430 \u0410\u043B\u043B\u0430 \u0410\u043D\u0430\u0441\u0442\u0430\u0441\u0438\u044F \u0410\u043D\u0433\u0435\u043B\u0438\u043D\u0430 \u0410\u043D\u043D\u0430 \u0410\u043D\u0442\u043E\u043D\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u0440\u0438\u044F \u0412\u0430\u0440\u0432\u0430\u0440\u0430 \u0412\u0435\u0440\u043E\u043D\u0438\u043A\u0430 \u0412\u0438\u043A\u0442\u043E\u0440\u0438\u044F \u0413\u0430\u043B\u0438\u043D\u0430 \u0414\u0430\u0440\u044C\u044F \u0414\u0438\u0430\u043D\u0430 \u0415\u0432\u0433\u0435\u043D\u0438\u044F \u0415\u043A\u0430\u0442\u0435\u0440\u0438\u043D\u0430 \u0415\u043B\u0435\u043D\u0430 \u0415\u043B\u0438\u0437\u0430\u0432\u0435\u0442\u0430 \u0416\u0430\u043D\u043D\u0430 \u0417\u0438\u043D\u0430\u0438\u0434\u0430 \u041A\u0430\u0440\u0438\u043D\u0430 \u041A\u0438\u0440\u0430 \u041A\u043B\u0430\u0432\u0434\u0438\u044F \u041A\u0440\u0438\u0441\u0442\u0438\u043D\u0430 \u041A\u0441\u0435\u043D\u0438\u044F \u041B\u0430\u0440\u0438\u0441\u0430 \u041B\u0438\u0434\u0438\u044F \u041B\u044E\u0434\u043C\u0438\u043B\u0430 \u041C\u0430\u0440\u0433\u0430\u0440\u0438\u0442\u0430 \u041C\u0430\u0440\u0438\u043D\u0430 \u041C\u0430\u0440\u0438\u044F \u041C\u0438\u043B\u0430\u043D\u0430 \u041D\u0430\u0442\u0430\u043B\u044C\u044F \u041D\u0430\u0442\u0430\u043B\u0438\u044F \u041D\u0438\u043D\u0430 \u041E\u043A\u0441\u0430\u043D\u0430 \u041E\u043B\u0435\u0441\u044F \u041E\u043B\u044C\u0433\u0430 \u041F\u043E\u043B\u0438\u043D\u0430 \u0420\u0430\u0438\u0441\u0430 \u0421\u0432\u0435\u0442\u043B\u0430\u043D\u0430 \u0421\u043E\u0444\u0438\u044F \u0421\u043E\u0444\u044C\u044F \u0422\u0430\u0438\u0441\u0438\u044F \u0422\u0430\u043C\u0430\u0440\u0430 \u0422\u0430\u0442\u044C\u044F\u043D\u0430 \u0423\u043B\u044C\u044F\u043D\u0430 \u042E\u043B\u0438\u044F \u042D\u043B\u044C\u0432\u0438\u0440\u0430 \u0420\u0435\u0433\u0438\u043D\u0430 \u0421\u043D\u0435\u0436\u0430\u043D\u0430 \u0410\u043B\u0451\u043D\u0430 \u0410\u043B\u0435\u043D\u0430 \u0412\u0430\u0441\u0438\u043B\u0438\u0441\u0430 \u0410\u0440\u0438\u043D\u0430 \u0415\u0441\u0435\u043D\u0438\u044F \u042D\u0432\u0435\u043B\u0438\u043D\u0430 \u0421\u0430\u0448\u0430 \u0416\u0435\u043D\u044F \u0412\u0430\u043B\u044F \u0414\u0438\u043C\u0430 \u041C\u0438\u0448\u0430 \u041A\u043E\u043B\u044F \u041F\u0435\u0442\u044F \u0412\u0430\u0441\u044F \u0421\u0435\u0440\u0451\u0436\u0430 \u0421\u0435\u0440\u0435\u0436\u0430 \u041F\u0430\u0448\u0430 \u041B\u0451\u0448\u0430 \u041B\u0435\u0448\u0430 \u0412\u0438\u0442\u044F \u041A\u043E\u0441\u0442\u044F \u0412\u043E\u0432\u0430 \u0412\u043E\u043B\u043E\u0434\u044F \u0412\u0430\u043D\u044F \u0413\u043E\u0448\u0430 \u0413\u0440\u0438\u0448\u0430 \u0422\u043E\u043B\u044F \u0411\u043E\u0440\u044F \u0421\u0442\u0430\u0441 \u0422\u0451\u043C\u0430 \u0422\u0430\u043D\u044F \u041A\u0430\u0442\u044F \u041B\u0435\u043D\u0430 \u041D\u0430\u0442\u0430\u0448\u0430 \u0421\u0432\u0435\u0442\u0430 \u042E\u043B\u044F \u041D\u0430\u0441\u0442\u044F \u0414\u0430\u0448\u0430 \u041C\u0430\u0448\u0430 \u041B\u044E\u0434\u0430 \u0413\u0430\u043B\u044F \u0412\u0438\u043A\u0430 \u041A\u0441\u044E\u0448\u0430 \u041B\u0438\u0437\u0430 \u0421\u043E\u043D\u044F \u041D\u0430\u0434\u044F \u041B\u0435\u0440\u0430 \u0410\u043B\u0451\u0448\u0430 \u0410\u043B\u0435\u0448\u0430 \u041C\u0438\u0442\u044F \u0421\u0435\u043D\u044F \u0424\u0435\u0434\u044F \u0416\u0435\u043D\u0435\u0447\u043A\u0430 \u041E\u043B\u0435\u043D\u044C\u043A\u0430 \u0422\u0430\u043D\u0435\u0447\u043A\u0430";
|
|
23567
23676
|
var EUROPEAN = "James John Robert Michael William David Richard Joseph Thomas Charles Christopher Daniel Matthew Anthony Donald Steven Paul Andrew Joshua Kenneth Kevin Brian George Timothy Ronald Edward Jason Jeffrey Ryan Jacob Gary Nicholas Eric Jonathan Stephen Larry Justin Scott Brandon Benjamin Samuel Gregory Alexander Patrick Raymond Dennis Jerry Tyler Aaron Nathan Henry Peter Zachary Douglas Harold Kyle Noah Ethan Oliver Harry Lucas Liam Mary Patricia Jennifer Linda Elizabeth Barbara Susan Jessica Sarah Karen Lisa Nancy Betty Margaret Sandra Ashley Kimberly Emily Donna Michelle Carol Amanda Dorothy Melissa Deborah Stephanie Rebecca Sharon Laura Cynthia Kathleen Angela Shirley Anna Brenda Pamela Emma Nicole Helen Samantha Katherine Christine Rachel Carolyn Janet Catherine Maria Heather Diane Ruth Julie Olivia Joyce Kelly Lauren Christina Joan Evelyn Judith Megan Andrea Cheryl Hannah Jacqueline Martha Teresa Sara Madison Frances Kathryn Janice Abigail Alice Julia Judy Sophia Denise Doris Marilyn Danielle Beverly Isabella Theresa Diana Natalie Charlotte Marie Kayla Alexis Javier Carlos Antonio Manuel Francisco Juan Pedro Alejandro Miguel Rafael Pablo Sergio Fernando Jorge Luis Alberto \xC1lvaro Diego Adri\xE1n Rub\xE9n Iv\xE1n \xD3scar Andr\xE9s Ra\xFAl Enrique Vicente Joaqu\xEDn Ignacio Gonzalo Marcos V\xEDctor Jaime Alfonso Guillermo Tom\xE1s Emilio Gabriel Nicol\xE1s Mart\xEDn Jordi Josep Xavier Luc\xEDa Carmen Isabel Cristina Marta Elena Raquel Silvia Beatriz Paula Nuria N\xFAria Sonia Alicia Irene Montserrat Inmaculada Noelia Lorena Sof\xEDa Valeria Claudia Natalia Sandra Ver\xF3nica Esther Yolanda Vanesa Laia Klaus J\xFCrgen Wolfgang Stefan Andreas Matthias Markus Tobias Florian Lukas Jonas Maximilian Sebastian Dirk Sabine Ursula Petra Monika Katrin Anja Pierre Michel Philippe Alain Fran\xE7ois Christophe Laurent Olivier Julien Mathieu S\xE9bastien Guillaume Antoine Camille Nathalie Isabelle Sylvie Sophie C\xE9line Aur\xE9lie Chlo\xE9 Manon Giuseppe Giovanni Marco Luca Francesco Alessandro Matteo Lorenzo Stefano Paolo Roberto Davide Simone Federico Giulia Francesca Chiara Valentina Alessia Martina Elisa Jo\xE3o Pedro Tiago Beatriz In\xEAs Mariana Piotr Krzysztof Tomasz Marcin Agnieszka Katarzyna Ma\u0142gorzata Magdalena";
|
|
23568
23677
|
var WORDS = "\u0412\u0435\u0440\u0430 \u041D\u0430\u0434\u0435\u0436\u0434\u0430 \u041B\u044E\u0431\u043E\u0432\u044C \u0421\u043B\u0430\u0432\u0430 \u0420\u043E\u043C\u0430\u043D \u0420\u043E\u0437\u0430 \u041C\u0430\u0439\u044F \u041B\u0438\u043B\u0438\u044F \u0417\u043B\u0430\u0442\u0430 \u041C\u0438\u043B\u0430 \u041D\u0438\u043A\u0430 \u041B\u0435\u0432 \u0413\u043B\u043E\u0440\u0438\u044F Will Mark Rose Grace Hope Faith Bill Frank Jack June April Summer Amber Ruby Lily Daisy Victoria Virginia Georgia Florence Sydney Chelsea Jordan Austin Dallas Mercedes Dolores Rosa Pilar Marina Esperanza Gloria Amparo Consuelo Roc\xEDo Salvador Santiago Jes\xFAs \xC1ngeles Hugo Ram\xF3n Christian Felix F\xE9lix Mario Martin Victor Pierre Paz Merc\xE8 Estrella Aurora Concepci\xF3n Remedios Soledad Milagros Angel \xC1ngel Dawn Joy Holly Ivy Iris Violet Pearl";
|
|
@@ -23570,7 +23679,7 @@ var NOT_NAMES = ["\u0436\u0435\u043D\u0430", "\u0436\u0435\u043D\u044B", "\u0436
|
|
|
23570
23679
|
var FIRST_NAMES = [...new Set(`${RUSSIAN} ${EUROPEAN}`.split(" "))];
|
|
23571
23680
|
var NAME_WORDS = WORDS.split(" ");
|
|
23572
23681
|
|
|
23573
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23682
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/person-names.js
|
|
23574
23683
|
var LATIN_TO_CYRILLIC = {
|
|
23575
23684
|
shch: "\u0449",
|
|
23576
23685
|
sch: "\u0449",
|
|
@@ -23778,7 +23887,7 @@ var findUnknownNames = /* @__PURE__ */ __name((text6, stem, taken) => {
|
|
|
23778
23887
|
return found2;
|
|
23779
23888
|
}, "findUnknownNames");
|
|
23780
23889
|
|
|
23781
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23890
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/attachments.js
|
|
23782
23891
|
var NOT_FILES = /* @__PURE__ */ new Set([
|
|
23783
23892
|
"webpage",
|
|
23784
23893
|
"share",
|
|
@@ -23818,7 +23927,7 @@ var matchDownloads = /* @__PURE__ */ __name((stored3, files2) => {
|
|
|
23818
23927
|
});
|
|
23819
23928
|
}, "matchDownloads");
|
|
23820
23929
|
|
|
23821
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23930
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
|
|
23822
23931
|
var QUERY_VERSION = 1;
|
|
23823
23932
|
var QUERY_LIMITS2 = {
|
|
23824
23933
|
...QUERY_LIMITS,
|
|
@@ -23854,7 +23963,7 @@ function exhausted(budget) {
|
|
|
23854
23963
|
}
|
|
23855
23964
|
__name(exhausted, "exhausted");
|
|
23856
23965
|
|
|
23857
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
23966
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
|
|
23858
23967
|
var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
|
|
23859
23968
|
var literal2 = /* @__PURE__ */ __name((c) => ({
|
|
23860
23969
|
kind: "char",
|
|
@@ -24254,7 +24363,7 @@ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
|
|
|
24254
24363
|
return out;
|
|
24255
24364
|
}, "foldRegex");
|
|
24256
24365
|
|
|
24257
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24366
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
|
|
24258
24367
|
var PRESET_VERSION = 1;
|
|
24259
24368
|
var PRESETS = {
|
|
24260
24369
|
password: {
|
|
@@ -24308,7 +24417,7 @@ var PRESETS = {
|
|
|
24308
24417
|
}
|
|
24309
24418
|
};
|
|
24310
24419
|
|
|
24311
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24420
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
|
|
24312
24421
|
var FIELD_VERSION = 2;
|
|
24313
24422
|
var UNITS = {
|
|
24314
24423
|
"": 1,
|
|
@@ -24769,12 +24878,12 @@ var validateAst = /* @__PURE__ */ __name((input) => {
|
|
|
24769
24878
|
return validateFields(parsed3.output);
|
|
24770
24879
|
}, "validateAst");
|
|
24771
24880
|
|
|
24772
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24881
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
|
|
24773
24882
|
var hasText = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "text" || node.field === "exact" : node.clauses.some(({ node: node2 }) => hasText(node2)), "hasText");
|
|
24774
24883
|
var isStemmed = /* @__PURE__ */ __name((node) => node.field === "text" && (node.operator === "term" || node.operator === "phrase") && node.value !== "", "isStemmed");
|
|
24775
24884
|
var hasStems = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? isStemmed(node) : node.clauses.some(({ node: node2 }) => hasStems(node2)), "hasStems");
|
|
24776
24885
|
|
|
24777
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24886
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
|
|
24778
24887
|
var LIVE = "mn.kind = 'url' AND mn.status <> 'dismissed'";
|
|
24779
24888
|
var MAIL_ROWS = `SELECT mn.source_id FROM mentions mn WHERE mn.source_type = 'email' AND ${LIVE}`;
|
|
24780
24889
|
var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
|
|
@@ -24798,7 +24907,7 @@ var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
|
|
|
24798
24907
|
};
|
|
24799
24908
|
}, "linkMatch");
|
|
24800
24909
|
|
|
24801
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24910
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
|
|
24802
24911
|
var SETTING = "phoneCountries";
|
|
24803
24912
|
var savedPhoneCountries = /* @__PURE__ */ __name((database) => {
|
|
24804
24913
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING);
|
|
@@ -24829,7 +24938,7 @@ var valueMatch = /* @__PURE__ */ __name((database, typed) => {
|
|
|
24829
24938
|
return { sql: "mn.value = ?", params: [phone?.value ?? normalizedValue(typed, { phoneCountries })] };
|
|
24830
24939
|
}, "valueMatch");
|
|
24831
24940
|
|
|
24832
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24941
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
|
|
24833
24942
|
var normalizeVocabularyName = /* @__PURE__ */ __name((input) => {
|
|
24834
24943
|
if (typeof input !== "string" || input.length > 200 || /[\p{Cc}\p{Cf}]/u.test(input))
|
|
24835
24944
|
throw new CliError("validation_error", "a vocabulary name takes 1\u2013200 characters without control characters");
|
|
@@ -24857,7 +24966,7 @@ var vocabularySimilarity = /* @__PURE__ */ __name((left, right) => {
|
|
|
24857
24966
|
return 2 * intersection2 / (aa2.size + bb.size);
|
|
24858
24967
|
}, "vocabularySimilarity");
|
|
24859
24968
|
|
|
24860
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24969
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
|
|
24861
24970
|
import { createHash } from "node:crypto";
|
|
24862
24971
|
var folded2 = /* @__PURE__ */ __name((name) => {
|
|
24863
24972
|
try {
|
|
@@ -24923,7 +25032,7 @@ var guardTagCreation = /* @__PURE__ */ __name((context, name, kind4, by, options
|
|
|
24923
25032
|
});
|
|
24924
25033
|
}, "guardTagCreation");
|
|
24925
25034
|
|
|
24926
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25035
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
|
|
24927
25036
|
var invalid2 = /* @__PURE__ */ __name((message2) => {
|
|
24928
25037
|
throw new CliError("validation_error", message2);
|
|
24929
25038
|
}, "invalid");
|
|
@@ -25000,7 +25109,7 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
|
|
|
25000
25109
|
};
|
|
25001
25110
|
}, "createTagRedirectIndex");
|
|
25002
25111
|
|
|
25003
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25112
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
|
|
25004
25113
|
var tagCanonicalId = /* @__PURE__ */ __name((database, id2) => {
|
|
25005
25114
|
const row2 = database.prepare("SELECT canonical_id FROM resolved_tags WHERE id=?").get(id2);
|
|
25006
25115
|
if (!row2)
|
|
@@ -25028,7 +25137,7 @@ var tagRedirectSnapshot = /* @__PURE__ */ __name((database) => {
|
|
|
25028
25137
|
return snapshot2;
|
|
25029
25138
|
}, "tagRedirectSnapshot");
|
|
25030
25139
|
|
|
25031
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25140
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
|
|
25032
25141
|
import { createHash as createHash2 } from "node:crypto";
|
|
25033
25142
|
var TASK_KEY_PREFIXES = {
|
|
25034
25143
|
question: "Q",
|
|
@@ -25056,7 +25165,7 @@ var taskAccountOf = /* @__PURE__ */ __name((database, rowId) => {
|
|
|
25056
25165
|
return row2 && String(row2.key) === inboxKey(String(row2.name)) ? String(row2.name) : void 0;
|
|
25057
25166
|
}, "taskAccountOf");
|
|
25058
25167
|
|
|
25059
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25168
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
|
|
25060
25169
|
var storedThing = /* @__PURE__ */ __name((type, id2) => ({ type: String(type), id: Number(id2) }), "storedThing");
|
|
25061
25170
|
var REFERABLE = {
|
|
25062
25171
|
note: { tombstone: true },
|
|
@@ -25072,6 +25181,9 @@ var REFERABLE = {
|
|
|
25072
25181
|
invoice: { tombstone: true },
|
|
25073
25182
|
payment: { tombstone: true },
|
|
25074
25183
|
order: { tombstone: true },
|
|
25184
|
+
deal: { tombstone: true },
|
|
25185
|
+
lead: { tombstone: true },
|
|
25186
|
+
pipeline: { tombstone: false },
|
|
25075
25187
|
message: { tombstone: true },
|
|
25076
25188
|
email: { tombstone: true },
|
|
25077
25189
|
email_thread: { tombstone: true },
|
|
@@ -25221,11 +25333,11 @@ var taskIdOf = /* @__PURE__ */ __name((database, rowId) => {
|
|
|
25221
25333
|
return row2 ? String(row2.id ?? row2.key) : void 0;
|
|
25222
25334
|
}, "taskIdOf");
|
|
25223
25335
|
|
|
25224
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25225
|
-
var toMs = /* @__PURE__ */ __name((
|
|
25226
|
-
if (
|
|
25336
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
|
|
25337
|
+
var toMs = /* @__PURE__ */ __name((iso14) => {
|
|
25338
|
+
if (iso14 === null || iso14 === void 0)
|
|
25227
25339
|
return null;
|
|
25228
|
-
const ms = Date.parse(
|
|
25340
|
+
const ms = Date.parse(iso14);
|
|
25229
25341
|
return Number.isNaN(ms) ? null : ms;
|
|
25230
25342
|
}, "toMs");
|
|
25231
25343
|
var toIso = /* @__PURE__ */ __name((ms) => typeof ms === "number" ? new Date(ms).toISOString() : null, "toIso");
|
|
@@ -25235,7 +25347,7 @@ var present = /* @__PURE__ */ __name((entries) => Object.fromEntries(Object.entr
|
|
|
25235
25347
|
var DELIVERY = { delivered: 1, read: 2 };
|
|
25236
25348
|
var deliveryOf = /* @__PURE__ */ __name((stored3) => stored3 === DELIVERY.read ? "read" : stored3 === DELIVERY.delivered ? "delivered" : void 0, "deliveryOf");
|
|
25237
25349
|
|
|
25238
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25350
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
|
|
25239
25351
|
var TAG_KINDS = ["tag", "topic"];
|
|
25240
25352
|
var TAGGABLE = { chat: "chat", contact: "identity", message: "message", task: "task" };
|
|
25241
25353
|
var TAG_TYPE = {
|
|
@@ -25438,7 +25550,7 @@ var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
|
|
|
25438
25550
|
return result;
|
|
25439
25551
|
}, "tagsOf");
|
|
25440
25552
|
|
|
25441
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25553
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
|
|
25442
25554
|
var speech = /* @__PURE__ */ __name((alias2) => `(coalesce(${alias2}.extractor,'') LIKE 'speech:%' OR ${alias2}.kind IN ('voice','video_note') OR coalesce(${alias2}.mime,'')='audio/ogg')`, "speech");
|
|
25443
25555
|
var SPEECH = speech("att");
|
|
25444
25556
|
var mentionText = /* @__PURE__ */ __name((alias2) => `CASE WHEN coalesce(json_extract(${alias2}.contact, '$.phone'), '') <> '' THEN 'phone: ' || json_extract(${alias2}.contact, '$.phone') ELSE ${alias2}.text END`, "mentionText");
|
|
@@ -25802,7 +25914,7 @@ var FIELD_COMPILERS = {
|
|
|
25802
25914
|
subject
|
|
25803
25915
|
};
|
|
25804
25916
|
|
|
25805
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25917
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
|
|
25806
25918
|
var placeOf = /* @__PURE__ */ __name((database) => {
|
|
25807
25919
|
const exact = database.prepare("SELECT id FROM places WHERE folded = ?");
|
|
25808
25920
|
const onStreet = database.prepare("SELECT id FROM places WHERE substr(folded, 1, ?) = ? LIMIT 2");
|
|
@@ -25818,7 +25930,7 @@ var placeOf = /* @__PURE__ */ __name((database) => {
|
|
|
25818
25930
|
};
|
|
25819
25931
|
}, "placeOf");
|
|
25820
25932
|
|
|
25821
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25933
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
|
|
25822
25934
|
var DRAIN_ON_WRITE = 500;
|
|
25823
25935
|
var METHOD = "rules";
|
|
25824
25936
|
var telegramLink = /* @__PURE__ */ __name((database) => {
|
|
@@ -25981,7 +26093,7 @@ var drainMentions = /* @__PURE__ */ __name((database, now2, limit = DRAIN_ON_WRI
|
|
|
25981
26093
|
return queued.length;
|
|
25982
26094
|
}, "drainMentions");
|
|
25983
26095
|
|
|
25984
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26096
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
|
|
25985
26097
|
var indexRow = /* @__PURE__ */ __name((database, name) => {
|
|
25986
26098
|
const exists2 = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'search_index_state'").get();
|
|
25987
26099
|
if (!exists2)
|
|
@@ -25989,7 +26101,7 @@ var indexRow = /* @__PURE__ */ __name((database, name) => {
|
|
|
25989
26101
|
return database.prepare("SELECT * FROM search_index_state WHERE name = ?").get(name);
|
|
25990
26102
|
}, "indexRow");
|
|
25991
26103
|
|
|
25992
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26104
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
|
|
25993
26105
|
var INDEX = "message_stems";
|
|
25994
26106
|
var SETTING2 = "searchStemmers";
|
|
25995
26107
|
var DRAIN_ON_WRITE2 = 500;
|
|
@@ -26111,7 +26223,7 @@ var stemmerCache = /* @__PURE__ */ __name(() => {
|
|
|
26111
26223
|
};
|
|
26112
26224
|
}, "stemmerCache");
|
|
26113
26225
|
|
|
26114
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26226
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
|
|
26115
26227
|
var SQLITE_BUSY = 5;
|
|
26116
26228
|
var pause = new Int32Array(new SharedArrayBuffer(4));
|
|
26117
26229
|
var isBusy = /* @__PURE__ */ __name((error) => {
|
|
@@ -26206,7 +26318,7 @@ var read = /* @__PURE__ */ __name((database, body2) => {
|
|
|
26206
26318
|
}
|
|
26207
26319
|
}, "read");
|
|
26208
26320
|
|
|
26209
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26321
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
|
|
26210
26322
|
var source = /* @__PURE__ */ __name((model, dims) => `SELECT k.id, k.chunkable_type,
|
|
26211
26323
|
coalesce(CASE k.chunkable_type
|
|
26212
26324
|
WHEN 'image' THEN (SELECT ch.account_id FROM attachments a JOIN messages m ON m.id = a.attachable_id
|
|
@@ -26348,7 +26460,7 @@ var dropUnusedVectors = /* @__PURE__ */ __name((database, hashes) => {
|
|
|
26348
26460
|
}, "dropUnusedVectors");
|
|
26349
26461
|
var dropAllUnusedVectors = /* @__PURE__ */ __name((database) => database.prepare("DELETE FROM embeddings WHERE NOT EXISTS (SELECT 1 FROM chunks k WHERE k.content_hash = embeddings.content_hash) RETURNING 1").all().length, "dropAllUnusedVectors");
|
|
26350
26462
|
|
|
26351
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26463
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
|
|
26352
26464
|
var accountPk = /* @__PURE__ */ __name(({ orm, now: now2 }, { provider, account, scope: scope3 }, name = null) => Number(orm.insert(accounts).values({ provider, externalId: account, name, scope: scope3 ?? "personal", createdAt: now2(), updatedAt: now2() }).onConflictDoUpdate({
|
|
26353
26465
|
target: [accounts.provider, accounts.externalId],
|
|
26354
26466
|
set: {
|
|
@@ -26457,7 +26569,7 @@ var dropOrphanPeople = /* @__PURE__ */ __name((database, unseenBefore) => {
|
|
|
26457
26569
|
AND id NOT IN (SELECT id FROM (${referencesTo(database, "persons", /* @__PURE__ */ new Set(["identity_links"]))}) WHERE id IS NOT NULL)`).run(JSON.stringify(persons2));
|
|
26458
26570
|
}, "dropOrphanPeople");
|
|
26459
26571
|
|
|
26460
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26572
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
|
|
26461
26573
|
var FOLDED = [
|
|
26462
26574
|
{ table: "tasks", column: "title" },
|
|
26463
26575
|
{ table: "tasks", column: "close_reason" },
|
|
@@ -26494,7 +26606,7 @@ var fillFolded = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
|
|
|
26494
26606
|
return filled2;
|
|
26495
26607
|
}, "fillFolded");
|
|
26496
26608
|
|
|
26497
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26609
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/history-skips.js
|
|
26498
26610
|
var HISTORY_KEY = "$history";
|
|
26499
26611
|
var objectOf = /* @__PURE__ */ __name((text6) => {
|
|
26500
26612
|
if (typeof text6 !== "string")
|
|
@@ -26570,7 +26682,7 @@ var withoutHistory = /* @__PURE__ */ __name((metadata3) => {
|
|
|
26570
26682
|
return rest;
|
|
26571
26683
|
}, "withoutHistory");
|
|
26572
26684
|
|
|
26573
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26685
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
|
|
26574
26686
|
import { createHash as createHash3 } from "node:crypto";
|
|
26575
26687
|
var CHUNK_CHARS = 1200;
|
|
26576
26688
|
var CHUNK_OVERLAP = 150;
|
|
@@ -26675,7 +26787,7 @@ var cutChunks = /* @__PURE__ */ __name((members2, limit = CHUNK_CHARS, check3, c
|
|
|
26675
26787
|
return chunks2;
|
|
26676
26788
|
}, "cutChunks");
|
|
26677
26789
|
|
|
26678
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26790
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/task-signature.js
|
|
26679
26791
|
var DAY = 864e5;
|
|
26680
26792
|
var CURRENCY = [
|
|
26681
26793
|
[/^(₽|руб.*|р\.?|rub)$/u, "RUB"],
|
|
@@ -26801,7 +26913,7 @@ var dueDayOf = /* @__PURE__ */ __name((text6, createdMs) => {
|
|
|
26801
26913
|
return best?.day ?? null;
|
|
26802
26914
|
}, "dueDayOf");
|
|
26803
26915
|
|
|
26804
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26916
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
|
|
26805
26917
|
var DAY2 = 864e5;
|
|
26806
26918
|
var STOP_WORDS = new Set([
|
|
26807
26919
|
// Russian and English as the test set ran them, already folded (пожалуйста → пожалуиста).
|
|
@@ -26956,7 +27068,7 @@ var rankCandidates = /* @__PURE__ */ __name((views, candidates) => candidates.ma
|
|
|
26956
27068
|
...compareViews(subjectViews ?? views, candidate, replyChain === void 0 ? {} : { replyChain })
|
|
26957
27069
|
})).sort((a, b) => b.score - a.score), "rankCandidates");
|
|
26958
27070
|
|
|
26959
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27071
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
|
|
26960
27072
|
var currentChunks = /* @__PURE__ */ __name((chatKey) => sql`SELECT k.content_hash, k.chunkable_id AS conversation_id, r.first_message_id,
|
|
26961
27073
|
r.last_message_id, r.text_start, r.text_end FROM chunks k JOIN chunk_messages r ON r.chunk_id = k.id
|
|
26962
27074
|
JOIN conversations c ON k.chunkable_type = 'conversation' AND c.id = k.chunkable_id
|
|
@@ -27227,7 +27339,7 @@ var readiness = /* @__PURE__ */ __name(({ orm }, chatKey, model) => {
|
|
|
27227
27339
|
};
|
|
27228
27340
|
}, "readiness");
|
|
27229
27341
|
|
|
27230
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27342
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
|
|
27231
27343
|
var DOCUMENT_PICTURE = "document_picture";
|
|
27232
27344
|
var SCAN_PAGE2 = 5e3;
|
|
27233
27345
|
var idOf = /* @__PURE__ */ __name((ref3) => {
|
|
@@ -27290,7 +27402,7 @@ var documentPicturesOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
|
|
|
27290
27402
|
}, "nearestPictures")
|
|
27291
27403
|
}), "documentPicturesOver");
|
|
27292
27404
|
|
|
27293
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27405
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
|
|
27294
27406
|
var glob = /* @__PURE__ */ __name((value) => [...fold(value).matchAll(/\\(.)|([*?])|(.)/gsu)].map(([, escaped2, wildcard, plain2]) => {
|
|
27295
27407
|
const literal4 = escaped2 ?? plain2 ?? "";
|
|
27296
27408
|
return wildcard ?? (/[*?[]/u.test(literal4) ? `[${literal4}]` : literal4);
|
|
@@ -27355,7 +27467,7 @@ var compile = /* @__PURE__ */ __name((node, columns, options) => {
|
|
|
27355
27467
|
var queryFilter = /* @__PURE__ */ __name((ast, columns, options = {}) => compile(ast.root, columns, options), "queryFilter");
|
|
27356
27468
|
var bound2 = /* @__PURE__ */ __name(({ sql: text6, params }) => sql.join(text6.split("?").map((part, at) => at < params.length ? sql`${sql.raw(part)}${params[at]}` : sql.raw(part)), sql``), "bound");
|
|
27357
27469
|
|
|
27358
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27470
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
|
|
27359
27471
|
var toJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.stringify(value), "toJson");
|
|
27360
27472
|
var fromJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.parse(String(value)), "fromJson");
|
|
27361
27473
|
var int = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "int");
|
|
@@ -27445,7 +27557,7 @@ var linkMeeting = /* @__PURE__ */ __name((database, id2, eventId, now2, mode = "
|
|
|
27445
27557
|
});
|
|
27446
27558
|
}, "linkMeeting");
|
|
27447
27559
|
|
|
27448
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27560
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
|
|
27449
27561
|
var EVENT_TEXT = "trim(coalesce(e.description, '') || ' ' || coalesce(e.location, '') || ' ' || coalesce((SELECT group_concat(p.name, ' ') FROM calendar_entries ce JOIN calendar_entry_participants p ON p.entry_id = ce.id WHERE ce.event_id = e.id AND ce.deleted_at IS NULL AND p.resource = 0 AND p.name IS NOT NULL), ''))";
|
|
27450
27562
|
var UNSEARCHED_EVENT_TYPES = [
|
|
27451
27563
|
"working-location",
|
|
@@ -27675,7 +27787,7 @@ var resetNoteIndex = /* @__PURE__ */ __name((database) => {
|
|
|
27675
27787
|
return true;
|
|
27676
27788
|
}, "resetNoteIndex");
|
|
27677
27789
|
|
|
27678
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27790
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
|
|
27679
27791
|
var keyOf3 = /* @__PURE__ */ __name((name) => fold(name).trim().replace(/^@/, ""), "keyOf");
|
|
27680
27792
|
var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
|
|
27681
27793
|
for (const key2 of new Set(names.filter((name) => !!name?.trim()).map(keyOf3))) {
|
|
@@ -27694,7 +27806,7 @@ var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
|
|
|
27694
27806
|
}
|
|
27695
27807
|
}, "resolvePersonLinks");
|
|
27696
27808
|
|
|
27697
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27809
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
|
|
27698
27810
|
var flag2 = /* @__PURE__ */ __name((value) => value === void 0 || value === null ? null : Number(value), "flag");
|
|
27699
27811
|
var prepare = /* @__PURE__ */ __name((orm) => ({
|
|
27700
27812
|
find: orm.select({
|
|
@@ -27919,7 +28031,7 @@ var meetingIdentityPk = /* @__PURE__ */ __name((context, accountId, identity) =>
|
|
|
27919
28031
|
}, "meetingIdentityPk");
|
|
27920
28032
|
var phoneOf = /* @__PURE__ */ __name(({ orm }, provider, nativeId) => orm.select({ phone: identities.phone }).from(identities).where(and(eq(identities.provider, provider), eq(identities.externalId, nativeId))).get()?.phone ?? null, "phoneOf");
|
|
27921
28033
|
|
|
27922
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28034
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
|
|
27923
28035
|
var chatOf = /* @__PURE__ */ __name(({ orm }, accountKey, chatKey) => orm.select({ id: chats.externalId }).from(chats).where(and(eq(chats.id, chatKey), eq(chats.accountId, accountKey))).get()?.id, "chatOf");
|
|
27924
28036
|
var findChatPk = /* @__PURE__ */ __name(({ orm }, accountKey, chatId) => orm.select({ pk: chats.id }).from(chats).where(and(eq(chats.accountId, accountKey), eq(chats.externalId, chatId))).get()?.pk, "findChatPk");
|
|
27925
28037
|
var chatPkFor = /* @__PURE__ */ __name((context, accountKey, chatId) => findChatPk(context, accountKey, chatId) ?? Number(context.orm.insert(chats).values({
|
|
@@ -28199,7 +28311,7 @@ var replaceAutoTags = /* @__PURE__ */ __name((context, key2, chatId, algorithm,
|
|
|
28199
28311
|
}
|
|
28200
28312
|
}, "replaceAutoTags");
|
|
28201
28313
|
|
|
28202
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28314
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/counters.js
|
|
28203
28315
|
var COUNTER_FIELDS = ["views", "reactions", "comments"];
|
|
28204
28316
|
var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
|
|
28205
28317
|
var counterObservationTime = /* @__PURE__ */ __name((observation, now2) => {
|
|
@@ -28218,7 +28330,7 @@ var counterFreshness = /* @__PURE__ */ __name((states) => {
|
|
|
28218
28330
|
return states.some((one2) => one2.freshness === "stale") ? "stale" : "fresh";
|
|
28219
28331
|
}, "counterFreshness");
|
|
28220
28332
|
|
|
28221
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28333
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/context/evidence.js
|
|
28222
28334
|
import { createHash as createHash4 } from "node:crypto";
|
|
28223
28335
|
var CONTEXT_MAX_READ_BYTES = 262144;
|
|
28224
28336
|
var CONTEXT_SOURCE_KINDS = ["message", "mail", "document", "meeting"];
|
|
@@ -28316,7 +28428,7 @@ var contextEvidenceRequest = /* @__PURE__ */ __name((input) => {
|
|
|
28316
28428
|
return { source: source2, query, chat: chat2, senders, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal: input.signal };
|
|
28317
28429
|
}, "contextEvidenceRequest");
|
|
28318
28430
|
|
|
28319
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28431
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/email-activity.js
|
|
28320
28432
|
var MAIL_AGENDA_COLUMNS = { chat_kind: { type: "enum", sql: "'dialog'" } };
|
|
28321
28433
|
var ACTIVITY = `
|
|
28322
28434
|
SELECT t.external_id AS thread, t.subject, t.last_email_at, t.emails_count,
|
|
@@ -28433,7 +28545,7 @@ var mailActivity = /* @__PURE__ */ __name((database) => ({
|
|
|
28433
28545
|
threadActivity: /* @__PURE__ */ __name(async (accountId, since, where) => threadActivity(database, accountId, since, where), "threadActivity")
|
|
28434
28546
|
}), "mailActivity");
|
|
28435
28547
|
|
|
28436
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28548
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
|
|
28437
28549
|
var GREETING = new RegExp("^(hi|hello|hey|dear|greetings|good (morning|afternoon|evening)|\u043F\u0440\u0438\u0432\u0435\u0442|\u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439(\u0442\u0435)?|\u0434\u043E\u0431\u0440(\u044B\u0439|\u043E\u0435|\u043E\u0433\u043E) (\u0434\u0435\u043D\u044C|\u0432\u0435\u0447\u0435\u0440|\u0443\u0442\u0440\u043E|\u0443\u0442\u0440\u0430|\u0434\u043D\u044F)|hola|buen(os|as) (d\xEDas|dias|tardes|noches)|estimad[oa]s?|querid[oa]s?)(?![\\p{L}\\p{N}])([\\s,]+\\p{L}[\\p{L}.'\u2019-]*){0,3}\\s*[,!.:]?$", "iu");
|
|
28438
28550
|
var SIGN_OFF = /^(best|best regards|best wishes|kind regards|warm regards|regards|thanks|thanks again|thanks a lot|thank you|many thanks|cheers|sincerely|yours|yours truly|yours sincerely|br|с уважением|спасибо|заранее спасибо|всего доброго|всего хорошего|un saludo|saludos|saludos cordiales|atentamente|gracias|muchas gracias)[\s,.!]*$/iu;
|
|
28439
28551
|
var ATTRIBUTION = /(wrote|написал[аи]?|escribió|a écrit|schrieb)\s*:\s*$/iu;
|
|
@@ -28574,7 +28686,7 @@ var mailOwnText = /* @__PURE__ */ __name((body2) => {
|
|
|
28574
28686
|
return text6 || body2.trim();
|
|
28575
28687
|
}, "mailOwnText");
|
|
28576
28688
|
|
|
28577
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28689
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
|
|
28578
28690
|
var titleOf = /* @__PURE__ */ __name((subject2) => subject2?.replace(/^\s*((re|fwd?|aw|wg)\s*:\s*)+/i, "").trim() || null, "titleOf");
|
|
28579
28691
|
var MAIL_PIECES = `(SELECT k.id, k.content_hash, k.chunkable_type AS type, k.chunkable_id AS owner, k.position,
|
|
28580
28692
|
k.start_offset, k.end_offset, k.account_id, k.occurred_at, a.attachable_id AS email_id,
|
|
@@ -28684,7 +28796,7 @@ var drainEmailIndex = /* @__PURE__ */ __name((database, stemmerFor2) => {
|
|
|
28684
28796
|
return emails3 + threads;
|
|
28685
28797
|
}, "drainEmailIndex");
|
|
28686
28798
|
|
|
28687
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28799
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
|
|
28688
28800
|
var locate = /* @__PURE__ */ __name((database, accountId, emailId, where) => database.prepare(`INSERT OR REPLACE INTO email_locations (mailbox_id, uidvalidity, uid, email_id)
|
|
28689
28801
|
SELECT id, ?, ?, ? FROM mailboxes WHERE account_id = ? AND external_id = ?`).run(where.uidvalidity, where.uid, emailId, accountId, where.folder), "locate");
|
|
28690
28802
|
var folderEmails = /* @__PURE__ */ __name((database, accountId, folder, uidvalidity) => database.prepare(`SELECT l.uid, e.external_id, coalesce(e.received_at, e.sent_at) AS at, e.read, e.flagged,
|
|
@@ -28782,7 +28894,7 @@ var forgetLocations = /* @__PURE__ */ __name((database, accountId, folder, uidva
|
|
|
28782
28894
|
var backfillSentAt = /* @__PURE__ */ __name((database, accountId, limit) => Number(database.prepare(`UPDATE emails SET sent_at = received_at WHERE id IN (
|
|
28783
28895
|
SELECT id FROM emails WHERE account_id = ? AND sent_at IS NULL AND received_at IS NOT NULL LIMIT ?)`).run(accountId, limit).changes), "backfillSentAt");
|
|
28784
28896
|
|
|
28785
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28897
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
|
|
28786
28898
|
var recountEmailThread = /* @__PURE__ */ __name((database, threadId, now2) => database.prepare(`UPDATE email_threads SET
|
|
28787
28899
|
emails_count = (SELECT count(*) FROM emails WHERE email_thread_id = ? AND deleted_at IS NULL),
|
|
28788
28900
|
last_email_at = (SELECT max(coalesce(sent_at, received_at)) FROM emails
|
|
@@ -28832,7 +28944,7 @@ var markEmailsRestored = /* @__PURE__ */ __name((database, accountId, externalId
|
|
|
28832
28944
|
return threads.length;
|
|
28833
28945
|
}, "markEmailsRestored");
|
|
28834
28946
|
|
|
28835
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
28947
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
|
|
28836
28948
|
var sorted = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(sorted) : value !== null && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key2) => [key2, sorted(value[key2])])) : value, "sorted");
|
|
28837
28949
|
var conditionsKey = /* @__PURE__ */ __name((conditions) => JSON.stringify(sorted(conditions)), "conditionsKey");
|
|
28838
28950
|
var ruleOf = /* @__PURE__ */ __name((row2) => ({
|
|
@@ -28899,7 +29011,7 @@ var mailRulesOver = /* @__PURE__ */ __name((database) => ({
|
|
|
28899
29011
|
}
|
|
28900
29012
|
}), "mailRulesOver");
|
|
28901
29013
|
|
|
28902
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29014
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
|
|
28903
29015
|
var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates, reason, now2) => {
|
|
28904
29016
|
database.prepare(`INSERT INTO link_reviews (linkable_type, linkable_id, entity_type, candidates, reason, status, created_at, updated_at)
|
|
28905
29017
|
VALUES (?, ?, ?, ?, ?, 'open', ?, ?)
|
|
@@ -28907,7 +29019,7 @@ var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates,
|
|
|
28907
29019
|
reason = excluded.reason, updated_at = excluded.updated_at WHERE link_reviews.status = 'open'`).run(linkable.type, linkable.id, entity, JSON.stringify([...candidates].sort((a, b) => a - b)), reason, now2, now2);
|
|
28908
29020
|
}, "reviewLink");
|
|
28909
29021
|
|
|
28910
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29022
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
|
|
28911
29023
|
function checkMeetingCancelled(signal) {
|
|
28912
29024
|
if (!signal?.aborted)
|
|
28913
29025
|
return;
|
|
@@ -28918,7 +29030,7 @@ function checkMeetingCancelled(signal) {
|
|
|
28918
29030
|
}
|
|
28919
29031
|
__name(checkMeetingCancelled, "checkMeetingCancelled");
|
|
28920
29032
|
|
|
28921
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29033
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
|
|
28922
29034
|
var meetingOf = /* @__PURE__ */ __name((row2) => ({
|
|
28923
29035
|
id: Number(row2.id),
|
|
28924
29036
|
accountId: Number(row2.account_id),
|
|
@@ -28968,7 +29080,7 @@ var transcriptRowOf = /* @__PURE__ */ __name((row2) => ({
|
|
|
28968
29080
|
createdAt: Number(row2.created_at)
|
|
28969
29081
|
}), "transcriptRowOf");
|
|
28970
29082
|
|
|
28971
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29083
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
|
|
28972
29084
|
var MEETING_TEXT = ["external_id", "title", "description", "location", "join_url", "timezone", "metadata"];
|
|
28973
29085
|
var TRANSCRIPT_TEXT = ["source", "format", "language", "content_hash", "metadata"];
|
|
28974
29086
|
var ROW_TEXT = ["speaker_name", "text", "normalized_text", "metadata"];
|
|
@@ -29135,7 +29247,7 @@ var meetingReadsOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
29135
29247
|
}
|
|
29136
29248
|
}), "meetingReadsOver");
|
|
29137
29249
|
|
|
29138
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29250
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
|
|
29139
29251
|
var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
|
|
29140
29252
|
const clauses = ["m.account_id=?", "m.deleted_at IS NULL"];
|
|
29141
29253
|
const params = [input.accountId];
|
|
@@ -29178,7 +29290,7 @@ var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
|
|
|
29178
29290
|
return { clauses, params };
|
|
29179
29291
|
}, "meetingSelectionSql");
|
|
29180
29292
|
|
|
29181
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29293
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
|
|
29182
29294
|
var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
29183
29295
|
async meetingChatLines(input) {
|
|
29184
29296
|
checkMeetingCancelled(input.signal);
|
|
@@ -29206,7 +29318,7 @@ var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
29206
29318
|
}
|
|
29207
29319
|
}), "meetingChatLinesOver");
|
|
29208
29320
|
|
|
29209
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29321
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
|
|
29210
29322
|
var MESSAGE_FIELDS = {
|
|
29211
29323
|
pk: messages.id,
|
|
29212
29324
|
nativeId: messages.externalId,
|
|
@@ -29377,7 +29489,7 @@ var chatActivity = /* @__PURE__ */ __name(({ database }, accountKey, since, wher
|
|
|
29377
29489
|
storedAt: toIso(Number(database.prepare("SELECT max(created_at) AS at FROM messages WHERE account_id = ?").get(accountKey)?.at) || null)
|
|
29378
29490
|
}), "chatActivity");
|
|
29379
29491
|
|
|
29380
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29492
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
|
|
29381
29493
|
var HIT_FIELDS = {
|
|
29382
29494
|
...MESSAGE_FIELDS,
|
|
29383
29495
|
chatTitle: sql`${chats.title}`.as("chat_title"),
|
|
@@ -29476,7 +29588,7 @@ var directReplies = /* @__PURE__ */ __name((context, parents, limit) => {
|
|
|
29476
29588
|
};
|
|
29477
29589
|
}, "directReplies");
|
|
29478
29590
|
|
|
29479
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29591
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
|
|
29480
29592
|
var identityRow = /* @__PURE__ */ __name(({ orm }, { provider, id: id2 }) => orm.select({ pk: identities.id, personPk: identityLinks.personId }).from(identities).innerJoin(identityLinks, eq(identityLinks.identityId, identities.id)).where(and(eq(identities.provider, provider), eq(identities.externalId, id2))).get(), "identityRow");
|
|
29481
29593
|
var required = /* @__PURE__ */ __name((context, ref3) => {
|
|
29482
29594
|
const found2 = identityRow(context, ref3);
|
|
@@ -29607,7 +29719,7 @@ var mentioning = /* @__PURE__ */ __name((context, accountKey, { id: id2, usernam
|
|
|
29607
29719
|
}, "mentioning");
|
|
29608
29720
|
var escaped = /* @__PURE__ */ __name((text6) => text6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "escaped");
|
|
29609
29721
|
|
|
29610
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29722
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
|
|
29611
29723
|
var missing2 = /* @__PURE__ */ __name(() => {
|
|
29612
29724
|
throw new CliError("not_found", "Meeting, participant or selected target not found");
|
|
29613
29725
|
}, "missing");
|
|
@@ -29729,7 +29841,7 @@ function meetingContextLinksOver(context) {
|
|
|
29729
29841
|
}
|
|
29730
29842
|
__name(meetingContextLinksOver, "meetingContextLinksOver");
|
|
29731
29843
|
|
|
29732
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29844
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
|
|
29733
29845
|
var INDEX_CODES = { meeting_transcript_row: 1, meeting_chat_message: 2, meeting_summary: 3 };
|
|
29734
29846
|
var meetingRowid = /* @__PURE__ */ __name((type, id2) => id2 * 4 + INDEX_CODES[type], "meetingRowid");
|
|
29735
29847
|
var summaryOf = /* @__PURE__ */ __name((row2) => ({
|
|
@@ -29758,7 +29870,7 @@ var indexedText = /* @__PURE__ */ __name((database, type, id2) => {
|
|
|
29758
29870
|
return row2 ? summaryText(summaryOf(row2)) : null;
|
|
29759
29871
|
}, "indexedText");
|
|
29760
29872
|
|
|
29761
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29873
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
|
|
29762
29874
|
var summaryBytes = ["title", "overview", "sections", "next_steps", "content"].map((key2) => `coalesce(length(CAST(s.${key2} AS BLOB)),0)`).join("+");
|
|
29763
29875
|
var meetingCurrentIndexRows = `
|
|
29764
29876
|
SELECT 'meeting_transcript_row' AS indexable_type,r.id,r.id*4+1 AS rid,1 AS live,coalesce(length(CAST(r.text AS BLOB)),0) AS bytes FROM meeting_transcript_rows r JOIN meeting_transcripts t ON t.id=r.meeting_transcript_id JOIN meetings m ON m.id=t.meeting_id WHERE m.account_id=? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL
|
|
@@ -29789,7 +29901,7 @@ var invalidateMeetingStems = /* @__PURE__ */ __name((database, type, id2) => {
|
|
|
29789
29901
|
}, "invalidateMeetingStems");
|
|
29790
29902
|
var meetingStemmableText = /* @__PURE__ */ __name((text6) => text6.replace(/[\p{L}\p{N}\p{M}\p{Co}]+/gu, (token) => token.length <= 1024 ? token : ""), "meetingStemmableText");
|
|
29791
29903
|
|
|
29792
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29904
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
|
|
29793
29905
|
function meetingHitIndexOver({ database, now: now2 }) {
|
|
29794
29906
|
return {
|
|
29795
29907
|
async indexSearch(original) {
|
|
@@ -29857,10 +29969,10 @@ function meetingHitIndexOver({ database, now: now2 }) {
|
|
|
29857
29969
|
}
|
|
29858
29970
|
__name(meetingHitIndexOver, "meetingHitIndexOver");
|
|
29859
29971
|
|
|
29860
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29972
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
|
|
29861
29973
|
import { createHash as createHash5 } from "node:crypto";
|
|
29862
29974
|
|
|
29863
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29975
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/trigrams.js
|
|
29864
29976
|
var trigrams = /* @__PURE__ */ __name((term) => {
|
|
29865
29977
|
const padded = ` ${term} `;
|
|
29866
29978
|
const pieces = /* @__PURE__ */ new Set();
|
|
@@ -29869,7 +29981,7 @@ var trigrams = /* @__PURE__ */ __name((term) => {
|
|
|
29869
29981
|
return [...pieces];
|
|
29870
29982
|
}, "trigrams");
|
|
29871
29983
|
|
|
29872
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
29984
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/correct.js
|
|
29873
29985
|
var SHORTEST_CORRECTION = 3;
|
|
29874
29986
|
var maxEdits = /* @__PURE__ */ __name((word2) => word2.length <= 4 ? 1 : 2, "maxEdits");
|
|
29875
29987
|
var editDistance = /* @__PURE__ */ __name((a, b, max) => {
|
|
@@ -29916,7 +30028,7 @@ var correctWords = /* @__PURE__ */ __name(async (vocabulary, words3) => {
|
|
|
29916
30028
|
return corrections;
|
|
29917
30029
|
}, "correctWords");
|
|
29918
30030
|
|
|
29919
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30031
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/garbled.js
|
|
29920
30032
|
var SHORTEST_GARBLED = 4;
|
|
29921
30033
|
var MOST_WIDENED = 64;
|
|
29922
30034
|
var plain = /* @__PURE__ */ __name((word2) => word2.replaceAll("\u044D", "\u0435"), "plain");
|
|
@@ -30008,7 +30120,7 @@ var widenWords = /* @__PURE__ */ __name((probes, vocabulary, stem, known2) => {
|
|
|
30008
30120
|
return found2.map((words3) => words3.sort((a, b) => a.distance - b.distance || b.docs - a.docs || a.term.localeCompare(b.term)).slice(0, MOST_WIDENED).map((word2) => word2.term));
|
|
30009
30121
|
}, "widenWords");
|
|
30010
30122
|
|
|
30011
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30123
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
|
|
30012
30124
|
import { readFileSync } from "node:fs";
|
|
30013
30125
|
var loaded;
|
|
30014
30126
|
var dictionary = /* @__PURE__ */ __name(() => {
|
|
@@ -30067,7 +30179,7 @@ var knownRussianWord = /* @__PURE__ */ __name((word2) => {
|
|
|
30067
30179
|
return false;
|
|
30068
30180
|
}, "knownRussianWord");
|
|
30069
30181
|
|
|
30070
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30182
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
|
|
30071
30183
|
var WORD3 = /[\p{L}\p{N}\p{M}]+/gu;
|
|
30072
30184
|
var MOST_WORDS = 128;
|
|
30073
30185
|
var quote = /* @__PURE__ */ __name((word2) => `"${word2.replaceAll('"', '""')}"`, "quote");
|
|
@@ -30294,7 +30406,7 @@ var matchMeetingText = /* @__PURE__ */ __name((tree, text6, stemmer) => {
|
|
|
30294
30406
|
return check3(tree);
|
|
30295
30407
|
}, "matchMeetingText");
|
|
30296
30408
|
|
|
30297
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30409
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
|
|
30298
30410
|
var fail3 = /* @__PURE__ */ __name((message2) => {
|
|
30299
30411
|
throw new CliError("validation_error", message2);
|
|
30300
30412
|
}, "fail");
|
|
@@ -30476,7 +30588,7 @@ function meetingHitSearchOver({ database }) {
|
|
|
30476
30588
|
}
|
|
30477
30589
|
__name(meetingHitSearchOver, "meetingHitSearchOver");
|
|
30478
30590
|
|
|
30479
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30591
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-languages.js
|
|
30480
30592
|
var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30481
30593
|
async fillTranscriptLanguages({ accountId, apply, now: now2 }) {
|
|
30482
30594
|
positiveReadInteger(accountId, "accountId");
|
|
@@ -30508,7 +30620,7 @@ var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30508
30620
|
}
|
|
30509
30621
|
}), "meetingLanguagesOver");
|
|
30510
30622
|
|
|
30511
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30623
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
|
|
30512
30624
|
import { createHash as createHash6 } from "node:crypto";
|
|
30513
30625
|
var cursorOf2 = /* @__PURE__ */ __name((value, key2) => {
|
|
30514
30626
|
if (value === void 0)
|
|
@@ -30598,7 +30710,7 @@ var meetingParticipantSearchOver = /* @__PURE__ */ __name((context) => ({
|
|
|
30598
30710
|
}
|
|
30599
30711
|
}), "meetingParticipantSearchOver");
|
|
30600
30712
|
|
|
30601
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30713
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
|
|
30602
30714
|
var preparationQueries = {
|
|
30603
30715
|
participants: {
|
|
30604
30716
|
fields: "p.id, p.identity_id, p.display_name, l.person_id",
|
|
@@ -30648,7 +30760,7 @@ var preparationQueries = {
|
|
|
30648
30760
|
}
|
|
30649
30761
|
};
|
|
30650
30762
|
|
|
30651
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30763
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
|
|
30652
30764
|
var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30653
30765
|
async preparationContext(original) {
|
|
30654
30766
|
const input = validateMeetingPreparationContext(original);
|
|
@@ -30689,7 +30801,7 @@ var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30689
30801
|
}
|
|
30690
30802
|
}), "meetingPreparationContextOver");
|
|
30691
30803
|
|
|
30692
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30804
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
|
|
30693
30805
|
var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
|
|
30694
30806
|
SELECT m.id FROM meetings m JOIN meeting_series s ON s.id=m.meeting_series_id
|
|
30695
30807
|
WHERE m.id IN (${Array.from({ length: anchors }, () => "?").join(",")}) AND m.account_id=? AND s.account_id=?
|
|
@@ -30703,7 +30815,7 @@ var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
|
|
|
30703
30815
|
JOIN main.projects p ON p.id=l.to_id WHERE p.account_id IS NULL AND p.deleted_at IS NULL
|
|
30704
30816
|
)`, "preparationSubjects");
|
|
30705
30817
|
|
|
30706
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30818
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
|
|
30707
30819
|
var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30708
30820
|
async preparationKnowledge(original) {
|
|
30709
30821
|
const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
|
|
@@ -30748,7 +30860,7 @@ var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => (
|
|
|
30748
30860
|
}
|
|
30749
30861
|
}), "meetingPreparationKnowledgeOver");
|
|
30750
30862
|
|
|
30751
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30863
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
|
|
30752
30864
|
var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30753
30865
|
async preparationNotes(original) {
|
|
30754
30866
|
const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
|
|
@@ -30801,7 +30913,7 @@ var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30801
30913
|
}
|
|
30802
30914
|
}), "meetingPreparationNotesOver");
|
|
30803
30915
|
|
|
30804
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30916
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
|
|
30805
30917
|
var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30806
30918
|
async relatedHistory(original) {
|
|
30807
30919
|
const input = validateMeetingRelatedHistory(original);
|
|
@@ -30872,7 +30984,7 @@ var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30872
30984
|
}
|
|
30873
30985
|
}), "meetingRelatedHistoryOver");
|
|
30874
30986
|
|
|
30875
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
30987
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
|
|
30876
30988
|
var number2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "number");
|
|
30877
30989
|
var text2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : String(value), "text");
|
|
30878
30990
|
var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
@@ -30953,7 +31065,7 @@ var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30953
31065
|
}
|
|
30954
31066
|
}), "meetingReviewOver");
|
|
30955
31067
|
|
|
30956
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
31068
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
|
|
30957
31069
|
var bytes2 = "length(CAST(external_id AS BLOB)) + coalesce(length(CAST(title AS BLOB)), 0)";
|
|
30958
31070
|
var ensureBytes2 = /* @__PURE__ */ __name((size2, budget) => {
|
|
30959
31071
|
if (!Number.isSafeInteger(size2) || size2 < 0 || size2 > budget)
|
|
@@ -31007,7 +31119,7 @@ var meetingSeriesHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
31007
31119
|
}
|
|
31008
31120
|
}), "meetingSeriesHistoryOver");
|
|
31009
31121
|
|
|
31010
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
31122
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
|
|
31011
31123
|
var MOST_ROWS = 5e5;
|
|
31012
31124
|
var meetingCountsSql = /* @__PURE__ */ __name((where) => `SELECT m.started_at, coalesce(m.duration_ms, m.ended_at - m.started_at) AS duration_ms,
|
|
31013
31125
|
EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = m.id AND t.deleted_at IS NULL
|
|
@@ -31076,7 +31188,7 @@ var meetingStatsOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
31076
31188
|
}
|
|
31077
31189
|
}), "meetingStatsOver");
|
|
31078
31190
|
|
|
31079
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
31191
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
|
|
31080
31192
|
var CURSOR_KEY = "meetings";
|
|
31081
31193
|
var seriesOf2 = /* @__PURE__ */ __name((row2) => ({
|
|
31082
31194
|
id: Number(row2.id),
|
|
@@ -31645,7 +31757,7 @@ var meetingStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
31645
31757
|
};
|
|
31646
31758
|
}, "meetingStoreOver");
|
|
31647
31759
|
|
|
31648
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
31760
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
|
|
31649
31761
|
var syncStateOf = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
|
|
31650
31762
|
const row2 = orm.select({ value: syncCursors.value, at: syncCursors.updatedAt }).from(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).get();
|
|
31651
31763
|
return row2 ? { value: row2.value, at: toIso(row2.at) } : void 0;
|
|
@@ -31671,7 +31783,7 @@ var release = /* @__PURE__ */ __name(({ orm }, chatKey, anchor, holder) => {
|
|
|
31671
31783
|
orm.delete(fetchLeases).where(and(eq(fetchLeases.chatId, chatKey), eq(fetchLeases.anchor, anchor), eq(fetchLeases.holder, holder))).run();
|
|
31672
31784
|
}, "release");
|
|
31673
31785
|
|
|
31674
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
31786
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/thread-columns.js
|
|
31675
31787
|
var THREAD_COLUMNS = {
|
|
31676
31788
|
subject: {
|
|
31677
31789
|
where: /* @__PURE__ */ __name(({ value }) => ({
|
|
@@ -31688,7 +31800,7 @@ var threadRows = /* @__PURE__ */ __name((database, filter) => {
|
|
|
31688
31800
|
AND (${filter.where?.sql ?? "1"}) ORDER BY coalesce(last_email_at, 0) DESC, id DESC LIMIT ? OFFSET ?`).all(filter.accountId ?? null, filter.accountId ?? null, filter.includeDeleted ? 1 : 0, ...filter.where?.params ?? [], limit, offset);
|
|
31689
31801
|
}, "threadRows");
|
|
31690
31802
|
|
|
31691
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
31803
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
|
|
31692
31804
|
var threadConversation = /* @__PURE__ */ __name((place, builtAt) => ({
|
|
31693
31805
|
id: `email:${place.emailId}`,
|
|
31694
31806
|
chatId: place.threadExternalId,
|
|
@@ -32244,7 +32356,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm, now: now2 }, stemme
|
|
|
32244
32356
|
}
|
|
32245
32357
|
}), "mailStoreOver");
|
|
32246
32358
|
|
|
32247
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
32359
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/search/dictionary.js
|
|
32248
32360
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
32249
32361
|
var DICTIONARIES = Object.fromEntries(LANGUAGES.map(({ name, dictionary: dictionary3 }) => [name, dictionary3]));
|
|
32250
32362
|
var folded4 = /* @__PURE__ */ __name((word2) => /^[а-яё'-]*$/.test(word2) ? word2.replaceAll("\u0451", "\u0435").replaceAll("\u0439", "\u0438") : fold(word2), "folded");
|
|
@@ -32334,7 +32446,7 @@ var knownWord = /* @__PURE__ */ __name((languages) => {
|
|
|
32334
32446
|
}, "knownWord");
|
|
32335
32447
|
var dictionaryLanguages = /* @__PURE__ */ __name((stemmers) => [stemmers.cyrillic, ...stemmers.latin.split(",")].filter((name) => Object.hasOwn(DICTIONARIES, name)), "dictionaryLanguages");
|
|
32336
32448
|
|
|
32337
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
32449
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
|
|
32338
32450
|
var predicates = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? [node] : node.clauses.flatMap(({ node: node2 }) => predicates(node2)), "predicates");
|
|
32339
32451
|
var readsTranscripts = /* @__PURE__ */ __name((node) => (node.operator === "term" || node.operator === "phrase") && /[\p{L}\p{N}]/u.test(normalize(node.value)) && (node.field === "transcript" || node.implicit === true && (node.field === "text" || node.field === "exact")), "readsTranscripts");
|
|
32340
32452
|
var LATIN_NUMBERS = new Set(`zero one two three four five six seven eight nine ten eleven twelve twenty thirty forty fifty sixty seventy
|
|
@@ -32420,7 +32532,7 @@ var spokenTranscripts = /* @__PURE__ */ __name((database, item, speaking, keys)
|
|
|
32420
32532
|
return found2;
|
|
32421
32533
|
}, "spokenTranscripts");
|
|
32422
32534
|
|
|
32423
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
32535
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
|
|
32424
32536
|
var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, found2, pks) => {
|
|
32425
32537
|
const placeLeaves = leaves.filter(({ node }) => (node.operator === "term" || node.operator === "phrase") && (node.implicit || node.field === "content" || node.field === "transcript"));
|
|
32426
32538
|
if (!placeLeaves.length || !pks.length || found2.length !== pks.length)
|
|
@@ -32467,7 +32579,7 @@ var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, f
|
|
|
32467
32579
|
});
|
|
32468
32580
|
}, "placeHits");
|
|
32469
32581
|
|
|
32470
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
32582
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-groups.js
|
|
32471
32583
|
var GROUPS = {
|
|
32472
32584
|
chat: {
|
|
32473
32585
|
key: "m.chat_id",
|
|
@@ -32489,7 +32601,7 @@ var GROUPS = {
|
|
|
32489
32601
|
}
|
|
32490
32602
|
};
|
|
32491
32603
|
|
|
32492
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
32604
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
|
|
32493
32605
|
var MESSAGES2 = {
|
|
32494
32606
|
rows: "messages",
|
|
32495
32607
|
threads: "chats",
|
|
@@ -32972,7 +33084,7 @@ var runCompiled = /* @__PURE__ */ __name(async (context, execution, by) => {
|
|
|
32972
33084
|
};
|
|
32973
33085
|
}, "runCompiled");
|
|
32974
33086
|
|
|
32975
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33087
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
|
|
32976
33088
|
function invalidMetadata() {
|
|
32977
33089
|
throw new CliError("validation_error", "stored counter metadata is malformed \u2014 check the store before refreshing");
|
|
32978
33090
|
}
|
|
@@ -33074,7 +33186,7 @@ var counterTargets = /* @__PURE__ */ __name((context, execution, options) => wit
|
|
|
33074
33186
|
};
|
|
33075
33187
|
}), "counterTargets");
|
|
33076
33188
|
|
|
33077
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33189
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
|
|
33078
33190
|
var NOT_FILE_LIST = [...NOT_FILES].map((kind4) => `'${kind4}'`).join(",");
|
|
33079
33191
|
var fileAttachments = /* @__PURE__ */ __name(({ database }, accountKey, { chatKey, messageId, beforePk, limit }) => database.prepare(`SELECT att.id AS pk, c.external_id AS chat_id, m.external_id AS message_id, att.position, att.kind, att.name, att.mime,
|
|
33080
33192
|
att.size, att.local_path, att.extraction AS origin, att.size AS read_bytes, att.extraction_error AS error, att.content_sha256, att.extractor
|
|
@@ -33193,7 +33305,7 @@ var attachmentViews = /* @__PURE__ */ __name(({ database }, accountKey, { chatKe
|
|
|
33193
33305
|
}));
|
|
33194
33306
|
}, "attachmentViews");
|
|
33195
33307
|
|
|
33196
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33308
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
|
|
33197
33309
|
var transcript = /* @__PURE__ */ __name(({ orm }, chatKey, messageId) => orm.select({ text: messageTranscripts.text, source: messageTranscripts.source }).from(messageTranscripts).where(and(eq(messageTranscripts.chatId, chatKey), eq(messageTranscripts.messageExternalId, messageId))).get(), "transcript");
|
|
33198
33310
|
var keepTranscript = /* @__PURE__ */ __name((context, chatKey, messageId, text6, source2) => {
|
|
33199
33311
|
const { orm, database, now: now2 } = context;
|
|
@@ -33231,7 +33343,7 @@ var intoVoiceAttachment = /* @__PURE__ */ __name((context, messagePk) => {
|
|
|
33231
33343
|
keepText(context, Number(row2.id), { text: String(row2.text), origin: "extracted", extractor: `speech:${row2.source}` });
|
|
33232
33344
|
}, "intoVoiceAttachment");
|
|
33233
33345
|
|
|
33234
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33346
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
|
|
33235
33347
|
var FIELDS = [
|
|
33236
33348
|
"threadExternalId",
|
|
33237
33349
|
"senderIdentityId",
|
|
@@ -33548,7 +33660,7 @@ var writeDerivedReactions = /* @__PURE__ */ __name((context, chatKey, messageId)
|
|
|
33548
33660
|
reactionStatementsOf(context.database).total.run(JSON.stringify(derived), chatKey, messageId);
|
|
33549
33661
|
}, "writeDerivedReactions");
|
|
33550
33662
|
|
|
33551
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33663
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/keys.js
|
|
33552
33664
|
var keysOver = /* @__PURE__ */ __name((context) => {
|
|
33553
33665
|
const findAccountPk2 = /* @__PURE__ */ __name((key2) => findAccountPk(context, key2), "findAccountPk");
|
|
33554
33666
|
const findChatPk2 = /* @__PURE__ */ __name((accountKey, chatId) => findChatPk(context, accountKey, chatId), "findChatPk");
|
|
@@ -33569,7 +33681,7 @@ var keysOver = /* @__PURE__ */ __name((context) => {
|
|
|
33569
33681
|
};
|
|
33570
33682
|
}, "keysOver");
|
|
33571
33683
|
|
|
33572
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33684
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
|
|
33573
33685
|
var accountGroupsOf = /* @__PURE__ */ __name((database) => {
|
|
33574
33686
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(ACCOUNT_GROUPS);
|
|
33575
33687
|
if (!row2)
|
|
@@ -33604,7 +33716,7 @@ var saveProfile = /* @__PURE__ */ __name((database, app, profile, key2, now2) =>
|
|
|
33604
33716
|
database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(PROFILES, JSON.stringify(profiles), now2);
|
|
33605
33717
|
}, "saveProfile");
|
|
33606
33718
|
|
|
33607
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33719
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
|
|
33608
33720
|
var BOT_KINDS = ["agent", "rule", "script", "integration"];
|
|
33609
33721
|
var ownerPerson = /* @__PURE__ */ __name((database) => {
|
|
33610
33722
|
const found2 = database.prepare("SELECT id FROM persons WHERE owner = 1 ORDER BY id LIMIT 1").get();
|
|
@@ -33661,7 +33773,7 @@ var proposedBySql = /* @__PURE__ */ __name((type, id2, by) => {
|
|
|
33661
33773
|
return { sql: bot("pb.name = ?"), params: [by.bot] };
|
|
33662
33774
|
}, "proposedBySql");
|
|
33663
33775
|
|
|
33664
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33776
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
|
|
33665
33777
|
var linkOwnIdentities = /* @__PURE__ */ __name((context) => {
|
|
33666
33778
|
const owner = ownerPerson(context.database).id;
|
|
33667
33779
|
const strays = context.database.prepare("SELECT DISTINCT l.person_id AS person FROM identity_links l JOIN identities i ON i.id = l.identity_id JOIN accounts a ON a.provider = i.provider AND a.external_id = i.external_id WHERE l.person_id <> ?").all(owner);
|
|
@@ -33682,7 +33794,7 @@ var linkToOwner = /* @__PURE__ */ __name((context, ref3) => {
|
|
|
33682
33794
|
return personOf(context, ref3);
|
|
33683
33795
|
}, "linkToOwner");
|
|
33684
33796
|
|
|
33685
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33797
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
|
|
33686
33798
|
var PROVIDERS_SETTING = "providers";
|
|
33687
33799
|
var storedProvidersOf = /* @__PURE__ */ __name((database) => {
|
|
33688
33800
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(PROVIDERS_SETTING);
|
|
@@ -33717,7 +33829,7 @@ var registerProvider = /* @__PURE__ */ __name((database, value, now2) => {
|
|
|
33717
33829
|
});
|
|
33718
33830
|
}, "registerProvider");
|
|
33719
33831
|
|
|
33720
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
33832
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
|
|
33721
33833
|
var DAY3 = 864e5;
|
|
33722
33834
|
var RECENTLY_CLOSED_MS = 14 * DAY3;
|
|
33723
33835
|
var TEXT_LIMIT = 20;
|
|
@@ -33916,7 +34028,7 @@ var taskSimilarityOver = /* @__PURE__ */ __name((context) => {
|
|
|
33916
34028
|
};
|
|
33917
34029
|
}, "taskSimilarityOver");
|
|
33918
34030
|
|
|
33919
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34031
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
|
|
33920
34032
|
var SETTING3 = "taskCategories";
|
|
33921
34033
|
var savedTaskCategories = /* @__PURE__ */ __name((database) => {
|
|
33922
34034
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING3);
|
|
@@ -33935,7 +34047,7 @@ var saveTaskCategories = /* @__PURE__ */ __name((database, categories, now2) =>
|
|
|
33935
34047
|
database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(SETTING3, JSON.stringify(categories), now2);
|
|
33936
34048
|
}, "saveTaskCategories");
|
|
33937
34049
|
|
|
33938
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34050
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
|
|
33939
34051
|
var DEFAULT_AGENT_CLOSE = { allowed: true, min: 0.8 };
|
|
33940
34052
|
var ALLOWED = "taskAgentClose";
|
|
33941
34053
|
var MIN = "taskAgentCloseMin";
|
|
@@ -33991,10 +34103,10 @@ var SUGGESTION_COLUMNS = [
|
|
|
33991
34103
|
];
|
|
33992
34104
|
var CLEAR_SUGGESTION = SUGGESTION_COLUMNS.map((column2) => `${column2} = NULL`).join(", ");
|
|
33993
34105
|
|
|
33994
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34106
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/mail-findings.js
|
|
33995
34107
|
var MAIL_FINDINGS_KIND = "mail_findings";
|
|
33996
34108
|
|
|
33997
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34109
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/decisions.js
|
|
33998
34110
|
var TASK_CLOSE_KIND = "task_close";
|
|
33999
34111
|
var DEFAULT_DECISION_POLICY = { agentDecisions: false, ruleProposalsOwnerOnly: true };
|
|
34000
34112
|
var isOwnerOnlyKind = /* @__PURE__ */ __name((kind4) => kind4 === MAIL_FINDINGS_KIND || kind4 === MEETING_FINDINGS_KIND || kind4 === TASK_CLOSE_KIND, "isOwnerOnlyKind");
|
|
@@ -34042,7 +34154,17 @@ var assertMayDecide = /* @__PURE__ */ __name((row2, by, policy = DEFAULT_DECISIO
|
|
|
34042
34154
|
}, "assertMayDecide");
|
|
34043
34155
|
var deciderAuthor = /* @__PURE__ */ __name((by) => by === "owner" ? "owner" : { bot: by.bot, ...by.model === void 0 ? {} : { model: by.model } }, "deciderAuthor");
|
|
34044
34156
|
|
|
34045
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34157
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/deals.js
|
|
34158
|
+
var DEAL_KINDS = ["deal", "lead"];
|
|
34159
|
+
var DEAL_STATUSES = ["open", "won", "lost"];
|
|
34160
|
+
var STAGE_OUTCOMES = DEAL_STATUSES;
|
|
34161
|
+
var DEAL_ROLES = ["owner", "contact", "decision-maker"];
|
|
34162
|
+
var dealLine = /* @__PURE__ */ __name((deal) => {
|
|
34163
|
+
const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
|
|
34164
|
+
return `${deal.title} \xB7 ${deal.stage}${money}${deal.status === "open" ? "" : ` (${deal.status})`}`;
|
|
34165
|
+
}, "dealLine");
|
|
34166
|
+
|
|
34167
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/ref-summaries.js
|
|
34046
34168
|
var PROFILE_PLACEHOLDER = "<profile>";
|
|
34047
34169
|
var oneLine = /* @__PURE__ */ __name((text6) => singleLine(text6.replace(/\s+/g, " ").trim()), "oneLine");
|
|
34048
34170
|
var openKind = /* @__PURE__ */ __name((kind4) => kind4 === "email" ? "message" : kind4 === "email_thread" ? "chat" : kind4 === "unknown" ? void 0 : kind4, "openKind");
|
|
@@ -34085,6 +34207,9 @@ var WORDS2 = {
|
|
|
34085
34207
|
invoice: "Invoice",
|
|
34086
34208
|
payment: "Payment",
|
|
34087
34209
|
order: "Order",
|
|
34210
|
+
deal: "Deal",
|
|
34211
|
+
lead: "Lead",
|
|
34212
|
+
pipeline: "Pipeline",
|
|
34088
34213
|
email: "Email",
|
|
34089
34214
|
email_thread: "Email thread",
|
|
34090
34215
|
unknown: "Unknown"
|
|
@@ -34095,7 +34220,7 @@ var refLabel = /* @__PURE__ */ __name((summary) => {
|
|
|
34095
34220
|
return `${WORDS2[summary.kind]} ${named3}${notes2 === "" ? "" : ` (${notes2})`}`;
|
|
34096
34221
|
}, "refLabel");
|
|
34097
34222
|
|
|
34098
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34223
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/ref-summaries.js
|
|
34099
34224
|
var EXCERPT_CHARS = 280;
|
|
34100
34225
|
var TITLE_CHARS = 120;
|
|
34101
34226
|
var MEMORY_TITLE_CHARS = 80;
|
|
@@ -34118,6 +34243,12 @@ var byId = /* @__PURE__ */ __name((kind4, table, columns) => ({
|
|
|
34118
34243
|
kind: kind4,
|
|
34119
34244
|
sql: /* @__PURE__ */ __name((body2) => `${select(columns(body2))} FROM w JOIN ${table} x ON x.id = w.k1`, "sql")
|
|
34120
34245
|
}), "byId");
|
|
34246
|
+
var crmColumns = /* @__PURE__ */ __name(() => ({
|
|
34247
|
+
title: "json_object('id', x.id, 'title', x.title, 'stage', (SELECT name FROM pipeline_stages WHERE id = x.stage_id), 'amount', x.amount, 'currency', x.currency, 'status', x.status)",
|
|
34248
|
+
holder: "(SELECT name FROM projects WHERE id = x.project_id)",
|
|
34249
|
+
at: "x.created_at",
|
|
34250
|
+
deleted: "x.deleted_at"
|
|
34251
|
+
}), "crmColumns");
|
|
34121
34252
|
var READERS = {
|
|
34122
34253
|
message: {
|
|
34123
34254
|
kind: "message",
|
|
@@ -34269,7 +34400,10 @@ var READERS = {
|
|
|
34269
34400
|
holder: "(SELECT name FROM projects WHERE id = x.project_id)",
|
|
34270
34401
|
at: "x.created_at",
|
|
34271
34402
|
deleted: "x.deleted_at"
|
|
34272
|
-
}))
|
|
34403
|
+
})),
|
|
34404
|
+
deal: byId("deal", "deals", crmColumns),
|
|
34405
|
+
lead: byId("lead", "leads", crmColumns),
|
|
34406
|
+
pipeline: byId("pipeline", "pipelines", () => ({ title: "x.name", at: "x.created_at" }))
|
|
34273
34407
|
};
|
|
34274
34408
|
var FALLBACK = { email: "message", email_thread: "chat" };
|
|
34275
34409
|
var route = /* @__PURE__ */ __name((reference2) => {
|
|
@@ -34360,6 +34494,9 @@ var titleOf2 = /* @__PURE__ */ __name((kind4, reference2, found2) => {
|
|
|
34360
34494
|
return fieldsOf2(found2.title, paymentLine);
|
|
34361
34495
|
case "order":
|
|
34362
34496
|
return fieldsOf2(found2.title, orderLine);
|
|
34497
|
+
case "deal":
|
|
34498
|
+
case "lead":
|
|
34499
|
+
return fieldsOf2(found2.title, dealLine);
|
|
34363
34500
|
case "folder":
|
|
34364
34501
|
return reference2.type === "folder" && reference2.path !== null && found2.title !== null ? `${found2.title}/${reference2.path}` : found2.title;
|
|
34365
34502
|
default:
|
|
@@ -34456,7 +34593,7 @@ var refReadsOf = /* @__PURE__ */ __name((database, texts2, { excerpt = false } =
|
|
|
34456
34593
|
var summaryOf2 = /* @__PURE__ */ __name(({ sender, excerpt, ...summary }, withExcerpt) => withExcerpt ? { ...summary, excerpt } : summary, "summaryOf");
|
|
34457
34594
|
var refSummariesOf = /* @__PURE__ */ __name((database, texts2, options = {}) => new Map([...refReadsOf(database, texts2, options)].map(([text6, read2]) => [text6, summaryOf2(read2, options.excerpt === true)])), "refSummariesOf");
|
|
34458
34595
|
|
|
34459
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34596
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
|
|
34460
34597
|
var sourceOf3 = /* @__PURE__ */ __name((read2, ref3) => ({
|
|
34461
34598
|
ref: ref3,
|
|
34462
34599
|
kind: read2.kind,
|
|
@@ -34492,7 +34629,7 @@ var evidenceSourcesOf = /* @__PURE__ */ __name((database, from2) => {
|
|
|
34492
34629
|
});
|
|
34493
34630
|
}, "evidenceSourcesOf");
|
|
34494
34631
|
|
|
34495
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34632
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/attachments/limits.js
|
|
34496
34633
|
var MAX_FILE_BYTES = 50 * 1024 * 1024;
|
|
34497
34634
|
var MAX_TEXT_CHARS = 2e6;
|
|
34498
34635
|
var ATTACHMENT_LIMIT_ENV = [
|
|
@@ -34518,7 +34655,7 @@ var pdfPreviewLimits = /* @__PURE__ */ __name((env = process.env) => {
|
|
|
34518
34655
|
return { pixels, bytes: positive(env, "MESSAGING_PDF_PREVIEW_MAX_MIB", 8 * 1024 * 1024, 1024 * 1024) };
|
|
34519
34656
|
}, "pdfPreviewLimits");
|
|
34520
34657
|
|
|
34521
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34658
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/ulid.js
|
|
34522
34659
|
import { randomBytes } from "node:crypto";
|
|
34523
34660
|
var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
34524
34661
|
var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
|
|
@@ -34531,7 +34668,7 @@ var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
|
|
|
34531
34668
|
return time3 + random;
|
|
34532
34669
|
}, "ulid");
|
|
34533
34670
|
|
|
34534
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34671
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
|
|
34535
34672
|
var FOLDED_FIELDS = ["title", "site", "language", "author"];
|
|
34536
34673
|
var encodeDocumentMetadata = /* @__PURE__ */ __name((meta, sections) => {
|
|
34537
34674
|
if (!meta && !sections?.length)
|
|
@@ -34552,7 +34689,7 @@ var languageOf = /* @__PURE__ */ __name((meta) => {
|
|
|
34552
34689
|
return typeof language === "string" && language !== "" ? language : null;
|
|
34553
34690
|
}, "languageOf");
|
|
34554
34691
|
|
|
34555
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34692
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
|
|
34556
34693
|
var isObject = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isObject");
|
|
34557
34694
|
var objectOf2 = /* @__PURE__ */ __name((value) => {
|
|
34558
34695
|
if (isObject(value))
|
|
@@ -34795,7 +34932,7 @@ var filesStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
|
|
|
34795
34932
|
};
|
|
34796
34933
|
}, "filesStoreOver");
|
|
34797
34934
|
|
|
34798
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34935
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
|
|
34799
34936
|
var IMPORTED_DOCUMENT_QUERY = defineQuery({
|
|
34800
34937
|
entity: "document",
|
|
34801
34938
|
backend: "sql",
|
|
@@ -34841,7 +34978,7 @@ var importedDocumentWhere = /* @__PURE__ */ __name((database, query) => {
|
|
|
34841
34978
|
return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns);
|
|
34842
34979
|
}, "importedDocumentWhere");
|
|
34843
34980
|
|
|
34844
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
34981
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
|
|
34845
34982
|
var NOTE_FORMATS = ["obsidian", "markdown"];
|
|
34846
34983
|
var iso2 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
34847
34984
|
var optionalIso = /* @__PURE__ */ __name((value) => value == null ? null : iso2(value), "optionalIso");
|
|
@@ -35367,7 +35504,7 @@ var notesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
35367
35504
|
};
|
|
35368
35505
|
}, "notesStoreOver");
|
|
35369
35506
|
|
|
35370
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
35507
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
|
|
35371
35508
|
var NAMED = "SELECT m.*, b.name AS author_name, b.kind AS author_kind FROM memories m LEFT JOIN bots b ON m.author_type = 'bot' AND b.id = m.author_id";
|
|
35372
35509
|
var iso3 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
35373
35510
|
var oneOf2 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
@@ -35589,7 +35726,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
35589
35726
|
};
|
|
35590
35727
|
}, "memoriesStoreOver");
|
|
35591
35728
|
|
|
35592
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
35729
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
|
|
35593
35730
|
var DEFAULT_FIRST_PASS_PER_CHAT = 0;
|
|
35594
35731
|
var KEY = "taskFirstPassPerChat";
|
|
35595
35732
|
var firstPassPerChatOf = /* @__PURE__ */ __name((value, setting = "task_first_pass_per_chat") => {
|
|
@@ -35609,7 +35746,7 @@ var saveFirstPassPerChat = /* @__PURE__ */ __name((database, value, now2) => {
|
|
|
35609
35746
|
database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(KEY, String(value), now2);
|
|
35610
35747
|
}, "saveFirstPassPerChat");
|
|
35611
35748
|
|
|
35612
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
35749
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/external-links.js
|
|
35613
35750
|
var EXTERNAL_SERVICE = /^[a-z][a-z0-9-]{0,31}$/;
|
|
35614
35751
|
var EXTERNAL_ID_CHARS = 200;
|
|
35615
35752
|
var SOURCE_URL_CHARS = 2e3;
|
|
@@ -35636,7 +35773,7 @@ var sourceUrlOf = /* @__PURE__ */ __name((value, reason = "task.source-url") =>
|
|
|
35636
35773
|
return text6;
|
|
35637
35774
|
}, "sourceUrlOf");
|
|
35638
35775
|
|
|
35639
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
35776
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-board.js
|
|
35640
35777
|
var TASK_SORTS = ["priority", "due", "created", "updated", "key", "state"];
|
|
35641
35778
|
var field = /* @__PURE__ */ __name((name, type, example, more = {}) => ({
|
|
35642
35779
|
name,
|
|
@@ -35859,7 +35996,7 @@ var withoutField = /* @__PURE__ */ __name((query, name) => {
|
|
|
35859
35996
|
return root === void 0 ? void 0 : { ...query, root };
|
|
35860
35997
|
}, "withoutField");
|
|
35861
35998
|
|
|
35862
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
35999
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-comments.js
|
|
35863
36000
|
var authorNamed = /* @__PURE__ */ __name((database, row2) => {
|
|
35864
36001
|
if (row2.author_type == null)
|
|
35865
36002
|
return null;
|
|
@@ -35887,7 +36024,7 @@ var addComment = /* @__PURE__ */ __name((context, task, body2, by) => {
|
|
|
35887
36024
|
return commentsOf(database, task).find((one2) => one2.ref === `note:${made}`);
|
|
35888
36025
|
}, "addComment");
|
|
35889
36026
|
|
|
35890
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
36027
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
|
|
35891
36028
|
var TASK_RELATION_KINDS = [
|
|
35892
36029
|
"blocked-by",
|
|
35893
36030
|
"follow-up-of",
|
|
@@ -36017,7 +36154,7 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
|
|
|
36017
36154
|
};
|
|
36018
36155
|
}, "taskRelationsStoreOver");
|
|
36019
36156
|
|
|
36020
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
36157
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
|
|
36021
36158
|
var TASK_ROLES = ["assignee", "reviewer", "watcher"];
|
|
36022
36159
|
var iso4 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
|
|
36023
36160
|
var recordTaskEvent = /* @__PURE__ */ __name((database, task, actor, kind4, changes, at) => {
|
|
@@ -36546,7 +36683,7 @@ var workTasksOver = /* @__PURE__ */ __name((context) => {
|
|
|
36546
36683
|
};
|
|
36547
36684
|
}, "workTasksOver");
|
|
36548
36685
|
|
|
36549
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
36686
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
|
|
36550
36687
|
var taskCloseOver = /* @__PURE__ */ __name((context) => {
|
|
36551
36688
|
const { database, now: now2 } = context;
|
|
36552
36689
|
const liveRow = /* @__PURE__ */ __name((id2) => {
|
|
@@ -36595,7 +36732,7 @@ var taskCloseOver = /* @__PURE__ */ __name((context) => {
|
|
|
36595
36732
|
};
|
|
36596
36733
|
}, "taskCloseOver");
|
|
36597
36734
|
|
|
36598
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
36735
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
|
|
36599
36736
|
var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
|
|
36600
36737
|
const { database, now: now2 } = context;
|
|
36601
36738
|
const required3 = /* @__PURE__ */ __name((id2) => {
|
|
@@ -36813,7 +36950,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
|
|
|
36813
36950
|
};
|
|
36814
36951
|
}, "taskPairsOver");
|
|
36815
36952
|
|
|
36816
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
36953
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-stats.js
|
|
36817
36954
|
var ACCOUNT_SCOPE = "t.package_id IS NOT NULL AND t.deleted_at IS NULL AND t.project_id = ?";
|
|
36818
36955
|
var TASK_STATS_SQL = {
|
|
36819
36956
|
rows: /* @__PURE__ */ __name((board, filter) => `SELECT t.source_group, t.source_kind, t.project_id, t.status, t.created_at, t.closed_at FROM tasks t WHERE ${board ? BOARD_SCOPE : ACCOUNT_SCOPE}${filter} ORDER BY t.created_at, t.id`, "rows"),
|
|
@@ -36852,7 +36989,7 @@ var taskStatsOver = /* @__PURE__ */ __name(({ database }, inbox) => ({
|
|
|
36852
36989
|
}, "statNames")
|
|
36853
36990
|
}), "taskStatsOver");
|
|
36854
36991
|
|
|
36855
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
36992
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
|
|
36856
36993
|
var COLUMNS3 = "t.id AS row_id, t.package_id, t.source_locator, t.source_kind, t.source_group, t.type, t.status, t.close_reason, t.source, t.created_at, t.due_at, t.closed_at, t.closed_by_type, t.closed_by_id, t.key, t.category, t.claimed_by, t.claimed_until, p.name AS account";
|
|
36857
36994
|
var inboxProject = /* @__PURE__ */ __name(({ database, now: now2 }, account, create) => {
|
|
36858
36995
|
const key2 = inboxKey(account);
|
|
@@ -37059,7 +37196,7 @@ var oneOf3 = /* @__PURE__ */ __name((values, value, column2) => {
|
|
|
37059
37196
|
throw new CliError("configuration_error", `the store holds a task with an unknown ${column2} "${String(value)}"`);
|
|
37060
37197
|
}, "oneOf");
|
|
37061
37198
|
|
|
37062
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37199
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/accounts.js
|
|
37063
37200
|
var accountAccountsOver = /* @__PURE__ */ __name((context) => {
|
|
37064
37201
|
const { database } = context;
|
|
37065
37202
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2 } = keysOver(context);
|
|
@@ -37104,7 +37241,7 @@ var accountsStoreOver = /* @__PURE__ */ __name((context, keyed) => {
|
|
|
37104
37241
|
};
|
|
37105
37242
|
}, "accountsStoreOver");
|
|
37106
37243
|
|
|
37107
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37244
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
|
|
37108
37245
|
var refColumn = /* @__PURE__ */ __name((ref3) => ref3 && Object.keys(ref3).length > 0 ? { providerRef: JSON.stringify(ref3) } : {}, "refColumn");
|
|
37109
37246
|
var updatePlaced = /* @__PURE__ */ __name(({ orm }, chatKey, messageId, files2, change) => {
|
|
37110
37247
|
const message2 = orm.select({ pk: messages.id }).from(messages).where(and(eq(messages.chatId, chatKey), eq(messages.externalId, messageId))).get();
|
|
@@ -37128,7 +37265,7 @@ var keepDownloads = /* @__PURE__ */ __name((context, chatKey, messageId, files2)
|
|
|
37128
37265
|
})), "keepDownloads");
|
|
37129
37266
|
var keepProviderRefs = /* @__PURE__ */ __name((context, chatKey, messageId, files2) => updatePlaced(context, chatKey, messageId, files2.filter((file) => Object.keys(file.providerRef).length > 0), (file) => refColumn(file.providerRef)), "keepProviderRefs");
|
|
37130
37267
|
|
|
37131
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37268
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/attachments.js
|
|
37132
37269
|
var accountAttachmentsOver = /* @__PURE__ */ __name((context) => {
|
|
37133
37270
|
const { database } = context;
|
|
37134
37271
|
const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
|
|
@@ -37185,7 +37322,7 @@ var attachmentsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
37185
37322
|
}, "keepAttachmentText")
|
|
37186
37323
|
}), "attachmentsStoreOver");
|
|
37187
37324
|
|
|
37188
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37325
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
|
|
37189
37326
|
var chatRow = /* @__PURE__ */ __name((context, accountKey, chatId) => context.database.prepare("SELECT * FROM chats WHERE account_id = ? AND external_id = ?").get(accountKey, chatId), "chatRow");
|
|
37190
37327
|
var pointerMover = /* @__PURE__ */ __name((context, type) => {
|
|
37191
37328
|
const statements = pointerPairs(context.database).filter(({ table }) => table !== "involvements").map(({ table, pointer }) => {
|
|
@@ -37365,7 +37502,7 @@ var rekeyChats = /* @__PURE__ */ __name((context, key2, accountKey, pairs, lockM
|
|
|
37365
37502
|
return done;
|
|
37366
37503
|
}, "rekeyChats");
|
|
37367
37504
|
|
|
37368
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37505
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
|
|
37369
37506
|
var historyStartKey = /* @__PURE__ */ __name((chatId) => `history_start:${chatId}`, "historyStartKey");
|
|
37370
37507
|
var fetchedKey = /* @__PURE__ */ __name((chatId) => `fetched:${chatId}`, "fetchedKey");
|
|
37371
37508
|
var CHAT_LIST_KEY = "chat_list_complete";
|
|
@@ -37423,7 +37560,7 @@ var chatCoverage = /* @__PURE__ */ __name(({ database }, accountKey) => {
|
|
|
37423
37560
|
return { ...coverage, oldestMessageAt: toIso(oldest) };
|
|
37424
37561
|
}, "chatCoverage");
|
|
37425
37562
|
|
|
37426
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37563
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/chats.js
|
|
37427
37564
|
var chatsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
37428
37565
|
const { database } = context;
|
|
37429
37566
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, writeState: writeState2 } = keysOver(context);
|
|
@@ -37558,7 +37695,7 @@ var chatsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
37558
37695
|
};
|
|
37559
37696
|
}, "chatsStoreOver");
|
|
37560
37697
|
|
|
37561
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37698
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
|
|
37562
37699
|
import { createHash as createHash7 } from "node:crypto";
|
|
37563
37700
|
var BATCH_CONTEXT = 50;
|
|
37564
37701
|
var replied = /* @__PURE__ */ __name((m) => sql`EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
|
|
@@ -37696,7 +37833,7 @@ var saveAnswers = /* @__PURE__ */ __name((context, id2, answer) => {
|
|
|
37696
37833
|
var clearAnswers = /* @__PURE__ */ __name(({ orm }, chatKey, model) => Number(orm.all(sql`DELETE FROM message_links WHERE chat_id = ${chatKey} AND source = 'agent'
|
|
37697
37834
|
${model === void 0 ? sql`` : sql`AND method = ${model}`} RETURNING 1 AS n`).length), "clearAnswers");
|
|
37698
37835
|
|
|
37699
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
37836
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
|
|
37700
37837
|
import { setTimeout } from "node:timers/promises";
|
|
37701
37838
|
var position = /* @__PURE__ */ __name((sentAt, pk) => `${sentAt}:${pk}`, "position");
|
|
37702
37839
|
var linkInputs = /* @__PURE__ */ __name(({ orm }, chatKey, { after: after2, limit }) => {
|
|
@@ -38008,7 +38145,7 @@ var agentAnswers = /* @__PURE__ */ __name(({ orm }, chatKey) => new Map(orm.all(
|
|
|
38008
38145
|
AND NOT EXISTS (SELECT 1 FROM messages d
|
|
38009
38146
|
WHERE d.id IN (l.message_id, l.parent_id) AND d.deleted_at > l.created_at)`).map(({ id: id2, parent: parent2 }) => [id2, parent2])), "agentAnswers");
|
|
38010
38147
|
|
|
38011
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38148
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/conversations.js
|
|
38012
38149
|
var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
38013
38150
|
const { database } = context;
|
|
38014
38151
|
const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
|
|
@@ -38115,7 +38252,7 @@ var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
38115
38252
|
};
|
|
38116
38253
|
}, "conversationsStoreOver");
|
|
38117
38254
|
|
|
38118
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38255
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/counters.js
|
|
38119
38256
|
var LIVE_MESSAGE = "SELECT m.id AS pk FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id WHERE ac.provider=? AND ac.external_id=? AND c.external_id=? AND m.external_id=? AND m.deleted_at IS NULL";
|
|
38120
38257
|
var accountCountersOver = /* @__PURE__ */ __name((context) => {
|
|
38121
38258
|
const { database } = context;
|
|
@@ -38140,7 +38277,7 @@ var countersStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
38140
38277
|
counterTargets: /* @__PURE__ */ __name(async (execution, options) => counterTargets(context, execution, options), "counterTargets")
|
|
38141
38278
|
}), "countersStoreOver");
|
|
38142
38279
|
|
|
38143
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38280
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
|
|
38144
38281
|
var MENTION_STATUSES = ["found", "linked", "dismissed"];
|
|
38145
38282
|
var MENTION_QUERY = defineQuery({
|
|
38146
38283
|
entity: "mention",
|
|
@@ -38356,7 +38493,7 @@ var listPlaces = /* @__PURE__ */ __name((database, { limit, offset }) => {
|
|
|
38356
38493
|
return { items: hasMore ? rows.slice(0, limit) : rows, hasMore };
|
|
38357
38494
|
}, "listPlaces");
|
|
38358
38495
|
|
|
38359
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38496
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/mentions.js
|
|
38360
38497
|
var accountMentionsOver = /* @__PURE__ */ __name((context) => {
|
|
38361
38498
|
const { database } = context;
|
|
38362
38499
|
const { findAccountPk: findAccountPk2 } = keysOver(context);
|
|
@@ -38391,7 +38528,7 @@ var mentionsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
38391
38528
|
places: /* @__PURE__ */ __name(async (window) => listPlaces(context.database, window), "places")
|
|
38392
38529
|
}), "mentionsStoreOver");
|
|
38393
38530
|
|
|
38394
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38531
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
|
|
38395
38532
|
var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messageId) => {
|
|
38396
38533
|
const read2 = database.prepare("SELECT m.id, m.external_id, m.text, m.sent_at, m.sender_name, coalesce(m.sender_chat_external_id, i.external_id) AS sender_id FROM messages m LEFT JOIN identities i ON i.id = m.sender_identity_id WHERE m.chat_id = ? AND m.deleted_at IS NULL AND (m.text LIKE '%google.com%' OR m.text LIKE '%forms.gle%') " + (messageId === void 0 ? "" : "AND m.external_id = ? ") + "ORDER BY m.sent_at DESC, m.id DESC");
|
|
38397
38534
|
const rows = messageId === void 0 ? read2.all(chatKey) : read2.all(chatKey, messageId);
|
|
@@ -38406,7 +38543,7 @@ var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messag
|
|
|
38406
38543
|
}));
|
|
38407
38544
|
}, "documentLinkMessages");
|
|
38408
38545
|
|
|
38409
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38546
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
|
|
38410
38547
|
var stemmerFor = stemmerCache();
|
|
38411
38548
|
var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit }) => {
|
|
38412
38549
|
if (wanted.length > 50 || !Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
@@ -38450,7 +38587,7 @@ var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit
|
|
|
38450
38587
|
});
|
|
38451
38588
|
}, "laterSharingRare");
|
|
38452
38589
|
|
|
38453
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38590
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/messages.js
|
|
38454
38591
|
var accountMessagesOver = /* @__PURE__ */ __name((context) => {
|
|
38455
38592
|
const { database } = context;
|
|
38456
38593
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf, chatPkFor: chatPkFor2, answeredChatPk: answeredChatPk2, upsertMessage: upsertMessage2 } = keysOver(context);
|
|
@@ -38585,7 +38722,7 @@ var messagesStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
38585
38722
|
laterSharingRare: /* @__PURE__ */ __name(async (wanted, options) => laterSharingRare(context, wanted, options), "laterSharingRare")
|
|
38586
38723
|
}), "messagesStoreOver");
|
|
38587
38724
|
|
|
38588
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38725
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
|
|
38589
38726
|
var GLOBAL_PROJECT = "SELECT id FROM main.projects WHERE account_id IS NULL AND deleted_at IS NULL";
|
|
38590
38727
|
var iso5 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
|
|
38591
38728
|
var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: accounts2, limit }) => {
|
|
@@ -38642,7 +38779,7 @@ var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: a
|
|
|
38642
38779
|
});
|
|
38643
38780
|
}, "personPreparation");
|
|
38644
38781
|
|
|
38645
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38782
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
|
|
38646
38783
|
var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds) => {
|
|
38647
38784
|
const id2 = Number(uid);
|
|
38648
38785
|
if (!/^[1-9]\d*$/.test(uid) || !Number.isSafeInteger(id2) || !accountIds.length || accountIds.length > 1e3 || accountIds.some((account) => !Number.isSafeInteger(account) || account <= 0))
|
|
@@ -38650,7 +38787,7 @@ var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds
|
|
|
38650
38787
|
return Boolean(database.prepare("SELECT 1 FROM persons p JOIN identity_links l ON l.person_id=p.id JOIN account_identities a ON a.identity_id=l.identity_id WHERE p.id=? AND a.account_id IN (SELECT value FROM json_each(?)) LIMIT 1").get(id2, JSON.stringify(accountIds)));
|
|
38651
38788
|
}, "personSeenInAccounts");
|
|
38652
38789
|
|
|
38653
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38790
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
|
|
38654
38791
|
var required2 = /* @__PURE__ */ __name(({ database }, key2, personId) => {
|
|
38655
38792
|
const row2 = database.prepare("SELECT a.id AS account_id, i.id AS identity_id FROM accounts a JOIN account_identities ai ON ai.account_id=a.id JOIN identities i ON i.id=ai.identity_id WHERE a.provider=? AND a.external_id=? AND i.provider=? AND i.external_id=?").get(key2.provider, key2.account, key2.provider, personId);
|
|
38656
38793
|
if (!row2)
|
|
@@ -38716,7 +38853,7 @@ var removeNote = /* @__PURE__ */ __name((context, key2, personId, id2) => {
|
|
|
38716
38853
|
return { id: id2, personId, removed: true };
|
|
38717
38854
|
}, "removeNote");
|
|
38718
38855
|
|
|
38719
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38856
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/people.js
|
|
38720
38857
|
var accountPeopleOver = /* @__PURE__ */ __name((context) => {
|
|
38721
38858
|
const { database } = context;
|
|
38722
38859
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, identityPk: identityPk2 } = keysOver(context);
|
|
@@ -38801,13 +38938,13 @@ var peopleStoreOver = /* @__PURE__ */ __name((context, keyed) => {
|
|
|
38801
38938
|
};
|
|
38802
38939
|
}, "peopleStoreOver");
|
|
38803
38940
|
|
|
38804
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38941
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
|
|
38805
38942
|
import { createHash as createHash9 } from "node:crypto";
|
|
38806
38943
|
|
|
38807
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38944
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
|
|
38808
38945
|
import { createHash as createHash8 } from "node:crypto";
|
|
38809
38946
|
|
|
38810
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
38947
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
|
|
38811
38948
|
var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
|
|
38812
38949
|
var AUTHOR_MEASURES = [
|
|
38813
38950
|
"messages",
|
|
@@ -38947,7 +39084,7 @@ var withoutUrls = /* @__PURE__ */ __name((text6) => text6.replace(/\S+/gu, (toke
|
|
|
38947
39084
|
var rankingWords = /* @__PURE__ */ __name((text6) => withoutUrls(text6).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
|
|
38948
39085
|
var rankingQuestion = /* @__PURE__ */ __name((text6) => withoutUrls(text6).includes("?"), "rankingQuestion");
|
|
38949
39086
|
|
|
38950
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39087
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
|
|
38951
39088
|
var RANKING_GRAPH_LIMITS = { nodes: 5e4, depth: 256, work: 1e7, bytes: 8388608 };
|
|
38952
39089
|
var exhausted2 = /* @__PURE__ */ __name((budget) => {
|
|
38953
39090
|
throw new CliError("validation_error", `ranking exceeded ${budget} \u2014 narrow its chat or date scope`, {
|
|
@@ -39169,7 +39306,7 @@ var rankReplyGraph = /* @__PURE__ */ __name((nodes, check3 = () => {
|
|
|
39169
39306
|
};
|
|
39170
39307
|
}, "rankReplyGraph");
|
|
39171
39308
|
|
|
39172
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39309
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
|
|
39173
39310
|
var adminEntityKey = /* @__PURE__ */ __name((row2) => JSON.stringify([row2.account.provider, row2.account.account, row2.id]), "adminEntityKey");
|
|
39174
39311
|
var personKey = /* @__PURE__ */ __name((node) => JSON.stringify([node.account.provider, node.account.account, node.sender]), "personKey");
|
|
39175
39312
|
var locator = /* @__PURE__ */ __name((node) => formatLocator({ ...node.account, chat: node.chatId, message: node.id }), "locator");
|
|
@@ -39343,7 +39480,7 @@ var calculateAdminStatistics = /* @__PURE__ */ __name((nodes, stays, options, in
|
|
|
39343
39480
|
return { items, evidence, summary, graph: graph.quality };
|
|
39344
39481
|
}, "calculateAdminStatistics");
|
|
39345
39482
|
|
|
39346
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39483
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
|
|
39347
39484
|
var rankingContextRange = /* @__PURE__ */ __name((root) => {
|
|
39348
39485
|
const dates = [];
|
|
39349
39486
|
const visit = /* @__PURE__ */ __name((node, required3) => {
|
|
@@ -39365,7 +39502,7 @@ var rankingContextRange = /* @__PURE__ */ __name((root) => {
|
|
|
39365
39502
|
return dates[0].node.resolution.date;
|
|
39366
39503
|
}, "rankingContextRange");
|
|
39367
39504
|
|
|
39368
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39505
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
|
|
39369
39506
|
var reactionCounts = /* @__PURE__ */ __name((stored3) => {
|
|
39370
39507
|
let counts;
|
|
39371
39508
|
try {
|
|
@@ -39660,7 +39797,7 @@ var rankQuery = /* @__PURE__ */ __name((context, execution, request, inspect) =>
|
|
|
39660
39797
|
});
|
|
39661
39798
|
}, "rankQuery");
|
|
39662
39799
|
|
|
39663
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39800
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
|
|
39664
39801
|
function fail4(message2, reason = "query.too-large") {
|
|
39665
39802
|
throw new CliError("validation_error", message2, { reason, complete: false });
|
|
39666
39803
|
}
|
|
@@ -39837,7 +39974,7 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
|
|
|
39837
39974
|
return result;
|
|
39838
39975
|
}), "adminStatisticsQuery");
|
|
39839
39976
|
|
|
39840
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39977
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
|
|
39841
39978
|
var conversationEligibility = /* @__PURE__ */ __name(async (context, execution) => {
|
|
39842
39979
|
if (!execution.accounts.length)
|
|
39843
39980
|
return { conversations: [], chats: [] };
|
|
@@ -39855,7 +39992,7 @@ var conversationEligibility = /* @__PURE__ */ __name(async (context, execution)
|
|
|
39855
39992
|
return { conversations: conversations2, chats: chats2 };
|
|
39856
39993
|
}, "conversationEligibility");
|
|
39857
39994
|
|
|
39858
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39995
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
|
|
39859
39996
|
import { createHash as createHash10 } from "node:crypto";
|
|
39860
39997
|
var EVIDENCE_BYTES = 64 * 1024;
|
|
39861
39998
|
var FINGERPRINT_BYTES = 8 * 1024 * 1024;
|
|
@@ -40005,7 +40142,7 @@ var rankingEvidence = /* @__PURE__ */ __name((context, execution, request) => {
|
|
|
40005
40142
|
return result;
|
|
40006
40143
|
}, "rankingEvidence");
|
|
40007
40144
|
|
|
40008
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40145
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/reply-times.js
|
|
40009
40146
|
var FAR = Number.MAX_SAFE_INTEGER;
|
|
40010
40147
|
var chatsIn = /* @__PURE__ */ __name((scope3, kinds2) => {
|
|
40011
40148
|
const params = [...scope3.accounts.flatMap(({ provider, account }) => [provider, account]), ...kinds2];
|
|
@@ -40099,7 +40236,7 @@ var waitingChats = /* @__PURE__ */ __name((context, scope3, waits, cap) => {
|
|
|
40099
40236
|
});
|
|
40100
40237
|
}, "waitingChats");
|
|
40101
40238
|
|
|
40102
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40239
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/queries.js
|
|
40103
40240
|
var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
|
|
40104
40241
|
const mailIndexed = /* @__PURE__ */ __name((execution) => {
|
|
40105
40242
|
if (execution.corpus === "mail")
|
|
@@ -40120,7 +40257,7 @@ var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
|
|
|
40120
40257
|
};
|
|
40121
40258
|
}, "queriesStoreOver");
|
|
40122
40259
|
|
|
40123
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40260
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
|
|
40124
40261
|
var saveChatEvents = /* @__PURE__ */ __name((context, accountKey, provider, chatKey, events3) => {
|
|
40125
40262
|
const { database, now: now2 } = context;
|
|
40126
40263
|
const insert = database.prepare(`INSERT INTO chat_events (chat_id, source_id, action, actor_identity_id, title, happened_at, created_at, updated_at)
|
|
@@ -40159,10 +40296,10 @@ var chatEventsOf = /* @__PURE__ */ __name(({ database }, chatKey, { since = 0, l
|
|
|
40159
40296
|
}));
|
|
40160
40297
|
}, "chatEventsOf");
|
|
40161
40298
|
|
|
40162
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40299
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
|
|
40163
40300
|
import { createHash as createHash11 } from "node:crypto";
|
|
40164
40301
|
|
|
40165
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40302
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/calendar.js
|
|
40166
40303
|
var calendarKey = /* @__PURE__ */ __name((zone, by) => {
|
|
40167
40304
|
const format = new Intl.DateTimeFormat("en-CA", {
|
|
40168
40305
|
timeZone: zone,
|
|
@@ -40182,7 +40319,7 @@ var weekKey = /* @__PURE__ */ __name((day) => {
|
|
|
40182
40319
|
return date3.toISOString().slice(0, 10);
|
|
40183
40320
|
}, "weekKey");
|
|
40184
40321
|
|
|
40185
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40322
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/retention.js
|
|
40186
40323
|
var RETENTION_TOLERANCE = 864e5;
|
|
40187
40324
|
var validateRetentionOptions = /* @__PURE__ */ __name((options) => {
|
|
40188
40325
|
const { since, until, cutoff, checkpoints, within, limit, by } = options;
|
|
@@ -40236,7 +40373,7 @@ var retentionCohorts = /* @__PURE__ */ __name((stays, options) => {
|
|
|
40236
40373
|
return [...groups.values()].sort((a, b) => a.cohort.localeCompare(b.cohort));
|
|
40237
40374
|
}, "retentionCohorts");
|
|
40238
40375
|
|
|
40239
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40376
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
|
|
40240
40377
|
var iso6 = /* @__PURE__ */ __name((at) => new Date(at).toISOString(), "iso");
|
|
40241
40378
|
var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId, options, evidence) => {
|
|
40242
40379
|
validateRetentionOptions(options);
|
|
@@ -40367,7 +40504,7 @@ var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId
|
|
|
40367
40504
|
};
|
|
40368
40505
|
}, "retentionQuery");
|
|
40369
40506
|
|
|
40370
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40507
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
|
|
40371
40508
|
var iso7 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
|
|
40372
40509
|
var marksOf = /* @__PURE__ */ __name(({ isBot, flagged, deleted, hasPhoto }) => ({
|
|
40373
40510
|
...isBot === void 0 ? {} : { bot: isBot },
|
|
@@ -40498,7 +40635,7 @@ var trackedChats = /* @__PURE__ */ __name((context, accountKey, where) => contex
|
|
|
40498
40635
|
lastCount: memberCountsOf(context, pk).at(-1) ?? null
|
|
40499
40636
|
})), "trackedChats");
|
|
40500
40637
|
|
|
40501
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40638
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/roster.js
|
|
40502
40639
|
var rosterStoreOver = /* @__PURE__ */ __name((context) => {
|
|
40503
40640
|
const { database } = context;
|
|
40504
40641
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, writeMembers: writeMembers2 } = keysOver(context);
|
|
@@ -40554,7 +40691,7 @@ var rosterStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
40554
40691
|
};
|
|
40555
40692
|
}, "rosterStoreOver");
|
|
40556
40693
|
|
|
40557
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40694
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
|
|
40558
40695
|
var pendingNormalization = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL").get()?.n), "pendingNormalization");
|
|
40559
40696
|
var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatch, until = /* @__PURE__ */ __name(() => false, "until") } = {}) => {
|
|
40560
40697
|
const next = database.prepare(`SELECT id AS pk, text FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL AND id > ? ORDER BY id LIMIT ?`);
|
|
@@ -40578,7 +40715,7 @@ var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatc
|
|
|
40578
40715
|
}
|
|
40579
40716
|
}, "backfillNormalized");
|
|
40580
40717
|
|
|
40581
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40718
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
|
|
40582
40719
|
var INDEX2 = "message_words";
|
|
40583
40720
|
var searchIndexState2 = /* @__PURE__ */ __name((database) => {
|
|
40584
40721
|
const row2 = indexRow(database, INDEX2);
|
|
@@ -40705,7 +40842,7 @@ var resetSearchIndex = /* @__PURE__ */ __name((database) => {
|
|
|
40705
40842
|
});
|
|
40706
40843
|
}, "resetSearchIndex");
|
|
40707
40844
|
|
|
40708
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40845
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
|
|
40709
40846
|
var fillStems = /* @__PURE__ */ __name((database, { batch = 5e3, until = /* @__PURE__ */ __name(() => false, "until"), onBatch, now: now2 = Date.now } = {}) => {
|
|
40710
40847
|
const filled2 = { stemmed: 0, drained: 0 };
|
|
40711
40848
|
const before2 = stemsState(database);
|
|
@@ -40800,7 +40937,7 @@ var followDefaultStemmers = /* @__PURE__ */ __name((database, now2 = Date.now) =
|
|
|
40800
40937
|
return resetStems(database, { now: now2 });
|
|
40801
40938
|
}, "followDefaultStemmers");
|
|
40802
40939
|
|
|
40803
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40940
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
|
|
40804
40941
|
var VOCABULARY = "SELECT term, doc FROM message_words_vocab WHERE col = 'normalized_text'";
|
|
40805
40942
|
var knownTerms = /* @__PURE__ */ __name(({ database }, terms2) => {
|
|
40806
40943
|
const lookup = database.prepare(`${VOCABULARY} AND term >= ? AND term <= ? LIMIT 1`);
|
|
@@ -40822,7 +40959,7 @@ var termCandidates = /* @__PURE__ */ __name(({ database }, pieces, { shortest, l
|
|
|
40822
40959
|
});
|
|
40823
40960
|
}, "termCandidates");
|
|
40824
40961
|
|
|
40825
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40962
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/search-index.js
|
|
40826
40963
|
var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
|
|
40827
40964
|
const { database } = context;
|
|
40828
40965
|
const stemmerFor2 = stemmerCache();
|
|
@@ -40844,7 +40981,7 @@ var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
40844
40981
|
};
|
|
40845
40982
|
}, "searchIndexStoreOver");
|
|
40846
40983
|
|
|
40847
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
40984
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
|
|
40848
40985
|
var HISTORY_KEPT = 1e3;
|
|
40849
40986
|
var commandFilter = /* @__PURE__ */ __name((commands) => commands ? { sql: ` AND command IN (${commands.map(() => "?").join(", ")})`, values: [...commands] } : { sql: "", values: [] }, "commandFilter");
|
|
40850
40987
|
var COLUMNS5 = "id, name, command, params, language, version, fields_version, created_at, updated_at, last_run_at, runs";
|
|
@@ -40913,7 +41050,7 @@ var clearHistory = /* @__PURE__ */ __name(({ database }, commands) => {
|
|
|
40913
41050
|
return database.prepare(`DELETE FROM searches WHERE name IS NULL${only.sql}`).run(...only.values).changes;
|
|
40914
41051
|
}, "clearHistory");
|
|
40915
41052
|
|
|
40916
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41053
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/searches.js
|
|
40917
41054
|
var searchesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
40918
41055
|
const { database } = context;
|
|
40919
41056
|
return {
|
|
@@ -40937,7 +41074,7 @@ var searchesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
40937
41074
|
};
|
|
40938
41075
|
}, "searchesStoreOver");
|
|
40939
41076
|
|
|
40940
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41077
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
|
|
40941
41078
|
var ACTION_TIERS = ["read", "draft", "write-private", "write-public", "destructive", "admin"];
|
|
40942
41079
|
var ACTION_OUTCOMES = ["ok", "refused", "failed"];
|
|
40943
41080
|
var CODE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
@@ -40980,7 +41117,7 @@ var agentActionsStoreOver = /* @__PURE__ */ __name((context, afterRecord = () =>
|
|
|
40980
41117
|
};
|
|
40981
41118
|
}, "agentActionsStoreOver");
|
|
40982
41119
|
|
|
40983
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41120
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
|
|
40984
41121
|
var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
|
|
40985
41122
|
}) => {
|
|
40986
41123
|
const { database, now: now2 } = context;
|
|
@@ -41039,7 +41176,7 @@ var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
|
|
|
41039
41176
|
};
|
|
41040
41177
|
}, "botUpdateStoreOver");
|
|
41041
41178
|
|
|
41042
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41179
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
|
|
41043
41180
|
var DAY4 = 864e5;
|
|
41044
41181
|
var accountsOf = /* @__PURE__ */ __name((filter) => {
|
|
41045
41182
|
if (filter.accountIds !== void 0 && filter.accountId !== void 0)
|
|
@@ -41148,7 +41285,7 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
|
|
|
41148
41285
|
return database.prepare(`SELECT e.* FROM events e WHERE ${clauses.join(" AND ")} ORDER BY ${filter.newest ? "e.starts_at DESC, e.id DESC" : "e.starts_at, e.id"} LIMIT ? OFFSET ?`).all(...params, limit, offset).map(eventOf);
|
|
41149
41286
|
}, "listEvents");
|
|
41150
41287
|
|
|
41151
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41288
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-forget.js
|
|
41152
41289
|
var distinctIds = /* @__PURE__ */ __name((rows) => [...new Set(rows.map((row2) => Number(row2.id)))], "distinctIds");
|
|
41153
41290
|
var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, accountId, cursorKey: cursorKey2, now: now2 }, refresh) => {
|
|
41154
41291
|
const unseenBefore = unreferenced(database, "identities");
|
|
@@ -41203,7 +41340,7 @@ var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, account
|
|
|
41203
41340
|
return { entries: entryIds.length, events: goneEvents.length };
|
|
41204
41341
|
}, "forgetCalendarRows");
|
|
41205
41342
|
|
|
41206
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41343
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
|
|
41207
41344
|
var calendarOf = /* @__PURE__ */ __name((row2) => ({
|
|
41208
41345
|
id: Number(row2.id),
|
|
41209
41346
|
accountId: Number(row2.account_id),
|
|
@@ -41790,7 +41927,7 @@ var eventStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
41790
41927
|
};
|
|
41791
41928
|
}, "eventStoreOver");
|
|
41792
41929
|
|
|
41793
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
41930
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
|
|
41794
41931
|
var CATALOG_QUERY = defineQuery({
|
|
41795
41932
|
entity: "document",
|
|
41796
41933
|
backend: "sql",
|
|
@@ -42032,7 +42169,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
|
|
|
42032
42169
|
};
|
|
42033
42170
|
}, "catalogStoreOver");
|
|
42034
42171
|
|
|
42035
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
42172
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
|
|
42036
42173
|
var drive = "CASE WHEN json_valid(n.front_matter) THEN json_extract(n.front_matter,'$.source')='google-drive' ELSE 0 END";
|
|
42037
42174
|
var field3 = /* @__PURE__ */ __name((name) => `CASE WHEN (${drive}) THEN
|
|
42038
42175
|
CASE WHEN json_type(n.front_matter,'$.${name}')='text' THEN json_extract(n.front_matter,'$.${name}') END END`, "field");
|
|
@@ -42045,7 +42182,7 @@ var contextDocumentTimeKind = `CASE WHEN (${remoteTime}) IS NOT NULL
|
|
|
42045
42182
|
THEN 'source-modified' ELSE 'stored-update' END`;
|
|
42046
42183
|
var contextDocumentUrl = `coalesce(${preferred("url")},n.url,${field3("sourceUrl")})`;
|
|
42047
42184
|
|
|
42048
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
42185
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
|
|
42049
42186
|
var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
|
|
42050
42187
|
const { source: source2, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal } = request;
|
|
42051
42188
|
signal?.throwIfAborted();
|
|
@@ -42144,7 +42281,7 @@ var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
|
|
|
42144
42281
|
});
|
|
42145
42282
|
}, "readMeetingContextEvidence");
|
|
42146
42283
|
|
|
42147
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
42284
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
|
|
42148
42285
|
var corpora = {
|
|
42149
42286
|
message: {
|
|
42150
42287
|
table: "messages",
|
|
@@ -42383,7 +42520,776 @@ var contextRecordsOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
42383
42520
|
}
|
|
42384
42521
|
}), "contextRecordsOver");
|
|
42385
42522
|
|
|
42386
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
42523
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/finance.js
|
|
42524
|
+
var refuse = /* @__PURE__ */ __name((message2, reason, code = "validation_error") => {
|
|
42525
|
+
throw new CliError(code, message2, { reason });
|
|
42526
|
+
}, "refuse");
|
|
42527
|
+
var oneOf4 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
42528
|
+
if (typeof value !== "string" || !allowed.includes(value))
|
|
42529
|
+
return refuse(`${what} is one of ${allowed.join(", ")}`, "finance.field");
|
|
42530
|
+
return value;
|
|
42531
|
+
}, "oneOf");
|
|
42532
|
+
var text3 = /* @__PURE__ */ __name((value, what, limit) => {
|
|
42533
|
+
if (value === void 0 || value === null)
|
|
42534
|
+
return null;
|
|
42535
|
+
if (typeof value !== "string" || !value.trim() || value.length > limit || value.includes("\0"))
|
|
42536
|
+
return refuse(`${what} takes 1\u2013${limit} characters`, "finance.field");
|
|
42537
|
+
return value.trim();
|
|
42538
|
+
}, "text");
|
|
42539
|
+
var isoDate = /* @__PURE__ */ __name((value, what) => {
|
|
42540
|
+
if (value === void 0 || value === null)
|
|
42541
|
+
return null;
|
|
42542
|
+
const date3 = typeof value === "string" ? value.trim() : "";
|
|
42543
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date3) || (/* @__PURE__ */ new Date(`${date3}T00:00:00Z`)).toISOString().slice(0, 10) !== date3)
|
|
42544
|
+
return refuse(`${what} is a date such as 2026-11-15`, "finance.field");
|
|
42545
|
+
return date3;
|
|
42546
|
+
}, "isoDate");
|
|
42547
|
+
var iso8 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
42548
|
+
var evidenceList = /* @__PURE__ */ __name((value) => {
|
|
42549
|
+
if (value === void 0)
|
|
42550
|
+
return [];
|
|
42551
|
+
if (!Array.isArray(value) || value.length > 8 || value.some((one2) => typeof one2 !== "string" || !one2.trim()))
|
|
42552
|
+
return refuse("evidence is a list of at most 8 references", "finance.field");
|
|
42553
|
+
return [...new Set(value.map((one2) => one2.trim()))];
|
|
42554
|
+
}, "evidenceList");
|
|
42555
|
+
var MAX_LINES = 500;
|
|
42556
|
+
var reasonOf = /* @__PURE__ */ __name((metadata3) => {
|
|
42557
|
+
if (metadata3 == null)
|
|
42558
|
+
return null;
|
|
42559
|
+
try {
|
|
42560
|
+
const { reason } = JSON.parse(String(metadata3));
|
|
42561
|
+
return typeof reason === "string" ? reason : null;
|
|
42562
|
+
} catch {
|
|
42563
|
+
return null;
|
|
42564
|
+
}
|
|
42565
|
+
}, "reasonOf");
|
|
42566
|
+
var PAID = "(SELECT coalesce(sum(a.amount), 0) FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = i.id AND p.review = 'confirmed' AND p.deleted_at IS NULL)";
|
|
42567
|
+
var INVOICES = `SELECT i.*, ${PAID} AS paid, b.name AS author_name, b.kind AS author_kind FROM invoices i LEFT JOIN bots b ON i.author_type = 'bot' AND b.id = i.author_id`;
|
|
42568
|
+
var PAYMENTS = "SELECT p.*, (SELECT coalesce(sum(amount), 0) FROM payment_allocations WHERE payment_id = p.id) AS allocated, b.name AS author_name, b.kind AS author_kind FROM payments p LEFT JOIN bots b ON p.author_type = 'bot' AND b.id = p.author_id";
|
|
42569
|
+
var reviewedRowsOver = /* @__PURE__ */ __name((context) => {
|
|
42570
|
+
const { database } = context;
|
|
42571
|
+
const partyOf = /* @__PURE__ */ __name((type, id2) => {
|
|
42572
|
+
if (type == null)
|
|
42573
|
+
return null;
|
|
42574
|
+
const { subject: subject2, subjectName: subjectName2, subjectIsOwner } = subjectOf(database, { subject_type: type, subject_id: id2 });
|
|
42575
|
+
return subject2 === null ? null : { ref: subject2, name: subjectName2, owner: subjectIsOwner };
|
|
42576
|
+
}, "partyOf");
|
|
42577
|
+
const partyThing = /* @__PURE__ */ __name((reference2, what) => {
|
|
42578
|
+
if (reference2 === void 0)
|
|
42579
|
+
return void 0;
|
|
42580
|
+
const thing = requiredThing(database, reference2, what);
|
|
42581
|
+
if (thing.type !== "person" && thing.type !== "organization")
|
|
42582
|
+
return refuse(`${what} is a person: or organization: reference, not ${reference2}`, "finance.party");
|
|
42583
|
+
return thing;
|
|
42584
|
+
}, "partyThing");
|
|
42585
|
+
const reviewedOf = /* @__PURE__ */ __name((row2, type) => ({
|
|
42586
|
+
review: row2.review,
|
|
42587
|
+
author: authorOf(row2),
|
|
42588
|
+
model: row2.model == null ? null : String(row2.model),
|
|
42589
|
+
confirmedBy: row2.confirmed_by_type == null ? null : { type: row2.confirmed_by_type, id: String(row2.confirmed_by_id) },
|
|
42590
|
+
source: String(row2.source),
|
|
42591
|
+
reason: reasonOf(row2.metadata),
|
|
42592
|
+
evidence: evidenceOf(context, { type, id: Number(row2.id) }),
|
|
42593
|
+
...projectOf(database, row2),
|
|
42594
|
+
createdAt: iso8(row2.created_at),
|
|
42595
|
+
updatedAt: iso8(row2.updated_at)
|
|
42596
|
+
}), "reviewedOf");
|
|
42597
|
+
const written2 = /* @__PURE__ */ __name((input) => {
|
|
42598
|
+
const owner = input.by === "owner";
|
|
42599
|
+
const { actor, model } = authorActor(context, input.by);
|
|
42600
|
+
const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
|
|
42601
|
+
const reason = owner ? null : text3(input.reason, "a reason", 2e3);
|
|
42602
|
+
return {
|
|
42603
|
+
owner,
|
|
42604
|
+
actor,
|
|
42605
|
+
model,
|
|
42606
|
+
source: source2,
|
|
42607
|
+
review: owner ? "confirmed" : "proposed",
|
|
42608
|
+
confirmedType: owner ? actor.type : null,
|
|
42609
|
+
confirmedId: owner ? actor.id : null,
|
|
42610
|
+
metadata: reason === null ? null : JSON.stringify({ reason }),
|
|
42611
|
+
project: input.project === void 0 ? null : projectId(database, input.project),
|
|
42612
|
+
evidence: evidenceList(input.evidence)
|
|
42613
|
+
};
|
|
42614
|
+
}, "written");
|
|
42615
|
+
const keepEvidence = /* @__PURE__ */ __name((type, id2, by) => {
|
|
42616
|
+
if (by.evidence.length)
|
|
42617
|
+
linkEvidence(context, { type, id: id2 }, by.evidence, by.owner ? "owner" : "agent");
|
|
42618
|
+
}, "keepEvidence");
|
|
42619
|
+
const ownerOnly = /* @__PURE__ */ __name((by, what) => {
|
|
42620
|
+
if (by !== "owner")
|
|
42621
|
+
refuse(`only the owner ${what}`, "finance.owner-only", "permission_error");
|
|
42622
|
+
}, "ownerOnly");
|
|
42623
|
+
const keepDecision = /* @__PURE__ */ __name((table, id2, by, reason) => {
|
|
42624
|
+
const why = [by === "owner" ? void 0 : by.reason.trim(), reason?.trim() || void 0].filter(Boolean).join(": ");
|
|
42625
|
+
if (by === "owner" && !why)
|
|
42626
|
+
return;
|
|
42627
|
+
const decision = by === "owner" ? { by: "owner", reason: why } : { by: "agent", bot: by.bot, reason: why };
|
|
42628
|
+
database.prepare(`UPDATE ${table} SET metadata = json_set(coalesce(metadata, '{}'), '$.decision', json(?)) WHERE id = ?`).run(JSON.stringify(decision), id2);
|
|
42629
|
+
}, "keepDecision");
|
|
42630
|
+
return { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision };
|
|
42631
|
+
}, "reviewedRowsOver");
|
|
42632
|
+
var financeOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
42633
|
+
const { database, now: now2 } = context;
|
|
42634
|
+
const { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision } = reviewedRowsOver(context);
|
|
42635
|
+
const invoiceOf2 = /* @__PURE__ */ __name((row2) => {
|
|
42636
|
+
const currency = String(row2.currency);
|
|
42637
|
+
const scale = scaleOf(currency);
|
|
42638
|
+
const [total, paid] = [Number(row2.total), Number(row2.paid)];
|
|
42639
|
+
const counterparty = partyOf(row2.counterparty_type, row2.counterparty_id);
|
|
42640
|
+
const fields4 = {
|
|
42641
|
+
id: Number(row2.id),
|
|
42642
|
+
number: row2.number == null ? null : String(row2.number),
|
|
42643
|
+
direction: row2.direction,
|
|
42644
|
+
total,
|
|
42645
|
+
currency,
|
|
42646
|
+
counterpartyName: counterparty?.name ?? null,
|
|
42647
|
+
dueDate: row2.due_date == null ? null : String(row2.due_date),
|
|
42648
|
+
status: row2.status,
|
|
42649
|
+
review: row2.review
|
|
42650
|
+
};
|
|
42651
|
+
return {
|
|
42652
|
+
id: String(row2.id),
|
|
42653
|
+
ref: `invoice:${row2.id}`,
|
|
42654
|
+
title: invoiceTitle(fields4),
|
|
42655
|
+
direction: fields4.direction,
|
|
42656
|
+
number: fields4.number,
|
|
42657
|
+
issuer: partyOf(row2.issuer_type, row2.issuer_id),
|
|
42658
|
+
counterparty,
|
|
42659
|
+
currency,
|
|
42660
|
+
total: formatDecimal(total, scale),
|
|
42661
|
+
paid: formatDecimal(paid, scale),
|
|
42662
|
+
open: formatDecimal(Math.max(total - paid, 0), scale),
|
|
42663
|
+
issueDate: row2.issue_date == null ? null : String(row2.issue_date),
|
|
42664
|
+
dueDate: fields4.dueDate,
|
|
42665
|
+
status: fields4.status,
|
|
42666
|
+
...reviewedOf(row2, "invoice")
|
|
42667
|
+
};
|
|
42668
|
+
}, "invoiceOf");
|
|
42669
|
+
const paymentOf3 = /* @__PURE__ */ __name((row2) => {
|
|
42670
|
+
const currency = String(row2.currency);
|
|
42671
|
+
const scale = scaleOf(currency);
|
|
42672
|
+
const [amount, allocated] = [Number(row2.amount), Number(row2.allocated)];
|
|
42673
|
+
const direction = row2.direction;
|
|
42674
|
+
const payer = partyOf(row2.payer_type, row2.payer_id);
|
|
42675
|
+
const payee = partyOf(row2.payee_type, row2.payee_id);
|
|
42676
|
+
const date3 = String(row2.payment_date);
|
|
42677
|
+
return {
|
|
42678
|
+
id: String(row2.id),
|
|
42679
|
+
ref: `payment:${row2.id}`,
|
|
42680
|
+
title: paymentEntryTitle({
|
|
42681
|
+
direction,
|
|
42682
|
+
amount,
|
|
42683
|
+
currency,
|
|
42684
|
+
partyName: (direction === "in" ? payer : payee)?.name ?? null,
|
|
42685
|
+
date: date3,
|
|
42686
|
+
review: row2.review
|
|
42687
|
+
}),
|
|
42688
|
+
direction,
|
|
42689
|
+
payer,
|
|
42690
|
+
payee,
|
|
42691
|
+
amount: formatDecimal(amount, scale),
|
|
42692
|
+
currency,
|
|
42693
|
+
date: date3,
|
|
42694
|
+
reference: row2.reference == null ? null : String(row2.reference),
|
|
42695
|
+
allocated: formatDecimal(allocated, scale),
|
|
42696
|
+
unallocated: formatDecimal(amount - allocated, scale),
|
|
42697
|
+
...reviewedOf(row2, "payment")
|
|
42698
|
+
};
|
|
42699
|
+
}, "paymentOf");
|
|
42700
|
+
const allocationsWhere = /* @__PURE__ */ __name((column2, id2) => database.prepare(`SELECT a.*, p.currency FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.${column2} = ? ORDER BY a.id`).all(id2).map((row2) => ({
|
|
42701
|
+
payment: `payment:${row2.payment_id}`,
|
|
42702
|
+
invoice: `invoice:${row2.invoice_id}`,
|
|
42703
|
+
amount: formatDecimal(Number(row2.amount), scaleOf(String(row2.currency))),
|
|
42704
|
+
currency: String(row2.currency),
|
|
42705
|
+
createdAt: iso8(row2.created_at)
|
|
42706
|
+
})), "allocationsWhere");
|
|
42707
|
+
const rowOf2 = /* @__PURE__ */ __name((reference2, type) => {
|
|
42708
|
+
const thing = requiredThing(database, reference2.includes(":") ? reference2 : `${type}:${reference2}`, `the ${type}`);
|
|
42709
|
+
if (thing.type !== type)
|
|
42710
|
+
return refuse(`${reference2} is not an ${type}`, "finance.ref");
|
|
42711
|
+
return database.prepare(`${type === "invoice" ? INVOICES : PAYMENTS} WHERE ${type[0]}.id = ?`).get(thing.id);
|
|
42712
|
+
}, "rowOf");
|
|
42713
|
+
const invoiceDetail = /* @__PURE__ */ __name((reference2) => {
|
|
42714
|
+
const row2 = rowOf2(reference2, "invoice");
|
|
42715
|
+
const scale = scaleOf(String(row2.currency));
|
|
42716
|
+
const lines = database.prepare("SELECT * FROM invoice_lines WHERE invoice_id = ? ORDER BY position").all(Number(row2.id)).map((line) => ({
|
|
42717
|
+
position: Number(line.position),
|
|
42718
|
+
description: String(line.description),
|
|
42719
|
+
quantity: String(line.quantity),
|
|
42720
|
+
unitPrice: line.unit_price == null ? null : formatDecimal(Number(line.unit_price), scale),
|
|
42721
|
+
amount: formatDecimal(Number(line.amount), scale)
|
|
42722
|
+
}));
|
|
42723
|
+
return { ...invoiceOf2(row2), lines, allocations: allocationsWhere("invoice_id", Number(row2.id)) };
|
|
42724
|
+
}, "invoiceDetail");
|
|
42725
|
+
const paymentDetail = /* @__PURE__ */ __name((reference2) => {
|
|
42726
|
+
const row2 = rowOf2(reference2, "payment");
|
|
42727
|
+
return { ...paymentOf3(row2), allocations: allocationsWhere("payment_id", Number(row2.id)) };
|
|
42728
|
+
}, "paymentDetail");
|
|
42729
|
+
const settle = /* @__PURE__ */ __name((invoiceId) => {
|
|
42730
|
+
const row2 = database.prepare(`SELECT i.status, i.total, ${PAID} AS paid FROM invoices i WHERE i.id = ?`).get(invoiceId);
|
|
42731
|
+
if (!row2)
|
|
42732
|
+
return;
|
|
42733
|
+
const status = settledStatus(row2.status, Number(row2.total), Number(row2.paid));
|
|
42734
|
+
database.prepare("UPDATE invoices SET status = ?, updated_at = ? WHERE id = ? AND status <> ?").run(status, now2(), invoiceId, status);
|
|
42735
|
+
}, "settle");
|
|
42736
|
+
const allocateRow = /* @__PURE__ */ __name((payment, reference2, units, actor) => {
|
|
42737
|
+
const invoice = rowOf2(reference2, "invoice");
|
|
42738
|
+
const [paymentRef, invoiceRef] = [`payment:${payment.id}`, `invoice:${invoice.id}`];
|
|
42739
|
+
if (invoice.deleted_at != null || invoice.review === "rejected")
|
|
42740
|
+
refuse(`${invoiceRef} is ${invoice.review === "rejected" ? "rejected" : "deleted"}`, "finance.allocate");
|
|
42741
|
+
if (invoice.status === "draft" || invoice.status === "void")
|
|
42742
|
+
refuse(`${invoiceRef} is ${invoice.status}; only an issued invoice is paid`, "finance.allocate");
|
|
42743
|
+
const currency = String(payment.currency);
|
|
42744
|
+
if (invoice.currency !== currency)
|
|
42745
|
+
refuse(`${paymentRef} is in ${currency} and ${invoiceRef} in ${String(invoice.currency)}; the store converts nothing`, "finance.currency");
|
|
42746
|
+
const fromPayment = Number(database.prepare("SELECT coalesce(sum(amount), 0) AS n FROM payment_allocations WHERE payment_id = ?").get(Number(payment.id))?.n);
|
|
42747
|
+
if (fromPayment + units > Number(payment.amount))
|
|
42748
|
+
refuse(`${paymentRef} is ${moneyLabel(Number(payment.amount), currency)} and ${moneyLabel(fromPayment, currency)} of it is already allocated; ${moneyLabel(units, currency)} more is too much`, "finance.over-payment");
|
|
42749
|
+
const toInvoice = Number(database.prepare("SELECT coalesce(sum(a.amount), 0) AS n FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND ((p.review = 'confirmed' AND p.deleted_at IS NULL) OR a.payment_id = ?)").get(Number(invoice.id), Number(payment.id))?.n);
|
|
42750
|
+
if (toInvoice + units > Number(invoice.total))
|
|
42751
|
+
refuse(`${invoiceRef} totals ${moneyLabel(Number(invoice.total), currency)} and ${moneyLabel(toInvoice, currency)} is already allocated to it; ${moneyLabel(units, currency)} more is too much`, "finance.over-invoice");
|
|
42752
|
+
const at = now2();
|
|
42753
|
+
database.prepare("INSERT INTO payment_allocations (payment_id, invoice_id, amount, author_type, author_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (payment_id, invoice_id) DO UPDATE SET amount = amount + excluded.amount, updated_at = excluded.updated_at").run(Number(payment.id), Number(invoice.id), units, actor.type, actor.id, at, at);
|
|
42754
|
+
return Number(invoice.id);
|
|
42755
|
+
}, "allocateRow");
|
|
42756
|
+
const coveredElsewhere = /* @__PURE__ */ __name((paymentId) => {
|
|
42757
|
+
const over = database.prepare("SELECT a.invoice_id, a.amount, i.total, i.currency, (SELECT coalesce(sum(o.amount), 0) FROM payment_allocations o JOIN payments p ON p.id = o.payment_id WHERE o.invoice_id = a.invoice_id AND o.payment_id <> a.payment_id AND p.review = 'confirmed' AND p.deleted_at IS NULL) AS others FROM payment_allocations a JOIN invoices i ON i.id = a.invoice_id WHERE a.payment_id = ? AND a.amount + others > i.total LIMIT 1").get(paymentId);
|
|
42758
|
+
if (!over)
|
|
42759
|
+
return;
|
|
42760
|
+
const currency = String(over.currency);
|
|
42761
|
+
refuse(`invoice:${over.invoice_id} is already covered by other payments: ${moneyLabel(Number(over.others), currency)} of ${moneyLabel(Number(over.total), currency)}; payment:${paymentId} would add ${moneyLabel(Number(over.amount), currency)}, so it stays proposed`, "finance.over-invoice");
|
|
42762
|
+
}, "coveredElsewhere");
|
|
42763
|
+
const decide2 = /* @__PURE__ */ __name((reference2, by, reason, confirm) => {
|
|
42764
|
+
const thing = requiredThing(database, reference2, "the proposal");
|
|
42765
|
+
if (thing.type !== "invoice" && thing.type !== "payment")
|
|
42766
|
+
return refuse(`${reference2} is not an invoice: or payment:`, "finance.ref");
|
|
42767
|
+
const type = thing.type;
|
|
42768
|
+
const table = type === "invoice" ? "invoices" : "payments";
|
|
42769
|
+
const row2 = rowOf2(reference2, type);
|
|
42770
|
+
const ref3 = `${type}:${row2.id}`;
|
|
42771
|
+
assertMayDecide({ id: ref3, proposedBy: proposerOf(database, row2.author_type, row2.author_id), ownerOnly: true }, by, context.decisions);
|
|
42772
|
+
if (row2.review !== "proposed")
|
|
42773
|
+
refuse(`${ref3} is already ${String(row2.review)}`, "proposal.wrong-state");
|
|
42774
|
+
const id2 = Number(row2.id);
|
|
42775
|
+
write(database, () => {
|
|
42776
|
+
const at = now2();
|
|
42777
|
+
if (confirm && type === "payment")
|
|
42778
|
+
coveredElsewhere(id2);
|
|
42779
|
+
if (confirm) {
|
|
42780
|
+
const { actor } = authorActor(context, deciderAuthor(by));
|
|
42781
|
+
database.prepare(`UPDATE ${table} SET review = 'confirmed', confirmed_by_type = ?, confirmed_by_id = ?, updated_at = ? WHERE id = ?`).run(actor.type, actor.id, at, id2);
|
|
42782
|
+
} else
|
|
42783
|
+
database.prepare(`UPDATE ${table} SET review = 'rejected', updated_at = ? WHERE id = ?`).run(at, id2);
|
|
42784
|
+
keepDecision(table, id2, by, reason);
|
|
42785
|
+
const touched = type === "invoice" ? [id2] : database.prepare("SELECT invoice_id FROM payment_allocations WHERE payment_id = ?").all(id2).map((one2) => Number(one2.invoice_id));
|
|
42786
|
+
if (!confirm)
|
|
42787
|
+
database.prepare(`DELETE FROM payment_allocations WHERE ${type === "invoice" ? "invoice_id" : "payment_id"} = ?`).run(id2);
|
|
42788
|
+
for (const invoice of touched)
|
|
42789
|
+
settle(invoice);
|
|
42790
|
+
});
|
|
42791
|
+
return type === "invoice" ? invoiceDetail(ref3) : paymentDetail(ref3);
|
|
42792
|
+
}, "decide");
|
|
42793
|
+
const mayAllocate = /* @__PURE__ */ __name((row2, by) => {
|
|
42794
|
+
if (by === "owner")
|
|
42795
|
+
return;
|
|
42796
|
+
const own = row2.author_type === "bot" && row2.author_name != null && botKey(String(row2.author_name)) === botKey(by.bot);
|
|
42797
|
+
if (row2.review !== "proposed" || !own)
|
|
42798
|
+
refuse(`only the owner allocates payment:${row2.id}; a bot allocates only from a payment it proposed that is still proposed`, "finance.owner-only", "permission_error");
|
|
42799
|
+
}, "mayAllocate");
|
|
42800
|
+
const limitOf2 = /* @__PURE__ */ __name((limit) => Math.min(Math.max(limit ?? 100, 1), 500), "limitOf");
|
|
42801
|
+
return {
|
|
42802
|
+
addInvoice: /* @__PURE__ */ __name((input) => {
|
|
42803
|
+
const direction = oneOf4(input.direction, INVOICE_DIRECTIONS, "an invoice's direction");
|
|
42804
|
+
const currency = currencyOf(input.currency);
|
|
42805
|
+
if (!Array.isArray(input.lines) || input.lines.length === 0 || input.lines.length > MAX_LINES)
|
|
42806
|
+
refuse(`an invoice has 1\u2013${MAX_LINES} lines`, "finance.lines");
|
|
42807
|
+
const lines = input.lines.map((line, at) => {
|
|
42808
|
+
const what = `line ${at + 1}`;
|
|
42809
|
+
const quantity = quantityOf(line.quantity ?? "1");
|
|
42810
|
+
const unitPrice = line.unitPrice === void 0 ? null : minorUnits(line.unitPrice, currency, `${what}'s unit price`);
|
|
42811
|
+
const computed = unitPrice === null ? null : lineUnits(quantity.thousandths, unitPrice);
|
|
42812
|
+
const amount = line.amount === void 0 ? computed : minorUnits(line.amount, currency, `${what}'s amount`);
|
|
42813
|
+
if (amount === null)
|
|
42814
|
+
return refuse(`${what} takes a unit price, an amount or both`, "finance.lines");
|
|
42815
|
+
if (computed !== null && computed !== amount)
|
|
42816
|
+
refuse(`${what}: ${quantity.text} \xD7 ${moneyLabel(unitPrice, currency)} is ${moneyLabel(computed, currency)}, not ${moneyLabel(amount, currency)}`, "finance.line-amount");
|
|
42817
|
+
return {
|
|
42818
|
+
description: text3(line.description, `${what}'s description`, 500) ?? refuse(`${what} needs a description`, "finance.lines"),
|
|
42819
|
+
quantity: quantity.text,
|
|
42820
|
+
unitPrice: unitPrice ?? (quantity.thousandths === 1000n ? amount : null),
|
|
42821
|
+
amount
|
|
42822
|
+
};
|
|
42823
|
+
});
|
|
42824
|
+
const total = lines.reduce((sum, line) => sum + line.amount, 0);
|
|
42825
|
+
if (!Number.isSafeInteger(total))
|
|
42826
|
+
refuse("an invoice's total is too large", "finance.total");
|
|
42827
|
+
if (total <= 0)
|
|
42828
|
+
refuse("an invoice totals more than 0", "finance.total");
|
|
42829
|
+
if (input.total !== void 0) {
|
|
42830
|
+
const printed = minorUnits(input.total, currency, "an invoice's total");
|
|
42831
|
+
if (printed !== total)
|
|
42832
|
+
refuse(`the invoice's total ${moneyLabel(printed, currency)} is not the sum of its lines, ${moneyLabel(total, currency)}`, "finance.total");
|
|
42833
|
+
}
|
|
42834
|
+
const number3 = text3(input.number, "an invoice's number", 80);
|
|
42835
|
+
const issueDate = isoDate(input.issueDate, "an invoice's issue date");
|
|
42836
|
+
const dueDate = isoDate(input.dueDate, "an invoice's due date");
|
|
42837
|
+
const id2 = write(database, () => {
|
|
42838
|
+
const issuer = partyThing(input.issuer, "the issuer");
|
|
42839
|
+
const counterparty = partyThing(input.counterparty, "the counterparty") ?? refuse("an invoice names its counterparty, a person: or organization:", "finance.party");
|
|
42840
|
+
const by = written2(input);
|
|
42841
|
+
const at = now2();
|
|
42842
|
+
const made = Number(database.prepare("INSERT INTO invoices (direction, number, issuer_type, issuer_id, counterparty_type, counterparty_id, project_id, currency, total, issue_date, due_date, status, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(direction, number3, issuer?.type ?? null, issuer?.id ?? null, counterparty.type, counterparty.id, by.project, currency, total, issueDate, dueDate, input.draft ? "draft" : "issued", by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at)?.id);
|
|
42843
|
+
const insert = database.prepare("INSERT INTO invoice_lines (invoice_id, position, description, quantity, unit_price, amount, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
|
42844
|
+
for (const [index2, line] of lines.entries())
|
|
42845
|
+
insert.run(made, index2 + 1, line.description, line.quantity, line.unitPrice, line.amount, at, at);
|
|
42846
|
+
keepEvidence("invoice", made, by);
|
|
42847
|
+
return made;
|
|
42848
|
+
});
|
|
42849
|
+
return invoiceDetail(`invoice:${id2}`);
|
|
42850
|
+
}, "addInvoice"),
|
|
42851
|
+
invoice: /* @__PURE__ */ __name((reference2) => invoiceDetail(reference2), "invoice"),
|
|
42852
|
+
invoices: /* @__PURE__ */ __name((filter = {}) => {
|
|
42853
|
+
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
42854
|
+
const counterparty = partyThing(filter.counterparty, "the counterparty");
|
|
42855
|
+
const by = proposedBySql("i.author_type", "i.author_id", filter.proposedBy);
|
|
42856
|
+
const status = filter.status === void 0 ? null : oneOf4(filter.status, INVOICE_STATUSES, "a status");
|
|
42857
|
+
const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
|
|
42858
|
+
return database.prepare(`${INVOICES} WHERE i.deleted_at IS NULL AND (? IS NULL OR i.direction = ?) AND (? IS NULL OR i.status = ?) AND (? IS NULL OR i.review = ?) AND (? IS NULL OR i.project_id = ?) AND (? IS NULL OR (i.counterparty_type = ? AND i.counterparty_id = ?)) AND (? IS NULL OR i.number = ?) ${filter.open ? "AND i.status IN ('issued', 'partly_paid') " : ""}AND ${by.sql} ORDER BY i.created_at DESC, i.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, status, status, review, review, project2, project2, counterparty?.type ?? null, counterparty?.type ?? null, counterparty?.id ?? null, filter.number ?? null, filter.number ?? null, ...by.params, limitOf2(filter.limit)).map(invoiceOf2);
|
|
42859
|
+
}, "invoices"),
|
|
42860
|
+
issueInvoice: /* @__PURE__ */ __name((reference2, by) => {
|
|
42861
|
+
ownerOnly(by, "issues an invoice");
|
|
42862
|
+
const row2 = rowOf2(reference2, "invoice");
|
|
42863
|
+
if (row2.status !== "draft")
|
|
42864
|
+
refuse(`invoice:${row2.id} is ${String(row2.status)}, not a draft`, "finance.status");
|
|
42865
|
+
write(database, () => {
|
|
42866
|
+
database.prepare("UPDATE invoices SET status = 'issued', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
|
|
42867
|
+
settle(Number(row2.id));
|
|
42868
|
+
});
|
|
42869
|
+
return invoiceDetail(`invoice:${row2.id}`);
|
|
42870
|
+
}, "issueInvoice"),
|
|
42871
|
+
voidInvoice: /* @__PURE__ */ __name((reference2, by) => {
|
|
42872
|
+
ownerOnly(by, "voids an invoice");
|
|
42873
|
+
const row2 = rowOf2(reference2, "invoice");
|
|
42874
|
+
if (row2.status === "void")
|
|
42875
|
+
refuse(`invoice:${row2.id} is already void`, "finance.status");
|
|
42876
|
+
const allocated = database.prepare("SELECT 1 FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND p.review = 'confirmed' AND p.deleted_at IS NULL LIMIT 1").get(Number(row2.id));
|
|
42877
|
+
if (allocated)
|
|
42878
|
+
refuse(`payments are allocated to invoice:${row2.id}; a paid invoice is not voided`, "finance.status");
|
|
42879
|
+
write(database, () => {
|
|
42880
|
+
database.prepare("DELETE FROM payment_allocations WHERE invoice_id = ? AND payment_id IN (SELECT id FROM payments WHERE review = 'proposed')").run(Number(row2.id));
|
|
42881
|
+
database.prepare("UPDATE invoices SET status = 'void', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
|
|
42882
|
+
});
|
|
42883
|
+
return invoiceDetail(`invoice:${row2.id}`);
|
|
42884
|
+
}, "voidInvoice"),
|
|
42885
|
+
addPayment: /* @__PURE__ */ __name((input) => {
|
|
42886
|
+
const direction = oneOf4(input.direction, MONEY_DIRECTIONS, "a payment's direction");
|
|
42887
|
+
const currency = currencyOf(input.currency);
|
|
42888
|
+
const amount = minorUnits(input.amount, currency, "a payment's amount");
|
|
42889
|
+
if (amount <= 0)
|
|
42890
|
+
refuse("a payment's amount is more than 0", "money.amount");
|
|
42891
|
+
const date3 = isoDate(input.date, "a payment's date") ?? refuse("a payment has a date", "finance.field");
|
|
42892
|
+
const reference2 = text3(input.reference, "a payment's reference", 500);
|
|
42893
|
+
const allocations = (input.allocations ?? []).map(({ invoice, amount: share }) => ({
|
|
42894
|
+
invoice,
|
|
42895
|
+
units: minorUnits(share, currency, `the amount allocated to ${invoice}`)
|
|
42896
|
+
}));
|
|
42897
|
+
const id2 = write(database, () => {
|
|
42898
|
+
const payer = partyThing(input.payer, "the payer");
|
|
42899
|
+
const payee = partyThing(input.payee, "the payee");
|
|
42900
|
+
const by = written2(input);
|
|
42901
|
+
const at = now2();
|
|
42902
|
+
const made = database.prepare("INSERT INTO payments (direction, payer_type, payer_id, payee_type, payee_id, amount, currency, payment_date, reference, project_id, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *").get(direction, payer?.type ?? null, payer?.id ?? null, payee?.type ?? null, payee?.id ?? null, amount, currency, date3, reference2, by.project, by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at);
|
|
42903
|
+
keepEvidence("payment", Number(made.id), by);
|
|
42904
|
+
const touched = allocations.map(({ invoice, units }) => allocateRow(made, invoice, units, by.actor));
|
|
42905
|
+
for (const invoice of touched)
|
|
42906
|
+
settle(invoice);
|
|
42907
|
+
return Number(made.id);
|
|
42908
|
+
});
|
|
42909
|
+
return paymentDetail(`payment:${id2}`);
|
|
42910
|
+
}, "addPayment"),
|
|
42911
|
+
payment: /* @__PURE__ */ __name((reference2) => paymentDetail(reference2), "payment"),
|
|
42912
|
+
payments: /* @__PURE__ */ __name((filter = {}) => {
|
|
42913
|
+
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
42914
|
+
const party2 = partyThing(filter.party, "the party");
|
|
42915
|
+
const by = proposedBySql("p.author_type", "p.author_id", filter.proposedBy);
|
|
42916
|
+
const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
|
|
42917
|
+
return database.prepare(`${PAYMENTS} WHERE p.deleted_at IS NULL AND (? IS NULL OR p.direction = ?) AND (? IS NULL OR p.review = ?) AND (? IS NULL OR p.project_id = ?) AND (? IS NULL OR (p.payer_type = ? AND p.payer_id = ?) OR (p.payee_type = ? AND p.payee_id = ?)) AND ${by.sql} ORDER BY p.created_at DESC, p.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, review, review, project2, project2, party2?.type ?? null, party2?.type ?? null, party2?.id ?? null, party2?.type ?? null, party2?.id ?? null, ...by.params, limitOf2(filter.limit)).map(paymentOf3);
|
|
42918
|
+
}, "payments"),
|
|
42919
|
+
allocate: /* @__PURE__ */ __name(({ payment, invoice, amount, by }) => {
|
|
42920
|
+
const row2 = rowOf2(payment, "payment");
|
|
42921
|
+
const ref3 = `payment:${row2.id}`;
|
|
42922
|
+
mayAllocate(row2, by);
|
|
42923
|
+
if (row2.review === "rejected" || row2.deleted_at != null)
|
|
42924
|
+
refuse(`${ref3} is ${String(row2.review)}`, "finance.allocate");
|
|
42925
|
+
const currency = String(row2.currency);
|
|
42926
|
+
const units = minorUnits(amount, currency, "an allocation");
|
|
42927
|
+
if (units <= 0)
|
|
42928
|
+
refuse("an allocation is more than 0", "money.amount");
|
|
42929
|
+
const invoiceId = write(database, () => {
|
|
42930
|
+
const { actor } = authorActor(context, by);
|
|
42931
|
+
const made = allocateRow(row2, invoice, units, actor);
|
|
42932
|
+
settle(made);
|
|
42933
|
+
return made;
|
|
42934
|
+
});
|
|
42935
|
+
const found2 = allocationsWhere("payment_id", Number(row2.id)).find((one2) => one2.invoice === `invoice:${invoiceId}`);
|
|
42936
|
+
return found2;
|
|
42937
|
+
}, "allocate"),
|
|
42938
|
+
unallocate: /* @__PURE__ */ __name(({ payment, invoice, by }) => {
|
|
42939
|
+
const row2 = rowOf2(payment, "payment");
|
|
42940
|
+
const ref3 = `payment:${row2.id}`;
|
|
42941
|
+
mayAllocate(row2, by);
|
|
42942
|
+
if (row2.review === "rejected" || row2.deleted_at != null)
|
|
42943
|
+
refuse(`${ref3} is ${row2.deleted_at != null ? "deleted" : "rejected"}; only a proposed or confirmed payment's allocations are taken back`, "finance.unallocate");
|
|
42944
|
+
const target = rowOf2(invoice, "invoice");
|
|
42945
|
+
write(database, () => {
|
|
42946
|
+
const gone = database.prepare("DELETE FROM payment_allocations WHERE payment_id = ? AND invoice_id = ?").run(Number(row2.id), Number(target.id));
|
|
42947
|
+
if (gone.changes === 0)
|
|
42948
|
+
throw new CliError("not_found", `${ref3} is not allocated to invoice:${target.id}`, {
|
|
42949
|
+
reason: "finance.not-allocated"
|
|
42950
|
+
});
|
|
42951
|
+
settle(Number(target.id));
|
|
42952
|
+
});
|
|
42953
|
+
return paymentDetail(ref3);
|
|
42954
|
+
}, "unallocate"),
|
|
42955
|
+
confirm: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, true), "confirm"),
|
|
42956
|
+
reject: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, false), "reject"),
|
|
42957
|
+
openTotals: /* @__PURE__ */ __name((filter = {}) => {
|
|
42958
|
+
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
42959
|
+
const rows = database.prepare(`SELECT i.direction, i.currency, sum(i.total - ${PAID}) AS open, count(*) AS n FROM invoices i WHERE i.review = 'confirmed' AND i.deleted_at IS NULL AND i.status IN ('issued', 'partly_paid') AND (? IS NULL OR i.project_id = ?) GROUP BY i.direction, i.currency ORDER BY i.currency`).all(project2, project2);
|
|
42960
|
+
const totals = /* @__PURE__ */ __name((direction) => rows.filter((row2) => row2.direction === direction).map((row2) => ({ ...moneyOf(Number(row2.open), String(row2.currency)), invoices: Number(row2.n) })), "totals");
|
|
42961
|
+
return { receivable: totals("receivable"), payable: totals("payable") };
|
|
42962
|
+
}, "openTotals")
|
|
42963
|
+
};
|
|
42964
|
+
}, "financeOperationsOver");
|
|
42965
|
+
var financeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
42966
|
+
const operations = financeOperationsOver(context);
|
|
42967
|
+
return {
|
|
42968
|
+
addInvoice: /* @__PURE__ */ __name(async (input) => operations.addInvoice(input), "addInvoice"),
|
|
42969
|
+
invoice: /* @__PURE__ */ __name(async (reference2) => operations.invoice(reference2), "invoice"),
|
|
42970
|
+
invoices: /* @__PURE__ */ __name(async (filter) => operations.invoices(filter), "invoices"),
|
|
42971
|
+
issueInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.issueInvoice(reference2, by), "issueInvoice"),
|
|
42972
|
+
voidInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.voidInvoice(reference2, by), "voidInvoice"),
|
|
42973
|
+
addPayment: /* @__PURE__ */ __name(async (input) => operations.addPayment(input), "addPayment"),
|
|
42974
|
+
payment: /* @__PURE__ */ __name(async (reference2) => operations.payment(reference2), "payment"),
|
|
42975
|
+
payments: /* @__PURE__ */ __name(async (filter) => operations.payments(filter), "payments"),
|
|
42976
|
+
allocate: /* @__PURE__ */ __name(async (input) => operations.allocate(input), "allocate"),
|
|
42977
|
+
unallocate: /* @__PURE__ */ __name(async (input) => operations.unallocate(input), "unallocate"),
|
|
42978
|
+
confirm: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.confirm(reference2, by, reason), "confirm"),
|
|
42979
|
+
reject: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.reject(reference2, by, reason), "reject"),
|
|
42980
|
+
openTotals: /* @__PURE__ */ __name(async (filter) => operations.openTotals(filter), "openTotals")
|
|
42981
|
+
};
|
|
42982
|
+
}, "financeStoreOver");
|
|
42983
|
+
|
|
42984
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/deals.js
|
|
42985
|
+
var TABLES = { deal: "deals", lead: "leads" };
|
|
42986
|
+
var itemsSql = /* @__PURE__ */ __name((kind4) => `SELECT d.*, s.name AS stage_name, s.pipeline_id, p.name AS pipeline_name, b.name AS author_name, b.kind AS author_kind, a.provider AS account_provider, a.external_id AS account_external_id FROM ${TABLES[kind4]} d JOIN pipeline_stages s ON s.id = d.stage_id JOIN pipelines p ON p.id = s.pipeline_id LEFT JOIN bots b ON d.author_type = 'bot' AND b.id = d.author_id LEFT JOIN accounts a ON a.id = d.account_id`, "itemsSql");
|
|
42987
|
+
var MAX_STAGES = 30;
|
|
42988
|
+
var MAX_PEOPLE = 20;
|
|
42989
|
+
var iso9 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
42990
|
+
var jsonField = /* @__PURE__ */ __name((metadata3, key2) => {
|
|
42991
|
+
if (metadata3 == null)
|
|
42992
|
+
return null;
|
|
42993
|
+
try {
|
|
42994
|
+
const value = JSON.parse(String(metadata3))[key2];
|
|
42995
|
+
return typeof value === "string" ? value : null;
|
|
42996
|
+
} catch {
|
|
42997
|
+
return null;
|
|
42998
|
+
}
|
|
42999
|
+
}, "jsonField");
|
|
43000
|
+
var accountOf3 = /* @__PURE__ */ __name((provider, external) => provider == null ? null : { provider: String(provider), account: String(external) }, "accountOf");
|
|
43001
|
+
var dealOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
43002
|
+
const { database, now: now2 } = context;
|
|
43003
|
+
const { partyOf, partyThing } = reviewedRowsOver(context);
|
|
43004
|
+
const today = /* @__PURE__ */ __name(() => new Date(now2()).toISOString().slice(0, 10), "today");
|
|
43005
|
+
const peopleOf = /* @__PURE__ */ __name((kind4, id2) => database.prepare(`SELECT to_id, role FROM links WHERE from_type = ? AND from_id = ? AND kind = ${linkKind("related-to")} AND to_type = 'person' AND to_id IS NOT NULL ORDER BY id`).all(kind4, id2).map((row2) => ({ ...partyOf("person", row2.to_id), role: row2.role })), "peopleOf");
|
|
43006
|
+
const itemOf = /* @__PURE__ */ __name((kind4) => (row2) => {
|
|
43007
|
+
const currency = row2.currency == null ? null : String(row2.currency);
|
|
43008
|
+
const amount = row2.amount == null || currency === null ? null : Number(row2.amount);
|
|
43009
|
+
const fields4 = {
|
|
43010
|
+
id: Number(row2.id),
|
|
43011
|
+
title: String(row2.title),
|
|
43012
|
+
stage: String(row2.stage_name),
|
|
43013
|
+
amount,
|
|
43014
|
+
currency,
|
|
43015
|
+
status: row2.status
|
|
43016
|
+
};
|
|
43017
|
+
return {
|
|
43018
|
+
id: String(row2.id),
|
|
43019
|
+
ref: `${kind4}:${row2.id}`,
|
|
43020
|
+
kind: kind4,
|
|
43021
|
+
title: fields4.title,
|
|
43022
|
+
summary: dealLine(fields4),
|
|
43023
|
+
pipeline: `pipeline:${row2.pipeline_id}`,
|
|
43024
|
+
pipelineName: String(row2.pipeline_name),
|
|
43025
|
+
stage: fields4.stage,
|
|
43026
|
+
status: fields4.status,
|
|
43027
|
+
organization: partyOf(row2.organization_id == null ? null : "organization", row2.organization_id),
|
|
43028
|
+
currency,
|
|
43029
|
+
amount: amount === null || currency === null ? null : formatDecimal(amount, scaleOf(currency)),
|
|
43030
|
+
closeDate: row2.close_date == null ? null : String(row2.close_date),
|
|
43031
|
+
closedDate: row2.closed_date == null ? null : String(row2.closed_date),
|
|
43032
|
+
closedReason: jsonField(row2.metadata, "closed_reason"),
|
|
43033
|
+
rank: row2.rank == null ? null : Number(row2.rank),
|
|
43034
|
+
deal: row2.deal_id == null ? null : `deal:${row2.deal_id}`,
|
|
43035
|
+
account: accountOf3(row2.account_provider, row2.account_external_id),
|
|
43036
|
+
externalId: row2.external_id == null ? null : String(row2.external_id),
|
|
43037
|
+
people: peopleOf(kind4, fields4.id),
|
|
43038
|
+
author: authorOf(row2),
|
|
43039
|
+
model: row2.model == null ? null : String(row2.model),
|
|
43040
|
+
source: String(row2.source),
|
|
43041
|
+
reason: jsonField(row2.metadata, "reason"),
|
|
43042
|
+
evidence: evidenceOf(context, { type: kind4, id: fields4.id }),
|
|
43043
|
+
...projectOf(database, row2),
|
|
43044
|
+
createdAt: iso9(row2.created_at),
|
|
43045
|
+
updatedAt: iso9(row2.updated_at)
|
|
43046
|
+
};
|
|
43047
|
+
}, "itemOf");
|
|
43048
|
+
const rowOf2 = /* @__PURE__ */ __name((reference2) => {
|
|
43049
|
+
const thing = requiredThing(database, reference2.includes(":") ? reference2 : `deal:${reference2}`, "the deal");
|
|
43050
|
+
if (thing.type !== "deal" && thing.type !== "lead")
|
|
43051
|
+
return refuse(`${reference2} is not a deal or a lead`, "deal.ref");
|
|
43052
|
+
return { kind: thing.type, row: database.prepare(`${itemsSql(thing.type)} WHERE d.id = ?`).get(thing.id) };
|
|
43053
|
+
}, "rowOf");
|
|
43054
|
+
const read2 = /* @__PURE__ */ __name((reference2) => {
|
|
43055
|
+
const { kind: kind4, row: row2 } = rowOf2(reference2);
|
|
43056
|
+
return itemOf(kind4)(row2);
|
|
43057
|
+
}, "read");
|
|
43058
|
+
const kindOf4 = /* @__PURE__ */ __name((kind4) => kind4 === void 0 ? "deal" : oneOf4(kind4, DEAL_KINDS, "a kind"), "kindOf");
|
|
43059
|
+
const pipelineRows = /* @__PURE__ */ __name((kind4) => database.prepare("SELECT p.*, a.provider AS account_provider, a.external_id AS account_external_id FROM pipelines p LEFT JOIN accounts a ON a.id = p.account_id WHERE (? IS NULL OR p.kind = ?) ORDER BY p.name_folded, p.id").all(kind4 ?? null, kind4 ?? null), "pipelineRows");
|
|
43060
|
+
const label = /* @__PURE__ */ __name((row2) => `pipeline:${row2.id} (${row2.name}${row2.account_provider == null ? "" : `, ${row2.account_provider}:${row2.account_external_id}`})`, "label");
|
|
43061
|
+
const pipelineRow = /* @__PURE__ */ __name((reference2, kind4) => {
|
|
43062
|
+
const named3 = reference2.trim();
|
|
43063
|
+
if (/^pipeline:\d+$/.test(named3)) {
|
|
43064
|
+
const row2 = pipelineRows(kind4).find((one2) => `pipeline:${one2.id}` === named3);
|
|
43065
|
+
if (!row2)
|
|
43066
|
+
throw new CliError("not_found", `no ${kind4 ?? ""} pipeline ${named3}`, { reason: "pipeline.not-found" });
|
|
43067
|
+
return row2;
|
|
43068
|
+
}
|
|
43069
|
+
const rows = pipelineRows(kind4).filter((one2) => one2.name_folded === fold(named3));
|
|
43070
|
+
if (rows.length === 0)
|
|
43071
|
+
throw new CliError("not_found", `no ${kind4 === void 0 ? "" : `${kind4} `}pipeline named ${named3}`, {
|
|
43072
|
+
reason: "pipeline.not-found"
|
|
43073
|
+
});
|
|
43074
|
+
if (rows.length > 1)
|
|
43075
|
+
return refuse(`more than one pipeline is named ${named3}: ${rows.map(label).join(", ")}; name one by its reference`, "pipeline.ambiguous");
|
|
43076
|
+
return rows[0];
|
|
43077
|
+
}, "pipelineRow");
|
|
43078
|
+
const stagesOf = /* @__PURE__ */ __name((pipelineIds) => database.prepare(`SELECT s.*, (SELECT count(*) FROM deals d WHERE d.stage_id = s.id AND d.status = 'open' AND d.deleted_at IS NULL) + (SELECT count(*) FROM leads l WHERE l.stage_id = s.id AND l.status = 'open' AND l.deleted_at IS NULL) AS open FROM pipeline_stages s WHERE s.pipeline_id IN (${pipelineIds.map(() => "?").join(", ") || "NULL"}) ORDER BY s.pipeline_id, s.position, s.id`).all(...pipelineIds), "stagesOf");
|
|
43079
|
+
const pipelinesOf = /* @__PURE__ */ __name((rows) => {
|
|
43080
|
+
const stages = stagesOf(rows.map((row2) => Number(row2.id)));
|
|
43081
|
+
return rows.map((row2) => ({
|
|
43082
|
+
id: String(row2.id),
|
|
43083
|
+
ref: `pipeline:${row2.id}`,
|
|
43084
|
+
name: String(row2.name),
|
|
43085
|
+
kind: row2.kind,
|
|
43086
|
+
account: accountOf3(row2.account_provider, row2.account_external_id),
|
|
43087
|
+
externalId: row2.external_id == null ? null : String(row2.external_id),
|
|
43088
|
+
stages: stages.filter((stage) => stage.pipeline_id === row2.id).map((stage) => ({
|
|
43089
|
+
name: String(stage.name),
|
|
43090
|
+
position: Number(stage.position),
|
|
43091
|
+
outcome: stage.outcome,
|
|
43092
|
+
externalId: stage.external_id == null ? null : String(stage.external_id),
|
|
43093
|
+
open: Number(stage.open)
|
|
43094
|
+
})),
|
|
43095
|
+
createdAt: iso9(row2.created_at)
|
|
43096
|
+
}));
|
|
43097
|
+
}, "pipelinesOf");
|
|
43098
|
+
const stageRow = /* @__PURE__ */ __name((stage, kind4, pipeline) => {
|
|
43099
|
+
const rows = database.prepare("SELECT s.*, p.name AS pipeline_name FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.name_folded = ? AND p.kind = ? AND (? IS NULL OR p.id = ?) ORDER BY p.id").all(fold(stage.trim()), kind4, pipeline ?? null, pipeline ?? null);
|
|
43100
|
+
if (rows.length === 0)
|
|
43101
|
+
return refuse(`no stage named ${stage} in ${pipeline === void 0 ? `a ${kind4} pipeline` : "that pipeline"}`, "deal.stage");
|
|
43102
|
+
if (rows.length > 1)
|
|
43103
|
+
return refuse(`more than one pipeline has a stage named ${stage}: ${rows.map((row2) => `pipeline:${row2.pipeline_id} (${row2.pipeline_name})`).join(", ")}; name the pipeline`, "deal.stage");
|
|
43104
|
+
return rows[0];
|
|
43105
|
+
}, "stageRow");
|
|
43106
|
+
const firstStage = /* @__PURE__ */ __name((kind4, pipeline) => {
|
|
43107
|
+
const pipelines2 = pipeline === void 0 ? pipelineRows(kind4) : [{ id: pipeline }];
|
|
43108
|
+
if (pipelines2.length !== 1)
|
|
43109
|
+
return refuse(`name the stage: ${pipelines2.length === 0 ? `no ${kind4} pipeline is stored` : `more than one ${kind4} pipeline is stored`}`, "deal.stage");
|
|
43110
|
+
const row2 = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ? ORDER BY position, id LIMIT 1").get(Number(pipelines2[0]?.id));
|
|
43111
|
+
return row2 ?? refuse("the pipeline has no stages", "deal.stage");
|
|
43112
|
+
}, "firstStage");
|
|
43113
|
+
const funnelOf = /* @__PURE__ */ __name((pipeline, since) => {
|
|
43114
|
+
const kind4 = pipeline.kind;
|
|
43115
|
+
const cutoff = since === null ? null : Date.parse(`${since}T00:00:00Z`);
|
|
43116
|
+
const items = database.prepare(`SELECT d.id, d.status, d.stage_id FROM ${TABLES[kind4]} d JOIN pipeline_stages s ON s.id = d.stage_id WHERE s.pipeline_id = ? AND d.deleted_at IS NULL AND (? IS NULL OR d.created_at >= ?)`).all(Number(pipeline.id), cutoff, cutoff);
|
|
43117
|
+
const stages = database.prepare("SELECT id, position, outcome FROM pipeline_stages WHERE pipeline_id = ? ORDER BY position, id").all(Number(pipeline.id));
|
|
43118
|
+
const order = new Map(stages.map((stage, at) => [Number(stage.id), at]));
|
|
43119
|
+
const lostStage = new Set(stages.filter((stage) => stage.outcome === "lost").map((stage) => Number(stage.id)));
|
|
43120
|
+
const entered = /* @__PURE__ */ new Map();
|
|
43121
|
+
for (const change of database.prepare("SELECT item_id, to_stage_id FROM pipeline_stage_changes WHERE item_type = ? AND pipeline_id = ?").all(kind4, Number(pipeline.id))) {
|
|
43122
|
+
const list2 = entered.get(Number(change.item_id)) ?? [];
|
|
43123
|
+
list2.push(Number(change.to_stage_id));
|
|
43124
|
+
entered.set(Number(change.item_id), list2);
|
|
43125
|
+
}
|
|
43126
|
+
const furthest = items.map((item) => {
|
|
43127
|
+
if (item.status === "won")
|
|
43128
|
+
return Number.POSITIVE_INFINITY;
|
|
43129
|
+
const reached = [...entered.get(Number(item.id)) ?? [], Number(item.stage_id)].filter((stage) => !lostStage.has(stage)).map((stage) => order.get(stage) ?? -1);
|
|
43130
|
+
return Math.max(-1, ...reached);
|
|
43131
|
+
});
|
|
43132
|
+
const lost = items.filter((item) => item.status === "lost").length;
|
|
43133
|
+
const reachedAt = /* @__PURE__ */ __name((at) => lostStage.has(Number(stages[at]?.id)) ? lost : furthest.filter((far) => far >= at).length, "reachedAt");
|
|
43134
|
+
const funnel = pipeline.stages.map((stage, at) => {
|
|
43135
|
+
const reached = reachedAt(at);
|
|
43136
|
+
const next = stages.findIndex((one2, after2) => after2 > at && !lostStage.has(Number(one2.id)));
|
|
43137
|
+
const conversion = lostStage.has(Number(stages[at]?.id)) || next === -1 || reached === 0 ? null : Math.round(reachedAt(next) / reached * 1e3) / 1e3;
|
|
43138
|
+
return { ...stage, reached, conversion };
|
|
43139
|
+
});
|
|
43140
|
+
const won = items.filter((item) => item.status === "won").length;
|
|
43141
|
+
return {
|
|
43142
|
+
...pipeline,
|
|
43143
|
+
stages: funnel,
|
|
43144
|
+
totals: {
|
|
43145
|
+
items: items.length,
|
|
43146
|
+
open: items.length - won - lost,
|
|
43147
|
+
won,
|
|
43148
|
+
lost,
|
|
43149
|
+
winRate: won + lost === 0 ? null : Math.round(won / (won + lost) * 1e3) / 1e3
|
|
43150
|
+
},
|
|
43151
|
+
since
|
|
43152
|
+
};
|
|
43153
|
+
}, "funnelOf");
|
|
43154
|
+
const setStage = /* @__PURE__ */ __name((kind4, id2, stage, status, date3) => {
|
|
43155
|
+
database.prepare(`UPDATE ${TABLES[kind4]} SET stage_id = ?, status = ?, closed_date = ?, updated_at = ? WHERE id = ?`).run(Number(stage.id), status, status === "open" ? null : date3, now2(), id2);
|
|
43156
|
+
}, "setStage");
|
|
43157
|
+
const notDeleted = /* @__PURE__ */ __name((row2, kind4, what) => {
|
|
43158
|
+
if (row2.deleted_at != null)
|
|
43159
|
+
refuse(`${kind4}:${row2.id} is deleted; it no longer ${what}`, "deal.closed");
|
|
43160
|
+
}, "notDeleted");
|
|
43161
|
+
return {
|
|
43162
|
+
addPipeline: /* @__PURE__ */ __name(({ name, kind: kind4, stages, by }) => {
|
|
43163
|
+
const pipelineKind = kindOf4(kind4);
|
|
43164
|
+
const named3 = text3(name, "a pipeline's name", 80) ?? refuse("a pipeline needs a name", "pipeline.field");
|
|
43165
|
+
if (!Array.isArray(stages) || stages.length === 0 || stages.length > MAX_STAGES)
|
|
43166
|
+
refuse(`a pipeline has 1\u2013${MAX_STAGES} stages`, "pipeline.field");
|
|
43167
|
+
const kept = stages.map((stage) => {
|
|
43168
|
+
const one2 = typeof stage === "string" ? { name: stage } : stage;
|
|
43169
|
+
return {
|
|
43170
|
+
name: text3(one2.name, "a stage's name", 80),
|
|
43171
|
+
outcome: one2.outcome === void 0 ? "open" : oneOf4(one2.outcome, STAGE_OUTCOMES, "a stage's outcome")
|
|
43172
|
+
};
|
|
43173
|
+
});
|
|
43174
|
+
if (new Set(kept.map((stage) => fold(stage.name))).size !== kept.length)
|
|
43175
|
+
refuse("each stage is named once", "pipeline.field");
|
|
43176
|
+
authorActor(context, by);
|
|
43177
|
+
const id2 = write(database, () => {
|
|
43178
|
+
if (database.prepare("SELECT 1 FROM pipelines WHERE name_folded = ? AND kind = ? AND account_id IS NULL").get(fold(named3), pipelineKind))
|
|
43179
|
+
refuse(`a ${pipelineKind} pipeline named ${named3} is already stored`, "pipeline.duplicate");
|
|
43180
|
+
const at = now2();
|
|
43181
|
+
const made = Number(database.prepare("INSERT INTO pipelines (kind, name, name_folded, created_at, updated_at) VALUES (?, ?, ?, ?, ?) RETURNING id").get(pipelineKind, named3, fold(named3), at, at)?.id);
|
|
43182
|
+
const insert = database.prepare("INSERT INTO pipeline_stages (pipeline_id, name, name_folded, position, outcome, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
43183
|
+
kept.forEach((stage, index2) => {
|
|
43184
|
+
insert.run(made, stage.name, fold(stage.name), index2 + 1, stage.outcome, at, at);
|
|
43185
|
+
});
|
|
43186
|
+
return made;
|
|
43187
|
+
});
|
|
43188
|
+
return pipelinesOf(pipelineRows(pipelineKind).filter((row2) => Number(row2.id) === id2))[0];
|
|
43189
|
+
}, "addPipeline"),
|
|
43190
|
+
pipelines: /* @__PURE__ */ __name((filter = {}) => pipelinesOf(pipelineRows(filter.kind === void 0 ? void 0 : kindOf4(filter.kind))), "pipelines"),
|
|
43191
|
+
pipeline: /* @__PURE__ */ __name((reference2, options = {}) => {
|
|
43192
|
+
const kind4 = options.kind === void 0 ? void 0 : kindOf4(options.kind);
|
|
43193
|
+
const since = isoDate(options.since, "the first day counted");
|
|
43194
|
+
return funnelOf(pipelinesOf([pipelineRow(reference2, kind4)])[0], since);
|
|
43195
|
+
}, "pipeline"),
|
|
43196
|
+
add: /* @__PURE__ */ __name((input) => {
|
|
43197
|
+
const kind4 = kindOf4(input.kind);
|
|
43198
|
+
const title = text3(input.title, `a ${kind4}'s title`, 200) ?? refuse(`a ${kind4} needs a title`, "deal.field");
|
|
43199
|
+
if (input.amount === void 0 !== (input.currency === void 0))
|
|
43200
|
+
refuse("an amount and its currency come together", "deal.field");
|
|
43201
|
+
const currency = input.currency === void 0 ? null : currencyOf(input.currency);
|
|
43202
|
+
const amount = currency === null ? null : minorUnits(input.amount, currency, "an amount");
|
|
43203
|
+
if (amount !== null && amount < 0)
|
|
43204
|
+
refuse("an amount is 0 or more", "money.amount");
|
|
43205
|
+
const closeDate = isoDate(input.closeDate, "an expected close day");
|
|
43206
|
+
const people2 = input.people ?? [];
|
|
43207
|
+
if (people2.length > MAX_PEOPLE)
|
|
43208
|
+
refuse(`at most ${MAX_PEOPLE} people`, "deal.field");
|
|
43209
|
+
const owner = input.by === "owner";
|
|
43210
|
+
const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
|
|
43211
|
+
const reason = text3(input.reason, "a reason", 2e3);
|
|
43212
|
+
const evidence = input.evidence ?? [];
|
|
43213
|
+
if (!Array.isArray(evidence) || evidence.length > 8)
|
|
43214
|
+
refuse("evidence is at most 8 references", "deal.field");
|
|
43215
|
+
const id2 = write(database, () => {
|
|
43216
|
+
const pipeline = input.pipeline === void 0 ? void 0 : Number(pipelineRow(input.pipeline, kind4).id);
|
|
43217
|
+
const stageText = text3(input.stage, "a stage's name", 80);
|
|
43218
|
+
const stage = stageText === null ? kind4 === "lead" ? firstStage(kind4, pipeline) : refuse("a deal starts in a stage", "deal.field") : stageRow(stageText, kind4, pipeline);
|
|
43219
|
+
const status = stage.outcome ?? "open";
|
|
43220
|
+
const organization2 = partyThing(input.organization, "the organization");
|
|
43221
|
+
if (organization2 !== void 0 && organization2.type !== "organization")
|
|
43222
|
+
refuse(`the organization is an organization: reference, not ${input.organization}`, "deal.field");
|
|
43223
|
+
const persons2 = people2.map(({ person: person2, role }) => {
|
|
43224
|
+
const thing = requiredThing(database, person2, "the person");
|
|
43225
|
+
if (thing.type !== "person")
|
|
43226
|
+
return refuse(`${person2} is not a person`, "deal.field");
|
|
43227
|
+
return { id: thing.id, role: oneOf4(role, DEAL_ROLES, "a person's role") };
|
|
43228
|
+
});
|
|
43229
|
+
const { actor, model } = authorActor(context, input.by);
|
|
43230
|
+
const at = now2();
|
|
43231
|
+
const made = Number(database.prepare(`INSERT INTO ${TABLES[kind4]} (title, organization_id, project_id, stage_id, status, currency, amount, close_date, closed_date, author_type, author_id, model, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id`).get(title, organization2?.id ?? null, input.project === void 0 ? null : projectId(database, input.project), Number(stage.id), status, currency, amount, closeDate, status === "open" ? null : today(), actor.type, actor.id, model, source2, reason === null ? null : JSON.stringify({ reason }), at, at)?.id);
|
|
43232
|
+
const link3 = database.prepare(`INSERT INTO links (from_type, from_id, to_type, to_id, kind, role, source, confirmed, created_at, author, updated_at) VALUES (?, ?, 'person', ?, ${linkKind("related-to")}, ?, ?, 1, ?, ?, ?)`);
|
|
43233
|
+
for (const person2 of persons2)
|
|
43234
|
+
link3.run(kind4, made, person2.id, person2.role, owner ? "owner" : "suggested", at, owner ? "owner" : "agent", at);
|
|
43235
|
+
if (evidence.length)
|
|
43236
|
+
linkEvidence(context, { type: kind4, id: made }, evidence, owner ? "owner" : "agent");
|
|
43237
|
+
return made;
|
|
43238
|
+
});
|
|
43239
|
+
return read2(`${kind4}:${id2}`);
|
|
43240
|
+
}, "add"),
|
|
43241
|
+
get: /* @__PURE__ */ __name((reference2) => read2(reference2), "get"),
|
|
43242
|
+
list: /* @__PURE__ */ __name((filter = {}) => {
|
|
43243
|
+
const kind4 = kindOf4(filter.kind);
|
|
43244
|
+
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43245
|
+
const organization2 = partyThing(filter.organization, "the organization");
|
|
43246
|
+
const by = proposedBySql("d.author_type", "d.author_id", filter.proposedBy);
|
|
43247
|
+
const status = filter.status === void 0 ? null : oneOf4(filter.status, DEAL_STATUSES, "a status");
|
|
43248
|
+
const stage = filter.stage === void 0 ? null : fold(filter.stage.trim());
|
|
43249
|
+
const pipeline = filter.pipeline === void 0 ? null : Number(pipelineRow(filter.pipeline, kind4).id);
|
|
43250
|
+
const limit = Math.min(Math.max(filter.limit ?? 100, 1), 500);
|
|
43251
|
+
return database.prepare(`${itemsSql(kind4)} WHERE d.deleted_at IS NULL AND (? IS NULL OR d.status = ?) AND (? IS NULL OR d.project_id = ?) AND (? IS NULL OR s.name_folded = ?) AND (? IS NULL OR p.id = ?) AND (? IS NULL OR d.organization_id = ?) AND ${by.sql} ORDER BY d.created_at DESC, d.id DESC LIMIT ?`).all(status, status, project2, project2, stage, stage, pipeline, pipeline, organization2?.id ?? null, organization2?.id ?? null, ...by.params, limit).map(itemOf(kind4));
|
|
43252
|
+
}, "list"),
|
|
43253
|
+
move: /* @__PURE__ */ __name((reference2, { stage, by }) => {
|
|
43254
|
+
authorActor(context, by);
|
|
43255
|
+
const { kind: kind4, row: row2 } = rowOf2(reference2);
|
|
43256
|
+
notDeleted(row2, kind4, "moves");
|
|
43257
|
+
const next = stageRow(text3(stage, "a stage's name", 80) ?? "", kind4, Number(row2.pipeline_id));
|
|
43258
|
+
write(database, () => setStage(kind4, Number(row2.id), next, next.outcome, today()));
|
|
43259
|
+
return read2(`${kind4}:${row2.id}`);
|
|
43260
|
+
}, "move"),
|
|
43261
|
+
close: /* @__PURE__ */ __name((reference2, { status, date: date3, reason, by }) => {
|
|
43262
|
+
authorActor(context, by);
|
|
43263
|
+
const outcome = oneOf4(status, ["won", "lost"], "a closed status");
|
|
43264
|
+
const day = isoDate(date3, "the day it closed") ?? today();
|
|
43265
|
+
const why = text3(reason, "why it closed", 2e3);
|
|
43266
|
+
const { kind: kind4, row: row2 } = rowOf2(reference2);
|
|
43267
|
+
notDeleted(row2, kind4, "closes");
|
|
43268
|
+
const stage = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ? AND outcome = ? ORDER BY position, id LIMIT 1").get(Number(row2.pipeline_id), outcome) ?? { id: row2.stage_id };
|
|
43269
|
+
write(database, () => {
|
|
43270
|
+
setStage(kind4, Number(row2.id), stage, outcome, day);
|
|
43271
|
+
if (why !== null)
|
|
43272
|
+
database.prepare(`UPDATE ${TABLES[kind4]} SET metadata = json_set(coalesce(metadata, '{}'), '$.closed_reason', ?) WHERE id = ?`).run(why, Number(row2.id));
|
|
43273
|
+
});
|
|
43274
|
+
return read2(`${kind4}:${row2.id}`);
|
|
43275
|
+
}, "close")
|
|
43276
|
+
};
|
|
43277
|
+
}, "dealOperationsOver");
|
|
43278
|
+
var dealsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
43279
|
+
const operations = dealOperationsOver(context);
|
|
43280
|
+
return {
|
|
43281
|
+
addPipeline: /* @__PURE__ */ __name(async (input) => operations.addPipeline(input), "addPipeline"),
|
|
43282
|
+
pipelines: /* @__PURE__ */ __name(async (filter) => operations.pipelines(filter), "pipelines"),
|
|
43283
|
+
pipeline: /* @__PURE__ */ __name(async (reference2, options) => operations.pipeline(reference2, options), "pipeline"),
|
|
43284
|
+
add: /* @__PURE__ */ __name(async (input) => operations.add(input), "add"),
|
|
43285
|
+
get: /* @__PURE__ */ __name(async (reference2) => operations.get(reference2), "get"),
|
|
43286
|
+
list: /* @__PURE__ */ __name(async (filter) => operations.list(filter), "list"),
|
|
43287
|
+
move: /* @__PURE__ */ __name(async (reference2, input) => operations.move(reference2, input), "move"),
|
|
43288
|
+
close: /* @__PURE__ */ __name(async (reference2, input) => operations.close(reference2, input), "close")
|
|
43289
|
+
};
|
|
43290
|
+
}, "dealsStoreOver");
|
|
43291
|
+
|
|
43292
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
|
|
42387
43293
|
var NOTE_FIELDS = [
|
|
42388
43294
|
"text",
|
|
42389
43295
|
"exact",
|
|
@@ -42813,7 +43719,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
|
|
|
42813
43719
|
};
|
|
42814
43720
|
}, "noteSearchOver");
|
|
42815
43721
|
|
|
42816
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
43722
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
|
|
42817
43723
|
var EVENT_FIELDS = ["text", "exact", "body", "title", "date", "in"];
|
|
42818
43724
|
var inEventAccounts = /* @__PURE__ */ __name((event) => searchableCopy(event, "c.account_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))"), "inEventAccounts");
|
|
42819
43725
|
var EVENT_CORPUS = {
|
|
@@ -42945,468 +43851,7 @@ var eventSearchOver = /* @__PURE__ */ __name((context) => {
|
|
|
42945
43851
|
};
|
|
42946
43852
|
}, "eventSearchOver");
|
|
42947
43853
|
|
|
42948
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
42949
|
-
var refuse = /* @__PURE__ */ __name((message2, reason, code = "validation_error") => {
|
|
42950
|
-
throw new CliError(code, message2, { reason });
|
|
42951
|
-
}, "refuse");
|
|
42952
|
-
var oneOf4 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
42953
|
-
if (typeof value !== "string" || !allowed.includes(value))
|
|
42954
|
-
return refuse(`${what} is one of ${allowed.join(", ")}`, "finance.field");
|
|
42955
|
-
return value;
|
|
42956
|
-
}, "oneOf");
|
|
42957
|
-
var text3 = /* @__PURE__ */ __name((value, what, limit) => {
|
|
42958
|
-
if (value === void 0 || value === null)
|
|
42959
|
-
return null;
|
|
42960
|
-
if (typeof value !== "string" || !value.trim() || value.length > limit || value.includes("\0"))
|
|
42961
|
-
return refuse(`${what} takes 1\u2013${limit} characters`, "finance.field");
|
|
42962
|
-
return value.trim();
|
|
42963
|
-
}, "text");
|
|
42964
|
-
var isoDate = /* @__PURE__ */ __name((value, what) => {
|
|
42965
|
-
if (value === void 0 || value === null)
|
|
42966
|
-
return null;
|
|
42967
|
-
const date3 = typeof value === "string" ? value.trim() : "";
|
|
42968
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(date3) || (/* @__PURE__ */ new Date(`${date3}T00:00:00Z`)).toISOString().slice(0, 10) !== date3)
|
|
42969
|
-
return refuse(`${what} is a date such as 2026-11-15`, "finance.field");
|
|
42970
|
-
return date3;
|
|
42971
|
-
}, "isoDate");
|
|
42972
|
-
var iso8 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
42973
|
-
var evidenceList = /* @__PURE__ */ __name((value) => {
|
|
42974
|
-
if (value === void 0)
|
|
42975
|
-
return [];
|
|
42976
|
-
if (!Array.isArray(value) || value.length > 8 || value.some((one2) => typeof one2 !== "string" || !one2.trim()))
|
|
42977
|
-
return refuse("evidence is a list of at most 8 references", "finance.field");
|
|
42978
|
-
return [...new Set(value.map((one2) => one2.trim()))];
|
|
42979
|
-
}, "evidenceList");
|
|
42980
|
-
var MAX_LINES = 500;
|
|
42981
|
-
var reasonOf = /* @__PURE__ */ __name((metadata3) => {
|
|
42982
|
-
if (metadata3 == null)
|
|
42983
|
-
return null;
|
|
42984
|
-
try {
|
|
42985
|
-
const { reason } = JSON.parse(String(metadata3));
|
|
42986
|
-
return typeof reason === "string" ? reason : null;
|
|
42987
|
-
} catch {
|
|
42988
|
-
return null;
|
|
42989
|
-
}
|
|
42990
|
-
}, "reasonOf");
|
|
42991
|
-
var PAID = "(SELECT coalesce(sum(a.amount), 0) FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = i.id AND p.review = 'confirmed' AND p.deleted_at IS NULL)";
|
|
42992
|
-
var INVOICES = `SELECT i.*, ${PAID} AS paid, b.name AS author_name, b.kind AS author_kind FROM invoices i LEFT JOIN bots b ON i.author_type = 'bot' AND b.id = i.author_id`;
|
|
42993
|
-
var PAYMENTS = "SELECT p.*, (SELECT coalesce(sum(amount), 0) FROM payment_allocations WHERE payment_id = p.id) AS allocated, b.name AS author_name, b.kind AS author_kind FROM payments p LEFT JOIN bots b ON p.author_type = 'bot' AND b.id = p.author_id";
|
|
42994
|
-
var reviewedRowsOver = /* @__PURE__ */ __name((context) => {
|
|
42995
|
-
const { database } = context;
|
|
42996
|
-
const partyOf = /* @__PURE__ */ __name((type, id2) => {
|
|
42997
|
-
if (type == null)
|
|
42998
|
-
return null;
|
|
42999
|
-
const { subject: subject2, subjectName: subjectName2, subjectIsOwner } = subjectOf(database, { subject_type: type, subject_id: id2 });
|
|
43000
|
-
return subject2 === null ? null : { ref: subject2, name: subjectName2, owner: subjectIsOwner };
|
|
43001
|
-
}, "partyOf");
|
|
43002
|
-
const partyThing = /* @__PURE__ */ __name((reference2, what) => {
|
|
43003
|
-
if (reference2 === void 0)
|
|
43004
|
-
return void 0;
|
|
43005
|
-
const thing = requiredThing(database, reference2, what);
|
|
43006
|
-
if (thing.type !== "person" && thing.type !== "organization")
|
|
43007
|
-
return refuse(`${what} is a person: or organization: reference, not ${reference2}`, "finance.party");
|
|
43008
|
-
return thing;
|
|
43009
|
-
}, "partyThing");
|
|
43010
|
-
const reviewedOf = /* @__PURE__ */ __name((row2, type) => ({
|
|
43011
|
-
review: row2.review,
|
|
43012
|
-
author: authorOf(row2),
|
|
43013
|
-
model: row2.model == null ? null : String(row2.model),
|
|
43014
|
-
confirmedBy: row2.confirmed_by_type == null ? null : { type: row2.confirmed_by_type, id: String(row2.confirmed_by_id) },
|
|
43015
|
-
source: String(row2.source),
|
|
43016
|
-
reason: reasonOf(row2.metadata),
|
|
43017
|
-
evidence: evidenceOf(context, { type, id: Number(row2.id) }),
|
|
43018
|
-
...projectOf(database, row2),
|
|
43019
|
-
createdAt: iso8(row2.created_at),
|
|
43020
|
-
updatedAt: iso8(row2.updated_at)
|
|
43021
|
-
}), "reviewedOf");
|
|
43022
|
-
const written2 = /* @__PURE__ */ __name((input) => {
|
|
43023
|
-
const owner = input.by === "owner";
|
|
43024
|
-
const { actor, model } = authorActor(context, input.by);
|
|
43025
|
-
const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
|
|
43026
|
-
const reason = owner ? null : text3(input.reason, "a reason", 2e3);
|
|
43027
|
-
return {
|
|
43028
|
-
owner,
|
|
43029
|
-
actor,
|
|
43030
|
-
model,
|
|
43031
|
-
source: source2,
|
|
43032
|
-
review: owner ? "confirmed" : "proposed",
|
|
43033
|
-
confirmedType: owner ? actor.type : null,
|
|
43034
|
-
confirmedId: owner ? actor.id : null,
|
|
43035
|
-
metadata: reason === null ? null : JSON.stringify({ reason }),
|
|
43036
|
-
project: input.project === void 0 ? null : projectId(database, input.project),
|
|
43037
|
-
evidence: evidenceList(input.evidence)
|
|
43038
|
-
};
|
|
43039
|
-
}, "written");
|
|
43040
|
-
const keepEvidence = /* @__PURE__ */ __name((type, id2, by) => {
|
|
43041
|
-
if (by.evidence.length)
|
|
43042
|
-
linkEvidence(context, { type, id: id2 }, by.evidence, by.owner ? "owner" : "agent");
|
|
43043
|
-
}, "keepEvidence");
|
|
43044
|
-
const ownerOnly = /* @__PURE__ */ __name((by, what) => {
|
|
43045
|
-
if (by !== "owner")
|
|
43046
|
-
refuse(`only the owner ${what}`, "finance.owner-only", "permission_error");
|
|
43047
|
-
}, "ownerOnly");
|
|
43048
|
-
const keepDecision = /* @__PURE__ */ __name((table, id2, by, reason) => {
|
|
43049
|
-
const why = [by === "owner" ? void 0 : by.reason.trim(), reason?.trim() || void 0].filter(Boolean).join(": ");
|
|
43050
|
-
if (by === "owner" && !why)
|
|
43051
|
-
return;
|
|
43052
|
-
const decision = by === "owner" ? { by: "owner", reason: why } : { by: "agent", bot: by.bot, reason: why };
|
|
43053
|
-
database.prepare(`UPDATE ${table} SET metadata = json_set(coalesce(metadata, '{}'), '$.decision', json(?)) WHERE id = ?`).run(JSON.stringify(decision), id2);
|
|
43054
|
-
}, "keepDecision");
|
|
43055
|
-
return { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision };
|
|
43056
|
-
}, "reviewedRowsOver");
|
|
43057
|
-
var financeOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
43058
|
-
const { database, now: now2 } = context;
|
|
43059
|
-
const { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision } = reviewedRowsOver(context);
|
|
43060
|
-
const invoiceOf2 = /* @__PURE__ */ __name((row2) => {
|
|
43061
|
-
const currency = String(row2.currency);
|
|
43062
|
-
const scale = scaleOf(currency);
|
|
43063
|
-
const [total, paid] = [Number(row2.total), Number(row2.paid)];
|
|
43064
|
-
const counterparty = partyOf(row2.counterparty_type, row2.counterparty_id);
|
|
43065
|
-
const fields4 = {
|
|
43066
|
-
id: Number(row2.id),
|
|
43067
|
-
number: row2.number == null ? null : String(row2.number),
|
|
43068
|
-
direction: row2.direction,
|
|
43069
|
-
total,
|
|
43070
|
-
currency,
|
|
43071
|
-
counterpartyName: counterparty?.name ?? null,
|
|
43072
|
-
dueDate: row2.due_date == null ? null : String(row2.due_date),
|
|
43073
|
-
status: row2.status,
|
|
43074
|
-
review: row2.review
|
|
43075
|
-
};
|
|
43076
|
-
return {
|
|
43077
|
-
id: String(row2.id),
|
|
43078
|
-
ref: `invoice:${row2.id}`,
|
|
43079
|
-
title: invoiceTitle(fields4),
|
|
43080
|
-
direction: fields4.direction,
|
|
43081
|
-
number: fields4.number,
|
|
43082
|
-
issuer: partyOf(row2.issuer_type, row2.issuer_id),
|
|
43083
|
-
counterparty,
|
|
43084
|
-
currency,
|
|
43085
|
-
total: formatDecimal(total, scale),
|
|
43086
|
-
paid: formatDecimal(paid, scale),
|
|
43087
|
-
open: formatDecimal(Math.max(total - paid, 0), scale),
|
|
43088
|
-
issueDate: row2.issue_date == null ? null : String(row2.issue_date),
|
|
43089
|
-
dueDate: fields4.dueDate,
|
|
43090
|
-
status: fields4.status,
|
|
43091
|
-
...reviewedOf(row2, "invoice")
|
|
43092
|
-
};
|
|
43093
|
-
}, "invoiceOf");
|
|
43094
|
-
const paymentOf3 = /* @__PURE__ */ __name((row2) => {
|
|
43095
|
-
const currency = String(row2.currency);
|
|
43096
|
-
const scale = scaleOf(currency);
|
|
43097
|
-
const [amount, allocated] = [Number(row2.amount), Number(row2.allocated)];
|
|
43098
|
-
const direction = row2.direction;
|
|
43099
|
-
const payer = partyOf(row2.payer_type, row2.payer_id);
|
|
43100
|
-
const payee = partyOf(row2.payee_type, row2.payee_id);
|
|
43101
|
-
const date3 = String(row2.payment_date);
|
|
43102
|
-
return {
|
|
43103
|
-
id: String(row2.id),
|
|
43104
|
-
ref: `payment:${row2.id}`,
|
|
43105
|
-
title: paymentEntryTitle({
|
|
43106
|
-
direction,
|
|
43107
|
-
amount,
|
|
43108
|
-
currency,
|
|
43109
|
-
partyName: (direction === "in" ? payer : payee)?.name ?? null,
|
|
43110
|
-
date: date3,
|
|
43111
|
-
review: row2.review
|
|
43112
|
-
}),
|
|
43113
|
-
direction,
|
|
43114
|
-
payer,
|
|
43115
|
-
payee,
|
|
43116
|
-
amount: formatDecimal(amount, scale),
|
|
43117
|
-
currency,
|
|
43118
|
-
date: date3,
|
|
43119
|
-
reference: row2.reference == null ? null : String(row2.reference),
|
|
43120
|
-
allocated: formatDecimal(allocated, scale),
|
|
43121
|
-
unallocated: formatDecimal(amount - allocated, scale),
|
|
43122
|
-
...reviewedOf(row2, "payment")
|
|
43123
|
-
};
|
|
43124
|
-
}, "paymentOf");
|
|
43125
|
-
const allocationsWhere = /* @__PURE__ */ __name((column2, id2) => database.prepare(`SELECT a.*, p.currency FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.${column2} = ? ORDER BY a.id`).all(id2).map((row2) => ({
|
|
43126
|
-
payment: `payment:${row2.payment_id}`,
|
|
43127
|
-
invoice: `invoice:${row2.invoice_id}`,
|
|
43128
|
-
amount: formatDecimal(Number(row2.amount), scaleOf(String(row2.currency))),
|
|
43129
|
-
currency: String(row2.currency),
|
|
43130
|
-
createdAt: iso8(row2.created_at)
|
|
43131
|
-
})), "allocationsWhere");
|
|
43132
|
-
const rowOf2 = /* @__PURE__ */ __name((reference2, type) => {
|
|
43133
|
-
const thing = requiredThing(database, reference2.includes(":") ? reference2 : `${type}:${reference2}`, `the ${type}`);
|
|
43134
|
-
if (thing.type !== type)
|
|
43135
|
-
return refuse(`${reference2} is not an ${type}`, "finance.ref");
|
|
43136
|
-
return database.prepare(`${type === "invoice" ? INVOICES : PAYMENTS} WHERE ${type[0]}.id = ?`).get(thing.id);
|
|
43137
|
-
}, "rowOf");
|
|
43138
|
-
const invoiceDetail = /* @__PURE__ */ __name((reference2) => {
|
|
43139
|
-
const row2 = rowOf2(reference2, "invoice");
|
|
43140
|
-
const scale = scaleOf(String(row2.currency));
|
|
43141
|
-
const lines = database.prepare("SELECT * FROM invoice_lines WHERE invoice_id = ? ORDER BY position").all(Number(row2.id)).map((line) => ({
|
|
43142
|
-
position: Number(line.position),
|
|
43143
|
-
description: String(line.description),
|
|
43144
|
-
quantity: String(line.quantity),
|
|
43145
|
-
unitPrice: line.unit_price == null ? null : formatDecimal(Number(line.unit_price), scale),
|
|
43146
|
-
amount: formatDecimal(Number(line.amount), scale)
|
|
43147
|
-
}));
|
|
43148
|
-
return { ...invoiceOf2(row2), lines, allocations: allocationsWhere("invoice_id", Number(row2.id)) };
|
|
43149
|
-
}, "invoiceDetail");
|
|
43150
|
-
const paymentDetail = /* @__PURE__ */ __name((reference2) => {
|
|
43151
|
-
const row2 = rowOf2(reference2, "payment");
|
|
43152
|
-
return { ...paymentOf3(row2), allocations: allocationsWhere("payment_id", Number(row2.id)) };
|
|
43153
|
-
}, "paymentDetail");
|
|
43154
|
-
const settle = /* @__PURE__ */ __name((invoiceId) => {
|
|
43155
|
-
const row2 = database.prepare(`SELECT i.status, i.total, ${PAID} AS paid FROM invoices i WHERE i.id = ?`).get(invoiceId);
|
|
43156
|
-
if (!row2)
|
|
43157
|
-
return;
|
|
43158
|
-
const status = settledStatus(row2.status, Number(row2.total), Number(row2.paid));
|
|
43159
|
-
database.prepare("UPDATE invoices SET status = ?, updated_at = ? WHERE id = ? AND status <> ?").run(status, now2(), invoiceId, status);
|
|
43160
|
-
}, "settle");
|
|
43161
|
-
const allocateRow = /* @__PURE__ */ __name((payment, reference2, units, actor) => {
|
|
43162
|
-
const invoice = rowOf2(reference2, "invoice");
|
|
43163
|
-
const [paymentRef, invoiceRef] = [`payment:${payment.id}`, `invoice:${invoice.id}`];
|
|
43164
|
-
if (invoice.deleted_at != null || invoice.review === "rejected")
|
|
43165
|
-
refuse(`${invoiceRef} is ${invoice.review === "rejected" ? "rejected" : "deleted"}`, "finance.allocate");
|
|
43166
|
-
if (invoice.status === "draft" || invoice.status === "void")
|
|
43167
|
-
refuse(`${invoiceRef} is ${invoice.status}; only an issued invoice is paid`, "finance.allocate");
|
|
43168
|
-
const currency = String(payment.currency);
|
|
43169
|
-
if (invoice.currency !== currency)
|
|
43170
|
-
refuse(`${paymentRef} is in ${currency} and ${invoiceRef} in ${String(invoice.currency)}; the store converts nothing`, "finance.currency");
|
|
43171
|
-
const fromPayment = Number(database.prepare("SELECT coalesce(sum(amount), 0) AS n FROM payment_allocations WHERE payment_id = ?").get(Number(payment.id))?.n);
|
|
43172
|
-
if (fromPayment + units > Number(payment.amount))
|
|
43173
|
-
refuse(`${paymentRef} is ${moneyLabel(Number(payment.amount), currency)} and ${moneyLabel(fromPayment, currency)} of it is already allocated; ${moneyLabel(units, currency)} more is too much`, "finance.over-payment");
|
|
43174
|
-
const toInvoice = Number(database.prepare("SELECT coalesce(sum(a.amount), 0) AS n FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND ((p.review = 'confirmed' AND p.deleted_at IS NULL) OR a.payment_id = ?)").get(Number(invoice.id), Number(payment.id))?.n);
|
|
43175
|
-
if (toInvoice + units > Number(invoice.total))
|
|
43176
|
-
refuse(`${invoiceRef} totals ${moneyLabel(Number(invoice.total), currency)} and ${moneyLabel(toInvoice, currency)} is already allocated to it; ${moneyLabel(units, currency)} more is too much`, "finance.over-invoice");
|
|
43177
|
-
const at = now2();
|
|
43178
|
-
database.prepare("INSERT INTO payment_allocations (payment_id, invoice_id, amount, author_type, author_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (payment_id, invoice_id) DO UPDATE SET amount = amount + excluded.amount, updated_at = excluded.updated_at").run(Number(payment.id), Number(invoice.id), units, actor.type, actor.id, at, at);
|
|
43179
|
-
return Number(invoice.id);
|
|
43180
|
-
}, "allocateRow");
|
|
43181
|
-
const coveredElsewhere = /* @__PURE__ */ __name((paymentId) => {
|
|
43182
|
-
const over = database.prepare("SELECT a.invoice_id, a.amount, i.total, i.currency, (SELECT coalesce(sum(o.amount), 0) FROM payment_allocations o JOIN payments p ON p.id = o.payment_id WHERE o.invoice_id = a.invoice_id AND o.payment_id <> a.payment_id AND p.review = 'confirmed' AND p.deleted_at IS NULL) AS others FROM payment_allocations a JOIN invoices i ON i.id = a.invoice_id WHERE a.payment_id = ? AND a.amount + others > i.total LIMIT 1").get(paymentId);
|
|
43183
|
-
if (!over)
|
|
43184
|
-
return;
|
|
43185
|
-
const currency = String(over.currency);
|
|
43186
|
-
refuse(`invoice:${over.invoice_id} is already covered by other payments: ${moneyLabel(Number(over.others), currency)} of ${moneyLabel(Number(over.total), currency)}; payment:${paymentId} would add ${moneyLabel(Number(over.amount), currency)}, so it stays proposed`, "finance.over-invoice");
|
|
43187
|
-
}, "coveredElsewhere");
|
|
43188
|
-
const decide2 = /* @__PURE__ */ __name((reference2, by, reason, confirm) => {
|
|
43189
|
-
const thing = requiredThing(database, reference2, "the proposal");
|
|
43190
|
-
if (thing.type !== "invoice" && thing.type !== "payment")
|
|
43191
|
-
return refuse(`${reference2} is not an invoice: or payment:`, "finance.ref");
|
|
43192
|
-
const type = thing.type;
|
|
43193
|
-
const table = type === "invoice" ? "invoices" : "payments";
|
|
43194
|
-
const row2 = rowOf2(reference2, type);
|
|
43195
|
-
const ref3 = `${type}:${row2.id}`;
|
|
43196
|
-
assertMayDecide({ id: ref3, proposedBy: proposerOf(database, row2.author_type, row2.author_id), ownerOnly: true }, by, context.decisions);
|
|
43197
|
-
if (row2.review !== "proposed")
|
|
43198
|
-
refuse(`${ref3} is already ${String(row2.review)}`, "proposal.wrong-state");
|
|
43199
|
-
const id2 = Number(row2.id);
|
|
43200
|
-
write(database, () => {
|
|
43201
|
-
const at = now2();
|
|
43202
|
-
if (confirm && type === "payment")
|
|
43203
|
-
coveredElsewhere(id2);
|
|
43204
|
-
if (confirm) {
|
|
43205
|
-
const { actor } = authorActor(context, deciderAuthor(by));
|
|
43206
|
-
database.prepare(`UPDATE ${table} SET review = 'confirmed', confirmed_by_type = ?, confirmed_by_id = ?, updated_at = ? WHERE id = ?`).run(actor.type, actor.id, at, id2);
|
|
43207
|
-
} else
|
|
43208
|
-
database.prepare(`UPDATE ${table} SET review = 'rejected', updated_at = ? WHERE id = ?`).run(at, id2);
|
|
43209
|
-
keepDecision(table, id2, by, reason);
|
|
43210
|
-
const touched = type === "invoice" ? [id2] : database.prepare("SELECT invoice_id FROM payment_allocations WHERE payment_id = ?").all(id2).map((one2) => Number(one2.invoice_id));
|
|
43211
|
-
if (!confirm)
|
|
43212
|
-
database.prepare(`DELETE FROM payment_allocations WHERE ${type === "invoice" ? "invoice_id" : "payment_id"} = ?`).run(id2);
|
|
43213
|
-
for (const invoice of touched)
|
|
43214
|
-
settle(invoice);
|
|
43215
|
-
});
|
|
43216
|
-
return type === "invoice" ? invoiceDetail(ref3) : paymentDetail(ref3);
|
|
43217
|
-
}, "decide");
|
|
43218
|
-
const mayAllocate = /* @__PURE__ */ __name((row2, by) => {
|
|
43219
|
-
if (by === "owner")
|
|
43220
|
-
return;
|
|
43221
|
-
const own = row2.author_type === "bot" && row2.author_name != null && botKey(String(row2.author_name)) === botKey(by.bot);
|
|
43222
|
-
if (row2.review !== "proposed" || !own)
|
|
43223
|
-
refuse(`only the owner allocates payment:${row2.id}; a bot allocates only from a payment it proposed that is still proposed`, "finance.owner-only", "permission_error");
|
|
43224
|
-
}, "mayAllocate");
|
|
43225
|
-
const limitOf2 = /* @__PURE__ */ __name((limit) => Math.min(Math.max(limit ?? 100, 1), 500), "limitOf");
|
|
43226
|
-
return {
|
|
43227
|
-
addInvoice: /* @__PURE__ */ __name((input) => {
|
|
43228
|
-
const direction = oneOf4(input.direction, INVOICE_DIRECTIONS, "an invoice's direction");
|
|
43229
|
-
const currency = currencyOf(input.currency);
|
|
43230
|
-
if (!Array.isArray(input.lines) || input.lines.length === 0 || input.lines.length > MAX_LINES)
|
|
43231
|
-
refuse(`an invoice has 1\u2013${MAX_LINES} lines`, "finance.lines");
|
|
43232
|
-
const lines = input.lines.map((line, at) => {
|
|
43233
|
-
const what = `line ${at + 1}`;
|
|
43234
|
-
const quantity = quantityOf(line.quantity ?? "1");
|
|
43235
|
-
const unitPrice = line.unitPrice === void 0 ? null : minorUnits(line.unitPrice, currency, `${what}'s unit price`);
|
|
43236
|
-
const computed = unitPrice === null ? null : lineUnits(quantity.thousandths, unitPrice);
|
|
43237
|
-
const amount = line.amount === void 0 ? computed : minorUnits(line.amount, currency, `${what}'s amount`);
|
|
43238
|
-
if (amount === null)
|
|
43239
|
-
return refuse(`${what} takes a unit price, an amount or both`, "finance.lines");
|
|
43240
|
-
if (computed !== null && computed !== amount)
|
|
43241
|
-
refuse(`${what}: ${quantity.text} \xD7 ${moneyLabel(unitPrice, currency)} is ${moneyLabel(computed, currency)}, not ${moneyLabel(amount, currency)}`, "finance.line-amount");
|
|
43242
|
-
return {
|
|
43243
|
-
description: text3(line.description, `${what}'s description`, 500) ?? refuse(`${what} needs a description`, "finance.lines"),
|
|
43244
|
-
quantity: quantity.text,
|
|
43245
|
-
unitPrice: unitPrice ?? (quantity.thousandths === 1000n ? amount : null),
|
|
43246
|
-
amount
|
|
43247
|
-
};
|
|
43248
|
-
});
|
|
43249
|
-
const total = lines.reduce((sum, line) => sum + line.amount, 0);
|
|
43250
|
-
if (!Number.isSafeInteger(total))
|
|
43251
|
-
refuse("an invoice's total is too large", "finance.total");
|
|
43252
|
-
if (total <= 0)
|
|
43253
|
-
refuse("an invoice totals more than 0", "finance.total");
|
|
43254
|
-
if (input.total !== void 0) {
|
|
43255
|
-
const printed = minorUnits(input.total, currency, "an invoice's total");
|
|
43256
|
-
if (printed !== total)
|
|
43257
|
-
refuse(`the invoice's total ${moneyLabel(printed, currency)} is not the sum of its lines, ${moneyLabel(total, currency)}`, "finance.total");
|
|
43258
|
-
}
|
|
43259
|
-
const number3 = text3(input.number, "an invoice's number", 80);
|
|
43260
|
-
const issueDate = isoDate(input.issueDate, "an invoice's issue date");
|
|
43261
|
-
const dueDate = isoDate(input.dueDate, "an invoice's due date");
|
|
43262
|
-
const id2 = write(database, () => {
|
|
43263
|
-
const issuer = partyThing(input.issuer, "the issuer");
|
|
43264
|
-
const counterparty = partyThing(input.counterparty, "the counterparty") ?? refuse("an invoice names its counterparty, a person: or organization:", "finance.party");
|
|
43265
|
-
const by = written2(input);
|
|
43266
|
-
const at = now2();
|
|
43267
|
-
const made = Number(database.prepare("INSERT INTO invoices (direction, number, issuer_type, issuer_id, counterparty_type, counterparty_id, project_id, currency, total, issue_date, due_date, status, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(direction, number3, issuer?.type ?? null, issuer?.id ?? null, counterparty.type, counterparty.id, by.project, currency, total, issueDate, dueDate, input.draft ? "draft" : "issued", by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at)?.id);
|
|
43268
|
-
const insert = database.prepare("INSERT INTO invoice_lines (invoice_id, position, description, quantity, unit_price, amount, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
|
43269
|
-
for (const [index2, line] of lines.entries())
|
|
43270
|
-
insert.run(made, index2 + 1, line.description, line.quantity, line.unitPrice, line.amount, at, at);
|
|
43271
|
-
keepEvidence("invoice", made, by);
|
|
43272
|
-
return made;
|
|
43273
|
-
});
|
|
43274
|
-
return invoiceDetail(`invoice:${id2}`);
|
|
43275
|
-
}, "addInvoice"),
|
|
43276
|
-
invoice: /* @__PURE__ */ __name((reference2) => invoiceDetail(reference2), "invoice"),
|
|
43277
|
-
invoices: /* @__PURE__ */ __name((filter = {}) => {
|
|
43278
|
-
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43279
|
-
const counterparty = partyThing(filter.counterparty, "the counterparty");
|
|
43280
|
-
const by = proposedBySql("i.author_type", "i.author_id", filter.proposedBy);
|
|
43281
|
-
const status = filter.status === void 0 ? null : oneOf4(filter.status, INVOICE_STATUSES, "a status");
|
|
43282
|
-
const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
|
|
43283
|
-
return database.prepare(`${INVOICES} WHERE i.deleted_at IS NULL AND (? IS NULL OR i.direction = ?) AND (? IS NULL OR i.status = ?) AND (? IS NULL OR i.review = ?) AND (? IS NULL OR i.project_id = ?) AND (? IS NULL OR (i.counterparty_type = ? AND i.counterparty_id = ?)) AND (? IS NULL OR i.number = ?) ${filter.open ? "AND i.status IN ('issued', 'partly_paid') " : ""}AND ${by.sql} ORDER BY i.created_at DESC, i.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, status, status, review, review, project2, project2, counterparty?.type ?? null, counterparty?.type ?? null, counterparty?.id ?? null, filter.number ?? null, filter.number ?? null, ...by.params, limitOf2(filter.limit)).map(invoiceOf2);
|
|
43284
|
-
}, "invoices"),
|
|
43285
|
-
issueInvoice: /* @__PURE__ */ __name((reference2, by) => {
|
|
43286
|
-
ownerOnly(by, "issues an invoice");
|
|
43287
|
-
const row2 = rowOf2(reference2, "invoice");
|
|
43288
|
-
if (row2.status !== "draft")
|
|
43289
|
-
refuse(`invoice:${row2.id} is ${String(row2.status)}, not a draft`, "finance.status");
|
|
43290
|
-
write(database, () => {
|
|
43291
|
-
database.prepare("UPDATE invoices SET status = 'issued', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
|
|
43292
|
-
settle(Number(row2.id));
|
|
43293
|
-
});
|
|
43294
|
-
return invoiceDetail(`invoice:${row2.id}`);
|
|
43295
|
-
}, "issueInvoice"),
|
|
43296
|
-
voidInvoice: /* @__PURE__ */ __name((reference2, by) => {
|
|
43297
|
-
ownerOnly(by, "voids an invoice");
|
|
43298
|
-
const row2 = rowOf2(reference2, "invoice");
|
|
43299
|
-
if (row2.status === "void")
|
|
43300
|
-
refuse(`invoice:${row2.id} is already void`, "finance.status");
|
|
43301
|
-
const allocated = database.prepare("SELECT 1 FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND p.review = 'confirmed' AND p.deleted_at IS NULL LIMIT 1").get(Number(row2.id));
|
|
43302
|
-
if (allocated)
|
|
43303
|
-
refuse(`payments are allocated to invoice:${row2.id}; a paid invoice is not voided`, "finance.status");
|
|
43304
|
-
write(database, () => {
|
|
43305
|
-
database.prepare("DELETE FROM payment_allocations WHERE invoice_id = ? AND payment_id IN (SELECT id FROM payments WHERE review = 'proposed')").run(Number(row2.id));
|
|
43306
|
-
database.prepare("UPDATE invoices SET status = 'void', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
|
|
43307
|
-
});
|
|
43308
|
-
return invoiceDetail(`invoice:${row2.id}`);
|
|
43309
|
-
}, "voidInvoice"),
|
|
43310
|
-
addPayment: /* @__PURE__ */ __name((input) => {
|
|
43311
|
-
const direction = oneOf4(input.direction, MONEY_DIRECTIONS, "a payment's direction");
|
|
43312
|
-
const currency = currencyOf(input.currency);
|
|
43313
|
-
const amount = minorUnits(input.amount, currency, "a payment's amount");
|
|
43314
|
-
if (amount <= 0)
|
|
43315
|
-
refuse("a payment's amount is more than 0", "money.amount");
|
|
43316
|
-
const date3 = isoDate(input.date, "a payment's date") ?? refuse("a payment has a date", "finance.field");
|
|
43317
|
-
const reference2 = text3(input.reference, "a payment's reference", 500);
|
|
43318
|
-
const allocations = (input.allocations ?? []).map(({ invoice, amount: share }) => ({
|
|
43319
|
-
invoice,
|
|
43320
|
-
units: minorUnits(share, currency, `the amount allocated to ${invoice}`)
|
|
43321
|
-
}));
|
|
43322
|
-
const id2 = write(database, () => {
|
|
43323
|
-
const payer = partyThing(input.payer, "the payer");
|
|
43324
|
-
const payee = partyThing(input.payee, "the payee");
|
|
43325
|
-
const by = written2(input);
|
|
43326
|
-
const at = now2();
|
|
43327
|
-
const made = database.prepare("INSERT INTO payments (direction, payer_type, payer_id, payee_type, payee_id, amount, currency, payment_date, reference, project_id, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *").get(direction, payer?.type ?? null, payer?.id ?? null, payee?.type ?? null, payee?.id ?? null, amount, currency, date3, reference2, by.project, by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at);
|
|
43328
|
-
keepEvidence("payment", Number(made.id), by);
|
|
43329
|
-
const touched = allocations.map(({ invoice, units }) => allocateRow(made, invoice, units, by.actor));
|
|
43330
|
-
for (const invoice of touched)
|
|
43331
|
-
settle(invoice);
|
|
43332
|
-
return Number(made.id);
|
|
43333
|
-
});
|
|
43334
|
-
return paymentDetail(`payment:${id2}`);
|
|
43335
|
-
}, "addPayment"),
|
|
43336
|
-
payment: /* @__PURE__ */ __name((reference2) => paymentDetail(reference2), "payment"),
|
|
43337
|
-
payments: /* @__PURE__ */ __name((filter = {}) => {
|
|
43338
|
-
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43339
|
-
const party2 = partyThing(filter.party, "the party");
|
|
43340
|
-
const by = proposedBySql("p.author_type", "p.author_id", filter.proposedBy);
|
|
43341
|
-
const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
|
|
43342
|
-
return database.prepare(`${PAYMENTS} WHERE p.deleted_at IS NULL AND (? IS NULL OR p.direction = ?) AND (? IS NULL OR p.review = ?) AND (? IS NULL OR p.project_id = ?) AND (? IS NULL OR (p.payer_type = ? AND p.payer_id = ?) OR (p.payee_type = ? AND p.payee_id = ?)) AND ${by.sql} ORDER BY p.created_at DESC, p.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, review, review, project2, project2, party2?.type ?? null, party2?.type ?? null, party2?.id ?? null, party2?.type ?? null, party2?.id ?? null, ...by.params, limitOf2(filter.limit)).map(paymentOf3);
|
|
43343
|
-
}, "payments"),
|
|
43344
|
-
allocate: /* @__PURE__ */ __name(({ payment, invoice, amount, by }) => {
|
|
43345
|
-
const row2 = rowOf2(payment, "payment");
|
|
43346
|
-
const ref3 = `payment:${row2.id}`;
|
|
43347
|
-
mayAllocate(row2, by);
|
|
43348
|
-
if (row2.review === "rejected" || row2.deleted_at != null)
|
|
43349
|
-
refuse(`${ref3} is ${String(row2.review)}`, "finance.allocate");
|
|
43350
|
-
const currency = String(row2.currency);
|
|
43351
|
-
const units = minorUnits(amount, currency, "an allocation");
|
|
43352
|
-
if (units <= 0)
|
|
43353
|
-
refuse("an allocation is more than 0", "money.amount");
|
|
43354
|
-
const invoiceId = write(database, () => {
|
|
43355
|
-
const { actor } = authorActor(context, by);
|
|
43356
|
-
const made = allocateRow(row2, invoice, units, actor);
|
|
43357
|
-
settle(made);
|
|
43358
|
-
return made;
|
|
43359
|
-
});
|
|
43360
|
-
const found2 = allocationsWhere("payment_id", Number(row2.id)).find((one2) => one2.invoice === `invoice:${invoiceId}`);
|
|
43361
|
-
return found2;
|
|
43362
|
-
}, "allocate"),
|
|
43363
|
-
unallocate: /* @__PURE__ */ __name(({ payment, invoice, by }) => {
|
|
43364
|
-
const row2 = rowOf2(payment, "payment");
|
|
43365
|
-
const ref3 = `payment:${row2.id}`;
|
|
43366
|
-
mayAllocate(row2, by);
|
|
43367
|
-
if (row2.review === "rejected" || row2.deleted_at != null)
|
|
43368
|
-
refuse(`${ref3} is ${row2.deleted_at != null ? "deleted" : "rejected"}; only a proposed or confirmed payment's allocations are taken back`, "finance.unallocate");
|
|
43369
|
-
const target = rowOf2(invoice, "invoice");
|
|
43370
|
-
write(database, () => {
|
|
43371
|
-
const gone = database.prepare("DELETE FROM payment_allocations WHERE payment_id = ? AND invoice_id = ?").run(Number(row2.id), Number(target.id));
|
|
43372
|
-
if (gone.changes === 0)
|
|
43373
|
-
throw new CliError("not_found", `${ref3} is not allocated to invoice:${target.id}`, {
|
|
43374
|
-
reason: "finance.not-allocated"
|
|
43375
|
-
});
|
|
43376
|
-
settle(Number(target.id));
|
|
43377
|
-
});
|
|
43378
|
-
return paymentDetail(ref3);
|
|
43379
|
-
}, "unallocate"),
|
|
43380
|
-
confirm: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, true), "confirm"),
|
|
43381
|
-
reject: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, false), "reject"),
|
|
43382
|
-
openTotals: /* @__PURE__ */ __name((filter = {}) => {
|
|
43383
|
-
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43384
|
-
const rows = database.prepare(`SELECT i.direction, i.currency, sum(i.total - ${PAID}) AS open, count(*) AS n FROM invoices i WHERE i.review = 'confirmed' AND i.deleted_at IS NULL AND i.status IN ('issued', 'partly_paid') AND (? IS NULL OR i.project_id = ?) GROUP BY i.direction, i.currency ORDER BY i.currency`).all(project2, project2);
|
|
43385
|
-
const totals = /* @__PURE__ */ __name((direction) => rows.filter((row2) => row2.direction === direction).map((row2) => ({ ...moneyOf(Number(row2.open), String(row2.currency)), invoices: Number(row2.n) })), "totals");
|
|
43386
|
-
return { receivable: totals("receivable"), payable: totals("payable") };
|
|
43387
|
-
}, "openTotals")
|
|
43388
|
-
};
|
|
43389
|
-
}, "financeOperationsOver");
|
|
43390
|
-
var financeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
43391
|
-
const operations = financeOperationsOver(context);
|
|
43392
|
-
return {
|
|
43393
|
-
addInvoice: /* @__PURE__ */ __name(async (input) => operations.addInvoice(input), "addInvoice"),
|
|
43394
|
-
invoice: /* @__PURE__ */ __name(async (reference2) => operations.invoice(reference2), "invoice"),
|
|
43395
|
-
invoices: /* @__PURE__ */ __name(async (filter) => operations.invoices(filter), "invoices"),
|
|
43396
|
-
issueInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.issueInvoice(reference2, by), "issueInvoice"),
|
|
43397
|
-
voidInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.voidInvoice(reference2, by), "voidInvoice"),
|
|
43398
|
-
addPayment: /* @__PURE__ */ __name(async (input) => operations.addPayment(input), "addPayment"),
|
|
43399
|
-
payment: /* @__PURE__ */ __name(async (reference2) => operations.payment(reference2), "payment"),
|
|
43400
|
-
payments: /* @__PURE__ */ __name(async (filter) => operations.payments(filter), "payments"),
|
|
43401
|
-
allocate: /* @__PURE__ */ __name(async (input) => operations.allocate(input), "allocate"),
|
|
43402
|
-
unallocate: /* @__PURE__ */ __name(async (input) => operations.unallocate(input), "unallocate"),
|
|
43403
|
-
confirm: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.confirm(reference2, by, reason), "confirm"),
|
|
43404
|
-
reject: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.reject(reference2, by, reason), "reject"),
|
|
43405
|
-
openTotals: /* @__PURE__ */ __name(async (filter) => operations.openTotals(filter), "openTotals")
|
|
43406
|
-
};
|
|
43407
|
-
}, "financeStoreOver");
|
|
43408
|
-
|
|
43409
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.583.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_8615f98b0983d1fbb51a11cdebd6e805/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-entries.js
|
|
43854
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-entries.js
|
|
43410
43855
|
var refuse2 = /* @__PURE__ */ __name((message2, reason) => {
|
|
43411
43856
|
throw new CliError("validation_error", message2, { reason });
|
|
43412
43857
|
}, "refuse");
|
|
@@ -43484,7 +43929,7 @@ var paymentEntriesOver = /* @__PURE__ */ __name((context) => {
|
|
|
43484
43929
|
};
|
|
43485
43930
|
}, "paymentEntriesOver");
|
|
43486
43931
|
|
|
43487
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
43932
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
|
|
43488
43933
|
var EVIDENCE_FINDINGS_KIND = "evidence_findings";
|
|
43489
43934
|
var reference = /* @__PURE__ */ __name((raw) => {
|
|
43490
43935
|
if (/^(document|note):[1-9]\d*$/.test(raw))
|
|
@@ -43510,7 +43955,7 @@ var validateEvidenceFindings = /* @__PURE__ */ __name((input) => {
|
|
|
43510
43955
|
return valid;
|
|
43511
43956
|
}, "validateEvidenceFindings");
|
|
43512
43957
|
|
|
43513
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
43958
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/moment.js
|
|
43514
43959
|
var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false } = {}) => {
|
|
43515
43960
|
try {
|
|
43516
43961
|
return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
|
|
@@ -43522,9 +43967,9 @@ var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false
|
|
|
43522
43967
|
}
|
|
43523
43968
|
}, "calendarMoment");
|
|
43524
43969
|
|
|
43525
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
43970
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
|
|
43526
43971
|
var NAMED3 = "SELECT f.*, b.name AS author_name, b.kind AS author_kind FROM facts f LEFT JOIN bots b ON f.author_type = 'bot' AND b.id = f.author_id";
|
|
43527
|
-
var
|
|
43972
|
+
var iso10 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
43528
43973
|
var oneOf5 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
43529
43974
|
if (typeof value !== "string" || !allowed.includes(value))
|
|
43530
43975
|
throw new CliError("validation_error", `${what} is one of ${allowed.join(", ")}`);
|
|
@@ -43540,7 +43985,7 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43540
43985
|
status: row2.status,
|
|
43541
43986
|
...projectOf(database, row2),
|
|
43542
43987
|
...subjectOf(database, row2),
|
|
43543
|
-
occurredAt: row2.occurred_at == null ? null :
|
|
43988
|
+
occurredAt: row2.occurred_at == null ? null : iso10(row2.occurred_at),
|
|
43544
43989
|
supersedes: row2.supersedes_id == null ? null : `fact:${row2.supersedes_id}`,
|
|
43545
43990
|
author: authorOf(row2),
|
|
43546
43991
|
model: row2.model == null ? null : String(row2.model),
|
|
@@ -43548,8 +43993,8 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43548
43993
|
scope: row2.scope == null ? null : row2.scope,
|
|
43549
43994
|
source: String(row2.source),
|
|
43550
43995
|
evidence: evidenceOf(context, { type: "fact", id: Number(row2.id) }),
|
|
43551
|
-
createdAt:
|
|
43552
|
-
updatedAt:
|
|
43996
|
+
createdAt: iso10(row2.created_at),
|
|
43997
|
+
updatedAt: iso10(row2.updated_at)
|
|
43553
43998
|
}), "factOf");
|
|
43554
43999
|
const rowOf2 = /* @__PURE__ */ __name((reference2) => {
|
|
43555
44000
|
const thing = requiredThing(database, reference2.includes(":") ? reference2 : `fact:${reference2}`, "the fact");
|
|
@@ -43665,7 +44110,7 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43665
44110
|
const step = {
|
|
43666
44111
|
step: "revoked",
|
|
43667
44112
|
by: "owner",
|
|
43668
|
-
at:
|
|
44113
|
+
at: iso10(at),
|
|
43669
44114
|
confirmedBy: { type: current.confirmed_by_type, id: String(current.confirmed_by_id) },
|
|
43670
44115
|
...decision === void 0 ? {} : { decision },
|
|
43671
44116
|
...reason?.trim() ? { reason: reason.trim() } : {}
|
|
@@ -43731,7 +44176,7 @@ var factsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
43731
44176
|
};
|
|
43732
44177
|
}, "factsStoreOver");
|
|
43733
44178
|
|
|
43734
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44179
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
|
|
43735
44180
|
var invalid4 = /* @__PURE__ */ __name((message2) => {
|
|
43736
44181
|
throw new CliError("validation_error", message2);
|
|
43737
44182
|
}, "invalid");
|
|
@@ -43835,10 +44280,10 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind4) => {
|
|
|
43835
44280
|
return { snapshot: snapshot2, snapshotParts, previous, outcomes, create };
|
|
43836
44281
|
}, "findingsCoreOver");
|
|
43837
44282
|
|
|
43838
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44283
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
|
|
43839
44284
|
var PROPOSAL_STATUSES = ["proposed", "approved", "rejected", "executed", "failed"];
|
|
43840
44285
|
var PROPOSAL_VERDICTS = ["useful", "not_useful"];
|
|
43841
|
-
var
|
|
44286
|
+
var iso11 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
|
|
43842
44287
|
var json2 = /* @__PURE__ */ __name((value) => value == null ? null : JSON.parse(String(value)), "json");
|
|
43843
44288
|
var STATUS = `CASE WHEN p.status = 'approved' AND p.kind IN ('${MEETING_FINDINGS_KIND}', '${EVIDENCE_FINDINGS_KIND}', '${MAIL_FINDINGS_KIND}') AND json_array_length(p.result, '$.accepted') = 0 THEN 'rejected' ELSE p.status END`;
|
|
43844
44289
|
var NAMED4 = `SELECT p.*, ${STATUS} AS shown_status, b.name AS proposer_name, b.kind AS proposer_kind FROM proposed_actions p LEFT JOIN bots b ON p.proposed_by_type = 'bot' AND b.id = p.proposed_by_id`;
|
|
@@ -43869,12 +44314,12 @@ var proposalOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43869
44314
|
kind: row2.proposed_by_type !== "bot" ? null : row2.proposer_kind === "rule" || row2.proposer_name === "rule" ? "rule" : "agent"
|
|
43870
44315
|
},
|
|
43871
44316
|
decidedBy: row2.decided_by_type == null ? null : { type: row2.decided_by_type, id: String(row2.decided_by_id) },
|
|
43872
|
-
decidedAt:
|
|
43873
|
-
executedAt:
|
|
44317
|
+
decidedAt: iso11(row2.decided_at),
|
|
44318
|
+
executedAt: iso11(row2.executed_at),
|
|
43874
44319
|
result: json2(row2.result),
|
|
43875
44320
|
error: row2.error == null ? null : String(row2.error),
|
|
43876
44321
|
verdict: row2.verdict ?? null,
|
|
43877
|
-
createdAt:
|
|
44322
|
+
createdAt: iso11(row2.created_at)
|
|
43878
44323
|
};
|
|
43879
44324
|
}, "actionOf");
|
|
43880
44325
|
const rowOf2 = /* @__PURE__ */ __name((id2) => {
|
|
@@ -44000,7 +44445,7 @@ var proposedActionsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
44000
44445
|
};
|
|
44001
44446
|
}, "proposedActionsStoreOver");
|
|
44002
44447
|
|
|
44003
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44448
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
|
|
44004
44449
|
var stale = /* @__PURE__ */ __name(() => {
|
|
44005
44450
|
throw new CliError("validation_error", "evidence findings changed since they were read; stage a new batch", {
|
|
44006
44451
|
reason: "evidence-findings.stale"
|
|
@@ -44181,7 +44626,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
44181
44626
|
};
|
|
44182
44627
|
}, "evidenceFindingsStoreOver");
|
|
44183
44628
|
|
|
44184
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44629
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
|
|
44185
44630
|
var pendingInvolvements = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM involvement_pending").get()?.n ?? 0), "pendingInvolvements");
|
|
44186
44631
|
var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => ({
|
|
44187
44632
|
rebuild: /* @__PURE__ */ __name((personId) => write(database, () => {
|
|
@@ -44234,7 +44679,7 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
|
|
|
44234
44679
|
}, "forPerson")
|
|
44235
44680
|
}), "involvementStoreOver");
|
|
44236
44681
|
|
|
44237
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44682
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
|
|
44238
44683
|
import { createHash as createHash12 } from "node:crypto";
|
|
44239
44684
|
var fields3 = "id,from_id,to_id,source,confirmed,updated_at,length(evidence) AS evidenceLength,substr(evidence,1,2000) AS evidence";
|
|
44240
44685
|
var id = /* @__PURE__ */ __name((value) => {
|
|
@@ -44320,7 +44765,7 @@ var meetingProjectsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 })
|
|
|
44320
44765
|
};
|
|
44321
44766
|
}, "meetingProjectsStoreOver");
|
|
44322
44767
|
|
|
44323
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44768
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
|
|
44324
44769
|
var ORGANIZATIONS_QUERY = {
|
|
44325
44770
|
entity: "organization",
|
|
44326
44771
|
backend: "sql",
|
|
@@ -44361,7 +44806,7 @@ var REMINDERS_QUERY = {
|
|
|
44361
44806
|
})
|
|
44362
44807
|
};
|
|
44363
44808
|
|
|
44364
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44809
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/organizations.js
|
|
44365
44810
|
var organizationOf = /* @__PURE__ */ __name((row2) => ({
|
|
44366
44811
|
id: String(row2.id),
|
|
44367
44812
|
ref: `organization:${row2.id}`,
|
|
@@ -44394,7 +44839,7 @@ var organizationsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) =>
|
|
|
44394
44839
|
}), "updateOrganization")
|
|
44395
44840
|
}), "organizationsStoreOver");
|
|
44396
44841
|
|
|
44397
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
44842
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/relation-proposals.js
|
|
44398
44843
|
var relationOf = /* @__PURE__ */ __name((link3) => ({
|
|
44399
44844
|
id: link3.id,
|
|
44400
44845
|
from: link3.from,
|
|
@@ -44620,16 +45065,16 @@ var decidedOrigin = /* @__PURE__ */ __name((by) => by === "owner" ? { origin: "o
|
|
|
44620
45065
|
provenance: `agent:${by.bot} for the owner: ${by.reason.trim()}`
|
|
44621
45066
|
}, "decidedOrigin");
|
|
44622
45067
|
|
|
44623
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45068
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
|
|
44624
45069
|
import { createHash as createHash15 } from "node:crypto";
|
|
44625
45070
|
|
|
44626
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45071
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
|
|
44627
45072
|
import { createHash as createHash14 } from "node:crypto";
|
|
44628
45073
|
|
|
44629
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45074
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
|
|
44630
45075
|
import { createHash as createHash13 } from "node:crypto";
|
|
44631
45076
|
|
|
44632
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45077
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
|
|
44633
45078
|
var consolidationId = /* @__PURE__ */ __name((value, field4) => {
|
|
44634
45079
|
if (typeof value !== "string" || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
|
|
44635
45080
|
throw new CliError("validation_error", `${field4} must be a positive canonical tag id`);
|
|
@@ -44680,7 +45125,7 @@ var consolidationApplyInput = /* @__PURE__ */ __name((options) => {
|
|
|
44680
45125
|
return input;
|
|
44681
45126
|
}, "consolidationApplyInput");
|
|
44682
45127
|
|
|
44683
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45128
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
|
|
44684
45129
|
var receiptOf = /* @__PURE__ */ __name((row2) => ({
|
|
44685
45130
|
id: String(row2.id),
|
|
44686
45131
|
sourceId: String(row2.source_id),
|
|
@@ -44755,7 +45200,7 @@ var applyTagConsolidation = /* @__PURE__ */ __name((context, preview, options) =
|
|
|
44755
45200
|
}, { beforeCommit: check3 });
|
|
44756
45201
|
}, "applyTagConsolidation");
|
|
44757
45202
|
|
|
44758
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45203
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
|
|
44759
45204
|
var selections = [
|
|
44760
45205
|
["taggings", "tag_id IN (SELECT value FROM json_each(?))"],
|
|
44761
45206
|
["aliases", "aliasable_type='tag' AND aliasable_id IN (SELECT value FROM json_each(?))"],
|
|
@@ -44899,7 +45344,7 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
|
|
|
44899
45344
|
};
|
|
44900
45345
|
}, "previewRows");
|
|
44901
45346
|
|
|
44902
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45347
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
|
|
44903
45348
|
var kinds = ["project", "tag", "topic"];
|
|
44904
45349
|
var cancelled2 = /* @__PURE__ */ __name((signal) => {
|
|
44905
45350
|
if (signal?.aborted)
|
|
@@ -45163,13 +45608,13 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45163
45608
|
};
|
|
45164
45609
|
}, "vocabularyStoreOver");
|
|
45165
45610
|
|
|
45166
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
45611
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
|
|
45167
45612
|
var TYPED_KEY_PREFIXES = new Set(Object.values(TASK_KEY_PREFIXES));
|
|
45168
45613
|
var ORGANIZATION_KINDS = ["company", "team", "family", "community"];
|
|
45169
45614
|
var PROJECT_TYPES = ["work", "client", "personal", "oss", "other"];
|
|
45170
45615
|
var SCOPES = ["personal", "work"];
|
|
45171
45616
|
var UNVERIFIED = { type: "unknown" };
|
|
45172
|
-
var
|
|
45617
|
+
var iso12 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
45173
45618
|
var bounded2 = /* @__PURE__ */ __name((limit = 100, offset = 0) => {
|
|
45174
45619
|
if (!Number.isInteger(limit) || limit < 1 || limit > 500 || !Number.isInteger(offset) || offset < 0 || offset > 1e5)
|
|
45175
45620
|
throw new CliError("validation_error", "limit takes 1\u2013500 and offset takes 0\u2013100000");
|
|
@@ -45271,7 +45716,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45271
45716
|
return { type: "chat", id: parsed3.chat };
|
|
45272
45717
|
if (parsed3.type === "folder")
|
|
45273
45718
|
return { type: "folder", id: parsed3.id, path: parsed3.path };
|
|
45274
|
-
if (parsed3.type === "entity" || parsed3.type === "memory" || parsed3.type === "fact" || parsed3.type === "bot" || parsed3.type === "event" || parsed3.type === "meeting" || parsed3.type === "invoice" || parsed3.type === "payment" || parsed3.type === "order")
|
|
45719
|
+
if (parsed3.type === "entity" || parsed3.type === "memory" || parsed3.type === "fact" || parsed3.type === "bot" || parsed3.type === "event" || parsed3.type === "meeting" || parsed3.type === "invoice" || parsed3.type === "payment" || parsed3.type === "order" || parsed3.type === "deal" || parsed3.type === "lead" || parsed3.type === "pipeline")
|
|
45275
45720
|
return void 0;
|
|
45276
45721
|
return { type: parsed3.type, id: parsed3.id };
|
|
45277
45722
|
}, "targetOfThing");
|
|
@@ -45302,8 +45747,8 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45302
45747
|
text: String(row2.body),
|
|
45303
45748
|
revision: Number(row2.revision),
|
|
45304
45749
|
authoredBy: "owner",
|
|
45305
|
-
createdAt:
|
|
45306
|
-
updatedAt:
|
|
45750
|
+
createdAt: iso12(row2.created_at),
|
|
45751
|
+
updatedAt: iso12(row2.updated_at)
|
|
45307
45752
|
};
|
|
45308
45753
|
}, "annotationOf");
|
|
45309
45754
|
const noteRow = /* @__PURE__ */ __name((id2) => /^\d+$/.test(id2) ? database.prepare("SELECT * FROM notes WHERE id = ? AND deleted_at IS NULL").get(Number(id2)) : void 0, "noteRow");
|
|
@@ -45324,7 +45769,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45324
45769
|
type: row2.type,
|
|
45325
45770
|
organizationId: row2.organization_id == null ? null : String(row2.organization_id),
|
|
45326
45771
|
scope: row2.scope,
|
|
45327
|
-
createdAt:
|
|
45772
|
+
createdAt: iso12(row2.created_at)
|
|
45328
45773
|
}), "projectOf");
|
|
45329
45774
|
const proposals = relationProposalsOver(context);
|
|
45330
45775
|
const RELATIONS = `SELECT * FROM links WHERE kind IN (${RELATION_KINDS.map(linkKind).join(",")}) AND to_id IS NOT NULL`;
|
|
@@ -45360,7 +45805,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45360
45805
|
const reminderOf = /* @__PURE__ */ __name((row2) => ({
|
|
45361
45806
|
id: String(row2.id),
|
|
45362
45807
|
task: taskIdOf(database, Number(row2.task_id)) ?? String(row2.task_id),
|
|
45363
|
-
dueAt:
|
|
45808
|
+
dueAt: iso12(row2.due_at),
|
|
45364
45809
|
timezone: String(row2.timezone),
|
|
45365
45810
|
state: row2.state,
|
|
45366
45811
|
revision: Number(row2.revision),
|
|
@@ -45704,7 +46149,7 @@ var projectKey = /* @__PURE__ */ __name((name) => {
|
|
|
45704
46149
|
return key2.padEnd(3, "X");
|
|
45705
46150
|
}, "projectKey");
|
|
45706
46151
|
|
|
45707
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
46152
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
|
|
45708
46153
|
var DAY5 = 864e5;
|
|
45709
46154
|
var SETTING4 = "logs_pruned_at";
|
|
45710
46155
|
var LOG_RETENTION = { agentActionsMs: 90 * DAY5, botUpdatePayloadsMs: 30 * DAY5 };
|
|
@@ -45731,7 +46176,7 @@ var logPruner = /* @__PURE__ */ __name((database, now2) => {
|
|
|
45731
46176
|
};
|
|
45732
46177
|
}, "logPruner");
|
|
45733
46178
|
|
|
45734
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
46179
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/mail/findings.js
|
|
45735
46180
|
var MAIL_FINDINGS_PER_RUN = 30;
|
|
45736
46181
|
var MAIL_FINDINGS_PER_SENDER = 5;
|
|
45737
46182
|
var invalid6 = /* @__PURE__ */ __name((message2) => {
|
|
@@ -45813,6 +46258,23 @@ var MAIL_FINDING_FIELDS = {
|
|
|
45813
46258
|
order_update: { needs: ["supplierName", "number", "status", "reason"], may: ["date"] }
|
|
45814
46259
|
};
|
|
45815
46260
|
var MAIL_FINDING_KINDS = Object.keys(MAIL_FINDING_FIELDS);
|
|
46261
|
+
var VALUES = {
|
|
46262
|
+
task: { type: ["bug", "feature", "chore"], commitment: ["explicit", "inferred"] },
|
|
46263
|
+
task_update: { change: ["close", "due", "detail"] },
|
|
46264
|
+
memory: { memoryKind: MEMORY_KINDS, scope: MEMORY_SCOPES },
|
|
46265
|
+
invoice: { direction: INVOICE_DIRECTIONS },
|
|
46266
|
+
payment: { direction: MONEY_DIRECTIONS },
|
|
46267
|
+
order: { purpose: ORDER_PURPOSES, status: ORDER_STATUSES },
|
|
46268
|
+
order_update: { status: ORDER_STATUSES }
|
|
46269
|
+
};
|
|
46270
|
+
var mailFindingFieldsHelp = /* @__PURE__ */ __name(() => MAIL_FINDING_KINDS.map((kind4) => {
|
|
46271
|
+
const { needs, may } = MAIL_FINDING_FIELDS[kind4];
|
|
46272
|
+
const named3 = /* @__PURE__ */ __name((field4) => {
|
|
46273
|
+
const values = VALUES[kind4]?.[field4];
|
|
46274
|
+
return values ? `${snakeCase(field4)} ${values.join("|")}` : snakeCase(field4);
|
|
46275
|
+
}, "named");
|
|
46276
|
+
return ` ${kind4}: ${needs.map(named3).join(", ")}${may.length ? `; optional ${may.map(named3).join(", ")}` : ""}`;
|
|
46277
|
+
}).join("\n"), "mailFindingFieldsHelp");
|
|
45816
46278
|
var typeOf2 = /* @__PURE__ */ __name((reference2) => {
|
|
45817
46279
|
try {
|
|
45818
46280
|
const parsed3 = parseReference(reference2);
|
|
@@ -46090,7 +46552,7 @@ var checkMailFindings = /* @__PURE__ */ __name((input) => {
|
|
|
46090
46552
|
}, "checkMailFindings");
|
|
46091
46553
|
var mailFindingFingerprint = /* @__PURE__ */ __name(({ id: _id, ...finding }) => findingHash(finding), "mailFindingFingerprint");
|
|
46092
46554
|
|
|
46093
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
46555
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/mail/score.js
|
|
46094
46556
|
var import_disposable_email_domains_js = __toESM(require_dist(), 1);
|
|
46095
46557
|
var import_tldts = __toESM(require_cjs(), 1);
|
|
46096
46558
|
var WEIGHTS = {
|
|
@@ -46223,7 +46685,7 @@ var scoreGroup = /* @__PURE__ */ __name((items, context) => {
|
|
|
46223
46685
|
return { score: kept.reduce((sum, signal) => sum + WEIGHTS[signal], 0), signals: kept };
|
|
46224
46686
|
}, "scoreGroup");
|
|
46225
46687
|
|
|
46226
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
46688
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/orders.js
|
|
46227
46689
|
var ORDERS = "SELECT o.*, b.name AS author_name, b.kind AS author_kind FROM orders o LEFT JOIN bots b ON o.author_type = 'bot' AND b.id = o.author_id";
|
|
46228
46690
|
var orderOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
46229
46691
|
const { database, now: now2 } = context;
|
|
@@ -46375,7 +46837,7 @@ var ordersStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
46375
46837
|
};
|
|
46376
46838
|
}, "ordersStoreOver");
|
|
46377
46839
|
|
|
46378
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
46840
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-findings.js
|
|
46379
46841
|
var stale2 = /* @__PURE__ */ __name(() => {
|
|
46380
46842
|
throw new CliError("validation_error", "mail findings cite mail that changed since it was read; stage a new batch", {
|
|
46381
46843
|
reason: "mail-findings.stale"
|
|
@@ -46416,7 +46878,7 @@ var mailFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
46416
46878
|
return invalid7("stored findings exceed the read budget");
|
|
46417
46879
|
return proposals.get(id2);
|
|
46418
46880
|
}, "load");
|
|
46419
|
-
const
|
|
46881
|
+
const accountOf4 = /* @__PURE__ */ __name((proposal) => mailbox2(proposal.account), "accountOf");
|
|
46420
46882
|
const view = /* @__PURE__ */ __name((proposal) => {
|
|
46421
46883
|
const input = proposal.payload;
|
|
46422
46884
|
if (!input || !proposal.account || !["proposed", "approved", "rejected"].includes(proposal.status))
|
|
@@ -46431,7 +46893,7 @@ var mailFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
46431
46893
|
decidedBy: proposal.decidedBy,
|
|
46432
46894
|
decidedAt: proposal.decidedAt,
|
|
46433
46895
|
previous: proposal.result ? proposal.result.items : input.findings.flatMap((finding) => {
|
|
46434
|
-
const held = core.previous(
|
|
46896
|
+
const held = core.previous(accountOf4(proposal), mailFindingFingerprint(finding));
|
|
46435
46897
|
return held ? [{ ...held, id: finding.id, reused: true }] : [];
|
|
46436
46898
|
}),
|
|
46437
46899
|
receipt: proposal.result
|
|
@@ -46800,7 +47262,7 @@ ${evidence.join("\n")}`, agent);
|
|
|
46800
47262
|
return batch;
|
|
46801
47263
|
}
|
|
46802
47264
|
const input = proposal.payload;
|
|
46803
|
-
const account =
|
|
47265
|
+
const account = accountOf4(proposal);
|
|
46804
47266
|
const chosen = batch.input.findings.filter((finding) => accepted.includes(finding.id));
|
|
46805
47267
|
if (chosen.length)
|
|
46806
47268
|
cite(chosen, account, true);
|
|
@@ -46832,7 +47294,7 @@ ${evidence.join("\n")}`, agent);
|
|
|
46832
47294
|
};
|
|
46833
47295
|
}, "mailFindingsStoreOver");
|
|
46834
47296
|
|
|
46835
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47297
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
|
|
46836
47298
|
var stale3 = /* @__PURE__ */ __name(() => {
|
|
46837
47299
|
throw new CliError("validation_error", "meeting findings changed since they were read; stage a new batch", {
|
|
46838
47300
|
reason: "meeting-findings.stale"
|
|
@@ -47000,7 +47462,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
47000
47462
|
};
|
|
47001
47463
|
}, "meetingFindingsStoreOver");
|
|
47002
47464
|
|
|
47003
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47465
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
|
|
47004
47466
|
var RANK_BATCH = 512;
|
|
47005
47467
|
var LIVE3 = "FROM chunks k JOIN meeting_transcripts t ON k.chunkable_type = 'meeting_transcript' AND t.id = k.chunkable_id JOIN meetings m ON m.id = t.meeting_id WHERE m.account_id = ? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL";
|
|
47006
47468
|
var limitOf = /* @__PURE__ */ __name((value, name, max = 1e3) => {
|
|
@@ -47271,7 +47733,7 @@ var meetingVectorsOver = /* @__PURE__ */ __name((context) => ({
|
|
|
47271
47733
|
}
|
|
47272
47734
|
}), "meetingVectorsOver");
|
|
47273
47735
|
|
|
47274
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47736
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
|
|
47275
47737
|
var OTHER_SOURCES = ["document", "note", "email"];
|
|
47276
47738
|
var TEXTS = {
|
|
47277
47739
|
document: "JOIN documents s ON mn.source_type = 'document' AND s.id = mn.source_id AND s.deleted_at IS NULL WHERE 1 ",
|
|
@@ -47372,11 +47834,11 @@ var sourceMentionStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
47372
47834
|
};
|
|
47373
47835
|
}, "sourceMentionStoreOver");
|
|
47374
47836
|
|
|
47375
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47837
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
|
|
47376
47838
|
import { mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
47377
47839
|
import { dirname } from "node:path";
|
|
47378
47840
|
|
|
47379
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47841
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
|
|
47380
47842
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
47381
47843
|
var CLIENTS_SETTING = "clients";
|
|
47382
47844
|
var coreVersion = (() => {
|
|
@@ -47434,7 +47896,7 @@ var refusalAdvice = /* @__PURE__ */ __name((clients, command, schema) => {
|
|
|
47434
47896
|
return mover ? `${own} (${mover.command} ${mover.version} moved the store to schema ${schema})` : own;
|
|
47435
47897
|
}, "refusalAdvice");
|
|
47436
47898
|
|
|
47437
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47899
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
|
|
47438
47900
|
var GENERATED = [
|
|
47439
47901
|
{
|
|
47440
47902
|
"name": "20261010184427_initial",
|
|
@@ -48434,10 +48896,59 @@ WHERE json_type(params, '$.selection') = 'object';`
|
|
|
48434
48896
|
"ALTER TABLE `tasks` ADD `source_url` text;",
|
|
48435
48897
|
"CREATE INDEX `tasks_by_provider_external_id` ON `tasks` (`provider`,`external_id`) WHERE external_id IS NOT NULL;"
|
|
48436
48898
|
]
|
|
48899
|
+
},
|
|
48900
|
+
{
|
|
48901
|
+
"name": "20261106010504_version-52-deals",
|
|
48902
|
+
"statements": [
|
|
48903
|
+
"CREATE TABLE `deals` (\n `id` integer PRIMARY KEY,\n `title` text NOT NULL,\n `organization_id` integer,\n `project_id` integer,\n `stage_id` integer NOT NULL,\n `status` text NOT NULL,\n `currency` text,\n `amount` integer,\n `close_date` text,\n `closed_date` text,\n `rank` real,\n `account_id` integer,\n `external_id` text,\n `author_type` text NOT NULL,\n `author_id` integer NOT NULL,\n `model` text,\n `source` text NOT NULL,\n `metadata` text,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n `deleted_at` integer,\n CONSTRAINT `fk_deals_organization_id_organizations_id_fk` FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`),\n CONSTRAINT `fk_deals_project_id_projects_id_fk` FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`),\n CONSTRAINT `fk_deals_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`stage_id`) REFERENCES `pipeline_stages`(`id`),\n CONSTRAINT `fk_deals_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`)\n);",
|
|
48904
|
+
"CREATE TABLE `leads` (\n `id` integer PRIMARY KEY,\n `title` text NOT NULL,\n `organization_id` integer,\n `project_id` integer,\n `stage_id` integer NOT NULL,\n `status` text NOT NULL,\n `currency` text,\n `amount` integer,\n `close_date` text,\n `closed_date` text,\n `rank` real,\n `deal_id` integer,\n `account_id` integer,\n `external_id` text,\n `author_type` text NOT NULL,\n `author_id` integer NOT NULL,\n `model` text,\n `source` text NOT NULL,\n `metadata` text,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n `deleted_at` integer,\n CONSTRAINT `fk_leads_organization_id_organizations_id_fk` FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`),\n CONSTRAINT `fk_leads_project_id_projects_id_fk` FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`),\n CONSTRAINT `fk_leads_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`stage_id`) REFERENCES `pipeline_stages`(`id`),\n CONSTRAINT `fk_leads_deal_id_deals_id_fk` FOREIGN KEY (`deal_id`) REFERENCES `deals`(`id`),\n CONSTRAINT `fk_leads_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`)\n);",
|
|
48905
|
+
"CREATE TABLE `pipeline_stage_changes` (\n `id` integer PRIMARY KEY,\n `item_type` text NOT NULL,\n `item_id` integer NOT NULL,\n `pipeline_id` integer NOT NULL,\n `from_stage_id` integer,\n `to_stage_id` integer NOT NULL,\n `changed_at` integer NOT NULL,\n CONSTRAINT `fk_pipeline_stage_changes_pipeline_id_pipelines_id_fk` FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`),\n CONSTRAINT `fk_pipeline_stage_changes_from_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`from_stage_id`) REFERENCES `pipeline_stages`(`id`),\n CONSTRAINT `fk_pipeline_stage_changes_to_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`to_stage_id`) REFERENCES `pipeline_stages`(`id`)\n);",
|
|
48906
|
+
"CREATE TABLE `pipeline_stages` (\n `id` integer PRIMARY KEY,\n `pipeline_id` integer NOT NULL,\n `name` text NOT NULL,\n `name_folded` text NOT NULL,\n `position` integer NOT NULL,\n `outcome` text DEFAULT 'open' NOT NULL,\n `external_id` text,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n CONSTRAINT `fk_pipeline_stages_pipeline_id_pipelines_id_fk` FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`),\n CONSTRAINT `pipeline_stages_pipeline_id_name_folded_unique` UNIQUE(`pipeline_id`,`name_folded`)\n);",
|
|
48907
|
+
"CREATE TABLE `pipelines` (\n `id` integer PRIMARY KEY,\n `account_id` integer,\n `external_id` text,\n `kind` text DEFAULT 'deal' NOT NULL,\n `name` text NOT NULL,\n `name_folded` text NOT NULL,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n CONSTRAINT `fk_pipelines_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`)\n);",
|
|
48908
|
+
"CREATE UNIQUE INDEX `deals_by_account_id_external_id` ON `deals` (`account_id`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;",
|
|
48909
|
+
"CREATE INDEX `deals_by_organization_id` ON `deals` (`organization_id`);",
|
|
48910
|
+
"CREATE INDEX `deals_by_project_id` ON `deals` (`project_id`);",
|
|
48911
|
+
"CREATE INDEX `deals_by_stage_id` ON `deals` (`stage_id`);",
|
|
48912
|
+
"CREATE INDEX `deals_by_author_type_author_id` ON `deals` (`author_type`,`author_id`);",
|
|
48913
|
+
"CREATE UNIQUE INDEX `leads_by_account_id_external_id` ON `leads` (`account_id`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;",
|
|
48914
|
+
"CREATE INDEX `leads_by_organization_id` ON `leads` (`organization_id`);",
|
|
48915
|
+
"CREATE INDEX `leads_by_project_id` ON `leads` (`project_id`);",
|
|
48916
|
+
"CREATE INDEX `leads_by_stage_id` ON `leads` (`stage_id`);",
|
|
48917
|
+
"CREATE INDEX `leads_by_deal_id` ON `leads` (`deal_id`);",
|
|
48918
|
+
"CREATE INDEX `leads_by_author_type_author_id` ON `leads` (`author_type`,`author_id`);",
|
|
48919
|
+
"CREATE INDEX `pipeline_stage_changes_by_item_type_item_id` ON `pipeline_stage_changes` (`item_type`,`item_id`);",
|
|
48920
|
+
"CREATE INDEX `pipeline_stage_changes_by_pipeline_id` ON `pipeline_stage_changes` (`pipeline_id`);",
|
|
48921
|
+
"CREATE INDEX `pipeline_stage_changes_by_from_stage_id` ON `pipeline_stage_changes` (`from_stage_id`);",
|
|
48922
|
+
"CREATE INDEX `pipeline_stage_changes_by_to_stage_id` ON `pipeline_stage_changes` (`to_stage_id`);",
|
|
48923
|
+
"CREATE UNIQUE INDEX `pipeline_stages_by_pipeline_id_external_id` ON `pipeline_stages` (`pipeline_id`,`external_id`) WHERE external_id IS NOT NULL;",
|
|
48924
|
+
"CREATE INDEX `pipeline_stages_by_pipeline_id_position` ON `pipeline_stages` (`pipeline_id`,`position`);",
|
|
48925
|
+
"CREATE UNIQUE INDEX `pipelines_by_account_id_external_id` ON `pipelines` (`account_id`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;",
|
|
48926
|
+
"CREATE UNIQUE INDEX `pipelines_by_name_folded_kind` ON `pipelines` (`name_folded`,`kind`) WHERE account_id IS NULL;"
|
|
48927
|
+
]
|
|
48928
|
+
},
|
|
48929
|
+
{
|
|
48930
|
+
"name": "20261106010507_version-52-deals-rules",
|
|
48931
|
+
"statements": [
|
|
48932
|
+
"-- The store's code checks these first and says why; the triggers keep a stray write from another build, a sync or a\n-- hand edit from storing a row the store's code would refuse.\nCREATE TRIGGER pipelines_valid_bi BEFORE INSERT ON pipelines WHEN new.kind NOT IN ('deal', 'lead') BEGIN\n SELECT RAISE(ABORT, 'pipelines: kind is deal or lead');\nEND;",
|
|
48933
|
+
"CREATE TRIGGER pipelines_valid_bu BEFORE UPDATE ON pipelines WHEN new.kind NOT IN ('deal', 'lead') BEGIN\n SELECT RAISE(ABORT, 'pipelines: kind is deal or lead');\nEND;",
|
|
48934
|
+
"CREATE TRIGGER pipelines_kind_bu BEFORE UPDATE OF kind ON pipelines\n WHEN new.kind <> old.kind AND EXISTS (SELECT 1 FROM pipeline_stages s WHERE s.pipeline_id = new.id\n AND (EXISTS (SELECT 1 FROM deals d WHERE d.stage_id = s.id) OR EXISTS (SELECT 1 FROM leads l WHERE l.stage_id = s.id))) BEGIN\n SELECT RAISE(ABORT, 'pipelines: the kind of a pipeline that holds deals or leads stays');\nEND;",
|
|
48935
|
+
"CREATE TRIGGER pipeline_stages_valid_bi BEFORE INSERT ON pipeline_stages\n WHEN new.outcome NOT IN ('open', 'won', 'lost') BEGIN\n SELECT RAISE(ABORT, 'pipeline_stages: outcome is open, won or lost');\nEND;",
|
|
48936
|
+
"CREATE TRIGGER pipeline_stages_valid_bu BEFORE UPDATE ON pipeline_stages\n WHEN new.outcome NOT IN ('open', 'won', 'lost') BEGIN\n SELECT RAISE(ABORT, 'pipeline_stages: outcome is open, won or lost');\nEND;",
|
|
48937
|
+
"CREATE TRIGGER deals_valid_bi BEFORE INSERT ON deals\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'deal' BEGIN\n SELECT RAISE(ABORT, 'deals: a known status, an amount with its currency, and a stage of a deal pipeline');\nEND;",
|
|
48938
|
+
"CREATE TRIGGER deals_valid_bu BEFORE UPDATE ON deals\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'deal' BEGIN\n SELECT RAISE(ABORT, 'deals: a known status, an amount with its currency, and a stage of a deal pipeline');\nEND;",
|
|
48939
|
+
"-- Every stage a row enters, with the time its writer gave, is what conversion between stages is counted from.\nCREATE TRIGGER deals_stage_ai AFTER INSERT ON deals BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'deal', new.id, s.pipeline_id, NULL, new.stage_id, new.created_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
|
|
48940
|
+
"CREATE TRIGGER deals_stage_au AFTER UPDATE OF stage_id ON deals WHEN new.stage_id IS NOT old.stage_id BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'deal', new.id, s.pipeline_id, old.stage_id, new.stage_id, new.updated_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
|
|
48941
|
+
"CREATE TRIGGER leads_valid_bi BEFORE INSERT ON leads\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'lead' BEGIN\n SELECT RAISE(ABORT, 'leads: a known status, an amount with its currency, and a stage of a lead pipeline');\nEND;",
|
|
48942
|
+
"CREATE TRIGGER leads_valid_bu BEFORE UPDATE ON leads\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'lead' BEGIN\n SELECT RAISE(ABORT, 'leads: a known status, an amount with its currency, and a stage of a lead pipeline');\nEND;",
|
|
48943
|
+
"CREATE TRIGGER leads_stage_ai AFTER INSERT ON leads BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'lead', new.id, s.pipeline_id, NULL, new.stage_id, new.created_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
|
|
48944
|
+
"CREATE TRIGGER leads_stage_au AFTER UPDATE OF stage_id ON leads WHEN new.stage_id IS NOT old.stage_id BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'lead', new.id, s.pipeline_id, old.stage_id, new.stage_id, new.updated_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
|
|
48945
|
+
"-- The default lead pipeline, so a lead can be recorded before the owner or an agent makes one.\nINSERT INTO pipelines (kind, name, name_folded, created_at, updated_at)\n VALUES ('lead', 'Leads', 'leads', CAST(strftime('%s', 'now') AS INTEGER) * 1000, CAST(strftime('%s', 'now') AS INTEGER) * 1000);",
|
|
48946
|
+
"INSERT INTO pipeline_stages (pipeline_id, name, name_folded, position, outcome, created_at, updated_at)\n SELECT p.id, v.name, v.name, v.position, v.outcome, p.created_at, p.created_at FROM pipelines p,\n (SELECT 'new' AS name, 1 AS position, 'open' AS outcome UNION ALL SELECT 'contacted', 2, 'open'\n UNION ALL SELECT 'qualified', 3, 'open' UNION ALL SELECT 'won', 4, 'won' UNION ALL SELECT 'lost', 5, 'lost') v\n WHERE p.kind = 'lead' AND p.name_folded = 'leads' AND p.account_id IS NULL;"
|
|
48947
|
+
]
|
|
48437
48948
|
}
|
|
48438
48949
|
];
|
|
48439
48950
|
|
|
48440
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
48951
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
|
|
48441
48952
|
var MANIFEST = [
|
|
48442
48953
|
{ name: "20261010184427_initial", version: 1, minCompatible: 1 },
|
|
48443
48954
|
{ name: "20261011035353_version-2-facts", version: 2, minCompatible: 1 },
|
|
@@ -48505,7 +49016,9 @@ var MANIFEST = [
|
|
|
48505
49016
|
{ name: "20261104232153_version-49-relation-amounts", version: 49, minCompatible: 34 },
|
|
48506
49017
|
{ name: "20261105125314_version-50-orders", version: 50, minCompatible: 34 },
|
|
48507
49018
|
{ name: "20261105125315_version-50-orders-rules", version: 50, minCompatible: 34 },
|
|
48508
|
-
{ name: "20261105144549_version-51-task-links", version: 51, minCompatible: 34 }
|
|
49019
|
+
{ name: "20261105144549_version-51-task-links", version: 51, minCompatible: 34 },
|
|
49020
|
+
{ name: "20261106010504_version-52-deals", version: 52, minCompatible: 34 },
|
|
49021
|
+
{ name: "20261106010507_version-52-deals-rules", version: 52, minCompatible: 34 }
|
|
48509
49022
|
];
|
|
48510
49023
|
var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated = GENERATED) => {
|
|
48511
49024
|
const migrations = [];
|
|
@@ -48529,7 +49042,7 @@ var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated
|
|
|
48529
49042
|
return migrations;
|
|
48530
49043
|
}, "generatedMigrations");
|
|
48531
49044
|
|
|
48532
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49045
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/migrations.js
|
|
48533
49046
|
var MIGRATIONS = generatedMigrations();
|
|
48534
49047
|
var HISTORY = `CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
48535
49048
|
version INTEGER PRIMARY KEY,
|
|
@@ -48582,7 +49095,7 @@ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now:
|
|
|
48582
49095
|
}
|
|
48583
49096
|
}, "migrate");
|
|
48584
49097
|
|
|
48585
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49098
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
|
|
48586
49099
|
var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
|
|
48587
49100
|
const pending = database.prepare("SELECT id, join_url FROM meetings WHERE join_url IS NOT NULL AND join_key IS NULL AND id > ? ORDER BY id LIMIT ?");
|
|
48588
49101
|
if (pending.get(0, 1) === void 0)
|
|
@@ -48604,7 +49117,7 @@ var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
|
|
|
48604
49117
|
}
|
|
48605
49118
|
}, "fillJoinKeys");
|
|
48606
49119
|
|
|
48607
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49120
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
|
|
48608
49121
|
var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
|
|
48609
49122
|
refuseOwnerStoreInTests(path);
|
|
48610
49123
|
const opened = "Bun" in globalThis ? await openUnderBun(path, readOnly) : await openUnderNode(path, readOnly);
|
|
@@ -48618,8 +49131,8 @@ var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {})
|
|
|
48618
49131
|
}, "openSqlite");
|
|
48619
49132
|
var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
48620
49133
|
quietSqliteWarning();
|
|
48621
|
-
const { drizzle } = await import("./node-
|
|
48622
|
-
const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-
|
|
49134
|
+
const { drizzle } = await import("./node-FMT4QVUG.js");
|
|
49135
|
+
const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-2RDIBVYM.js");
|
|
48623
49136
|
const client = await nodeClient(path, { readOnly });
|
|
48624
49137
|
try {
|
|
48625
49138
|
return { database: cacheOverNodeSqlite(client), orm: drizzle({ client }) };
|
|
@@ -48629,8 +49142,8 @@ var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
|
48629
49142
|
}
|
|
48630
49143
|
}, "openUnderNode");
|
|
48631
49144
|
var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
48632
|
-
const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-
|
|
48633
|
-
const { drizzle } = await import("./bun-
|
|
49145
|
+
const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-INSVTXFN.js");
|
|
49146
|
+
const { drizzle } = await import("./bun-4NGTZRHL.js");
|
|
48634
49147
|
const client = await bunClient(path, readOnly ? { readonly: true, create: false } : void 0);
|
|
48635
49148
|
try {
|
|
48636
49149
|
return { database: cacheOverBunSqlite(client), orm: drizzle({ client }) };
|
|
@@ -48640,7 +49153,7 @@ var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
|
48640
49153
|
}
|
|
48641
49154
|
}, "openUnderBun");
|
|
48642
49155
|
|
|
48643
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49156
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-facts.js
|
|
48644
49157
|
var PAYMENT_FACTS_TO_MOVE = "payment_facts_to_move";
|
|
48645
49158
|
var paymentOf = /* @__PURE__ */ __name((metadata3) => {
|
|
48646
49159
|
try {
|
|
@@ -48708,7 +49221,7 @@ var movePaymentFacts = /* @__PURE__ */ __name((context) => {
|
|
|
48708
49221
|
});
|
|
48709
49222
|
}, "movePaymentFacts");
|
|
48710
49223
|
|
|
48711
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49224
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
|
|
48712
49225
|
var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
|
|
48713
49226
|
const ours = MIGRATIONS.at(-1)?.version ?? 0;
|
|
48714
49227
|
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='schema_migrations'").get())
|
|
@@ -48723,7 +49236,7 @@ var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
|
|
|
48723
49236
|
throw new CliError("configuration_error", `The store requires schema ${minCompatible}, but this tool supports ${ours}; ${refusalAdvice(storeClients(database), command, version)}`);
|
|
48724
49237
|
}, "assertReadCompatible");
|
|
48725
49238
|
|
|
48726
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49239
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/suggested-links.js
|
|
48727
49240
|
var SUGGESTED_LINKS_TO_MOVE = "suggested_links_to_move";
|
|
48728
49241
|
var proposerOf2 = /* @__PURE__ */ __name((provenance2) => {
|
|
48729
49242
|
if (provenance2?.startsWith("rule:"))
|
|
@@ -48769,7 +49282,7 @@ var moveSuggestedLinks = /* @__PURE__ */ __name((database, now2) => {
|
|
|
48769
49282
|
});
|
|
48770
49283
|
}, "moveSuggestedLinks");
|
|
48771
49284
|
|
|
48772
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49285
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/test-accounts.js
|
|
48773
49286
|
var TEST_ACCOUNTS_TO_PURGE = "test_accounts_to_purge";
|
|
48774
49287
|
var TEST_PROVIDER = "chat";
|
|
48775
49288
|
var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
|
|
@@ -48790,7 +49303,7 @@ var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
|
|
|
48790
49303
|
}
|
|
48791
49304
|
}, "purgeTestAccounts");
|
|
48792
49305
|
|
|
48793
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49306
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
|
|
48794
49307
|
var BACKFILL_ON_OPEN = 5e3;
|
|
48795
49308
|
var NOT_WRITABLE = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EROFS"]);
|
|
48796
49309
|
var createWritable = /* @__PURE__ */ __name((file) => {
|
|
@@ -48855,10 +49368,10 @@ var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Da
|
|
|
48855
49368
|
}
|
|
48856
49369
|
}, "openStoreContext");
|
|
48857
49370
|
|
|
48858
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49371
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
|
|
48859
49372
|
import { createHash as createHash16 } from "node:crypto";
|
|
48860
49373
|
|
|
48861
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49374
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
|
|
48862
49375
|
var text4 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
|
|
48863
49376
|
var ref = text4(2048);
|
|
48864
49377
|
var timestamp2 = pipe(number(), safeInteger(), minValue(0));
|
|
@@ -48924,7 +49437,7 @@ var projectAnnotationsSchema = strictObject({
|
|
|
48924
49437
|
}))
|
|
48925
49438
|
});
|
|
48926
49439
|
|
|
48927
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49440
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
|
|
48928
49441
|
var PROJECT_ANNOTATIONS_MAX_BYTES = 4 * 1024 * 1024;
|
|
48929
49442
|
var invalid9 = /* @__PURE__ */ __name((field4) => {
|
|
48930
49443
|
throw new CliError("validation_error", `invalid project annotations.${field4}`);
|
|
@@ -49028,7 +49541,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
|
|
|
49028
49541
|
invalid9("external.unused");
|
|
49029
49542
|
}, "validateProjectAnnotationsGraph");
|
|
49030
49543
|
|
|
49031
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49544
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
|
|
49032
49545
|
var hash = pipe(string(), regex(/^[a-f0-9]{64}$/));
|
|
49033
49546
|
var ref2 = pipe(string(), minLength(1), maxLength(2048));
|
|
49034
49547
|
var targetSchema = strictObject({
|
|
@@ -49134,7 +49647,7 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
|
|
|
49134
49647
|
};
|
|
49135
49648
|
}, "planBoundProjectAnnotations");
|
|
49136
49649
|
|
|
49137
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49650
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
|
|
49138
49651
|
import { createHash as createHash17 } from "node:crypto";
|
|
49139
49652
|
var text5 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
|
|
49140
49653
|
var timestamp3 = pipe(number(), safeInteger(), minValue(0));
|
|
@@ -49228,7 +49741,7 @@ var projectAnnotationSnapshotFingerprint = /* @__PURE__ */ __name((json3) => {
|
|
|
49228
49741
|
})).digest("hex");
|
|
49229
49742
|
}, "projectAnnotationSnapshotFingerprint");
|
|
49230
49743
|
|
|
49231
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49744
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
|
|
49232
49745
|
var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false) => {
|
|
49233
49746
|
if (!request || typeof request !== "object" || Array.isArray(request))
|
|
49234
49747
|
throw new CliError("validation_error", "project annotation request is required");
|
|
@@ -49245,7 +49758,7 @@ var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false)
|
|
|
49245
49758
|
return { snapshot: snapshot2, projectId: Number(request.project.slice(8)) };
|
|
49246
49759
|
}, "projectAnnotationRequest");
|
|
49247
49760
|
|
|
49248
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49761
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
|
|
49249
49762
|
var SnapshotBudget = class {
|
|
49250
49763
|
static {
|
|
49251
49764
|
__name(this, "SnapshotBudget");
|
|
@@ -49271,13 +49784,13 @@ var SnapshotBudget = class {
|
|
|
49271
49784
|
}
|
|
49272
49785
|
};
|
|
49273
49786
|
|
|
49274
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49787
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
|
|
49275
49788
|
import { createHash as createHash19 } from "node:crypto";
|
|
49276
49789
|
|
|
49277
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49790
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
|
|
49278
49791
|
var planProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3, target, bindings) => planBoundProjectAnnotations(decodeProjectAnnotationSnapshot(json3), projectAnnotationSnapshotFingerprint(json3), target, bindings), "planProjectAnnotationSnapshot");
|
|
49279
49792
|
|
|
49280
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49793
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
|
|
49281
49794
|
import { createHash as createHash18 } from "node:crypto";
|
|
49282
49795
|
var invalid11 = /* @__PURE__ */ __name(() => {
|
|
49283
49796
|
throw new CliError("configuration_error", "project snapshot has an unavailable or unsupported dependency");
|
|
@@ -49420,7 +49933,7 @@ var ProjectSnapshotSources = class {
|
|
|
49420
49933
|
}
|
|
49421
49934
|
};
|
|
49422
49935
|
|
|
49423
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
49936
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
|
|
49424
49937
|
var unsupported = /* @__PURE__ */ __name(() => {
|
|
49425
49938
|
throw new CliError("configuration_error", "project snapshot has unsupported metadata, deletion or account scope");
|
|
49426
49939
|
}, "unsupported");
|
|
@@ -49591,7 +50104,7 @@ var projectAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, bu
|
|
|
49591
50104
|
return { snapshot: snapshot2, read_bytes: budget.bytes, records: budget.records };
|
|
49592
50105
|
}), "projectAnnotationSnapshot");
|
|
49593
50106
|
|
|
49594
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50107
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
|
|
49595
50108
|
var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, manifest, bindings, budget) => read(database, () => {
|
|
49596
50109
|
const current = projectAnnotationSnapshot(database, projectId2, budget).snapshot;
|
|
49597
50110
|
const sources = new ProjectSnapshotSources(database, budget);
|
|
@@ -49653,7 +50166,7 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, ma
|
|
|
49653
50166
|
};
|
|
49654
50167
|
}), "previewAnnotationSnapshot");
|
|
49655
50168
|
|
|
49656
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50169
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
|
|
49657
50170
|
var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, snapshot2, bindings) => {
|
|
49658
50171
|
const mappings = { ...bindings };
|
|
49659
50172
|
const resolve = /* @__PURE__ */ __name((ref3) => {
|
|
@@ -49695,7 +50208,7 @@ var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, sna
|
|
|
49695
50208
|
return mappings;
|
|
49696
50209
|
}, "restoreAnnotationRecords");
|
|
49697
50210
|
|
|
49698
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50211
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
|
|
49699
50212
|
var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
49700
50213
|
async preview(request) {
|
|
49701
50214
|
const { snapshot: snapshot2, projectId: projectId2 } = projectAnnotationRequest(request);
|
|
@@ -49725,7 +50238,7 @@ var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
49725
50238
|
}
|
|
49726
50239
|
}), "projectAnnotationStoreOver");
|
|
49727
50240
|
|
|
49728
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50241
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/domain/records.js
|
|
49729
50242
|
import { createHash as createHash20 } from "node:crypto";
|
|
49730
50243
|
var RECORDS_SCHEMA_VERSION = 1;
|
|
49731
50244
|
var RECORD_OPERATIONS = ["upsert", "delete"];
|
|
@@ -49957,7 +50470,7 @@ var envelopeOfJsonl = /* @__PURE__ */ __name((text6) => {
|
|
|
49957
50470
|
return isObject2(header) ? { ...header, records: records2 } : header;
|
|
49958
50471
|
}, "envelopeOfJsonl");
|
|
49959
50472
|
|
|
49960
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50473
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/records.js
|
|
49961
50474
|
var PROJECTED = {
|
|
49962
50475
|
invoice: { roles: ["issuer", "counterparty", "project"], many: [] },
|
|
49963
50476
|
payment: { roles: ["payer", "payee", "project", "settles"], many: ["settles"] }
|
|
@@ -49975,7 +50488,7 @@ var codeOf = /* @__PURE__ */ __name((error) => {
|
|
|
49975
50488
|
return error.code === "not_found" ? "record.reference-not-found" : "record.entity";
|
|
49976
50489
|
}, "codeOf");
|
|
49977
50490
|
var unsettled = /* @__PURE__ */ __name((fields4, relations) => recordFingerprint(fields4, relations.filter((relation) => relation.role !== "settles")), "unsettled");
|
|
49978
|
-
var
|
|
50491
|
+
var iso13 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
49979
50492
|
var stringField = /* @__PURE__ */ __name((fields4, name) => {
|
|
49980
50493
|
const value = fields4[name];
|
|
49981
50494
|
if (value === void 0 || value === null)
|
|
@@ -50308,9 +50821,9 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50308
50821
|
entity: entityRef(row2.entity_type, row2.entity_id),
|
|
50309
50822
|
flagged: row2.entity_id != null && (row2.deleted_at != null || row2.projected_fingerprint !== row2.fingerprint),
|
|
50310
50823
|
batchId: String(row2.batch_id),
|
|
50311
|
-
createdAt:
|
|
50312
|
-
updatedAt:
|
|
50313
|
-
deletedAt: row2.deleted_at == null ? null :
|
|
50824
|
+
createdAt: iso13(row2.created_at),
|
|
50825
|
+
updatedAt: iso13(row2.updated_at),
|
|
50826
|
+
deletedAt: row2.deleted_at == null ? null : iso13(row2.deleted_at)
|
|
50314
50827
|
}), "sourceRecordOf");
|
|
50315
50828
|
const SELECT2 = "SELECT r.*, a.provider, a.external_id AS account FROM records r JOIN accounts a ON a.id = r.account_id ";
|
|
50316
50829
|
const rowOf2 = /* @__PURE__ */ __name((key2) => sql2(`${SELECT2}WHERE a.provider = ? AND a.external_id = ? AND r.type = ? AND r.external_id = ?`).get(key2.provider, key2.account, key2.type, key2.externalId), "rowOf");
|
|
@@ -50370,7 +50883,7 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50370
50883
|
};
|
|
50371
50884
|
}, "recordStoreOver");
|
|
50372
50885
|
|
|
50373
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50886
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
|
|
50374
50887
|
var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to) => {
|
|
50375
50888
|
const touching = and(eq(syncRanges.chatId, chatKey), lte(syncRanges.fromKey, to + 1), gte(syncRanges.toKey, from2 - 1));
|
|
50376
50889
|
let merged = { from: from2, to };
|
|
@@ -50383,7 +50896,7 @@ var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to)
|
|
|
50383
50896
|
}, "markRange");
|
|
50384
50897
|
var ranges = /* @__PURE__ */ __name(({ orm }, chatKey) => orm.select({ from: syncRanges.fromKey, to: syncRanges.toKey }).from(syncRanges).where(eq(syncRanges.chatId, chatKey)).orderBy(syncRanges.fromKey).all(), "ranges");
|
|
50385
50898
|
|
|
50386
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50899
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-analysis-marks.js
|
|
50387
50900
|
var prefixOf2 = /* @__PURE__ */ __name(({ provider, account }) => `task_analysis:${provider}:${account}:`, "prefixOf");
|
|
50388
50901
|
var markOf = /* @__PURE__ */ __name((prefix, row2) => ({
|
|
50389
50902
|
chatId: String(row2.key).slice(prefix.length),
|
|
@@ -50404,7 +50917,7 @@ var setTaskAnalysisMark = /* @__PURE__ */ __name((database, account, { chatId, c
|
|
|
50404
50917
|
database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(prefixOf2(account) + chatId, JSON.stringify({ ...saved, checkedAt: checkedAt ?? new Date(now2).toISOString() }), now2);
|
|
50405
50918
|
}, "setTaskAnalysisMark");
|
|
50406
50919
|
|
|
50407
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50920
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
|
|
50408
50921
|
var keyOf4 = /* @__PURE__ */ __name(({ provider, account }) => `task_rules_until:${provider}:${account}`, "keyOf");
|
|
50409
50922
|
var taskRulesStop = /* @__PURE__ */ __name((database, account) => {
|
|
50410
50923
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(keyOf4(account));
|
|
@@ -50414,7 +50927,7 @@ var setTaskRulesStop = /* @__PURE__ */ __name((database, account, until, now2) =
|
|
|
50414
50927
|
database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(keyOf4(account), JSON.stringify(until), now2);
|
|
50415
50928
|
}, "setTaskRulesStop");
|
|
50416
50929
|
|
|
50417
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50930
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sync.js
|
|
50418
50931
|
var syncStoreOver = /* @__PURE__ */ __name((context) => {
|
|
50419
50932
|
const { database } = context;
|
|
50420
50933
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, identityPk: identityPk2, writeMembers: writeMembers2, writeState: writeState2 } = keysOver(context);
|
|
@@ -50473,7 +50986,7 @@ var syncStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50473
50986
|
};
|
|
50474
50987
|
}, "syncStoreOver");
|
|
50475
50988
|
|
|
50476
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
50989
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/tags.js
|
|
50477
50990
|
var tagsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
50478
50991
|
const { database } = context;
|
|
50479
50992
|
return {
|
|
@@ -50495,7 +51008,7 @@ var tagsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50495
51008
|
};
|
|
50496
51009
|
}, "tagsStoreOver");
|
|
50497
51010
|
|
|
50498
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51011
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
|
|
50499
51012
|
var IS_IMAGE = sql`(a.kind = 'photo' OR a.mime LIKE 'image/%')`;
|
|
50500
51013
|
var neighbours = /* @__PURE__ */ __name(({ orm }, chatKey, messagePk, sentAt, { messages: messages2, withinMs }, side) => orm.all(sql`SELECT sender_name AS sender, text, sent_at AS sentAt FROM messages
|
|
50501
51014
|
WHERE chat_id = ${chatKey} AND deleted_at IS NULL AND trim(text) <> '' AND id <> ${messagePk}
|
|
@@ -50622,7 +51135,7 @@ var savePictureChunks = /* @__PURE__ */ __name(({ orm, now: now2, database }, ac
|
|
|
50622
51135
|
dropUnusedVectors(database, released.map(({ hash: hash2 }) => hash2));
|
|
50623
51136
|
}, "savePictureChunks");
|
|
50624
51137
|
|
|
50625
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51138
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
|
|
50626
51139
|
var messagesToEmbed = /* @__PURE__ */ __name(({ orm }, accountPk2, { chatKey, model, after: after2, limit }) => orm.all(sql`SELECT m.id AS messagePk, m.text, m.sent_at AS sentAt, k.content_hash AS hash,
|
|
50627
51140
|
EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ${model} AND v.content_hash = k.content_hash) AS embedded
|
|
50628
51141
|
FROM messages m
|
|
@@ -50711,7 +51224,7 @@ var nearestMessages = /* @__PURE__ */ __name((context, accountPk2, { limit, quer
|
|
|
50711
51224
|
return plain2(best(found2));
|
|
50712
51225
|
}, "nearestMessages");
|
|
50713
51226
|
|
|
50714
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51227
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/vectors.js
|
|
50715
51228
|
var accountVectorsOver = /* @__PURE__ */ __name((context, mail) => {
|
|
50716
51229
|
const { database } = context;
|
|
50717
51230
|
const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
|
|
@@ -50969,7 +51482,7 @@ var vectorsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
50969
51482
|
embeddedHashes: /* @__PURE__ */ __name(async (model, hashes) => embeddedHashes(context, model, hashes), "embeddedHashes")
|
|
50970
51483
|
}), "vectorsStoreOver");
|
|
50971
51484
|
|
|
50972
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51485
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
|
|
50973
51486
|
import { existsSync, readFileSync as readFileSync4 } from "node:fs";
|
|
50974
51487
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
50975
51488
|
var BOOKKEEPING = ["schema_migrations", "store_settings"];
|
|
@@ -51057,10 +51570,10 @@ var lastBackup = /* @__PURE__ */ __name((path) => {
|
|
|
51057
51570
|
}
|
|
51058
51571
|
}, "lastBackup");
|
|
51059
51572
|
|
|
51060
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51573
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/providers.js
|
|
51061
51574
|
var registerProvider2 = /* @__PURE__ */ __name((store, entry2) => store.accounts.registerProvider(entry2), "registerProvider");
|
|
51062
51575
|
|
|
51063
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51576
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
|
|
51064
51577
|
var COUNTED_TABLES = [
|
|
51065
51578
|
"accounts",
|
|
51066
51579
|
"chats",
|
|
@@ -51145,7 +51658,7 @@ var storeContents = /* @__PURE__ */ __name((database) => {
|
|
|
51145
51658
|
};
|
|
51146
51659
|
}, "storeContents");
|
|
51147
51660
|
|
|
51148
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
51661
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.588.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_b859f846da38ad2f474ef5e15fe95f19/node_modules/@wirecat/cli-core/dist/store/store.js
|
|
51149
51662
|
var openStore = /* @__PURE__ */ __name(async (options = {}) => {
|
|
51150
51663
|
const context = await openStoreContext(options);
|
|
51151
51664
|
try {
|
|
@@ -51211,6 +51724,7 @@ var storeOver = /* @__PURE__ */ __name((context) => {
|
|
|
51211
51724
|
const facts2 = once3(() => factsStoreOver(context));
|
|
51212
51725
|
const finance = once3(() => financeStoreOver(context));
|
|
51213
51726
|
const orders2 = once3(() => ordersStoreOver(context));
|
|
51727
|
+
const deals2 = once3(() => dealsStoreOver(context));
|
|
51214
51728
|
const records2 = once3(() => recordStoreOver(context));
|
|
51215
51729
|
const memories2 = once3(() => memoriesStoreOver(context));
|
|
51216
51730
|
const proposedActions2 = once3(() => proposedActionsStoreOver(context));
|
|
@@ -51321,6 +51835,9 @@ var storeOver = /* @__PURE__ */ __name((context) => {
|
|
|
51321
51835
|
get orders() {
|
|
51322
51836
|
return orders2();
|
|
51323
51837
|
},
|
|
51838
|
+
get deals() {
|
|
51839
|
+
return deals2();
|
|
51840
|
+
},
|
|
51324
51841
|
get records() {
|
|
51325
51842
|
return records2();
|
|
51326
51843
|
},
|
|
@@ -51449,6 +51966,9 @@ export {
|
|
|
51449
51966
|
mayDecide,
|
|
51450
51967
|
assertMayDecide,
|
|
51451
51968
|
deciderAuthor,
|
|
51969
|
+
DEAL_KINDS,
|
|
51970
|
+
DEAL_STATUSES,
|
|
51971
|
+
DEAL_ROLES,
|
|
51452
51972
|
openOf,
|
|
51453
51973
|
refLabel,
|
|
51454
51974
|
MAX_FILE_BYTES,
|
|
@@ -51497,6 +52017,7 @@ export {
|
|
|
51497
52017
|
ORGANIZATION_KINDS,
|
|
51498
52018
|
PROJECT_TYPES,
|
|
51499
52019
|
SCOPES,
|
|
52020
|
+
mailFindingFieldsHelp,
|
|
51500
52021
|
validateMailFindings,
|
|
51501
52022
|
registrableOf,
|
|
51502
52023
|
scoreGroup,
|