Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
772ca12
feat: initial db pull implementation
svetch Sep 23, 2025
16d6dc0
fix: generate imports and attributes for zmodel-code-generator
svetch Sep 24, 2025
a997864
fix: add option to not exclude imports in loadDocument
svetch Sep 24, 2025
f7a88be
fix: continue work on db pull
svetch Sep 24, 2025
ae21f69
fix: missing import
svetch Sep 24, 2025
8fb1e37
fix: rewrite model generation
svetch Sep 26, 2025
ba26032
feat: add ast factory
svetch Oct 5, 2025
ec56faa
fix: ast factory import order
svetch Oct 5, 2025
f19c6f5
fix: some runtime bugs
svetch Oct 6, 2025
3cd05d1
fix: lint fix
svetch Oct 20, 2025
b794a7c
fix: update zmodel code generator
svetch Oct 20, 2025
33ecb33
feat: add exclude schemas option
svetch Oct 20, 2025
58922da
feat: implement initial diff update
svetch Oct 20, 2025
4980be8
fix: update format in zmodel code generator
svetch Oct 20, 2025
05eb61e
fix: typo
svetch Oct 20, 2025
5e8a159
feat: progress on database introspection and syncing
svetch Oct 21, 2025
4a9158c
fix: make ignore behave it does in prisma with no index models
svetch Oct 21, 2025
c7809b3
fix: lint fix
svetch Oct 21, 2025
b794a66
feat: make all format options configurable
svetch Oct 21, 2025
419515e
fix: lint fix
svetch Oct 21, 2025
d9cd916
feat: Handle the database type mapping
svetch Oct 22, 2025
3384f8b
fix: catch up with feature updates
svetch Nov 12, 2025
c3f8357
fix: add sqlite e2e test and fix some bugs
svetch Nov 21, 2025
2f7e379
fix: lint fix
svetch Nov 21, 2025
f2d9770
fix: formatting for e2e test schemas
svetch Nov 21, 2025
454772e
test: run db pull e2e test also for postgres
svetch Nov 21, 2025
68fe375
fix: postgres instorspection schema filter
svetch Nov 23, 2025
1dc45fa
test: update cli tests
svetch Nov 23, 2025
68708b4
feat(cli): Improves database introspection and syncing
svetch Dec 15, 2025
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 @@ -29,8 +29,10 @@
"pack": "pnpm pack"
},
"dependencies": {
"@dotenvx/dotenvx": "^1.51.0",
"@zenstackhq/common-helpers": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"colors": "1.4.0",
"commander": "^8.3.0",
Expand All @@ -42,10 +44,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 @@ -54,6 +58,7 @@
"@zenstackhq/typescript-config": "workspace:*",
"@zenstackhq/vitest-config": "workspace:*",
"better-sqlite3": "catalog:",
"pg": "^8.16.3",
"tmp": "catalog:"
}
}
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