@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.
Files changed (56) hide show
  1. package/README.md +37 -0
  2. package/dist/commands/generate.d.ts +3 -0
  3. package/dist/commands/generate.d.ts.map +1 -0
  4. package/dist/commands/generate.js +107 -0
  5. package/dist/commands/generate.js.map +1 -0
  6. package/dist/commands/init.d.ts +3 -0
  7. package/dist/commands/init.d.ts.map +1 -0
  8. package/dist/commands/init.js +98 -0
  9. package/dist/commands/init.js.map +1 -0
  10. package/dist/commands/inspect.d.ts +2 -0
  11. package/dist/commands/inspect.d.ts.map +1 -0
  12. package/dist/commands/inspect.js +77 -0
  13. package/dist/commands/inspect.js.map +1 -0
  14. package/dist/commands/pull.d.ts +3 -0
  15. package/dist/commands/pull.d.ts.map +1 -0
  16. package/dist/commands/pull.js +100 -0
  17. package/dist/commands/pull.js.map +1 -0
  18. package/dist/commands/push.d.ts +3 -0
  19. package/dist/commands/push.d.ts.map +1 -0
  20. package/dist/commands/push.js +135 -0
  21. package/dist/commands/push.js.map +1 -0
  22. package/dist/dsl-to-json.d.ts +28 -0
  23. package/dist/dsl-to-json.d.ts.map +1 -0
  24. package/dist/dsl-to-json.js +69 -0
  25. package/dist/dsl-to-json.js.map +1 -0
  26. package/dist/generator.d.ts +19 -0
  27. package/dist/generator.d.ts.map +1 -0
  28. package/dist/generator.js +161 -0
  29. package/dist/generator.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +30 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/parser.d.ts +36 -0
  35. package/dist/parser.d.ts.map +1 -0
  36. package/dist/parser.js +234 -0
  37. package/dist/parser.js.map +1 -0
  38. package/dist/type-mapper.d.ts +17 -0
  39. package/dist/type-mapper.d.ts.map +1 -0
  40. package/dist/type-mapper.js +90 -0
  41. package/dist/type-mapper.js.map +1 -0
  42. package/generated/index.ts +89 -0
  43. package/package.json +33 -0
  44. package/src/commands/generate.ts +78 -0
  45. package/src/commands/init.ts +63 -0
  46. package/src/commands/inspect.ts +98 -0
  47. package/src/commands/pull.ts +68 -0
  48. package/src/commands/push.ts +106 -0
  49. package/src/dsl-to-json.ts +99 -0
  50. package/src/generator.ts +178 -0
  51. package/src/index.ts +32 -0
  52. package/src/parser.ts +285 -0
  53. package/src/test-bulk.ts +38 -0
  54. package/src/test-load.ts +28 -0
  55. package/src/type-mapper.ts +90 -0
  56. package/tsconfig.json +21 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Type Mapping Utilities
3
+ * Maps between Takyonic DSL types and PostgreSQL types
4
+ */
5
+
6
+ /**
7
+ * Map Takyonic DSL type to PostgreSQL type
8
+ */
9
+ export function dslTypeToPostgres(dslType: string): string {
10
+ const normalized = dslType.toLowerCase().trim();
11
+
12
+ switch (normalized) {
13
+ case 'string':
14
+ return 'text';
15
+ case 'int':
16
+ case 'integer':
17
+ return 'integer';
18
+ case 'float':
19
+ case 'double':
20
+ return 'double precision';
21
+ case 'json':
22
+ return 'jsonb';
23
+ case 'bool':
24
+ case 'boolean':
25
+ return 'boolean';
26
+ case 'timestamp':
27
+ return 'timestamp';
28
+ case 'date':
29
+ return 'date';
30
+ case 'uuid':
31
+ return 'uuid';
32
+ default:
33
+ // Return as-is for unknown types (might be custom PostgreSQL types)
34
+ return normalized;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Map PostgreSQL type to Takyonic DSL type
40
+ */
41
+ export function postgresTypeToDsl(postgresType: string): string {
42
+ const normalized = postgresType.toLowerCase().trim();
43
+
44
+ switch (normalized) {
45
+ case 'text':
46
+ case 'varchar':
47
+ case 'character varying':
48
+ case 'char':
49
+ return 'string';
50
+ case 'integer':
51
+ case 'int':
52
+ case 'int4':
53
+ return 'int';
54
+ case 'bigint':
55
+ case 'int8':
56
+ return 'int';
57
+ case 'double precision':
58
+ case 'real':
59
+ case 'float':
60
+ return 'float';
61
+ case 'jsonb':
62
+ case 'json':
63
+ return 'json';
64
+ case 'boolean':
65
+ case 'bool':
66
+ return 'bool';
67
+ case 'timestamp':
68
+ case 'timestamp without time zone':
69
+ case 'timestamp with time zone':
70
+ return 'timestamp';
71
+ case 'date':
72
+ return 'date';
73
+ case 'uuid':
74
+ return 'uuid';
75
+ case 'numeric':
76
+ case 'decimal':
77
+ return 'float';
78
+ default:
79
+ // Return as-is for unknown types
80
+ return normalized;
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Check if a type is nullable based on PostgreSQL type information
86
+ */
87
+ export function isNullableType(postgresType: string, isNullable: boolean): boolean {
88
+ return isNullable;
89
+ }
90
+
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "lib": ["ES2022"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "moduleResolution": "node",
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist", "src/test-*.ts"]
20
+ }
21
+