baja-lite 1.0.20 → 1.0.22
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.
- package/cjs/code.js +27 -24
- package/cjs/sql.d.ts +1 -1
- package/cjs/sql.js +58 -46
- package/es/code.js +27 -24
- package/es/sql.d.ts +1 -1
- package/es/sql.js +58 -46
- package/package.json +5 -5
- package/src/code.ts +26 -23
- package/src/sql.ts +57 -39
package/cjs/code.js
CHANGED
|
@@ -278,33 +278,36 @@ try {
|
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
280
|
const txt = mustache_1.default.render(template, data, {}, ['<%', '%>']);
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
281
|
+
const _fileName = configData.command[command].replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]);
|
|
282
|
+
const fileNames = _fileName.split(',');
|
|
283
|
+
for (const fileName of fileNames) {
|
|
284
|
+
const filePath = path_1.default.join(basepath, fileName);
|
|
285
|
+
const dirname = path_1.default.dirname(filePath);
|
|
286
|
+
(0, shelljs_1.mkdir)('-p', dirname);
|
|
287
|
+
// try {
|
|
288
|
+
// fs.statSync(dirname);
|
|
289
|
+
// } catch (error) {
|
|
290
|
+
// fs.mkdirSync(dirname);
|
|
291
|
+
// console.info(`[生成] ${dirname}`);
|
|
292
|
+
// }
|
|
293
|
+
try {
|
|
294
|
+
fs_1.default.statSync(filePath);
|
|
295
|
+
if (force === false) {
|
|
296
|
+
console.warn(`[跳过] ${filePath}`);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
console.warn(`[覆盖] ${filePath}`);
|
|
301
|
+
}
|
|
296
302
|
}
|
|
297
|
-
|
|
298
|
-
console.
|
|
303
|
+
catch (error) {
|
|
304
|
+
console.info(`[生成] ${filePath}`);
|
|
299
305
|
}
|
|
306
|
+
if (configData.output) {
|
|
307
|
+
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
308
|
+
}
|
|
309
|
+
fs_1.default.writeFileSync(path_1.default.join(basepath, fileName), txt);
|
|
300
310
|
}
|
|
301
|
-
catch (error) {
|
|
302
|
-
console.info(`[生成] ${filePath}`);
|
|
303
|
-
}
|
|
304
|
-
if (configData.output) {
|
|
305
|
-
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
306
|
-
}
|
|
307
|
-
fs_1.default.writeFileSync(path_1.default.join(basepath, fileName), txt);
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
const replServer = (0, repl_1.start)();
|
package/cjs/sql.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { XML } from './convert-xml';
|
|
2
2
|
import { ArrayList } from './list';
|
|
3
|
-
import { EnumMap } from 'enum';
|
|
3
|
+
import { EnumMap } from './enum';
|
|
4
4
|
import { ExtensionCodec } from "@msgpack/msgpack";
|
|
5
5
|
export declare const extensionCodec: ExtensionCodec<undefined>;
|
|
6
6
|
declare const _daoDBName: unique symbol;
|
package/cjs/sql.js
CHANGED
|
@@ -1675,15 +1675,9 @@ const FieldFilter = (K, V, def, uuidColumn, option) => {
|
|
|
1675
1675
|
// 只有在非插入或者非UUID时,进行空置检查
|
|
1676
1676
|
if (option?.insert === true && uuidColumn === true) {
|
|
1677
1677
|
ret = 1;
|
|
1678
|
-
if (V === undefined) {
|
|
1678
|
+
if (V === undefined || (0, string_1.emptyString)(`${V ?? ''}`)) {
|
|
1679
1679
|
V = null;
|
|
1680
1680
|
}
|
|
1681
|
-
else if ((0, string_1.emptyString)(`${V ?? ''}`)) {
|
|
1682
|
-
V = '';
|
|
1683
|
-
}
|
|
1684
|
-
else {
|
|
1685
|
-
ret = 1;
|
|
1686
|
-
}
|
|
1687
1681
|
}
|
|
1688
1682
|
else {
|
|
1689
1683
|
if (V === null) {
|
|
@@ -2341,19 +2335,23 @@ class SqlService {
|
|
|
2341
2335
|
}, { everyLength: option?.every === true ? 1 : option?.maxDeal });
|
|
2342
2336
|
return result;
|
|
2343
2337
|
};
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
}
|
|
2338
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2339
|
+
return fn();
|
|
2340
|
+
}
|
|
2341
|
+
else {
|
|
2342
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2343
|
+
}
|
|
2344
|
+
// return new Promise<bigint[]>(async (resolve, reject) => {
|
|
2345
|
+
// try {
|
|
2346
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2347
|
+
// resolve((await fn())!);
|
|
2348
|
+
// } else {
|
|
2349
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2350
|
+
// }
|
|
2351
|
+
// } catch (error) {
|
|
2352
|
+
// reject(error);
|
|
2353
|
+
// }
|
|
2354
|
+
// });
|
|
2357
2355
|
}
|
|
2358
2356
|
else {
|
|
2359
2357
|
const fn = async () => {
|
|
@@ -2370,19 +2368,23 @@ class SqlService {
|
|
|
2370
2368
|
}, { everyLength: 1 });
|
|
2371
2369
|
return result[0];
|
|
2372
2370
|
};
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
}
|
|
2371
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2372
|
+
return fn();
|
|
2373
|
+
}
|
|
2374
|
+
else {
|
|
2375
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2376
|
+
}
|
|
2377
|
+
// return new Promise<bigint>(async (resolve, reject) => {
|
|
2378
|
+
// try {
|
|
2379
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2380
|
+
// resolve((await fn())!);
|
|
2381
|
+
// } else {
|
|
2382
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2383
|
+
// }
|
|
2384
|
+
// } catch (error) {
|
|
2385
|
+
// reject(error);
|
|
2386
|
+
// }
|
|
2387
|
+
// });
|
|
2386
2388
|
}
|
|
2387
2389
|
}
|
|
2388
2390
|
_update(datas, option) {
|
|
@@ -2458,6 +2460,12 @@ class SqlService {
|
|
|
2458
2460
|
}, { everyLength: option?.maxDeal });
|
|
2459
2461
|
return result.reduce((a, b) => a + b);
|
|
2460
2462
|
};
|
|
2463
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2464
|
+
return fn();
|
|
2465
|
+
}
|
|
2466
|
+
else {
|
|
2467
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2468
|
+
}
|
|
2461
2469
|
return new Promise(async (resolve, reject) => {
|
|
2462
2470
|
try {
|
|
2463
2471
|
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
@@ -2577,19 +2585,23 @@ class SqlService {
|
|
|
2577
2585
|
}
|
|
2578
2586
|
return result;
|
|
2579
2587
|
};
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
}
|
|
2588
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2589
|
+
return fn();
|
|
2590
|
+
}
|
|
2591
|
+
else {
|
|
2592
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2593
|
+
}
|
|
2594
|
+
// return new Promise<number>(async (resolve, reject) => {
|
|
2595
|
+
// try {
|
|
2596
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2597
|
+
// resolve((await fn())!);
|
|
2598
|
+
// } else {
|
|
2599
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2600
|
+
// }
|
|
2601
|
+
// } catch (error) {
|
|
2602
|
+
// reject(error);
|
|
2603
|
+
// }
|
|
2604
|
+
// });
|
|
2593
2605
|
}
|
|
2594
2606
|
}
|
|
2595
2607
|
_template(templateResult, result, error) {
|
package/es/code.js
CHANGED
|
@@ -273,33 +273,36 @@ try {
|
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
275
|
const txt = mustache.render(template, data, {}, ['<%', '%>']);
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
276
|
+
const _fileName = configData.command[command].replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]);
|
|
277
|
+
const fileNames = _fileName.split(',');
|
|
278
|
+
for (const fileName of fileNames) {
|
|
279
|
+
const filePath = path.join(basepath, fileName);
|
|
280
|
+
const dirname = path.dirname(filePath);
|
|
281
|
+
mkdir('-p', dirname);
|
|
282
|
+
// try {
|
|
283
|
+
// fs.statSync(dirname);
|
|
284
|
+
// } catch (error) {
|
|
285
|
+
// fs.mkdirSync(dirname);
|
|
286
|
+
// console.info(`[生成] ${dirname}`);
|
|
287
|
+
// }
|
|
288
|
+
try {
|
|
289
|
+
fs.statSync(filePath);
|
|
290
|
+
if (force === false) {
|
|
291
|
+
console.warn(`[跳过] ${filePath}`);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
console.warn(`[覆盖] ${filePath}`);
|
|
296
|
+
}
|
|
291
297
|
}
|
|
292
|
-
|
|
293
|
-
console.
|
|
298
|
+
catch (error) {
|
|
299
|
+
console.info(`[生成] ${filePath}`);
|
|
294
300
|
}
|
|
301
|
+
if (configData.output) {
|
|
302
|
+
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
303
|
+
}
|
|
304
|
+
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
295
305
|
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
console.info(`[生成] ${filePath}`);
|
|
298
|
-
}
|
|
299
|
-
if (configData.output) {
|
|
300
|
-
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
|
|
301
|
-
}
|
|
302
|
-
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
308
|
const replServer = start();
|
package/es/sql.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { XML } from './convert-xml';
|
|
2
2
|
import { ArrayList } from './list';
|
|
3
|
-
import { EnumMap } from 'enum';
|
|
3
|
+
import { EnumMap } from './enum';
|
|
4
4
|
import { ExtensionCodec } from "@msgpack/msgpack";
|
|
5
5
|
export declare const extensionCodec: ExtensionCodec<undefined>;
|
|
6
6
|
declare const _daoDBName: unique symbol;
|
package/es/sql.js
CHANGED
|
@@ -1631,15 +1631,9 @@ const FieldFilter = (K, V, def, uuidColumn, option) => {
|
|
|
1631
1631
|
// 只有在非插入或者非UUID时,进行空置检查
|
|
1632
1632
|
if (option?.insert === true && uuidColumn === true) {
|
|
1633
1633
|
ret = 1;
|
|
1634
|
-
if (V === undefined) {
|
|
1634
|
+
if (V === undefined || emptyString(`${V ?? ''}`)) {
|
|
1635
1635
|
V = null;
|
|
1636
1636
|
}
|
|
1637
|
-
else if (emptyString(`${V ?? ''}`)) {
|
|
1638
|
-
V = '';
|
|
1639
|
-
}
|
|
1640
|
-
else {
|
|
1641
|
-
ret = 1;
|
|
1642
|
-
}
|
|
1643
1637
|
}
|
|
1644
1638
|
else {
|
|
1645
1639
|
if (V === null) {
|
|
@@ -2295,19 +2289,23 @@ export class SqlService {
|
|
|
2295
2289
|
}, { everyLength: option?.every === true ? 1 : option?.maxDeal });
|
|
2296
2290
|
return result;
|
|
2297
2291
|
};
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
}
|
|
2292
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2293
|
+
return fn();
|
|
2294
|
+
}
|
|
2295
|
+
else {
|
|
2296
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2297
|
+
}
|
|
2298
|
+
// return new Promise<bigint[]>(async (resolve, reject) => {
|
|
2299
|
+
// try {
|
|
2300
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2301
|
+
// resolve((await fn())!);
|
|
2302
|
+
// } else {
|
|
2303
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2304
|
+
// }
|
|
2305
|
+
// } catch (error) {
|
|
2306
|
+
// reject(error);
|
|
2307
|
+
// }
|
|
2308
|
+
// });
|
|
2311
2309
|
}
|
|
2312
2310
|
else {
|
|
2313
2311
|
const fn = async () => {
|
|
@@ -2324,19 +2322,23 @@ export class SqlService {
|
|
|
2324
2322
|
}, { everyLength: 1 });
|
|
2325
2323
|
return result[0];
|
|
2326
2324
|
};
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2325
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2326
|
+
return fn();
|
|
2327
|
+
}
|
|
2328
|
+
else {
|
|
2329
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2330
|
+
}
|
|
2331
|
+
// return new Promise<bigint>(async (resolve, reject) => {
|
|
2332
|
+
// try {
|
|
2333
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2334
|
+
// resolve((await fn())!);
|
|
2335
|
+
// } else {
|
|
2336
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2337
|
+
// }
|
|
2338
|
+
// } catch (error) {
|
|
2339
|
+
// reject(error);
|
|
2340
|
+
// }
|
|
2341
|
+
// });
|
|
2340
2342
|
}
|
|
2341
2343
|
}
|
|
2342
2344
|
_update(datas, option) {
|
|
@@ -2412,6 +2414,12 @@ export class SqlService {
|
|
|
2412
2414
|
}, { everyLength: option?.maxDeal });
|
|
2413
2415
|
return result.reduce((a, b) => a + b);
|
|
2414
2416
|
};
|
|
2417
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2418
|
+
return fn();
|
|
2419
|
+
}
|
|
2420
|
+
else {
|
|
2421
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2422
|
+
}
|
|
2415
2423
|
return new Promise(async (resolve, reject) => {
|
|
2416
2424
|
try {
|
|
2417
2425
|
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
@@ -2531,19 +2539,23 @@ export class SqlService {
|
|
|
2531
2539
|
}
|
|
2532
2540
|
return result;
|
|
2533
2541
|
};
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
}
|
|
2542
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2543
|
+
return fn();
|
|
2544
|
+
}
|
|
2545
|
+
else {
|
|
2546
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn);
|
|
2547
|
+
}
|
|
2548
|
+
// return new Promise<number>(async (resolve, reject) => {
|
|
2549
|
+
// try {
|
|
2550
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2551
|
+
// resolve((await fn())!);
|
|
2552
|
+
// } else {
|
|
2553
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2554
|
+
// }
|
|
2555
|
+
// } catch (error) {
|
|
2556
|
+
// reject(error);
|
|
2557
|
+
// }
|
|
2558
|
+
// });
|
|
2547
2559
|
}
|
|
2548
2560
|
}
|
|
2549
2561
|
_template(templateResult, result, error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baja-lite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "some util for self",
|
|
5
5
|
"homepage": "https://github.com/void-soul/util-man",
|
|
6
6
|
"repository": {
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"reflect-metadata": "0.2.2",
|
|
44
44
|
"sql-formatter": "15.4.0",
|
|
45
45
|
"sqlstring": "2.3.3",
|
|
46
|
-
"tslib": "2.
|
|
46
|
+
"tslib": "2.7.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/better-sqlite3": "7.6.11",
|
|
50
50
|
"@types/mustache": "4.2.5",
|
|
51
51
|
"@types/node": "20.14.14",
|
|
52
52
|
"@types/sqlstring": "2.3.2",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
54
|
-
"@typescript-eslint/parser": "8.
|
|
55
|
-
"better-sqlite3": "11.1
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "8.2.0",
|
|
54
|
+
"@typescript-eslint/parser": "8.2.0",
|
|
55
|
+
"better-sqlite3": "11.2.1",
|
|
56
56
|
"ioredis": "5.4.1",
|
|
57
57
|
"mongodb": "6.8.0",
|
|
58
58
|
"mysql2": "3.11.0",
|
package/src/code.ts
CHANGED
|
@@ -283,31 +283,34 @@ try {
|
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
const txt = mustache.render(template, data, {}, ['<%', '%>']);
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
286
|
+
const _fileName = configData.command[command]!.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]);
|
|
287
|
+
const fileNames = _fileName.split(',');
|
|
288
|
+
for(const fileName of fileNames){
|
|
289
|
+
const filePath = path.join(basepath, fileName);
|
|
290
|
+
const dirname = path.dirname(filePath);
|
|
291
|
+
mkdir('-p', dirname);
|
|
292
|
+
// try {
|
|
293
|
+
// fs.statSync(dirname);
|
|
294
|
+
// } catch (error) {
|
|
295
|
+
// fs.mkdirSync(dirname);
|
|
296
|
+
// console.info(`[生成] ${dirname}`);
|
|
297
|
+
// }
|
|
298
|
+
try {
|
|
299
|
+
fs.statSync(filePath);
|
|
300
|
+
if (force === false) {
|
|
301
|
+
console.warn(`[跳过] ${filePath}`);
|
|
302
|
+
return;
|
|
303
|
+
} else {
|
|
304
|
+
console.warn(`[覆盖] ${filePath}`);
|
|
305
|
+
}
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.info(`[生成] ${filePath}`);
|
|
303
308
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]));
|
|
309
|
+
if (configData.output) {
|
|
310
|
+
outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a: string, b: string) => data[b]));
|
|
311
|
+
}
|
|
312
|
+
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
309
313
|
}
|
|
310
|
-
fs.writeFileSync(path.join(basepath, fileName), txt);
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
const replServer = start();
|
package/src/sql.ts
CHANGED
|
@@ -13,7 +13,7 @@ import HTML from 'html-parse-stringify';
|
|
|
13
13
|
import { XML, convert } from './convert-xml';
|
|
14
14
|
import { ArrayList } from './list';
|
|
15
15
|
import LGet from 'lodash.get';
|
|
16
|
-
import { EnumMap } from 'enum';
|
|
16
|
+
import { EnumMap } from './enum';
|
|
17
17
|
import { encode, decode, ExtensionCodec, DecodeError } from "@msgpack/msgpack";
|
|
18
18
|
(BigInt.prototype as any).toJSON = function () { return this.toString() }
|
|
19
19
|
|
|
@@ -1998,12 +1998,8 @@ const FieldFilter = (
|
|
|
1998
1998
|
// 只有在非插入或者非UUID时,进行空置检查
|
|
1999
1999
|
if (option?.insert === true && uuidColumn === true) {
|
|
2000
2000
|
ret = 1;
|
|
2001
|
-
if (V === undefined) {
|
|
2001
|
+
if (V === undefined || emptyString(`${V ?? ''}`)) {
|
|
2002
2002
|
V = null;
|
|
2003
|
-
} else if (emptyString(`${V ?? ''}`)) {
|
|
2004
|
-
V = '';
|
|
2005
|
-
} else {
|
|
2006
|
-
ret = 1;
|
|
2007
2003
|
}
|
|
2008
2004
|
} else {
|
|
2009
2005
|
if (V === null) {
|
|
@@ -2710,17 +2706,23 @@ export class SqlService<T extends object> {
|
|
|
2710
2706
|
);
|
|
2711
2707
|
return result;
|
|
2712
2708
|
};
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
}
|
|
2709
|
+
|
|
2710
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2711
|
+
return fn();
|
|
2712
|
+
} else {
|
|
2713
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn) as Promise<bigint[]>;
|
|
2714
|
+
}
|
|
2715
|
+
// return new Promise<bigint[]>(async (resolve, reject) => {
|
|
2716
|
+
// try {
|
|
2717
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2718
|
+
// resolve((await fn())!);
|
|
2719
|
+
// } else {
|
|
2720
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2721
|
+
// }
|
|
2722
|
+
// } catch (error) {
|
|
2723
|
+
// reject(error);
|
|
2724
|
+
// }
|
|
2725
|
+
// });
|
|
2724
2726
|
} else {
|
|
2725
2727
|
const fn = async () => {
|
|
2726
2728
|
const result = await excuteSplit<Partial<T>, bigint>(
|
|
@@ -2739,17 +2741,22 @@ export class SqlService<T extends object> {
|
|
|
2739
2741
|
);
|
|
2740
2742
|
return result[0]!;
|
|
2741
2743
|
};
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2744
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2745
|
+
return fn();
|
|
2746
|
+
} else {
|
|
2747
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn) as Promise<bigint>;
|
|
2748
|
+
}
|
|
2749
|
+
// return new Promise<bigint>(async (resolve, reject) => {
|
|
2750
|
+
// try {
|
|
2751
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2752
|
+
// resolve((await fn())!);
|
|
2753
|
+
// } else {
|
|
2754
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
2755
|
+
// }
|
|
2756
|
+
// } catch (error) {
|
|
2757
|
+
// reject(error);
|
|
2758
|
+
// }
|
|
2759
|
+
// });
|
|
2753
2760
|
}
|
|
2754
2761
|
}
|
|
2755
2762
|
|
|
@@ -2856,6 +2863,12 @@ export class SqlService<T extends object> {
|
|
|
2856
2863
|
);
|
|
2857
2864
|
return result.reduce((a, b) => a + b);
|
|
2858
2865
|
};
|
|
2866
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
2867
|
+
return fn();
|
|
2868
|
+
} else {
|
|
2869
|
+
return option?.dao?.transaction(SyncMode.Async, fn, option?.conn) as Promise<number>;
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2859
2872
|
return new Promise<number>(async (resolve, reject) => {
|
|
2860
2873
|
try {
|
|
2861
2874
|
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
@@ -3002,17 +3015,22 @@ export class SqlService<T extends object> {
|
|
|
3002
3015
|
}
|
|
3003
3016
|
return result;
|
|
3004
3017
|
};
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3018
|
+
if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
3019
|
+
return fn();
|
|
3020
|
+
} else {
|
|
3021
|
+
return option?.dao?.transaction<number>(SyncMode.Async, fn, option?.conn) as Promise<number>;
|
|
3022
|
+
}
|
|
3023
|
+
// return new Promise<number>(async (resolve, reject) => {
|
|
3024
|
+
// try {
|
|
3025
|
+
// if (this[_dbType] === DBType.SqliteRemote || option?.conn?.[_inTransaction] === true) {
|
|
3026
|
+
// resolve((await fn())!);
|
|
3027
|
+
// } else {
|
|
3028
|
+
// await option?.dao?.transaction(SyncMode.Async, async () => resolve((await fn())!), option?.conn);
|
|
3029
|
+
// }
|
|
3030
|
+
// } catch (error) {
|
|
3031
|
+
// reject(error);
|
|
3032
|
+
// }
|
|
3033
|
+
// });
|
|
3016
3034
|
}
|
|
3017
3035
|
}
|
|
3018
3036
|
|