diff --git a/.github/workflows/update-samples.yml b/.github/workflows/update-samples.yml new file mode 100644 index 000000000..4fd474843 --- /dev/null +++ b/.github/workflows/update-samples.yml @@ -0,0 +1,27 @@ +name: Update Samples + +on: + release: + types: [published] + +jobs: + dispatch: + runs-on: ubuntu-latest + + strategy: + matrix: + repo: + [ + 'zenstackhq/sample-todo-nextjs', + 'zenstackhq/sample-todo-nextjs-tanstack', + 'zenstackhq/sample-todo-trpc', + 'zenstackhq/sample-todo-sveltekit', + ] + + steps: + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v3.0.0 + with: + token: ${{ secrets.RELEASE_TRIGGER_TOKEN }} + repository: ${{ matrix.repo }} + event-type: zenstack-release diff --git a/package.json b/package.json index 0bb55596e..686c94f72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-monorepo", - "version": "1.11.1", + "version": "1.12.0", "description": "", "scripts": { "build": "pnpm -r build", diff --git a/packages/ide/jetbrains/build.gradle.kts b/packages/ide/jetbrains/build.gradle.kts index ea192ff0b..a24b3cb4a 100644 --- a/packages/ide/jetbrains/build.gradle.kts +++ b/packages/ide/jetbrains/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "dev.zenstack" -version = "1.11.1" +version = "1.12.0" repositories { mavenCentral() diff --git a/packages/ide/jetbrains/package.json b/packages/ide/jetbrains/package.json index 564af0351..bca28240f 100644 --- a/packages/ide/jetbrains/package.json +++ b/packages/ide/jetbrains/package.json @@ -1,6 +1,6 @@ { "name": "jetbrains", - "version": "1.11.1", + "version": "1.12.0", "displayName": "ZenStack JetBrains IDE Plugin", "description": "ZenStack JetBrains IDE plugin", "homepage": "https://zenstack.dev", diff --git a/packages/language/package.json b/packages/language/package.json index 7e8fa9fdc..b26a5badd 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/language", - "version": "1.11.1", + "version": "1.12.0", "displayName": "ZenStack modeling language compiler", "description": "ZenStack modeling language compiler", "homepage": "https://zenstack.dev", diff --git a/packages/misc/redwood/package.json b/packages/misc/redwood/package.json index 33d41a01c..64126d931 100644 --- a/packages/misc/redwood/package.json +++ b/packages/misc/redwood/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/redwood", "displayName": "ZenStack RedwoodJS Integration", - "version": "1.11.1", + "version": "1.12.0", "description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.", "repository": { "type": "git", diff --git a/packages/plugins/openapi/package.json b/packages/plugins/openapi/package.json index 38c85462b..67717aeca 100644 --- a/packages/plugins/openapi/package.json +++ b/packages/plugins/openapi/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/openapi", "displayName": "ZenStack Plugin and Runtime for OpenAPI", - "version": "1.11.1", + "version": "1.12.0", "description": "ZenStack plugin and runtime supporting OpenAPI", "main": "index.js", "repository": { diff --git a/packages/plugins/openapi/tests/openapi-restful.test.ts b/packages/plugins/openapi/tests/openapi-restful.test.ts index 9e84ad047..9997dd540 100644 --- a/packages/plugins/openapi/tests/openapi-restful.test.ts +++ b/packages/plugins/openapi/tests/openapi-restful.test.ts @@ -11,6 +11,8 @@ import * as tmp from 'tmp'; import YAML from 'yaml'; import generate from '../src'; +tmp.setGracefulCleanup(); + describe('Open API Plugin RESTful Tests', () => { it('run plugin', async () => { for (const specVersion of ['3.0.0', '3.1.0']) { diff --git a/packages/plugins/openapi/tests/openapi-rpc.test.ts b/packages/plugins/openapi/tests/openapi-rpc.test.ts index 8e8e3a6ac..6873ab5ce 100644 --- a/packages/plugins/openapi/tests/openapi-rpc.test.ts +++ b/packages/plugins/openapi/tests/openapi-rpc.test.ts @@ -11,6 +11,8 @@ import * as tmp from 'tmp'; import YAML from 'yaml'; import generate from '../src'; +tmp.setGracefulCleanup(); + describe('Open API Plugin RPC Tests', () => { it('run plugin', async () => { for (const specVersion of ['3.0.0', '3.1.0']) { diff --git a/packages/plugins/swr/package.json b/packages/plugins/swr/package.json index 9266a6a36..4612e4040 100644 --- a/packages/plugins/swr/package.json +++ b/packages/plugins/swr/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/swr", "displayName": "ZenStack plugin for generating SWR hooks", - "version": "1.11.1", + "version": "1.12.0", "description": "ZenStack plugin for generating SWR hooks", "main": "index.js", "repository": { diff --git a/packages/plugins/tanstack-query/package.json b/packages/plugins/tanstack-query/package.json index 51871526a..de3a02ce7 100644 --- a/packages/plugins/tanstack-query/package.json +++ b/packages/plugins/tanstack-query/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/tanstack-query", "displayName": "ZenStack plugin for generating tanstack-query hooks", - "version": "1.11.1", + "version": "1.12.0", "description": "ZenStack plugin for generating tanstack-query hooks", "main": "index.js", "exports": { diff --git a/packages/plugins/tanstack-query/src/generator.ts b/packages/plugins/tanstack-query/src/generator.ts index 3dd040f71..89a14ca05 100644 --- a/packages/plugins/tanstack-query/src/generator.ts +++ b/packages/plugins/tanstack-query/src/generator.ts @@ -98,7 +98,7 @@ function generateQueryHook( const capOperation = upperCaseFirst(operation); const argsType = overrideInputType ?? `Prisma.${model}${capOperation}Args`; - const inputType = `Prisma.SelectSubset`; + const inputType = makeQueryArgsType(target, argsType); const infinite = generateMode.includes('Infinite'); const suspense = generateMode.includes('Suspense'); @@ -589,6 +589,7 @@ function makeBaseImports(target: TargetFramework, version: TanStackVersion) { return [ `import type { UseMutationOptions, UseQueryOptions, UseInfiniteQueryOptions, InfiniteData } from '@tanstack/vue-query';`, `import { getHooksContext } from '${runtimeImportBase}/${target}';`, + `import type { MaybeRefOrGetter, ComputedRef } from 'vue';`, ...shared, ]; } @@ -608,6 +609,15 @@ function makeBaseImports(target: TargetFramework, version: TanStackVersion) { } } +function makeQueryArgsType(target: string, argsType: string) { + const type = `Prisma.SelectSubset`; + if (target === 'vue') { + return `MaybeRefOrGetter<${type}> | ComputedRef<${type}>`; + } else { + return type; + } +} + function makeQueryOptions( target: string, returnType: string, @@ -625,8 +635,12 @@ function makeQueryOptions( suspense ? 'Suspense' : '' }InfiniteQueryOptions<${returnType}, TError, InfiniteData<${dataType}>>, 'queryKey'>` : `Omit, 'queryKey'>`; - case 'vue': - return `Omit, 'queryKey'>`; + case 'vue': { + const baseOption = `Omit, 'queryKey'>`; + return `MaybeRefOrGetter<${baseOption}> | ComputedRef<${baseOption}>`; + } case 'svelte': return infinite ? version === 'v4' @@ -644,8 +658,10 @@ function makeMutationOptions(target: string, returnType: string, argsType: strin switch (target) { case 'react': return `UseMutationOptions<${returnType}, DefaultError, ${argsType}>`; - case 'vue': - return `UseMutationOptions<${returnType}, DefaultError, ${argsType}, unknown>`; + case 'vue': { + const baseOption = `UseMutationOptions<${returnType}, DefaultError, ${argsType}, unknown>`; + return `MaybeRefOrGetter<${baseOption}> | ComputedRef<${baseOption}>`; + } case 'svelte': return `MutationOptions<${returnType}, DefaultError, ${argsType}>`; default: diff --git a/packages/plugins/tanstack-query/src/runtime/vue.ts b/packages/plugins/tanstack-query/src/runtime/vue.ts index 049b66907..4bd3ebf4b 100644 --- a/packages/plugins/tanstack-query/src/runtime/vue.ts +++ b/packages/plugins/tanstack-query/src/runtime/vue.ts @@ -5,12 +5,13 @@ import { useMutation, useQuery, useQueryClient, + type QueryKey, type UseInfiniteQueryOptions, type UseMutationOptions, type UseQueryOptions, } from '@tanstack/vue-query'; import type { ModelMeta } from '@zenstackhq/runtime/cross'; -import { inject, provide } from 'vue'; +import { computed, inject, provide, toValue, type ComputedRef, type MaybeRefOrGetter } from 'vue'; import { APIContext, DEFAULT_QUERY_ENDPOINT, @@ -60,17 +61,25 @@ export function getHooksContext() { export function useModelQuery( model: string, url: string, - args?: unknown, - options?: Omit, 'queryKey'>, + args?: MaybeRefOrGetter | ComputedRef, + options?: + | MaybeRefOrGetter, 'queryKey'>> + | ComputedRef, 'queryKey'>>, fetch?: FetchFn, optimisticUpdate = false ) { - const reqUrl = makeUrl(url, args); - return useQuery({ - queryKey: getQueryKey(model, url, args, false, optimisticUpdate), - queryFn: () => fetcher(reqUrl, undefined, fetch, false), - ...options, + const queryOptions = computed(() => { + return { + queryKey: getQueryKey(model, url, toValue(args), false, optimisticUpdate), + queryFn: ({ queryKey }: { queryKey: QueryKey }) => { + const [_prefix, _model, _op, args] = queryKey; + const reqUrl = makeUrl(url, toValue(args)); + return fetcher(reqUrl, undefined, fetch, false); + }, + ...toValue(options), + }; }); + return useQuery(queryOptions); } /** @@ -86,17 +95,24 @@ export function useModelQuery( export function useInfiniteModelQuery( model: string, url: string, - args?: unknown, - options?: Omit, 'queryKey'>, + args?: MaybeRefOrGetter | ComputedRef, + options?: + | MaybeRefOrGetter, 'queryKey'>> + | ComputedRef, 'queryKey'>>, fetch?: FetchFn ) { - return useInfiniteQuery({ - queryKey: getQueryKey(model, url, args, true), - queryFn: ({ pageParam }) => { - return fetcher(makeUrl(url, pageParam ?? args), undefined, fetch, false); + // CHECKME: vue-query's `useInfiniteQuery`'s input typing seems wrong + const queryOptions: any = computed(() => ({ + queryKey: getQueryKey(model, url, toValue(args), true), + queryFn: ({ queryKey, pageParam }: { queryKey: QueryKey; pageParam?: unknown }) => { + const [_prefix, _model, _op, args] = queryKey; + const reqUrl = makeUrl(url, pageParam ?? toValue(args)); + return fetcher(reqUrl, undefined, fetch, false); }, - ...options, - }); + ...toValue(options), + })); + + return useInfiniteQuery(queryOptions); } /** @@ -124,7 +140,9 @@ export function useModelMutation< method: 'POST' | 'PUT' | 'DELETE', url: string, modelMeta: ModelMeta, - options?: Omit, 'mutationFn'>, + options?: + | MaybeRefOrGetter, 'mutationFn'>> + | ComputedRef, 'mutationFn'>>, fetch?: FetchFn, invalidateQueries = true, checkReadBack?: C, @@ -146,7 +164,7 @@ export function useModelMutation< }; // TODO: figure out the typing problem - const finalOptions: any = { ...options, mutationFn }; + const finalOptions: any = computed(() => ({ ...toValue(options), mutationFn })); const operation = url.split('/').pop(); if (operation) { const { logging } = getHooksContext(); @@ -155,7 +173,7 @@ export function useModelMutation< model, operation, modelMeta, - finalOptions, + toValue(finalOptions), (predicate) => queryClient.invalidateQueries({ predicate }), logging ); @@ -166,7 +184,7 @@ export function useModelMutation< model, operation, modelMeta, - finalOptions, + toValue(finalOptions), queryClient.getQueryCache().getAll(), (queryKey, data) => queryClient.setQueryData(queryKey, data), invalidateQueries ? (predicate) => queryClient.invalidateQueries({ predicate }) : undefined, diff --git a/packages/plugins/trpc/package.json b/packages/plugins/trpc/package.json index e9fddc330..51c93d85b 100644 --- a/packages/plugins/trpc/package.json +++ b/packages/plugins/trpc/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/trpc", "displayName": "ZenStack plugin for tRPC", - "version": "1.11.1", + "version": "1.12.0", "description": "ZenStack plugin for tRPC", "main": "index.js", "repository": { diff --git a/packages/plugins/trpc/src/helpers.ts b/packages/plugins/trpc/src/helpers.ts index 54aec3ecb..fba27ed84 100644 --- a/packages/plugins/trpc/src/helpers.ts +++ b/packages/plugins/trpc/src/helpers.ts @@ -238,7 +238,7 @@ export function generateRouterTypingImports(sourceFile: SourceFile, model: Model // eslint-disable-next-line @typescript-eslint/no-unused-vars export function generateRouterSchemaImport(sourceFile: SourceFile, zodSchemasImport: string) { - sourceFile.addStatements(`import $Schema from '${zodSchemasImport}/input';`); + sourceFile.addStatements(`import * as $Schema from '${zodSchemasImport}/input';`); } export function generateHelperImport(sourceFile: SourceFile) { diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts index e7fa40292..6827584d1 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { type RouterFactory, type ProcBuilder, type BaseConfig, db } from '.'; -import $Schema from '@zenstackhq/runtime/zod/input'; +import * as $Schema from '@zenstackhq/runtime/zod/input'; import { checkRead, checkMutate } from '../helper'; import type { Prisma } from '@prisma/client'; import type { diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts index 15bd74328..06ce01f31 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { type RouterFactory, type ProcBuilder, type BaseConfig, db } from '.'; -import $Schema from '@zenstackhq/runtime/zod/input'; +import * as $Schema from '@zenstackhq/runtime/zod/input'; import { checkRead, checkMutate } from '../helper'; import type { Prisma } from '@prisma/client'; import type { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 8d582796e..24d24178c 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/runtime", "displayName": "ZenStack Runtime Library", - "version": "1.11.1", + "version": "1.12.0", "description": "Runtime of ZenStack for both client-side and server-side environments.", "repository": { "type": "git", diff --git a/packages/schema/package.json b/packages/schema/package.json index 25ebd253b..b7d284889 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack Language Tools", "description": "Build scalable web apps with minimum code by defining authorization and validation rules inside the data schema that closer to the database", - "version": "1.11.1", + "version": "1.12.0", "author": { "name": "ZenStack Team" }, diff --git a/packages/schema/tests/generator/expression-writer.test.ts b/packages/schema/tests/generator/expression-writer.test.ts index 7121c9589..13f69fd89 100644 --- a/packages/schema/tests/generator/expression-writer.test.ts +++ b/packages/schema/tests/generator/expression-writer.test.ts @@ -6,6 +6,8 @@ import { Project, VariableDeclarationKind } from 'ts-morph'; import { ExpressionWriter } from '../../src/plugins/access-policy/expression-writer'; import { loadModel } from '../utils'; +tmp.setGracefulCleanup(); + describe('Expression Writer Tests', () => { it('boolean literal', async () => { await check( diff --git a/packages/schema/tests/generator/prisma-generator.test.ts b/packages/schema/tests/generator/prisma-generator.test.ts index 30a477026..0e8987703 100644 --- a/packages/schema/tests/generator/prisma-generator.test.ts +++ b/packages/schema/tests/generator/prisma-generator.test.ts @@ -8,6 +8,8 @@ import { loadDocument } from '../../src/cli/cli-util'; import PrismaSchemaGenerator from '../../src/plugins/prisma/schema-generator'; import { loadModel } from '../utils'; +tmp.setGracefulCleanup(); + describe('Prisma generator test', () => { it('datasource coverage', async () => { const model = await loadModel(` diff --git a/packages/schema/tests/utils.ts b/packages/schema/tests/utils.ts index 7369838f5..2746a3362 100644 --- a/packages/schema/tests/utils.ts +++ b/packages/schema/tests/utils.ts @@ -7,21 +7,25 @@ import { URI } from 'vscode-uri'; import { createZModelServices } from '../src/language-server/zmodel-module'; import { mergeBaseModel } from '../src/utils/ast-utils'; +tmp.setGracefulCleanup(); + type Errorish = Error | { message: string; stack?: string } | string; export class SchemaLoadingError extends Error { - cause: Errors + cause: Errors; constructor(public readonly errors: Errors) { - const stack = errors.find((e): e is typeof e & { stack: string } => typeof e === 'object' && 'stack' in e)?.stack; + const stack = errors.find( + (e): e is typeof e & { stack: string } => typeof e === 'object' && 'stack' in e + )?.stack; const message = errors.map((e) => (typeof e === 'string' ? e : e.message)).join('\n'); - super(`Schema error:\n${ message }`); + super(`Schema error:\n${message}`); if (stack) { const shiftedStack = stack.split('\n').slice(1).join('\n'); - this.stack = shiftedStack + this.stack = shiftedStack; } - this.cause = errors + this.cause = errors; } } @@ -83,13 +87,13 @@ export async function loadModelWithError(content: string, verbose = false) { } export async function safelyLoadModel(content: string, validate = true, verbose = false) { - const [ result ] = await Promise.allSettled([ loadModel(content, validate, verbose) ]); + const [result] = await Promise.allSettled([loadModel(content, validate, verbose)]); - return result + return result; } export const errorLike = (msg: string) => ({ reason: { - message: expect.stringContaining(msg) + message: expect.stringContaining(msg), }, -}) +}); diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5e3707444..992604f8a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "1.11.1", + "version": "1.12.0", "description": "ZenStack plugin development SDK", "main": "index.js", "scripts": { diff --git a/packages/server/package.json b/packages/server/package.json index 699933197..13891e920 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "1.11.1", + "version": "1.12.0", "displayName": "ZenStack Server-side Adapters", "description": "ZenStack server-side adapters", "homepage": "https://zenstack.dev", diff --git a/packages/testtools/package.json b/packages/testtools/package.json index 8e68dabc0..1acb82f59 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "1.11.1", + "version": "1.12.0", "description": "ZenStack Test Tools", "main": "index.js", "private": true, diff --git a/packages/testtools/src/model.ts b/packages/testtools/src/model.ts index 4be8a1613..310a2c019 100644 --- a/packages/testtools/src/model.ts +++ b/packages/testtools/src/model.ts @@ -7,6 +7,8 @@ import { URI } from 'vscode-uri'; import { createZModelServices } from 'zenstack/language-server/zmodel-module'; import { mergeBaseModel } from 'zenstack/utils/ast-utils'; +tmp.setGracefulCleanup(); + export class SchemaLoadingError extends Error { constructor(public readonly errors: string[]) { super('Schema error:\n' + errors.join('\n')); diff --git a/packages/testtools/src/schema.ts b/packages/testtools/src/schema.ts index 5fef95299..a6885237f 100644 --- a/packages/testtools/src/schema.ts +++ b/packages/testtools/src/schema.ts @@ -24,6 +24,8 @@ import prismaPlugin from 'zenstack/plugins/prisma'; */ export const FILE_SPLITTER = '#FILE_SPLITTER#'; +tmp.setGracefulCleanup(); + export type FullDbClientContract = Record & { $on(eventType: any, callback: (event: any) => void): void; $use(cb: any): void; diff --git a/tests/integration/tests/cli/config.test.ts b/tests/integration/tests/cli/config.test.ts index f047889fd..096e86ca3 100644 --- a/tests/integration/tests/cli/config.test.ts +++ b/tests/integration/tests/cli/config.test.ts @@ -5,6 +5,8 @@ import * as fs from 'fs'; import * as tmp from 'tmp'; import { createProgram } from '../../../../packages/schema/src/cli'; +tmp.setGracefulCleanup(); + describe('CLI Config Tests', () => { let origDir: string; diff --git a/tests/integration/tests/cli/format.test.ts b/tests/integration/tests/cli/format.test.ts index 781d6c917..9d7b2a52b 100644 --- a/tests/integration/tests/cli/format.test.ts +++ b/tests/integration/tests/cli/format.test.ts @@ -1,6 +1,9 @@ import * as fs from 'fs'; import * as tmp from 'tmp'; import { createProgram } from '../../../../packages/schema/src/cli'; + +tmp.setGracefulCleanup(); + describe('CLI format test', () => { let origDir: string; diff --git a/tests/integration/tests/cli/generate.test.ts b/tests/integration/tests/cli/generate.test.ts index 90f9e2311..5dd8ddf1c 100644 --- a/tests/integration/tests/cli/generate.test.ts +++ b/tests/integration/tests/cli/generate.test.ts @@ -8,6 +8,8 @@ import * as tmp from 'tmp'; import { createProgram } from '../../../../packages/schema/src/cli'; import { createNpmrc } from './share'; +tmp.setGracefulCleanup(); + describe('CLI generate command tests', () => { let origDir: string; const MODEL = ` diff --git a/tests/integration/tests/cli/init.test.ts b/tests/integration/tests/cli/init.test.ts index ab6fcc747..0f9f69894 100644 --- a/tests/integration/tests/cli/init.test.ts +++ b/tests/integration/tests/cli/init.test.ts @@ -9,6 +9,8 @@ import { createProgram } from '../../../../packages/schema/src/cli'; import { execSync } from '../../../../packages/schema/src/utils/exec-utils'; import { createNpmrc } from './share'; +tmp.setGracefulCleanup(); + // Skipping these tests as they seem to cause hangs intermittently when running with other tests // eslint-disable-next-line jest/no-disabled-tests describe.skip('CLI init command tests', () => { diff --git a/tests/integration/tests/cli/plugins.test.ts b/tests/integration/tests/cli/plugins.test.ts index 6efb3bad4..5a8e44ae7 100644 --- a/tests/integration/tests/cli/plugins.test.ts +++ b/tests/integration/tests/cli/plugins.test.ts @@ -7,6 +7,8 @@ import * as path from 'path'; import * as tmp from 'tmp'; import { createProgram } from '../../../../packages/schema/src/cli'; +tmp.setGracefulCleanup(); + describe('CLI Plugins Tests', () => { let origDir: string; diff --git a/tests/integration/tests/plugins/prisma.test.ts b/tests/integration/tests/plugins/prisma.test.ts index 9e462f578..32d5a8e59 100644 --- a/tests/integration/tests/plugins/prisma.test.ts +++ b/tests/integration/tests/plugins/prisma.test.ts @@ -3,6 +3,8 @@ import fs from 'fs'; import path from 'path'; import tmp from 'tmp'; +tmp.setGracefulCleanup(); + describe('Prisma plugin tests', () => { let origDir: string; diff --git a/tests/integration/tests/regression/issue-1162.test.ts b/tests/integration/tests/regression/issue-1162.test.ts deleted file mode 100644 index fd7f0dded..000000000 --- a/tests/integration/tests/regression/issue-1162.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { loadSchema } from '@zenstackhq/testtools'; - -describe('issue 1162', () => { - it('regression', async () => { - const { enhance } = await loadSchema( - ` - model User { - id String @id @default(cuid()) - companies CompanyUser[] - @@allow('all', true) - } - - model Company { - id String @id @default(cuid()) - users CompanyUser[] - @@allow('all', true) - } - - model CompanyUser { - company Company @relation(fields: [companyId], references: [id], onDelete: Cascade) - companyId String - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - userId String - @@id([companyId, userId]) - @@allow('all', true) - } - `, - { logPrismaQuery: true } - ); - - const db = enhance(); - - await db.user.create({ data: { id: 'abc' } }); - await db.user.create({ data: { id: 'def' } }); - await db.company.create({ data: { id: '1', users: { create: { userId: 'abc' } } } }); - await expect( - db.company.update({ - where: { id: '1' }, - data: { - users: { - createMany: { - data: [{ userId: 'abc' }, { userId: 'def' }], - skipDuplicates: true, - }, - }, - }, - include: { users: true }, - }) - ).resolves.toMatchObject({ - users: expect.arrayContaining([ - { companyId: '1', userId: 'abc' }, - { companyId: '1', userId: 'def' }, - ]), - }); - }); -});