baja-lite 1.6.4 → 1.6.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 (73) hide show
  1. package/boot-remote.d.ts +2 -0
  2. package/{src/boot-remote.ts → boot-remote.js} +63 -64
  3. package/boot.d.ts +2 -0
  4. package/{src/boot.ts → boot.js} +163 -170
  5. package/code.d.ts +2 -0
  6. package/{src/code.ts → code.js} +405 -414
  7. package/convert-xml.d.ts +10 -0
  8. package/{src/convert-xml.ts → convert-xml.js} +410 -460
  9. package/error.d.ts +5 -0
  10. package/error.js +13 -0
  11. package/event.d.ts +10 -0
  12. package/event.js +38 -0
  13. package/fn.d.ts +128 -0
  14. package/fn.js +172 -0
  15. package/{src/index.ts → index.d.ts} +10 -11
  16. package/index.js +10 -0
  17. package/math.d.ts +83 -0
  18. package/math.js +451 -0
  19. package/object.d.ts +126 -0
  20. package/object.js +321 -0
  21. package/package.json +1 -1
  22. package/snowflake.d.ts +12 -0
  23. package/{src/snowflake.ts → snowflake.js} +108 -127
  24. package/sql.d.ts +2148 -0
  25. package/sql.js +5370 -0
  26. package/sqlite.d.ts +32 -0
  27. package/{src/sqlite.ts → sqlite.js} +156 -157
  28. package/string.d.ts +17 -0
  29. package/string.js +105 -0
  30. package/test-mysql.d.ts +2 -0
  31. package/test-mysql.js +114 -0
  32. package/test-postgresql.d.ts +2 -0
  33. package/{src/test-postgresql.ts → test-postgresql.js} +91 -80
  34. package/test-sqlite.d.ts +1 -0
  35. package/{src/test-sqlite.ts → test-sqlite.js} +90 -80
  36. package/test-xml.d.ts +1 -0
  37. package/{src/test-xml.ts → test-xml.js} +2 -2
  38. package/test.d.ts +1 -0
  39. package/{src/test.ts → test.js} +2 -3
  40. package/wx/base.d.ts +11 -0
  41. package/wx/base.js +78 -0
  42. package/wx/mini.d.ts +52 -0
  43. package/wx/mini.js +112 -0
  44. package/wx/organ.d.ts +65 -0
  45. package/wx/organ.js +171 -0
  46. package/{src/wx/types.ts → wx/types.d.ts} +560 -549
  47. package/wx/types.js +1 -0
  48. package/{src/wx.ts → wx.d.ts} +3 -3
  49. package/wx.js +3 -0
  50. package/.eslintignore +0 -7
  51. package/.eslintrc.cjs +0 -89
  52. package/.prettierrc +0 -7
  53. package/.vscode/settings.json +0 -9
  54. package/ci.js +0 -33
  55. package/package-cjs.json +0 -17
  56. package/pnpm-lock.yaml +0 -2840
  57. package/pnpm-workspace.yaml +0 -2
  58. package/src/error.ts +0 -11
  59. package/src/event.ts +0 -34
  60. package/src/fn.ts +0 -295
  61. package/src/math.ts +0 -405
  62. package/src/object.ts +0 -342
  63. package/src/sql.ts +0 -5529
  64. package/src/string.ts +0 -111
  65. package/src/test-mysql.ts +0 -148
  66. package/src/wx/base.ts +0 -77
  67. package/src/wx/mini.ts +0 -147
  68. package/src/wx/organ.ts +0 -290
  69. package/tsconfig.cjs.json +0 -42
  70. package/tsconfig.json +0 -44
  71. package/xml/event-report.xml +0 -13
  72. package/yarn.lock +0 -1977
  73. /package/{Readme.md → README.md} +0 -0
@@ -0,0 +1,2 @@
1
+ import { GlobalSqlOptionForWeb } from './sql.js';
2
+ export declare const BootRomote: (options: GlobalSqlOptionForWeb) => Promise<void>;
@@ -1,64 +1,63 @@
1
- import { DBType, _Hump, getEnums } from 'baja-lite-field';
2
- import { ColumnMode, GlobalSqlOptionForWeb, SqlCache, SqliteRemote, _DataConvert, _GlobalSqlOption, _dao, _defOption, _enum, _primaryDB, _sqlCache, logger } from './sql.js';
3
-
4
- export const BootRomote = async function (options: GlobalSqlOptionForWeb) {
5
- globalThis[_GlobalSqlOption] = Object.assign({}, _defOption);
6
- if(options.skipEmptyString !== undefined){
7
- globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
8
- }
9
- if(options.skipNull !== undefined){
10
- globalThis[_GlobalSqlOption].skipNull = options.skipNull;
11
- }
12
- if(options.skipEmptyString !== undefined){
13
- globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
14
- }
15
- if(options.maxDeal !== undefined){
16
- globalThis[_GlobalSqlOption].maxDeal = options.maxDeal;
17
- }
18
- if(options.SqliteRemote !== undefined){
19
- globalThis[_GlobalSqlOption].SqliteRemote = options.SqliteRemote;
20
- }
21
- globalThis[_Hump] = options.columnMode === ColumnMode.HUMP;
22
- logger.level = options.log ?? 'info';
23
- globalThis[_sqlCache] = new SqlCache();
24
- if (options.sqlMap) {
25
- await globalThis[_sqlCache].init(options);
26
- }
27
- globalThis[_dao] = {
28
- [DBType.SqliteRemote]: {},
29
- };
30
- if (options.enums) {
31
- globalThis[_enum] = getEnums(options.enums);
32
- }
33
- if (options.dataConvert) {
34
- globalThis[_DataConvert] = options.dataConvert;
35
- }
36
- if (options.SqliteRemote && options.SqliteRemote.db) {
37
- if (typeof options.SqliteRemote.db === 'string') {
38
- options.SqliteRemote.service.initDB(options.SqliteRemote.db);
39
- globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
40
- } else {
41
- let flag = false;
42
- for (const [key, fileName] of Object.entries(options.SqliteRemote.db)) {
43
- await options.SqliteRemote.service.initDB(fileName);
44
- const db = new SqliteRemote(options.SqliteRemote.service, fileName);
45
- if (flag === false) {
46
- globalThis[_dao][DBType.SqliteRemote][_primaryDB] = db;
47
- flag = true;
48
- }
49
- globalThis[_dao][DBType.SqliteRemote][key] = db;
50
- }
51
- }
52
- }
53
- }
54
-
55
- // export const AppendRomote = async function (dbName: string) {
56
- // if (!globalThis[_dao][DBType.SqliteRemote][dbName]) {
57
- // globalThis[_GlobalSqlOption].SqliteRemote.service.initDB(dbName);
58
- // const db = new SqliteRemote(globalThis[_GlobalSqlOption].SqliteRemote.service, dbName);
59
- // if (globalThis[_dao][DBType.SqliteRemote][_primaryDB] === undefined) {
60
- // globalThis[_dao][DBType.SqliteRemote][_primaryDB] = db;
61
- // }
62
- // globalThis[_dao][DBType.SqliteRemote][dbName] = db;
63
- // }
64
- // }
1
+ import { DBType, _Hump, getEnums } from 'baja-lite-field';
2
+ import { ColumnMode, SqlCache, SqliteRemote, _DataConvert, _GlobalSqlOption, _dao, _defOption, _enum, _primaryDB, _sqlCache, logger } from './sql.js';
3
+ export const BootRomote = async function (options) {
4
+ globalThis[_GlobalSqlOption] = Object.assign({}, _defOption);
5
+ if (options.skipEmptyString !== undefined) {
6
+ globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
7
+ }
8
+ if (options.skipNull !== undefined) {
9
+ globalThis[_GlobalSqlOption].skipNull = options.skipNull;
10
+ }
11
+ if (options.skipEmptyString !== undefined) {
12
+ globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
13
+ }
14
+ if (options.maxDeal !== undefined) {
15
+ globalThis[_GlobalSqlOption].maxDeal = options.maxDeal;
16
+ }
17
+ if (options.SqliteRemote !== undefined) {
18
+ globalThis[_GlobalSqlOption].SqliteRemote = options.SqliteRemote;
19
+ }
20
+ globalThis[_Hump] = options.columnMode === ColumnMode.HUMP;
21
+ logger.level = options.log ?? 'info';
22
+ globalThis[_sqlCache] = new SqlCache();
23
+ if (options.sqlMap) {
24
+ await globalThis[_sqlCache].init(options);
25
+ }
26
+ globalThis[_dao] = {
27
+ [DBType.SqliteRemote]: {},
28
+ };
29
+ if (options.enums) {
30
+ globalThis[_enum] = getEnums(options.enums);
31
+ }
32
+ if (options.dataConvert) {
33
+ globalThis[_DataConvert] = options.dataConvert;
34
+ }
35
+ if (options.SqliteRemote && options.SqliteRemote.db) {
36
+ if (typeof options.SqliteRemote.db === 'string') {
37
+ options.SqliteRemote.service.initDB(options.SqliteRemote.db);
38
+ globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
39
+ }
40
+ else {
41
+ let flag = false;
42
+ for (const [key, fileName] of Object.entries(options.SqliteRemote.db)) {
43
+ await options.SqliteRemote.service.initDB(fileName);
44
+ const db = new SqliteRemote(options.SqliteRemote.service, fileName);
45
+ if (flag === false) {
46
+ globalThis[_dao][DBType.SqliteRemote][_primaryDB] = db;
47
+ flag = true;
48
+ }
49
+ globalThis[_dao][DBType.SqliteRemote][key] = db;
50
+ }
51
+ }
52
+ }
53
+ };
54
+ // export const AppendRomote = async function (dbName: string) {
55
+ // if (!globalThis[_dao][DBType.SqliteRemote][dbName]) {
56
+ // globalThis[_GlobalSqlOption].SqliteRemote.service.initDB(dbName);
57
+ // const db = new SqliteRemote(globalThis[_GlobalSqlOption].SqliteRemote.service, dbName);
58
+ // if (globalThis[_dao][DBType.SqliteRemote][_primaryDB] === undefined) {
59
+ // globalThis[_dao][DBType.SqliteRemote][_primaryDB] = db;
60
+ // }
61
+ // globalThis[_dao][DBType.SqliteRemote][dbName] = db;
62
+ // }
63
+ // }
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,170 +1,163 @@
1
- import { _Hump, DBType, getEnums } from 'baja-lite-field';
2
- import events from 'events';
3
- import { _dao, _DataConvert, _defOption, _enum, _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) {
6
- globalThis[_GlobalSqlOption] = Object.assign({}, _defOption);
7
- if (options.skipEmptyString !== undefined) {
8
- globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
9
- }
10
- if (options.skipNull !== undefined) {
11
- globalThis[_GlobalSqlOption].skipNull = options.skipNull;
12
- }
13
- if (options.skipEmptyString !== undefined) {
14
- globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
15
- }
16
- if (options.maxDeal !== undefined) {
17
- globalThis[_GlobalSqlOption].maxDeal = options.maxDeal;
18
- }
19
- globalThis[_Hump] = options.columnMode === ColumnMode.HUMP;
20
- logger.level = options.log ?? 'info';
21
- globalThis[_sqlCache] = new SqlCache();
22
- if (options.sqlDir) {
23
- globalThis[_path] = await import('path');
24
- globalThis[_fs] = await import('fs');
25
- }
26
- if (options.sqlMap || options.sqlDir) {
27
- await globalThis[_sqlCache].init(options);
28
- }
29
- globalThis[_dao] = {
30
- [DBType.Mongo]: {},
31
- [DBType.Mysql]: {},
32
- [DBType.Postgresql]: {},
33
- [DBType.Sqlite]: {},
34
- [DBType.SqliteRemote]: {},
35
- [DBType.Redis]: {}
36
- };
37
- if (options.enums) {
38
- globalThis[_enum] = getEnums(options.enums);
39
- }
40
- if (options.dataConvert) {
41
- globalThis[_DataConvert] = options.dataConvert;
42
- }
43
- if (options.Mysql) {
44
- const { createPool } = await import('mysql2/promise');
45
- if (options.Mysql['host']) {
46
- globalThis[_dao][DBType.Mysql][_primaryDB] = new Mysql(createPool({
47
- ...options.Mysql,
48
- multipleStatements: true,
49
- decimalNumbers: true,
50
- supportBigNumbers: true
51
- }));
52
- }
53
- else {
54
- let flag = false;
55
- for (const [key, option] of Object.entries(options.Mysql)) {
56
- const db = new Mysql(createPool({
57
- ...option,
58
- multipleStatements: true,
59
- decimalNumbers: true,
60
- supportBigNumbers: true
61
- }));
62
- if (!flag) {
63
- globalThis[_dao][DBType.Mysql][_primaryDB] = db;
64
- flag = true;
65
- }
66
- globalThis[_dao][DBType.Mysql][key] = db;
67
- }
68
- }
69
- }
70
- if (options.Sqlite) {
71
- if (typeof options.Sqlite === 'string') {
72
- globalThis[_dao][DBType.Sqlite][_primaryDB] = new Sqlite(new options.BetterSqlite3(options.Sqlite, { fileMustExist: false }));
73
- } else {
74
- let flag = false;
75
- for (const [key, fileName] of Object.entries(options.Sqlite)) {
76
- const db = new Sqlite(new options.BetterSqlite3(fileName, { fileMustExist: false }));
77
- if (!flag) {
78
- globalThis[_dao][DBType.Sqlite][_primaryDB] = db;
79
- flag = true;
80
- }
81
- globalThis[_dao][DBType.Sqlite][key] = db;
82
- }
83
- }
84
- }
85
- if (options.SqliteRemote && options.SqliteRemote.db) {
86
- if (typeof options.SqliteRemote.db === 'string') {
87
- options.SqliteRemote.service.initDB(options.SqliteRemote.db);
88
- globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
89
- }
90
- else {
91
- let flag = false;
92
- for (const [key, fileName] of Object.entries(options.SqliteRemote.db)) {
93
- options.SqliteRemote.service.initDB(fileName);
94
- const db = new SqliteRemote(options.SqliteRemote.service, fileName);
95
- if (!flag) {
96
- globalThis[_dao][DBType.SqliteRemote][_primaryDB] = db;
97
- flag = true;
98
- }
99
- globalThis[_dao][DBType.SqliteRemote][key] = db;
100
- }
101
- }
102
- }
103
- if (options.Redis) {
104
- events.setMaxListeners(0);
105
- const { Redis } = await import('ioredis');
106
- if (options.Redis['host']) {
107
- globalThis[_dao][DBType.Redis][_primaryDB] = new Redis(options.Redis);
108
- }
109
- else {
110
- let flag = false;
111
- for (const [key, option] of Object.entries(options.Redis)) {
112
- const db = new Redis(option);
113
- if (!flag) {
114
- globalThis[_dao][DBType.Redis][_primaryDB] = db;
115
- flag = true;
116
- }
117
- globalThis[_dao][DBType.Redis][key] = db;
118
- }
119
- }
120
- const clients = Object.values(globalThis[_dao][DBType.Redis]) as any;
121
- const Redlock = await import('redlock');
122
- globalThis[_dao][DBType.RedisLock] = new Redlock.default(
123
- clients,
124
- {
125
- // The expected clock drift; for more details see:
126
- // http://redis.io/topics/distlock
127
- driftFactor: 0.01, // multiplied by lock ttl to determine drift time
128
-
129
- // The max number of times Redlock will attempt to lock a resource
130
- // before erroring.
131
- retryCount: 10,
132
-
133
- // the time in ms between attempts
134
- retryDelay: 200, // time in ms
135
-
136
- // the max time in ms randomly added to retries
137
- // to improve performance under high contention
138
- // see https://www.awsarchitectureblog.com/2015/03/backoff.html
139
- retryJitter: 200, // time in ms
140
-
141
- // The minimum remaining time on a lock before an extension is automatically
142
- // attempted with the `using` API.
143
- automaticExtensionThreshold: 500, // time in ms
144
- }
145
- );
146
- const { EventEmitter } = await import('events');
147
- const event = new EventEmitter({ captureRejections: true });
148
- event.on('error', error => {
149
- logger.error('event-bus', error);
150
- });
151
- globalThis[_EventBus] = event;
152
- }
153
- if (options.Postgresql) {
154
- const Pool = await import('pg-pool');
155
- if (options.Postgresql['host']) {
156
- globalThis[_dao][DBType.Postgresql][_primaryDB] = new Postgresql(new Pool.default(options.Postgresql));
157
- }
158
- else {
159
- let flag = false;
160
- for (const [key, option] of Object.entries(options.Postgresql)) {
161
- const db = new Postgresql(new Pool.default(option));
162
- if (!flag) {
163
- globalThis[_dao][DBType.Postgresql][_primaryDB] = db;
164
- flag = true;
165
- }
166
- globalThis[_dao][DBType.Postgresql][key] = db;
167
- }
168
- }
169
- }
170
- }
1
+ import { _Hump, DBType, getEnums } from 'baja-lite-field';
2
+ import events from 'events';
3
+ import { _dao, _DataConvert, _defOption, _enum, _EventBus, _fs, _GlobalSqlOption, _path, _primaryDB, _sqlCache, ColumnMode, logger, Mysql, Postgresql, SqlCache, Sqlite, SqliteRemote } from './sql.js';
4
+ export const Boot = async function (options) {
5
+ globalThis[_GlobalSqlOption] = Object.assign({}, _defOption);
6
+ if (options.skipEmptyString !== undefined) {
7
+ globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
8
+ }
9
+ if (options.skipNull !== undefined) {
10
+ globalThis[_GlobalSqlOption].skipNull = options.skipNull;
11
+ }
12
+ if (options.skipEmptyString !== undefined) {
13
+ globalThis[_GlobalSqlOption].skipEmptyString = options.skipEmptyString;
14
+ }
15
+ if (options.maxDeal !== undefined) {
16
+ globalThis[_GlobalSqlOption].maxDeal = options.maxDeal;
17
+ }
18
+ globalThis[_Hump] = options.columnMode === ColumnMode.HUMP;
19
+ logger.level = options.log ?? 'info';
20
+ globalThis[_sqlCache] = new SqlCache();
21
+ if (options.sqlDir) {
22
+ globalThis[_path] = await import('path');
23
+ globalThis[_fs] = await import('fs');
24
+ }
25
+ if (options.sqlMap || options.sqlDir) {
26
+ await globalThis[_sqlCache].init(options);
27
+ }
28
+ globalThis[_dao] = {
29
+ [DBType.Mongo]: {},
30
+ [DBType.Mysql]: {},
31
+ [DBType.Postgresql]: {},
32
+ [DBType.Sqlite]: {},
33
+ [DBType.SqliteRemote]: {},
34
+ [DBType.Redis]: {}
35
+ };
36
+ if (options.enums) {
37
+ globalThis[_enum] = getEnums(options.enums);
38
+ }
39
+ if (options.dataConvert) {
40
+ globalThis[_DataConvert] = options.dataConvert;
41
+ }
42
+ if (options.Mysql) {
43
+ const { createPool } = await import('mysql2/promise');
44
+ if (options.Mysql['host']) {
45
+ globalThis[_dao][DBType.Mysql][_primaryDB] = new Mysql(createPool({
46
+ ...options.Mysql,
47
+ multipleStatements: true,
48
+ decimalNumbers: true,
49
+ supportBigNumbers: true
50
+ }));
51
+ }
52
+ else {
53
+ let flag = false;
54
+ for (const [key, option] of Object.entries(options.Mysql)) {
55
+ const db = new Mysql(createPool({
56
+ ...option,
57
+ multipleStatements: true,
58
+ decimalNumbers: true,
59
+ supportBigNumbers: true
60
+ }));
61
+ if (!flag) {
62
+ globalThis[_dao][DBType.Mysql][_primaryDB] = db;
63
+ flag = true;
64
+ }
65
+ globalThis[_dao][DBType.Mysql][key] = db;
66
+ }
67
+ }
68
+ }
69
+ if (options.Sqlite) {
70
+ if (typeof options.Sqlite === 'string') {
71
+ globalThis[_dao][DBType.Sqlite][_primaryDB] = new Sqlite(new options.BetterSqlite3(options.Sqlite, { fileMustExist: false }));
72
+ }
73
+ else {
74
+ let flag = false;
75
+ for (const [key, fileName] of Object.entries(options.Sqlite)) {
76
+ const db = new Sqlite(new options.BetterSqlite3(fileName, { fileMustExist: false }));
77
+ if (!flag) {
78
+ globalThis[_dao][DBType.Sqlite][_primaryDB] = db;
79
+ flag = true;
80
+ }
81
+ globalThis[_dao][DBType.Sqlite][key] = db;
82
+ }
83
+ }
84
+ }
85
+ if (options.SqliteRemote && options.SqliteRemote.db) {
86
+ if (typeof options.SqliteRemote.db === 'string') {
87
+ options.SqliteRemote.service.initDB(options.SqliteRemote.db);
88
+ globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
89
+ }
90
+ else {
91
+ let flag = false;
92
+ for (const [key, fileName] of Object.entries(options.SqliteRemote.db)) {
93
+ options.SqliteRemote.service.initDB(fileName);
94
+ const db = new SqliteRemote(options.SqliteRemote.service, fileName);
95
+ if (!flag) {
96
+ globalThis[_dao][DBType.SqliteRemote][_primaryDB] = db;
97
+ flag = true;
98
+ }
99
+ globalThis[_dao][DBType.SqliteRemote][key] = db;
100
+ }
101
+ }
102
+ }
103
+ if (options.Redis) {
104
+ events.setMaxListeners(0);
105
+ const { Redis } = await import('ioredis');
106
+ if (options.Redis['host']) {
107
+ globalThis[_dao][DBType.Redis][_primaryDB] = new Redis(options.Redis);
108
+ }
109
+ else {
110
+ let flag = false;
111
+ for (const [key, option] of Object.entries(options.Redis)) {
112
+ const db = new Redis(option);
113
+ if (!flag) {
114
+ globalThis[_dao][DBType.Redis][_primaryDB] = db;
115
+ flag = true;
116
+ }
117
+ globalThis[_dao][DBType.Redis][key] = db;
118
+ }
119
+ }
120
+ const clients = Object.values(globalThis[_dao][DBType.Redis]);
121
+ const Redlock = await import('redlock');
122
+ globalThis[_dao][DBType.RedisLock] = new Redlock.default(clients, {
123
+ // The expected clock drift; for more details see:
124
+ // http://redis.io/topics/distlock
125
+ driftFactor: 0.01, // multiplied by lock ttl to determine drift time
126
+ // The max number of times Redlock will attempt to lock a resource
127
+ // before erroring.
128
+ retryCount: 10,
129
+ // the time in ms between attempts
130
+ retryDelay: 200, // time in ms
131
+ // the max time in ms randomly added to retries
132
+ // to improve performance under high contention
133
+ // see https://www.awsarchitectureblog.com/2015/03/backoff.html
134
+ retryJitter: 200, // time in ms
135
+ // The minimum remaining time on a lock before an extension is automatically
136
+ // attempted with the `using` API.
137
+ automaticExtensionThreshold: 500, // time in ms
138
+ });
139
+ const { EventEmitter } = await import('events');
140
+ const event = new EventEmitter({ captureRejections: true });
141
+ event.on('error', error => {
142
+ logger.error('event-bus', error);
143
+ });
144
+ globalThis[_EventBus] = event;
145
+ }
146
+ if (options.Postgresql) {
147
+ const Pool = await import('pg-pool');
148
+ if (options.Postgresql['host']) {
149
+ globalThis[_dao][DBType.Postgresql][_primaryDB] = new Postgresql(new Pool.default(options.Postgresql));
150
+ }
151
+ else {
152
+ let flag = false;
153
+ for (const [key, option] of Object.entries(options.Postgresql)) {
154
+ const db = new Postgresql(new Pool.default(option));
155
+ if (!flag) {
156
+ globalThis[_dao][DBType.Postgresql][_primaryDB] = db;
157
+ flag = true;
158
+ }
159
+ globalThis[_dao][DBType.Postgresql][key] = db;
160
+ }
161
+ }
162
+ }
163
+ };
package/code.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};