@dbml/core 5.3.0 → 5.4.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.
Files changed (184) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +201 -1
  3. package/lib/export/DbmlExporter.js +5 -1
  4. package/lib/export/JsonExporter.js +0 -0
  5. package/lib/export/ModelExporter.js +0 -0
  6. package/lib/export/MysqlExporter.js +0 -0
  7. package/lib/export/OracleExporter.js +0 -0
  8. package/lib/export/PostgresExporter.js +0 -0
  9. package/lib/export/README.md +0 -0
  10. package/lib/export/SqlServerExporter.js +0 -0
  11. package/lib/export/index.js +0 -0
  12. package/lib/export/utils.js +0 -0
  13. package/lib/import/index.js +0 -0
  14. package/lib/index.js +7 -0
  15. package/lib/model_structure/check.js +0 -0
  16. package/lib/model_structure/config.js +0 -0
  17. package/lib/model_structure/database.js +0 -0
  18. package/lib/model_structure/dbState.js +0 -0
  19. package/lib/model_structure/element.js +0 -0
  20. package/lib/model_structure/endpoint.js +0 -0
  21. package/lib/model_structure/enum.js +0 -0
  22. package/lib/model_structure/enumValue.js +0 -0
  23. package/lib/model_structure/field.js +0 -0
  24. package/lib/model_structure/indexColumn.js +0 -0
  25. package/lib/model_structure/indexes.js +0 -0
  26. package/lib/model_structure/ref.js +0 -0
  27. package/lib/model_structure/schema.js +0 -0
  28. package/lib/model_structure/stickyNote.js +0 -0
  29. package/lib/model_structure/table.js +0 -0
  30. package/lib/model_structure/tableGroup.js +0 -0
  31. package/lib/model_structure/tablePartial.js +0 -0
  32. package/lib/model_structure/utils.js +0 -0
  33. package/lib/parse/ANTLR/ASTGeneration/AST.js +0 -0
  34. package/lib/parse/ANTLR/ASTGeneration/ParserErrorListener.js +0 -0
  35. package/lib/parse/ANTLR/ASTGeneration/SyntaxError.js +0 -0
  36. package/lib/parse/ANTLR/ASTGeneration/constants.js +0 -0
  37. package/lib/parse/ANTLR/ASTGeneration/helpers.js +0 -0
  38. package/lib/parse/ANTLR/ASTGeneration/index.js +0 -0
  39. package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +0 -0
  40. package/lib/parse/ANTLR/ASTGeneration/mssql/README.md +263 -157
  41. package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +0 -0
  42. package/lib/parse/ANTLR/ASTGeneration/mysql/README.md +262 -157
  43. package/lib/parse/ANTLR/ASTGeneration/oraclesql/OracleSQLASTGen.js +0 -0
  44. package/lib/parse/ANTLR/ASTGeneration/oraclesql/README.md +261 -157
  45. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLLexerBase.js +0 -0
  46. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLParserBase.js +0 -0
  47. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +0 -0
  48. package/lib/parse/ANTLR/ASTGeneration/postgres/README.md +252 -157
  49. package/lib/parse/ANTLR/ASTGeneration/snowflake/README.md +236 -157
  50. package/lib/parse/ANTLR/ASTGeneration/snowflake/SnowflakeASTGen.js +0 -0
  51. package/lib/parse/ANTLR/README.md +0 -0
  52. package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.g4 +0 -0
  53. package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.interp +0 -0
  54. package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.js +0 -0
  55. package/lib/parse/ANTLR/parsers/mssql/TSqlLexer.tokens +0 -0
  56. package/lib/parse/ANTLR/parsers/mssql/TSqlParser.g4 +0 -0
  57. package/lib/parse/ANTLR/parsers/mssql/TSqlParser.interp +0 -0
  58. package/lib/parse/ANTLR/parsers/mssql/TSqlParser.js +0 -0
  59. package/lib/parse/ANTLR/parsers/mssql/TSqlParser.tokens +0 -0
  60. package/lib/parse/ANTLR/parsers/mssql/TSqlParserVisitor.js +0 -0
  61. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.g4 +0 -0
  62. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.interp +0 -0
  63. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.js +0 -0
  64. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.tokens +0 -0
  65. package/lib/parse/ANTLR/parsers/mysql/MySqlLexerBase.js +0 -0
  66. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.g4 +0 -0
  67. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.interp +0 -0
  68. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.js +0 -0
  69. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.tokens +0 -0
  70. package/lib/parse/ANTLR/parsers/mysql/MySqlParserVisitor.js +0 -0
  71. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.g4 +0 -0
  72. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.interp +0 -0
  73. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.js +0 -0
  74. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexer.tokens +0 -0
  75. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlLexerBase.js +0 -0
  76. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.g4 +0 -0
  77. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.interp +0 -0
  78. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.js +0 -0
  79. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParser.tokens +0 -0
  80. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserBase.js +0 -0
  81. package/lib/parse/ANTLR/parsers/oraclesql/OracleSqlParserVisitor.js +0 -0
  82. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.g4 +0 -0
  83. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.interp +0 -0
  84. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.js +0 -0
  85. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.tokens +0 -0
  86. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.g4 +0 -0
  87. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.interp +0 -0
  88. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.js +0 -0
  89. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.tokens +0 -0
  90. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserVisitor.js +0 -0
  91. package/lib/parse/ANTLR/parsers/postgresql/README.md +0 -0
  92. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.g4 +0 -0
  93. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.interp +0 -0
  94. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.js +0 -0
  95. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.tokens +0 -0
  96. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.g4 +0 -0
  97. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.interp +0 -0
  98. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.js +0 -0
  99. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.tokens +0 -0
  100. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParserVisitor.js +0 -0
  101. package/lib/parse/Parser.js +0 -0
  102. package/lib/parse/buildParser.js +0 -0
  103. package/lib/parse/databaseGenerator.js +0 -0
  104. package/lib/parse/dbml/parser.pegjs +0 -0
  105. package/lib/parse/dbmlParser.js +0 -0
  106. package/lib/parse/error.js +0 -0
  107. package/lib/parse/mssql/base_parsers.js +0 -0
  108. package/lib/parse/mssql/column_definition/actions.js +0 -0
  109. package/lib/parse/mssql/column_definition/index.js +0 -0
  110. package/lib/parse/mssql/constraint_definition/actions.js +0 -0
  111. package/lib/parse/mssql/constraint_definition/index.js +0 -0
  112. package/lib/parse/mssql/expression.js +0 -0
  113. package/lib/parse/mssql/fk_definition/actions.js +0 -0
  114. package/lib/parse/mssql/fk_definition/index.js +0 -0
  115. package/lib/parse/mssql/index.js +0 -0
  116. package/lib/parse/mssql/index_definition/actions.js +0 -0
  117. package/lib/parse/mssql/index_definition/index.js +0 -0
  118. package/lib/parse/mssql/keyword_parsers.js +0 -0
  119. package/lib/parse/mssql/keyword_utils.js +0 -0
  120. package/lib/parse/mssql/statements/actions.js +0 -0
  121. package/lib/parse/mssql/statements/index.js +0 -0
  122. package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +0 -0
  123. package/lib/parse/mssql/statements/statement_types/alter_table/add/actions.js +0 -0
  124. package/lib/parse/mssql/statements/statement_types/alter_table/add/index.js +0 -0
  125. package/lib/parse/mssql/statements/statement_types/alter_table/index.js +0 -0
  126. package/lib/parse/mssql/statements/statement_types/comments/actions.js +0 -0
  127. package/lib/parse/mssql/statements/statement_types/comments/index.js +0 -0
  128. package/lib/parse/mssql/statements/statement_types/create_index/actions.js +0 -0
  129. package/lib/parse/mssql/statements/statement_types/create_index/index.js +0 -0
  130. package/lib/parse/mssql/statements/statement_types/create_table/actions.js +0 -0
  131. package/lib/parse/mssql/statements/statement_types/create_table/index.js +0 -0
  132. package/lib/parse/mssql/statements/statement_types/index.js +0 -0
  133. package/lib/parse/mssql/utils.js +0 -0
  134. package/lib/parse/mssql/whitespaces.js +0 -0
  135. package/lib/parse/mssqlParser.js +0 -0
  136. package/lib/parse/mysql/parser.pegjs +0 -0
  137. package/lib/parse/mysqlParser.js +0 -0
  138. package/lib/parse/postgresParser.js +0 -0
  139. package/lib/parse/postgresql/Base_rules.pegjs +0 -0
  140. package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +0 -0
  141. package/lib/parse/postgresql/Commands/Commands.pegjs +0 -0
  142. package/lib/parse/postgresql/Commands/Comment.pegjs +0 -0
  143. package/lib/parse/postgresql/Commands/Create_index.pegjs +0 -0
  144. package/lib/parse/postgresql/Commands/Create_table/Create_table.pegjs +0 -0
  145. package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +0 -0
  146. package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +0 -0
  147. package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +0 -0
  148. package/lib/parse/postgresql/Commands/Create_type/Create_type.pegjs +0 -0
  149. package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +0 -0
  150. package/lib/parse/postgresql/Commands/Create_type/Create_type_range.pegjs +0 -0
  151. package/lib/parse/postgresql/Commands/Ignore_syntax.pegjs +0 -0
  152. package/lib/parse/postgresql/Expression.pegjs +0 -0
  153. package/lib/parse/postgresql/InitializerUtils.pegjs +0 -0
  154. package/lib/parse/postgresql/Keywords.pegjs +0 -0
  155. package/lib/parse/postgresql/get_parser.js +0 -0
  156. package/lib/parse/postgresql/parser.pegjs +0 -0
  157. package/lib/parse/schemarb/parser.pegjs +0 -0
  158. package/lib/parse/schemarbParser.js +0 -0
  159. package/lib/transform/index.js +30 -0
  160. package/lib/utils/version.js +0 -0
  161. package/package.json +3 -3
  162. package/types/export/ModelExporter.d.ts +0 -0
  163. package/types/export/index.d.ts +0 -0
  164. package/types/import/index.d.ts +0 -0
  165. package/types/index.d.ts +2 -1
  166. package/types/model_structure/check.d.ts +0 -0
  167. package/types/model_structure/database.d.ts +0 -0
  168. package/types/model_structure/dbState.d.ts +0 -0
  169. package/types/model_structure/element.d.ts +0 -0
  170. package/types/model_structure/endpoint.d.ts +0 -0
  171. package/types/model_structure/enum.d.ts +0 -0
  172. package/types/model_structure/enumValue.d.ts +0 -0
  173. package/types/model_structure/field.d.ts +0 -0
  174. package/types/model_structure/indexColumn.d.ts +0 -0
  175. package/types/model_structure/indexes.d.ts +0 -0
  176. package/types/model_structure/ref.d.ts +0 -0
  177. package/types/model_structure/schema.d.ts +0 -0
  178. package/types/model_structure/stickyNote.d.ts +0 -0
  179. package/types/model_structure/table.d.ts +0 -0
  180. package/types/model_structure/tableGroup.d.ts +0 -0
  181. package/types/model_structure/tablePartial.d.ts +0 -0
  182. package/types/parse/Parser.d.ts +0 -0
  183. package/types/parse/error.d.ts +0 -0
  184. package/types/transform/index.d.ts +7 -0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renameTable = renameTable;
7
+ var _parse = require("@dbml/parse");
8
+ /**
9
+ * Renames a table in DBML code using symbol table and token-based replacement.
10
+ *
11
+ * @param {string | { schema?: string; table: string }} oldName - The current table name
12
+ * @param {string | { schema?: string; table: string }} newName - The new table name
13
+ * @param {string} dbmlCode - The DBML code containing the table
14
+ * @returns {string} The updated DBML code with the renamed table
15
+ *
16
+ * @example
17
+ * // String format
18
+ * renameTable('users', 'customers', dbmlCode);
19
+ * renameTable('public.users', 'auth.customers', dbmlCode);
20
+ *
21
+ * @example
22
+ * // Object format
23
+ * renameTable({ table: 'users' }, { table: 'customers' }, dbmlCode);
24
+ * renameTable({ schema: 'auth', table: 'users' }, { schema: 'auth', table: 'customers' }, dbmlCode);
25
+ */
26
+ function renameTable(oldName, newName, dbmlCode) {
27
+ var compiler = new _parse.Compiler();
28
+ compiler.setSource(dbmlCode);
29
+ return compiler.renameTable(oldName, newName);
30
+ }
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/core",
4
- "version": "5.3.0",
4
+ "version": "5.4.0",
5
5
  "description": "> TODO: description",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "lint:fix": "eslint --fix ."
36
36
  },
37
37
  "dependencies": {
38
- "@dbml/parse": "^5.3.0",
38
+ "@dbml/parse": "^5.4.0",
39
39
  "antlr4": "^4.13.1",
40
40
  "lodash": "^4.17.15",
41
41
  "parsimmon": "^1.13.0",
@@ -73,7 +73,7 @@
73
73
  "^lodash-es$": "lodash"
74
74
  }
75
75
  },
76
- "gitHead": "c8e67b627584b81d18c16a6f2983a92d75a326d9",
76
+ "gitHead": "e7837a6418602e2b9d5a350335b669155d5c7ad4",
77
77
  "engines": {
78
78
  "node": ">=16"
79
79
  }
File without changes
File without changes
File without changes
package/types/index.d.ts CHANGED
@@ -2,5 +2,6 @@ import ModelExporter from './export/ModelExporter';
2
2
  import Parser from './parse/Parser';
3
3
  import importer from './import';
4
4
  import exporter from './export';
5
- export { importer, exporter, ModelExporter, Parser };
5
+ import { renameTable } from './transform';
6
+ export { renameTable, importer, exporter, ModelExporter, Parser };
6
7
  export { CompilerDiagnostic, CompilerError as CompilerDiagnostics, EditorPosition, ErrorCode, WarningLevel, } from './parse/error';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export type TableNameInput = string | { schema?: string; table: string };
2
+
3
+ export function renameTable(
4
+ oldName: TableNameInput,
5
+ newName: TableNameInput,
6
+ dbmlCode: string
7
+ ): string;