baja-lite 1.3.27 → 1.3.28

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