@wirecat/cli-memo 0.131.41 → 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-ZTYUFM24.js → all-profiles-ZBEW2K6Y.js} +5 -5
- package/dist/bundle/{anthropic-BLXCM7J2.js → anthropic-2OBFMS2B.js} +3 -3
- package/dist/bundle/{app-server-MXYDSTTW.js → app-server-2BPUD7XU.js} +35 -35
- package/dist/bundle/auto-NIATDHS4.js +86 -0
- package/dist/bundle/{bun-GFMA4TKJ.js → bun-4NGTZRHL.js} +2 -2
- package/dist/bundle/{bun-sqlite-3V6EB3XP.js → bun-sqlite-INSVTXFN.js} +2 -2
- package/dist/bundle/{chunk-J364I2EL.js → chunk-2IO2DEBO.js} +8 -8
- package/dist/bundle/{chunk-ONJAEHOD.js → chunk-2P54ZDQO.js} +7 -7
- package/dist/bundle/{chunk-AYOFFZMO.js → chunk-2XCXOI4F.js} +22 -4
- package/dist/bundle/{chunk-XXDWCZRM.js → chunk-42VOTRWE.js} +1 -1
- package/dist/bundle/{chunk-ULDE2Y7M.js → chunk-4OYYJSRS.js} +49 -48
- package/dist/bundle/{chunk-V5TOZXBU.js → chunk-5O3T7Z7F.js} +1267 -765
- package/dist/bundle/{chunk-QUA7EHLA.js → chunk-67TMJCHI.js} +10 -10
- package/dist/bundle/{chunk-2G66FZPO.js → chunk-6BW7SC6A.js} +1 -1
- package/dist/bundle/{chunk-A6HC2DWU.js → chunk-A2KU4HSF.js} +56 -56
- package/dist/bundle/{chunk-UA2H5FRV.js → chunk-CKLLVPTR.js} +1 -1
- package/dist/bundle/{chunk-RMJLG2D6.js → chunk-CZ2CX43P.js} +4 -4
- package/dist/bundle/{chunk-G6EOW6PY.js → chunk-DA5YMQCB.js} +2 -2
- package/dist/bundle/{chunk-SCIU5WHL.js → chunk-E3P7PIR3.js} +3 -3
- package/dist/bundle/{chunk-WG3JJ7D5.js → chunk-EKFHAT36.js} +1 -1
- package/dist/bundle/{chunk-OY2CMEUW.js → chunk-ELPCHMDA.js} +3 -3
- package/dist/bundle/{chunk-FVN42IND.js → chunk-F6UUS3OF.js} +1 -1
- package/dist/bundle/{chunk-OLVBY6N6.js → chunk-GECE7WJD.js} +2 -2
- package/dist/bundle/{chunk-Y4B4273X.js → chunk-GHLLCV4E.js} +7 -7
- package/dist/bundle/{chunk-7AS5QFWJ.js → chunk-HCMQGNZU.js} +5 -5
- package/dist/bundle/{chunk-7EOGXNLO.js → chunk-HQQC5JRS.js} +4 -4
- package/dist/bundle/{chunk-RZUSWGAC.js → chunk-IAML53OZ.js} +2 -2
- package/dist/bundle/{chunk-BFN5KXGH.js → chunk-JWQWLMFP.js} +257 -257
- package/dist/bundle/{chunk-2E4N5DVE.js → chunk-KBOLP4OR.js} +27 -27
- package/dist/bundle/{chunk-2O2BSM4K.js → chunk-KHEFBWLH.js} +1 -1
- package/dist/bundle/{chunk-JO3FC5B4.js → chunk-KKXXP5RY.js} +7 -7
- package/dist/bundle/{chunk-6V6VCYOS.js → chunk-KVKO4X7K.js} +3 -3
- package/dist/bundle/{chunk-LGILT5CA.js → chunk-LBMZ7SQI.js} +2 -2
- package/dist/bundle/{chunk-RNINC74Q.js → chunk-LJDBOXZN.js} +1 -1
- package/dist/bundle/{chunk-VT4PCMY2.js → chunk-MWKPW3RU.js} +1 -1
- package/dist/bundle/{chunk-ZETAM63O.js → chunk-NCBHNEWW.js} +1 -1
- package/dist/bundle/{chunk-5KL7T2EP.js → chunk-NP5FU56F.js} +1 -1
- package/dist/bundle/{chunk-NKKC6SLX.js → chunk-O34QHLL5.js} +1 -1
- package/dist/bundle/{chunk-Y7XDV4GQ.js → chunk-O4I3BJPM.js} +6 -6
- package/dist/bundle/{chunk-IJJ4OEXK.js → chunk-O6YTC7DC.js} +1 -1
- package/dist/bundle/{chunk-776YSJJY.js → chunk-OAIRZNL2.js} +1 -1
- package/dist/bundle/{chunk-ARNYYXLO.js → chunk-OJX6GNQY.js} +20 -20
- package/dist/bundle/{chunk-ISVO2PHD.js → chunk-OYHQYCGJ.js} +4 -4
- package/dist/bundle/{chunk-DYSWDGOU.js → chunk-PRL227K7.js} +5 -5
- package/dist/bundle/{chunk-NYNUDUFA.js → chunk-QWNEZWGZ.js} +4 -4
- package/dist/bundle/{chunk-F3OGJQWY.js → chunk-QWNVEFWY.js} +5 -5
- package/dist/bundle/{chunk-WFME7ILV.js → chunk-QWZUMUA7.js} +5 -5
- package/dist/bundle/{chunk-QCE6BNKK.js → chunk-RHIQ34XW.js} +2 -2
- package/dist/bundle/{chunk-PPSIMMJM.js → chunk-RV4EBFH2.js} +17 -9
- package/dist/bundle/{chunk-7GEK5BE5.js → chunk-T4NH7JI6.js} +2 -2
- package/dist/bundle/{chunk-N2EY7NT3.js → chunk-TBGBA45H.js} +1 -1
- package/dist/bundle/{chunk-LLL4RBDU.js → chunk-TCNOZZPS.js} +11 -11
- package/dist/bundle/{chunk-B5LF2FVU.js → chunk-TWBJOORY.js} +1 -1
- package/dist/bundle/{chunk-VF24JTL4.js → chunk-TXU5T7VA.js} +1 -1
- package/dist/bundle/{chunk-NFN3JTGD.js → chunk-UCLNEOQS.js} +12 -12
- package/dist/bundle/{chunk-S7TVQ7ES.js → chunk-UK2MCVKV.js} +305 -248
- package/dist/bundle/{chunk-3MVDNB6Y.js → chunk-UX34ZUMK.js} +3 -3
- package/dist/bundle/{chunk-BJWDBPLF.js → chunk-W7GJREIL.js} +2 -2
- package/dist/bundle/{chunk-YNYOWOKD.js → chunk-WFA2ZLJB.js} +148 -148
- package/dist/bundle/{chunk-RMMYPYNA.js → chunk-WG6AOUQW.js} +20 -20
- package/dist/bundle/{chunk-BA3HPVBN.js → chunk-WSPCOSYD.js} +4 -4
- package/dist/bundle/{chunk-NP7Y3JQ7.js → chunk-XUNIJW7V.js} +9 -9
- package/dist/bundle/{chunk-IJS2X4AZ.js → chunk-YLJWCB6F.js} +43 -43
- package/dist/bundle/{command-contract-KCV6NNGF.js → command-contract-EYE52WTH.js} +11 -11
- package/dist/bundle/{decode-SU7TIUXV.js → decode-JVG6DJJV.js} +2 -2
- package/dist/bundle/{echarts-CJG2WVOX.js → echarts-4IS4IPI4.js} +2 -2
- package/dist/bundle/{embed-IBURCPTK.js → embed-7CN33CQR.js} +3 -3
- package/dist/bundle/{embedder-SK773RJG.js → embedder-TZ345BZF.js} +6 -6
- package/dist/bundle/{entry-6WOJUMZN.js → entry-5VZRNBLV.js} +4 -4
- package/dist/bundle/failure-KIFYUUO6.js +66 -0
- package/dist/bundle/{first-run-CMSDLJGE.js → first-run-EMHSBODF.js} +5 -5
- package/dist/bundle/{first-screen-6IZLOQ3Q.js → first-screen-3PJ3HFLG.js} +12 -12
- package/dist/bundle/{instructions-RHGGUIBR.js → instructions-BTAYTZIS.js} +1 -1
- package/dist/bundle/{mcp-HBKMY35O.js → mcp-I5KREUIV.js} +35 -35
- package/dist/bundle/memo.js +6 -6
- package/dist/bundle/{node-NBXEN7JU.js → node-FMT4QVUG.js} +2 -2
- package/dist/bundle/{node-sqlite-WAGIYOYR.js → node-sqlite-2RDIBVYM.js} +3 -3
- package/dist/bundle/{oauth-INSEXJD2.js → oauth-MF53KMXM.js} +4 -4
- package/dist/bundle/{open-LXFV2C67.js → open-WKKHNBXL.js} +2 -2
- package/dist/bundle/{openai-OCWAXC7E.js → openai-36KNG2DB.js} +7 -7
- package/dist/bundle/{process-MRPJP32M.js → process-F2FWK4Q4.js} +1 -1
- package/dist/bundle/{program-XKO4X6BB.js → program-W55Y6LL2.js} +342 -90
- package/dist/bundle/{prompt-ROLOHFNO.js → prompt-2TR6X3TJ.js} +2 -2
- package/dist/bundle/{recognize-63ZLC4DN.js → recognize-MOBCGUI7.js} +1 -1
- package/dist/bundle/{remote-J4ZBFG3Y.js → remote-GARKVCO7.js} +4 -4
- package/dist/bundle/{rerank-HUQCCGYO.js → rerank-L3G7P3KX.js} +4 -4
- package/dist/bundle/{serve-MFJYL4AB.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-2JQ5K33G.js → server-XLMROR5L.js} +50 -50
- package/dist/bundle/{state-AV5MO77W.js → state-5N2RVH2Y.js} +3 -3
- package/dist/bundle/{store-H4HCVN4H.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/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/program.d.ts.map +1 -1
- package/dist/program.js +65 -0
- package/dist/program.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/dist/bundle/auto-2RK6FE5A.js +0 -86
- package/dist/bundle/failure-4N6GOEGN.js +0 -66
- package/dist/bundle/server-RKPGL53W.js +0 -48
- package/dist/bundle/server-ZN2KC4EE.js +0 -61
- package/dist/bundle/store-maintenance-command-4GYOMUXE.js +0 -48
- package/dist/bundle/update-ATXEHV72.js +0 -69
- /package/dist/bundle/{chunk-VVDYRHYP.js → chunk-O3EZTSTN.js} +0 -0
|
@@ -100,11 +100,11 @@ import {
|
|
|
100
100
|
validateQuery,
|
|
101
101
|
walkQuery,
|
|
102
102
|
zonedMoment
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-A2KU4HSF.js";
|
|
104
104
|
import {
|
|
105
105
|
holdsCredential,
|
|
106
106
|
secretNamed
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-42VOTRWE.js";
|
|
108
108
|
import {
|
|
109
109
|
DEFAULT_STEMMERS,
|
|
110
110
|
DEFAULT_STEMMERS_VERSION,
|
|
@@ -117,26 +117,26 @@ import {
|
|
|
117
117
|
fold,
|
|
118
118
|
normalize,
|
|
119
119
|
parseStemmers
|
|
120
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-GHLLCV4E.js";
|
|
121
121
|
import {
|
|
122
122
|
DEFAULT_TASK_CATEGORIES,
|
|
123
123
|
sharedConfigPath,
|
|
124
124
|
storedTaskCategories,
|
|
125
125
|
taskCategoriesReader
|
|
126
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-OYHQYCGJ.js";
|
|
127
127
|
import {
|
|
128
128
|
refuseOwnerStoreInTests,
|
|
129
129
|
storePath
|
|
130
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-F6UUS3OF.js";
|
|
131
131
|
import {
|
|
132
132
|
quietSqliteWarning,
|
|
133
133
|
storeCapable
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-QWNVEFWY.js";
|
|
135
135
|
import {
|
|
136
136
|
PRAGMAS,
|
|
137
137
|
TIME_LIMIT_FUNCTION,
|
|
138
138
|
TimeLimitReached
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-CKLLVPTR.js";
|
|
140
140
|
import {
|
|
141
141
|
array,
|
|
142
142
|
boolean,
|
|
@@ -186,7 +186,7 @@ import {
|
|
|
186
186
|
sql,
|
|
187
187
|
sqliteTable,
|
|
188
188
|
text
|
|
189
|
-
} from "./chunk-
|
|
189
|
+
} from "./chunk-TXU5T7VA.js";
|
|
190
190
|
import {
|
|
191
191
|
__commonJS,
|
|
192
192
|
__name,
|
|
@@ -9930,7 +9930,7 @@ var require_cjs = __commonJS({
|
|
|
9930
9930
|
}
|
|
9931
9931
|
});
|
|
9932
9932
|
|
|
9933
|
-
// 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
|
|
9934
9934
|
var bindArea = /* @__PURE__ */ __name(({ keyed, whole }, account) => {
|
|
9935
9935
|
const methods = whole;
|
|
9936
9936
|
return Object.fromEntries(Object.keys(keyed).map((name) => [
|
|
@@ -10058,7 +10058,7 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
|
|
|
10058
10058
|
};
|
|
10059
10059
|
}, "bindAccount");
|
|
10060
10060
|
|
|
10061
|
-
// 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
|
|
10062
10062
|
var SCHEME = "msg:";
|
|
10063
10063
|
var formatLocator = /* @__PURE__ */ __name(({ provider, account, chat: chat2, message: message2 }) => SCHEME + [provider, account, chat2, message2].map(encodeURIComponent).join("/"), "formatLocator");
|
|
10064
10064
|
var isLocator = /* @__PURE__ */ __name((reference2) => reference2.trim().startsWith(SCHEME), "isLocator");
|
|
@@ -10072,7 +10072,7 @@ var parseLocator = /* @__PURE__ */ __name((reference2) => {
|
|
|
10072
10072
|
return { provider, account, chat: chat2, message: message2 };
|
|
10073
10073
|
}, "parseLocator");
|
|
10074
10074
|
|
|
10075
|
-
// 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
|
|
10076
10076
|
var SIMPLE_REFERENCES = [
|
|
10077
10077
|
"note",
|
|
10078
10078
|
"document",
|
|
@@ -10087,6 +10087,9 @@ var SIMPLE_REFERENCES = [
|
|
|
10087
10087
|
"invoice",
|
|
10088
10088
|
"payment",
|
|
10089
10089
|
"order",
|
|
10090
|
+
"deal",
|
|
10091
|
+
"lead",
|
|
10092
|
+
"pipeline",
|
|
10090
10093
|
"entity"
|
|
10091
10094
|
];
|
|
10092
10095
|
var malformed = /* @__PURE__ */ __name((text6, shape) => new CliError("validation_error", `"${singleLine(text6)}" is not a reference \u2014 expected ${shape}`, {
|
|
@@ -10220,7 +10223,7 @@ var looksLikeReference = /* @__PURE__ */ __name((text6) => {
|
|
|
10220
10223
|
return match !== null && byPrefix.has(match[1]);
|
|
10221
10224
|
}, "looksLikeReference");
|
|
10222
10225
|
|
|
10223
|
-
// 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
|
|
10224
10227
|
var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events"];
|
|
10225
10228
|
var MESSENGER_OPENS = { chat: "messages list", message: "messages show", contact: "contacts show" };
|
|
10226
10229
|
var PROVIDERS = [
|
|
@@ -10336,7 +10339,7 @@ var providerNamed = /* @__PURE__ */ __name((word2) => {
|
|
|
10336
10339
|
var kindIn = /* @__PURE__ */ __name((provider) => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind, "kindIn");
|
|
10337
10340
|
var kindOf = /* @__PURE__ */ __name((provider) => kindIn(provider) ?? "messages", "kindOf");
|
|
10338
10341
|
|
|
10339
|
-
// 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
|
|
10340
10343
|
var isBotProvider = /* @__PURE__ */ __name((provider) => provider.endsWith("-bot"), "isBotProvider");
|
|
10341
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");
|
|
10342
10345
|
var fail = /* @__PURE__ */ __name((message2) => {
|
|
@@ -10359,7 +10362,7 @@ var sourceOf = /* @__PURE__ */ __name((name, value, providers2) => {
|
|
|
10359
10362
|
return fail(`${name} takes ${[...sources, "messages", "mail"].join(", ")} \u2014 not "${value}"`);
|
|
10360
10363
|
}, "sourceOf");
|
|
10361
10364
|
|
|
10362
|
-
// 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
|
|
10363
10366
|
var ACCOUNT_GROUPS = "accountGroups";
|
|
10364
10367
|
var ACCOUNT_GROUPS_SETTING = "account_groups";
|
|
10365
10368
|
var GROUP_NAME = /^[a-z0-9][a-z0-9_-]*$/i;
|
|
@@ -10546,7 +10549,7 @@ var fitting = /* @__PURE__ */ __name((entries, kinds2, what, reasonOf2 = (kind4)
|
|
|
10546
10549
|
return { accounts: [...chosen.values()], skipped };
|
|
10547
10550
|
}, "fitting");
|
|
10548
10551
|
|
|
10549
|
-
// 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
|
|
10550
10553
|
var IndexBuilderOn = class {
|
|
10551
10554
|
static {
|
|
10552
10555
|
__name(this, "IndexBuilderOn");
|
|
@@ -10741,7 +10744,7 @@ function alias(table, alias2) {
|
|
|
10741
10744
|
}
|
|
10742
10745
|
__name(alias, "alias");
|
|
10743
10746
|
|
|
10744
|
-
// 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
|
|
10745
10748
|
var ENTITY_TABLES = {
|
|
10746
10749
|
account: "accounts",
|
|
10747
10750
|
attachment: "attachments",
|
|
@@ -10749,6 +10752,7 @@ var ENTITY_TABLES = {
|
|
|
10749
10752
|
calendar_entry: "calendar_entries",
|
|
10750
10753
|
chat: "chats",
|
|
10751
10754
|
conversation: "conversations",
|
|
10755
|
+
deal: "deals",
|
|
10752
10756
|
document: "documents",
|
|
10753
10757
|
document_picture: "documents",
|
|
10754
10758
|
email: "emails",
|
|
@@ -10760,6 +10764,7 @@ var ENTITY_TABLES = {
|
|
|
10760
10764
|
identity: "identities",
|
|
10761
10765
|
image: "attachments",
|
|
10762
10766
|
invoice: "invoices",
|
|
10767
|
+
lead: "leads",
|
|
10763
10768
|
meeting: "meetings",
|
|
10764
10769
|
meeting_transcript: "meeting_transcripts",
|
|
10765
10770
|
meeting_transcript_row: "meeting_transcript_rows",
|
|
@@ -10770,6 +10775,7 @@ var ENTITY_TABLES = {
|
|
|
10770
10775
|
organization: "organizations",
|
|
10771
10776
|
payment: "payments",
|
|
10772
10777
|
person: "persons",
|
|
10778
|
+
pipeline: "pipelines",
|
|
10773
10779
|
place: "places",
|
|
10774
10780
|
project: "projects",
|
|
10775
10781
|
tag: "canonical_tags",
|
|
@@ -10784,7 +10790,7 @@ var orphanPointers = /* @__PURE__ */ __name((database) => pointerPairs(database)
|
|
|
10784
10790
|
return { table, pointer, type, count, known: known2 };
|
|
10785
10791
|
}).filter(({ count }) => count > 0)), "orphanPointers");
|
|
10786
10792
|
|
|
10787
|
-
// 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
|
|
10788
10794
|
var canonicalTags = sqliteTable("canonical_tags", {
|
|
10789
10795
|
id: integer("id").primaryKey(),
|
|
10790
10796
|
name: text("name").notNull().unique(),
|
|
@@ -10793,7 +10799,7 @@ var canonicalTags = sqliteTable("canonical_tags", {
|
|
|
10793
10799
|
updatedAt: integer("updated_at").notNull()
|
|
10794
10800
|
});
|
|
10795
10801
|
|
|
10796
|
-
// 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
|
|
10797
10803
|
var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
|
|
10798
10804
|
sourceKey: text("source_key").notNull(),
|
|
10799
10805
|
collection: text("collection").notNull(),
|
|
@@ -10803,13 +10809,13 @@ var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
|
|
|
10803
10809
|
createdAt: integer("created_at").notNull()
|
|
10804
10810
|
}, (table) => [primaryKey({ columns: [table.sourceKey, table.collection] })]);
|
|
10805
10811
|
|
|
10806
|
-
// 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
|
|
10807
10813
|
var documentIndexPending = sqliteTable("document_index_pending", {
|
|
10808
10814
|
id: integer("id").notNull(),
|
|
10809
10815
|
indexableType: text("indexable_type").notNull()
|
|
10810
10816
|
}, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
|
|
10811
10817
|
|
|
10812
|
-
// 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
|
|
10813
10819
|
var tagRedirects = sqliteTable("tag_redirects", {
|
|
10814
10820
|
sourceId: integer("source_id").primaryKey().references(() => canonicalTags.id),
|
|
10815
10821
|
survivorId: integer("survivor_id").notNull().references(() => canonicalTags.id),
|
|
@@ -10835,7 +10841,7 @@ var tagConsolidations = sqliteTable("tag_consolidations", {
|
|
|
10835
10841
|
index("tag_consolidations_by_actor_type_actor_id").on(table.actorType, table.actorId)
|
|
10836
10842
|
]);
|
|
10837
10843
|
|
|
10838
|
-
// 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
|
|
10839
10845
|
var accounts = sqliteTable("accounts", {
|
|
10840
10846
|
id: integer("id").primaryKey(),
|
|
10841
10847
|
provider: text("provider").notNull(),
|
|
@@ -12161,6 +12167,108 @@ var orders = sqliteTable("orders", {
|
|
|
12161
12167
|
index("orders_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
12162
12168
|
index("orders_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById)
|
|
12163
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
|
+
]);
|
|
12164
12272
|
var records = sqliteTable("records", {
|
|
12165
12273
|
id: integer("id").primaryKey(),
|
|
12166
12274
|
accountId: integer("account_id").notNull().references(() => accounts.id),
|
|
@@ -12502,7 +12610,7 @@ var storeSettings = sqliteTable("store_settings", {
|
|
|
12502
12610
|
at: integer("at").notNull()
|
|
12503
12611
|
});
|
|
12504
12612
|
|
|
12505
|
-
// 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
|
|
12506
12614
|
var ARMS = [
|
|
12507
12615
|
[
|
|
12508
12616
|
"message",
|
|
@@ -12629,7 +12737,7 @@ var drainInvolvementQueue = /* @__PURE__ */ __name((database, cap = QUEUE_CAP) =
|
|
|
12629
12737
|
return recomputed;
|
|
12630
12738
|
}, "drainInvolvementQueue");
|
|
12631
12739
|
|
|
12632
|
-
// 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
|
|
12633
12741
|
import { domainToUnicode } from "node:url";
|
|
12634
12742
|
|
|
12635
12743
|
// node_modules/.pnpm/psl@1.15.0/node_modules/psl/dist/psl.mjs
|
|
@@ -22651,7 +22759,7 @@ var oa = /* @__PURE__ */ __name((e) => {
|
|
|
22651
22759
|
}, "oa");
|
|
22652
22760
|
var na = { parse: O, get: aa, isValid: oa };
|
|
22653
22761
|
|
|
22654
|
-
// 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
|
|
22655
22763
|
var LINK = /https?:\/\/(?:(?:docs|drive|sheets|slides)\.google\.com|forms\.gle)(?:[/?#][^\s<>"'`]*)?/gi;
|
|
22656
22764
|
var ID = /^[\w-]{10,}$/;
|
|
22657
22765
|
var trimUrl = /* @__PURE__ */ __name((url) => {
|
|
@@ -22692,7 +22800,7 @@ var googleDocumentLinks = /* @__PURE__ */ __name((text6) => [...text6.matchAll(L
|
|
|
22692
22800
|
return { url, documentId: googleDocumentId(url) };
|
|
22693
22801
|
}), "googleDocumentLinks");
|
|
22694
22802
|
|
|
22695
|
-
// 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
|
|
22696
22804
|
var PHONE_PLANS = [
|
|
22697
22805
|
{
|
|
22698
22806
|
country: "us",
|
|
@@ -23072,7 +23180,7 @@ var PHONE_PLANS = [
|
|
|
23072
23180
|
}
|
|
23073
23181
|
];
|
|
23074
23182
|
|
|
23075
|
-
// 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
|
|
23076
23184
|
var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
|
|
23077
23185
|
var DEFAULT_PHONE_COUNTRIES = ["ru"];
|
|
23078
23186
|
var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
|
|
@@ -23113,7 +23221,7 @@ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
|
|
|
23113
23221
|
return void 0;
|
|
23114
23222
|
}, "nationalPhone");
|
|
23115
23223
|
|
|
23116
|
-
// 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
|
|
23117
23225
|
var BEFORE = [
|
|
23118
23226
|
[/^(?:ул\.?|улиц[аеыу]|улицей)$/iu, "\u0443\u043B\u0438\u0446\u0430"],
|
|
23119
23227
|
[/^(?:пр-т|просп\.?|проспект[аеу]?)$/iu, "\u043F\u0440\u043E\u0441\u043F\u0435\u043A\u0442"],
|
|
@@ -23373,7 +23481,7 @@ var findPlaces = /* @__PURE__ */ __name((text6) => {
|
|
|
23373
23481
|
return found2.sort((a, b) => a.start - b.start);
|
|
23374
23482
|
}, "findPlaces");
|
|
23375
23483
|
|
|
23376
|
-
// 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
|
|
23377
23485
|
var MENTION_KINDS = ["phone", "email", "url", "document", "person-name", "place"];
|
|
23378
23486
|
var MENTION_VERSIONS = {
|
|
23379
23487
|
phone: 1,
|
|
@@ -23563,7 +23671,7 @@ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE
|
|
|
23563
23671
|
};
|
|
23564
23672
|
}, "typedPhone");
|
|
23565
23673
|
|
|
23566
|
-
// 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
|
|
23567
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";
|
|
23568
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";
|
|
23569
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";
|
|
@@ -23571,7 +23679,7 @@ var NOT_NAMES = ["\u0436\u0435\u043D\u0430", "\u0436\u0435\u043D\u044B", "\u0436
|
|
|
23571
23679
|
var FIRST_NAMES = [...new Set(`${RUSSIAN} ${EUROPEAN}`.split(" "))];
|
|
23572
23680
|
var NAME_WORDS = WORDS.split(" ");
|
|
23573
23681
|
|
|
23574
|
-
// 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
|
|
23575
23683
|
var LATIN_TO_CYRILLIC = {
|
|
23576
23684
|
shch: "\u0449",
|
|
23577
23685
|
sch: "\u0449",
|
|
@@ -23779,7 +23887,7 @@ var findUnknownNames = /* @__PURE__ */ __name((text6, stem, taken) => {
|
|
|
23779
23887
|
return found2;
|
|
23780
23888
|
}, "findUnknownNames");
|
|
23781
23889
|
|
|
23782
|
-
// 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
|
|
23783
23891
|
var NOT_FILES = /* @__PURE__ */ new Set([
|
|
23784
23892
|
"webpage",
|
|
23785
23893
|
"share",
|
|
@@ -23819,7 +23927,7 @@ var matchDownloads = /* @__PURE__ */ __name((stored3, files2) => {
|
|
|
23819
23927
|
});
|
|
23820
23928
|
}, "matchDownloads");
|
|
23821
23929
|
|
|
23822
|
-
// 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
|
|
23823
23931
|
var QUERY_VERSION = 1;
|
|
23824
23932
|
var QUERY_LIMITS2 = {
|
|
23825
23933
|
...QUERY_LIMITS,
|
|
@@ -23855,7 +23963,7 @@ function exhausted(budget) {
|
|
|
23855
23963
|
}
|
|
23856
23964
|
__name(exhausted, "exhausted");
|
|
23857
23965
|
|
|
23858
|
-
// 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
|
|
23859
23967
|
var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
|
|
23860
23968
|
var literal2 = /* @__PURE__ */ __name((c) => ({
|
|
23861
23969
|
kind: "char",
|
|
@@ -24255,7 +24363,7 @@ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
|
|
|
24255
24363
|
return out;
|
|
24256
24364
|
}, "foldRegex");
|
|
24257
24365
|
|
|
24258
|
-
// 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
|
|
24259
24367
|
var PRESET_VERSION = 1;
|
|
24260
24368
|
var PRESETS = {
|
|
24261
24369
|
password: {
|
|
@@ -24309,7 +24417,7 @@ var PRESETS = {
|
|
|
24309
24417
|
}
|
|
24310
24418
|
};
|
|
24311
24419
|
|
|
24312
|
-
// 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
|
|
24313
24421
|
var FIELD_VERSION = 2;
|
|
24314
24422
|
var UNITS = {
|
|
24315
24423
|
"": 1,
|
|
@@ -24770,12 +24878,12 @@ var validateAst = /* @__PURE__ */ __name((input) => {
|
|
|
24770
24878
|
return validateFields(parsed3.output);
|
|
24771
24879
|
}, "validateAst");
|
|
24772
24880
|
|
|
24773
|
-
// 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
|
|
24774
24882
|
var hasText = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "text" || node.field === "exact" : node.clauses.some(({ node: node2 }) => hasText(node2)), "hasText");
|
|
24775
24883
|
var isStemmed = /* @__PURE__ */ __name((node) => node.field === "text" && (node.operator === "term" || node.operator === "phrase") && node.value !== "", "isStemmed");
|
|
24776
24884
|
var hasStems = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? isStemmed(node) : node.clauses.some(({ node: node2 }) => hasStems(node2)), "hasStems");
|
|
24777
24885
|
|
|
24778
|
-
// 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
|
|
24779
24887
|
var LIVE = "mn.kind = 'url' AND mn.status <> 'dismissed'";
|
|
24780
24888
|
var MAIL_ROWS = `SELECT mn.source_id FROM mentions mn WHERE mn.source_type = 'email' AND ${LIVE}`;
|
|
24781
24889
|
var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
|
|
@@ -24799,7 +24907,7 @@ var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
|
|
|
24799
24907
|
};
|
|
24800
24908
|
}, "linkMatch");
|
|
24801
24909
|
|
|
24802
|
-
// 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
|
|
24803
24911
|
var SETTING = "phoneCountries";
|
|
24804
24912
|
var savedPhoneCountries = /* @__PURE__ */ __name((database) => {
|
|
24805
24913
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING);
|
|
@@ -24830,7 +24938,7 @@ var valueMatch = /* @__PURE__ */ __name((database, typed) => {
|
|
|
24830
24938
|
return { sql: "mn.value = ?", params: [phone?.value ?? normalizedValue(typed, { phoneCountries })] };
|
|
24831
24939
|
}, "valueMatch");
|
|
24832
24940
|
|
|
24833
|
-
// 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
|
|
24834
24942
|
var normalizeVocabularyName = /* @__PURE__ */ __name((input) => {
|
|
24835
24943
|
if (typeof input !== "string" || input.length > 200 || /[\p{Cc}\p{Cf}]/u.test(input))
|
|
24836
24944
|
throw new CliError("validation_error", "a vocabulary name takes 1\u2013200 characters without control characters");
|
|
@@ -24858,7 +24966,7 @@ var vocabularySimilarity = /* @__PURE__ */ __name((left, right) => {
|
|
|
24858
24966
|
return 2 * intersection2 / (aa2.size + bb.size);
|
|
24859
24967
|
}, "vocabularySimilarity");
|
|
24860
24968
|
|
|
24861
|
-
// 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
|
|
24862
24970
|
import { createHash } from "node:crypto";
|
|
24863
24971
|
var folded2 = /* @__PURE__ */ __name((name) => {
|
|
24864
24972
|
try {
|
|
@@ -24924,7 +25032,7 @@ var guardTagCreation = /* @__PURE__ */ __name((context, name, kind4, by, options
|
|
|
24924
25032
|
});
|
|
24925
25033
|
}, "guardTagCreation");
|
|
24926
25034
|
|
|
24927
|
-
// 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
|
|
24928
25036
|
var invalid2 = /* @__PURE__ */ __name((message2) => {
|
|
24929
25037
|
throw new CliError("validation_error", message2);
|
|
24930
25038
|
}, "invalid");
|
|
@@ -25001,7 +25109,7 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
|
|
|
25001
25109
|
};
|
|
25002
25110
|
}, "createTagRedirectIndex");
|
|
25003
25111
|
|
|
25004
|
-
// 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
|
|
25005
25113
|
var tagCanonicalId = /* @__PURE__ */ __name((database, id2) => {
|
|
25006
25114
|
const row2 = database.prepare("SELECT canonical_id FROM resolved_tags WHERE id=?").get(id2);
|
|
25007
25115
|
if (!row2)
|
|
@@ -25029,7 +25137,7 @@ var tagRedirectSnapshot = /* @__PURE__ */ __name((database) => {
|
|
|
25029
25137
|
return snapshot2;
|
|
25030
25138
|
}, "tagRedirectSnapshot");
|
|
25031
25139
|
|
|
25032
|
-
// 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
|
|
25033
25141
|
import { createHash as createHash2 } from "node:crypto";
|
|
25034
25142
|
var TASK_KEY_PREFIXES = {
|
|
25035
25143
|
question: "Q",
|
|
@@ -25057,7 +25165,7 @@ var taskAccountOf = /* @__PURE__ */ __name((database, rowId) => {
|
|
|
25057
25165
|
return row2 && String(row2.key) === inboxKey(String(row2.name)) ? String(row2.name) : void 0;
|
|
25058
25166
|
}, "taskAccountOf");
|
|
25059
25167
|
|
|
25060
|
-
// 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
|
|
25061
25169
|
var storedThing = /* @__PURE__ */ __name((type, id2) => ({ type: String(type), id: Number(id2) }), "storedThing");
|
|
25062
25170
|
var REFERABLE = {
|
|
25063
25171
|
note: { tombstone: true },
|
|
@@ -25073,6 +25181,9 @@ var REFERABLE = {
|
|
|
25073
25181
|
invoice: { tombstone: true },
|
|
25074
25182
|
payment: { tombstone: true },
|
|
25075
25183
|
order: { tombstone: true },
|
|
25184
|
+
deal: { tombstone: true },
|
|
25185
|
+
lead: { tombstone: true },
|
|
25186
|
+
pipeline: { tombstone: false },
|
|
25076
25187
|
message: { tombstone: true },
|
|
25077
25188
|
email: { tombstone: true },
|
|
25078
25189
|
email_thread: { tombstone: true },
|
|
@@ -25222,11 +25333,11 @@ var taskIdOf = /* @__PURE__ */ __name((database, rowId) => {
|
|
|
25222
25333
|
return row2 ? String(row2.id ?? row2.key) : void 0;
|
|
25223
25334
|
}, "taskIdOf");
|
|
25224
25335
|
|
|
25225
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25226
|
-
var toMs = /* @__PURE__ */ __name((
|
|
25227
|
-
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)
|
|
25228
25339
|
return null;
|
|
25229
|
-
const ms = Date.parse(
|
|
25340
|
+
const ms = Date.parse(iso14);
|
|
25230
25341
|
return Number.isNaN(ms) ? null : ms;
|
|
25231
25342
|
}, "toMs");
|
|
25232
25343
|
var toIso = /* @__PURE__ */ __name((ms) => typeof ms === "number" ? new Date(ms).toISOString() : null, "toIso");
|
|
@@ -25236,7 +25347,7 @@ var present = /* @__PURE__ */ __name((entries) => Object.fromEntries(Object.entr
|
|
|
25236
25347
|
var DELIVERY = { delivered: 1, read: 2 };
|
|
25237
25348
|
var deliveryOf = /* @__PURE__ */ __name((stored3) => stored3 === DELIVERY.read ? "read" : stored3 === DELIVERY.delivered ? "delivered" : void 0, "deliveryOf");
|
|
25238
25349
|
|
|
25239
|
-
// 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
|
|
25240
25351
|
var TAG_KINDS = ["tag", "topic"];
|
|
25241
25352
|
var TAGGABLE = { chat: "chat", contact: "identity", message: "message", task: "task" };
|
|
25242
25353
|
var TAG_TYPE = {
|
|
@@ -25439,7 +25550,7 @@ var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
|
|
|
25439
25550
|
return result;
|
|
25440
25551
|
}, "tagsOf");
|
|
25441
25552
|
|
|
25442
|
-
// 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
|
|
25443
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");
|
|
25444
25555
|
var SPEECH = speech("att");
|
|
25445
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");
|
|
@@ -25803,7 +25914,7 @@ var FIELD_COMPILERS = {
|
|
|
25803
25914
|
subject
|
|
25804
25915
|
};
|
|
25805
25916
|
|
|
25806
|
-
// 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
|
|
25807
25918
|
var placeOf = /* @__PURE__ */ __name((database) => {
|
|
25808
25919
|
const exact = database.prepare("SELECT id FROM places WHERE folded = ?");
|
|
25809
25920
|
const onStreet = database.prepare("SELECT id FROM places WHERE substr(folded, 1, ?) = ? LIMIT 2");
|
|
@@ -25819,7 +25930,7 @@ var placeOf = /* @__PURE__ */ __name((database) => {
|
|
|
25819
25930
|
};
|
|
25820
25931
|
}, "placeOf");
|
|
25821
25932
|
|
|
25822
|
-
// 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
|
|
25823
25934
|
var DRAIN_ON_WRITE = 500;
|
|
25824
25935
|
var METHOD = "rules";
|
|
25825
25936
|
var telegramLink = /* @__PURE__ */ __name((database) => {
|
|
@@ -25982,7 +26093,7 @@ var drainMentions = /* @__PURE__ */ __name((database, now2, limit = DRAIN_ON_WRI
|
|
|
25982
26093
|
return queued.length;
|
|
25983
26094
|
}, "drainMentions");
|
|
25984
26095
|
|
|
25985
|
-
// 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
|
|
25986
26097
|
var indexRow = /* @__PURE__ */ __name((database, name) => {
|
|
25987
26098
|
const exists2 = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'search_index_state'").get();
|
|
25988
26099
|
if (!exists2)
|
|
@@ -25990,7 +26101,7 @@ var indexRow = /* @__PURE__ */ __name((database, name) => {
|
|
|
25990
26101
|
return database.prepare("SELECT * FROM search_index_state WHERE name = ?").get(name);
|
|
25991
26102
|
}, "indexRow");
|
|
25992
26103
|
|
|
25993
|
-
// 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
|
|
25994
26105
|
var INDEX = "message_stems";
|
|
25995
26106
|
var SETTING2 = "searchStemmers";
|
|
25996
26107
|
var DRAIN_ON_WRITE2 = 500;
|
|
@@ -26112,7 +26223,7 @@ var stemmerCache = /* @__PURE__ */ __name(() => {
|
|
|
26112
26223
|
};
|
|
26113
26224
|
}, "stemmerCache");
|
|
26114
26225
|
|
|
26115
|
-
// 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
|
|
26116
26227
|
var SQLITE_BUSY = 5;
|
|
26117
26228
|
var pause = new Int32Array(new SharedArrayBuffer(4));
|
|
26118
26229
|
var isBusy = /* @__PURE__ */ __name((error) => {
|
|
@@ -26207,7 +26318,7 @@ var read = /* @__PURE__ */ __name((database, body2) => {
|
|
|
26207
26318
|
}
|
|
26208
26319
|
}, "read");
|
|
26209
26320
|
|
|
26210
|
-
// 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
|
|
26211
26322
|
var source = /* @__PURE__ */ __name((model, dims) => `SELECT k.id, k.chunkable_type,
|
|
26212
26323
|
coalesce(CASE k.chunkable_type
|
|
26213
26324
|
WHEN 'image' THEN (SELECT ch.account_id FROM attachments a JOIN messages m ON m.id = a.attachable_id
|
|
@@ -26349,7 +26460,7 @@ var dropUnusedVectors = /* @__PURE__ */ __name((database, hashes) => {
|
|
|
26349
26460
|
}, "dropUnusedVectors");
|
|
26350
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");
|
|
26351
26462
|
|
|
26352
|
-
// 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
|
|
26353
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({
|
|
26354
26465
|
target: [accounts.provider, accounts.externalId],
|
|
26355
26466
|
set: {
|
|
@@ -26458,7 +26569,7 @@ var dropOrphanPeople = /* @__PURE__ */ __name((database, unseenBefore) => {
|
|
|
26458
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));
|
|
26459
26570
|
}, "dropOrphanPeople");
|
|
26460
26571
|
|
|
26461
|
-
// 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
|
|
26462
26573
|
var FOLDED = [
|
|
26463
26574
|
{ table: "tasks", column: "title" },
|
|
26464
26575
|
{ table: "tasks", column: "close_reason" },
|
|
@@ -26495,7 +26606,7 @@ var fillFolded = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
|
|
|
26495
26606
|
return filled2;
|
|
26496
26607
|
}, "fillFolded");
|
|
26497
26608
|
|
|
26498
|
-
// 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
|
|
26499
26610
|
var HISTORY_KEY = "$history";
|
|
26500
26611
|
var objectOf = /* @__PURE__ */ __name((text6) => {
|
|
26501
26612
|
if (typeof text6 !== "string")
|
|
@@ -26571,7 +26682,7 @@ var withoutHistory = /* @__PURE__ */ __name((metadata3) => {
|
|
|
26571
26682
|
return rest;
|
|
26572
26683
|
}, "withoutHistory");
|
|
26573
26684
|
|
|
26574
|
-
// 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
|
|
26575
26686
|
import { createHash as createHash3 } from "node:crypto";
|
|
26576
26687
|
var CHUNK_CHARS = 1200;
|
|
26577
26688
|
var CHUNK_OVERLAP = 150;
|
|
@@ -26676,7 +26787,7 @@ var cutChunks = /* @__PURE__ */ __name((members2, limit = CHUNK_CHARS, check3, c
|
|
|
26676
26787
|
return chunks2;
|
|
26677
26788
|
}, "cutChunks");
|
|
26678
26789
|
|
|
26679
|
-
// 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
|
|
26680
26791
|
var DAY = 864e5;
|
|
26681
26792
|
var CURRENCY = [
|
|
26682
26793
|
[/^(₽|руб.*|р\.?|rub)$/u, "RUB"],
|
|
@@ -26802,7 +26913,7 @@ var dueDayOf = /* @__PURE__ */ __name((text6, createdMs) => {
|
|
|
26802
26913
|
return best?.day ?? null;
|
|
26803
26914
|
}, "dueDayOf");
|
|
26804
26915
|
|
|
26805
|
-
// 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
|
|
26806
26917
|
var DAY2 = 864e5;
|
|
26807
26918
|
var STOP_WORDS = new Set([
|
|
26808
26919
|
// Russian and English as the test set ran them, already folded (пожалуйста → пожалуиста).
|
|
@@ -26957,7 +27068,7 @@ var rankCandidates = /* @__PURE__ */ __name((views, candidates) => candidates.ma
|
|
|
26957
27068
|
...compareViews(subjectViews ?? views, candidate, replyChain === void 0 ? {} : { replyChain })
|
|
26958
27069
|
})).sort((a, b) => b.score - a.score), "rankCandidates");
|
|
26959
27070
|
|
|
26960
|
-
// 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
|
|
26961
27072
|
var currentChunks = /* @__PURE__ */ __name((chatKey) => sql`SELECT k.content_hash, k.chunkable_id AS conversation_id, r.first_message_id,
|
|
26962
27073
|
r.last_message_id, r.text_start, r.text_end FROM chunks k JOIN chunk_messages r ON r.chunk_id = k.id
|
|
26963
27074
|
JOIN conversations c ON k.chunkable_type = 'conversation' AND c.id = k.chunkable_id
|
|
@@ -27228,7 +27339,7 @@ var readiness = /* @__PURE__ */ __name(({ orm }, chatKey, model) => {
|
|
|
27228
27339
|
};
|
|
27229
27340
|
}, "readiness");
|
|
27230
27341
|
|
|
27231
|
-
// 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
|
|
27232
27343
|
var DOCUMENT_PICTURE = "document_picture";
|
|
27233
27344
|
var SCAN_PAGE2 = 5e3;
|
|
27234
27345
|
var idOf = /* @__PURE__ */ __name((ref3) => {
|
|
@@ -27291,7 +27402,7 @@ var documentPicturesOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
|
|
|
27291
27402
|
}, "nearestPictures")
|
|
27292
27403
|
}), "documentPicturesOver");
|
|
27293
27404
|
|
|
27294
|
-
// 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
|
|
27295
27406
|
var glob = /* @__PURE__ */ __name((value) => [...fold(value).matchAll(/\\(.)|([*?])|(.)/gsu)].map(([, escaped2, wildcard, plain2]) => {
|
|
27296
27407
|
const literal4 = escaped2 ?? plain2 ?? "";
|
|
27297
27408
|
return wildcard ?? (/[*?[]/u.test(literal4) ? `[${literal4}]` : literal4);
|
|
@@ -27356,7 +27467,7 @@ var compile = /* @__PURE__ */ __name((node, columns, options) => {
|
|
|
27356
27467
|
var queryFilter = /* @__PURE__ */ __name((ast, columns, options = {}) => compile(ast.root, columns, options), "queryFilter");
|
|
27357
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");
|
|
27358
27469
|
|
|
27359
|
-
// 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
|
|
27360
27471
|
var toJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.stringify(value), "toJson");
|
|
27361
27472
|
var fromJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.parse(String(value)), "fromJson");
|
|
27362
27473
|
var int = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "int");
|
|
@@ -27446,7 +27557,7 @@ var linkMeeting = /* @__PURE__ */ __name((database, id2, eventId, now2, mode = "
|
|
|
27446
27557
|
});
|
|
27447
27558
|
}, "linkMeeting");
|
|
27448
27559
|
|
|
27449
|
-
// 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
|
|
27450
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), ''))";
|
|
27451
27562
|
var UNSEARCHED_EVENT_TYPES = [
|
|
27452
27563
|
"working-location",
|
|
@@ -27676,7 +27787,7 @@ var resetNoteIndex = /* @__PURE__ */ __name((database) => {
|
|
|
27676
27787
|
return true;
|
|
27677
27788
|
}, "resetNoteIndex");
|
|
27678
27789
|
|
|
27679
|
-
// 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
|
|
27680
27791
|
var keyOf3 = /* @__PURE__ */ __name((name) => fold(name).trim().replace(/^@/, ""), "keyOf");
|
|
27681
27792
|
var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
|
|
27682
27793
|
for (const key2 of new Set(names.filter((name) => !!name?.trim()).map(keyOf3))) {
|
|
@@ -27695,7 +27806,7 @@ var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
|
|
|
27695
27806
|
}
|
|
27696
27807
|
}, "resolvePersonLinks");
|
|
27697
27808
|
|
|
27698
|
-
// 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
|
|
27699
27810
|
var flag2 = /* @__PURE__ */ __name((value) => value === void 0 || value === null ? null : Number(value), "flag");
|
|
27700
27811
|
var prepare = /* @__PURE__ */ __name((orm) => ({
|
|
27701
27812
|
find: orm.select({
|
|
@@ -27920,7 +28031,7 @@ var meetingIdentityPk = /* @__PURE__ */ __name((context, accountId, identity) =>
|
|
|
27920
28031
|
}, "meetingIdentityPk");
|
|
27921
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");
|
|
27922
28033
|
|
|
27923
|
-
// 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
|
|
27924
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");
|
|
27925
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");
|
|
27926
28037
|
var chatPkFor = /* @__PURE__ */ __name((context, accountKey, chatId) => findChatPk(context, accountKey, chatId) ?? Number(context.orm.insert(chats).values({
|
|
@@ -28200,7 +28311,7 @@ var replaceAutoTags = /* @__PURE__ */ __name((context, key2, chatId, algorithm,
|
|
|
28200
28311
|
}
|
|
28201
28312
|
}, "replaceAutoTags");
|
|
28202
28313
|
|
|
28203
|
-
// 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
|
|
28204
28315
|
var COUNTER_FIELDS = ["views", "reactions", "comments"];
|
|
28205
28316
|
var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
|
|
28206
28317
|
var counterObservationTime = /* @__PURE__ */ __name((observation, now2) => {
|
|
@@ -28219,7 +28330,7 @@ var counterFreshness = /* @__PURE__ */ __name((states) => {
|
|
|
28219
28330
|
return states.some((one2) => one2.freshness === "stale") ? "stale" : "fresh";
|
|
28220
28331
|
}, "counterFreshness");
|
|
28221
28332
|
|
|
28222
|
-
// 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
|
|
28223
28334
|
import { createHash as createHash4 } from "node:crypto";
|
|
28224
28335
|
var CONTEXT_MAX_READ_BYTES = 262144;
|
|
28225
28336
|
var CONTEXT_SOURCE_KINDS = ["message", "mail", "document", "meeting"];
|
|
@@ -28317,7 +28428,7 @@ var contextEvidenceRequest = /* @__PURE__ */ __name((input) => {
|
|
|
28317
28428
|
return { source: source2, query, chat: chat2, senders, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal: input.signal };
|
|
28318
28429
|
}, "contextEvidenceRequest");
|
|
28319
28430
|
|
|
28320
|
-
// 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
|
|
28321
28432
|
var MAIL_AGENDA_COLUMNS = { chat_kind: { type: "enum", sql: "'dialog'" } };
|
|
28322
28433
|
var ACTIVITY = `
|
|
28323
28434
|
SELECT t.external_id AS thread, t.subject, t.last_email_at, t.emails_count,
|
|
@@ -28434,7 +28545,7 @@ var mailActivity = /* @__PURE__ */ __name((database) => ({
|
|
|
28434
28545
|
threadActivity: /* @__PURE__ */ __name(async (accountId, since, where) => threadActivity(database, accountId, since, where), "threadActivity")
|
|
28435
28546
|
}), "mailActivity");
|
|
28436
28547
|
|
|
28437
|
-
// 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
|
|
28438
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");
|
|
28439
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;
|
|
28440
28551
|
var ATTRIBUTION = /(wrote|написал[аи]?|escribió|a écrit|schrieb)\s*:\s*$/iu;
|
|
@@ -28575,7 +28686,7 @@ var mailOwnText = /* @__PURE__ */ __name((body2) => {
|
|
|
28575
28686
|
return text6 || body2.trim();
|
|
28576
28687
|
}, "mailOwnText");
|
|
28577
28688
|
|
|
28578
|
-
// 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
|
|
28579
28690
|
var titleOf = /* @__PURE__ */ __name((subject2) => subject2?.replace(/^\s*((re|fwd?|aw|wg)\s*:\s*)+/i, "").trim() || null, "titleOf");
|
|
28580
28691
|
var MAIL_PIECES = `(SELECT k.id, k.content_hash, k.chunkable_type AS type, k.chunkable_id AS owner, k.position,
|
|
28581
28692
|
k.start_offset, k.end_offset, k.account_id, k.occurred_at, a.attachable_id AS email_id,
|
|
@@ -28685,7 +28796,7 @@ var drainEmailIndex = /* @__PURE__ */ __name((database, stemmerFor2) => {
|
|
|
28685
28796
|
return emails3 + threads;
|
|
28686
28797
|
}, "drainEmailIndex");
|
|
28687
28798
|
|
|
28688
|
-
// 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
|
|
28689
28800
|
var locate = /* @__PURE__ */ __name((database, accountId, emailId, where) => database.prepare(`INSERT OR REPLACE INTO email_locations (mailbox_id, uidvalidity, uid, email_id)
|
|
28690
28801
|
SELECT id, ?, ?, ? FROM mailboxes WHERE account_id = ? AND external_id = ?`).run(where.uidvalidity, where.uid, emailId, accountId, where.folder), "locate");
|
|
28691
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,
|
|
@@ -28783,7 +28894,7 @@ var forgetLocations = /* @__PURE__ */ __name((database, accountId, folder, uidva
|
|
|
28783
28894
|
var backfillSentAt = /* @__PURE__ */ __name((database, accountId, limit) => Number(database.prepare(`UPDATE emails SET sent_at = received_at WHERE id IN (
|
|
28784
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");
|
|
28785
28896
|
|
|
28786
|
-
// 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
|
|
28787
28898
|
var recountEmailThread = /* @__PURE__ */ __name((database, threadId, now2) => database.prepare(`UPDATE email_threads SET
|
|
28788
28899
|
emails_count = (SELECT count(*) FROM emails WHERE email_thread_id = ? AND deleted_at IS NULL),
|
|
28789
28900
|
last_email_at = (SELECT max(coalesce(sent_at, received_at)) FROM emails
|
|
@@ -28833,7 +28944,7 @@ var markEmailsRestored = /* @__PURE__ */ __name((database, accountId, externalId
|
|
|
28833
28944
|
return threads.length;
|
|
28834
28945
|
}, "markEmailsRestored");
|
|
28835
28946
|
|
|
28836
|
-
// 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
|
|
28837
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");
|
|
28838
28949
|
var conditionsKey = /* @__PURE__ */ __name((conditions) => JSON.stringify(sorted(conditions)), "conditionsKey");
|
|
28839
28950
|
var ruleOf = /* @__PURE__ */ __name((row2) => ({
|
|
@@ -28900,7 +29011,7 @@ var mailRulesOver = /* @__PURE__ */ __name((database) => ({
|
|
|
28900
29011
|
}
|
|
28901
29012
|
}), "mailRulesOver");
|
|
28902
29013
|
|
|
28903
|
-
// 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
|
|
28904
29015
|
var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates, reason, now2) => {
|
|
28905
29016
|
database.prepare(`INSERT INTO link_reviews (linkable_type, linkable_id, entity_type, candidates, reason, status, created_at, updated_at)
|
|
28906
29017
|
VALUES (?, ?, ?, ?, ?, 'open', ?, ?)
|
|
@@ -28908,7 +29019,7 @@ var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates,
|
|
|
28908
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);
|
|
28909
29020
|
}, "reviewLink");
|
|
28910
29021
|
|
|
28911
|
-
// 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
|
|
28912
29023
|
function checkMeetingCancelled(signal) {
|
|
28913
29024
|
if (!signal?.aborted)
|
|
28914
29025
|
return;
|
|
@@ -28919,7 +29030,7 @@ function checkMeetingCancelled(signal) {
|
|
|
28919
29030
|
}
|
|
28920
29031
|
__name(checkMeetingCancelled, "checkMeetingCancelled");
|
|
28921
29032
|
|
|
28922
|
-
// 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
|
|
28923
29034
|
var meetingOf = /* @__PURE__ */ __name((row2) => ({
|
|
28924
29035
|
id: Number(row2.id),
|
|
28925
29036
|
accountId: Number(row2.account_id),
|
|
@@ -28969,7 +29080,7 @@ var transcriptRowOf = /* @__PURE__ */ __name((row2) => ({
|
|
|
28969
29080
|
createdAt: Number(row2.created_at)
|
|
28970
29081
|
}), "transcriptRowOf");
|
|
28971
29082
|
|
|
28972
|
-
// 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
|
|
28973
29084
|
var MEETING_TEXT = ["external_id", "title", "description", "location", "join_url", "timezone", "metadata"];
|
|
28974
29085
|
var TRANSCRIPT_TEXT = ["source", "format", "language", "content_hash", "metadata"];
|
|
28975
29086
|
var ROW_TEXT = ["speaker_name", "text", "normalized_text", "metadata"];
|
|
@@ -29136,7 +29247,7 @@ var meetingReadsOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
29136
29247
|
}
|
|
29137
29248
|
}), "meetingReadsOver");
|
|
29138
29249
|
|
|
29139
|
-
// 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
|
|
29140
29251
|
var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
|
|
29141
29252
|
const clauses = ["m.account_id=?", "m.deleted_at IS NULL"];
|
|
29142
29253
|
const params = [input.accountId];
|
|
@@ -29179,7 +29290,7 @@ var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
|
|
|
29179
29290
|
return { clauses, params };
|
|
29180
29291
|
}, "meetingSelectionSql");
|
|
29181
29292
|
|
|
29182
|
-
// 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
|
|
29183
29294
|
var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
29184
29295
|
async meetingChatLines(input) {
|
|
29185
29296
|
checkMeetingCancelled(input.signal);
|
|
@@ -29207,7 +29318,7 @@ var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
29207
29318
|
}
|
|
29208
29319
|
}), "meetingChatLinesOver");
|
|
29209
29320
|
|
|
29210
|
-
// 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
|
|
29211
29322
|
var MESSAGE_FIELDS = {
|
|
29212
29323
|
pk: messages.id,
|
|
29213
29324
|
nativeId: messages.externalId,
|
|
@@ -29378,7 +29489,7 @@ var chatActivity = /* @__PURE__ */ __name(({ database }, accountKey, since, wher
|
|
|
29378
29489
|
storedAt: toIso(Number(database.prepare("SELECT max(created_at) AS at FROM messages WHERE account_id = ?").get(accountKey)?.at) || null)
|
|
29379
29490
|
}), "chatActivity");
|
|
29380
29491
|
|
|
29381
|
-
// 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
|
|
29382
29493
|
var HIT_FIELDS = {
|
|
29383
29494
|
...MESSAGE_FIELDS,
|
|
29384
29495
|
chatTitle: sql`${chats.title}`.as("chat_title"),
|
|
@@ -29477,7 +29588,7 @@ var directReplies = /* @__PURE__ */ __name((context, parents, limit) => {
|
|
|
29477
29588
|
};
|
|
29478
29589
|
}, "directReplies");
|
|
29479
29590
|
|
|
29480
|
-
// 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
|
|
29481
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");
|
|
29482
29593
|
var required = /* @__PURE__ */ __name((context, ref3) => {
|
|
29483
29594
|
const found2 = identityRow(context, ref3);
|
|
@@ -29608,7 +29719,7 @@ var mentioning = /* @__PURE__ */ __name((context, accountKey, { id: id2, usernam
|
|
|
29608
29719
|
}, "mentioning");
|
|
29609
29720
|
var escaped = /* @__PURE__ */ __name((text6) => text6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "escaped");
|
|
29610
29721
|
|
|
29611
|
-
// 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
|
|
29612
29723
|
var missing2 = /* @__PURE__ */ __name(() => {
|
|
29613
29724
|
throw new CliError("not_found", "Meeting, participant or selected target not found");
|
|
29614
29725
|
}, "missing");
|
|
@@ -29730,7 +29841,7 @@ function meetingContextLinksOver(context) {
|
|
|
29730
29841
|
}
|
|
29731
29842
|
__name(meetingContextLinksOver, "meetingContextLinksOver");
|
|
29732
29843
|
|
|
29733
|
-
// 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
|
|
29734
29845
|
var INDEX_CODES = { meeting_transcript_row: 1, meeting_chat_message: 2, meeting_summary: 3 };
|
|
29735
29846
|
var meetingRowid = /* @__PURE__ */ __name((type, id2) => id2 * 4 + INDEX_CODES[type], "meetingRowid");
|
|
29736
29847
|
var summaryOf = /* @__PURE__ */ __name((row2) => ({
|
|
@@ -29759,7 +29870,7 @@ var indexedText = /* @__PURE__ */ __name((database, type, id2) => {
|
|
|
29759
29870
|
return row2 ? summaryText(summaryOf(row2)) : null;
|
|
29760
29871
|
}, "indexedText");
|
|
29761
29872
|
|
|
29762
|
-
// 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
|
|
29763
29874
|
var summaryBytes = ["title", "overview", "sections", "next_steps", "content"].map((key2) => `coalesce(length(CAST(s.${key2} AS BLOB)),0)`).join("+");
|
|
29764
29875
|
var meetingCurrentIndexRows = `
|
|
29765
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
|
|
@@ -29790,7 +29901,7 @@ var invalidateMeetingStems = /* @__PURE__ */ __name((database, type, id2) => {
|
|
|
29790
29901
|
}, "invalidateMeetingStems");
|
|
29791
29902
|
var meetingStemmableText = /* @__PURE__ */ __name((text6) => text6.replace(/[\p{L}\p{N}\p{M}\p{Co}]+/gu, (token) => token.length <= 1024 ? token : ""), "meetingStemmableText");
|
|
29792
29903
|
|
|
29793
|
-
// 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
|
|
29794
29905
|
function meetingHitIndexOver({ database, now: now2 }) {
|
|
29795
29906
|
return {
|
|
29796
29907
|
async indexSearch(original) {
|
|
@@ -29858,10 +29969,10 @@ function meetingHitIndexOver({ database, now: now2 }) {
|
|
|
29858
29969
|
}
|
|
29859
29970
|
__name(meetingHitIndexOver, "meetingHitIndexOver");
|
|
29860
29971
|
|
|
29861
|
-
// 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
|
|
29862
29973
|
import { createHash as createHash5 } from "node:crypto";
|
|
29863
29974
|
|
|
29864
|
-
// 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
|
|
29865
29976
|
var trigrams = /* @__PURE__ */ __name((term) => {
|
|
29866
29977
|
const padded = ` ${term} `;
|
|
29867
29978
|
const pieces = /* @__PURE__ */ new Set();
|
|
@@ -29870,7 +29981,7 @@ var trigrams = /* @__PURE__ */ __name((term) => {
|
|
|
29870
29981
|
return [...pieces];
|
|
29871
29982
|
}, "trigrams");
|
|
29872
29983
|
|
|
29873
|
-
// 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
|
|
29874
29985
|
var SHORTEST_CORRECTION = 3;
|
|
29875
29986
|
var maxEdits = /* @__PURE__ */ __name((word2) => word2.length <= 4 ? 1 : 2, "maxEdits");
|
|
29876
29987
|
var editDistance = /* @__PURE__ */ __name((a, b, max) => {
|
|
@@ -29917,7 +30028,7 @@ var correctWords = /* @__PURE__ */ __name(async (vocabulary, words3) => {
|
|
|
29917
30028
|
return corrections;
|
|
29918
30029
|
}, "correctWords");
|
|
29919
30030
|
|
|
29920
|
-
// 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
|
|
29921
30032
|
var SHORTEST_GARBLED = 4;
|
|
29922
30033
|
var MOST_WIDENED = 64;
|
|
29923
30034
|
var plain = /* @__PURE__ */ __name((word2) => word2.replaceAll("\u044D", "\u0435"), "plain");
|
|
@@ -30009,7 +30120,7 @@ var widenWords = /* @__PURE__ */ __name((probes, vocabulary, stem, known2) => {
|
|
|
30009
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));
|
|
30010
30121
|
}, "widenWords");
|
|
30011
30122
|
|
|
30012
|
-
// 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
|
|
30013
30124
|
import { readFileSync } from "node:fs";
|
|
30014
30125
|
var loaded;
|
|
30015
30126
|
var dictionary = /* @__PURE__ */ __name(() => {
|
|
@@ -30068,7 +30179,7 @@ var knownRussianWord = /* @__PURE__ */ __name((word2) => {
|
|
|
30068
30179
|
return false;
|
|
30069
30180
|
}, "knownRussianWord");
|
|
30070
30181
|
|
|
30071
|
-
// 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
|
|
30072
30183
|
var WORD3 = /[\p{L}\p{N}\p{M}]+/gu;
|
|
30073
30184
|
var MOST_WORDS = 128;
|
|
30074
30185
|
var quote = /* @__PURE__ */ __name((word2) => `"${word2.replaceAll('"', '""')}"`, "quote");
|
|
@@ -30295,7 +30406,7 @@ var matchMeetingText = /* @__PURE__ */ __name((tree, text6, stemmer) => {
|
|
|
30295
30406
|
return check3(tree);
|
|
30296
30407
|
}, "matchMeetingText");
|
|
30297
30408
|
|
|
30298
|
-
// 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
|
|
30299
30410
|
var fail3 = /* @__PURE__ */ __name((message2) => {
|
|
30300
30411
|
throw new CliError("validation_error", message2);
|
|
30301
30412
|
}, "fail");
|
|
@@ -30477,7 +30588,7 @@ function meetingHitSearchOver({ database }) {
|
|
|
30477
30588
|
}
|
|
30478
30589
|
__name(meetingHitSearchOver, "meetingHitSearchOver");
|
|
30479
30590
|
|
|
30480
|
-
// 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
|
|
30481
30592
|
var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30482
30593
|
async fillTranscriptLanguages({ accountId, apply, now: now2 }) {
|
|
30483
30594
|
positiveReadInteger(accountId, "accountId");
|
|
@@ -30509,7 +30620,7 @@ var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30509
30620
|
}
|
|
30510
30621
|
}), "meetingLanguagesOver");
|
|
30511
30622
|
|
|
30512
|
-
// 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
|
|
30513
30624
|
import { createHash as createHash6 } from "node:crypto";
|
|
30514
30625
|
var cursorOf2 = /* @__PURE__ */ __name((value, key2) => {
|
|
30515
30626
|
if (value === void 0)
|
|
@@ -30599,7 +30710,7 @@ var meetingParticipantSearchOver = /* @__PURE__ */ __name((context) => ({
|
|
|
30599
30710
|
}
|
|
30600
30711
|
}), "meetingParticipantSearchOver");
|
|
30601
30712
|
|
|
30602
|
-
// 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
|
|
30603
30714
|
var preparationQueries = {
|
|
30604
30715
|
participants: {
|
|
30605
30716
|
fields: "p.id, p.identity_id, p.display_name, l.person_id",
|
|
@@ -30649,7 +30760,7 @@ var preparationQueries = {
|
|
|
30649
30760
|
}
|
|
30650
30761
|
};
|
|
30651
30762
|
|
|
30652
|
-
// 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
|
|
30653
30764
|
var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30654
30765
|
async preparationContext(original) {
|
|
30655
30766
|
const input = validateMeetingPreparationContext(original);
|
|
@@ -30690,7 +30801,7 @@ var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30690
30801
|
}
|
|
30691
30802
|
}), "meetingPreparationContextOver");
|
|
30692
30803
|
|
|
30693
|
-
// 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
|
|
30694
30805
|
var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
|
|
30695
30806
|
SELECT m.id FROM meetings m JOIN meeting_series s ON s.id=m.meeting_series_id
|
|
30696
30807
|
WHERE m.id IN (${Array.from({ length: anchors }, () => "?").join(",")}) AND m.account_id=? AND s.account_id=?
|
|
@@ -30704,7 +30815,7 @@ var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
|
|
|
30704
30815
|
JOIN main.projects p ON p.id=l.to_id WHERE p.account_id IS NULL AND p.deleted_at IS NULL
|
|
30705
30816
|
)`, "preparationSubjects");
|
|
30706
30817
|
|
|
30707
|
-
// 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
|
|
30708
30819
|
var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30709
30820
|
async preparationKnowledge(original) {
|
|
30710
30821
|
const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
|
|
@@ -30749,7 +30860,7 @@ var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => (
|
|
|
30749
30860
|
}
|
|
30750
30861
|
}), "meetingPreparationKnowledgeOver");
|
|
30751
30862
|
|
|
30752
|
-
// 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
|
|
30753
30864
|
var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30754
30865
|
async preparationNotes(original) {
|
|
30755
30866
|
const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
|
|
@@ -30802,7 +30913,7 @@ var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30802
30913
|
}
|
|
30803
30914
|
}), "meetingPreparationNotesOver");
|
|
30804
30915
|
|
|
30805
|
-
// 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
|
|
30806
30917
|
var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
30807
30918
|
async relatedHistory(original) {
|
|
30808
30919
|
const input = validateMeetingRelatedHistory(original);
|
|
@@ -30873,7 +30984,7 @@ var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30873
30984
|
}
|
|
30874
30985
|
}), "meetingRelatedHistoryOver");
|
|
30875
30986
|
|
|
30876
|
-
// 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
|
|
30877
30988
|
var number2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "number");
|
|
30878
30989
|
var text2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : String(value), "text");
|
|
30879
30990
|
var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
@@ -30954,7 +31065,7 @@ var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
30954
31065
|
}
|
|
30955
31066
|
}), "meetingReviewOver");
|
|
30956
31067
|
|
|
30957
|
-
// 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
|
|
30958
31069
|
var bytes2 = "length(CAST(external_id AS BLOB)) + coalesce(length(CAST(title AS BLOB)), 0)";
|
|
30959
31070
|
var ensureBytes2 = /* @__PURE__ */ __name((size2, budget) => {
|
|
30960
31071
|
if (!Number.isSafeInteger(size2) || size2 < 0 || size2 > budget)
|
|
@@ -31008,7 +31119,7 @@ var meetingSeriesHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
31008
31119
|
}
|
|
31009
31120
|
}), "meetingSeriesHistoryOver");
|
|
31010
31121
|
|
|
31011
|
-
// 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
|
|
31012
31123
|
var MOST_ROWS = 5e5;
|
|
31013
31124
|
var meetingCountsSql = /* @__PURE__ */ __name((where) => `SELECT m.started_at, coalesce(m.duration_ms, m.ended_at - m.started_at) AS duration_ms,
|
|
31014
31125
|
EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = m.id AND t.deleted_at IS NULL
|
|
@@ -31077,7 +31188,7 @@ var meetingStatsOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
31077
31188
|
}
|
|
31078
31189
|
}), "meetingStatsOver");
|
|
31079
31190
|
|
|
31080
|
-
// 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
|
|
31081
31192
|
var CURSOR_KEY = "meetings";
|
|
31082
31193
|
var seriesOf2 = /* @__PURE__ */ __name((row2) => ({
|
|
31083
31194
|
id: Number(row2.id),
|
|
@@ -31646,7 +31757,7 @@ var meetingStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
31646
31757
|
};
|
|
31647
31758
|
}, "meetingStoreOver");
|
|
31648
31759
|
|
|
31649
|
-
// 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
|
|
31650
31761
|
var syncStateOf = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
|
|
31651
31762
|
const row2 = orm.select({ value: syncCursors.value, at: syncCursors.updatedAt }).from(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).get();
|
|
31652
31763
|
return row2 ? { value: row2.value, at: toIso(row2.at) } : void 0;
|
|
@@ -31672,7 +31783,7 @@ var release = /* @__PURE__ */ __name(({ orm }, chatKey, anchor, holder) => {
|
|
|
31672
31783
|
orm.delete(fetchLeases).where(and(eq(fetchLeases.chatId, chatKey), eq(fetchLeases.anchor, anchor), eq(fetchLeases.holder, holder))).run();
|
|
31673
31784
|
}, "release");
|
|
31674
31785
|
|
|
31675
|
-
// 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
|
|
31676
31787
|
var THREAD_COLUMNS = {
|
|
31677
31788
|
subject: {
|
|
31678
31789
|
where: /* @__PURE__ */ __name(({ value }) => ({
|
|
@@ -31689,7 +31800,7 @@ var threadRows = /* @__PURE__ */ __name((database, filter) => {
|
|
|
31689
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);
|
|
31690
31801
|
}, "threadRows");
|
|
31691
31802
|
|
|
31692
|
-
// 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
|
|
31693
31804
|
var threadConversation = /* @__PURE__ */ __name((place, builtAt) => ({
|
|
31694
31805
|
id: `email:${place.emailId}`,
|
|
31695
31806
|
chatId: place.threadExternalId,
|
|
@@ -32245,7 +32356,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm, now: now2 }, stemme
|
|
|
32245
32356
|
}
|
|
32246
32357
|
}), "mailStoreOver");
|
|
32247
32358
|
|
|
32248
|
-
// 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
|
|
32249
32360
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
32250
32361
|
var DICTIONARIES = Object.fromEntries(LANGUAGES.map(({ name, dictionary: dictionary3 }) => [name, dictionary3]));
|
|
32251
32362
|
var folded4 = /* @__PURE__ */ __name((word2) => /^[а-яё'-]*$/.test(word2) ? word2.replaceAll("\u0451", "\u0435").replaceAll("\u0439", "\u0438") : fold(word2), "folded");
|
|
@@ -32335,7 +32446,7 @@ var knownWord = /* @__PURE__ */ __name((languages) => {
|
|
|
32335
32446
|
}, "knownWord");
|
|
32336
32447
|
var dictionaryLanguages = /* @__PURE__ */ __name((stemmers) => [stemmers.cyrillic, ...stemmers.latin.split(",")].filter((name) => Object.hasOwn(DICTIONARIES, name)), "dictionaryLanguages");
|
|
32337
32448
|
|
|
32338
|
-
// 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
|
|
32339
32450
|
var predicates = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? [node] : node.clauses.flatMap(({ node: node2 }) => predicates(node2)), "predicates");
|
|
32340
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");
|
|
32341
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
|
|
@@ -32421,7 +32532,7 @@ var spokenTranscripts = /* @__PURE__ */ __name((database, item, speaking, keys)
|
|
|
32421
32532
|
return found2;
|
|
32422
32533
|
}, "spokenTranscripts");
|
|
32423
32534
|
|
|
32424
|
-
// 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
|
|
32425
32536
|
var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, found2, pks) => {
|
|
32426
32537
|
const placeLeaves = leaves.filter(({ node }) => (node.operator === "term" || node.operator === "phrase") && (node.implicit || node.field === "content" || node.field === "transcript"));
|
|
32427
32538
|
if (!placeLeaves.length || !pks.length || found2.length !== pks.length)
|
|
@@ -32468,7 +32579,7 @@ var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, f
|
|
|
32468
32579
|
});
|
|
32469
32580
|
}, "placeHits");
|
|
32470
32581
|
|
|
32471
|
-
// 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
|
|
32472
32583
|
var GROUPS = {
|
|
32473
32584
|
chat: {
|
|
32474
32585
|
key: "m.chat_id",
|
|
@@ -32490,7 +32601,7 @@ var GROUPS = {
|
|
|
32490
32601
|
}
|
|
32491
32602
|
};
|
|
32492
32603
|
|
|
32493
|
-
// 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
|
|
32494
32605
|
var MESSAGES2 = {
|
|
32495
32606
|
rows: "messages",
|
|
32496
32607
|
threads: "chats",
|
|
@@ -32973,7 +33084,7 @@ var runCompiled = /* @__PURE__ */ __name(async (context, execution, by) => {
|
|
|
32973
33084
|
};
|
|
32974
33085
|
}, "runCompiled");
|
|
32975
33086
|
|
|
32976
|
-
// 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
|
|
32977
33088
|
function invalidMetadata() {
|
|
32978
33089
|
throw new CliError("validation_error", "stored counter metadata is malformed \u2014 check the store before refreshing");
|
|
32979
33090
|
}
|
|
@@ -33075,7 +33186,7 @@ var counterTargets = /* @__PURE__ */ __name((context, execution, options) => wit
|
|
|
33075
33186
|
};
|
|
33076
33187
|
}), "counterTargets");
|
|
33077
33188
|
|
|
33078
|
-
// 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
|
|
33079
33190
|
var NOT_FILE_LIST = [...NOT_FILES].map((kind4) => `'${kind4}'`).join(",");
|
|
33080
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,
|
|
33081
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
|
|
@@ -33194,7 +33305,7 @@ var attachmentViews = /* @__PURE__ */ __name(({ database }, accountKey, { chatKe
|
|
|
33194
33305
|
}));
|
|
33195
33306
|
}, "attachmentViews");
|
|
33196
33307
|
|
|
33197
|
-
// 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
|
|
33198
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");
|
|
33199
33310
|
var keepTranscript = /* @__PURE__ */ __name((context, chatKey, messageId, text6, source2) => {
|
|
33200
33311
|
const { orm, database, now: now2 } = context;
|
|
@@ -33232,7 +33343,7 @@ var intoVoiceAttachment = /* @__PURE__ */ __name((context, messagePk) => {
|
|
|
33232
33343
|
keepText(context, Number(row2.id), { text: String(row2.text), origin: "extracted", extractor: `speech:${row2.source}` });
|
|
33233
33344
|
}, "intoVoiceAttachment");
|
|
33234
33345
|
|
|
33235
|
-
// 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
|
|
33236
33347
|
var FIELDS = [
|
|
33237
33348
|
"threadExternalId",
|
|
33238
33349
|
"senderIdentityId",
|
|
@@ -33549,7 +33660,7 @@ var writeDerivedReactions = /* @__PURE__ */ __name((context, chatKey, messageId)
|
|
|
33549
33660
|
reactionStatementsOf(context.database).total.run(JSON.stringify(derived), chatKey, messageId);
|
|
33550
33661
|
}, "writeDerivedReactions");
|
|
33551
33662
|
|
|
33552
|
-
// 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
|
|
33553
33664
|
var keysOver = /* @__PURE__ */ __name((context) => {
|
|
33554
33665
|
const findAccountPk2 = /* @__PURE__ */ __name((key2) => findAccountPk(context, key2), "findAccountPk");
|
|
33555
33666
|
const findChatPk2 = /* @__PURE__ */ __name((accountKey, chatId) => findChatPk(context, accountKey, chatId), "findChatPk");
|
|
@@ -33570,7 +33681,7 @@ var keysOver = /* @__PURE__ */ __name((context) => {
|
|
|
33570
33681
|
};
|
|
33571
33682
|
}, "keysOver");
|
|
33572
33683
|
|
|
33573
|
-
// 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
|
|
33574
33685
|
var accountGroupsOf = /* @__PURE__ */ __name((database) => {
|
|
33575
33686
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(ACCOUNT_GROUPS);
|
|
33576
33687
|
if (!row2)
|
|
@@ -33605,7 +33716,7 @@ var saveProfile = /* @__PURE__ */ __name((database, app, profile, key2, now2) =>
|
|
|
33605
33716
|
database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(PROFILES, JSON.stringify(profiles), now2);
|
|
33606
33717
|
}, "saveProfile");
|
|
33607
33718
|
|
|
33608
|
-
// 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
|
|
33609
33720
|
var BOT_KINDS = ["agent", "rule", "script", "integration"];
|
|
33610
33721
|
var ownerPerson = /* @__PURE__ */ __name((database) => {
|
|
33611
33722
|
const found2 = database.prepare("SELECT id FROM persons WHERE owner = 1 ORDER BY id LIMIT 1").get();
|
|
@@ -33662,7 +33773,7 @@ var proposedBySql = /* @__PURE__ */ __name((type, id2, by) => {
|
|
|
33662
33773
|
return { sql: bot("pb.name = ?"), params: [by.bot] };
|
|
33663
33774
|
}, "proposedBySql");
|
|
33664
33775
|
|
|
33665
|
-
// 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
|
|
33666
33777
|
var linkOwnIdentities = /* @__PURE__ */ __name((context) => {
|
|
33667
33778
|
const owner = ownerPerson(context.database).id;
|
|
33668
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);
|
|
@@ -33683,7 +33794,7 @@ var linkToOwner = /* @__PURE__ */ __name((context, ref3) => {
|
|
|
33683
33794
|
return personOf(context, ref3);
|
|
33684
33795
|
}, "linkToOwner");
|
|
33685
33796
|
|
|
33686
|
-
// 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
|
|
33687
33798
|
var PROVIDERS_SETTING = "providers";
|
|
33688
33799
|
var storedProvidersOf = /* @__PURE__ */ __name((database) => {
|
|
33689
33800
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(PROVIDERS_SETTING);
|
|
@@ -33718,7 +33829,7 @@ var registerProvider = /* @__PURE__ */ __name((database, value, now2) => {
|
|
|
33718
33829
|
});
|
|
33719
33830
|
}, "registerProvider");
|
|
33720
33831
|
|
|
33721
|
-
// 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
|
|
33722
33833
|
var DAY3 = 864e5;
|
|
33723
33834
|
var RECENTLY_CLOSED_MS = 14 * DAY3;
|
|
33724
33835
|
var TEXT_LIMIT = 20;
|
|
@@ -33917,7 +34028,7 @@ var taskSimilarityOver = /* @__PURE__ */ __name((context) => {
|
|
|
33917
34028
|
};
|
|
33918
34029
|
}, "taskSimilarityOver");
|
|
33919
34030
|
|
|
33920
|
-
// 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
|
|
33921
34032
|
var SETTING3 = "taskCategories";
|
|
33922
34033
|
var savedTaskCategories = /* @__PURE__ */ __name((database) => {
|
|
33923
34034
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING3);
|
|
@@ -33936,7 +34047,7 @@ var saveTaskCategories = /* @__PURE__ */ __name((database, categories, now2) =>
|
|
|
33936
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);
|
|
33937
34048
|
}, "saveTaskCategories");
|
|
33938
34049
|
|
|
33939
|
-
// 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
|
|
33940
34051
|
var DEFAULT_AGENT_CLOSE = { allowed: true, min: 0.8 };
|
|
33941
34052
|
var ALLOWED = "taskAgentClose";
|
|
33942
34053
|
var MIN = "taskAgentCloseMin";
|
|
@@ -33992,10 +34103,10 @@ var SUGGESTION_COLUMNS = [
|
|
|
33992
34103
|
];
|
|
33993
34104
|
var CLEAR_SUGGESTION = SUGGESTION_COLUMNS.map((column2) => `${column2} = NULL`).join(", ");
|
|
33994
34105
|
|
|
33995
|
-
// 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
|
|
33996
34107
|
var MAIL_FINDINGS_KIND = "mail_findings";
|
|
33997
34108
|
|
|
33998
|
-
// 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
|
|
33999
34110
|
var TASK_CLOSE_KIND = "task_close";
|
|
34000
34111
|
var DEFAULT_DECISION_POLICY = { agentDecisions: false, ruleProposalsOwnerOnly: true };
|
|
34001
34112
|
var isOwnerOnlyKind = /* @__PURE__ */ __name((kind4) => kind4 === MAIL_FINDINGS_KIND || kind4 === MEETING_FINDINGS_KIND || kind4 === TASK_CLOSE_KIND, "isOwnerOnlyKind");
|
|
@@ -34043,7 +34154,17 @@ var assertMayDecide = /* @__PURE__ */ __name((row2, by, policy = DEFAULT_DECISIO
|
|
|
34043
34154
|
}, "assertMayDecide");
|
|
34044
34155
|
var deciderAuthor = /* @__PURE__ */ __name((by) => by === "owner" ? "owner" : { bot: by.bot, ...by.model === void 0 ? {} : { model: by.model } }, "deciderAuthor");
|
|
34045
34156
|
|
|
34046
|
-
// 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
|
|
34047
34168
|
var PROFILE_PLACEHOLDER = "<profile>";
|
|
34048
34169
|
var oneLine = /* @__PURE__ */ __name((text6) => singleLine(text6.replace(/\s+/g, " ").trim()), "oneLine");
|
|
34049
34170
|
var openKind = /* @__PURE__ */ __name((kind4) => kind4 === "email" ? "message" : kind4 === "email_thread" ? "chat" : kind4 === "unknown" ? void 0 : kind4, "openKind");
|
|
@@ -34086,6 +34207,9 @@ var WORDS2 = {
|
|
|
34086
34207
|
invoice: "Invoice",
|
|
34087
34208
|
payment: "Payment",
|
|
34088
34209
|
order: "Order",
|
|
34210
|
+
deal: "Deal",
|
|
34211
|
+
lead: "Lead",
|
|
34212
|
+
pipeline: "Pipeline",
|
|
34089
34213
|
email: "Email",
|
|
34090
34214
|
email_thread: "Email thread",
|
|
34091
34215
|
unknown: "Unknown"
|
|
@@ -34096,7 +34220,7 @@ var refLabel = /* @__PURE__ */ __name((summary) => {
|
|
|
34096
34220
|
return `${WORDS2[summary.kind]} ${named3}${notes2 === "" ? "" : ` (${notes2})`}`;
|
|
34097
34221
|
}, "refLabel");
|
|
34098
34222
|
|
|
34099
|
-
// 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
|
|
34100
34224
|
var EXCERPT_CHARS = 280;
|
|
34101
34225
|
var TITLE_CHARS = 120;
|
|
34102
34226
|
var MEMORY_TITLE_CHARS = 80;
|
|
@@ -34119,6 +34243,12 @@ var byId = /* @__PURE__ */ __name((kind4, table, columns) => ({
|
|
|
34119
34243
|
kind: kind4,
|
|
34120
34244
|
sql: /* @__PURE__ */ __name((body2) => `${select(columns(body2))} FROM w JOIN ${table} x ON x.id = w.k1`, "sql")
|
|
34121
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");
|
|
34122
34252
|
var READERS = {
|
|
34123
34253
|
message: {
|
|
34124
34254
|
kind: "message",
|
|
@@ -34270,7 +34400,10 @@ var READERS = {
|
|
|
34270
34400
|
holder: "(SELECT name FROM projects WHERE id = x.project_id)",
|
|
34271
34401
|
at: "x.created_at",
|
|
34272
34402
|
deleted: "x.deleted_at"
|
|
34273
|
-
}))
|
|
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" }))
|
|
34274
34407
|
};
|
|
34275
34408
|
var FALLBACK = { email: "message", email_thread: "chat" };
|
|
34276
34409
|
var route = /* @__PURE__ */ __name((reference2) => {
|
|
@@ -34361,6 +34494,9 @@ var titleOf2 = /* @__PURE__ */ __name((kind4, reference2, found2) => {
|
|
|
34361
34494
|
return fieldsOf2(found2.title, paymentLine);
|
|
34362
34495
|
case "order":
|
|
34363
34496
|
return fieldsOf2(found2.title, orderLine);
|
|
34497
|
+
case "deal":
|
|
34498
|
+
case "lead":
|
|
34499
|
+
return fieldsOf2(found2.title, dealLine);
|
|
34364
34500
|
case "folder":
|
|
34365
34501
|
return reference2.type === "folder" && reference2.path !== null && found2.title !== null ? `${found2.title}/${reference2.path}` : found2.title;
|
|
34366
34502
|
default:
|
|
@@ -34457,7 +34593,7 @@ var refReadsOf = /* @__PURE__ */ __name((database, texts2, { excerpt = false } =
|
|
|
34457
34593
|
var summaryOf2 = /* @__PURE__ */ __name(({ sender, excerpt, ...summary }, withExcerpt) => withExcerpt ? { ...summary, excerpt } : summary, "summaryOf");
|
|
34458
34594
|
var refSummariesOf = /* @__PURE__ */ __name((database, texts2, options = {}) => new Map([...refReadsOf(database, texts2, options)].map(([text6, read2]) => [text6, summaryOf2(read2, options.excerpt === true)])), "refSummariesOf");
|
|
34459
34595
|
|
|
34460
|
-
// 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
|
|
34461
34597
|
var sourceOf3 = /* @__PURE__ */ __name((read2, ref3) => ({
|
|
34462
34598
|
ref: ref3,
|
|
34463
34599
|
kind: read2.kind,
|
|
@@ -34493,7 +34629,7 @@ var evidenceSourcesOf = /* @__PURE__ */ __name((database, from2) => {
|
|
|
34493
34629
|
});
|
|
34494
34630
|
}, "evidenceSourcesOf");
|
|
34495
34631
|
|
|
34496
|
-
// 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
|
|
34497
34633
|
var MAX_FILE_BYTES = 50 * 1024 * 1024;
|
|
34498
34634
|
var MAX_TEXT_CHARS = 2e6;
|
|
34499
34635
|
var ATTACHMENT_LIMIT_ENV = [
|
|
@@ -34519,7 +34655,7 @@ var pdfPreviewLimits = /* @__PURE__ */ __name((env = process.env) => {
|
|
|
34519
34655
|
return { pixels, bytes: positive(env, "MESSAGING_PDF_PREVIEW_MAX_MIB", 8 * 1024 * 1024, 1024 * 1024) };
|
|
34520
34656
|
}, "pdfPreviewLimits");
|
|
34521
34657
|
|
|
34522
|
-
// 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
|
|
34523
34659
|
import { randomBytes } from "node:crypto";
|
|
34524
34660
|
var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
34525
34661
|
var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
|
|
@@ -34532,7 +34668,7 @@ var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
|
|
|
34532
34668
|
return time3 + random;
|
|
34533
34669
|
}, "ulid");
|
|
34534
34670
|
|
|
34535
|
-
// 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
|
|
34536
34672
|
var FOLDED_FIELDS = ["title", "site", "language", "author"];
|
|
34537
34673
|
var encodeDocumentMetadata = /* @__PURE__ */ __name((meta, sections) => {
|
|
34538
34674
|
if (!meta && !sections?.length)
|
|
@@ -34553,7 +34689,7 @@ var languageOf = /* @__PURE__ */ __name((meta) => {
|
|
|
34553
34689
|
return typeof language === "string" && language !== "" ? language : null;
|
|
34554
34690
|
}, "languageOf");
|
|
34555
34691
|
|
|
34556
|
-
// 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
|
|
34557
34693
|
var isObject = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isObject");
|
|
34558
34694
|
var objectOf2 = /* @__PURE__ */ __name((value) => {
|
|
34559
34695
|
if (isObject(value))
|
|
@@ -34796,7 +34932,7 @@ var filesStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
|
|
|
34796
34932
|
};
|
|
34797
34933
|
}, "filesStoreOver");
|
|
34798
34934
|
|
|
34799
|
-
// 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
|
|
34800
34936
|
var IMPORTED_DOCUMENT_QUERY = defineQuery({
|
|
34801
34937
|
entity: "document",
|
|
34802
34938
|
backend: "sql",
|
|
@@ -34842,7 +34978,7 @@ var importedDocumentWhere = /* @__PURE__ */ __name((database, query) => {
|
|
|
34842
34978
|
return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns);
|
|
34843
34979
|
}, "importedDocumentWhere");
|
|
34844
34980
|
|
|
34845
|
-
// 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
|
|
34846
34982
|
var NOTE_FORMATS = ["obsidian", "markdown"];
|
|
34847
34983
|
var iso2 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
34848
34984
|
var optionalIso = /* @__PURE__ */ __name((value) => value == null ? null : iso2(value), "optionalIso");
|
|
@@ -35368,7 +35504,7 @@ var notesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
35368
35504
|
};
|
|
35369
35505
|
}, "notesStoreOver");
|
|
35370
35506
|
|
|
35371
|
-
// 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
|
|
35372
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";
|
|
35373
35509
|
var iso3 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
35374
35510
|
var oneOf2 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
@@ -35590,7 +35726,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
35590
35726
|
};
|
|
35591
35727
|
}, "memoriesStoreOver");
|
|
35592
35728
|
|
|
35593
|
-
// 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
|
|
35594
35730
|
var DEFAULT_FIRST_PASS_PER_CHAT = 0;
|
|
35595
35731
|
var KEY = "taskFirstPassPerChat";
|
|
35596
35732
|
var firstPassPerChatOf = /* @__PURE__ */ __name((value, setting = "task_first_pass_per_chat") => {
|
|
@@ -35610,7 +35746,7 @@ var saveFirstPassPerChat = /* @__PURE__ */ __name((database, value, now2) => {
|
|
|
35610
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);
|
|
35611
35747
|
}, "saveFirstPassPerChat");
|
|
35612
35748
|
|
|
35613
|
-
// 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
|
|
35614
35750
|
var EXTERNAL_SERVICE = /^[a-z][a-z0-9-]{0,31}$/;
|
|
35615
35751
|
var EXTERNAL_ID_CHARS = 200;
|
|
35616
35752
|
var SOURCE_URL_CHARS = 2e3;
|
|
@@ -35637,7 +35773,7 @@ var sourceUrlOf = /* @__PURE__ */ __name((value, reason = "task.source-url") =>
|
|
|
35637
35773
|
return text6;
|
|
35638
35774
|
}, "sourceUrlOf");
|
|
35639
35775
|
|
|
35640
|
-
// 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
|
|
35641
35777
|
var TASK_SORTS = ["priority", "due", "created", "updated", "key", "state"];
|
|
35642
35778
|
var field = /* @__PURE__ */ __name((name, type, example, more = {}) => ({
|
|
35643
35779
|
name,
|
|
@@ -35860,7 +35996,7 @@ var withoutField = /* @__PURE__ */ __name((query, name) => {
|
|
|
35860
35996
|
return root === void 0 ? void 0 : { ...query, root };
|
|
35861
35997
|
}, "withoutField");
|
|
35862
35998
|
|
|
35863
|
-
// 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
|
|
35864
36000
|
var authorNamed = /* @__PURE__ */ __name((database, row2) => {
|
|
35865
36001
|
if (row2.author_type == null)
|
|
35866
36002
|
return null;
|
|
@@ -35888,7 +36024,7 @@ var addComment = /* @__PURE__ */ __name((context, task, body2, by) => {
|
|
|
35888
36024
|
return commentsOf(database, task).find((one2) => one2.ref === `note:${made}`);
|
|
35889
36025
|
}, "addComment");
|
|
35890
36026
|
|
|
35891
|
-
// 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
|
|
35892
36028
|
var TASK_RELATION_KINDS = [
|
|
35893
36029
|
"blocked-by",
|
|
35894
36030
|
"follow-up-of",
|
|
@@ -36018,7 +36154,7 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
|
|
|
36018
36154
|
};
|
|
36019
36155
|
}, "taskRelationsStoreOver");
|
|
36020
36156
|
|
|
36021
|
-
// 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
|
|
36022
36158
|
var TASK_ROLES = ["assignee", "reviewer", "watcher"];
|
|
36023
36159
|
var iso4 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
|
|
36024
36160
|
var recordTaskEvent = /* @__PURE__ */ __name((database, task, actor, kind4, changes, at) => {
|
|
@@ -36547,7 +36683,7 @@ var workTasksOver = /* @__PURE__ */ __name((context) => {
|
|
|
36547
36683
|
};
|
|
36548
36684
|
}, "workTasksOver");
|
|
36549
36685
|
|
|
36550
|
-
// 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
|
|
36551
36687
|
var taskCloseOver = /* @__PURE__ */ __name((context) => {
|
|
36552
36688
|
const { database, now: now2 } = context;
|
|
36553
36689
|
const liveRow = /* @__PURE__ */ __name((id2) => {
|
|
@@ -36596,7 +36732,7 @@ var taskCloseOver = /* @__PURE__ */ __name((context) => {
|
|
|
36596
36732
|
};
|
|
36597
36733
|
}, "taskCloseOver");
|
|
36598
36734
|
|
|
36599
|
-
// 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
|
|
36600
36736
|
var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
|
|
36601
36737
|
const { database, now: now2 } = context;
|
|
36602
36738
|
const required3 = /* @__PURE__ */ __name((id2) => {
|
|
@@ -36814,7 +36950,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
|
|
|
36814
36950
|
};
|
|
36815
36951
|
}, "taskPairsOver");
|
|
36816
36952
|
|
|
36817
|
-
// 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
|
|
36818
36954
|
var ACCOUNT_SCOPE = "t.package_id IS NOT NULL AND t.deleted_at IS NULL AND t.project_id = ?";
|
|
36819
36955
|
var TASK_STATS_SQL = {
|
|
36820
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"),
|
|
@@ -36853,7 +36989,7 @@ var taskStatsOver = /* @__PURE__ */ __name(({ database }, inbox) => ({
|
|
|
36853
36989
|
}, "statNames")
|
|
36854
36990
|
}), "taskStatsOver");
|
|
36855
36991
|
|
|
36856
|
-
// 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
|
|
36857
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";
|
|
36858
36994
|
var inboxProject = /* @__PURE__ */ __name(({ database, now: now2 }, account, create) => {
|
|
36859
36995
|
const key2 = inboxKey(account);
|
|
@@ -37060,7 +37196,7 @@ var oneOf3 = /* @__PURE__ */ __name((values, value, column2) => {
|
|
|
37060
37196
|
throw new CliError("configuration_error", `the store holds a task with an unknown ${column2} "${String(value)}"`);
|
|
37061
37197
|
}, "oneOf");
|
|
37062
37198
|
|
|
37063
|
-
// 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
|
|
37064
37200
|
var accountAccountsOver = /* @__PURE__ */ __name((context) => {
|
|
37065
37201
|
const { database } = context;
|
|
37066
37202
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2 } = keysOver(context);
|
|
@@ -37105,7 +37241,7 @@ var accountsStoreOver = /* @__PURE__ */ __name((context, keyed) => {
|
|
|
37105
37241
|
};
|
|
37106
37242
|
}, "accountsStoreOver");
|
|
37107
37243
|
|
|
37108
|
-
// 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
|
|
37109
37245
|
var refColumn = /* @__PURE__ */ __name((ref3) => ref3 && Object.keys(ref3).length > 0 ? { providerRef: JSON.stringify(ref3) } : {}, "refColumn");
|
|
37110
37246
|
var updatePlaced = /* @__PURE__ */ __name(({ orm }, chatKey, messageId, files2, change) => {
|
|
37111
37247
|
const message2 = orm.select({ pk: messages.id }).from(messages).where(and(eq(messages.chatId, chatKey), eq(messages.externalId, messageId))).get();
|
|
@@ -37129,7 +37265,7 @@ var keepDownloads = /* @__PURE__ */ __name((context, chatKey, messageId, files2)
|
|
|
37129
37265
|
})), "keepDownloads");
|
|
37130
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");
|
|
37131
37267
|
|
|
37132
|
-
// 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
|
|
37133
37269
|
var accountAttachmentsOver = /* @__PURE__ */ __name((context) => {
|
|
37134
37270
|
const { database } = context;
|
|
37135
37271
|
const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
|
|
@@ -37186,7 +37322,7 @@ var attachmentsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
37186
37322
|
}, "keepAttachmentText")
|
|
37187
37323
|
}), "attachmentsStoreOver");
|
|
37188
37324
|
|
|
37189
|
-
// 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
|
|
37190
37326
|
var chatRow = /* @__PURE__ */ __name((context, accountKey, chatId) => context.database.prepare("SELECT * FROM chats WHERE account_id = ? AND external_id = ?").get(accountKey, chatId), "chatRow");
|
|
37191
37327
|
var pointerMover = /* @__PURE__ */ __name((context, type) => {
|
|
37192
37328
|
const statements = pointerPairs(context.database).filter(({ table }) => table !== "involvements").map(({ table, pointer }) => {
|
|
@@ -37366,7 +37502,7 @@ var rekeyChats = /* @__PURE__ */ __name((context, key2, accountKey, pairs, lockM
|
|
|
37366
37502
|
return done;
|
|
37367
37503
|
}, "rekeyChats");
|
|
37368
37504
|
|
|
37369
|
-
// 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
|
|
37370
37506
|
var historyStartKey = /* @__PURE__ */ __name((chatId) => `history_start:${chatId}`, "historyStartKey");
|
|
37371
37507
|
var fetchedKey = /* @__PURE__ */ __name((chatId) => `fetched:${chatId}`, "fetchedKey");
|
|
37372
37508
|
var CHAT_LIST_KEY = "chat_list_complete";
|
|
@@ -37424,7 +37560,7 @@ var chatCoverage = /* @__PURE__ */ __name(({ database }, accountKey) => {
|
|
|
37424
37560
|
return { ...coverage, oldestMessageAt: toIso(oldest) };
|
|
37425
37561
|
}, "chatCoverage");
|
|
37426
37562
|
|
|
37427
|
-
// 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
|
|
37428
37564
|
var chatsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
37429
37565
|
const { database } = context;
|
|
37430
37566
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, writeState: writeState2 } = keysOver(context);
|
|
@@ -37559,7 +37695,7 @@ var chatsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
37559
37695
|
};
|
|
37560
37696
|
}, "chatsStoreOver");
|
|
37561
37697
|
|
|
37562
|
-
// 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
|
|
37563
37699
|
import { createHash as createHash7 } from "node:crypto";
|
|
37564
37700
|
var BATCH_CONTEXT = 50;
|
|
37565
37701
|
var replied = /* @__PURE__ */ __name((m) => sql`EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
|
|
@@ -37697,7 +37833,7 @@ var saveAnswers = /* @__PURE__ */ __name((context, id2, answer) => {
|
|
|
37697
37833
|
var clearAnswers = /* @__PURE__ */ __name(({ orm }, chatKey, model) => Number(orm.all(sql`DELETE FROM message_links WHERE chat_id = ${chatKey} AND source = 'agent'
|
|
37698
37834
|
${model === void 0 ? sql`` : sql`AND method = ${model}`} RETURNING 1 AS n`).length), "clearAnswers");
|
|
37699
37835
|
|
|
37700
|
-
// 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
|
|
37701
37837
|
import { setTimeout } from "node:timers/promises";
|
|
37702
37838
|
var position = /* @__PURE__ */ __name((sentAt, pk) => `${sentAt}:${pk}`, "position");
|
|
37703
37839
|
var linkInputs = /* @__PURE__ */ __name(({ orm }, chatKey, { after: after2, limit }) => {
|
|
@@ -38009,7 +38145,7 @@ var agentAnswers = /* @__PURE__ */ __name(({ orm }, chatKey) => new Map(orm.all(
|
|
|
38009
38145
|
AND NOT EXISTS (SELECT 1 FROM messages d
|
|
38010
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");
|
|
38011
38147
|
|
|
38012
|
-
// 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
|
|
38013
38149
|
var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
38014
38150
|
const { database } = context;
|
|
38015
38151
|
const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
|
|
@@ -38116,7 +38252,7 @@ var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
38116
38252
|
};
|
|
38117
38253
|
}, "conversationsStoreOver");
|
|
38118
38254
|
|
|
38119
|
-
// 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
|
|
38120
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";
|
|
38121
38257
|
var accountCountersOver = /* @__PURE__ */ __name((context) => {
|
|
38122
38258
|
const { database } = context;
|
|
@@ -38141,7 +38277,7 @@ var countersStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
38141
38277
|
counterTargets: /* @__PURE__ */ __name(async (execution, options) => counterTargets(context, execution, options), "counterTargets")
|
|
38142
38278
|
}), "countersStoreOver");
|
|
38143
38279
|
|
|
38144
|
-
// 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
|
|
38145
38281
|
var MENTION_STATUSES = ["found", "linked", "dismissed"];
|
|
38146
38282
|
var MENTION_QUERY = defineQuery({
|
|
38147
38283
|
entity: "mention",
|
|
@@ -38357,7 +38493,7 @@ var listPlaces = /* @__PURE__ */ __name((database, { limit, offset }) => {
|
|
|
38357
38493
|
return { items: hasMore ? rows.slice(0, limit) : rows, hasMore };
|
|
38358
38494
|
}, "listPlaces");
|
|
38359
38495
|
|
|
38360
|
-
// 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
|
|
38361
38497
|
var accountMentionsOver = /* @__PURE__ */ __name((context) => {
|
|
38362
38498
|
const { database } = context;
|
|
38363
38499
|
const { findAccountPk: findAccountPk2 } = keysOver(context);
|
|
@@ -38392,7 +38528,7 @@ var mentionsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
38392
38528
|
places: /* @__PURE__ */ __name(async (window) => listPlaces(context.database, window), "places")
|
|
38393
38529
|
}), "mentionsStoreOver");
|
|
38394
38530
|
|
|
38395
|
-
// 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
|
|
38396
38532
|
var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messageId) => {
|
|
38397
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");
|
|
38398
38534
|
const rows = messageId === void 0 ? read2.all(chatKey) : read2.all(chatKey, messageId);
|
|
@@ -38407,7 +38543,7 @@ var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messag
|
|
|
38407
38543
|
}));
|
|
38408
38544
|
}, "documentLinkMessages");
|
|
38409
38545
|
|
|
38410
|
-
// 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
|
|
38411
38547
|
var stemmerFor = stemmerCache();
|
|
38412
38548
|
var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit }) => {
|
|
38413
38549
|
if (wanted.length > 50 || !Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
@@ -38451,7 +38587,7 @@ var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit
|
|
|
38451
38587
|
});
|
|
38452
38588
|
}, "laterSharingRare");
|
|
38453
38589
|
|
|
38454
|
-
// 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
|
|
38455
38591
|
var accountMessagesOver = /* @__PURE__ */ __name((context) => {
|
|
38456
38592
|
const { database } = context;
|
|
38457
38593
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf, chatPkFor: chatPkFor2, answeredChatPk: answeredChatPk2, upsertMessage: upsertMessage2 } = keysOver(context);
|
|
@@ -38586,7 +38722,7 @@ var messagesStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
38586
38722
|
laterSharingRare: /* @__PURE__ */ __name(async (wanted, options) => laterSharingRare(context, wanted, options), "laterSharingRare")
|
|
38587
38723
|
}), "messagesStoreOver");
|
|
38588
38724
|
|
|
38589
|
-
// 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
|
|
38590
38726
|
var GLOBAL_PROJECT = "SELECT id FROM main.projects WHERE account_id IS NULL AND deleted_at IS NULL";
|
|
38591
38727
|
var iso5 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
|
|
38592
38728
|
var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: accounts2, limit }) => {
|
|
@@ -38643,7 +38779,7 @@ var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: a
|
|
|
38643
38779
|
});
|
|
38644
38780
|
}, "personPreparation");
|
|
38645
38781
|
|
|
38646
|
-
// 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
|
|
38647
38783
|
var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds) => {
|
|
38648
38784
|
const id2 = Number(uid);
|
|
38649
38785
|
if (!/^[1-9]\d*$/.test(uid) || !Number.isSafeInteger(id2) || !accountIds.length || accountIds.length > 1e3 || accountIds.some((account) => !Number.isSafeInteger(account) || account <= 0))
|
|
@@ -38651,7 +38787,7 @@ var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds
|
|
|
38651
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)));
|
|
38652
38788
|
}, "personSeenInAccounts");
|
|
38653
38789
|
|
|
38654
|
-
// 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
|
|
38655
38791
|
var required2 = /* @__PURE__ */ __name(({ database }, key2, personId) => {
|
|
38656
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);
|
|
38657
38793
|
if (!row2)
|
|
@@ -38717,7 +38853,7 @@ var removeNote = /* @__PURE__ */ __name((context, key2, personId, id2) => {
|
|
|
38717
38853
|
return { id: id2, personId, removed: true };
|
|
38718
38854
|
}, "removeNote");
|
|
38719
38855
|
|
|
38720
|
-
// 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
|
|
38721
38857
|
var accountPeopleOver = /* @__PURE__ */ __name((context) => {
|
|
38722
38858
|
const { database } = context;
|
|
38723
38859
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, identityPk: identityPk2 } = keysOver(context);
|
|
@@ -38802,13 +38938,13 @@ var peopleStoreOver = /* @__PURE__ */ __name((context, keyed) => {
|
|
|
38802
38938
|
};
|
|
38803
38939
|
}, "peopleStoreOver");
|
|
38804
38940
|
|
|
38805
|
-
// 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
|
|
38806
38942
|
import { createHash as createHash9 } from "node:crypto";
|
|
38807
38943
|
|
|
38808
|
-
// 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
|
|
38809
38945
|
import { createHash as createHash8 } from "node:crypto";
|
|
38810
38946
|
|
|
38811
|
-
// 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
|
|
38812
38948
|
var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
|
|
38813
38949
|
var AUTHOR_MEASURES = [
|
|
38814
38950
|
"messages",
|
|
@@ -38948,7 +39084,7 @@ var withoutUrls = /* @__PURE__ */ __name((text6) => text6.replace(/\S+/gu, (toke
|
|
|
38948
39084
|
var rankingWords = /* @__PURE__ */ __name((text6) => withoutUrls(text6).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
|
|
38949
39085
|
var rankingQuestion = /* @__PURE__ */ __name((text6) => withoutUrls(text6).includes("?"), "rankingQuestion");
|
|
38950
39086
|
|
|
38951
|
-
// 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
|
|
38952
39088
|
var RANKING_GRAPH_LIMITS = { nodes: 5e4, depth: 256, work: 1e7, bytes: 8388608 };
|
|
38953
39089
|
var exhausted2 = /* @__PURE__ */ __name((budget) => {
|
|
38954
39090
|
throw new CliError("validation_error", `ranking exceeded ${budget} \u2014 narrow its chat or date scope`, {
|
|
@@ -39170,7 +39306,7 @@ var rankReplyGraph = /* @__PURE__ */ __name((nodes, check3 = () => {
|
|
|
39170
39306
|
};
|
|
39171
39307
|
}, "rankReplyGraph");
|
|
39172
39308
|
|
|
39173
|
-
// 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
|
|
39174
39310
|
var adminEntityKey = /* @__PURE__ */ __name((row2) => JSON.stringify([row2.account.provider, row2.account.account, row2.id]), "adminEntityKey");
|
|
39175
39311
|
var personKey = /* @__PURE__ */ __name((node) => JSON.stringify([node.account.provider, node.account.account, node.sender]), "personKey");
|
|
39176
39312
|
var locator = /* @__PURE__ */ __name((node) => formatLocator({ ...node.account, chat: node.chatId, message: node.id }), "locator");
|
|
@@ -39344,7 +39480,7 @@ var calculateAdminStatistics = /* @__PURE__ */ __name((nodes, stays, options, in
|
|
|
39344
39480
|
return { items, evidence, summary, graph: graph.quality };
|
|
39345
39481
|
}, "calculateAdminStatistics");
|
|
39346
39482
|
|
|
39347
|
-
// 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
|
|
39348
39484
|
var rankingContextRange = /* @__PURE__ */ __name((root) => {
|
|
39349
39485
|
const dates = [];
|
|
39350
39486
|
const visit = /* @__PURE__ */ __name((node, required3) => {
|
|
@@ -39366,7 +39502,7 @@ var rankingContextRange = /* @__PURE__ */ __name((root) => {
|
|
|
39366
39502
|
return dates[0].node.resolution.date;
|
|
39367
39503
|
}, "rankingContextRange");
|
|
39368
39504
|
|
|
39369
|
-
// 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
|
|
39370
39506
|
var reactionCounts = /* @__PURE__ */ __name((stored3) => {
|
|
39371
39507
|
let counts;
|
|
39372
39508
|
try {
|
|
@@ -39661,7 +39797,7 @@ var rankQuery = /* @__PURE__ */ __name((context, execution, request, inspect) =>
|
|
|
39661
39797
|
});
|
|
39662
39798
|
}, "rankQuery");
|
|
39663
39799
|
|
|
39664
|
-
// 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
|
|
39665
39801
|
function fail4(message2, reason = "query.too-large") {
|
|
39666
39802
|
throw new CliError("validation_error", message2, { reason, complete: false });
|
|
39667
39803
|
}
|
|
@@ -39838,7 +39974,7 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
|
|
|
39838
39974
|
return result;
|
|
39839
39975
|
}), "adminStatisticsQuery");
|
|
39840
39976
|
|
|
39841
|
-
// 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
|
|
39842
39978
|
var conversationEligibility = /* @__PURE__ */ __name(async (context, execution) => {
|
|
39843
39979
|
if (!execution.accounts.length)
|
|
39844
39980
|
return { conversations: [], chats: [] };
|
|
@@ -39856,7 +39992,7 @@ var conversationEligibility = /* @__PURE__ */ __name(async (context, execution)
|
|
|
39856
39992
|
return { conversations: conversations2, chats: chats2 };
|
|
39857
39993
|
}, "conversationEligibility");
|
|
39858
39994
|
|
|
39859
|
-
// 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
|
|
39860
39996
|
import { createHash as createHash10 } from "node:crypto";
|
|
39861
39997
|
var EVIDENCE_BYTES = 64 * 1024;
|
|
39862
39998
|
var FINGERPRINT_BYTES = 8 * 1024 * 1024;
|
|
@@ -40006,7 +40142,7 @@ var rankingEvidence = /* @__PURE__ */ __name((context, execution, request) => {
|
|
|
40006
40142
|
return result;
|
|
40007
40143
|
}, "rankingEvidence");
|
|
40008
40144
|
|
|
40009
|
-
// 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
|
|
40010
40146
|
var FAR = Number.MAX_SAFE_INTEGER;
|
|
40011
40147
|
var chatsIn = /* @__PURE__ */ __name((scope3, kinds2) => {
|
|
40012
40148
|
const params = [...scope3.accounts.flatMap(({ provider, account }) => [provider, account]), ...kinds2];
|
|
@@ -40100,7 +40236,7 @@ var waitingChats = /* @__PURE__ */ __name((context, scope3, waits, cap) => {
|
|
|
40100
40236
|
});
|
|
40101
40237
|
}, "waitingChats");
|
|
40102
40238
|
|
|
40103
|
-
// 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
|
|
40104
40240
|
var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
|
|
40105
40241
|
const mailIndexed = /* @__PURE__ */ __name((execution) => {
|
|
40106
40242
|
if (execution.corpus === "mail")
|
|
@@ -40121,7 +40257,7 @@ var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
|
|
|
40121
40257
|
};
|
|
40122
40258
|
}, "queriesStoreOver");
|
|
40123
40259
|
|
|
40124
|
-
// 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
|
|
40125
40261
|
var saveChatEvents = /* @__PURE__ */ __name((context, accountKey, provider, chatKey, events3) => {
|
|
40126
40262
|
const { database, now: now2 } = context;
|
|
40127
40263
|
const insert = database.prepare(`INSERT INTO chat_events (chat_id, source_id, action, actor_identity_id, title, happened_at, created_at, updated_at)
|
|
@@ -40160,10 +40296,10 @@ var chatEventsOf = /* @__PURE__ */ __name(({ database }, chatKey, { since = 0, l
|
|
|
40160
40296
|
}));
|
|
40161
40297
|
}, "chatEventsOf");
|
|
40162
40298
|
|
|
40163
|
-
// 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
|
|
40164
40300
|
import { createHash as createHash11 } from "node:crypto";
|
|
40165
40301
|
|
|
40166
|
-
// 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
|
|
40167
40303
|
var calendarKey = /* @__PURE__ */ __name((zone, by) => {
|
|
40168
40304
|
const format = new Intl.DateTimeFormat("en-CA", {
|
|
40169
40305
|
timeZone: zone,
|
|
@@ -40183,7 +40319,7 @@ var weekKey = /* @__PURE__ */ __name((day) => {
|
|
|
40183
40319
|
return date3.toISOString().slice(0, 10);
|
|
40184
40320
|
}, "weekKey");
|
|
40185
40321
|
|
|
40186
|
-
// 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
|
|
40187
40323
|
var RETENTION_TOLERANCE = 864e5;
|
|
40188
40324
|
var validateRetentionOptions = /* @__PURE__ */ __name((options) => {
|
|
40189
40325
|
const { since, until, cutoff, checkpoints, within, limit, by } = options;
|
|
@@ -40237,7 +40373,7 @@ var retentionCohorts = /* @__PURE__ */ __name((stays, options) => {
|
|
|
40237
40373
|
return [...groups.values()].sort((a, b) => a.cohort.localeCompare(b.cohort));
|
|
40238
40374
|
}, "retentionCohorts");
|
|
40239
40375
|
|
|
40240
|
-
// 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
|
|
40241
40377
|
var iso6 = /* @__PURE__ */ __name((at) => new Date(at).toISOString(), "iso");
|
|
40242
40378
|
var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId, options, evidence) => {
|
|
40243
40379
|
validateRetentionOptions(options);
|
|
@@ -40368,7 +40504,7 @@ var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId
|
|
|
40368
40504
|
};
|
|
40369
40505
|
}, "retentionQuery");
|
|
40370
40506
|
|
|
40371
|
-
// 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
|
|
40372
40508
|
var iso7 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
|
|
40373
40509
|
var marksOf = /* @__PURE__ */ __name(({ isBot, flagged, deleted, hasPhoto }) => ({
|
|
40374
40510
|
...isBot === void 0 ? {} : { bot: isBot },
|
|
@@ -40499,7 +40635,7 @@ var trackedChats = /* @__PURE__ */ __name((context, accountKey, where) => contex
|
|
|
40499
40635
|
lastCount: memberCountsOf(context, pk).at(-1) ?? null
|
|
40500
40636
|
})), "trackedChats");
|
|
40501
40637
|
|
|
40502
|
-
// 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
|
|
40503
40639
|
var rosterStoreOver = /* @__PURE__ */ __name((context) => {
|
|
40504
40640
|
const { database } = context;
|
|
40505
40641
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, writeMembers: writeMembers2 } = keysOver(context);
|
|
@@ -40555,7 +40691,7 @@ var rosterStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
40555
40691
|
};
|
|
40556
40692
|
}, "rosterStoreOver");
|
|
40557
40693
|
|
|
40558
|
-
// 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
|
|
40559
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");
|
|
40560
40696
|
var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatch, until = /* @__PURE__ */ __name(() => false, "until") } = {}) => {
|
|
40561
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 ?`);
|
|
@@ -40579,7 +40715,7 @@ var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatc
|
|
|
40579
40715
|
}
|
|
40580
40716
|
}, "backfillNormalized");
|
|
40581
40717
|
|
|
40582
|
-
// 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
|
|
40583
40719
|
var INDEX2 = "message_words";
|
|
40584
40720
|
var searchIndexState2 = /* @__PURE__ */ __name((database) => {
|
|
40585
40721
|
const row2 = indexRow(database, INDEX2);
|
|
@@ -40706,7 +40842,7 @@ var resetSearchIndex = /* @__PURE__ */ __name((database) => {
|
|
|
40706
40842
|
});
|
|
40707
40843
|
}, "resetSearchIndex");
|
|
40708
40844
|
|
|
40709
|
-
// 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
|
|
40710
40846
|
var fillStems = /* @__PURE__ */ __name((database, { batch = 5e3, until = /* @__PURE__ */ __name(() => false, "until"), onBatch, now: now2 = Date.now } = {}) => {
|
|
40711
40847
|
const filled2 = { stemmed: 0, drained: 0 };
|
|
40712
40848
|
const before2 = stemsState(database);
|
|
@@ -40801,7 +40937,7 @@ var followDefaultStemmers = /* @__PURE__ */ __name((database, now2 = Date.now) =
|
|
|
40801
40937
|
return resetStems(database, { now: now2 });
|
|
40802
40938
|
}, "followDefaultStemmers");
|
|
40803
40939
|
|
|
40804
|
-
// 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
|
|
40805
40941
|
var VOCABULARY = "SELECT term, doc FROM message_words_vocab WHERE col = 'normalized_text'";
|
|
40806
40942
|
var knownTerms = /* @__PURE__ */ __name(({ database }, terms2) => {
|
|
40807
40943
|
const lookup = database.prepare(`${VOCABULARY} AND term >= ? AND term <= ? LIMIT 1`);
|
|
@@ -40823,7 +40959,7 @@ var termCandidates = /* @__PURE__ */ __name(({ database }, pieces, { shortest, l
|
|
|
40823
40959
|
});
|
|
40824
40960
|
}, "termCandidates");
|
|
40825
40961
|
|
|
40826
|
-
// 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
|
|
40827
40963
|
var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
|
|
40828
40964
|
const { database } = context;
|
|
40829
40965
|
const stemmerFor2 = stemmerCache();
|
|
@@ -40845,7 +40981,7 @@ var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
40845
40981
|
};
|
|
40846
40982
|
}, "searchIndexStoreOver");
|
|
40847
40983
|
|
|
40848
|
-
// 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
|
|
40849
40985
|
var HISTORY_KEPT = 1e3;
|
|
40850
40986
|
var commandFilter = /* @__PURE__ */ __name((commands) => commands ? { sql: ` AND command IN (${commands.map(() => "?").join(", ")})`, values: [...commands] } : { sql: "", values: [] }, "commandFilter");
|
|
40851
40987
|
var COLUMNS5 = "id, name, command, params, language, version, fields_version, created_at, updated_at, last_run_at, runs";
|
|
@@ -40914,7 +41050,7 @@ var clearHistory = /* @__PURE__ */ __name(({ database }, commands) => {
|
|
|
40914
41050
|
return database.prepare(`DELETE FROM searches WHERE name IS NULL${only.sql}`).run(...only.values).changes;
|
|
40915
41051
|
}, "clearHistory");
|
|
40916
41052
|
|
|
40917
|
-
// 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
|
|
40918
41054
|
var searchesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
40919
41055
|
const { database } = context;
|
|
40920
41056
|
return {
|
|
@@ -40938,7 +41074,7 @@ var searchesStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
40938
41074
|
};
|
|
40939
41075
|
}, "searchesStoreOver");
|
|
40940
41076
|
|
|
40941
|
-
// 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
|
|
40942
41078
|
var ACTION_TIERS = ["read", "draft", "write-private", "write-public", "destructive", "admin"];
|
|
40943
41079
|
var ACTION_OUTCOMES = ["ok", "refused", "failed"];
|
|
40944
41080
|
var CODE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
@@ -40981,7 +41117,7 @@ var agentActionsStoreOver = /* @__PURE__ */ __name((context, afterRecord = () =>
|
|
|
40981
41117
|
};
|
|
40982
41118
|
}, "agentActionsStoreOver");
|
|
40983
41119
|
|
|
40984
|
-
// 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
|
|
40985
41121
|
var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
|
|
40986
41122
|
}) => {
|
|
40987
41123
|
const { database, now: now2 } = context;
|
|
@@ -41040,7 +41176,7 @@ var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
|
|
|
41040
41176
|
};
|
|
41041
41177
|
}, "botUpdateStoreOver");
|
|
41042
41178
|
|
|
41043
|
-
// 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
|
|
41044
41180
|
var DAY4 = 864e5;
|
|
41045
41181
|
var accountsOf = /* @__PURE__ */ __name((filter) => {
|
|
41046
41182
|
if (filter.accountIds !== void 0 && filter.accountId !== void 0)
|
|
@@ -41149,7 +41285,7 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
|
|
|
41149
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);
|
|
41150
41286
|
}, "listEvents");
|
|
41151
41287
|
|
|
41152
|
-
// 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
|
|
41153
41289
|
var distinctIds = /* @__PURE__ */ __name((rows) => [...new Set(rows.map((row2) => Number(row2.id)))], "distinctIds");
|
|
41154
41290
|
var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, accountId, cursorKey: cursorKey2, now: now2 }, refresh) => {
|
|
41155
41291
|
const unseenBefore = unreferenced(database, "identities");
|
|
@@ -41204,7 +41340,7 @@ var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, account
|
|
|
41204
41340
|
return { entries: entryIds.length, events: goneEvents.length };
|
|
41205
41341
|
}, "forgetCalendarRows");
|
|
41206
41342
|
|
|
41207
|
-
// 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
|
|
41208
41344
|
var calendarOf = /* @__PURE__ */ __name((row2) => ({
|
|
41209
41345
|
id: Number(row2.id),
|
|
41210
41346
|
accountId: Number(row2.account_id),
|
|
@@ -41791,7 +41927,7 @@ var eventStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
41791
41927
|
};
|
|
41792
41928
|
}, "eventStoreOver");
|
|
41793
41929
|
|
|
41794
|
-
// 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
|
|
41795
41931
|
var CATALOG_QUERY = defineQuery({
|
|
41796
41932
|
entity: "document",
|
|
41797
41933
|
backend: "sql",
|
|
@@ -42033,7 +42169,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
|
|
|
42033
42169
|
};
|
|
42034
42170
|
}, "catalogStoreOver");
|
|
42035
42171
|
|
|
42036
|
-
// 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
|
|
42037
42173
|
var drive = "CASE WHEN json_valid(n.front_matter) THEN json_extract(n.front_matter,'$.source')='google-drive' ELSE 0 END";
|
|
42038
42174
|
var field3 = /* @__PURE__ */ __name((name) => `CASE WHEN (${drive}) THEN
|
|
42039
42175
|
CASE WHEN json_type(n.front_matter,'$.${name}')='text' THEN json_extract(n.front_matter,'$.${name}') END END`, "field");
|
|
@@ -42046,7 +42182,7 @@ var contextDocumentTimeKind = `CASE WHEN (${remoteTime}) IS NOT NULL
|
|
|
42046
42182
|
THEN 'source-modified' ELSE 'stored-update' END`;
|
|
42047
42183
|
var contextDocumentUrl = `coalesce(${preferred("url")},n.url,${field3("sourceUrl")})`;
|
|
42048
42184
|
|
|
42049
|
-
// 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
|
|
42050
42186
|
var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
|
|
42051
42187
|
const { source: source2, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal } = request;
|
|
42052
42188
|
signal?.throwIfAborted();
|
|
@@ -42145,7 +42281,7 @@ var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
|
|
|
42145
42281
|
});
|
|
42146
42282
|
}, "readMeetingContextEvidence");
|
|
42147
42283
|
|
|
42148
|
-
// 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
|
|
42149
42285
|
var corpora = {
|
|
42150
42286
|
message: {
|
|
42151
42287
|
table: "messages",
|
|
@@ -42384,7 +42520,776 @@ var contextRecordsOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
42384
42520
|
}
|
|
42385
42521
|
}), "contextRecordsOver");
|
|
42386
42522
|
|
|
42387
|
-
// 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
|
|
42388
43293
|
var NOTE_FIELDS = [
|
|
42389
43294
|
"text",
|
|
42390
43295
|
"exact",
|
|
@@ -42814,7 +43719,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
|
|
|
42814
43719
|
};
|
|
42815
43720
|
}, "noteSearchOver");
|
|
42816
43721
|
|
|
42817
|
-
// 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
|
|
42818
43723
|
var EVENT_FIELDS = ["text", "exact", "body", "title", "date", "in"];
|
|
42819
43724
|
var inEventAccounts = /* @__PURE__ */ __name((event) => searchableCopy(event, "c.account_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))"), "inEventAccounts");
|
|
42820
43725
|
var EVENT_CORPUS = {
|
|
@@ -42946,468 +43851,7 @@ var eventSearchOver = /* @__PURE__ */ __name((context) => {
|
|
|
42946
43851
|
};
|
|
42947
43852
|
}, "eventSearchOver");
|
|
42948
43853
|
|
|
42949
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
42950
|
-
var refuse = /* @__PURE__ */ __name((message2, reason, code = "validation_error") => {
|
|
42951
|
-
throw new CliError(code, message2, { reason });
|
|
42952
|
-
}, "refuse");
|
|
42953
|
-
var oneOf4 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
42954
|
-
if (typeof value !== "string" || !allowed.includes(value))
|
|
42955
|
-
return refuse(`${what} is one of ${allowed.join(", ")}`, "finance.field");
|
|
42956
|
-
return value;
|
|
42957
|
-
}, "oneOf");
|
|
42958
|
-
var text3 = /* @__PURE__ */ __name((value, what, limit) => {
|
|
42959
|
-
if (value === void 0 || value === null)
|
|
42960
|
-
return null;
|
|
42961
|
-
if (typeof value !== "string" || !value.trim() || value.length > limit || value.includes("\0"))
|
|
42962
|
-
return refuse(`${what} takes 1\u2013${limit} characters`, "finance.field");
|
|
42963
|
-
return value.trim();
|
|
42964
|
-
}, "text");
|
|
42965
|
-
var isoDate = /* @__PURE__ */ __name((value, what) => {
|
|
42966
|
-
if (value === void 0 || value === null)
|
|
42967
|
-
return null;
|
|
42968
|
-
const date3 = typeof value === "string" ? value.trim() : "";
|
|
42969
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(date3) || (/* @__PURE__ */ new Date(`${date3}T00:00:00Z`)).toISOString().slice(0, 10) !== date3)
|
|
42970
|
-
return refuse(`${what} is a date such as 2026-11-15`, "finance.field");
|
|
42971
|
-
return date3;
|
|
42972
|
-
}, "isoDate");
|
|
42973
|
-
var iso8 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
42974
|
-
var evidenceList = /* @__PURE__ */ __name((value) => {
|
|
42975
|
-
if (value === void 0)
|
|
42976
|
-
return [];
|
|
42977
|
-
if (!Array.isArray(value) || value.length > 8 || value.some((one2) => typeof one2 !== "string" || !one2.trim()))
|
|
42978
|
-
return refuse("evidence is a list of at most 8 references", "finance.field");
|
|
42979
|
-
return [...new Set(value.map((one2) => one2.trim()))];
|
|
42980
|
-
}, "evidenceList");
|
|
42981
|
-
var MAX_LINES = 500;
|
|
42982
|
-
var reasonOf = /* @__PURE__ */ __name((metadata3) => {
|
|
42983
|
-
if (metadata3 == null)
|
|
42984
|
-
return null;
|
|
42985
|
-
try {
|
|
42986
|
-
const { reason } = JSON.parse(String(metadata3));
|
|
42987
|
-
return typeof reason === "string" ? reason : null;
|
|
42988
|
-
} catch {
|
|
42989
|
-
return null;
|
|
42990
|
-
}
|
|
42991
|
-
}, "reasonOf");
|
|
42992
|
-
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)";
|
|
42993
|
-
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`;
|
|
42994
|
-
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";
|
|
42995
|
-
var reviewedRowsOver = /* @__PURE__ */ __name((context) => {
|
|
42996
|
-
const { database } = context;
|
|
42997
|
-
const partyOf = /* @__PURE__ */ __name((type, id2) => {
|
|
42998
|
-
if (type == null)
|
|
42999
|
-
return null;
|
|
43000
|
-
const { subject: subject2, subjectName: subjectName2, subjectIsOwner } = subjectOf(database, { subject_type: type, subject_id: id2 });
|
|
43001
|
-
return subject2 === null ? null : { ref: subject2, name: subjectName2, owner: subjectIsOwner };
|
|
43002
|
-
}, "partyOf");
|
|
43003
|
-
const partyThing = /* @__PURE__ */ __name((reference2, what) => {
|
|
43004
|
-
if (reference2 === void 0)
|
|
43005
|
-
return void 0;
|
|
43006
|
-
const thing = requiredThing(database, reference2, what);
|
|
43007
|
-
if (thing.type !== "person" && thing.type !== "organization")
|
|
43008
|
-
return refuse(`${what} is a person: or organization: reference, not ${reference2}`, "finance.party");
|
|
43009
|
-
return thing;
|
|
43010
|
-
}, "partyThing");
|
|
43011
|
-
const reviewedOf = /* @__PURE__ */ __name((row2, type) => ({
|
|
43012
|
-
review: row2.review,
|
|
43013
|
-
author: authorOf(row2),
|
|
43014
|
-
model: row2.model == null ? null : String(row2.model),
|
|
43015
|
-
confirmedBy: row2.confirmed_by_type == null ? null : { type: row2.confirmed_by_type, id: String(row2.confirmed_by_id) },
|
|
43016
|
-
source: String(row2.source),
|
|
43017
|
-
reason: reasonOf(row2.metadata),
|
|
43018
|
-
evidence: evidenceOf(context, { type, id: Number(row2.id) }),
|
|
43019
|
-
...projectOf(database, row2),
|
|
43020
|
-
createdAt: iso8(row2.created_at),
|
|
43021
|
-
updatedAt: iso8(row2.updated_at)
|
|
43022
|
-
}), "reviewedOf");
|
|
43023
|
-
const written2 = /* @__PURE__ */ __name((input) => {
|
|
43024
|
-
const owner = input.by === "owner";
|
|
43025
|
-
const { actor, model } = authorActor(context, input.by);
|
|
43026
|
-
const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
|
|
43027
|
-
const reason = owner ? null : text3(input.reason, "a reason", 2e3);
|
|
43028
|
-
return {
|
|
43029
|
-
owner,
|
|
43030
|
-
actor,
|
|
43031
|
-
model,
|
|
43032
|
-
source: source2,
|
|
43033
|
-
review: owner ? "confirmed" : "proposed",
|
|
43034
|
-
confirmedType: owner ? actor.type : null,
|
|
43035
|
-
confirmedId: owner ? actor.id : null,
|
|
43036
|
-
metadata: reason === null ? null : JSON.stringify({ reason }),
|
|
43037
|
-
project: input.project === void 0 ? null : projectId(database, input.project),
|
|
43038
|
-
evidence: evidenceList(input.evidence)
|
|
43039
|
-
};
|
|
43040
|
-
}, "written");
|
|
43041
|
-
const keepEvidence = /* @__PURE__ */ __name((type, id2, by) => {
|
|
43042
|
-
if (by.evidence.length)
|
|
43043
|
-
linkEvidence(context, { type, id: id2 }, by.evidence, by.owner ? "owner" : "agent");
|
|
43044
|
-
}, "keepEvidence");
|
|
43045
|
-
const ownerOnly = /* @__PURE__ */ __name((by, what) => {
|
|
43046
|
-
if (by !== "owner")
|
|
43047
|
-
refuse(`only the owner ${what}`, "finance.owner-only", "permission_error");
|
|
43048
|
-
}, "ownerOnly");
|
|
43049
|
-
const keepDecision = /* @__PURE__ */ __name((table, id2, by, reason) => {
|
|
43050
|
-
const why = [by === "owner" ? void 0 : by.reason.trim(), reason?.trim() || void 0].filter(Boolean).join(": ");
|
|
43051
|
-
if (by === "owner" && !why)
|
|
43052
|
-
return;
|
|
43053
|
-
const decision = by === "owner" ? { by: "owner", reason: why } : { by: "agent", bot: by.bot, reason: why };
|
|
43054
|
-
database.prepare(`UPDATE ${table} SET metadata = json_set(coalesce(metadata, '{}'), '$.decision', json(?)) WHERE id = ?`).run(JSON.stringify(decision), id2);
|
|
43055
|
-
}, "keepDecision");
|
|
43056
|
-
return { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision };
|
|
43057
|
-
}, "reviewedRowsOver");
|
|
43058
|
-
var financeOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
43059
|
-
const { database, now: now2 } = context;
|
|
43060
|
-
const { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision } = reviewedRowsOver(context);
|
|
43061
|
-
const invoiceOf2 = /* @__PURE__ */ __name((row2) => {
|
|
43062
|
-
const currency = String(row2.currency);
|
|
43063
|
-
const scale = scaleOf(currency);
|
|
43064
|
-
const [total, paid] = [Number(row2.total), Number(row2.paid)];
|
|
43065
|
-
const counterparty = partyOf(row2.counterparty_type, row2.counterparty_id);
|
|
43066
|
-
const fields4 = {
|
|
43067
|
-
id: Number(row2.id),
|
|
43068
|
-
number: row2.number == null ? null : String(row2.number),
|
|
43069
|
-
direction: row2.direction,
|
|
43070
|
-
total,
|
|
43071
|
-
currency,
|
|
43072
|
-
counterpartyName: counterparty?.name ?? null,
|
|
43073
|
-
dueDate: row2.due_date == null ? null : String(row2.due_date),
|
|
43074
|
-
status: row2.status,
|
|
43075
|
-
review: row2.review
|
|
43076
|
-
};
|
|
43077
|
-
return {
|
|
43078
|
-
id: String(row2.id),
|
|
43079
|
-
ref: `invoice:${row2.id}`,
|
|
43080
|
-
title: invoiceTitle(fields4),
|
|
43081
|
-
direction: fields4.direction,
|
|
43082
|
-
number: fields4.number,
|
|
43083
|
-
issuer: partyOf(row2.issuer_type, row2.issuer_id),
|
|
43084
|
-
counterparty,
|
|
43085
|
-
currency,
|
|
43086
|
-
total: formatDecimal(total, scale),
|
|
43087
|
-
paid: formatDecimal(paid, scale),
|
|
43088
|
-
open: formatDecimal(Math.max(total - paid, 0), scale),
|
|
43089
|
-
issueDate: row2.issue_date == null ? null : String(row2.issue_date),
|
|
43090
|
-
dueDate: fields4.dueDate,
|
|
43091
|
-
status: fields4.status,
|
|
43092
|
-
...reviewedOf(row2, "invoice")
|
|
43093
|
-
};
|
|
43094
|
-
}, "invoiceOf");
|
|
43095
|
-
const paymentOf3 = /* @__PURE__ */ __name((row2) => {
|
|
43096
|
-
const currency = String(row2.currency);
|
|
43097
|
-
const scale = scaleOf(currency);
|
|
43098
|
-
const [amount, allocated] = [Number(row2.amount), Number(row2.allocated)];
|
|
43099
|
-
const direction = row2.direction;
|
|
43100
|
-
const payer = partyOf(row2.payer_type, row2.payer_id);
|
|
43101
|
-
const payee = partyOf(row2.payee_type, row2.payee_id);
|
|
43102
|
-
const date3 = String(row2.payment_date);
|
|
43103
|
-
return {
|
|
43104
|
-
id: String(row2.id),
|
|
43105
|
-
ref: `payment:${row2.id}`,
|
|
43106
|
-
title: paymentEntryTitle({
|
|
43107
|
-
direction,
|
|
43108
|
-
amount,
|
|
43109
|
-
currency,
|
|
43110
|
-
partyName: (direction === "in" ? payer : payee)?.name ?? null,
|
|
43111
|
-
date: date3,
|
|
43112
|
-
review: row2.review
|
|
43113
|
-
}),
|
|
43114
|
-
direction,
|
|
43115
|
-
payer,
|
|
43116
|
-
payee,
|
|
43117
|
-
amount: formatDecimal(amount, scale),
|
|
43118
|
-
currency,
|
|
43119
|
-
date: date3,
|
|
43120
|
-
reference: row2.reference == null ? null : String(row2.reference),
|
|
43121
|
-
allocated: formatDecimal(allocated, scale),
|
|
43122
|
-
unallocated: formatDecimal(amount - allocated, scale),
|
|
43123
|
-
...reviewedOf(row2, "payment")
|
|
43124
|
-
};
|
|
43125
|
-
}, "paymentOf");
|
|
43126
|
-
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) => ({
|
|
43127
|
-
payment: `payment:${row2.payment_id}`,
|
|
43128
|
-
invoice: `invoice:${row2.invoice_id}`,
|
|
43129
|
-
amount: formatDecimal(Number(row2.amount), scaleOf(String(row2.currency))),
|
|
43130
|
-
currency: String(row2.currency),
|
|
43131
|
-
createdAt: iso8(row2.created_at)
|
|
43132
|
-
})), "allocationsWhere");
|
|
43133
|
-
const rowOf2 = /* @__PURE__ */ __name((reference2, type) => {
|
|
43134
|
-
const thing = requiredThing(database, reference2.includes(":") ? reference2 : `${type}:${reference2}`, `the ${type}`);
|
|
43135
|
-
if (thing.type !== type)
|
|
43136
|
-
return refuse(`${reference2} is not an ${type}`, "finance.ref");
|
|
43137
|
-
return database.prepare(`${type === "invoice" ? INVOICES : PAYMENTS} WHERE ${type[0]}.id = ?`).get(thing.id);
|
|
43138
|
-
}, "rowOf");
|
|
43139
|
-
const invoiceDetail = /* @__PURE__ */ __name((reference2) => {
|
|
43140
|
-
const row2 = rowOf2(reference2, "invoice");
|
|
43141
|
-
const scale = scaleOf(String(row2.currency));
|
|
43142
|
-
const lines = database.prepare("SELECT * FROM invoice_lines WHERE invoice_id = ? ORDER BY position").all(Number(row2.id)).map((line) => ({
|
|
43143
|
-
position: Number(line.position),
|
|
43144
|
-
description: String(line.description),
|
|
43145
|
-
quantity: String(line.quantity),
|
|
43146
|
-
unitPrice: line.unit_price == null ? null : formatDecimal(Number(line.unit_price), scale),
|
|
43147
|
-
amount: formatDecimal(Number(line.amount), scale)
|
|
43148
|
-
}));
|
|
43149
|
-
return { ...invoiceOf2(row2), lines, allocations: allocationsWhere("invoice_id", Number(row2.id)) };
|
|
43150
|
-
}, "invoiceDetail");
|
|
43151
|
-
const paymentDetail = /* @__PURE__ */ __name((reference2) => {
|
|
43152
|
-
const row2 = rowOf2(reference2, "payment");
|
|
43153
|
-
return { ...paymentOf3(row2), allocations: allocationsWhere("payment_id", Number(row2.id)) };
|
|
43154
|
-
}, "paymentDetail");
|
|
43155
|
-
const settle = /* @__PURE__ */ __name((invoiceId) => {
|
|
43156
|
-
const row2 = database.prepare(`SELECT i.status, i.total, ${PAID} AS paid FROM invoices i WHERE i.id = ?`).get(invoiceId);
|
|
43157
|
-
if (!row2)
|
|
43158
|
-
return;
|
|
43159
|
-
const status = settledStatus(row2.status, Number(row2.total), Number(row2.paid));
|
|
43160
|
-
database.prepare("UPDATE invoices SET status = ?, updated_at = ? WHERE id = ? AND status <> ?").run(status, now2(), invoiceId, status);
|
|
43161
|
-
}, "settle");
|
|
43162
|
-
const allocateRow = /* @__PURE__ */ __name((payment, reference2, units, actor) => {
|
|
43163
|
-
const invoice = rowOf2(reference2, "invoice");
|
|
43164
|
-
const [paymentRef, invoiceRef] = [`payment:${payment.id}`, `invoice:${invoice.id}`];
|
|
43165
|
-
if (invoice.deleted_at != null || invoice.review === "rejected")
|
|
43166
|
-
refuse(`${invoiceRef} is ${invoice.review === "rejected" ? "rejected" : "deleted"}`, "finance.allocate");
|
|
43167
|
-
if (invoice.status === "draft" || invoice.status === "void")
|
|
43168
|
-
refuse(`${invoiceRef} is ${invoice.status}; only an issued invoice is paid`, "finance.allocate");
|
|
43169
|
-
const currency = String(payment.currency);
|
|
43170
|
-
if (invoice.currency !== currency)
|
|
43171
|
-
refuse(`${paymentRef} is in ${currency} and ${invoiceRef} in ${String(invoice.currency)}; the store converts nothing`, "finance.currency");
|
|
43172
|
-
const fromPayment = Number(database.prepare("SELECT coalesce(sum(amount), 0) AS n FROM payment_allocations WHERE payment_id = ?").get(Number(payment.id))?.n);
|
|
43173
|
-
if (fromPayment + units > Number(payment.amount))
|
|
43174
|
-
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");
|
|
43175
|
-
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);
|
|
43176
|
-
if (toInvoice + units > Number(invoice.total))
|
|
43177
|
-
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");
|
|
43178
|
-
const at = now2();
|
|
43179
|
-
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);
|
|
43180
|
-
return Number(invoice.id);
|
|
43181
|
-
}, "allocateRow");
|
|
43182
|
-
const coveredElsewhere = /* @__PURE__ */ __name((paymentId) => {
|
|
43183
|
-
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);
|
|
43184
|
-
if (!over)
|
|
43185
|
-
return;
|
|
43186
|
-
const currency = String(over.currency);
|
|
43187
|
-
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");
|
|
43188
|
-
}, "coveredElsewhere");
|
|
43189
|
-
const decide2 = /* @__PURE__ */ __name((reference2, by, reason, confirm) => {
|
|
43190
|
-
const thing = requiredThing(database, reference2, "the proposal");
|
|
43191
|
-
if (thing.type !== "invoice" && thing.type !== "payment")
|
|
43192
|
-
return refuse(`${reference2} is not an invoice: or payment:`, "finance.ref");
|
|
43193
|
-
const type = thing.type;
|
|
43194
|
-
const table = type === "invoice" ? "invoices" : "payments";
|
|
43195
|
-
const row2 = rowOf2(reference2, type);
|
|
43196
|
-
const ref3 = `${type}:${row2.id}`;
|
|
43197
|
-
assertMayDecide({ id: ref3, proposedBy: proposerOf(database, row2.author_type, row2.author_id), ownerOnly: true }, by, context.decisions);
|
|
43198
|
-
if (row2.review !== "proposed")
|
|
43199
|
-
refuse(`${ref3} is already ${String(row2.review)}`, "proposal.wrong-state");
|
|
43200
|
-
const id2 = Number(row2.id);
|
|
43201
|
-
write(database, () => {
|
|
43202
|
-
const at = now2();
|
|
43203
|
-
if (confirm && type === "payment")
|
|
43204
|
-
coveredElsewhere(id2);
|
|
43205
|
-
if (confirm) {
|
|
43206
|
-
const { actor } = authorActor(context, deciderAuthor(by));
|
|
43207
|
-
database.prepare(`UPDATE ${table} SET review = 'confirmed', confirmed_by_type = ?, confirmed_by_id = ?, updated_at = ? WHERE id = ?`).run(actor.type, actor.id, at, id2);
|
|
43208
|
-
} else
|
|
43209
|
-
database.prepare(`UPDATE ${table} SET review = 'rejected', updated_at = ? WHERE id = ?`).run(at, id2);
|
|
43210
|
-
keepDecision(table, id2, by, reason);
|
|
43211
|
-
const touched = type === "invoice" ? [id2] : database.prepare("SELECT invoice_id FROM payment_allocations WHERE payment_id = ?").all(id2).map((one2) => Number(one2.invoice_id));
|
|
43212
|
-
if (!confirm)
|
|
43213
|
-
database.prepare(`DELETE FROM payment_allocations WHERE ${type === "invoice" ? "invoice_id" : "payment_id"} = ?`).run(id2);
|
|
43214
|
-
for (const invoice of touched)
|
|
43215
|
-
settle(invoice);
|
|
43216
|
-
});
|
|
43217
|
-
return type === "invoice" ? invoiceDetail(ref3) : paymentDetail(ref3);
|
|
43218
|
-
}, "decide");
|
|
43219
|
-
const mayAllocate = /* @__PURE__ */ __name((row2, by) => {
|
|
43220
|
-
if (by === "owner")
|
|
43221
|
-
return;
|
|
43222
|
-
const own = row2.author_type === "bot" && row2.author_name != null && botKey(String(row2.author_name)) === botKey(by.bot);
|
|
43223
|
-
if (row2.review !== "proposed" || !own)
|
|
43224
|
-
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");
|
|
43225
|
-
}, "mayAllocate");
|
|
43226
|
-
const limitOf2 = /* @__PURE__ */ __name((limit) => Math.min(Math.max(limit ?? 100, 1), 500), "limitOf");
|
|
43227
|
-
return {
|
|
43228
|
-
addInvoice: /* @__PURE__ */ __name((input) => {
|
|
43229
|
-
const direction = oneOf4(input.direction, INVOICE_DIRECTIONS, "an invoice's direction");
|
|
43230
|
-
const currency = currencyOf(input.currency);
|
|
43231
|
-
if (!Array.isArray(input.lines) || input.lines.length === 0 || input.lines.length > MAX_LINES)
|
|
43232
|
-
refuse(`an invoice has 1\u2013${MAX_LINES} lines`, "finance.lines");
|
|
43233
|
-
const lines = input.lines.map((line, at) => {
|
|
43234
|
-
const what = `line ${at + 1}`;
|
|
43235
|
-
const quantity = quantityOf(line.quantity ?? "1");
|
|
43236
|
-
const unitPrice = line.unitPrice === void 0 ? null : minorUnits(line.unitPrice, currency, `${what}'s unit price`);
|
|
43237
|
-
const computed = unitPrice === null ? null : lineUnits(quantity.thousandths, unitPrice);
|
|
43238
|
-
const amount = line.amount === void 0 ? computed : minorUnits(line.amount, currency, `${what}'s amount`);
|
|
43239
|
-
if (amount === null)
|
|
43240
|
-
return refuse(`${what} takes a unit price, an amount or both`, "finance.lines");
|
|
43241
|
-
if (computed !== null && computed !== amount)
|
|
43242
|
-
refuse(`${what}: ${quantity.text} \xD7 ${moneyLabel(unitPrice, currency)} is ${moneyLabel(computed, currency)}, not ${moneyLabel(amount, currency)}`, "finance.line-amount");
|
|
43243
|
-
return {
|
|
43244
|
-
description: text3(line.description, `${what}'s description`, 500) ?? refuse(`${what} needs a description`, "finance.lines"),
|
|
43245
|
-
quantity: quantity.text,
|
|
43246
|
-
unitPrice: unitPrice ?? (quantity.thousandths === 1000n ? amount : null),
|
|
43247
|
-
amount
|
|
43248
|
-
};
|
|
43249
|
-
});
|
|
43250
|
-
const total = lines.reduce((sum, line) => sum + line.amount, 0);
|
|
43251
|
-
if (!Number.isSafeInteger(total))
|
|
43252
|
-
refuse("an invoice's total is too large", "finance.total");
|
|
43253
|
-
if (total <= 0)
|
|
43254
|
-
refuse("an invoice totals more than 0", "finance.total");
|
|
43255
|
-
if (input.total !== void 0) {
|
|
43256
|
-
const printed = minorUnits(input.total, currency, "an invoice's total");
|
|
43257
|
-
if (printed !== total)
|
|
43258
|
-
refuse(`the invoice's total ${moneyLabel(printed, currency)} is not the sum of its lines, ${moneyLabel(total, currency)}`, "finance.total");
|
|
43259
|
-
}
|
|
43260
|
-
const number3 = text3(input.number, "an invoice's number", 80);
|
|
43261
|
-
const issueDate = isoDate(input.issueDate, "an invoice's issue date");
|
|
43262
|
-
const dueDate = isoDate(input.dueDate, "an invoice's due date");
|
|
43263
|
-
const id2 = write(database, () => {
|
|
43264
|
-
const issuer = partyThing(input.issuer, "the issuer");
|
|
43265
|
-
const counterparty = partyThing(input.counterparty, "the counterparty") ?? refuse("an invoice names its counterparty, a person: or organization:", "finance.party");
|
|
43266
|
-
const by = written2(input);
|
|
43267
|
-
const at = now2();
|
|
43268
|
-
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);
|
|
43269
|
-
const insert = database.prepare("INSERT INTO invoice_lines (invoice_id, position, description, quantity, unit_price, amount, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
|
43270
|
-
for (const [index2, line] of lines.entries())
|
|
43271
|
-
insert.run(made, index2 + 1, line.description, line.quantity, line.unitPrice, line.amount, at, at);
|
|
43272
|
-
keepEvidence("invoice", made, by);
|
|
43273
|
-
return made;
|
|
43274
|
-
});
|
|
43275
|
-
return invoiceDetail(`invoice:${id2}`);
|
|
43276
|
-
}, "addInvoice"),
|
|
43277
|
-
invoice: /* @__PURE__ */ __name((reference2) => invoiceDetail(reference2), "invoice"),
|
|
43278
|
-
invoices: /* @__PURE__ */ __name((filter = {}) => {
|
|
43279
|
-
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43280
|
-
const counterparty = partyThing(filter.counterparty, "the counterparty");
|
|
43281
|
-
const by = proposedBySql("i.author_type", "i.author_id", filter.proposedBy);
|
|
43282
|
-
const status = filter.status === void 0 ? null : oneOf4(filter.status, INVOICE_STATUSES, "a status");
|
|
43283
|
-
const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
|
|
43284
|
-
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);
|
|
43285
|
-
}, "invoices"),
|
|
43286
|
-
issueInvoice: /* @__PURE__ */ __name((reference2, by) => {
|
|
43287
|
-
ownerOnly(by, "issues an invoice");
|
|
43288
|
-
const row2 = rowOf2(reference2, "invoice");
|
|
43289
|
-
if (row2.status !== "draft")
|
|
43290
|
-
refuse(`invoice:${row2.id} is ${String(row2.status)}, not a draft`, "finance.status");
|
|
43291
|
-
write(database, () => {
|
|
43292
|
-
database.prepare("UPDATE invoices SET status = 'issued', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
|
|
43293
|
-
settle(Number(row2.id));
|
|
43294
|
-
});
|
|
43295
|
-
return invoiceDetail(`invoice:${row2.id}`);
|
|
43296
|
-
}, "issueInvoice"),
|
|
43297
|
-
voidInvoice: /* @__PURE__ */ __name((reference2, by) => {
|
|
43298
|
-
ownerOnly(by, "voids an invoice");
|
|
43299
|
-
const row2 = rowOf2(reference2, "invoice");
|
|
43300
|
-
if (row2.status === "void")
|
|
43301
|
-
refuse(`invoice:${row2.id} is already void`, "finance.status");
|
|
43302
|
-
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));
|
|
43303
|
-
if (allocated)
|
|
43304
|
-
refuse(`payments are allocated to invoice:${row2.id}; a paid invoice is not voided`, "finance.status");
|
|
43305
|
-
write(database, () => {
|
|
43306
|
-
database.prepare("DELETE FROM payment_allocations WHERE invoice_id = ? AND payment_id IN (SELECT id FROM payments WHERE review = 'proposed')").run(Number(row2.id));
|
|
43307
|
-
database.prepare("UPDATE invoices SET status = 'void', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
|
|
43308
|
-
});
|
|
43309
|
-
return invoiceDetail(`invoice:${row2.id}`);
|
|
43310
|
-
}, "voidInvoice"),
|
|
43311
|
-
addPayment: /* @__PURE__ */ __name((input) => {
|
|
43312
|
-
const direction = oneOf4(input.direction, MONEY_DIRECTIONS, "a payment's direction");
|
|
43313
|
-
const currency = currencyOf(input.currency);
|
|
43314
|
-
const amount = minorUnits(input.amount, currency, "a payment's amount");
|
|
43315
|
-
if (amount <= 0)
|
|
43316
|
-
refuse("a payment's amount is more than 0", "money.amount");
|
|
43317
|
-
const date3 = isoDate(input.date, "a payment's date") ?? refuse("a payment has a date", "finance.field");
|
|
43318
|
-
const reference2 = text3(input.reference, "a payment's reference", 500);
|
|
43319
|
-
const allocations = (input.allocations ?? []).map(({ invoice, amount: share }) => ({
|
|
43320
|
-
invoice,
|
|
43321
|
-
units: minorUnits(share, currency, `the amount allocated to ${invoice}`)
|
|
43322
|
-
}));
|
|
43323
|
-
const id2 = write(database, () => {
|
|
43324
|
-
const payer = partyThing(input.payer, "the payer");
|
|
43325
|
-
const payee = partyThing(input.payee, "the payee");
|
|
43326
|
-
const by = written2(input);
|
|
43327
|
-
const at = now2();
|
|
43328
|
-
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);
|
|
43329
|
-
keepEvidence("payment", Number(made.id), by);
|
|
43330
|
-
const touched = allocations.map(({ invoice, units }) => allocateRow(made, invoice, units, by.actor));
|
|
43331
|
-
for (const invoice of touched)
|
|
43332
|
-
settle(invoice);
|
|
43333
|
-
return Number(made.id);
|
|
43334
|
-
});
|
|
43335
|
-
return paymentDetail(`payment:${id2}`);
|
|
43336
|
-
}, "addPayment"),
|
|
43337
|
-
payment: /* @__PURE__ */ __name((reference2) => paymentDetail(reference2), "payment"),
|
|
43338
|
-
payments: /* @__PURE__ */ __name((filter = {}) => {
|
|
43339
|
-
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43340
|
-
const party2 = partyThing(filter.party, "the party");
|
|
43341
|
-
const by = proposedBySql("p.author_type", "p.author_id", filter.proposedBy);
|
|
43342
|
-
const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
|
|
43343
|
-
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);
|
|
43344
|
-
}, "payments"),
|
|
43345
|
-
allocate: /* @__PURE__ */ __name(({ payment, invoice, amount, by }) => {
|
|
43346
|
-
const row2 = rowOf2(payment, "payment");
|
|
43347
|
-
const ref3 = `payment:${row2.id}`;
|
|
43348
|
-
mayAllocate(row2, by);
|
|
43349
|
-
if (row2.review === "rejected" || row2.deleted_at != null)
|
|
43350
|
-
refuse(`${ref3} is ${String(row2.review)}`, "finance.allocate");
|
|
43351
|
-
const currency = String(row2.currency);
|
|
43352
|
-
const units = minorUnits(amount, currency, "an allocation");
|
|
43353
|
-
if (units <= 0)
|
|
43354
|
-
refuse("an allocation is more than 0", "money.amount");
|
|
43355
|
-
const invoiceId = write(database, () => {
|
|
43356
|
-
const { actor } = authorActor(context, by);
|
|
43357
|
-
const made = allocateRow(row2, invoice, units, actor);
|
|
43358
|
-
settle(made);
|
|
43359
|
-
return made;
|
|
43360
|
-
});
|
|
43361
|
-
const found2 = allocationsWhere("payment_id", Number(row2.id)).find((one2) => one2.invoice === `invoice:${invoiceId}`);
|
|
43362
|
-
return found2;
|
|
43363
|
-
}, "allocate"),
|
|
43364
|
-
unallocate: /* @__PURE__ */ __name(({ payment, invoice, by }) => {
|
|
43365
|
-
const row2 = rowOf2(payment, "payment");
|
|
43366
|
-
const ref3 = `payment:${row2.id}`;
|
|
43367
|
-
mayAllocate(row2, by);
|
|
43368
|
-
if (row2.review === "rejected" || row2.deleted_at != null)
|
|
43369
|
-
refuse(`${ref3} is ${row2.deleted_at != null ? "deleted" : "rejected"}; only a proposed or confirmed payment's allocations are taken back`, "finance.unallocate");
|
|
43370
|
-
const target = rowOf2(invoice, "invoice");
|
|
43371
|
-
write(database, () => {
|
|
43372
|
-
const gone = database.prepare("DELETE FROM payment_allocations WHERE payment_id = ? AND invoice_id = ?").run(Number(row2.id), Number(target.id));
|
|
43373
|
-
if (gone.changes === 0)
|
|
43374
|
-
throw new CliError("not_found", `${ref3} is not allocated to invoice:${target.id}`, {
|
|
43375
|
-
reason: "finance.not-allocated"
|
|
43376
|
-
});
|
|
43377
|
-
settle(Number(target.id));
|
|
43378
|
-
});
|
|
43379
|
-
return paymentDetail(ref3);
|
|
43380
|
-
}, "unallocate"),
|
|
43381
|
-
confirm: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, true), "confirm"),
|
|
43382
|
-
reject: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, false), "reject"),
|
|
43383
|
-
openTotals: /* @__PURE__ */ __name((filter = {}) => {
|
|
43384
|
-
const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
|
|
43385
|
-
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);
|
|
43386
|
-
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");
|
|
43387
|
-
return { receivable: totals("receivable"), payable: totals("payable") };
|
|
43388
|
-
}, "openTotals")
|
|
43389
|
-
};
|
|
43390
|
-
}, "financeOperationsOver");
|
|
43391
|
-
var financeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
43392
|
-
const operations = financeOperationsOver(context);
|
|
43393
|
-
return {
|
|
43394
|
-
addInvoice: /* @__PURE__ */ __name(async (input) => operations.addInvoice(input), "addInvoice"),
|
|
43395
|
-
invoice: /* @__PURE__ */ __name(async (reference2) => operations.invoice(reference2), "invoice"),
|
|
43396
|
-
invoices: /* @__PURE__ */ __name(async (filter) => operations.invoices(filter), "invoices"),
|
|
43397
|
-
issueInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.issueInvoice(reference2, by), "issueInvoice"),
|
|
43398
|
-
voidInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.voidInvoice(reference2, by), "voidInvoice"),
|
|
43399
|
-
addPayment: /* @__PURE__ */ __name(async (input) => operations.addPayment(input), "addPayment"),
|
|
43400
|
-
payment: /* @__PURE__ */ __name(async (reference2) => operations.payment(reference2), "payment"),
|
|
43401
|
-
payments: /* @__PURE__ */ __name(async (filter) => operations.payments(filter), "payments"),
|
|
43402
|
-
allocate: /* @__PURE__ */ __name(async (input) => operations.allocate(input), "allocate"),
|
|
43403
|
-
unallocate: /* @__PURE__ */ __name(async (input) => operations.unallocate(input), "unallocate"),
|
|
43404
|
-
confirm: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.confirm(reference2, by, reason), "confirm"),
|
|
43405
|
-
reject: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.reject(reference2, by, reason), "reject"),
|
|
43406
|
-
openTotals: /* @__PURE__ */ __name(async (filter) => operations.openTotals(filter), "openTotals")
|
|
43407
|
-
};
|
|
43408
|
-
}, "financeStoreOver");
|
|
43409
|
-
|
|
43410
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/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
|
|
43411
43855
|
var refuse2 = /* @__PURE__ */ __name((message2, reason) => {
|
|
43412
43856
|
throw new CliError("validation_error", message2, { reason });
|
|
43413
43857
|
}, "refuse");
|
|
@@ -43485,7 +43929,7 @@ var paymentEntriesOver = /* @__PURE__ */ __name((context) => {
|
|
|
43485
43929
|
};
|
|
43486
43930
|
}, "paymentEntriesOver");
|
|
43487
43931
|
|
|
43488
|
-
// 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
|
|
43489
43933
|
var EVIDENCE_FINDINGS_KIND = "evidence_findings";
|
|
43490
43934
|
var reference = /* @__PURE__ */ __name((raw) => {
|
|
43491
43935
|
if (/^(document|note):[1-9]\d*$/.test(raw))
|
|
@@ -43511,7 +43955,7 @@ var validateEvidenceFindings = /* @__PURE__ */ __name((input) => {
|
|
|
43511
43955
|
return valid;
|
|
43512
43956
|
}, "validateEvidenceFindings");
|
|
43513
43957
|
|
|
43514
|
-
// 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
|
|
43515
43959
|
var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false } = {}) => {
|
|
43516
43960
|
try {
|
|
43517
43961
|
return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
|
|
@@ -43523,9 +43967,9 @@ var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false
|
|
|
43523
43967
|
}
|
|
43524
43968
|
}, "calendarMoment");
|
|
43525
43969
|
|
|
43526
|
-
// 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
|
|
43527
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";
|
|
43528
|
-
var
|
|
43972
|
+
var iso10 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
43529
43973
|
var oneOf5 = /* @__PURE__ */ __name((value, allowed, what) => {
|
|
43530
43974
|
if (typeof value !== "string" || !allowed.includes(value))
|
|
43531
43975
|
throw new CliError("validation_error", `${what} is one of ${allowed.join(", ")}`);
|
|
@@ -43541,7 +43985,7 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43541
43985
|
status: row2.status,
|
|
43542
43986
|
...projectOf(database, row2),
|
|
43543
43987
|
...subjectOf(database, row2),
|
|
43544
|
-
occurredAt: row2.occurred_at == null ? null :
|
|
43988
|
+
occurredAt: row2.occurred_at == null ? null : iso10(row2.occurred_at),
|
|
43545
43989
|
supersedes: row2.supersedes_id == null ? null : `fact:${row2.supersedes_id}`,
|
|
43546
43990
|
author: authorOf(row2),
|
|
43547
43991
|
model: row2.model == null ? null : String(row2.model),
|
|
@@ -43549,8 +43993,8 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43549
43993
|
scope: row2.scope == null ? null : row2.scope,
|
|
43550
43994
|
source: String(row2.source),
|
|
43551
43995
|
evidence: evidenceOf(context, { type: "fact", id: Number(row2.id) }),
|
|
43552
|
-
createdAt:
|
|
43553
|
-
updatedAt:
|
|
43996
|
+
createdAt: iso10(row2.created_at),
|
|
43997
|
+
updatedAt: iso10(row2.updated_at)
|
|
43554
43998
|
}), "factOf");
|
|
43555
43999
|
const rowOf2 = /* @__PURE__ */ __name((reference2) => {
|
|
43556
44000
|
const thing = requiredThing(database, reference2.includes(":") ? reference2 : `fact:${reference2}`, "the fact");
|
|
@@ -43666,7 +44110,7 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43666
44110
|
const step = {
|
|
43667
44111
|
step: "revoked",
|
|
43668
44112
|
by: "owner",
|
|
43669
|
-
at:
|
|
44113
|
+
at: iso10(at),
|
|
43670
44114
|
confirmedBy: { type: current.confirmed_by_type, id: String(current.confirmed_by_id) },
|
|
43671
44115
|
...decision === void 0 ? {} : { decision },
|
|
43672
44116
|
...reason?.trim() ? { reason: reason.trim() } : {}
|
|
@@ -43732,7 +44176,7 @@ var factsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
43732
44176
|
};
|
|
43733
44177
|
}, "factsStoreOver");
|
|
43734
44178
|
|
|
43735
|
-
// 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
|
|
43736
44180
|
var invalid4 = /* @__PURE__ */ __name((message2) => {
|
|
43737
44181
|
throw new CliError("validation_error", message2);
|
|
43738
44182
|
}, "invalid");
|
|
@@ -43836,10 +44280,10 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind4) => {
|
|
|
43836
44280
|
return { snapshot: snapshot2, snapshotParts, previous, outcomes, create };
|
|
43837
44281
|
}, "findingsCoreOver");
|
|
43838
44282
|
|
|
43839
|
-
// 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
|
|
43840
44284
|
var PROPOSAL_STATUSES = ["proposed", "approved", "rejected", "executed", "failed"];
|
|
43841
44285
|
var PROPOSAL_VERDICTS = ["useful", "not_useful"];
|
|
43842
|
-
var
|
|
44286
|
+
var iso11 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
|
|
43843
44287
|
var json2 = /* @__PURE__ */ __name((value) => value == null ? null : JSON.parse(String(value)), "json");
|
|
43844
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`;
|
|
43845
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`;
|
|
@@ -43870,12 +44314,12 @@ var proposalOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
|
43870
44314
|
kind: row2.proposed_by_type !== "bot" ? null : row2.proposer_kind === "rule" || row2.proposer_name === "rule" ? "rule" : "agent"
|
|
43871
44315
|
},
|
|
43872
44316
|
decidedBy: row2.decided_by_type == null ? null : { type: row2.decided_by_type, id: String(row2.decided_by_id) },
|
|
43873
|
-
decidedAt:
|
|
43874
|
-
executedAt:
|
|
44317
|
+
decidedAt: iso11(row2.decided_at),
|
|
44318
|
+
executedAt: iso11(row2.executed_at),
|
|
43875
44319
|
result: json2(row2.result),
|
|
43876
44320
|
error: row2.error == null ? null : String(row2.error),
|
|
43877
44321
|
verdict: row2.verdict ?? null,
|
|
43878
|
-
createdAt:
|
|
44322
|
+
createdAt: iso11(row2.created_at)
|
|
43879
44323
|
};
|
|
43880
44324
|
}, "actionOf");
|
|
43881
44325
|
const rowOf2 = /* @__PURE__ */ __name((id2) => {
|
|
@@ -44001,7 +44445,7 @@ var proposedActionsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
44001
44445
|
};
|
|
44002
44446
|
}, "proposedActionsStoreOver");
|
|
44003
44447
|
|
|
44004
|
-
// 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
|
|
44005
44449
|
var stale = /* @__PURE__ */ __name(() => {
|
|
44006
44450
|
throw new CliError("validation_error", "evidence findings changed since they were read; stage a new batch", {
|
|
44007
44451
|
reason: "evidence-findings.stale"
|
|
@@ -44182,7 +44626,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
44182
44626
|
};
|
|
44183
44627
|
}, "evidenceFindingsStoreOver");
|
|
44184
44628
|
|
|
44185
|
-
// 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
|
|
44186
44630
|
var pendingInvolvements = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM involvement_pending").get()?.n ?? 0), "pendingInvolvements");
|
|
44187
44631
|
var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => ({
|
|
44188
44632
|
rebuild: /* @__PURE__ */ __name((personId) => write(database, () => {
|
|
@@ -44235,7 +44679,7 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
|
|
|
44235
44679
|
}, "forPerson")
|
|
44236
44680
|
}), "involvementStoreOver");
|
|
44237
44681
|
|
|
44238
|
-
// 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
|
|
44239
44683
|
import { createHash as createHash12 } from "node:crypto";
|
|
44240
44684
|
var fields3 = "id,from_id,to_id,source,confirmed,updated_at,length(evidence) AS evidenceLength,substr(evidence,1,2000) AS evidence";
|
|
44241
44685
|
var id = /* @__PURE__ */ __name((value) => {
|
|
@@ -44321,7 +44765,7 @@ var meetingProjectsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 })
|
|
|
44321
44765
|
};
|
|
44322
44766
|
}, "meetingProjectsStoreOver");
|
|
44323
44767
|
|
|
44324
|
-
// 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
|
|
44325
44769
|
var ORGANIZATIONS_QUERY = {
|
|
44326
44770
|
entity: "organization",
|
|
44327
44771
|
backend: "sql",
|
|
@@ -44362,7 +44806,7 @@ var REMINDERS_QUERY = {
|
|
|
44362
44806
|
})
|
|
44363
44807
|
};
|
|
44364
44808
|
|
|
44365
|
-
// 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
|
|
44366
44810
|
var organizationOf = /* @__PURE__ */ __name((row2) => ({
|
|
44367
44811
|
id: String(row2.id),
|
|
44368
44812
|
ref: `organization:${row2.id}`,
|
|
@@ -44395,7 +44839,7 @@ var organizationsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) =>
|
|
|
44395
44839
|
}), "updateOrganization")
|
|
44396
44840
|
}), "organizationsStoreOver");
|
|
44397
44841
|
|
|
44398
|
-
// 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
|
|
44399
44843
|
var relationOf = /* @__PURE__ */ __name((link3) => ({
|
|
44400
44844
|
id: link3.id,
|
|
44401
44845
|
from: link3.from,
|
|
@@ -44621,16 +45065,16 @@ var decidedOrigin = /* @__PURE__ */ __name((by) => by === "owner" ? { origin: "o
|
|
|
44621
45065
|
provenance: `agent:${by.bot} for the owner: ${by.reason.trim()}`
|
|
44622
45066
|
}, "decidedOrigin");
|
|
44623
45067
|
|
|
44624
|
-
// 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
|
|
44625
45069
|
import { createHash as createHash15 } from "node:crypto";
|
|
44626
45070
|
|
|
44627
|
-
// 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
|
|
44628
45072
|
import { createHash as createHash14 } from "node:crypto";
|
|
44629
45073
|
|
|
44630
|
-
// 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
|
|
44631
45075
|
import { createHash as createHash13 } from "node:crypto";
|
|
44632
45076
|
|
|
44633
|
-
// 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
|
|
44634
45078
|
var consolidationId = /* @__PURE__ */ __name((value, field4) => {
|
|
44635
45079
|
if (typeof value !== "string" || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
|
|
44636
45080
|
throw new CliError("validation_error", `${field4} must be a positive canonical tag id`);
|
|
@@ -44681,7 +45125,7 @@ var consolidationApplyInput = /* @__PURE__ */ __name((options) => {
|
|
|
44681
45125
|
return input;
|
|
44682
45126
|
}, "consolidationApplyInput");
|
|
44683
45127
|
|
|
44684
|
-
// 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
|
|
44685
45129
|
var receiptOf = /* @__PURE__ */ __name((row2) => ({
|
|
44686
45130
|
id: String(row2.id),
|
|
44687
45131
|
sourceId: String(row2.source_id),
|
|
@@ -44756,7 +45200,7 @@ var applyTagConsolidation = /* @__PURE__ */ __name((context, preview, options) =
|
|
|
44756
45200
|
}, { beforeCommit: check3 });
|
|
44757
45201
|
}, "applyTagConsolidation");
|
|
44758
45202
|
|
|
44759
|
-
// 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
|
|
44760
45204
|
var selections = [
|
|
44761
45205
|
["taggings", "tag_id IN (SELECT value FROM json_each(?))"],
|
|
44762
45206
|
["aliases", "aliasable_type='tag' AND aliasable_id IN (SELECT value FROM json_each(?))"],
|
|
@@ -44900,7 +45344,7 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
|
|
|
44900
45344
|
};
|
|
44901
45345
|
}, "previewRows");
|
|
44902
45346
|
|
|
44903
|
-
// 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
|
|
44904
45348
|
var kinds = ["project", "tag", "topic"];
|
|
44905
45349
|
var cancelled2 = /* @__PURE__ */ __name((signal) => {
|
|
44906
45350
|
if (signal?.aborted)
|
|
@@ -45164,13 +45608,13 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45164
45608
|
};
|
|
45165
45609
|
}, "vocabularyStoreOver");
|
|
45166
45610
|
|
|
45167
|
-
// 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
|
|
45168
45612
|
var TYPED_KEY_PREFIXES = new Set(Object.values(TASK_KEY_PREFIXES));
|
|
45169
45613
|
var ORGANIZATION_KINDS = ["company", "team", "family", "community"];
|
|
45170
45614
|
var PROJECT_TYPES = ["work", "client", "personal", "oss", "other"];
|
|
45171
45615
|
var SCOPES = ["personal", "work"];
|
|
45172
45616
|
var UNVERIFIED = { type: "unknown" };
|
|
45173
|
-
var
|
|
45617
|
+
var iso12 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
45174
45618
|
var bounded2 = /* @__PURE__ */ __name((limit = 100, offset = 0) => {
|
|
45175
45619
|
if (!Number.isInteger(limit) || limit < 1 || limit > 500 || !Number.isInteger(offset) || offset < 0 || offset > 1e5)
|
|
45176
45620
|
throw new CliError("validation_error", "limit takes 1\u2013500 and offset takes 0\u2013100000");
|
|
@@ -45272,7 +45716,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45272
45716
|
return { type: "chat", id: parsed3.chat };
|
|
45273
45717
|
if (parsed3.type === "folder")
|
|
45274
45718
|
return { type: "folder", id: parsed3.id, path: parsed3.path };
|
|
45275
|
-
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")
|
|
45276
45720
|
return void 0;
|
|
45277
45721
|
return { type: parsed3.type, id: parsed3.id };
|
|
45278
45722
|
}, "targetOfThing");
|
|
@@ -45303,8 +45747,8 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45303
45747
|
text: String(row2.body),
|
|
45304
45748
|
revision: Number(row2.revision),
|
|
45305
45749
|
authoredBy: "owner",
|
|
45306
|
-
createdAt:
|
|
45307
|
-
updatedAt:
|
|
45750
|
+
createdAt: iso12(row2.created_at),
|
|
45751
|
+
updatedAt: iso12(row2.updated_at)
|
|
45308
45752
|
};
|
|
45309
45753
|
}, "annotationOf");
|
|
45310
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");
|
|
@@ -45325,7 +45769,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45325
45769
|
type: row2.type,
|
|
45326
45770
|
organizationId: row2.organization_id == null ? null : String(row2.organization_id),
|
|
45327
45771
|
scope: row2.scope,
|
|
45328
|
-
createdAt:
|
|
45772
|
+
createdAt: iso12(row2.created_at)
|
|
45329
45773
|
}), "projectOf");
|
|
45330
45774
|
const proposals = relationProposalsOver(context);
|
|
45331
45775
|
const RELATIONS = `SELECT * FROM links WHERE kind IN (${RELATION_KINDS.map(linkKind).join(",")}) AND to_id IS NOT NULL`;
|
|
@@ -45361,7 +45805,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
45361
45805
|
const reminderOf = /* @__PURE__ */ __name((row2) => ({
|
|
45362
45806
|
id: String(row2.id),
|
|
45363
45807
|
task: taskIdOf(database, Number(row2.task_id)) ?? String(row2.task_id),
|
|
45364
|
-
dueAt:
|
|
45808
|
+
dueAt: iso12(row2.due_at),
|
|
45365
45809
|
timezone: String(row2.timezone),
|
|
45366
45810
|
state: row2.state,
|
|
45367
45811
|
revision: Number(row2.revision),
|
|
@@ -45705,7 +46149,7 @@ var projectKey = /* @__PURE__ */ __name((name) => {
|
|
|
45705
46149
|
return key2.padEnd(3, "X");
|
|
45706
46150
|
}, "projectKey");
|
|
45707
46151
|
|
|
45708
|
-
// 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
|
|
45709
46153
|
var DAY5 = 864e5;
|
|
45710
46154
|
var SETTING4 = "logs_pruned_at";
|
|
45711
46155
|
var LOG_RETENTION = { agentActionsMs: 90 * DAY5, botUpdatePayloadsMs: 30 * DAY5 };
|
|
@@ -45732,7 +46176,7 @@ var logPruner = /* @__PURE__ */ __name((database, now2) => {
|
|
|
45732
46176
|
};
|
|
45733
46177
|
}, "logPruner");
|
|
45734
46178
|
|
|
45735
|
-
// 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
|
|
45736
46180
|
var MAIL_FINDINGS_PER_RUN = 30;
|
|
45737
46181
|
var MAIL_FINDINGS_PER_SENDER = 5;
|
|
45738
46182
|
var invalid6 = /* @__PURE__ */ __name((message2) => {
|
|
@@ -46108,7 +46552,7 @@ var checkMailFindings = /* @__PURE__ */ __name((input) => {
|
|
|
46108
46552
|
}, "checkMailFindings");
|
|
46109
46553
|
var mailFindingFingerprint = /* @__PURE__ */ __name(({ id: _id, ...finding }) => findingHash(finding), "mailFindingFingerprint");
|
|
46110
46554
|
|
|
46111
|
-
// 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
|
|
46112
46556
|
var import_disposable_email_domains_js = __toESM(require_dist(), 1);
|
|
46113
46557
|
var import_tldts = __toESM(require_cjs(), 1);
|
|
46114
46558
|
var WEIGHTS = {
|
|
@@ -46241,7 +46685,7 @@ var scoreGroup = /* @__PURE__ */ __name((items, context) => {
|
|
|
46241
46685
|
return { score: kept.reduce((sum, signal) => sum + WEIGHTS[signal], 0), signals: kept };
|
|
46242
46686
|
}, "scoreGroup");
|
|
46243
46687
|
|
|
46244
|
-
// 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
|
|
46245
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";
|
|
46246
46690
|
var orderOperationsOver = /* @__PURE__ */ __name((context) => {
|
|
46247
46691
|
const { database, now: now2 } = context;
|
|
@@ -46393,7 +46837,7 @@ var ordersStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
46393
46837
|
};
|
|
46394
46838
|
}, "ordersStoreOver");
|
|
46395
46839
|
|
|
46396
|
-
// 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
|
|
46397
46841
|
var stale2 = /* @__PURE__ */ __name(() => {
|
|
46398
46842
|
throw new CliError("validation_error", "mail findings cite mail that changed since it was read; stage a new batch", {
|
|
46399
46843
|
reason: "mail-findings.stale"
|
|
@@ -46434,7 +46878,7 @@ var mailFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
46434
46878
|
return invalid7("stored findings exceed the read budget");
|
|
46435
46879
|
return proposals.get(id2);
|
|
46436
46880
|
}, "load");
|
|
46437
|
-
const
|
|
46881
|
+
const accountOf4 = /* @__PURE__ */ __name((proposal) => mailbox2(proposal.account), "accountOf");
|
|
46438
46882
|
const view = /* @__PURE__ */ __name((proposal) => {
|
|
46439
46883
|
const input = proposal.payload;
|
|
46440
46884
|
if (!input || !proposal.account || !["proposed", "approved", "rejected"].includes(proposal.status))
|
|
@@ -46449,7 +46893,7 @@ var mailFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
46449
46893
|
decidedBy: proposal.decidedBy,
|
|
46450
46894
|
decidedAt: proposal.decidedAt,
|
|
46451
46895
|
previous: proposal.result ? proposal.result.items : input.findings.flatMap((finding) => {
|
|
46452
|
-
const held = core.previous(
|
|
46896
|
+
const held = core.previous(accountOf4(proposal), mailFindingFingerprint(finding));
|
|
46453
46897
|
return held ? [{ ...held, id: finding.id, reused: true }] : [];
|
|
46454
46898
|
}),
|
|
46455
46899
|
receipt: proposal.result
|
|
@@ -46818,7 +47262,7 @@ ${evidence.join("\n")}`, agent);
|
|
|
46818
47262
|
return batch;
|
|
46819
47263
|
}
|
|
46820
47264
|
const input = proposal.payload;
|
|
46821
|
-
const account =
|
|
47265
|
+
const account = accountOf4(proposal);
|
|
46822
47266
|
const chosen = batch.input.findings.filter((finding) => accepted.includes(finding.id));
|
|
46823
47267
|
if (chosen.length)
|
|
46824
47268
|
cite(chosen, account, true);
|
|
@@ -46850,7 +47294,7 @@ ${evidence.join("\n")}`, agent);
|
|
|
46850
47294
|
};
|
|
46851
47295
|
}, "mailFindingsStoreOver");
|
|
46852
47296
|
|
|
46853
|
-
// 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
|
|
46854
47298
|
var stale3 = /* @__PURE__ */ __name(() => {
|
|
46855
47299
|
throw new CliError("validation_error", "meeting findings changed since they were read; stage a new batch", {
|
|
46856
47300
|
reason: "meeting-findings.stale"
|
|
@@ -47018,7 +47462,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
47018
47462
|
};
|
|
47019
47463
|
}, "meetingFindingsStoreOver");
|
|
47020
47464
|
|
|
47021
|
-
// 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
|
|
47022
47466
|
var RANK_BATCH = 512;
|
|
47023
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";
|
|
47024
47468
|
var limitOf = /* @__PURE__ */ __name((value, name, max = 1e3) => {
|
|
@@ -47289,7 +47733,7 @@ var meetingVectorsOver = /* @__PURE__ */ __name((context) => ({
|
|
|
47289
47733
|
}
|
|
47290
47734
|
}), "meetingVectorsOver");
|
|
47291
47735
|
|
|
47292
|
-
// 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
|
|
47293
47737
|
var OTHER_SOURCES = ["document", "note", "email"];
|
|
47294
47738
|
var TEXTS = {
|
|
47295
47739
|
document: "JOIN documents s ON mn.source_type = 'document' AND s.id = mn.source_id AND s.deleted_at IS NULL WHERE 1 ",
|
|
@@ -47390,11 +47834,11 @@ var sourceMentionStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
47390
47834
|
};
|
|
47391
47835
|
}, "sourceMentionStoreOver");
|
|
47392
47836
|
|
|
47393
|
-
// 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
|
|
47394
47838
|
import { mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
47395
47839
|
import { dirname } from "node:path";
|
|
47396
47840
|
|
|
47397
|
-
// 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
|
|
47398
47842
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
47399
47843
|
var CLIENTS_SETTING = "clients";
|
|
47400
47844
|
var coreVersion = (() => {
|
|
@@ -47452,7 +47896,7 @@ var refusalAdvice = /* @__PURE__ */ __name((clients, command, schema) => {
|
|
|
47452
47896
|
return mover ? `${own} (${mover.command} ${mover.version} moved the store to schema ${schema})` : own;
|
|
47453
47897
|
}, "refusalAdvice");
|
|
47454
47898
|
|
|
47455
|
-
// 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
|
|
47456
47900
|
var GENERATED = [
|
|
47457
47901
|
{
|
|
47458
47902
|
"name": "20261010184427_initial",
|
|
@@ -48452,10 +48896,59 @@ WHERE json_type(params, '$.selection') = 'object';`
|
|
|
48452
48896
|
"ALTER TABLE `tasks` ADD `source_url` text;",
|
|
48453
48897
|
"CREATE INDEX `tasks_by_provider_external_id` ON `tasks` (`provider`,`external_id`) WHERE external_id IS NOT NULL;"
|
|
48454
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
|
+
]
|
|
48455
48948
|
}
|
|
48456
48949
|
];
|
|
48457
48950
|
|
|
48458
|
-
// 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
|
|
48459
48952
|
var MANIFEST = [
|
|
48460
48953
|
{ name: "20261010184427_initial", version: 1, minCompatible: 1 },
|
|
48461
48954
|
{ name: "20261011035353_version-2-facts", version: 2, minCompatible: 1 },
|
|
@@ -48523,7 +49016,9 @@ var MANIFEST = [
|
|
|
48523
49016
|
{ name: "20261104232153_version-49-relation-amounts", version: 49, minCompatible: 34 },
|
|
48524
49017
|
{ name: "20261105125314_version-50-orders", version: 50, minCompatible: 34 },
|
|
48525
49018
|
{ name: "20261105125315_version-50-orders-rules", version: 50, minCompatible: 34 },
|
|
48526
|
-
{ 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 }
|
|
48527
49022
|
];
|
|
48528
49023
|
var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated = GENERATED) => {
|
|
48529
49024
|
const migrations = [];
|
|
@@ -48547,7 +49042,7 @@ var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated
|
|
|
48547
49042
|
return migrations;
|
|
48548
49043
|
}, "generatedMigrations");
|
|
48549
49044
|
|
|
48550
|
-
// 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
|
|
48551
49046
|
var MIGRATIONS = generatedMigrations();
|
|
48552
49047
|
var HISTORY = `CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
48553
49048
|
version INTEGER PRIMARY KEY,
|
|
@@ -48600,7 +49095,7 @@ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now:
|
|
|
48600
49095
|
}
|
|
48601
49096
|
}, "migrate");
|
|
48602
49097
|
|
|
48603
|
-
// 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
|
|
48604
49099
|
var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
|
|
48605
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 ?");
|
|
48606
49101
|
if (pending.get(0, 1) === void 0)
|
|
@@ -48622,7 +49117,7 @@ var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
|
|
|
48622
49117
|
}
|
|
48623
49118
|
}, "fillJoinKeys");
|
|
48624
49119
|
|
|
48625
|
-
// 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
|
|
48626
49121
|
var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
|
|
48627
49122
|
refuseOwnerStoreInTests(path);
|
|
48628
49123
|
const opened = "Bun" in globalThis ? await openUnderBun(path, readOnly) : await openUnderNode(path, readOnly);
|
|
@@ -48636,8 +49131,8 @@ var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {})
|
|
|
48636
49131
|
}, "openSqlite");
|
|
48637
49132
|
var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
48638
49133
|
quietSqliteWarning();
|
|
48639
|
-
const { drizzle } = await import("./node-
|
|
48640
|
-
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");
|
|
48641
49136
|
const client = await nodeClient(path, { readOnly });
|
|
48642
49137
|
try {
|
|
48643
49138
|
return { database: cacheOverNodeSqlite(client), orm: drizzle({ client }) };
|
|
@@ -48647,8 +49142,8 @@ var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
|
48647
49142
|
}
|
|
48648
49143
|
}, "openUnderNode");
|
|
48649
49144
|
var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
48650
|
-
const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-
|
|
48651
|
-
const { drizzle } = await import("./bun-
|
|
49145
|
+
const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-INSVTXFN.js");
|
|
49146
|
+
const { drizzle } = await import("./bun-4NGTZRHL.js");
|
|
48652
49147
|
const client = await bunClient(path, readOnly ? { readonly: true, create: false } : void 0);
|
|
48653
49148
|
try {
|
|
48654
49149
|
return { database: cacheOverBunSqlite(client), orm: drizzle({ client }) };
|
|
@@ -48658,7 +49153,7 @@ var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
|
|
|
48658
49153
|
}
|
|
48659
49154
|
}, "openUnderBun");
|
|
48660
49155
|
|
|
48661
|
-
// 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
|
|
48662
49157
|
var PAYMENT_FACTS_TO_MOVE = "payment_facts_to_move";
|
|
48663
49158
|
var paymentOf = /* @__PURE__ */ __name((metadata3) => {
|
|
48664
49159
|
try {
|
|
@@ -48726,7 +49221,7 @@ var movePaymentFacts = /* @__PURE__ */ __name((context) => {
|
|
|
48726
49221
|
});
|
|
48727
49222
|
}, "movePaymentFacts");
|
|
48728
49223
|
|
|
48729
|
-
// 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
|
|
48730
49225
|
var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
|
|
48731
49226
|
const ours = MIGRATIONS.at(-1)?.version ?? 0;
|
|
48732
49227
|
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='schema_migrations'").get())
|
|
@@ -48741,7 +49236,7 @@ var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
|
|
|
48741
49236
|
throw new CliError("configuration_error", `The store requires schema ${minCompatible}, but this tool supports ${ours}; ${refusalAdvice(storeClients(database), command, version)}`);
|
|
48742
49237
|
}, "assertReadCompatible");
|
|
48743
49238
|
|
|
48744
|
-
// 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
|
|
48745
49240
|
var SUGGESTED_LINKS_TO_MOVE = "suggested_links_to_move";
|
|
48746
49241
|
var proposerOf2 = /* @__PURE__ */ __name((provenance2) => {
|
|
48747
49242
|
if (provenance2?.startsWith("rule:"))
|
|
@@ -48787,7 +49282,7 @@ var moveSuggestedLinks = /* @__PURE__ */ __name((database, now2) => {
|
|
|
48787
49282
|
});
|
|
48788
49283
|
}, "moveSuggestedLinks");
|
|
48789
49284
|
|
|
48790
|
-
// 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
|
|
48791
49286
|
var TEST_ACCOUNTS_TO_PURGE = "test_accounts_to_purge";
|
|
48792
49287
|
var TEST_PROVIDER = "chat";
|
|
48793
49288
|
var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
|
|
@@ -48808,7 +49303,7 @@ var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
|
|
|
48808
49303
|
}
|
|
48809
49304
|
}, "purgeTestAccounts");
|
|
48810
49305
|
|
|
48811
|
-
// 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
|
|
48812
49307
|
var BACKFILL_ON_OPEN = 5e3;
|
|
48813
49308
|
var NOT_WRITABLE = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EROFS"]);
|
|
48814
49309
|
var createWritable = /* @__PURE__ */ __name((file) => {
|
|
@@ -48873,10 +49368,10 @@ var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Da
|
|
|
48873
49368
|
}
|
|
48874
49369
|
}, "openStoreContext");
|
|
48875
49370
|
|
|
48876
|
-
// 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
|
|
48877
49372
|
import { createHash as createHash16 } from "node:crypto";
|
|
48878
49373
|
|
|
48879
|
-
// 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
|
|
48880
49375
|
var text4 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
|
|
48881
49376
|
var ref = text4(2048);
|
|
48882
49377
|
var timestamp2 = pipe(number(), safeInteger(), minValue(0));
|
|
@@ -48942,7 +49437,7 @@ var projectAnnotationsSchema = strictObject({
|
|
|
48942
49437
|
}))
|
|
48943
49438
|
});
|
|
48944
49439
|
|
|
48945
|
-
// 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
|
|
48946
49441
|
var PROJECT_ANNOTATIONS_MAX_BYTES = 4 * 1024 * 1024;
|
|
48947
49442
|
var invalid9 = /* @__PURE__ */ __name((field4) => {
|
|
48948
49443
|
throw new CliError("validation_error", `invalid project annotations.${field4}`);
|
|
@@ -49046,7 +49541,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
|
|
|
49046
49541
|
invalid9("external.unused");
|
|
49047
49542
|
}, "validateProjectAnnotationsGraph");
|
|
49048
49543
|
|
|
49049
|
-
// 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
|
|
49050
49545
|
var hash = pipe(string(), regex(/^[a-f0-9]{64}$/));
|
|
49051
49546
|
var ref2 = pipe(string(), minLength(1), maxLength(2048));
|
|
49052
49547
|
var targetSchema = strictObject({
|
|
@@ -49152,7 +49647,7 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
|
|
|
49152
49647
|
};
|
|
49153
49648
|
}, "planBoundProjectAnnotations");
|
|
49154
49649
|
|
|
49155
|
-
// 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
|
|
49156
49651
|
import { createHash as createHash17 } from "node:crypto";
|
|
49157
49652
|
var text5 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
|
|
49158
49653
|
var timestamp3 = pipe(number(), safeInteger(), minValue(0));
|
|
@@ -49246,7 +49741,7 @@ var projectAnnotationSnapshotFingerprint = /* @__PURE__ */ __name((json3) => {
|
|
|
49246
49741
|
})).digest("hex");
|
|
49247
49742
|
}, "projectAnnotationSnapshotFingerprint");
|
|
49248
49743
|
|
|
49249
|
-
// 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
|
|
49250
49745
|
var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false) => {
|
|
49251
49746
|
if (!request || typeof request !== "object" || Array.isArray(request))
|
|
49252
49747
|
throw new CliError("validation_error", "project annotation request is required");
|
|
@@ -49263,7 +49758,7 @@ var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false)
|
|
|
49263
49758
|
return { snapshot: snapshot2, projectId: Number(request.project.slice(8)) };
|
|
49264
49759
|
}, "projectAnnotationRequest");
|
|
49265
49760
|
|
|
49266
|
-
// 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
|
|
49267
49762
|
var SnapshotBudget = class {
|
|
49268
49763
|
static {
|
|
49269
49764
|
__name(this, "SnapshotBudget");
|
|
@@ -49289,13 +49784,13 @@ var SnapshotBudget = class {
|
|
|
49289
49784
|
}
|
|
49290
49785
|
};
|
|
49291
49786
|
|
|
49292
|
-
// 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
|
|
49293
49788
|
import { createHash as createHash19 } from "node:crypto";
|
|
49294
49789
|
|
|
49295
|
-
// 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
|
|
49296
49791
|
var planProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3, target, bindings) => planBoundProjectAnnotations(decodeProjectAnnotationSnapshot(json3), projectAnnotationSnapshotFingerprint(json3), target, bindings), "planProjectAnnotationSnapshot");
|
|
49297
49792
|
|
|
49298
|
-
// 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
|
|
49299
49794
|
import { createHash as createHash18 } from "node:crypto";
|
|
49300
49795
|
var invalid11 = /* @__PURE__ */ __name(() => {
|
|
49301
49796
|
throw new CliError("configuration_error", "project snapshot has an unavailable or unsupported dependency");
|
|
@@ -49438,7 +49933,7 @@ var ProjectSnapshotSources = class {
|
|
|
49438
49933
|
}
|
|
49439
49934
|
};
|
|
49440
49935
|
|
|
49441
|
-
// 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
|
|
49442
49937
|
var unsupported = /* @__PURE__ */ __name(() => {
|
|
49443
49938
|
throw new CliError("configuration_error", "project snapshot has unsupported metadata, deletion or account scope");
|
|
49444
49939
|
}, "unsupported");
|
|
@@ -49609,7 +50104,7 @@ var projectAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, bu
|
|
|
49609
50104
|
return { snapshot: snapshot2, read_bytes: budget.bytes, records: budget.records };
|
|
49610
50105
|
}), "projectAnnotationSnapshot");
|
|
49611
50106
|
|
|
49612
|
-
// 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
|
|
49613
50108
|
var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, manifest, bindings, budget) => read(database, () => {
|
|
49614
50109
|
const current = projectAnnotationSnapshot(database, projectId2, budget).snapshot;
|
|
49615
50110
|
const sources = new ProjectSnapshotSources(database, budget);
|
|
@@ -49671,7 +50166,7 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, ma
|
|
|
49671
50166
|
};
|
|
49672
50167
|
}), "previewAnnotationSnapshot");
|
|
49673
50168
|
|
|
49674
|
-
// 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
|
|
49675
50170
|
var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, snapshot2, bindings) => {
|
|
49676
50171
|
const mappings = { ...bindings };
|
|
49677
50172
|
const resolve = /* @__PURE__ */ __name((ref3) => {
|
|
@@ -49713,7 +50208,7 @@ var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, sna
|
|
|
49713
50208
|
return mappings;
|
|
49714
50209
|
}, "restoreAnnotationRecords");
|
|
49715
50210
|
|
|
49716
|
-
// 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
|
|
49717
50212
|
var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
49718
50213
|
async preview(request) {
|
|
49719
50214
|
const { snapshot: snapshot2, projectId: projectId2 } = projectAnnotationRequest(request);
|
|
@@ -49743,7 +50238,7 @@ var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
|
|
|
49743
50238
|
}
|
|
49744
50239
|
}), "projectAnnotationStoreOver");
|
|
49745
50240
|
|
|
49746
|
-
// 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
|
|
49747
50242
|
import { createHash as createHash20 } from "node:crypto";
|
|
49748
50243
|
var RECORDS_SCHEMA_VERSION = 1;
|
|
49749
50244
|
var RECORD_OPERATIONS = ["upsert", "delete"];
|
|
@@ -49975,7 +50470,7 @@ var envelopeOfJsonl = /* @__PURE__ */ __name((text6) => {
|
|
|
49975
50470
|
return isObject2(header) ? { ...header, records: records2 } : header;
|
|
49976
50471
|
}, "envelopeOfJsonl");
|
|
49977
50472
|
|
|
49978
|
-
// 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
|
|
49979
50474
|
var PROJECTED = {
|
|
49980
50475
|
invoice: { roles: ["issuer", "counterparty", "project"], many: [] },
|
|
49981
50476
|
payment: { roles: ["payer", "payee", "project", "settles"], many: ["settles"] }
|
|
@@ -49993,7 +50488,7 @@ var codeOf = /* @__PURE__ */ __name((error) => {
|
|
|
49993
50488
|
return error.code === "not_found" ? "record.reference-not-found" : "record.entity";
|
|
49994
50489
|
}, "codeOf");
|
|
49995
50490
|
var unsettled = /* @__PURE__ */ __name((fields4, relations) => recordFingerprint(fields4, relations.filter((relation) => relation.role !== "settles")), "unsettled");
|
|
49996
|
-
var
|
|
50491
|
+
var iso13 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
|
|
49997
50492
|
var stringField = /* @__PURE__ */ __name((fields4, name) => {
|
|
49998
50493
|
const value = fields4[name];
|
|
49999
50494
|
if (value === void 0 || value === null)
|
|
@@ -50326,9 +50821,9 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50326
50821
|
entity: entityRef(row2.entity_type, row2.entity_id),
|
|
50327
50822
|
flagged: row2.entity_id != null && (row2.deleted_at != null || row2.projected_fingerprint !== row2.fingerprint),
|
|
50328
50823
|
batchId: String(row2.batch_id),
|
|
50329
|
-
createdAt:
|
|
50330
|
-
updatedAt:
|
|
50331
|
-
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)
|
|
50332
50827
|
}), "sourceRecordOf");
|
|
50333
50828
|
const SELECT2 = "SELECT r.*, a.provider, a.external_id AS account FROM records r JOIN accounts a ON a.id = r.account_id ";
|
|
50334
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");
|
|
@@ -50388,7 +50883,7 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50388
50883
|
};
|
|
50389
50884
|
}, "recordStoreOver");
|
|
50390
50885
|
|
|
50391
|
-
// 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
|
|
50392
50887
|
var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to) => {
|
|
50393
50888
|
const touching = and(eq(syncRanges.chatId, chatKey), lte(syncRanges.fromKey, to + 1), gte(syncRanges.toKey, from2 - 1));
|
|
50394
50889
|
let merged = { from: from2, to };
|
|
@@ -50401,7 +50896,7 @@ var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to)
|
|
|
50401
50896
|
}, "markRange");
|
|
50402
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");
|
|
50403
50898
|
|
|
50404
|
-
// 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
|
|
50405
50900
|
var prefixOf2 = /* @__PURE__ */ __name(({ provider, account }) => `task_analysis:${provider}:${account}:`, "prefixOf");
|
|
50406
50901
|
var markOf = /* @__PURE__ */ __name((prefix, row2) => ({
|
|
50407
50902
|
chatId: String(row2.key).slice(prefix.length),
|
|
@@ -50422,7 +50917,7 @@ var setTaskAnalysisMark = /* @__PURE__ */ __name((database, account, { chatId, c
|
|
|
50422
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);
|
|
50423
50918
|
}, "setTaskAnalysisMark");
|
|
50424
50919
|
|
|
50425
|
-
// 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
|
|
50426
50921
|
var keyOf4 = /* @__PURE__ */ __name(({ provider, account }) => `task_rules_until:${provider}:${account}`, "keyOf");
|
|
50427
50922
|
var taskRulesStop = /* @__PURE__ */ __name((database, account) => {
|
|
50428
50923
|
const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(keyOf4(account));
|
|
@@ -50432,7 +50927,7 @@ var setTaskRulesStop = /* @__PURE__ */ __name((database, account, until, now2) =
|
|
|
50432
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);
|
|
50433
50928
|
}, "setTaskRulesStop");
|
|
50434
50929
|
|
|
50435
|
-
// 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
|
|
50436
50931
|
var syncStoreOver = /* @__PURE__ */ __name((context) => {
|
|
50437
50932
|
const { database } = context;
|
|
50438
50933
|
const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, identityPk: identityPk2, writeMembers: writeMembers2, writeState: writeState2 } = keysOver(context);
|
|
@@ -50491,7 +50986,7 @@ var syncStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50491
50986
|
};
|
|
50492
50987
|
}, "syncStoreOver");
|
|
50493
50988
|
|
|
50494
|
-
// 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
|
|
50495
50990
|
var tagsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
50496
50991
|
const { database } = context;
|
|
50497
50992
|
return {
|
|
@@ -50513,7 +51008,7 @@ var tagsStoreOver = /* @__PURE__ */ __name((context) => {
|
|
|
50513
51008
|
};
|
|
50514
51009
|
}, "tagsStoreOver");
|
|
50515
51010
|
|
|
50516
|
-
// 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
|
|
50517
51012
|
var IS_IMAGE = sql`(a.kind = 'photo' OR a.mime LIKE 'image/%')`;
|
|
50518
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
|
|
50519
51014
|
WHERE chat_id = ${chatKey} AND deleted_at IS NULL AND trim(text) <> '' AND id <> ${messagePk}
|
|
@@ -50640,7 +51135,7 @@ var savePictureChunks = /* @__PURE__ */ __name(({ orm, now: now2, database }, ac
|
|
|
50640
51135
|
dropUnusedVectors(database, released.map(({ hash: hash2 }) => hash2));
|
|
50641
51136
|
}, "savePictureChunks");
|
|
50642
51137
|
|
|
50643
|
-
// 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
|
|
50644
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,
|
|
50645
51140
|
EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ${model} AND v.content_hash = k.content_hash) AS embedded
|
|
50646
51141
|
FROM messages m
|
|
@@ -50729,7 +51224,7 @@ var nearestMessages = /* @__PURE__ */ __name((context, accountPk2, { limit, quer
|
|
|
50729
51224
|
return plain2(best(found2));
|
|
50730
51225
|
}, "nearestMessages");
|
|
50731
51226
|
|
|
50732
|
-
// 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
|
|
50733
51228
|
var accountVectorsOver = /* @__PURE__ */ __name((context, mail) => {
|
|
50734
51229
|
const { database } = context;
|
|
50735
51230
|
const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
|
|
@@ -50987,7 +51482,7 @@ var vectorsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
|
|
|
50987
51482
|
embeddedHashes: /* @__PURE__ */ __name(async (model, hashes) => embeddedHashes(context, model, hashes), "embeddedHashes")
|
|
50988
51483
|
}), "vectorsStoreOver");
|
|
50989
51484
|
|
|
50990
|
-
// 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
|
|
50991
51486
|
import { existsSync, readFileSync as readFileSync4 } from "node:fs";
|
|
50992
51487
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
50993
51488
|
var BOOKKEEPING = ["schema_migrations", "store_settings"];
|
|
@@ -51075,10 +51570,10 @@ var lastBackup = /* @__PURE__ */ __name((path) => {
|
|
|
51075
51570
|
}
|
|
51076
51571
|
}, "lastBackup");
|
|
51077
51572
|
|
|
51078
|
-
// 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
|
|
51079
51574
|
var registerProvider2 = /* @__PURE__ */ __name((store, entry2) => store.accounts.registerProvider(entry2), "registerProvider");
|
|
51080
51575
|
|
|
51081
|
-
// 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
|
|
51082
51577
|
var COUNTED_TABLES = [
|
|
51083
51578
|
"accounts",
|
|
51084
51579
|
"chats",
|
|
@@ -51163,7 +51658,7 @@ var storeContents = /* @__PURE__ */ __name((database) => {
|
|
|
51163
51658
|
};
|
|
51164
51659
|
}, "storeContents");
|
|
51165
51660
|
|
|
51166
|
-
// 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
|
|
51167
51662
|
var openStore = /* @__PURE__ */ __name(async (options = {}) => {
|
|
51168
51663
|
const context = await openStoreContext(options);
|
|
51169
51664
|
try {
|
|
@@ -51229,6 +51724,7 @@ var storeOver = /* @__PURE__ */ __name((context) => {
|
|
|
51229
51724
|
const facts2 = once3(() => factsStoreOver(context));
|
|
51230
51725
|
const finance = once3(() => financeStoreOver(context));
|
|
51231
51726
|
const orders2 = once3(() => ordersStoreOver(context));
|
|
51727
|
+
const deals2 = once3(() => dealsStoreOver(context));
|
|
51232
51728
|
const records2 = once3(() => recordStoreOver(context));
|
|
51233
51729
|
const memories2 = once3(() => memoriesStoreOver(context));
|
|
51234
51730
|
const proposedActions2 = once3(() => proposedActionsStoreOver(context));
|
|
@@ -51339,6 +51835,9 @@ var storeOver = /* @__PURE__ */ __name((context) => {
|
|
|
51339
51835
|
get orders() {
|
|
51340
51836
|
return orders2();
|
|
51341
51837
|
},
|
|
51838
|
+
get deals() {
|
|
51839
|
+
return deals2();
|
|
51840
|
+
},
|
|
51342
51841
|
get records() {
|
|
51343
51842
|
return records2();
|
|
51344
51843
|
},
|
|
@@ -51467,6 +51966,9 @@ export {
|
|
|
51467
51966
|
mayDecide,
|
|
51468
51967
|
assertMayDecide,
|
|
51469
51968
|
deciderAuthor,
|
|
51969
|
+
DEAL_KINDS,
|
|
51970
|
+
DEAL_STATUSES,
|
|
51971
|
+
DEAL_ROLES,
|
|
51470
51972
|
openOf,
|
|
51471
51973
|
refLabel,
|
|
51472
51974
|
MAX_FILE_BYTES,
|