@contractspec/example.crm-pipeline 3.7.17 → 3.7.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/.turbo/turbo-build.log +135 -135
  2. package/CHANGELOG.md +20 -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 +13 -13
@@ -1,59 +1,2 @@
1
1
  // @bun
2
- // src/deal/deal.test-spec.ts
3
- import { defineTestSpec } from "@contractspec/lib.contracts-spec/tests";
4
- var dealListTest = defineTestSpec({
5
- meta: {
6
- key: "test.crm.deal.list",
7
- version: "1.0.0",
8
- owners: ["@example.crm-pipeline"],
9
- description: "Test for listing deals",
10
- stability: "stable",
11
- tags: ["test"]
12
- },
13
- target: {
14
- type: "operation",
15
- operation: { key: "crm.deal.list", version: "1.0.0" }
16
- },
17
- scenarios: [
18
- {
19
- key: "success",
20
- when: { operation: { key: "crm.deal.list" } },
21
- then: [{ type: "expectOutput", match: {} }]
22
- },
23
- {
24
- key: "error",
25
- when: { operation: { key: "crm.deal.list" } },
26
- then: [{ type: "expectError" }]
27
- }
28
- ]
29
- });
30
- var dealMoveTest = defineTestSpec({
31
- meta: {
32
- key: "test.crm.deal.move",
33
- version: "1.0.0",
34
- owners: ["@example.crm-pipeline"],
35
- description: "Test for moving deal",
36
- stability: "stable",
37
- tags: ["test"]
38
- },
39
- target: {
40
- type: "operation",
41
- operation: { key: "crm.deal.move", version: "1.0.0" }
42
- },
43
- scenarios: [
44
- {
45
- key: "success",
46
- when: { operation: { key: "crm.deal.move" } },
47
- then: [{ type: "expectOutput", match: {} }]
48
- },
49
- {
50
- key: "error",
51
- when: { operation: { key: "crm.deal.move" } },
52
- then: [{ type: "expectError" }]
53
- }
54
- ]
55
- });
56
- export {
57
- dealMoveTest,
58
- dealListTest
59
- };
2
+ import{defineTestSpec as g}from"@contractspec/lib.contracts-spec/tests";var j=g({meta:{key:"test.crm.deal.list",version:"1.0.0",owners:["@example.crm-pipeline"],description:"Test for listing deals",stability:"stable",tags:["test"]},target:{type:"operation",operation:{key:"crm.deal.list",version:"1.0.0"}},scenarios:[{key:"success",when:{operation:{key:"crm.deal.list"}},then:[{type:"expectOutput",match:{}}]},{key:"error",when:{operation:{key:"crm.deal.list"}},then:[{type:"expectError"}]}]}),k=g({meta:{key:"test.crm.deal.move",version:"1.0.0",owners:["@example.crm-pipeline"],description:"Test for moving deal",stability:"stable",tags:["test"]},target:{type:"operation",operation:{key:"crm.deal.move",version:"1.0.0"}},scenarios:[{key:"success",when:{operation:{key:"crm.deal.move"}},then:[{type:"expectOutput",match:{}}]},{key:"error",when:{operation:{key:"crm.deal.move"}},then:[{type:"expectError"}]}]});export{k as dealMoveTest,j as dealListTest};
@@ -1,409 +1,2 @@
1
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
- ]);
16
-
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
- }
37
- });
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
- }
51
- });
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
- }
60
- });
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
- }
68
- });
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
- }
130
- });
131
-
132
- // src/deal/deal.operation.ts
133
- import {
134
- defineCommand,
135
- defineQuery
136
- } from "@contractspec/lib.contracts-spec/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
- WinDealInputModel,
393
- WinDealContract,
394
- MoveDealInputModel,
395
- MoveDealContract,
396
- LoseDealInputModel,
397
- LoseDealContract,
398
- ListDealsOutputModel,
399
- ListDealsInputModel,
400
- ListDealsContract,
401
- DealWonPayloadModel,
402
- DealStatusFilterEnum,
403
- DealStatusEnum,
404
- DealMovedPayloadModel,
405
- DealModel,
406
- DealLostPayloadModel,
407
- CreateDealInputModel,
408
- CreateDealContract
409
- };
2
+ import{defineEnum as H}from"@contractspec/lib.schema";var D=H("DealStatus",["OPEN","WON","LOST","STALE"]),g=H("DealStatusFilter",["OPEN","WON","LOST","all"]);import{defineSchemaModel as C,ScalarTypeEnum as x}from"@contractspec/lib.schema";var L=C({name:"Deal",description:"A deal in the CRM pipeline",fields:{id:{type:x.String_unsecure(),isOptional:!1},name:{type:x.String_unsecure(),isOptional:!1},value:{type:x.Float_unsecure(),isOptional:!1},currency:{type:x.String_unsecure(),isOptional:!1},pipelineId:{type:x.String_unsecure(),isOptional:!1},stageId:{type:x.String_unsecure(),isOptional:!1},status:{type:D,isOptional:!1},contactId:{type:x.String_unsecure(),isOptional:!0},companyId:{type:x.String_unsecure(),isOptional:!0},ownerId:{type:x.String_unsecure(),isOptional:!1},expectedCloseDate:{type:x.DateTime(),isOptional:!0},createdAt:{type:x.DateTime(),isOptional:!1},updatedAt:{type:x.DateTime(),isOptional:!1}}}),j=C({name:"CreateDealInput",description:"Input for creating a deal",fields:{name:{type:x.NonEmptyString(),isOptional:!1},value:{type:x.Float_unsecure(),isOptional:!1},currency:{type:x.String_unsecure(),isOptional:!0},pipelineId:{type:x.String_unsecure(),isOptional:!1},stageId:{type:x.String_unsecure(),isOptional:!1},contactId:{type:x.String_unsecure(),isOptional:!0},companyId:{type:x.String_unsecure(),isOptional:!0},expectedCloseDate:{type:x.DateTime(),isOptional:!0}}}),k=C({name:"MoveDealInput",description:"Input for moving a deal to another stage",fields:{dealId:{type:x.String_unsecure(),isOptional:!1},stageId:{type:x.String_unsecure(),isOptional:!1},position:{type:x.Int_unsecure(),isOptional:!0}}}),q=C({name:"DealMovedPayload",fields:{dealId:{type:x.String_unsecure(),isOptional:!1},fromStage:{type:x.String_unsecure(),isOptional:!1},toStage:{type:x.String_unsecure(),isOptional:!1}}}),w=C({name:"WinDealInput",description:"Input for marking a deal as won",fields:{dealId:{type:x.String_unsecure(),isOptional:!1},wonSource:{type:x.String_unsecure(),isOptional:!0},notes:{type:x.String_unsecure(),isOptional:!0}}}),z=C({name:"DealWonPayload",fields:{dealId:{type:x.String_unsecure(),isOptional:!1},value:{type:x.Float_unsecure(),isOptional:!1}}}),A=C({name:"LoseDealInput",description:"Input for marking a deal as lost",fields:{dealId:{type:x.String_unsecure(),isOptional:!1},lostReason:{type:x.String_unsecure(),isOptional:!1},notes:{type:x.String_unsecure(),isOptional:!0}}}),B=C({name:"DealLostPayload",fields:{dealId:{type:x.String_unsecure(),isOptional:!1},reason:{type:x.String_unsecure(),isOptional:!1}}}),F=C({name:"ListDealsInput",description:"Input for listing deals",fields:{pipelineId:{type:x.String_unsecure(),isOptional:!0},stageId:{type:x.String_unsecure(),isOptional:!0},status:{type:g,isOptional:!0},ownerId:{type:x.String_unsecure(),isOptional:!0},search:{type:x.String_unsecure(),isOptional:!0},limit:{type:x.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:x.Int_unsecure(),isOptional:!0,defaultValue:0}}}),G=C({name:"ListDealsOutput",description:"Output for listing deals",fields:{deals:{type:L,isArray:!0,isOptional:!1},total:{type:x.Int_unsecure(),isOptional:!1},totalValue:{type:x.Float_unsecure(),isOptional:!1}}});import{defineCommand as v,defineQuery as I}from"@contractspec/lib.contracts-spec/operations";var t=["@example.crm-pipeline"],J=v({meta:{key:"crm.deal.create",version:"1.0.0",stability:"stable",owners:[...t],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:j,output:L},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.created",version:"1.0.0",when:"Deal is created",payload:L}],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"}}]}}),K=v({meta:{key:"crm.deal.move",version:"1.0.0",stability:"stable",owners:[...t],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:k,output:L},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.moved",version:"1.0.0",when:"Deal stage changed",payload:q}],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"}}]}}),P=v({meta:{key:"crm.deal.win",version:"1.0.0",stability:"stable",owners:[...t],tags:["crm","deal","won"],description:"Mark a deal as won.",goal:"Close a deal as successful.",context:"Deal closing flow."},io:{input:w,output:L},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.won",version:"1.0.0",when:"Deal is won",payload:z}],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"}}]}}),U=v({meta:{key:"crm.deal.lose",version:"1.0.0",stability:"stable",owners:[...t],tags:["crm","deal","lost"],description:"Mark a deal as lost.",goal:"Close a deal as unsuccessful.",context:"Deal closing flow."},io:{input:A,output:L},policy:{auth:"user"},sideEffects:{emits:[{key:"deal.lost",version:"1.0.0",when:"Deal is lost",payload:B}],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"}}]}}),V=I({meta:{key:"crm.deal.list",version:"1.0.0",stability:"stable",owners:[...t],tags:["crm","deal","list"],description:"List deals with filters.",goal:"Show pipeline, deal lists, dashboards.",context:"Pipeline view, deal list."},io:{input:F,output:G},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{w as WinDealInputModel,P as WinDealContract,k as MoveDealInputModel,K as MoveDealContract,A as LoseDealInputModel,U as LoseDealContract,G as ListDealsOutputModel,F as ListDealsInputModel,V as ListDealsContract,z as DealWonPayloadModel,g as DealStatusFilterEnum,D as DealStatusEnum,q as DealMovedPayloadModel,L as DealModel,B as DealLostPayloadModel,j as CreateDealInputModel,J as CreateDealContract};
@@ -1,16 +1,5 @@
1
1
  // @bun
2
- // src/docs/crm-pipeline.docblock.ts
3
- import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
4
- var crmPipelineDocBlocks = [
5
- {
6
- id: "docs.examples.crm-pipeline.goal",
7
- title: "CRM Pipeline \u2014 Goal",
8
- summary: "Deals, stages, contacts, companies, and tasks with auditable stage movement.",
9
- kind: "goal",
10
- visibility: "public",
11
- route: "/docs/examples/crm-pipeline/goal",
12
- tags: ["crm", "goal"],
13
- body: `## Why it matters
2
+ import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.examples.crm-pipeline.goal",title:"CRM Pipeline \u2014 Goal",summary:"Deals, stages, contacts, companies, and tasks with auditable stage movement.",kind:"goal",visibility:"public",route:"/docs/examples/crm-pipeline/goal",tags:["crm","goal"],body:`## Why it matters
14
3
  - Regenerable CRM flow for deals/stages without code drift.
15
4
  - Ensures stage movement, tasks, and contacts stay aligned across surfaces.
16
5
 
@@ -20,17 +9,7 @@ var crmPipelineDocBlocks = [
20
9
 
21
10
  ## Success criteria
22
11
  - Stage/state changes emit events and remain declarative in spec.
23
- - PII (contacts) is scoped/redacted in presentations.`
24
- },
25
- {
26
- id: "docs.examples.crm-pipeline.usage",
27
- title: "CRM Pipeline \u2014 Usage",
28
- summary: "How to seed, extend, and regenerate the CRM pipeline.",
29
- kind: "usage",
30
- visibility: "public",
31
- route: "/docs/examples/crm-pipeline/usage",
32
- tags: ["crm", "usage"],
33
- body: `## Setup
12
+ - PII (contacts) is scoped/redacted in presentations.`},{id:"docs.examples.crm-pipeline.usage",title:"CRM Pipeline \u2014 Usage",summary:"How to seed, extend, and regenerate the CRM pipeline.",kind:"usage",visibility:"public",route:"/docs/examples/crm-pipeline/usage",tags:["crm","usage"],body:`## Setup
34
13
  1) Seed (if available) or create pipeline stages, deals, contacts, companies, tasks.
35
14
  2) Configure Notifications for stage changes/tasks; set policy.pii for contact data.
36
15
 
@@ -62,17 +41,7 @@ var crmPipelineDocBlocks = [
62
41
  3) Run contractspec build to generate handlers and types.
63
42
  4) Wire the generated handler into your existing router.
64
43
  5) Expand to events and presentations as you add surface areas.
65
- `
66
- },
67
- {
68
- id: "docs.examples.crm-pipeline.reference",
69
- title: "CRM Pipeline \u2014 Reference",
70
- summary: "Entities, contracts, events, and presentations for the CRM template.",
71
- kind: "reference",
72
- visibility: "public",
73
- route: "/docs/examples/crm-pipeline",
74
- tags: ["crm", "reference"],
75
- body: `## Entities
44
+ `},{id:"docs.examples.crm-pipeline.reference",title:"CRM Pipeline \u2014 Reference",summary:"Entities, contracts, events, and presentations for the CRM template.",kind:"reference",visibility:"public",route:"/docs/examples/crm-pipeline",tags:["crm","reference"],body:`## Entities
76
45
  - Contact, Company, Deal, Pipeline, Stage, Task.
77
46
 
78
47
  ## Contracts
@@ -86,17 +55,7 @@ var crmPipelineDocBlocks = [
86
55
 
87
56
  ## Notes
88
57
  - Stage definitions should be declarative; enforce via spec and regeneration.
89
- - Use Notifications for deal/task updates; Audit Trail for state changes.`
90
- },
91
- {
92
- id: "docs.examples.crm-pipeline.constraints",
93
- title: "CRM Pipeline \u2014 Constraints & Safety",
94
- summary: "Internal guardrails for stages, PII, and regeneration semantics in the CRM template.",
95
- kind: "reference",
96
- visibility: "internal",
97
- route: "/docs/examples/crm-pipeline/constraints",
98
- tags: ["crm", "constraints", "internal"],
99
- body: `## Constraints
58
+ - Use Notifications for deal/task updates; Audit Trail for state changes.`},{id:"docs.examples.crm-pipeline.constraints",title:"CRM Pipeline \u2014 Constraints & Safety",summary:"Internal guardrails for stages, PII, and regeneration semantics in the CRM template.",kind:"reference",visibility:"internal",route:"/docs/examples/crm-pipeline/constraints",tags:["crm","constraints","internal"],body:`## Constraints
100
59
  - Stage definitions/order must remain declarative; no imperative overrides in code.
101
60
  - Events to emit: deal.created, stage.moved, task.completed, contact.updated (minimum).
102
61
  - Regeneration should not alter stage semantics without explicit spec change.
@@ -108,7 +67,4 @@ var crmPipelineDocBlocks = [
108
67
  ## Verification
109
68
  - Add fixtures for stage move rules and SLA/task changes.
110
69
  - Ensure Audit/Notifications remain wired for stage and task events.
111
- - Use Feature Flags for experimental stages/SLAs; default safe/off.`
112
- }
113
- ];
114
- registerDocBlocks(crmPipelineDocBlocks);
70
+ - Use Feature Flags for experimental stages/SLAs; default safe/off.`}];f(h);
@@ -1,16 +1,5 @@
1
1
  // @bun
2
- // src/docs/crm-pipeline.docblock.ts
3
- import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
4
- var crmPipelineDocBlocks = [
5
- {
6
- id: "docs.examples.crm-pipeline.goal",
7
- title: "CRM Pipeline \u2014 Goal",
8
- summary: "Deals, stages, contacts, companies, and tasks with auditable stage movement.",
9
- kind: "goal",
10
- visibility: "public",
11
- route: "/docs/examples/crm-pipeline/goal",
12
- tags: ["crm", "goal"],
13
- body: `## Why it matters
2
+ import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.examples.crm-pipeline.goal",title:"CRM Pipeline \u2014 Goal",summary:"Deals, stages, contacts, companies, and tasks with auditable stage movement.",kind:"goal",visibility:"public",route:"/docs/examples/crm-pipeline/goal",tags:["crm","goal"],body:`## Why it matters
14
3
  - Regenerable CRM flow for deals/stages without code drift.
15
4
  - Ensures stage movement, tasks, and contacts stay aligned across surfaces.
16
5
 
@@ -20,17 +9,7 @@ var crmPipelineDocBlocks = [
20
9
 
21
10
  ## Success criteria
22
11
  - Stage/state changes emit events and remain declarative in spec.
23
- - PII (contacts) is scoped/redacted in presentations.`
24
- },
25
- {
26
- id: "docs.examples.crm-pipeline.usage",
27
- title: "CRM Pipeline \u2014 Usage",
28
- summary: "How to seed, extend, and regenerate the CRM pipeline.",
29
- kind: "usage",
30
- visibility: "public",
31
- route: "/docs/examples/crm-pipeline/usage",
32
- tags: ["crm", "usage"],
33
- body: `## Setup
12
+ - PII (contacts) is scoped/redacted in presentations.`},{id:"docs.examples.crm-pipeline.usage",title:"CRM Pipeline \u2014 Usage",summary:"How to seed, extend, and regenerate the CRM pipeline.",kind:"usage",visibility:"public",route:"/docs/examples/crm-pipeline/usage",tags:["crm","usage"],body:`## Setup
34
13
  1) Seed (if available) or create pipeline stages, deals, contacts, companies, tasks.
35
14
  2) Configure Notifications for stage changes/tasks; set policy.pii for contact data.
36
15
 
@@ -62,17 +41,7 @@ var crmPipelineDocBlocks = [
62
41
  3) Run contractspec build to generate handlers and types.
63
42
  4) Wire the generated handler into your existing router.
64
43
  5) Expand to events and presentations as you add surface areas.
65
- `
66
- },
67
- {
68
- id: "docs.examples.crm-pipeline.reference",
69
- title: "CRM Pipeline \u2014 Reference",
70
- summary: "Entities, contracts, events, and presentations for the CRM template.",
71
- kind: "reference",
72
- visibility: "public",
73
- route: "/docs/examples/crm-pipeline",
74
- tags: ["crm", "reference"],
75
- body: `## Entities
44
+ `},{id:"docs.examples.crm-pipeline.reference",title:"CRM Pipeline \u2014 Reference",summary:"Entities, contracts, events, and presentations for the CRM template.",kind:"reference",visibility:"public",route:"/docs/examples/crm-pipeline",tags:["crm","reference"],body:`## Entities
76
45
  - Contact, Company, Deal, Pipeline, Stage, Task.
77
46
 
78
47
  ## Contracts
@@ -86,17 +55,7 @@ var crmPipelineDocBlocks = [
86
55
 
87
56
  ## Notes
88
57
  - Stage definitions should be declarative; enforce via spec and regeneration.
89
- - Use Notifications for deal/task updates; Audit Trail for state changes.`
90
- },
91
- {
92
- id: "docs.examples.crm-pipeline.constraints",
93
- title: "CRM Pipeline \u2014 Constraints & Safety",
94
- summary: "Internal guardrails for stages, PII, and regeneration semantics in the CRM template.",
95
- kind: "reference",
96
- visibility: "internal",
97
- route: "/docs/examples/crm-pipeline/constraints",
98
- tags: ["crm", "constraints", "internal"],
99
- body: `## Constraints
58
+ - Use Notifications for deal/task updates; Audit Trail for state changes.`},{id:"docs.examples.crm-pipeline.constraints",title:"CRM Pipeline \u2014 Constraints & Safety",summary:"Internal guardrails for stages, PII, and regeneration semantics in the CRM template.",kind:"reference",visibility:"internal",route:"/docs/examples/crm-pipeline/constraints",tags:["crm","constraints","internal"],body:`## Constraints
100
59
  - Stage definitions/order must remain declarative; no imperative overrides in code.
101
60
  - Events to emit: deal.created, stage.moved, task.completed, contact.updated (minimum).
102
61
  - Regeneration should not alter stage semantics without explicit spec change.
@@ -108,7 +67,4 @@ var crmPipelineDocBlocks = [
108
67
  ## Verification
109
68
  - Add fixtures for stage move rules and SLA/task changes.
110
69
  - Ensure Audit/Notifications remain wired for stage and task events.
111
- - Use Feature Flags for experimental stages/SLAs; default safe/off.`
112
- }
113
- ];
114
- registerDocBlocks(crmPipelineDocBlocks);
70
+ - Use Feature Flags for experimental stages/SLAs; default safe/off.`}];f(h);