befly 3.8.29 → 3.8.31

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 (70) hide show
  1. package/README.md +91 -6
  2. package/checks/checkApi.ts +2 -1
  3. package/checks/checkApp.ts +31 -1
  4. package/checks/checkTable.ts +3 -2
  5. package/hooks/cors.ts +3 -3
  6. package/hooks/parser.ts +8 -6
  7. package/hooks/permission.ts +12 -5
  8. package/hooks/validator.ts +1 -1
  9. package/lib/cacheHelper.ts +73 -65
  10. package/lib/cipher.ts +2 -1
  11. package/lib/connect.ts +23 -52
  12. package/lib/dbHelper.ts +14 -11
  13. package/lib/jwt.ts +58 -437
  14. package/lib/logger.ts +76 -197
  15. package/lib/redisHelper.ts +163 -1
  16. package/lib/sqlBuilder.ts +2 -1
  17. package/lib/validator.ts +150 -384
  18. package/loader/loadApis.ts +4 -7
  19. package/loader/loadHooks.ts +6 -5
  20. package/loader/loadPlugins.ts +11 -13
  21. package/main.ts +26 -53
  22. package/package.json +10 -8
  23. package/paths.ts +0 -6
  24. package/plugins/cipher.ts +1 -1
  25. package/plugins/config.ts +3 -4
  26. package/plugins/db.ts +6 -7
  27. package/plugins/jwt.ts +7 -6
  28. package/plugins/logger.ts +6 -6
  29. package/plugins/redis.ts +9 -13
  30. package/router/api.ts +2 -2
  31. package/router/static.ts +4 -8
  32. package/sync/syncAll.ts +8 -13
  33. package/sync/syncApi.ts +14 -10
  34. package/sync/syncDb/apply.ts +1 -2
  35. package/sync/syncDb.ts +12 -15
  36. package/sync/syncDev.ts +19 -56
  37. package/sync/syncMenu.ts +182 -137
  38. package/tests/cacheHelper.test.ts +327 -0
  39. package/tests/dbHelper-columns.test.ts +5 -20
  40. package/tests/dbHelper-execute.test.ts +14 -68
  41. package/tests/fields-redis-cache.test.ts +5 -3
  42. package/tests/integration.test.ts +17 -32
  43. package/tests/jwt.test.ts +36 -94
  44. package/tests/logger.test.ts +32 -34
  45. package/tests/redisHelper.test.ts +271 -2
  46. package/tests/redisKeys.test.ts +76 -0
  47. package/tests/sync-connection.test.ts +0 -6
  48. package/tests/syncDb-constants.test.ts +12 -12
  49. package/tests/util.test.ts +5 -1
  50. package/tests/validator.test.ts +611 -85
  51. package/types/befly.d.ts +9 -15
  52. package/types/cache.d.ts +73 -0
  53. package/types/common.d.ts +10 -128
  54. package/types/database.d.ts +221 -5
  55. package/types/index.ts +6 -5
  56. package/types/plugin.d.ts +1 -4
  57. package/types/redis.d.ts +37 -2
  58. package/types/table.d.ts +175 -0
  59. package/config.ts +0 -70
  60. package/hooks/_rateLimit.ts +0 -64
  61. package/lib/regexAliases.ts +0 -59
  62. package/lib/xml.ts +0 -383
  63. package/tests/validator-advanced.test.ts +0 -653
  64. package/tests/xml.test.ts +0 -101
  65. package/types/addon.d.ts +0 -50
  66. package/types/crypto.d.ts +0 -23
  67. package/types/jwt.d.ts +0 -99
  68. package/types/logger.d.ts +0 -43
  69. package/types/tool.d.ts +0 -67
  70. package/types/validator.d.ts +0 -43
@@ -108,25 +108,25 @@ describe('MYSQL_TABLE_CONFIG', () => {
108
108
  });
109
109
  });
110
110
 
111
- describe('typeMapping (MySQL)', () => {
111
+ describe('getTypeMapping (MySQL)', () => {
112
112
  test('number 映射为 BIGINT', () => {
113
- expect(constants.typeMapping.number).toBe('BIGINT');
113
+ expect(constants.getTypeMapping().number).toBe('BIGINT');
114
114
  });
115
115
 
116
116
  test('string 映射为 VARCHAR', () => {
117
- expect(constants.typeMapping.string).toBe('VARCHAR');
117
+ expect(constants.getTypeMapping().string).toBe('VARCHAR');
118
118
  });
119
119
 
120
120
  test('text 映射为 MEDIUMTEXT', () => {
121
- expect(constants.typeMapping.text).toBe('MEDIUMTEXT');
121
+ expect(constants.getTypeMapping().text).toBe('MEDIUMTEXT');
122
122
  });
123
123
 
124
124
  test('array_string 映射为 VARCHAR', () => {
125
- expect(constants.typeMapping.array_string).toBe('VARCHAR');
125
+ expect(constants.getTypeMapping().array_string).toBe('VARCHAR');
126
126
  });
127
127
 
128
128
  test('array_text 映射为 MEDIUMTEXT', () => {
129
- expect(constants.typeMapping.array_text).toBe('MEDIUMTEXT');
129
+ expect(constants.getTypeMapping().array_text).toBe('MEDIUMTEXT');
130
130
  });
131
131
  });
132
132
 
@@ -137,15 +137,15 @@ describe('IS_PLAN', () => {
137
137
  });
138
138
 
139
139
  describe('数据库类型判断 (MySQL)', () => {
140
- test('IS_MYSQL 为 true', () => {
141
- expect(constants.IS_MYSQL).toBe(true);
140
+ test('isMySQL 为 true', () => {
141
+ expect(constants.isMySQL()).toBe(true);
142
142
  });
143
143
 
144
- test('IS_PG 为 false', () => {
145
- expect(constants.IS_PG).toBe(false);
144
+ test('isPG 为 false', () => {
145
+ expect(constants.isPG()).toBe(false);
146
146
  });
147
147
 
148
- test('IS_SQLITE 为 false', () => {
149
- expect(constants.IS_SQLITE).toBe(false);
148
+ test('isSQLite 为 false', () => {
149
+ expect(constants.isSQLite()).toBe(false);
150
150
  });
151
151
  });
@@ -1,5 +1,9 @@
1
1
  import { describe, test, expect } from 'bun:test';
2
- import { keysToCamel, keysToSnake, arrayKeysToCamel, calcPerfTime, fieldClear } from 'befly-util';
2
+ import { keysToCamel } from 'befly-shared/keysToCamel';
3
+ import { keysToSnake } from 'befly-shared/keysToSnake';
4
+ import { arrayKeysToCamel } from 'befly-shared/arrayKeysToCamel';
5
+ import { calcPerfTime } from 'befly-shared/calcPerfTime';
6
+ import { fieldClear } from 'befly-shared/fieldClear';
3
7
 
4
8
  describe('Util - keysToCamel', () => {
5
9
  test('转换对象键名为驼峰', () => {