@contractspec/example.crm-pipeline 0.0.0-canary-20260113170453

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 (206) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +172 -0
  2. package/.turbo/turbo-build.log +173 -0
  3. package/CHANGELOG.md +436 -0
  4. package/LICENSE +21 -0
  5. package/README.md +139 -0
  6. package/dist/crm-pipeline.feature.d.ts +12 -0
  7. package/dist/crm-pipeline.feature.d.ts.map +1 -0
  8. package/dist/crm-pipeline.feature.js +166 -0
  9. package/dist/crm-pipeline.feature.js.map +1 -0
  10. package/dist/deal/deal.enum.d.ts +14 -0
  11. package/dist/deal/deal.enum.d.ts.map +1 -0
  12. package/dist/deal/deal.enum.js +25 -0
  13. package/dist/deal/deal.enum.js.map +1 -0
  14. package/dist/deal/deal.operation.d.ts +513 -0
  15. package/dist/deal/deal.operation.d.ts.map +1 -0
  16. package/dist/deal/deal.operation.js +270 -0
  17. package/dist/deal/deal.operation.js.map +1 -0
  18. package/dist/deal/deal.schema.d.ts +300 -0
  19. package/dist/deal/deal.schema.d.ts.map +1 -0
  20. package/dist/deal/deal.schema.js +286 -0
  21. package/dist/deal/deal.schema.js.map +1 -0
  22. package/dist/deal/deal.test-spec.d.ts +8 -0
  23. package/dist/deal/deal.test-spec.d.ts.map +1 -0
  24. package/dist/deal/deal.test-spec.js +65 -0
  25. package/dist/deal/deal.test-spec.js.map +1 -0
  26. package/dist/deal/index.d.ts +4 -0
  27. package/dist/deal/index.js +5 -0
  28. package/dist/docs/crm-pipeline.docblock.d.ts +1 -0
  29. package/dist/docs/crm-pipeline.docblock.js +100 -0
  30. package/dist/docs/crm-pipeline.docblock.js.map +1 -0
  31. package/dist/docs/index.d.ts +1 -0
  32. package/dist/docs/index.js +1 -0
  33. package/dist/entities/company.entity.d.ts +40 -0
  34. package/dist/entities/company.entity.d.ts.map +1 -0
  35. package/dist/entities/company.entity.js +63 -0
  36. package/dist/entities/company.entity.js.map +1 -0
  37. package/dist/entities/contact.entity.d.ts +44 -0
  38. package/dist/entities/contact.entity.d.ts.map +1 -0
  39. package/dist/entities/contact.entity.js +78 -0
  40. package/dist/entities/contact.entity.js.map +1 -0
  41. package/dist/entities/deal.entity.d.ts +73 -0
  42. package/dist/entities/deal.entity.d.ts.map +1 -0
  43. package/dist/entities/deal.entity.js +120 -0
  44. package/dist/entities/deal.entity.js.map +1 -0
  45. package/dist/entities/index.d.ts +15 -0
  46. package/dist/entities/index.d.ts.map +1 -0
  47. package/dist/entities/index.js +33 -0
  48. package/dist/entities/index.js.map +1 -0
  49. package/dist/entities/task.entity.d.ts +65 -0
  50. package/dist/entities/task.entity.d.ts.map +1 -0
  51. package/dist/entities/task.entity.js +129 -0
  52. package/dist/entities/task.entity.js.map +1 -0
  53. package/dist/events/contact.event.d.ts +29 -0
  54. package/dist/events/contact.event.d.ts.map +1 -0
  55. package/dist/events/contact.event.js +45 -0
  56. package/dist/events/contact.event.js.map +1 -0
  57. package/dist/events/deal.event.d.ts +111 -0
  58. package/dist/events/deal.event.d.ts.map +1 -0
  59. package/dist/events/deal.event.js +172 -0
  60. package/dist/events/deal.event.js.map +1 -0
  61. package/dist/events/index.d.ts +4 -0
  62. package/dist/events/index.js +5 -0
  63. package/dist/events/task.event.d.ts +29 -0
  64. package/dist/events/task.event.d.ts.map +1 -0
  65. package/dist/events/task.event.js +45 -0
  66. package/dist/events/task.event.js.map +1 -0
  67. package/dist/example.d.ts +7 -0
  68. package/dist/example.d.ts.map +1 -0
  69. package/dist/example.js +53 -0
  70. package/dist/example.js.map +1 -0
  71. package/dist/handlers/crm.handlers.d.ts +89 -0
  72. package/dist/handlers/crm.handlers.d.ts.map +1 -0
  73. package/dist/handlers/crm.handlers.js +172 -0
  74. package/dist/handlers/crm.handlers.js.map +1 -0
  75. package/dist/handlers/deal.handlers.d.ts +94 -0
  76. package/dist/handlers/deal.handlers.d.ts.map +1 -0
  77. package/dist/handlers/deal.handlers.js +120 -0
  78. package/dist/handlers/deal.handlers.js.map +1 -0
  79. package/dist/handlers/index.d.ts +4 -0
  80. package/dist/handlers/index.js +5 -0
  81. package/dist/handlers/mock-data.d.ts +49 -0
  82. package/dist/handlers/mock-data.d.ts.map +1 -0
  83. package/dist/handlers/mock-data.js +188 -0
  84. package/dist/handlers/mock-data.js.map +1 -0
  85. package/dist/index.d.ts +47 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +56 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/operations/index.d.ts +5 -0
  90. package/dist/operations/index.js +6 -0
  91. package/dist/presentations/dashboard.presentation.d.ts +14 -0
  92. package/dist/presentations/dashboard.presentation.d.ts.map +1 -0
  93. package/dist/presentations/dashboard.presentation.js +62 -0
  94. package/dist/presentations/dashboard.presentation.js.map +1 -0
  95. package/dist/presentations/index.d.ts +3 -0
  96. package/dist/presentations/index.js +4 -0
  97. package/dist/presentations/pipeline.presentation.d.ts +22 -0
  98. package/dist/presentations/pipeline.presentation.d.ts.map +1 -0
  99. package/dist/presentations/pipeline.presentation.js +122 -0
  100. package/dist/presentations/pipeline.presentation.js.map +1 -0
  101. package/dist/seeders/index.d.ts +10 -0
  102. package/dist/seeders/index.d.ts.map +1 -0
  103. package/dist/seeders/index.js +47 -0
  104. package/dist/seeders/index.js.map +1 -0
  105. package/dist/shared/overlay-types.d.ts +34 -0
  106. package/dist/shared/overlay-types.d.ts.map +1 -0
  107. package/dist/shared/overlay-types.js +0 -0
  108. package/dist/ui/CrmDashboard.d.ts +7 -0
  109. package/dist/ui/CrmDashboard.d.ts.map +1 -0
  110. package/dist/ui/CrmDashboard.js +304 -0
  111. package/dist/ui/CrmDashboard.js.map +1 -0
  112. package/dist/ui/CrmDealCard.d.ts +15 -0
  113. package/dist/ui/CrmDealCard.d.ts.map +1 -0
  114. package/dist/ui/CrmDealCard.js +49 -0
  115. package/dist/ui/CrmDealCard.js.map +1 -0
  116. package/dist/ui/CrmPipelineBoard.d.ts +23 -0
  117. package/dist/ui/CrmPipelineBoard.d.ts.map +1 -0
  118. package/dist/ui/CrmPipelineBoard.js +98 -0
  119. package/dist/ui/CrmPipelineBoard.js.map +1 -0
  120. package/dist/ui/hooks/index.d.ts +3 -0
  121. package/dist/ui/hooks/index.js +6 -0
  122. package/dist/ui/hooks/useDealList.d.ts +35 -0
  123. package/dist/ui/hooks/useDealList.d.ts.map +1 -0
  124. package/dist/ui/hooks/useDealList.js +94 -0
  125. package/dist/ui/hooks/useDealList.js.map +1 -0
  126. package/dist/ui/hooks/useDealMutations.d.ts +26 -0
  127. package/dist/ui/hooks/useDealMutations.d.ts.map +1 -0
  128. package/dist/ui/hooks/useDealMutations.js +159 -0
  129. package/dist/ui/hooks/useDealMutations.js.map +1 -0
  130. package/dist/ui/index.d.ts +14 -0
  131. package/dist/ui/index.js +15 -0
  132. package/dist/ui/modals/CreateDealModal.d.ts +33 -0
  133. package/dist/ui/modals/CreateDealModal.d.ts.map +1 -0
  134. package/dist/ui/modals/CreateDealModal.js +183 -0
  135. package/dist/ui/modals/CreateDealModal.js.map +1 -0
  136. package/dist/ui/modals/DealActionsModal.d.ts +51 -0
  137. package/dist/ui/modals/DealActionsModal.d.ts.map +1 -0
  138. package/dist/ui/modals/DealActionsModal.js +372 -0
  139. package/dist/ui/modals/DealActionsModal.js.map +1 -0
  140. package/dist/ui/modals/index.d.ts +3 -0
  141. package/dist/ui/modals/index.js +4 -0
  142. package/dist/ui/overlays/demo-overlays.d.ts +19 -0
  143. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -0
  144. package/dist/ui/overlays/demo-overlays.js +68 -0
  145. package/dist/ui/overlays/demo-overlays.js.map +1 -0
  146. package/dist/ui/overlays/index.d.ts +2 -0
  147. package/dist/ui/overlays/index.js +3 -0
  148. package/dist/ui/renderers/index.d.ts +3 -0
  149. package/dist/ui/renderers/index.js +4 -0
  150. package/dist/ui/renderers/pipeline.markdown.d.ts +23 -0
  151. package/dist/ui/renderers/pipeline.markdown.d.ts.map +1 -0
  152. package/dist/ui/renderers/pipeline.markdown.js +118 -0
  153. package/dist/ui/renderers/pipeline.markdown.js.map +1 -0
  154. package/dist/ui/renderers/pipeline.renderer.d.ts +9 -0
  155. package/dist/ui/renderers/pipeline.renderer.d.ts.map +1 -0
  156. package/dist/ui/renderers/pipeline.renderer.js +28 -0
  157. package/dist/ui/renderers/pipeline.renderer.js.map +1 -0
  158. package/example.ts +1 -0
  159. package/package.json +127 -0
  160. package/src/crm-pipeline.feature.ts +100 -0
  161. package/src/deal/deal.enum.ts +21 -0
  162. package/src/deal/deal.operation.ts +291 -0
  163. package/src/deal/deal.schema.ts +154 -0
  164. package/src/deal/deal.test-spec.ts +55 -0
  165. package/src/deal/index.ts +26 -0
  166. package/src/docs/crm-pipeline.docblock.ts +98 -0
  167. package/src/docs/index.ts +1 -0
  168. package/src/entities/company.entity.ts +77 -0
  169. package/src/entities/contact.entity.ts +93 -0
  170. package/src/entities/deal.entity.ts +160 -0
  171. package/src/entities/index.ts +45 -0
  172. package/src/entities/task.entity.ts +137 -0
  173. package/src/events/contact.event.ts +31 -0
  174. package/src/events/deal.event.ts +104 -0
  175. package/src/events/index.ts +3 -0
  176. package/src/events/task.event.ts +28 -0
  177. package/src/example.ts +38 -0
  178. package/src/handlers/crm.handlers.ts +415 -0
  179. package/src/handlers/deal.handlers.ts +253 -0
  180. package/src/handlers/index.ts +30 -0
  181. package/src/handlers/mock-data.ts +198 -0
  182. package/src/index.ts +32 -0
  183. package/src/operations/index.ts +20 -0
  184. package/src/presentations/dashboard.presentation.ts +59 -0
  185. package/src/presentations/index.ts +2 -0
  186. package/src/presentations/pipeline.presentation.ts +117 -0
  187. package/src/seeders/index.ts +35 -0
  188. package/src/shared/overlay-types.ts +39 -0
  189. package/src/ui/CrmDashboard.tsx +311 -0
  190. package/src/ui/CrmDealCard.tsx +83 -0
  191. package/src/ui/CrmPipelineBoard.tsx +136 -0
  192. package/src/ui/hooks/index.ts +10 -0
  193. package/src/ui/hooks/useDealList.ts +113 -0
  194. package/src/ui/hooks/useDealMutations.ts +174 -0
  195. package/src/ui/index.ts +18 -0
  196. package/src/ui/modals/CreateDealModal.tsx +239 -0
  197. package/src/ui/modals/DealActionsModal.tsx +424 -0
  198. package/src/ui/modals/index.ts +2 -0
  199. package/src/ui/overlays/demo-overlays.ts +68 -0
  200. package/src/ui/overlays/index.ts +1 -0
  201. package/src/ui/renderers/index.ts +6 -0
  202. package/src/ui/renderers/pipeline.markdown.ts +198 -0
  203. package/src/ui/renderers/pipeline.renderer.tsx +35 -0
  204. package/tsconfig.json +10 -0
  205. package/tsconfig.tsbuildinfo +1 -0
  206. package/tsdown.config.js +7 -0
@@ -0,0 +1,270 @@
1
+ import { CreateDealInputModel, DealLostPayloadModel, DealModel, DealMovedPayloadModel, DealWonPayloadModel, ListDealsInputModel, ListDealsOutputModel, LoseDealInputModel, MoveDealInputModel, WinDealInputModel } from "./deal.schema.js";
2
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts/operations";
3
+
4
+ //#region src/deal/deal.operation.ts
5
+ const OWNERS = ["@example.crm-pipeline"];
6
+ /**
7
+ * Create a new deal.
8
+ */
9
+ const CreateDealContract = defineCommand({
10
+ meta: {
11
+ key: "crm.deal.create",
12
+ version: "1.0.0",
13
+ stability: "stable",
14
+ owners: [...OWNERS],
15
+ tags: [
16
+ "crm",
17
+ "deal",
18
+ "create"
19
+ ],
20
+ description: "Create a new deal in the pipeline.",
21
+ goal: "Allow sales reps to create new opportunities.",
22
+ context: "Deal creation UI, quick add."
23
+ },
24
+ io: {
25
+ input: CreateDealInputModel,
26
+ output: DealModel
27
+ },
28
+ policy: { auth: "user" },
29
+ sideEffects: {
30
+ emits: [{
31
+ key: "deal.created",
32
+ version: "1.0.0",
33
+ when: "Deal is created",
34
+ payload: DealModel
35
+ }],
36
+ audit: ["deal.created"]
37
+ },
38
+ acceptance: {
39
+ scenarios: [{
40
+ key: "create-deal-happy-path",
41
+ given: ["User is authenticated"],
42
+ when: ["User creates a deal with valid data"],
43
+ then: ["Deal is created", "DealCreated event is emitted"]
44
+ }],
45
+ examples: [{
46
+ key: "create-basic-deal",
47
+ input: {
48
+ title: "Big Corp Q3 License",
49
+ stageId: "stage-lead",
50
+ value: 5e4,
51
+ companyId: "comp-123"
52
+ },
53
+ output: {
54
+ id: "deal-789",
55
+ title: "Big Corp Q3 License",
56
+ status: "open"
57
+ }
58
+ }]
59
+ }
60
+ });
61
+ /**
62
+ * Move deal to a different stage.
63
+ */
64
+ const MoveDealContract = defineCommand({
65
+ meta: {
66
+ key: "crm.deal.move",
67
+ version: "1.0.0",
68
+ stability: "stable",
69
+ owners: [...OWNERS],
70
+ tags: [
71
+ "crm",
72
+ "deal",
73
+ "move",
74
+ "kanban"
75
+ ],
76
+ description: "Move a deal to a different stage.",
77
+ goal: "Allow drag-and-drop stage movement in Kanban.",
78
+ context: "Pipeline Kanban view."
79
+ },
80
+ io: {
81
+ input: MoveDealInputModel,
82
+ output: DealModel
83
+ },
84
+ policy: { auth: "user" },
85
+ sideEffects: {
86
+ emits: [{
87
+ key: "deal.moved",
88
+ version: "1.0.0",
89
+ when: "Deal stage changed",
90
+ payload: DealMovedPayloadModel
91
+ }],
92
+ audit: ["deal.moved"]
93
+ },
94
+ acceptance: {
95
+ scenarios: [{
96
+ key: "move-deal-happy-path",
97
+ given: ["Deal exists in stage A"],
98
+ when: ["User moves deal to stage B"],
99
+ then: ["Deal stage is updated", "DealMoved event is emitted"]
100
+ }],
101
+ examples: [{
102
+ key: "move-to-negotiation",
103
+ input: {
104
+ dealId: "deal-789",
105
+ targetStageId: "stage-negotiation"
106
+ },
107
+ output: {
108
+ id: "deal-789",
109
+ stageId: "stage-negotiation",
110
+ movedAt: "2025-01-15T10:00:00Z"
111
+ }
112
+ }]
113
+ }
114
+ });
115
+ /**
116
+ * Mark deal as won.
117
+ */
118
+ const WinDealContract = defineCommand({
119
+ meta: {
120
+ key: "crm.deal.win",
121
+ version: "1.0.0",
122
+ stability: "stable",
123
+ owners: [...OWNERS],
124
+ tags: [
125
+ "crm",
126
+ "deal",
127
+ "won"
128
+ ],
129
+ description: "Mark a deal as won.",
130
+ goal: "Close a deal as successful.",
131
+ context: "Deal closing flow."
132
+ },
133
+ io: {
134
+ input: WinDealInputModel,
135
+ output: DealModel
136
+ },
137
+ policy: { auth: "user" },
138
+ sideEffects: {
139
+ emits: [{
140
+ key: "deal.won",
141
+ version: "1.0.0",
142
+ when: "Deal is won",
143
+ payload: DealWonPayloadModel
144
+ }],
145
+ audit: ["deal.won"]
146
+ },
147
+ acceptance: {
148
+ scenarios: [{
149
+ key: "win-deal-happy-path",
150
+ given: ["Deal is open"],
151
+ when: ["User marks deal as won"],
152
+ then: ["Deal status becomes WON", "DealWon event is emitted"]
153
+ }],
154
+ examples: [{
155
+ key: "mark-won",
156
+ input: {
157
+ dealId: "deal-789",
158
+ actualValue: 52e3,
159
+ note: "Signed contract attached"
160
+ },
161
+ output: {
162
+ id: "deal-789",
163
+ status: "won",
164
+ closedAt: "2025-01-20T14:30:00Z"
165
+ }
166
+ }]
167
+ }
168
+ });
169
+ /**
170
+ * Mark deal as lost.
171
+ */
172
+ const LoseDealContract = defineCommand({
173
+ meta: {
174
+ key: "crm.deal.lose",
175
+ version: "1.0.0",
176
+ stability: "stable",
177
+ owners: [...OWNERS],
178
+ tags: [
179
+ "crm",
180
+ "deal",
181
+ "lost"
182
+ ],
183
+ description: "Mark a deal as lost.",
184
+ goal: "Close a deal as unsuccessful.",
185
+ context: "Deal closing flow."
186
+ },
187
+ io: {
188
+ input: LoseDealInputModel,
189
+ output: DealModel
190
+ },
191
+ policy: { auth: "user" },
192
+ sideEffects: {
193
+ emits: [{
194
+ key: "deal.lost",
195
+ version: "1.0.0",
196
+ when: "Deal is lost",
197
+ payload: DealLostPayloadModel
198
+ }],
199
+ audit: ["deal.lost"]
200
+ },
201
+ acceptance: {
202
+ scenarios: [{
203
+ key: "lose-deal-happy-path",
204
+ given: ["Deal is open"],
205
+ when: ["User marks deal as lost"],
206
+ then: ["Deal status becomes LOST", "DealLost event is emitted"]
207
+ }],
208
+ examples: [{
209
+ key: "mark-lost",
210
+ input: {
211
+ dealId: "deal-789",
212
+ reason: "competitor",
213
+ note: "Went with cheaper option"
214
+ },
215
+ output: {
216
+ id: "deal-789",
217
+ status: "lost",
218
+ closedAt: "2025-01-21T09:00:00Z"
219
+ }
220
+ }]
221
+ }
222
+ });
223
+ /**
224
+ * List deals in pipeline.
225
+ */
226
+ const ListDealsContract = defineQuery({
227
+ meta: {
228
+ key: "crm.deal.list",
229
+ version: "1.0.0",
230
+ stability: "stable",
231
+ owners: [...OWNERS],
232
+ tags: [
233
+ "crm",
234
+ "deal",
235
+ "list"
236
+ ],
237
+ description: "List deals with filters.",
238
+ goal: "Show pipeline, deal lists, dashboards.",
239
+ context: "Pipeline view, deal list."
240
+ },
241
+ io: {
242
+ input: ListDealsInputModel,
243
+ output: ListDealsOutputModel
244
+ },
245
+ policy: { auth: "user" },
246
+ acceptance: {
247
+ scenarios: [{
248
+ key: "list-deals-happy-path",
249
+ given: ["User has access to deals"],
250
+ when: ["User lists deals"],
251
+ then: ["List of deals is returned"]
252
+ }],
253
+ examples: [{
254
+ key: "list-filter-stage",
255
+ input: {
256
+ stageId: "stage-lead",
257
+ limit: 20
258
+ },
259
+ output: {
260
+ items: [],
261
+ total: 5,
262
+ hasMore: false
263
+ }
264
+ }]
265
+ }
266
+ });
267
+
268
+ //#endregion
269
+ export { CreateDealContract, ListDealsContract, LoseDealContract, MoveDealContract, WinDealContract };
270
+ //# sourceMappingURL=deal.operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deal.operation.js","names":[],"sources":["../../src/deal/deal.operation.ts"],"sourcesContent":["import {\n defineCommand,\n defineQuery,\n} from '@contractspec/lib.contracts/operations';\nimport {\n DealModel,\n CreateDealInputModel,\n MoveDealInputModel,\n DealMovedPayloadModel,\n WinDealInputModel,\n DealWonPayloadModel,\n LoseDealInputModel,\n DealLostPayloadModel,\n ListDealsInputModel,\n ListDealsOutputModel,\n} from './deal.schema';\n\nconst OWNERS = ['@example.crm-pipeline'] as const;\n\n/**\n * Create a new deal.\n */\nexport const CreateDealContract = defineCommand({\n meta: {\n key: 'crm.deal.create',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['crm', 'deal', 'create'],\n description: 'Create a new deal in the pipeline.',\n goal: 'Allow sales reps to create new opportunities.',\n context: 'Deal creation UI, quick add.',\n },\n io: {\n input: CreateDealInputModel,\n output: DealModel,\n },\n policy: {\n auth: 'user',\n },\n sideEffects: {\n emits: [\n {\n key: 'deal.created',\n version: '1.0.0',\n when: 'Deal is created',\n payload: DealModel,\n },\n ],\n audit: ['deal.created'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'create-deal-happy-path',\n given: ['User is authenticated'],\n when: ['User creates a deal with valid data'],\n then: ['Deal is created', 'DealCreated event is emitted'],\n },\n ],\n examples: [\n {\n key: 'create-basic-deal',\n input: {\n title: 'Big Corp Q3 License',\n stageId: 'stage-lead',\n value: 50000,\n companyId: 'comp-123',\n },\n output: {\n id: 'deal-789',\n title: 'Big Corp Q3 License',\n status: 'open',\n },\n },\n ],\n },\n});\n\n/**\n * Move deal to a different stage.\n */\nexport const MoveDealContract = defineCommand({\n meta: {\n key: 'crm.deal.move',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['crm', 'deal', 'move', 'kanban'],\n description: 'Move a deal to a different stage.',\n goal: 'Allow drag-and-drop stage movement in Kanban.',\n context: 'Pipeline Kanban view.',\n },\n io: {\n input: MoveDealInputModel,\n output: DealModel,\n },\n policy: {\n auth: 'user',\n },\n sideEffects: {\n emits: [\n {\n key: 'deal.moved',\n version: '1.0.0',\n when: 'Deal stage changed',\n payload: DealMovedPayloadModel,\n },\n ],\n audit: ['deal.moved'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'move-deal-happy-path',\n given: ['Deal exists in stage A'],\n when: ['User moves deal to stage B'],\n then: ['Deal stage is updated', 'DealMoved event is emitted'],\n },\n ],\n examples: [\n {\n key: 'move-to-negotiation',\n input: { dealId: 'deal-789', targetStageId: 'stage-negotiation' },\n output: {\n id: 'deal-789',\n stageId: 'stage-negotiation',\n movedAt: '2025-01-15T10:00:00Z',\n },\n },\n ],\n },\n});\n\n/**\n * Mark deal as won.\n */\nexport const WinDealContract = defineCommand({\n meta: {\n key: 'crm.deal.win',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['crm', 'deal', 'won'],\n description: 'Mark a deal as won.',\n goal: 'Close a deal as successful.',\n context: 'Deal closing flow.',\n },\n io: {\n input: WinDealInputModel,\n output: DealModel,\n },\n policy: {\n auth: 'user',\n },\n sideEffects: {\n emits: [\n {\n key: 'deal.won',\n version: '1.0.0',\n when: 'Deal is won',\n payload: DealWonPayloadModel,\n },\n ],\n audit: ['deal.won'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'win-deal-happy-path',\n given: ['Deal is open'],\n when: ['User marks deal as won'],\n then: ['Deal status becomes WON', 'DealWon event is emitted'],\n },\n ],\n examples: [\n {\n key: 'mark-won',\n input: {\n dealId: 'deal-789',\n actualValue: 52000,\n note: 'Signed contract attached',\n },\n output: {\n id: 'deal-789',\n status: 'won',\n closedAt: '2025-01-20T14:30:00Z',\n },\n },\n ],\n },\n});\n\n/**\n * Mark deal as lost.\n */\nexport const LoseDealContract = defineCommand({\n meta: {\n key: 'crm.deal.lose',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['crm', 'deal', 'lost'],\n description: 'Mark a deal as lost.',\n goal: 'Close a deal as unsuccessful.',\n context: 'Deal closing flow.',\n },\n io: {\n input: LoseDealInputModel,\n output: DealModel,\n },\n policy: {\n auth: 'user',\n },\n sideEffects: {\n emits: [\n {\n key: 'deal.lost',\n version: '1.0.0',\n when: 'Deal is lost',\n payload: DealLostPayloadModel,\n },\n ],\n audit: ['deal.lost'],\n },\n acceptance: {\n scenarios: [\n {\n key: 'lose-deal-happy-path',\n given: ['Deal is open'],\n when: ['User marks deal as lost'],\n then: ['Deal status becomes LOST', 'DealLost event is emitted'],\n },\n ],\n examples: [\n {\n key: 'mark-lost',\n input: {\n dealId: 'deal-789',\n reason: 'competitor',\n note: 'Went with cheaper option',\n },\n output: {\n id: 'deal-789',\n status: 'lost',\n closedAt: '2025-01-21T09:00:00Z',\n },\n },\n ],\n },\n});\n\n/**\n * List deals in pipeline.\n */\nexport const ListDealsContract = defineQuery({\n meta: {\n key: 'crm.deal.list',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['crm', 'deal', 'list'],\n description: 'List deals with filters.',\n goal: 'Show pipeline, deal lists, dashboards.',\n context: 'Pipeline view, deal list.',\n },\n io: {\n input: ListDealsInputModel,\n output: ListDealsOutputModel,\n },\n policy: {\n auth: 'user',\n },\n acceptance: {\n scenarios: [\n {\n key: 'list-deals-happy-path',\n given: ['User has access to deals'],\n when: ['User lists deals'],\n then: ['List of deals is returned'],\n },\n ],\n examples: [\n {\n key: 'list-filter-stage',\n input: { stageId: 'stage-lead', limit: 20 },\n output: { items: [], total: 5, hasMore: false },\n },\n ],\n },\n});\n"],"mappings":";;;;AAiBA,MAAM,SAAS,CAAC,wBAAwB;;;;AAKxC,MAAa,qBAAqB,cAAc;CAC9C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAO;GAAQ;GAAS;EAC/B,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,QACP;CACD,aAAa;EACX,OAAO,CACL;GACE,KAAK;GACL,SAAS;GACT,MAAM;GACN,SAAS;GACV,CACF;EACD,OAAO,CAAC,eAAe;EACxB;CACD,YAAY;EACV,WAAW,CACT;GACE,KAAK;GACL,OAAO,CAAC,wBAAwB;GAChC,MAAM,CAAC,sCAAsC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ACnC,MAAM,CAAC,mBAAmB;GAC1B,MAAM,CAAC,4BAA4B;GACpC,CACF;EACD,UAAU,CACR;GACE,KAAK;GACL,OAAO;IAAE,SAAS;IAAc,OAAO;IAAI;GAC3C,QAAQ;IAAE,OAAO,EAAE;IAAE,OAAO;IAAG,SAAS;IAAO;GAChD,CACF;EACF;CACF,CAAC"}
@@ -0,0 +1,300 @@
1
+ import * as _contractspec_lib_schema125 from "@contractspec/lib.schema";
2
+
3
+ //#region src/deal/deal.schema.d.ts
4
+ /**
5
+ * A deal in the CRM pipeline.
6
+ */
7
+ declare const DealModel: _contractspec_lib_schema125.SchemaModel<{
8
+ id: {
9
+ type: _contractspec_lib_schema125.FieldType<string, string>;
10
+ isOptional: false;
11
+ };
12
+ name: {
13
+ type: _contractspec_lib_schema125.FieldType<string, string>;
14
+ isOptional: false;
15
+ };
16
+ value: {
17
+ type: _contractspec_lib_schema125.FieldType<number, number>;
18
+ isOptional: false;
19
+ };
20
+ currency: {
21
+ type: _contractspec_lib_schema125.FieldType<string, string>;
22
+ isOptional: false;
23
+ };
24
+ pipelineId: {
25
+ type: _contractspec_lib_schema125.FieldType<string, string>;
26
+ isOptional: false;
27
+ };
28
+ stageId: {
29
+ type: _contractspec_lib_schema125.FieldType<string, string>;
30
+ isOptional: false;
31
+ };
32
+ status: {
33
+ type: _contractspec_lib_schema125.EnumType<[string, string, string, string]>;
34
+ isOptional: false;
35
+ };
36
+ contactId: {
37
+ type: _contractspec_lib_schema125.FieldType<string, string>;
38
+ isOptional: true;
39
+ };
40
+ companyId: {
41
+ type: _contractspec_lib_schema125.FieldType<string, string>;
42
+ isOptional: true;
43
+ };
44
+ ownerId: {
45
+ type: _contractspec_lib_schema125.FieldType<string, string>;
46
+ isOptional: false;
47
+ };
48
+ expectedCloseDate: {
49
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
50
+ isOptional: true;
51
+ };
52
+ createdAt: {
53
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
54
+ isOptional: false;
55
+ };
56
+ updatedAt: {
57
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
58
+ isOptional: false;
59
+ };
60
+ }>;
61
+ /**
62
+ * Input for creating a deal.
63
+ */
64
+ declare const CreateDealInputModel: _contractspec_lib_schema125.SchemaModel<{
65
+ name: {
66
+ type: _contractspec_lib_schema125.FieldType<string, string>;
67
+ isOptional: false;
68
+ };
69
+ value: {
70
+ type: _contractspec_lib_schema125.FieldType<number, number>;
71
+ isOptional: false;
72
+ };
73
+ currency: {
74
+ type: _contractspec_lib_schema125.FieldType<string, string>;
75
+ isOptional: true;
76
+ };
77
+ pipelineId: {
78
+ type: _contractspec_lib_schema125.FieldType<string, string>;
79
+ isOptional: false;
80
+ };
81
+ stageId: {
82
+ type: _contractspec_lib_schema125.FieldType<string, string>;
83
+ isOptional: false;
84
+ };
85
+ contactId: {
86
+ type: _contractspec_lib_schema125.FieldType<string, string>;
87
+ isOptional: true;
88
+ };
89
+ companyId: {
90
+ type: _contractspec_lib_schema125.FieldType<string, string>;
91
+ isOptional: true;
92
+ };
93
+ expectedCloseDate: {
94
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
95
+ isOptional: true;
96
+ };
97
+ }>;
98
+ /**
99
+ * Input for moving a deal to another stage.
100
+ */
101
+ declare const MoveDealInputModel: _contractspec_lib_schema125.SchemaModel<{
102
+ dealId: {
103
+ type: _contractspec_lib_schema125.FieldType<string, string>;
104
+ isOptional: false;
105
+ };
106
+ stageId: {
107
+ type: _contractspec_lib_schema125.FieldType<string, string>;
108
+ isOptional: false;
109
+ };
110
+ position: {
111
+ type: _contractspec_lib_schema125.FieldType<number, number>;
112
+ isOptional: true;
113
+ };
114
+ }>;
115
+ /**
116
+ * Payload for deal moved event.
117
+ */
118
+ declare const DealMovedPayloadModel: _contractspec_lib_schema125.SchemaModel<{
119
+ dealId: {
120
+ type: _contractspec_lib_schema125.FieldType<string, string>;
121
+ isOptional: false;
122
+ };
123
+ fromStage: {
124
+ type: _contractspec_lib_schema125.FieldType<string, string>;
125
+ isOptional: false;
126
+ };
127
+ toStage: {
128
+ type: _contractspec_lib_schema125.FieldType<string, string>;
129
+ isOptional: false;
130
+ };
131
+ }>;
132
+ /**
133
+ * Input for marking a deal as won.
134
+ */
135
+ declare const WinDealInputModel: _contractspec_lib_schema125.SchemaModel<{
136
+ dealId: {
137
+ type: _contractspec_lib_schema125.FieldType<string, string>;
138
+ isOptional: false;
139
+ };
140
+ wonSource: {
141
+ type: _contractspec_lib_schema125.FieldType<string, string>;
142
+ isOptional: true;
143
+ };
144
+ notes: {
145
+ type: _contractspec_lib_schema125.FieldType<string, string>;
146
+ isOptional: true;
147
+ };
148
+ }>;
149
+ /**
150
+ * Payload for deal won event.
151
+ */
152
+ declare const DealWonPayloadModel: _contractspec_lib_schema125.SchemaModel<{
153
+ dealId: {
154
+ type: _contractspec_lib_schema125.FieldType<string, string>;
155
+ isOptional: false;
156
+ };
157
+ value: {
158
+ type: _contractspec_lib_schema125.FieldType<number, number>;
159
+ isOptional: false;
160
+ };
161
+ }>;
162
+ /**
163
+ * Input for marking a deal as lost.
164
+ */
165
+ declare const LoseDealInputModel: _contractspec_lib_schema125.SchemaModel<{
166
+ dealId: {
167
+ type: _contractspec_lib_schema125.FieldType<string, string>;
168
+ isOptional: false;
169
+ };
170
+ lostReason: {
171
+ type: _contractspec_lib_schema125.FieldType<string, string>;
172
+ isOptional: false;
173
+ };
174
+ notes: {
175
+ type: _contractspec_lib_schema125.FieldType<string, string>;
176
+ isOptional: true;
177
+ };
178
+ }>;
179
+ /**
180
+ * Payload for deal lost event.
181
+ */
182
+ declare const DealLostPayloadModel: _contractspec_lib_schema125.SchemaModel<{
183
+ dealId: {
184
+ type: _contractspec_lib_schema125.FieldType<string, string>;
185
+ isOptional: false;
186
+ };
187
+ reason: {
188
+ type: _contractspec_lib_schema125.FieldType<string, string>;
189
+ isOptional: false;
190
+ };
191
+ }>;
192
+ /**
193
+ * Input for listing deals.
194
+ */
195
+ declare const ListDealsInputModel: _contractspec_lib_schema125.SchemaModel<{
196
+ pipelineId: {
197
+ type: _contractspec_lib_schema125.FieldType<string, string>;
198
+ isOptional: true;
199
+ };
200
+ stageId: {
201
+ type: _contractspec_lib_schema125.FieldType<string, string>;
202
+ isOptional: true;
203
+ };
204
+ status: {
205
+ type: _contractspec_lib_schema125.EnumType<[string, string, string, string]>;
206
+ isOptional: true;
207
+ };
208
+ ownerId: {
209
+ type: _contractspec_lib_schema125.FieldType<string, string>;
210
+ isOptional: true;
211
+ };
212
+ search: {
213
+ type: _contractspec_lib_schema125.FieldType<string, string>;
214
+ isOptional: true;
215
+ };
216
+ limit: {
217
+ type: _contractspec_lib_schema125.FieldType<number, number>;
218
+ isOptional: true;
219
+ defaultValue: number;
220
+ };
221
+ offset: {
222
+ type: _contractspec_lib_schema125.FieldType<number, number>;
223
+ isOptional: true;
224
+ defaultValue: number;
225
+ };
226
+ }>;
227
+ /**
228
+ * Output for listing deals.
229
+ */
230
+ declare const ListDealsOutputModel: _contractspec_lib_schema125.SchemaModel<{
231
+ deals: {
232
+ type: _contractspec_lib_schema125.SchemaModel<{
233
+ id: {
234
+ type: _contractspec_lib_schema125.FieldType<string, string>;
235
+ isOptional: false;
236
+ };
237
+ name: {
238
+ type: _contractspec_lib_schema125.FieldType<string, string>;
239
+ isOptional: false;
240
+ };
241
+ value: {
242
+ type: _contractspec_lib_schema125.FieldType<number, number>;
243
+ isOptional: false;
244
+ };
245
+ currency: {
246
+ type: _contractspec_lib_schema125.FieldType<string, string>;
247
+ isOptional: false;
248
+ };
249
+ pipelineId: {
250
+ type: _contractspec_lib_schema125.FieldType<string, string>;
251
+ isOptional: false;
252
+ };
253
+ stageId: {
254
+ type: _contractspec_lib_schema125.FieldType<string, string>;
255
+ isOptional: false;
256
+ };
257
+ status: {
258
+ type: _contractspec_lib_schema125.EnumType<[string, string, string, string]>;
259
+ isOptional: false;
260
+ };
261
+ contactId: {
262
+ type: _contractspec_lib_schema125.FieldType<string, string>;
263
+ isOptional: true;
264
+ };
265
+ companyId: {
266
+ type: _contractspec_lib_schema125.FieldType<string, string>;
267
+ isOptional: true;
268
+ };
269
+ ownerId: {
270
+ type: _contractspec_lib_schema125.FieldType<string, string>;
271
+ isOptional: false;
272
+ };
273
+ expectedCloseDate: {
274
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
275
+ isOptional: true;
276
+ };
277
+ createdAt: {
278
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
279
+ isOptional: false;
280
+ };
281
+ updatedAt: {
282
+ type: _contractspec_lib_schema125.FieldType<Date, string>;
283
+ isOptional: false;
284
+ };
285
+ }>;
286
+ isArray: true;
287
+ isOptional: false;
288
+ };
289
+ total: {
290
+ type: _contractspec_lib_schema125.FieldType<number, number>;
291
+ isOptional: false;
292
+ };
293
+ totalValue: {
294
+ type: _contractspec_lib_schema125.FieldType<number, number>;
295
+ isOptional: false;
296
+ };
297
+ }>;
298
+ //#endregion
299
+ export { CreateDealInputModel, DealLostPayloadModel, DealModel, DealMovedPayloadModel, DealWonPayloadModel, ListDealsInputModel, ListDealsOutputModel, LoseDealInputModel, MoveDealInputModel, WinDealInputModel };
300
+ //# sourceMappingURL=deal.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deal.schema.d.ts","names":[],"sources":["../../src/deal/deal.schema.ts"],"sourcesContent":[],"mappings":";;;;;;AAMa,cAAA,SAkBX,8BAlBoB,WAkBpB,CAAA;EAAA,EAAA,EAAA;UAAA,2BAAA,CAAA;;;;;;;;;;;;;;;;IAlBoB,IAAA,uCAAA,CAAA,MAAA,EAAA,MAAA,CAAA;IAuBT,UAAA,EAAA,KAAA;EAaX,CAAA;;;;;;;;;;IAb+B,IAAA,uCAAA,CAAA,MAAA,EAAA,MAAA,CAAA;IAkBpB,UAAA,EAAA,IAAA;EAQX,CAAA;;;;EAR6B,CAAA;EAalB,OAAA,EAAA;IAOX,IAAA,uCAAA,CAAA,MAAA,EAAA,MAAA,CAAA;;;;IAPgC,IA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