@takyonic/cli 1.0.2
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/README.md +37 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +107 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +98 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +2 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +77 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/pull.d.ts +3 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +100 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +135 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/dsl-to-json.d.ts +28 -0
- package/dist/dsl-to-json.d.ts.map +1 -0
- package/dist/dsl-to-json.js +69 -0
- package/dist/dsl-to-json.js.map +1 -0
- package/dist/generator.d.ts +19 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/generator.js +161 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.d.ts +36 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +234 -0
- package/dist/parser.js.map +1 -0
- package/dist/type-mapper.d.ts +17 -0
- package/dist/type-mapper.d.ts.map +1 -0
- package/dist/type-mapper.js +90 -0
- package/dist/type-mapper.js.map +1 -0
- package/generated/index.ts +89 -0
- package/package.json +33 -0
- package/src/commands/generate.ts +78 -0
- package/src/commands/init.ts +63 -0
- package/src/commands/inspect.ts +98 -0
- package/src/commands/pull.ts +68 -0
- package/src/commands/push.ts +106 -0
- package/src/dsl-to-json.ts +99 -0
- package/src/generator.ts +178 -0
- package/src/index.ts +32 -0
- package/src/parser.ts +285 -0
- package/src/test-bulk.ts +38 -0
- package/src/test-load.ts +28 -0
- package/src/type-mapper.ts +90 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSL to JSON Converter
|
|
3
|
+
* Converts parsed Takyonic DSL schema to JSON format expected by server
|
|
4
|
+
*/
|
|
5
|
+
import { TakyonicSchema } from './parser';
|
|
6
|
+
export interface ColumnSchema {
|
|
7
|
+
name: string;
|
|
8
|
+
data_type: string;
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
default_value?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IndexInfo {
|
|
13
|
+
name: string;
|
|
14
|
+
columns: string[];
|
|
15
|
+
unique: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TableSchema {
|
|
18
|
+
name: string;
|
|
19
|
+
columns: ColumnSchema[];
|
|
20
|
+
indexes?: IndexInfo[];
|
|
21
|
+
foreign_keys?: any[];
|
|
22
|
+
cache_ttl?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Convert Takyonic DSL schema to server JSON format
|
|
26
|
+
*/
|
|
27
|
+
export declare function dslToJson(schema: TakyonicSchema): TableSchema[];
|
|
28
|
+
//# sourceMappingURL=dsl-to-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsl-to-json.d.ts","sourceRoot":"","sources":["../src/dsl-to-json.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAG3D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,EAAE,CAE/D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DSL to JSON Converter
|
|
4
|
+
* Converts parsed Takyonic DSL schema to JSON format expected by server
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.dslToJson = dslToJson;
|
|
8
|
+
const type_mapper_1 = require("./type-mapper");
|
|
9
|
+
/**
|
|
10
|
+
* Convert Takyonic DSL schema to server JSON format
|
|
11
|
+
*/
|
|
12
|
+
function dslToJson(schema) {
|
|
13
|
+
return schema.tables.map(table => convertTable(table));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert a single table definition to server format
|
|
17
|
+
*/
|
|
18
|
+
function convertTable(table) {
|
|
19
|
+
const columns = [];
|
|
20
|
+
const indexes = [];
|
|
21
|
+
const primaryKeyColumns = [];
|
|
22
|
+
// Convert fields to columns
|
|
23
|
+
for (const field of table.fields) {
|
|
24
|
+
const postgresType = (0, type_mapper_1.dslTypeToPostgres)(field.type);
|
|
25
|
+
// Check if field is nullable (default to false, unless explicitly marked)
|
|
26
|
+
// For now, we'll assume all fields are non-nullable unless we add nullable decorator
|
|
27
|
+
const nullable = false;
|
|
28
|
+
columns.push({
|
|
29
|
+
name: field.name,
|
|
30
|
+
data_type: postgresType,
|
|
31
|
+
nullable,
|
|
32
|
+
default_value: field.decorators.default,
|
|
33
|
+
});
|
|
34
|
+
// Track primary key fields
|
|
35
|
+
if (field.decorators.primary) {
|
|
36
|
+
primaryKeyColumns.push(field.name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Create primary key index if we have primary key fields
|
|
40
|
+
if (primaryKeyColumns.length > 0) {
|
|
41
|
+
indexes.push({
|
|
42
|
+
name: `${table.name}_pkey`,
|
|
43
|
+
columns: primaryKeyColumns,
|
|
44
|
+
unique: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// Always ensure we have an 'id' column for Takyonic (if not present, add it)
|
|
48
|
+
const hasIdColumn = columns.some(col => col.name === 'id');
|
|
49
|
+
if (!hasIdColumn && primaryKeyColumns.length === 0) {
|
|
50
|
+
// Add id column if no primary key is defined
|
|
51
|
+
columns.unshift({
|
|
52
|
+
name: 'id',
|
|
53
|
+
data_type: 'text',
|
|
54
|
+
nullable: false,
|
|
55
|
+
});
|
|
56
|
+
indexes.push({
|
|
57
|
+
name: `${table.name}_pkey`,
|
|
58
|
+
columns: ['id'],
|
|
59
|
+
unique: true,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
name: table.name,
|
|
64
|
+
columns,
|
|
65
|
+
indexes: indexes.length > 0 ? indexes : undefined,
|
|
66
|
+
foreign_keys: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=dsl-to-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsl-to-json.js","sourceRoot":"","sources":["../src/dsl-to-json.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA6BH,8BAEC;AA5BD,+CAAkD;AAuBlD;;GAEG;AACH,SAAgB,SAAS,CAAC,MAAsB;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,YA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AI,EAAE,IAAI;YACV,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,OAAO;YAC1B,OAAO,EAAE,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO;QACP,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACjD,YAAY,EAAE,EAAE;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ColumnSchema {
|
|
2
|
+
name: string;
|
|
3
|
+
data_type: string;
|
|
4
|
+
nullable: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface TableSchema {
|
|
7
|
+
name: string;
|
|
8
|
+
columns: ColumnSchema[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generates TypeScript code from schema
|
|
12
|
+
*
|
|
13
|
+
* This generates type definitions that work with the @takyonic/sdk package.
|
|
14
|
+
* Instead of generating a full client, it produces interfaces that can be
|
|
15
|
+
* used with the SDK's generic table methods.
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateTypeScript(schema: TableSchema[]): string;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAyED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAwFhE"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTypeScript = generateTypeScript;
|
|
4
|
+
/**
|
|
5
|
+
* Maps PostgreSQL data types to TypeScript types
|
|
6
|
+
*/
|
|
7
|
+
function mapPostgresToTypeScript(dataType) {
|
|
8
|
+
const normalized = dataType.toLowerCase();
|
|
9
|
+
switch (normalized) {
|
|
10
|
+
case 'text':
|
|
11
|
+
case 'varchar':
|
|
12
|
+
case 'character varying':
|
|
13
|
+
case 'char':
|
|
14
|
+
case 'uuid':
|
|
15
|
+
return 'string';
|
|
16
|
+
case 'integer':
|
|
17
|
+
case 'int':
|
|
18
|
+
case 'int4':
|
|
19
|
+
case 'bigint':
|
|
20
|
+
case 'int8':
|
|
21
|
+
case 'numeric':
|
|
22
|
+
case 'decimal':
|
|
23
|
+
case 'double precision':
|
|
24
|
+
case 'real':
|
|
25
|
+
case 'float':
|
|
26
|
+
case 'smallint':
|
|
27
|
+
case 'int2':
|
|
28
|
+
return 'number';
|
|
29
|
+
case 'boolean':
|
|
30
|
+
case 'bool':
|
|
31
|
+
return 'boolean';
|
|
32
|
+
case 'jsonb':
|
|
33
|
+
case 'json':
|
|
34
|
+
return 'Record<string, unknown>';
|
|
35
|
+
case 'timestamp':
|
|
36
|
+
case 'timestamp without time zone':
|
|
37
|
+
case 'timestamp with time zone':
|
|
38
|
+
case 'date':
|
|
39
|
+
case 'time':
|
|
40
|
+
case 'time without time zone':
|
|
41
|
+
case 'time with time zone':
|
|
42
|
+
return 'Date';
|
|
43
|
+
default:
|
|
44
|
+
return 'unknown';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Converts table name to PascalCase for interface names
|
|
49
|
+
*/
|
|
50
|
+
function toPascalCase(str) {
|
|
51
|
+
return str
|
|
52
|
+
.split('_')
|
|
53
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
54
|
+
.join('');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generates TypeScript interface for a table
|
|
58
|
+
*/
|
|
59
|
+
function generateInterface(table) {
|
|
60
|
+
const interfaceName = toPascalCase(table.name);
|
|
61
|
+
const columns = table.columns
|
|
62
|
+
.map(col => {
|
|
63
|
+
const tsType = mapPostgresToTypeScript(col.data_type);
|
|
64
|
+
const optional = col.nullable ? '?' : '';
|
|
65
|
+
return ` ${col.name}${optional}: ${tsType};`;
|
|
66
|
+
})
|
|
67
|
+
.join('\n');
|
|
68
|
+
return `export interface ${interfaceName} {\n${columns}\n}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generates TypeScript code from schema
|
|
72
|
+
*
|
|
73
|
+
* This generates type definitions that work with the @takyonic/sdk package.
|
|
74
|
+
* Instead of generating a full client, it produces interfaces that can be
|
|
75
|
+
* used with the SDK's generic table methods.
|
|
76
|
+
*/
|
|
77
|
+
function generateTypeScript(schema) {
|
|
78
|
+
const interfaces = schema.map(generateInterface).join('\n\n');
|
|
79
|
+
// Generate table name type union
|
|
80
|
+
const tableNames = schema.map(t => `'${t.name}'`).join(' | ');
|
|
81
|
+
// Generate table type mapping
|
|
82
|
+
const tableTypeMap = schema
|
|
83
|
+
.map(t => ` ${t.name}: ${toPascalCase(t.name)};`)
|
|
84
|
+
.join('\n');
|
|
85
|
+
// Generate usage examples
|
|
86
|
+
const exampleTable = schema[0];
|
|
87
|
+
const exampleType = exampleTable ? toPascalCase(exampleTable.name) : 'YourTable';
|
|
88
|
+
const exampleName = exampleTable ? exampleTable.name : 'your_table';
|
|
89
|
+
const code = `/**
|
|
90
|
+
* Auto-generated by Takyonic CLI
|
|
91
|
+
*
|
|
92
|
+
* This file contains TypeScript interfaces for your database schema.
|
|
93
|
+
* Use these types with the @takyonic/sdk package for type-safe queries.
|
|
94
|
+
*
|
|
95
|
+
* Do not edit this file manually - regenerate with: takyonic-cli generate
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
import type { TakyonicClient } from '@takyonic/sdk';
|
|
99
|
+
|
|
100
|
+
// =============================================================================
|
|
101
|
+
// Table Interfaces
|
|
102
|
+
// =============================================================================
|
|
103
|
+
|
|
104
|
+
${interfaces}
|
|
105
|
+
|
|
106
|
+
// =============================================================================
|
|
107
|
+
// Type Utilities
|
|
108
|
+
// =============================================================================
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Union type of all table names in the schema
|
|
112
|
+
*/
|
|
113
|
+
export type TableName = ${tableNames || 'never'};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Mapping from table names to their interface types
|
|
117
|
+
*/
|
|
118
|
+
export interface TableTypes {
|
|
119
|
+
${tableTypeMap}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Helper type to get the interface type for a table name
|
|
124
|
+
*/
|
|
125
|
+
export type TableType<T extends TableName> = TableTypes[T];
|
|
126
|
+
|
|
127
|
+
// =============================================================================
|
|
128
|
+
// Usage Examples
|
|
129
|
+
// =============================================================================
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Example usage with @takyonic/sdk:
|
|
133
|
+
*
|
|
134
|
+
* \`\`\`typescript
|
|
135
|
+
* import { TakyonicClient } from '@takyonic/sdk';
|
|
136
|
+
* import type { ${exampleType} } from './generated';
|
|
137
|
+
*
|
|
138
|
+
* const db = new TakyonicClient({
|
|
139
|
+
* endpoint: 'http://localhost:8080',
|
|
140
|
+
* token: process.env.TAKYONIC_API_KEY!
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* // Type-safe queries
|
|
144
|
+
* const records = await db.table<${exampleType}>('${exampleName}').get();
|
|
145
|
+
*
|
|
146
|
+
* // Type-safe inserts
|
|
147
|
+
* await db.table<${exampleType}>('${exampleName}').insert({
|
|
148
|
+
* id: 'new-id',
|
|
149
|
+
* // ... other fields
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* // Type-safe search with filters
|
|
153
|
+
* const filtered = await db.table<${exampleType}>('${exampleName}')
|
|
154
|
+
* .where('id', '=', 'some-id')
|
|
155
|
+
* .get();
|
|
156
|
+
* \`\`\`
|
|
157
|
+
*/
|
|
158
|
+
`;
|
|
159
|
+
return code;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;AAyFA,gDAwFC;AAtKD;;GAEG;AACH,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAE1C,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS,CAAC;QACf,KAAK,mBAAmB,CAAC;QACzB,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,kBAAkB,CAAC;QACxB,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO,CAAC;QACb,KAAK,UAAU,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,MAAM;YACT,OAAO,SAAS,CAAC;QACnB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,yBAAyB,CAAC;QACnC,KAAK,WAAW,CAAC;QACjB,KAAK,6BAA6B,CAAC;QACnC,KAAK,0BAA0B,CAAC;QACh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,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE9D,8BAA8B;IAC9B,MAAM,YAAY,GAAG,MAAM;SACxB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SACjD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,0BAA0B;IAC1B,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IACjF,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;IAEpE,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;EAeb,UAAU;;;;;;;;;0BASc,UAAU,IAAI,OAAO;;;;;;EAM7C,YAAY;;;;;;;;;;;;;;;;;mBAiBK,WAAW;;;;;;;;oCAQM,WAAW,MAAM,WAAW;;;oBAG5C,WAAW,MAAM,WAAW;;;;;;qCAMX,WAAW,MAAM,WAAW;;;;;CAKhE,CAAC;IAEA,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
|
+
const inspect_1 = require("./commands/inspect");
|
|
10
|
+
const init_1 = require("./commands/init");
|
|
11
|
+
const generate_1 = require("./commands/generate");
|
|
12
|
+
const pull_1 = require("./commands/pull");
|
|
13
|
+
const push_1 = require("./commands/push");
|
|
14
|
+
// Load environment variables
|
|
15
|
+
dotenv_1.default.config();
|
|
16
|
+
const program = new commander_1.Command();
|
|
17
|
+
program
|
|
18
|
+
.name('takyonic-cli')
|
|
19
|
+
.description('⚡ Takyonic CLI - High-performance Data Framework for PostgreSQL')
|
|
20
|
+
.version('1.0.0');
|
|
21
|
+
program.addCommand(init_1.initCommand);
|
|
22
|
+
program.addCommand(generate_1.generateCommand);
|
|
23
|
+
program.addCommand(pull_1.pullCommand);
|
|
24
|
+
program.addCommand(push_1.pushCommand);
|
|
25
|
+
program
|
|
26
|
+
.command('inspect')
|
|
27
|
+
.description('Inspect database schema via Takyonic server API')
|
|
28
|
+
.action(inspect_1.inspectCommand);
|
|
29
|
+
program.parse();
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,oDAA4B;AAC5B,gDAAoD;AACpD,0CAA8C;AAC9C,kDAAsD;AACtD,0CAA8C;AAC9C,0CAA8C;AAE9C,6BAA6B;AAC7B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CAAC,iEAAiE,CAAC;KAC9E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,0BAAe,CAAC,CAAC;AACpC,OAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,kBAAW,CAAC,CAAC;AAEhC,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,iDAAiD,CAAC;KAC9D,MAAM,CAAC,wBAAc,CAAC,CAAC;AAE1B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takyonic DSL Parser
|
|
3
|
+
* Parses .takyonic schema files into structured data
|
|
4
|
+
*/
|
|
5
|
+
export interface EngineConfig {
|
|
6
|
+
provider: string;
|
|
7
|
+
db?: string;
|
|
8
|
+
cache?: string;
|
|
9
|
+
port?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TableField {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
decorators: {
|
|
15
|
+
primary?: boolean;
|
|
16
|
+
default?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface TableDefinition {
|
|
20
|
+
name: string;
|
|
21
|
+
fields: TableField[];
|
|
22
|
+
}
|
|
23
|
+
export interface TakyonicSchema {
|
|
24
|
+
engine: EngineConfig;
|
|
25
|
+
tables: TableDefinition[];
|
|
26
|
+
}
|
|
27
|
+
export declare class ParseError extends Error {
|
|
28
|
+
line?: number | undefined;
|
|
29
|
+
column?: number | undefined;
|
|
30
|
+
constructor(message: string, line?: number | undefined, column?: number | undefined);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse a Takyonic DSL file into structured schema
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseTakyonicSchema(content: string): TakyonicSchema;
|
|
36
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,qBAAa,UAAW,SAAQ,KAAK;IACC,IAAI,CAAC,EAAE,MAAM;IAAS,MAAM,CAAC,EAAE,MAAM;gBAA7D,OAAO,EAAE,MAAM,EAAS,IAAI,CAAC,EAAE,MAAM,YAAA,EAAS,MAAM,CAAC,EAAE,MAAM,YAAA;CAI1E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAmDnE"}
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Takyonic DSL Parser
|
|
4
|
+
* Parses .takyonic schema files into structured data
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ParseError = void 0;
|
|
8
|
+
exports.parseTakyonicSchema = parseTakyonicSchema;
|
|
9
|
+
class ParseError extends Error {
|
|
10
|
+
line;
|
|
11
|
+
column;
|
|
12
|
+
constructor(message, line, column) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.line = line;
|
|
15
|
+
this.column = column;
|
|
16
|
+
this.name = 'ParseError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ParseError = ParseError;
|
|
20
|
+
/**
|
|
21
|
+
* Parse a Takyonic DSL file into structured schema
|
|
22
|
+
*/
|
|
23
|
+
function parseTakyonicSchema(content) {
|
|
24
|
+
const lines = content.split('\n');
|
|
25
|
+
let currentLine = 0;
|
|
26
|
+
let currentColumn = 0;
|
|
27
|
+
const schema = {
|
|
28
|
+
engine: { provider: 'takyonic' },
|
|
29
|
+
tables: [],
|
|
30
|
+
};
|
|
31
|
+
let i = 0;
|
|
32
|
+
while (i < lines.length) {
|
|
33
|
+
const line = lines[i].trim();
|
|
34
|
+
currentLine = i + 1;
|
|
35
|
+
// Skip empty lines and comments
|
|
36
|
+
if (!line || line.startsWith('//')) {
|
|
37
|
+
i++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// Parse engine block
|
|
41
|
+
if (line.startsWith('engine')) {
|
|
42
|
+
const engineEnd = findBlockEnd(lines, i);
|
|
43
|
+
schema.engine = parseEngineBlock(lines.slice(i, engineEnd + 1));
|
|
44
|
+
i = engineEnd + 1;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// Parse table definitions
|
|
48
|
+
if (line.startsWith('table')) {
|
|
49
|
+
const tableEnd = findBlockEnd(lines, i);
|
|
50
|
+
const table = parseTableBlock(lines.slice(i, tableEnd + 1));
|
|
51
|
+
schema.tables.push(table);
|
|
52
|
+
i = tableEnd + 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
i++;
|
|
56
|
+
}
|
|
57
|
+
// Validate engine has provider
|
|
58
|
+
if (!schema.engine.provider) {
|
|
59
|
+
throw new ParseError('Engine block must specify provider', currentLine);
|
|
60
|
+
}
|
|
61
|
+
if (schema.engine.provider !== 'takyonic') {
|
|
62
|
+
throw new ParseError('Provider must be "takyonic"', currentLine);
|
|
63
|
+
}
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Find the closing brace for a block starting at startLine
|
|
68
|
+
*/
|
|
69
|
+
function findBlockEnd(lines, startLine) {
|
|
70
|
+
let depth = 0;
|
|
71
|
+
let foundOpen = false;
|
|
72
|
+
for (let i = startLine; i < lines.length; i++) {
|
|
73
|
+
const line = lines[i];
|
|
74
|
+
for (let j = 0; j < line.length; j++) {
|
|
75
|
+
if (line[j] === '{') {
|
|
76
|
+
depth++;
|
|
77
|
+
foundOpen = true;
|
|
78
|
+
}
|
|
79
|
+
else if (line[j] === '}') {
|
|
80
|
+
depth--;
|
|
81
|
+
if (foundOpen && depth === 0) {
|
|
82
|
+
return i;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
throw new ParseError('Unclosed block', startLine + 1);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Parse engine block
|
|
91
|
+
*/
|
|
92
|
+
function parseEngineBlock(lines) {
|
|
93
|
+
const config = { provider: 'takyonic' };
|
|
94
|
+
const content = lines.join('\n');
|
|
95
|
+
// Extract provider
|
|
96
|
+
const providerMatch = content.match(/provider\s*=\s*"([^"]+)"/);
|
|
97
|
+
if (providerMatch) {
|
|
98
|
+
config.provider = providerMatch[1];
|
|
99
|
+
}
|
|
100
|
+
// Extract db
|
|
101
|
+
const dbMatch = content.match(/db\s*=\s*(env\([^)]+\)|"[^"]+")/);
|
|
102
|
+
if (dbMatch) {
|
|
103
|
+
config.db = dbMatch[1];
|
|
104
|
+
}
|
|
105
|
+
// Extract cache
|
|
106
|
+
const cacheMatch = content.match(/cache\s*=\s*"([^"]+)"/);
|
|
107
|
+
if (cacheMatch) {
|
|
108
|
+
config.cache = cacheMatch[1];
|
|
109
|
+
}
|
|
110
|
+
// Extract port
|
|
111
|
+
const portMatch = content.match(/port\s*=\s*(\d+)/);
|
|
112
|
+
if (portMatch) {
|
|
113
|
+
config.port = parseInt(portMatch[1], 10);
|
|
114
|
+
}
|
|
115
|
+
return config;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Parse table block
|
|
119
|
+
*/
|
|
120
|
+
function parseTableBlock(lines) {
|
|
121
|
+
// Extract table name from first line
|
|
122
|
+
const firstLine = lines[0].trim();
|
|
123
|
+
const tableNameMatch = firstLine.match(/table\s+(\w+)\s*\{/);
|
|
124
|
+
if (!tableNameMatch) {
|
|
125
|
+
throw new ParseError('Invalid table definition', 1);
|
|
126
|
+
}
|
|
127
|
+
const tableName = tableNameMatch[1];
|
|
128
|
+
const fields = [];
|
|
129
|
+
// Parse field definitions (skip first and last lines which are table declaration and closing brace)
|
|
130
|
+
for (let i = 1; i < lines.length - 1; i++) {
|
|
131
|
+
const line = lines[i].trim();
|
|
132
|
+
// Skip empty lines and comments
|
|
133
|
+
if (!line || line.startsWith('//')) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const field = parseFieldLine(line);
|
|
137
|
+
if (field) {
|
|
138
|
+
fields.push(field);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
name: tableName,
|
|
143
|
+
fields,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Parse a single field line
|
|
148
|
+
* Supports both formats:
|
|
149
|
+
* - Space syntax: "id string @primary"
|
|
150
|
+
* - Colon syntax: "id: string @primary"
|
|
151
|
+
* Example: "price int @default(now())"
|
|
152
|
+
*/
|
|
153
|
+
function parseFieldLine(line) {
|
|
154
|
+
// Remove comments
|
|
155
|
+
const cleanLine = line.split('//')[0].trim();
|
|
156
|
+
if (!cleanLine) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
// Extract decorators first (they start with @)
|
|
160
|
+
const decorators = {};
|
|
161
|
+
const decoratorPattern = /@(\w+)/g;
|
|
162
|
+
let decoratorMatch;
|
|
163
|
+
while ((decoratorMatch = decoratorPattern.exec(cleanLine)) !== null) {
|
|
164
|
+
const decoratorName = decoratorMatch[1];
|
|
165
|
+
const decoratorStart = decoratorMatch.index + decoratorMatch[0].length;
|
|
166
|
+
if (decoratorName === 'primary') {
|
|
167
|
+
decorators.primary = true;
|
|
168
|
+
}
|
|
169
|
+
else if (decoratorName === 'default') {
|
|
170
|
+
// Extract the value with balanced parentheses
|
|
171
|
+
const valueStart = cleanLine.indexOf('(', decoratorStart);
|
|
172
|
+
if (valueStart !== -1) {
|
|
173
|
+
const value = extractBalancedParens(cleanLine, valueStart);
|
|
174
|
+
if (value) {
|
|
175
|
+
// Remove outer quotes if present
|
|
176
|
+
decorators.default = value.replace(/^["']|["']$/g, '');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Remove all decorators from the line to parse name and type
|
|
182
|
+
const lineWithoutDecorators = cleanLine.replace(/@\w+(\([^)]*\)|\(.*?\)\))?/g, '').trim();
|
|
183
|
+
// Handle both "name: type" and "name type" formats
|
|
184
|
+
let name;
|
|
185
|
+
let type;
|
|
186
|
+
if (lineWithoutDecorators.includes(':')) {
|
|
187
|
+
// Colon syntax: "id: string" or "id : string"
|
|
188
|
+
const colonParts = lineWithoutDecorators.split(':').map(p => p.trim());
|
|
189
|
+
if (colonParts.length < 2 || !colonParts[0] || !colonParts[1]) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
name = colonParts[0];
|
|
193
|
+
type = colonParts[1].split(/\s+/)[0]; // Take first word after colon as type
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// Space syntax: "id string"
|
|
197
|
+
const parts = lineWithoutDecorators.split(/\s+/);
|
|
198
|
+
if (parts.length < 2) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
name = parts[0];
|
|
202
|
+
type = parts[1];
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
name,
|
|
206
|
+
type,
|
|
207
|
+
decorators,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Extract content within balanced parentheses
|
|
212
|
+
* For input "@default(now())" starting at '(' position, returns "now()"
|
|
213
|
+
*/
|
|
214
|
+
function extractBalancedParens(str, startPos) {
|
|
215
|
+
if (str[startPos] !== '(') {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
let depth = 0;
|
|
219
|
+
let start = startPos + 1;
|
|
220
|
+
for (let i = startPos; i < str.length; i++) {
|
|
221
|
+
if (str[i] === '(') {
|
|
222
|
+
depth++;
|
|
223
|
+
}
|
|
224
|
+
else if (str[i] === ')') {
|
|
225
|
+
depth--;
|
|
226
|
+
if (depth === 0) {
|
|
227
|
+
return str.substring(start, i);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// Unbalanced parentheses - return what we have
|
|
232
|
+
return str.substring(start);
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsCH,kDAmDC;AA7DD,MAAa,UAAW,SAAQ,KAAK;IACC;IAAsB;IAA1D,YAAY,OAAe,EAAS,IAAa,EAAS,MAAe;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QADmB,SAAI,GAAJ,IAAI,CAAS;QAAS,WAAM,GAAN,MAAM,CAAS;QAEvE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AALD,gCAKC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,MAAM,MAAM,GAAmB;QAC7B,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;QAChC,MAAM,EAAE,EAAE;KACX,C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IAAI,CAAC;QACd,CAAC;QACD,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAAC,GAAW,EAAE,QAAgB;IAC1D,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,QAAQ,GAAG,CAAC,CAAC;IAEzB,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACnB,KAAK,EAAE,CAAC;QACV,CAAC;aAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1B,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChB,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Mapping Utilities
|
|
3
|
+
* Maps between Takyonic DSL types and PostgreSQL types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Map Takyonic DSL type to PostgreSQL type
|
|
7
|
+
*/
|
|
8
|
+
export declare function dslTypeToPostgres(dslType: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Map PostgreSQL type to Takyonic DSL type
|
|
11
|
+
*/
|
|
12
|
+
export declare function postgresTypeToDsl(postgresType: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a type is nullable based on PostgreSQL type information
|
|
15
|
+
*/
|
|
16
|
+
export declare function isNullableType(postgresType: string, isNullable: boolean): boolean;
|
|
17
|
+
//# sourceMappingURL=type-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-mapper.d.ts","sourceRoot":"","sources":["../src/type-mapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2BzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAyC9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAEjF"}
|