@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.
Files changed (70) hide show
  1. package/.turbo/turbo-build.log +222 -214
  2. package/CHANGELOG.md +52 -0
  3. package/dist/components/docs/DocsIndexPage.js +2 -2
  4. package/dist/components/docs/docsManifest.js +1 -1
  5. package/dist/components/docs/getting-started/DataViewTutorialPage.js +81 -6
  6. package/dist/components/docs/getting-started/index.js +94 -19
  7. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.d.ts +6 -0
  8. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +176 -0
  9. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.d.ts +1 -0
  10. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +176 -0
  11. package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
  12. package/dist/components/docs/guides/index.d.ts +1 -0
  13. package/dist/components/docs/guides/index.js +220 -46
  14. package/dist/components/docs/index.js +1003 -309
  15. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +22 -5
  16. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
  17. package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
  18. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
  19. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
  20. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  21. package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  22. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.d.ts +10 -0
  23. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +43 -0
  24. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.d.ts +1 -0
  25. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.js +43 -0
  26. package/dist/components/docs/libraries/index.d.ts +1 -0
  27. package/dist/components/docs/libraries/index.js +496 -97
  28. package/dist/components/docs/specs/SpecsDataViewsPage.js +49 -3
  29. package/dist/components/docs/specs/index.js +60 -14
  30. package/dist/index.js +1014 -320
  31. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  32. package/dist/node/components/docs/docsManifest.js +1 -1
  33. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +81 -6
  34. package/dist/node/components/docs/getting-started/index.js +94 -19
  35. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +175 -0
  36. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +175 -0
  37. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  38. package/dist/node/components/docs/guides/index.js +220 -46
  39. package/dist/node/components/docs/index.js +1003 -309
  40. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
  41. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
  42. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
  43. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
  44. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  45. package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  46. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +42 -0
  47. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.js +42 -0
  48. package/dist/node/components/docs/libraries/index.js +496 -97
  49. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +49 -3
  50. package/dist/node/components/docs/specs/index.js +60 -14
  51. package/dist/node/index.js +1014 -320
  52. package/package.json +74 -26
  53. package/src/components/docs/docsManifest.test.ts +87 -0
  54. package/src/components/docs/docsManifest.ts +90 -3
  55. package/src/components/docs/generated/docs-index.notifications.json +7 -7
  56. package/src/components/docs/getting-started/DataViewTutorialPage.tsx +181 -50
  57. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.ts +185 -0
  58. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.tsx +186 -0
  59. package/src/components/docs/guides/GuidesIndexPage.tsx +49 -42
  60. package/src/components/docs/guides/index.ts +1 -0
  61. package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +148 -35
  62. package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +38 -5
  63. package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +267 -64
  64. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +235 -0
  65. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +8 -2
  66. package/src/components/docs/libraries/LibrariesPersonalizationPage.tsx +141 -31
  67. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.content.ts +78 -0
  68. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.tsx +137 -0
  69. package/src/components/docs/libraries/index.ts +1 -0
  70. package/src/components/docs/specs/SpecsDataViewsPage.tsx +239 -113
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var K=Object.defineProperty;var N=(F)=>F;function O(F,G){this[F]=N.bind(null,G)}var Y=(F,G)=>{for(var J in G)K(F,J,{get:G[J],enumerable:!0,configurable:!0,set:O.bind(G,J)})};var Z=(F,G)=>()=>(F&&(G=F(F=0)),G);import H from"@contractspec/lib.ui-link";import{ChevronRight as Q}from"lucide-react";import{jsx as z,jsxs as B}from"react/jsx-runtime";var U=`import { defineDataView } from '@contractspec/lib.contracts-spec/data-views';
2
+ var v=Object.defineProperty;var D=(K)=>K;function M(K,N){this[K]=D.bind(null,N)}var B=(K,N)=>{for(var Y in N)v(K,Y,{get:N[Y],enumerable:!0,configurable:!0,set:M.bind(N,Y)})};var _=(K,N)=>()=>(K&&(N=K(K=0)),N);import{CodeBlock as Z}from"@contractspec/lib.design-system";import{HStack as R,VStack as z}from"@contractspec/lib.design-system/layout";import{List as $,ListItem as J}from"@contractspec/lib.design-system/list";import{Code as F,H1 as W,H2 as O,H3 as Q,P as G,Text as w}from"@contractspec/lib.design-system/typography";import U from"@contractspec/lib.ui-link";import{ChevronRight as X}from"lucide-react";import{jsx as f,jsxs as q}from"react/jsx-runtime";var b=`import { defineDataView } from '@contractspec/lib.contracts-spec/data-views';
3
3
  import { ListDataGridShowcaseRowsQuery } from '@contractspec/example.data-grid-showcase/contracts/data-grid-showcase.operation';
4
4
 
5
5
  export const DataGridShowcaseDataView = defineDataView({
@@ -62,8 +62,41 @@ export const DataGridShowcaseDataView = defineDataView({
62
62
  dataPath: 'lastActivityAt',
63
63
  format: { type: 'datetime', dateStyle: 'medium', timeStyle: 'short' },
64
64
  },
65
- { key: 'notes', label: 'Notes', dataPath: 'notes' },
65
+ {
66
+ key: 'notes',
67
+ label: 'Notes',
68
+ dataPath: 'notes',
69
+ visibility: { minDataDepth: 'detailed' },
70
+ },
66
71
  ],
72
+ collection: {
73
+ viewModes: {
74
+ defaultMode: 'table',
75
+ allowedModes: ['list', 'grid', 'table'],
76
+ },
77
+ pagination: {
78
+ pageSize: 25,
79
+ pageSizeOptions: [10, 25, 50],
80
+ },
81
+ toolbar: {
82
+ search: true,
83
+ viewMode: true,
84
+ filters: true,
85
+ density: true,
86
+ dataDepth: true,
87
+ },
88
+ density: 'comfortable',
89
+ dataDepth: 'standard',
90
+ personalization: {
91
+ enabled: true,
92
+ persist: {
93
+ viewMode: true,
94
+ density: true,
95
+ dataDepth: true,
96
+ pageSize: true,
97
+ },
98
+ },
99
+ },
67
100
  filters: [
68
101
  { key: 'status', label: 'Status', field: 'status', type: 'enum' },
69
102
  {
@@ -82,4 +115,17 @@ export const DataGridShowcaseDataView = defineDataView({
82
115
  },
83
116
  ],
84
117
  },
85
- });`;function q(){return B("div",{className:"space-y-8",children:[B("div",{className:"space-y-4",children:[z("h1",{className:"font-bold text-4xl",children:"DataViews"}),B("p",{className:"text-muted-foreground",children:["A ",z("strong",{children:"DataViewSpec"})," describes how data should be queried, filtered, sorted, and presented to users. Runtime adapters execute optimized database queries and serve list views, detail views, and search interfaces while respecting policy constraints."]})]}),B("div",{className:"space-y-4",children:[z("h2",{className:"font-bold text-2xl",children:"Core concepts"}),B("div",{className:"space-y-3",children:[B("div",{children:[z("h3",{className:"font-semibold text-lg",children:"Data sources"}),z("p",{className:"text-muted-foreground",children:"A DataView connects to one or more data sources\u2014databases, APIs, or other capabilities. You specify the source and the fields you want to expose."})]}),B("div",{children:[z("h3",{className:"font-semibold text-lg",children:"Filtering"}),z("p",{className:"text-muted-foreground",children:"Define filters that users can apply to narrow down results. Filters are typed as search, enum, number, percent, currency, date, time, datetime, duration, or boolean so renderers and query helpers can validate values before execution."})]}),B("div",{children:[z("h3",{className:"font-semibold text-lg",children:"Sorting"}),z("p",{className:"text-muted-foreground",children:"Specify which fields can be sorted and the default sort order. ContractSpec generates efficient database queries with proper indexes."})]}),B("div",{children:[z("h3",{className:"font-semibold text-lg",children:"Pagination"}),z("p",{className:"text-muted-foreground",children:"DataViews automatically support pagination to handle large datasets. You can configure page size limits and cursor-based or offset-based pagination."})]}),B("div",{children:[z("h3",{className:"font-semibold text-lg",children:"Aggregations"}),z("p",{className:"text-muted-foreground",children:"Compute aggregates like counts, sums, averages, and group-by operations. These are useful for dashboards and summary views."})]})]})]}),B("div",{className:"space-y-4",children:[z("h2",{className:"font-bold text-2xl",children:"Example DataViewSpec"}),B("p",{className:"text-muted-foreground",children:["Here is the canonical table contract used by the live"," ",z(H,{href:"/docs/examples/data-grid-showcase",className:"text-[color:var(--rust)] underline underline-offset-4",children:"Data Grid Showcase"}),":"]}),z("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:z("pre",{children:U})}),z("p",{className:"text-muted-foreground text-sm",children:"This one contract drives the DataView lane, while the same rows and controller also feed the raw web primitive, native-first primitive, and composed design-system demos."})]}),B("div",{className:"space-y-4",children:[z("h2",{className:"font-bold text-2xl",children:"Policy integration"}),B("p",{className:"text-muted-foreground",children:["DataViews automatically enforce"," ",z(H,{href:"/docs/specs/policy",className:"text-violet-400 hover:text-violet-300",children:"PolicySpecs"}),". If a user doesn't have permission to see certain fields, those fields are automatically filtered out or redacted. If a user can only see their own data, the query is automatically scoped."]}),z("p",{className:"text-muted-foreground",children:"This means you define the data view once, and it works correctly for all users based on their permissions\u2014no need to write separate queries for different roles."})]}),B("div",{className:"space-y-4",children:[z("h2",{className:"font-bold text-2xl",children:"Served outputs"}),z("p",{className:"text-muted-foreground",children:"From a DataViewSpec, ContractSpec serves:"}),B("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[B("li",{children:[z("strong",{children:"Database queries"})," \u2013 Optimized SQL or NoSQL queries executed at runtime"]}),B("li",{children:[z("strong",{children:"API endpoints"})," \u2013 RESTful or GraphQL endpoints for fetching data"]}),B("li",{children:[z("strong",{children:"UI components"})," \u2013 List views, tables, cards, and detail views"]}),B("li",{children:[z("strong",{children:"Search interfaces"})," \u2013 Full-text search with autocomplete"]}),B("li",{children:[z("strong",{children:"Export functions"})," \u2013 CSV, JSON, or Excel exports"]})]})]}),B("div",{className:"space-y-4",children:[z("h2",{className:"font-bold text-2xl",children:"Best practices"}),B("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[z("li",{children:"Only expose fields that users actually need\u2014this improves performance and security."}),z("li",{children:"Use appropriate indexes for sortable and filterable fields."}),z("li",{children:"Set reasonable pagination limits to prevent performance issues."}),z("li",{children:"Use aggregations sparingly\u2014they can be expensive on large datasets."}),z("li",{children:"Test DataViews with realistic data volumes to ensure they perform well."})]})]}),B("div",{className:"flex items-center gap-4 pt-4",children:[z(H,{href:"/docs/specs/capabilities",className:"btn-ghost",children:"Previous: Capabilities"}),B(H,{href:"/docs/specs/workflows",className:"btn-primary",children:["Next: Workflows ",z(Q,{size:16})]})]})]})}export{q as SpecsDataViewsPage};
118
+ });`;function l(){return q(z,{className:"space-y-8",children:[q(z,{className:"space-y-4",children:[f(W,{className:"font-bold text-4xl",children:"DataViews"}),q(G,{className:"text-muted-foreground",children:["A ",f(w,{className:"font-semibold",children:"DataViewSpec"})," describes how data should be queried, filtered, sorted, and presented to users. Runtime adapters execute optimized database queries and serve list views, detail views, and search interfaces while respecting policy constraints."]})]}),q(z,{className:"space-y-4",children:[f(O,{className:"font-bold text-2xl",children:"Core concepts"}),q(z,{className:"space-y-3",children:[q(z,{children:[f(Q,{className:"font-semibold text-lg",children:"Data sources"}),f(G,{className:"text-muted-foreground",children:"A DataView connects to one or more data sources\u2014databases, APIs, or other capabilities. You specify the source and the fields you want to expose."})]}),q(z,{children:[f(Q,{className:"font-semibold text-lg",children:"Filtering"}),f(G,{className:"text-muted-foreground",children:"Define filters that users can apply to narrow down results. Filters are typed as search, enum, number, percent, currency, date, time, datetime, duration, or boolean so renderers and query helpers can validate values before execution."})]}),q(z,{children:[f(Q,{className:"font-semibold text-lg",children:"Sorting"}),f(G,{className:"text-muted-foreground",children:"Specify which fields can be sorted and the default sort order. ContractSpec generates efficient database queries with proper indexes."})]}),q(z,{children:[f(Q,{className:"font-semibold text-lg",children:"Pagination"}),f(G,{className:"text-muted-foreground",children:"DataViews automatically support pagination to handle large datasets. You can configure page size limits and cursor-based or offset-based pagination."})]}),q(z,{children:[f(Q,{className:"font-semibold text-lg",children:"Collection modes and data depth"}),q(G,{className:"text-muted-foreground",children:["List, grid, and table views can share a single"," ",f(F,{children:"view.collection"})," contract. It declares allowed view modes, toolbar controls, page-size defaults, density, data depth, and persistence hints. Fields can use"," ",f(F,{children:"visibility.minDataDepth"})," so summary views stay light while detailed views expose richer context."]})]}),q(z,{children:[f(Q,{className:"font-semibold text-lg",children:"Personalization hints"}),q(G,{className:"text-muted-foreground",children:["The contract layer stays neutral: it can opt into persistence with"," ",f(F,{children:"view.collection.personalization"}),", but it does not import the personalization runtime. Host apps resolve preferences and behavior insights into renderer props."]})]})]})]}),q(z,{className:"space-y-4",children:[f(O,{className:"font-bold text-2xl",children:"Example DataViewSpec"}),q(G,{className:"text-muted-foreground",children:["Here is the canonical table contract used by the live"," ",f(U,{href:"/docs/examples/data-grid-showcase",className:"text-[color:var(--rust)] underline underline-offset-4",children:f(w,{children:"Data Grid Showcase"})}),":"]}),f(Z,{language:"typescript",code:b}),f(G,{className:"text-muted-foreground text-sm",children:"This one contract drives the DataView lane, while the same rows and controller also feed the raw web primitive, native-first primitive, and composed design-system demos."})]}),q(z,{className:"space-y-4",children:[f(O,{className:"font-bold text-2xl",children:"Policy integration"}),q(G,{className:"text-muted-foreground",children:["DataViews automatically enforce"," ",f(U,{href:"/docs/specs/policy",className:"text-violet-400 hover:text-violet-300",children:f(w,{children:"PolicySpecs"})}),". If a user doesn't have permission to see certain fields, those fields are automatically filtered out or redacted. If a user can only see their own data, the query is automatically scoped."]}),f(G,{className:"text-muted-foreground",children:"This means you define the data view once, and it works correctly for all users based on their permissions\u2014no need to write separate queries for different roles."})]}),q(z,{className:"space-y-4",children:[f(O,{className:"font-bold text-2xl",children:"Personalized Rendering Pattern"}),q(G,{className:"text-muted-foreground",children:["To personalize a DataView, keep the spec declarative and resolve user-specific defaults at the app boundary. Use"," ",f(F,{children:"resolveDataViewPreferences"})," from"," ",f(F,{children:"@contractspec/lib.personalization/data-view-preferences"}),"to compute ",f(F,{children:"viewMode"}),", ",f(F,{children:"density"}),","," ",f(F,{children:"dataDepth"}),", and ",f(F,{children:"pageSize"}),". Pass those values to ",f(F,{children:"DataViewRenderer"})," as controlled or default props, then record UI changes with ",f(F,{children:"trackDataViewInteraction"}),"."]}),f(Z,{language:"tsx",code:`const resolved = resolveDataViewPreferences({
119
+ spec: DataGridShowcaseDataView,
120
+ preferences: profile.canonical,
121
+ insights,
122
+ record: savedPreference,
123
+ });
124
+
125
+ <DataViewRenderer
126
+ spec={DataGridShowcaseDataView}
127
+ items={rows}
128
+ defaultViewMode={resolved.viewMode}
129
+ defaultDensity={resolved.density}
130
+ defaultDataDepth={resolved.dataDepth}
131
+ />;`})]}),q(z,{className:"space-y-4",children:[f(O,{className:"font-bold text-2xl",children:"Served outputs"}),f(G,{className:"text-muted-foreground",children:"From a DataViewSpec, ContractSpec serves:"}),q($,{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[f(J,{children:q(w,{children:[f(w,{className:"font-semibold",children:"Database queries"})," \u2013 Optimized SQL or NoSQL queries executed at runtime"]})}),f(J,{children:q(w,{children:[f(w,{className:"font-semibold",children:"API endpoints"})," \u2013 RESTful or GraphQL endpoints for fetching data"]})}),f(J,{children:q(w,{children:[f(w,{className:"font-semibold",children:"UI components"})," \u2013 List views, tables, cards, and detail views"]})}),f(J,{children:q(w,{children:[f(w,{className:"font-semibold",children:"Personalized defaults"})," \u2013 Plain renderer props for preferred mode, density, data depth, and page size"]})}),f(J,{children:q(w,{children:[f(w,{className:"font-semibold",children:"Search interfaces"})," \u2013 Full-text search with autocomplete"]})}),f(J,{children:q(w,{children:[f(w,{className:"font-semibold",children:"Export functions"})," \u2013 CSV, JSON, or Excel exports"]})})]})]}),q(z,{className:"space-y-4",children:[f(O,{className:"font-bold text-2xl",children:"Best practices"}),q($,{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[f(J,{children:f(w,{children:"Only expose fields that users actually need\u2014this improves performance and security."})}),f(J,{children:f(w,{children:"Use appropriate indexes for sortable and filterable fields."})}),f(J,{children:f(w,{children:"Set reasonable pagination limits to prevent performance issues."})}),f(J,{children:q(w,{children:["Use ",f(F,{children:"allowedModes"})," to constrain mode switching to layouts that the fields and row actions can support."]})}),f(J,{children:q(w,{children:["Store preferences only for dimensions enabled by"," ",f(F,{children:"view.collection.personalization.persist"}),"."]})}),f(J,{children:f(w,{children:"Test DataViews with realistic data volumes to ensure they perform well."})})]})]}),q(R,{className:"items-center gap-4 pt-4",children:[f(U,{href:"/docs/specs/capabilities",className:"btn-ghost",children:f(w,{children:"Previous: Capabilities"})}),q(U,{href:"/docs/specs/workflows",className:"btn-primary",children:[f(w,{children:"Next: Workflows"})," ",f(X,{size:16})]})]})]})}export{l as SpecsDataViewsPage};