@contractspec/example.saas-boilerplate 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.
- package/.turbo/turbo-build.log +8 -8
- package/AGENTS.md +50 -27
- package/CHANGELOG.md +16 -0
- package/README.md +64 -144
- package/dist/billing/billing.event.js +1 -1
- package/dist/billing/index.d.ts +6 -6
- package/dist/billing/index.js +1 -1
- package/dist/browser/billing/billing.event.js +1 -1
- package/dist/browser/billing/index.js +1 -1
- package/dist/browser/index.js +931 -932
- package/dist/browser/project/index.js +209 -209
- package/dist/browser/project/project.event.js +1 -1
- package/dist/browser/ui/SaasDashboard.js +45 -45
- package/dist/browser/ui/SaasProjectList.js +7 -7
- package/dist/browser/ui/SaasSettingsPanel.js +12 -12
- package/dist/browser/ui/hooks/index.js +2 -2
- package/dist/browser/ui/hooks/useProjectList.js +1 -1
- package/dist/browser/ui/hooks/useProjectMutations.js +1 -1
- package/dist/browser/ui/index.js +483 -484
- package/dist/browser/ui/modals/CreateProjectModal.js +10 -10
- package/dist/browser/ui/modals/ProjectActionsModal.js +13 -13
- package/dist/browser/ui/modals/index.js +23 -23
- package/dist/browser/ui/renderers/index.js +112 -112
- package/dist/browser/ui/renderers/project-list.renderer.js +7 -7
- package/dist/handlers/index.d.ts +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +931 -932
- package/dist/node/billing/billing.event.js +1 -1
- package/dist/node/billing/index.js +1 -1
- package/dist/node/index.js +931 -932
- package/dist/node/project/index.js +209 -209
- package/dist/node/project/project.event.js +1 -1
- package/dist/node/ui/SaasDashboard.js +45 -45
- package/dist/node/ui/SaasProjectList.js +7 -7
- package/dist/node/ui/SaasSettingsPanel.js +12 -12
- package/dist/node/ui/hooks/index.js +2 -2
- package/dist/node/ui/hooks/useProjectList.js +1 -1
- package/dist/node/ui/hooks/useProjectMutations.js +1 -1
- package/dist/node/ui/index.js +483 -484
- package/dist/node/ui/modals/CreateProjectModal.js +10 -10
- package/dist/node/ui/modals/ProjectActionsModal.js +13 -13
- package/dist/node/ui/modals/index.js +23 -23
- package/dist/node/ui/renderers/index.js +112 -112
- package/dist/node/ui/renderers/project-list.renderer.js +7 -7
- package/dist/presentations/index.d.ts +1 -1
- package/dist/project/index.d.ts +7 -7
- package/dist/project/index.js +209 -209
- package/dist/project/project.event.js +1 -1
- package/dist/settings/index.d.ts +1 -1
- package/dist/ui/SaasDashboard.js +45 -45
- package/dist/ui/SaasProjectList.js +7 -7
- package/dist/ui/SaasSettingsPanel.js +12 -12
- package/dist/ui/hooks/index.d.ts +2 -2
- package/dist/ui/hooks/index.js +2 -2
- package/dist/ui/hooks/useProjectList.d.ts +5 -0
- package/dist/ui/hooks/useProjectList.js +1 -1
- package/dist/ui/hooks/useProjectMutations.d.ts +8 -0
- package/dist/ui/hooks/useProjectMutations.js +1 -1
- package/dist/ui/index.d.ts +4 -4
- package/dist/ui/index.js +483 -484
- package/dist/ui/modals/CreateProjectModal.js +10 -10
- package/dist/ui/modals/ProjectActionsModal.js +13 -13
- package/dist/ui/modals/index.js +23 -23
- package/dist/ui/renderers/index.d.ts +1 -1
- package/dist/ui/renderers/index.js +112 -112
- package/dist/ui/renderers/project-list.renderer.d.ts +1 -1
- package/dist/ui/renderers/project-list.renderer.js +7 -7
- package/package.json +14 -14
- package/src/billing/billing.entity.ts +132 -132
- package/src/billing/billing.enum.ts +9 -9
- package/src/billing/billing.event.ts +71 -71
- package/src/billing/billing.handler.ts +87 -87
- package/src/billing/billing.operations.ts +158 -158
- package/src/billing/billing.presentation.ts +45 -45
- package/src/billing/billing.schema.ts +76 -76
- package/src/billing/index.ts +43 -48
- package/src/dashboard/dashboard.presentation.ts +45 -45
- package/src/dashboard/index.ts +2 -2
- package/src/docs/saas-boilerplate.docblock.ts +43 -43
- package/src/example.ts +32 -32
- package/src/handlers/index.ts +9 -9
- package/src/handlers/saas.handlers.ts +250 -249
- package/src/index.ts +40 -41
- package/src/presentations/index.ts +18 -20
- package/src/project/index.ts +45 -50
- package/src/project/project.entity.ts +68 -68
- package/src/project/project.enum.ts +8 -8
- package/src/project/project.event.ts +79 -79
- package/src/project/project.handler.ts +103 -103
- package/src/project/project.operations.ts +236 -236
- package/src/project/project.presentation.ts +46 -46
- package/src/project/project.schema.ts +90 -90
- package/src/saas-boilerplate.feature.ts +100 -100
- package/src/seeders/index.ts +20 -20
- package/src/settings/index.ts +2 -3
- package/src/settings/settings.entity.ts +65 -65
- package/src/settings/settings.enum.ts +4 -4
- package/src/shared/mock-data.ts +92 -92
- package/src/shared/overlay-types.ts +23 -23
- package/src/tests/operations.test-spec.ts +96 -96
- package/src/ui/SaasDashboard.tsx +270 -270
- package/src/ui/SaasProjectList.tsx +90 -90
- package/src/ui/SaasSettingsPanel.tsx +84 -84
- package/src/ui/hooks/index.ts +3 -3
- package/src/ui/hooks/useProjectList.ts +69 -68
- package/src/ui/hooks/useProjectMutations.ts +144 -143
- package/src/ui/index.ts +8 -12
- package/src/ui/modals/CreateProjectModal.tsx +154 -154
- package/src/ui/modals/ProjectActionsModal.tsx +321 -321
- package/src/ui/overlays/demo-overlays.ts +49 -49
- package/src/ui/renderers/index.ts +5 -4
- package/src/ui/renderers/project-list.markdown.ts +204 -204
- package/src/ui/renderers/project-list.renderer.tsx +14 -13
- package/tsconfig.json +7 -8
- package/tsdown.config.js +7 -3
|
@@ -5,164 +5,164 @@ import { MOCK_PROJECTS } from '../shared/mock-data';
|
|
|
5
5
|
|
|
6
6
|
// Types inferred from contract schemas
|
|
7
7
|
export interface Project {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
slug?: string;
|
|
12
|
+
organizationId: string;
|
|
13
|
+
createdBy: string;
|
|
14
|
+
status: 'DRAFT' | 'ACTIVE' | 'ARCHIVED' | 'DELETED';
|
|
15
|
+
isPublic: boolean;
|
|
16
|
+
tags: string[];
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface CreateProjectInput {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
slug?: string;
|
|
25
|
+
isPublic?: boolean;
|
|
26
|
+
tags?: string[];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface UpdateProjectInput {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
projectId: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
slug?: string;
|
|
34
|
+
isPublic?: boolean;
|
|
35
|
+
tags?: string[];
|
|
36
|
+
status?: 'DRAFT' | 'ACTIVE' | 'ARCHIVED' | 'DELETED';
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export interface ListProjectsInput {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
status?: 'DRAFT' | 'ACTIVE' | 'ARCHIVED' | 'all';
|
|
41
|
+
search?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
offset?: number;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface ListProjectsOutput {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
projects: Project[];
|
|
48
|
+
total: number;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Mock handler for ListProjectsContract.
|
|
53
53
|
*/
|
|
54
54
|
export async function mockListProjectsHandler(
|
|
55
|
-
|
|
55
|
+
input: ListProjectsInput
|
|
56
56
|
): Promise<ListProjectsOutput> {
|
|
57
|
-
|
|
57
|
+
const { status, search, limit = 20, offset = 0 } = input;
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
let filtered = [...MOCK_PROJECTS];
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if (status && status !== 'all') {
|
|
62
|
+
filtered = filtered.filter((p) => p.status === status);
|
|
63
|
+
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
if (search) {
|
|
66
|
+
const q = search.toLowerCase();
|
|
67
|
+
filtered = filtered.filter(
|
|
68
|
+
(p) =>
|
|
69
|
+
p.name.toLowerCase().includes(q) ||
|
|
70
|
+
p.description?.toLowerCase().includes(q) ||
|
|
71
|
+
p.tags.some((t) => t.toLowerCase().includes(q))
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
filtered.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const total = filtered.length;
|
|
78
|
+
const projects = filtered.slice(offset, offset + limit);
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
return {
|
|
81
|
+
projects,
|
|
82
|
+
total,
|
|
83
|
+
};
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Mock handler for GetProjectContract.
|
|
88
88
|
*/
|
|
89
89
|
export async function mockGetProjectHandler(input: {
|
|
90
|
-
|
|
90
|
+
projectId: string;
|
|
91
91
|
}): Promise<Project> {
|
|
92
|
-
|
|
92
|
+
const project = MOCK_PROJECTS.find((p) => p.id === input.projectId);
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
if (!project) {
|
|
95
|
+
throw new Error('NOT_FOUND');
|
|
96
|
+
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
return project;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Mock handler for CreateProjectContract.
|
|
103
103
|
*/
|
|
104
104
|
export async function mockCreateProjectHandler(
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
input: CreateProjectInput,
|
|
106
|
+
context: { organizationId: string; userId: string }
|
|
107
107
|
): Promise<Project> {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
108
|
+
if (input.slug) {
|
|
109
|
+
const exists = MOCK_PROJECTS.some((p) => p.slug === input.slug);
|
|
110
|
+
if (exists) {
|
|
111
|
+
throw new Error('SLUG_EXISTS');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const now = new Date();
|
|
116
|
+
return {
|
|
117
|
+
id: `proj-${Date.now()}`,
|
|
118
|
+
name: input.name,
|
|
119
|
+
description: input.description,
|
|
120
|
+
slug: input.slug ?? input.name.toLowerCase().replace(/\s+/g, '-'),
|
|
121
|
+
organizationId: context.organizationId,
|
|
122
|
+
createdBy: context.userId,
|
|
123
|
+
status: 'DRAFT',
|
|
124
|
+
isPublic: input.isPublic ?? false,
|
|
125
|
+
tags: input.tags ?? [],
|
|
126
|
+
createdAt: now,
|
|
127
|
+
updatedAt: now,
|
|
128
|
+
};
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Mock handler for UpdateProjectContract.
|
|
133
133
|
*/
|
|
134
134
|
export async function mockUpdateProjectHandler(
|
|
135
|
-
|
|
135
|
+
input: UpdateProjectInput
|
|
136
136
|
): Promise<Project> {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
const project = MOCK_PROJECTS.find((p) => p.id === input.projectId);
|
|
138
|
+
|
|
139
|
+
if (!project) {
|
|
140
|
+
throw new Error('NOT_FOUND');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
...project,
|
|
145
|
+
name: input.name ?? project.name,
|
|
146
|
+
description: input.description ?? project.description,
|
|
147
|
+
slug: input.slug ?? project.slug,
|
|
148
|
+
isPublic: input.isPublic ?? project.isPublic,
|
|
149
|
+
tags: input.tags ?? project.tags,
|
|
150
|
+
status: input.status ?? project.status,
|
|
151
|
+
updatedAt: new Date(),
|
|
152
|
+
};
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Mock handler for DeleteProjectContract.
|
|
157
157
|
*/
|
|
158
158
|
export async function mockDeleteProjectHandler(input: {
|
|
159
|
-
|
|
159
|
+
projectId: string;
|
|
160
160
|
}): Promise<{ success: boolean }> {
|
|
161
|
-
|
|
161
|
+
const project = MOCK_PROJECTS.find((p) => p.id === input.projectId);
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
if (!project) {
|
|
164
|
+
throw new Error('NOT_FOUND');
|
|
165
|
+
}
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
return { success: true };
|
|
168
168
|
}
|