@contractspec/example.saas-boilerplate 1.57.0 → 1.58.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.
- package/.turbo/turbo-build.log +160 -180
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +20 -0
- package/dist/billing/billing.entity.d.ts +40 -45
- package/dist/billing/billing.entity.d.ts.map +1 -1
- package/dist/billing/billing.entity.js +110 -118
- package/dist/billing/billing.enum.d.ts +2 -7
- package/dist/billing/billing.enum.d.ts.map +1 -1
- package/dist/billing/billing.enum.js +17 -24
- package/dist/billing/billing.event.d.ts +67 -73
- package/dist/billing/billing.event.d.ts.map +1 -1
- package/dist/billing/billing.event.js +84 -146
- package/dist/billing/billing.handler.d.ts +59 -62
- package/dist/billing/billing.handler.d.ts.map +1 -1
- package/dist/billing/billing.handler.js +140 -49
- package/dist/billing/billing.operations.d.ts +138 -144
- package/dist/billing/billing.operations.d.ts.map +1 -1
- package/dist/billing/billing.operations.js +273 -175
- package/dist/billing/billing.presentation.d.ts +2 -7
- package/dist/billing/billing.presentation.d.ts.map +1 -1
- package/dist/billing/billing.presentation.js +51 -57
- package/dist/billing/billing.schema.d.ts +159 -164
- package/dist/billing/billing.schema.d.ts.map +1 -1
- package/dist/billing/billing.schema.js +112 -204
- package/dist/billing/index.d.ts +11 -8
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +689 -9
- package/dist/browser/billing/billing.entity.js +113 -0
- package/dist/browser/billing/billing.enum.js +19 -0
- package/dist/browser/billing/billing.event.js +90 -0
- package/dist/browser/billing/billing.handler.js +148 -0
- package/dist/browser/billing/billing.operations.js +278 -0
- package/dist/browser/billing/billing.presentation.js +52 -0
- package/dist/browser/billing/billing.schema.js +121 -0
- package/dist/browser/billing/index.js +688 -0
- package/dist/browser/dashboard/dashboard.presentation.js +52 -0
- package/dist/browser/dashboard/index.js +52 -0
- package/dist/browser/docs/index.js +93 -0
- package/dist/browser/docs/saas-boilerplate.docblock.js +93 -0
- package/dist/browser/example.js +39 -0
- package/dist/browser/handlers/index.js +358 -0
- package/dist/browser/handlers/saas.handlers.js +134 -0
- package/dist/browser/index.js +3340 -0
- package/dist/browser/presentations/index.js +290 -0
- package/dist/browser/project/index.js +790 -0
- package/dist/browser/project/project.entity.js +77 -0
- package/dist/browser/project/project.enum.js +18 -0
- package/dist/browser/project/project.event.js +103 -0
- package/dist/browser/project/project.handler.js +178 -0
- package/dist/browser/project/project.operations.js +372 -0
- package/dist/browser/project/project.presentation.js +177 -0
- package/dist/browser/project/project.schema.js +134 -0
- package/dist/browser/saas-boilerplate.feature.js +88 -0
- package/dist/browser/seeders/index.js +20 -0
- package/dist/browser/settings/index.js +75 -0
- package/dist/browser/settings/settings.entity.js +74 -0
- package/dist/browser/settings/settings.enum.js +11 -0
- package/dist/browser/shared/mock-data.js +104 -0
- package/dist/browser/shared/overlay-types.js +0 -0
- package/dist/browser/tests/operations.test-spec.js +112 -0
- package/dist/browser/ui/SaasDashboard.js +988 -0
- package/dist/browser/ui/SaasProjectList.js +162 -0
- package/dist/browser/ui/SaasSettingsPanel.js +145 -0
- package/dist/browser/ui/hooks/index.js +159 -0
- package/dist/browser/ui/hooks/useProjectList.js +66 -0
- package/dist/browser/ui/hooks/useProjectMutations.js +91 -0
- package/dist/browser/ui/index.js +1808 -0
- package/dist/browser/ui/modals/CreateProjectModal.js +153 -0
- package/dist/browser/ui/modals/ProjectActionsModal.js +335 -0
- package/dist/browser/ui/modals/index.js +487 -0
- package/dist/browser/ui/overlays/demo-overlays.js +61 -0
- package/dist/browser/ui/overlays/index.js +61 -0
- package/dist/browser/ui/renderers/index.js +675 -0
- package/dist/browser/ui/renderers/project-list.markdown.js +499 -0
- package/dist/browser/ui/renderers/project-list.renderer.js +177 -0
- package/dist/dashboard/dashboard.presentation.d.ts +2 -7
- package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
- package/dist/dashboard/dashboard.presentation.js +51 -53
- package/dist/dashboard/index.d.ts +5 -2
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +53 -3
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +94 -1
- package/dist/docs/saas-boilerplate.docblock.d.ts +2 -1
- package/dist/docs/saas-boilerplate.docblock.d.ts.map +1 -0
- package/dist/docs/saas-boilerplate.docblock.js +45 -51
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +38 -50
- package/dist/handlers/index.d.ts +7 -4
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +358 -4
- package/dist/handlers/saas.handlers.d.ts +60 -59
- package/dist/handlers/saas.handlers.d.ts.map +1 -1
- package/dist/handlers/saas.handlers.js +127 -140
- package/dist/index.d.ts +15 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3335 -75
- package/dist/node/billing/billing.entity.js +113 -0
- package/dist/node/billing/billing.enum.js +19 -0
- package/dist/node/billing/billing.event.js +90 -0
- package/dist/node/billing/billing.handler.js +148 -0
- package/dist/node/billing/billing.operations.js +278 -0
- package/dist/node/billing/billing.presentation.js +52 -0
- package/dist/node/billing/billing.schema.js +121 -0
- package/dist/node/billing/index.js +688 -0
- package/dist/node/dashboard/dashboard.presentation.js +52 -0
- package/dist/node/dashboard/index.js +52 -0
- package/dist/node/docs/index.js +93 -0
- package/dist/node/docs/saas-boilerplate.docblock.js +93 -0
- package/dist/node/example.js +39 -0
- package/dist/node/handlers/index.js +358 -0
- package/dist/node/handlers/saas.handlers.js +134 -0
- package/dist/node/index.js +3340 -0
- package/dist/node/presentations/index.js +290 -0
- package/dist/node/project/index.js +790 -0
- package/dist/node/project/project.entity.js +77 -0
- package/dist/node/project/project.enum.js +18 -0
- package/dist/node/project/project.event.js +103 -0
- package/dist/node/project/project.handler.js +178 -0
- package/dist/node/project/project.operations.js +372 -0
- package/dist/node/project/project.presentation.js +177 -0
- package/dist/node/project/project.schema.js +134 -0
- package/dist/node/saas-boilerplate.feature.js +88 -0
- package/dist/node/seeders/index.js +20 -0
- package/dist/node/settings/index.js +75 -0
- package/dist/node/settings/settings.entity.js +74 -0
- package/dist/node/settings/settings.enum.js +11 -0
- package/dist/node/shared/mock-data.js +104 -0
- package/dist/node/shared/overlay-types.js +0 -0
- package/dist/node/tests/operations.test-spec.js +112 -0
- package/dist/node/ui/SaasDashboard.js +988 -0
- package/dist/node/ui/SaasProjectList.js +162 -0
- package/dist/node/ui/SaasSettingsPanel.js +145 -0
- package/dist/node/ui/hooks/index.js +159 -0
- package/dist/node/ui/hooks/useProjectList.js +66 -0
- package/dist/node/ui/hooks/useProjectMutations.js +91 -0
- package/dist/node/ui/index.js +1808 -0
- package/dist/node/ui/modals/CreateProjectModal.js +153 -0
- package/dist/node/ui/modals/ProjectActionsModal.js +335 -0
- package/dist/node/ui/modals/index.js +487 -0
- package/dist/node/ui/overlays/demo-overlays.js +61 -0
- package/dist/node/ui/overlays/index.js +61 -0
- package/dist/node/ui/renderers/index.js +675 -0
- package/dist/node/ui/renderers/project-list.markdown.js +499 -0
- package/dist/node/ui/renderers/project-list.renderer.js +177 -0
- package/dist/presentations/index.d.ts +13 -14
- package/dist/presentations/index.d.ts.map +1 -1
- package/dist/presentations/index.js +289 -15
- package/dist/project/index.d.ts +11 -8
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +791 -9
- package/dist/project/project.entity.d.ts +23 -28
- package/dist/project/project.entity.d.ts.map +1 -1
- package/dist/project/project.entity.js +75 -82
- package/dist/project/project.enum.d.ts +2 -7
- package/dist/project/project.enum.d.ts.map +1 -1
- package/dist/project/project.enum.js +16 -23
- package/dist/project/project.event.d.ts +69 -75
- package/dist/project/project.event.d.ts.map +1 -1
- package/dist/project/project.event.js +95 -156
- package/dist/project/project.handler.d.ts +44 -47
- package/dist/project/project.handler.d.ts.map +1 -1
- package/dist/project/project.handler.js +168 -71
- package/dist/project/project.operations.d.ts +341 -347
- package/dist/project/project.operations.d.ts.map +1 -1
- package/dist/project/project.operations.js +366 -253
- package/dist/project/project.presentation.d.ts +2 -7
- package/dist/project/project.presentation.d.ts.map +1 -1
- package/dist/project/project.presentation.js +174 -61
- package/dist/project/project.schema.d.ts +191 -196
- package/dist/project/project.schema.d.ts.map +1 -1
- package/dist/project/project.schema.js +125 -205
- package/dist/saas-boilerplate.feature.d.ts +1 -6
- package/dist/saas-boilerplate.feature.d.ts.map +1 -1
- package/dist/saas-boilerplate.feature.js +87 -206
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +18 -16
- package/dist/settings/index.d.ts +6 -3
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +75 -3
- package/dist/settings/settings.entity.d.ts +23 -28
- package/dist/settings/settings.entity.d.ts.map +1 -1
- package/dist/settings/settings.entity.js +72 -75
- package/dist/settings/settings.enum.d.ts +1 -6
- package/dist/settings/settings.enum.d.ts.map +1 -1
- package/dist/settings/settings.enum.js +10 -19
- package/dist/shared/mock-data.d.ts +74 -77
- package/dist/shared/mock-data.d.ts.map +1 -1
- package/dist/shared/mock-data.js +102 -135
- package/dist/shared/overlay-types.d.ts +25 -28
- package/dist/shared/overlay-types.d.ts.map +1 -1
- package/dist/shared/overlay-types.js +1 -0
- package/dist/tests/operations.test-spec.d.ts +4 -9
- package/dist/tests/operations.test-spec.d.ts.map +1 -1
- package/dist/tests/operations.test-spec.js +108 -118
- package/dist/ui/SaasDashboard.d.ts +1 -6
- package/dist/ui/SaasDashboard.d.ts.map +1 -1
- package/dist/ui/SaasDashboard.js +977 -286
- package/dist/ui/SaasProjectList.d.ts +4 -11
- package/dist/ui/SaasProjectList.d.ts.map +1 -1
- package/dist/ui/SaasProjectList.js +159 -72
- package/dist/ui/SaasSettingsPanel.d.ts +1 -6
- package/dist/ui/SaasSettingsPanel.d.ts.map +1 -1
- package/dist/ui/SaasSettingsPanel.js +142 -134
- package/dist/ui/hooks/index.d.ts +3 -3
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +158 -4
- package/dist/ui/hooks/useProjectList.d.ts +26 -30
- package/dist/ui/hooks/useProjectList.d.ts.map +1 -1
- package/dist/ui/hooks/useProjectList.js +63 -71
- package/dist/ui/hooks/useProjectMutations.d.ts +20 -24
- package/dist/ui/hooks/useProjectMutations.d.ts.map +1 -1
- package/dist/ui/hooks/useProjectMutations.js +88 -142
- package/dist/ui/index.d.ts +8 -14
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1809 -15
- package/dist/ui/modals/CreateProjectModal.d.ts +10 -19
- package/dist/ui/modals/CreateProjectModal.d.ts.map +1 -1
- package/dist/ui/modals/CreateProjectModal.js +150 -135
- package/dist/ui/modals/ProjectActionsModal.d.ts +20 -33
- package/dist/ui/modals/ProjectActionsModal.d.ts.map +1 -1
- package/dist/ui/modals/ProjectActionsModal.js +333 -289
- package/dist/ui/modals/index.d.ts +3 -3
- package/dist/ui/modals/index.d.ts.map +1 -0
- package/dist/ui/modals/index.js +487 -3
- package/dist/ui/overlays/demo-overlays.d.ts +10 -8
- package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
- package/dist/ui/overlays/demo-overlays.js +60 -68
- package/dist/ui/overlays/index.d.ts +2 -2
- package/dist/ui/overlays/index.d.ts.map +1 -0
- package/dist/ui/overlays/index.js +62 -3
- package/dist/ui/renderers/index.d.ts +3 -3
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +675 -3
- package/dist/ui/renderers/project-list.markdown.d.ts +15 -14
- package/dist/ui/renderers/project-list.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/project-list.markdown.js +496 -146
- package/dist/ui/renderers/project-list.renderer.d.ts +6 -7
- package/dist/ui/renderers/project-list.renderer.d.ts.map +1 -1
- package/dist/ui/renderers/project-list.renderer.js +176 -15
- package/package.json +508 -98
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -180
- package/dist/billing/billing.entity.js.map +0 -1
- package/dist/billing/billing.enum.js.map +0 -1
- package/dist/billing/billing.event.js.map +0 -1
- package/dist/billing/billing.handler.js.map +0 -1
- package/dist/billing/billing.operations.js.map +0 -1
- package/dist/billing/billing.presentation.js.map +0 -1
- package/dist/billing/billing.schema.js.map +0 -1
- package/dist/dashboard/dashboard.presentation.js.map +0 -1
- package/dist/docs/saas-boilerplate.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/saas.handlers.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/presentations/index.js.map +0 -1
- package/dist/project/project.entity.js.map +0 -1
- package/dist/project/project.enum.js.map +0 -1
- package/dist/project/project.event.js.map +0 -1
- package/dist/project/project.handler.js.map +0 -1
- package/dist/project/project.operations.js.map +0 -1
- package/dist/project/project.presentation.js.map +0 -1
- package/dist/project/project.schema.js.map +0 -1
- package/dist/saas-boilerplate.feature.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/settings/settings.entity.js.map +0 -1
- package/dist/settings/settings.enum.js.map +0 -1
- package/dist/shared/mock-data.js.map +0 -1
- package/dist/tests/operations.test-spec.js.map +0 -1
- package/dist/ui/SaasDashboard.js.map +0 -1
- package/dist/ui/SaasProjectList.js.map +0 -1
- package/dist/ui/SaasSettingsPanel.js.map +0 -1
- package/dist/ui/hooks/useProjectList.js.map +0 -1
- package/dist/ui/hooks/useProjectMutations.js.map +0 -1
- package/dist/ui/modals/CreateProjectModal.js.map +0 -1
- package/dist/ui/modals/ProjectActionsModal.js.map +0 -1
- package/dist/ui/overlays/demo-overlays.js.map +0 -1
- package/dist/ui/renderers/project-list.markdown.js.map +0 -1
- package/dist/ui/renderers/project-list.renderer.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
package/dist/project/index.js
CHANGED
|
@@ -1,9 +1,791 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/shared/mock-data.ts
|
|
3
|
+
var MOCK_PROJECTS = [
|
|
4
|
+
{
|
|
5
|
+
id: "proj-1",
|
|
6
|
+
name: "Marketing Website",
|
|
7
|
+
description: "Main company website redesign project",
|
|
8
|
+
slug: "marketing-website",
|
|
9
|
+
organizationId: "demo-org",
|
|
10
|
+
createdBy: "user-1",
|
|
11
|
+
status: "ACTIVE",
|
|
12
|
+
isPublic: false,
|
|
13
|
+
tags: ["marketing", "website", "redesign"],
|
|
14
|
+
createdAt: new Date("2024-01-15T10:00:00Z"),
|
|
15
|
+
updatedAt: new Date("2024-03-20T14:30:00Z")
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "proj-2",
|
|
19
|
+
name: "Mobile App v2",
|
|
20
|
+
description: "Next generation mobile application",
|
|
21
|
+
slug: "mobile-app-v2",
|
|
22
|
+
organizationId: "demo-org",
|
|
23
|
+
createdBy: "user-2",
|
|
24
|
+
status: "ACTIVE",
|
|
25
|
+
isPublic: false,
|
|
26
|
+
tags: ["mobile", "app", "v2"],
|
|
27
|
+
createdAt: new Date("2024-02-01T09:00:00Z"),
|
|
28
|
+
updatedAt: new Date("2024-04-05T11:15:00Z")
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "proj-3",
|
|
32
|
+
name: "API Integration",
|
|
33
|
+
description: "Third-party API integration project",
|
|
34
|
+
slug: "api-integration",
|
|
35
|
+
organizationId: "demo-org",
|
|
36
|
+
createdBy: "user-1",
|
|
37
|
+
status: "DRAFT",
|
|
38
|
+
isPublic: false,
|
|
39
|
+
tags: ["api", "integration"],
|
|
40
|
+
createdAt: new Date("2024-03-10T08:00:00Z"),
|
|
41
|
+
updatedAt: new Date("2024-03-10T08:00:00Z")
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "proj-4",
|
|
45
|
+
name: "Analytics Dashboard",
|
|
46
|
+
description: "Internal analytics and reporting dashboard",
|
|
47
|
+
slug: "analytics-dashboard",
|
|
48
|
+
organizationId: "demo-org",
|
|
49
|
+
createdBy: "user-3",
|
|
50
|
+
status: "ARCHIVED",
|
|
51
|
+
isPublic: true,
|
|
52
|
+
tags: ["analytics", "dashboard", "reporting"],
|
|
53
|
+
createdAt: new Date("2023-10-01T12:00:00Z"),
|
|
54
|
+
updatedAt: new Date("2024-02-28T16:45:00Z")
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
var MOCK_SUBSCRIPTION = {
|
|
58
|
+
id: "sub-1",
|
|
59
|
+
organizationId: "demo-org",
|
|
60
|
+
planId: "pro",
|
|
61
|
+
planName: "Professional",
|
|
62
|
+
status: "ACTIVE",
|
|
63
|
+
currentPeriodStart: new Date("2024-04-01T00:00:00Z"),
|
|
64
|
+
currentPeriodEnd: new Date("2024-05-01T00:00:00Z"),
|
|
65
|
+
limits: {
|
|
66
|
+
projects: 25,
|
|
67
|
+
users: 10,
|
|
68
|
+
storage: 50,
|
|
69
|
+
apiCalls: 1e5
|
|
70
|
+
},
|
|
71
|
+
usage: {
|
|
72
|
+
projects: 4,
|
|
73
|
+
users: 5,
|
|
74
|
+
storage: 12.5,
|
|
75
|
+
apiCalls: 45230
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var MOCK_USAGE_SUMMARY = {
|
|
79
|
+
organizationId: "demo-org",
|
|
80
|
+
period: "current_month",
|
|
81
|
+
apiCalls: {
|
|
82
|
+
total: 45230,
|
|
83
|
+
limit: 1e5,
|
|
84
|
+
percentUsed: 45.23
|
|
85
|
+
},
|
|
86
|
+
storage: {
|
|
87
|
+
totalGb: 12.5,
|
|
88
|
+
limitGb: 50,
|
|
89
|
+
percentUsed: 25
|
|
90
|
+
},
|
|
91
|
+
activeProjects: 4,
|
|
92
|
+
activeUsers: 5,
|
|
93
|
+
breakdown: [
|
|
94
|
+
{ date: "2024-04-01", apiCalls: 3200, storageGb: 12.1 },
|
|
95
|
+
{ date: "2024-04-02", apiCalls: 2800, storageGb: 12.2 },
|
|
96
|
+
{ date: "2024-04-03", apiCalls: 4100, storageGb: 12.3 },
|
|
97
|
+
{ date: "2024-04-04", apiCalls: 3600, storageGb: 12.4 },
|
|
98
|
+
{ date: "2024-04-05", apiCalls: 3800, storageGb: 12.5 }
|
|
99
|
+
]
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/project/project.handler.ts
|
|
103
|
+
async function mockListProjectsHandler(input) {
|
|
104
|
+
const { status, search, limit = 20, offset = 0 } = input;
|
|
105
|
+
let filtered = [...MOCK_PROJECTS];
|
|
106
|
+
if (status && status !== "all") {
|
|
107
|
+
filtered = filtered.filter((p) => p.status === status);
|
|
108
|
+
}
|
|
109
|
+
if (search) {
|
|
110
|
+
const q = search.toLowerCase();
|
|
111
|
+
filtered = filtered.filter((p) => p.name.toLowerCase().includes(q) || p.description?.toLowerCase().includes(q) || p.tags.some((t) => t.toLowerCase().includes(q)));
|
|
112
|
+
}
|
|
113
|
+
filtered.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
114
|
+
const total = filtered.length;
|
|
115
|
+
const projects = filtered.slice(offset, offset + limit);
|
|
116
|
+
return {
|
|
117
|
+
projects,
|
|
118
|
+
total
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
async function mockGetProjectHandler(input) {
|
|
122
|
+
const project = MOCK_PROJECTS.find((p) => p.id === input.projectId);
|
|
123
|
+
if (!project) {
|
|
124
|
+
throw new Error("NOT_FOUND");
|
|
125
|
+
}
|
|
126
|
+
return project;
|
|
127
|
+
}
|
|
128
|
+
async function mockCreateProjectHandler(input, context) {
|
|
129
|
+
if (input.slug) {
|
|
130
|
+
const exists = MOCK_PROJECTS.some((p) => p.slug === input.slug);
|
|
131
|
+
if (exists) {
|
|
132
|
+
throw new Error("SLUG_EXISTS");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const now = new Date;
|
|
136
|
+
return {
|
|
137
|
+
id: `proj-${Date.now()}`,
|
|
138
|
+
name: input.name,
|
|
139
|
+
description: input.description,
|
|
140
|
+
slug: input.slug ?? input.name.toLowerCase().replace(/\s+/g, "-"),
|
|
141
|
+
organizationId: context.organizationId,
|
|
142
|
+
createdBy: context.userId,
|
|
143
|
+
status: "DRAFT",
|
|
144
|
+
isPublic: input.isPublic ?? false,
|
|
145
|
+
tags: input.tags ?? [],
|
|
146
|
+
createdAt: now,
|
|
147
|
+
updatedAt: now
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async function mockUpdateProjectHandler(input) {
|
|
151
|
+
const project = MOCK_PROJECTS.find((p) => p.id === input.projectId);
|
|
152
|
+
if (!project) {
|
|
153
|
+
throw new Error("NOT_FOUND");
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
...project,
|
|
157
|
+
name: input.name ?? project.name,
|
|
158
|
+
description: input.description ?? project.description,
|
|
159
|
+
slug: input.slug ?? project.slug,
|
|
160
|
+
isPublic: input.isPublic ?? project.isPublic,
|
|
161
|
+
tags: input.tags ?? project.tags,
|
|
162
|
+
status: input.status ?? project.status,
|
|
163
|
+
updatedAt: new Date
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async function mockDeleteProjectHandler(input) {
|
|
167
|
+
const project = MOCK_PROJECTS.find((p) => p.id === input.projectId);
|
|
168
|
+
if (!project) {
|
|
169
|
+
throw new Error("NOT_FOUND");
|
|
170
|
+
}
|
|
171
|
+
return { success: true };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/project/project.enum.ts
|
|
175
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
176
|
+
var ProjectStatusSchemaEnum = defineEnum("ProjectStatus", [
|
|
177
|
+
"DRAFT",
|
|
178
|
+
"ACTIVE",
|
|
179
|
+
"ARCHIVED",
|
|
180
|
+
"DELETED"
|
|
181
|
+
]);
|
|
182
|
+
var ProjectStatusFilterEnum = defineEnum("ProjectStatusFilter", [
|
|
183
|
+
"DRAFT",
|
|
184
|
+
"ACTIVE",
|
|
185
|
+
"ARCHIVED",
|
|
186
|
+
"all"
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
// src/project/project.schema.ts
|
|
190
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
191
|
+
var ProjectModel = defineSchemaModel({
|
|
192
|
+
name: "Project",
|
|
193
|
+
description: "A project within an organization",
|
|
194
|
+
fields: {
|
|
195
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
196
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
197
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
198
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
199
|
+
organizationId: {
|
|
200
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
201
|
+
isOptional: false
|
|
202
|
+
},
|
|
203
|
+
createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
204
|
+
status: { type: ProjectStatusSchemaEnum, isOptional: false },
|
|
205
|
+
isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
206
|
+
tags: {
|
|
207
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
208
|
+
isArray: true,
|
|
209
|
+
isOptional: false
|
|
210
|
+
},
|
|
211
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
212
|
+
updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
var CreateProjectInputModel = defineSchemaModel({
|
|
216
|
+
name: "CreateProjectInput",
|
|
217
|
+
description: "Input for creating a project",
|
|
218
|
+
fields: {
|
|
219
|
+
name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
|
|
220
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
221
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
222
|
+
isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: true },
|
|
223
|
+
tags: {
|
|
224
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
225
|
+
isArray: true,
|
|
226
|
+
isOptional: true
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
var UpdateProjectInputModel = defineSchemaModel({
|
|
231
|
+
name: "UpdateProjectInput",
|
|
232
|
+
description: "Input for updating a project",
|
|
233
|
+
fields: {
|
|
234
|
+
projectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
235
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
236
|
+
description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
237
|
+
slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
238
|
+
isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: true },
|
|
239
|
+
tags: {
|
|
240
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
241
|
+
isArray: true,
|
|
242
|
+
isOptional: true
|
|
243
|
+
},
|
|
244
|
+
status: { type: ProjectStatusSchemaEnum, isOptional: true }
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
var GetProjectInputModel = defineSchemaModel({
|
|
248
|
+
name: "GetProjectInput",
|
|
249
|
+
fields: {
|
|
250
|
+
projectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
var DeleteProjectInputModel = defineSchemaModel({
|
|
254
|
+
name: "DeleteProjectInput",
|
|
255
|
+
fields: {
|
|
256
|
+
projectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
var DeleteProjectOutputModel = defineSchemaModel({
|
|
260
|
+
name: "DeleteProjectOutput",
|
|
261
|
+
fields: {
|
|
262
|
+
success: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
var ProjectDeletedPayloadModel = defineSchemaModel({
|
|
266
|
+
name: "ProjectDeletedPayload",
|
|
267
|
+
fields: {
|
|
268
|
+
projectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
var ListProjectsInputModel = defineSchemaModel({
|
|
272
|
+
name: "ListProjectsInput",
|
|
273
|
+
description: "Input for listing projects",
|
|
274
|
+
fields: {
|
|
275
|
+
status: { type: ProjectStatusFilterEnum, isOptional: true },
|
|
276
|
+
search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
277
|
+
limit: {
|
|
278
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
279
|
+
isOptional: true,
|
|
280
|
+
defaultValue: 20
|
|
281
|
+
},
|
|
282
|
+
offset: {
|
|
283
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
284
|
+
isOptional: true,
|
|
285
|
+
defaultValue: 0
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
var ListProjectsOutputModel = defineSchemaModel({
|
|
290
|
+
name: "ListProjectsOutput",
|
|
291
|
+
description: "Output for listing projects",
|
|
292
|
+
fields: {
|
|
293
|
+
projects: { type: ProjectModel, isArray: true, isOptional: false },
|
|
294
|
+
total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// src/project/project.operations.ts
|
|
299
|
+
import {
|
|
300
|
+
defineCommand,
|
|
301
|
+
defineQuery
|
|
302
|
+
} from "@contractspec/lib.contracts/operations";
|
|
303
|
+
var OWNERS = ["example.saas-boilerplate"];
|
|
304
|
+
var CreateProjectContract = defineCommand({
|
|
305
|
+
meta: {
|
|
306
|
+
key: "saas.project.create",
|
|
307
|
+
version: "1.0.0",
|
|
308
|
+
stability: "stable",
|
|
309
|
+
owners: [...OWNERS],
|
|
310
|
+
tags: ["saas", "project", "create"],
|
|
311
|
+
description: "Create a new project in the organization.",
|
|
312
|
+
goal: "Allow users to create projects for organizing work.",
|
|
313
|
+
context: "Called from project creation UI or API."
|
|
314
|
+
},
|
|
315
|
+
io: {
|
|
316
|
+
input: CreateProjectInputModel,
|
|
317
|
+
output: ProjectModel,
|
|
318
|
+
errors: {
|
|
319
|
+
SLUG_EXISTS: {
|
|
320
|
+
description: "A project with this slug already exists",
|
|
321
|
+
http: 409,
|
|
322
|
+
gqlCode: "SLUG_EXISTS",
|
|
323
|
+
when: "Slug is already taken in the organization"
|
|
324
|
+
},
|
|
325
|
+
LIMIT_REACHED: {
|
|
326
|
+
description: "Project limit reached for this plan",
|
|
327
|
+
http: 403,
|
|
328
|
+
gqlCode: "LIMIT_REACHED",
|
|
329
|
+
when: "Organization has reached project limit"
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
policy: {
|
|
334
|
+
auth: "user"
|
|
335
|
+
},
|
|
336
|
+
sideEffects: {
|
|
337
|
+
emits: [
|
|
338
|
+
{
|
|
339
|
+
key: "project.created",
|
|
340
|
+
version: "1.0.0",
|
|
341
|
+
when: "Project is created",
|
|
342
|
+
payload: ProjectModel
|
|
343
|
+
}
|
|
344
|
+
],
|
|
345
|
+
audit: ["project.created"]
|
|
346
|
+
},
|
|
347
|
+
acceptance: {
|
|
348
|
+
scenarios: [
|
|
349
|
+
{
|
|
350
|
+
key: "create-project-happy-path",
|
|
351
|
+
given: ["User is authenticated"],
|
|
352
|
+
when: ["User creates project"],
|
|
353
|
+
then: ["Project is created", "ProjectCreated event is emitted"]
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
examples: [
|
|
357
|
+
{
|
|
358
|
+
key: "create-basic",
|
|
359
|
+
input: { name: "Website Redesign", slug: "website-redesign" },
|
|
360
|
+
output: { id: "proj-123", name: "Website Redesign", isArchived: false }
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
var GetProjectContract = defineQuery({
|
|
366
|
+
meta: {
|
|
367
|
+
key: "saas.project.get",
|
|
368
|
+
version: "1.0.0",
|
|
369
|
+
stability: "stable",
|
|
370
|
+
owners: [...OWNERS],
|
|
371
|
+
tags: ["saas", "project", "get"],
|
|
372
|
+
description: "Get a project by ID.",
|
|
373
|
+
goal: "Retrieve project details.",
|
|
374
|
+
context: "Project detail page, API calls."
|
|
375
|
+
},
|
|
376
|
+
io: {
|
|
377
|
+
input: GetProjectInputModel,
|
|
378
|
+
output: ProjectModel,
|
|
379
|
+
errors: {
|
|
380
|
+
NOT_FOUND: {
|
|
381
|
+
description: "Project not found",
|
|
382
|
+
http: 404,
|
|
383
|
+
gqlCode: "NOT_FOUND",
|
|
384
|
+
when: "Project ID is invalid or user lacks access"
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
policy: {
|
|
389
|
+
auth: "user"
|
|
390
|
+
},
|
|
391
|
+
acceptance: {
|
|
392
|
+
scenarios: [
|
|
393
|
+
{
|
|
394
|
+
key: "get-project-happy-path",
|
|
395
|
+
given: ["Project exists"],
|
|
396
|
+
when: ["User requests project"],
|
|
397
|
+
then: ["Project details are returned"]
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
examples: [
|
|
401
|
+
{
|
|
402
|
+
key: "get-existing",
|
|
403
|
+
input: { projectId: "proj-123" },
|
|
404
|
+
output: { id: "proj-123", name: "Website Redesign" }
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
var UpdateProjectContract = defineCommand({
|
|
410
|
+
meta: {
|
|
411
|
+
key: "saas.project.update",
|
|
412
|
+
version: "1.0.0",
|
|
413
|
+
stability: "stable",
|
|
414
|
+
owners: [...OWNERS],
|
|
415
|
+
tags: ["saas", "project", "update"],
|
|
416
|
+
description: "Update project details.",
|
|
417
|
+
goal: "Allow project owners/editors to modify project.",
|
|
418
|
+
context: "Project settings page."
|
|
419
|
+
},
|
|
420
|
+
io: {
|
|
421
|
+
input: UpdateProjectInputModel,
|
|
422
|
+
output: ProjectModel
|
|
423
|
+
},
|
|
424
|
+
policy: {
|
|
425
|
+
auth: "user"
|
|
426
|
+
},
|
|
427
|
+
sideEffects: {
|
|
428
|
+
emits: [
|
|
429
|
+
{
|
|
430
|
+
key: "project.updated",
|
|
431
|
+
version: "1.0.0",
|
|
432
|
+
when: "Project is updated",
|
|
433
|
+
payload: ProjectModel
|
|
434
|
+
}
|
|
435
|
+
],
|
|
436
|
+
audit: ["project.updated"]
|
|
437
|
+
},
|
|
438
|
+
acceptance: {
|
|
439
|
+
scenarios: [
|
|
440
|
+
{
|
|
441
|
+
key: "update-project-happy-path",
|
|
442
|
+
given: ["Project exists"],
|
|
443
|
+
when: ["User updates description"],
|
|
444
|
+
then: ["Project is updated", "ProjectUpdated event is emitted"]
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
examples: [
|
|
448
|
+
{
|
|
449
|
+
key: "update-desc",
|
|
450
|
+
input: { projectId: "proj-123", description: "New description" },
|
|
451
|
+
output: { id: "proj-123", description: "New description" }
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
var DeleteProjectContract = defineCommand({
|
|
457
|
+
meta: {
|
|
458
|
+
key: "saas.project.delete",
|
|
459
|
+
version: "1.0.0",
|
|
460
|
+
stability: "stable",
|
|
461
|
+
owners: [...OWNERS],
|
|
462
|
+
tags: ["saas", "project", "delete"],
|
|
463
|
+
description: "Delete a project (soft delete).",
|
|
464
|
+
goal: "Allow project owners to remove projects.",
|
|
465
|
+
context: "Project settings page."
|
|
466
|
+
},
|
|
467
|
+
io: {
|
|
468
|
+
input: DeleteProjectInputModel,
|
|
469
|
+
output: DeleteProjectOutputModel
|
|
470
|
+
},
|
|
471
|
+
policy: {
|
|
472
|
+
auth: "user"
|
|
473
|
+
},
|
|
474
|
+
sideEffects: {
|
|
475
|
+
emits: [
|
|
476
|
+
{
|
|
477
|
+
key: "project.deleted",
|
|
478
|
+
version: "1.0.0",
|
|
479
|
+
when: "Project is deleted",
|
|
480
|
+
payload: ProjectDeletedPayloadModel
|
|
481
|
+
}
|
|
482
|
+
],
|
|
483
|
+
audit: ["project.deleted"]
|
|
484
|
+
},
|
|
485
|
+
acceptance: {
|
|
486
|
+
scenarios: [
|
|
487
|
+
{
|
|
488
|
+
key: "delete-project-happy-path",
|
|
489
|
+
given: ["Project exists"],
|
|
490
|
+
when: ["User deletes project"],
|
|
491
|
+
then: ["Project is deleted", "ProjectDeleted event is emitted"]
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
examples: [
|
|
495
|
+
{
|
|
496
|
+
key: "delete-existing",
|
|
497
|
+
input: { projectId: "proj-123" },
|
|
498
|
+
output: { success: true }
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
var ListProjectsContract = defineQuery({
|
|
504
|
+
meta: {
|
|
505
|
+
key: "saas.project.list",
|
|
506
|
+
version: "1.0.0",
|
|
507
|
+
stability: "stable",
|
|
508
|
+
owners: [...OWNERS],
|
|
509
|
+
tags: ["saas", "project", "list"],
|
|
510
|
+
description: "List projects in the organization.",
|
|
511
|
+
goal: "Show all projects user has access to.",
|
|
512
|
+
context: "Project list page, dashboard."
|
|
513
|
+
},
|
|
514
|
+
io: {
|
|
515
|
+
input: ListProjectsInputModel,
|
|
516
|
+
output: ListProjectsOutputModel
|
|
517
|
+
},
|
|
518
|
+
policy: {
|
|
519
|
+
auth: "user"
|
|
520
|
+
},
|
|
521
|
+
acceptance: {
|
|
522
|
+
scenarios: [
|
|
523
|
+
{
|
|
524
|
+
key: "list-projects-happy-path",
|
|
525
|
+
given: ["Projects exist"],
|
|
526
|
+
when: ["User lists projects"],
|
|
527
|
+
then: ["List of projects is returned"]
|
|
528
|
+
}
|
|
529
|
+
],
|
|
530
|
+
examples: [
|
|
531
|
+
{
|
|
532
|
+
key: "list-all",
|
|
533
|
+
input: { limit: 10 },
|
|
534
|
+
output: { items: [], total: 5 }
|
|
535
|
+
}
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// src/project/project.event.ts
|
|
541
|
+
import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
|
|
542
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
543
|
+
var ProjectCreatedPayload = defineSchemaModel2({
|
|
544
|
+
name: "ProjectCreatedPayload",
|
|
545
|
+
description: "Payload when a project is created",
|
|
546
|
+
fields: {
|
|
547
|
+
projectId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
548
|
+
name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
549
|
+
organizationId: {
|
|
550
|
+
type: ScalarTypeEnum2.String_unsecure(),
|
|
551
|
+
isOptional: false
|
|
552
|
+
},
|
|
553
|
+
createdBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
554
|
+
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
var ProjectUpdatedPayload = defineSchemaModel2({
|
|
558
|
+
name: "ProjectUpdatedPayload",
|
|
559
|
+
description: "Payload when a project is updated",
|
|
560
|
+
fields: {
|
|
561
|
+
projectId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
562
|
+
updatedFields: {
|
|
563
|
+
type: ScalarTypeEnum2.String_unsecure(),
|
|
564
|
+
isArray: true,
|
|
565
|
+
isOptional: false
|
|
566
|
+
},
|
|
567
|
+
updatedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
568
|
+
updatedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
var ProjectDeletedPayload = defineSchemaModel2({
|
|
572
|
+
name: "ProjectDeletedPayload",
|
|
573
|
+
description: "Payload when a project is deleted",
|
|
574
|
+
fields: {
|
|
575
|
+
projectId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
576
|
+
organizationId: {
|
|
577
|
+
type: ScalarTypeEnum2.String_unsecure(),
|
|
578
|
+
isOptional: false
|
|
579
|
+
},
|
|
580
|
+
deletedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
581
|
+
deletedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
var ProjectArchivedPayload = defineSchemaModel2({
|
|
585
|
+
name: "ProjectArchivedPayload",
|
|
586
|
+
description: "Payload when a project is archived",
|
|
587
|
+
fields: {
|
|
588
|
+
projectId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
589
|
+
archivedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
590
|
+
archivedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
var ProjectCreatedEvent = defineEvent({
|
|
594
|
+
meta: {
|
|
595
|
+
key: "project.created",
|
|
596
|
+
version: "1.0.0",
|
|
597
|
+
description: "A new project has been created.",
|
|
598
|
+
stability: "stable",
|
|
599
|
+
owners: ["@saas-team"],
|
|
600
|
+
tags: ["project", "created"]
|
|
601
|
+
},
|
|
602
|
+
payload: ProjectCreatedPayload
|
|
603
|
+
});
|
|
604
|
+
var ProjectUpdatedEvent = defineEvent({
|
|
605
|
+
meta: {
|
|
606
|
+
key: "project.updated",
|
|
607
|
+
version: "1.0.0",
|
|
608
|
+
description: "A project has been updated.",
|
|
609
|
+
stability: "stable",
|
|
610
|
+
owners: ["@saas-team"],
|
|
611
|
+
tags: ["project", "updated"]
|
|
612
|
+
},
|
|
613
|
+
payload: ProjectUpdatedPayload
|
|
614
|
+
});
|
|
615
|
+
var ProjectDeletedEvent = defineEvent({
|
|
616
|
+
meta: {
|
|
617
|
+
key: "project.deleted",
|
|
618
|
+
version: "1.0.0",
|
|
619
|
+
description: "A project has been deleted.",
|
|
620
|
+
stability: "stable",
|
|
621
|
+
owners: ["@saas-team"],
|
|
622
|
+
tags: ["project", "deleted"]
|
|
623
|
+
},
|
|
624
|
+
payload: ProjectDeletedPayload
|
|
625
|
+
});
|
|
626
|
+
var ProjectArchivedEvent = defineEvent({
|
|
627
|
+
meta: {
|
|
628
|
+
key: "project.archived",
|
|
629
|
+
version: "1.0.0",
|
|
630
|
+
description: "A project has been archived.",
|
|
631
|
+
stability: "stable",
|
|
632
|
+
owners: ["@saas-team"],
|
|
633
|
+
tags: ["project", "archived"]
|
|
634
|
+
},
|
|
635
|
+
payload: ProjectArchivedPayload
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
// src/project/project.entity.ts
|
|
639
|
+
import {
|
|
640
|
+
defineEntity,
|
|
641
|
+
defineEntityEnum,
|
|
642
|
+
field,
|
|
643
|
+
index
|
|
644
|
+
} from "@contractspec/lib.schema";
|
|
645
|
+
var ProjectStatusEnum = defineEntityEnum({
|
|
646
|
+
name: "ProjectStatus",
|
|
647
|
+
values: ["DRAFT", "ACTIVE", "ARCHIVED", "DELETED"],
|
|
648
|
+
schema: "saas_app",
|
|
649
|
+
description: "Status of a project."
|
|
650
|
+
});
|
|
651
|
+
var ProjectEntity = defineEntity({
|
|
652
|
+
name: "Project",
|
|
653
|
+
description: "A project belonging to an organization.",
|
|
654
|
+
schema: "saas_app",
|
|
655
|
+
map: "project",
|
|
656
|
+
fields: {
|
|
657
|
+
id: field.id({ description: "Unique project ID" }),
|
|
658
|
+
name: field.string({ description: "Project name" }),
|
|
659
|
+
description: field.string({
|
|
660
|
+
isOptional: true,
|
|
661
|
+
description: "Project description"
|
|
662
|
+
}),
|
|
663
|
+
slug: field.string({
|
|
664
|
+
isOptional: true,
|
|
665
|
+
description: "URL-friendly identifier"
|
|
666
|
+
}),
|
|
667
|
+
organizationId: field.foreignKey({ description: "Owning organization" }),
|
|
668
|
+
createdBy: field.foreignKey({
|
|
669
|
+
description: "User who created the project"
|
|
670
|
+
}),
|
|
671
|
+
status: field.enum("ProjectStatus", { default: "DRAFT" }),
|
|
672
|
+
isPublic: field.boolean({
|
|
673
|
+
default: false,
|
|
674
|
+
description: "Whether project is publicly visible"
|
|
675
|
+
}),
|
|
676
|
+
settings: field.json({
|
|
677
|
+
isOptional: true,
|
|
678
|
+
description: "Project-specific settings"
|
|
679
|
+
}),
|
|
680
|
+
tags: field.string({ isArray: true, description: "Project tags" }),
|
|
681
|
+
metadata: field.json({ isOptional: true }),
|
|
682
|
+
createdAt: field.createdAt(),
|
|
683
|
+
updatedAt: field.updatedAt(),
|
|
684
|
+
archivedAt: field.dateTime({ isOptional: true })
|
|
685
|
+
},
|
|
686
|
+
indexes: [
|
|
687
|
+
index.on(["organizationId", "status"]),
|
|
688
|
+
index.on(["organizationId", "createdAt"]),
|
|
689
|
+
index.unique(["organizationId", "slug"])
|
|
690
|
+
],
|
|
691
|
+
enums: [ProjectStatusEnum]
|
|
692
|
+
});
|
|
693
|
+
var ProjectMemberEntity = defineEntity({
|
|
694
|
+
name: "ProjectMember",
|
|
695
|
+
description: "User access to a specific project.",
|
|
696
|
+
schema: "saas_app",
|
|
697
|
+
map: "project_member",
|
|
698
|
+
fields: {
|
|
699
|
+
id: field.id(),
|
|
700
|
+
projectId: field.foreignKey(),
|
|
701
|
+
userId: field.foreignKey(),
|
|
702
|
+
role: field.string({
|
|
703
|
+
description: "Role in project (owner, editor, viewer)"
|
|
704
|
+
}),
|
|
705
|
+
addedBy: field.string({ isOptional: true }),
|
|
706
|
+
createdAt: field.createdAt()
|
|
707
|
+
},
|
|
708
|
+
indexes: [index.unique(["projectId", "userId"])]
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
// src/project/project.presentation.ts
|
|
712
|
+
import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
|
|
713
|
+
var ProjectListPresentation = definePresentation({
|
|
714
|
+
meta: {
|
|
715
|
+
key: "saas.project.list",
|
|
716
|
+
version: "1.0.0",
|
|
717
|
+
title: "Project List",
|
|
718
|
+
description: "List view of projects with status, tags, and last updated info",
|
|
719
|
+
domain: "saas-boilerplate",
|
|
720
|
+
owners: ["@saas-team"],
|
|
721
|
+
tags: ["project", "list", "dashboard"],
|
|
722
|
+
stability: StabilityEnum.Beta,
|
|
723
|
+
goal: "Browse and manage projects",
|
|
724
|
+
context: "Project list page"
|
|
725
|
+
},
|
|
726
|
+
source: {
|
|
727
|
+
type: "component",
|
|
728
|
+
framework: "react",
|
|
729
|
+
componentKey: "ProjectListView",
|
|
730
|
+
props: ProjectModel
|
|
731
|
+
},
|
|
732
|
+
targets: ["react", "markdown", "application/json"],
|
|
733
|
+
policy: {
|
|
734
|
+
flags: ["saas.projects.enabled"]
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
var ProjectDetailPresentation = definePresentation({
|
|
738
|
+
meta: {
|
|
739
|
+
key: "saas.project.detail",
|
|
740
|
+
version: "1.0.0",
|
|
741
|
+
title: "Project Details",
|
|
742
|
+
description: "Detailed view of a project with settings and activity",
|
|
743
|
+
domain: "saas-boilerplate",
|
|
744
|
+
owners: ["@saas-team"],
|
|
745
|
+
tags: ["project", "detail"],
|
|
746
|
+
stability: StabilityEnum.Beta,
|
|
747
|
+
goal: "View and edit project details",
|
|
748
|
+
context: "Project detail page"
|
|
749
|
+
},
|
|
750
|
+
source: {
|
|
751
|
+
type: "component",
|
|
752
|
+
framework: "react",
|
|
753
|
+
componentKey: "ProjectDetailView"
|
|
754
|
+
},
|
|
755
|
+
targets: ["react", "markdown"],
|
|
756
|
+
policy: {
|
|
757
|
+
flags: ["saas.projects.enabled"]
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
export {
|
|
761
|
+
mockUpdateProjectHandler,
|
|
762
|
+
mockListProjectsHandler,
|
|
763
|
+
mockGetProjectHandler,
|
|
764
|
+
mockDeleteProjectHandler,
|
|
765
|
+
mockCreateProjectHandler,
|
|
766
|
+
UpdateProjectInputModel,
|
|
767
|
+
UpdateProjectContract,
|
|
768
|
+
ProjectUpdatedEvent,
|
|
769
|
+
ProjectStatusSchemaEnum,
|
|
770
|
+
ProjectStatusFilterEnum,
|
|
771
|
+
ProjectStatusEnum,
|
|
772
|
+
ProjectModel,
|
|
773
|
+
ProjectMemberEntity,
|
|
774
|
+
ProjectListPresentation,
|
|
775
|
+
ProjectEntity,
|
|
776
|
+
ProjectDetailPresentation,
|
|
777
|
+
ProjectDeletedPayloadModel,
|
|
778
|
+
ProjectDeletedEvent,
|
|
779
|
+
ProjectCreatedEvent,
|
|
780
|
+
ProjectArchivedEvent,
|
|
781
|
+
ListProjectsOutputModel,
|
|
782
|
+
ListProjectsInputModel,
|
|
783
|
+
ListProjectsContract,
|
|
784
|
+
GetProjectInputModel,
|
|
785
|
+
GetProjectContract,
|
|
786
|
+
DeleteProjectOutputModel,
|
|
787
|
+
DeleteProjectInputModel,
|
|
788
|
+
DeleteProjectContract,
|
|
789
|
+
CreateProjectInputModel,
|
|
790
|
+
CreateProjectContract
|
|
791
|
+
};
|