@contractspec/example.crm-pipeline 1.57.0 → 1.58.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 +20 -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
@@ -1 +1 @@
1
- {"version":3,"file":"deal.operation.d.ts","names":[],"sources":["../../src/deal/deal.operation.ts"],"mappings":";;;;;;;cAsBa,kBAAA,+BAAkB,aAAA,2BAAA,WAAA;;UAuD7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAvD6B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4DlB,gBAAA,+BAAgB,aAAA,2BAAA,WAAA;;UAkD3B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;UAlD2B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuDhB,eAAA,+BAAe,aAAA,2BAAA,WAAA;;UAsD1B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;UAtD0B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2Df,gBAAA,+BAAgB,aAAA,2BAAA,WAAA;;UAsD3B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;UAtD2B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2DhB,iBAAA,+BAAiB,aAAA,2BAAA,WAAA;;UAmC5B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAnC4B,yBAAA,CAAA,SAAA"}
1
+ {"version":3,"file":"deal.operation.d.ts","sourceRoot":"","sources":["../../src/deal/deal.operation.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuD7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkD3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsD1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsD3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmC5B,CAAC"}
@@ -1,270 +1,397 @@
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";
1
+ // @bun
2
+ // src/deal/deal.enum.ts
3
+ import { defineEnum } from "@contractspec/lib.schema";
4
+ var DealStatusEnum = defineEnum("DealStatus", [
5
+ "OPEN",
6
+ "WON",
7
+ "LOST",
8
+ "STALE"
9
+ ]);
10
+ var DealStatusFilterEnum = defineEnum("DealStatusFilter", [
11
+ "OPEN",
12
+ "WON",
13
+ "LOST",
14
+ "all"
15
+ ]);
3
16
 
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
- }
17
+ // src/deal/deal.schema.ts
18
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
19
+ var DealModel = defineSchemaModel({
20
+ name: "Deal",
21
+ description: "A deal in the CRM pipeline",
22
+ fields: {
23
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
25
+ value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
26
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
+ pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
+ stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
29
+ status: { type: DealStatusEnum, isOptional: false },
30
+ contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
31
+ companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
32
+ ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
33
+ expectedCloseDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
34
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
35
+ updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
36
+ }
60
37
  });
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
- }
38
+ var CreateDealInputModel = defineSchemaModel({
39
+ name: "CreateDealInput",
40
+ description: "Input for creating a deal",
41
+ fields: {
42
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
+ value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
44
+ currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
47
+ contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
48
+ companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
49
+ expectedCloseDate: { type: ScalarTypeEnum.DateTime(), isOptional: true }
50
+ }
114
51
  });
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
- }
52
+ var MoveDealInputModel = defineSchemaModel({
53
+ name: "MoveDealInput",
54
+ description: "Input for moving a deal to another stage",
55
+ fields: {
56
+ dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
+ stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
59
+ }
168
60
  });
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
- }
61
+ var DealMovedPayloadModel = defineSchemaModel({
62
+ name: "DealMovedPayload",
63
+ fields: {
64
+ dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
+ fromStage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
+ toStage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
67
+ }
222
68
  });
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
- }
69
+ var WinDealInputModel = defineSchemaModel({
70
+ name: "WinDealInput",
71
+ description: "Input for marking a deal as won",
72
+ fields: {
73
+ dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
74
+ wonSource: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
75
+ notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
76
+ }
77
+ });
78
+ var DealWonPayloadModel = defineSchemaModel({
79
+ name: "DealWonPayload",
80
+ fields: {
81
+ dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
+ value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
83
+ }
84
+ });
85
+ var LoseDealInputModel = defineSchemaModel({
86
+ name: "LoseDealInput",
87
+ description: "Input for marking a deal as lost",
88
+ fields: {
89
+ dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
90
+ lostReason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
91
+ notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
92
+ }
93
+ });
94
+ var DealLostPayloadModel = defineSchemaModel({
95
+ name: "DealLostPayload",
96
+ fields: {
97
+ dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
98
+ reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
99
+ }
100
+ });
101
+ var ListDealsInputModel = defineSchemaModel({
102
+ name: "ListDealsInput",
103
+ description: "Input for listing deals",
104
+ fields: {
105
+ pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
106
+ stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
107
+ status: { type: DealStatusFilterEnum, isOptional: true },
108
+ ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
109
+ search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
110
+ limit: {
111
+ type: ScalarTypeEnum.Int_unsecure(),
112
+ isOptional: true,
113
+ defaultValue: 20
114
+ },
115
+ offset: {
116
+ type: ScalarTypeEnum.Int_unsecure(),
117
+ isOptional: true,
118
+ defaultValue: 0
119
+ }
120
+ }
121
+ });
122
+ var ListDealsOutputModel = defineSchemaModel({
123
+ name: "ListDealsOutput",
124
+ description: "Output for listing deals",
125
+ fields: {
126
+ deals: { type: DealModel, isArray: true, isOptional: false },
127
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
128
+ totalValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
129
+ }
266
130
  });
267
131
 
268
- //#endregion
269
- export { CreateDealContract, ListDealsContract, LoseDealContract, MoveDealContract, WinDealContract };
270
- //# sourceMappingURL=deal.operation.js.map
132
+ // src/deal/deal.operation.ts
133
+ import {
134
+ defineCommand,
135
+ defineQuery
136
+ } from "@contractspec/lib.contracts/operations";
137
+ var OWNERS = ["@example.crm-pipeline"];
138
+ var CreateDealContract = defineCommand({
139
+ meta: {
140
+ key: "crm.deal.create",
141
+ version: "1.0.0",
142
+ stability: "stable",
143
+ owners: [...OWNERS],
144
+ tags: ["crm", "deal", "create"],
145
+ description: "Create a new deal in the pipeline.",
146
+ goal: "Allow sales reps to create new opportunities.",
147
+ context: "Deal creation UI, quick add."
148
+ },
149
+ io: {
150
+ input: CreateDealInputModel,
151
+ output: DealModel
152
+ },
153
+ policy: {
154
+ auth: "user"
155
+ },
156
+ sideEffects: {
157
+ emits: [
158
+ {
159
+ key: "deal.created",
160
+ version: "1.0.0",
161
+ when: "Deal is created",
162
+ payload: DealModel
163
+ }
164
+ ],
165
+ audit: ["deal.created"]
166
+ },
167
+ acceptance: {
168
+ scenarios: [
169
+ {
170
+ key: "create-deal-happy-path",
171
+ given: ["User is authenticated"],
172
+ when: ["User creates a deal with valid data"],
173
+ then: ["Deal is created", "DealCreated event is emitted"]
174
+ }
175
+ ],
176
+ examples: [
177
+ {
178
+ key: "create-basic-deal",
179
+ input: {
180
+ title: "Big Corp Q3 License",
181
+ stageId: "stage-lead",
182
+ value: 50000,
183
+ companyId: "comp-123"
184
+ },
185
+ output: {
186
+ id: "deal-789",
187
+ title: "Big Corp Q3 License",
188
+ status: "open"
189
+ }
190
+ }
191
+ ]
192
+ }
193
+ });
194
+ var MoveDealContract = defineCommand({
195
+ meta: {
196
+ key: "crm.deal.move",
197
+ version: "1.0.0",
198
+ stability: "stable",
199
+ owners: [...OWNERS],
200
+ tags: ["crm", "deal", "move", "kanban"],
201
+ description: "Move a deal to a different stage.",
202
+ goal: "Allow drag-and-drop stage movement in Kanban.",
203
+ context: "Pipeline Kanban view."
204
+ },
205
+ io: {
206
+ input: MoveDealInputModel,
207
+ output: DealModel
208
+ },
209
+ policy: {
210
+ auth: "user"
211
+ },
212
+ sideEffects: {
213
+ emits: [
214
+ {
215
+ key: "deal.moved",
216
+ version: "1.0.0",
217
+ when: "Deal stage changed",
218
+ payload: DealMovedPayloadModel
219
+ }
220
+ ],
221
+ audit: ["deal.moved"]
222
+ },
223
+ acceptance: {
224
+ scenarios: [
225
+ {
226
+ key: "move-deal-happy-path",
227
+ given: ["Deal exists in stage A"],
228
+ when: ["User moves deal to stage B"],
229
+ then: ["Deal stage is updated", "DealMoved event is emitted"]
230
+ }
231
+ ],
232
+ examples: [
233
+ {
234
+ key: "move-to-negotiation",
235
+ input: { dealId: "deal-789", targetStageId: "stage-negotiation" },
236
+ output: {
237
+ id: "deal-789",
238
+ stageId: "stage-negotiation",
239
+ movedAt: "2025-01-15T10:00:00Z"
240
+ }
241
+ }
242
+ ]
243
+ }
244
+ });
245
+ var WinDealContract = defineCommand({
246
+ meta: {
247
+ key: "crm.deal.win",
248
+ version: "1.0.0",
249
+ stability: "stable",
250
+ owners: [...OWNERS],
251
+ tags: ["crm", "deal", "won"],
252
+ description: "Mark a deal as won.",
253
+ goal: "Close a deal as successful.",
254
+ context: "Deal closing flow."
255
+ },
256
+ io: {
257
+ input: WinDealInputModel,
258
+ output: DealModel
259
+ },
260
+ policy: {
261
+ auth: "user"
262
+ },
263
+ sideEffects: {
264
+ emits: [
265
+ {
266
+ key: "deal.won",
267
+ version: "1.0.0",
268
+ when: "Deal is won",
269
+ payload: DealWonPayloadModel
270
+ }
271
+ ],
272
+ audit: ["deal.won"]
273
+ },
274
+ acceptance: {
275
+ scenarios: [
276
+ {
277
+ key: "win-deal-happy-path",
278
+ given: ["Deal is open"],
279
+ when: ["User marks deal as won"],
280
+ then: ["Deal status becomes WON", "DealWon event is emitted"]
281
+ }
282
+ ],
283
+ examples: [
284
+ {
285
+ key: "mark-won",
286
+ input: {
287
+ dealId: "deal-789",
288
+ actualValue: 52000,
289
+ note: "Signed contract attached"
290
+ },
291
+ output: {
292
+ id: "deal-789",
293
+ status: "won",
294
+ closedAt: "2025-01-20T14:30:00Z"
295
+ }
296
+ }
297
+ ]
298
+ }
299
+ });
300
+ var LoseDealContract = defineCommand({
301
+ meta: {
302
+ key: "crm.deal.lose",
303
+ version: "1.0.0",
304
+ stability: "stable",
305
+ owners: [...OWNERS],
306
+ tags: ["crm", "deal", "lost"],
307
+ description: "Mark a deal as lost.",
308
+ goal: "Close a deal as unsuccessful.",
309
+ context: "Deal closing flow."
310
+ },
311
+ io: {
312
+ input: LoseDealInputModel,
313
+ output: DealModel
314
+ },
315
+ policy: {
316
+ auth: "user"
317
+ },
318
+ sideEffects: {
319
+ emits: [
320
+ {
321
+ key: "deal.lost",
322
+ version: "1.0.0",
323
+ when: "Deal is lost",
324
+ payload: DealLostPayloadModel
325
+ }
326
+ ],
327
+ audit: ["deal.lost"]
328
+ },
329
+ acceptance: {
330
+ scenarios: [
331
+ {
332
+ key: "lose-deal-happy-path",
333
+ given: ["Deal is open"],
334
+ when: ["User marks deal as lost"],
335
+ then: ["Deal status becomes LOST", "DealLost event is emitted"]
336
+ }
337
+ ],
338
+ examples: [
339
+ {
340
+ key: "mark-lost",
341
+ input: {
342
+ dealId: "deal-789",
343
+ reason: "competitor",
344
+ note: "Went with cheaper option"
345
+ },
346
+ output: {
347
+ id: "deal-789",
348
+ status: "lost",
349
+ closedAt: "2025-01-21T09:00:00Z"
350
+ }
351
+ }
352
+ ]
353
+ }
354
+ });
355
+ var ListDealsContract = defineQuery({
356
+ meta: {
357
+ key: "crm.deal.list",
358
+ version: "1.0.0",
359
+ stability: "stable",
360
+ owners: [...OWNERS],
361
+ tags: ["crm", "deal", "list"],
362
+ description: "List deals with filters.",
363
+ goal: "Show pipeline, deal lists, dashboards.",
364
+ context: "Pipeline view, deal list."
365
+ },
366
+ io: {
367
+ input: ListDealsInputModel,
368
+ output: ListDealsOutputModel
369
+ },
370
+ policy: {
371
+ auth: "user"
372
+ },
373
+ acceptance: {
374
+ scenarios: [
375
+ {
376
+ key: "list-deals-happy-path",
377
+ given: ["User has access to deals"],
378
+ when: ["User lists deals"],
379
+ then: ["List of deals is returned"]
380
+ }
381
+ ],
382
+ examples: [
383
+ {
384
+ key: "list-filter-stage",
385
+ input: { stageId: "stage-lead", limit: 20 },
386
+ output: { items: [], total: 5, hasMore: false }
387
+ }
388
+ ]
389
+ }
390
+ });
391
+ export {
392
+ WinDealContract,
393
+ MoveDealContract,
394
+ LoseDealContract,
395
+ ListDealsContract,
396
+ CreateDealContract
397
+ };