Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
990d4ba
feat: initial db pull implementation
svetch Sep 23, 2025
5e376c9
fix: generate imports and attributes for zmodel-code-generator
svetch Sep 24, 2025
ab7d8c9
fix: add option to not exclude imports in loadDocument
svetch Sep 24, 2025
5e1616a
fix: continue work on db pull
svetch Sep 24, 2025
e1561c0
fix: missing import
svetch Sep 24, 2025
96e25b7
fix: rewrite model generation
svetch Sep 26, 2025
c7d3ac8
feat: add ast factory
svetch Oct 5, 2025
15c8506
fix: ast factory import order
svetch Oct 5, 2025
db6bba6
fix: some runtime bugs
svetch Oct 6, 2025
e247f9c
fix: lint fix
svetch Oct 20, 2025
436b70f
fix: update zmodel code generator
svetch Oct 20, 2025
fee75a1
feat: add exclude schemas option
svetch Oct 20, 2025
4570997
feat: implement initial diff update
svetch Oct 20, 2025
52ad8f6
fix: update format in zmodel code generator
svetch Oct 20, 2025
4a78c0c
fix: typo
svetch Oct 20, 2025
ad7ba59
feat: progress on database introspection and syncing
svetch Oct 21, 2025
cdd8a0b
fix: make ignore behave it does in prisma with no index models
svetch Oct 21, 2025
b0a0ed9
fix: lint fix
svetch Oct 21, 2025
6747ade
feat: make all format options configurable
svetch Oct 21, 2025
dbc43d5
fix: lint fix
svetch Oct 21, 2025
2229460
feat: Handle the database type mapping
svetch Oct 22, 2025
3762338
fix: catch up with feature updates
svetch Nov 12, 2025
45cb1b8
fix: add sqlite e2e test and fix some bugs
svetch Nov 21, 2025
9bfecbd
fix: lint fix
svetch Nov 21, 2025
3c23fe7
fix: formatting for e2e test schemas
svetch Nov 21, 2025
a2e9858
test: run db pull e2e test also for postgres
svetch Nov 21, 2025
02acdde
fix: postgres instorspection schema filter
svetch Nov 23, 2025
23b482b
test: update cli tests
svetch Nov 23, 2025
a8b7e71
feat(cli): Improves database introspection and syncing
svetch Dec 15, 2025
5dc7e9a
fix(cli): fixes field casing and sort issues
svetch Jan 9, 2026
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
7 changes: 6 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"./package.json": "./package.json"
},
"dependencies": {
"@dotenvx/dotenvx": "^1.51.0",
"@zenstackhq/common-helpers": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"chokidar": "^5.0.0",
"colors": "1.4.0",
Expand All @@ -50,10 +52,12 @@
"package-manager-detector": "^1.3.0",
"prisma": "catalog:",
"semver": "^7.7.2",
"ts-pattern": "catalog:"
"ts-pattern": "catalog:",
"vscode-uri": "^3.1.0"
},
"devDependencies": {
"@types/better-sqlite3": "catalog:",
"@types/pg": "^8.11.11",
"@types/semver": "^7.7.0",
"@types/tmp": "catalog:",
"@zenstackhq/eslint-config": "workspace:*",
Expand All @@ -62,6 +66,7 @@
"@zenstackhq/typescript-config": "workspace:*",
"@zenstackhq/vitest-config": "workspace:*",
"better-sqlite3": "catalog:",
"pg": "^8.16.3",
"tmp": "catalog:"
},
"engines": {
Expand Down
25 changes: 21 additions & 4 deletions packages/cli/src/actions/action-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadDocument } from '@zenstackhq/language';
import { isDataSource } from '@zenstackhq/language/ast';
import { type ZModelServices, loadDocument } from '@zenstackhq/language';
import { type Model, isDataSource } from '@zenstackhq/language/ast';
import { PrismaSchemaGenerator } from '@zenstackhq/sdk';
import colors from 'colors';
import fs from 'node:fs';
Expand Down Expand Up @@ -41,8 +41,22 @@ export function getSchemaFile(file?: string) {
}
}

export async function loadSchemaDocument(schemaFile: string) {
const loadResult = await loadDocument(schemaFile);
export async function loadSchemaDocument(
schemaFile: string,
opts?: { keepImports?: boolean; returnServices?: false },
): Promise<Model>;
export async function loadSchemaDocument(
schemaFile: string,
opts: { returnServices: true; keepImports?: boolean },
): Promise<{ model: Model; services: ZModelServices }>;
export async function loadSchemaDocument(
schemaFile: string,
opts: { returnServices?: boolean; keepImports?: boolean } = {},
) {
const returnServices = opts.returnServices || false;
const keepImports = opts.keepImports || false;

const loadResult = await loadDocument(schemaFile, [], keepImports);
if (!loadResult.success) {
loadResult.errors.forEach((err) => {
console.error(colors.red(err));
Expand All @@ -52,6 +66,9 @@ export async function loadSchemaDocument(schemaFile: string) {
loadResult.warnings.forEach((warn) => {
console.warn(colors.yellow(warn));
});

if (returnServices) return { model: loadResult.model, services: loadResult.services };

return loadResult.model;
}

Expand Down
Loading
Loading