Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/console/src/schemas/objectDetailPageSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @module schemas/objectDetailPageSchema
*/

import type { PageSchema, BaseSchema } from '@object-ui/types';
import type { PageNodeSchema, BaseSchema } from '@object-ui/types';

/** Widget schema node with `objectName` property. */
interface ObjectWidgetNode extends BaseSchema {
Expand All @@ -36,7 +36,7 @@ interface ObjectWidgetNode extends BaseSchema {
export function buildObjectDetailPageSchema(
objectName: string,
item?: Record<string, unknown> | null,
): PageSchema {
): PageNodeSchema {
const label = (item?.label as string) || objectName;
const description = (item?.description as string) || objectName;

Expand Down
20 changes: 10 additions & 10 deletions packages/app-shell/src/hooks/useNavigationSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { useCallback, useEffect, useRef } from 'react';
import { toast } from 'sonner';
import type { NavigationItem, AppSchema } from '@object-ui/types';
import type { NavigationItem, AppComponentSchema } from '@object-ui/types';
import { useObjectTranslation } from '@object-ui/i18n';
import { useAdapter } from '../providers/AdapterProvider';
import { useMetadata } from '../providers/MetadataProvider';
Expand Down Expand Up @@ -210,7 +210,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {

/** Persist an updated app schema and refresh metadata. */
const saveApp = useCallback(
async (appName: string, schema: AppSchema) => {
async (appName: string, schema: AppComponentSchema) => {
const client = adapterRef.current?.getClient();
if (client) {
await client.meta.saveItem('app', appName, schema);
Expand All @@ -222,8 +222,8 @@ export function useNavigationSync(): UseNavigationSyncReturn {

/** Find the current app schema from metadata by name. */
const findApp = useCallback(
(appName: string): AppSchema | undefined =>
matchAppBySegment(apps, appName) as AppSchema | undefined,
(appName: string): AppComponentSchema | undefined =>
matchAppBySegment(apps, appName) as AppComponentSchema | undefined,
[apps],
);

Expand All @@ -245,7 +245,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {
icon: 'FileText',
};
const updated = addNavigationItem(prev, newItem);
const updatedApp: AppSchema = { ...app, navigation: updated };
const updatedApp: AppComponentSchema = { ...app, navigation: updated };

try {
await saveApp(appName, updatedApp);
Expand Down Expand Up @@ -283,7 +283,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {
icon: 'LayoutDashboard',
};
const updated = addNavigationItem(prev, newItem);
const updatedApp: AppSchema = { ...app, navigation: updated };
const updatedApp: AppComponentSchema = { ...app, navigation: updated };

try {
await saveApp(appName, updatedApp);
Expand Down Expand Up @@ -320,7 +320,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {
const updated = removeNavigationItems(prev, 'page', pageName);
if (navigationEqual(updated, prev)) return; // nothing changed

const updatedApp: AppSchema = { ...app, navigation: updated };
const updatedApp: AppComponentSchema = { ...app, navigation: updated };

try {
await saveApp(appName, updatedApp);
Expand Down Expand Up @@ -353,7 +353,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {
const updated = removeNavigationItems(prev, 'dashboard', dashboardName);
if (navigationEqual(updated, prev)) return;

const updatedApp: AppSchema = { ...app, navigation: updated };
const updatedApp: AppComponentSchema = { ...app, navigation: updated };

try {
await saveApp(appName, updatedApp);
Expand Down Expand Up @@ -390,7 +390,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {
const updated = renameNavigationItems(prev, 'page', oldName, newName);
if (navigationEqual(updated, prev)) return;

const updatedApp: AppSchema = { ...app, navigation: updated };
const updatedApp: AppComponentSchema = { ...app, navigation: updated };

try {
await saveApp(appName, updatedApp);
Expand Down Expand Up @@ -423,7 +423,7 @@ export function useNavigationSync(): UseNavigationSyncReturn {
const updated = renameNavigationItems(prev, 'dashboard', oldName, newName);
if (navigationEqual(updated, prev)) return;

const updatedApp: AppSchema = { ...app, navigation: updated };
const updatedApp: AppComponentSchema = { ...app, navigation: updated };

try {
await saveApp(appName, updatedApp);
Expand Down
28 changes: 14 additions & 14 deletions packages/components/src/renderers/layout/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import React, { useMemo } from 'react';
import type { PageSchema, PageRegion, SchemaNode } from '@object-ui/types';
import type { PageNodeSchema, PageRegion, SchemaNode } from '@object-ui/types';
import { SchemaRenderer, PageVariablesProvider, PageVariableActionBridge } from '@object-ui/react';
import { ComponentRegistry } from '@object-ui/core';
import { compile, manifestFromConfigs } from '@object-ui/sdui-parser';
Expand Down Expand Up @@ -183,7 +183,7 @@ const RegionLayout: React.FC<{
// FlatContent — legacy body/children fallback
// ---------------------------------------------------------------------------

const FlatContent: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const FlatContent: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
const content = schema.body || schema.children;
const nodes: SchemaNode[] = Array.isArray(content)
? content
Expand All @@ -207,15 +207,15 @@ const FlatContent: React.FC<{ schema: PageSchema }> = ({ schema }) => {
// ---------------------------------------------------------------------------

/** Template: full-width single column */
const FullWidthTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const FullWidthTemplate: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
if (schema.regions && schema.regions.length > 0) {
return <RegionLayout regions={schema.regions} pageType={schema.pageType} />;
}
return <FlatContent schema={schema} />;
};

/** Template: header-sidebar-main — header spanning full width, sidebar + main below */
const HeaderSidebarMainTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const HeaderSidebarMainTemplate: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
const regions = schema.regions || [];
if (regions.length === 0) return <FlatContent schema={schema} />;

Expand Down Expand Up @@ -245,7 +245,7 @@ const HeaderSidebarMainTemplate: React.FC<{ schema: PageSchema }> = ({ schema })
};

/** Template: three-column — sidebar + main + aside */
const ThreeColumnTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const ThreeColumnTemplate: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
const regions = schema.regions || [];
if (regions.length === 0) return <FlatContent schema={schema} />;

Expand Down Expand Up @@ -283,7 +283,7 @@ const ThreeColumnTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
};

/** Template: dashboard — 2x2 grid of regions */
const DashboardTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const DashboardTemplate: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
const regions = schema.regions || [];
if (regions.length === 0) return <FlatContent schema={schema} />;

Expand All @@ -305,7 +305,7 @@ const DashboardTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
};

/** Template registry — maps template names to layout components */
const TEMPLATE_REGISTRY: Record<string, React.FC<{ schema: PageSchema }>> = {
const TEMPLATE_REGISTRY: Record<string, React.FC<{ schema: PageNodeSchema }>> = {
'default': FullWidthTemplate,
'full-width': FullWidthTemplate,
'header-sidebar-main': HeaderSidebarMainTemplate,
Expand All @@ -314,7 +314,7 @@ const TEMPLATE_REGISTRY: Record<string, React.FC<{ schema: PageSchema }>> = {
};

/** Resolve template: if the schema specifies a template name, use the matching layout */
function resolveTemplate(schema: PageSchema): React.FC<{ schema: PageSchema }> | null {
function resolveTemplate(schema: PageNodeSchema): React.FC<{ schema: PageNodeSchema }> | null {
if (!schema.template) return null;
return TEMPLATE_REGISTRY[schema.template] || null;
}
Expand All @@ -324,31 +324,31 @@ function resolveTemplate(schema: PageSchema): React.FC<{ schema: PageSchema }> |
// ---------------------------------------------------------------------------

/** Record page — detail-oriented, narrower max-width */
const RecordPageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const RecordPageLayout: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
if (schema.regions && schema.regions.length > 0) {
return <RegionLayout regions={schema.regions} pageType="record" />;
}
return <FlatContent schema={schema} />;
};

/** Home page — dashboard-style, wider layout */
const HomePageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const HomePageLayout: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
if (schema.regions && schema.regions.length > 0) {
return <RegionLayout regions={schema.regions} pageType="home" />;
}
return <FlatContent schema={schema} />;
};

/** App page — application shell, full-width capable */
const AppPageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const AppPageLayout: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
if (schema.regions && schema.regions.length > 0) {
return <RegionLayout regions={schema.regions} pageType="app" />;
}
return <FlatContent schema={schema} />;
};

/** Utility page — compact, focused, narrower */
const UtilityPageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
const UtilityPageLayout: React.FC<{ schema: PageNodeSchema }> = ({ schema }) => {
if (schema.regions && schema.regions.length > 0) {
return <RegionLayout regions={schema.regions} pageType="utility" />;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ function getJsxManifest() {
// ---------------------------------------------------------------------------

export const PageRenderer: React.FC<{
schema: PageSchema;
schema: PageNodeSchema;
className?: string;
[key: string]: any;
}> = ({ schema, className, ...props }) => {
Expand Down Expand Up @@ -528,7 +528,7 @@ export const PageRenderer: React.FC<{
<div className={cn(fullBleed ? 'space-y-6' : 'mx-auto space-y-6', maxWidthClass)}>
{/* Page header — suppressed on record pages (the page:header component
in the header region renders the record-bound title instead).
`title` is the objectui spelling; the spec's PageSchema declares
`title` is the objectui spelling; the spec's PageNodeSchema declares
`label` (required), so dual-read it — mirrors the fallback
DashboardRenderer already uses (framework#1878 §3 recheck). */}
{pageType !== 'record' && (pageTitle || schema.description) && (
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/dashboard-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* are unit-testable in isolation from React and the data layer.
*/

import type { DashboardSchema, DashboardWidgetSchema, PageVariable } from '@object-ui/types';
import type { DashboardComponentSchema, DashboardWidgetSchema, PageVariable } from '@object-ui/types';

/** Reserved filter name for the dashboard's built-in date range. */
export const DATE_RANGE_FILTER_NAME = 'dateRange';
Expand Down Expand Up @@ -125,7 +125,7 @@ function normalizeFilterOptions(
* named by its `name` (defaulting to `field`). Later duplicates win.
*/
export function resolveDashboardFilterDefs(
schema: Pick<DashboardSchema, 'globalFilters' | 'dateRange'>,
schema: Pick<DashboardComponentSchema, 'globalFilters' | 'dateRange'>,
): DashboardFilterDef[] {
const byName = new Map<string, DashboardFilterDef>();

Expand Down
6 changes: 3 additions & 3 deletions packages/layout/src/AppSchemaRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
SidebarInput,
useSidebar,
} from '@object-ui/components';
import type { AppSchema, NavigationItem, NavigationArea } from '@object-ui/types';
import type { AppComponentSchema, NavigationItem, NavigationArea } from '@object-ui/types';
import { menuItemToNavigationItem } from '@object-ui/types';
import { AppShell, type AppShellBranding } from './AppShell';
import {
Expand All @@ -57,7 +57,7 @@ export type MobileNavMode = 'drawer' | 'bottom_nav' | 'hamburger';

export interface AppSchemaRendererProps {
/** The AppSchema JSON to render */
schema: AppSchema;
schema: AppComponentSchema;

/** Base URL prefix for generated hrefs (e.g. "/apps/crm") */
basePath?: string;
Expand Down Expand Up @@ -279,7 +279,7 @@ function InternalSidebar({
enableReorder,
onReorder,
}: {
schema: AppSchema;
schema: AppComponentSchema;
basePath: string;
evalVis: VisibilityEvaluator;
checkPerm: PermissionChecker;
Expand Down
4 changes: 2 additions & 2 deletions packages/layout/src/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// packages/layout/src/Page.tsx
import React from 'react';
import { SchemaRenderer } from '@object-ui/react';
import { PageSchema, SchemaNode } from '@object-ui/types';
import { PageNodeSchema, SchemaNode } from '@object-ui/types';
import { PageHeader } from './PageHeader';
import { cn } from '@object-ui/components';

Expand All @@ -12,7 +12,7 @@ const getChildren = (children?: SchemaNode[] | SchemaNode): SchemaNode[] => {
return [children];
};

export function Page({ schema, className, style, id, ...props }: { schema: PageSchema; className?: string; style?: React.CSSProperties; id?: string } & any) {
export function Page({ schema, className, style, id, ...props }: { schema: PageNodeSchema; className?: string; style?: React.CSSProperties; id?: string } & any) {
const children = getChildren(schema.children);

return (
Expand Down
22 changes: 11 additions & 11 deletions packages/layout/src/__tests__/AppSchemaRenderer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { describe, it, expect, vi } from 'vitest';
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import type { AppSchema, NavigationItem, NavigationArea } from '@object-ui/types';
import type { AppComponentSchema, NavigationItem, NavigationArea } from '@object-ui/types';
import { AppSchemaRenderer } from '../AppSchemaRenderer';

/** Wrap component in MemoryRouter */
function renderApp(
schema: AppSchema,
schema: AppComponentSchema,
props: Partial<React.ComponentProps<typeof AppSchemaRenderer>> = {},
initialEntries: string[] = ['/'],
) {
Expand All @@ -32,7 +32,7 @@ function renderApp(
// Fixtures
// ---------------------------------------------------------------------------

const minimalSchema: AppSchema = {
const minimalSchema: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'Sales CRM',
Expand All @@ -44,7 +44,7 @@ const navItems: NavigationItem[] = [
{ id: 'n3', type: 'page', label: 'Settings', icon: 'Settings', pageName: 'settings' },
];

const schemaWithNav: AppSchema = {
const schemaWithNav: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'Sales CRM',
Expand All @@ -70,7 +70,7 @@ const serviceArea: NavigationArea = {
],
};

const schemaWithAreas: AppSchema = {
const schemaWithAreas: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'Sales CRM',
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('AppSchemaRenderer', () => {
// #2918 — `type: 'component'` is part of the nav vocabulary; the sidebar
// renders it as a link to the ComponentRegistry route.
it('renders a component navigation item with its /component href', () => {
const schema: AppSchema = {
const schema: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'Sales CRM',
Expand All @@ -145,7 +145,7 @@ describe('AppSchemaRenderer', () => {
// --- Legacy menu migration ---

it('renders legacy menu items converted to NavigationItem', () => {
const legacySchema: AppSchema = {
const legacySchema: AppComponentSchema = {
type: 'app',
name: 'legacy',
title: 'Legacy App',
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('AppSchemaRenderer', () => {
// --- Area visibility and permissions ---

it('hides areas that fail visibility check', () => {
const schemaWithHiddenArea: AppSchema = {
const schemaWithHiddenArea: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'CRM',
Expand All @@ -207,7 +207,7 @@ describe('AppSchemaRenderer', () => {
});

it('hides areas that fail permission check', () => {
const schemaWithPermArea: AppSchema = {
const schemaWithPermArea: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'CRM',
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('AppSchemaRenderer', () => {
// --- Permission & visibility on nav items ---

it('hides navigation items based on visibility', () => {
const schema: AppSchema = {
const schema: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'CRM',
Expand All @@ -274,7 +274,7 @@ describe('AppSchemaRenderer', () => {
});

it('hides navigation items based on permissions', () => {
const schema: AppSchema = {
const schema: AppComponentSchema = {
type: 'app',
name: 'crm',
title: 'CRM',
Expand Down
Loading
Loading