db-modeling-markdown 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +168 -164
  2. package/dist/dialects/core/dbImportProvider.d.ts +5 -5
  3. package/dist/dialects/core/dbImportProvider.js +6 -6
  4. package/dist/dialects/core/dbProvider.d.ts +34 -34
  5. package/dist/dialects/core/dbProvider.js +119 -119
  6. package/dist/dialects/core/dbProvider.js.map +1 -1
  7. package/dist/dialects/core/dbUtils.d.ts +35 -35
  8. package/dist/dialects/core/dbUtils.js +157 -158
  9. package/dist/dialects/core/dbUtils.js.map +1 -1
  10. package/dist/dialects/core/providerFactory.d.ts +7 -7
  11. package/dist/dialects/core/providerFactory.js +63 -63
  12. package/dist/dialects/core/providerFactory.js.map +1 -1
  13. package/dist/dialects/db2/db2Provider.d.ts +19 -19
  14. package/dist/dialects/db2/db2Provider.js +185 -186
  15. package/dist/dialects/db2/db2Provider.js.map +1 -1
  16. package/dist/dialects/mariadb/mariaDbImportProvider.d.ts +19 -19
  17. package/dist/dialects/mariadb/mariaDbImportProvider.js +260 -253
  18. package/dist/dialects/mariadb/mariaDbImportProvider.js.map +1 -1
  19. package/dist/dialects/mariadb/mariaDbProvider.d.ts +18 -18
  20. package/dist/dialects/mariadb/mariaDbProvider.js +152 -153
  21. package/dist/dialects/mariadb/mariaDbProvider.js.map +1 -1
  22. package/dist/dialects/mariadb/mariaDbUtil.d.ts +6 -6
  23. package/dist/dialects/mariadb/mariaDbUtil.js +22 -22
  24. package/dist/dialects/mariadb/mariaDbUtil.js.map +1 -1
  25. package/dist/dialects/mssql/msSqlProvider.d.ts +21 -21
  26. package/dist/dialects/mssql/msSqlProvider.js +264 -265
  27. package/dist/dialects/mssql/msSqlProvider.js.map +1 -1
  28. package/dist/dialects/mysql/mySqlImportProvider.d.ts +3 -3
  29. package/dist/dialects/mysql/mySqlImportProvider.js +7 -7
  30. package/dist/dialects/mysql/mySqlProvider.d.ts +3 -3
  31. package/dist/dialects/mysql/mySqlProvider.js +7 -7
  32. package/dist/dialects/oracle/oracleProvider.d.ts +35 -35
  33. package/dist/dialects/oracle/oracleProvider.js +327 -327
  34. package/dist/dialects/oracle/oracleProvider.js.map +1 -1
  35. package/dist/dialects/postgresql/postgreSqlProvider.d.ts +19 -19
  36. package/dist/dialects/postgresql/postgreSqlProvider.js +172 -173
  37. package/dist/dialects/postgresql/postgreSqlProvider.js.map +1 -1
  38. package/dist/dialects/sqlite/sqliteSqlProvider.d.ts +23 -23
  39. package/dist/dialects/sqlite/sqliteSqlProvider.js +147 -148
  40. package/dist/dialects/sqlite/sqliteSqlProvider.js.map +1 -1
  41. package/dist/index.d.ts +10 -10
  42. package/dist/index.js +9 -9
  43. package/dist/lib/code-flow/codeFlow.d.ts +37 -37
  44. package/dist/lib/code-flow/codeFlow.js +61 -61
  45. package/dist/lib/markdown-object/markdownModel.d.ts +14 -14
  46. package/dist/lib/markdown-object/markdownModel.js +12 -12
  47. package/dist/lib/markdown-object/markdownModel.js.map +1 -1
  48. package/dist/lib/markdown-object/markdownReader.d.ts +39 -39
  49. package/dist/lib/markdown-object/markdownReader.js +261 -258
  50. package/dist/lib/markdown-object/markdownReader.js.map +1 -1
  51. package/dist/lib/markdown-object/markdownWriter.d.ts +36 -36
  52. package/dist/lib/markdown-object/markdownWriter.js +224 -223
  53. package/dist/lib/markdown-object/markdownWriter.js.map +1 -1
  54. package/dist/lib/markdown-object/readerContext.d.ts +12 -12
  55. package/dist/lib/markdown-object/readerContext.js +48 -48
  56. package/dist/lib/markdown-object/readerContext.js.map +1 -1
  57. package/dist/lib/utils/fileHelper.d.ts +14 -15
  58. package/dist/lib/utils/fileHelper.js +58 -57
  59. package/dist/lib/utils/fileHelper.js.map +1 -1
  60. package/dist/lib/utils/logger.d.ts +9 -9
  61. package/dist/lib/utils/logger.js +60 -60
  62. package/dist/lib/utils/logger.js.map +1 -1
  63. package/dist/lib/utils/markdownParser.d.ts +22 -22
  64. package/dist/lib/utils/markdownParser.js +99 -95
  65. package/dist/lib/utils/markdownParser.js.map +1 -1
  66. package/dist/lib/utils/sqlHelper.d.ts +3 -3
  67. package/dist/lib/utils/sqlHelper.js +23 -23
  68. package/dist/lib/utils/sqlHelper.js.map +1 -1
  69. package/dist/lib/utils/systemHelper.d.ts +2 -2
  70. package/dist/lib/utils/systemHelper.js +6 -6
  71. package/dist/lib/utils/textFileReader.d.ts +25 -25
  72. package/dist/lib/utils/textFileReader.js +57 -57
  73. package/dist/lib/utils/textFileReader.js.map +1 -1
  74. package/dist/lib/utils/textHelper.d.ts +21 -21
  75. package/dist/lib/utils/textHelper.js +75 -71
  76. package/dist/lib/utils/textHelper.js.map +1 -1
  77. package/dist/models/databaseTypes.d.ts +33 -33
  78. package/dist/models/databaseTypes.js +37 -37
  79. package/dist/models/databaseTypes.js.map +1 -1
  80. package/dist/models/dbColumn.d.ts +43 -43
  81. package/dist/models/dbColumn.js +2 -2
  82. package/dist/models/dbDiffModel.d.ts +43 -43
  83. package/dist/models/dbDiffModel.js +2 -2
  84. package/dist/models/dbForeignKey.d.ts +33 -33
  85. package/dist/models/dbForeignKey.js +2 -2
  86. package/dist/models/dbIndex.d.ts +28 -28
  87. package/dist/models/dbIndex.js +2 -2
  88. package/dist/models/dbIndexType.d.ts +8 -8
  89. package/dist/models/dbIndexType.js +12 -12
  90. package/dist/models/dbIndexType.js.map +1 -1
  91. package/dist/models/dbModel.d.ts +10 -10
  92. package/dist/models/dbModel.js +2 -2
  93. package/dist/models/dbPrimaryKey.d.ts +16 -16
  94. package/dist/models/dbPrimaryKey.js +2 -2
  95. package/dist/models/dbTable.d.ts +49 -49
  96. package/dist/models/dbTable.js +2 -2
  97. package/dist/models/dbTableMarkdown.d.ts +35 -34
  98. package/dist/models/dbTableMarkdown.js +2 -2
  99. package/dist/resources/mariadb/procAppUpgradeDB.sql +164 -0
  100. package/dist/resources/mariadb/sql-create-table-fk.njk +10 -0
  101. package/dist/resources/mariadb/sql-create-table.njk +12 -0
  102. package/dist/resources/mariadb/sql-create-tables.njk +9 -0
  103. package/dist/resources/mariadb/sql-drop-tables.njk +10 -0
  104. package/dist/resources/mariadb/sql-drop-then-create-tables.njk +4 -0
  105. package/dist/resources/mariadb/sql-upgrade-new-table.njk +15 -0
  106. package/dist/resources/mariadb/sql-upgrade-table-fk.njk +10 -0
  107. package/dist/resources/mariadb/sql-upgrade-table.njk +41 -0
  108. package/dist/resources/mariadb/sql-upgrade-tables.njk +19 -0
  109. package/dist/services/dbOptions.d.ts +35 -35
  110. package/dist/services/dbOptions.js +17 -17
  111. package/dist/services/dbmOptions.d.ts +28 -28
  112. package/dist/services/dbmOptions.js +34 -34
  113. package/dist/services/dbmService.d.ts +87 -87
  114. package/dist/services/dbmService.js +244 -246
  115. package/dist/services/dbmService.js.map +1 -1
  116. package/package.json +29 -34
  117. package/CHANGELOG.md +0 -81
  118. package/CONTRIBUTING.md +0 -82
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DbOptions = void 0;
4
- const databaseTypes_1 = require("../models/databaseTypes");
5
- /**
6
- * Options for database connection
7
- */
8
- class DbOptions {
9
- constructor() {
10
- /**
11
- * The database type
12
- * Default is `mariadb`
13
- */
14
- this.databaseType = databaseTypes_1.DatabaseTypes.mariadb;
15
- }
16
- }
17
- exports.DbOptions = DbOptions;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DbOptions = void 0;
4
+ const databaseTypes_1 = require("../models/databaseTypes");
5
+ /**
6
+ * Options for database connection
7
+ */
8
+ class DbOptions {
9
+ constructor() {
10
+ /**
11
+ * The database type
12
+ * Default is `mariadb`
13
+ */
14
+ this.databaseType = databaseTypes_1.DatabaseTypes.mariadb;
15
+ }
16
+ }
17
+ exports.DbOptions = DbOptions;
18
18
  //# sourceMappingURL=dbOptions.js.map
@@ -1,28 +1,28 @@
1
- import { DatabaseTypes } from '../models/databaseTypes';
2
- /**
3
- * Options for generation functions
4
- */
5
- export declare class DbmOptions {
6
- /**
7
- * The database type
8
- */
9
- database: DatabaseTypes;
10
- /**
11
- * The extension of table definition markdown files.
12
- * Default is `.db.md`
13
- */
14
- mdFileExtension: string;
15
- /**
16
- * The markdown file directory of the database model.
17
- */
18
- sourceFolder: string;
19
- /**
20
- * The path of the output file.
21
- */
22
- targetPath: string;
23
- /**
24
- * The markdown file directory of the previous database version.
25
- */
26
- previousVersionFolder: string;
27
- }
28
- export declare const DefaultOptions: DbmOptions;
1
+ import { DatabaseTypes } from '../models/databaseTypes';
2
+ /**
3
+ * Options for generation functions
4
+ */
5
+ export declare class DbmOptions {
6
+ /**
7
+ * The database type
8
+ */
9
+ database: DatabaseTypes;
10
+ /**
11
+ * The extension of table definition markdown files.
12
+ * Default is `.db.md`
13
+ */
14
+ mdFileExtension: string;
15
+ /**
16
+ * The markdown file directory of the database model.
17
+ */
18
+ sourceFolder: string;
19
+ /**
20
+ * The path of the output file.
21
+ */
22
+ targetPath: string;
23
+ /**
24
+ * The markdown file directory of the previous database version.
25
+ */
26
+ previousVersionFolder: string;
27
+ }
28
+ export declare const DefaultOptions: DbmOptions;
@@ -1,35 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultOptions = exports.DbmOptions = void 0;
4
- const databaseTypes_1 = require("../models/databaseTypes");
5
- /**
6
- * Options for generation functions
7
- */
8
- class DbmOptions {
9
- constructor() {
10
- /**
11
- * The database type
12
- */
13
- this.database = databaseTypes_1.DatabaseTypes.mysql;
14
- /**
15
- * The extension of table definition markdown files.
16
- * Default is `.db.md`
17
- */
18
- this.mdFileExtension = '.db.md';
19
- /**
20
- * The markdown file directory of the database model.
21
- */
22
- this.sourceFolder = '';
23
- /**
24
- * The path of the output file.
25
- */
26
- this.targetPath = '';
27
- /**
28
- * The markdown file directory of the previous database version.
29
- */
30
- this.previousVersionFolder = '';
31
- }
32
- }
33
- exports.DbmOptions = DbmOptions;
34
- exports.DefaultOptions = new DbmOptions();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultOptions = exports.DbmOptions = void 0;
4
+ const databaseTypes_1 = require("../models/databaseTypes");
5
+ /**
6
+ * Options for generation functions
7
+ */
8
+ class DbmOptions {
9
+ constructor() {
10
+ /**
11
+ * The database type
12
+ */
13
+ this.database = databaseTypes_1.DatabaseTypes.mysql;
14
+ /**
15
+ * The extension of table definition markdown files.
16
+ * Default is `.db.md`
17
+ */
18
+ this.mdFileExtension = '.db.md';
19
+ /**
20
+ * The markdown file directory of the database model.
21
+ */
22
+ this.sourceFolder = '';
23
+ /**
24
+ * The path of the output file.
25
+ */
26
+ this.targetPath = '';
27
+ /**
28
+ * The markdown file directory of the previous database version.
29
+ */
30
+ this.previousVersionFolder = '';
31
+ }
32
+ }
33
+ exports.DbmOptions = DbmOptions;
34
+ exports.DefaultOptions = new DbmOptions();
35
35
  //# sourceMappingURL=dbmOptions.js.map
@@ -1,87 +1,87 @@
1
- import { DbModel } from '../models/dbModel';
2
- import { DbmOptions } from './dbmOptions';
3
- import { DbOptions } from './dbOptions';
4
- /**
5
- * The database modeling markdown service.
6
- */
7
- export declare class DbmService {
8
- /**
9
- * New a markdown file (.db.md) that defines a table.
10
- * The file will be located at `options.sourceFolder` with name `<tableName>.db.md`.
11
- * @param options the options (required: `sourceFolder`)
12
- * @param tableName The table name
13
- */
14
- static newDbmMarkdownFile(options: DbmOptions, tableName: string): string;
15
- /**
16
- * Generate a SQL file with create-table-if-not-exists scripts.
17
- * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
18
- */
19
- static toCreateTableIfNotExistsSql(options: DbmOptions): string;
20
- /**
21
- * Generate a SQL file with create-table scripts.
22
- * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
23
- */
24
- static toCreateTableSql(options: DbmOptions): string;
25
- /**
26
- * Generate a SQL file with drop-table scripts.
27
- * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
28
- */
29
- static toDropTableSql(options: DbmOptions): string;
30
- /**
31
- * Generate a SQL file with drop-then-create-table scripts.
32
- * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
33
- */
34
- static toDropThenCreateTableSql(options: DbmOptions): string;
35
- /**
36
- * Generate a SQL file with upgrade scripts.
37
- * support:
38
- * - new tables,
39
- * - new columns,
40
- * - new primary keys
41
- * - new indexes
42
- * - new foreign keys
43
- * @param options the options, required: `database`, `sourceFolder`, `targetPath`, `previousVersionFolder`.
44
- */
45
- static toUpgradeSql(options: DbmOptions): string;
46
- /**
47
- * Generate a JSON file.
48
- * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
49
- */
50
- static toJson(options: DbmOptions): string;
51
- /**
52
- * Generate markdown files from a json file
53
- * @param jsonFile the json file path
54
- * @param markdownFolder the folder to which we will write
55
- * @param force If true, delete all files whose extension matched, default: `false`.
56
- * @param fileExtension generated file extension, default: `.db.md`.
57
- */
58
- static fromJsonFile(jsonFile: string, markdownFolder: string, force?: boolean, fileExtension?: string): void;
59
- /**
60
- * Generate markdown files from a model
61
- * @param model the model object with
62
- * @param markdownFolder the folder to which we will write
63
- * @param force If true, delete all files whose extension matched, default: `false`.
64
- * @param fileExtension generated file extension, default: `.db.md`.
65
- */
66
- static toMarkdown(model: DbModel, markdownFolder: string, force?: boolean, fileExtension?: string): void;
67
- /**
68
- * Generate a index file for a model
69
- * @param model the model object with
70
- * @param markdownFolder the folder to which we will write
71
- * @param filename generated file name, default: `index.md`.
72
- */
73
- static genIndexFile(model: DbModel, markdownFolder: string, filename?: string): void;
74
- /**
75
- * Get a model object.
76
- * @param options the options, required: `database`, `sourceFolder`.
77
- */
78
- static toModel(options: DbmOptions): DbModel;
79
- /**
80
- * Generate markdown files from a database
81
- * @param dbOptions the datbase connection configure
82
- * @param markdownFolder the folder to which we will write
83
- * @param force If true, delete all files whose extension matched, default: `false`.
84
- * @param fileExtension generated file extension, default: `.db.md`.
85
- */
86
- static fromDatabase(dbOptions: DbOptions, markdownFolder: string, force?: boolean, fileExtension?: string): Promise<void>;
87
- }
1
+ import { DbModel } from '../models/dbModel';
2
+ import { DbmOptions } from './dbmOptions';
3
+ import { DbOptions } from './dbOptions';
4
+ /**
5
+ * The database modeling markdown service.
6
+ */
7
+ export declare class DbmService {
8
+ /**
9
+ * New a markdown file (.db.md) that defines a table.
10
+ * The file will be located at `options.sourceFolder` with name `<tableName>.db.md`.
11
+ * @param options the options (required: `sourceFolder`)
12
+ * @param tableName The table name
13
+ */
14
+ static newDbmMarkdownFile(options: DbmOptions, tableName: string): string;
15
+ /**
16
+ * Generate a SQL file with create-table-if-not-exists scripts.
17
+ * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
18
+ */
19
+ static toCreateTableIfNotExistsSql(options: DbmOptions): string;
20
+ /**
21
+ * Generate a SQL file with create-table scripts.
22
+ * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
23
+ */
24
+ static toCreateTableSql(options: DbmOptions): string;
25
+ /**
26
+ * Generate a SQL file with drop-table scripts.
27
+ * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
28
+ */
29
+ static toDropTableSql(options: DbmOptions): string;
30
+ /**
31
+ * Generate a SQL file with drop-then-create-table scripts.
32
+ * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
33
+ */
34
+ static toDropThenCreateTableSql(options: DbmOptions): string;
35
+ /**
36
+ * Generate a SQL file with upgrade scripts.
37
+ * support:
38
+ * - new tables,
39
+ * - new columns,
40
+ * - new primary keys
41
+ * - new indexes
42
+ * - new foreign keys
43
+ * @param options the options, required: `database`, `sourceFolder`, `targetPath`, `previousVersionFolder`.
44
+ */
45
+ static toUpgradeSql(options: DbmOptions): string;
46
+ /**
47
+ * Generate a JSON file.
48
+ * @param options the options, required: `database`, `sourceFolder`, `targetPath`.
49
+ */
50
+ static toJson(options: DbmOptions): string;
51
+ /**
52
+ * Generate markdown files from a json file
53
+ * @param jsonFile the json file path
54
+ * @param markdownFolder the folder to which we will write
55
+ * @param force If true, delete all files whose extension matched, default: `false`.
56
+ * @param fileExtension generated file extension, default: `.db.md`.
57
+ */
58
+ static fromJsonFile(jsonFile: string, markdownFolder: string, force?: boolean, fileExtension?: string): void;
59
+ /**
60
+ * Generate markdown files from a model
61
+ * @param model the model object with
62
+ * @param markdownFolder the folder to which we will write
63
+ * @param force If true, delete all files whose extension matched, default: `false`.
64
+ * @param fileExtension generated file extension, default: `.db.md`.
65
+ */
66
+ static toMarkdown(model: DbModel, markdownFolder: string, force?: boolean, fileExtension?: string): void;
67
+ /**
68
+ * Generate a index file for a model
69
+ * @param model the model object with
70
+ * @param markdownFolder the folder to which we will write
71
+ * @param filename generated file name, default: `index.md`.
72
+ */
73
+ static genIndexFile(model: DbModel, markdownFolder: string, filename?: string): void;
74
+ /**
75
+ * Get a model object.
76
+ * @param options the options, required: `database`, `sourceFolder`.
77
+ */
78
+ static toModel(options: DbmOptions): DbModel;
79
+ /**
80
+ * Generate markdown files from a database
81
+ * @param dbOptions the datbase connection configure
82
+ * @param markdownFolder the folder to which we will write
83
+ * @param force If true, delete all files whose extension matched, default: `false`.
84
+ * @param fileExtension generated file extension, default: `.db.md`.
85
+ */
86
+ static fromDatabase(dbOptions: DbOptions, markdownFolder: string, force?: boolean, fileExtension?: string): Promise<void>;
87
+ }