@danielhritcu/zenstack-custom 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +2525 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +7 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +2492 -0
- package/dist/cli.js.map +1 -0
- package/dist/codegen/index.cjs +2745 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.d.cts +265 -0
- package/dist/codegen/index.d.ts +265 -0
- package/dist/codegen/index.js +2668 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/config-1Cdfs72F.d.cts +97 -0
- package/dist/config-1Cdfs72F.d.ts +97 -0
- package/dist/drizzle/index.cjs +994 -0
- package/dist/drizzle/index.cjs.map +1 -0
- package/dist/drizzle/index.d.cts +224 -0
- package/dist/drizzle/index.d.ts +224 -0
- package/dist/drizzle/index.js +917 -0
- package/dist/drizzle/index.js.map +1 -0
- package/dist/index.cjs +3705 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3575 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { PgTable, PgColumn } from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
interface DerivedModelDescriptor<TBase extends PgTable = PgTable, TWhere extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
|
+
__brand: "derived";
|
|
5
|
+
base: TBase;
|
|
6
|
+
where: TWhere;
|
|
7
|
+
narrow: Record<string, readonly unknown[]> | null;
|
|
8
|
+
baseName: string;
|
|
9
|
+
}
|
|
10
|
+
interface RelationDescriptor {
|
|
11
|
+
kind: "one" | "many" | "filtered" | "through";
|
|
12
|
+
}
|
|
13
|
+
interface OneRelation extends RelationDescriptor {
|
|
14
|
+
kind: "one";
|
|
15
|
+
target: PgTable | DerivedModelDescriptor;
|
|
16
|
+
fields: PgColumn[];
|
|
17
|
+
references: PgColumn[];
|
|
18
|
+
/** Source-side discriminator filter (polymorphic FK) */
|
|
19
|
+
where?: Record<string, unknown>;
|
|
20
|
+
/** Disambiguation name when multiple relations point to the same target */
|
|
21
|
+
relationName?: string;
|
|
22
|
+
}
|
|
23
|
+
interface ManyRelation extends RelationDescriptor {
|
|
24
|
+
kind: "many";
|
|
25
|
+
target: PgTable;
|
|
26
|
+
where?: Record<string, unknown>;
|
|
27
|
+
single?: boolean;
|
|
28
|
+
}
|
|
29
|
+
type ThroughPath = {
|
|
30
|
+
[relation: string]: true | ThroughPath;
|
|
31
|
+
};
|
|
32
|
+
interface ThroughRelation extends RelationDescriptor {
|
|
33
|
+
kind: "through";
|
|
34
|
+
path: ThroughPath;
|
|
35
|
+
}
|
|
36
|
+
type AnyRelation = OneRelation | ManyRelation | ThroughRelation;
|
|
37
|
+
type SearchField = PgColumn | {
|
|
38
|
+
[relation: string]: SearchField[];
|
|
39
|
+
};
|
|
40
|
+
interface SearchProfile {
|
|
41
|
+
fields: SearchField[];
|
|
42
|
+
mode?: "contains" | "startsWith" | "equals";
|
|
43
|
+
strategy?: "all" | "any";
|
|
44
|
+
}
|
|
45
|
+
interface DerivedField {
|
|
46
|
+
needs: Record<string, true>;
|
|
47
|
+
compute: (data: Record<string, unknown>) => unknown;
|
|
48
|
+
}
|
|
49
|
+
interface GlobalConfig {
|
|
50
|
+
defaultWhere?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
interface ModelConfig {
|
|
53
|
+
table: PgTable;
|
|
54
|
+
relations?: Record<string, AnyRelation>;
|
|
55
|
+
computed?: Record<string, unknown> | ((eb: any) => Record<string, unknown>);
|
|
56
|
+
search?: Record<string, SearchProfile>;
|
|
57
|
+
defaultWhere?: Record<string, unknown>;
|
|
58
|
+
derived?: Record<string, DerivedField>;
|
|
59
|
+
validate?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
interface ExtendedSchema {
|
|
62
|
+
tables: Record<string, PgTable>;
|
|
63
|
+
derived: Record<string, DerivedModelDescriptor>;
|
|
64
|
+
}
|
|
65
|
+
interface ModelsOutput {
|
|
66
|
+
schema: ExtendedSchema;
|
|
67
|
+
global: GlobalConfig;
|
|
68
|
+
models: Record<string, ModelConfig>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface SchemaConfig {
|
|
72
|
+
enums: Record<string, unknown>;
|
|
73
|
+
views?: Record<string, unknown>;
|
|
74
|
+
types?: Record<string, unknown>;
|
|
75
|
+
output: string;
|
|
76
|
+
}
|
|
77
|
+
interface ZenConfig {
|
|
78
|
+
tables: Record<string, PgTable>;
|
|
79
|
+
schema: SchemaConfig;
|
|
80
|
+
default?: {
|
|
81
|
+
where?: Record<string, unknown>;
|
|
82
|
+
};
|
|
83
|
+
derived: Record<string, DerivedModelDescriptor>;
|
|
84
|
+
models: Record<string, ModelConfig>;
|
|
85
|
+
}
|
|
86
|
+
declare function defineConfig<T extends Record<string, PgTable>, D extends Record<string, DerivedModelDescriptor> = {}>(tables: T, config: {
|
|
87
|
+
schema: SchemaConfig;
|
|
88
|
+
default?: {
|
|
89
|
+
where?: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
derived?: D;
|
|
92
|
+
models: (orm: T & {
|
|
93
|
+
[K in keyof D]: D[K] extends DerivedModelDescriptor<infer TBase> ? TBase & D[K] : D[K];
|
|
94
|
+
}) => Record<string, ModelConfig>;
|
|
95
|
+
}): ZenConfig;
|
|
96
|
+
|
|
97
|
+
export { type AnyRelation as A, type DerivedField as D, type ExtendedSchema as E, type GlobalConfig as G, type ManyRelation as M, type OneRelation as O, type SchemaConfig as S, type ThroughPath as T, type ZenConfig as Z, type DerivedModelDescriptor as a, type ModelConfig as b, type ModelsOutput as c, type SearchField as d, type SearchProfile as e, type ThroughRelation as f, defineConfig as g };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { PgTable, PgColumn } from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
interface DerivedModelDescriptor<TBase extends PgTable = PgTable, TWhere extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
|
+
__brand: "derived";
|
|
5
|
+
base: TBase;
|
|
6
|
+
where: TWhere;
|
|
7
|
+
narrow: Record<string, readonly unknown[]> | null;
|
|
8
|
+
baseName: string;
|
|
9
|
+
}
|
|
10
|
+
interface RelationDescriptor {
|
|
11
|
+
kind: "one" | "many" | "filtered" | "through";
|
|
12
|
+
}
|
|
13
|
+
interface OneRelation extends RelationDescriptor {
|
|
14
|
+
kind: "one";
|
|
15
|
+
target: PgTable | DerivedModelDescriptor;
|
|
16
|
+
fields: PgColumn[];
|
|
17
|
+
references: PgColumn[];
|
|
18
|
+
/** Source-side discriminator filter (polymorphic FK) */
|
|
19
|
+
where?: Record<string, unknown>;
|
|
20
|
+
/** Disambiguation name when multiple relations point to the same target */
|
|
21
|
+
relationName?: string;
|
|
22
|
+
}
|
|
23
|
+
interface ManyRelation extends RelationDescriptor {
|
|
24
|
+
kind: "many";
|
|
25
|
+
target: PgTable;
|
|
26
|
+
where?: Record<string, unknown>;
|
|
27
|
+
single?: boolean;
|
|
28
|
+
}
|
|
29
|
+
type ThroughPath = {
|
|
30
|
+
[relation: string]: true | ThroughPath;
|
|
31
|
+
};
|
|
32
|
+
interface ThroughRelation extends RelationDescriptor {
|
|
33
|
+
kind: "through";
|
|
34
|
+
path: ThroughPath;
|
|
35
|
+
}
|
|
36
|
+
type AnyRelation = OneRelation | ManyRelation | ThroughRelation;
|
|
37
|
+
type SearchField = PgColumn | {
|
|
38
|
+
[relation: string]: SearchField[];
|
|
39
|
+
};
|
|
40
|
+
interface SearchProfile {
|
|
41
|
+
fields: SearchField[];
|
|
42
|
+
mode?: "contains" | "startsWith" | "equals";
|
|
43
|
+
strategy?: "all" | "any";
|
|
44
|
+
}
|
|
45
|
+
interface DerivedField {
|
|
46
|
+
needs: Record<string, true>;
|
|
47
|
+
compute: (data: Record<string, unknown>) => unknown;
|
|
48
|
+
}
|
|
49
|
+
interface GlobalConfig {
|
|
50
|
+
defaultWhere?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
interface ModelConfig {
|
|
53
|
+
table: PgTable;
|
|
54
|
+
relations?: Record<string, AnyRelation>;
|
|
55
|
+
computed?: Record<string, unknown> | ((eb: any) => Record<string, unknown>);
|
|
56
|
+
search?: Record<string, SearchProfile>;
|
|
57
|
+
defaultWhere?: Record<string, unknown>;
|
|
58
|
+
derived?: Record<string, DerivedField>;
|
|
59
|
+
validate?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
interface ExtendedSchema {
|
|
62
|
+
tables: Record<string, PgTable>;
|
|
63
|
+
derived: Record<string, DerivedModelDescriptor>;
|
|
64
|
+
}
|
|
65
|
+
interface ModelsOutput {
|
|
66
|
+
schema: ExtendedSchema;
|
|
67
|
+
global: GlobalConfig;
|
|
68
|
+
models: Record<string, ModelConfig>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface SchemaConfig {
|
|
72
|
+
enums: Record<string, unknown>;
|
|
73
|
+
views?: Record<string, unknown>;
|
|
74
|
+
types?: Record<string, unknown>;
|
|
75
|
+
output: string;
|
|
76
|
+
}
|
|
77
|
+
interface ZenConfig {
|
|
78
|
+
tables: Record<string, PgTable>;
|
|
79
|
+
schema: SchemaConfig;
|
|
80
|
+
default?: {
|
|
81
|
+
where?: Record<string, unknown>;
|
|
82
|
+
};
|
|
83
|
+
derived: Record<string, DerivedModelDescriptor>;
|
|
84
|
+
models: Record<string, ModelConfig>;
|
|
85
|
+
}
|
|
86
|
+
declare function defineConfig<T extends Record<string, PgTable>, D extends Record<string, DerivedModelDescriptor> = {}>(tables: T, config: {
|
|
87
|
+
schema: SchemaConfig;
|
|
88
|
+
default?: {
|
|
89
|
+
where?: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
derived?: D;
|
|
92
|
+
models: (orm: T & {
|
|
93
|
+
[K in keyof D]: D[K] extends DerivedModelDescriptor<infer TBase> ? TBase & D[K] : D[K];
|
|
94
|
+
}) => Record<string, ModelConfig>;
|
|
95
|
+
}): ZenConfig;
|
|
96
|
+
|
|
97
|
+
export { type AnyRelation as A, type DerivedField as D, type ExtendedSchema as E, type GlobalConfig as G, type ManyRelation as M, type OneRelation as O, type SchemaConfig as S, type ThroughPath as T, type ZenConfig as Z, type DerivedModelDescriptor as a, type ModelConfig as b, type ModelsOutput as c, type SearchField as d, type SearchProfile as e, type ThroughRelation as f, defineConfig as g };
|