From 5001f00aeacbcbb999df145162ef6fbd2ef4c6ab Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Mon, 1 Dec 2025 21:08:21 +0800 Subject: [PATCH 1/5] test(bun): basic e2e tests --- package.json | 2 +- packages/testtools/src/client.ts | 9 +- pnpm-lock.yaml | 101 ++++++++++--- pnpm-workspace.yaml | 39 ++--- tests/bun/e2e.test.ts | 111 ++++++++++++++ tests/bun/package.json | 28 ++++ tests/bun/schemas/input.ts | 50 +++++++ tests/bun/schemas/models.ts | 14 ++ tests/bun/schemas/schema.ts | 177 +++++++++++++++++++++++ tests/bun/schemas/schema.zmodel | 46 ++++++ tests/bun/scripts/generate.ts | 20 +++ tests/bun/tsconfig.json | 8 + tests/e2e/package.json | 1 - tests/regression/package.json | 3 +- tests/regression/test/issue-204/input.ts | 4 +- tests/regression/test/issue-422/input.ts | 8 +- tests/regression/tsconfig.json | 2 +- turbo.json | 6 +- 18 files changed, 572 insertions(+), 57 deletions(-) create mode 100644 tests/bun/e2e.test.ts create mode 100644 tests/bun/package.json create mode 100644 tests/bun/schemas/input.ts create mode 100644 tests/bun/schemas/models.ts create mode 100644 tests/bun/schemas/schema.ts create mode 100644 tests/bun/schemas/schema.zmodel create mode 100644 tests/bun/scripts/generate.ts create mode 100644 tests/bun/tsconfig.json diff --git a/package.json b/package.json index 2418e326..8be97821 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "turbo run build", "watch": "turbo run watch build", "lint": "turbo run lint", - "test": "vitest run", + "test": "turbo run test", "format": "prettier --write \"**/*.{ts,tsx,md}\"", "pr": "gh pr create --fill-first --base dev", "merge-main": "gh pr create --title \"merge dev to main\" --body \"\" --base main --head dev", diff --git a/packages/testtools/src/client.ts b/packages/testtools/src/client.ts index c756f126..1defaeaf 100644 --- a/packages/testtools/src/client.ts +++ b/packages/testtools/src/client.ts @@ -25,13 +25,15 @@ export function getTestDbProvider() { return val as 'sqlite' | 'postgresql'; } -const TEST_PG_CONFIG = { +export const TEST_PG_CONFIG = { host: process.env['TEST_PG_HOST'] ?? 'localhost', port: process.env['TEST_PG_PORT'] ? parseInt(process.env['TEST_PG_PORT']) : 5432, user: process.env['TEST_PG_USER'] ?? 'postgres', password: process.env['TEST_PG_PASSWORD'] ?? 'postgres', }; +export const TEST_PG_URL = `postgres://${TEST_PG_CONFIG.user}:${TEST_PG_CONFIG.password}@${TEST_PG_CONFIG.host}:${TEST_PG_CONFIG.port}`; + type ExtraTestClientOptions = { /** * Database provider @@ -104,10 +106,7 @@ export async function createTestClient( let _schema: SchemaDef; const provider = options?.provider ?? getTestDbProvider() ?? 'sqlite'; const dbName = options?.dbName ?? getTestDbName(provider); - const dbUrl = - provider === 'sqlite' - ? `file:${dbName}` - : `postgres://${TEST_PG_CONFIG.user}:${TEST_PG_CONFIG.password}@${TEST_PG_CONFIG.host}:${TEST_PG_CONFIG.port}/${dbName}`; + const dbUrl = provider === 'sqlite' ? `file:${dbName}` : `${TEST_PG_URL}/${dbName}`; let model: Model | undefined; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 35ce119e..ba4c48c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,7 +43,7 @@ catalogs: specifier: 16.0.1 version: 16.0.1 pg: - specifier: ^8.13.1 + specifier: 8.16.3 version: 8.16.3 prisma: specifier: ^6.19.0 @@ -804,6 +804,46 @@ importers: specifier: 'catalog:' version: 6.19.0(magicast@0.3.5)(typescript@5.9.3) + tests/bun: + dependencies: + '@zenstackhq/cli': + specifier: workspace:* + version: link:../../packages/cli + '@zenstackhq/common-helpers': + specifier: workspace:* + version: link:../../packages/common-helpers + '@zenstackhq/orm': + specifier: workspace:* + version: link:../../packages/orm + '@zenstackhq/plugin-policy': + specifier: workspace:* + version: link:../../packages/plugins/policy + '@zenstackhq/testtools': + specifier: workspace:* + version: link:../../packages/testtools + kysely: + specifier: 'catalog:' + version: 0.28.8 + kysely-bun-sqlite: + specifier: ^0.4.0 + version: 0.4.0(kysely@0.28.8) + pg: + specifier: 'catalog:' + version: 8.16.3 + devDependencies: + '@types/pg': + specifier: ^8.15.6 + version: 8.15.6 + '@zenstackhq/typescript-config': + specifier: workspace:* + version: link:../../packages/config/typescript-config + '@zenstackhq/vitest-config': + specifier: workspace:* + version: link:../../packages/config/vitest-config + bun-types: + specifier: ^1.3.3 + version: 1.3.3 + tests/e2e: dependencies: '@paralleldrive/cuid2': @@ -846,9 +886,6 @@ importers: specifier: ^11.0.5 version: 11.0.5 devDependencies: - '@types/uuid': - specifier: ^11.0.0 - version: 11.0.0 '@zenstackhq/typescript-config': specifier: workspace:* version: link:../../packages/config/typescript-config @@ -865,6 +902,9 @@ importers: specifier: 'catalog:' version: 10.6.0 devDependencies: + '@types/node': + specifier: 'catalog:' + version: 20.19.24 '@zenstackhq/cli': specifier: workspace:* version: link:../../packages/cli @@ -2916,6 +2956,9 @@ packages: '@types/pg@8.11.11': resolution: {integrity: sha512-kGT1qKM8wJQ5qlawUrEkXgvMSXoV213KfMGXcwfDwUIfUHXqXYXOfS1nE1LINRJVVVx5wCm70XnFlMHaIcQAfw==} + '@types/pg@8.15.6': + resolution: {integrity: sha512-NoaMtzhxOrubeL/7UZuNTrejB4MPAJ0RpxZqXQf2qXuVlTPuG6Y8p4u9dKRaue4yjmC7ZhzVO2/Yyyn25znrPQ==} + '@types/pluralize@0.0.33': resolution: {integrity: sha512-JOqsl+ZoCpP4e8TDke9W79FDcSgPAR0l6pixx2JHkhnRjvShyYiAYw2LVsnA7K08Y6DeOnaU6ujmENO4os/cYg==} @@ -2963,10 +3006,6 @@ packages: '@types/toposort@2.0.7': resolution: {integrity: sha512-sQNk65vbC36+UixCkcky+dCr7MlflHcVILg1FVGqlUntsLFv9xd9ToWIVko/gTuin+cVe16t+2YubEFkhnSuPQ==} - '@types/uuid@11.0.0': - resolution: {integrity: sha512-HVyk8nj2m+jcFRNazzqyVKiZezyhDKrGUA3jlEcg/nZ6Ms+qHwocba1Y/AaVaznJTAM9xpdFSh+ptbNrhOGvZA==} - deprecated: This is a stub types definition. uuid provides its own type definitions, so you do not need this installed. - '@types/vscode@1.101.0': resolution: {integrity: sha512-ZWf0IWa+NGegdW3iU42AcDTFHWW7fApLdkdnBqwYEtHVIBGbTu0ZNQKP/kX3Ds/uMJXIMQNAojHR4vexCEEz5Q==} @@ -3626,6 +3665,9 @@ packages: buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + bun-types@1.3.3: + resolution: {integrity: sha512-z3Xwlg7j2l9JY27x5Qn3Wlyos8YAp0kKRlrePAOjgjMGS5IG6E7Jnlx736vH9UVI4wUICwwhC9anYL++XeOgTQ==} + bundle-name@4.1.0: resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} engines: {node: '>=18'} @@ -5160,6 +5202,12 @@ packages: knitwork@1.2.0: resolution: {integrity: sha512-xYSH7AvuQ6nXkq42x0v5S8/Iry+cfulBz/DJQzhIyESdLD7425jXsPy4vn5cCXU+HhRN2kVw51Vd1K6/By4BQg==} + kysely-bun-sqlite@0.4.0: + resolution: {integrity: sha512-2EkQE5sT4ewiw7IWfJsAkpxJ/QPVKXKO5sRYI/xjjJIJlECuOdtG+ssYM0twZJySrdrmuildNPFYVreyu1EdZg==} + engines: {bun: '>=1.1.31'} + peerDependencies: + kysely: ^0.28.2 + kysely@0.28.8: resolution: {integrity: sha512-QUOgl5ZrS9IRuhq5FvOKFSsD/3+IA6MLE81/bOOTRA/YQpKDza2sFdN5g6JCB9BOpqMJDGefLCQ9F12hRS13TA==} engines: {node: '>=20.0.0'} @@ -9551,7 +9599,7 @@ snapshots: '@types/connect@3.4.38': dependencies: - '@types/node': 20.17.24 + '@types/node': 20.19.24 '@types/cookie@0.6.0': {} @@ -9565,7 +9613,7 @@ snapshots: '@types/express-serve-static-core@5.1.0': dependencies: - '@types/node': 20.17.24 + '@types/node': 20.19.24 '@types/qs': 6.14.0 '@types/range-parser': 1.2.7 '@types/send': 1.2.0 @@ -9604,6 +9652,12 @@ snapshots: pg-protocol: 1.10.3 pg-types: 4.0.2 + '@types/pg@8.15.6': + dependencies: + '@types/node': 20.19.24 + pg-protocol: 1.10.3 + pg-types: 2.2.0 + '@types/pluralize@0.0.33': {} '@types/qs@6.14.0': {} @@ -9625,16 +9679,16 @@ snapshots: '@types/send@0.17.5': dependencies: '@types/mime': 1.3.5 - '@types/node': 20.17.24 + '@types/node': 20.19.24 '@types/send@1.2.0': dependencies: - '@types/node': 20.17.24 + '@types/node': 20.19.24 '@types/serve-static@1.15.9': dependencies: '@types/http-errors': 2.0.5 - '@types/node': 20.17.24 + '@types/node': 20.19.24 '@types/send': 0.17.5 '@types/sql.js@1.4.9': @@ -9646,7 +9700,7 @@ snapshots: dependencies: '@types/cookiejar': 2.1.5 '@types/methods': 1.1.4 - '@types/node': 20.17.24 + '@types/node': 20.19.24 form-data: 4.0.4 '@types/supertest@6.0.3': @@ -9658,10 +9712,6 @@ snapshots: '@types/toposort@2.0.7': {} - '@types/uuid@11.0.0': - dependencies: - uuid: 11.0.5 - '@types/vscode@1.101.0': {} '@types/whatwg-mimetype@3.0.2': {} @@ -10466,6 +10516,10 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + bun-types@1.3.3: + dependencies: + '@types/node': 20.19.24 + bundle-name@4.1.0: dependencies: run-applescript: 7.1.0 @@ -11175,7 +11229,7 @@ snapshots: eslint: 9.29.0(jiti@2.6.1) eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.29.0(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-react: 7.37.5(eslint@9.29.0(jiti@2.6.1)) eslint-plugin-react-hooks: 7.0.1(eslint@9.29.0(jiti@2.6.1)) @@ -11208,7 +11262,7 @@ snapshots: tinyglobby: 0.2.15 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.29.0(jiti@2.6.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)) transitivePeerDependencies: - supports-color @@ -11223,7 +11277,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.29.0(jiti@2.6.1)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.46.2(eslint@9.29.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)))(eslint@9.29.0(jiti@2.6.1)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 @@ -12247,6 +12301,11 @@ snapshots: knitwork@1.2.0: {} + kysely-bun-sqlite@0.4.0(kysely@0.28.8): + dependencies: + bun-types: 1.3.3 + kysely: 0.28.8 + kysely@0.28.8: {} langium-cli@3.5.0: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e5cc8997..7ed7bb0e 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,28 +2,29 @@ packages: - packages/** - samples/** - tests/** + catalog: + '@tanstack/react-query': 5.90.6 + '@types/better-sqlite3': ^7.6.13 + '@types/node': ^20.19.0 + '@types/react': 19.2.0 + '@types/react-dom': 19.2.0 + '@types/tmp': ^0.2.6 + better-sqlite3: ^12.2.0 + decimal.js: ^10.4.3 kysely: ~0.28.8 - zod: ^4.0.0 - prisma: ^6.19.0 langium: 3.5.0 langium-cli: 3.5.0 - ts-pattern: ^5.7.1 - typescript: ^5.9.3 - '@types/node': ^20.19.0 - tmp: ^0.2.3 - '@types/tmp': ^0.2.6 - 'zod-validation-error': ^4.0.1 - 'better-sqlite3': ^12.2.0 - '@types/better-sqlite3': ^7.6.13 - 'pg': ^8.13.1 - 'sql.js': ^1.13.0 - 'decimal.js': '^10.4.3' + next: 16.0.1 + pg: 8.16.3 + prisma: ^6.19.0 react: 19.2.0 - '@types/react': 19.2.0 react-dom: 19.2.0 - '@types/react-dom': 19.2.0 - '@tanstack/react-query': 5.90.6 - 'next': 16.0.1 - 'vue': 3.5.22 - 'svelte': 5.43.3 + sql.js: ^1.13.0 + svelte: 5.43.3 + tmp: ^0.2.3 + ts-pattern: ^5.7.1 + typescript: ^5.9.3 + vue: 3.5.22 + zod: ^4.0.0 + zod-validation-error: ^4.0.1 diff --git a/tests/bun/e2e.test.ts b/tests/bun/e2e.test.ts new file mode 100644 index 00000000..f4aebeb9 --- /dev/null +++ b/tests/bun/e2e.test.ts @@ -0,0 +1,111 @@ +import { clone } from '@zenstackhq/common-helpers'; +import { ZenStackClient } from '@zenstackhq/orm'; +import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres'; +import { PolicyPlugin } from '@zenstackhq/plugin-policy'; +import { TEST_PG_URL } from '@zenstackhq/testtools'; +import Database from 'bun:sqlite'; +import { describe, expect, it } from 'bun:test'; +import type { Dialect } from 'kysely'; +import { BunSqliteDialect } from 'kysely-bun-sqlite'; +import { Client, Pool } from 'pg'; +import { schema } from './schemas/schema'; + +describe.each([{ provider: 'sqlite' }, { provider: 'postgres' }])('Bun e2e tests $provider', ({ provider }) => { + it('works with simple CRUD', async () => { + const db = await createClient(provider, 'bun-e2e-crud'); + + const user = await db.user.create({ + data: { + id: '1', + email: 'u1@example.com', + name: 'Test User', + }, + }); + expect(user).toMatchObject({ + id: '1', + email: 'u1@example.com', + name: 'Test User', + }); + + let found = await db.user.findUnique({ + where: { id: '1' }, + }); + expect(found).toMatchObject(user); + + await db.user.update({ where: { id: '1' }, data: { name: 'Updated Name' } }); + found = await db.user.findFirst(); + expect(found).toMatchObject({ name: 'Updated Name' }); + + await db.user.delete({ where: { id: '1' } }); + const count = await db.user.count(); + expect(count).toBe(0); + }); + + it('enforces policies', async () => { + const db = await createClient(provider, 'bun-e2e-policies'); + const authDb = db.$use(new PolicyPlugin()); + + // create a user + await db.user.create({ + data: { + id: '1', + email: 'u1@example.com', + name: 'Test User', + posts: { + create: [ + { + id: 'p1', + title: 'First Post', + content: 'Hello World', + published: true, + }, + { + id: 'p2', + title: 'Second Post', + content: 'Draft Post', + published: false, + }, + ], + }, + }, + }); + + const anonCount = await authDb.post.count(); + expect(anonCount).toBe(0); + + const user1DbCount = await authDb.$setAuth({ id: '1' }).post.count(); + expect(user1DbCount).toBe(2); + + const user2DbCount = await authDb.$setAuth({ id: '2' }).post.count(); + expect(user2DbCount).toBe(1); + }); +}); + +async function createClient(provider: 'sqlite' | 'postgres', dbName?: string) { + const _schema = clone(schema); + let dialect: Dialect; + if (provider === 'sqlite') { + (_schema as any).provider.type = 'sqlite'; + dialect = new BunSqliteDialect({ + database: new Database(':memory:'), + }); + } else { + (_schema as any).provider.type = 'postgresql'; + const pgClient = new Client({ + connectionString: TEST_PG_URL, + }); + await pgClient.connect(); + await pgClient.query(`DROP DATABASE IF EXISTS "${dbName}"`); + await pgClient.query(`CREATE DATABASE "${dbName}"`); + await pgClient.end(); + dialect = new PostgresDialect({ + pool: new Pool({ + connectionString: `${TEST_PG_URL}/${dbName}`, + }), + }); + } + + const db = new ZenStackClient(_schema, { dialect }); + await db.$pushSchema(); + return db; +} diff --git a/tests/bun/package.json b/tests/bun/package.json new file mode 100644 index 00000000..0823fdca --- /dev/null +++ b/tests/bun/package.json @@ -0,0 +1,28 @@ +{ + "name": "bun-e2e", + "version": "3.0.0-beta.27", + "private": true, + "type": "module", + "scripts": { + "build": "pnpm test:generate && pnpm test:typecheck", + "test:generate": "tsx scripts/generate.ts", + "test:typecheck": "tsc --noEmit", + "test": "bun test" + }, + "dependencies": { + "@zenstackhq/cli": "workspace:*", + "@zenstackhq/orm": "workspace:*", + "@zenstackhq/plugin-policy": "workspace:*", + "@zenstackhq/common-helpers": "workspace:*", + "@zenstackhq/testtools": "workspace:*", + "kysely-bun-sqlite": "^0.4.0", + "pg": "catalog:", + "kysely": "catalog:" + }, + "devDependencies": { + "@types/pg": "^8.15.6", + "@zenstackhq/typescript-config": "workspace:*", + "@zenstackhq/vitest-config": "workspace:*", + "bun-types": "^1.3.3" + } +} diff --git a/tests/bun/schemas/input.ts b/tests/bun/schemas/input.ts new file mode 100644 index 00000000..fb776314 --- /dev/null +++ b/tests/bun/schemas/input.ts @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaType as $Schema } from "./schema"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; +import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; +export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; +export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; +export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">; +export type UserCreateArgs = $CreateArgs<$Schema, "User">; +export type UserCreateManyArgs = $CreateManyArgs<$Schema, "User">; +export type UserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "User">; +export type UserUpdateArgs = $UpdateArgs<$Schema, "User">; +export type UserUpdateManyArgs = $UpdateManyArgs<$Schema, "User">; +export type UserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "User">; +export type UserUpsertArgs = $UpsertArgs<$Schema, "User">; +export type UserDeleteArgs = $DeleteArgs<$Schema, "User">; +export type UserDeleteManyArgs = $DeleteManyArgs<$Schema, "User">; +export type UserCountArgs = $CountArgs<$Schema, "User">; +export type UserAggregateArgs = $AggregateArgs<$Schema, "User">; +export type UserGroupByArgs = $GroupByArgs<$Schema, "User">; +export type UserWhereInput = $WhereInput<$Schema, "User">; +export type UserSelect = $SelectInput<$Schema, "User">; +export type UserInclude = $IncludeInput<$Schema, "User">; +export type UserOmit = $OmitInput<$Schema, "User">; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; +export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">; +export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">; +export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">; +export type PostCreateArgs = $CreateArgs<$Schema, "Post">; +export type PostCreateManyArgs = $CreateManyArgs<$Schema, "Post">; +export type PostCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Post">; +export type PostUpdateArgs = $UpdateArgs<$Schema, "Post">; +export type PostUpdateManyArgs = $UpdateManyArgs<$Schema, "Post">; +export type PostUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Post">; +export type PostUpsertArgs = $UpsertArgs<$Schema, "Post">; +export type PostDeleteArgs = $DeleteArgs<$Schema, "Post">; +export type PostDeleteManyArgs = $DeleteManyArgs<$Schema, "Post">; +export type PostCountArgs = $CountArgs<$Schema, "Post">; +export type PostAggregateArgs = $AggregateArgs<$Schema, "Post">; +export type PostGroupByArgs = $GroupByArgs<$Schema, "Post">; +export type PostWhereInput = $WhereInput<$Schema, "Post">; +export type PostSelect = $SelectInput<$Schema, "Post">; +export type PostInclude = $IncludeInput<$Schema, "Post">; +export type PostOmit = $OmitInput<$Schema, "Post">; +export type PostGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Post", Options, Args>; diff --git a/tests/bun/schemas/models.ts b/tests/bun/schemas/models.ts new file mode 100644 index 00000000..b91301c9 --- /dev/null +++ b/tests/bun/schemas/models.ts @@ -0,0 +1,14 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { schema as $schema, type SchemaType as $Schema } from "./schema"; +import { type ModelResult as $ModelResult, type TypeDefResult as $TypeDefResult } from "@zenstackhq/orm"; +export type User = $ModelResult<$Schema, "User">; +export type Post = $ModelResult<$Schema, "Post">; +export type CommonFields = $TypeDefResult<$Schema, "CommonFields">; +export const Role = $schema.enums.Role.values; +export type Role = (typeof Role)[keyof typeof Role]; diff --git a/tests/bun/schemas/schema.ts b/tests/bun/schemas/schema.ts new file mode 100644 index 00000000..627922bc --- /dev/null +++ b/tests/bun/schemas/schema.ts @@ -0,0 +1,177 @@ +////////////////////////////////////////////////////////////////////////////////////////////// +// DO NOT MODIFY THIS FILE // +// This file is automatically generated by ZenStack CLI and should not be manually updated. // +////////////////////////////////////////////////////////////////////////////////////////////// + +/* eslint-disable */ + +import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema"; +const _schema = { + provider: { + type: "sqlite" + }, + models: { + User: { + name: "User", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }] + }, + email: { + name: "email", + type: "String", + unique: true, + attributes: [{ name: "@unique" }] + }, + name: { + name: "name", + type: "String", + optional: true + }, + role: { + name: "role", + type: "Role", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal("USER") }] }], + default: "USER" + }, + posts: { + name: "posts", + type: "Post", + array: true, + relation: { opposite: "author" } + }, + meta: { + name: "meta", + type: "Json", + optional: true + } + }, + attributes: [ + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]), "==", ExpressionUtils.field("id")) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "!=", ExpressionUtils._null()) }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" }, + email: { type: "String" } + } + }, + Post: { + name: "Post", + fields: { + id: { + name: "id", + type: "String", + id: true, + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }] + }, + title: { + name: "title", + type: "String" + }, + content: { + name: "content", + type: "String", + optional: true + }, + published: { + name: "published", + type: "Boolean", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.literal(false) }] }], + default: false + }, + author: { + name: "author", + type: "User", + attributes: [{ name: "@relation", args: [{ name: "fields", value: ExpressionUtils.array([ExpressionUtils.field("authorId")]) }, { name: "references", value: ExpressionUtils.array([ExpressionUtils.field("id")]) }, { name: "onUpdate", value: ExpressionUtils.literal("Cascade") }, { name: "onDelete", value: ExpressionUtils.literal("Cascade") }] }], + relation: { opposite: "posts", fields: ["authorId"], references: ["id"], onUpdate: "Cascade", onDelete: "Cascade" } + }, + authorId: { + name: "authorId", + type: "String", + foreignKeyFor: [ + "author" + ] + } + }, + attributes: [ + { name: "@@deny", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.call("auth"), "==", ExpressionUtils._null()) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("all") }, { name: "condition", value: ExpressionUtils.binary(ExpressionUtils.member(ExpressionUtils.call("auth"), ["id"]), "==", ExpressionUtils.field("authorId")) }] }, + { name: "@@allow", args: [{ name: "operation", value: ExpressionUtils.literal("read") }, { name: "condition", value: ExpressionUtils.field("published") }] } + ], + idFields: ["id"], + uniqueFields: { + id: { type: "String" } + } + } + }, + typeDefs: { + CommonFields: { + name: "CommonFields", + fields: { + id: { + name: "id", + type: "String", + attributes: [{ name: "@id" }, { name: "@default", args: [{ name: "value", value: ExpressionUtils.call("cuid") }] }], + default: ExpressionUtils.call("cuid") + }, + createdAt: { + name: "createdAt", + type: "DateTime", + attributes: [{ name: "@default", args: [{ name: "value", value: ExpressionUtils.call("now") }] }], + default: ExpressionUtils.call("now") + }, + updatedAt: { + name: "updatedAt", + type: "DateTime", + updatedAt: true, + attributes: [{ name: "@updatedAt" }] + } + } + } + }, + enums: { + Role: { + values: { + ADMIN: "ADMIN", + USER: "USER" + } + } + }, + authType: "User", + plugins: {} +} as const satisfies SchemaDef; +type Schema = typeof _schema & { + __brand?: "schema"; +}; +export const schema: Schema = _schema; +export type SchemaType = Schema; diff --git a/tests/bun/schemas/schema.zmodel b/tests/bun/schemas/schema.zmodel new file mode 100644 index 00000000..05f14bf4 --- /dev/null +++ b/tests/bun/schemas/schema.zmodel @@ -0,0 +1,46 @@ +datasource db { + provider = "sqlite" + url = "file:./dev.db" +} + +plugin policy { + provider = "../../../packages/plugins/policy" +} + +enum Role { + ADMIN + USER +} + +type CommonFields { + id String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model User with CommonFields { + email String @unique + name String? + password String @ignore + role Role @default(USER) + posts Post[] + meta Json? + + // Access policies + @@allow('all', auth().id == id) + @@allow('read', auth() != null) +} + +model Post with CommonFields { + title String + content String? + published Boolean @default(false) + author User @relation(fields: [authorId], references: [id], onUpdate: Cascade, onDelete: Cascade) + authorId String + + // Access policies + @@deny('all', auth() == null) + @@allow('all', auth().id == authorId) + @@allow('read', published) +} + diff --git a/tests/bun/scripts/generate.ts b/tests/bun/scripts/generate.ts new file mode 100644 index 00000000..09a2ac23 --- /dev/null +++ b/tests/bun/scripts/generate.ts @@ -0,0 +1,20 @@ +import { glob } from 'glob'; +import { execSync } from 'node:child_process'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const dir = path.dirname(fileURLToPath(import.meta.url)); + +async function main() { + const zmodelFiles = [...glob.sync(path.resolve(dir, '../schemas/*.zmodel'))]; + for (const file of zmodelFiles) { + console.log(`Generating TS schema for: ${file}`); + await generate(file); + } +} + +async function generate(schemaPath: string) { + execSync('bunx --bun zen generate', { cwd: path.dirname(schemaPath) }); +} + +main(); diff --git a/tests/bun/tsconfig.json b/tests/bun/tsconfig.json new file mode 100644 index 00000000..37dbe4e2 --- /dev/null +++ b/tests/bun/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@zenstackhq/typescript-config/base.json", + "compilerOptions": { + "noEmit": true, + "noImplicitAny": false, + "types": ["bun-types"] + } +} diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 38625d7c..2160f3f7 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -27,7 +27,6 @@ "uuid": "^11.0.5" }, "devDependencies": { - "@types/uuid": "^11.0.0", "@zenstackhq/cli": "workspace:*", "@zenstackhq/typescript-config": "workspace:*", "@zenstackhq/vitest-config": "workspace:*" diff --git a/tests/regression/package.json b/tests/regression/package.json index f4a4c8ff..b1de3381 100644 --- a/tests/regression/package.json +++ b/tests/regression/package.json @@ -17,6 +17,7 @@ "@zenstackhq/orm": "workspace:*", "@zenstackhq/sdk": "workspace:*", "@zenstackhq/typescript-config": "workspace:*", - "@zenstackhq/vitest-config": "workspace:*" + "@zenstackhq/vitest-config": "workspace:*", + "@types/node": "catalog:" } } diff --git a/tests/regression/test/issue-204/input.ts b/tests/regression/test/issue-204/input.ts index d39dc0e5..9564b7f2 100644 --- a/tests/regression/test/issue-204/input.ts +++ b/tests/regression/test/issue-204/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type FooFindManyArgs = $FindManyArgs<$Schema, "Foo">; export type FooFindUniqueArgs = $FindUniqueArgs<$Schema, "Foo">; @@ -27,4 +27,4 @@ export type FooWhereInput = $WhereInput<$Schema, "Foo">; export type FooSelect = $SelectInput<$Schema, "Foo">; export type FooInclude = $IncludeInput<$Schema, "Foo">; export type FooOmit = $OmitInput<$Schema, "Foo">; -export type FooGetPayload> = $SimplifiedModelResult<$Schema, "Foo", Args>; +export type FooGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Foo", Options, Args>; diff --git a/tests/regression/test/issue-422/input.ts b/tests/regression/test/issue-422/input.ts index 73b7ed9a..a931f068 100644 --- a/tests/regression/test/issue-422/input.ts +++ b/tests/regression/test/issue-422/input.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { type SchemaType as $Schema } from "./schema"; -import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm"; +import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput, ClientOptions as $ClientOptions } from "@zenstackhq/orm"; import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm"; export type SessionFindManyArgs = $FindManyArgs<$Schema, "Session">; export type SessionFindUniqueArgs = $FindUniqueArgs<$Schema, "Session">; @@ -27,7 +27,7 @@ export type SessionWhereInput = $WhereInput<$Schema, "Session">; export type SessionSelect = $SelectInput<$Schema, "Session">; export type SessionInclude = $IncludeInput<$Schema, "Session">; export type SessionOmit = $OmitInput<$Schema, "Session">; -export type SessionGetPayload> = $SimplifiedModelResult<$Schema, "Session", Args>; +export type SessionGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Session", Options, Args>; export type UserFindManyArgs = $FindManyArgs<$Schema, "User">; export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">; export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">; @@ -47,7 +47,7 @@ export type UserWhereInput = $WhereInput<$Schema, "User">; export type UserSelect = $SelectInput<$Schema, "User">; export type UserInclude = $IncludeInput<$Schema, "User">; export type UserOmit = $OmitInput<$Schema, "User">; -export type UserGetPayload> = $SimplifiedModelResult<$Schema, "User", Args>; +export type UserGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "User", Options, Args>; export type ProfileFindManyArgs = $FindManyArgs<$Schema, "Profile">; export type ProfileFindUniqueArgs = $FindUniqueArgs<$Schema, "Profile">; export type ProfileFindFirstArgs = $FindFirstArgs<$Schema, "Profile">; @@ -67,4 +67,4 @@ export type ProfileWhereInput = $WhereInput<$Schema, "Profile">; export type ProfileSelect = $SelectInput<$Schema, "Profile">; export type ProfileInclude = $IncludeInput<$Schema, "Profile">; export type ProfileOmit = $OmitInput<$Schema, "Profile">; -export type ProfileGetPayload> = $SimplifiedModelResult<$Schema, "Profile", Args>; +export type ProfileGetPayload, Options extends $ClientOptions<$Schema> = $ClientOptions<$Schema>> = $SimplifiedModelResult<$Schema, "Profile", Options, Args>; diff --git a/tests/regression/tsconfig.json b/tests/regression/tsconfig.json index e0b83aa8..1dd80744 100644 --- a/tests/regression/tsconfig.json +++ b/tests/regression/tsconfig.json @@ -2,7 +2,7 @@ "extends": "@zenstackhq/typescript-config/base.json", "compilerOptions": { "noEmit": true, - "types": ["@zenstackhq/testtools/types"] + "types": ["@zenstackhq/testtools/types", "node"] }, "include": ["src/**/*.ts", "test/**/*.ts"] } diff --git a/turbo.json b/turbo.json index ab312f31..c6631358 100644 --- a/turbo.json +++ b/turbo.json @@ -15,7 +15,9 @@ "dependsOn": ["^lint"] }, "test": { - "dependsOn": ["build"] + "dependsOn": ["build"], + "cache": false } - } + }, + "globalPassThroughEnv": ["TEST_DB_PROVIDER"] } From f6f1c5cbcbd8470b1613968bc58e27d0125cffa6 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Mon, 1 Dec 2025 21:14:08 +0800 Subject: [PATCH 2/5] update CI --- .github/workflows/build-test.yml | 5 +++++ tests/bun/e2e.test.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f9f1eb9a..ab0662d4 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -51,6 +51,11 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'pnpm' + - name: Use Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Get pnpm store directory id: pnpm-cache shell: bash diff --git a/tests/bun/e2e.test.ts b/tests/bun/e2e.test.ts index f4aebeb9..9bb8e260 100644 --- a/tests/bun/e2e.test.ts +++ b/tests/bun/e2e.test.ts @@ -10,7 +10,9 @@ import { BunSqliteDialect } from 'kysely-bun-sqlite'; import { Client, Pool } from 'pg'; import { schema } from './schemas/schema'; -describe.each([{ provider: 'sqlite' }, { provider: 'postgres' }])('Bun e2e tests $provider', ({ provider }) => { +describe('Bun e2e tests', () => { + const provider = (process.env['TEST_DB_PROVIDER'] ?? 'sqlite') as 'sqlite' | 'postgresql'; + it('works with simple CRUD', async () => { const db = await createClient(provider, 'bun-e2e-crud'); @@ -81,7 +83,7 @@ describe.each([{ provider: 'sqlite' }, { provider: 'postgres' }])('Bun e2e tests }); }); -async function createClient(provider: 'sqlite' | 'postgres', dbName?: string) { +async function createClient(provider: 'sqlite' | 'postgresql', dbName?: string) { const _schema = clone(schema); let dialect: Dialect; if (provider === 'sqlite') { From 5ec276b97a1bc7814f3314048528beead0ba3c42 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Mon, 1 Dec 2025 21:16:56 +0800 Subject: [PATCH 3/5] update --- pnpm-lock.yaml | 2 +- pnpm-workspace.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba4c48c6..72419059 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,7 +43,7 @@ catalogs: specifier: 16.0.1 version: 16.0.1 pg: - specifier: 8.16.3 + specifier: ^8.13.1 version: 8.16.3 prisma: specifier: ^6.19.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 7ed7bb0e..b165d0c3 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -16,7 +16,7 @@ catalog: langium: 3.5.0 langium-cli: 3.5.0 next: 16.0.1 - pg: 8.16.3 + pg: ^8.13.1 prisma: ^6.19.0 react: 19.2.0 react-dom: 19.2.0 From 50a03b5359461dc6fbaa0f3bc937b1336ff1a7d5 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Mon, 1 Dec 2025 21:18:37 +0800 Subject: [PATCH 4/5] update --- pnpm-lock.yaml | 3 --- tests/bun/e2e.test.ts | 2 +- tests/bun/package.json | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 72419059..c5365a5d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -837,9 +837,6 @@ importers: '@zenstackhq/typescript-config': specifier: workspace:* version: link:../../packages/config/typescript-config - '@zenstackhq/vitest-config': - specifier: workspace:* - version: link:../../packages/config/vitest-config bun-types: specifier: ^1.3.3 version: 1.3.3 diff --git a/tests/bun/e2e.test.ts b/tests/bun/e2e.test.ts index 9bb8e260..b2aedbb9 100644 --- a/tests/bun/e2e.test.ts +++ b/tests/bun/e2e.test.ts @@ -83,7 +83,7 @@ describe('Bun e2e tests', () => { }); }); -async function createClient(provider: 'sqlite' | 'postgresql', dbName?: string) { +async function createClient(provider: 'sqlite' | 'postgresql', dbName: string) { const _schema = clone(schema); let dialect: Dialect; if (provider === 'sqlite') { diff --git a/tests/bun/package.json b/tests/bun/package.json index 0823fdca..a5a29b3d 100644 --- a/tests/bun/package.json +++ b/tests/bun/package.json @@ -22,7 +22,6 @@ "devDependencies": { "@types/pg": "^8.15.6", "@zenstackhq/typescript-config": "workspace:*", - "@zenstackhq/vitest-config": "workspace:*", "bun-types": "^1.3.3" } } From 6e1589eed5776fa530cdf72b8079c6c0f1548afd Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Mon, 1 Dec 2025 21:31:52 +0800 Subject: [PATCH 5/5] update --- tests/bun/e2e.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bun/e2e.test.ts b/tests/bun/e2e.test.ts index b2aedbb9..bfc60494 100644 --- a/tests/bun/e2e.test.ts +++ b/tests/bun/e2e.test.ts @@ -3,7 +3,7 @@ import { ZenStackClient } from '@zenstackhq/orm'; import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres'; import { PolicyPlugin } from '@zenstackhq/plugin-policy'; import { TEST_PG_URL } from '@zenstackhq/testtools'; -import Database from 'bun:sqlite'; +import { Database } from 'bun:sqlite'; import { describe, expect, it } from 'bun:test'; import type { Dialect } from 'kysely'; import { BunSqliteDialect } from 'kysely-bun-sqlite';