Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.
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
4 changes: 1 addition & 3 deletions packages/orm/src/client/crud-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ExpressionBuilder, OperandExpression, SqlBool } from 'kysely';
import type { DbNull, JsonNull, JsonNullValues, JsonValue } from '../common-types';
import type {
BuiltinType,
FieldDef,
Expand Down Expand Up @@ -32,8 +33,6 @@ import type {
} from '../schema';
import type {
AtLeast,
JsonNullValues,
JsonValue,
MapBaseType,
NonEmptyArray,
NullableIf,
Expand All @@ -45,7 +44,6 @@ import type {
WrapType,
XOR,
} from '../utils/type-utils';
import type { DbNull, JsonNull } from './null-values';
import type { ClientOptions } from './options';
import type { ToKyselySchema } from './query-builder';

Expand Down
2 changes: 1 addition & 1 deletion packages/orm/src/client/crud/dialects/base-dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { enumerate, invariant, isPlainObject } from '@zenstackhq/common-helpers'
import type { Expression, ExpressionBuilder, ExpressionWrapper, SqlBool, ValueNode } from 'kysely';
import { expressionBuilder, sql, type SelectQueryBuilder } from 'kysely';
import { match, P } from 'ts-pattern';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types';
import type { BuiltinType, DataSourceProviderType, FieldDef, GetModels, ModelDef, SchemaDef } from '../../../schema';
import type { OrArray } from '../../../utils/type-utils';
import { AGGREGATE_OPERATORS, DELEGATE_JOINED_FIELD_PREFIX, LOGICAL_COMBINATORS } from '../../constants';
Expand All @@ -15,7 +16,6 @@ import type {
StringFilter,
} from '../../crud-types';
import { createConfigError, createInvalidInputError, createNotSupportedError } from '../../errors';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../null-values';
import type { ClientOptions } from '../../options';
import {
aggregate,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/src/client/crud/dialects/postgresql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {
} from 'kysely';
import { match } from 'ts-pattern';
import z from 'zod';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types';
import type { BuiltinType, FieldDef, GetModels, SchemaDef } from '../../../schema';
import { DELEGATE_JOINED_FIELD_PREFIX } from '../../constants';
import type { FindArgs } from '../../crud-types';
import { createInternalError } from '../../errors';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../null-values';
import type { ClientOptions } from '../../options';
import {
buildJoinPairs,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/src/client/crud/dialects/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
type SqlBool,
} from 'kysely';
import { match } from 'ts-pattern';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types';
import type { BuiltinType, FieldDef, GetModels, SchemaDef } from '../../../schema';
import { DELEGATE_JOINED_FIELD_PREFIX } from '../../constants';
import type { FindArgs } from '../../crud-types';
import { createInternalError } from '../../errors';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../null-values';
import {
getDelegateDescendantModels,
getManyToManyRelation,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/src/client/crud/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Decimal from 'decimal.js';
import stableStringify from 'json-stable-stringify';
import { match, P } from 'ts-pattern';
import { z, ZodType } from 'zod';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../../common-types';
import {
type AttributeApplication,
type BuiltinType,
Expand Down Expand Up @@ -32,7 +33,6 @@ import {
type UpsertArgs,
} from '../../crud-types';
import { createInternalError, createInvalidInputError } from '../../errors';
import { AnyNullClass, DbNullClass, JsonNullClass } from '../../null-values';
import {
fieldHasDefaultValue,
getDiscriminatorField,
Expand Down
1 change: 0 additions & 1 deletion packages/orm/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export type * from './crud-types';
export { getCrudDialect } from './crud/dialects';
export { BaseCrudDialect } from './crud/dialects/base-dialect';
export { ORMError, ORMErrorReason, RejectedByPolicyReason } from './errors';
export { AnyNull, DbNull, JsonNull } from './null-values';
export * from './options';
export * from './plugin';
export type { ZenStackPromise } from './promise';
Expand Down
17 changes: 0 additions & 17 deletions packages/orm/src/client/null-values.ts

This file was deleted.

25 changes: 25 additions & 0 deletions packages/orm/src/common-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export type JsonValue = string | number | boolean | JsonObject | JsonArray;
export type JsonObject = { [key: string]: JsonValue | null };
export type JsonArray = ReadonlyArray<JsonValue | null>;
export type JsonNullValues = DbNull | JsonNull | AnyNull;
Comment thread
ymc9 marked this conversation as resolved.

export class DbNullClass {
// @ts-ignore
private __brand = 'DbNull' as const;
}
export const DbNull = new DbNullClass();
export type DbNull = typeof DbNull;

export class JsonNullClass {
// @ts-ignore
private __brand = 'JsonNull' as const;
}
export const JsonNull = new JsonNullClass();
export type JsonNull = typeof JsonNull;

export class AnyNullClass {
// @ts-ignore
private __brand = 'AnyNull' as const;
Comment thread
ymc9 marked this conversation as resolved.
Comment thread
ymc9 marked this conversation as resolved.
Comment thread
ymc9 marked this conversation as resolved.
}
export const AnyNull = new AnyNullClass();
export type AnyNull = typeof AnyNull;
2 changes: 1 addition & 1 deletion packages/orm/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './client';
export * from './common-types';
Comment thread
ymc9 marked this conversation as resolved.
export * as KyselyUtils from './utils/kysely-utils';
export * as SchemaUtils from './utils/schema-utils';
export type { JsonArray, JsonObject, JsonValue } from './utils/type-utils';
9 changes: 1 addition & 8 deletions packages/orm/src/utils/type-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type Decimal from 'decimal.js';
import type { AnyNull, DbNull, JsonNull } from '../client/null-values';
import type { JsonObject, JsonValue } from '../common-types';

export type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

Expand Down Expand Up @@ -45,13 +45,6 @@ type TypeMap = {

export type MapBaseType<T extends string> = T extends keyof TypeMap ? TypeMap[T] : unknown;

export type JsonValue = string | number | boolean | JsonObject | JsonArray;

export type JsonObject = { [key: string]: JsonValue | null };
export type JsonArray = ReadonlyArray<JsonValue | null>;

export type JsonNullValues = DbNull | JsonNull | AnyNull;

export function call(code: string) {
return { code };
}
Expand Down
Loading