@contractspec/example.crm-pipeline 1.57.0 → 1.59.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.
Files changed (259) hide show
  1. package/.turbo/turbo-build.log +148 -164
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +39 -0
  4. package/dist/browser/crm-pipeline.feature.js +75 -0
  5. package/dist/browser/deal/deal.enum.js +18 -0
  6. package/dist/browser/deal/deal.operation.js +396 -0
  7. package/dist/browser/deal/deal.schema.js +141 -0
  8. package/dist/browser/deal/deal.test-spec.js +58 -0
  9. package/dist/browser/deal/index.js +408 -0
  10. package/dist/browser/docs/crm-pipeline.docblock.js +113 -0
  11. package/dist/browser/docs/index.js +113 -0
  12. package/dist/browser/entities/company.entity.js +52 -0
  13. package/dist/browser/entities/contact.entity.js +66 -0
  14. package/dist/browser/entities/deal.entity.js +107 -0
  15. package/dist/browser/entities/index.js +343 -0
  16. package/dist/browser/entities/task.entity.js +99 -0
  17. package/dist/browser/events/contact.event.js +31 -0
  18. package/dist/browser/events/deal.event.js +101 -0
  19. package/dist/browser/events/index.js +158 -0
  20. package/dist/browser/events/task.event.js +28 -0
  21. package/dist/browser/example.js +39 -0
  22. package/dist/browser/handlers/crm.handlers.js +160 -0
  23. package/dist/browser/handlers/deal.handlers.js +293 -0
  24. package/dist/browser/handlers/index.js +456 -0
  25. package/dist/browser/handlers/mock-data.js +165 -0
  26. package/dist/browser/index.js +3279 -0
  27. package/dist/browser/operations/index.js +407 -0
  28. package/dist/browser/presentations/dashboard.presentation.js +52 -0
  29. package/dist/browser/presentations/index.js +284 -0
  30. package/dist/browser/presentations/pipeline.presentation.js +233 -0
  31. package/dist/browser/seeders/index.js +22 -0
  32. package/dist/browser/shared/overlay-types.js +0 -0
  33. package/dist/browser/ui/CrmDashboard.js +1325 -0
  34. package/dist/browser/ui/CrmDealCard.js +50 -0
  35. package/dist/browser/ui/CrmPipelineBoard.js +160 -0
  36. package/dist/browser/ui/hooks/index.js +186 -0
  37. package/dist/browser/ui/hooks/useDealList.js +84 -0
  38. package/dist/browser/ui/hooks/useDealMutations.js +100 -0
  39. package/dist/browser/ui/index.js +1972 -0
  40. package/dist/browser/ui/modals/CreateDealModal.js +211 -0
  41. package/dist/browser/ui/modals/DealActionsModal.js +428 -0
  42. package/dist/browser/ui/modals/index.js +638 -0
  43. package/dist/browser/ui/overlays/demo-overlays.js +55 -0
  44. package/dist/browser/ui/overlays/index.js +55 -0
  45. package/dist/browser/ui/renderers/index.js +827 -0
  46. package/dist/browser/ui/renderers/pipeline.markdown.js +564 -0
  47. package/dist/browser/ui/renderers/pipeline.renderer.js +264 -0
  48. package/dist/crm-pipeline.feature.d.ts +1 -6
  49. package/dist/crm-pipeline.feature.d.ts.map +1 -1
  50. package/dist/crm-pipeline.feature.js +74 -164
  51. package/dist/deal/deal.enum.d.ts +2 -7
  52. package/dist/deal/deal.enum.d.ts.map +1 -1
  53. package/dist/deal/deal.enum.js +16 -22
  54. package/dist/deal/deal.operation.d.ts +444 -450
  55. package/dist/deal/deal.operation.d.ts.map +1 -1
  56. package/dist/deal/deal.operation.js +390 -263
  57. package/dist/deal/deal.schema.d.ts +251 -256
  58. package/dist/deal/deal.schema.d.ts.map +1 -1
  59. package/dist/deal/deal.schema.js +131 -275
  60. package/dist/deal/deal.test-spec.d.ts +2 -7
  61. package/dist/deal/deal.test-spec.d.ts.map +1 -1
  62. package/dist/deal/deal.test-spec.js +56 -62
  63. package/dist/deal/index.d.ts +7 -4
  64. package/dist/deal/index.d.ts.map +1 -0
  65. package/dist/deal/index.js +408 -4
  66. package/dist/docs/crm-pipeline.docblock.d.ts +2 -1
  67. package/dist/docs/crm-pipeline.docblock.d.ts.map +1 -0
  68. package/dist/docs/crm-pipeline.docblock.js +45 -51
  69. package/dist/docs/index.d.ts +2 -1
  70. package/dist/docs/index.d.ts.map +1 -0
  71. package/dist/docs/index.js +114 -1
  72. package/dist/entities/company.entity.d.ts +27 -32
  73. package/dist/entities/company.entity.d.ts.map +1 -1
  74. package/dist/entities/company.entity.js +51 -61
  75. package/dist/entities/contact.entity.d.ts +31 -36
  76. package/dist/entities/contact.entity.d.ts.map +1 -1
  77. package/dist/entities/contact.entity.js +65 -76
  78. package/dist/entities/deal.entity.d.ts +52 -57
  79. package/dist/entities/deal.entity.d.ts.map +1 -1
  80. package/dist/entities/deal.entity.js +104 -116
  81. package/dist/entities/index.d.ts +6 -10
  82. package/dist/entities/index.d.ts.map +1 -1
  83. package/dist/entities/index.js +342 -31
  84. package/dist/entities/task.entity.d.ts +42 -47
  85. package/dist/entities/task.entity.d.ts.map +1 -1
  86. package/dist/entities/task.entity.js +95 -124
  87. package/dist/events/contact.event.d.ts +21 -27
  88. package/dist/events/contact.event.d.ts.map +1 -1
  89. package/dist/events/contact.event.js +29 -42
  90. package/dist/events/deal.event.d.ts +100 -106
  91. package/dist/events/deal.event.d.ts.map +1 -1
  92. package/dist/events/deal.event.js +93 -163
  93. package/dist/events/index.d.ts +4 -4
  94. package/dist/events/index.d.ts.map +1 -0
  95. package/dist/events/index.js +158 -4
  96. package/dist/events/task.event.d.ts +21 -27
  97. package/dist/events/task.event.d.ts.map +1 -1
  98. package/dist/events/task.event.js +26 -42
  99. package/dist/example.d.ts +2 -6
  100. package/dist/example.d.ts.map +1 -1
  101. package/dist/example.js +38 -50
  102. package/dist/handlers/crm.handlers.d.ts +80 -78
  103. package/dist/handlers/crm.handlers.d.ts.map +1 -1
  104. package/dist/handlers/crm.handlers.js +155 -166
  105. package/dist/handlers/deal.handlers.d.ts +58 -63
  106. package/dist/handlers/deal.handlers.d.ts.map +1 -1
  107. package/dist/handlers/deal.handlers.js +279 -105
  108. package/dist/handlers/index.d.ts +10 -4
  109. package/dist/handlers/index.d.ts.map +1 -0
  110. package/dist/handlers/index.js +456 -4
  111. package/dist/handlers/mock-data.d.ts +38 -41
  112. package/dist/handlers/mock-data.d.ts.map +1 -1
  113. package/dist/handlers/mock-data.js +162 -184
  114. package/dist/index.d.ts +13 -42
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +3277 -53
  117. package/dist/node/crm-pipeline.feature.js +75 -0
  118. package/dist/node/deal/deal.enum.js +18 -0
  119. package/dist/node/deal/deal.operation.js +396 -0
  120. package/dist/node/deal/deal.schema.js +141 -0
  121. package/dist/node/deal/deal.test-spec.js +58 -0
  122. package/dist/node/deal/index.js +408 -0
  123. package/dist/node/docs/crm-pipeline.docblock.js +113 -0
  124. package/dist/node/docs/index.js +113 -0
  125. package/dist/node/entities/company.entity.js +52 -0
  126. package/dist/node/entities/contact.entity.js +66 -0
  127. package/dist/node/entities/deal.entity.js +107 -0
  128. package/dist/node/entities/index.js +343 -0
  129. package/dist/node/entities/task.entity.js +99 -0
  130. package/dist/node/events/contact.event.js +31 -0
  131. package/dist/node/events/deal.event.js +101 -0
  132. package/dist/node/events/index.js +158 -0
  133. package/dist/node/events/task.event.js +28 -0
  134. package/dist/node/example.js +39 -0
  135. package/dist/node/handlers/crm.handlers.js +160 -0
  136. package/dist/node/handlers/deal.handlers.js +293 -0
  137. package/dist/node/handlers/index.js +456 -0
  138. package/dist/node/handlers/mock-data.js +165 -0
  139. package/dist/node/index.js +3279 -0
  140. package/dist/node/operations/index.js +407 -0
  141. package/dist/node/presentations/dashboard.presentation.js +52 -0
  142. package/dist/node/presentations/index.js +284 -0
  143. package/dist/node/presentations/pipeline.presentation.js +233 -0
  144. package/dist/node/seeders/index.js +22 -0
  145. package/dist/node/shared/overlay-types.js +0 -0
  146. package/dist/node/ui/CrmDashboard.js +1325 -0
  147. package/dist/node/ui/CrmDealCard.js +50 -0
  148. package/dist/node/ui/CrmPipelineBoard.js +160 -0
  149. package/dist/node/ui/hooks/index.js +186 -0
  150. package/dist/node/ui/hooks/useDealList.js +84 -0
  151. package/dist/node/ui/hooks/useDealMutations.js +100 -0
  152. package/dist/node/ui/index.js +1972 -0
  153. package/dist/node/ui/modals/CreateDealModal.js +211 -0
  154. package/dist/node/ui/modals/DealActionsModal.js +428 -0
  155. package/dist/node/ui/modals/index.js +638 -0
  156. package/dist/node/ui/overlays/demo-overlays.js +55 -0
  157. package/dist/node/ui/overlays/index.js +55 -0
  158. package/dist/node/ui/renderers/index.js +827 -0
  159. package/dist/node/ui/renderers/pipeline.markdown.js +564 -0
  160. package/dist/node/ui/renderers/pipeline.renderer.js +264 -0
  161. package/dist/operations/index.d.ts +2 -5
  162. package/dist/operations/index.d.ts.map +1 -0
  163. package/dist/operations/index.js +407 -5
  164. package/dist/presentations/dashboard.presentation.d.ts +2 -7
  165. package/dist/presentations/dashboard.presentation.d.ts.map +1 -1
  166. package/dist/presentations/dashboard.presentation.js +51 -60
  167. package/dist/presentations/index.d.ts +3 -3
  168. package/dist/presentations/index.d.ts.map +1 -0
  169. package/dist/presentations/index.js +284 -3
  170. package/dist/presentations/pipeline.presentation.d.ts +4 -9
  171. package/dist/presentations/pipeline.presentation.d.ts.map +1 -1
  172. package/dist/presentations/pipeline.presentation.js +228 -116
  173. package/dist/seeders/index.d.ts +4 -8
  174. package/dist/seeders/index.d.ts.map +1 -1
  175. package/dist/seeders/index.js +21 -45
  176. package/dist/shared/overlay-types.d.ts +25 -28
  177. package/dist/shared/overlay-types.d.ts.map +1 -1
  178. package/dist/shared/overlay-types.js +1 -0
  179. package/dist/ui/CrmDashboard.d.ts +1 -6
  180. package/dist/ui/CrmDashboard.d.ts.map +1 -1
  181. package/dist/ui/CrmDashboard.js +1318 -296
  182. package/dist/ui/CrmDealCard.d.ts +8 -12
  183. package/dist/ui/CrmDealCard.d.ts.map +1 -1
  184. package/dist/ui/CrmDealCard.js +47 -45
  185. package/dist/ui/CrmPipelineBoard.d.ts +11 -20
  186. package/dist/ui/CrmPipelineBoard.d.ts.map +1 -1
  187. package/dist/ui/CrmPipelineBoard.js +157 -94
  188. package/dist/ui/hooks/index.d.ts +3 -3
  189. package/dist/ui/hooks/index.d.ts.map +1 -0
  190. package/dist/ui/hooks/index.js +185 -4
  191. package/dist/ui/hooks/useDealList.d.ts +28 -32
  192. package/dist/ui/hooks/useDealList.d.ts.map +1 -1
  193. package/dist/ui/hooks/useDealList.js +81 -90
  194. package/dist/ui/hooks/useDealMutations.d.ts +18 -22
  195. package/dist/ui/hooks/useDealMutations.d.ts.map +1 -1
  196. package/dist/ui/hooks/useDealMutations.js +97 -155
  197. package/dist/ui/index.d.ts +8 -14
  198. package/dist/ui/index.d.ts.map +1 -0
  199. package/dist/ui/index.js +1973 -15
  200. package/dist/ui/modals/CreateDealModal.d.ts +19 -29
  201. package/dist/ui/modals/CreateDealModal.d.ts.map +1 -1
  202. package/dist/ui/modals/CreateDealModal.js +209 -180
  203. package/dist/ui/modals/DealActionsModal.d.ts +31 -44
  204. package/dist/ui/modals/DealActionsModal.d.ts.map +1 -1
  205. package/dist/ui/modals/DealActionsModal.js +424 -367
  206. package/dist/ui/modals/index.d.ts +3 -3
  207. package/dist/ui/modals/index.d.ts.map +1 -0
  208. package/dist/ui/modals/index.js +638 -3
  209. package/dist/ui/overlays/demo-overlays.d.ts +10 -8
  210. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
  211. package/dist/ui/overlays/demo-overlays.js +54 -66
  212. package/dist/ui/overlays/index.d.ts +2 -2
  213. package/dist/ui/overlays/index.d.ts.map +1 -0
  214. package/dist/ui/overlays/index.js +56 -3
  215. package/dist/ui/renderers/index.d.ts +3 -3
  216. package/dist/ui/renderers/index.d.ts.map +1 -0
  217. package/dist/ui/renderers/index.js +827 -3
  218. package/dist/ui/renderers/pipeline.markdown.d.ts +12 -11
  219. package/dist/ui/renderers/pipeline.markdown.d.ts.map +1 -1
  220. package/dist/ui/renderers/pipeline.markdown.js +560 -114
  221. package/dist/ui/renderers/pipeline.renderer.d.ts +9 -7
  222. package/dist/ui/renderers/pipeline.renderer.d.ts.map +1 -1
  223. package/dist/ui/renderers/pipeline.renderer.js +261 -24
  224. package/package.json +476 -90
  225. package/tsdown.config.js +1 -2
  226. package/.turbo/turbo-build$colon$bundle.log +0 -164
  227. package/dist/crm-pipeline.feature.js.map +0 -1
  228. package/dist/deal/deal.enum.js.map +0 -1
  229. package/dist/deal/deal.operation.js.map +0 -1
  230. package/dist/deal/deal.schema.js.map +0 -1
  231. package/dist/deal/deal.test-spec.js.map +0 -1
  232. package/dist/docs/crm-pipeline.docblock.js.map +0 -1
  233. package/dist/entities/company.entity.js.map +0 -1
  234. package/dist/entities/contact.entity.js.map +0 -1
  235. package/dist/entities/deal.entity.js.map +0 -1
  236. package/dist/entities/index.js.map +0 -1
  237. package/dist/entities/task.entity.js.map +0 -1
  238. package/dist/events/contact.event.js.map +0 -1
  239. package/dist/events/deal.event.js.map +0 -1
  240. package/dist/events/task.event.js.map +0 -1
  241. package/dist/example.js.map +0 -1
  242. package/dist/handlers/crm.handlers.js.map +0 -1
  243. package/dist/handlers/deal.handlers.js.map +0 -1
  244. package/dist/handlers/mock-data.js.map +0 -1
  245. package/dist/index.js.map +0 -1
  246. package/dist/presentations/dashboard.presentation.js.map +0 -1
  247. package/dist/presentations/pipeline.presentation.js.map +0 -1
  248. package/dist/seeders/index.js.map +0 -1
  249. package/dist/ui/CrmDashboard.js.map +0 -1
  250. package/dist/ui/CrmDealCard.js.map +0 -1
  251. package/dist/ui/CrmPipelineBoard.js.map +0 -1
  252. package/dist/ui/hooks/useDealList.js.map +0 -1
  253. package/dist/ui/hooks/useDealMutations.js.map +0 -1
  254. package/dist/ui/modals/CreateDealModal.js.map +0 -1
  255. package/dist/ui/modals/DealActionsModal.js.map +0 -1
  256. package/dist/ui/overlays/demo-overlays.js.map +0 -1
  257. package/dist/ui/renderers/pipeline.markdown.js.map +0 -1
  258. package/dist/ui/renderers/pipeline.renderer.js.map +0 -1
  259. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,293 @@
1
+ // src/handlers/mock-data.ts
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
+ };