@contractspec/example.lifecycle-dashboard 0.0.0-canary-20260113162409
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$colon$bundle.log +25 -0
- package/.turbo/turbo-build.log +26 -0
- package/CHANGELOG.md +293 -0
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/lifecycle-dashboard.docblock.d.ts +1 -0
- package/dist/docs/lifecycle-dashboard.docblock.js +20 -0
- package/dist/docs/lifecycle-dashboard.docblock.js.map +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +43 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/snippets/page.d.ts +11 -0
- package/dist/snippets/page.d.ts.map +1 -0
- package/dist/snippets/page.js +63 -0
- package/dist/snippets/page.js.map +1 -0
- package/example.ts +1 -0
- package/package.json +56 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/lifecycle-dashboard.docblock.ts +18 -0
- package/src/example.ts +31 -0
- package/src/index.ts +3 -0
- package/src/snippets/page.ts +58 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +6 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DocBlock } from '@contractspec/lib.contracts/docs';
|
|
2
|
+
import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
|
|
3
|
+
|
|
4
|
+
const blocks: DocBlock[] = [
|
|
5
|
+
{
|
|
6
|
+
id: 'docs.examples.lifecycle-dashboard',
|
|
7
|
+
title: 'Lifecycle Dashboard (example snippet)',
|
|
8
|
+
summary:
|
|
9
|
+
'Minimal dashboard page pattern that calls lifecycle-managed API routes and renders a status card.',
|
|
10
|
+
kind: 'reference',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
route: '/docs/examples/lifecycle-dashboard',
|
|
13
|
+
tags: ['lifecycle', 'dashboard', 'example'],
|
|
14
|
+
body: `## What this example shows\n- A simple client-driven fetch to \`POST /api/lifecycle/assessments\`.\n- A card-shaped UI pattern for stage + confidence + recommendations.\n\n## Notes\n- Keep your app design-system-first (no raw HTML in application code).\n- Add explicit loading/error/empty states with accessible messaging.\n- Implement API routes in your app as thin adapters over lifecycle-managed services.`,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
registerDocBlocks(blocks);
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineExample } from '@contractspec/lib.contracts';
|
|
2
|
+
|
|
3
|
+
const example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'lifecycle-dashboard',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'Lifecycle Dashboard (snippet)',
|
|
8
|
+
description:
|
|
9
|
+
'A minimal dashboard page pattern: call lifecycle-managed endpoints and render a mobile-friendly status card.',
|
|
10
|
+
kind: 'blueprint',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.core'],
|
|
14
|
+
tags: ['lifecycle', 'dashboard', 'nextjs', 'snippet'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: 'docs.examples.lifecycle-dashboard',
|
|
18
|
+
},
|
|
19
|
+
entrypoints: {
|
|
20
|
+
packageName: '@contractspec/example.lifecycle-dashboard',
|
|
21
|
+
docs: './docs',
|
|
22
|
+
},
|
|
23
|
+
surfaces: {
|
|
24
|
+
templates: true,
|
|
25
|
+
sandbox: { enabled: true, modes: ['markdown', 'specs'] },
|
|
26
|
+
studio: { enabled: true, installable: true },
|
|
27
|
+
mcp: { enabled: true },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default example;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic snippet for a Next.js App Router page.
|
|
3
|
+
*
|
|
4
|
+
* We keep this as a string so `packages/examples/*` stays design-system-first and
|
|
5
|
+
* avoids raw HTML in runnable application code.
|
|
6
|
+
*/
|
|
7
|
+
export const lifecycleDashboardNextPageSnippet = `'use client';
|
|
8
|
+
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
type StageCard = {
|
|
12
|
+
stage: number;
|
|
13
|
+
name: string;
|
|
14
|
+
confidence: number;
|
|
15
|
+
recommendation?: {
|
|
16
|
+
actions: { id: string; title: string; description: string }[];
|
|
17
|
+
};
|
|
18
|
+
libraries?: { id: string; description: string }[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default function LifecycleDashboardPage() {
|
|
22
|
+
const [card, setCard] = useState<StageCard | null>(null);
|
|
23
|
+
const [loading, setLoading] = useState(false);
|
|
24
|
+
const [error, setError] = useState<string>();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
void runAssessment();
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
async function runAssessment() {
|
|
31
|
+
try {
|
|
32
|
+
setLoading(true);
|
|
33
|
+
setError(undefined);
|
|
34
|
+
const response = await fetch('/api/lifecycle/assessments', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify({ tenantId: 'demo' }),
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) throw new Error('Failed assessment');
|
|
40
|
+
const data = await response.json();
|
|
41
|
+
setCard({
|
|
42
|
+
stage: data.assessment.stage,
|
|
43
|
+
name: data.assessment.stageName ?? \`Stage \${data.assessment.stage}\`,
|
|
44
|
+
confidence: data.assessment.confidence,
|
|
45
|
+
recommendation: data.recommendation,
|
|
46
|
+
libraries: data.libraries,
|
|
47
|
+
});
|
|
48
|
+
} catch (err) {
|
|
49
|
+
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
50
|
+
} finally {
|
|
51
|
+
setLoading(false);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Render using your app's design system components in real code.
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
`;
|