@taicode/common-server 3.8.0 → 4.0.0-beta.10

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 (218) hide show
  1. package/output/app/index.d.ts +18 -15
  2. package/output/app/index.d.ts.map +1 -1
  3. package/output/app/index.js +330 -9
  4. package/output/auth/index.d.ts +73 -0
  5. package/output/auth/index.d.ts.map +1 -0
  6. package/output/auth/index.js +196 -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 +109 -0
  11. package/output/core/boot/context.d.ts.map +1 -0
  12. package/output/core/boot/context.js +145 -0
  13. package/output/core/boot/lifecycle.d.ts +206 -0
  14. package/output/core/boot/lifecycle.d.ts.map +1 -0
  15. package/output/core/boot/lifecycle.js +255 -0
  16. package/output/core/boot/shutdown.d.ts +34 -0
  17. package/output/core/boot/shutdown.d.ts.map +1 -0
  18. package/output/core/boot/shutdown.js +50 -0
  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 +5 -4
  22. package/output/core/boot/steps.d.ts +138 -0
  23. package/output/core/boot/steps.d.ts.map +1 -0
  24. package/output/core/boot/steps.js +259 -0
  25. package/output/core/entries.d.ts +151 -0
  26. package/output/core/entries.d.ts.map +1 -0
  27. package/output/core/entries.js +242 -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 +458 -0
  31. package/output/core/env.d.ts +83 -0
  32. package/output/core/env.d.ts.map +1 -0
  33. package/output/core/env.js +124 -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/core/modules/cookie/index.js +17 -0
  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/core/modules/identity/index.js +14 -0
  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/core/modules/logging/index.js +29 -0
  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/core/modules/openapi/index.js +41 -0
  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/core/modules/request-id/index.d.ts +33 -0
  64. package/output/core/modules/request-id/index.d.ts.map +1 -0
  65. package/output/core/modules/request-id/index.js +66 -0
  66. package/output/core/modules/response/index.d.ts +50 -0
  67. package/output/core/modules/response/index.d.ts.map +1 -0
  68. package/output/core/modules/response/index.js +102 -0
  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 +205 -0
  81. package/output/core/resource.d.ts +56 -0
  82. package/output/core/resource.d.ts.map +1 -0
  83. package/output/core/resource.js +56 -0
  84. package/output/core/test-support/database.d.ts +89 -0
  85. package/output/core/test-support/database.d.ts.map +1 -0
  86. package/output/core/test-support/database.js +131 -0
  87. package/output/core/test-support/database.test.d.ts.map +1 -0
  88. package/output/core/test-support/database.test.js +111 -0
  89. package/output/core/test-support/environment.d.ts +38 -0
  90. package/output/core/test-support/environment.d.ts.map +1 -0
  91. package/output/core/test-support/environment.js +45 -0
  92. package/output/core/test-support/service-context.d.ts +64 -0
  93. package/output/core/test-support/service-context.d.ts.map +1 -0
  94. package/output/core/test-support/service-context.js +63 -0
  95. package/output/core/test-support/service-context.test.d.ts +2 -0
  96. package/output/core/test-support/service-context.test.d.ts.map +1 -0
  97. package/output/core/test-support/service-context.test.js +55 -0
  98. package/output/core/test-support/test-server.d.ts +154 -0
  99. package/output/core/test-support/test-server.d.ts.map +1 -0
  100. package/output/core/test-support/test-server.js +114 -0
  101. package/output/core/test-support/test-server.test.d.ts +2 -0
  102. package/output/core/test-support/test-server.test.d.ts.map +1 -0
  103. package/output/core/test-support/test-server.test.js +296 -0
  104. package/output/core/test-support/testdata.d.ts +255 -0
  105. package/output/core/test-support/testdata.d.ts.map +1 -0
  106. package/output/core/test-support/testdata.js +271 -0
  107. package/output/core/test-support/testdata.test.d.ts +2 -0
  108. package/output/core/test-support/testdata.test.d.ts.map +1 -0
  109. package/output/core/test-support/testdata.test.js +334 -0
  110. package/output/core/type-augment.d.ts +34 -0
  111. package/output/core/type-augment.d.ts.map +1 -0
  112. package/output/core/type-augment.js +7 -0
  113. package/output/core/types.d.ts +582 -0
  114. package/output/core/types.d.ts.map +1 -0
  115. package/output/core/types.js +2 -0
  116. package/output/cors/index.d.ts +3 -0
  117. package/output/cors/index.d.ts.map +1 -0
  118. package/output/cors/index.js +28 -0
  119. package/output/index.d.ts +10 -4
  120. package/output/index.d.ts.map +1 -1
  121. package/output/index.js +25 -5
  122. package/output/rate-limit/index.d.ts +23 -0
  123. package/output/rate-limit/index.d.ts.map +1 -0
  124. package/output/rate-limit/index.js +43 -0
  125. package/output/{rate-limiter/rate-limiter.d.ts → rate-limit/limiter.d.ts} +1 -1
  126. package/output/rate-limit/limiter.d.ts.map +1 -0
  127. package/output/{rate-limiter → rate-limit}/memory-store.d.ts +6 -0
  128. package/output/rate-limit/memory-store.d.ts.map +1 -0
  129. package/output/{rate-limiter → rate-limit}/memory-store.js +8 -0
  130. package/output/{rate-limiter → rate-limit}/redis-store.d.ts +18 -0
  131. package/output/rate-limit/redis-store.d.ts.map +1 -0
  132. package/output/{rate-limiter → rate-limit}/redis-store.js +35 -0
  133. package/output/rate-limit/redis-store.test.d.ts.map +1 -0
  134. package/output/{rate-limiter → rate-limit}/redis-store.test.js +2 -2
  135. package/output/rate-limit/types.d.ts +45 -0
  136. package/output/rate-limit/types.d.ts.map +1 -0
  137. package/output/{redis-cache/redis-cache.d.ts → redis/cache.d.ts} +1 -1
  138. package/output/redis/cache.d.ts.map +1 -0
  139. package/output/redis/cache.test.d.ts +2 -0
  140. package/output/redis/cache.test.d.ts.map +1 -0
  141. package/output/{redis-cache/redis-cache.test.js → redis/cache.test.js} +1 -1
  142. package/output/redis/index.d.ts +50 -0
  143. package/output/redis/index.d.ts.map +1 -0
  144. package/output/redis/index.js +71 -0
  145. package/output/redis/index.test.d.ts +2 -0
  146. package/output/{context → redis}/index.test.d.ts.map +1 -1
  147. package/output/redis/index.test.js +55 -0
  148. package/output/redis-queue/index.js +1 -1
  149. package/output/redis-queue/test-helpers.d.ts +1 -1
  150. package/output/redis-queue/test-helpers.js +1 -1
  151. package/output/redis-queue/types.d.ts +3 -12
  152. package/output/redis-queue/types.d.ts.map +1 -1
  153. package/package.json +11 -7
  154. package/output/app/assemble.d.ts +0 -16
  155. package/output/app/assemble.d.ts.map +0 -1
  156. package/output/app/assemble.js +0 -124
  157. package/output/app/database.d.ts +0 -36
  158. package/output/app/database.d.ts.map +0 -1
  159. package/output/app/database.js +0 -40
  160. package/output/app/database.test.d.ts.map +0 -1
  161. package/output/app/database.test.js +0 -66
  162. package/output/app/default-modules.d.ts +0 -23
  163. package/output/app/default-modules.d.ts.map +0 -1
  164. package/output/app/default-modules.js +0 -40
  165. package/output/app/define-server.d.ts +0 -12
  166. package/output/app/define-server.d.ts.map +0 -1
  167. package/output/app/define-server.js +0 -289
  168. package/output/app/define-server.test.d.ts +0 -2
  169. package/output/app/define-server.test.d.ts.map +0 -1
  170. package/output/app/define-server.test.js +0 -299
  171. package/output/app/env.d.ts +0 -24
  172. package/output/app/env.d.ts.map +0 -1
  173. package/output/app/env.js +0 -38
  174. package/output/app/env.test.js +0 -78
  175. package/output/app/module.d.ts +0 -88
  176. package/output/app/module.d.ts.map +0 -1
  177. package/output/app/module.js +0 -34
  178. package/output/app/shutdown.d.ts +0 -9
  179. package/output/app/shutdown.d.ts.map +0 -1
  180. package/output/app/shutdown.js +0 -15
  181. package/output/app/shutdown.test.d.ts +0 -2
  182. package/output/app/shutdown.test.d.ts.map +0 -1
  183. package/output/app/shutdown.test.js +0 -149
  184. package/output/app/signal.d.ts +0 -12
  185. package/output/app/signal.d.ts.map +0 -1
  186. package/output/app/steps.d.ts +0 -17
  187. package/output/app/steps.d.ts.map +0 -1
  188. package/output/app/steps.js +0 -41
  189. package/output/app/types.d.ts +0 -149
  190. package/output/app/types.d.ts.map +0 -1
  191. package/output/context/index.d.ts +0 -6
  192. package/output/context/index.d.ts.map +0 -1
  193. package/output/context/index.js +0 -14
  194. package/output/rate-limiter/index.d.ts +0 -5
  195. package/output/rate-limiter/index.d.ts.map +0 -1
  196. package/output/rate-limiter/index.js +0 -4
  197. package/output/rate-limiter/memory-store.d.ts.map +0 -1
  198. package/output/rate-limiter/rate-limiter.d.ts.map +0 -1
  199. package/output/rate-limiter/redis-store.d.ts.map +0 -1
  200. package/output/rate-limiter/redis-store.test.d.ts.map +0 -1
  201. package/output/rate-limiter/types.d.ts +0 -27
  202. package/output/rate-limiter/types.d.ts.map +0 -1
  203. package/output/redis-cache/index.d.ts +0 -4
  204. package/output/redis-cache/index.d.ts.map +0 -1
  205. package/output/redis-cache/index.js +0 -1
  206. package/output/redis-cache/redis-cache.d.ts.map +0 -1
  207. package/output/redis-cache/redis-cache.test.d.ts +0 -2
  208. package/output/redis-cache/redis-cache.test.d.ts.map +0 -1
  209. package/output/schema/index.d.ts.map +0 -1
  210. /package/output/{app → core}/env.test.d.ts +0 -0
  211. /package/output/{app → core/modules/auth-provider}/types.js +0 -0
  212. /package/output/{context → core/modules/context}/index.test.d.ts +0 -0
  213. /package/output/{context → core/modules/context}/index.test.js +0 -0
  214. /package/output/{app → core/test-support}/database.test.d.ts +0 -0
  215. /package/output/{rate-limiter/rate-limiter.js → rate-limit/limiter.js} +0 -0
  216. /package/output/{rate-limiter → rate-limit}/redis-store.test.d.ts +0 -0
  217. /package/output/{rate-limiter → rate-limit}/types.js +0 -0
  218. /package/output/{redis-cache/redis-cache.js → redis/cache.js} +0 -0
@@ -0,0 +1,296 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { defineServer } from '../entries.js';
3
+ import { routerSchema } from '../modules/schema/builders.js';
4
+ import { defineResource } from '../resource.js';
5
+ import { createTestServer } from './test-server.js';
6
+ const IDENTITY = { service: 'probe', title: 'Probe', version: '0.0.0' };
7
+ const ROUTE_SCHEMA = routerSchema({
8
+ operationId: 'probeGet',
9
+ summary: '探测',
10
+ description: '探测路由',
11
+ tags: ['探测'],
12
+ });
13
+ const APP_URL = 'postgresql://postgres:secret@db.internal:5432/taicode-labs?schema=probe';
14
+ const TEST_URL = 'postgresql://postgres:secret@db.internal:5432/taicode-labs?schema=probe_test';
15
+ const ORIGINAL_ENV = { ...process.env };
16
+ afterEach(() => {
17
+ process.env = { ...ORIGINAL_ENV };
18
+ });
19
+ function buildServer(seen = {}) {
20
+ return defineServer({
21
+ app: IDENTITY,
22
+ resources: (ctx) => {
23
+ seen.databaseUrl = ctx.env.DATABASE_URL;
24
+ seen.env = ctx.env.ENV;
25
+ return {};
26
+ },
27
+ config: () => ({ server: { cookieNames: ['token'] } }),
28
+ clients: () => ({}),
29
+ services: () => ({}),
30
+ middlewares: () => [],
31
+ routers: ({ app }) => {
32
+ app.get('/probe', { schema: ROUTE_SCHEMA }, async () => ({ ok: true }));
33
+ },
34
+ });
35
+ }
36
+ /** 把 vitest 自己设的环境变量清干净,让每个用例只看到自己注入的值 */
37
+ function useEnv(overrides) {
38
+ process.env.ENV = 'development';
39
+ // 注意:给 process.env 赋 undefined 会变成字符串 "undefined",所以必须先 delete
40
+ delete process.env.DATABASE_URL;
41
+ delete process.env.TEST_DATABASE_URL;
42
+ process.env.LOG_LEVEL = 'silent';
43
+ for (const [key, value] of Object.entries(overrides)) {
44
+ if (value === undefined) {
45
+ delete process.env[key];
46
+ }
47
+ else {
48
+ process.env[key] = value;
49
+ }
50
+ }
51
+ }
52
+ describe('createTestServer', () => {
53
+ it('与 startServer 装配同一套处理链:系统路由 + 业务路由 + zod 序列化 + 成功信封', async () => {
54
+ useEnv({ DATABASE_URL: APP_URL });
55
+ const testServer = await createTestServer(buildServer());
56
+ const response = await testServer.app.inject({ method: 'GET', url: '/probe' });
57
+ expect(response.statusCode).toBe(200);
58
+ // 信封形状来自框架 core/response,而不是测试自己拼的一份
59
+ expect(response.json()).toEqual({ status: 'SUCCESS', message: 'ok', data: { ok: true } });
60
+ // 框架系统路由同样就位
61
+ expect((await testServer.app.inject({ method: 'GET', url: '/health' })).statusCode).toBe(200);
62
+ await testServer.app.close();
63
+ });
64
+ it('数据层被结算到 *_test(resources 从 ctx.env 拿到的就是测试目标),且不改写全局 process.env', async () => {
65
+ useEnv({ DATABASE_URL: APP_URL });
66
+ const seen = {};
67
+ const testServer = await createTestServer(buildServer(seen));
68
+ // resources 从 `ctx.env.DATABASE_URL` 读到的是结算后的测试目标
69
+ expect(seen.databaseUrl).toContain('schema=probe_test');
70
+ // 交出来的连接串就是「测试实际连的那个」,不是从 process.env 再推一遍
71
+ expect(testServer.env.DATABASE_URL).toBe(seen.databaseUrl);
72
+ // **不改写全局 process.env.DATABASE_URL**:测试目标只属于本次装配,避免同进程并行串扰
73
+ expect(process.env.DATABASE_URL).toBe(APP_URL);
74
+ await testServer.app.close();
75
+ });
76
+ it('显式 TEST_DATABASE_URL 优先于派生', async () => {
77
+ useEnv({
78
+ DATABASE_URL: APP_URL,
79
+ TEST_DATABASE_URL: TEST_URL.replace('probe_test', 'explicit_test'),
80
+ });
81
+ const seen = {};
82
+ const testServer = await createTestServer(buildServer(seen));
83
+ expect(seen.databaseUrl).toContain('schema=explicit_test');
84
+ await testServer.app.close();
85
+ });
86
+ it('不监听端口(测试用 inject,占端口会让重跑互相踩)', async () => {
87
+ useEnv({ DATABASE_URL: APP_URL });
88
+ const testServer = await createTestServer(buildServer());
89
+ expect(testServer.app.server.listening).toBe(false);
90
+ await testServer.app.close();
91
+ });
92
+ it('env 强制加载测试层:ENV 没人给时兜底成 test(不用调用方额外声明)', async () => {
93
+ useEnv({ DATABASE_URL: APP_URL, ENV: undefined });
94
+ const seen = {};
95
+ const testServer = await createTestServer(buildServer(seen));
96
+ expect(seen.env).toBe('test');
97
+ await testServer.app.close();
98
+ });
99
+ it('环境闸门:非可清理环境在装配之前就失败(resources 一次都没跑)', async () => {
100
+ useEnv({ DATABASE_URL: APP_URL, ENV: 'production' });
101
+ const onResources = vi.fn(buildServer().resources);
102
+ const server = defineServer({ ...buildServer(), resources: onResources });
103
+ await expect(createTestServer(server)).rejects.toThrow(/ENV="production"/);
104
+ expect(onResources).not.toHaveBeenCalled();
105
+ });
106
+ it('schema 闸门:目标不以 *_test 结尾时拒绝装配', async () => {
107
+ useEnv({ DATABASE_URL: APP_URL, TEST_DATABASE_URL: APP_URL });
108
+ const onResources = vi.fn(buildServer().resources);
109
+ const server = defineServer({ ...buildServer(), resources: onResources });
110
+ await expect(createTestServer(server)).rejects.toThrow(/必须以 _test 结尾/);
111
+ expect(onResources).not.toHaveBeenCalled();
112
+ });
113
+ it('关闭时走同一套八步流程(services 的 dispose 被调用)', async () => {
114
+ useEnv({ DATABASE_URL: APP_URL });
115
+ const onDispose = vi.fn();
116
+ const server = defineServer({
117
+ ...buildServer(),
118
+ services: () => ({ unit: { dispose: onDispose } }),
119
+ });
120
+ const testServer = await createTestServer(server);
121
+ await testServer.app.close();
122
+ expect(onDispose).toHaveBeenCalledTimes(1);
123
+ });
124
+ it('业务路由缺少 schema 时注册即失败(守卫在测试入口同样生效)', async () => {
125
+ useEnv({ DATABASE_URL: APP_URL });
126
+ const server = defineServer({
127
+ ...buildServer(),
128
+ routers: ({ app }) => {
129
+ app.get('/bad', async () => ({ ok: true }));
130
+ },
131
+ });
132
+ await expect(createTestServer(server)).rejects.toThrow(/GET \/bad 缺少 schema/);
133
+ });
134
+ it('返回装配产物本身:resources / config / clients / services 与槽位一一对应', async () => {
135
+ useEnv({ DATABASE_URL: APP_URL });
136
+ const resources = { cache: { get: () => undefined } };
137
+ const config = { server: { cookieNames: ['token'] } };
138
+ const clients = { account: { verify: async () => true } };
139
+ const services = { user: { name: () => 'user' } };
140
+ const testServer = await createTestServer(defineServer({
141
+ app: IDENTITY,
142
+ resources: () => resources,
143
+ config: () => config,
144
+ clients: () => clients,
145
+ services: () => services,
146
+ middlewares: () => [],
147
+ routers: () => { },
148
+ }));
149
+ // 装配产物直接交出来:测试能断言/操作它们本身,而不是再构造一份副本。
150
+ // `resources` / `clients` 经过 `Live<T>` 视图(剔 `false` 键),所以按值比较;
151
+ // `config` / `services` 就是槽位原始返回值,引用相同。
152
+ expect(testServer.resources).toEqual(resources);
153
+ expect(testServer.clients).toEqual(clients);
154
+ expect(testServer.config).toBe(config);
155
+ expect(testServer.services).toBe(services);
156
+ // env 是**改写后**的快照(resources 看到的就是它)
157
+ expect(testServer.env.DATABASE_URL).toContain('schema=probe_test');
158
+ await testServer.app.close();
159
+ });
160
+ it('只有定义一个参数:没有「半个生产」的配置入口', () => {
161
+ // 签名只有一个必填参数。这条断言盯着「别再加 options」——一旦加了,测试就能绕开
162
+ // 生产接线,本入口随即失去证明力。
163
+ expect(createTestServer.length).toBe(1);
164
+ });
165
+ it('不复位入口只留 reprovision 一个:flushServices / resetTestData 都已移除', async () => {
166
+ useEnv({ DATABASE_URL: APP_URL });
167
+ const testServer = await createTestServer(buildServer());
168
+ expect('flushServices' in testServer).toBe(false);
169
+ expect('resetTestData' in testServer).toBe(false);
170
+ expect('cleanServerData' in testServer).toBe(false);
171
+ expect(typeof testServer.reprovision).toBe('function');
172
+ await testServer.app.close();
173
+ });
174
+ it('不外漏装配层产物:resourceUnits 只活在闭包里', async () => {
175
+ useEnv({ DATABASE_URL: APP_URL });
176
+ const server = defineServer({
177
+ ...buildServer(),
178
+ resources: () => ({
179
+ database: defineResource({ marker: 'db' }, { clean: () => { } }),
180
+ }),
181
+ });
182
+ const testServer = await createTestServer(server);
183
+ // `ResourceSetupUnit[]` 是 boot 层的产物;把它挂在测试对象上等于把下层的实现细节
184
+ // 变成公开契约,测试就能绕过 `reprovision()` 自己编排清理。
185
+ expect('resourceUnits' in testServer).toBe(false);
186
+ // `testData`(已发现的脚本名单)同理:它是装配期的中间产物,唯一用法是「再来一遍基线」,
187
+ // 而那件事就是 `reprovision()`。外面既没有 `loadTestData` 可以拿它做什么,也没有第二个入口
188
+ // 需要它——挂出去只会让人以为「我该自己编排装载顺序」。
189
+ expect('testData' in testServer).toBe(false);
190
+ expect(Object.keys(testServer).sort()).toEqual(['app', 'clients', 'config', 'env', 'log', 'reprovision', 'resources', 'services']);
191
+ await testServer.app.close();
192
+ });
193
+ });
194
+ describe('TestServer.reprovision', () => {
195
+ it('清完数据再关旧实例:clean() 一定跑在 dispose() 之前(连接还在)', async () => {
196
+ useEnv({ DATABASE_URL: APP_URL });
197
+ const order = [];
198
+ const server = defineServer({
199
+ ...buildServer(),
200
+ resources: () => ({
201
+ database: defineResource({ marker: 'db' }, {
202
+ clean: () => { order.push('clean:database'); },
203
+ dispose: () => { order.push('dispose:database'); },
204
+ }),
205
+ }),
206
+ services: () => ({
207
+ cache: {
208
+ clean: () => { order.push('clean:cache'); },
209
+ dispose: () => { order.push('dispose:cache'); },
210
+ },
211
+ }),
212
+ });
213
+ const first = await createTestServer(server);
214
+ const second = await first.reprovision();
215
+ // 资源声明序 → 服务声明序 → 八步关闭(dispose 逆序)
216
+ expect(order).toEqual(['clean:database', 'clean:cache', 'dispose:cache', 'dispose:database']);
217
+ // 旧 app 已关(再 inject 会失败),新 app 可用
218
+ await expect(first.app.inject({ method: 'GET', url: '/health' })).rejects.toThrow();
219
+ expect((await second.app.inject({ method: 'GET', url: '/health' })).statusCode).toBe(200);
220
+ await second.app.close();
221
+ });
222
+ it('返回的是新实例:app / resources / services 全部换新,env 快照复用', async () => {
223
+ useEnv({ DATABASE_URL: APP_URL });
224
+ let built = 0;
225
+ const server = defineServer({
226
+ ...buildServer(),
227
+ services: () => {
228
+ built += 1;
229
+ return { unit: { id: built } };
230
+ },
231
+ });
232
+ const first = await createTestServer(server);
233
+ const second = await first.reprovision();
234
+ expect(second).not.toBe(first);
235
+ expect(second.app).not.toBe(first.app);
236
+ expect(second.services).not.toBe(first.services);
237
+ expect(second.services).toEqual({ unit: { id: 2 } });
238
+ // env 是同一份快照(不重跑 prepareTestDatabase)
239
+ expect(second.env).toBe(first.env);
240
+ await second.app.close();
241
+ });
242
+ it('clean() 失败冒泡:不会去装配、也不会留下半开的世界', async () => {
243
+ useEnv({ DATABASE_URL: APP_URL });
244
+ let assembled = 0;
245
+ const server = defineServer({
246
+ ...buildServer(),
247
+ resources: () => ({
248
+ database: defineResource({ marker: 'db' }, {
249
+ clean: () => { throw new Error('truncate failed'); },
250
+ }),
251
+ }),
252
+ services: () => {
253
+ assembled += 1;
254
+ return {};
255
+ },
256
+ });
257
+ const testServer = await createTestServer(server);
258
+ await expect(testServer.reprovision()).rejects.toThrow(/truncate failed/);
259
+ // 失败发生在装配之前:services 只被构造过一次
260
+ expect(assembled).toBe(1);
261
+ await testServer.app.close();
262
+ });
263
+ it('app.close() 失败不阻断:clean 已跑完,仍然会重新装配', async () => {
264
+ useEnv({ DATABASE_URL: APP_URL });
265
+ const order = [];
266
+ const server = defineServer({
267
+ ...buildServer(),
268
+ resources: () => ({
269
+ database: defineResource({ marker: 'db' }, {
270
+ clean: () => { order.push('clean'); },
271
+ dispose: () => { throw new Error('dispose failed'); },
272
+ }),
273
+ }),
274
+ });
275
+ const first = await createTestServer(server);
276
+ const second = await first.reprovision();
277
+ expect(order).toEqual(['clean']);
278
+ expect((await second.app.inject({ method: 'GET', url: '/health' })).statusCode).toBe(200);
279
+ await second.app.close();
280
+ });
281
+ it('环境闸门:非可清理环境下连 clean() 都不跑', async () => {
282
+ useEnv({ DATABASE_URL: APP_URL });
283
+ const onClean = vi.fn();
284
+ const server = defineServer({
285
+ ...buildServer(),
286
+ resources: () => ({
287
+ database: defineResource({ marker: 'db' }, { clean: onClean }),
288
+ }),
289
+ });
290
+ const testServer = await createTestServer(server);
291
+ testServer.env.ENV = 'production';
292
+ await expect(testServer.reprovision()).rejects.toThrow(/ENV="production"/);
293
+ expect(onClean).not.toHaveBeenCalled();
294
+ await testServer.app.close();
295
+ });
296
+ });
@@ -0,0 +1,255 @@
1
+ import type { AppEnv, ClientsView, LoggerLike, ResourcesView, Server } from '../types.js';
2
+ /**
3
+ * **测试数据(testdata)机制**:`packages/server/testdata/*.ts|js` 下的脚本,在 `development` /
4
+ * `test` 启动时自动加载,并在用例之间被重新加载。
5
+ *
6
+ * ## 为什么是「目录 + 约定方法」,而不是资源上的生命周期
7
+ *
8
+ * 「这条用例需要哪些样本数据」与「这份数据怎么删掉」是**同一件事的正反面**,写在同一个文件里
9
+ * 才不容易漏。把 `cleanup` 挂到资源单元上做不到这一点:资源只知道「有哪些表 / 哪些 key」,
10
+ * 不知道「谁往里写了什么」——新增一个 model 就要回去改一次清库清单,漏改只会安静地变脏。
11
+ *
12
+ * 所以机制倒过来:**数据脚本自己负责自己**。
13
+ *
14
+ * ```ts
15
+ * // packages/server/testdata/01-base.ts(推荐写法)
16
+ * import { defineTestData } from '@taicode/common-server/app'
17
+ * import type { AppResources } from '../source/resources'
18
+ *
19
+ * export default defineTestData<AppResources>({
20
+ * async load(ctx) { …插入样本数据… },
21
+ * })
22
+ * ```
23
+ *
24
+ * 命名导出 `load(ctx)` / `cleanup(ctx)`(+ 可选 `dependsOn`)继续支持;两者都有时默认导出优先。
25
+ *
26
+ * ## 契约(只有三条)
27
+ *
28
+ * 1. **目录固定**:`<cwd>/testdata`(`tsx watch ./source/index.ts` 与 `vitest` 的 cwd 都是
29
+ * `packages/server`)。目录不存在 = 没有脚本。
30
+ * 2. **`load` 必需,`cleanup` 可选**:只写 `load` 的脚本是**合法**的——它的数据由资源单元的
31
+ * `clean()`(典型实现 `TRUNCATE ... CASCADE`)在重装前清掉。需要「资源清不掉的东西」
32
+ * (下游 mock 预置、临时文件)时才写 `cleanup`。
33
+ * 3. **顺序**:文件名(字典序升序)是默认序;需要「我必须排在某脚本之后」时用
34
+ * `dependsOn` 显式声明,见下节。
35
+ *
36
+ * ## 顺序:`dependsOn` 是权威,文件名只做同层破平
37
+ *
38
+ * ```ts
39
+ * // packages/server/testdata/02-organization.ts
40
+ * import { defineTestData } from '@taicode/common-server/app'
41
+ *
42
+ * export default defineTestData({
43
+ * dependsOn: ['01-database'],
44
+ * async load(ctx) { … },
45
+ * })
46
+ * ```
47
+ *
48
+ * - **引用名 = 去扩展名的文件名**(`01-base.ts` → `'01-base'`),与 `TestDataUnit.name` 一致。
49
+ * - **只影响顺序,不注入任何东西**:声明依赖**不会**把前一个脚本的客户端/数据递给你——需要共享
50
+ * 资源时用 `ctx.resources`(框架注入的装配产物),而不是依赖另一个脚本。
51
+ * - **`cleanup` 不用声明**:它是装配序的逆序,依赖自动反向成立(后建的先拆)。
52
+ * - **同层按文件名升序**:没有依赖关系的脚本之间的相对顺序由文件名决定,结果确定可复现。
53
+ * - **缺依赖 / 自依赖 / 环一律报错**(不是跳过、不是猜测顺序):顺序是安全属性,猜错只会
54
+ * 变成偶发的外键冲突。
55
+ *
56
+ * 为什么要有这个字段:数字前缀是「顺序的替身」,中间插一个脚本就得重命名后面全部文件——
57
+ * 纯噪音改动,还会切断 git 历史。依赖声明让「谁必须在谁之后」贴着原因写。
58
+ *
59
+ * > 字段名与已删除的**模块装配期** `dependsOn`(连同 `validateLifecycleDependencies`,§11-2)
60
+ * > 无关:那个是资源/模块之间的构造依赖,这个是数据脚本之间的**执行顺序**。
61
+ *
62
+ * ## 两条与「安全」有关的约定
63
+ *
64
+ * - **`_` 开头的文件不是脚本**:它们是脚本之间共享的 helper(`_client.ts`),不会被 `load` /
65
+ * `cleanup`。否则扫描目录就会把工具文件也当成脚本执行。
66
+ * - **只在可清理环境执行**:`load` / `cleanup` 两个执行入口的**第 0 步**都是
67
+ * `assertCleanableEnvironment(ctx.env.ENV)`。判据是装配期的 `ctx.env` 快照(事后改写
68
+ * `process.env` 不影响结论)。
69
+ *
70
+ * ## 执行顺序与失败语义
71
+ *
72
+ * | 入口 | 顺序 | 失败 |
73
+ * | --- | --- | --- |
74
+ * | `loadTestData` | **执行序**(`dependsOn` 拓扑序,同层按文件名升序) | 立即冒泡 |
75
+ * | `cleanupTestData` | **执行序逆序**(无 `cleanup` 的脚本跳过) | 立即冒泡 |
76
+ *
77
+ * `cleanup` 逆序是「后建的先拆」,依赖因此不必反向声明。
78
+ *
79
+ * 失败**一律冒泡**,不降级成「跳过这条脚本」:数据没准备好时静默继续只会让后续用例读到脏状态,
80
+ * 制造伪绿。
81
+ *
82
+ * ## 脚本拿到什么:`ctx`
83
+ *
84
+ * 脚本不再自己读 env、不再自己建连接——框架把装配好的东西注入进来。`load` 跑在
85
+ * `app.ready()` 之后、`listen` 之前,所以装配产物**全部已经存在**:
86
+ *
87
+ * | 字段 | 是什么 | 为什么给 |
88
+ * | --- | --- | --- |
89
+ * | `env` | 装配快照 `AppEnv<Env>` | 脚本不碰 `process.env`;看到的就是应用看到的那份 |
90
+ * | `resources` | `ResourcesView<Resources>`(单元已解包) | 脚本写数据的地方就是被测服务读数据的地方 |
91
+ * | `config` | 启动期配置快照 `Awaited<Config>`(只读) | 有些基线必须以配置为输入(按配置里的管理员名单造账号) |
92
+ * | `clients` | `ClientsView<Clients>` | 预置 / 清理下游 mock 状态的唯一正当通道 |
93
+ * | `services` | `Awaited<Services>`(已 `init()`) | 走服务造数据才会自动满足业务不变量(哈希、缓存失效、审计) |
94
+ * | `log` | `ctx.log` | 日志与装配期同一路输出 |
95
+ *
96
+ * 「脚本自己建一份客户端」是**错的**:同一份数据经两条连接写/读,缓存与连接级状态对不上
97
+ * (account 曾经的 `globalThis` 重置注册表就是这个坑的产物)。所以注入 `resources` 是结构性的,
98
+ * 不是便利。
99
+ *
100
+ * **为什么不给 `app`**:拿到 `app` 就能 `inject()`,等于「跑一条业务链路来造数据」。那会一次性
101
+ * 引入中间件链(鉴权 / 限流 / requestId)、响应信封与错误映射,让基线脚本的失败语义、执行顺序、
102
+ * 耗时全部失控——而这三样正是 `dependsOn` 与「失败直接冒泡」想守住的东西。要跑链路请写在用例里。
103
+ *
104
+ * ## 三条使用边界
105
+ *
106
+ * 1. **首选 `resources`,`services` 只在「必须满足业务不变量」时用**,并在文件头写明原因。
107
+ * 同一个目录里一半 raw write、一半走 service,数据形状迟早会不一致。
108
+ * 2. **`config` 是快照**:脚本写配置表**不会**刷新当前实例的 `ctx.config`,要生效只能重新装配。
109
+ * 3. **`clients` 只用于预置 / 清理下游 mock**:`development` 会跑同一批脚本,误发就是真的发出去了。
110
+ */
111
+ export interface TestDataContext<Resources = object, Env = object, Config = object, Clients = object, Services = object> {
112
+ /** 本次装配的 env 快照(框架固定约定 + 应用扩展字段);脚本**不必也不该**再读 `process.env` */
113
+ readonly env: AppEnv<Env>;
114
+ /** 装配好的资源(单元已解包):写数据 / 清缓存都用它,而不是另建一份客户端 */
115
+ readonly resources: ResourcesView<Resources>;
116
+ /** 启动期配置快照(只读):写配置表不会刷新它,要生效需重新装配 */
117
+ readonly config: Awaited<Config>;
118
+ /** 外部客户端:只用于预置 / 清理下游 mock,不得产生真实外部副作用 */
119
+ readonly clients: ClientsView<Clients>;
120
+ /** 已 `init()` 完成的服务实例:走它造数据才会满足业务不变量 */
121
+ readonly services: Awaited<Services>;
122
+ /** 记录型 logger(与装配期同一个) */
123
+ readonly log: LoggerLike;
124
+ }
125
+ /** 一个测试数据脚本(`testdata/*.ts` 的约定导出) */
126
+ export interface TestDataScript<Resources = object, Env = object, Config = object, Clients = object, Services = object> {
127
+ /** 加载本脚本负责的测试数据(可重复执行) */
128
+ load(ctx: TestDataContext<Resources, Env, Config, Clients, Services>): void | Promise<void>;
129
+ /**
130
+ * 清理本脚本负责的测试数据(可选)。
131
+ *
132
+ * **大多数脚本不需要它**:内存数据库的行由资源单元的 `clean()`(典型实现
133
+ * `TRUNCATE ... CASCADE`)在重新装配前清掉。只有「资源清不掉的东西」才需要自己写
134
+ * `cleanup`——下游 mock 的预置状态、临时文件、外部队列的 key。
135
+ *
136
+ * 提供时必须能把 `load()` 的效果完全撤销;不提供时重装前由资源兜底。
137
+ */
138
+ cleanup?(ctx: TestDataContext<Resources, Env, Config, Clients, Services>): void | Promise<void>;
139
+ /**
140
+ * 必须在哪些脚本**之后**执行(去扩展名的文件名;缺省 = 无要求)。
141
+ *
142
+ * 只影响排序:`load` 按依赖拓扑序(同层按文件名升序),`cleanup` 取其逆序。
143
+ * 校验严格:引用不存在的脚本、引用自己、循环依赖都会让装载阶段**抛错**。
144
+ */
145
+ readonly dependsOn?: readonly string[];
146
+ }
147
+ /** `defineTestData()` 的入参:与 `TestDataScript` 同形(只有 `load` 必需) */
148
+ export type TestDataDefinition<Resources = object, Env = object, Config = object, Clients = object, Services = object> = TestDataScript<Resources, Env, Config, Clients, Services>;
149
+ /**
150
+ * 由**一个** `Server` 类型推出脚本类型(`defineTestData<typeof server>({ … })` 用的就是这个)。
151
+ *
152
+ * 五个槽位泛型本来要一个个手写、顺序还得对上(`Resources, Env, Config, Clients, Services` 与
153
+ * `Server` 的 `Resources, Config, Clients, Services, Env` 不同序);直接给 `server` 就没这个问题:
154
+ * 写错泛型名会当场报错,而不是静默拿到 `object`。
155
+ *
156
+ * 非 `Server` 类型(如直接传 `AccountResources`)退化为「只声明 `resources`」的老写法。
157
+ */
158
+ export type TestDataScriptOf<S, Env = object> = S extends Server<infer Resources, infer Config, infer Clients, infer Services, infer AppEnvShape> ? TestDataScript<Resources, AppEnvShape, Config, Clients, Services> : TestDataScript<S, Env>;
159
+ /** `defineTestData<S>()` 的入参(`TestDataScriptOf` 的别名,语义更贴近调用处) */
160
+ export type TestDataDefinitionOf<S, Env = object> = TestDataScriptOf<S, Env>;
161
+ /**
162
+ * 声明一个测试数据脚本(**唯一正当的写法**)。
163
+ *
164
+ * ```ts
165
+ * // packages/server/testdata/03-system-config.ts
166
+ * import { defineTestData } from '@taicode/common-server/app'
167
+ * import type { server } from '../source/server' // 纯类型导入,无副作用
168
+ *
169
+ * export default defineTestData<typeof server>({
170
+ * dependsOn: ['01-database'],
171
+ * async load(ctx) { …插入样本数据… },
172
+ * async cleanup(ctx) { …删掉自己插入的数据… },
173
+ * })
174
+ * ```
175
+ *
176
+ * 泛型写 `typeof server` 而不是逐个槽位:`ctx` 上的 `resources` / `config` / `clients` /
177
+ * `services` / `env` 类型一次到位。只想声明 `resources` 时也可以写
178
+ * `defineTestData<AccountResources>({ … })`(其余槽位退化为 `object`)。
179
+ *
180
+ * ## 它解决什么
181
+ *
182
+ * 命名导出 `load` 是**约定**,写错只在装载期才会暴露(少写 `load` = 启动直接失败)。
183
+ * `defineTestData` 把这份约定变成**定义期**就检查的东西:
184
+ *
185
+ * 1. **缺 `load` 当场报错**(不是等到 `discoverTestDataModules()` 扫描到它);
186
+ * 2. **`dependsOn` 当场校验**(必须是字符串数组、不能有重复项;引用不存在的脚本 / 自依赖 /
187
+ * 环属于跨文件问题,仍在装载期由 `sortByDependencies()` 统一判定);
188
+ * 3. **结果冻结**:脚本之间不会互相改写 `load` / `cleanup`(执行器拿到的就是定义时那份)。
189
+ *
190
+ * `ctx` 的类型由 `S` 一次性带进来:`defineTestData<typeof server>({ load(ctx) {…} })` 里
191
+ * `ctx.services` / `ctx.resources` / `ctx.config` 全部有类型,不需要每个脚本再手写
192
+ * `type Ctx = TestDataContext<…>`。
193
+ *
194
+ * ## 与「命名导出」的关系
195
+ *
196
+ * 两种写法都合法,`defineTestData` 只是把结构显式化:
197
+ *
198
+ * ```ts
199
+ * // 推荐:默认导出一个定义对象
200
+ * export default defineTestData<typeof server>({ load })
201
+ *
202
+ * // 等价:命名导出(旧写法,继续支持)
203
+ * export async function load(ctx: TestDataContext<AccountResources>) { … }
204
+ * export const dependsOn = ['01-database']
205
+ * ```
206
+ *
207
+ * 同一个文件里两者都有时,**默认导出优先**——避免「改了默认导出、命名导出还在生效」的歧义。
208
+ */
209
+ export declare function defineTestData<S = object, Env = object>(definition: TestDataDefinitionOf<S, Env>): TestDataScriptOf<S, Env>;
210
+ /** 一个已从磁盘装载好的脚本单元(含名字,用于日志与报错定位) */
211
+ export interface TestDataUnit<Resources = object, Env = object, Config = object, Clients = object, Services = object> extends TestDataScript<Resources, Env, Config, Clients, Services> {
212
+ /** 脚本文件名去掉扩展名(`01-base.ts` → `01-base`) */
213
+ readonly name: string;
214
+ }
215
+ /** 两个执行入口的共同入参 */
216
+ export interface TestDataRunParams<Resources = object, Env = object, Config = object, Clients = object, Services = object> {
217
+ /**
218
+ * 本次装配的 ctx(`env` + `resources` + `config` + `clients` + `services` + `log`)。**必填**:
219
+ *
220
+ * - 闸门读 `ctx.env.ENV`:非 `CLEANABLE_ENVS`(`development` / `test`)一律抛错,一个脚本都不跑;
221
+ * - 脚本拿到的就是这份 ctx,所以它看到的环境 / 资源与本次装配完全一致。
222
+ */
223
+ ctx: TestDataContext<Resources, Env, Config, Clients, Services>;
224
+ /** 已装载的脚本(`discoverTestDataModules()` 的产物);缺省 = 没有脚本 */
225
+ units?: readonly TestDataUnit<Resources, Env, Config, Clients, Services>[];
226
+ /** 日志标签(`defineServer({ app: { service } })`) */
227
+ service?: string;
228
+ }
229
+ /** 默认脚本目录(相对 `process.cwd()`) */
230
+ export declare function resolveTestDataDirectory(): string;
231
+ /**
232
+ * 扫描目录并**装载**全部脚本(`import()` 一次,模块本身由 ESM 缓存复用)。
233
+ *
234
+ * 目录不存在 → 空数组(不是错误:没写测试数据的服务是合法的)。
235
+ * 文件存在但缺 `load` → **抛错**,并指出是哪个文件。
236
+ *
237
+ * 返回的顺序就是**执行序**:`dependsOn` 拓扑序 + 同层文件名升序(`load` 直接正序跑,
238
+ * `cleanup` 直接逆序跑)。
239
+ */
240
+ export declare function discoverTestDataModules<Resources = object, Env = object, Config = object, Clients = object, Services = object>(directory?: string): Promise<TestDataUnit<Resources, Env, Config, Clients, Services>[]>;
241
+ /**
242
+ * 加载测试数据:按**执行序**逐项 `await load(ctx)`(依赖在前,同层按文件名升序)。
243
+ *
244
+ * 在 `createTestServer()` / `startServer()` 装配完成后自动执行一次;也可以由测试自己再调。
245
+ */
246
+ export declare function loadTestData<Resources, Env, Config, Clients, Services>(params: TestDataRunParams<Resources, Env, Config, Clients, Services>): Promise<void>;
247
+ /**
248
+ * 清理测试数据:按执行序**逆序**逐项 `await cleanup()`(后建的先拆)。
249
+ *
250
+ * 依赖不必反向声明:`load` 的拓扑序取逆就是安全的拆除序。没有 `cleanup` 的脚本直接跳过。
251
+ *
252
+ * 注意:它只负责「把脚本插入的东西撤掉」,不是「把整个库清空」——库由资源单元的 `clean()` 清。
253
+ */
254
+ export declare function cleanupTestData<Resources, Env, Config, Clients, Services>(params: TestDataRunParams<Resources, Env, Config, Clients, Services>): Promise<void>;
255
+ //# sourceMappingURL=testdata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testdata.d.ts","sourceRoot":"","sources":["../../../source/core/test-support/testdata.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AACH,MAAM,WAAW,eAAe,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,QAAQ,GAAG,MAAM;IACrH,gEAAgE;IAChE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IACtC,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpC,0BAA0B;IAC1B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;CACzB;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAc,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,QAAQ,GAAG,MAAM;IACpH,0BAA0B;IAC1B,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,SAAS,EAAE,GAAG,E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