baja-lite 1.1.3 → 1.1.4

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/.eslintignore +7 -0
  2. package/.eslintrc.cjs +89 -0
  3. package/.prettierrc +4 -0
  4. package/ci.js +29 -0
  5. package/package-cjs.json +17 -0
  6. package/package.json +6 -6
  7. package/{boot-remote.js → src/boot-remote.ts} +7 -6
  8. package/{boot.js → src/boot.ts} +39 -32
  9. package/{code.js → src/code.ts} +67 -64
  10. package/{convert-xml.js → src/convert-xml.ts} +155 -105
  11. package/src/enum.ts +71 -0
  12. package/src/error.ts +11 -0
  13. package/src/fn.ts +295 -0
  14. package/{index.d.ts → src/index.ts} +11 -11
  15. package/{list.js → src/list.ts} +9 -8
  16. package/src/math.ts +405 -0
  17. package/src/object.ts +247 -0
  18. package/src/set-ex.ts +374 -0
  19. package/src/sql.ts +5281 -0
  20. package/{sqlite.js → src/sqlite.ts} +52 -53
  21. package/src/string.ts +111 -0
  22. package/{test-mysql.js → src/test-mysql.ts} +126 -135
  23. package/src/test-postgresql.ts +79 -0
  24. package/{test-sqlite.js → src/test-sqlite.ts} +80 -89
  25. package/{test-xml.js → src/test-xml.ts} +1 -1
  26. package/src/test.ts +2 -0
  27. package/src/wx/base.ts +76 -0
  28. package/src/wx/mini.ts +133 -0
  29. package/src/wx/organ.ts +290 -0
  30. package/{wx/types.d.ts → src/wx/types.ts} +10 -21
  31. package/test.json +0 -0
  32. package/tsconfig.base.json +80 -0
  33. package/tsconfig.cjs.json +42 -0
  34. package/tsconfig.json +44 -0
  35. package/xml/event-report.xml +13 -0
  36. package/yarn.lock +1493 -0
  37. package/boot-remote.d.ts +0 -2
  38. package/boot.d.ts +0 -2
  39. package/code.d.ts +0 -2
  40. package/convert-xml.d.ts +0 -10
  41. package/enum.d.ts +0 -18
  42. package/enum.js +0 -59
  43. package/error.d.ts +0 -5
  44. package/error.js +0 -13
  45. package/fn.d.ts +0 -128
  46. package/fn.js +0 -172
  47. package/index.js +0 -11
  48. package/list.d.ts +0 -10
  49. package/math.d.ts +0 -83
  50. package/math.js +0 -451
  51. package/object.d.ts +0 -83
  52. package/object.js +0 -222
  53. package/set-ex.d.ts +0 -198
  54. package/set-ex.js +0 -338
  55. package/sql.d.ts +0 -1858
  56. package/sql.js +0 -5025
  57. package/sqlite.d.ts +0 -32
  58. package/string.d.ts +0 -17
  59. package/string.js +0 -105
  60. package/test-mysql.d.ts +0 -2
  61. package/test-postgresql.d.ts +0 -2
  62. package/test-postgresql.js +0 -90
  63. package/test-sqlite.d.ts +0 -1
  64. package/test-xml.d.ts +0 -1
  65. package/test.d.ts +0 -1
  66. package/test.js +0 -2
  67. package/wx/base.d.ts +0 -11
  68. package/wx/base.js +0 -78
  69. package/wx/mini.d.ts +0 -45
  70. package/wx/mini.js +0 -102
  71. package/wx/organ.d.ts +0 -65
  72. package/wx/organ.js +0 -171
  73. package/wx/types.js +0 -1
  74. package/wx.js +0 -3
  75. /package/{README.md → Readme.md} +0 -0
  76. /package/{wx.d.ts → src/wx.ts} +0 -0
package/.eslintignore ADDED
@@ -0,0 +1,7 @@
1
+ /dist
2
+ /src-capacitor
3
+ /src-cordova
4
+ /.quasar
5
+ /node_modules
6
+ .eslintrc.cjs
7
+ /quasar.config.*.temporary.compiled*
package/.eslintrc.cjs ADDED
@@ -0,0 +1,89 @@
1
+ module.exports = {
2
+ // https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
3
+ // This option interrupts the configuration hierarchy at this file
4
+ // Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
5
+ root: true,
6
+
7
+ // https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser
8
+ // Must use parserOptions instead of "parser" to allow vue-eslint-parser to keep working
9
+ // `parser: 'vue-eslint-parser'` is already included with any 'plugin:vue/**' config and should be omitted
10
+ parserOptions: {
11
+ parser: require.resolve('@typescript-eslint/parser'),
12
+ extraFileExtensions: [ '.vue' ]
13
+ },
14
+
15
+ env: {
16
+ browser: true,
17
+ es2021: true,
18
+ node: true
19
+ },
20
+
21
+ // Rules order is important, please avoid shuffling them
22
+ extends: [
23
+ // Base ESLint recommended rules
24
+ // 'eslint:recommended',
25
+
26
+ // https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#usage
27
+ // ESLint typescript rules
28
+ 'plugin:@typescript-eslint/recommended',
29
+
30
+ // Uncomment any of the lines below to choose desired strictness,
31
+ // but leave only one uncommented!
32
+ // See https://eslint.vuejs.org/rules/#available-rules
33
+ 'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
34
+ // 'plugin:vue/vue3-strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
35
+ // 'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
36
+
37
+ // https://github.com/prettier/eslint-config-prettier#installation
38
+ // usage with Prettier, provided by 'eslint-config-prettier'.
39
+ 'prettier'
40
+ ],
41
+
42
+ plugins: [
43
+ // required to apply rules which need type information
44
+ '@typescript-eslint',
45
+
46
+ // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
47
+ // required to lint *.vue files
48
+ 'vue'
49
+
50
+ // https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
51
+ // Prettier has not been included as plugin to avoid performance impact
52
+ // add it as an extension for your IDE
53
+
54
+ ],
55
+
56
+ globals: {
57
+ ga: 'readonly', // Google Analytics
58
+ cordova: 'readonly',
59
+ __statics: 'readonly',
60
+ __QUASAR_SSR__: 'readonly',
61
+ __QUASAR_SSR_SERVER__: 'readonly',
62
+ __QUASAR_SSR_CLIENT__: 'readonly',
63
+ __QUASAR_SSR_PWA__: 'readonly',
64
+ process: 'readonly',
65
+ Capacitor: 'readonly',
66
+ chrome: 'readonly'
67
+ },
68
+
69
+ // add your custom rules here
70
+ rules: {
71
+
72
+ 'prefer-promise-reject-errors': 'off',
73
+
74
+ quotes: ['warn', 'single', { avoidEscape: true }],
75
+
76
+ // this rule, if on, would require explicit return type on the `render` function
77
+ '@typescript-eslint/explicit-function-return-type': 'off',
78
+
79
+ // in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled
80
+ '@typescript-eslint/no-var-requires': 'off',
81
+
82
+ // The core 'no-unused-vars' rules (in the eslint:recommended ruleset)
83
+ // does not work with type definitions
84
+ 'no-unused-vars': 'off',
85
+
86
+ // allow debugger during development only
87
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
88
+ }
89
+ }
package/.prettierrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "semi": true
4
+ }
package/ci.js ADDED
@@ -0,0 +1,29 @@
1
+ // import { rm, exec, cp } from 'shelljs';
2
+ import pkg from 'shelljs';
3
+ import cjs from './package-cjs.json' with { type: "json" };
4
+ import def from './package.json' with { type: "json" };
5
+ import fs from 'fs';
6
+ const { rm, exec, cp } = pkg;
7
+
8
+ rm('-rf', './dist/');
9
+ rm('-rf', './tsconfig.tsbuildinfo');
10
+ exec('yarn tsc');
11
+ rm('-rf', './tsconfig.tsbuildinfo');
12
+ cp('./package.json', './dist/package.json');
13
+ cp('./README.md', './dist/README.md');
14
+ cp('./LICENSE', './dist/LICENSE');
15
+ rm('-rf', './dist/tsconfig.tsbuildinfo');
16
+
17
+ rm('-rf', './dist-cjs/');
18
+ rm('-rf', './tsconfig.cjs.tsbuildinfo');
19
+ exec('yarn tsc -p tsconfig.cjs.json');
20
+ rm('-rf', './tsconfig.cjs.tsbuildinfo');
21
+ fs.writeFileSync('./dist-cjs/package.json', JSON.stringify(Object.assign(def, cjs), null, 2));
22
+ cp('./README.md', './dist-cjs/README.md');
23
+ cp('./LICENSE', './dist-cjs/LICENSE');
24
+
25
+
26
+ cp('-R', './dist/*', 'E:\\pro\\v\\apps-services\\fast-start\\node_modules\\baja-lite');
27
+ cp('-R', './dist-cjs/*', 'E:\\pro\\v\\apps-services\\attack-service\\node_modules\\baja-lite-cjs');
28
+ cp('-R', './dist/*', 'E:\\pro\\v\\apps-services\\attack-front\\node_modules\\baja-lite');
29
+ console.log('cp over');
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "baja-lite-cjs",
3
+ "type": "commonjs",
4
+ "exports": {
5
+ ".": {
6
+ "require": "./index.js"
7
+ },
8
+ "./boot.js":"./boot.js",
9
+ "./boot-remote.js":"./boot-remote.js",
10
+ "./wx.js": "./wx.js"
11
+ },
12
+ "types": "./index.d.ts",
13
+ "bin": {
14
+ "baja": "./code.js"
15
+ },
16
+ "main": "./index.js"
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baja-lite",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "some util for self",
5
5
  "homepage": "https://github.com/void-soul/util-man",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "baja": "./code.js"
25
25
  },
26
- "models": "./es/index.js",
26
+ "models": "./index.js",
27
27
  "scripts": {
28
28
  "dist": "node ./ci.js",
29
29
  "mysql": "bun --inspect ./src/test-mysql.ts",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@msgpack/msgpack": "3.0.0-beta3",
38
- "@types/request-promise": "^4.1.51",
38
+ "@types/request-promise": "4.1.51",
39
39
  "axios": "1.7.9",
40
40
  "decimal.js": "10.5.0",
41
41
  "html-parse-stringify": "3.0.1",
@@ -45,7 +45,7 @@
45
45
  "pino": "9.6.0",
46
46
  "pino-pretty": "13.0.0",
47
47
  "reflect-metadata": "0.2.2",
48
- "request-promise": "^4.2.6",
48
+ "request-promise": "4.2.6",
49
49
  "sql-formatter": "15.4.10",
50
50
  "sqlstring": "2.3.3",
51
51
  "tslib": "2.8.1"
@@ -54,7 +54,7 @@
54
54
  "@types/better-sqlite3": "7.6.12",
55
55
  "@types/lodash.get": "4.4.9",
56
56
  "@types/mustache": "4.2.5",
57
- "@types/node": "22.12.0",
57
+ "@types/node": "22.13.0",
58
58
  "@types/pg-pool": "2.0.6",
59
59
  "@types/shelljs": "0.8.15",
60
60
  "@types/sqlstring": "2.3.2",
@@ -62,7 +62,7 @@
62
62
  "@typescript-eslint/parser": "8.22.0",
63
63
  "better-sqlite3": "11.8.1",
64
64
  "ioredis": "5.4.2",
65
- "mongodb": "6.12.0",
65
+ "mongodb": "6.13.0",
66
66
  "mysql2": "3.12.0",
67
67
  "pg": "8.13.1",
68
68
  "pg-pool": "3.7.0",
@@ -1,6 +1,7 @@
1
1
  import { getEnums } from './enum.js';
2
- import { _primaryDB, _dao, logger, DBType, _sqlCache, _GlobalSqlOption, _defOption, SqlCache, SqliteRemote, _Hump, ColumnMode, _enums } from './sql.js';
3
- export const BootRomote = async function (options) {
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) {
4
5
  globalThis[_GlobalSqlOption] = Object.assign({}, _defOption, options);
5
6
  globalThis[_Hump] = globalThis[_GlobalSqlOption].columnMode === ColumnMode.HUMP;
6
7
  logger.level = options.log ?? 'info';
@@ -18,8 +19,7 @@ export const BootRomote = async function (options) {
18
19
  if (typeof options.SqliteRemote.db === 'string') {
19
20
  options.SqliteRemote.service.initDB(options.SqliteRemote.db);
20
21
  globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
21
- }
22
- else {
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,7 +32,8 @@ export const BootRomote = async function (options) {
32
32
  }
33
33
  }
34
34
  }
35
- };
35
+ }
36
+
36
37
  // export const AppendRomote = async function (dbName: string) {
37
38
  // if (!globalThis[_dao][DBType.SqliteRemote][dbName]) {
38
39
  // globalThis[_GlobalSqlOption].SqliteRemote.service.initDB(dbName);
@@ -42,4 +43,4 @@ export const BootRomote = async function (options) {
42
43
  // }
43
44
  // globalThis[_dao][DBType.SqliteRemote][dbName] = db;
44
45
  // }
45
- // }
46
+ // }
@@ -1,6 +1,7 @@
1
1
  import { getEnums } from './enum.js';
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) {
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) {
4
5
  globalThis[_GlobalSqlOption] = Object.assign({}, _defOption, options);
5
6
  globalThis[_Hump] = globalThis[_GlobalSqlOption].columnMode === ColumnMode.HUMP;
6
7
  if (options.sqlDir) {
@@ -32,8 +33,8 @@ export const Boot = async function (options) {
32
33
  decimalNumbers: true,
33
34
  supportBigNumbers: true
34
35
  }));
35
- }
36
- else {
36
+
37
+ } else {
37
38
  let flag = false;
38
39
  for (const [key, option] of Object.entries(options.Mysql)) {
39
40
  const db = new Mysql(createPool({
@@ -42,6 +43,7 @@ export const Boot = async function (options) {
42
43
  decimalNumbers: true,
43
44
  supportBigNumbers: true
44
45
  }));
46
+
45
47
  if (flag === false) {
46
48
  globalThis[_dao][DBType.Mysql][_primaryDB] = db;
47
49
  flag = true;
@@ -53,8 +55,7 @@ export const Boot = async function (options) {
53
55
  if (options.Sqlite) {
54
56
  if (typeof options.Sqlite === 'string') {
55
57
  globalThis[_dao][DBType.Sqlite][_primaryDB] = new Sqlite(new options.BetterSqlite3(options.Sqlite, { fileMustExist: false }));
56
- }
57
- else {
58
+ } else {
58
59
  let flag = false;
59
60
  for (const [key, fileName] of Object.entries(options.Sqlite)) {
60
61
  const db = new Sqlite(new options.BetterSqlite3(fileName, { fileMustExist: false }));
@@ -70,8 +71,7 @@ export const Boot = async function (options) {
70
71
  if (typeof options.SqliteRemote.db === 'string') {
71
72
  options.SqliteRemote.service.initDB(options.SqliteRemote.db);
72
73
  globalThis[_dao][DBType.SqliteRemote][_primaryDB] = new SqliteRemote(options.SqliteRemote.service, options.SqliteRemote.db);
73
- }
74
- else {
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,8 +88,7 @@ export const Boot = async function (options) {
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
- }
92
- else {
91
+ } else {
93
92
  let flag = false;
94
93
  for (const [key, option] of Object.entries(options.Redis)) {
95
94
  const db = new Redis(option);
@@ -100,25 +99,32 @@ export const Boot = async function (options) {
100
99
  globalThis[_dao][DBType.Redis][key] = db;
101
100
  }
102
101
  }
103
- const clients = Object.values(globalThis[_dao][DBType.Redis]);
102
+ const clients = Object.values(globalThis[_dao][DBType.Redis]) as any;
104
103
  const Redlock = await import('redlock');
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
- });
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
+ );
122
128
  const { EventEmitter } = await import('events');
123
129
  const event = new EventEmitter({ captureRejections: true });
124
130
  event.on('error', error => {
@@ -127,14 +133,15 @@ export const Boot = async function (options) {
127
133
  globalThis[_EventBus] = event;
128
134
  }
129
135
  if (options.Postgresql) {
130
- const Pool = await import('pg-pool');
136
+ const Pool = await import('pg-pool');
131
137
  if (options.Postgresql['host']) {
132
138
  globalThis[_dao][DBType.Postgresql][_primaryDB] = new Postgresql(new Pool.default(options.Postgresql));
133
- }
134
- else {
139
+
140
+ } else {
135
141
  let flag = false;
136
142
  for (const [key, option] of Object.entries(options.Postgresql)) {
137
143
  const db = new Postgresql(new Pool.default(option));
144
+
138
145
  if (flag === false) {
139
146
  globalThis[_dao][DBType.Postgresql][_primaryDB] = db;
140
147
  flag = true;
@@ -143,4 +150,4 @@ export const Boot = async function (options) {
143
150
  }
144
151
  }
145
152
  }
146
- };
153
+ }