@supacloud/db-zenstack 0.2.1 → 0.3.0

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/README.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # @supacloud/db-zenstack
2
2
 
3
- Optional ZenStack adapter for model compilation and `createZenStackDatabase`.
3
+ The required ZenStack adapter for model compilation and `createZenStackDatabase`.
4
4
 
5
- `@supacloud/db` re-exports `@supacloud/db/zenstack` and `@supacloud/db/model` from this package so existing imports keep working. The control plane does not depend on this package. Install it only in an application that compiles ZModel or hosts the model command transaction.
5
+ Install `@supacloud/model-tooling` for the development-only `supacloud-model`
6
+ commands. This adapter keeps the Bun SQL runtime path separate from the
7
+ Management API's PostgreSQL introspection path; the user CLI never opens a
8
+ database connection.
9
+
10
+ `@supacloud/db` re-exports `@supacloud/db/zenstack` and `@supacloud/db/model` from this package so existing imports keep working. The selected Vibecoding stack installs this adapter together with `@supacloud/db`.
6
11
 
7
12
  `@supacloud/db` catalog, RLS, and command-receipt code does not import this adapter.
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env bun
2
- export declare function modelMain(argv: string[]): Promise<void>;
2
+ export type ModelToolCommand = {
3
+ readonly executable: string;
4
+ readonly args?: readonly string[];
5
+ };
6
+ export interface ModelToolchain {
7
+ resolve(binary: "zen" | "prisma"): ModelToolCommand;
8
+ }
9
+ export declare function modelMain(argv: string[], toolchain?: ModelToolchain): Promise<void>;
package/dist/model-cli.js CHANGED
@@ -65,7 +65,10 @@ function modelProcess(command, schema, generated, candidate) {
65
65
  }
66
66
 
67
67
  // src/model-cli.ts
68
- async function modelMain(argv) {
68
+ function defaultToolchain(root = process.cwd()) {
69
+ return { resolve: (binary) => ({ executable: resolve2(root, "node_modules/.bin", binary) }) };
70
+ }
71
+ async function modelMain(argv, toolchain = defaultToolchain()) {
69
72
  const [command, ...flags] = argv;
70
73
  if (!["generate", "check", "diff", "pull"].includes(command ?? ""))
71
74
  throw new Error("Usage: supacloud-model generate|check|diff|pull [--schema file] [--output dir] [--candidate file]");
@@ -119,12 +122,13 @@ async function modelMain(argv) {
119
122
  await compileModel(source, join2(validation, "generated"));
120
123
  }
121
124
  const operation = modelProcess(command, source, output, candidate);
122
- const binary = resolve2("node_modules/.bin", operation.binary);
123
- if (!existsSync(binary))
125
+ const tool = toolchain.resolve(operation.binary);
126
+ if (!existsSync(tool.executable))
124
127
  throw new Error(`Install the pinned ${operation.binary} tooling in the application`);
125
128
  await mkdir2(dirname2(candidate), { recursive: true });
126
- const child = Bun.spawn([binary, ...operation.args], {
127
- env: { ...process.env, DATABASE_URL: databaseUrl },
129
+ const { SUPACLOUD_MODEL_DATABASE_URL: _selectedDatabaseUrl, ...parentEnv } = process.env;
130
+ const child = Bun.spawn([tool.executable, ...tool.args ?? [], ...operation.args], {
131
+ env: { ...parentEnv, DATABASE_URL: databaseUrl },
128
132
  stdio: ["ignore", "inherit", "inherit"]
129
133
  });
130
134
  if (await child.exited !== 0)
package/dist/model.d.ts CHANGED
@@ -7,7 +7,8 @@ export declare const BOOTSTRAP_MODEL_SCHEMA = "datasource db {\n provider = \"p
7
7
  /** Offline model compilation: no plugin execution, no database or migration ledger writes. */
8
8
  export declare function compileModel(schemaFile: string, output: string, check?: boolean): Promise<string[]>;
9
9
  export type ModelCommand = "generate" | "check" | "diff" | "pull";
10
- export declare function modelProcess(command: "diff" | "pull", schema: string, generated: string, candidate: string): {
11
- binary: string;
12
- args: string[];
10
+ export type ModelProcess = {
11
+ readonly binary: "prisma" | "zen";
12
+ readonly args: readonly string[];
13
13
  };
14
+ export declare function modelProcess(command: "diff" | "pull", schema: string, generated: string, candidate: string): ModelProcess;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@supacloud/db-zenstack",
3
- "version": "0.2.1",
4
- "description": "Optional ZenStack model adapter for SupaCloud. Not part of the control-plane database package.",
3
+ "version": "0.3.0",
4
+ "description": "Required ZenStack model adapter for the SupaCloud Vibecoding stack.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -43,8 +43,8 @@
43
43
  "directory": "packages/db-zenstack"
44
44
  },
45
45
  "dependencies": {
46
- "@supacloud/contracts": "0.16.1",
47
- "@supacloud/db": "0.24.2",
46
+ "@supacloud/contracts": "0.16.2",
47
+ "@supacloud/db": "0.25.0",
48
48
  "@zenstackhq/language": "3.10.0",
49
49
  "@zenstackhq/orm": "3.10.0",
50
50
  "@zenstackhq/plugin-policy": "3.10.0",
@@ -60,8 +60,8 @@
60
60
  "typescript": "7.1.0-beta"
61
61
  },
62
62
  "overrides": {
63
- "@supacloud/contracts": "0.16.1",
64
- "@supacloud/db": "0.24.2",
63
+ "@supacloud/contracts": "0.16.2",
64
+ "@supacloud/db": "0.25.0",
65
65
  "deepmerge-ts": "8.0.2",
66
66
  "prisma": "6.19.3"
67
67
  },