@contractspec/example.crm-pipeline 3.7.16 → 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.
Files changed (135) hide show
  1. package/.turbo/turbo-build.log +135 -135
  2. package/CHANGELOG.md +40 -0
  3. package/dist/browser/crm-pipeline.feature.js +1 -82
  4. package/dist/browser/deal/deal.enum.js +1 -18
  5. package/dist/browser/deal/deal.operation.js +1 -396
  6. package/dist/browser/deal/deal.schema.js +1 -141
  7. package/dist/browser/deal/deal.test-spec.js +1 -58
  8. package/dist/browser/deal/index.js +1 -408
  9. package/dist/browser/docs/crm-pipeline.docblock.js +5 -49
  10. package/dist/browser/docs/index.js +5 -49
  11. package/dist/browser/entities/company.entity.js +1 -52
  12. package/dist/browser/entities/contact.entity.js +1 -66
  13. package/dist/browser/entities/deal.entity.js +1 -107
  14. package/dist/browser/entities/index.js +1 -343
  15. package/dist/browser/entities/task.entity.js +1 -99
  16. package/dist/browser/events/contact.event.js +1 -31
  17. package/dist/browser/events/deal.event.js +1 -101
  18. package/dist/browser/events/index.js +1 -158
  19. package/dist/browser/events/task.event.js +1 -28
  20. package/dist/browser/example.js +1 -39
  21. package/dist/browser/handlers/crm.handlers.js +2 -171
  22. package/dist/browser/handlers/deal.handlers.js +1 -293
  23. package/dist/browser/handlers/index.js +2 -467
  24. package/dist/browser/handlers/mock-data.js +1 -165
  25. package/dist/browser/index.js +8 -3461
  26. package/dist/browser/operations/index.js +1 -407
  27. package/dist/browser/presentations/dashboard.presentation.js +1 -55
  28. package/dist/browser/presentations/index.js +1 -290
  29. package/dist/browser/presentations/pipeline.presentation.js +1 -236
  30. package/dist/browser/seeders/index.js +1 -22
  31. package/dist/browser/ui/CrmDashboard.js +1 -1547
  32. package/dist/browser/ui/CrmDealCard.js +1 -50
  33. package/dist/browser/ui/CrmPipelineBoard.js +1 -160
  34. package/dist/browser/ui/hooks/index.js +1 -197
  35. package/dist/browser/ui/hooks/useDealList.js +1 -95
  36. package/dist/browser/ui/hooks/useDealMutations.js +1 -100
  37. package/dist/browser/ui/index.js +4 -2205
  38. package/dist/browser/ui/modals/CreateDealModal.js +1 -211
  39. package/dist/browser/ui/modals/DealActionsModal.js +1 -428
  40. package/dist/browser/ui/modals/index.js +1 -638
  41. package/dist/browser/ui/overlays/demo-overlays.js +1 -55
  42. package/dist/browser/ui/overlays/index.js +1 -55
  43. package/dist/browser/ui/renderers/index.js +4 -849
  44. package/dist/browser/ui/renderers/pipeline.markdown.js +4 -575
  45. package/dist/browser/ui/renderers/pipeline.renderer.js +1 -275
  46. package/dist/browser/ui/tables/DealListTab.js +1 -390
  47. package/dist/crm-pipeline.feature.js +1 -82
  48. package/dist/deal/deal.enum.js +1 -18
  49. package/dist/deal/deal.operation.js +1 -396
  50. package/dist/deal/deal.schema.js +1 -141
  51. package/dist/deal/deal.test-spec.js +1 -58
  52. package/dist/deal/index.js +1 -408
  53. package/dist/docs/crm-pipeline.docblock.js +5 -49
  54. package/dist/docs/index.js +5 -49
  55. package/dist/entities/company.entity.js +1 -52
  56. package/dist/entities/contact.entity.js +1 -66
  57. package/dist/entities/deal.entity.js +1 -107
  58. package/dist/entities/index.js +1 -343
  59. package/dist/entities/task.entity.js +1 -99
  60. package/dist/events/contact.event.js +1 -31
  61. package/dist/events/deal.event.js +1 -101
  62. package/dist/events/index.js +1 -158
  63. package/dist/events/task.event.js +1 -28
  64. package/dist/example.js +1 -39
  65. package/dist/handlers/crm.handlers.js +2 -171
  66. package/dist/handlers/deal.handlers.js +1 -293
  67. package/dist/handlers/index.js +2 -467
  68. package/dist/handlers/mock-data.js +1 -165
  69. package/dist/index.js +8 -3461
  70. package/dist/node/crm-pipeline.feature.js +1 -82
  71. package/dist/node/deal/deal.enum.js +1 -18
  72. package/dist/node/deal/deal.operation.js +1 -396
  73. package/dist/node/deal/deal.schema.js +1 -141
  74. package/dist/node/deal/deal.test-spec.js +1 -58
  75. package/dist/node/deal/index.js +1 -408
  76. package/dist/node/docs/crm-pipeline.docblock.js +5 -49
  77. package/dist/node/docs/index.js +5 -49
  78. package/dist/node/entities/company.entity.js +1 -52
  79. package/dist/node/entities/contact.entity.js +1 -66
  80. package/dist/node/entities/deal.entity.js +1 -107
  81. package/dist/node/entities/index.js +1 -343
  82. package/dist/node/entities/task.entity.js +1 -99
  83. package/dist/node/events/contact.event.js +1 -31
  84. package/dist/node/events/deal.event.js +1 -101
  85. package/dist/node/events/index.js +1 -158
  86. package/dist/node/events/task.event.js +1 -28
  87. package/dist/node/example.js +1 -39
  88. package/dist/node/handlers/crm.handlers.js +2 -171
  89. package/dist/node/handlers/deal.handlers.js +1 -293
  90. package/dist/node/handlers/index.js +2 -467
  91. package/dist/node/handlers/mock-data.js +1 -165
  92. package/dist/node/index.js +8 -3461
  93. package/dist/node/operations/index.js +1 -407
  94. package/dist/node/presentations/dashboard.presentation.js +1 -55
  95. package/dist/node/presentations/index.js +1 -290
  96. package/dist/node/presentations/pipeline.presentation.js +1 -236
  97. package/dist/node/seeders/index.js +1 -22
  98. package/dist/node/ui/CrmDashboard.js +1 -1547
  99. package/dist/node/ui/CrmDealCard.js +1 -50
  100. package/dist/node/ui/CrmPipelineBoard.js +1 -160
  101. package/dist/node/ui/hooks/index.js +1 -197
  102. package/dist/node/ui/hooks/useDealList.js +1 -95
  103. package/dist/node/ui/hooks/useDealMutations.js +1 -100
  104. package/dist/node/ui/index.js +4 -2205
  105. package/dist/node/ui/modals/CreateDealModal.js +1 -211
  106. package/dist/node/ui/modals/DealActionsModal.js +1 -428
  107. package/dist/node/ui/modals/index.js +1 -638
  108. package/dist/node/ui/overlays/demo-overlays.js +1 -55
  109. package/dist/node/ui/overlays/index.js +1 -55
  110. package/dist/node/ui/renderers/index.js +4 -849
  111. package/dist/node/ui/renderers/pipeline.markdown.js +4 -575
  112. package/dist/node/ui/renderers/pipeline.renderer.js +1 -275
  113. package/dist/node/ui/tables/DealListTab.js +1 -390
  114. package/dist/operations/index.js +1 -407
  115. package/dist/presentations/dashboard.presentation.js +1 -55
  116. package/dist/presentations/index.js +1 -290
  117. package/dist/presentations/pipeline.presentation.js +1 -236
  118. package/dist/seeders/index.js +1 -22
  119. package/dist/ui/CrmDashboard.js +1 -1547
  120. package/dist/ui/CrmDealCard.js +1 -50
  121. package/dist/ui/CrmPipelineBoard.js +1 -160
  122. package/dist/ui/hooks/index.js +1 -197
  123. package/dist/ui/hooks/useDealList.js +1 -95
  124. package/dist/ui/hooks/useDealMutations.js +1 -100
  125. package/dist/ui/index.js +4 -2205
  126. package/dist/ui/modals/CreateDealModal.js +1 -211
  127. package/dist/ui/modals/DealActionsModal.js +1 -428
  128. package/dist/ui/modals/index.js +1 -638
  129. package/dist/ui/overlays/demo-overlays.js +1 -55
  130. package/dist/ui/overlays/index.js +1 -55
  131. package/dist/ui/renderers/index.js +4 -849
  132. package/dist/ui/renderers/pipeline.markdown.js +4 -575
  133. package/dist/ui/renderers/pipeline.renderer.js +1 -275
  134. package/dist/ui/tables/DealListTab.js +1 -390
  135. package/package.json +16 -16
@@ -1,82 +1 @@
1
- // src/crm-pipeline.feature.ts
2
- import { defineFeature } from "@contractspec/lib.contracts-spec";
3
- var CrmPipelineFeature = defineFeature({
4
- meta: {
5
- key: "crm-pipeline",
6
- title: "CRM Pipeline",
7
- description: "CRM and sales pipeline management with deals, contacts, and companies",
8
- domain: "crm",
9
- owners: ["@crm-team"],
10
- tags: ["crm", "sales", "pipeline", "deals"],
11
- stability: "experimental",
12
- version: "1.0.0"
13
- },
14
- operations: [
15
- { key: "crm.deal.create", version: "1.0.0" },
16
- { key: "crm.deal.move", version: "1.0.0" },
17
- { key: "crm.deal.win", version: "1.0.0" },
18
- { key: "crm.deal.lose", version: "1.0.0" },
19
- { key: "crm.deal.list", version: "1.0.0" }
20
- ],
21
- events: [
22
- { key: "deal.created", version: "1.0.0" },
23
- { key: "deal.moved", version: "1.0.0" },
24
- { key: "deal.won", version: "1.0.0" },
25
- { key: "deal.lost", version: "1.0.0" },
26
- { key: "contact.created", version: "1.0.0" },
27
- { key: "task.completed", version: "1.0.0" }
28
- ],
29
- presentations: [
30
- { key: "crm.dashboard", version: "1.0.0" },
31
- { key: "crm.pipeline.kanban", version: "1.0.0" },
32
- { key: "crm.deal.viewList", version: "1.0.0" },
33
- { key: "crm.deal.detail", version: "1.0.0" },
34
- { key: "crm.deal.card", version: "1.0.0" },
35
- { key: "crm.pipeline.metrics", version: "1.0.0" }
36
- ],
37
- opToPresentation: [
38
- {
39
- op: { key: "crm.deal.list", version: "1.0.0" },
40
- pres: { key: "crm.pipeline.kanban", version: "1.0.0" }
41
- },
42
- {
43
- op: { key: "crm.deal.move", version: "1.0.0" },
44
- pres: { key: "crm.pipeline.kanban", version: "1.0.0" }
45
- }
46
- ],
47
- presentationsTargets: [
48
- { key: "crm.dashboard", version: "1.0.0", targets: ["react", "markdown"] },
49
- {
50
- key: "crm.pipeline.kanban",
51
- version: "1.0.0",
52
- targets: ["react", "markdown"]
53
- },
54
- {
55
- key: "crm.deal.viewList",
56
- version: "1.0.0",
57
- targets: ["react", "markdown", "application/json"]
58
- },
59
- {
60
- key: "crm.pipeline.metrics",
61
- version: "1.0.0",
62
- targets: ["react", "markdown"]
63
- }
64
- ],
65
- capabilities: {
66
- requires: [
67
- { key: "identity", version: "1.0.0" },
68
- { key: "audit-trail", version: "1.0.0" },
69
- { key: "notifications", version: "1.0.0" }
70
- ]
71
- },
72
- telemetry: [{ key: "crm-pipeline.telemetry", version: "1.0.0" }],
73
- docs: [
74
- "docs.examples.crm-pipeline.goal",
75
- "docs.examples.crm-pipeline.usage",
76
- "docs.examples.crm-pipeline.reference",
77
- "docs.examples.crm-pipeline.constraints"
78
- ]
79
- });
80
- export {
81
- CrmPipelineFeature
82
- };
1
+ import{defineFeature as g}from"@contractspec/lib.contracts-spec";var j=g({meta:{key:"crm-pipeline",title:"CRM Pipeline",description:"CRM and sales pipeline management with deals, contacts, and companies",domain:"crm",owners:["@crm-team"],tags:["crm","sales","pipeline","deals"],stability:"experimental",version:"1.0.0"},operations:[{key:"crm.deal.create",version:"1.0.0"},{key:"crm.deal.move",version:"1.0.0"},{key:"crm.deal.win",version:"1.0.0"},{key:"crm.deal.lose",version:"1.0.0"},{key:"crm.deal.list",version:"1.0.0"}],events:[{key:"deal.created",version:"1.0.0"},{key:"deal.moved",version:"1.0.0"},{key:"deal.won",version:"1.0.0"},{key:"deal.lost",version:"1.0.0"},{key:"contact.created",version:"1.0.0"},{key:"task.completed",version:"1.0.0"}],presentations:[{key:"crm.dashboard",version:"1.0.0"},{key:"crm.pipeline.kanban",version:"1.0.0"},{key:"crm.deal.viewList",version:"1.0.0"},{key:"crm.deal.detail",version:"1.0.0"},{key:"crm.deal.card",version:"1.0.0"},{key:"crm.pipeline.metrics",version:"1.0.0"}],opToPresentation:[{op:{key:"crm.deal.list",version:"1.0.0"},pres:{key:"crm.pipeline.kanban",version:"1.0.0"}},{op:{key:"crm.deal.move",version:"1.0.0"},pres:{key:"crm.pipeline.kanban",version:"1.0.0"}}],presentationsTargets:[{key:"crm.dashboard",version:"1.0.0",targets:["react","markdown"]},{key:"crm.pipeline.kanban",version:"1.0.0",targets:["react","markdown"]},{key:"crm.deal.viewList",version:"1.0.0",targets:["react","markdown","application/json"]},{key:"crm.pipeline.metrics",version:"1.0.0",targets:["react","markdown"]}],capabilities:{requires:[{key:"identity",version:"1.0.0"},{key:"audit-trail",version:"1.0.0"},{key:"notifications",version:"1.0.0"}]},telemetry:[{key:"crm-pipeline.telemetry",version:"1.0.0"}],docs:["docs.examples.crm-pipeline.goal","docs.examples.crm-pipeline.usage","docs.examples.crm-pipeline.reference","docs.examples.crm-pipeline.constraints"]});export{j as CrmPipelineFeature};
@@ -1,18 +1 @@
1
- // src/deal/deal.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var DealStatusEnum = defineEnum("DealStatus", [
4
- "OPEN",
5
- "WON",
6
- "LOST",
7
- "STALE"
8
- ]);
9
- var DealStatusFilterEnum = defineEnum("DealStatusFilter", [
10
- "OPEN",
11
- "WON",
12
- "LOST",
13
- "all"
14
- ]);
15
- export {
16
- DealStatusFilterEnum,
17
- DealStatusEnum
18
- };
1
+ import{defineEnum as g}from"@contractspec/lib.schema";var k=g("DealStatus",["OPEN","WON","LOST","STALE"]),q=g("DealStatusFilter",["OPEN","WON","LOST","all"]);export{q as DealStatusFilterEnum,k as DealStatusEnum};
@@ -1,396 +1 @@
1
- // src/deal/deal.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var DealStatusEnum = defineEnum("DealStatus", [
4
- "OPEN",
5
- "WON",
6
- "LOST",
7
- "STALE"
8
- ]);
9
- var DealStatusFilterEnum = defineEnum("DealStatusFilter", [
10
- "OPEN",
11
- "WON",
12
- "LOST",
13
- "all"
14
- ]);
15
-
16
- // src/deal/deal.schema.ts
17
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
18
- var DealModel = defineSchemaModel({
19
- name: "Deal",
20
- description: "A deal in the CRM pipeline",
21
- fields: {
22
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
- value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
25
- currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
- pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
- status: { type: DealStatusEnum, isOptional: false },
29
- contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
30
- companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
31
- ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
- expectedCloseDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
33
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
34
- updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
35
- }
36
- });
37
- var CreateDealInputModel = defineSchemaModel({
38
- name: "CreateDealInput",
39
- description: "Input for creating a deal",
40
- fields: {
41
- name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
- value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
43
- currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
44
- pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
- contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
- companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
48
- expectedCloseDate: { type: ScalarTypeEnum.DateTime(), isOptional: true }
49
- }
50
- });
51
- var MoveDealInputModel = defineSchemaModel({
52
- name: "MoveDealInput",
53
- description: "Input for moving a deal to another stage",
54
- fields: {
55
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
56
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
- position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
58
- }
59
- });
60
- var DealMovedPayloadModel = defineSchemaModel({
61
- name: "DealMovedPayload",
62
- fields: {
63
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
- fromStage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
- toStage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
66
- }
67
- });
68
- var WinDealInputModel = defineSchemaModel({
69
- name: "WinDealInput",
70
- description: "Input for marking a deal as won",
71
- fields: {
72
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
73
- wonSource: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
74
- notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
75
- }
76
- });
77
- var DealWonPayloadModel = defineSchemaModel({
78
- name: "DealWonPayload",
79
- fields: {
80
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
- value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
82
- }
83
- });
84
- var LoseDealInputModel = defineSchemaModel({
85
- name: "LoseDealInput",
86
- description: "Input for marking a deal as lost",
87
- fields: {
88
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
89
- lostReason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
90
- notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
91
- }
92
- });
93
- var DealLostPayloadModel = defineSchemaModel({
94
- name: "DealLostPayload",
95
- fields: {
96
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
97
- reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
98
- }
99
- });
100
- var ListDealsInputModel = defineSchemaModel({
101
- name: "ListDealsInput",
102
- description: "Input for listing deals",
103
- fields: {
104
- pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
105
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
106
- status: { type: DealStatusFilterEnum, isOptional: true },
107
- ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
108
- search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
109
- limit: {
110
- type: ScalarTypeEnum.Int_unsecure(),
111
- isOptional: true,
112
- defaultValue: 20
113
- },
114
- offset: {
115
- type: ScalarTypeEnum.Int_unsecure(),
116
- isOptional: true,
117
- defaultValue: 0
118
- }
119
- }
120
- });
121
- var ListDealsOutputModel = defineSchemaModel({
122
- name: "ListDealsOutput",
123
- description: "Output for listing deals",
124
- fields: {
125
- deals: { type: DealModel, isArray: true, isOptional: false },
126
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
127
- totalValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
128
- }
129
- });
130
-
131
- // src/deal/deal.operation.ts
132
- import {
133
- defineCommand,
134
- defineQuery
135
- } from "@contractspec/lib.contracts-spec/operations";
136
- var OWNERS = ["@example.crm-pipeline"];
137
- var CreateDealContract = defineCommand({
138
- meta: {
139
- key: "crm.deal.create",
140
- version: "1.0.0",
141
- stability: "stable",
142
- owners: [...OWNERS],
143
- tags: ["crm", "deal", "create"],
144
- description: "Create a new deal in the pipeline.",
145
- goal: "Allow sales reps to create new opportunities.",
146
- context: "Deal creation UI, quick add."
147
- },
148
- io: {
149
- input: CreateDealInputModel,
150
- output: DealModel
151
- },
152
- policy: {
153
- auth: "user"
154
- },
155
- sideEffects: {
156
- emits: [
157
- {
158
- key: "deal.created",
159
- version: "1.0.0",
160
- when: "Deal is created",
161
- payload: DealModel
162
- }
163
- ],
164
- audit: ["deal.created"]
165
- },
166
- acceptance: {
167
- scenarios: [
168
- {
169
- key: "create-deal-happy-path",
170
- given: ["User is authenticated"],
171
- when: ["User creates a deal with valid data"],
172
- then: ["Deal is created", "DealCreated event is emitted"]
173
- }
174
- ],
175
- examples: [
176
- {
177
- key: "create-basic-deal",
178
- input: {
179
- title: "Big Corp Q3 License",
180
- stageId: "stage-lead",
181
- value: 50000,
182
- companyId: "comp-123"
183
- },
184
- output: {
185
- id: "deal-789",
186
- title: "Big Corp Q3 License",
187
- status: "open"
188
- }
189
- }
190
- ]
191
- }
192
- });
193
- var MoveDealContract = defineCommand({
194
- meta: {
195
- key: "crm.deal.move",
196
- version: "1.0.0",
197
- stability: "stable",
198
- owners: [...OWNERS],
199
- tags: ["crm", "deal", "move", "kanban"],
200
- description: "Move a deal to a different stage.",
201
- goal: "Allow drag-and-drop stage movement in Kanban.",
202
- context: "Pipeline Kanban view."
203
- },
204
- io: {
205
- input: MoveDealInputModel,
206
- output: DealModel
207
- },
208
- policy: {
209
- auth: "user"
210
- },
211
- sideEffects: {
212
- emits: [
213
- {
214
- key: "deal.moved",
215
- version: "1.0.0",
216
- when: "Deal stage changed",
217
- payload: DealMovedPayloadModel
218
- }
219
- ],
220
- audit: ["deal.moved"]
221
- },
222
- acceptance: {
223
- scenarios: [
224
- {
225
- key: "move-deal-happy-path",
226
- given: ["Deal exists in stage A"],
227
- when: ["User moves deal to stage B"],
228
- then: ["Deal stage is updated", "DealMoved event is emitted"]
229
- }
230
- ],
231
- examples: [
232
- {
233
- key: "move-to-negotiation",
234
- input: { dealId: "deal-789", targetStageId: "stage-negotiation" },
235
- output: {
236
- id: "deal-789",
237
- stageId: "stage-negotiation",
238
- movedAt: "2025-01-15T10:00:00Z"
239
- }
240
- }
241
- ]
242
- }
243
- });
244
- var WinDealContract = defineCommand({
245
- meta: {
246
- key: "crm.deal.win",
247
- version: "1.0.0",
248
- stability: "stable",
249
- owners: [...OWNERS],
250
- tags: ["crm", "deal", "won"],
251
- description: "Mark a deal as won.",
252
- goal: "Close a deal as successful.",
253
- context: "Deal closing flow."
254
- },
255
- io: {
256
- input: WinDealInputModel,
257
- output: DealModel
258
- },
259
- policy: {
260
- auth: "user"
261
- },
262
- sideEffects: {
263
- emits: [
264
- {
265
- key: "deal.won",
266
- version: "1.0.0",
267
- when: "Deal is won",
268
- payload: DealWonPayloadModel
269
- }
270
- ],
271
- audit: ["deal.won"]
272
- },
273
- acceptance: {
274
- scenarios: [
275
- {
276
- key: "win-deal-happy-path",
277
- given: ["Deal is open"],
278
- when: ["User marks deal as won"],
279
- then: ["Deal status becomes WON", "DealWon event is emitted"]
280
- }
281
- ],
282
- examples: [
283
- {
284
- key: "mark-won",
285
- input: {
286
- dealId: "deal-789",
287
- actualValue: 52000,
288
- note: "Signed contract attached"
289
- },
290
- output: {
291
- id: "deal-789",
292
- status: "won",
293
- closedAt: "2025-01-20T14:30:00Z"
294
- }
295
- }
296
- ]
297
- }
298
- });
299
- var LoseDealContract = defineCommand({
300
- meta: {
301
- key: "crm.deal.lose",
302
- version: "1.0.0",
303
- stability: "stable",
304
- owners: [...OWNERS],
305
- tags: ["crm", "deal", "lost"],
306
- description: "Mark a deal as lost.",
307
- goal: "Close a deal as unsuccessful.",
308
- context: "Deal closing flow."
309
- },
310
- io: {
311
- input: LoseDealInputModel,
312
- output: DealModel
313
- },
314
- policy: {
315
- auth: "user"
316
- },
317
- sideEffects: {
318
- emits: [
319
- {
320
- key: "deal.lost",
321
- version: "1.0.0",
322
- when: "Deal is lost",
323
- payload: DealLostPayloadModel
324
- }
325
- ],
326
- audit: ["deal.lost"]
327
- },
328
- acceptance: {
329
- scenarios: [
330
- {
331
- key: "lose-deal-happy-path",
332
- given: ["Deal is open"],
333
- when: ["User marks deal as lost"],
334
- then: ["Deal status becomes LOST", "DealLost event is emitted"]
335
- }
336
- ],
337
- examples: [
338
- {
339
- key: "mark-lost",
340
- input: {
341
- dealId: "deal-789",
342
- reason: "competitor",
343
- note: "Went with cheaper option"
344
- },
345
- output: {
346
- id: "deal-789",
347
- status: "lost",
348
- closedAt: "2025-01-21T09:00:00Z"
349
- }
350
- }
351
- ]
352
- }
353
- });
354
- var ListDealsContract = defineQuery({
355
- meta: {
356
- key: "crm.deal.list",
357
- version: "1.0.0",
358
- stability: "stable",
359
- owners: [...OWNERS],
360
- tags: ["crm", "deal", "list"],
361
- description: "List deals with filters.",
362
- goal: "Show pipeline, deal lists, dashboards.",
363
- context: "Pipeline view, deal list."
364
- },
365
- io: {
366
- input: ListDealsInputModel,
367
- output: ListDealsOutputModel
368
- },
369
- policy: {
370
- auth: "user"
371
- },
372
- acceptance: {
373
- scenarios: [
374
- {
375
- key: "list-deals-happy-path",
376
- given: ["User has access to deals"],
377
- when: ["User lists deals"],
378
- then: ["List of deals is returned"]
379
- }
380
- ],
381
- examples: [
382
- {
383
- key: "list-filter-stage",
384
- input: { stageId: "stage-lead", limit: 20 },
385
- output: { items: [], total: 5, hasMore: false }
386
- }
387
- ]
388
- }
389
- });
390
- export {
391
- WinDealContract,
392
- MoveDealContract,
393
- LoseDealContract,
394
- ListDealsContract,
395
- CreateDealContract
396
- };
1
+ import{defineEnum as z}from"@contractspec/lib.schema";var A=z("DealStatus",["OPEN","WON","LOST","STALE"]),B=z("DealStatusFilter",["OPEN","WON","LOST","all"]);import{defineSchemaModel as k,ScalarTypeEnum as j}from"@contractspec/lib.schema";var q=k({name:"Deal",description:"A deal in the CRM pipeline",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!1},value:{type:j.Float_unsecure(),isOptional:!1},currency:{type:j.String_unsecure(),isOptional:!1},pipelineId:{type:j.String_unsecure(),isOptional:!1},stageId:{type:j.String_unsecure(),isOptional:!1},status:{type:A,isOptional:!1},contactId:{type:j.String_unsecure(),isOptional:!0},companyId:{type:j.String_unsecure(),isOptional:!0},ownerId:{type:j.String_unsecure(),isOptional:!1},expectedCloseDate:{type:j.DateTime(),isOptional:!0},createdAt:{type:j.DateTime(),isOptional:!1},updatedAt:{type:j.DateTime(),isOptional:!1}}}),G=k({name:"CreateDealInput",description:"Input for creating a deal",fields:{name:{type:j.NonEmptyString(),isOptional:!1},value:{type:j.Float_unsecure(),isOptional:!1},currency:{type:j.String_unsecure(),isOptional:!0},pipelineId:{type:j.String_unsecure(),isOptional:!1},stageId:{type:j.String_unsecure(),isOptional:!1},contactId:{type:j.String_unsecure(),isOptional:!0},companyId:{type:j.String_unsecure(),isOptional:!0},expectedCloseDate:{type:j.DateTime(),isOptional:!0}}}),H=k({name:"MoveDealInput",description:"Input for moving a deal to another stage",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},stageId:{type:j.String_unsecure(),isOptional:!1},position:{type:j.Int_unsecure(),isOptional:!0}}}),J=k({name:"DealMovedPayload",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},fromStage:{type:j.String_unsecure(),isOptional:!1},toStage:{type:j.String_unsecure(),isOptional:!1}}}),K=k({name:"WinDealInput",description:"Input for marking a deal as won",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},wonSource:{type:j.String_unsecure(),isOptional:!0},notes:{type:j.String_unsecure(),isOptional:!0}}}),U=k({name:"DealWonPayload",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},value:{type:j.Float_unsecure(),isOptional:!1}}}),V=k({name:"LoseDealInput",description:"Input for marking a deal as lost",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},lostReason:{type:j.String_unsecure(),isOptional:!1},notes:{type:j.String_unsecure(),isOptional:!0}}}),X=k({name:"DealLostPayload",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},reason:{type:j.String_unsecure(),isOptional:!1}}}),Y=k({name:"ListDealsInput",description:"Input for listing deals",fields:{pipelineId:{type:j.String_unsecure(),isOptional:!0},stageId:{type:j.String_unsecure(),isOptional:!0},status:{type:B,isOptional:!0},ownerId:{type:j.String_unsecure(),isOptional:!0},search:{type:j.String_unsecure(),isOptional:!0},limit:{type:j.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:j.Int_unsecure(),isOptional:!0,defaultValue:0}}}),Z=k({name:"ListDealsOutput",description:"Output for listing deals",fields:{deals:{type:q,isArray:!0,isOptional:!1},total:{type:j.Int_unsecure(),isOptional:!1},totalValue:{type:j.Float_unsecure(),isOptional:!1}}});import{defineCommand as x,defineQuery as _}from"@contractspec/lib.contracts-spec/operations";var w=["@example.crm-pipeline"],L=x({meta:{key:"crm.deal.create",version:"1.0.0",stability:"stable",owners:[...w],tags:["crm","deal","create"],description:"Create a new deal in the pipeline.",goal:"Allow sales reps to create new opportunities.",context:"Deal creation UI, quick add."},io:{input:G,output:q},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.created",version:"1.0.0",when:"Deal is created",payload:q}],audit:["deal.created"]},acceptance:{scenarios:[{key:"create-deal-happy-path",given:["User is authenticated"],when:["User creates a deal with valid data"],then:["Deal is created","DealCreated event is emitted"]}],examples:[{key:"create-basic-deal",input:{title:"Big Corp Q3 License",stageId:"stage-lead",value:50000,companyId:"comp-123"},output:{id:"deal-789",title:"Big Corp Q3 License",status:"open"}}]}}),C=x({meta:{key:"crm.deal.move",version:"1.0.0",stability:"stable",owners:[...w],tags:["crm","deal","move","kanban"],description:"Move a deal to a different stage.",goal:"Allow drag-and-drop stage movement in Kanban.",context:"Pipeline Kanban view."},io:{input:H,output:q},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.moved",version:"1.0.0",when:"Deal stage changed",payload:J}],audit:["deal.moved"]},acceptance:{scenarios:[{key:"move-deal-happy-path",given:["Deal exists in stage A"],when:["User moves deal to stage B"],then:["Deal stage is updated","DealMoved event is emitted"]}],examples:[{key:"move-to-negotiation",input:{dealId:"deal-789",targetStageId:"stage-negotiation"},output:{id:"deal-789",stageId:"stage-negotiation",movedAt:"2025-01-15T10:00:00Z"}}]}}),I=x({meta:{key:"crm.deal.win",version:"1.0.0",stability:"stable",owners:[...w],tags:["crm","deal","won"],description:"Mark a deal as won.",goal:"Close a deal as successful.",context:"Deal closing flow."},io:{input:K,output:q},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.won",version:"1.0.0",when:"Deal is won",payload:U}],audit:["deal.won"]},acceptance:{scenarios:[{key:"win-deal-happy-path",given:["Deal is open"],when:["User marks deal as won"],then:["Deal status becomes WON","DealWon event is emitted"]}],examples:[{key:"mark-won",input:{dealId:"deal-789",actualValue:52000,note:"Signed contract attached"},output:{id:"deal-789",status:"won",closedAt:"2025-01-20T14:30:00Z"}}]}}),N=x({meta:{key:"crm.deal.lose",version:"1.0.0",stability:"stable",owners:[...w],tags:["crm","deal","lost"],description:"Mark a deal as lost.",goal:"Close a deal as unsuccessful.",context:"Deal closing flow."},io:{input:V,output:q},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.lost",version:"1.0.0",when:"Deal is lost",payload:X}],audit:["deal.lost"]},acceptance:{scenarios:[{key:"lose-deal-happy-path",given:["Deal is open"],when:["User marks deal as lost"],then:["Deal status becomes LOST","DealLost event is emitted"]}],examples:[{key:"mark-lost",input:{dealId:"deal-789",reason:"competitor",note:"Went with cheaper option"},output:{id:"deal-789",status:"lost",closedAt:"2025-01-21T09:00:00Z"}}]}}),R=_({meta:{key:"crm.deal.list",version:"1.0.0",stability:"stable",owners:[...w],tags:["crm","deal","list"],description:"List deals with filters.",goal:"Show pipeline, deal lists, dashboards.",context:"Pipeline view, deal list."},io:{input:Y,output:Z},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-deals-happy-path",given:["User has access to deals"],when:["User lists deals"],then:["List of deals is returned"]}],examples:[{key:"list-filter-stage",input:{stageId:"stage-lead",limit:20},output:{items:[],total:5,hasMore:!1}}]}});export{I as WinDealContract,C as MoveDealContract,N as LoseDealContract,R as ListDealsContract,L as CreateDealContract};
@@ -1,141 +1 @@
1
- // src/deal/deal.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var DealStatusEnum = defineEnum("DealStatus", [
4
- "OPEN",
5
- "WON",
6
- "LOST",
7
- "STALE"
8
- ]);
9
- var DealStatusFilterEnum = defineEnum("DealStatusFilter", [
10
- "OPEN",
11
- "WON",
12
- "LOST",
13
- "all"
14
- ]);
15
-
16
- // src/deal/deal.schema.ts
17
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
18
- var DealModel = defineSchemaModel({
19
- name: "Deal",
20
- description: "A deal in the CRM pipeline",
21
- fields: {
22
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
23
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
- value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
25
- currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
- pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
- status: { type: DealStatusEnum, isOptional: false },
29
- contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
30
- companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
31
- ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
- expectedCloseDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },
33
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
34
- updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
35
- }
36
- });
37
- var CreateDealInputModel = defineSchemaModel({
38
- name: "CreateDealInput",
39
- description: "Input for creating a deal",
40
- fields: {
41
- name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
- value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
43
- currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
44
- pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
- contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
- companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
48
- expectedCloseDate: { type: ScalarTypeEnum.DateTime(), isOptional: true }
49
- }
50
- });
51
- var MoveDealInputModel = defineSchemaModel({
52
- name: "MoveDealInput",
53
- description: "Input for moving a deal to another stage",
54
- fields: {
55
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
56
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
- position: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
58
- }
59
- });
60
- var DealMovedPayloadModel = defineSchemaModel({
61
- name: "DealMovedPayload",
62
- fields: {
63
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
- fromStage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
65
- toStage: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
66
- }
67
- });
68
- var WinDealInputModel = defineSchemaModel({
69
- name: "WinDealInput",
70
- description: "Input for marking a deal as won",
71
- fields: {
72
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
73
- wonSource: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
74
- notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
75
- }
76
- });
77
- var DealWonPayloadModel = defineSchemaModel({
78
- name: "DealWonPayload",
79
- fields: {
80
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
- value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
82
- }
83
- });
84
- var LoseDealInputModel = defineSchemaModel({
85
- name: "LoseDealInput",
86
- description: "Input for marking a deal as lost",
87
- fields: {
88
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
89
- lostReason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
90
- notes: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
91
- }
92
- });
93
- var DealLostPayloadModel = defineSchemaModel({
94
- name: "DealLostPayload",
95
- fields: {
96
- dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
97
- reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
98
- }
99
- });
100
- var ListDealsInputModel = defineSchemaModel({
101
- name: "ListDealsInput",
102
- description: "Input for listing deals",
103
- fields: {
104
- pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
105
- stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
106
- status: { type: DealStatusFilterEnum, isOptional: true },
107
- ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
108
- search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
109
- limit: {
110
- type: ScalarTypeEnum.Int_unsecure(),
111
- isOptional: true,
112
- defaultValue: 20
113
- },
114
- offset: {
115
- type: ScalarTypeEnum.Int_unsecure(),
116
- isOptional: true,
117
- defaultValue: 0
118
- }
119
- }
120
- });
121
- var ListDealsOutputModel = defineSchemaModel({
122
- name: "ListDealsOutput",
123
- description: "Output for listing deals",
124
- fields: {
125
- deals: { type: DealModel, isArray: true, isOptional: false },
126
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
127
- totalValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false }
128
- }
129
- });
130
- export {
131
- WinDealInputModel,
132
- MoveDealInputModel,
133
- LoseDealInputModel,
134
- ListDealsOutputModel,
135
- ListDealsInputModel,
136
- DealWonPayloadModel,
137
- DealMovedPayloadModel,
138
- DealModel,
139
- DealLostPayloadModel,
140
- CreateDealInputModel
141
- };
1
+ import{defineEnum as q}from"@contractspec/lib.schema";var v=q("DealStatus",["OPEN","WON","LOST","STALE"]),w=q("DealStatusFilter",["OPEN","WON","LOST","all"]);import{defineSchemaModel as k,ScalarTypeEnum as j}from"@contractspec/lib.schema";var x=k({name:"Deal",description:"A deal in the CRM pipeline",fields:{id:{type:j.String_unsecure(),isOptional:!1},name:{type:j.String_unsecure(),isOptional:!1},value:{type:j.Float_unsecure(),isOptional:!1},currency:{type:j.String_unsecure(),isOptional:!1},pipelineId:{type:j.String_unsecure(),isOptional:!1},stageId:{type:j.String_unsecure(),isOptional:!1},status:{type:v,isOptional:!1},contactId:{type:j.String_unsecure(),isOptional:!0},companyId:{type:j.String_unsecure(),isOptional:!0},ownerId:{type:j.String_unsecure(),isOptional:!1},expectedCloseDate:{type:j.DateTime(),isOptional:!0},createdAt:{type:j.DateTime(),isOptional:!1},updatedAt:{type:j.DateTime(),isOptional:!1}}}),G=k({name:"CreateDealInput",description:"Input for creating a deal",fields:{name:{type:j.NonEmptyString(),isOptional:!1},value:{type:j.Float_unsecure(),isOptional:!1},currency:{type:j.String_unsecure(),isOptional:!0},pipelineId:{type:j.String_unsecure(),isOptional:!1},stageId:{type:j.String_unsecure(),isOptional:!1},contactId:{type:j.String_unsecure(),isOptional:!0},companyId:{type:j.String_unsecure(),isOptional:!0},expectedCloseDate:{type:j.DateTime(),isOptional:!0}}}),H=k({name:"MoveDealInput",description:"Input for moving a deal to another stage",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},stageId:{type:j.String_unsecure(),isOptional:!1},position:{type:j.Int_unsecure(),isOptional:!0}}}),I=k({name:"DealMovedPayload",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},fromStage:{type:j.String_unsecure(),isOptional:!1},toStage:{type:j.String_unsecure(),isOptional:!1}}}),J=k({name:"WinDealInput",description:"Input for marking a deal as won",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},wonSource:{type:j.String_unsecure(),isOptional:!0},notes:{type:j.String_unsecure(),isOptional:!0}}}),K=k({name:"DealWonPayload",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},value:{type:j.Float_unsecure(),isOptional:!1}}}),L=k({name:"LoseDealInput",description:"Input for marking a deal as lost",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},lostReason:{type:j.String_unsecure(),isOptional:!1},notes:{type:j.String_unsecure(),isOptional:!0}}}),N=k({name:"DealLostPayload",fields:{dealId:{type:j.String_unsecure(),isOptional:!1},reason:{type:j.String_unsecure(),isOptional:!1}}}),P=k({name:"ListDealsInput",description:"Input for listing deals",fields:{pipelineId:{type:j.String_unsecure(),isOptional:!0},stageId:{type:j.String_unsecure(),isOptional:!0},status:{type:w,isOptional:!0},ownerId:{type:j.String_unsecure(),isOptional:!0},search:{type:j.String_unsecure(),isOptional:!0},limit:{type:j.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:j.Int_unsecure(),isOptional:!0,defaultValue:0}}}),Q=k({name:"ListDealsOutput",description:"Output for listing deals",fields:{deals:{type:x,isArray:!0,isOptional:!1},total:{type:j.Int_unsecure(),isOptional:!1},totalValue:{type:j.Float_unsecure(),isOptional:!1}}});export{J as WinDealInputModel,H as MoveDealInputModel,L as LoseDealInputModel,Q as ListDealsOutputModel,P as ListDealsInputModel,K as DealWonPayloadModel,I as DealMovedPayloadModel,x as DealModel,N as DealLostPayloadModel,G as CreateDealInputModel};