baja-lite 1.1.4 → 1.1.5

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 (76) hide show
  1. package/boot-remote.d.ts +2 -0
  2. package/{src/boot-remote.ts → boot-remote.js} +6 -7
  3. package/boot.d.ts +2 -0
  4. package/{src/boot.ts → boot.js} +32 -39
  5. package/code.d.ts +2 -0
  6. package/{src/code.ts → code.js} +64 -67
  7. package/convert-xml.d.ts +10 -0
  8. package/{src/convert-xml.ts → convert-xml.js} +105 -155
  9. package/enum.d.ts +18 -0
  10. package/enum.js +59 -0
  11. package/error.d.ts +5 -0
  12. package/error.js +13 -0
  13. package/fn.d.ts +128 -0
  14. package/fn.js +172 -0
  15. package/{src/index.ts → index.d.ts} +11 -11
  16. package/index.js +11 -0
  17. package/list.d.ts +10 -0
  18. package/{src/list.ts → list.js} +8 -9
  19. package/math.d.ts +83 -0
  20. package/math.js +451 -0
  21. package/object.d.ts +83 -0
  22. package/object.js +222 -0
  23. package/package.json +1 -1
  24. package/set-ex.d.ts +198 -0
  25. package/set-ex.js +338 -0
  26. package/sql.d.ts +1858 -0
  27. package/sql.js +5025 -0
  28. package/sqlite.d.ts +32 -0
  29. package/{src/sqlite.ts → sqlite.js} +53 -52
  30. package/string.d.ts +17 -0
  31. package/string.js +105 -0
  32. package/test-mysql.d.ts +2 -0
  33. package/{src/test-mysql.ts → test-mysql.js} +135 -126
  34. package/test-postgresql.d.ts +2 -0
  35. package/test-postgresql.js +90 -0
  36. package/test-sqlite.d.ts +1 -0
  37. package/{src/test-sqlite.ts → test-sqlite.js} +89 -80
  38. package/test-xml.d.ts +1 -0
  39. package/{src/test-xml.ts → test-xml.js} +1 -1
  40. package/test.d.ts +1 -0
  41. package/test.js +2 -0
  42. package/wx/base.d.ts +11 -0
  43. package/wx/base.js +78 -0
  44. package/wx/mini.d.ts +45 -0
  45. package/wx/mini.js +102 -0
  46. package/wx/organ.d.ts +65 -0
  47. package/wx/organ.js +171 -0
  48. package/{src/wx/types.ts → wx/types.d.ts} +21 -10
  49. package/wx/types.js +1 -0
  50. package/wx.js +3 -0
  51. package/.eslintignore +0 -7
  52. package/.eslintrc.cjs +0 -89
  53. package/.prettierrc +0 -4
  54. package/ci.js +0 -29
  55. package/package-cjs.json +0 -17
  56. package/src/enum.ts +0 -71
  57. package/src/error.ts +0 -11
  58. package/src/fn.ts +0 -295
  59. package/src/math.ts +0 -405
  60. package/src/object.ts +0 -247
  61. package/src/set-ex.ts +0 -374
  62. package/src/sql.ts +0 -5281
  63. package/src/string.ts +0 -111
  64. package/src/test-postgresql.ts +0 -79
  65. package/src/test.ts +0 -2
  66. package/src/wx/base.ts +0 -76
  67. package/src/wx/mini.ts +0 -133
  68. package/src/wx/organ.ts +0 -290
  69. package/test.json +0 -0
  70. package/tsconfig.base.json +0 -80
  71. package/tsconfig.cjs.json +0 -42
  72. package/tsconfig.json +0 -44
  73. package/xml/event-report.xml +0 -13
  74. package/yarn.lock +0 -1493
  75. /package/{Readme.md → README.md} +0 -0
  76. /package/{src/wx.ts → wx.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ import { GlobalSqlOptionForWeb } from './sql.js';
2
+ export declare const BootRomote: (options: GlobalSqlOptionForWeb) => Promise<void>;
@@ -1,7 +1,6 @@
1
1
  import { getEnums } from './enum.js';
2
- import { _primaryDB, _dao, logger, DBType, _sqlCache, _GlobalSqlOption, GlobalSqlOptionForWeb, _defOption, SqlCache, SqliteRemote, _Hump, ColumnMode, _enums } from './sql.js';
3
-
4
- export const BootRomote = async function (options: GlobalSqlOptionForWeb) {
2
+ import { _primaryDB, _dao, logger, DBType, _sqlCache, _GlobalSqlOption, _defOption, SqlCache, SqliteRemote, _Hump, ColumnMode, _enums } from './sql.js';
3
+ export const BootRomote = async function (options) {
5
4
  globalThis[_GlobalSqlOption] = Object.assign({}, _defOption, options);
6
5
  globalThis[_Hump] = globalThis[_GlobalSqlOption].columnMode === ColumnMode.HUMP;
7
6
  logger.level = options.log ?? 'info';
@@ -19,7 +18,8 @@ export const BootRomote = async function (options: GlobalSqlOptionForWeb) {
19
18
  if (typeof options.SqliteRemote.db === 'string') {
20
19
  options.SqliteRemote.service.initDB(options.SqliteRemote.db);
21
20
  globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
22
- } else {
21
+ }
22
+ else {
23
23
  let flag = false;
24
24
  for (const [key, fileName] of Object.entries(options.SqliteRemote.db)) {
25
25
  await options.SqliteRemote.service.initDB(fileName);
@@ -32,8 +32,7 @@ export const BootRomote = async function (options: GlobalSqlOptionForWeb) {
32
32
  }
33
33
  }
34
34
  }
35
- }
36
-
35
+ };
37
36
  // export const AppendRomote = async function (dbName: string) {
38
37
  // if (!globalThis[_dao][DBType.SqliteRemote][dbName]) {
39
38
  // globalThis[_GlobalSqlOption].SqliteRemote.service.initDB(dbName);
@@ -43,4 +42,4 @@ export const BootRomote = async function (options: GlobalSqlOptionForWeb) {
43
42
  // }
44
43
  // globalThis[_dao][DBType.SqliteRemote][dbName] = db;
45
44
  // }
46
- // }
45
+ // }
package/boot.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { GlobalSqlOption } from './sql.js';
2
+ export declare const Boot: (options: GlobalSqlOption) => Promise<void>;
@@ -1,7 +1,6 @@
1
1
  import { getEnums } from './enum.js';
2
- import { _GlobalSqlOption, GlobalSqlOption, _enums, _EventBus, _defOption, logger, _sqlCache, SqlCache, _dao, DBType, _primaryDB, SqliteRemote, _fs, _path, Mysql, Sqlite, _Hump, ColumnMode, Postgresql } from './sql.js';
3
-
4
- export const Boot = async function (options: GlobalSqlOption) {
2
+ import { _GlobalSqlOption, _enums, _EventBus, _defOption, logger, _sqlCache, SqlCache, _dao, DBType, _primaryDB, SqliteRemote, _fs, _path, Mysql, Sqlite, _Hump, ColumnMode, Postgresql } from './sql.js';
3
+ export const Boot = async function (options) {
5
4
  globalThis[_GlobalSqlOption] = Object.assign({}, _defOption, options);
6
5
  globalThis[_Hump] = globalThis[_GlobalSqlOption].columnMode === ColumnMode.HUMP;
7
6
  if (options.sqlDir) {
@@ -33,8 +32,8 @@ export const Boot = async function (options: GlobalSqlOption) {
33
32
  decimalNumbers: true,
34
33
  supportBigNumbers: true
35
34
  }));
36
-
37
- } else {
35
+ }
36
+ else {
38
37
  let flag = false;
39
38
  for (const [key, option] of Object.entries(options.Mysql)) {
40
39
  const db = new Mysql(createPool({
@@ -43,7 +42,6 @@ export const Boot = async function (options: GlobalSqlOption) {
43
42
  decimalNumbers: true,
44
43
  supportBigNumbers: true
45
44
  }));
46
-
47
45
  if (flag === false) {
48
46
  globalThis[_dao][DBType.Mysql][_primaryDB] = db;
49
47
  flag = true;
@@ -55,7 +53,8 @@ export const Boot = async function (options: GlobalSqlOption) {
55
53
  if (options.Sqlite) {
56
54
  if (typeof options.Sqlite === 'string') {
57
55
  globalThis[_dao][DBType.Sqlite][_primaryDB] = new Sqlite(new options.BetterSqlite3(options.Sqlite, { fileMustExist: false }));
58
- } else {
56
+ }
57
+ else {
59
58
  let flag = false;
60
59
  for (const [key, fileName] of Object.entries(options.Sqlite)) {
61
60
  const db = new Sqlite(new options.BetterSqlite3(fileName, { fileMustExist: false }));
@@ -71,7 +70,8 @@ export const Boot = async function (options: GlobalSqlOption) {
71
70
  if (typeof options.SqliteRemote.db === 'string') {
72
71
  options.SqliteRemote.service.initDB(options.SqliteRemote.db);
73
72
  globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
74
- } else {
73
+ }
74
+ else {
75
75
  let flag = false;
76
76
  for (const [key, fileName] of Object.entries(options.SqliteRemote.db)) {
77
77
  options.SqliteRemote.service.initDB(fileName);
@@ -88,7 +88,8 @@ export const Boot = async function (options: GlobalSqlOption) {
88
88
  const { Redis } = await import('ioredis');
89
89
  if (options.Redis['host']) {
90
90
  globalThis[_dao][DBType.Redis][_primaryDB] = new Redis(options.Redis);
91
- } else {
91
+ }
92
+ else {
92
93
  let flag = false;
93
94
  for (const [key, option] of Object.entries(options.Redis)) {
94
95
  const db = new Redis(option);
@@ -99,32 +100,25 @@ export const Boot = async function (options: GlobalSqlOption) {
99
100
  globalThis[_dao][DBType.Redis][key] = db;
100
101
  }
101
102
  }
102
- const clients = Object.values(globalThis[_dao][DBType.Redis]) as any;
103
+ const clients = Object.values(globalThis[_dao][DBType.Redis]);
103
104
  const Redlock = await import('redlock');
104
- globalThis[_dao][DBType.RedisLock] = new Redlock.default(
105
- clients,
106
- {
107
- // The expected clock drift; for more details see:
108
- // http://redis.io/topics/distlock
109
- driftFactor: 0.01, // multiplied by lock ttl to determine drift time
110
-
111
- // The max number of times Redlock will attempt to lock a resource
112
- // before erroring.
113
- retryCount: 10,
114
-
115
- // the time in ms between attempts
116
- retryDelay: 200, // time in ms
117
-
118
- // the max time in ms randomly added to retries
119
- // to improve performance under high contention
120
- // see https://www.awsarchitectureblog.com/2015/03/backoff.html
121
- retryJitter: 200, // time in ms
122
-
123
- // The minimum remaining time on a lock before an extension is automatically
124
- // attempted with the `using` API.
125
- automaticExtensionThreshold: 500, // time in ms
126
- }
127
- );
105
+ globalThis[_dao][DBType.RedisLock] = new Redlock.default(clients, {
106
+ // The expected clock drift; for more details see:
107
+ // http://redis.io/topics/distlock
108
+ driftFactor: 0.01, // multiplied by lock ttl to determine drift time
109
+ // The max number of times Redlock will attempt to lock a resource
110
+ // before erroring.
111
+ retryCount: 10,
112
+ // the time in ms between attempts
113
+ retryDelay: 200, // time in ms
114
+ // the max time in ms randomly added to retries
115
+ // to improve performance under high contention
116
+ // see https://www.awsarchitectureblog.com/2015/03/backoff.html
117
+ retryJitter: 200, // time in ms
118
+ // The minimum remaining time on a lock before an extension is automatically
119
+ // attempted with the `using` API.
120
+ automaticExtensionThreshold: 500, // time in ms
121
+ });
128
122
  const { EventEmitter } = await import('events');
129
123
  const event = new EventEmitter({ captureRejections: true });
130
124
  event.on('error', error => {
@@ -133,15 +127,14 @@ export const Boot = async function (options: GlobalSqlOption) {
133
127
  globalThis[_EventBus] = event;
134
128
  }
135
129
  if (options.Postgresql) {
136
- const Pool = await import('pg-pool');
130
+ const Pool = await import('pg-pool');
137
131
  if (options.Postgresql['host']) {
138
132
  globalThis[_dao][DBType.Postgresql][_primaryDB] = new Postgresql(new Pool.default(options.Postgresql));
139
-
140
- } else {
133
+ }
134
+ else {
141
135
  let flag = false;
142
136
  for (const [key, option] of Object.entries(options.Postgresql)) {
143
137
  const db = new Postgresql(new Pool.default(option));
144
-
145
138
  if (flag === false) {
146
139
  globalThis[_dao][DBType.Postgresql][_primaryDB] = db;
147
140
  flag = true;
@@ -150,4 +143,4 @@ export const Boot = async function (options: GlobalSqlOption) {
150
143
  }
151
144
  }
152
145
  }
153
- }
146
+ };
package/code.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -5,7 +5,6 @@ import { start } from 'repl';
5
5
  import { createPool } from 'mysql2/promise';
6
6
  import mustache from 'mustache';
7
7
  import { mkdir } from 'shelljs';
8
-
9
8
  const lxMap = {
10
9
  tinyint: "number",
11
10
  smallint: "number",
@@ -129,26 +128,10 @@ console.log(`
129
128
  -----
130
129
  force: 切换是否覆盖
131
130
  `);
132
-
133
-
134
131
  try {
135
- const outputs = new Set<string>();
132
+ const outputs = new Set();
136
133
  const _configData = fs.readFileSync(config, { encoding: 'utf-8' }).toString();
137
- const configData = JSON.parse(_configData) as {
138
- host: string;
139
- port: number;
140
- user: string;
141
- password: string;
142
- database: string;
143
- command: Record<string, string>;
144
- commands: Record<string, string[]>;
145
- output: string;
146
- id: string;
147
- logicDeleteK: string;
148
- logicDeleteV: number;
149
- NotlogicDeleteV: number;
150
- tables: string;
151
- };
134
+ const configData = JSON.parse(_configData);
152
135
  const templates = Object.fromEntries(fs.readdirSync(templatePath).map(r => [path.basename(r, '.mu'), fs.readFileSync(path.join(templatePath, r), { encoding: 'utf-8' }).toString()]));
153
136
  const pool = createPool({
154
137
  host: configData.host,
@@ -157,9 +140,9 @@ try {
157
140
  password: configData.password,
158
141
  database: configData.database
159
142
  });
160
- async function getTables(tableName: string) {
143
+ async function getTables(tableName) {
161
144
  const conn = await pool.getConnection();
162
- const params: (string | string[])[] = [configData.database];
145
+ const params = [configData.database];
163
146
  let sql = `
164
147
  SELECT TABLE_NAME tableName, IFNULL(TABLE_COMMENT, TABLE_NAME) title FROM information_schema.TABLES
165
148
  WHERE TABLE_SCHEMA= ? AND TABLE_TYPE = 'BASE TABLE'`;
@@ -167,13 +150,13 @@ try {
167
150
  sql += ` AND TABLE_NAME IN (?)`;
168
151
  params.push(tableName.split(/,|\s/).map(r => r.trim()));
169
152
  }
170
- const [result] = await conn.query<any[]>(sql, params);
153
+ const [result] = await conn.query(sql, params);
171
154
  conn.release();
172
155
  return result;
173
156
  }
174
- async function getColumns(tableName: string) {
157
+ async function getColumns(tableName) {
175
158
  const conn = await pool.getConnection();
176
- const [result] = await conn.query<any[]>(`
159
+ const [result] = await conn.query(`
177
160
  SELECT
178
161
  DATA_TYPE type,
179
162
  COLUMN_NAME \`name\`,
@@ -187,27 +170,38 @@ try {
187
170
  `, [configData.database, tableName]);
188
171
  let logicDelete = '';
189
172
  const columns = result.map(r => {
190
- if (r.id === 1) { r.id = true; }
191
- else delete r.id;
192
- if (r.notNull === 1) { r.notNull = true; }
193
- else delete r.notNull;
194
-
195
-
196
- const fields = new Array<string>(`type:SqlType.${r.type}`);
197
- if (r.length !== null) { fields.push(`length:${r.length}`); }
198
- if (r.scale !== null) { fields.push(`scale:${r.scale}`); }
173
+ if (r.id === 1) {
174
+ r.id = true;
175
+ }
176
+ else
177
+ delete r.id;
178
+ if (r.notNull === 1) {
179
+ r.notNull = true;
180
+ }
181
+ else
182
+ delete r.notNull;
183
+ const fields = new Array(`type:SqlType.${r.type}`);
184
+ if (r.length !== null) {
185
+ fields.push(`length:${r.length}`);
186
+ }
187
+ if (r.scale !== null) {
188
+ fields.push(`scale:${r.scale}`);
189
+ }
199
190
  if (r.def !== null) {
200
- r.def ??= '';
191
+ r.def ?? (r.def = '');
201
192
  if (isNaN(r.def) || r.def === '') {
202
193
  fields.push(`def:'${r.def}'`);
203
- } else {
194
+ }
195
+ else {
204
196
  fields.push(`def:${r.def}`);
205
197
  }
206
198
  }
207
199
  if (r.id === true) {
208
200
  fields.push(`id:true`);
209
201
  }
210
- if (r.notNull === true) { fields.push(`notNull:true`); }
202
+ if (r.notNull === true) {
203
+ fields.push(`notNull:true`);
204
+ }
211
205
  if (r.id === true && configData.id) {
212
206
  fields.push(configData.id);
213
207
  }
@@ -215,66 +209,62 @@ try {
215
209
  fields.push(`logicDelete: ${configData.logicDeleteV}`);
216
210
  logicDelete = `AND ${r.name} = ${configData.NotlogicDeleteV}`;
217
211
  }
218
- if (r.comment) { fields.push(`comment: '${r.comment}'`); }
212
+ if (r.comment) {
213
+ fields.push(`comment: '${r.comment}'`);
214
+ }
219
215
  r.comment = r.comment ?? '';
220
216
  r.Type = lxMap[r.type];
221
217
  r.Field = `@Field({${fields.join(',')}})`;
222
- r.Name = r.name.replace(/_(\w)/g, (a: string, b: string) => b.toUpperCase());
223
- r.NAME = r.Name.replace(/\w/, (v: string) => v.toUpperCase());
218
+ r.Name = r.name.replace(/_(\w)/g, (a, b) => b.toUpperCase());
219
+ r.NAME = r.Name.replace(/\w/, (v) => v.toUpperCase());
224
220
  return r;
225
221
  });
226
222
  conn.release();
227
223
  return { columns, logicDelete };
228
224
  }
229
- async function excute(command: string, input: string, modelName: string) {
225
+ async function excute(command, input, modelName) {
230
226
  const tables = await getTables(input);
231
227
  if (input !== '.') {
232
- const checkTable = input.split(/,|\s/).map(r => r.trim())
228
+ const checkTable = input.split(/,|\s/).map(r => r.trim());
233
229
  if (checkTable.length !== tables.length) {
234
230
  console.error(`[错误] 输入的表与数据库查询返回表不符,数据库返回${tables.length}个:${tables.map(i => i.tableName).join(',')}`);
235
231
  return;
236
232
  }
237
233
  }
238
- modelName ??= '';
234
+ modelName ?? (modelName = '');
239
235
  const modelPath = modelName ? `/${modelName}/` : '';
240
236
  for (const { tableName, title } of tables) {
241
237
  const { columns, logicDelete } = await getColumns(tableName);
242
- const className = tableName.replace(/_(\w)/g, (a: string, b: string) => b.toUpperCase());
243
- const ClassName = className.replace(/\w/, (v: string) => v.toUpperCase());
238
+ const className = tableName.replace(/_(\w)/g, (a, b) => b.toUpperCase());
239
+ const ClassName = className.replace(/\w/, (v) => v.toUpperCase());
244
240
  const vueName = tableName.replace(/_/g, '-');
245
241
  const splitName = tableName.replace(/_/g, '/');
246
- const SplitName = tableName.replace(/_/, '/').replace(/_(\w)/g, (a: string, b: string) => b.toUpperCase());
242
+ const SplitName = tableName.replace(/_/, '/').replace(/_(\w)/g, (a, b) => b.toUpperCase());
247
243
  const data = {
248
244
  title,
249
-
250
245
  tableName,
251
246
  className,
252
247
  ClassName,
253
248
  vueName,
254
249
  splitName,
255
250
  SplitName,
256
-
257
251
  columns,
258
252
  columnNames: columns?.map(i => i.name),
259
253
  ColumnNames: columns?.map(i => i.Name),
260
254
  columnNames_join: columns?.map(i => i.name).join(','),
261
255
  ColumnNames_join: columns?.map(i => `${i.name} ${i.Name}`).join(','),
262
-
263
256
  columns_no_id: columns?.filter(i => !i.id),
264
257
  columnNames_no_id: columns?.filter(i => !i.id).map(i => i.name),
265
258
  ColumnNames_no_id: columns?.filter(i => !i.id).map(i => i.Name),
266
259
  columnNames_no_id_join: columns?.filter(i => !i.id).map(i => i.name).join(','),
267
260
  ColumnNames_no_id_join: columns?.filter(i => !i.id).map(i => i.Name).join(','),
268
-
269
261
  ids: columns?.filter(i => i.id),
270
262
  idNames: columns?.filter(i => i.id).map(i => i.name),
271
263
  IdNames: columns?.filter(i => i.id).map(i => i.Name),
272
264
  idNames_join: columns?.filter(i => i.id).map(i => i.name).join(','),
273
265
  IdNames_join: columns?.filter(i => i.id).map(i => i.Name).join(','),
274
-
275
266
  modelName,
276
267
  modelPath,
277
-
278
268
  logicDelete
279
269
  };
280
270
  const template = templates[command];
@@ -283,9 +273,9 @@ try {
283
273
  return;
284
274
  }
285
275
  const txt = mustache.render(template, data, {}, ['<%', '%>']);
286
- const _fileName = configData.command[command]!.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]);
276
+ const _fileName = configData.command[command].replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]);
287
277
  const fileNames = _fileName.split(',');
288
- for(const fileName of fileNames){
278
+ for (const fileName of fileNames) {
289
279
  const filePath = path.join(basepath, fileName);
290
280
  const dirname = path.dirname(filePath);
291
281
  mkdir('-p', dirname);
@@ -300,28 +290,31 @@ try {
300
290
  if (force === false) {
301
291
  console.warn(`[跳过] ${filePath}`);
302
292
  return;
303
- } else {
293
+ }
294
+ else {
304
295
  console.warn(`[覆盖] ${filePath}`);
305
296
  }
306
- } catch (error) {
297
+ }
298
+ catch (error) {
307
299
  console.info(`[生成] ${filePath}`);
308
300
  }
309
301
  if (configData.output) {
310
- outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]));
302
+ outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
311
303
  }
312
304
  fs.writeFileSync(path.join(basepath, fileName), txt);
313
305
  }
314
306
  }
315
307
  }
316
308
  const replServer = start();
317
- function defineCommand(command: string, comands?: string[]) {
309
+ function defineCommand(command, comands) {
318
310
  if (comands) {
319
311
  console.log(`[组合]${command}>${comands.join(',')}注册成功`);
320
- } else {
312
+ }
313
+ else {
321
314
  console.log(`[命令]${command}注册成功`);
322
315
  }
323
316
  if (comands) {
324
- replServer.defineCommand(command, async input => {
317
+ replServer.defineCommand(command, async (input) => {
325
318
  outputs.clear();
326
319
  const inputs = input.match(/([^:]+):{0,1}([a-zA-Z0-9]*)/);
327
320
  if (inputs?.length !== 3) {
@@ -329,20 +322,21 @@ try {
329
322
  }
330
323
  const [_, tables, modelName] = inputs;
331
324
  for (const c of comands) {
332
- await excute(c, tables!, modelName ?? '');
325
+ await excute(c, tables, modelName ?? '');
333
326
  }
334
327
  console.info('执行完毕!下面打印生成的输出');
335
328
  console.info(Array.from(outputs).join(','));
336
329
  });
337
- } else {
338
- replServer.defineCommand(command, async input => {
330
+ }
331
+ else {
332
+ replServer.defineCommand(command, async (input) => {
339
333
  outputs.clear();
340
334
  const inputs = input.match(/([^:]+):{0,1}([a-zA-Z0-9]*)/);
341
335
  if (inputs?.length !== 3) {
342
336
  return console.error(`[错误]命令格式应为: table1,table2[:模块名]`);
343
337
  }
344
338
  const [_, tables, modelName] = inputs;
345
- await excute(command, tables!, modelName ?? '');
339
+ await excute(command, tables, modelName ?? '');
346
340
  console.info('执行完毕!下面打印生成的输出');
347
341
  console.info(Array.from(outputs).join(','));
348
342
  });
@@ -356,22 +350,25 @@ try {
356
350
  for (const command of Object.keys(configData.command)) {
357
351
  if (!templates[command]) {
358
352
  console.error(`命令:${command}没有定义模板,该命令不会生效`);
359
- } else {
353
+ }
354
+ else {
360
355
  defineCommand(command);
361
356
  }
362
357
  }
363
358
  }
364
359
  if (configData.commands) {
365
360
  for (const [command, commands] of Object.entries(configData.commands)) {
366
- const keys = commands as string[];
361
+ const keys = commands;
367
362
  const error = keys.filter(k => !templates[k]).join(',');
368
363
  if (error) {
369
364
  console.error(`组合命令:${command}定义了${commands},但是${error}没有定义模板,该命令不会生效`);
370
- } else {
365
+ }
366
+ else {
371
367
  defineCommand(command, keys);
372
368
  }
373
369
  }
374
370
  }
375
- } catch (error) {
371
+ }
372
+ catch (error) {
376
373
  console.error(error);
377
374
  }
@@ -0,0 +1,10 @@
1
+ export interface XML {
2
+ type: 'tag' | 'text';
3
+ name: string;
4
+ id?: string;
5
+ voidElement: boolean;
6
+ attrs: Record<string, string>;
7
+ children: XML[];
8
+ content: string;
9
+ }
10
+ export declare const convert: (childrens: XML[], param: Record<string, any>, parentIds: string[], myBatisMapper: Record<string, XML[]>) => string;