@revealui/db 0.2.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/LICENSE +22 -0
- package/README.md +137 -0
- package/dist/audit-store.d.ts +56 -0
- package/dist/audit-store.d.ts.map +1 -0
- package/dist/audit-store.js +120 -0
- package/dist/audit-store.js.map +1 -0
- package/dist/client/index.d.ts +214 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +396 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +109 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +10 -0
- package/dist/client/types.js.map +1 -0
- package/dist/crypto.d.ts +27 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +68 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/log-transport.d.ts +20 -0
- package/dist/log-transport.d.ts.map +1 -0
- package/dist/log-transport.js +49 -0
- package/dist/log-transport.js.map +1 -0
- package/dist/pool.d.ts +36 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +218 -0
- package/dist/pool.js.map +1 -0
- package/dist/queries/boards.d.ts +138 -0
- package/dist/queries/boards.d.ts.map +1 -0
- package/dist/queries/boards.js +87 -0
- package/dist/queries/boards.js.map +1 -0
- package/dist/queries/code-provenance.d.ts +250 -0
- package/dist/queries/code-provenance.d.ts.map +1 -0
- package/dist/queries/code-provenance.js +130 -0
- package/dist/queries/code-provenance.js.map +1 -0
- package/dist/queries/optimized-queries.d.ts +89 -0
- package/dist/queries/optimized-queries.d.ts.map +1 -0
- package/dist/queries/optimized-queries.js +371 -0
- package/dist/queries/optimized-queries.js.map +1 -0
- package/dist/queries/ticket-comments.d.ts +37 -0
- package/dist/queries/ticket-comments.d.ts.map +1 -0
- package/dist/queries/ticket-comments.js +52 -0
- package/dist/queries/ticket-comments.js.map +1 -0
- package/dist/queries/ticket-labels.d.ts +69 -0
- package/dist/queries/ticket-labels.d.ts.map +1 -0
- package/dist/queries/ticket-labels.js +51 -0
- package/dist/queries/ticket-labels.js.map +1 -0
- package/dist/queries/tickets.d.ts +301 -0
- package/dist/queries/tickets.d.ts.map +1 -0
- package/dist/queries/tickets.js +89 -0
- package/dist/queries/tickets.js.map +1 -0
- package/dist/queries/todos.d.ts +37 -0
- package/dist/queries/todos.d.ts.map +1 -0
- package/dist/queries/todos.js +37 -0
- package/dist/queries/todos.js.map +1 -0
- package/dist/schema/agents.d.ts +1413 -0
- package/dist/schema/agents.d.ts.map +1 -0
- package/dist/schema/agents.js +207 -0
- package/dist/schema/agents.js.map +1 -0
- package/dist/schema/api-keys.d.ts +298 -0
- package/dist/schema/api-keys.d.ts.map +1 -0
- package/dist/schema/api-keys.js +53 -0
- package/dist/schema/api-keys.js.map +1 -0
- package/dist/schema/app-logs.d.ts +168 -0
- package/dist/schema/app-logs.d.ts.map +1 -0
- package/dist/schema/app-logs.js +25 -0
- package/dist/schema/app-logs.js.map +1 -0
- package/dist/schema/audit-log.d.ts +174 -0
- package/dist/schema/audit-log.d.ts.map +1 -0
- package/dist/schema/audit-log.js +37 -0
- package/dist/schema/audit-log.js.map +1 -0
- package/dist/schema/cms.d.ts +1015 -0
- package/dist/schema/cms.d.ts.map +1 -0
- package/dist/schema/cms.js +137 -0
- package/dist/schema/cms.js.map +1 -0
- package/dist/schema/code-provenance.d.ts +488 -0
- package/dist/schema/code-provenance.d.ts.map +1 -0
- package/dist/schema/code-provenance.js +72 -0
- package/dist/schema/code-provenance.js.map +1 -0
- package/dist/schema/collab-edits.d.ts +165 -0
- package/dist/schema/collab-edits.d.ts.map +1 -0
- package/dist/schema/collab-edits.js +21 -0
- package/dist/schema/collab-edits.js.map +1 -0
- package/dist/schema/crdt-operations.d.ts +153 -0
- package/dist/schema/crdt-operations.d.ts.map +1 -0
- package/dist/schema/crdt-operations.js +30 -0
- package/dist/schema/crdt-operations.js.map +1 -0
- package/dist/schema/error-events.d.ts +223 -0
- package/dist/schema/error-events.d.ts.map +1 -0
- package/dist/schema/error-events.js +44 -0
- package/dist/schema/error-events.js.map +1 -0
- package/dist/schema/index.d.ts +130 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +310 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/licenses.d.ts +189 -0
- package/dist/schema/licenses.d.ts.map +1 -0
- package/dist/schema/licenses.js +39 -0
- package/dist/schema/licenses.js.map +1 -0
- package/dist/schema/node-ids.d.ts +122 -0
- package/dist/schema/node-ids.d.ts.map +1 -0
- package/dist/schema/node-ids.js +25 -0
- package/dist/schema/node-ids.js.map +1 -0
- package/dist/schema/pages.d.ts +488 -0
- package/dist/schema/pages.d.ts.map +1 -0
- package/dist/schema/pages.js +70 -0
- package/dist/schema/pages.js.map +1 -0
- package/dist/schema/password-reset-tokens.d.ts +137 -0
- package/dist/schema/password-reset-tokens.d.ts.map +1 -0
- package/dist/schema/password-reset-tokens.js +26 -0
- package/dist/schema/password-reset-tokens.js.map +1 -0
- package/dist/schema/query.d.ts +11 -0
- package/dist/schema/query.d.ts.map +1 -0
- package/dist/schema/query.js +11 -0
- package/dist/schema/query.js.map +1 -0
- package/dist/schema/rate-limits.d.ts +212 -0
- package/dist/schema/rate-limits.d.ts.map +1 -0
- package/dist/schema/rate-limits.js +38 -0
- package/dist/schema/rate-limits.js.map +1 -0
- package/dist/schema/rest.d.ts +31 -0
- package/dist/schema/rest.d.ts.map +1 -0
- package/dist/schema/rest.js +37 -0
- package/dist/schema/rest.js.map +1 -0
- package/dist/schema/sites.d.ts +365 -0
- package/dist/schema/sites.d.ts.map +1 -0
- package/dist/schema/sites.js +62 -0
- package/dist/schema/sites.js.map +1 -0
- package/dist/schema/tickets.d.ts +1118 -0
- package/dist/schema/tickets.d.ts.map +1 -0
- package/dist/schema/tickets.js +150 -0
- package/dist/schema/tickets.js.map +1 -0
- package/dist/schema/todos.d.ts +98 -0
- package/dist/schema/todos.d.ts.map +1 -0
- package/dist/schema/todos.js +12 -0
- package/dist/schema/todos.js.map +1 -0
- package/dist/schema/users.d.ts +503 -0
- package/dist/schema/users.d.ts.map +1 -0
- package/dist/schema/users.js +75 -0
- package/dist/schema/users.js.map +1 -0
- package/dist/schema/vector.d.ts +9 -0
- package/dist/schema/vector.d.ts.map +1 -0
- package/dist/schema/vector.js +9 -0
- package/dist/schema/vector.js.map +1 -0
- package/dist/schema/waitlist.d.ts +151 -0
- package/dist/schema/waitlist.d.ts.map +1 -0
- package/dist/schema/waitlist.js +17 -0
- package/dist/schema/waitlist.js.map +1 -0
- package/dist/schema/yjs-documents.d.ts +116 -0
- package/dist/schema/yjs-documents.d.ts.map +1 -0
- package/dist/schema/yjs-documents.js +15 -0
- package/dist/schema/yjs-documents.js.map +1 -0
- package/dist/types/database.d.ts +740 -0
- package/dist/types/database.d.ts.map +1 -0
- package/dist/types/database.js +151 -0
- package/dist/types/database.js.map +1 -0
- package/dist/types/discover.d.ts +83 -0
- package/dist/types/discover.d.ts.map +1 -0
- package/dist/types/discover.js +271 -0
- package/dist/types/discover.js.map +1 -0
- package/dist/types/extract-relationships.d.ts +115 -0
- package/dist/types/extract-relationships.d.ts.map +1 -0
- package/dist/types/extract-relationships.js +455 -0
- package/dist/types/extract-relationships.js.map +1 -0
- package/dist/types/generate-contracts.d.ts +19 -0
- package/dist/types/generate-contracts.d.ts.map +1 -0
- package/dist/types/generate-contracts.js +128 -0
- package/dist/types/generate-contracts.js.map +1 -0
- package/dist/types/generate-zod-schemas.d.ts +20 -0
- package/dist/types/generate-zod-schemas.d.ts.map +1 -0
- package/dist/types/generate-zod-schemas.js +128 -0
- package/dist/types/generate-zod-schemas.js.map +1 -0
- package/dist/types/generate.d.ts +17 -0
- package/dist/types/generate.d.ts.map +1 -0
- package/dist/types/generate.js +298 -0
- package/dist/types/generate.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/introspect.d.ts +75 -0
- package/dist/types/introspect.d.ts.map +1 -0
- package/dist/types/introspect.js +187 -0
- package/dist/types/introspect.js.map +1 -0
- package/dist/types/stripe-schema.d.ts +893 -0
- package/dist/types/stripe-schema.d.ts.map +1 -0
- package/dist/types/stripe-schema.js +112 -0
- package/dist/types/stripe-schema.js.map +1 -0
- package/package.json +154 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Relationship Extraction Utility
|
|
4
|
+
*
|
|
5
|
+
* Automatically extracts relationships from Drizzle relations() calls.
|
|
6
|
+
* This eliminates the need to manually maintain hardcoded relationships.
|
|
7
|
+
* Uses TypeScript Compiler API for robust, semantic parsing.
|
|
8
|
+
*/
|
|
9
|
+
import * as ts from 'typescript';
|
|
10
|
+
import type { DiscoveredTable } from './discover.js';
|
|
11
|
+
export interface ExtractedRelationship {
|
|
12
|
+
foreignKeyName: string;
|
|
13
|
+
columns: string[];
|
|
14
|
+
isOneToOne: boolean;
|
|
15
|
+
referencedRelation: string;
|
|
16
|
+
referencedColumns: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface TableRelationships {
|
|
19
|
+
tableVariableName: string;
|
|
20
|
+
relationships: ExtractedRelationship[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parse error with location information
|
|
24
|
+
*/
|
|
25
|
+
export interface ParseError {
|
|
26
|
+
file: string;
|
|
27
|
+
message: string;
|
|
28
|
+
position?: {
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
};
|
|
32
|
+
node?: string;
|
|
33
|
+
context?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Result of relationship extraction with errors
|
|
37
|
+
*/
|
|
38
|
+
export interface ExtractionResult {
|
|
39
|
+
relationships: TableRelationships[];
|
|
40
|
+
errors: ParseError[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Converts camelCase to snake_case
|
|
44
|
+
* @internal Exported for testing purposes
|
|
45
|
+
*/
|
|
46
|
+
export declare function camelToSnake(str: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Generates foreign key name from relationship
|
|
49
|
+
* Format: <table>_<column>_<referenced_table>_<referenced_column>_fk
|
|
50
|
+
* @internal Exported for testing purposes
|
|
51
|
+
*/
|
|
52
|
+
export declare function generateForeignKeyName(tableName: string, column: string, referencedTable: string, referencedColumn: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Converts table variable name to database table name
|
|
55
|
+
* @internal Exported for testing purposes
|
|
56
|
+
*/
|
|
57
|
+
export declare function getTableName(variableName: string, tables: DiscoveredTable[]): string;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a ParseError with position information from source file
|
|
60
|
+
* @internal Exported for testing purposes
|
|
61
|
+
*/
|
|
62
|
+
export declare function createParseError(sourceFile: ts.SourceFile, node: ts.Node | null, message: string, context?: string): ParseError;
|
|
63
|
+
/**
|
|
64
|
+
* Parses a TypeScript source file using TypeScript Compiler API
|
|
65
|
+
* @internal Exported for testing purposes
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseSourceFile(filePath: string): ts.SourceFile;
|
|
68
|
+
/**
|
|
69
|
+
* Resolves column name from a TypeScript property access expression
|
|
70
|
+
* Handles: sessions.userId -> userId -> user_id
|
|
71
|
+
* @internal Exported for testing purposes
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveColumnName(expr: ts.Expression, expectedTableVar: string): string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Extracts column names from an array literal expression
|
|
76
|
+
* Handles: [sessions.userId, sessions.otherColumn]
|
|
77
|
+
* Detects and warns about unsupported patterns (spreads, nested access, etc.)
|
|
78
|
+
* @internal Exported for testing purposes
|
|
79
|
+
*/
|
|
80
|
+
export declare function extractArrayElements(arrayExpr: ts.ArrayLiteralExpression, expectedTableVar: string, sourceFile: ts.SourceFile, context: string, errors: ParseError[]): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Finds all relations() calls in a single AST traversal
|
|
83
|
+
* Returns a map of table variable name to relations() call expression
|
|
84
|
+
*
|
|
85
|
+
* Performance: O(M) where M = AST nodes (single pass)
|
|
86
|
+
* @internal Exported for testing purposes
|
|
87
|
+
*/
|
|
88
|
+
export declare function findAllRelationsCalls(sourceFile: ts.SourceFile): Map<string, ts.CallExpression>;
|
|
89
|
+
export declare function extractRelationsObject(relationsCall: ts.CallExpression): ts.ObjectLiteralExpression | null;
|
|
90
|
+
/**
|
|
91
|
+
* Parses a single one() relationship from a property assignment
|
|
92
|
+
* Handles: relationName: one(referencedTable, { fields: [...], references: [...] })
|
|
93
|
+
* Detects unsupported patterns (computed properties, spreads, etc.)
|
|
94
|
+
* @internal Exported for testing purposes
|
|
95
|
+
*/
|
|
96
|
+
export declare function parseOneRelationship(prop: ts.PropertyAssignment, sourceTable: string, tables: DiscoveredTable[], sourceFile: ts.SourceFile, errors: ParseError[]): ExtractedRelationship | null;
|
|
97
|
+
/**
|
|
98
|
+
* Extracts all one() relationships from a relations object
|
|
99
|
+
* Detects unsupported patterns and collects errors
|
|
100
|
+
* @internal Exported for testing purposes
|
|
101
|
+
*/
|
|
102
|
+
export declare function extractOneRelationships(relationsObj: ts.ObjectLiteralExpression, sourceTable: string, tables: DiscoveredTable[], sourceFile: ts.SourceFile, errors: ParseError[]): ExtractedRelationship[];
|
|
103
|
+
/**
|
|
104
|
+
* Validates extracted relationships against discovered tables
|
|
105
|
+
* @internal Exported for testing purposes
|
|
106
|
+
*/
|
|
107
|
+
export declare function validateRelationships(relationships: TableRelationships[], tables: DiscoveredTable[]): ParseError[];
|
|
108
|
+
/**
|
|
109
|
+
* Extracts all relationships from core/index.ts using AST
|
|
110
|
+
*
|
|
111
|
+
* Performance: Single AST traversal (O(M)) instead of N traversals (O(N×M))
|
|
112
|
+
* Returns structured result with relationships and errors
|
|
113
|
+
*/
|
|
114
|
+
export declare function extractRelationships(tables: DiscoveredTable[]): ExtractionResult;
|
|
115
|
+
//# sourceMappingURL=extract-relationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-relationships.d.ts","sourceRoot":"","sources":["../../src/types/extract-relationships.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAKpD,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,iBAAiB,EAAE,MAAM,EAAE,CAAA;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,EAAE,MAAM,CAAA;IACzB,aAAa,EAAE,qBAAqB,EAAE,CAAA;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,kBAAkB,EAAE,CAAA;IACnC,MAAM,EAAE,UAAU,EAAE,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAER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wBAAgB,uBAAuB,CACrC,YAAY,EAAE,EAAE,CAAC,uBAAuB,EACxC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,eAAe,EAAE,EACzB,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,MAAM,EAAE,UAAU,EAAE,GACnB,qBAAqB,EAAE,CAwBzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,kBAAkB,EAAE,EACnC,MAAM,EAAE,eAAe,EAAE,GACxB,UAAU,EAAE,CA+Dd;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAyFhF"}
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Relationship Extraction Utility
|
|
4
|
+
*
|
|
5
|
+
* Automatically extracts relationships from Drizzle relations() calls.
|
|
6
|
+
* This eliminates the need to manually maintain hardcoded relationships.
|
|
7
|
+
* Uses TypeScript Compiler API for robust, semantic parsing.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { logger } from '@revealui/utils/logger';
|
|
13
|
+
import * as ts from 'typescript';
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
/**
|
|
17
|
+
* Converts camelCase to snake_case
|
|
18
|
+
* @internal Exported for testing purposes
|
|
19
|
+
*/
|
|
20
|
+
export function camelToSnake(str) {
|
|
21
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generates foreign key name from relationship
|
|
25
|
+
* Format: <table>_<column>_<referenced_table>_<referenced_column>_fk
|
|
26
|
+
* @internal Exported for testing purposes
|
|
27
|
+
*/
|
|
28
|
+
export function generateForeignKeyName(tableName, column, referencedTable, referencedColumn) {
|
|
29
|
+
return `${tableName}_${column}_${referencedTable}_${referencedColumn}_fk`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts table variable name to database table name
|
|
33
|
+
* @internal Exported for testing purposes
|
|
34
|
+
*/
|
|
35
|
+
export function getTableName(variableName, tables) {
|
|
36
|
+
const table = tables.find((t) => t.variableName === variableName);
|
|
37
|
+
return table ? table.tableName : camelToSnake(variableName);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a ParseError with position information from source file
|
|
41
|
+
* @internal Exported for testing purposes
|
|
42
|
+
*/
|
|
43
|
+
export function createParseError(sourceFile, node, message, context) {
|
|
44
|
+
const error = {
|
|
45
|
+
file: sourceFile.fileName,
|
|
46
|
+
message,
|
|
47
|
+
};
|
|
48
|
+
if (context) {
|
|
49
|
+
error.context = context;
|
|
50
|
+
}
|
|
51
|
+
if (node) {
|
|
52
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
53
|
+
error.position = {
|
|
54
|
+
line: pos.line + 1, // 1-indexed
|
|
55
|
+
column: pos.character + 1, // 1-indexed
|
|
56
|
+
};
|
|
57
|
+
error.node = ts.SyntaxKind[node.kind];
|
|
58
|
+
}
|
|
59
|
+
return error;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parses a TypeScript source file using TypeScript Compiler API
|
|
63
|
+
* @internal Exported for testing purposes
|
|
64
|
+
*/
|
|
65
|
+
export function parseSourceFile(filePath) {
|
|
66
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
67
|
+
return ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolves column name from a TypeScript property access expression
|
|
71
|
+
* Handles: sessions.userId -> userId -> user_id
|
|
72
|
+
* @internal Exported for testing purposes
|
|
73
|
+
*/
|
|
74
|
+
export function resolveColumnName(expr, expectedTableVar) {
|
|
75
|
+
// Check if it's a property access expression like sessions.userId
|
|
76
|
+
if (ts.isPropertyAccessExpression(expr)) {
|
|
77
|
+
// Check if the object is the expected table variable
|
|
78
|
+
if (ts.isIdentifier(expr.expression)) {
|
|
79
|
+
const tableVar = expr.expression.text;
|
|
80
|
+
if (tableVar === expectedTableVar) {
|
|
81
|
+
// Extract the property name (column name in camelCase)
|
|
82
|
+
const columnVar = expr.name.text;
|
|
83
|
+
// Convert camelCase to snake_case for database column name
|
|
84
|
+
return camelToSnake(columnVar);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extracts column names from an array literal expression
|
|
92
|
+
* Handles: [sessions.userId, sessions.otherColumn]
|
|
93
|
+
* Detects and warns about unsupported patterns (spreads, nested access, etc.)
|
|
94
|
+
* @internal Exported for testing purposes
|
|
95
|
+
*/
|
|
96
|
+
export function extractArrayElements(arrayExpr, expectedTableVar, sourceFile, context, errors) {
|
|
97
|
+
const columns = [];
|
|
98
|
+
for (const element of arrayExpr.elements) {
|
|
99
|
+
// Detect unsupported spread elements
|
|
100
|
+
if (ts.isSpreadElement(element)) {
|
|
101
|
+
errors.push(createParseError(sourceFile, element, `Spread operator in array is not supported`, context));
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
// Detect nested property access (e.g., sessions.user.profile)
|
|
105
|
+
if (ts.isPropertyAccessExpression(element)) {
|
|
106
|
+
let depth = 0;
|
|
107
|
+
let current = element;
|
|
108
|
+
while (ts.isPropertyAccessExpression(current)) {
|
|
109
|
+
depth++;
|
|
110
|
+
current = current.expression;
|
|
111
|
+
}
|
|
112
|
+
if (depth > 1) {
|
|
113
|
+
errors.push(createParseError(sourceFile, element, `Nested property access (depth ${depth}) is not supported - only direct table.column access`, context));
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Detect computed property access (e.g., sessions[someVar])
|
|
118
|
+
if (ts.isElementAccessExpression(element)) {
|
|
119
|
+
errors.push(createParseError(sourceFile, element, `Computed property access is not supported - only direct table.column access`, context));
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const columnName = resolveColumnName(element, expectedTableVar);
|
|
123
|
+
if (columnName) {
|
|
124
|
+
columns.push(columnName);
|
|
125
|
+
}
|
|
126
|
+
else if (!ts.isIdentifier(element)) {
|
|
127
|
+
// Not a simple property access - warn
|
|
128
|
+
errors.push(createParseError(sourceFile, element, `Unsupported expression type in array - only table.column references are supported`, context));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return columns;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Finds all relations() calls in a single AST traversal
|
|
135
|
+
* Returns a map of table variable name to relations() call expression
|
|
136
|
+
*
|
|
137
|
+
* Performance: O(M) where M = AST nodes (single pass)
|
|
138
|
+
* @internal Exported for testing purposes
|
|
139
|
+
*/
|
|
140
|
+
export function findAllRelationsCalls(sourceFile) {
|
|
141
|
+
const results = new Map();
|
|
142
|
+
function visit(node) {
|
|
143
|
+
// Look for VariableStatement with export modifier
|
|
144
|
+
if (ts.isVariableStatement(node)) {
|
|
145
|
+
if (node.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
146
|
+
node.declarationList.declarations.forEach((decl) => {
|
|
147
|
+
if (ts.isIdentifier(decl.name) && decl.initializer) {
|
|
148
|
+
// Check if initializer is a call to relations()
|
|
149
|
+
if (ts.isCallExpression(decl.initializer)) {
|
|
150
|
+
const callExpr = decl.initializer;
|
|
151
|
+
// Check if the function being called is 'relations'
|
|
152
|
+
if (ts.isIdentifier(callExpr.expression)) {
|
|
153
|
+
if (callExpr.expression.text === 'relations') {
|
|
154
|
+
// Extract table variable name from first argument
|
|
155
|
+
const firstArg = callExpr.arguments[0];
|
|
156
|
+
if (firstArg && ts.isIdentifier(firstArg)) {
|
|
157
|
+
const tableVar = firstArg.text;
|
|
158
|
+
results.set(tableVar, callExpr);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
ts.forEachChild(node, visit);
|
|
168
|
+
}
|
|
169
|
+
ts.forEachChild(sourceFile, visit);
|
|
170
|
+
return results;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Extracts the object literal from the arrow function in relations() call
|
|
174
|
+
* Handles: relations(table, ({ one, many }) => ({ ... }))
|
|
175
|
+
* @internal Exported for testing purposes
|
|
176
|
+
*/
|
|
177
|
+
/** Recursively unwrap parenthesized expressions to find an object literal */
|
|
178
|
+
function unwrapToObjectLiteral(node) {
|
|
179
|
+
if (ts.isObjectLiteralExpression(node))
|
|
180
|
+
return node;
|
|
181
|
+
if (ts.isParenthesizedExpression(node))
|
|
182
|
+
return unwrapToObjectLiteral(node.expression);
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
export function extractRelationsObject(relationsCall) {
|
|
186
|
+
// relations() call should have a second argument (the arrow function)
|
|
187
|
+
if (relationsCall.arguments.length < 2)
|
|
188
|
+
return null;
|
|
189
|
+
const secondArg = relationsCall.arguments[1];
|
|
190
|
+
if (!secondArg)
|
|
191
|
+
return null;
|
|
192
|
+
// Check if second argument is an arrow function
|
|
193
|
+
if (ts.isArrowFunction(secondArg)) {
|
|
194
|
+
// Recursively unwrap parenthesized expressions to find the object literal
|
|
195
|
+
return unwrapToObjectLiteral(secondArg.body);
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Parses a single one() relationship from a property assignment
|
|
201
|
+
* Handles: relationName: one(referencedTable, { fields: [...], references: [...] })
|
|
202
|
+
* Detects unsupported patterns (computed properties, spreads, etc.)
|
|
203
|
+
* @internal Exported for testing purposes
|
|
204
|
+
*/
|
|
205
|
+
export function parseOneRelationship(prop, sourceTable, tables, sourceFile, errors) {
|
|
206
|
+
// Detect computed property names (not supported)
|
|
207
|
+
if (ts.isComputedPropertyName(prop.name)) {
|
|
208
|
+
errors.push(createParseError(sourceFile, prop.name, `Computed property name is not supported - only literal property names are supported`, `Table: ${sourceTable}`));
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
// Check if the value is a call to one()
|
|
212
|
+
if (!ts.isCallExpression(prop.initializer))
|
|
213
|
+
return null;
|
|
214
|
+
const callExpr = prop.initializer;
|
|
215
|
+
// Check if the function being called is 'one'
|
|
216
|
+
if (!ts.isIdentifier(callExpr.expression))
|
|
217
|
+
return null;
|
|
218
|
+
if (callExpr.expression.text !== 'one')
|
|
219
|
+
return null;
|
|
220
|
+
const relationName = ts.isIdentifier(prop.name) ? prop.name.text : 'unknown';
|
|
221
|
+
// one() call should have two arguments: (referencedTable, { fields, references })
|
|
222
|
+
if (callExpr.arguments.length < 2)
|
|
223
|
+
return null;
|
|
224
|
+
// First argument should be the referenced table variable
|
|
225
|
+
const referencedTableArg = callExpr.arguments[0];
|
|
226
|
+
if (!(referencedTableArg && ts.isIdentifier(referencedTableArg)))
|
|
227
|
+
return null;
|
|
228
|
+
const referencedTableVar = referencedTableArg.text;
|
|
229
|
+
// Second argument should be an object literal with fields and references
|
|
230
|
+
const configArg = callExpr.arguments[1];
|
|
231
|
+
if (!(configArg && ts.isObjectLiteralExpression(configArg)))
|
|
232
|
+
return null;
|
|
233
|
+
// Extract fields array
|
|
234
|
+
let fieldsArray = null;
|
|
235
|
+
let referencesArray = null;
|
|
236
|
+
for (const prop of configArg.properties) {
|
|
237
|
+
if (ts.isPropertyAssignment(prop)) {
|
|
238
|
+
if (ts.isIdentifier(prop.name)) {
|
|
239
|
+
if (prop.name.text === 'fields' && ts.isArrayLiteralExpression(prop.initializer)) {
|
|
240
|
+
fieldsArray = prop.initializer;
|
|
241
|
+
}
|
|
242
|
+
else if (prop.name.text === 'references' &&
|
|
243
|
+
ts.isArrayLiteralExpression(prop.initializer)) {
|
|
244
|
+
referencesArray = prop.initializer;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (!(fieldsArray && referencesArray))
|
|
250
|
+
return null;
|
|
251
|
+
// Extract column names from arrays with error tracking
|
|
252
|
+
const fieldsContext = `Table: ${sourceTable}, Relation: ${relationName}, fields`;
|
|
253
|
+
const referencesContext = `Table: ${sourceTable}, Relation: ${relationName}, references`;
|
|
254
|
+
const fieldColumns = extractArrayElements(fieldsArray, sourceTable, sourceFile, fieldsContext, errors);
|
|
255
|
+
const refColumns = extractArrayElements(referencesArray, referencedTableVar, sourceFile, referencesContext, errors);
|
|
256
|
+
if (fieldColumns.length === 0 || refColumns.length === 0)
|
|
257
|
+
return null;
|
|
258
|
+
// Build relationship object
|
|
259
|
+
const sourceTableName = getTableName(sourceTable, tables);
|
|
260
|
+
const referencedTableName = getTableName(referencedTableVar, tables);
|
|
261
|
+
const firstFieldColumn = fieldColumns[0];
|
|
262
|
+
const firstRefColumn = refColumns[0];
|
|
263
|
+
if (!(firstFieldColumn && firstRefColumn))
|
|
264
|
+
return null;
|
|
265
|
+
return {
|
|
266
|
+
foreignKeyName: generateForeignKeyName(sourceTableName, firstFieldColumn, referencedTableName, firstRefColumn),
|
|
267
|
+
columns: fieldColumns,
|
|
268
|
+
isOneToOne: true, // one() = isOneToOne: true
|
|
269
|
+
referencedRelation: referencedTableName,
|
|
270
|
+
referencedColumns: refColumns,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Extracts all one() relationships from a relations object
|
|
275
|
+
* Detects unsupported patterns and collects errors
|
|
276
|
+
* @internal Exported for testing purposes
|
|
277
|
+
*/
|
|
278
|
+
export function extractOneRelationships(relationsObj, sourceTable, tables, sourceFile, errors) {
|
|
279
|
+
const relationships = [];
|
|
280
|
+
// Iterate through properties in the relations object
|
|
281
|
+
for (const prop of relationsObj.properties) {
|
|
282
|
+
if (ts.isPropertyAssignment(prop)) {
|
|
283
|
+
const relationship = parseOneRelationship(prop, sourceTable, tables, sourceFile, errors);
|
|
284
|
+
if (relationship) {
|
|
285
|
+
relationships.push(relationship);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
// Shorthand property or method signature - warn
|
|
290
|
+
errors.push(createParseError(sourceFile, prop, `Only property assignments are supported in relations object - shorthand or method signatures are not supported`, `Table: ${sourceTable}`));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return relationships;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Validates extracted relationships against discovered tables
|
|
297
|
+
* @internal Exported for testing purposes
|
|
298
|
+
*/
|
|
299
|
+
export function validateRelationships(relationships, tables) {
|
|
300
|
+
const errors = [];
|
|
301
|
+
const tableNameMap = new Map(); // variableName -> tableName
|
|
302
|
+
for (const table of tables) {
|
|
303
|
+
tableNameMap.set(table.variableName, table.tableName);
|
|
304
|
+
}
|
|
305
|
+
const foreignKeyNames = new Set();
|
|
306
|
+
for (const tableRel of relationships) {
|
|
307
|
+
for (const rel of tableRel.relationships) {
|
|
308
|
+
// Validate referenced table exists
|
|
309
|
+
const referencedTableExists = Array.from(tableNameMap.values()).includes(rel.referencedRelation);
|
|
310
|
+
if (!referencedTableExists) {
|
|
311
|
+
errors.push({
|
|
312
|
+
file: 'core/index.ts', // Relationships come from core/index.ts
|
|
313
|
+
message: `Referenced table '${rel.referencedRelation}' does not exist`,
|
|
314
|
+
context: `Table: ${tableRel.tableVariableName}, FK: ${rel.foreignKeyName}`,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
// Validate foreign key name uniqueness
|
|
318
|
+
if (foreignKeyNames.has(rel.foreignKeyName)) {
|
|
319
|
+
errors.push({
|
|
320
|
+
file: 'core/index.ts',
|
|
321
|
+
message: `Duplicate foreign key name: ${rel.foreignKeyName}`,
|
|
322
|
+
context: `Table: ${tableRel.tableVariableName}`,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
foreignKeyNames.add(rel.foreignKeyName);
|
|
326
|
+
// Validate columns are not empty
|
|
327
|
+
if (rel.columns.length === 0) {
|
|
328
|
+
errors.push({
|
|
329
|
+
file: 'core/index.ts',
|
|
330
|
+
message: `Empty columns array in relationship`,
|
|
331
|
+
context: `Table: ${tableRel.tableVariableName}, FK: ${rel.foreignKeyName}`,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
// Validate referenced columns are not empty
|
|
335
|
+
if (rel.referencedColumns.length === 0) {
|
|
336
|
+
errors.push({
|
|
337
|
+
file: 'core/index.ts',
|
|
338
|
+
message: `Empty referencedColumns array in relationship`,
|
|
339
|
+
context: `Table: ${tableRel.tableVariableName}, FK: ${rel.foreignKeyName}`,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// Validate column count matches
|
|
343
|
+
if (rel.columns.length !== rel.referencedColumns.length) {
|
|
344
|
+
errors.push({
|
|
345
|
+
file: 'core/index.ts',
|
|
346
|
+
message: `Column count mismatch: ${rel.columns.length} columns vs ${rel.referencedColumns.length} referenced columns`,
|
|
347
|
+
context: `Table: ${tableRel.tableVariableName}, FK: ${rel.foreignKeyName}`,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return errors;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Extracts all relationships from core/index.ts using AST
|
|
356
|
+
*
|
|
357
|
+
* Performance: Single AST traversal (O(M)) instead of N traversals (O(N×M))
|
|
358
|
+
* Returns structured result with relationships and errors
|
|
359
|
+
*/
|
|
360
|
+
export function extractRelationships(tables) {
|
|
361
|
+
// Always resolve to src/schema/index.ts, regardless of whether running from src or dist
|
|
362
|
+
const packageRoot = join(__dirname, '../..');
|
|
363
|
+
const coreIndexPath = join(packageRoot, 'src/schema/index.ts');
|
|
364
|
+
const errors = [];
|
|
365
|
+
const results = [];
|
|
366
|
+
try {
|
|
367
|
+
const sourceFile = parseSourceFile(coreIndexPath);
|
|
368
|
+
// Single-pass extraction: find all relations() calls in one AST traversal
|
|
369
|
+
const relationsCallsMap = findAllRelationsCalls(sourceFile);
|
|
370
|
+
// Find all table variable names from tables list
|
|
371
|
+
const tableVars = tables.map((t) => t.variableName);
|
|
372
|
+
// Extract relationships from cached relations() calls
|
|
373
|
+
for (const tableVar of tableVars) {
|
|
374
|
+
const relationsCall = relationsCallsMap.get(tableVar);
|
|
375
|
+
if (relationsCall) {
|
|
376
|
+
const relationsObj = extractRelationsObject(relationsCall);
|
|
377
|
+
if (relationsObj) {
|
|
378
|
+
const relationships = extractOneRelationships(relationsObj, tableVar, tables, sourceFile, errors);
|
|
379
|
+
// Always create an entry, even if empty (for tables with no relationships)
|
|
380
|
+
results.push({
|
|
381
|
+
tableVariableName: tableVar,
|
|
382
|
+
relationships,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
// No relations object found - warn but don't fail
|
|
387
|
+
errors.push(createParseError(sourceFile, relationsCall, `No relations object found for table ${tableVar}`, `Table: ${tableVar}`));
|
|
388
|
+
results.push({
|
|
389
|
+
tableVariableName: tableVar,
|
|
390
|
+
relationships: [],
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
// No relations() call found - not an error, just missing (some tables have no relations)
|
|
396
|
+
// Don't add error, just create empty entry
|
|
397
|
+
results.push({
|
|
398
|
+
tableVariableName: tableVar,
|
|
399
|
+
relationships: [],
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// Note: We don't process many() relationships because:
|
|
404
|
+
// - many() relationships don't create FKs on the source table
|
|
405
|
+
// - They indicate the OTHER table has a FK pointing back
|
|
406
|
+
// - The relationship entry should only be on the table that HAS the FK
|
|
407
|
+
// - That relationship is already extracted from the one() call on the other table
|
|
408
|
+
// Validate extracted relationships
|
|
409
|
+
const validationErrors = validateRelationships(results, tables);
|
|
410
|
+
errors.push(...validationErrors);
|
|
411
|
+
return { relationships: results, errors };
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
// Critical error - file couldn't be parsed at all
|
|
415
|
+
errors.push({
|
|
416
|
+
file: coreIndexPath,
|
|
417
|
+
message: `Failed to parse source file: ${error instanceof Error ? error.message : String(error)}`,
|
|
418
|
+
});
|
|
419
|
+
// Return empty results for all tables on critical error
|
|
420
|
+
return {
|
|
421
|
+
relationships: tables.map((t) => ({
|
|
422
|
+
tableVariableName: t.variableName,
|
|
423
|
+
relationships: [],
|
|
424
|
+
})),
|
|
425
|
+
errors,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// CLI interface for testing
|
|
430
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
431
|
+
void import('./discover.js').then(({ discoverTables }) => {
|
|
432
|
+
const discoveryResult = discoverTables();
|
|
433
|
+
const { tables } = discoveryResult;
|
|
434
|
+
const extractionResult = extractRelationships(tables);
|
|
435
|
+
const { relationships } = extractionResult;
|
|
436
|
+
logger.info(`\n📊 Extracted relationships:\n`);
|
|
437
|
+
for (const tableRel of relationships) {
|
|
438
|
+
logger.info(` ${tableRel.tableVariableName}:`);
|
|
439
|
+
for (const rel of tableRel.relationships) {
|
|
440
|
+
logger.info(` - ${rel.foreignKeyName} (${rel.columns.join(', ')} → ${rel.referencedRelation}.${rel.referencedColumns.join(', ')}) [${rel.isOneToOne ? '1:1' : '1:N'}]`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
// Log errors if any
|
|
444
|
+
if (extractionResult.errors.length > 0) {
|
|
445
|
+
logger.warn('\n⚠️ Extraction errors:');
|
|
446
|
+
for (const error of extractionResult.errors) {
|
|
447
|
+
const location = error.position
|
|
448
|
+
? `${error.file}:${error.position.line}:${error.position.column}`
|
|
449
|
+
: error.file;
|
|
450
|
+
logger.warn(` - ${location}: ${error.message}${error.context ? ` (${error.context})` : ''}`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
//# sourceMappingURL=extract-relationships.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-relationships.js","sourceRoot":"","sources":["../../src/types/extract-relationships.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAGhC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAkCrC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAiB,EACjB,MAAc,EACd,eAAuB,EACvB,gBAAwB;IAExB,OAAO,GAAG,SAAS,IAAI,MAAM,IAAI,eAAe,IAAI,gBAAgB,KAAK,CAAA;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,YAAoB,EAAE,MAAyB;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,CAAA;IACjE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CA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K,CAAC,IAAI,CAAA;gBACd,MAAM,CAAC,IAAI,CACT,OAAO,QAAQ,KAAK,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACjF,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Contract Wrapper Generator
|
|
4
|
+
*
|
|
5
|
+
* Generates Contract wrappers for all auto-generated Zod schemas.
|
|
6
|
+
* Contracts provide a unified interface combining TypeScript types,
|
|
7
|
+
* Zod schemas, and runtime validation.
|
|
8
|
+
*
|
|
9
|
+
* Generated contracts include:
|
|
10
|
+
* - RowContract: For database row types
|
|
11
|
+
* - InsertContract: For database insert types
|
|
12
|
+
*
|
|
13
|
+
* Output: packages/contracts/src/generated/contracts.ts
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Generate Contract wrappers file from discovered tables
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateContracts(): void;
|
|
19
|
+
//# sourceMappingURL=generate-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-contracts.d.ts","sourceRoot":"","sources":["../../src/types/generate-contracts.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAuBH;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAyFxC"}
|