@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.
@@ -0,0 +1,265 @@
1
+ import { a as DerivedModelDescriptor, E as ExtendedSchema, G as GlobalConfig, b as ModelConfig, c as ModelsOutput, M as ManyRelation, O as OneRelation, T as ThroughPath, f as ThroughRelation, A as AnyRelation, e as SearchProfile, D as DerivedField } from '../config-1Cdfs72F.cjs';
2
+ export { S as SchemaConfig, d as SearchField, Z as ZenConfig, g as defineConfig } from '../config-1Cdfs72F.cjs';
3
+ import { PgTable, PgColumn, getTableConfig } from 'drizzle-orm/pg-core';
4
+
5
+ declare function derived<TBase extends PgTable, const TWhere extends Record<string, unknown>>(base: TBase, opts: {
6
+ where: TWhere;
7
+ narrow?: Record<string, readonly unknown[]>;
8
+ }): DerivedModelDescriptor<TBase, TWhere> & TBase;
9
+ type DefineModelsFn = (globalConfig: GlobalConfig, models: Record<string, ModelConfig>) => ModelsOutput;
10
+ type ExtendedResult<TTables extends Record<string, PgTable>, TDerived extends Record<string, DerivedModelDescriptor>> = TTables & TDerived & {
11
+ __extended: ExtendedSchema;
12
+ } & DefineModelsFn;
13
+ declare function extend<TTables extends Record<string, PgTable>, TDerived extends Record<string, DerivedModelDescriptor>>(tables: TTables, derivedModels: TDerived): ExtendedResult<TTables, TDerived>;
14
+
15
+ declare function one(target: PgTable | DerivedModelDescriptor, opts: {
16
+ fields: PgColumn[];
17
+ references: PgColumn[];
18
+ where?: Record<string, unknown>;
19
+ relationName?: string;
20
+ }): OneRelation;
21
+ declare function many(target: PgTable, opts?: {
22
+ where?: Record<string, unknown>;
23
+ single?: boolean;
24
+ }): ManyRelation;
25
+ declare function through(path: ThroughPath): ThroughRelation;
26
+
27
+ interface RelationHelpers {
28
+ one: typeof one;
29
+ many: typeof many;
30
+ through: typeof through;
31
+ }
32
+ interface ModelOptions {
33
+ relations?: (helpers: RelationHelpers) => Record<string, AnyRelation>;
34
+ computed?: Record<string, unknown> | ((eb: any) => Record<string, unknown>);
35
+ search?: Record<string, SearchProfile>;
36
+ defaultWhere?: Record<string, unknown>;
37
+ derived?: Record<string, DerivedField>;
38
+ validate?: Record<string, unknown>;
39
+ }
40
+ declare function model(table: PgTable, opts: ModelOptions): ModelConfig;
41
+ declare function defineModels(extendedSchema: {
42
+ __extended: ExtendedSchema;
43
+ }, globalConfig: GlobalConfig, models: Record<string, ModelConfig>): ModelsOutput;
44
+
45
+ interface ComputedFieldDeclaration {
46
+ type: string;
47
+ tsType: string;
48
+ }
49
+ interface DerivedModelDeclaration {
50
+ where: Record<string, unknown>;
51
+ narrow?: Record<string, readonly unknown[]> | null;
52
+ relations?: Record<string, Record<string, true>>;
53
+ }
54
+ interface FilteredRelationDeclaration {
55
+ relation: Record<string, true>;
56
+ where: Record<string, unknown>;
57
+ single?: boolean;
58
+ }
59
+ interface ThroughRelationDeclaration {
60
+ path: ThroughRelationPath;
61
+ }
62
+ interface SearchDefaultDeclaration {
63
+ fields: Record<string, unknown>;
64
+ mode?: "contains" | "startsWith" | "equals";
65
+ strategy?: "all" | "any";
66
+ }
67
+ type ComputedFieldsConfig = Record<string, Record<string, ComputedFieldDeclaration>>;
68
+ type DerivedModelsConfig = Record<string, Record<string, DerivedModelDeclaration>>;
69
+ type FilteredRelationsConfig = Record<string, Record<string, FilteredRelationDeclaration>>;
70
+ type ThroughRelationsConfig = Record<string, Record<string, ThroughRelationDeclaration>>;
71
+ type SearchDefaultsConfig = Record<string, Record<string, SearchDefaultDeclaration>>;
72
+ type ResolvedRelationTargets = Record<string, Record<string, string>>;
73
+ type ThroughRelationPath = {
74
+ [key: string]: true | ThroughRelationPath;
75
+ };
76
+
77
+ interface FKRelationInfo {
78
+ targetExportName: string;
79
+ fields: string[];
80
+ references: string[];
81
+ relationName: string | null;
82
+ }
83
+ interface LegacyConfig {
84
+ computedFields: ComputedFieldsConfig;
85
+ computedCallbacks: Record<string, Record<string, (eb: any, ctx: any) => any>>;
86
+ derivedModels: DerivedModelsConfig;
87
+ filteredRelations: FilteredRelationsConfig;
88
+ searchDefaults: SearchDefaultsConfig;
89
+ throughRelations: ThroughRelationsConfig;
90
+ relationTargets: ResolvedRelationTargets;
91
+ modelScopes: Record<string, Record<string, unknown>>;
92
+ derivedFields: Record<string, Record<string, DerivedField>>;
93
+ validationSchemas: Record<string, Record<string, unknown>>;
94
+ fkRelations: Record<string, Record<string, FKRelationInfo>>;
95
+ }
96
+ declare function adaptToLegacyConfig(output: ModelsOutput): LegacyConfig;
97
+
98
+ interface EnumInfo {
99
+ pgName: string;
100
+ zenstackName: string;
101
+ values: string[];
102
+ mapping: Record<string, string> | null;
103
+ mappedName?: string | null;
104
+ }
105
+ interface ComputedFieldInfo {
106
+ name: string;
107
+ type: string;
108
+ tsType: string;
109
+ }
110
+ interface TableInfo {
111
+ exportName: string;
112
+ sqlName: string;
113
+ modelName: string;
114
+ typeName: string;
115
+ table: PgTable;
116
+ cfg: ReturnType<typeof getTableConfig>;
117
+ sqlToJsKey: Map<string, string>;
118
+ jsKeySet: Set<string>;
119
+ computedFields: ComputedFieldInfo[];
120
+ derivedFrom: string | null;
121
+ defaultWhere: Record<string, unknown> | null;
122
+ narrow: Record<string, readonly unknown[]> | null;
123
+ }
124
+ interface ViewInfo {
125
+ exportName: string;
126
+ sqlName: string;
127
+ modelName: string;
128
+ typeName: string;
129
+ columns: Map<string, unknown>;
130
+ sqlToJsKey: Map<string, string>;
131
+ }
132
+ interface FieldInfo {
133
+ name: string;
134
+ sqlName: string;
135
+ type: string;
136
+ isJsonColumn: boolean;
137
+ optional: boolean;
138
+ array: boolean;
139
+ id: boolean;
140
+ unique: boolean;
141
+ hasDefault: boolean;
142
+ dbAttrs: string[];
143
+ defaultExpr: string | null;
144
+ enumPgName: string | null;
145
+ isGenerated: boolean;
146
+ }
147
+ interface FKInfo {
148
+ name: string;
149
+ localColumns: string[];
150
+ foreignTable: string;
151
+ foreignColumns: string[];
152
+ }
153
+ interface RelationField {
154
+ fieldName: string;
155
+ targetModel: string;
156
+ optional: boolean;
157
+ array: boolean;
158
+ relationName: string | null;
159
+ fields: string[] | null;
160
+ references: string[] | null;
161
+ hasDefault: boolean;
162
+ kind?: "normal" | "filtered" | "through";
163
+ sourceRelation?: string;
164
+ throughPath?: string[];
165
+ where?: Record<string, unknown>;
166
+ single?: boolean;
167
+ _opposite?: string;
168
+ }
169
+
170
+ interface TypedJsonFieldInfo {
171
+ entitySqlName: string;
172
+ entityTypeName: string;
173
+ fieldName: string;
174
+ typeDefName: string;
175
+ isArray: boolean;
176
+ sourceTypeName?: string;
177
+ }
178
+ interface TypeDefField {
179
+ name: string;
180
+ rawName?: string;
181
+ type: string;
182
+ optional?: boolean;
183
+ array?: boolean;
184
+ }
185
+ interface TypeDefInfo {
186
+ name: string;
187
+ fields: Record<string, TypeDefField>;
188
+ }
189
+ interface TypeDefMapping {
190
+ typeDefName: string;
191
+ isArray: boolean;
192
+ }
193
+ interface TypedJsonArtifacts {
194
+ typeDefs: Map<string, TypeDefInfo>;
195
+ fieldToTypeDef: Map<string, TypeDefMapping>;
196
+ typedJsonFields: TypedJsonFieldInfo[];
197
+ }
198
+
199
+ declare function mapColumn(jsKey: string, col: any, enumMap: Map<string, EnumInfo>): FieldInfo;
200
+
201
+ declare function discoverEnums(allEnums: Record<string, unknown>): Map<string, EnumInfo>;
202
+ declare function assertNoTypedColumnOverrides(tablesFilePath: string): void;
203
+ declare function discoverTables(allTables: Record<string, unknown>, computedFieldsConfig?: ComputedFieldsConfig, derivedModelsConfig?: DerivedModelsConfig): TableInfo[];
204
+ declare function discoverViews(allViews: Record<string, unknown>): ViewInfo[];
205
+ declare function extractFKs(table: PgTable): FKInfo[];
206
+
207
+ type RelationTargets = Record<string, Record<string, string>>;
208
+ declare function buildRelations(tables: TableInfo[], relationTargets?: RelationTargets, filteredRelations?: FilteredRelationsConfig, throughRelations?: ThroughRelationsConfig, fkRelations?: Record<string, Record<string, FKRelationInfo>>): {
209
+ modelRelations: Map<string, RelationField[]>;
210
+ inverseRelations: Map<string, RelationField[]>;
211
+ };
212
+
213
+ declare function emitEnumBlock(info: EnumInfo): string;
214
+ declare function emitFieldBlock(field: FieldInfo): string;
215
+ declare function emitRelationField(rel: RelationField, opposite: string): string;
216
+ interface EmitSchemaOptions {
217
+ tables: TableInfo[];
218
+ enumMap: Map<string, EnumInfo>;
219
+ modelRelations: Map<string, RelationField[]>;
220
+ inverseRelations: Map<string, RelationField[]>;
221
+ searchDefaults: SearchDefaultsConfig;
222
+ modelScopes?: Record<string, Record<string, unknown>>;
223
+ typeDefs?: Map<string, TypeDefInfo>;
224
+ fieldToTypeDef?: Map<string, TypeDefMapping>;
225
+ views?: ViewInfo[];
226
+ }
227
+ declare function emitSchemaTs({ tables, enumMap, modelRelations, inverseRelations, searchDefaults, modelScopes, typeDefs, fieldToTypeDef, views, }: EmitSchemaOptions): string;
228
+ declare function emitModelsTs(tables: TableInfo[], typedJsonFields?: TypedJsonFieldInfo[]): string;
229
+ declare function emitViewsTs(views: ViewInfo[], typedJsonFields?: TypedJsonFieldInfo[]): string;
230
+ declare function emitInputTs(tables: TableInfo[]): string;
231
+ declare function emitIndexTs({ tables, views, enumMap, typeDefs, typedJsonFields, }: {
232
+ tables: TableInfo[];
233
+ views: ViewInfo[];
234
+ enumMap: Map<string, EnumInfo>;
235
+ typeDefs: Map<string, TypeDefInfo>;
236
+ typedJsonFields: TypedJsonFieldInfo[];
237
+ }): string;
238
+ declare function emitCompatTs({ tables, views, enumMap, typedJsonFields, }: {
239
+ tables: TableInfo[];
240
+ views: ViewInfo[];
241
+ enumMap: Map<string, EnumInfo>;
242
+ typedJsonFields: TypedJsonFieldInfo[];
243
+ }): string;
244
+ declare function emitOrmTypesTs(tables: TableInfo[]): string;
245
+ declare function emitEnumsTs(enumMap: Map<string, EnumInfo>): string;
246
+
247
+ declare function buildTypeDefs(typesPath: string, tables: TableInfo[], views?: ViewInfo[], enumMap?: Map<string, EnumInfo>): TypedJsonArtifacts;
248
+ declare function emitTypeDefsBlock(typeDefs: Map<string, TypeDefInfo>): string;
249
+ declare function emitJsonNamespaceBlock(typeDefs: Map<string, TypeDefInfo>, typedJsonFields: TypedJsonFieldInfo[], indent?: string): string[];
250
+ declare function emitJsonRawNamespaceBlock(typedJsonFields: TypedJsonFieldInfo[], indent?: string): string[];
251
+ declare function emitJsonTs(typeDefs: Map<string, TypeDefInfo>, typedJsonFields: TypedJsonFieldInfo[]): string;
252
+ declare function emitJsonRawTs(typedJsonFields: TypedJsonFieldInfo[]): string;
253
+
254
+ declare const APP_SLUG_SQL = "app_slug";
255
+ declare const APP_SLUG_JS = "appSlug";
256
+ declare const GENERATED_FILE_BANNER: string[];
257
+ declare function emitGeneratedFileBanner(): string[];
258
+ declare function capitalize(s: string): string;
259
+ declare function toPascalCase(s: string): string;
260
+ declare function uncapitalize(s: string): string;
261
+ declare function esc(s: string): string;
262
+ declare function getDrizzleTableName(table: unknown): string;
263
+ declare function writeFileIfChanged(filePath: string, content: string): boolean;
264
+
265
+ export { APP_SLUG_JS, APP_SLUG_SQL, type ComputedFieldDeclaration, type ComputedFieldInfo, type ComputedFieldsConfig, DerivedField, type DerivedModelDeclaration, DerivedModelDescriptor, type DerivedModelsConfig, type EmitSchemaOptions, type EnumInfo, ExtendedSchema, type FKInfo, type FKRelationInfo, type FieldInfo, type FilteredRelationDeclaration, type FilteredRelationsConfig, GENERATED_FILE_BANNER, GlobalConfig, ManyRelation, ModelConfig, ModelsOutput, OneRelation, type RelationField, type ResolvedRelationTargets, type SearchDefaultDeclaration, type SearchDefaultsConfig, SearchProfile, type TableInfo, ThroughPath, ThroughRelation, type ThroughRelationDeclaration, type ThroughRelationPath, type ThroughRelationsConfig, type TypeDefField, type TypeDefInfo, type TypeDefMapping, type TypedJsonArtifacts, type TypedJsonFieldInfo, type ViewInfo, adaptToLegacyConfig, assertNoTypedColumnOverrides, buildRelations, buildTypeDefs, capitalize, defineModels, derived, discoverEnums, discoverTables, discoverViews, emitCompatTs, emitEnumBlock, emitEnumsTs, emitFieldBlock, emitGeneratedFileBanner, emitIndexTs, emitInputTs, emitJsonNamespaceBlock, emitJsonRawNamespaceBlock, emitJsonRawTs, emitJsonTs, emitModelsTs, emitOrmTypesTs, emitRelationField, emitSchemaTs, emitTypeDefsBlock, emitViewsTs, esc, extend, extractFKs, getDrizzleTableName, many, mapColumn, model, one, through, toPascalCase, uncapitalize, writeFileIfChanged };
@@ -0,0 +1,265 @@
1
+ import { a as DerivedModelDescriptor, E as ExtendedSchema, G as GlobalConfig, b as ModelConfig, c as ModelsOutput, M as ManyRelation, O as OneRelation, T as ThroughPath, f as ThroughRelation, A as AnyRelation, e as SearchProfile, D as DerivedField } from '../config-1Cdfs72F.js';
2
+ export { S as SchemaConfig, d as SearchField, Z as ZenConfig, g as defineConfig } from '../config-1Cdfs72F.js';
3
+ import { PgTable, PgColumn, getTableConfig } from 'drizzle-orm/pg-core';
4
+
5
+ declare function derived<TBase extends PgTable, const TWhere extends Record<string, unknown>>(base: TBase, opts: {
6
+ where: TWhere;
7
+ narrow?: Record<string, readonly unknown[]>;
8
+ }): DerivedModelDescriptor<TBase, TWhere> & TBase;
9
+ type DefineModelsFn = (globalConfig: GlobalConfig, models: Record<string, ModelConfig>) => ModelsOutput;
10
+ type ExtendedResult<TTables extends Record<string, PgTable>, TDerived extends Record<string, DerivedModelDescriptor>> = TTables & TDerived & {
11
+ __extended: ExtendedSchema;
12
+ } & DefineModelsFn;
13
+ declare function extend<TTables extends Record<string, PgTable>, TDerived extends Record<string, DerivedModelDescriptor>>(tables: TTables, derivedModels: TDerived): ExtendedResult<TTables, TDerived>;
14
+
15
+ declare function one(target: PgTable | DerivedModelDescriptor, opts: {
16
+ fields: PgColumn[];
17
+ references: PgColumn[];
18
+ where?: Record<string, unknown>;
19
+ relationName?: string;
20
+ }): OneRelation;
21
+ declare function many(target: PgTable, opts?: {
22
+ where?: Record<string, unknown>;
23
+ single?: boolean;
24
+ }): ManyRelation;
25
+ declare function through(path: ThroughPath): ThroughRelation;
26
+
27
+ interface RelationHelpers {
28
+ one: typeof one;
29
+ many: typeof many;
30
+ through: typeof through;
31
+ }
32
+ interface ModelOptions {
33
+ relations?: (helpers: RelationHelpers) => Record<string, AnyRelation>;
34
+ computed?: Record<string, unknown> | ((eb: any) => Record<string, unknown>);
35
+ search?: Record<string, SearchProfile>;
36
+ defaultWhere?: Record<string, unknown>;
37
+ derived?: Record<string, DerivedField>;
38
+ validate?: Record<string, unknown>;
39
+ }
40
+ declare function model(table: PgTable, opts: ModelOptions): ModelConfig;
41
+ declare function defineModels(extendedSchema: {
42
+ __extended: ExtendedSchema;
43
+ }, globalConfig: GlobalConfig, models: Record<string, ModelConfig>): ModelsOutput;
44
+
45
+ interface ComputedFieldDeclaration {
46
+ type: string;
47
+ tsType: string;
48
+ }
49
+ interface DerivedModelDeclaration {
50
+ where: Record<string, unknown>;
51
+ narrow?: Record<string, readonly unknown[]> | null;
52
+ relations?: Record<string, Record<string, true>>;
53
+ }
54
+ interface FilteredRelationDeclaration {
55
+ relation: Record<string, true>;
56
+ where: Record<string, unknown>;
57
+ single?: boolean;
58
+ }
59
+ interface ThroughRelationDeclaration {
60
+ path: ThroughRelationPath;
61
+ }
62
+ interface SearchDefaultDeclaration {
63
+ fields: Record<string, unknown>;
64
+ mode?: "contains" | "startsWith" | "equals";
65
+ strategy?: "all" | "any";
66
+ }
67
+ type ComputedFieldsConfig = Record<string, Record<string, ComputedFieldDeclaration>>;
68
+ type DerivedModelsConfig = Record<string, Record<string, DerivedModelDeclaration>>;
69
+ type FilteredRelationsConfig = Record<string, Record<string, FilteredRelationDeclaration>>;
70
+ type ThroughRelationsConfig = Record<string, Record<string, ThroughRelationDeclaration>>;
71
+ type SearchDefaultsConfig = Record<string, Record<string, SearchDefaultDeclaration>>;
72
+ type ResolvedRelationTargets = Record<string, Record<string, string>>;
73
+ type ThroughRelationPath = {
74
+ [key: string]: true | ThroughRelationPath;
75
+ };
76
+
77
+ interface FKRelationInfo {
78
+ targetExportName: string;
79
+ fields: string[];
80
+ references: string[];
81
+ relationName: string | null;
82
+ }
83
+ interface LegacyConfig {
84
+ computedFields: ComputedFieldsConfig;
85
+ computedCallbacks: Record<string, Record<string, (eb: any, ctx: any) => any>>;
86
+ derivedModels: DerivedModelsConfig;
87
+ filteredRelations: FilteredRelationsConfig;
88
+ searchDefaults: SearchDefaultsConfig;
89
+ throughRelations: ThroughRelationsConfig;
90
+ relationTargets: ResolvedRelationTargets;
91
+ modelScopes: Record<string, Record<string, unknown>>;
92
+ derivedFields: Record<string, Record<string, DerivedField>>;
93
+ validationSchemas: Record<string, Record<string, unknown>>;
94
+ fkRelations: Record<string, Record<string, FKRelationInfo>>;
95
+ }
96
+ declare function adaptToLegacyConfig(output: ModelsOutput): LegacyConfig;
97
+
98
+ interface EnumInfo {
99
+ pgName: string;
100
+ zenstackName: string;
101
+ values: string[];
102
+ mapping: Record<string, string> | null;
103
+ mappedName?: string | null;
104
+ }
105
+ interface ComputedFieldInfo {
106
+ name: string;
107
+ type: string;
108
+ tsType: string;
109
+ }
110
+ interface TableInfo {
111
+ exportName: string;
112
+ sqlName: string;
113
+ modelName: string;
114
+ typeName: string;
115
+ table: PgTable;
116
+ cfg: ReturnType<typeof getTableConfig>;
117
+ sqlToJsKey: Map<string, string>;
118
+ jsKeySet: Set<string>;
119
+ computedFields: ComputedFieldInfo[];
120
+ derivedFrom: string | null;
121
+ defaultWhere: Record<string, unknown> | null;
122
+ narrow: Record<string, readonly unknown[]> | null;
123
+ }
124
+ interface ViewInfo {
125
+ exportName: string;
126
+ sqlName: string;
127
+ modelName: string;
128
+ typeName: string;
129
+ columns: Map<string, unknown>;
130
+ sqlToJsKey: Map<string, string>;
131
+ }
132
+ interface FieldInfo {
133
+ name: string;
134
+ sqlName: string;
135
+ type: string;
136
+ isJsonColumn: boolean;
137
+ optional: boolean;
138
+ array: boolean;
139
+ id: boolean;
140
+ unique: boolean;
141
+ hasDefault: boolean;
142
+ dbAttrs: string[];
143
+ defaultExpr: string | null;
144
+ enumPgName: string | null;
145
+ isGenerated: boolean;
146
+ }
147
+ interface FKInfo {
148
+ name: string;
149
+ localColumns: string[];
150
+ foreignTable: string;
151
+ foreignColumns: string[];
152
+ }
153
+ interface RelationField {
154
+ fieldName: string;
155
+ targetModel: string;
156
+ optional: boolean;
157
+ array: boolean;
158
+ relationName: string | null;
159
+ fields: string[] | null;
160
+ references: string[] | null;
161
+ hasDefault: boolean;
162
+ kind?: "normal" | "filtered" | "through";
163
+ sourceRelation?: string;
164
+ throughPath?: string[];
165
+ where?: Record<string, unknown>;
166
+ single?: boolean;
167
+ _opposite?: string;
168
+ }
169
+
170
+ interface TypedJsonFieldInfo {
171
+ entitySqlName: string;
172
+ entityTypeName: string;
173
+ fieldName: string;
174
+ typeDefName: string;
175
+ isArray: boolean;
176
+ sourceTypeName?: string;
177
+ }
178
+ interface TypeDefField {
179
+ name: string;
180
+ rawName?: string;
181
+ type: string;
182
+ optional?: boolean;
183
+ array?: boolean;
184
+ }
185
+ interface TypeDefInfo {
186
+ name: string;
187
+ fields: Record<string, TypeDefField>;
188
+ }
189
+ interface TypeDefMapping {
190
+ typeDefName: string;
191
+ isArray: boolean;
192
+ }
193
+ interface TypedJsonArtifacts {
194
+ typeDefs: Map<string, TypeDefInfo>;
195
+ fieldToTypeDef: Map<string, TypeDefMapping>;
196
+ typedJsonFields: TypedJsonFieldInfo[];
197
+ }
198
+
199
+ declare function mapColumn(jsKey: string, col: any, enumMap: Map<string, EnumInfo>): FieldInfo;
200
+
201
+ declare function discoverEnums(allEnums: Record<string, unknown>): Map<string, EnumInfo>;
202
+ declare function assertNoTypedColumnOverrides(tablesFilePath: string): void;
203
+ declare function discoverTables(allTables: Record<string, unknown>, computedFieldsConfig?: ComputedFieldsConfig, derivedModelsConfig?: DerivedModelsConfig): TableInfo[];
204
+ declare function discoverViews(allViews: Record<string, unknown>): ViewInfo[];
205
+ declare function extractFKs(table: PgTable): FKInfo[];
206
+
207
+ type RelationTargets = Record<string, Record<string, string>>;
208
+ declare function buildRelations(tables: TableInfo[], relationTargets?: RelationTargets, filteredRelations?: FilteredRelationsConfig, throughRelations?: ThroughRelationsConfig, fkRelations?: Record<string, Record<string, FKRelationInfo>>): {
209
+ modelRelations: Map<string, RelationField[]>;
210
+ inverseRelations: Map<string, RelationField[]>;
211
+ };
212
+
213
+ declare function emitEnumBlock(info: EnumInfo): string;
214
+ declare function emitFieldBlock(field: FieldInfo): string;
215
+ declare function emitRelationField(rel: RelationField, opposite: string): string;
216
+ interface EmitSchemaOptions {
217
+ tables: TableInfo[];
218
+ enumMap: Map<string, EnumInfo>;
219
+ modelRelations: Map<string, RelationField[]>;
220
+ inverseRelations: Map<string, RelationField[]>;
221
+ searchDefaults: SearchDefaultsConfig;
222
+ modelScopes?: Record<string, Record<string, unknown>>;
223
+ typeDefs?: Map<string, TypeDefInfo>;
224
+ fieldToTypeDef?: Map<string, TypeDefMapping>;
225
+ views?: ViewInfo[];
226
+ }
227
+ declare function emitSchemaTs({ tables, enumMap, modelRelations, inverseRelations, searchDefaults, modelScopes, typeDefs, fieldToTypeDef, views, }: EmitSchemaOptions): string;
228
+ declare function emitModelsTs(tables: TableInfo[], typedJsonFields?: TypedJsonFieldInfo[]): string;
229
+ declare function emitViewsTs(views: ViewInfo[], typedJsonFields?: TypedJsonFieldInfo[]): string;
230
+ declare function emitInputTs(tables: TableInfo[]): string;
231
+ declare function emitIndexTs({ tables, views, enumMap, typeDefs, typedJsonFields, }: {
232
+ tables: TableInfo[];
233
+ views: ViewInfo[];
234
+ enumMap: Map<string, EnumInfo>;
235
+ typeDefs: Map<string, TypeDefInfo>;
236
+ typedJsonFields: TypedJsonFieldInfo[];
237
+ }): string;
238
+ declare function emitCompatTs({ tables, views, enumMap, typedJsonFields, }: {
239
+ tables: TableInfo[];
240
+ views: ViewInfo[];
241
+ enumMap: Map<string, EnumInfo>;
242
+ typedJsonFields: TypedJsonFieldInfo[];
243
+ }): string;
244
+ declare function emitOrmTypesTs(tables: TableInfo[]): string;
245
+ declare function emitEnumsTs(enumMap: Map<string, EnumInfo>): string;
246
+
247
+ declare function buildTypeDefs(typesPath: string, tables: TableInfo[], views?: ViewInfo[], enumMap?: Map<string, EnumInfo>): TypedJsonArtifacts;
248
+ declare function emitTypeDefsBlock(typeDefs: Map<string, TypeDefInfo>): string;
249
+ declare function emitJsonNamespaceBlock(typeDefs: Map<string, TypeDefInfo>, typedJsonFields: TypedJsonFieldInfo[], indent?: string): string[];
250
+ declare function emitJsonRawNamespaceBlock(typedJsonFields: TypedJsonFieldInfo[], indent?: string): string[];
251
+ declare function emitJsonTs(typeDefs: Map<string, TypeDefInfo>, typedJsonFields: TypedJsonFieldInfo[]): string;
252
+ declare function emitJsonRawTs(typedJsonFields: TypedJsonFieldInfo[]): string;
253
+
254
+ declare const APP_SLUG_SQL = "app_slug";
255
+ declare const APP_SLUG_JS = "appSlug";
256
+ declare const GENERATED_FILE_BANNER: string[];
257
+ declare function emitGeneratedFileBanner(): string[];
258
+ declare function capitalize(s: string): string;
259
+ declare function toPascalCase(s: string): string;
260
+ declare function uncapitalize(s: string): string;
261
+ declare function esc(s: string): string;
262
+ declare function getDrizzleTableName(table: unknown): string;
263
+ declare function writeFileIfChanged(filePath: string, content: string): boolean;
264
+
265
+ export { APP_SLUG_JS, APP_SLUG_SQL, type ComputedFieldDeclaration, type ComputedFieldInfo, type ComputedFieldsConfig, DerivedField, type DerivedModelDeclaration, DerivedModelDescriptor, type DerivedModelsConfig, type EmitSchemaOptions, type EnumInfo, ExtendedSchema, type FKInfo, type FKRelationInfo, type FieldInfo, type FilteredRelationDeclaration, type FilteredRelationsConfig, GENERATED_FILE_BANNER, GlobalConfig, ManyRelation, ModelConfig, ModelsOutput, OneRelation, type RelationField, type ResolvedRelationTargets, type SearchDefaultDeclaration, type SearchDefaultsConfig, SearchProfile, type TableInfo, ThroughPath, ThroughRelation, type ThroughRelationDeclaration, type ThroughRelationPath, type ThroughRelationsConfig, type TypeDefField, type TypeDefInfo, type TypeDefMapping, type TypedJsonArtifacts, type TypedJsonFieldInfo, type ViewInfo, adaptToLegacyConfig, assertNoTypedColumnOverrides, buildRelations, buildTypeDefs, capitalize, defineModels, derived, discoverEnums, discoverTables, discoverViews, emitCompatTs, emitEnumBlock, emitEnumsTs, emitFieldBlock, emitGeneratedFileBanner, emitIndexTs, emitInputTs, emitJsonNamespaceBlock, emitJsonRawNamespaceBlock, emitJsonRawTs, emitJsonTs, emitModelsTs, emitOrmTypesTs, emitRelationField, emitSchemaTs, emitTypeDefsBlock, emitViewsTs, esc, extend, extractFKs, getDrizzleTableName, many, mapColumn, model, one, through, toPascalCase, uncapitalize, writeFileIfChanged };