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
39792cb
feat: initial db pull implementation
svetch Sep 23, 2025
1d80f6e
fix: generate imports and attributes for zmodel-code-generator
svetch Sep 24, 2025
e83ca14
fix: add option to not exclude imports in loadDocument
svetch Sep 24, 2025
6e27c73
fix: continue work on db pull
svetch Sep 24, 2025
207af7a
fix: missing import
svetch Sep 24, 2025
215e689
fix: rewrite model generation
svetch Sep 26, 2025
58107ac
feat: add ast factory
svetch Oct 5, 2025
3e9e3c2
fix: ast factory import order
svetch Oct 5, 2025
1744b1a
fix: some runtime bugs
svetch Oct 6, 2025
3e46208
fix: lint fix
svetch Oct 20, 2025
5772d49
fix: update zmodel code generator
svetch Oct 20, 2025
b5571e7
feat: add exclude schemas option
svetch Oct 20, 2025
b97f3e9
feat: implement initial diff update
svetch Oct 20, 2025
a137126
fix: update format in zmodel code generator
svetch Oct 20, 2025
3e9444d
fix: typo
svetch Oct 20, 2025
7cc2ab8
feat: progress on database introspection and syncing
svetch Oct 21, 2025
8f119f0
fix: make ignore behave it does in prisma with no index models
svetch Oct 21, 2025
8d4e90b
fix: lint fix
svetch Oct 21, 2025
5292760
feat: make all format options configurable
svetch Oct 21, 2025
269d553
fix: lint fix
svetch Oct 21, 2025
463c5fb
feat: Handle the database type mapping
svetch Oct 22, 2025
0c2d0d3
fix: catch up with feature updates
svetch Nov 12, 2025
f5db50c
fix: add sqlite e2e test and fix some bugs
svetch Nov 21, 2025
a3d6b84
fix: lint fix
svetch Nov 21, 2025
f2757e4
fix: formatting for e2e test schemas
svetch Nov 21, 2025
805983a
test: run db pull e2e test also for postgres
svetch Nov 21, 2025
d14ebd3
fix: postgres instorspection schema filter
svetch Nov 23, 2025
78d505c
test: update cli tests
svetch Nov 23, 2025
5db51e6
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:*",
"prisma": "catalog:",
"colors": "1.4.0",
Expand All @@ -41,10 +43,12 @@
"ora": "^5.4.1",
"package-manager-detector": "^1.3.0",
"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 @@ -53,6 +57,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