@taicode/common-server 4.0.0-beta.3 → 4.0.0-beta.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 (271) hide show
  1. package/output/app/index.d.ts +13 -15
  2. package/output/app/index.d.ts.map +1 -1
  3. package/output/app/index.js +256 -18
  4. package/output/auth/index.d.ts +72 -0
  5. package/output/auth/index.d.ts.map +1 -0
  6. package/output/auth/index.js +176 -0
  7. package/output/core/assemble.d.ts +64 -0
  8. package/output/core/assemble.d.ts.map +1 -0
  9. package/output/core/assemble.js +88 -0
  10. package/output/core/boot/context.d.ts +89 -0
  11. package/output/core/boot/context.d.ts.map +1 -0
  12. package/output/{app → core/boot}/context.js +44 -17
  13. package/output/{app → core/boot}/lifecycle.d.ts +13 -15
  14. package/output/core/boot/lifecycle.d.ts.map +1 -0
  15. package/output/{app → core/boot}/lifecycle.js +15 -12
  16. package/output/{app → core/boot}/shutdown.d.ts +9 -6
  17. package/output/core/boot/shutdown.d.ts.map +1 -0
  18. package/output/{app → core/boot}/shutdown.js +7 -4
  19. package/output/core/boot/signal.d.ts +13 -0
  20. package/output/core/boot/signal.d.ts.map +1 -0
  21. package/output/{app → core/boot}/signal.js +3 -2
  22. package/output/core/boot/steps.d.ts +107 -0
  23. package/output/core/boot/steps.d.ts.map +1 -0
  24. package/output/core/boot/steps.js +200 -0
  25. package/output/core/entries.d.ts +123 -0
  26. package/output/core/entries.d.ts.map +1 -0
  27. package/output/core/entries.js +193 -0
  28. package/output/core/entries.test.d.ts +2 -0
  29. package/output/core/entries.test.d.ts.map +1 -0
  30. package/output/core/entries.test.js +217 -0
  31. package/output/core/env.d.ts +62 -0
  32. package/output/core/env.d.ts.map +1 -0
  33. package/output/core/env.js +96 -0
  34. package/output/{app → core}/env.test.d.ts.map +1 -1
  35. package/output/core/env.test.js +105 -0
  36. package/output/core/modules/auth-provider/index.d.ts +10 -0
  37. package/output/core/modules/auth-provider/index.d.ts.map +1 -0
  38. package/output/core/modules/auth-provider/index.js +9 -0
  39. package/output/core/modules/auth-provider/types.d.ts +71 -0
  40. package/output/core/modules/auth-provider/types.d.ts.map +1 -0
  41. package/output/core/modules/context/index.d.ts +18 -0
  42. package/output/core/modules/context/index.d.ts.map +1 -0
  43. package/output/core/modules/context/index.js +23 -0
  44. package/output/core/modules/context/index.test.d.ts.map +1 -0
  45. package/output/core/modules/cookie/index.d.ts +21 -0
  46. package/output/core/modules/cookie/index.d.ts.map +1 -0
  47. package/output/{app/core/cookie.js → core/modules/cookie/index.js} +1 -6
  48. package/output/core/modules/identity/index.d.ts +4 -0
  49. package/output/core/modules/identity/index.d.ts.map +1 -0
  50. package/output/{app/core/identity.js → core/modules/identity/index.js} +1 -1
  51. package/output/core/modules/logging/index.d.ts +5 -0
  52. package/output/core/modules/logging/index.d.ts.map +1 -0
  53. package/output/{app/core/logging.js → core/modules/logging/index.js} +2 -2
  54. package/output/core/modules/openapi/index.d.ts +7 -0
  55. package/output/core/modules/openapi/index.d.ts.map +1 -0
  56. package/output/{app/core/openapi.js → core/modules/openapi/index.js} +11 -12
  57. package/output/core/modules/permission-operations/index.d.ts +26 -0
  58. package/output/core/modules/permission-operations/index.d.ts.map +1 -0
  59. package/output/core/modules/permission-operations/index.js +36 -0
  60. package/output/core/modules/permission-operations/index.test.d.ts +2 -0
  61. package/output/core/modules/permission-operations/index.test.d.ts.map +1 -0
  62. package/output/core/modules/permission-operations/index.test.js +45 -0
  63. package/output/{app/core/request-id.d.ts → core/modules/request-id/index.d.ts} +1 -4
  64. package/output/core/modules/request-id/index.d.ts.map +1 -0
  65. package/output/{app/core/request-id.js → core/modules/request-id/index.js} +2 -2
  66. package/output/core/modules/response/index.d.ts +22 -0
  67. package/output/core/modules/response/index.d.ts.map +1 -0
  68. package/output/{app/core/response.js → core/modules/response/index.js} +22 -11
  69. package/output/{schema/index.d.ts → core/modules/schema/builders.d.ts} +8 -1
  70. package/output/core/modules/schema/builders.d.ts.map +1 -0
  71. package/output/{schema/index.js → core/modules/schema/builders.js} +7 -4
  72. package/output/core/modules/schema/index.d.ts +34 -0
  73. package/output/core/modules/schema/index.d.ts.map +1 -0
  74. package/output/core/modules/schema/index.js +62 -0
  75. package/output/core/modules/schema/index.test.d.ts +2 -0
  76. package/output/core/modules/schema/index.test.d.ts.map +1 -0
  77. package/output/core/modules/schema/index.test.js +55 -0
  78. package/output/core/modules/system-routes/index.d.ts +15 -0
  79. package/output/core/modules/system-routes/index.d.ts.map +1 -0
  80. package/output/core/modules/system-routes/index.js +171 -0
  81. package/output/core/test-support/database.d.ts +96 -0
  82. package/output/core/test-support/database.d.ts.map +1 -0
  83. package/output/core/test-support/database.js +144 -0
  84. package/output/core/test-support/database.test.d.ts +2 -0
  85. package/output/core/test-support/database.test.d.ts.map +1 -0
  86. package/output/core/test-support/database.test.js +110 -0
  87. package/output/core/test-support/environment.d.ts +33 -0
  88. package/output/core/test-support/environment.d.ts.map +1 -0
  89. package/output/core/test-support/environment.js +42 -0
  90. package/output/core/test-support/test-server.d.ts +94 -0
  91. package/output/core/test-support/test-server.d.ts.map +1 -0
  92. package/output/core/test-support/test-server.js +60 -0
  93. package/output/core/test-support/test-server.test.d.ts +2 -0
  94. package/output/core/test-support/test-server.test.d.ts.map +1 -0
  95. package/output/core/test-support/test-server.test.js +162 -0
  96. package/output/{app → core}/type-augment.d.ts +2 -2
  97. package/output/core/type-augment.d.ts.map +1 -0
  98. package/output/{app → core}/types.d.ts +153 -66
  99. package/output/core/types.d.ts.map +1 -0
  100. package/output/cors/index.d.ts +3 -0
  101. package/output/cors/index.d.ts.map +1 -0
  102. package/output/cors/index.js +27 -0
  103. package/output/index.d.ts +8 -4
  104. package/output/index.d.ts.map +1 -1
  105. package/output/index.js +24 -5
  106. package/output/rate-limit/index.d.ts +23 -0
  107. package/output/rate-limit/index.d.ts.map +1 -0
  108. package/output/rate-limit/index.js +42 -0
  109. package/output/{rate-limiter/rate-limiter.d.ts → rate-limit/limiter.d.ts} +1 -1
  110. package/output/rate-limit/limiter.d.ts.map +1 -0
  111. package/output/rate-limit/memory-store.d.ts.map +1 -0
  112. package/output/rate-limit/redis-store.d.ts.map +1 -0
  113. package/output/rate-limit/redis-store.test.d.ts.map +1 -0
  114. package/output/{rate-limiter → rate-limit}/redis-store.test.js +2 -2
  115. package/output/{rate-limiter → rate-limit}/types.d.ts +0 -1
  116. package/output/rate-limit/types.d.ts.map +1 -0
  117. package/output/rate-limit/types.js +1 -0
  118. package/output/{redis-cache/redis-cache.d.ts → redis/cache.d.ts} +1 -1
  119. package/output/redis/cache.d.ts.map +1 -0
  120. package/output/redis/cache.test.d.ts +2 -0
  121. package/output/redis/cache.test.d.ts.map +1 -0
  122. package/output/{redis-cache/redis-cache.test.js → redis/cache.test.js} +1 -1
  123. package/output/{app/redis.d.ts → redis/index.d.ts} +7 -6
  124. package/output/redis/index.d.ts.map +1 -0
  125. package/output/{app/redis.js → redis/index.js} +10 -4
  126. package/output/redis/index.test.d.ts +2 -0
  127. package/output/{context → redis}/index.test.d.ts.map +1 -1
  128. package/output/redis/index.test.js +55 -0
  129. package/output/redis-queue/index.js +1 -1
  130. package/output/redis-queue/test-helpers.d.ts +1 -1
  131. package/output/redis-queue/test-helpers.js +1 -1
  132. package/output/redis-queue/types.d.ts +3 -12
  133. package/output/redis-queue/types.d.ts.map +1 -1
  134. package/package.json +16 -15
  135. package/LICENSE +0 -21
  136. package/output/app/auth.test.d.ts +0 -2
  137. package/output/app/auth.test.d.ts.map +0 -1
  138. package/output/app/auth.test.js +0 -148
  139. package/output/app/boot.d.ts +0 -44
  140. package/output/app/boot.d.ts.map +0 -1
  141. package/output/app/boot.js +0 -158
  142. package/output/app/config.test.d.ts +0 -2
  143. package/output/app/config.test.d.ts.map +0 -1
  144. package/output/app/config.test.js +0 -132
  145. package/output/app/context.d.ts +0 -74
  146. package/output/app/context.d.ts.map +0 -1
  147. package/output/app/core/cookie.d.ts +0 -25
  148. package/output/app/core/cookie.d.ts.map +0 -1
  149. package/output/app/core/identity.d.ts +0 -12
  150. package/output/app/core/identity.d.ts.map +0 -1
  151. package/output/app/core/index.d.ts +0 -44
  152. package/output/app/core/index.d.ts.map +0 -1
  153. package/output/app/core/index.js +0 -57
  154. package/output/app/core/logging.d.ts +0 -13
  155. package/output/app/core/logging.d.ts.map +0 -1
  156. package/output/app/core/openapi.d.ts +0 -17
  157. package/output/app/core/openapi.d.ts.map +0 -1
  158. package/output/app/core/request-id.d.ts.map +0 -1
  159. package/output/app/core/response.d.ts +0 -41
  160. package/output/app/core/response.d.ts.map +0 -1
  161. package/output/app/define-server.negative-cases.d.ts +0 -40
  162. package/output/app/define-server.negative-cases.d.ts.map +0 -1
  163. package/output/app/define-server.negative-cases.js +0 -268
  164. package/output/app/define-server.test.d.ts +0 -2
  165. package/output/app/define-server.test.d.ts.map +0 -1
  166. package/output/app/define-server.test.js +0 -97
  167. package/output/app/entries.d.ts +0 -31
  168. package/output/app/entries.d.ts.map +0 -1
  169. package/output/app/entries.js +0 -66
  170. package/output/app/env.d.ts +0 -59
  171. package/output/app/env.d.ts.map +0 -1
  172. package/output/app/env.js +0 -66
  173. package/output/app/env.test.js +0 -124
  174. package/output/app/error-contract.test.d.ts +0 -2
  175. package/output/app/error-contract.test.d.ts.map +0 -1
  176. package/output/app/error-contract.test.js +0 -227
  177. package/output/app/errors.d.ts +0 -20
  178. package/output/app/errors.d.ts.map +0 -1
  179. package/output/app/errors.js +0 -51
  180. package/output/app/generate-openapi.test.d.ts +0 -2
  181. package/output/app/generate-openapi.test.d.ts.map +0 -1
  182. package/output/app/generate-openapi.test.js +0 -123
  183. package/output/app/lifecycle-logging.test.d.ts +0 -2
  184. package/output/app/lifecycle-logging.test.d.ts.map +0 -1
  185. package/output/app/lifecycle-logging.test.js +0 -175
  186. package/output/app/lifecycle.d.ts.map +0 -1
  187. package/output/app/lifecycle.test.d.ts +0 -2
  188. package/output/app/lifecycle.test.d.ts.map +0 -1
  189. package/output/app/lifecycle.test.js +0 -153
  190. package/output/app/middleware/auth.d.ts +0 -71
  191. package/output/app/middleware/auth.d.ts.map +0 -1
  192. package/output/app/middleware/auth.js +0 -190
  193. package/output/app/middleware/context.d.ts +0 -13
  194. package/output/app/middleware/context.d.ts.map +0 -1
  195. package/output/app/middleware/context.js +0 -15
  196. package/output/app/middleware/cors.d.ts +0 -14
  197. package/output/app/middleware/cors.d.ts.map +0 -1
  198. package/output/app/middleware/cors.js +0 -30
  199. package/output/app/middleware/index.d.ts +0 -17
  200. package/output/app/middleware/index.d.ts.map +0 -1
  201. package/output/app/middleware/index.js +0 -16
  202. package/output/app/middleware/rate-limit.d.ts +0 -24
  203. package/output/app/middleware/rate-limit.d.ts.map +0 -1
  204. package/output/app/middleware/rate-limit.js +0 -46
  205. package/output/app/middleware-order.test.d.ts +0 -2
  206. package/output/app/middleware-order.test.d.ts.map +0 -1
  207. package/output/app/middleware-order.test.js +0 -149
  208. package/output/app/permission-operations.d.ts +0 -48
  209. package/output/app/permission-operations.d.ts.map +0 -1
  210. package/output/app/permission-operations.js +0 -77
  211. package/output/app/permission-operations.test.d.ts +0 -2
  212. package/output/app/permission-operations.test.d.ts.map +0 -1
  213. package/output/app/permission-operations.test.js +0 -72
  214. package/output/app/permission-registration.test.d.ts +0 -2
  215. package/output/app/permission-registration.test.d.ts.map +0 -1
  216. package/output/app/permission-registration.test.js +0 -138
  217. package/output/app/redis.d.ts.map +0 -1
  218. package/output/app/registered-operations.test.d.ts +0 -2
  219. package/output/app/registered-operations.test.d.ts.map +0 -1
  220. package/output/app/registered-operations.test.js +0 -57
  221. package/output/app/request-id.test.d.ts +0 -2
  222. package/output/app/request-id.test.d.ts.map +0 -1
  223. package/output/app/request-id.test.js +0 -130
  224. package/output/app/resources.test.d.ts +0 -2
  225. package/output/app/resources.test.d.ts.map +0 -1
  226. package/output/app/resources.test.js +0 -222
  227. package/output/app/shutdown.d.ts.map +0 -1
  228. package/output/app/shutdown.test.d.ts +0 -2
  229. package/output/app/shutdown.test.d.ts.map +0 -1
  230. package/output/app/shutdown.test.js +0 -210
  231. package/output/app/signal.d.ts +0 -12
  232. package/output/app/signal.d.ts.map +0 -1
  233. package/output/app/smoke.test.d.ts +0 -2
  234. package/output/app/smoke.test.d.ts.map +0 -1
  235. package/output/app/smoke.test.js +0 -210
  236. package/output/app/test-support.d.ts +0 -21
  237. package/output/app/test-support.d.ts.map +0 -1
  238. package/output/app/test-support.js +0 -24
  239. package/output/app/type-augment.d.ts.map +0 -1
  240. package/output/app/types.d.ts.map +0 -1
  241. package/output/context/index.d.ts +0 -6
  242. package/output/context/index.d.ts.map +0 -1
  243. package/output/context/index.js +0 -14
  244. package/output/rate-limiter/index.d.ts +0 -5
  245. package/output/rate-limiter/index.d.ts.map +0 -1
  246. package/output/rate-limiter/index.js +0 -4
  247. package/output/rate-limiter/memory-store.d.ts.map +0 -1
  248. package/output/rate-limiter/rate-limiter.d.ts.map +0 -1
  249. package/output/rate-limiter/redis-store.d.ts.map +0 -1
  250. package/output/rate-limiter/redis-store.test.d.ts.map +0 -1
  251. package/output/rate-limiter/types.d.ts.map +0 -1
  252. package/output/redis-cache/index.d.ts +0 -4
  253. package/output/redis-cache/index.d.ts.map +0 -1
  254. package/output/redis-cache/index.js +0 -1
  255. package/output/redis-cache/redis-cache.d.ts.map +0 -1
  256. package/output/redis-cache/redis-cache.test.d.ts +0 -2
  257. package/output/redis-cache/redis-cache.test.d.ts.map +0 -1
  258. package/output/schema/index.d.ts.map +0 -1
  259. /package/output/{app → core}/env.test.d.ts +0 -0
  260. /package/output/{rate-limiter → core/modules/auth-provider}/types.js +0 -0
  261. /package/output/{context → core/modules/context}/index.test.d.ts +0 -0
  262. /package/output/{context → core/modules/context}/index.test.js +0 -0
  263. /package/output/{app → core}/type-augment.js +0 -0
  264. /package/output/{app → core}/types.js +0 -0
  265. /package/output/{rate-limiter/rate-limiter.js → rate-limit/limiter.js} +0 -0
  266. /package/output/{rate-limiter → rate-limit}/memory-store.d.ts +0 -0
  267. /package/output/{rate-limiter → rate-limit}/memory-store.js +0 -0
  268. /package/output/{rate-limiter → rate-limit}/redis-store.d.ts +0 -0
  269. /package/output/{rate-limiter → rate-limit}/redis-store.js +0 -0
  270. /package/output/{rate-limiter → rate-limit}/redis-store.test.d.ts +0 -0
  271. /package/output/{redis-cache/redis-cache.js → redis/cache.js} +0 -0
@@ -1,210 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { defineServer, startServer } from './entries.js';
3
- import { runShutdown, SHUTDOWN_ORDER } from './shutdown.js';
4
- function createShutdownLog() {
5
- const entries = [];
6
- return { entries, log: { error: (obj, msg) => void entries.push({ obj, msg }) } };
7
- }
8
- function createRecordingHandles(record, throwOn) {
9
- const step = (name) => () => {
10
- record.push(name);
11
- if (name === throwOn) {
12
- throw new Error(`boom:${name}`);
13
- }
14
- };
15
- return {
16
- flushRouters: step('flushRouters'),
17
- flushMiddlewares: step('flushMiddlewares'),
18
- flushServices: step('flushServices'),
19
- disposeServices: step('disposeServices'),
20
- flushConfig: step('flushConfig'),
21
- flushResources: step('flushResources'),
22
- };
23
- }
24
- describe('SHUTDOWN_ORDER', () => {
25
- it('固定六步且顺序不可变:阶段逆序 flush,services 内部先 flush 再逐单元 dispose', () => {
26
- expect(SHUTDOWN_ORDER).toEqual([
27
- 'flushRouters',
28
- 'flushMiddlewares',
29
- 'flushServices',
30
- 'disposeServices',
31
- 'flushConfig',
32
- 'flushResources',
33
- ]);
34
- });
35
- });
36
- describe('runShutdown', () => {
37
- it('按固定序执行全部步骤', async () => {
38
- const record = [];
39
- const { log } = createShutdownLog();
40
- await runShutdown(createRecordingHandles(record), log);
41
- expect(record).toEqual([...SHUTDOWN_ORDER]);
42
- });
43
- it('单步抛错不阻断后续,并聚合上报', async () => {
44
- const record = [];
45
- const { entries, log } = createShutdownLog();
46
- await runShutdown(createRecordingHandles(record, 'flushRouters'), log);
47
- expect(record).toEqual([...SHUTDOWN_ORDER]);
48
- const aggregate = entries.find((entry) => entry.msg === '[shutdown] completed with errors');
49
- expect(aggregate).toBeDefined();
50
- const payload = aggregate?.obj;
51
- expect(payload.count).toBe(1);
52
- expect(payload.errors).toHaveLength(1);
53
- });
54
- });
55
- describe('关闭流程集成', () => {
56
- it('各阶段 disposer 按阶段逆序执行:routers → middlewares → services → config → resources', async () => {
57
- const calls = [];
58
- const server = defineServer({
59
- app: { service: 'shutdown-stages', title: 'Shutdown Stages', version: '1.0.0' },
60
- resources: (ctx) => {
61
- ctx.disposer.add(() => {
62
- calls.push('flushResources');
63
- });
64
- return {};
65
- },
66
- config: (ctx) => {
67
- ctx.disposer.add(() => {
68
- calls.push('flushConfig');
69
- });
70
- return {};
71
- },
72
- services: (ctx) => {
73
- ctx.disposer.add(() => {
74
- calls.push('flushServices');
75
- });
76
- return {
77
- a: {
78
- dispose: () => {
79
- calls.push('disposeServiceA');
80
- },
81
- },
82
- };
83
- },
84
- middlewares: (ctx) => {
85
- ctx.disposer.add(() => {
86
- calls.push('flushMiddlewares');
87
- });
88
- return [];
89
- },
90
- routers: (ctx) => {
91
- ctx.disposer.add(() => {
92
- calls.push('flushRouters');
93
- });
94
- },
95
- });
96
- const app = await startServer(server, { listen: false });
97
- await app.close();
98
- expect(calls).toEqual([
99
- 'flushRouters',
100
- 'flushMiddlewares',
101
- 'flushServices',
102
- 'disposeServiceA',
103
- 'flushConfig',
104
- 'flushResources',
105
- ]);
106
- });
107
- it('阶段内多个 disposer 按**逆注册序**(LIFO)执行', async () => {
108
- const calls = [];
109
- const server = defineServer({
110
- app: { service: 'shutdown-lifo', title: 'Shutdown LIFO', version: '1.0.0' },
111
- resources: (ctx) => {
112
- // 先建 A,再建 B(B 可能依赖 A)→ 关闭时先 B 后 A
113
- ctx.disposer.add(() => {
114
- calls.push('disposeA');
115
- });
116
- ctx.disposer.add(() => {
117
- calls.push('disposeB');
118
- });
119
- return {};
120
- },
121
- config: () => ({}),
122
- services: () => ({}),
123
- middlewares: () => [],
124
- routers: () => undefined,
125
- });
126
- const app = await startServer(server, { listen: false });
127
- await app.close();
128
- expect(calls).toEqual(['disposeB', 'disposeA']);
129
- });
130
- it('某个 disposer 抛错不影响同阶段其它 disposer(且 `close()` 不抛)', async () => {
131
- const calls = [];
132
- const server = defineServer({
133
- app: { service: 'shutdown-disposer-error', title: 'Shutdown Disposer Error', version: '1.0.0' },
134
- resources: (ctx) => {
135
- ctx.disposer.add(() => {
136
- calls.push('disposeA');
137
- });
138
- ctx.disposer.add(() => {
139
- calls.push('disposeB:throw');
140
- throw new Error('disposer boom');
141
- });
142
- ctx.disposer.add(() => {
143
- calls.push('disposeC');
144
- });
145
- return {};
146
- },
147
- config: () => ({}),
148
- services: () => ({}),
149
- middlewares: () => [],
150
- routers: () => undefined,
151
- });
152
- const app = await startServer(server, { listen: false });
153
- await expect(app.close()).resolves.toBeUndefined();
154
- // LIFO:C → B(抛错)→ A;B 的错误不阻断 A
155
- expect(calls).toEqual(['disposeC', 'disposeB:throw', 'disposeA']);
156
- });
157
- it('未注册任何 disposer 时无操作:关闭照常完成', async () => {
158
- const calls = [];
159
- const server = defineServer({
160
- app: { service: 'shutdown-empty', title: 'Shutdown Empty', version: '1.0.0' },
161
- resources: () => ({}),
162
- config: () => ({}),
163
- services: () => ({
164
- a: {
165
- dispose: () => {
166
- calls.push('disposeServiceA');
167
- },
168
- },
169
- }),
170
- middlewares: () => [],
171
- routers: () => undefined,
172
- });
173
- const app = await startServer(server, { listen: false });
174
- await expect(app.close()).resolves.toBeUndefined();
175
- expect(calls).toEqual(['disposeServiceA']);
176
- });
177
- it('StartServerOptions.shutdown 整体覆盖默认关闭流程', async () => {
178
- const calls = [];
179
- const server = defineServer({
180
- app: { service: 'shutdown-override', title: 'Shutdown Override', version: '1.0.0' },
181
- resources: (ctx) => {
182
- ctx.disposer.add(() => {
183
- calls.push('flushResources');
184
- });
185
- return {};
186
- },
187
- config: () => ({}),
188
- services: () => ({
189
- a: {
190
- dispose: () => {
191
- calls.push('default-dispose');
192
- },
193
- },
194
- }),
195
- middlewares: () => [],
196
- routers: () => undefined,
197
- });
198
- const app = await startServer(server, {
199
- listen: false,
200
- shutdown: async (ctx) => {
201
- expect(ctx.app).toBeDefined();
202
- expect(ctx.services).toBeDefined();
203
- calls.push('custom');
204
- },
205
- });
206
- await app.close();
207
- // 整体覆盖:默认六步(含各阶段 flush)都不执行
208
- expect(calls).toEqual(['custom']);
209
- });
210
- });
@@ -1,12 +0,0 @@
1
- import type { LoggerLike } from './types.js';
2
- import type { FastifyInstance } from 'fastify';
3
- /**
4
- * 内置信号处理(设计 §7.1 `activate` 尾部 / §7.2)。
5
- *
6
- * `SIGTERM` / `SIGINT` / `uncaughtException` / `unhandledRejection` ⇒ `app.close()`(触发 `onClose`
7
- * 的关闭 6 步)⇒ `process.exit(0/1)`。**仅 `listen: true` 时装信号处理**。
8
- *
9
- * @returns detach 函数(移除本次注册的监听器)
10
- */
11
- export declare function attachSignalHandlers(app: FastifyInstance, log: LoggerLike): () => void;
12
- //# sourceMappingURL=signal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../source/app/signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,IAAI,CA2CtF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=smoke.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smoke.test.d.ts","sourceRoot":"","sources":["../../source/app/smoke.test.ts"],"names":[],"mappings":""}
@@ -1,210 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { z } from 'zod';
3
- import { defineServer, generateOpenApi, startServer } from './entries.js';
4
- import { SystemError, UserError } from './errors.js';
5
- import { defaultMiddlewares } from './middleware/index.js';
6
- import { createCache, createRedis } from './redis.js';
7
- const summarySchema = {
8
- querystring: z.object({ currency: z.string().optional() }),
9
- response: {
10
- 200: z.object({
11
- status: z.string(),
12
- message: z.string(),
13
- data: z.object({ siteName: z.string(), currency: z.string() }),
14
- }),
15
- },
16
- };
17
- describe('端到端冒烟:defineServer → startServer → inject → generateOpenApi', () => {
18
- it('真实装配路径跑通最小服务器(无 Postgres / 无 Redis / 无网络)', async () => {
19
- const previousDatabaseUrl = process.env.DATABASE_URL;
20
- const previousRedisUrl = process.env.REDIS_URL;
21
- delete process.env.DATABASE_URL;
22
- delete process.env.REDIS_URL;
23
- const lifecycleEvents = [];
24
- const counters = { readConfiguration: 0, disposeDatabase: 0 };
25
- const database = {
26
- readSystemConfiguration: async () => {
27
- counters.readConfiguration += 1;
28
- return { siteName: 'taicode-smoke', currency: 'CNY' };
29
- },
30
- };
31
- try {
32
- const server = defineServer({
33
- app: { service: 'smoke', title: 'Smoke Service', version: '1.4.0' },
34
- resources: (ctx) => {
35
- const redis = createRedis(ctx.env, ctx.log);
36
- return {
37
- // 构造但不建连;出 spec 路径也会构造
38
- database,
39
- redis,
40
- cache: createCache({ env: ctx.env, prefix: 'smoke', redis, log: ctx.log }),
41
- };
42
- },
43
- config: async ({ resources }) => {
44
- const configuration = await resources.database.readSystemConfiguration();
45
- return { siteName: configuration.siteName, currency: configuration.currency };
46
- },
47
- // 声明序即启动序(services 之间不得相互依赖)
48
- services: (ctx) => {
49
- return {
50
- // routers 拿不到 resources / config,只能穿过 service
51
- // 配置一律在**调用期**现读:构造期不得读配置(出 spec 路径不跑 config 槽位)
52
- configuration: {
53
- readSiteName: () => ctx.config.siteName,
54
- readCurrency: () => ctx.config.currency,
55
- },
56
- ledger: {
57
- init: () => {
58
- lifecycleEvents.push('init:ledger');
59
- },
60
- dispose: () => {
61
- lifecycleEvents.push('dispose:ledger');
62
- },
63
- },
64
- repository: {
65
- init: () => {
66
- lifecycleEvents.push('init:repository');
67
- },
68
- dispose: () => {
69
- lifecycleEvents.push('dispose:repository');
70
- },
71
- },
72
- mailer: {
73
- init: () => {
74
- lifecycleEvents.push('init:mailer');
75
- },
76
- dispose: () => {
77
- lifecycleEvents.push('dispose:mailer');
78
- },
79
- },
80
- databaseLifecycle: {
81
- dispose: () => {
82
- counters.disposeDatabase += 1;
83
- },
84
- },
85
- };
86
- },
87
- // 默认预设 [cors, context, auth]
88
- middlewares: (ctx) => defaultMiddlewares(ctx),
89
- routers: (ctx) => {
90
- ctx.app.get('/ledger/summary', { schema: summarySchema }, () => ({
91
- siteName: ctx.services.configuration.readSiteName(),
92
- currency: ctx.services.configuration.readCurrency(),
93
- }));
94
- ctx.app.get('/ledger/invalid-token', () => {
95
- throw new UserError('INVALID_TOKEN', undefined, '令牌无效或已过期');
96
- });
97
- ctx.app.get('/ledger/database-down', () => {
98
- throw new SystemError('DATABASE_UNAVAILABLE', undefined, '数据库暂不可用');
99
- });
100
- },
101
- });
102
- const app = await startServer(server, { listen: false });
103
- // ── 装配期:声明序 init ────────────────────────────────────────────
104
- expect(lifecycleEvents).toEqual(['init:ledger', 'init:repository', 'init:mailer']);
105
- expect(counters.readConfiguration).toBe(1);
106
- try {
107
- // ── 业务路由:成功信封 ────────────────────────────────────────────
108
- const summaryResponse = await app.inject({
109
- method: 'GET',
110
- url: '/ledger/summary?currency=CNY',
111
- headers: { 'x-request-id': 'smoke-summary-1' },
112
- });
113
- expect(summaryResponse.statusCode).toBe(200);
114
- expect(summaryResponse.json()).toEqual({
115
- status: 'SUCCESS',
116
- message: 'ok',
117
- data: { siteName: 'taicode-smoke', currency: 'CNY' },
118
- });
119
- expect(summaryResponse.headers['x-request-id']).toBe('smoke-summary-1');
120
- // ── UserError → 400 ───────────────────────────────────────────────
121
- const userErrorResponse = await app.inject({ method: 'GET', url: '/ledger/invalid-token' });
122
- expect(userErrorResponse.statusCode).toBe(400);
123
- expect(userErrorResponse.json()).toEqual({
124
- status: 'INVALID_TOKEN',
125
- message: '令牌无效或已过期',
126
- data: null,
127
- });
128
- // ── SystemError → 500 ─────────────────────────────────────────────
129
- const systemErrorResponse = await app.inject({ method: 'GET', url: '/ledger/database-down' });
130
- expect(systemErrorResponse.statusCode).toBe(500);
131
- expect(systemErrorResponse.json()).toEqual({
132
- status: 'DATABASE_UNAVAILABLE',
133
- message: '数据库暂不可用',
134
- data: null,
135
- });
136
- // ── 未匹配路由 → 404 ──────────────────────────────────────────────
137
- const notFoundResponse = await app.inject({ method: 'GET', url: '/no-such-route' });
138
- expect(notFoundResponse.statusCode).toBe(404);
139
- expect(notFoundResponse.json()).toMatchObject({ status: 'NOT_IMPLEMENTED', data: null });
140
- expect(notFoundResponse.headers['x-request-id']).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
141
- expect(notFoundResponse.json()).not.toHaveProperty('requestId');
142
- }
143
- finally {
144
- await app.close();
145
- }
146
- // ── 关闭:services 逆序 dispose ─────────────────────────────────────
147
- expect(lifecycleEvents).toEqual([
148
- 'init:ledger',
149
- 'init:repository',
150
- 'init:mailer',
151
- 'dispose:mailer',
152
- 'dispose:repository',
153
- 'dispose:ledger',
154
- ]);
155
- expect(counters.disposeDatabase).toBe(1);
156
- // ── 同一份定义 → generateOpenApi:不跑 config、不重跑 init ──────────
157
- const spec = (await generateOpenApi(server));
158
- expect(counters.readConfiguration).toBe(1);
159
- expect(lifecycleEvents).toHaveLength(6);
160
- expect(spec.openapi).toBe('3.0.3');
161
- expect(spec.info).toMatchObject({ title: 'Smoke Service', version: '1.4.0' });
162
- expect(Object.keys(spec.paths ?? {})).toEqual(expect.arrayContaining(['/ledger/summary', '/ledger/invalid-token', '/ledger/database-down']));
163
- }
164
- finally {
165
- if (previousDatabaseUrl === undefined) {
166
- delete process.env.DATABASE_URL;
167
- }
168
- else {
169
- process.env.DATABASE_URL = previousDatabaseUrl;
170
- }
171
- if (previousRedisUrl === undefined) {
172
- delete process.env.REDIS_URL;
173
- }
174
- else {
175
- process.env.REDIS_URL = previousRedisUrl;
176
- }
177
- }
178
- });
179
- it('非预置原生插件可在 routers(ctx) 里经 ctx.app.register() 注册并生效', async () => {
180
- const smokeDecoratorPlugin = async (app) => {
181
- app.decorate('smokeDecorator', () => 'smoke-decorated');
182
- app.get('/plugin/decorated', () => ({
183
- value: app.smokeDecorator(),
184
- }));
185
- };
186
- const server = defineServer({
187
- app: { service: 'smoke-plugin', title: 'Smoke Plugin', version: '1.0.0' },
188
- resources: () => ({}),
189
- config: () => ({}),
190
- services: () => ({}),
191
- middlewares: () => [],
192
- routers: (ctx) => {
193
- void ctx.app.register(smokeDecoratorPlugin);
194
- },
195
- });
196
- const app = await startServer(server, { listen: false });
197
- try {
198
- const response = await app.inject({ method: 'GET', url: '/plugin/decorated' });
199
- expect(response.statusCode).toBe(200);
200
- expect(response.json()).toEqual({
201
- status: 'SUCCESS',
202
- message: 'ok',
203
- data: { value: 'smoke-decorated' },
204
- });
205
- }
206
- finally {
207
- await app.close();
208
- }
209
- });
210
- });
@@ -1,21 +0,0 @@
1
- import type { ConfigEnv } from './env.js';
2
- import type { LoggerLike } from './types.js';
3
- /**
4
- * 测试公共助手(仅测试使用)。
5
- *
6
- * 只放「多个测试文件都要用」的小工具:记录型 logger、测试用 env。
7
- * 断言与业务语义一律写在各自 `*.test.ts` 内,避免助手文件成为第二真相源。
8
- */
9
- export interface LogEntry {
10
- level: 'debug' | 'info' | 'warn' | 'error';
11
- obj: unknown;
12
- msg?: string;
13
- }
14
- /** 记录型 logger:满足 `LoggerLike`,便于断言「被调用了 / 在什么级别」 */
15
- export interface RecordingLogger extends LoggerLike {
16
- readonly entries: LogEntry[];
17
- }
18
- export declare function createRecordingLogger(): RecordingLogger;
19
- /** 测试用 `ConfigEnv`(固定读取约定:`ENV` / `API_PORT` / `LOG_LEVEL` / `DATABASE_URL` / `REDIS_URL`) */
20
- export declare function createTestConfigEnv(overrides?: Partial<ConfigEnv>): ConfigEnv;
21
- //# sourceMappingURL=test-support.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-support.d.ts","sourceRoot":"","sources":["../../source/app/test-support.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;;GAKG;AAEH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;IAC1C,GAAG,EAAE,OAAO,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,oDAAoD;AACpD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAA;CAC7B;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAcvD;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,SAAS,GAAE,OAAO,CAAC,SAAS,CAAM,GAAG,SAAS,CASjF"}
@@ -1,24 +0,0 @@
1
- export function createRecordingLogger() {
2
- const entries = [];
3
- const record = (level) => (obj, msg) => {
4
- entries.push({ level, obj, msg });
5
- };
6
- return {
7
- entries,
8
- debug: record('debug'),
9
- info: record('info'),
10
- warn: record('warn'),
11
- error: record('error'),
12
- };
13
- }
14
- /** 测试用 `ConfigEnv`(固定读取约定:`ENV` / `API_PORT` / `LOG_LEVEL` / `DATABASE_URL` / `REDIS_URL`) */
15
- export function createTestConfigEnv(overrides = {}) {
16
- return {
17
- ENV: 'test',
18
- API_PORT: '',
19
- LOG_LEVEL: 'info',
20
- DATABASE_URL: '',
21
- REDIS_URL: undefined,
22
- ...overrides,
23
- };
24
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-augment.d.ts","sourceRoot":"","sources":["../../source/app/type-augment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;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AAE,CAAC,CAAC,GAAG;IACpD,QAAQ,CAAC,OAAO,EAAE,OAAO,YAAY,CAAA;CACtC,CAAA;AAED,4BAA4B;AAC5B,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO;IACvE,+CAA+C;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,eAAe;IACf,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5D;AAED,oDAAoD;AACpD,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;IACpE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CAC9B;AAED,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA"}
@@ -1,6 +0,0 @@
1
- import type { FastifyBaseLogger, FastifyRequest } from 'fastify';
2
- export interface RequestContext {
3
- log: FastifyBaseLogger;
4
- }
5
- export declare function createContext(request: FastifyRequest): RequestContext;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEhE,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,iBAAiB,CAAA;CACvB;AAcD,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAErE"}
@@ -1,14 +0,0 @@
1
- const fallbackLogger = {
2
- trace: () => { },
3
- debug: () => { },
4
- info: () => { },
5
- warn: () => { },
6
- error: () => { },
7
- fatal: () => { },
8
- child: () => fallbackLogger,
9
- level: 'info',
10
- silent: () => { },
11
- };
12
- export function createContext(request) {
13
- return { log: request.log || fallbackLogger };
14
- }
@@ -1,5 +0,0 @@
1
- export * from './types.js';
2
- export * from './rate-limiter.js';
3
- export * from './memory-store.js';
4
- export * from './redis-store.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/rate-limiter/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA"}
@@ -1,4 +0,0 @@
1
- export * from './types.js';
2
- export * from './rate-limiter.js';
3
- export * from './memory-store.js';
4
- export * from './redis-store.js';
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../source/rate-limiter/memory-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAO/D,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,eAAe,CAA8B;gBAEzC,iBAAiB,SAAQ;IAY/B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAY/C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B,OAAO,IAAI,IAAI;CAOhB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../../source/rate-limiter/rate-limi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CAAC,QAAQ,CAAC,KAAK,CAA+B;IACrD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,OAAO,CAAC,gBAAgB,CAAI;gBAEhB,OAAO,GAAE,0BAA+B;IAyBvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B,UAAU,IAAI,IAAI;IAKZ,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqB/C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBpD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/C,4BAA4B;IACf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,QAAQ;CAOjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"redis-store.test.d.ts","sourceRoot":"","sources":["../../source/rate-limiter/redis-store.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../source/rate-limiter/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,IAAI,CAAA;IACjB,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,IAAI,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IAC/C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClC,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB"}
@@ -1,4 +0,0 @@
1
- export { RedisCache, createRedisClient } from './redis-cache.js';
2
- export type { RedisCacheL1Options, RedisCacheOptions } from './redis-cache.js';
3
- export type { RedisClientType } from 'redis';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/redis-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAChE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE9E,YAAY,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA"}
@@ -1 +0,0 @@
1
- export { RedisCache, createRedisClient } from './redis-cache.js';
@@ -1 +0,0 @@
1
- {"version":3,"file":"redis-cache.d.ts","sourceRoot":"","sources":["../../source/redis-cache/redis-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,OAAO,CAAA;AAE1D;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH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G,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/C;;;;;;OAMG;IACU,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB5D;;;;;;OAMG;IACU,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IA6BhG;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAIhB,8CAA8C;YAChC,aAAa;YAmBb,aAAa;IAY3B,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ;CAOjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,eAAe,CAkBpF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=redis-cache.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redis-cache.test.d.ts","sourceRoot":"","sources":["../../source/redis-cache/redis-cache.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,K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