Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Project Structure & Module Organization

Core CLI logic lives in `src/`: `cli/` exposes the executable wrapper, `drizzle-to-zero.ts` coordinates schema translation, adapters sit in `node-postgres/` and `postgres-js/`, and helpers such as `tables.ts` or `relations.ts` centralize shared builders. Vitest unit suites reside in `tests/`, while end-to-end fixtures live under `integration/`, `no-config-integration/`, and `db/`. Generated bundles land in `dist/` and coverage reports in `coverage/`; treat them as expendable artifacts unless you are preparing a release.
Core CLI logic lives in `src/`: `cli/` exposes the executable wrapper, `drizzle-to-zero.ts` coordinates schema translation, and helpers such as `tables.ts` or `relations.ts` centralize shared builders. Vitest unit suites reside in `tests/`, while end-to-end fixtures live under `integration/`, `no-config-integration/`, and `db/`. Generated bundles land in `dist/` and coverage reports in `coverage/`; treat them as expendable artifacts unless you are preparing a release.

## Build, Test, and Development Commands

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ The CLI automatically detects whether `.js` file extensions are needed in import

You can also control optional outputs from the generator:

- **--skip-types**: Skip generating table `Row<>` type exports.
- **--skip-types**: Skip generating table `Row[]` type exports.
- **--skip-builder**: Skip generating the query `builder` export.
- **--disable-legacy-mutators**: Disable legacy CRUD mutators (sets `enableLegacyMutators` to `false` in the generated schema). Use this when you want to use only custom mutators instead of the default CRUD operations.
- **--disable-legacy-queries**: Disable legacy CRUD queries (sets `enableLegacyQueries` to `false` in the generated schema). Use this when you want to use only custom queries.
- **--skip-declare**: Skip generating the module augmentation for default types in Zero.
- **--enable-legacy-mutators**: Disable legacy CRUD mutators (sets `enableLegacyMutators` to `true` in the generated schema).
- **--enable-legacy-queries**: Disable legacy CRUD queries (sets `enableLegacyQueries` to `true` in the generated schema).

For more information on disabling legacy mutators and queries, see the [Zero documentation](https://zero.rocicorp.dev/docs/custom-mutators#disabling-crud-mutators).

Expand Down
36 changes: 1 addition & 35 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,7 @@ const main = async () => {
],
});

await tsup.build({
outDir: "./dist/postgres-js",
splitting: false,
dts: true,
entry: ["src/postgres-js/index.ts"],
format: ["cjs", "esm"],
external: [
"esbuild",
"tsx",
"prettier",
"typescript",
"@rocicorp/zero",
"drizzle-orm",
"commander",
"ts-morph",
],
});

await tsup.build({
outDir: "./dist/node-postgres",
splitting: false,
dts: true,
entry: ["src/node-postgres/index.ts"],
format: ["cjs", "esm"],
external: [
"esbuild",
"tsx",
"prettier",
"typescript",
"@rocicorp/zero",
"drizzle-orm",
"commander",
"ts-morph",
],
});


await tsup.build({
outDir: "./dist/cli",
Expand Down
2 changes: 1 addition & 1 deletion integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"build": "tsc",
"drizzle-zero:generate": "drizzle-zero generate -f --disable-legacy-mutators --disable-legacy-queries",
"drizzle-zero:generate": "drizzle-zero generate -f",
"pretest": "pnpm drizzle-zero:generate",
"test": "pnpm build && vitest run"
},
Expand Down
26 changes: 13 additions & 13 deletions integration/synced-queries.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { syncedQueryWithContext } from "@rocicorp/zero";
import { z } from "zod";
import { builder } from "./zero-schema.gen";
import { zql } from "./zero-schema.gen";

export const allUsers = syncedQueryWithContext(
"integration.allUsers",
z.tuple([]),
(_ctx) => builder.user.orderBy("id", "asc"),
(_ctx) => zql.user.orderBy("id", "asc"),
);

export const filtersWithChildren = syncedQueryWithContext(
"integration.filtersWithChildren",
z.tuple([z.string()]),
(_ctx, rootId) =>
builder.filters
zql.filters
.where((q) => q.cmp("id", "=", rootId))
.related("children", (q) => q.related("children").orderBy("id", "asc")),
);
Expand All @@ -21,7 +21,7 @@ export const messagesBySender = syncedQueryWithContext(
"integration.messagesBySender",
z.tuple([z.string()]),
(_ctx, senderId) =>
builder.message
zql.message
.where((q) => q.cmp("senderId", "=", senderId))
.orderBy("id", "asc"),
);
Expand All @@ -30,14 +30,14 @@ export const messagesByBody = syncedQueryWithContext(
"integration.messagesByBody",
z.tuple([z.string()]),
(_ctx, body) =>
builder.message.where((q) => q.cmp("body", "=", body)).orderBy("id", "asc"),
zql.message.where((q) => q.cmp("body", "=", body)).orderBy("id", "asc"),
);

export const messageWithRelations = syncedQueryWithContext(
"integration.messageWithRelations",
z.tuple([z.string()]),
(_ctx, id) =>
builder.message
zql.message
.where((q) => q.cmp("id", "=", id))
.related("medium")
.related("sender")
Expand All @@ -48,7 +48,7 @@ export const userWithMediums = syncedQueryWithContext(
"integration.userWithMediums",
z.tuple([z.string()]),
(_ctx, id) =>
builder.user
zql.user
.where((q) => q.cmp("id", "=", id))
.related("mediums")
.one(),
Expand All @@ -58,7 +58,7 @@ export const userWithFriends = syncedQueryWithContext(
"integration.userWithFriends",
z.tuple([z.string()]),
(_ctx, id) =>
builder.user
zql.user
.where((q) => q.cmp("id", "=", id))
.related("friends")
.one(),
Expand All @@ -67,33 +67,33 @@ export const userWithFriends = syncedQueryWithContext(
export const messageById = syncedQueryWithContext(
"integration.messageById",
z.tuple([z.string()]),
(_ctx, id) => builder.message.where((q) => q.cmp("id", "=", id)).one(),
(_ctx, id) => zql.message.where((q) => q.cmp("id", "=", id)).one(),
);

export const mediumById = syncedQueryWithContext(
"integration.mediumById",
z.tuple([z.string()]),
(_ctx, id) => builder.medium.where((q) => q.cmp("id", "=", id)).one(),
(_ctx, id) => zql.medium.where((q) => q.cmp("id", "=", id)).one(),
);

export const allTypesById = syncedQueryWithContext(
"integration.allTypesById",
z.tuple([z.string()]),
(_ctx, id) => builder.allTypes.where((q) => q.cmp("id", "=", id)).one(),
(_ctx, id) => zql.allTypes.where((q) => q.cmp("id", "=", id)).one(),
);

export const allTypesByStatus = syncedQueryWithContext(
"integration.allTypesByStatus",
z.tuple([z.enum(["active", "inactive", "pending"])]),
(_ctx, status) =>
builder.allTypes.where((q) => q.cmp("status", "=", status)).one(),
zql.allTypes.where((q) => q.cmp("status", "=", status)).one(),
);

export const complexOrderWithEverything = syncedQueryWithContext(
"integration.complexOrderWithEverything",
z.tuple([z.string()]),
(_ctx, orderId) =>
builder.orderTable
zql.orderTable
.where((q) => q.cmp("id", "=", orderId))
.related("customer", (q) =>
q
Expand Down
Loading
Loading