Skip to content

Commit 5cd651b

Browse files
committed
feat(runtime): refactor to use @objectstack/runtime and implement standalone stack functionality
1 parent c80187d commit 5cd651b

8 files changed

Lines changed: 35 additions & 28 deletions

File tree

examples/app-crm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@objectstack/spec": "workspace:*",
22-
"@objectstack/service-cloud": "workspace:*"
22+
"@objectstack/runtime": "workspace:*"
2323
},
2424
"devDependencies": {
2525
"@objectstack/cli": "workspace:*",

packages/cli/src/commands/serve.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,24 @@ export default class Serve extends Command {
175175
throw new Error(`No default export found in ${args.config}`);
176176
}
177177

178-
// Standalone is the default OS dev workflow. Every bare
179-
// `defineStack()` is booted via `@objectstack/service-cloud`'s
180-
// `createBootStack()` (runtime / cloud / standalone selected by
181-
// `OBJECTSTACK_MODE`, default `standalone`). Set
182-
// `OBJECTSTACK_MODE=off` to fall back to the legacy lightweight
183-
// assembler.
178+
// Boot-mode dispatch: standalone goes directly through
179+
// `@objectstack/runtime` (no cloud dependencies). runtime/cloud
180+
// modes go through `@objectstack/service-cloud`.
184181
if (shouldBootWithLibrary(config)) {
185-
const { createBootStack } = await import('@objectstack/service-cloud');
186-
const bootResult = await createBootStack({
187-
mode: config.bootMode,
188-
runtime: config.runtime ?? config.project,
189-
cloud: config.cloud,
190-
standalone: config.standalone,
191-
});
192-
config = bootResult as any;
182+
const resolvedMode = config.bootMode ?? process.env.OBJECTSTACK_MODE ?? 'standalone';
183+
if (resolvedMode === 'standalone') {
184+
const { createStandaloneStack } = await import('@objectstack/runtime');
185+
const bootResult = await createStandaloneStack(config.standalone);
186+
config = bootResult as any;
187+
} else {
188+
const { createBootStack } = await import('@objectstack/service-cloud');
189+
const bootResult = await createBootStack({
190+
mode: config.bootMode,
191+
runtime: config.runtime ?? config.project,
192+
cloud: config.cloud,
193+
});
194+
config = bootResult as any;
195+
}
193196
}
194197

195198
// ── Resolve plugin tiers ──────────────────────────────────────

packages/runtime/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"@objectstack/driver-memory": "workspace:*",
3030
"@objectstack/driver-sql": "workspace:*",
3131
"@objectstack/driver-turso": "workspace:*",
32+
"@objectstack/metadata": "workspace:*",
33+
"@objectstack/objectql": "workspace:*",
3234
"typescript": "^6.0.3",
3335
"vitest": "^4.1.4"
3436
},

packages/runtime/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export { ObjectKernel } from '@objectstack/core';
77
export { Runtime } from './runtime.js';
88
export type { RuntimeConfig } from './runtime.js';
99

10+
// Export Standalone Stack
11+
export { createStandaloneStack } from './standalone-stack.js';
12+
export type { StandaloneStackConfig, StandaloneStackResult } from './standalone-stack.js';
13+
1014
// Export Plugins
1115
export { DriverPlugin } from './driver-plugin.js';
1216
export { AppPlugin } from './app-plugin.js';

packages/services/service-cloud/src/standalone-stack.ts renamed to packages/runtime/src/standalone-stack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export async function createStandaloneStack(config?: StandaloneStackConfig): Pro
3939

4040
const { ObjectQLPlugin } = await import('@objectstack/objectql');
4141
const { MetadataPlugin } = await import('@objectstack/metadata');
42-
const { DriverPlugin, AppPlugin } = await import('@objectstack/runtime');
42+
const { DriverPlugin } = await import('./driver-plugin.js');
43+
const { AppPlugin } = await import('./app-plugin.js');
4344

4445
const cwd = process.cwd();
4546
const projectId = cfg.projectId ?? process.env.OBJECTSTACK_PROJECT_ID ?? 'proj_local';

packages/services/service-cloud/src/boot-stack.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { z } from 'zod';
1414
import { resolveMode, resolveAuthSecret, resolveBaseUrl } from './boot-env.js';
1515
import type { BootMode } from './boot-env.js';
1616
import { createRuntimeStack, RuntimeStackConfigSchema } from './runtime-stack.js';
17-
import { createStandaloneStack, StandaloneStackConfigSchema } from './standalone-stack.js';
1817
import { createCloudStack } from './cloud-stack.js';
1918
import type { CloudStackConfig } from './cloud-stack.js';
2019
import type { ProjectTemplate } from './multi-project-plugin.js';
@@ -35,7 +34,7 @@ const CloudStackConfigSchema = z.object({
3534

3635
export const BootStackConfigSchema = z.object({
3736
/** Explicit mode override. When unset, resolves from env. */
38-
mode: z.enum(['runtime', 'cloud', 'standalone', 'project']).optional(),
37+
mode: z.enum(['runtime', 'cloud', 'project']).optional(),
3938
/** Runtime-mode options (used when mode resolves to `runtime`). */
4039
runtime: RuntimeStackConfigSchema.optional(),
4140
/**
@@ -45,8 +44,6 @@ export const BootStackConfigSchema = z.object({
4544
project: RuntimeStackConfigSchema.optional(),
4645
/** Cloud-mode options (used when mode resolves to `cloud`). */
4746
cloud: CloudStackConfigSchema.optional(),
48-
/** Standalone-mode options (used when mode resolves to `standalone`). */
49-
standalone: StandaloneStackConfigSchema.optional(),
5047
});
5148

5249
export type BootStackConfig = z.input<typeof BootStackConfigSchema>;
@@ -92,10 +89,6 @@ export async function createBootStack(config?: BootStackConfig): Promise<BootSta
9289
return createCloudStack(merged);
9390
}
9491

95-
if (mode === 'standalone') {
96-
return createStandaloneStack(cfg.standalone);
97-
}
98-
9992
// runtime (also reached via deprecated `mode: 'project'`)
10093
return createRuntimeStack(cfg.runtime ?? cfg.project);
10194
}

packages/services/service-cloud/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ export { createProjectStack, ProjectStackConfigSchema } from './runtime-stack.js
7878
/** @deprecated Use `RuntimeStackConfig`/`RuntimeStackResult`. */
7979
export type { ProjectStackConfig, ProjectStackResult } from './runtime-stack.js';
8080

81-
export { createStandaloneStack, StandaloneStackConfigSchema } from './standalone-stack.js';
82-
export type { StandaloneStackConfig, StandaloneStackResult } from './standalone-stack.js';
8381

8482
export { createBootStack, BootStackConfigSchema } from './boot-stack.js';
8583
export type { BootStackConfig, BootStackResult } from './boot-stack.js';

pnpm-lock.yaml

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)