@contractspec/example.crm-pipeline 3.7.6 → 3.7.10

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 (130) hide show
  1. package/.turbo/turbo-build.log +45 -42
  2. package/AGENTS.md +51 -33
  3. package/CHANGELOG.md +36 -0
  4. package/README.md +67 -148
  5. package/dist/browser/docs/crm-pipeline.docblock.js +1 -1
  6. package/dist/browser/docs/index.js +1 -1
  7. package/dist/browser/events/contact.event.js +1 -1
  8. package/dist/browser/events/deal.event.js +1 -1
  9. package/dist/browser/events/index.js +3 -3
  10. package/dist/browser/events/task.event.js +1 -1
  11. package/dist/browser/handlers/crm.handlers.js +13 -2
  12. package/dist/browser/handlers/index.js +13 -2
  13. package/dist/browser/index.js +680 -447
  14. package/dist/browser/ui/CrmDashboard.js +574 -352
  15. package/dist/browser/ui/CrmDealCard.js +5 -5
  16. package/dist/browser/ui/CrmPipelineBoard.js +13 -13
  17. package/dist/browser/ui/hooks/index.js +21 -10
  18. package/dist/browser/ui/hooks/useDealList.js +20 -9
  19. package/dist/browser/ui/hooks/useDealMutations.js +1 -1
  20. package/dist/browser/ui/index.js +683 -450
  21. package/dist/browser/ui/modals/CreateDealModal.js +12 -12
  22. package/dist/browser/ui/modals/DealActionsModal.js +21 -21
  23. package/dist/browser/ui/modals/index.js +33 -33
  24. package/dist/browser/ui/renderers/index.js +140 -118
  25. package/dist/browser/ui/renderers/pipeline.markdown.js +13 -2
  26. package/dist/browser/ui/renderers/pipeline.renderer.js +108 -97
  27. package/dist/browser/ui/tables/DealListTab.js +390 -0
  28. package/dist/deal/index.d.ts +2 -2
  29. package/dist/docs/crm-pipeline.docblock.js +1 -1
  30. package/dist/docs/index.js +1 -1
  31. package/dist/events/contact.event.js +1 -1
  32. package/dist/events/deal.event.js +1 -1
  33. package/dist/events/index.js +3 -3
  34. package/dist/events/task.event.js +1 -1
  35. package/dist/handlers/crm.handlers.d.ts +2 -0
  36. package/dist/handlers/crm.handlers.js +13 -2
  37. package/dist/handlers/index.d.ts +2 -2
  38. package/dist/handlers/index.js +13 -2
  39. package/dist/index.d.ts +3 -3
  40. package/dist/index.js +680 -447
  41. package/dist/node/docs/crm-pipeline.docblock.js +1 -1
  42. package/dist/node/docs/index.js +1 -1
  43. package/dist/node/events/contact.event.js +1 -1
  44. package/dist/node/events/deal.event.js +1 -1
  45. package/dist/node/events/index.js +3 -3
  46. package/dist/node/events/task.event.js +1 -1
  47. package/dist/node/handlers/crm.handlers.js +13 -2
  48. package/dist/node/handlers/index.js +13 -2
  49. package/dist/node/index.js +680 -447
  50. package/dist/node/ui/CrmDashboard.js +574 -352
  51. package/dist/node/ui/CrmDealCard.js +5 -5
  52. package/dist/node/ui/CrmPipelineBoard.js +13 -13
  53. package/dist/node/ui/hooks/index.js +21 -10
  54. package/dist/node/ui/hooks/useDealList.js +20 -9
  55. package/dist/node/ui/hooks/useDealMutations.js +1 -1
  56. package/dist/node/ui/index.js +683 -450
  57. package/dist/node/ui/modals/CreateDealModal.js +12 -12
  58. package/dist/node/ui/modals/DealActionsModal.js +21 -21
  59. package/dist/node/ui/modals/index.js +33 -33
  60. package/dist/node/ui/renderers/index.js +140 -118
  61. package/dist/node/ui/renderers/pipeline.markdown.js +13 -2
  62. package/dist/node/ui/renderers/pipeline.renderer.js +108 -97
  63. package/dist/node/ui/tables/DealListTab.js +390 -0
  64. package/dist/operations/index.d.ts +1 -1
  65. package/dist/ui/CrmDashboard.js +574 -352
  66. package/dist/ui/CrmDealCard.js +5 -5
  67. package/dist/ui/CrmPipelineBoard.js +13 -13
  68. package/dist/ui/hooks/index.d.ts +2 -2
  69. package/dist/ui/hooks/index.js +21 -10
  70. package/dist/ui/hooks/useDealList.d.ts +8 -2
  71. package/dist/ui/hooks/useDealList.js +20 -9
  72. package/dist/ui/hooks/useDealMutations.d.ts +9 -0
  73. package/dist/ui/hooks/useDealMutations.js +1 -1
  74. package/dist/ui/index.d.ts +3 -3
  75. package/dist/ui/index.js +683 -450
  76. package/dist/ui/modals/CreateDealModal.js +12 -12
  77. package/dist/ui/modals/DealActionsModal.js +21 -21
  78. package/dist/ui/modals/index.js +33 -33
  79. package/dist/ui/renderers/index.d.ts +1 -1
  80. package/dist/ui/renderers/index.js +140 -118
  81. package/dist/ui/renderers/pipeline.markdown.js +13 -2
  82. package/dist/ui/renderers/pipeline.renderer.d.ts +1 -1
  83. package/dist/ui/renderers/pipeline.renderer.js +108 -97
  84. package/dist/ui/tables/DealListTab.d.ts +20 -0
  85. package/dist/ui/tables/DealListTab.js +391 -0
  86. package/dist/ui/tables/DealListTab.smoke.test.d.ts +1 -0
  87. package/package.json +29 -14
  88. package/src/crm-pipeline.feature.ts +86 -86
  89. package/src/deal/deal.enum.ts +8 -8
  90. package/src/deal/deal.operation.ts +255 -255
  91. package/src/deal/deal.schema.ts +92 -92
  92. package/src/deal/deal.test-spec.ts +48 -48
  93. package/src/deal/index.ts +17 -19
  94. package/src/docs/crm-pipeline.docblock.ts +44 -44
  95. package/src/entities/company.entity.ts +52 -52
  96. package/src/entities/contact.entity.ts +67 -67
  97. package/src/entities/deal.entity.ts +134 -134
  98. package/src/entities/index.ts +27 -27
  99. package/src/entities/task.entity.ts +105 -105
  100. package/src/events/contact.event.ts +22 -22
  101. package/src/events/deal.event.ts +77 -77
  102. package/src/events/task.event.ts +19 -19
  103. package/src/example.ts +32 -32
  104. package/src/handlers/crm.handlers.ts +375 -357
  105. package/src/handlers/deal.handlers.ts +179 -179
  106. package/src/handlers/index.ts +18 -19
  107. package/src/handlers/mock-data.ts +167 -167
  108. package/src/index.ts +11 -11
  109. package/src/operations/index.ts +16 -16
  110. package/src/presentations/dashboard.presentation.ts +45 -45
  111. package/src/presentations/pipeline.presentation.ts +90 -90
  112. package/src/seeders/index.ts +26 -26
  113. package/src/shared/overlay-types.ts +23 -23
  114. package/src/ui/CrmDashboard.tsx +210 -279
  115. package/src/ui/CrmDealCard.tsx +64 -64
  116. package/src/ui/CrmPipelineBoard.tsx +105 -105
  117. package/src/ui/hooks/index.ts +3 -3
  118. package/src/ui/hooks/useDealList.ts +113 -85
  119. package/src/ui/hooks/useDealMutations.ts +151 -150
  120. package/src/ui/index.ts +5 -10
  121. package/src/ui/modals/CreateDealModal.tsx +217 -217
  122. package/src/ui/modals/DealActionsModal.tsx +390 -390
  123. package/src/ui/overlays/demo-overlays.ts +43 -43
  124. package/src/ui/renderers/index.ts +4 -3
  125. package/src/ui/renderers/pipeline.markdown.ts +165 -165
  126. package/src/ui/renderers/pipeline.renderer.tsx +17 -16
  127. package/src/ui/tables/DealListTab.smoke.test.tsx +149 -0
  128. package/src/ui/tables/DealListTab.tsx +276 -0
  129. package/tsconfig.json +7 -8
  130. package/tsdown.config.js +7 -3
@@ -7,167 +7,168 @@
7
7
  * - WinDealContract
8
8
  * - LoseDealContract
9
9
  */
10
- import { useCallback, useState } from 'react';
10
+
11
11
  import { useTemplateRuntime } from '@contractspec/lib.example-shared-ui';
12
+ import { useCallback, useState } from 'react';
12
13
  import type {
13
- CreateDealInput,
14
- CrmHandlers,
15
- Deal,
16
- LoseDealInput,
17
- MoveDealInput,
18
- WinDealInput,
14
+ CreateDealInput,
15
+ CrmHandlers,
16
+ Deal,
17
+ LoseDealInput,
18
+ MoveDealInput,
19
+ WinDealInput,
19
20
  } from '../../handlers/crm.handlers';
20
21
 
21
22
  export interface MutationState<T> {
22
- loading: boolean;
23
- error: Error | null;
24
- data: T | null;
23
+ loading: boolean;
24
+ error: Error | null;
25
+ data: T | null;
25
26
  }
26
27
 
27
28
  export interface UseDealMutationsOptions {
28
- onSuccess?: () => void;
29
- onError?: (error: Error) => void;
29
+ onSuccess?: () => void;
30
+ onError?: (error: Error) => void;
30
31
  }
31
32
 
32
33
  export function useDealMutations(options: UseDealMutationsOptions = {}) {
33
- const { handlers, projectId } = useTemplateRuntime<{ crm: CrmHandlers }>();
34
- const { crm } = handlers;
35
-
36
- const [createState, setCreateState] = useState<MutationState<Deal>>({
37
- loading: false,
38
- error: null,
39
- data: null,
40
- });
41
-
42
- const [moveState, setMoveState] = useState<MutationState<Deal>>({
43
- loading: false,
44
- error: null,
45
- data: null,
46
- });
47
-
48
- const [winState, setWinState] = useState<MutationState<Deal>>({
49
- loading: false,
50
- error: null,
51
- data: null,
52
- });
53
-
54
- const [loseState, setLoseState] = useState<MutationState<Deal>>({
55
- loading: false,
56
- error: null,
57
- data: null,
58
- });
59
-
60
- /**
61
- * Create a new deal
62
- */
63
- const createDeal = useCallback(
64
- async (input: CreateDealInput): Promise<Deal | null> => {
65
- setCreateState({ loading: true, error: null, data: null });
66
- try {
67
- const result = await crm.createDeal(input, {
68
- projectId,
69
- ownerId: 'user-1', // Demo user
70
- });
71
- setCreateState({ loading: false, error: null, data: result });
72
- options.onSuccess?.();
73
- return result;
74
- } catch (err) {
75
- const error =
76
- err instanceof Error ? err : new Error('Failed to create deal');
77
- setCreateState({ loading: false, error, data: null });
78
- options.onError?.(error);
79
- return null;
80
- }
81
- },
82
- [crm, projectId, options]
83
- );
84
-
85
- /**
86
- * Move a deal to a different stage
87
- */
88
- const moveDeal = useCallback(
89
- async (input: MoveDealInput): Promise<Deal | null> => {
90
- setMoveState({ loading: true, error: null, data: null });
91
- try {
92
- const result = await crm.moveDeal(input);
93
- setMoveState({ loading: false, error: null, data: result });
94
- options.onSuccess?.();
95
- return result;
96
- } catch (err) {
97
- const error =
98
- err instanceof Error ? err : new Error('Failed to move deal');
99
- setMoveState({ loading: false, error, data: null });
100
- options.onError?.(error);
101
- return null;
102
- }
103
- },
104
- [crm, options]
105
- );
106
-
107
- /**
108
- * Mark a deal as won
109
- */
110
- const winDeal = useCallback(
111
- async (input: WinDealInput): Promise<Deal | null> => {
112
- setWinState({ loading: true, error: null, data: null });
113
- try {
114
- const result = await crm.winDeal(input);
115
- setWinState({ loading: false, error: null, data: result });
116
- options.onSuccess?.();
117
- return result;
118
- } catch (err) {
119
- const error =
120
- err instanceof Error ? err : new Error('Failed to mark deal as won');
121
- setWinState({ loading: false, error, data: null });
122
- options.onError?.(error);
123
- return null;
124
- }
125
- },
126
- [crm, options]
127
- );
128
-
129
- /**
130
- * Mark a deal as lost
131
- */
132
- const loseDeal = useCallback(
133
- async (input: LoseDealInput): Promise<Deal | null> => {
134
- setLoseState({ loading: true, error: null, data: null });
135
- try {
136
- const result = await crm.loseDeal(input);
137
- setLoseState({ loading: false, error: null, data: result });
138
- options.onSuccess?.();
139
- return result;
140
- } catch (err) {
141
- const error =
142
- err instanceof Error ? err : new Error('Failed to mark deal as lost');
143
- setLoseState({ loading: false, error, data: null });
144
- options.onError?.(error);
145
- return null;
146
- }
147
- },
148
- [crm, options]
149
- );
150
-
151
- return {
152
- // Mutations
153
- createDeal,
154
- moveDeal,
155
- winDeal,
156
- loseDeal,
157
-
158
- // State
159
- createState,
160
- moveState,
161
- winState,
162
- loseState,
163
-
164
- // Convenience
165
- isLoading:
166
- createState.loading ||
167
- moveState.loading ||
168
- winState.loading ||
169
- loseState.loading,
170
- };
34
+ const { handlers, projectId } = useTemplateRuntime<{ crm: CrmHandlers }>();
35
+ const { crm } = handlers;
36
+
37
+ const [createState, setCreateState] = useState<MutationState<Deal>>({
38
+ loading: false,
39
+ error: null,
40
+ data: null,
41
+ });
42
+
43
+ const [moveState, setMoveState] = useState<MutationState<Deal>>({
44
+ loading: false,
45
+ error: null,
46
+ data: null,
47
+ });
48
+
49
+ const [winState, setWinState] = useState<MutationState<Deal>>({
50
+ loading: false,
51
+ error: null,
52
+ data: null,
53
+ });
54
+
55
+ const [loseState, setLoseState] = useState<MutationState<Deal>>({
56
+ loading: false,
57
+ error: null,
58
+ data: null,
59
+ });
60
+
61
+ /**
62
+ * Create a new deal
63
+ */
64
+ const createDeal = useCallback(
65
+ async (input: CreateDealInput): Promise<Deal | null> => {
66
+ setCreateState({ loading: true, error: null, data: null });
67
+ try {
68
+ const result = await crm.createDeal(input, {
69
+ projectId,
70
+ ownerId: 'user-1', // Demo user
71
+ });
72
+ setCreateState({ loading: false, error: null, data: result });
73
+ options.onSuccess?.();
74
+ return result;
75
+ } catch (err) {
76
+ const error =
77
+ err instanceof Error ? err : new Error('Failed to create deal');
78
+ setCreateState({ loading: false, error, data: null });
79
+ options.onError?.(error);
80
+ return null;
81
+ }
82
+ },
83
+ [crm, projectId, options]
84
+ );
85
+
86
+ /**
87
+ * Move a deal to a different stage
88
+ */
89
+ const moveDeal = useCallback(
90
+ async (input: MoveDealInput): Promise<Deal | null> => {
91
+ setMoveState({ loading: true, error: null, data: null });
92
+ try {
93
+ const result = await crm.moveDeal(input);
94
+ setMoveState({ loading: false, error: null, data: result });
95
+ options.onSuccess?.();
96
+ return result;
97
+ } catch (err) {
98
+ const error =
99
+ err instanceof Error ? err : new Error('Failed to move deal');
100
+ setMoveState({ loading: false, error, data: null });
101
+ options.onError?.(error);
102
+ return null;
103
+ }
104
+ },
105
+ [crm, options]
106
+ );
107
+
108
+ /**
109
+ * Mark a deal as won
110
+ */
111
+ const winDeal = useCallback(
112
+ async (input: WinDealInput): Promise<Deal | null> => {
113
+ setWinState({ loading: true, error: null, data: null });
114
+ try {
115
+ const result = await crm.winDeal(input);
116
+ setWinState({ loading: false, error: null, data: result });
117
+ options.onSuccess?.();
118
+ return result;
119
+ } catch (err) {
120
+ const error =
121
+ err instanceof Error ? err : new Error('Failed to mark deal as won');
122
+ setWinState({ loading: false, error, data: null });
123
+ options.onError?.(error);
124
+ return null;
125
+ }
126
+ },
127
+ [crm, options]
128
+ );
129
+
130
+ /**
131
+ * Mark a deal as lost
132
+ */
133
+ const loseDeal = useCallback(
134
+ async (input: LoseDealInput): Promise<Deal | null> => {
135
+ setLoseState({ loading: true, error: null, data: null });
136
+ try {
137
+ const result = await crm.loseDeal(input);
138
+ setLoseState({ loading: false, error: null, data: result });
139
+ options.onSuccess?.();
140
+ return result;
141
+ } catch (err) {
142
+ const error =
143
+ err instanceof Error ? err : new Error('Failed to mark deal as lost');
144
+ setLoseState({ loading: false, error, data: null });
145
+ options.onError?.(error);
146
+ return null;
147
+ }
148
+ },
149
+ [crm, options]
150
+ );
151
+
152
+ return {
153
+ // Mutations
154
+ createDeal,
155
+ moveDeal,
156
+ winDeal,
157
+ loseDeal,
158
+
159
+ // State
160
+ createState,
161
+ moveState,
162
+ winState,
163
+ loseState,
164
+
165
+ // Convenience
166
+ isLoading:
167
+ createState.loading ||
168
+ moveState.loading ||
169
+ winState.loading ||
170
+ loseState.loading,
171
+ };
171
172
  }
172
173
 
173
174
  // Note: Types are re-exported from the handlers package
package/src/ui/index.ts CHANGED
@@ -1,18 +1,13 @@
1
1
  // Main dashboard
2
2
  export * from './CrmDashboard';
3
-
3
+ export * from './CrmDealCard';
4
4
  // Components
5
5
  export * from './CrmPipelineBoard';
6
- export * from './CrmDealCard';
7
-
8
- // Modals
9
- export * from './modals';
10
-
11
6
  // Hooks
12
7
  export * from './hooks';
13
-
14
- // Renderers
15
- export * from './renderers';
16
-
8
+ // Modals
9
+ export * from './modals';
17
10
  // Overlays
18
11
  export * from './overlays';
12
+ // Renderers
13
+ export * from './renderers';