@contractspec/example.saas-boilerplate 1.46.0 β†’ 1.47.0

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 (131) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +183 -108
  2. package/.turbo/turbo-build.log +182 -107
  3. package/CHANGELOG.md +58 -0
  4. package/README.md +0 -1
  5. package/dist/billing/billing.event.d.ts +4 -4
  6. package/dist/billing/billing.event.js +1 -1
  7. package/dist/billing/billing.operations.d.ts +5 -5
  8. package/dist/billing/billing.presentation.d.ts +3 -4
  9. package/dist/billing/billing.presentation.d.ts.map +1 -1
  10. package/dist/billing/billing.presentation.js +5 -5
  11. package/dist/billing/billing.presentation.js.map +1 -1
  12. package/dist/dashboard/dashboard.presentation.d.ts +3 -4
  13. package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
  14. package/dist/dashboard/dashboard.presentation.js +5 -5
  15. package/dist/dashboard/dashboard.presentation.js.map +1 -1
  16. package/dist/example.d.ts +2 -2
  17. package/dist/example.d.ts.map +1 -1
  18. package/dist/example.js +4 -2
  19. package/dist/example.js.map +1 -1
  20. package/dist/handlers/index.d.ts +2 -1
  21. package/dist/handlers/index.js +2 -1
  22. package/dist/handlers/saas.handlers.d.ts +68 -0
  23. package/dist/handlers/saas.handlers.d.ts.map +1 -0
  24. package/dist/handlers/saas.handlers.js +148 -0
  25. package/dist/handlers/saas.handlers.js.map +1 -0
  26. package/dist/index.d.ts +13 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +13 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/project/project.event.d.ts +5 -5
  31. package/dist/project/project.event.d.ts.map +1 -1
  32. package/dist/project/project.event.js +1 -1
  33. package/dist/project/project.operations.d.ts +6 -6
  34. package/dist/project/project.presentation.d.ts +3 -4
  35. package/dist/project/project.presentation.d.ts.map +1 -1
  36. package/dist/project/project.presentation.js +5 -5
  37. package/dist/project/project.presentation.js.map +1 -1
  38. package/dist/saas-boilerplate.feature.d.ts +2 -2
  39. package/dist/saas-boilerplate.feature.d.ts.map +1 -1
  40. package/dist/saas-boilerplate.feature.js +9 -2
  41. package/dist/saas-boilerplate.feature.js.map +1 -1
  42. package/dist/seeders/index.d.ts +10 -0
  43. package/dist/seeders/index.d.ts.map +1 -0
  44. package/dist/seeders/index.js +19 -0
  45. package/dist/seeders/index.js.map +1 -0
  46. package/dist/shared/overlay-types.d.ts +34 -0
  47. package/dist/shared/overlay-types.d.ts.map +1 -0
  48. package/dist/shared/overlay-types.js +0 -0
  49. package/dist/tests/operations.test-spec.d.ts +10 -0
  50. package/dist/tests/operations.test-spec.d.ts.map +1 -0
  51. package/dist/tests/operations.test-spec.js +123 -0
  52. package/dist/tests/operations.test-spec.js.map +1 -0
  53. package/dist/ui/SaasDashboard.d.ts +7 -0
  54. package/dist/ui/SaasDashboard.d.ts.map +1 -0
  55. package/dist/ui/SaasDashboard.js +298 -0
  56. package/dist/ui/SaasDashboard.js.map +1 -0
  57. package/dist/ui/SaasProjectList.d.ts +14 -0
  58. package/dist/ui/SaasProjectList.d.ts.map +1 -0
  59. package/dist/ui/SaasProjectList.js +76 -0
  60. package/dist/ui/SaasProjectList.js.map +1 -0
  61. package/dist/ui/SaasSettingsPanel.d.ts +7 -0
  62. package/dist/ui/SaasSettingsPanel.d.ts.map +1 -0
  63. package/dist/ui/SaasSettingsPanel.js +138 -0
  64. package/dist/ui/SaasSettingsPanel.js.map +1 -0
  65. package/dist/ui/hooks/index.d.ts +3 -0
  66. package/dist/ui/hooks/index.js +6 -0
  67. package/dist/ui/hooks/useProjectList.d.ts +34 -0
  68. package/dist/ui/hooks/useProjectList.d.ts.map +1 -0
  69. package/dist/ui/hooks/useProjectList.js +75 -0
  70. package/dist/ui/hooks/useProjectList.js.map +1 -0
  71. package/dist/ui/hooks/useProjectMutations.d.ts +28 -0
  72. package/dist/ui/hooks/useProjectMutations.d.ts.map +1 -0
  73. package/dist/ui/hooks/useProjectMutations.js +146 -0
  74. package/dist/ui/hooks/useProjectMutations.js.map +1 -0
  75. package/dist/ui/index.d.ts +14 -0
  76. package/dist/ui/index.js +15 -0
  77. package/dist/ui/modals/CreateProjectModal.d.ts +23 -0
  78. package/dist/ui/modals/CreateProjectModal.d.ts.map +1 -0
  79. package/dist/ui/modals/CreateProjectModal.js +139 -0
  80. package/dist/ui/modals/CreateProjectModal.js.map +1 -0
  81. package/dist/ui/modals/ProjectActionsModal.d.ts +38 -0
  82. package/dist/ui/modals/ProjectActionsModal.d.ts.map +1 -0
  83. package/dist/ui/modals/ProjectActionsModal.js +292 -0
  84. package/dist/ui/modals/ProjectActionsModal.js.map +1 -0
  85. package/dist/ui/modals/index.d.ts +3 -0
  86. package/dist/ui/modals/index.js +4 -0
  87. package/dist/ui/overlays/demo-overlays.d.ts +19 -0
  88. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -0
  89. package/dist/ui/overlays/demo-overlays.js +70 -0
  90. package/dist/ui/overlays/demo-overlays.js.map +1 -0
  91. package/dist/ui/overlays/index.d.ts +2 -0
  92. package/dist/ui/overlays/index.js +3 -0
  93. package/dist/ui/renderers/index.d.ts +3 -0
  94. package/dist/ui/renderers/index.js +4 -0
  95. package/dist/ui/renderers/project-list.markdown.d.ts +31 -0
  96. package/dist/ui/renderers/project-list.markdown.d.ts.map +1 -0
  97. package/dist/ui/renderers/project-list.markdown.js +148 -0
  98. package/dist/ui/renderers/project-list.markdown.js.map +1 -0
  99. package/dist/ui/renderers/project-list.renderer.d.ts +9 -0
  100. package/dist/ui/renderers/project-list.renderer.d.ts.map +1 -0
  101. package/dist/ui/renderers/project-list.renderer.js +17 -0
  102. package/dist/ui/renderers/project-list.renderer.js.map +1 -0
  103. package/package.json +38 -14
  104. package/src/billing/billing.presentation.ts +5 -6
  105. package/src/dashboard/dashboard.presentation.ts +5 -6
  106. package/src/example.ts +3 -3
  107. package/src/handlers/index.ts +3 -0
  108. package/src/handlers/saas.handlers.ts +300 -0
  109. package/src/index.ts +5 -0
  110. package/src/project/project.presentation.ts +5 -6
  111. package/src/saas-boilerplate.feature.ts +3 -3
  112. package/src/seeders/index.ts +28 -0
  113. package/src/shared/overlay-types.ts +39 -0
  114. package/src/tests/operations.test-spec.ts +109 -0
  115. package/src/ui/SaasDashboard.tsx +325 -0
  116. package/src/ui/SaasProjectList.tsx +113 -0
  117. package/src/ui/SaasSettingsPanel.tsx +96 -0
  118. package/src/ui/hooks/index.ts +10 -0
  119. package/src/ui/hooks/useProjectList.ts +95 -0
  120. package/src/ui/hooks/useProjectMutations.ts +166 -0
  121. package/src/ui/index.ts +18 -0
  122. package/src/ui/modals/CreateProjectModal.tsx +176 -0
  123. package/src/ui/modals/ProjectActionsModal.tsx +346 -0
  124. package/src/ui/modals/index.ts +2 -0
  125. package/src/ui/overlays/demo-overlays.ts +74 -0
  126. package/src/ui/overlays/index.ts +1 -0
  127. package/src/ui/renderers/index.ts +7 -0
  128. package/src/ui/renderers/project-list.markdown.ts +239 -0
  129. package/src/ui/renderers/project-list.renderer.tsx +22 -0
  130. package/tsconfig.json +1 -1
  131. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Demo Overlay Definitions for SaaS Boilerplate
3
+ *
4
+ * These overlays customize the presentation for different contexts
5
+ * (e.g., demo users, different subscription tiers).
6
+ */
7
+ import type { OverlayDefinition } from '../../shared/overlay-types';
8
+
9
+ /**
10
+ * Free tier overlay - shows upgrade prompts and limits
11
+ */
12
+ export const saasFreeUserOverlay: OverlayDefinition = {
13
+ overlayId: 'saas-boilerplate.free-tier',
14
+ version: '1.0.0',
15
+ description: 'Shows limitations for free tier users',
16
+ appliesTo: {
17
+ feature: 'saas-boilerplate',
18
+ tier: 'free',
19
+ },
20
+ modifications: [
21
+ {
22
+ type: 'setLimit',
23
+ field: 'projects',
24
+ max: 3,
25
+ message: 'Upgrade to create more projects',
26
+ },
27
+ { type: 'hideField', field: 'advancedSettings', reason: 'Pro feature' },
28
+ {
29
+ type: 'addBadge',
30
+ position: 'header',
31
+ label: 'Free Plan',
32
+ variant: 'default',
33
+ },
34
+ ],
35
+ };
36
+
37
+ /**
38
+ * Demo user overlay
39
+ */
40
+ export const saasDemoOverlay: OverlayDefinition = {
41
+ overlayId: 'saas-boilerplate.demo-user',
42
+ version: '1.0.0',
43
+ description: 'Demo mode for SaaS boilerplate',
44
+ appliesTo: {
45
+ feature: 'saas-boilerplate',
46
+ role: 'demo',
47
+ },
48
+ modifications: [
49
+ {
50
+ type: 'hideField',
51
+ field: 'billingSection',
52
+ reason: 'Demo users cannot access billing',
53
+ },
54
+ {
55
+ type: 'hideField',
56
+ field: 'deleteAccount',
57
+ reason: 'Not available in demo',
58
+ },
59
+ {
60
+ type: 'addBadge',
61
+ position: 'header',
62
+ label: 'Demo Mode',
63
+ variant: 'warning',
64
+ },
65
+ ],
66
+ };
67
+
68
+ /**
69
+ * All overlays for saas-boilerplate
70
+ */
71
+ export const saasOverlays: OverlayDefinition[] = [
72
+ saasFreeUserOverlay,
73
+ saasDemoOverlay,
74
+ ];
@@ -0,0 +1 @@
1
+ export * from './demo-overlays';
@@ -0,0 +1,7 @@
1
+ // SaaS renderers
2
+ export { projectListReactRenderer } from './project-list.renderer';
3
+ export {
4
+ projectListMarkdownRenderer,
5
+ saasDashboardMarkdownRenderer,
6
+ saasBillingMarkdownRenderer,
7
+ } from './project-list.markdown';
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Markdown renderer for SaaS Project List presentation
3
+ *
4
+ * Uses dynamic import to ensure correct build order.
5
+ */
6
+ import type { PresentationRenderer } from '@contractspec/lib.contracts';
7
+ import {
8
+ mockListProjectsHandler,
9
+ mockGetSubscriptionHandler,
10
+ } from '@contractspec/example.saas-boilerplate/handlers';
11
+
12
+ interface ProjectItem {
13
+ id: string;
14
+ name: string;
15
+ status: string;
16
+ description?: string;
17
+ }
18
+
19
+ /**
20
+ * Markdown renderer for saas-boilerplate.project.list presentation
21
+ * Only handles ProjectListView component
22
+ */
23
+ export const projectListMarkdownRenderer: PresentationRenderer<{
24
+ mimeType: string;
25
+ body: string;
26
+ }> = {
27
+ target: 'markdown',
28
+ render: async (desc, _ctx) => {
29
+ // Only handle ProjectListView
30
+ if (
31
+ desc.source.type !== 'component' ||
32
+ desc.source.componentKey !== 'ProjectListView'
33
+ ) {
34
+ throw new Error('projectListMarkdownRenderer: not ProjectListView');
35
+ }
36
+
37
+ const data = await mockListProjectsHandler({
38
+ limit: 20,
39
+ offset: 0,
40
+ });
41
+
42
+ // The example handler returns 'projects', not 'items'
43
+ const items =
44
+ (data as { projects?: ProjectItem[]; items?: ProjectItem[] }).projects ??
45
+ (data as { items?: ProjectItem[] }).items ??
46
+ [];
47
+
48
+ const lines: string[] = [
49
+ '# Projects',
50
+ '',
51
+ `**Total**: ${data.total} projects`,
52
+ '',
53
+ ];
54
+
55
+ if (items.length === 0) {
56
+ lines.push('_No projects found._');
57
+ } else {
58
+ lines.push('| Status | Project | Description |');
59
+ lines.push('|--------|---------|-------------|');
60
+ for (const project of items) {
61
+ const status =
62
+ project.status === 'ACTIVE'
63
+ ? 'βœ…'
64
+ : project.status === 'ARCHIVED'
65
+ ? 'πŸ“¦'
66
+ : '⏸️';
67
+ lines.push(
68
+ `| ${status} | **${project.name}** | ${project.description ?? '-'} |`
69
+ );
70
+ }
71
+ }
72
+
73
+ return {
74
+ mimeType: 'text/markdown',
75
+ body: lines.join('\n'),
76
+ };
77
+ },
78
+ };
79
+
80
+ /**
81
+ * Markdown renderer for saas-boilerplate.dashboard presentation
82
+ * Only handles SaasDashboard component
83
+ */
84
+ export const saasDashboardMarkdownRenderer: PresentationRenderer<{
85
+ mimeType: string;
86
+ body: string;
87
+ }> = {
88
+ target: 'markdown',
89
+ render: async (desc, _ctx) => {
90
+ // Only handle SaasDashboard
91
+ if (
92
+ desc.source.type !== 'component' ||
93
+ desc.source.componentKey !== 'SaasDashboard'
94
+ ) {
95
+ throw new Error('saasDashboardMarkdownRenderer: not SaasDashboard');
96
+ }
97
+
98
+ const [projectsData, subscription] = await Promise.all([
99
+ mockListProjectsHandler({ limit: 50 }),
100
+ mockGetSubscriptionHandler(),
101
+ ]);
102
+
103
+ const projects =
104
+ (projectsData as { projects?: ProjectItem[] }).projects ?? [];
105
+ const activeProjects = projects.filter((p) => p.status === 'ACTIVE').length;
106
+ const archivedProjects = projects.filter(
107
+ (p) => p.status === 'ARCHIVED'
108
+ ).length;
109
+
110
+ const lines: string[] = [
111
+ '# SaaS Dashboard',
112
+ '',
113
+ '> Organization overview and usage summary',
114
+ '',
115
+ '## Summary',
116
+ '',
117
+ '| Metric | Value |',
118
+ '|--------|-------|',
119
+ `| Total Projects | ${projectsData.total} |`,
120
+ `| Active Projects | ${activeProjects} |`,
121
+ `| Archived Projects | ${archivedProjects} |`,
122
+ `| Subscription Plan | ${subscription.planName} |`,
123
+ `| Subscription Status | ${subscription.status} |`,
124
+ '',
125
+ '## Projects',
126
+ '',
127
+ ];
128
+
129
+ if (projects.length === 0) {
130
+ lines.push('_No projects yet._');
131
+ } else {
132
+ lines.push('| Status | Project | Description |');
133
+ lines.push('|--------|---------|-------------|');
134
+ for (const project of projects.slice(0, 10)) {
135
+ const status =
136
+ project.status === 'ACTIVE'
137
+ ? 'βœ…'
138
+ : project.status === 'ARCHIVED'
139
+ ? 'πŸ“¦'
140
+ : '⏸️';
141
+ lines.push(
142
+ `| ${status} | **${project.name}** | ${project.description ?? '-'} |`
143
+ );
144
+ }
145
+ if (projects.length > 10) {
146
+ lines.push(
147
+ `| ... | ... | _${projectsData.total - 10} more projects_ |`
148
+ );
149
+ }
150
+ }
151
+
152
+ lines.push('');
153
+ lines.push('## Subscription');
154
+ lines.push('');
155
+ lines.push(`- **Plan**: ${subscription.planName}`);
156
+ lines.push(`- **Status**: ${subscription.status}`);
157
+ if (subscription.currentPeriodEnd) {
158
+ lines.push(
159
+ `- **Period End**: ${new Date(subscription.currentPeriodEnd).toLocaleDateString()}`
160
+ );
161
+ }
162
+
163
+ return {
164
+ mimeType: 'text/markdown',
165
+ body: lines.join('\n'),
166
+ };
167
+ },
168
+ };
169
+
170
+ /**
171
+ * Markdown renderer for saas-boilerplate.billing.settings presentation
172
+ * Only handles SubscriptionView component
173
+ */
174
+ export const saasBillingMarkdownRenderer: PresentationRenderer<{
175
+ mimeType: string;
176
+ body: string;
177
+ }> = {
178
+ target: 'markdown',
179
+ render: async (desc, _ctx) => {
180
+ // Only handle SubscriptionView
181
+ if (
182
+ desc.source.type !== 'component' ||
183
+ desc.source.componentKey !== 'SubscriptionView'
184
+ ) {
185
+ throw new Error('saasBillingMarkdownRenderer: not SubscriptionView');
186
+ }
187
+
188
+ const subscription = await mockGetSubscriptionHandler();
189
+
190
+ const lines: string[] = [
191
+ '# Billing & Subscription',
192
+ '',
193
+ '> Current subscription details and billing information',
194
+ '',
195
+ '## Subscription Details',
196
+ '',
197
+ '| Property | Value |',
198
+ '|----------|-------|',
199
+ `| Plan | ${subscription.planName} |`,
200
+ `| Status | ${subscription.status} |`,
201
+ `| ID | ${subscription.id} |`,
202
+ `| Period Start | ${new Date(subscription.currentPeriodStart).toLocaleDateString()} |`,
203
+ `| Period End | ${new Date(subscription.currentPeriodEnd).toLocaleDateString()} |`,
204
+ ];
205
+
206
+ lines.push('');
207
+ lines.push('## Plan Limits');
208
+ lines.push('');
209
+ lines.push(`- **Projects**: ${subscription.limits.projects}`);
210
+ lines.push(`- **Users**: ${subscription.limits.users}`);
211
+
212
+ lines.push('');
213
+ lines.push('## Plan Features');
214
+ lines.push('');
215
+
216
+ if (subscription.planName.toLowerCase().includes('free')) {
217
+ lines.push('- βœ… Up to 3 projects');
218
+ lines.push('- βœ… Basic support');
219
+ lines.push('- ❌ Priority support');
220
+ lines.push('- ❌ Advanced analytics');
221
+ } else if (subscription.planName.toLowerCase().includes('pro')) {
222
+ lines.push('- βœ… Unlimited projects');
223
+ lines.push('- βœ… Priority support');
224
+ lines.push('- βœ… Advanced analytics');
225
+ lines.push('- ❌ Custom integrations');
226
+ } else {
227
+ lines.push('- βœ… Unlimited projects');
228
+ lines.push('- βœ… Priority support');
229
+ lines.push('- βœ… Advanced analytics');
230
+ lines.push('- βœ… Custom integrations');
231
+ lines.push('- βœ… Dedicated support');
232
+ }
233
+
234
+ return {
235
+ mimeType: 'text/markdown',
236
+ body: lines.join('\n'),
237
+ };
238
+ },
239
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * React renderer for SaaS Project List presentation
3
+ */
4
+ import * as React from 'react';
5
+ import type { PresentationRenderer } from '@contractspec/lib.contracts';
6
+ import { SaasProjectList } from '../SaasProjectList';
7
+
8
+ export const projectListReactRenderer: PresentationRenderer<React.ReactElement> =
9
+ {
10
+ target: 'react',
11
+ render: async (desc, _ctx) => {
12
+ if (desc.source.type !== 'component') {
13
+ throw new Error('Invalid source type');
14
+ }
15
+
16
+ if (desc.source.componentKey !== 'SaasProjectListView') {
17
+ throw new Error(`Unknown component: ${desc.source.componentKey}`);
18
+ }
19
+
20
+ return <SaasProjectList />;
21
+ },
22
+ };
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "@contractspec/tool.typescript/react-library.json",
3
3
  "include": ["src"],
4
- "exclude": ["node_modules"],
4
+ "exclude": ["node_modules", "dist"],
5
5
  "compilerOptions": {
6
6
  "rootDir": "src",
7
7
  "outDir": "dist"