baja-lite 1.5.27 → 1.5.29
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/package.json +9 -9
- package/sql.js +20 -2
- package/sqlite.js +20 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baja-lite",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.29",
|
|
4
4
|
"description": "some util for self",
|
|
5
5
|
"homepage": "https://github.com/void-soul/baja-lite",
|
|
6
6
|
"repository": {
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"@msgpack/msgpack": "3.1.2",
|
|
39
39
|
"@types/request-promise": "4.1.51",
|
|
40
40
|
"axios": "1.11.0",
|
|
41
|
-
"baja-lite-field": "1.4.
|
|
41
|
+
"baja-lite-field": "1.4.14",
|
|
42
42
|
"decimal.js": "10.6.0",
|
|
43
43
|
"html-parse-stringify": "3.0.1",
|
|
44
44
|
"iterare": "1.2.1",
|
|
45
45
|
"lodash.get": "4.4.2",
|
|
46
46
|
"mustache": "4.2.0",
|
|
47
47
|
"pino": "9.7.0",
|
|
48
|
-
"pino-pretty": "13.
|
|
48
|
+
"pino-pretty": "13.1.1",
|
|
49
49
|
"reflect-metadata": "0.2.2",
|
|
50
50
|
"request": "2.88.2",
|
|
51
51
|
"request-promise": "4.2.6",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"@types/better-sqlite3": "7.6.13",
|
|
58
58
|
"@types/lodash.get": "4.4.9",
|
|
59
59
|
"@types/mustache": "4.2.6",
|
|
60
|
-
"@types/node": "24.0
|
|
60
|
+
"@types/node": "24.1.0",
|
|
61
61
|
"@types/shelljs": "0.8.17",
|
|
62
62
|
"@types/sqlstring": "2.3.2",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
64
|
-
"@typescript-eslint/parser": "8.
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "8.38.0",
|
|
64
|
+
"@typescript-eslint/parser": "8.38.0",
|
|
65
65
|
"better-sqlite3": "12.2.0",
|
|
66
|
-
"ioredis": "5.
|
|
66
|
+
"ioredis": "5.7.0",
|
|
67
67
|
"mongodb": "6.18.0",
|
|
68
|
-
"mysql2": "3.14.
|
|
68
|
+
"mysql2": "3.14.3",
|
|
69
69
|
"pg": "8.16.3",
|
|
70
70
|
"pg-pool": "3.10.1",
|
|
71
71
|
"redlock": "5.0.0-beta.2",
|
|
72
72
|
"shelljs": "0.10.0",
|
|
73
|
-
"typescript": "5.
|
|
73
|
+
"typescript": "5.9.2"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=20"
|
package/sql.js
CHANGED
|
@@ -949,10 +949,28 @@ export class Sqlite {
|
|
|
949
949
|
PRIMARY KEY ( ______tableName )
|
|
950
950
|
);
|
|
951
951
|
`);
|
|
952
|
-
this[_daoDB].function('UUID_SHORT', { deterministic:
|
|
953
|
-
this[_daoDB].function('
|
|
952
|
+
this[_daoDB].function('UUID_SHORT', { deterministic: false }, () => snowflake.generate());
|
|
953
|
+
this[_daoDB].function('UUID', { deterministic: false }, () => snowflake.generate());
|
|
954
|
+
this[_daoDB].function('TIME_TO_SEC', { deterministic: true }, (time) => time.split(':').map((v, i) => parseInt(v) * (i === 0 ? 360 : i === 1 ? 60 : 0)).reduce((a, b) => a + b, 0));
|
|
954
955
|
this[_daoDB].function('IF', { deterministic: true }, (condition, v1, v2) => condition ? v1 : v2);
|
|
955
956
|
this[_daoDB].function('RIGHT', { deterministic: true }, (src, p) => src.slice(p * -1));
|
|
957
|
+
this[_daoDB].function('LEFT', { deterministic: true }, (str, len) => str?.substring(0, len) || null);
|
|
958
|
+
this[_daoDB].function('NOW', { deterministic: false }, () => new Date().toISOString().slice(0, 19).replace('T', ' '));
|
|
959
|
+
this[_daoDB].function('CURDATE', { deterministic: false }, () => new Date().toISOString().split('T')[0]);
|
|
960
|
+
this[_daoDB].function('DATE_FORMAT', { deterministic: true }, (dateStr, format) => {
|
|
961
|
+
const date = new Date(dateStr);
|
|
962
|
+
return format
|
|
963
|
+
.replace('%Y', date.getFullYear().toString())
|
|
964
|
+
.replace('%m', (date.getMonth() + 1).toString().padStart(2, '0'))
|
|
965
|
+
.replace('%d', date.getDate().toString().padStart(2, '0'))
|
|
966
|
+
.replace('%H', date.getHours().toString().padStart(2, '0'))
|
|
967
|
+
.replace('%i', date.getMinutes().toString().padStart(2, '0'))
|
|
968
|
+
.replace('%s', date.getSeconds().toString().padStart(2, '0'));
|
|
969
|
+
});
|
|
970
|
+
this[_daoDB].function('RAND', { deterministic: false }, () => Math.random());
|
|
971
|
+
this[_daoDB].function('UNIX_TIMESTAMP', { deterministic: false }, (dateStr) => dateStr
|
|
972
|
+
? Math.floor(new Date(dateStr).getTime() / 1000)
|
|
973
|
+
: Math.floor(Date.now() / 1000));
|
|
956
974
|
}
|
|
957
975
|
createConnection(sync) {
|
|
958
976
|
if (sync === SyncMode.Async) {
|
package/sqlite.js
CHANGED
|
@@ -132,10 +132,28 @@ export class SqliteRemoteClass {
|
|
|
132
132
|
PRIMARY KEY ( ______tableName )
|
|
133
133
|
);
|
|
134
134
|
`);
|
|
135
|
-
this.dbList[dbName].function('UUID_SHORT', { deterministic:
|
|
136
|
-
this.dbList[dbName].function('
|
|
135
|
+
this.dbList[dbName].function('UUID_SHORT', { deterministic: false }, () => snowflake.generate());
|
|
136
|
+
this.dbList[dbName].function('UUID', { deterministic: false }, () => snowflake.generate());
|
|
137
|
+
this.dbList[dbName].function('TIME_TO_SEC', { deterministic: true }, (time) => time.split(':').map((v, i) => parseInt(v) * (i === 0 ? 360 : i === 1 ? 60 : 0)).reduce((a, b) => a + b, 0));
|
|
137
138
|
this.dbList[dbName].function('IF', { deterministic: true }, (condition, v1, v2) => condition ? v1 : v2);
|
|
138
139
|
this.dbList[dbName].function('RIGHT', { deterministic: true }, (src, p) => src.slice(p * -1));
|
|
140
|
+
this.dbList[dbName].function('LEFT', { deterministic: true }, (str, len) => str?.substring(0, len) || null);
|
|
141
|
+
this.dbList[dbName].function('NOW', { deterministic: false }, () => new Date().toISOString().slice(0, 19).replace('T', ' '));
|
|
142
|
+
this.dbList[dbName].function('CURDATE', { deterministic: false }, () => new Date().toISOString().split('T')[0]);
|
|
143
|
+
this.dbList[dbName].function('DATE_FORMAT', { deterministic: true }, (dateStr, format) => {
|
|
144
|
+
const date = new Date(dateStr);
|
|
145
|
+
return format
|
|
146
|
+
.replace('%Y', date.getFullYear().toString())
|
|
147
|
+
.replace('%m', (date.getMonth() + 1).toString().padStart(2, '0'))
|
|
148
|
+
.replace('%d', date.getDate().toString().padStart(2, '0'))
|
|
149
|
+
.replace('%H', date.getHours().toString().padStart(2, '0'))
|
|
150
|
+
.replace('%i', date.getMinutes().toString().padStart(2, '0'))
|
|
151
|
+
.replace('%s', date.getSeconds().toString().padStart(2, '0'));
|
|
152
|
+
});
|
|
153
|
+
this.dbList[dbName].function('RAND', { deterministic: false }, () => Math.random());
|
|
154
|
+
this.dbList[dbName].function('UNIX_TIMESTAMP', { deterministic: false }, (dateStr) => dateStr
|
|
155
|
+
? Math.floor(new Date(dateStr).getTime() / 1000)
|
|
156
|
+
: Math.floor(Date.now() / 1000));
|
|
139
157
|
}
|
|
140
158
|
}
|
|
141
159
|
async export(dbName, exportPath) {
|