Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
28b3c5d
feat: initial db pull implementation
svetch Sep 23, 2025
8d9dd14
fix: generate imports and attributes for zmodel-code-generator
svetch Sep 24, 2025
05e19e5
fix: add option to not exclude imports in loadDocument
svetch Sep 24, 2025
30a7324
fix: continue work on db pull
svetch Sep 24, 2025
1bb620e
fix: missing import
svetch Sep 24, 2025
2a82cc1
fix: rewrite model generation
svetch Sep 26, 2025
3b55a8b
feat: add ast factory
svetch Oct 5, 2025
061177b
fix: ast factory import order
svetch Oct 5, 2025
53928f8
fix: some runtime bugs
svetch Oct 6, 2025
15e5033
fix: lint fix
svetch Oct 20, 2025
1e6c06e
fix: update zmodel code generator
svetch Oct 20, 2025
5c0389c
feat: add exclude schemas option
svetch Oct 20, 2025
faccb01
feat: implement initial diff update
svetch Oct 20, 2025
0710b84
fix: update format in zmodel code generator
svetch Oct 20, 2025
697225e
fix: typo
svetch Oct 20, 2025
2b36948
feat: progress on database introspection and syncing
svetch Oct 21, 2025
0ff59d7
fix: make ignore behave it does in prisma with no index models
svetch Oct 21, 2025
6c12b98
fix: lint fix
svetch Oct 21, 2025
8172e71
feat: make all format options configurable
svetch Oct 21, 2025
37e27cf
fix: lint fix
svetch Oct 21, 2025
fc08233
feat: Handle the database type mapping
svetch Oct 22, 2025
fa5776e
fix: catch up with feature updates
svetch Nov 12, 2025
70e90bb
fix: add sqlite e2e test and fix some bugs
svetch Nov 21, 2025
801d651
fix: lint fix
svetch Nov 21, 2025
b4c510e
fix: formatting for e2e test schemas
svetch Nov 21, 2025
d8e9a76
test: run db pull e2e test also for postgres
svetch Nov 21, 2025
1a065ea
fix: postgres instorspection schema filter
svetch Nov 23, 2025
0a0dabf
test: update cli tests
svetch Nov 23, 2025
44a70f5
feat(cli): Improves database introspection and syncing
svetch Dec 15, 2025
3dee449
fix(cli): fixes field casing and sort issues
svetch Jan 9, 2026
a3ae1dd
chore(cli): remove temporary test script
svetch Jan 27, 2026
9c484df
chore: update pnpm-lock.yaml
svetch Jan 27, 2026
c2d4b36
feat(cli): add MySQL support for schema introspection
svetch Jan 27, 2026
6780461
fix(cli): improve field matching logic during db pull
svetch Jan 27, 2026
6e62512
feat(cli): enhance SQLite introspection with autoincrement support
svetch Jan 27, 2026
aaed097
fix(cli): refine attribute generation in db pull
svetch Jan 27, 2026
0a7b86d
test(cli): update db pull tests for SQLite specific behavior
svetch Jan 27, 2026
8edade1
refactor(language): export ZModelServices type
svetch Jan 27, 2026
210198c
fix(cli): improve sqlite introspection for autoincrement and fk names
svetch Jan 28, 2026
69cbc08
feat(cli): enhance field matching logic during pull by using relation…
svetch Jan 28, 2026
86c22a0
refactor(cli): refine relation name generation and table syncing
svetch Jan 28, 2026
89eb50a
test(cli): update pull tests to reflect improved schema generation
svetch Jan 28, 2026
f6f2660
test(cli): add MySQL support to test utility helpers
svetch Jan 28, 2026
54790e4
fix(cli): omit default constraint names in table sync
svetch Jan 28, 2026
6e756b5
fix: correctly handle default values for 'text' type in PostgreSQL
svetch Jan 28, 2026
1006081
fix: sort table indexes to ensure stable schema generation
svetch Jan 28, 2026
ac01e9f
refactor: dynamically determine supported db providers in CLI
svetch Jan 28, 2026
371552d
test: fix typo in pull test description
svetch Jan 28, 2026
472b377
chore(cli): remove debug artifacts and silence test logs
svetch Jan 28, 2026
8e478d1
fix(cli): ensure MySQL column and index ordering
svetch Jan 29, 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
3 changes: 3 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
"./package.json": "./package.json"
},
"dependencies": {
"@dotenvx/dotenvx": "^1.51.0",
"@zenstackhq/common-helpers": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/orm": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"@zenstackhq/server": "workspace:*",
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