@contractspec/example.saas-boilerplate 3.8.9 → 3.8.10

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 (156) hide show
  1. package/.turbo/turbo-build.log +156 -156
  2. package/CHANGELOG.md +20 -0
  3. package/dist/billing/billing.entity.js +1 -113
  4. package/dist/billing/billing.enum.js +1 -19
  5. package/dist/billing/billing.event.js +1 -90
  6. package/dist/billing/billing.handler.js +1 -148
  7. package/dist/billing/billing.operations.js +1 -278
  8. package/dist/billing/billing.presentation.js +1 -55
  9. package/dist/billing/billing.schema.js +1 -121
  10. package/dist/billing/index.js +1 -691
  11. package/dist/browser/billing/billing.entity.js +1 -113
  12. package/dist/browser/billing/billing.enum.js +1 -19
  13. package/dist/browser/billing/billing.event.js +1 -90
  14. package/dist/browser/billing/billing.handler.js +1 -148
  15. package/dist/browser/billing/billing.operations.js +1 -278
  16. package/dist/browser/billing/billing.presentation.js +1 -55
  17. package/dist/browser/billing/billing.schema.js +1 -121
  18. package/dist/browser/billing/index.js +1 -691
  19. package/dist/browser/dashboard/dashboard.presentation.js +1 -55
  20. package/dist/browser/dashboard/index.js +1 -55
  21. package/dist/browser/docs/index.js +5 -49
  22. package/dist/browser/docs/saas-boilerplate.docblock.js +5 -49
  23. package/dist/browser/example.js +1 -39
  24. package/dist/browser/handlers/index.js +2 -358
  25. package/dist/browser/handlers/saas.handlers.js +2 -134
  26. package/dist/browser/index.js +9 -3591
  27. package/dist/browser/presentations/index.js +1 -299
  28. package/dist/browser/project/index.js +1 -793
  29. package/dist/browser/project/project.entity.js +1 -77
  30. package/dist/browser/project/project.enum.js +1 -18
  31. package/dist/browser/project/project.event.js +1 -103
  32. package/dist/browser/project/project.handler.js +1 -178
  33. package/dist/browser/project/project.operations.js +1 -372
  34. package/dist/browser/project/project.presentation.js +1 -180
  35. package/dist/browser/project/project.schema.js +1 -134
  36. package/dist/browser/saas-boilerplate.feature.js +1 -304
  37. package/dist/browser/seeders/index.js +2 -20
  38. package/dist/browser/settings/index.js +1 -75
  39. package/dist/browser/settings/settings.entity.js +1 -74
  40. package/dist/browser/settings/settings.enum.js +1 -11
  41. package/dist/browser/shared/mock-data.js +1 -104
  42. package/dist/browser/tests/operations.test-spec.js +1 -112
  43. package/dist/browser/ui/SaasDashboard.js +1 -1239
  44. package/dist/browser/ui/SaasDashboard.visualizations.js +1 -249
  45. package/dist/browser/ui/SaasProjectList.js +1 -162
  46. package/dist/browser/ui/SaasSettingsPanel.js +1 -145
  47. package/dist/browser/ui/hooks/index.js +1 -159
  48. package/dist/browser/ui/hooks/useProjectList.js +1 -66
  49. package/dist/browser/ui/hooks/useProjectMutations.js +1 -91
  50. package/dist/browser/ui/index.js +5 -2077
  51. package/dist/browser/ui/modals/CreateProjectModal.js +1 -153
  52. package/dist/browser/ui/modals/ProjectActionsModal.js +1 -335
  53. package/dist/browser/ui/modals/index.js +1 -487
  54. package/dist/browser/ui/overlays/demo-overlays.js +1 -61
  55. package/dist/browser/ui/overlays/index.js +1 -61
  56. package/dist/browser/ui/renderers/index.js +5 -901
  57. package/dist/browser/ui/renderers/project-list.markdown.js +5 -725
  58. package/dist/browser/ui/renderers/project-list.renderer.js +1 -177
  59. package/dist/browser/visualizations/catalog.js +1 -155
  60. package/dist/browser/visualizations/index.js +1 -217
  61. package/dist/browser/visualizations/selectors.js +1 -210
  62. package/dist/dashboard/dashboard.presentation.js +1 -55
  63. package/dist/dashboard/index.js +1 -55
  64. package/dist/docs/index.js +5 -49
  65. package/dist/docs/saas-boilerplate.docblock.js +5 -49
  66. package/dist/example.js +1 -39
  67. package/dist/handlers/index.js +2 -358
  68. package/dist/handlers/saas.handlers.js +2 -134
  69. package/dist/index.js +9 -3591
  70. package/dist/node/billing/billing.entity.js +1 -113
  71. package/dist/node/billing/billing.enum.js +1 -19
  72. package/dist/node/billing/billing.event.js +1 -90
  73. package/dist/node/billing/billing.handler.js +1 -148
  74. package/dist/node/billing/billing.operations.js +1 -278
  75. package/dist/node/billing/billing.presentation.js +1 -55
  76. package/dist/node/billing/billing.schema.js +1 -121
  77. package/dist/node/billing/index.js +1 -691
  78. package/dist/node/dashboard/dashboard.presentation.js +1 -55
  79. package/dist/node/dashboard/index.js +1 -55
  80. package/dist/node/docs/index.js +5 -49
  81. package/dist/node/docs/saas-boilerplate.docblock.js +5 -49
  82. package/dist/node/example.js +1 -39
  83. package/dist/node/handlers/index.js +2 -358
  84. package/dist/node/handlers/saas.handlers.js +2 -134
  85. package/dist/node/index.js +9 -3591
  86. package/dist/node/presentations/index.js +1 -299
  87. package/dist/node/project/index.js +1 -793
  88. package/dist/node/project/project.entity.js +1 -77
  89. package/dist/node/project/project.enum.js +1 -18
  90. package/dist/node/project/project.event.js +1 -103
  91. package/dist/node/project/project.handler.js +1 -178
  92. package/dist/node/project/project.operations.js +1 -372
  93. package/dist/node/project/project.presentation.js +1 -180
  94. package/dist/node/project/project.schema.js +1 -134
  95. package/dist/node/saas-boilerplate.feature.js +1 -304
  96. package/dist/node/seeders/index.js +2 -20
  97. package/dist/node/settings/index.js +1 -75
  98. package/dist/node/settings/settings.entity.js +1 -74
  99. package/dist/node/settings/settings.enum.js +1 -11
  100. package/dist/node/shared/mock-data.js +1 -104
  101. package/dist/node/tests/operations.test-spec.js +1 -112
  102. package/dist/node/ui/SaasDashboard.js +1 -1239
  103. package/dist/node/ui/SaasDashboard.visualizations.js +1 -249
  104. package/dist/node/ui/SaasProjectList.js +1 -162
  105. package/dist/node/ui/SaasSettingsPanel.js +1 -145
  106. package/dist/node/ui/hooks/index.js +1 -159
  107. package/dist/node/ui/hooks/useProjectList.js +1 -66
  108. package/dist/node/ui/hooks/useProjectMutations.js +1 -91
  109. package/dist/node/ui/index.js +5 -2077
  110. package/dist/node/ui/modals/CreateProjectModal.js +1 -153
  111. package/dist/node/ui/modals/ProjectActionsModal.js +1 -335
  112. package/dist/node/ui/modals/index.js +1 -487
  113. package/dist/node/ui/overlays/demo-overlays.js +1 -61
  114. package/dist/node/ui/overlays/index.js +1 -61
  115. package/dist/node/ui/renderers/index.js +5 -901
  116. package/dist/node/ui/renderers/project-list.markdown.js +5 -725
  117. package/dist/node/ui/renderers/project-list.renderer.js +1 -177
  118. package/dist/node/visualizations/catalog.js +1 -155
  119. package/dist/node/visualizations/index.js +1 -217
  120. package/dist/node/visualizations/selectors.js +1 -210
  121. package/dist/presentations/index.js +1 -299
  122. package/dist/project/index.js +1 -793
  123. package/dist/project/project.entity.js +1 -77
  124. package/dist/project/project.enum.js +1 -18
  125. package/dist/project/project.event.js +1 -103
  126. package/dist/project/project.handler.js +1 -178
  127. package/dist/project/project.operations.js +1 -372
  128. package/dist/project/project.presentation.js +1 -180
  129. package/dist/project/project.schema.js +1 -134
  130. package/dist/saas-boilerplate.feature.js +1 -304
  131. package/dist/seeders/index.js +2 -20
  132. package/dist/settings/index.js +1 -75
  133. package/dist/settings/settings.entity.js +1 -74
  134. package/dist/settings/settings.enum.js +1 -11
  135. package/dist/shared/mock-data.js +1 -104
  136. package/dist/tests/operations.test-spec.js +1 -112
  137. package/dist/ui/SaasDashboard.js +1 -1239
  138. package/dist/ui/SaasDashboard.visualizations.js +1 -249
  139. package/dist/ui/SaasProjectList.js +1 -162
  140. package/dist/ui/SaasSettingsPanel.js +1 -145
  141. package/dist/ui/hooks/index.js +1 -159
  142. package/dist/ui/hooks/useProjectList.js +1 -66
  143. package/dist/ui/hooks/useProjectMutations.js +1 -91
  144. package/dist/ui/index.js +5 -2077
  145. package/dist/ui/modals/CreateProjectModal.js +1 -153
  146. package/dist/ui/modals/ProjectActionsModal.js +1 -335
  147. package/dist/ui/modals/index.js +1 -487
  148. package/dist/ui/overlays/demo-overlays.js +1 -61
  149. package/dist/ui/overlays/index.js +1 -61
  150. package/dist/ui/renderers/index.js +5 -901
  151. package/dist/ui/renderers/project-list.markdown.js +5 -725
  152. package/dist/ui/renderers/project-list.renderer.js +1 -177
  153. package/dist/visualizations/catalog.js +1 -155
  154. package/dist/visualizations/index.js +1 -217
  155. package/dist/visualizations/selectors.js +1 -210
  156. package/package.json +12 -12
@@ -1,177 +1 @@
1
- // src/ui/hooks/useProjectList.ts
2
- import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
- import { useCallback, useEffect, useMemo, useState } from "react";
4
- function useProjectList(options = {}) {
5
- const { handlers, projectId } = useTemplateRuntime();
6
- const { saas } = handlers;
7
- const [data, setData] = useState(null);
8
- const [subscription, setSubscription] = useState(null);
9
- const [loading, setLoading] = useState(true);
10
- const [error, setError] = useState(null);
11
- const [page, setPage] = useState(1);
12
- const fetchData = useCallback(async () => {
13
- setLoading(true);
14
- setError(null);
15
- try {
16
- const [projectsResult, subscriptionResult] = await Promise.all([
17
- saas.listProjects({
18
- projectId,
19
- status: options.status === "all" ? undefined : options.status,
20
- search: options.search,
21
- limit: options.limit ?? 20,
22
- offset: (page - 1) * (options.limit ?? 20)
23
- }),
24
- saas.getSubscription({ projectId })
25
- ]);
26
- setData({
27
- items: projectsResult.items,
28
- total: projectsResult.total
29
- });
30
- setSubscription(subscriptionResult);
31
- } catch (err) {
32
- setError(err instanceof Error ? err : new Error("Unknown error"));
33
- } finally {
34
- setLoading(false);
35
- }
36
- }, [saas, projectId, options.status, options.search, options.limit, page]);
37
- useEffect(() => {
38
- fetchData();
39
- }, [fetchData]);
40
- const stats = useMemo(() => {
41
- if (!data)
42
- return null;
43
- const items = data.items;
44
- return {
45
- total: data.total,
46
- activeCount: items.filter((p) => p.status === "ACTIVE").length,
47
- draftCount: items.filter((p) => p.status === "DRAFT").length,
48
- projectLimit: 10,
49
- usagePercent: Math.min(data.total / 10 * 100, 100)
50
- };
51
- }, [data]);
52
- return {
53
- data,
54
- subscription,
55
- loading,
56
- error,
57
- stats,
58
- page,
59
- refetch: fetchData,
60
- nextPage: () => setPage((p) => p + 1),
61
- prevPage: () => page > 1 && setPage((p) => p - 1)
62
- };
63
- }
64
-
65
- // src/ui/SaasProjectList.tsx
66
- import {
67
- Button,
68
- EmptyState,
69
- EntityCard,
70
- ErrorState,
71
- LoaderBlock,
72
- StatCard,
73
- StatCardGroup,
74
- StatusChip
75
- } from "@contractspec/lib.design-system";
76
- import { jsxDEV } from "react/jsx-dev-runtime";
77
- "use client";
78
- function getStatusTone(status) {
79
- switch (status) {
80
- case "ACTIVE":
81
- return "success";
82
- case "DRAFT":
83
- return "neutral";
84
- case "ARCHIVED":
85
- return "danger";
86
- default:
87
- return "neutral";
88
- }
89
- }
90
- function SaasProjectList({
91
- onProjectClick,
92
- onCreateProject
93
- }) {
94
- const { data, loading, error, stats, refetch } = useProjectList();
95
- if (loading && !data) {
96
- return /* @__PURE__ */ jsxDEV(LoaderBlock, {
97
- label: "Loading projects..."
98
- }, undefined, false, undefined, this);
99
- }
100
- if (error) {
101
- return /* @__PURE__ */ jsxDEV(ErrorState, {
102
- title: "Failed to load projects",
103
- description: error.message,
104
- onRetry: refetch,
105
- retryLabel: "Retry"
106
- }, undefined, false, undefined, this);
107
- }
108
- if (!data?.items.length) {
109
- return /* @__PURE__ */ jsxDEV(EmptyState, {
110
- title: "No projects found",
111
- description: "Create your first project to get started.",
112
- primaryAction: onCreateProject ? /* @__PURE__ */ jsxDEV(Button, {
113
- onPress: onCreateProject,
114
- children: "Create Project"
115
- }, undefined, false, undefined, this) : undefined
116
- }, undefined, false, undefined, this);
117
- }
118
- return /* @__PURE__ */ jsxDEV("div", {
119
- className: "space-y-6",
120
- children: [
121
- stats && /* @__PURE__ */ jsxDEV(StatCardGroup, {
122
- children: [
123
- /* @__PURE__ */ jsxDEV(StatCard, {
124
- label: "Total Projects",
125
- value: stats.total.toString()
126
- }, undefined, false, undefined, this),
127
- /* @__PURE__ */ jsxDEV(StatCard, {
128
- label: "Active",
129
- value: stats.activeCount.toString()
130
- }, undefined, false, undefined, this),
131
- /* @__PURE__ */ jsxDEV(StatCard, {
132
- label: "Draft",
133
- value: stats.draftCount.toString()
134
- }, undefined, false, undefined, this)
135
- ]
136
- }, undefined, true, undefined, this),
137
- /* @__PURE__ */ jsxDEV("div", {
138
- className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3",
139
- children: data.items.map((project) => /* @__PURE__ */ jsxDEV(EntityCard, {
140
- cardTitle: project.name,
141
- cardSubtitle: project.tier,
142
- meta: /* @__PURE__ */ jsxDEV("p", {
143
- className: "text-muted-foreground text-sm",
144
- children: project.description
145
- }, undefined, false, undefined, this),
146
- chips: /* @__PURE__ */ jsxDEV(StatusChip, {
147
- tone: getStatusTone(project.status),
148
- label: project.status
149
- }, undefined, false, undefined, this),
150
- footer: /* @__PURE__ */ jsxDEV("span", {
151
- className: "text-muted-foreground text-xs",
152
- children: project.updatedAt.toLocaleDateString()
153
- }, undefined, false, undefined, this),
154
- onClick: onProjectClick ? () => onProjectClick(project.id) : undefined
155
- }, project.id, false, undefined, this))
156
- }, undefined, false, undefined, this)
157
- ]
158
- }, undefined, true, undefined, this);
159
- }
160
-
161
- // src/ui/renderers/project-list.renderer.tsx
162
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
163
- var projectListReactRenderer = {
164
- target: "react",
165
- render: async (desc, _ctx) => {
166
- if (desc.source.type !== "component") {
167
- throw new Error("Invalid source type");
168
- }
169
- if (desc.source.componentKey !== "SaasProjectListView") {
170
- throw new Error(`Unknown component: ${desc.source.componentKey}`);
171
- }
172
- return /* @__PURE__ */ jsxDEV2(SaasProjectList, {}, undefined, false, undefined, this);
173
- }
174
- };
175
- export {
176
- projectListReactRenderer
177
- };
1
+ import{useTemplateRuntime as G}from"@contractspec/lib.example-shared-ui";import{useCallback as M,useEffect as B,useMemo as I,useState as $}from"react";function O(w={}){let{handlers:U,projectId:f}=G(),{saas:V}=U,[K,v]=$(null),[z,m]=$(null),[X,H]=$(!0),[Y,J]=$(null),[q,N]=$(1),A=M(async()=>{H(!0),J(null);try{let[R,_]=await Promise.all([V.listProjects({projectId:f,status:w.status==="all"?void 0:w.status,search:w.search,limit:w.limit??20,offset:(q-1)*(w.limit??20)}),V.getSubscription({projectId:f})]);v({items:R.items,total:R.total}),m(_)}catch(R){J(R instanceof Error?R:Error("Unknown error"))}finally{H(!1)}},[V,f,w.status,w.search,w.limit,q]);B(()=>{A()},[A]);let Z=I(()=>{if(!K)return null;let R=K.items;return{total:K.total,activeCount:R.filter((_)=>_.status==="ACTIVE").length,draftCount:R.filter((_)=>_.status==="DRAFT").length,projectLimit:10,usagePercent:Math.min(K.total/10*100,100)}},[K]);return{data:K,subscription:z,loading:X,error:Y,stats:Z,page:q,refetch:A,nextPage:()=>N((R)=>R+1),prevPage:()=>q>1&&N((R)=>R-1)}}import{Button as L,EmptyState as T,EntityCard as E,ErrorState as D,LoaderBlock as b,StatCard as F,StatCardGroup as h,StatusChip as k}from"@contractspec/lib.design-system";import{jsx as y,jsxs as Q}from"react/jsx-runtime";function P(w){switch(w){case"ACTIVE":return"success";case"DRAFT":return"neutral";case"ARCHIVED":return"danger";default:return"neutral"}}function W({onProjectClick:w,onCreateProject:U}){let{data:f,loading:V,error:K,stats:v,refetch:z}=O();if(V&&!f)return y(b,{label:"Loading projects..."});if(K)return y(D,{title:"Failed to load projects",description:K.message,onRetry:z,retryLabel:"Retry"});if(!f?.items.length)return y(T,{title:"No projects found",description:"Create your first project to get started.",primaryAction:U?y(L,{onPress:U,children:"Create Project"}):void 0});return Q("div",{className:"space-y-6",children:[v&&Q(h,{children:[y(F,{label:"Total Projects",value:v.total.toString()}),y(F,{label:"Active",value:v.activeCount.toString()}),y(F,{label:"Draft",value:v.draftCount.toString()})]}),y("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:f.items.map((m)=>y(E,{cardTitle:m.name,cardSubtitle:m.tier,meta:y("p",{className:"text-muted-foreground text-sm",children:m.description}),chips:y(k,{tone:P(m.status),label:m.status}),footer:y("span",{className:"text-muted-foreground text-xs",children:m.updatedAt.toLocaleDateString()}),onClick:w?()=>w(m.id):void 0},m.id))})]})}import{jsx as n}from"react/jsx-runtime";var r={target:"react",render:async(w,U)=>{if(w.source.type!=="component")throw Error("Invalid source type");if(w.source.componentKey!=="SaasProjectListView")throw Error(`Unknown component: ${w.source.componentKey}`);return n(W,{})}};export{r as projectListReactRenderer};
@@ -1,155 +1 @@
1
- // src/visualizations/catalog.ts
2
- import {
3
- defineVisualization,
4
- VisualizationRegistry
5
- } from "@contractspec/lib.contracts-spec/visualizations";
6
- var PROJECT_LIST_REF = {
7
- key: "saas.project.list",
8
- version: "1.0.0"
9
- };
10
- var META = {
11
- version: "1.0.0",
12
- domain: "saas",
13
- stability: "experimental",
14
- owners: ["@example.saas-boilerplate"],
15
- tags: ["saas", "visualization", "projects"]
16
- };
17
- var SaasProjectUsageVisualization = defineVisualization({
18
- meta: {
19
- ...META,
20
- key: "saas-boilerplate.visualization.project-usage",
21
- title: "Project Capacity",
22
- description: "Current project count against the current plan limit.",
23
- goal: "Show usage against the active plan allowance.",
24
- context: "SaaS account overview."
25
- },
26
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
27
- visualization: {
28
- kind: "metric",
29
- measure: "totalProjects",
30
- comparisonMeasure: "projectLimit",
31
- measures: [
32
- {
33
- key: "totalProjects",
34
- label: "Projects",
35
- dataPath: "totalProjects",
36
- format: "number"
37
- },
38
- {
39
- key: "projectLimit",
40
- label: "Plan Limit",
41
- dataPath: "projectLimit",
42
- format: "number"
43
- }
44
- ],
45
- table: { caption: "Current project count and plan limit." }
46
- }
47
- });
48
- var SaasProjectStatusVisualization = defineVisualization({
49
- meta: {
50
- ...META,
51
- key: "saas-boilerplate.visualization.project-status",
52
- title: "Project Status",
53
- description: "Distribution of project states.",
54
- goal: "Show the mix of active, draft, and archived projects.",
55
- context: "Project portfolio overview."
56
- },
57
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
58
- visualization: {
59
- kind: "pie",
60
- nameDimension: "status",
61
- valueMeasure: "projects",
62
- dimensions: [
63
- { key: "status", label: "Status", dataPath: "status", type: "category" }
64
- ],
65
- measures: [
66
- {
67
- key: "projects",
68
- label: "Projects",
69
- dataPath: "projects",
70
- format: "number"
71
- }
72
- ],
73
- table: { caption: "Project counts by status." }
74
- }
75
- });
76
- var SaasProjectTierVisualization = defineVisualization({
77
- meta: {
78
- ...META,
79
- key: "saas-boilerplate.visualization.project-tiers",
80
- title: "Tier Comparison",
81
- description: "Distribution of projects across tiers.",
82
- goal: "Compare how the current portfolio is distributed by tier.",
83
- context: "Plan and packaging overview."
84
- },
85
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
86
- visualization: {
87
- kind: "cartesian",
88
- variant: "bar",
89
- xDimension: "tier",
90
- yMeasures: ["projects"],
91
- dimensions: [
92
- { key: "tier", label: "Tier", dataPath: "tier", type: "category" }
93
- ],
94
- measures: [
95
- {
96
- key: "projects",
97
- label: "Projects",
98
- dataPath: "projects",
99
- format: "number",
100
- color: "#1d4ed8"
101
- }
102
- ],
103
- table: { caption: "Project counts by tier." }
104
- }
105
- });
106
- var SaasProjectActivityVisualization = defineVisualization({
107
- meta: {
108
- ...META,
109
- key: "saas-boilerplate.visualization.project-activity",
110
- title: "Recent Project Activity",
111
- description: "Daily project creation activity.",
112
- goal: "Show recent project activity over time.",
113
- context: "Project portfolio trend view."
114
- },
115
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
116
- visualization: {
117
- kind: "cartesian",
118
- variant: "line",
119
- xDimension: "day",
120
- yMeasures: ["projects"],
121
- dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
122
- measures: [
123
- {
124
- key: "projects",
125
- label: "Projects",
126
- dataPath: "projects",
127
- format: "number",
128
- color: "#0f766e"
129
- }
130
- ],
131
- table: { caption: "Daily project creation counts." }
132
- }
133
- });
134
- var SaasVisualizationSpecs = [
135
- SaasProjectUsageVisualization,
136
- SaasProjectStatusVisualization,
137
- SaasProjectTierVisualization,
138
- SaasProjectActivityVisualization
139
- ];
140
- var SaasVisualizationRegistry = new VisualizationRegistry([
141
- ...SaasVisualizationSpecs
142
- ]);
143
- var SaasVisualizationRefs = SaasVisualizationSpecs.map((spec) => ({
144
- key: spec.meta.key,
145
- version: spec.meta.version
146
- }));
147
- export {
148
- SaasVisualizationSpecs,
149
- SaasVisualizationRegistry,
150
- SaasVisualizationRefs,
151
- SaasProjectUsageVisualization,
152
- SaasProjectTierVisualization,
153
- SaasProjectStatusVisualization,
154
- SaasProjectActivityVisualization
155
- };
1
+ import{defineVisualization as b,VisualizationRegistry as w}from"@contractspec/lib.contracts-spec/visualizations";var h={key:"saas.project.list",version:"1.0.0"},k={version:"1.0.0",domain:"saas",stability:"experimental",owners:["@example.saas-boilerplate"],tags:["saas","visualization","projects"]},x=b({meta:{...k,key:"saas-boilerplate.visualization.project-usage",title:"Project Capacity",description:"Current project count against the current plan limit.",goal:"Show usage against the active plan allowance.",context:"SaaS account overview."},source:{primary:h,resultPath:"data"},visualization:{kind:"metric",measure:"totalProjects",comparisonMeasure:"projectLimit",measures:[{key:"totalProjects",label:"Projects",dataPath:"totalProjects",format:"number"},{key:"projectLimit",label:"Plan Limit",dataPath:"projectLimit",format:"number"}],table:{caption:"Current project count and plan limit."}}}),B=b({meta:{...k,key:"saas-boilerplate.visualization.project-status",title:"Project Status",description:"Distribution of project states.",goal:"Show the mix of active, draft, and archived projects.",context:"Project portfolio overview."},source:{primary:h,resultPath:"data"},visualization:{kind:"pie",nameDimension:"status",valueMeasure:"projects",dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"projects",label:"Projects",dataPath:"projects",format:"number"}],table:{caption:"Project counts by status."}}}),D=b({meta:{...k,key:"saas-boilerplate.visualization.project-tiers",title:"Tier Comparison",description:"Distribution of projects across tiers.",goal:"Compare how the current portfolio is distributed by tier.",context:"Plan and packaging overview."},source:{primary:h,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"tier",yMeasures:["projects"],dimensions:[{key:"tier",label:"Tier",dataPath:"tier",type:"category"}],measures:[{key:"projects",label:"Projects",dataPath:"projects",format:"number",color:"#1d4ed8"}],table:{caption:"Project counts by tier."}}}),G=b({meta:{...k,key:"saas-boilerplate.visualization.project-activity",title:"Recent Project Activity",description:"Daily project creation activity.",goal:"Show recent project activity over time.",context:"Project portfolio trend view."},source:{primary:h,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"day",yMeasures:["projects"],dimensions:[{key:"day",label:"Day",dataPath:"day",type:"time"}],measures:[{key:"projects",label:"Projects",dataPath:"projects",format:"number",color:"#0f766e"}],table:{caption:"Daily project creation counts."}}}),q=[x,B,D,G],K=new w([...q]),N=q.map((m)=>({key:m.meta.key,version:m.meta.version}));export{q as SaasVisualizationSpecs,K as SaasVisualizationRegistry,N as SaasVisualizationRefs,x as SaasProjectUsageVisualization,D as SaasProjectTierVisualization,B as SaasProjectStatusVisualization,G as SaasProjectActivityVisualization};
@@ -1,217 +1 @@
1
- // src/visualizations/catalog.ts
2
- import {
3
- defineVisualization,
4
- VisualizationRegistry
5
- } from "@contractspec/lib.contracts-spec/visualizations";
6
- var PROJECT_LIST_REF = {
7
- key: "saas.project.list",
8
- version: "1.0.0"
9
- };
10
- var META = {
11
- version: "1.0.0",
12
- domain: "saas",
13
- stability: "experimental",
14
- owners: ["@example.saas-boilerplate"],
15
- tags: ["saas", "visualization", "projects"]
16
- };
17
- var SaasProjectUsageVisualization = defineVisualization({
18
- meta: {
19
- ...META,
20
- key: "saas-boilerplate.visualization.project-usage",
21
- title: "Project Capacity",
22
- description: "Current project count against the current plan limit.",
23
- goal: "Show usage against the active plan allowance.",
24
- context: "SaaS account overview."
25
- },
26
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
27
- visualization: {
28
- kind: "metric",
29
- measure: "totalProjects",
30
- comparisonMeasure: "projectLimit",
31
- measures: [
32
- {
33
- key: "totalProjects",
34
- label: "Projects",
35
- dataPath: "totalProjects",
36
- format: "number"
37
- },
38
- {
39
- key: "projectLimit",
40
- label: "Plan Limit",
41
- dataPath: "projectLimit",
42
- format: "number"
43
- }
44
- ],
45
- table: { caption: "Current project count and plan limit." }
46
- }
47
- });
48
- var SaasProjectStatusVisualization = defineVisualization({
49
- meta: {
50
- ...META,
51
- key: "saas-boilerplate.visualization.project-status",
52
- title: "Project Status",
53
- description: "Distribution of project states.",
54
- goal: "Show the mix of active, draft, and archived projects.",
55
- context: "Project portfolio overview."
56
- },
57
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
58
- visualization: {
59
- kind: "pie",
60
- nameDimension: "status",
61
- valueMeasure: "projects",
62
- dimensions: [
63
- { key: "status", label: "Status", dataPath: "status", type: "category" }
64
- ],
65
- measures: [
66
- {
67
- key: "projects",
68
- label: "Projects",
69
- dataPath: "projects",
70
- format: "number"
71
- }
72
- ],
73
- table: { caption: "Project counts by status." }
74
- }
75
- });
76
- var SaasProjectTierVisualization = defineVisualization({
77
- meta: {
78
- ...META,
79
- key: "saas-boilerplate.visualization.project-tiers",
80
- title: "Tier Comparison",
81
- description: "Distribution of projects across tiers.",
82
- goal: "Compare how the current portfolio is distributed by tier.",
83
- context: "Plan and packaging overview."
84
- },
85
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
86
- visualization: {
87
- kind: "cartesian",
88
- variant: "bar",
89
- xDimension: "tier",
90
- yMeasures: ["projects"],
91
- dimensions: [
92
- { key: "tier", label: "Tier", dataPath: "tier", type: "category" }
93
- ],
94
- measures: [
95
- {
96
- key: "projects",
97
- label: "Projects",
98
- dataPath: "projects",
99
- format: "number",
100
- color: "#1d4ed8"
101
- }
102
- ],
103
- table: { caption: "Project counts by tier." }
104
- }
105
- });
106
- var SaasProjectActivityVisualization = defineVisualization({
107
- meta: {
108
- ...META,
109
- key: "saas-boilerplate.visualization.project-activity",
110
- title: "Recent Project Activity",
111
- description: "Daily project creation activity.",
112
- goal: "Show recent project activity over time.",
113
- context: "Project portfolio trend view."
114
- },
115
- source: { primary: PROJECT_LIST_REF, resultPath: "data" },
116
- visualization: {
117
- kind: "cartesian",
118
- variant: "line",
119
- xDimension: "day",
120
- yMeasures: ["projects"],
121
- dimensions: [{ key: "day", label: "Day", dataPath: "day", type: "time" }],
122
- measures: [
123
- {
124
- key: "projects",
125
- label: "Projects",
126
- dataPath: "projects",
127
- format: "number",
128
- color: "#0f766e"
129
- }
130
- ],
131
- table: { caption: "Daily project creation counts." }
132
- }
133
- });
134
- var SaasVisualizationSpecs = [
135
- SaasProjectUsageVisualization,
136
- SaasProjectStatusVisualization,
137
- SaasProjectTierVisualization,
138
- SaasProjectActivityVisualization
139
- ];
140
- var SaasVisualizationRegistry = new VisualizationRegistry([
141
- ...SaasVisualizationSpecs
142
- ]);
143
- var SaasVisualizationRefs = SaasVisualizationSpecs.map((spec) => ({
144
- key: spec.meta.key,
145
- version: spec.meta.version
146
- }));
147
-
148
- // src/visualizations/selectors.ts
149
- function toDayKey(value) {
150
- const date = value instanceof Date ? value : new Date(value);
151
- return date.toISOString().slice(0, 10);
152
- }
153
- function createSaasVisualizationItems(projects, projectLimit = 10) {
154
- const statusCounts = new Map;
155
- const tierCounts = new Map;
156
- const activityCounts = new Map;
157
- for (const project of projects) {
158
- statusCounts.set(project.status, (statusCounts.get(project.status) ?? 0) + 1);
159
- tierCounts.set(project.tier, (tierCounts.get(project.tier) ?? 0) + 1);
160
- const day = toDayKey(project.createdAt);
161
- activityCounts.set(day, (activityCounts.get(day) ?? 0) + 1);
162
- }
163
- return [
164
- {
165
- key: "saas-capacity",
166
- spec: SaasProjectUsageVisualization,
167
- data: { data: [{ totalProjects: projects.length, projectLimit }] },
168
- title: "Project Capacity",
169
- description: "Current project count compared to the active limit.",
170
- height: 220
171
- },
172
- {
173
- key: "saas-status",
174
- spec: SaasProjectStatusVisualization,
175
- data: {
176
- data: Array.from(statusCounts.entries()).map(([status, count]) => ({
177
- status,
178
- projects: count
179
- }))
180
- },
181
- title: "Project Status",
182
- description: "Status mix across the current project portfolio.",
183
- height: 260
184
- },
185
- {
186
- key: "saas-tier",
187
- spec: SaasProjectTierVisualization,
188
- data: {
189
- data: Array.from(tierCounts.entries()).map(([tier, count]) => ({
190
- tier,
191
- projects: count
192
- }))
193
- },
194
- title: "Tier Comparison",
195
- description: "How projects are distributed across tiers."
196
- },
197
- {
198
- key: "saas-activity",
199
- spec: SaasProjectActivityVisualization,
200
- data: {
201
- data: Array.from(activityCounts.entries()).sort(([left], [right]) => left.localeCompare(right)).map(([day, count]) => ({ day, projects: count }))
202
- },
203
- title: "Recent Project Activity",
204
- description: "Daily project creation activity."
205
- }
206
- ];
207
- }
208
- export {
209
- createSaasVisualizationItems,
210
- SaasVisualizationSpecs,
211
- SaasVisualizationRegistry,
212
- SaasVisualizationRefs,
213
- SaasProjectUsageVisualization,
214
- SaasProjectTierVisualization,
215
- SaasProjectStatusVisualization,
216
- SaasProjectActivityVisualization
217
- };
1
+ import{defineVisualization as m,VisualizationRegistry as $}from"@contractspec/lib.contracts-spec/visualizations";var q={key:"saas.project.list",version:"1.0.0"},w={version:"1.0.0",domain:"saas",stability:"experimental",owners:["@example.saas-boilerplate"],tags:["saas","visualization","projects"]},N=m({meta:{...w,key:"saas-boilerplate.visualization.project-usage",title:"Project Capacity",description:"Current project count against the current plan limit.",goal:"Show usage against the active plan allowance.",context:"SaaS account overview."},source:{primary:q,resultPath:"data"},visualization:{kind:"metric",measure:"totalProjects",comparisonMeasure:"projectLimit",measures:[{key:"totalProjects",label:"Projects",dataPath:"totalProjects",format:"number"},{key:"projectLimit",label:"Plan Limit",dataPath:"projectLimit",format:"number"}],table:{caption:"Current project count and plan limit."}}}),Q=m({meta:{...w,key:"saas-boilerplate.visualization.project-status",title:"Project Status",description:"Distribution of project states.",goal:"Show the mix of active, draft, and archived projects.",context:"Project portfolio overview."},source:{primary:q,resultPath:"data"},visualization:{kind:"pie",nameDimension:"status",valueMeasure:"projects",dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"projects",label:"Projects",dataPath:"projects",format:"number"}],table:{caption:"Project counts by status."}}}),W=m({meta:{...w,key:"saas-boilerplate.visualization.project-tiers",title:"Tier Comparison",description:"Distribution of projects across tiers.",goal:"Compare how the current portfolio is distributed by tier.",context:"Plan and packaging overview."},source:{primary:q,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"tier",yMeasures:["projects"],dimensions:[{key:"tier",label:"Tier",dataPath:"tier",type:"category"}],measures:[{key:"projects",label:"Projects",dataPath:"projects",format:"number",color:"#1d4ed8"}],table:{caption:"Project counts by tier."}}}),X=m({meta:{...w,key:"saas-boilerplate.visualization.project-activity",title:"Recent Project Activity",description:"Daily project creation activity.",goal:"Show recent project activity over time.",context:"Project portfolio trend view."},source:{primary:q,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"day",yMeasures:["projects"],dimensions:[{key:"day",label:"Day",dataPath:"day",type:"time"}],measures:[{key:"projects",label:"Projects",dataPath:"projects",format:"number",color:"#0f766e"}],table:{caption:"Daily project creation counts."}}}),Z=[N,Q,W,X],h=new $([...Z]),U=Z.map((k)=>({key:k.meta.key,version:k.meta.version}));function D(k){return(k instanceof Date?k:new Date(k)).toISOString().slice(0,10)}function I(k,Y=10){let B=new Map,G=new Map,H=new Map;for(let x of k){B.set(x.status,(B.get(x.status)??0)+1),G.set(x.tier,(G.get(x.tier)??0)+1);let b=D(x.createdAt);H.set(b,(H.get(b)??0)+1)}return[{key:"saas-capacity",spec:N,data:{data:[{totalProjects:k.length,projectLimit:Y}]},title:"Project Capacity",description:"Current project count compared to the active limit.",height:220},{key:"saas-status",spec:Q,data:{data:Array.from(B.entries()).map(([x,b])=>({status:x,projects:b}))},title:"Project Status",description:"Status mix across the current project portfolio.",height:260},{key:"saas-tier",spec:W,data:{data:Array.from(G.entries()).map(([x,b])=>({tier:x,projects:b}))},title:"Tier Comparison",description:"How projects are distributed across tiers."},{key:"saas-activity",spec:X,data:{data:Array.from(H.entries()).sort(([x],[b])=>x.localeCompare(b)).map(([x,b])=>({day:x,projects:b}))},title:"Recent Project Activity",description:"Daily project creation activity."}]}export{I as createSaasVisualizationItems,Z as SaasVisualizationSpecs,h as SaasVisualizationRegistry,U as SaasVisualizationRefs,N as SaasProjectUsageVisualization,W as SaasProjectTierVisualization,Q as SaasProjectStatusVisualization,X as SaasProjectActivityVisualization};