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