@contractspec/bundle.library 3.9.8 → 3.9.9
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 +222 -214
- package/CHANGELOG.md +52 -0
- package/dist/components/docs/DocsIndexPage.js +2 -2
- package/dist/components/docs/docsManifest.js +1 -1
- package/dist/components/docs/getting-started/DataViewTutorialPage.js +81 -6
- package/dist/components/docs/getting-started/index.js +94 -19
- package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.d.ts +6 -0
- package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +176 -0
- package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.d.ts +1 -0
- package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +176 -0
- package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
- package/dist/components/docs/guides/index.d.ts +1 -0
- package/dist/components/docs/guides/index.js +220 -46
- package/dist/components/docs/index.js +1003 -309
- package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +22 -5
- package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
- package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
- package/dist/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
- package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
- package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
- package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
- package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.d.ts +10 -0
- package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +43 -0
- package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.d.ts +1 -0
- package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.js +43 -0
- package/dist/components/docs/libraries/index.d.ts +1 -0
- package/dist/components/docs/libraries/index.js +496 -97
- package/dist/components/docs/specs/SpecsDataViewsPage.js +49 -3
- package/dist/components/docs/specs/index.js +60 -14
- package/dist/index.js +1014 -320
- package/dist/node/components/docs/DocsIndexPage.js +2 -2
- package/dist/node/components/docs/docsManifest.js +1 -1
- package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +81 -6
- package/dist/node/components/docs/getting-started/index.js +94 -19
- package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +175 -0
- package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +175 -0
- package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
- package/dist/node/components/docs/guides/index.js +220 -46
- package/dist/node/components/docs/index.js +1003 -309
- package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
- package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
- package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
- package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
- package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
- package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
- package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +42 -0
- package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.js +42 -0
- package/dist/node/components/docs/libraries/index.js +496 -97
- package/dist/node/components/docs/specs/SpecsDataViewsPage.js +49 -3
- package/dist/node/components/docs/specs/index.js +60 -14
- package/dist/node/index.js +1014 -320
- package/package.json +74 -26
- package/src/components/docs/docsManifest.test.ts +87 -0
- package/src/components/docs/docsManifest.ts +90 -3
- package/src/components/docs/generated/docs-index.notifications.json +7 -7
- package/src/components/docs/getting-started/DataViewTutorialPage.tsx +181 -50
- package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.ts +185 -0
- package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.tsx +186 -0
- package/src/components/docs/guides/GuidesIndexPage.tsx +49 -42
- package/src/components/docs/guides/index.ts +1 -0
- package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +148 -35
- package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +38 -5
- package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +267 -64
- package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +235 -0
- package/src/components/docs/libraries/LibrariesOverviewPage.tsx +8 -2
- package/src/components/docs/libraries/LibrariesPersonalizationPage.tsx +141 -31
- package/src/components/docs/libraries/LibrariesTranslationRuntimePage.content.ts +78 -0
- package/src/components/docs/libraries/LibrariesTranslationRuntimePage.tsx +137 -0
- package/src/components/docs/libraries/index.ts +1 -0
- package/src/components/docs/specs/SpecsDataViewsPage.tsx +239 -113
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
export declare const shellUsageExample = "import {\n AppShell,\n
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
export declare const shellUsageExample = "import {\n AppShell,\n type ShellCommandGroup,\n type ShellNavSection,\n type ShellNotificationCenter,\n type PageOutlineItem,\n} from \"@contractspec/lib.design-system/shell\";\n\nconst navigation: ShellNavSection[] = [\n {\n title: \"Workspace\",\n items: [\n { label: \"Dashboard\", href: \"/dashboard\" },\n {\n label: \"Contracts\",\n href: \"/contracts\",\n children: [\n { label: \"Operations\", href: \"/contracts/operations\" },\n { label: \"Events\", href: \"/contracts/events\" },\n ],\n },\n ],\n },\n];\n\nconst commands: ShellCommandGroup[] = [\n {\n heading: \"Quick actions\",\n items: [\n { id: \"new-contract\", label: \"New contract\", shortcut: \"N\" },\n { id: \"import\", label: \"Import existing app\" },\n ],\n },\n];\n\nconst outline: PageOutlineItem[] = [\n {\n id: \"architecture\",\n label: \"Architecture\",\n level: 1,\n children: [\n { id: \"desktop\", label: \"Desktop shell\", level: 2 },\n { id: \"mobile\", label: \"Mobile adaptation\", level: 2 },\n ],\n },\n];\n\nconst notifications: ShellNotificationCenter = {\n label: \"Notifications\",\n loading: false,\n unreadCount: 2,\n items: [\n {\n id: \"contract-approved\",\n title: \"Contract approved\",\n body: \"Billing.create is ready to publish.\",\n status: \"unread\",\n createdAt: \"2026-04-29T09:30:00Z\",\n actionUrl: \"/contracts/billing.create\",\n category: \"Review\",\n },\n ],\n onSelect: (item) => openNotificationTarget(item),\n onMarkRead: (item) => markNotificationRead(item.id),\n onMarkAllRead: () => markAllNotificationsRead(),\n};\n\nexport function WorkspacePage() {\n return (\n <AppShell\n title=\"ContractSpec\"\n homeHref=\"/dashboard\"\n navigation={navigation}\n commands={commands}\n breadcrumbs={[\n { label: \"Workspace\", href: \"/dashboard\" },\n { label: \"Contracts\" },\n ]}\n notifications={notifications}\n pageOutline={outline}\n activeHref=\"/contracts\"\n activeOutlineId=\"desktop\"\n userMenu={<UserMenu onSignOut={() => signOut()} />}\n >\n <main>{/* route content */}</main>\n </AppShell>\n );\n}";
|
|
2
|
+
export declare const notificationCenterExample = "import {\n ListNotificationsOutputModel,\n MarkNotificationReadInputModel,\n} from \"@contractspec/lib.contracts-spec/notifications\";\nimport {\n notificationsSchemaContribution,\n renderNotificationTemplate,\n} from \"@contractspec/lib.notification\";\nimport type { ShellNotificationCenter } from \"@contractspec/lib.design-system/shell\";\n\ntype NotificationListResult = {\n unreadCount: number;\n notifications: Array<{\n id: string;\n title: string;\n body: string;\n type: string;\n status: string;\n readAt?: string | Date | null;\n createdAt: string | Date;\n actionUrl?: string;\n metadata?: Record<string, unknown>;\n }>;\n};\n\nexport function toShellNotifications(\n data: NotificationListResult,\n actions: {\n open: (id: string) => void;\n markRead: (input: { notificationId: string }) => void;\n markAllRead: () => void;\n }\n): ShellNotificationCenter {\n return {\n unreadCount: data.unreadCount,\n items: data.notifications.map((notification) => ({\n id: notification.id,\n title: notification.title,\n body: notification.body,\n status: notification.status,\n createdAt: notification.createdAt,\n actionUrl: notification.actionUrl,\n category: notification.type,\n metadata: notification.metadata,\n })),\n onSelect: (item) => actions.open(item.id),\n onMarkRead: (item) => actions.markRead({ notificationId: item.id }),\n onMarkAllRead: actions.markAllRead,\n };\n}\n\nvoid ListNotificationsOutputModel;\nvoid MarkNotificationReadInputModel;\nvoid notificationsSchemaContribution;\nvoid renderNotificationTemplate;";
|
|
3
|
+
export declare const scratchPrompt = "You are implementing a modern application shell from scratch.\n\nGoal:\nBuild a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, in-app notifications, and an in-page section navigator called PageOutline.\n\nUse this architecture:\n- Keep route content independent from navigation chrome.\n- Create a typed navigation model with sections, items, active state, optional children, badges, icons, disabled items, and href/onSelect support.\n- Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.\n- Create a breadcrumb model for the topbar.\n- Create a PageOutline model for right-side in-page navigation with exactly three supported levels. It should render anchors, support active section state, and degrade gracefully when no sections exist.\n- Create a ShellNotificationCenter model with render-ready items, unread count, loading and empty states, onSelect, onMarkRead, onMarkAllRead, and optional custom item rendering.\n- Expose the system from the design system or a dedicated shell module, not from a single app route.\n\nNotification boundary:\n- Use @contractspec/lib.contracts-spec/notifications as the canonical source for notification contracts, operation models, and feature metadata.\n- Use @contractspec/lib.notification for reusable notification entities, schema contribution, channels, templates, and i18n helpers.\n- Keep persistence, polling/subscriptions, delivery providers, and optimistic mutations in the host application or notification runtime layer.\n- Pass only render-ready ShellNotificationCenter state into AppShell so the design system does not import or own notification runtime behavior.\n\nDesktop behavior:\n- Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.\n- Topbar with breadcrumbs and an optional command trigger.\n- Topbar notification trigger with unread badge, loading/empty states, mark-read actions, and item selection.\n- Content area with optional right PageOutline.\n- Keep dimensions stable. Navigation labels must not resize layout on hover or active state.\n\nMobile web behavior:\n- Use bottom navigation for the primary destinations.\n- Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.\n- Keep route content first and make the shell controls reachable without covering important content.\n\nNative behavior:\n- Add .native.tsx entrypoints for Expo/React Native.\n- Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation, notifications, and account actions.\n- Keep the same typed navigation, command, breadcrumb, notification, and PageOutline data contracts across web and native.\n\nImplementation constraints:\n- Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.\n- Do not hardcode app-specific routes in the shell component.\n- Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.\n- Include tests for navigation rendering, nested items, command filtering, breadcrumbs, notification unread badge/loading/empty/callback behavior, PageOutline level handling, active section state, and mobile/native adaptation contracts.\n- Update docs and exports so developers can import the shell from a stable public API.\n\nDeliverables:\n- Typed shell models.\n- Web shell components.\n- Native shell components or adapters.\n- PageOutline component with three-level support.\n- ShellNotifications or equivalent notification center component for web and native shell placement.\n- Usage example.\n- Focused tests and typecheck/build evidence.";
|
|
4
|
+
export declare const refactorPrompt = "You are refactoring an existing application to use the shared application shell system.\n\nGoal:\nReplace app-specific sidebar, topbar, breadcrumb, command palette, notification badge/inbox, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell, ShellNotifications, and PageOutline system.\n\nStart by auditing:\n- Current layout wrappers and route groups.\n- Sidebar, topbar, breadcrumb, command/search, auth menu, and mobile navigation implementations.\n- Existing notification badges, inbox panels, toasts that represent durable in-app items, unread count queries, mark-read actions, and delivery modules.\n- Imports from @contractspec/module.notifications that should migrate to @contractspec/lib.contracts-spec/notifications or @contractspec/lib.notification.\n- Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.\n- Any in-page summary/table-of-contents components that should become PageOutline data.\n- Web-only assumptions that would block Expo/React Native adaptation.\n\nRefactor plan:\n1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.\n2. Map existing command/search behavior into grouped command actions with search text and quick actions.\n3. Map existing route metadata into breadcrumbs.\n4. Move canonical notification contracts to @contractspec/lib.contracts-spec/notifications and reusable helpers to @contractspec/lib.notification; keep the old module shim only for compatibility imports that still need the legacy module id.\n5. Convert notification query results into ShellNotificationCenter items with unreadCount, loading, empty state, onSelect, onMarkRead, and onMarkAllRead callbacks.\n6. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.\n7. Wrap app routes in AppShell while keeping page content components route-local.\n8. Move primary mobile destinations into bottom navigation and deeper/account/notification actions into a menu or drawer.\n9. Add or preserve .native.tsx adapters when the app targets Expo.\n\nPreserve behavior:\n- Existing route URLs and access rules.\n- Existing keyboard shortcuts where they are public behavior.\n- Existing analytics or telemetry events on navigation and command actions.\n- Existing notification delivery semantics, unread count semantics, deep links, and mark-read behavior.\n- Existing auth/logout behavior.\n- Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.\n\nQuality gates:\n- Add regression tests around current visible navigation before removing old shell code when coverage is missing.\n- Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, notification unread badge/loading/empty/callback behavior, auth menu, mobile bottom navigation, and PageOutline anchor behavior.\n- Run lint, typecheck, and the app's relevant test/build command.\n- Remove dead app-specific shell components only after the shared shell path is verified.\n\nOutput:\n- List old shell files removed or simplified.\n- List new shared shell integration points.\n- Include before/after route coverage and verification commands.";
|
|
5
|
+
export declare const notificationGuide: readonly [{
|
|
6
|
+
readonly title: "Contracts stay canonical";
|
|
7
|
+
readonly body: "Use @contractspec/lib.contracts-spec/notifications for operation models, feature metadata, and contract-level compatibility.";
|
|
8
|
+
}, {
|
|
9
|
+
readonly title: "Runtime helpers stay reusable";
|
|
10
|
+
readonly body: "Use @contractspec/lib.notification for schema contribution, channel adapters, templates, and i18n without importing the deprecated module shim in new code.";
|
|
11
|
+
}, {
|
|
12
|
+
readonly title: "Apps own live state";
|
|
13
|
+
readonly body: "Fetch, subscribe, persist, mutate, and reconcile notification state in the host app or runtime layer where auth and tenancy are known.";
|
|
14
|
+
}, {
|
|
15
|
+
readonly title: "Shell receives view state";
|
|
16
|
+
readonly body: "Pass AppShell a ShellNotificationCenter with render-ready items, counts, loading state, and callbacks; the design system only renders affordances.";
|
|
17
|
+
}];
|
|
4
18
|
export declare const shellParts: readonly [{
|
|
5
19
|
readonly title: "Sidebar";
|
|
6
20
|
readonly body: "Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area.";
|
|
7
21
|
}, {
|
|
8
22
|
readonly title: "Topbar";
|
|
9
|
-
readonly body: "Breadcrumbs stay visible while the current route changes.
|
|
23
|
+
readonly body: "Breadcrumbs stay visible while the current route changes. Command search and notification affordances can live here when the sidebar is collapsed or hidden.";
|
|
10
24
|
}, {
|
|
11
25
|
readonly title: "PageOutline";
|
|
12
26
|
readonly body: "The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state.";
|
|
27
|
+
}, {
|
|
28
|
+
readonly title: "Notifications";
|
|
29
|
+
readonly body: "The shell renders unread badges, item lists, loading/empty states, mark-read actions, and deep-link selection from host-owned notification state.";
|
|
13
30
|
}, {
|
|
14
31
|
readonly title: "Mobile adapters";
|
|
15
|
-
readonly body: "Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation and account actions.";
|
|
32
|
+
readonly body: "Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation, notifications, and account actions.";
|
|
16
33
|
}];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var i=Object.defineProperty;var n=(e)=>e;function o(e,t){this[e]=n.bind(null,t)}var s=(e,t)=>{for(var a in t)i(e,a,{get:t[a],enumerable:!0,configurable:!0,set:o.bind(t,a)})};var r=(e,t)=>()=>(e&&(t=e(e=0)),t);var l=`import {
|
|
3
3
|
AppShell,
|
|
4
|
-
|
|
5
|
-
type
|
|
4
|
+
type ShellCommandGroup,
|
|
5
|
+
type ShellNavSection,
|
|
6
|
+
type ShellNotificationCenter,
|
|
6
7
|
type PageOutlineItem,
|
|
7
8
|
} from "@contractspec/lib.design-system/shell";
|
|
8
9
|
|
|
9
|
-
const navigation:
|
|
10
|
+
const navigation: ShellNavSection[] = [
|
|
10
11
|
{
|
|
11
12
|
title: "Workspace",
|
|
12
13
|
items: [
|
|
@@ -23,6 +24,16 @@ const navigation: AppShellNavigationSection[] = [
|
|
|
23
24
|
},
|
|
24
25
|
];
|
|
25
26
|
|
|
27
|
+
const commands: ShellCommandGroup[] = [
|
|
28
|
+
{
|
|
29
|
+
heading: "Quick actions",
|
|
30
|
+
items: [
|
|
31
|
+
{ id: "new-contract", label: "New contract", shortcut: "N" },
|
|
32
|
+
{ id: "import", label: "Import existing app" },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
26
37
|
const outline: PageOutlineItem[] = [
|
|
27
38
|
{
|
|
28
39
|
id: "architecture",
|
|
@@ -35,41 +46,104 @@ const outline: PageOutlineItem[] = [
|
|
|
35
46
|
},
|
|
36
47
|
];
|
|
37
48
|
|
|
49
|
+
const notifications: ShellNotificationCenter = {
|
|
50
|
+
label: "Notifications",
|
|
51
|
+
loading: false,
|
|
52
|
+
unreadCount: 2,
|
|
53
|
+
items: [
|
|
54
|
+
{
|
|
55
|
+
id: "contract-approved",
|
|
56
|
+
title: "Contract approved",
|
|
57
|
+
body: "Billing.create is ready to publish.",
|
|
58
|
+
status: "unread",
|
|
59
|
+
createdAt: "2026-04-29T09:30:00Z",
|
|
60
|
+
actionUrl: "/contracts/billing.create",
|
|
61
|
+
category: "Review",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
onSelect: (item) => openNotificationTarget(item),
|
|
65
|
+
onMarkRead: (item) => markNotificationRead(item.id),
|
|
66
|
+
onMarkAllRead: () => markAllNotificationsRead(),
|
|
67
|
+
};
|
|
68
|
+
|
|
38
69
|
export function WorkspacePage() {
|
|
39
70
|
return (
|
|
40
71
|
<AppShell
|
|
41
|
-
|
|
72
|
+
title="ContractSpec"
|
|
73
|
+
homeHref="/dashboard"
|
|
42
74
|
navigation={navigation}
|
|
75
|
+
commands={commands}
|
|
43
76
|
breadcrumbs={[
|
|
44
77
|
{ label: "Workspace", href: "/dashboard" },
|
|
45
78
|
{ label: "Contracts" },
|
|
46
79
|
]}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
actions: [
|
|
53
|
-
{ id: "new-contract", label: "New contract" },
|
|
54
|
-
{ id: "import", label: "Import existing app" },
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
}}
|
|
59
|
-
user={{
|
|
60
|
-
name: "Ada Lovelace",
|
|
61
|
-
email: "ada@example.com",
|
|
62
|
-
actions: [{ label: "Sign out", onSelect: () => signOut() }],
|
|
63
|
-
}}
|
|
64
|
-
pageOutline={<PageOutline items={outline} activeId="desktop" />}
|
|
80
|
+
notifications={notifications}
|
|
81
|
+
pageOutline={outline}
|
|
82
|
+
activeHref="/contracts"
|
|
83
|
+
activeOutlineId="desktop"
|
|
84
|
+
userMenu={<UserMenu onSignOut={() => signOut()} />}
|
|
65
85
|
>
|
|
66
86
|
<main>{/* route content */}</main>
|
|
67
87
|
</AppShell>
|
|
68
88
|
);
|
|
69
|
-
}`,d=`
|
|
89
|
+
}`,d=`import {
|
|
90
|
+
ListNotificationsOutputModel,
|
|
91
|
+
MarkNotificationReadInputModel,
|
|
92
|
+
} from "@contractspec/lib.contracts-spec/notifications";
|
|
93
|
+
import {
|
|
94
|
+
notificationsSchemaContribution,
|
|
95
|
+
renderNotificationTemplate,
|
|
96
|
+
} from "@contractspec/lib.notification";
|
|
97
|
+
import type { ShellNotificationCenter } from "@contractspec/lib.design-system/shell";
|
|
98
|
+
|
|
99
|
+
type NotificationListResult = {
|
|
100
|
+
unreadCount: number;
|
|
101
|
+
notifications: Array<{
|
|
102
|
+
id: string;
|
|
103
|
+
title: string;
|
|
104
|
+
body: string;
|
|
105
|
+
type: string;
|
|
106
|
+
status: string;
|
|
107
|
+
readAt?: string | Date | null;
|
|
108
|
+
createdAt: string | Date;
|
|
109
|
+
actionUrl?: string;
|
|
110
|
+
metadata?: Record<string, unknown>;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export function toShellNotifications(
|
|
115
|
+
data: NotificationListResult,
|
|
116
|
+
actions: {
|
|
117
|
+
open: (id: string) => void;
|
|
118
|
+
markRead: (input: { notificationId: string }) => void;
|
|
119
|
+
markAllRead: () => void;
|
|
120
|
+
}
|
|
121
|
+
): ShellNotificationCenter {
|
|
122
|
+
return {
|
|
123
|
+
unreadCount: data.unreadCount,
|
|
124
|
+
items: data.notifications.map((notification) => ({
|
|
125
|
+
id: notification.id,
|
|
126
|
+
title: notification.title,
|
|
127
|
+
body: notification.body,
|
|
128
|
+
status: notification.status,
|
|
129
|
+
createdAt: notification.createdAt,
|
|
130
|
+
actionUrl: notification.actionUrl,
|
|
131
|
+
category: notification.type,
|
|
132
|
+
metadata: notification.metadata,
|
|
133
|
+
})),
|
|
134
|
+
onSelect: (item) => actions.open(item.id),
|
|
135
|
+
onMarkRead: (item) => actions.markRead({ notificationId: item.id }),
|
|
136
|
+
onMarkAllRead: actions.markAllRead,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
void ListNotificationsOutputModel;
|
|
141
|
+
void MarkNotificationReadInputModel;
|
|
142
|
+
void notificationsSchemaContribution;
|
|
143
|
+
void renderNotificationTemplate;`,p=`You are implementing a modern application shell from scratch.
|
|
70
144
|
|
|
71
145
|
Goal:
|
|
72
|
-
Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, and an in-page section navigator called PageOutline.
|
|
146
|
+
Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, in-app notifications, and an in-page section navigator called PageOutline.
|
|
73
147
|
|
|
74
148
|
Use this architecture:
|
|
75
149
|
- Keep route content independent from navigation chrome.
|
|
@@ -77,29 +151,37 @@ Use this architecture:
|
|
|
77
151
|
- Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
|
|
78
152
|
- Create a breadcrumb model for the topbar.
|
|
79
153
|
- Create a PageOutline model for right-side in-page navigation with exactly three supported levels. It should render anchors, support active section state, and degrade gracefully when no sections exist.
|
|
154
|
+
- Create a ShellNotificationCenter model with render-ready items, unread count, loading and empty states, onSelect, onMarkRead, onMarkAllRead, and optional custom item rendering.
|
|
80
155
|
- Expose the system from the design system or a dedicated shell module, not from a single app route.
|
|
81
156
|
|
|
157
|
+
Notification boundary:
|
|
158
|
+
- Use @contractspec/lib.contracts-spec/notifications as the canonical source for notification contracts, operation models, and feature metadata.
|
|
159
|
+
- Use @contractspec/lib.notification for reusable notification entities, schema contribution, channels, templates, and i18n helpers.
|
|
160
|
+
- Keep persistence, polling/subscriptions, delivery providers, and optimistic mutations in the host application or notification runtime layer.
|
|
161
|
+
- Pass only render-ready ShellNotificationCenter state into AppShell so the design system does not import or own notification runtime behavior.
|
|
162
|
+
|
|
82
163
|
Desktop behavior:
|
|
83
164
|
- Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
|
|
84
165
|
- Topbar with breadcrumbs and an optional command trigger.
|
|
166
|
+
- Topbar notification trigger with unread badge, loading/empty states, mark-read actions, and item selection.
|
|
85
167
|
- Content area with optional right PageOutline.
|
|
86
168
|
- Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
|
|
87
169
|
|
|
88
170
|
Mobile web behavior:
|
|
89
171
|
- Use bottom navigation for the primary destinations.
|
|
90
|
-
- Put deeper navigation, command search, auth actions, and secondary actions behind a menu or drawer.
|
|
172
|
+
- Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.
|
|
91
173
|
- Keep route content first and make the shell controls reachable without covering important content.
|
|
92
174
|
|
|
93
175
|
Native behavior:
|
|
94
176
|
- Add .native.tsx entrypoints for Expo/React Native.
|
|
95
|
-
- Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation and account actions.
|
|
96
|
-
- Keep the same typed navigation, command, breadcrumb, and PageOutline data contracts across web and native.
|
|
177
|
+
- Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation, notifications, and account actions.
|
|
178
|
+
- Keep the same typed navigation, command, breadcrumb, notification, and PageOutline data contracts across web and native.
|
|
97
179
|
|
|
98
180
|
Implementation constraints:
|
|
99
181
|
- Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
|
|
100
182
|
- Do not hardcode app-specific routes in the shell component.
|
|
101
183
|
- Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
|
|
102
|
-
- Include tests for navigation rendering, nested items, command filtering, breadcrumbs, PageOutline level handling, active section state, and mobile/native adaptation contracts.
|
|
184
|
+
- Include tests for navigation rendering, nested items, command filtering, breadcrumbs, notification unread badge/loading/empty/callback behavior, PageOutline level handling, active section state, and mobile/native adaptation contracts.
|
|
103
185
|
- Update docs and exports so developers can import the shell from a stable public API.
|
|
104
186
|
|
|
105
187
|
Deliverables:
|
|
@@ -107,15 +189,18 @@ Deliverables:
|
|
|
107
189
|
- Web shell components.
|
|
108
190
|
- Native shell components or adapters.
|
|
109
191
|
- PageOutline component with three-level support.
|
|
192
|
+
- ShellNotifications or equivalent notification center component for web and native shell placement.
|
|
110
193
|
- Usage example.
|
|
111
|
-
- Focused tests and typecheck/build evidence.`,
|
|
194
|
+
- Focused tests and typecheck/build evidence.`,m=`You are refactoring an existing application to use the shared application shell system.
|
|
112
195
|
|
|
113
196
|
Goal:
|
|
114
|
-
Replace app-specific sidebar, topbar, breadcrumb, command palette, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell and PageOutline system.
|
|
197
|
+
Replace app-specific sidebar, topbar, breadcrumb, command palette, notification badge/inbox, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell, ShellNotifications, and PageOutline system.
|
|
115
198
|
|
|
116
199
|
Start by auditing:
|
|
117
200
|
- Current layout wrappers and route groups.
|
|
118
201
|
- Sidebar, topbar, breadcrumb, command/search, auth menu, and mobile navigation implementations.
|
|
202
|
+
- Existing notification badges, inbox panels, toasts that represent durable in-app items, unread count queries, mark-read actions, and delivery modules.
|
|
203
|
+
- Imports from @contractspec/module.notifications that should migrate to @contractspec/lib.contracts-spec/notifications or @contractspec/lib.notification.
|
|
119
204
|
- Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
|
|
120
205
|
- Any in-page summary/table-of-contents components that should become PageOutline data.
|
|
121
206
|
- Web-only assumptions that would block Expo/React Native adaptation.
|
|
@@ -124,25 +209,28 @@ Refactor plan:
|
|
|
124
209
|
1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
|
|
125
210
|
2. Map existing command/search behavior into grouped command actions with search text and quick actions.
|
|
126
211
|
3. Map existing route metadata into breadcrumbs.
|
|
127
|
-
4.
|
|
128
|
-
5.
|
|
129
|
-
6.
|
|
130
|
-
7.
|
|
212
|
+
4. Move canonical notification contracts to @contractspec/lib.contracts-spec/notifications and reusable helpers to @contractspec/lib.notification; keep the old module shim only for compatibility imports that still need the legacy module id.
|
|
213
|
+
5. Convert notification query results into ShellNotificationCenter items with unreadCount, loading, empty state, onSelect, onMarkRead, and onMarkAllRead callbacks.
|
|
214
|
+
6. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
|
|
215
|
+
7. Wrap app routes in AppShell while keeping page content components route-local.
|
|
216
|
+
8. Move primary mobile destinations into bottom navigation and deeper/account/notification actions into a menu or drawer.
|
|
217
|
+
9. Add or preserve .native.tsx adapters when the app targets Expo.
|
|
131
218
|
|
|
132
219
|
Preserve behavior:
|
|
133
220
|
- Existing route URLs and access rules.
|
|
134
221
|
- Existing keyboard shortcuts where they are public behavior.
|
|
135
222
|
- Existing analytics or telemetry events on navigation and command actions.
|
|
223
|
+
- Existing notification delivery semantics, unread count semantics, deep links, and mark-read behavior.
|
|
136
224
|
- Existing auth/logout behavior.
|
|
137
225
|
- Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
|
|
138
226
|
|
|
139
227
|
Quality gates:
|
|
140
228
|
- Add regression tests around current visible navigation before removing old shell code when coverage is missing.
|
|
141
|
-
- Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
|
|
229
|
+
- Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, notification unread badge/loading/empty/callback behavior, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
|
|
142
230
|
- Run lint, typecheck, and the app's relevant test/build command.
|
|
143
231
|
- Remove dead app-specific shell components only after the shared shell path is verified.
|
|
144
232
|
|
|
145
233
|
Output:
|
|
146
234
|
- List old shell files removed or simplified.
|
|
147
235
|
- List new shared shell integration points.
|
|
148
|
-
- Include before/after route coverage and verification commands.`,
|
|
236
|
+
- Include before/after route coverage and verification commands.`,u=[{title:"Contracts stay canonical",body:"Use @contractspec/lib.contracts-spec/notifications for operation models, feature metadata, and contract-level compatibility."},{title:"Runtime helpers stay reusable",body:"Use @contractspec/lib.notification for schema contribution, channel adapters, templates, and i18n without importing the deprecated module shim in new code."},{title:"Apps own live state",body:"Fetch, subscribe, persist, mutate, and reconcile notification state in the host app or runtime layer where auth and tenancy are known."},{title:"Shell receives view state",body:"Pass AppShell a ShellNotificationCenter with render-ready items, counts, loading state, and callbacks; the design system only renders affordances."}],h=[{title:"Sidebar",body:"Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area."},{title:"Topbar",body:"Breadcrumbs stay visible while the current route changes. Command search and notification affordances can live here when the sidebar is collapsed or hidden."},{title:"PageOutline",body:"The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state."},{title:"Notifications",body:"The shell renders unread badges, item lists, loading/empty states, mark-read actions, and deep-link selection from host-owned notification state."},{title:"Mobile adapters",body:"Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation, notifications, and account actions."}];export{l as shellUsageExample,h as shellParts,p as scratchPrompt,m as refactorPrompt,u as notificationGuide,d as notificationCenterExample};
|