Skip to content

Commit 9348936

Browse files
authored
Merge pull request #507 from objectstack-ai/copilot/update-objectstack-to-latest-again
2 parents 831f326 + 7169d99 commit 9348936

32 files changed

Lines changed: 715 additions & 240 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
- **@objectstack v3.0.4 Upgrade**: Upgraded all `@objectstack/*` packages from `^3.0.2` to `^3.0.4` across 42 references
1213
- **@objectstack v3.0.0 Upgrade**: Upgraded all `@objectstack/*` packages from `^2.0.7` to `^3.0.0` across 13 package.json files
1314
- **Breaking change migrations**:
1415
- `Hub` namespace → `Cloud` in @object-ui/types re-exports
@@ -22,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2223

2324
### Added
2425

26+
- **Preview Mode** (`@object-ui/auth`): New `previewMode` prop on `AuthProvider` for auto-login with simulated identity — skip login/registration for marketplace demos and app showcases. Includes `PreviewBanner` component, `isPreviewMode` / `previewMode` on `useAuth()`, and `PreviewModeOptions` type. Aligns with `@objectstack/spec` kernel `PreviewModeConfig`.
27+
- **Discovery Preview Detection** (`@object-ui/react`): Extended `DiscoveryInfo` with `mode` and `previewMode` fields for server-driven preview mode detection.
28+
- **Console Preview Support**: `ConditionalAuthWrapper` auto-detects `mode === 'preview'` from server discovery and configures auth accordingly.
2529
- **Console Bundle Optimization**: Split monolithic 3.7 MB main chunk into 17 granular cacheable chunks via `manualChunks` — main entry reduced from 1,008 KB gzip to 48.5 KB gzip (95% reduction)
2630
- **Gzip + Brotli Compression**: Pre-compressed assets via `vite-plugin-compression2` — Brotli main entry at 40 KB
2731
- **Bundle Analysis**: Added `rollup-plugin-visualizer` generating interactive treemap at `dist/stats.html`; new `build:analyze` script

apps/console/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@
5858
"@object-ui/plugin-view": "workspace:*",
5959
"@object-ui/react": "workspace:*",
6060
"@object-ui/types": "workspace:*",
61-
"@objectstack/cli": "^3.0.2",
62-
"@objectstack/client": "^3.0.2",
63-
"@objectstack/driver-memory": "^3.0.2",
64-
"@objectstack/objectql": "^3.0.2",
65-
"@objectstack/plugin-msw": "^3.0.2",
66-
"@objectstack/runtime": "^3.0.2",
67-
"@objectstack/spec": "^3.0.2",
61+
"@objectstack/cli": "^3.0.4",
62+
"@objectstack/client": "^3.0.4",
63+
"@objectstack/driver-memory": "^3.0.4",
64+
"@objectstack/objectql": "^3.0.4",
65+
"@objectstack/plugin-msw": "^3.0.4",
66+
"@objectstack/runtime": "^3.0.4",
67+
"@objectstack/spec": "^3.0.4",
6868
"@tailwindcss/postcss": "^4.1.18",
6969
"@testing-library/jest-dom": "^6.9.1",
7070
"@testing-library/react": "^16.3.2",

apps/console/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SchemaRendererProvider } from '@object-ui/react';
77
import { ObjectStackAdapter } from './dataSource';
88
import type { ConnectionState } from './dataSource';
99
import appConfig from '../objectstack.shared';
10-
import { AuthGuard, useAuth } from '@object-ui/auth';
10+
import { AuthGuard, useAuth, PreviewBanner } from '@object-ui/auth';
1111

1212
// Components (eagerly loaded — always needed)
1313
import { ConsoleLayout } from './components/ConsoleLayout';
@@ -387,6 +387,7 @@ export function App() {
387387
<ThemeProvider defaultTheme="system" storageKey="object-ui-theme">
388388
<ConsoleToaster position="bottom-right" />
389389
<ConditionalAuthWrapper authUrl="/api/auth">
390+
<PreviewBanner />
390391
<BrowserRouter basename={import.meta.env.BASE_URL?.replace(/\/$/, '') || '/'}>
391392
<Suspense fallback={<LoadingScreen />}>
392393
<Routes>

apps/console/src/components/ConditionalAuthWrapper.tsx

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
*
44
* This component fetches discovery information from the server and conditionally
55
* enables/disables authentication based on the server's auth service status.
6+
* Also detects preview mode from the server and configures the auth provider accordingly.
67
*/
78

89
import { useState, useEffect, ReactNode } from 'react';
910
import { ObjectStackAdapter } from '../dataSource';
1011
import { AuthProvider } from '@object-ui/auth';
12+
import type { PreviewModeOptions } from '@object-ui/auth';
1113
import { LoadingScreen } from './LoadingScreen';
1214
import type { DiscoveryInfo } from '@object-ui/react';
1315

@@ -23,11 +25,12 @@ interface ConditionalAuthWrapperProps {
2325
* 1. Creates a temporary data source connection
2426
* 2. Fetches discovery information from the server
2527
* 3. Checks if auth.enabled is true in the discovery response
26-
* 4. Conditionally wraps children with AuthProvider if auth is enabled
27-
* 5. Bypasses auth if discovery indicates auth is disabled (development/demo mode)
28+
* 4. Detects preview mode from discovery (mode === 'preview')
29+
* 5. Conditionally wraps children with AuthProvider with the appropriate config
2830
*/
2931
export function ConditionalAuthWrapper({ children, authUrl }: ConditionalAuthWrapperProps) {
3032
const [authEnabled, setAuthEnabled] = useState<boolean | null>(null);
33+
const [previewMode, setPreviewMode] = useState<PreviewModeOptions | undefined>(undefined);
3134
const [isLoading, setIsLoading] = useState(true);
3235

3336
useEffect(() => {
@@ -47,10 +50,24 @@ export function ConditionalAuthWrapper({ children, authUrl }: ConditionalAuthWra
4750
const discovery = await adapter.getDiscovery() as DiscoveryInfo | null;
4851

4952
if (!cancelled) {
50-
// Check if auth is enabled in discovery
51-
// Default to true if discovery doesn't provide this information
52-
const isAuthEnabled = discovery?.services?.auth?.enabled ?? true;
53-
setAuthEnabled(isAuthEnabled);
53+
// Detect preview mode from discovery
54+
if (discovery?.mode === 'preview') {
55+
setPreviewMode({
56+
autoLogin: discovery.previewMode?.autoLogin ?? true,
57+
simulatedRole: discovery.previewMode?.simulatedRole ?? 'admin',
58+
simulatedUserName: discovery.previewMode?.simulatedUserName ?? 'Preview User',
59+
readOnly: discovery.previewMode?.readOnly ?? false,
60+
expiresInSeconds: discovery.previewMode?.expiresInSeconds ?? 0,
61+
bannerMessage: discovery.previewMode?.bannerMessage,
62+
});
63+
// In preview mode, auth is effectively bypassed
64+
setAuthEnabled(false);
65+
} else {
66+
// Check if auth is enabled in discovery
67+
// Default to true if discovery doesn't provide this information
68+
const isAuthEnabled = discovery?.services?.auth?.enabled ?? true;
69+
setAuthEnabled(isAuthEnabled);
70+
}
5471
}
5572
} catch (error) {
5673
if (!cancelled) {
@@ -76,6 +93,15 @@ export function ConditionalAuthWrapper({ children, authUrl }: ConditionalAuthWra
7693
return <LoadingScreen />;
7794
}
7895

96+
// If in preview mode, wrap with a preview-configured AuthProvider
97+
if (previewMode) {
98+
return (
99+
<AuthProvider authUrl={authUrl} previewMode={previewMode}>
100+
{children}
101+
</AuthProvider>
102+
);
103+
}
104+
79105
// If auth is enabled, wrap with AuthProvider
80106
if (authEnabled) {
81107
return (

examples/crm/console-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
* import { ConsolePlugin } from './console-plugin';
1010
* kernel.use(ConsolePlugin);
1111
*/
12-
export { ConsolePlugin } from '@object-ui/console';
12+
export { ConsolePlugin } from '../../apps/console/plugin';

examples/crm/objectstack.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { OrderObject } from './src/objects/order.object';
88
import { UserObject } from './src/objects/user.object';
99
import { ProjectObject } from './src/objects/project.object';
1010
import { EventObject } from './src/objects/event.object';
11-
import { ConsolePlugin } from '@object-ui/console';
11+
import { ConsolePlugin } from '../../apps/console/plugin';
1212

1313
export default defineStack({
1414
objects: [

examples/crm/package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@
1919
},
2020
"dependencies": {
2121
"@hono/node-server": "^1.19.9",
22-
"@object-ui/console": "workspace:*",
23-
"@objectstack/core": "^3.0.2",
24-
"@objectstack/driver-memory": "^3.0.2",
25-
"@objectstack/objectql": "^3.0.2",
26-
"@objectstack/plugin-auth": "^3.0.2",
27-
"@objectstack/plugin-hono-server": "^3.0.2",
28-
"@objectstack/runtime": "^3.0.2",
29-
"@objectstack/spec": "^3.0.2",
22+
"@objectstack/core": "^3.0.4",
23+
"@objectstack/driver-memory": "^3.0.4",
24+
"@objectstack/objectql": "^3.0.4",
25+
"@objectstack/plugin-auth": "^3.0.4",
26+
"@objectstack/plugin-hono-server": "^3.0.4",
27+
"@objectstack/runtime": "^3.0.4",
28+
"@objectstack/spec": "^3.0.4",
3029
"hono": "^4.11.9",
3130
"pino": "^8.21.0",
3231
"pino-pretty": "^13.1.3"
3332
},
3433
"devDependencies": {
35-
"@objectstack/cli": "^3.0.2",
34+
"@objectstack/cli": "^3.0.4",
3635
"tsx": "^4.21.0",
3736
"typescript": "^5.9.3"
3837
}

examples/crm/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { InMemoryDriver } from '@objectstack/driver-memory';
77
import { AuthPlugin } from '@objectstack/plugin-auth';
88
import config from './objectstack.config';
99
import { pino } from 'pino';
10-
import { ConsolePlugin } from '@object-ui/console';
10+
import { ConsolePlugin } from '../../apps/console/plugin';
1111

1212
async function startServer() {
1313
const logger = pino({

examples/kitchen-sink/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"build": "objectstack compile objectstack.config.ts"
1515
},
1616
"dependencies": {
17-
"@objectstack/spec": "^3.0.2"
17+
"@objectstack/spec": "^3.0.4"
1818
},
1919
"devDependencies": {
20-
"@objectstack/cli": "^3.0.2",
20+
"@objectstack/cli": "^3.0.4",
2121
"typescript": "^5.9.3"
2222
}
2323
}

examples/msw-todo/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
},
1212
"dependencies": {
1313
"@object-ui/example-todo": "workspace:*",
14-
"@objectstack/client": "^3.0.2",
15-
"@objectstack/driver-memory": "^3.0.2",
16-
"@objectstack/objectql": "^3.0.2",
17-
"@objectstack/plugin-msw": "^3.0.2",
18-
"@objectstack/runtime": "^3.0.2",
19-
"@objectstack/spec": "^3.0.2",
14+
"@objectstack/client": "^3.0.4",
15+
"@objectstack/driver-memory": "^3.0.4",
16+
"@objectstack/objectql": "^3.0.4",
17+
"@objectstack/plugin-msw": "^3.0.4",
18+
"@objectstack/runtime": "^3.0.4",
19+
"@objectstack/spec": "^3.0.4",
2020
"react": "19.2.4",
2121
"react-dom": "19.2.4"
2222
},

0 commit comments

Comments
 (0)