@contractspec/example.crm-pipeline 3.7.17 → 3.7.18
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/.turbo/turbo-build.log +135 -135
- package/CHANGELOG.md +20 -0
- package/dist/browser/crm-pipeline.feature.js +1 -82
- package/dist/browser/deal/deal.enum.js +1 -18
- package/dist/browser/deal/deal.operation.js +1 -396
- package/dist/browser/deal/deal.schema.js +1 -141
- package/dist/browser/deal/deal.test-spec.js +1 -58
- package/dist/browser/deal/index.js +1 -408
- package/dist/browser/docs/crm-pipeline.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/entities/company.entity.js +1 -52
- package/dist/browser/entities/contact.entity.js +1 -66
- package/dist/browser/entities/deal.entity.js +1 -107
- package/dist/browser/entities/index.js +1 -343
- package/dist/browser/entities/task.entity.js +1 -99
- package/dist/browser/events/contact.event.js +1 -31
- package/dist/browser/events/deal.event.js +1 -101
- package/dist/browser/events/index.js +1 -158
- package/dist/browser/events/task.event.js +1 -28
- package/dist/browser/example.js +1 -39
- package/dist/browser/handlers/crm.handlers.js +2 -171
- package/dist/browser/handlers/deal.handlers.js +1 -293
- package/dist/browser/handlers/index.js +2 -467
- package/dist/browser/handlers/mock-data.js +1 -165
- package/dist/browser/index.js +8 -3461
- package/dist/browser/operations/index.js +1 -407
- package/dist/browser/presentations/dashboard.presentation.js +1 -55
- package/dist/browser/presentations/index.js +1 -290
- package/dist/browser/presentations/pipeline.presentation.js +1 -236
- package/dist/browser/seeders/index.js +1 -22
- package/dist/browser/ui/CrmDashboard.js +1 -1547
- package/dist/browser/ui/CrmDealCard.js +1 -50
- package/dist/browser/ui/CrmPipelineBoard.js +1 -160
- package/dist/browser/ui/hooks/index.js +1 -197
- package/dist/browser/ui/hooks/useDealList.js +1 -95
- package/dist/browser/ui/hooks/useDealMutations.js +1 -100
- package/dist/browser/ui/index.js +4 -2205
- package/dist/browser/ui/modals/CreateDealModal.js +1 -211
- package/dist/browser/ui/modals/DealActionsModal.js +1 -428
- package/dist/browser/ui/modals/index.js +1 -638
- package/dist/browser/ui/overlays/demo-overlays.js +1 -55
- package/dist/browser/ui/overlays/index.js +1 -55
- package/dist/browser/ui/renderers/index.js +4 -849
- package/dist/browser/ui/renderers/pipeline.markdown.js +4 -575
- package/dist/browser/ui/renderers/pipeline.renderer.js +1 -275
- package/dist/browser/ui/tables/DealListTab.js +1 -390
- package/dist/crm-pipeline.feature.js +1 -82
- package/dist/deal/deal.enum.js +1 -18
- package/dist/deal/deal.operation.js +1 -396
- package/dist/deal/deal.schema.js +1 -141
- package/dist/deal/deal.test-spec.js +1 -58
- package/dist/deal/index.js +1 -408
- package/dist/docs/crm-pipeline.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/entities/company.entity.js +1 -52
- package/dist/entities/contact.entity.js +1 -66
- package/dist/entities/deal.entity.js +1 -107
- package/dist/entities/index.js +1 -343
- package/dist/entities/task.entity.js +1 -99
- package/dist/events/contact.event.js +1 -31
- package/dist/events/deal.event.js +1 -101
- package/dist/events/index.js +1 -158
- package/dist/events/task.event.js +1 -28
- package/dist/example.js +1 -39
- package/dist/handlers/crm.handlers.js +2 -171
- package/dist/handlers/deal.handlers.js +1 -293
- package/dist/handlers/index.js +2 -467
- package/dist/handlers/mock-data.js +1 -165
- package/dist/index.js +8 -3461
- package/dist/node/crm-pipeline.feature.js +1 -82
- package/dist/node/deal/deal.enum.js +1 -18
- package/dist/node/deal/deal.operation.js +1 -396
- package/dist/node/deal/deal.schema.js +1 -141
- package/dist/node/deal/deal.test-spec.js +1 -58
- package/dist/node/deal/index.js +1 -408
- package/dist/node/docs/crm-pipeline.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/entities/company.entity.js +1 -52
- package/dist/node/entities/contact.entity.js +1 -66
- package/dist/node/entities/deal.entity.js +1 -107
- package/dist/node/entities/index.js +1 -343
- package/dist/node/entities/task.entity.js +1 -99
- package/dist/node/events/contact.event.js +1 -31
- package/dist/node/events/deal.event.js +1 -101
- package/dist/node/events/index.js +1 -158
- package/dist/node/events/task.event.js +1 -28
- package/dist/node/example.js +1 -39
- package/dist/node/handlers/crm.handlers.js +2 -171
- package/dist/node/handlers/deal.handlers.js +1 -293
- package/dist/node/handlers/index.js +2 -467
- package/dist/node/handlers/mock-data.js +1 -165
- package/dist/node/index.js +8 -3461
- package/dist/node/operations/index.js +1 -407
- package/dist/node/presentations/dashboard.presentation.js +1 -55
- package/dist/node/presentations/index.js +1 -290
- package/dist/node/presentations/pipeline.presentation.js +1 -236
- package/dist/node/seeders/index.js +1 -22
- package/dist/node/ui/CrmDashboard.js +1 -1547
- package/dist/node/ui/CrmDealCard.js +1 -50
- package/dist/node/ui/CrmPipelineBoard.js +1 -160
- package/dist/node/ui/hooks/index.js +1 -197
- package/dist/node/ui/hooks/useDealList.js +1 -95
- package/dist/node/ui/hooks/useDealMutations.js +1 -100
- package/dist/node/ui/index.js +4 -2205
- package/dist/node/ui/modals/CreateDealModal.js +1 -211
- package/dist/node/ui/modals/DealActionsModal.js +1 -428
- package/dist/node/ui/modals/index.js +1 -638
- package/dist/node/ui/overlays/demo-overlays.js +1 -55
- package/dist/node/ui/overlays/index.js +1 -55
- package/dist/node/ui/renderers/index.js +4 -849
- package/dist/node/ui/renderers/pipeline.markdown.js +4 -575
- package/dist/node/ui/renderers/pipeline.renderer.js +1 -275
- package/dist/node/ui/tables/DealListTab.js +1 -390
- package/dist/operations/index.js +1 -407
- package/dist/presentations/dashboard.presentation.js +1 -55
- package/dist/presentations/index.js +1 -290
- package/dist/presentations/pipeline.presentation.js +1 -236
- package/dist/seeders/index.js +1 -22
- package/dist/ui/CrmDashboard.js +1 -1547
- package/dist/ui/CrmDealCard.js +1 -50
- package/dist/ui/CrmPipelineBoard.js +1 -160
- package/dist/ui/hooks/index.js +1 -197
- package/dist/ui/hooks/useDealList.js +1 -95
- package/dist/ui/hooks/useDealMutations.js +1 -100
- package/dist/ui/index.js +4 -2205
- package/dist/ui/modals/CreateDealModal.js +1 -211
- package/dist/ui/modals/DealActionsModal.js +1 -428
- package/dist/ui/modals/index.js +1 -638
- package/dist/ui/overlays/demo-overlays.js +1 -55
- package/dist/ui/overlays/index.js +1 -55
- package/dist/ui/renderers/index.js +4 -849
- package/dist/ui/renderers/pipeline.markdown.js +4 -575
- package/dist/ui/renderers/pipeline.renderer.js +1 -275
- package/dist/ui/tables/DealListTab.js +1 -390
- package/package.json +13 -13
|
@@ -1,293 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var MOCK_STAGES = [
|
|
3
|
-
{ id: "stage-1", name: "Lead", position: 1, pipelineId: "pipeline-1" },
|
|
4
|
-
{ id: "stage-2", name: "Qualified", position: 2, pipelineId: "pipeline-1" },
|
|
5
|
-
{ id: "stage-3", name: "Proposal", position: 3, pipelineId: "pipeline-1" },
|
|
6
|
-
{ id: "stage-4", name: "Negotiation", position: 4, pipelineId: "pipeline-1" },
|
|
7
|
-
{ id: "stage-5", name: "Closed", position: 5, pipelineId: "pipeline-1" }
|
|
8
|
-
];
|
|
9
|
-
var MOCK_DEALS = [
|
|
10
|
-
{
|
|
11
|
-
id: "deal-1",
|
|
12
|
-
name: "Enterprise License - Acme Corp",
|
|
13
|
-
value: 75000,
|
|
14
|
-
currency: "USD",
|
|
15
|
-
pipelineId: "pipeline-1",
|
|
16
|
-
stageId: "stage-3",
|
|
17
|
-
status: "OPEN",
|
|
18
|
-
contactId: "contact-1",
|
|
19
|
-
companyId: "company-1",
|
|
20
|
-
ownerId: "user-1",
|
|
21
|
-
expectedCloseDate: new Date("2024-05-15T00:00:00Z"),
|
|
22
|
-
createdAt: new Date("2024-02-01T10:00:00Z"),
|
|
23
|
-
updatedAt: new Date("2024-04-10T14:30:00Z")
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
id: "deal-2",
|
|
27
|
-
name: "Startup Plan - TechStart Inc",
|
|
28
|
-
value: 12000,
|
|
29
|
-
currency: "USD",
|
|
30
|
-
pipelineId: "pipeline-1",
|
|
31
|
-
stageId: "stage-2",
|
|
32
|
-
status: "OPEN",
|
|
33
|
-
contactId: "contact-2",
|
|
34
|
-
companyId: "company-2",
|
|
35
|
-
ownerId: "user-2",
|
|
36
|
-
expectedCloseDate: new Date("2024-04-30T00:00:00Z"),
|
|
37
|
-
createdAt: new Date("2024-03-15T09:00:00Z"),
|
|
38
|
-
updatedAt: new Date("2024-04-08T11:15:00Z")
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: "deal-3",
|
|
42
|
-
name: "Professional Services - Global Ltd",
|
|
43
|
-
value: 45000,
|
|
44
|
-
currency: "USD",
|
|
45
|
-
pipelineId: "pipeline-1",
|
|
46
|
-
stageId: "stage-4",
|
|
47
|
-
status: "OPEN",
|
|
48
|
-
contactId: "contact-3",
|
|
49
|
-
companyId: "company-3",
|
|
50
|
-
ownerId: "user-1",
|
|
51
|
-
expectedCloseDate: new Date("2024-04-20T00:00:00Z"),
|
|
52
|
-
createdAt: new Date("2024-01-20T08:00:00Z"),
|
|
53
|
-
updatedAt: new Date("2024-04-12T16:45:00Z")
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: "deal-4",
|
|
57
|
-
name: "Annual Contract - SmallBiz Co",
|
|
58
|
-
value: 8500,
|
|
59
|
-
currency: "USD",
|
|
60
|
-
pipelineId: "pipeline-1",
|
|
61
|
-
stageId: "stage-1",
|
|
62
|
-
status: "OPEN",
|
|
63
|
-
contactId: "contact-4",
|
|
64
|
-
companyId: "company-4",
|
|
65
|
-
ownerId: "user-3",
|
|
66
|
-
createdAt: new Date("2024-04-05T12:00:00Z"),
|
|
67
|
-
updatedAt: new Date("2024-04-05T12:00:00Z")
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: "deal-5",
|
|
71
|
-
name: "Custom Integration - MegaCorp",
|
|
72
|
-
value: 125000,
|
|
73
|
-
currency: "USD",
|
|
74
|
-
pipelineId: "pipeline-1",
|
|
75
|
-
stageId: "stage-5",
|
|
76
|
-
status: "WON",
|
|
77
|
-
contactId: "contact-5",
|
|
78
|
-
companyId: "company-5",
|
|
79
|
-
ownerId: "user-1",
|
|
80
|
-
expectedCloseDate: new Date("2024-03-31T00:00:00Z"),
|
|
81
|
-
createdAt: new Date("2023-11-10T10:00:00Z"),
|
|
82
|
-
updatedAt: new Date("2024-03-28T09:00:00Z")
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "deal-6",
|
|
86
|
-
name: "Pilot Project - NewCo",
|
|
87
|
-
value: 5000,
|
|
88
|
-
currency: "USD",
|
|
89
|
-
pipelineId: "pipeline-1",
|
|
90
|
-
stageId: "stage-2",
|
|
91
|
-
status: "LOST",
|
|
92
|
-
contactId: "contact-6",
|
|
93
|
-
companyId: "company-6",
|
|
94
|
-
ownerId: "user-2",
|
|
95
|
-
createdAt: new Date("2024-01-15T14:00:00Z"),
|
|
96
|
-
updatedAt: new Date("2024-02-28T10:30:00Z")
|
|
97
|
-
}
|
|
98
|
-
];
|
|
99
|
-
var MOCK_COMPANIES = [
|
|
100
|
-
{
|
|
101
|
-
id: "company-1",
|
|
102
|
-
name: "Acme Corporation",
|
|
103
|
-
domain: "acme.com",
|
|
104
|
-
industry: "Technology",
|
|
105
|
-
size: "1000-5000",
|
|
106
|
-
website: "https://acme.com",
|
|
107
|
-
createdAt: new Date("2024-01-01T00:00:00Z")
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
id: "company-2",
|
|
111
|
-
name: "TechStart Inc",
|
|
112
|
-
domain: "techstart.io",
|
|
113
|
-
industry: "Software",
|
|
114
|
-
size: "10-50",
|
|
115
|
-
website: "https://techstart.io",
|
|
116
|
-
createdAt: new Date("2024-02-15T00:00:00Z")
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
id: "company-3",
|
|
120
|
-
name: "Global Ltd",
|
|
121
|
-
domain: "global.com",
|
|
122
|
-
industry: "Consulting",
|
|
123
|
-
size: "500-1000",
|
|
124
|
-
website: "https://global.com",
|
|
125
|
-
createdAt: new Date("2023-12-01T00:00:00Z")
|
|
126
|
-
}
|
|
127
|
-
];
|
|
128
|
-
var MOCK_CONTACTS = [
|
|
129
|
-
{
|
|
130
|
-
id: "contact-1",
|
|
131
|
-
firstName: "John",
|
|
132
|
-
lastName: "Smith",
|
|
133
|
-
email: "john.smith@acme.com",
|
|
134
|
-
phone: "+1-555-0101",
|
|
135
|
-
title: "VP of Engineering",
|
|
136
|
-
companyId: "company-1",
|
|
137
|
-
createdAt: new Date("2024-01-05T00:00:00Z")
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: "contact-2",
|
|
141
|
-
firstName: "Sarah",
|
|
142
|
-
lastName: "Johnson",
|
|
143
|
-
email: "sarah@techstart.io",
|
|
144
|
-
phone: "+1-555-0102",
|
|
145
|
-
title: "CEO",
|
|
146
|
-
companyId: "company-2",
|
|
147
|
-
createdAt: new Date("2024-02-20T00:00:00Z")
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
id: "contact-3",
|
|
151
|
-
firstName: "Michael",
|
|
152
|
-
lastName: "Brown",
|
|
153
|
-
email: "michael.brown@global.com",
|
|
154
|
-
phone: "+1-555-0103",
|
|
155
|
-
title: "CTO",
|
|
156
|
-
companyId: "company-3",
|
|
157
|
-
createdAt: new Date("2023-12-10T00:00:00Z")
|
|
158
|
-
}
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
// src/handlers/deal.handlers.ts
|
|
162
|
-
async function mockListDealsHandler(input) {
|
|
163
|
-
const {
|
|
164
|
-
pipelineId,
|
|
165
|
-
stageId,
|
|
166
|
-
status,
|
|
167
|
-
ownerId,
|
|
168
|
-
search,
|
|
169
|
-
limit = 20,
|
|
170
|
-
offset = 0
|
|
171
|
-
} = input;
|
|
172
|
-
let filtered = [...MOCK_DEALS];
|
|
173
|
-
if (pipelineId) {
|
|
174
|
-
filtered = filtered.filter((d) => d.pipelineId === pipelineId);
|
|
175
|
-
}
|
|
176
|
-
if (stageId) {
|
|
177
|
-
filtered = filtered.filter((d) => d.stageId === stageId);
|
|
178
|
-
}
|
|
179
|
-
if (status && status !== "all") {
|
|
180
|
-
filtered = filtered.filter((d) => d.status === status);
|
|
181
|
-
}
|
|
182
|
-
if (ownerId) {
|
|
183
|
-
filtered = filtered.filter((d) => d.ownerId === ownerId);
|
|
184
|
-
}
|
|
185
|
-
if (search) {
|
|
186
|
-
const q = search.toLowerCase();
|
|
187
|
-
filtered = filtered.filter((d) => d.name.toLowerCase().includes(q));
|
|
188
|
-
}
|
|
189
|
-
filtered.sort((a, b) => b.value - a.value);
|
|
190
|
-
const total = filtered.length;
|
|
191
|
-
const totalValue = filtered.reduce((sum, d) => sum + d.value, 0);
|
|
192
|
-
const deals = filtered.slice(offset, offset + limit);
|
|
193
|
-
return {
|
|
194
|
-
deals,
|
|
195
|
-
total,
|
|
196
|
-
totalValue
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
async function mockCreateDealHandler(input, context) {
|
|
200
|
-
const now = new Date;
|
|
201
|
-
const deal = {
|
|
202
|
-
id: `deal-${Date.now()}`,
|
|
203
|
-
name: input.name,
|
|
204
|
-
value: input.value,
|
|
205
|
-
currency: input.currency ?? "USD",
|
|
206
|
-
pipelineId: input.pipelineId,
|
|
207
|
-
stageId: input.stageId,
|
|
208
|
-
status: "OPEN",
|
|
209
|
-
contactId: input.contactId,
|
|
210
|
-
companyId: input.companyId,
|
|
211
|
-
ownerId: context.ownerId,
|
|
212
|
-
expectedCloseDate: input.expectedCloseDate,
|
|
213
|
-
createdAt: now,
|
|
214
|
-
updatedAt: now
|
|
215
|
-
};
|
|
216
|
-
MOCK_DEALS.push(deal);
|
|
217
|
-
return deal;
|
|
218
|
-
}
|
|
219
|
-
async function mockMoveDealHandler(input) {
|
|
220
|
-
const dealIndex = MOCK_DEALS.findIndex((d) => d.id === input.dealId);
|
|
221
|
-
if (dealIndex === -1) {
|
|
222
|
-
throw new Error("NOT_FOUND");
|
|
223
|
-
}
|
|
224
|
-
const deal = MOCK_DEALS[dealIndex];
|
|
225
|
-
if (!deal) {
|
|
226
|
-
throw new Error("NOT_FOUND");
|
|
227
|
-
}
|
|
228
|
-
const stage = MOCK_STAGES.find((s) => s.id === input.stageId);
|
|
229
|
-
if (!stage) {
|
|
230
|
-
throw new Error("INVALID_STAGE");
|
|
231
|
-
}
|
|
232
|
-
const updatedDeal = {
|
|
233
|
-
...deal,
|
|
234
|
-
stageId: input.stageId,
|
|
235
|
-
updatedAt: new Date
|
|
236
|
-
};
|
|
237
|
-
MOCK_DEALS[dealIndex] = updatedDeal;
|
|
238
|
-
return updatedDeal;
|
|
239
|
-
}
|
|
240
|
-
async function mockWinDealHandler(input) {
|
|
241
|
-
const dealIndex = MOCK_DEALS.findIndex((d) => d.id === input.dealId);
|
|
242
|
-
if (dealIndex === -1) {
|
|
243
|
-
throw new Error("NOT_FOUND");
|
|
244
|
-
}
|
|
245
|
-
const deal = MOCK_DEALS[dealIndex];
|
|
246
|
-
if (!deal) {
|
|
247
|
-
throw new Error("NOT_FOUND");
|
|
248
|
-
}
|
|
249
|
-
const updatedDeal = {
|
|
250
|
-
...deal,
|
|
251
|
-
status: "WON",
|
|
252
|
-
updatedAt: new Date
|
|
253
|
-
};
|
|
254
|
-
MOCK_DEALS[dealIndex] = updatedDeal;
|
|
255
|
-
return updatedDeal;
|
|
256
|
-
}
|
|
257
|
-
async function mockLoseDealHandler(input) {
|
|
258
|
-
const dealIndex = MOCK_DEALS.findIndex((d) => d.id === input.dealId);
|
|
259
|
-
if (dealIndex === -1) {
|
|
260
|
-
throw new Error("NOT_FOUND");
|
|
261
|
-
}
|
|
262
|
-
const deal = MOCK_DEALS[dealIndex];
|
|
263
|
-
if (!deal) {
|
|
264
|
-
throw new Error("NOT_FOUND");
|
|
265
|
-
}
|
|
266
|
-
const updatedDeal = {
|
|
267
|
-
...deal,
|
|
268
|
-
status: "LOST",
|
|
269
|
-
updatedAt: new Date
|
|
270
|
-
};
|
|
271
|
-
MOCK_DEALS[dealIndex] = updatedDeal;
|
|
272
|
-
return updatedDeal;
|
|
273
|
-
}
|
|
274
|
-
async function mockGetDealsByStageHandler(input) {
|
|
275
|
-
const deals = MOCK_DEALS.filter((d) => d.pipelineId === input.pipelineId && d.status === "OPEN");
|
|
276
|
-
const grouped = {};
|
|
277
|
-
for (const stage of MOCK_STAGES) {
|
|
278
|
-
grouped[stage.id] = deals.filter((d) => d.stageId === stage.id);
|
|
279
|
-
}
|
|
280
|
-
return grouped;
|
|
281
|
-
}
|
|
282
|
-
async function mockGetPipelineStagesHandler(input) {
|
|
283
|
-
return MOCK_STAGES.filter((s) => s.pipelineId === input.pipelineId);
|
|
284
|
-
}
|
|
285
|
-
export {
|
|
286
|
-
mockWinDealHandler,
|
|
287
|
-
mockMoveDealHandler,
|
|
288
|
-
mockLoseDealHandler,
|
|
289
|
-
mockListDealsHandler,
|
|
290
|
-
mockGetPipelineStagesHandler,
|
|
291
|
-
mockGetDealsByStageHandler,
|
|
292
|
-
mockCreateDealHandler
|
|
293
|
-
};
|
|
1
|
+
var U=[{id:"stage-1",name:"Lead",position:1,pipelineId:"pipeline-1"},{id:"stage-2",name:"Qualified",position:2,pipelineId:"pipeline-1"},{id:"stage-3",name:"Proposal",position:3,pipelineId:"pipeline-1"},{id:"stage-4",name:"Negotiation",position:4,pipelineId:"pipeline-1"},{id:"stage-5",name:"Closed",position:5,pipelineId:"pipeline-1"}],N=[{id:"deal-1",name:"Enterprise License - Acme Corp",value:75000,currency:"USD",pipelineId:"pipeline-1",stageId:"stage-3",status:"OPEN",contactId:"contact-1",companyId:"company-1",ownerId:"user-1",expectedCloseDate:new Date("2024-05-15T00:00:00Z"),createdAt:new Date("2024-02-01T10:00:00Z"),updatedAt:new Date("2024-04-10T14:30:00Z")},{id:"deal-2",name:"Startup Plan - TechStart Inc",value:12000,currency:"USD",pipelineId:"pipeline-1",stageId:"stage-2",status:"OPEN",contactId:"contact-2",companyId:"company-2",ownerId:"user-2",expectedCloseDate:new Date("2024-04-30T00:00:00Z"),createdAt:new Date("2024-03-15T09:00:00Z"),updatedAt:new Date("2024-04-08T11:15:00Z")},{id:"deal-3",name:"Professional Services - Global Ltd",value:45000,currency:"USD",pipelineId:"pipeline-1",stageId:"stage-4",status:"OPEN",contactId:"contact-3",companyId:"company-3",ownerId:"user-1",expectedCloseDate:new Date("2024-04-20T00:00:00Z"),createdAt:new Date("2024-01-20T08:00:00Z"),updatedAt:new Date("2024-04-12T16:45:00Z")},{id:"deal-4",name:"Annual Contract - SmallBiz Co",value:8500,currency:"USD",pipelineId:"pipeline-1",stageId:"stage-1",status:"OPEN",contactId:"contact-4",companyId:"company-4",ownerId:"user-3",createdAt:new Date("2024-04-05T12:00:00Z"),updatedAt:new Date("2024-04-05T12:00:00Z")},{id:"deal-5",name:"Custom Integration - MegaCorp",value:125000,currency:"USD",pipelineId:"pipeline-1",stageId:"stage-5",status:"WON",contactId:"contact-5",companyId:"company-5",ownerId:"user-1",expectedCloseDate:new Date("2024-03-31T00:00:00Z"),createdAt:new Date("2023-11-10T10:00:00Z"),updatedAt:new Date("2024-03-28T09:00:00Z")},{id:"deal-6",name:"Pilot Project - NewCo",value:5000,currency:"USD",pipelineId:"pipeline-1",stageId:"stage-2",status:"LOST",contactId:"contact-6",companyId:"company-6",ownerId:"user-2",createdAt:new Date("2024-01-15T14:00:00Z"),updatedAt:new Date("2024-02-28T10:30:00Z")}],q=[{id:"company-1",name:"Acme Corporation",domain:"acme.com",industry:"Technology",size:"1000-5000",website:"https://acme.com",createdAt:new Date("2024-01-01T00:00:00Z")},{id:"company-2",name:"TechStart Inc",domain:"techstart.io",industry:"Software",size:"10-50",website:"https://techstart.io",createdAt:new Date("2024-02-15T00:00:00Z")},{id:"company-3",name:"Global Ltd",domain:"global.com",industry:"Consulting",size:"500-1000",website:"https://global.com",createdAt:new Date("2023-12-01T00:00:00Z")}],v=[{id:"contact-1",firstName:"John",lastName:"Smith",email:"john.smith@acme.com",phone:"+1-555-0101",title:"VP of Engineering",companyId:"company-1",createdAt:new Date("2024-01-05T00:00:00Z")},{id:"contact-2",firstName:"Sarah",lastName:"Johnson",email:"sarah@techstart.io",phone:"+1-555-0102",title:"CEO",companyId:"company-2",createdAt:new Date("2024-02-20T00:00:00Z")},{id:"contact-3",firstName:"Michael",lastName:"Brown",email:"michael.brown@global.com",phone:"+1-555-0103",title:"CTO",companyId:"company-3",createdAt:new Date("2023-12-10T00:00:00Z")}];async function h(j){let{pipelineId:z,stageId:F,status:B,ownerId:P,search:Q,limit:X=20,offset:W=0}=j,H=[...N];if(z)H=H.filter((J)=>J.pipelineId===z);if(F)H=H.filter((J)=>J.stageId===F);if(B&&B!=="all")H=H.filter((J)=>J.status===B);if(P)H=H.filter((J)=>J.ownerId===P);if(Q){let J=Q.toLowerCase();H=H.filter((R)=>R.name.toLowerCase().includes(J))}H.sort((J,R)=>R.value-J.value);let Y=H.length,Z=H.reduce((J,R)=>J+R.value,0);return{deals:H.slice(W,W+X),total:Y,totalValue:Z}}async function k(j,z){let F=new Date,B={id:`deal-${Date.now()}`,name:j.name,value:j.value,currency:j.currency??"USD",pipelineId:j.pipelineId,stageId:j.stageId,status:"OPEN",contactId:j.contactId,companyId:j.companyId,ownerId:z.ownerId,expectedCloseDate:j.expectedCloseDate,createdAt:F,updatedAt:F};return N.push(B),B}async function T(j){let z=N.findIndex((Q)=>Q.id===j.dealId);if(z===-1)throw Error("NOT_FOUND");let F=N[z];if(!F)throw Error("NOT_FOUND");if(!U.find((Q)=>Q.id===j.stageId))throw Error("INVALID_STAGE");let P={...F,stageId:j.stageId,updatedAt:new Date};return N[z]=P,P}async function b(j){let z=N.findIndex((P)=>P.id===j.dealId);if(z===-1)throw Error("NOT_FOUND");let F=N[z];if(!F)throw Error("NOT_FOUND");let B={...F,status:"WON",updatedAt:new Date};return N[z]=B,B}async function m(j){let z=N.findIndex((P)=>P.id===j.dealId);if(z===-1)throw Error("NOT_FOUND");let F=N[z];if(!F)throw Error("NOT_FOUND");let B={...F,status:"LOST",updatedAt:new Date};return N[z]=B,B}async function w(j){let z=N.filter((B)=>B.pipelineId===j.pipelineId&&B.status==="OPEN"),F={};for(let B of U)F[B.id]=z.filter((P)=>P.stageId===B.id);return F}async function G(j){return U.filter((z)=>z.pipelineId===j.pipelineId)}export{b as mockWinDealHandler,T as mockMoveDealHandler,m as mockLoseDealHandler,h as mockListDealsHandler,G as mockGetPipelineStagesHandler,w as mockGetDealsByStageHandler,k as mockCreateDealHandler};
|