@wirecat/cli-core 0.584.0 → 0.586.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
- package/dist/domain/deals.d.ts +20 -0
- package/dist/domain/deals.js +15 -0
- package/dist/domain/ref-summaries.js +1 -0
- package/dist/domain/references.d.ts +1 -1
- package/dist/domain/references.js +1 -0
- package/dist/errors/reasons.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/services/proposals/kinds/deals.d.ts +4 -0
- package/dist/services/proposals/kinds/deals.js +32 -0
- package/dist/services/proposals/registry.js +2 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/sqlite/deals.d.ts +104 -0
- package/dist/store/sqlite/deals.js +264 -0
- package/dist/store/sqlite/entity-types.d.ts +1 -0
- package/dist/store/sqlite/entity-types.js +1 -0
- package/dist/store/sqlite/finance.d.ts +3 -3
- package/dist/store/sqlite/knowledge.js +2 -1
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +21 -0
- package/dist/store/sqlite/ref-summaries.js +10 -0
- package/dist/store/sqlite/schema.d.ts +554 -0
- package/dist/store/sqlite/schema.js +52 -0
- package/dist/store/sqlite/things.js +1 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ shape of this file.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.586.0 — 06.11.2026
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **cli-core accepts `@wirecat/cli-base` 0.78 and 0.79 (peer range `>=0.76.0 <0.80.0`) and builds with 0.79.0**,
|
|
15
|
+
whose vocabulary has the finance resources `records`, `invoices`, `orders`, `payments` and the verb `allocate`
|
|
16
|
+
(0.78.0), and the CRM resources `deals`, `leads`, `pipelines`, `stages`, `products` and `users` (0.79.0), for the
|
|
17
|
+
Bitrix24 CLI `b24`. The lower bound stays, so nothing changes for a CLI on cli-base 0.76 or 0.77.
|
|
18
|
+
|
|
19
|
+
## 0.585.0 — 06.11.2026
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **Deals in the store (store version 52).** `store.deals` keeps the owner's sales pipelines (`pipelines`,
|
|
24
|
+
`pipeline_stages`, made by the owner only) and the deals in them (table `opportunities`, ref `deal:<id>`): title,
|
|
25
|
+
organization, project, stage, status `open`, `won` or `lost` kept apart from the stage, the expected amount in minor
|
|
26
|
+
units with its currency, the expected close day and the day it closed. The people on a deal are `related-to` links
|
|
27
|
+
with a role (`owner`, `contact`, `decision-maker`). The owner's deal is confirmed at once; an agent's is a `deal`
|
|
28
|
+
proposal only the owner decides. Only the owner moves a deal, within its own pipeline, or closes it.
|
|
29
|
+
|
|
10
30
|
## 0.584.0 — 06.11.2026
|
|
11
31
|
|
|
12
32
|
### Added
|
|
@@ -3,9 +3,9 @@ import type { CacheDatabase } from "../../store/driver.js";
|
|
|
3
3
|
import type { Messenger } from "./context.js";
|
|
4
4
|
/** `doctor`'s short summary of the store. Must answer for a broken file, so an error is a field. */
|
|
5
5
|
export declare const storeSummary: (env: NodeJS.ProcessEnv) => Promise<{
|
|
6
|
+
error?: undefined;
|
|
6
7
|
path: string;
|
|
7
8
|
exists: boolean;
|
|
8
|
-
error?: undefined;
|
|
9
9
|
} | {
|
|
10
10
|
path: string;
|
|
11
11
|
exists: boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FinanceReview } from "./finance.js";
|
|
2
|
+
/** Whether a deal ended, kept apart from the stage it stands in. */
|
|
3
|
+
export declare const DEAL_STATUSES: readonly ["open", "won", "lost"];
|
|
4
|
+
/** The part a person plays on a deal: the owner's side runs it, the client's side talks or decides. */
|
|
5
|
+
export declare const DEAL_ROLES: readonly ["owner", "contact", "decision-maker"];
|
|
6
|
+
export type DealStatus = (typeof DEAL_STATUSES)[number];
|
|
7
|
+
export type DealRole = (typeof DEAL_ROLES)[number];
|
|
8
|
+
export interface DealTitleFields {
|
|
9
|
+
id: number;
|
|
10
|
+
title: string;
|
|
11
|
+
stage: string;
|
|
12
|
+
amount: number | null;
|
|
13
|
+
currency: string | null;
|
|
14
|
+
status: DealStatus;
|
|
15
|
+
review: FinanceReview;
|
|
16
|
+
}
|
|
17
|
+
/** "Site redesign · Proposal, 500 000.00 RUB": a ref summary's title, which `refLabel` prefixes. */
|
|
18
|
+
export declare const dealLine: (deal: DealTitleFields) => string;
|
|
19
|
+
/** "Deal Site redesign · Proposal, 500 000.00 RUB (won)". */
|
|
20
|
+
export declare const dealTitle: (deal: DealTitleFields) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moneyLabel } from "./money.js";
|
|
2
|
+
/** Whether a deal ended, kept apart from the stage it stands in. */
|
|
3
|
+
export const DEAL_STATUSES = ["open", "won", "lost"];
|
|
4
|
+
/** The part a person plays on a deal: the owner's side runs it, the client's side talks or decides. */
|
|
5
|
+
export const DEAL_ROLES = ["owner", "contact", "decision-maker"];
|
|
6
|
+
/** "Site redesign · Proposal, 500 000.00 RUB": a ref summary's title, which `refLabel` prefixes. */
|
|
7
|
+
export const dealLine = (deal) => {
|
|
8
|
+
const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
|
|
9
|
+
const notes = [deal.status === "open" ? null : deal.status, deal.review === "confirmed" ? null : deal.review]
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join(", ");
|
|
12
|
+
return `${deal.title} · ${deal.stage}${money}${notes ? ` (${notes})` : ""}`;
|
|
13
|
+
};
|
|
14
|
+
/** "Deal Site redesign · Proposal, 500 000.00 RUB (won)". */
|
|
15
|
+
export const dealTitle = (deal) => `Deal ${dealLine(deal)}`;
|
|
@@ -33,7 +33,7 @@ export type Reference = {
|
|
|
33
33
|
* Things named by their store id (a task also by its key or the task package's id). `entity` is the name
|
|
34
34
|
* before organizations and projects: it still parses, so an old file's reference resolves as not found.
|
|
35
35
|
*/
|
|
36
|
-
export declare const SIMPLE_REFERENCES: readonly ["note", "document", "person", "organization", "project", "task", "memory", "fact", "bot", "event", "invoice", "payment", "order", "entity"];
|
|
36
|
+
export declare const SIMPLE_REFERENCES: readonly ["note", "document", "person", "organization", "project", "task", "memory", "fact", "bot", "event", "invoice", "payment", "order", "deal", "entity"];
|
|
37
37
|
export type SimpleReference = (typeof SIMPLE_REFERENCES)[number];
|
|
38
38
|
export type RefKindName = Exclude<Reference["type"], "entity">;
|
|
39
39
|
export interface RefKindSpec<R extends Reference = Reference> {
|
package/dist/errors/reasons.js
CHANGED
|
@@ -203,6 +203,14 @@ const OTHERS = [
|
|
|
203
203
|
validation("money.amount", "the amount is not a decimal string in the currency's scale"),
|
|
204
204
|
validation("money.currency", "the currency is not one the store keeps money in"),
|
|
205
205
|
validation("money.quantity", "the quantity is not a decimal above 0"),
|
|
206
|
+
validation("deal.closed", "a won, lost, rejected or deleted deal does not move or close again"),
|
|
207
|
+
validation("deal.field", "a field of the deal is not valid"),
|
|
208
|
+
["deal.owner-only", "permission_error", "only the owner moves or closes a deal, or makes a pipeline"],
|
|
209
|
+
validation("deal.ref", "the reference names no deal"),
|
|
210
|
+
validation("deal.stage", "no stage of that name, or a stage name more than one pipeline has"),
|
|
211
|
+
validation("pipeline.duplicate", "a pipeline of that name is already stored"),
|
|
212
|
+
validation("pipeline.field", "a pipeline needs a name and at least one stage, each named once"),
|
|
213
|
+
["pipeline.not-found", "not_found", "no stored pipeline has that name"],
|
|
206
214
|
validation("order.duplicate", "the shop's order with this number is already stored; change its status instead"),
|
|
207
215
|
validation("order.proposed", "the shop's order with this number already waits for the owner in a findings batch"),
|
|
208
216
|
validation("order.field", "a field of the order is not valid"),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { bareCheck, type CheckWords, checkWords } from "./domain/checks.js";
|
|
2
2
|
export type { CounterField, CounterObservation, CounterObservations, CounterState } from "./domain/counters.js";
|
|
3
3
|
export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
|
|
4
|
+
export { DEAL_ROLES, DEAL_STATUSES, type DealRole, type DealStatus } from "./domain/deals.js";
|
|
4
5
|
export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
|
|
5
6
|
export { type FormattedText, type HtmlFormatting, type MarkdownFormatting, type TextSpan, validateFormattedText, } from "./domain/formatting.js";
|
|
6
7
|
export { formatLocator, isLocator, type MessageLocator, parseLocator } from "./domain/locator.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { bareCheck, checkWords } from "./domain/checks.js";
|
|
2
2
|
export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
|
|
3
|
+
export { DEAL_ROLES, DEAL_STATUSES } from "./domain/deals.js";
|
|
3
4
|
export { FINANCE_REVIEWS, INVOICE_DIRECTIONS, INVOICE_STATUSES, MONEY_DIRECTIONS, } from "./domain/finance.js";
|
|
4
5
|
export { validateFormattedText, } from "./domain/formatting.js";
|
|
5
6
|
export { formatLocator, isLocator, parseLocator } from "./domain/locator.js";
|
|
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
-
limit?: undefined;
|
|
42
41
|
event_id?: undefined;
|
|
43
42
|
series_id?: undefined;
|
|
44
43
|
page?: undefined;
|
|
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
|
|
|
54
53
|
format?: undefined;
|
|
55
54
|
transcript_id?: undefined;
|
|
56
55
|
query?: undefined;
|
|
56
|
+
limit?: undefined;
|
|
57
57
|
scan_limit?: undefined;
|
|
58
58
|
max_read_bytes?: undefined;
|
|
59
59
|
cursor?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
limit?: undefined;
|
|
62
61
|
event_id?: undefined;
|
|
63
62
|
series_id?: undefined;
|
|
64
63
|
page?: undefined;
|
|
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
|
|
|
76
75
|
format?: undefined;
|
|
77
76
|
transcript_id?: undefined;
|
|
78
77
|
query?: undefined;
|
|
78
|
+
limit?: undefined;
|
|
79
79
|
scan_limit?: undefined;
|
|
80
80
|
max_read_bytes?: undefined;
|
|
81
81
|
cursor?: undefined;
|
|
82
82
|
} | {
|
|
83
|
-
limit?: undefined;
|
|
84
83
|
event_id?: undefined;
|
|
85
84
|
series_id?: undefined;
|
|
86
85
|
page?: undefined;
|
|
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
|
|
|
102
101
|
minimum: number;
|
|
103
102
|
};
|
|
104
103
|
query?: undefined;
|
|
104
|
+
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
-
limit?: undefined;
|
|
192
191
|
event_id?: undefined;
|
|
193
192
|
series_id?: undefined;
|
|
194
193
|
page?: undefined;
|
|
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
|
|
|
204
203
|
format?: undefined;
|
|
205
204
|
transcript_id?: undefined;
|
|
206
205
|
query?: undefined;
|
|
206
|
+
limit?: undefined;
|
|
207
207
|
scan_limit?: undefined;
|
|
208
208
|
max_read_bytes?: undefined;
|
|
209
209
|
cursor?: undefined;
|
|
210
210
|
} | {
|
|
211
|
-
limit?: undefined;
|
|
212
211
|
event_id?: undefined;
|
|
213
212
|
series_id?: undefined;
|
|
214
213
|
page?: undefined;
|
|
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
|
|
|
226
225
|
format?: undefined;
|
|
227
226
|
transcript_id?: undefined;
|
|
228
227
|
query?: undefined;
|
|
228
|
+
limit?: undefined;
|
|
229
229
|
scan_limit?: undefined;
|
|
230
230
|
max_read_bytes?: undefined;
|
|
231
231
|
cursor?: undefined;
|
|
232
232
|
} | {
|
|
233
|
-
limit?: undefined;
|
|
234
233
|
event_id?: undefined;
|
|
235
234
|
series_id?: undefined;
|
|
236
235
|
page?: undefined;
|
|
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
|
|
|
252
251
|
minimum: number;
|
|
253
252
|
};
|
|
254
253
|
query?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
-
limit?: undefined;
|
|
342
341
|
event_id?: undefined;
|
|
343
342
|
series_id?: undefined;
|
|
344
343
|
page?: undefined;
|
|
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
|
|
|
354
353
|
format?: undefined;
|
|
355
354
|
transcript_id?: undefined;
|
|
356
355
|
query?: undefined;
|
|
356
|
+
limit?: undefined;
|
|
357
357
|
scan_limit?: undefined;
|
|
358
358
|
max_read_bytes?: undefined;
|
|
359
359
|
cursor?: undefined;
|
|
360
360
|
} | {
|
|
361
|
-
limit?: undefined;
|
|
362
361
|
event_id?: undefined;
|
|
363
362
|
series_id?: undefined;
|
|
364
363
|
page?: undefined;
|
|
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
|
|
|
376
375
|
format?: undefined;
|
|
377
376
|
transcript_id?: undefined;
|
|
378
377
|
query?: undefined;
|
|
378
|
+
limit?: undefined;
|
|
379
379
|
scan_limit?: undefined;
|
|
380
380
|
max_read_bytes?: undefined;
|
|
381
381
|
cursor?: undefined;
|
|
382
382
|
} | {
|
|
383
|
-
limit?: undefined;
|
|
384
383
|
event_id?: undefined;
|
|
385
384
|
series_id?: undefined;
|
|
386
385
|
page?: undefined;
|
|
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
|
|
|
402
401
|
minimum: number;
|
|
403
402
|
};
|
|
404
403
|
query?: undefined;
|
|
404
|
+
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
-
limit?: undefined;
|
|
492
491
|
event_id?: undefined;
|
|
493
492
|
series_id?: undefined;
|
|
494
493
|
page?: undefined;
|
|
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
|
|
|
504
503
|
format?: undefined;
|
|
505
504
|
transcript_id?: undefined;
|
|
506
505
|
query?: undefined;
|
|
506
|
+
limit?: undefined;
|
|
507
507
|
scan_limit?: undefined;
|
|
508
508
|
max_read_bytes?: undefined;
|
|
509
509
|
cursor?: undefined;
|
|
510
510
|
} | {
|
|
511
|
-
limit?: undefined;
|
|
512
511
|
event_id?: undefined;
|
|
513
512
|
series_id?: undefined;
|
|
514
513
|
page?: undefined;
|
|
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
|
|
|
526
525
|
format?: undefined;
|
|
527
526
|
transcript_id?: undefined;
|
|
528
527
|
query?: undefined;
|
|
528
|
+
limit?: undefined;
|
|
529
529
|
scan_limit?: undefined;
|
|
530
530
|
max_read_bytes?: undefined;
|
|
531
531
|
cursor?: undefined;
|
|
532
532
|
} | {
|
|
533
|
-
limit?: undefined;
|
|
534
533
|
event_id?: undefined;
|
|
535
534
|
series_id?: undefined;
|
|
536
535
|
page?: undefined;
|
|
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
|
|
|
552
551
|
minimum: number;
|
|
553
552
|
};
|
|
554
553
|
query?: undefined;
|
|
554
|
+
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
-
limit?: undefined;
|
|
642
641
|
event_id?: undefined;
|
|
643
642
|
series_id?: undefined;
|
|
644
643
|
page?: undefined;
|
|
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
|
|
|
654
653
|
format?: undefined;
|
|
655
654
|
transcript_id?: undefined;
|
|
656
655
|
query?: undefined;
|
|
656
|
+
limit?: undefined;
|
|
657
657
|
scan_limit?: undefined;
|
|
658
658
|
max_read_bytes?: undefined;
|
|
659
659
|
cursor?: undefined;
|
|
660
660
|
} | {
|
|
661
|
-
limit?: undefined;
|
|
662
661
|
event_id?: undefined;
|
|
663
662
|
series_id?: undefined;
|
|
664
663
|
page?: undefined;
|
|
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
|
|
|
676
675
|
format?: undefined;
|
|
677
676
|
transcript_id?: undefined;
|
|
678
677
|
query?: undefined;
|
|
678
|
+
limit?: undefined;
|
|
679
679
|
scan_limit?: undefined;
|
|
680
680
|
max_read_bytes?: undefined;
|
|
681
681
|
cursor?: undefined;
|
|
682
682
|
} | {
|
|
683
|
-
limit?: undefined;
|
|
684
683
|
event_id?: undefined;
|
|
685
684
|
series_id?: undefined;
|
|
686
685
|
page?: undefined;
|
|
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
|
|
|
702
701
|
minimum: number;
|
|
703
702
|
};
|
|
704
703
|
query?: undefined;
|
|
704
|
+
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MessageStore } from "../../../store/index.js";
|
|
2
|
+
import type { ProposalKind } from "../types.js";
|
|
3
|
+
/** An agent's deal, by its own ref (`deal:12`) as orders are; only the owner decides it. */
|
|
4
|
+
export declare const dealKind: (store: Pick<MessageStore, "deals">) => ProposalKind;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { kept, proposerOfAuthor, pushed } from "./shared.js";
|
|
2
|
+
const rowOf = (deal) => ({
|
|
3
|
+
id: deal.ref,
|
|
4
|
+
kind: "deal",
|
|
5
|
+
status: deal.review,
|
|
6
|
+
project: deal.project,
|
|
7
|
+
subject: deal.ref,
|
|
8
|
+
object: deal.organization?.ref ?? null,
|
|
9
|
+
summary: `Deal ${deal.summary}`,
|
|
10
|
+
proposedBy: proposerOfAuthor(deal.author),
|
|
11
|
+
reason: deal.reason,
|
|
12
|
+
evidence: [],
|
|
13
|
+
score: null,
|
|
14
|
+
signals: null,
|
|
15
|
+
parts: null,
|
|
16
|
+
createdAt: deal.createdAt,
|
|
17
|
+
});
|
|
18
|
+
/** An agent's deal, by its own ref (`deal:12`) as orders are; only the owner decides it. */
|
|
19
|
+
export const dealKind = (store) => ({
|
|
20
|
+
kind: "deal",
|
|
21
|
+
prefix: "deal",
|
|
22
|
+
list: async (filter) => {
|
|
23
|
+
const status = filter.status ?? "proposed";
|
|
24
|
+
const deals = await store.deals.list({ ...pushed(filter), ...(status === "all" ? {} : { review: status }) });
|
|
25
|
+
return kept(deals.map(rowOf), filter);
|
|
26
|
+
},
|
|
27
|
+
get: async (id) => rowOf(await store.deals.get(id)),
|
|
28
|
+
decide: async (id, { confirm, by, reason }) => {
|
|
29
|
+
const deal = confirm ? await store.deals.confirm(id, by, reason) : await store.deals.reject(id, by, reason);
|
|
30
|
+
return { id, kind: "deal", status: confirm ? "confirmed" : "rejected", made: confirm ? [deal.ref] : [] };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { mayDecide } from "../../store/decisions.js";
|
|
3
3
|
import { actionKind } from "./kinds/action.js";
|
|
4
|
+
import { dealKind } from "./kinds/deals.js";
|
|
4
5
|
import { factKind } from "./kinds/fact.js";
|
|
5
6
|
import { invoiceKind, paymentKind } from "./kinds/finance.js";
|
|
6
7
|
import { findingsKind } from "./kinds/findings.js";
|
|
@@ -135,6 +136,7 @@ export const proposalRegistry = (store) => {
|
|
|
135
136
|
invoiceKind(store),
|
|
136
137
|
paymentKind(store),
|
|
137
138
|
orderKind(store),
|
|
139
|
+
dealKind(store),
|
|
138
140
|
organizationKind(store),
|
|
139
141
|
memoryKind(store),
|
|
140
142
|
findingsKind(store),
|
package/dist/store/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export type { BotUpdate, BotUpdateStore } from "./sqlite/bot-updates.js";
|
|
|
34
34
|
export type { CatalogActor, CatalogEntry, CatalogInput, CatalogQuery, CatalogStore } from "./sqlite/catalog.js";
|
|
35
35
|
export { CATALOG_QUERY } from "./sqlite/catalog.js";
|
|
36
36
|
export type { ChatMetadata } from "./sqlite/chats.js";
|
|
37
|
+
export type { Deal, DealFilter, DealInput, DealPerson, DealsStore, Pipeline, PipelineStage, } from "./sqlite/deals.js";
|
|
37
38
|
export type { Email, EmailAddress, EmailAttachment, EmailFacts, EmailFilter, EmailInput, EmailInThread, EmailLocationInput, EmailRecipient, EmailRef, EmailThread, EmailVectorHit, FolderEmail, Mailbox, MailboxInput, MailFilter, MailStore, PartialEmail, SenderScore, ThreadDetails, ThreadSave, } from "./sqlite/emails.js";
|
|
38
39
|
export { EVENT_FIELDS, type EventChunkToEmbed, type EventHit, type EventQuery, type EventSearch, type NearestEvent, } from "./sqlite/event-search.js";
|
|
39
40
|
export type { EvidenceSource } from "./sqlite/evidence-sources.js";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type DealRole, type DealStatus } from "../../domain/deals.js";
|
|
2
|
+
import { type FinanceReview } from "../../domain/finance.js";
|
|
3
|
+
import { type Decider } from "../decisions.js";
|
|
4
|
+
import { type ProposedByFilter } from "./actors.js";
|
|
5
|
+
import { type Party, type Reviewed, type Written } from "./finance.js";
|
|
6
|
+
import { type Author } from "./memories.js";
|
|
7
|
+
import type { StoreContext } from "./open.js";
|
|
8
|
+
export interface PipelineStage {
|
|
9
|
+
name: string;
|
|
10
|
+
position: number;
|
|
11
|
+
/** Open deals standing in it, the owner's and agents' not rejected. */
|
|
12
|
+
open: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Pipeline {
|
|
15
|
+
name: string;
|
|
16
|
+
stages: PipelineStage[];
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DealPerson extends Party {
|
|
20
|
+
role: DealRole;
|
|
21
|
+
}
|
|
22
|
+
export interface Deal extends Reviewed {
|
|
23
|
+
id: string;
|
|
24
|
+
ref: string;
|
|
25
|
+
title: string;
|
|
26
|
+
/** One line with stage, amount and status, as a list or the review inbox prints it. */
|
|
27
|
+
summary: string;
|
|
28
|
+
pipeline: string;
|
|
29
|
+
stage: string;
|
|
30
|
+
status: DealStatus;
|
|
31
|
+
organization: Party | null;
|
|
32
|
+
/** Both `null` when no amount is expected yet. */
|
|
33
|
+
currency: string | null;
|
|
34
|
+
amount: string | null;
|
|
35
|
+
/** `YYYY-MM-DD`: the day it is expected to close. */
|
|
36
|
+
closeDate: string | null;
|
|
37
|
+
/** `YYYY-MM-DD`: the day it was won or lost. */
|
|
38
|
+
closedDate: string | null;
|
|
39
|
+
/** Why it was won or lost, as the owner said when closing it. */
|
|
40
|
+
closedReason: string | null;
|
|
41
|
+
people: DealPerson[];
|
|
42
|
+
}
|
|
43
|
+
export interface DealInput extends Written {
|
|
44
|
+
title: string;
|
|
45
|
+
/** A stage's name; `pipeline` names its pipeline when more than one has a stage of that name. */
|
|
46
|
+
stage: string;
|
|
47
|
+
pipeline?: string;
|
|
48
|
+
organization?: string;
|
|
49
|
+
/** A decimal string in `currency`; give both or neither. */
|
|
50
|
+
amount?: string;
|
|
51
|
+
currency?: string;
|
|
52
|
+
closeDate?: string;
|
|
53
|
+
people?: {
|
|
54
|
+
person: string;
|
|
55
|
+
role: DealRole;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
58
|
+
export interface DealFilter {
|
|
59
|
+
status?: DealStatus;
|
|
60
|
+
/** A stage's or pipeline's name, in any letter case. */
|
|
61
|
+
stage?: string;
|
|
62
|
+
pipeline?: string;
|
|
63
|
+
project?: string;
|
|
64
|
+
organization?: string;
|
|
65
|
+
review?: FinanceReview;
|
|
66
|
+
proposedBy?: ProposedByFilter;
|
|
67
|
+
/** 1–500, 100 by default; newest written first. */
|
|
68
|
+
limit?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The owner's sales pipelines and the deals in them. The owner's deal is confirmed at once; an agent's waits as
|
|
72
|
+
* proposed for him, and only he decides it. Only the owner makes a pipeline, moves a deal or closes it.
|
|
73
|
+
*/
|
|
74
|
+
export interface DealsStore {
|
|
75
|
+
addPipeline(input: {
|
|
76
|
+
name: string;
|
|
77
|
+
stages: string[];
|
|
78
|
+
by: Author;
|
|
79
|
+
}): Promise<Pipeline>;
|
|
80
|
+
pipelines(): Promise<Pipeline[]>;
|
|
81
|
+
add(input: DealInput): Promise<Deal>;
|
|
82
|
+
get(reference: string): Promise<Deal>;
|
|
83
|
+
list(filter?: DealFilter): Promise<Deal[]>;
|
|
84
|
+
/** To another stage of the deal's own pipeline. */
|
|
85
|
+
move(reference: string, input: {
|
|
86
|
+
stage: string;
|
|
87
|
+
by: Author;
|
|
88
|
+
}): Promise<Deal>;
|
|
89
|
+
/** `date` is the day it closed, today when left out. */
|
|
90
|
+
close(reference: string, input: {
|
|
91
|
+
status: Exclude<DealStatus, "open">;
|
|
92
|
+
date?: string;
|
|
93
|
+
reason?: string;
|
|
94
|
+
by: Author;
|
|
95
|
+
}): Promise<Deal>;
|
|
96
|
+
confirm(reference: string, by: Decider, reason?: string): Promise<Deal>;
|
|
97
|
+
reject(reference: string, by: Decider, reason?: string): Promise<Deal>;
|
|
98
|
+
}
|
|
99
|
+
type DealOperations = {
|
|
100
|
+
[K in keyof DealsStore]: DealsStore[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => R : never;
|
|
101
|
+
};
|
|
102
|
+
export declare const dealOperationsOver: (context: StoreContext) => DealOperations;
|
|
103
|
+
export declare const dealsStoreOver: (context: StoreContext) => DealsStore;
|
|
104
|
+
export {};
|