Skip to content

Commit 55714ab

Browse files
committed
fix(zod): cyclic dependency
1 parent 3815277 commit 55714ab

15 files changed

Lines changed: 561 additions & 55 deletions

File tree

packages/orm/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"build": "tsc --noEmit && tsdown",
1919
"watch": "tsdown --watch",
2020
"lint": "eslint src --ext ts",
21-
"pack": "pnpm pack"
21+
"pack": "pnpm pack",
22+
"test:generate": "tsx ../../scripts/test-generate.ts . --generate-models=true"
2223
},
2324
"keywords": [],
2425
"files": [

packages/orm/src/client/crud-types.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type {
1818
GetModelFieldType,
1919
GetModels,
2020
GetSubModels,
21-
GetTypeDefField,
2221
GetTypeDefFields,
2322
GetTypeDefFieldType,
2423
GetTypeDefs,
@@ -33,6 +32,7 @@ import type {
3332
SchemaDef,
3433
TypeDefFieldIsArray,
3534
TypeDefFieldIsOptional,
35+
TypeDefResult,
3636
UpdatedAtInfo,
3737
} from '@zenstackhq/schema';
3838
import type {
@@ -44,7 +44,6 @@ import type {
4444
Optional,
4545
OrArray,
4646
OrUndefinedIf,
47-
PartialIf,
4847
Simplify,
4948
TypeMap,
5049
ValueOfPotentialTuple,
@@ -291,31 +290,7 @@ export type SimplifiedPlainResult<
291290
ExtResult extends ExtResultBase<Schema> = {},
292291
> = Simplify<ModelResult<Schema, Model, Args, Options, false, false, ExtResult>>;
293292

294-
export type TypeDefResult<
295-
Schema extends SchemaDef,
296-
TypeDef extends GetTypeDefs<Schema>,
297-
Partial extends boolean = false,
298-
> = PartialIf<
299-
Optional<
300-
{
301-
[Key in GetTypeDefFields<Schema, TypeDef>]: MapFieldDefType<
302-
Schema,
303-
GetTypeDefField<Schema, TypeDef, Key>,
304-
Partial
305-
>;
306-
},
307-
// optionality
308-
Partial extends true
309-
? never
310-
: keyof {
311-
[Key in GetTypeDefFields<Schema, TypeDef> as TypeDefFieldIsOptional<Schema, TypeDef, Key> extends true
312-
? Key
313-
: never]: true;
314-
}
315-
>,
316-
Partial
317-
> &
318-
Record<string, unknown>;
293+
export type { TypeDefResult } from '@zenstackhq/schema';
319294

320295
export type BatchResult = { count: number };
321296

packages/orm/src/common-types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
export type JsonValue = string | number | boolean | JsonObject | JsonArray;
2-
export type JsonObject = { [key: string]: JsonValue | null };
3-
export type JsonArray = Array<JsonValue | null>;
1+
export type { JsonArray, JsonObject, JsonValue } from '@zenstackhq/schema';
42
export type JsonNullValues = DbNull | JsonNull | AnyNull;
53

64
export class DbNullClass {

packages/orm/src/utils/type-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type Decimal from 'decimal.js';
2-
import type { JsonObject, JsonValue } from '../common-types';
2+
import type { JsonObject, JsonValue } from '@zenstackhq/schema';
33

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

0 commit comments

Comments
 (0)