@wirecat/cli-core 0.586.0 → 0.588.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 +38 -0
- package/dist/calendar/cli/local-times.js +3 -13
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/local-times.d.ts +16 -0
- package/dist/cli/local-times.js +65 -0
- package/dist/cli/runs/command.js +3 -2
- package/dist/domain/deals.d.ts +8 -6
- package/dist/domain/deals.js +7 -8
- package/dist/domain/ref-summaries.js +2 -0
- package/dist/domain/references.d.ts +1 -1
- package/dist/domain/references.js +2 -0
- package/dist/errors/reasons.js +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mail/cli/index.js +12 -11
- package/dist/mail/cli/review.js +10 -7
- package/dist/mail/read.d.ts +1 -1
- package/dist/mail/read.js +2 -2
- package/dist/services/proposals/registry.js +0 -2
- package/dist/store/index.d.ts +1 -1
- package/dist/store/sqlite/deals.d.ts +128 -29
- package/dist/store/sqlite/deals.js +270 -156
- package/dist/store/sqlite/entity-types.d.ts +3 -1
- package/dist/store/sqlite/entity-types.js +3 -1
- package/dist/store/sqlite/knowledge.js +3 -1
- package/dist/store/sqlite/migrations.generated.js +39 -11
- package/dist/store/sqlite/ref-summaries.js +11 -7
- package/dist/store/sqlite/schema.d.ts +600 -38
- package/dist/store/sqlite/schema.js +86 -14
- package/dist/store/sqlite/things.js +2 -0
- package/package.json +3 -3
- package/dist/services/proposals/kinds/deals.d.ts +0 -4
- package/dist/services/proposals/kinds/deals.js +0 -32
|
@@ -1,31 +1,61 @@
|
|
|
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";
|
|
1
|
+
import { type DealKind, type DealRole, type DealStatus, type StageOutcome } from "../../domain/deals.js";
|
|
4
2
|
import { type ProposedByFilter } from "./actors.js";
|
|
5
|
-
import { type Party
|
|
3
|
+
import { type Party } from "./finance.js";
|
|
6
4
|
import { type Author } from "./memories.js";
|
|
7
5
|
import type { StoreContext } from "./open.js";
|
|
8
6
|
export interface PipelineStage {
|
|
9
7
|
name: string;
|
|
10
8
|
position: number;
|
|
11
|
-
|
|
9
|
+
outcome: StageOutcome;
|
|
10
|
+
externalId: string | null;
|
|
11
|
+
/** Open deals or leads standing in it now. */
|
|
12
12
|
open: number;
|
|
13
13
|
}
|
|
14
14
|
export interface Pipeline {
|
|
15
|
+
id: string;
|
|
16
|
+
ref: string;
|
|
15
17
|
name: string;
|
|
18
|
+
kind: DealKind;
|
|
19
|
+
/** The CRM account it was copied from; `null` for the owner's or an agent's own. */
|
|
20
|
+
account: {
|
|
21
|
+
provider: string;
|
|
22
|
+
account: string;
|
|
23
|
+
} | null;
|
|
24
|
+
externalId: string | null;
|
|
16
25
|
stages: PipelineStage[];
|
|
17
26
|
createdAt: string;
|
|
18
27
|
}
|
|
28
|
+
export interface FunnelStage extends PipelineStage {
|
|
29
|
+
/** Rows that got this far: entered this stage or a later one that is not lost, or were won. */
|
|
30
|
+
reached: number;
|
|
31
|
+
/** `reached` of the next stage that is not lost over this stage's, 0–1; `null` for the last or an empty one. */
|
|
32
|
+
conversion: number | null;
|
|
33
|
+
}
|
|
34
|
+
/** A pipeline with its funnel, counted from `pipeline_stage_changes`. */
|
|
35
|
+
export interface PipelineReport extends Omit<Pipeline, "stages"> {
|
|
36
|
+
stages: FunnelStage[];
|
|
37
|
+
totals: {
|
|
38
|
+
items: number;
|
|
39
|
+
open: number;
|
|
40
|
+
won: number;
|
|
41
|
+
lost: number;
|
|
42
|
+
winRate: number | null;
|
|
43
|
+
};
|
|
44
|
+
/** `YYYY-MM-DD`: only rows made since that day are counted; `null` for all. */
|
|
45
|
+
since: string | null;
|
|
46
|
+
}
|
|
19
47
|
export interface DealPerson extends Party {
|
|
20
48
|
role: DealRole;
|
|
21
49
|
}
|
|
22
|
-
export interface Deal
|
|
50
|
+
export interface Deal {
|
|
23
51
|
id: string;
|
|
24
52
|
ref: string;
|
|
53
|
+
kind: DealKind;
|
|
25
54
|
title: string;
|
|
26
|
-
/** One line with stage, amount and status, as a list
|
|
55
|
+
/** One line with stage, amount and status, as a list prints it. */
|
|
27
56
|
summary: string;
|
|
28
57
|
pipeline: string;
|
|
58
|
+
pipelineName: string;
|
|
29
59
|
stage: string;
|
|
30
60
|
status: DealStatus;
|
|
31
61
|
organization: Party | null;
|
|
@@ -36,14 +66,44 @@ export interface Deal extends Reviewed {
|
|
|
36
66
|
closeDate: string | null;
|
|
37
67
|
/** `YYYY-MM-DD`: the day it was won or lost. */
|
|
38
68
|
closedDate: string | null;
|
|
39
|
-
/** Why it was won or lost, as
|
|
69
|
+
/** Why it was won or lost, as given when closing it. */
|
|
40
70
|
closedReason: string | null;
|
|
71
|
+
rank: number | null;
|
|
72
|
+
/** A lead's deal, once it became one. */
|
|
73
|
+
deal: string | null;
|
|
74
|
+
account: {
|
|
75
|
+
provider: string;
|
|
76
|
+
account: string;
|
|
77
|
+
} | null;
|
|
78
|
+
externalId: string | null;
|
|
41
79
|
people: DealPerson[];
|
|
80
|
+
author: {
|
|
81
|
+
type: "person" | "bot";
|
|
82
|
+
id: string;
|
|
83
|
+
name: string | null;
|
|
84
|
+
kind: "agent" | "rule" | null;
|
|
85
|
+
};
|
|
86
|
+
model: string | null;
|
|
87
|
+
source: string;
|
|
88
|
+
reason: string | null;
|
|
89
|
+
evidence: string[];
|
|
90
|
+
project: string | null;
|
|
91
|
+
projectName: string | null;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt: string;
|
|
42
94
|
}
|
|
43
|
-
export interface DealInput
|
|
95
|
+
export interface DealInput {
|
|
96
|
+
/** Who writes it; the owner and an agent write alike, and only the author is kept. */
|
|
97
|
+
by: Author;
|
|
98
|
+
/** `deal` when left out. */
|
|
99
|
+
kind?: DealKind;
|
|
44
100
|
title: string;
|
|
45
|
-
/**
|
|
46
|
-
|
|
101
|
+
/**
|
|
102
|
+
* A stage's name, in `pipeline` when given, else in the only pipeline of the kind that has it. A lead may leave it
|
|
103
|
+
* out when there is one lead pipeline: it starts in that pipeline's first stage.
|
|
104
|
+
*/
|
|
105
|
+
stage?: string;
|
|
106
|
+
/** `pipeline:<id>`, or a name only one pipeline of the kind has. */
|
|
47
107
|
pipeline?: string;
|
|
48
108
|
organization?: string;
|
|
49
109
|
/** A decimal string in `currency`; give both or neither. */
|
|
@@ -54,51 +114,90 @@ export interface DealInput extends Written {
|
|
|
54
114
|
person: string;
|
|
55
115
|
role: DealRole;
|
|
56
116
|
}[];
|
|
117
|
+
project?: string;
|
|
118
|
+
/** Where an agent's row came from, such as `agent`; the owner's is always `owner`. */
|
|
119
|
+
source?: string;
|
|
120
|
+
reason?: string;
|
|
121
|
+
evidence?: string[];
|
|
57
122
|
}
|
|
58
123
|
export interface DealFilter {
|
|
124
|
+
/** `deal` when left out. */
|
|
125
|
+
kind?: DealKind;
|
|
59
126
|
status?: DealStatus;
|
|
60
|
-
/** A stage's
|
|
127
|
+
/** A stage's name, in any letter case. */
|
|
61
128
|
stage?: string;
|
|
129
|
+
/** `pipeline:<id>`, or a name only one pipeline of the kind has. */
|
|
62
130
|
pipeline?: string;
|
|
63
131
|
project?: string;
|
|
64
132
|
organization?: string;
|
|
65
|
-
review?: FinanceReview;
|
|
66
133
|
proposedBy?: ProposedByFilter;
|
|
67
134
|
/** 1–500, 100 by default; newest written first. */
|
|
68
135
|
limit?: number;
|
|
69
136
|
}
|
|
137
|
+
export interface PipelineInput {
|
|
138
|
+
name: string;
|
|
139
|
+
/** `deal` when left out. */
|
|
140
|
+
kind?: DealKind;
|
|
141
|
+
/** In order; a bare name is an open stage. */
|
|
142
|
+
stages: (string | {
|
|
143
|
+
name: string;
|
|
144
|
+
outcome?: StageOutcome;
|
|
145
|
+
})[];
|
|
146
|
+
by: Author;
|
|
147
|
+
}
|
|
70
148
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
149
|
+
* Sales pipelines and the deals and leads in them. The owner and his agents write alike: nothing waits for review,
|
|
150
|
+
* and memo's permission settings are where writes are limited. Every stage a row enters is kept, by triggers, so a
|
|
151
|
+
* pipeline's report counts conversion between stages.
|
|
73
152
|
*/
|
|
74
153
|
export interface DealsStore {
|
|
75
|
-
addPipeline(input:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
154
|
+
addPipeline(input: PipelineInput): Promise<Pipeline>;
|
|
155
|
+
pipelines(filter?: {
|
|
156
|
+
kind?: DealKind;
|
|
157
|
+
}): Promise<Pipeline[]>;
|
|
158
|
+
/** One pipeline by `pipeline:<id>` or a name only one pipeline has, with its funnel. */
|
|
159
|
+
pipeline(reference: string, options?: {
|
|
160
|
+
kind?: DealKind;
|
|
161
|
+
since?: string;
|
|
162
|
+
}): Promise<PipelineReport>;
|
|
81
163
|
add(input: DealInput): Promise<Deal>;
|
|
164
|
+
/** `deal:<id>` or `lead:<id>`; a bare id is a deal. */
|
|
82
165
|
get(reference: string): Promise<Deal>;
|
|
83
166
|
list(filter?: DealFilter): Promise<Deal[]>;
|
|
84
|
-
/** To another stage of
|
|
167
|
+
/** To another stage of its own pipeline; a stage whose outcome is won or lost closes it, an open one reopens it. */
|
|
85
168
|
move(reference: string, input: {
|
|
86
169
|
stage: string;
|
|
87
170
|
by: Author;
|
|
88
171
|
}): Promise<Deal>;
|
|
89
|
-
/** `date`
|
|
172
|
+
/** Won or lost, on `date` (today when left out); it moves to its pipeline's stage of that outcome when there is one. */
|
|
90
173
|
close(reference: string, input: {
|
|
91
174
|
status: Exclude<DealStatus, "open">;
|
|
92
175
|
date?: string;
|
|
93
176
|
reason?: string;
|
|
94
177
|
by: Author;
|
|
95
178
|
}): Promise<Deal>;
|
|
96
|
-
confirm(reference: string, by: Decider, reason?: string): Promise<Deal>;
|
|
97
|
-
reject(reference: string, by: Decider, reason?: string): Promise<Deal>;
|
|
98
179
|
}
|
|
99
|
-
|
|
100
|
-
|
|
180
|
+
export declare const dealOperationsOver: (context: StoreContext) => {
|
|
181
|
+
addPipeline: ({ name, kind, stages, by }: PipelineInput) => Pipeline;
|
|
182
|
+
pipelines: (filter?: {
|
|
183
|
+
kind?: DealKind;
|
|
184
|
+
}) => Pipeline[];
|
|
185
|
+
pipeline: (reference: string, options?: {
|
|
186
|
+
kind?: DealKind;
|
|
187
|
+
since?: string;
|
|
188
|
+
}) => PipelineReport;
|
|
189
|
+
add: (input: DealInput) => Deal;
|
|
190
|
+
get: (reference: string) => Deal;
|
|
191
|
+
list: (filter?: DealFilter) => Deal[];
|
|
192
|
+
move: (reference: string, { stage, by }: {
|
|
193
|
+
stage: string;
|
|
194
|
+
by: Author;
|
|
195
|
+
}) => Deal;
|
|
196
|
+
close: (reference: string, { status, date, reason, by }: {
|
|
197
|
+
status: Exclude<DealStatus, "open">;
|
|
198
|
+
date?: string;
|
|
199
|
+
reason?: string;
|
|
200
|
+
by: Author;
|
|
201
|
+
}) => Deal;
|
|
101
202
|
};
|
|
102
|
-
export declare const dealOperationsOver: (context: StoreContext) => DealOperations;
|
|
103
203
|
export declare const dealsStoreOver: (context: StoreContext) => DealsStore;
|
|
104
|
-
export {};
|