@contractspec/example.crm-pipeline 3.7.6 → 3.7.7

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 (105) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/AGENTS.md +51 -33
  3. package/README.md +66 -148
  4. package/dist/browser/events/contact.event.js +1 -1
  5. package/dist/browser/events/deal.event.js +1 -1
  6. package/dist/browser/events/index.js +3 -3
  7. package/dist/browser/events/task.event.js +1 -1
  8. package/dist/browser/index.js +293 -293
  9. package/dist/browser/ui/CrmDashboard.js +221 -221
  10. package/dist/browser/ui/CrmDealCard.js +5 -5
  11. package/dist/browser/ui/CrmPipelineBoard.js +13 -13
  12. package/dist/browser/ui/hooks/index.js +2 -2
  13. package/dist/browser/ui/hooks/useDealList.js +1 -1
  14. package/dist/browser/ui/hooks/useDealMutations.js +1 -1
  15. package/dist/browser/ui/index.js +290 -290
  16. package/dist/browser/ui/modals/CreateDealModal.js +12 -12
  17. package/dist/browser/ui/modals/DealActionsModal.js +21 -21
  18. package/dist/browser/ui/modals/index.js +33 -33
  19. package/dist/browser/ui/renderers/index.js +116 -116
  20. package/dist/browser/ui/renderers/pipeline.renderer.js +97 -97
  21. package/dist/deal/index.d.ts +2 -2
  22. package/dist/events/contact.event.js +1 -1
  23. package/dist/events/deal.event.js +1 -1
  24. package/dist/events/index.js +3 -3
  25. package/dist/events/task.event.js +1 -1
  26. package/dist/handlers/index.d.ts +2 -2
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.js +293 -293
  29. package/dist/node/events/contact.event.js +1 -1
  30. package/dist/node/events/deal.event.js +1 -1
  31. package/dist/node/events/index.js +3 -3
  32. package/dist/node/events/task.event.js +1 -1
  33. package/dist/node/index.js +293 -293
  34. package/dist/node/ui/CrmDashboard.js +221 -221
  35. package/dist/node/ui/CrmDealCard.js +5 -5
  36. package/dist/node/ui/CrmPipelineBoard.js +13 -13
  37. package/dist/node/ui/hooks/index.js +2 -2
  38. package/dist/node/ui/hooks/useDealList.js +1 -1
  39. package/dist/node/ui/hooks/useDealMutations.js +1 -1
  40. package/dist/node/ui/index.js +290 -290
  41. package/dist/node/ui/modals/CreateDealModal.js +12 -12
  42. package/dist/node/ui/modals/DealActionsModal.js +21 -21
  43. package/dist/node/ui/modals/index.js +33 -33
  44. package/dist/node/ui/renderers/index.js +116 -116
  45. package/dist/node/ui/renderers/pipeline.renderer.js +97 -97
  46. package/dist/operations/index.d.ts +1 -1
  47. package/dist/ui/CrmDashboard.js +221 -221
  48. package/dist/ui/CrmDealCard.js +5 -5
  49. package/dist/ui/CrmPipelineBoard.js +13 -13
  50. package/dist/ui/hooks/index.d.ts +2 -2
  51. package/dist/ui/hooks/index.js +2 -2
  52. package/dist/ui/hooks/useDealList.js +1 -1
  53. package/dist/ui/hooks/useDealMutations.d.ts +9 -0
  54. package/dist/ui/hooks/useDealMutations.js +1 -1
  55. package/dist/ui/index.d.ts +3 -3
  56. package/dist/ui/index.js +290 -290
  57. package/dist/ui/modals/CreateDealModal.js +12 -12
  58. package/dist/ui/modals/DealActionsModal.js +21 -21
  59. package/dist/ui/modals/index.js +33 -33
  60. package/dist/ui/renderers/index.d.ts +1 -1
  61. package/dist/ui/renderers/index.js +116 -116
  62. package/dist/ui/renderers/pipeline.renderer.d.ts +1 -1
  63. package/dist/ui/renderers/pipeline.renderer.js +97 -97
  64. package/package.json +10 -10
  65. package/src/crm-pipeline.feature.ts +86 -86
  66. package/src/deal/deal.enum.ts +8 -8
  67. package/src/deal/deal.operation.ts +255 -255
  68. package/src/deal/deal.schema.ts +92 -92
  69. package/src/deal/deal.test-spec.ts +48 -48
  70. package/src/deal/index.ts +17 -19
  71. package/src/docs/crm-pipeline.docblock.ts +43 -43
  72. package/src/entities/company.entity.ts +52 -52
  73. package/src/entities/contact.entity.ts +67 -67
  74. package/src/entities/deal.entity.ts +134 -134
  75. package/src/entities/index.ts +27 -27
  76. package/src/entities/task.entity.ts +105 -105
  77. package/src/events/contact.event.ts +22 -22
  78. package/src/events/deal.event.ts +77 -77
  79. package/src/events/task.event.ts +19 -19
  80. package/src/example.ts +32 -32
  81. package/src/handlers/crm.handlers.ts +358 -357
  82. package/src/handlers/deal.handlers.ts +179 -179
  83. package/src/handlers/index.ts +18 -19
  84. package/src/handlers/mock-data.ts +167 -167
  85. package/src/index.ts +11 -11
  86. package/src/operations/index.ts +16 -16
  87. package/src/presentations/dashboard.presentation.ts +45 -45
  88. package/src/presentations/pipeline.presentation.ts +90 -90
  89. package/src/seeders/index.ts +26 -26
  90. package/src/shared/overlay-types.ts +23 -23
  91. package/src/ui/CrmDashboard.tsx +256 -256
  92. package/src/ui/CrmDealCard.tsx +64 -64
  93. package/src/ui/CrmPipelineBoard.tsx +105 -105
  94. package/src/ui/hooks/index.ts +3 -3
  95. package/src/ui/hooks/useDealList.ts +85 -85
  96. package/src/ui/hooks/useDealMutations.ts +151 -150
  97. package/src/ui/index.ts +5 -10
  98. package/src/ui/modals/CreateDealModal.tsx +217 -217
  99. package/src/ui/modals/DealActionsModal.tsx +390 -390
  100. package/src/ui/overlays/demo-overlays.ts +43 -43
  101. package/src/ui/renderers/index.ts +4 -3
  102. package/src/ui/renderers/pipeline.markdown.ts +165 -165
  103. package/src/ui/renderers/pipeline.renderer.tsx +17 -16
  104. package/tsconfig.json +7 -8
  105. 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';