Skip to content
Merged
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
3 changes: 2 additions & 1 deletion packages/auth-adapters/better-auth/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"rootDir": ".",
"noPropertyAccessFromIndexSignature": false
"noPropertyAccessFromIndexSignature": false,
"types": ["node"]
},
"include": ["src/**/*"]
}
6 changes: 3 additions & 3 deletions packages/cli/src/actions/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ZenStackClient, type ClientContract } from '@zenstackhq/orm';
import { MysqlDialect } from '@zenstackhq/orm/dialects/mysql';
import { PostgresDialect } from '@zenstackhq/orm/dialects/postgres';
import { SqliteDialect } from '@zenstackhq/orm/dialects/sqlite';
import type { SchemaDef } from '@zenstackhq/orm/schema';
import { RPCApiHandler } from '@zenstackhq/server/api';
import { ZenStackMiddleware } from '@zenstackhq/server/express';
import type BetterSqlite3 from 'better-sqlite3';
Expand All @@ -24,7 +25,6 @@ import type { Pool as PgPoolType } from 'pg';
import { CliError } from '../cli-error';
import { getVersion } from '../utils/version-utils';
import { getOutputPath, getSchemaFile, loadSchemaDocument } from './action-utils';
import type { SchemaDef } from '@zenstackhq/orm/schema';

type Options = {
output?: string;
Expand Down Expand Up @@ -198,7 +198,7 @@ async function createDialect(provider: string, databaseUrl: string, outputPath:
}
}

export function createProxyApp(client: ClientContract<any, any>, schema: any): express.Application {
export function createProxyApp(client: ClientContract<SchemaDef>, schema: SchemaDef): express.Application {
const app = express();
app.use(cors());
app.use(express.json({ limit: '5mb' }));
Expand All @@ -219,7 +219,7 @@ export function createProxyApp(client: ClientContract<any, any>, schema: any): e
return app;
}

function startServer(client: ClientContract<any, any>, schema: any, options: Options) {
function startServer(client: ClientContract<SchemaDef>, schema: any, options: Options) {
const app = createProxyApp(client, schema);

const server = app.listen(options.port, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/plugins/custom-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { createProject, runCli } from '../utils';
import { execSync } from 'node:child_process';

describe('Custom plugins tests', () => {
it('runs custom plugin generator', async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createConfig } from '@zenstackhq/tsdown-config';

export default createConfig({ entry: { index: 'src/index.ts' } });
export default createConfig({
entry: { index: 'src/index.ts' },
});
16 changes: 9 additions & 7 deletions packages/orm/src/client/crud-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,20 +808,22 @@ export type TypedJsonFilter<
Array extends boolean,
Optional extends boolean,
AllowedKinds extends FilterKind,
> = XOR<JsonFilter<AllowedKinds>, TypedJsonTypedFilter<Schema, TypeDefName, Array, Optional, AllowedKinds>>;
> =
| (JsonFilter<AllowedKinds> & { [Key in GetTypeDefFields<Schema, TypeDefName>]?: never })
| (TypedJsonTypedFilter<Schema, TypeDefName, Array, AllowedKinds> & {
[Key in keyof JsonFilter<AllowedKinds>]?: never;
})
| (Optional extends true ? null | JsonNullValues : never);
Comment thread
ymc9 marked this conversation as resolved.

type TypedJsonTypedFilter<
Schema extends SchemaDef,
TypeDefName extends GetTypeDefs<Schema>,
Array extends boolean,
Optional extends boolean,
AllowedKinds extends FilterKind,
> = 'Json' extends AllowedKinds
?
| (Array extends true
? ArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds>
: NonArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds>)
| (Optional extends true ? null | JsonNullValues : never)
? Array extends true
? ArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds>
: NonArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds>
: {};

type ArrayTypedJsonFilter<
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/src/client/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export interface RuntimePlugin<
result?: ExtResult;
}

export type AnyPlugin = RuntimePlugin<any, any, any, any>;
export type AnyPlugin = RuntimePlugin<SchemaDef, any, any, any>;

/**
* Defines a ZenStack runtime plugin based on type of the given schema.
Expand Down
4 changes: 2 additions & 2 deletions packages/orm/src/client/zod/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
} from '../crud/operations/base';
import { createInternalError } from '../errors';
import type { ClientOptions, QueryOptions } from '../options';
import type { AnyPlugin, ExtQueryArgsBase, RuntimePlugin } from '../plugin';
import type { AnyPlugin, ExtQueryArgsBase } from '../plugin';
import {
fieldHasDefaultValue,
getEnum,
Expand Down Expand Up @@ -121,7 +121,7 @@ export class ZodSchemaFactory<
}
}

private get plugins(): RuntimePlugin<Schema, any, any, any>[] {
private get plugins(): AnyPlugin[] {
return this.options.plugins ?? [];
}

Expand Down
1 change: 1 addition & 0 deletions packages/testtools/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function createTestProject(zmodelContent?: string) {
esModuleInterop: true,
skipLibCheck: true,
strict: true,
types: ['node'],
},
include: ['**/*.ts'],
},
Expand Down
Loading
Loading