Skip to content

Commit 68adf79

Browse files
authored
Merge pull request #304 from zenstackhq/dev
merge dev to main (v3.0.0-beta.9)
2 parents 35a9e0d + 2298fc9 commit 68adf79

File tree

331 files changed

+9457
-1021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+9457
-1021
lines changed

TODO.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
- [x] Array update
5757
- [x] Strict typing for checked/unchecked input
5858
- [x] Upsert
59-
- [ ] Implement with "on conflict"
6059
- [x] Delete
6160
- [x] Aggregation
6261
- [x] Count
@@ -86,7 +85,7 @@
8685
- [ ] Global omit
8786
- [ ] DbNull vs JsonNull
8887
- [ ] Migrate to tsdown
89-
- [ ] @default validation
88+
- [x] @default validation
9089
- [ ] Benchmark
9190
- [x] Plugin
9291
- [x] Post-mutation hooks should be called after transaction is committed
@@ -96,7 +95,7 @@
9695
- [x] ZModel
9796
- [x] Runtime
9897
- [x] Typing
99-
- [ ] Validation
98+
- [x] Validation
10099
- [ ] Access Policy
101100
- [ ] Short-circuit pre-create check for scalar-field only policies
102101
- [x] Inject "on conflict do update"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-v3",
3-
"version": "3.0.0-beta.8",
3+
"version": "3.0.0-beta.9",
44
"description": "ZenStack",
55
"packageManager": "[email protected]",
66
"scripts": {

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack CLI",
55
"description": "FullStack database toolkit with built-in access control and automatic API generation.",
6-
"version": "3.0.0-beta.8",
6+
"version": "3.0.0-beta.9",
77
"type": "module",
88
"author": {
99
"name": "ZenStack Team"
@@ -53,7 +53,7 @@
5353
"@zenstackhq/testtools": "workspace:*",
5454
"@zenstackhq/typescript-config": "workspace:*",
5555
"@zenstackhq/vitest-config": "workspace:*",
56-
"better-sqlite3": "^12.2.0",
56+
"better-sqlite3": "catalog:",
5757
"tmp": "catalog:"
5858
}
5959
}

packages/cli/src/plugins/prisma.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import path from 'node:path';
55
const plugin: CliPlugin = {
66
name: 'Prisma Schema Generator',
77
statusText: 'Generating Prisma schema',
8-
async generate({ model, schemaFile, defaultOutputPath, pluginOptions }) {
8+
async generate({ model, defaultOutputPath, pluginOptions }) {
99
let outFile = path.join(defaultOutputPath, 'schema.prisma');
1010
if (typeof pluginOptions['output'] === 'string') {
11-
outFile = path.resolve(path.dirname(schemaFile), pluginOptions['output']);
11+
outFile = path.resolve(defaultOutputPath, pluginOptions['output']);
1212
if (!fs.existsSync(path.dirname(outFile))) {
1313
fs.mkdirSync(path.dirname(outFile), { recursive: true });
1414
}

packages/cli/test/plugins/prisma-plugin.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,25 @@ model User {
5757
runCli('generate', workDir);
5858
expect(fs.existsSync(path.join(workDir, 'prisma/schema.prisma'))).toBe(true);
5959
});
60+
61+
it('can generate a Prisma schema with custom output relative to zenstack.output', () => {
62+
const workDir = createProject(`
63+
plugin prisma {
64+
provider = '@core/prisma'
65+
output = './schema.prisma'
66+
}
67+
68+
model User {
69+
id String @id @default(cuid())
70+
}
71+
`);
72+
73+
const pkgJson = JSON.parse(fs.readFileSync(path.join(workDir, 'package.json'), 'utf8'));
74+
pkgJson.zenstack = {
75+
output: './relative',
76+
};
77+
fs.writeFileSync(path.join(workDir, 'package.json'), JSON.stringify(pkgJson, null, 2));
78+
runCli('generate', workDir);
79+
expect(fs.existsSync(path.join(workDir, 'relative/schema.prisma'))).toBe(true);
80+
});
6081
});

packages/cli/test/ts-schema-gen.test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,64 @@ model User extends Base {
360360
expect(schema.enums).toMatchObject({ Role: expect.any(Object) });
361361
expect(schema.models).toMatchObject({ User: expect.any(Object) });
362362
});
363+
364+
it('generates correct default literal function arguments', async () => {
365+
const { schema } = await generateTsSchema(`
366+
model User {
367+
id String @id @default(uuid(7))
368+
}
369+
`);
370+
371+
expect(schema.models).toMatchObject({
372+
User: {
373+
name: 'User',
374+
fields: {
375+
id: {
376+
name: 'id',
377+
type: 'String',
378+
id: true,
379+
attributes: [
380+
{
381+
name: '@id',
382+
},
383+
{
384+
name: '@default',
385+
args: [
386+
{
387+
name: 'value',
388+
value: {
389+
kind: 'call',
390+
function: 'uuid',
391+
args: [
392+
{
393+
kind: 'literal',
394+
value: 7,
395+
},
396+
],
397+
},
398+
},
399+
],
400+
},
401+
],
402+
default: {
403+
kind: 'call',
404+
function: 'uuid',
405+
args: [
406+
{
407+
kind: 'literal',
408+
value: 7,
409+
},
410+
],
411+
},
412+
},
413+
},
414+
idFields: ['id'],
415+
uniqueFields: {
416+
id: {
417+
type: 'String',
418+
},
419+
},
420+
},
421+
});
422+
});
363423
});

packages/common-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/common-helpers",
3-
"version": "3.0.0-beta.8",
3+
"version": "3.0.0-beta.9",
44
"description": "ZenStack Common Helpers",
55
"type": "module",
66
"scripts": {
File renamed without changes.

packages/eslint-config/package.json renamed to packages/config/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/eslint-config",
3-
"version": "3.0.0-beta.8",
3+
"version": "3.0.0-beta.9",
44
"type": "module",
55
"private": true,
66
"license": "MIT"
File renamed without changes.

0 commit comments

Comments
 (0)