Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
29771e6
docs: v3 docs structure
ymc9 Aug 1, 2025
4a3bc18
fix build
ymc9 Aug 1, 2025
ae00828
WIP
ymc9 Aug 3, 2025
2815551
WIP
ymc9 Aug 3, 2025
f215f86
progress on ORM part
ymc9 Aug 5, 2025
a43c1d8
update
ymc9 Aug 5, 2025
f649467
update embed mechanism
ymc9 Aug 5, 2025
5cfdf6d
fix stackblitz embed
ymc9 Aug 5, 2025
2c526ff
make code tabs sync
ymc9 Aug 5, 2025
a9d76ec
complete filter section
ymc9 Aug 9, 2025
09208d3
update docs
ymc9 Aug 9, 2025
b61a2e0
progress on delete
ymc9 Aug 9, 2025
80a8026
Merge remote-tracking branch 'origin/main' into docs/v3
ymc9 Aug 10, 2025
7531a18
more progress on ORM API
ymc9 Aug 10, 2025
c608cf4
ORM docs progress
ymc9 Aug 12, 2025
710b83c
query builder docs
ymc9 Aug 12, 2025
f0014f0
computed fields
ymc9 Aug 13, 2025
016fc3d
polymorphism
ymc9 Aug 13, 2025
963d91f
plugins part
ymc9 Aug 13, 2025
dda23fc
update plugins part
ymc9 Aug 14, 2025
d7b5e4e
add logging
ymc9 Aug 14, 2025
e087eb8
add inferred types section
ymc9 Aug 15, 2025
617275e
progress
ymc9 Aug 15, 2025
6ff3510
progress
ymc9 Aug 17, 2025
22de9b9
prisma migration guide
ymc9 Aug 17, 2025
63d5c61
Merge remote-tracking branch 'origin/main' into docs/v3
ymc9 Aug 17, 2025
2fd667e
update broken links
ymc9 Aug 17, 2025
b9e6193
update
ymc9 Aug 17, 2025
1a2a102
copywriting
ymc9 Aug 18, 2025
847a11e
zmodel language reference
ymc9 Aug 19, 2025
ec14645
update
ymc9 Aug 19, 2025
3ebe44f
fix links
ymc9 Aug 19, 2025
f847870
almost done
ymc9 Aug 19, 2025
07209d7
updates
ymc9 Aug 19, 2025
16d96b1
update
ymc9 Aug 19, 2025
25822c8
update
ymc9 Aug 20, 2025
192910f
update
ymc9 Aug 21, 2025
db39b21
add feature gap
ymc9 Aug 24, 2025
3dc70c7
update
ymc9 Aug 24, 2025
2a1cbbb
use git submodules to implement code snippet loading
ymc9 Aug 24, 2025
2fe949a
addressing review comments
ymc9 Aug 24, 2025
7d880b0
update
ymc9 Aug 26, 2025
8c059c5
v3 LP
ymc9 Aug 29, 2025
790de90
update
ymc9 Aug 29, 2025
014cbbe
update
ymc9 Aug 29, 2025
1356842
update responsiveness
ymc9 Aug 29, 2025
99c6b5a
update
ymc9 Aug 29, 2025
0fdcf9c
update
ymc9 Aug 30, 2025
2e229b3
update
ymc9 Aug 30, 2025
6b9d453
update
ymc9 Aug 30, 2025
4bd1637
nav bar
ymc9 Sep 1, 2025
277f966
update
ymc9 Sep 1, 2025
0111abb
update submodules
ymc9 Sep 1, 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
4 changes: 4 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const config = {
label: '1.x',
banner: 'none',
},
'3.x': {
label: '3.0 Alpha',
banner: 'none',
},
},
},
blog: false,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@docusaurus/theme-mermaid": "3.4.0",
"@giscus/react": "^2.4.0",
"@mdx-js/react": "^3.0.1",
"@stackblitz/sdk": "^1.11.0",
"autoprefixer": "^10.4.13",
"clsx": "^1.2.1",
"postcss": "^8.4.21",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/components/StackBlitzEmbed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { useEffect, useRef } from 'react';
import sdk from '@stackblitz/sdk';

interface StackBlitzEmbedProps {
projectId: string;
height?: string;
}

const StackBlitzEmbed: React.FC<StackBlitzEmbedProps> = ({ projectId, height = '600px' }) => {
const containerRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (containerRef.current) {
sdk.embedProjectId(containerRef.current, projectId, {
openFile: 'main.ts',
height,
view: 'editor',
forceEmbedLayout: true,
});
}
}, [projectId, height]);

return <div ref={containerRef} style={{ width: '100%', height }} />;
};

export default StackBlitzEmbed;
26 changes: 26 additions & 0 deletions src/components/StackBlitzGithubEmbed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { useEffect, useRef } from 'react';
import sdk from '@stackblitz/sdk';

interface StackBlitzGithubEmbedProps {
repoPath: string;
height?: string;
}

const StackBlitzGithubEmbed: React.FC<StackBlitzGithubEmbedProps> = ({ repoPath, height = '600px' }) => {
const containerRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (containerRef.current) {
sdk.embedGithubProject(containerRef.current, repoPath, {
openFile: 'main.ts',
height,
view: 'editor',
forceEmbedLayout: true,
});
}
}, [repoPath, height]);

return <div ref={containerRef} style={{ width: '100%', height }} />;
};

export default StackBlitzGithubEmbed;
28 changes: 28 additions & 0 deletions versioned_docs/version-3.x/_components/PackageExec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import CodeBlock from '@theme/CodeBlock';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';

interface Props {
command: string;
}

const pkgManagers = [
{ name: 'npm', command: 'npx' },
{ name: 'pnpm', command: 'pnpm' },
{ name: 'bun', command: 'bunx' },
{ name: 'yarn', command: 'npx' },
];

const PackageInstall = ({ command }: Props) => {
return (
<Tabs>
{pkgManagers.map((pkg) => (
<TabItem key={pkg.name} value={pkg.name} label={pkg.name}>
<CodeBlock language="bash">{`${pkg.command} ${command}`}</CodeBlock>
</TabItem>
))}
</Tabs>
);
};

export default PackageInstall;
33 changes: 33 additions & 0 deletions versioned_docs/version-3.x/_components/PackageInstall.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import CodeBlock from '@theme/CodeBlock';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';

interface Props {
devDependencies: string[];
dependencies: string[];
}

const pkgManagers = [
{ name: 'npm', command: 'npm install', dev: '--save-dev' },
{ name: 'pnpm', command: 'pnpm add', dev: '--save-dev' },
{ name: 'bun', command: 'bun add', dev: '--dev' },
{ name: 'yarn', command: 'yarn add', dev: '--dev' },
];

const PackageInstall = ({ devDependencies, dependencies }: Props) => {
return (
<Tabs>
{pkgManagers.map((pkg) => (
<TabItem key={pkg.name} value={pkg.name} label={pkg.name}>
<CodeBlock language="bash">
{`${devDependencies?.length ? `${pkg.command} ${pkg.dev} ${devDependencies.join(' ')}\n` : ''}${
dependencies?.length ? `${pkg.command} ${dependencies.join(' ')}` : ''
}`}
</CodeBlock>
</TabItem>
))}
</Tabs>
);
};

export default PackageInstall;
23 changes: 23 additions & 0 deletions versioned_docs/version-3.x/_components/_zmodel-starter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```zmodel
datasource db {
provider = 'sqlite'
url = "file:./dev.db"
}

model User {
id String @id @default(cuid())
email String @unique @email @length(6, 32)
posts Post[]
}

model Post {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @length(1, 256)
content String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String
}
```
9 changes: 9 additions & 0 deletions versioned_docs/version-3.x/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
description: ZenStack FAQ.

slug: /faq
sidebar_label: FAQ
sidebar_position: 100
---

# 🙋🏻 FAQ
7 changes: 7 additions & 0 deletions versioned_docs/version-3.x/migration/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
position: 3
label: Migration
collapsible: true
collapsed: true
link:
type: generated-index
title: Migration
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/migration/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 1
description: Introduction to ZenStack migration
---

# Introduction
7 changes: 7 additions & 0 deletions versioned_docs/version-3.x/orm/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
position: 2
label: ORM
collapsible: true
collapsed: true
link:
type: generated-index
title: ORM
4 changes: 4 additions & 0 deletions versioned_docs/version-3.x/orm/access-control/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
position: 8
label: Access Control
collapsible: true
collapsed: true
3 changes: 3 additions & 0 deletions versioned_docs/version-3.x/orm/access-control/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Introduction

Coming soon 🚧
7 changes: 7 additions & 0 deletions versioned_docs/version-3.x/orm/api/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
position: 6
label: ORM API
collapsible: true
collapsed: true
link:
type: generated-index
title: ORM API
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/aggregate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 6
description: Aggregate API
---

# Aggregate
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 5
description: Count API
---

# Count
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 2
description: Create API
---

# Create
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 4
description: Delete API
---

# Delete
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/find.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 1
description: Find API
---

# Find
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 7
description: Transaction API
---

# Transaction
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/api/update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 3
description: Update API
---

# Update
6 changes: 6 additions & 0 deletions versioned_docs/version-3.x/orm/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 4
description: Using the CLI
---

# Using the CLI
7 changes: 7 additions & 0 deletions versioned_docs/version-3.x/orm/computed-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 10
description: Computed fields in ZModel
---

# Computed Fields

65 changes: 65 additions & 0 deletions versioned_docs/version-3.x/orm/database-client.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
sidebar_position: 5
description: Creating a database client
---

import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';
import PackageInstall from '../_components/PackageInstall';

# Database Client

The `zen generate` command compiles the ZModel schema into TypeScript code, which we can in turn use to initialize a type-safe database client. ZenStack uses Kysely to handle the low-level database operations, so the client is initialize with a Kysely dialect - an object that encapsulates database details.

The samples below only shows creating a client using SQLite (via [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)) and PostgreSQL (via [node-postgres](https://github.com/brianc/node-postgres)), however you can also use any other Kysely dialects.

<Tabs>

<TabItem value="sqlite" label={`SQLite`}>

<PackageInstall dependencies={["better-sqlite3"]} devDependencies={['@types/better-sqlite3']} />

```ts title='db.ts'
import { ZenStackClient } from '@zenstackhq/runtime';
import { SqliteDialect } from 'kysely';
import SQLite from 'better-sqlite3';
import { schema } from '@/zenstack/schema';

export const db = new ZenStackClient(schema, {
dialect: new SqliteDialect({
database: new SQLite(':memory:'),
}),
});
```
</TabItem>

<TabItem value="postgres" label={`PostgreSQL`}>

<PackageInstall dependencies={["pg"]} devDependencies={['@types/pg']} />

```ts title='db.ts'
import { ZenStackClient } from '@zenstackhq/runtime';
import { schema } from '@/zenstack/schema';
import { PostgresDialect } from 'kysely';
import { Pool } from 'pg';

export const db = new ZenStackClient(schema, {
dialect: new PostgresDialect({
pool: new Pool({
connectionString: process.env.DATABASE_URL,
}),
}),
});
```
</TabItem>

</Tabs>

The created `db` object has the full ORM API inferred from the type of the `schema` parameter. When necessary, you can also explicitly get the inferred client type like:

```ts
import type { ClientContract } from '@zenstackhq/runtime';
import type { SchemaType } from '@/zenstack/schema';

export type DbClient = ClientContract<SchemaType>;
```
Loading