@taicode/common-server 3.7.11 → 3.7.13
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/output/index.d.ts +1 -0
- package/output/index.d.ts.map +1 -1
- package/output/index.js +1 -0
- package/output/rate-limiter/index.d.ts +1 -0
- package/output/rate-limiter/index.d.ts.map +1 -1
- package/output/rate-limiter/index.js +1 -0
- package/output/rate-limiter/rate-limiter.d.ts.map +1 -1
- package/output/rate-limiter/redis-store.d.ts +45 -0
- package/output/rate-limiter/redis-store.d.ts.map +1 -0
- package/output/rate-limiter/redis-store.js +114 -0
- package/output/rate-limiter/redis-store.test.d.ts +2 -0
- package/output/rate-limiter/redis-store.test.d.ts.map +1 -0
- package/output/rate-limiter/redis-store.test.js +70 -0
- package/output/redis-cache/index.d.ts +4 -0
- package/output/redis-cache/index.d.ts.map +1 -0
- package/output/redis-cache/index.js +1 -0
- package/output/redis-cache/redis-cache.d.ts +139 -0
- package/output/redis-cache/redis-cache.d.ts.map +1 -0
- package/output/redis-cache/redis-cache.js +282 -0
- package/output/redis-cache/redis-cache.test.d.ts +2 -0
- package/output/redis-cache/redis-cache.test.d.ts.map +1 -0
- package/output/redis-cache/redis-cache.test.js +156 -0
- package/output/redis-queue/redis-queue-batch-consumer.d.ts +2 -2
- package/output/redis-queue/redis-queue-batch-consumer.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-batch-consumer.js +5 -6
- package/output/redis-queue/redis-queue-batch-consumer.test.d.ts +1 -1
- package/output/redis-queue/redis-queue-batch-consumer.test.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-batch-consumer.test.js +1 -3
- package/output/redis-queue/redis-queue-common.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-common.test.d.ts +17 -13
- package/output/redis-queue/redis-queue-common.test.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-consumer.d.ts +2 -2
- package/output/redis-queue/redis-queue-consumer.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-consumer.js +2 -3
- package/output/redis-queue/redis-queue-consumer.test.d.ts +1 -1
- package/output/redis-queue/redis-queue-consumer.test.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-consumer.test.js +1 -1
- package/output/redis-queue/redis-queue-provider.d.ts +2 -2
- package/output/redis-queue/redis-queue-provider.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-provider.js +1 -1
- package/output/redis-queue/redis-queue-provider.test.d.ts +2 -2
- package/output/redis-queue/redis-queue-provider.test.d.ts.map +1 -1
- package/output/redis-queue/redis-queue-provider.test.js +42 -42
- package/output/redis-queue/test-helpers.d.ts +11 -14
- package/output/redis-queue/test-helpers.d.ts.map +1 -1
- package/output/redis-queue/test-helpers.js +9 -23
- package/output/redis-queue/test-helpers.test.d.ts +1 -1
- package/output/redis-queue/test-helpers.test.d.ts.map +1 -1
- package/output/redis-queue/test-helpers.test.js +7 -13
- package/output/redis-queue/types.d.ts +7 -0
- package/output/redis-queue/types.d.ts.map +1 -1
- package/output/schema/index.d.ts +1 -1
- package/output/schema/index.d.ts.map +1 -1
- package/package.json +11 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-queue-consumer.test.d.ts","sourceRoot":"","sources":["../../source/redis-queue/redis-queue-consumer.test.ts"],"names":[],"mappings":"AAQA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"redis-queue-consumer.test.d.ts","sourceRoot":"","sources":["../../source/redis-queue/redis-queue-consumer.test.ts"],"names":[],"mappings":"AAQA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAGD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,kBAAkB;QAC1B,CAAC,GAAG,EAAE,cAAc,MAAM,EAAE,GAAG,YAAY,CAAA;KAC5C;CACF"}
|
|
@@ -139,7 +139,7 @@ describe('RedisQueueConsumer', () => {
|
|
|
139
139
|
}, { maxRetries: 2 });
|
|
140
140
|
await provider.connect();
|
|
141
141
|
await consumer.connect();
|
|
142
|
-
|
|
142
|
+
await provider.enqueue({ test: 1 });
|
|
143
143
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
144
144
|
// 最多 1 次初始 + 2 次重试 = 3 次,但允许恢复机制导致的额外尝试
|
|
145
145
|
expect(attemptCount).toBeGreaterThanOrEqual(3);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RedisQueueCommon } from './redis-queue-common.js';
|
|
2
|
-
import type { RedisQueueRegistry, RedisQueueProviderConfig, Task, QueueStats } from './types.js';
|
|
2
|
+
import type { AnyRegistry, RedisQueueRegistry, RedisQueueProviderConfig, Task, QueueStats } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Redis 队列生产者
|
|
5
5
|
*
|
|
@@ -34,7 +34,7 @@ import type { RedisQueueRegistry, RedisQueueProviderConfig, Task, QueueStats } f
|
|
|
34
34
|
* await provider.enqueue({ orderId: '123', amount: 100 })
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export declare class RedisQueueProvider<R extends
|
|
37
|
+
export declare class RedisQueueProvider<R extends AnyRegistry = RedisQueueRegistry, K extends keyof R & string = keyof R & string> extends RedisQueueCommon {
|
|
38
38
|
private readonly processingDelay;
|
|
39
39
|
constructor(queueKey: K, config?: RedisQueueProviderConfig);
|
|
40
40
|
protected getLogPrefix(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-queue-provider.d.ts","sourceRoot":"","sources":["../../source/redis-queue/redis-queue-provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"redis-queue-provider.d.ts","sourceRoot":"","sources":["../../source/redis-queue/redis-queue-provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,kBAAkB,CAC7B,CAAC,SAAS,WAAW,GAAG,kBAAkB,EAC1C,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAC7C,SAAQ,gBAAgB;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;gBAE5B,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAE,wBAA6B;IAU9D,SAAS,CAAC,YAAY,IAAI,MAAM;IAMhC;;;;;;;;;;;OAWG;IACG,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACxC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA0F1C;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAWzD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC;IAevC;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAmD7B"}
|
|
@@ -63,7 +63,7 @@ export class RedisQueueProvider extends RedisQueueCommon {
|
|
|
63
63
|
// 严格检查 id 类型,只接受 string
|
|
64
64
|
if (customId !== undefined && typeof customId !== 'string') {
|
|
65
65
|
throw new TypeError(`[RedisQueueProvider] Task id must be a string, got ${typeof customId}. ` +
|
|
66
|
-
|
|
66
|
+
'Please use string type for task id field.');
|
|
67
67
|
}
|
|
68
68
|
const taskId = customId || randomUUID();
|
|
69
69
|
const task = {
|
|
@@ -17,9 +17,9 @@ type TestTaskData = {
|
|
|
17
17
|
example?: string;
|
|
18
18
|
foo?: string;
|
|
19
19
|
number?: number;
|
|
20
|
-
data?:
|
|
20
|
+
data?: unknown;
|
|
21
21
|
};
|
|
22
|
-
declare module
|
|
22
|
+
declare module './types.js' {
|
|
23
23
|
interface RedisQueueRegistry {
|
|
24
24
|
[key: `test:provider:${string}`]: TestTaskData;
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-queue-provider.test.d.ts","sourceRoot":"","sources":["../../source/redis-queue/redis-queue-provider.test.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"redis-queue-provider.test.d.ts","sourceRoot":"","sources":["../../source/redis-queue/redis-queue-provider.test.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAGD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,kBAAkB;QAC1B,CAAC,GAAG,EAAE,iBAAiB,MAAM,EAAE,GAAG,YAAY,CAAA;KAC/C;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from
|
|
2
|
-
import { RedisQueueProvider } from
|
|
3
|
-
import { clearQueue, getQueueTasks } from
|
|
4
|
-
const REDIS_URL = process.env.REDIS_URL ||
|
|
5
|
-
describe(
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { RedisQueueProvider } from './redis-queue-provider.js';
|
|
3
|
+
import { clearQueue, getQueueTasks } from './test-helpers.js';
|
|
4
|
+
const REDIS_URL = process.env.REDIS_URL || 'redis://localhost:6379';
|
|
5
|
+
describe('RedisQueueProvider', () => {
|
|
6
6
|
const providers = [];
|
|
7
7
|
afterEach(async () => {
|
|
8
8
|
for (const provider of providers) {
|
|
@@ -20,24 +20,24 @@ describe("RedisQueueProvider", () => {
|
|
|
20
20
|
providers.push(provider);
|
|
21
21
|
return provider;
|
|
22
22
|
};
|
|
23
|
-
describe(
|
|
24
|
-
it(
|
|
23
|
+
describe('连接管理', () => {
|
|
24
|
+
it('应该成功连接到 Redis', async () => {
|
|
25
25
|
const provider = createProvider();
|
|
26
26
|
await provider.connect();
|
|
27
27
|
const health = await provider.health();
|
|
28
28
|
expect(health).toBe(true);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
|
-
describe(
|
|
32
|
-
it(
|
|
31
|
+
describe('任务入队', () => {
|
|
32
|
+
it('应该成功将任务推入队列', async () => {
|
|
33
33
|
const provider = createProvider();
|
|
34
34
|
await provider.connect();
|
|
35
|
-
const taskId = await provider.enqueue({ foo:
|
|
35
|
+
const taskId = await provider.enqueue({ foo: 'bar' });
|
|
36
36
|
expect(taskId).toBeTruthy();
|
|
37
37
|
const stats = await provider.statistics();
|
|
38
38
|
expect(stats.pending).toBe(1);
|
|
39
39
|
});
|
|
40
|
-
it(
|
|
40
|
+
it('应该能够批量入队任务', async () => {
|
|
41
41
|
const provider = createProvider();
|
|
42
42
|
await provider.connect();
|
|
43
43
|
const taskIds = await provider.enqueue([
|
|
@@ -49,30 +49,30 @@ describe("RedisQueueProvider", () => {
|
|
|
49
49
|
const stats = await provider.statistics();
|
|
50
50
|
expect(stats.pending).toBe(3);
|
|
51
51
|
});
|
|
52
|
-
it(
|
|
52
|
+
it('入队的任务应该包含正确的元数据', async () => {
|
|
53
53
|
const provider = createProvider();
|
|
54
54
|
await provider.connect();
|
|
55
|
-
const taskId = await provider.enqueue({ test:
|
|
55
|
+
const taskId = await provider.enqueue({ test: 'data', number: 42 });
|
|
56
56
|
const task = await provider.getTask(taskId);
|
|
57
57
|
expect(task).toBeTruthy();
|
|
58
58
|
expect(task?.id).toBe(taskId);
|
|
59
|
-
expect(task?.data).toEqual({ test:
|
|
60
|
-
expect(task?.status).toBe(
|
|
59
|
+
expect(task?.data).toEqual({ test: 'data', number: 42 });
|
|
60
|
+
expect(task?.status).toBe('pending');
|
|
61
61
|
expect(task?.retryCount).toBe(0);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
-
describe(
|
|
65
|
-
it(
|
|
64
|
+
describe('队列操作', () => {
|
|
65
|
+
it('应该正确返回队列统计信息', async () => {
|
|
66
66
|
const provider = createProvider();
|
|
67
67
|
await provider.connect();
|
|
68
|
-
await provider.enqueue([{ test:
|
|
68
|
+
await provider.enqueue([{ test: '1' }, { test: '2' }, { test: '3' }]);
|
|
69
69
|
const stats = await provider.statistics();
|
|
70
70
|
expect(stats.pending).toBe(3);
|
|
71
71
|
expect(stats.processing).toBe(0);
|
|
72
72
|
expect(stats.completed).toBe(0);
|
|
73
73
|
expect(stats.failed).toBe(0);
|
|
74
74
|
});
|
|
75
|
-
it(
|
|
75
|
+
it('应该能够清空队列', async () => {
|
|
76
76
|
const provider = createProvider();
|
|
77
77
|
await provider.connect();
|
|
78
78
|
await provider.enqueue([{ data: 1 }, { data: 2 }]);
|
|
@@ -80,64 +80,64 @@ describe("RedisQueueProvider", () => {
|
|
|
80
80
|
const stats = await provider.statistics();
|
|
81
81
|
expect(stats.pending).toBe(0);
|
|
82
82
|
});
|
|
83
|
-
it(
|
|
83
|
+
it('应该能够使用 getQueueTasks 获取特定状态的任务', async () => {
|
|
84
84
|
const provider = createProvider();
|
|
85
85
|
await provider.connect();
|
|
86
86
|
await provider.enqueue([
|
|
87
|
-
{ name:
|
|
88
|
-
{ name:
|
|
89
|
-
{ name:
|
|
87
|
+
{ name: 'task1' },
|
|
88
|
+
{ name: 'task2' },
|
|
89
|
+
{ name: 'task3' },
|
|
90
90
|
]);
|
|
91
|
-
const pendingTasks = await getQueueTasks(provider,
|
|
91
|
+
const pendingTasks = await getQueueTasks(provider, 'pending');
|
|
92
92
|
expect(pendingTasks).toHaveLength(3);
|
|
93
|
-
expect(pendingTasks.every(t => t.status ===
|
|
93
|
+
expect(pendingTasks.every(t => t.status === 'pending')).toBe(true);
|
|
94
94
|
// 验证任务数据
|
|
95
95
|
const taskNames = pendingTasks.map(t => t.data.name);
|
|
96
|
-
expect(taskNames).toContain(
|
|
97
|
-
expect(taskNames).toContain(
|
|
98
|
-
expect(taskNames).toContain(
|
|
96
|
+
expect(taskNames).toContain('task1');
|
|
97
|
+
expect(taskNames).toContain('task2');
|
|
98
|
+
expect(taskNames).toContain('task3');
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
|
-
describe(
|
|
102
|
-
it(
|
|
101
|
+
describe('幂等性', () => {
|
|
102
|
+
it('应该支持在 data 中指定 id 来实现幂等性', async () => {
|
|
103
103
|
const provider = createProvider();
|
|
104
104
|
await provider.connect();
|
|
105
|
-
await provider.enqueue({ id:
|
|
106
|
-
await provider.enqueue({ id:
|
|
107
|
-
await provider.enqueue({ id:
|
|
105
|
+
await provider.enqueue({ id: 'unique-1', value: 1 });
|
|
106
|
+
await provider.enqueue({ id: 'unique-1', value: 2 });
|
|
107
|
+
await provider.enqueue({ id: 'unique-2', value: 3 });
|
|
108
108
|
const stats = await provider.statistics();
|
|
109
109
|
expect(stats.pending).toBe(2); // 只有 unique-1 和 unique-2
|
|
110
110
|
});
|
|
111
|
-
it(
|
|
111
|
+
it('应该拒绝非 string 类型的 id 并抛出 TypeError', async () => {
|
|
112
112
|
const provider = createProvider();
|
|
113
113
|
await provider.connect();
|
|
114
114
|
// 尝试传入数字类型的 id,应该抛出 TypeError
|
|
115
115
|
await expect(async () => {
|
|
116
|
-
await provider.enqueue({ id: 123, value:
|
|
116
|
+
await provider.enqueue({ id: 123, value: 'test' });
|
|
117
117
|
}).rejects.toThrow(TypeError);
|
|
118
118
|
await expect(async () => {
|
|
119
|
-
await provider.enqueue({ id: 123, value:
|
|
119
|
+
await provider.enqueue({ id: 123, value: 'test' });
|
|
120
120
|
}).rejects.toThrow(/must be a string/);
|
|
121
121
|
// 尝试传入布尔类型的 id,应该抛出 TypeError
|
|
122
122
|
await expect(async () => {
|
|
123
|
-
await provider.enqueue({ id: true, value:
|
|
123
|
+
await provider.enqueue({ id: true, value: 'test' });
|
|
124
124
|
}).rejects.toThrow(TypeError);
|
|
125
125
|
// 尝试传入对象类型的 id,应该抛出 TypeError
|
|
126
126
|
await expect(async () => {
|
|
127
127
|
await provider.enqueue({
|
|
128
|
-
id: { nested:
|
|
129
|
-
value:
|
|
128
|
+
id: { nested: 'value' },
|
|
129
|
+
value: 'test',
|
|
130
130
|
});
|
|
131
131
|
}).rejects.toThrow(TypeError);
|
|
132
132
|
// 字符串类型的 id 应该正常工作
|
|
133
|
-
await expect(provider.enqueue({ id:
|
|
133
|
+
await expect(provider.enqueue({ id: '123', value: 'test' })).resolves.not.toThrow();
|
|
134
134
|
// 验证只有字符串 ID 的任务被入队
|
|
135
135
|
const stats = await provider.statistics();
|
|
136
136
|
expect(stats.pending).toBe(1);
|
|
137
137
|
});
|
|
138
138
|
});
|
|
139
|
-
describe(
|
|
140
|
-
it(
|
|
139
|
+
describe('延迟处理', () => {
|
|
140
|
+
it('应该支持延迟入队任务', async () => {
|
|
141
141
|
const provider = createProvider({ processingDelay: 2000 });
|
|
142
142
|
await provider.connect();
|
|
143
143
|
const taskId = (await provider.enqueue({ test: true }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { RedisQueueBatchConsumer } from './redis-queue-batch-consumer.js';
|
|
2
1
|
import { RedisQueueConsumer } from './redis-queue-consumer.js';
|
|
2
|
+
import type { RedisQueueBatchConsumer } from './redis-queue-batch-consumer.js';
|
|
3
3
|
import type { RedisQueueProvider } from './redis-queue-provider.js';
|
|
4
|
-
import type { RedisQueueRegistry, Task } from './types.js';
|
|
4
|
+
import type { AnyRegistry, QueueStats, RedisQueueRegistry, Task } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* 测试辅助函数:立即派发任务到消费者
|
|
7
7
|
*
|
|
@@ -38,7 +38,12 @@ import type { RedisQueueRegistry, Task } from './types.js';
|
|
|
38
38
|
* })
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export declare function dispatchQueueTask<R extends
|
|
41
|
+
export declare function dispatchQueueTask<R extends AnyRegistry = RedisQueueRegistry, K extends keyof R & string = keyof R & string>(consumer: RedisQueueConsumer<R, K> | RedisQueueBatchConsumer<R, K>, taskIds: string[]): Promise<void>;
|
|
42
|
+
/** `waitQueueCompletion` 的配置项 */
|
|
43
|
+
export interface WaitQueueCompletionOptions {
|
|
44
|
+
timeout?: number;
|
|
45
|
+
interval?: number;
|
|
46
|
+
}
|
|
42
47
|
/**
|
|
43
48
|
* 测试辅助函数:等待队列达到指定状态
|
|
44
49
|
*
|
|
@@ -56,15 +61,7 @@ export declare function dispatchQueueTask<R extends Record<string, any> = RedisQ
|
|
|
56
61
|
* await waitQueueCompletion(provider, stats => stats.completed >= 10, { timeout: 5000 })
|
|
57
62
|
* ```
|
|
58
63
|
*/
|
|
59
|
-
export declare function waitQueueCompletion<R extends
|
|
60
|
-
pending: number;
|
|
61
|
-
processing: number;
|
|
62
|
-
completed: number;
|
|
63
|
-
failed: number;
|
|
64
|
-
}) => boolean, options?: {
|
|
65
|
-
timeout?: number;
|
|
66
|
-
interval?: number;
|
|
67
|
-
}): Promise<void>;
|
|
64
|
+
export declare function waitQueueCompletion<R extends AnyRegistry = RedisQueueRegistry, K extends keyof R & string = keyof R & string>(instance: RedisQueueProvider<R, K> | RedisQueueConsumer<R, K> | RedisQueueBatchConsumer<R, K>, predicate: (stats: QueueStats) => boolean, options?: WaitQueueCompletionOptions): Promise<void>;
|
|
68
65
|
/**
|
|
69
66
|
* 测试辅助函数:清空队列所有状态
|
|
70
67
|
*
|
|
@@ -88,7 +85,7 @@ export declare function waitQueueCompletion<R extends Record<string, any> = Redi
|
|
|
88
85
|
* })
|
|
89
86
|
* ```
|
|
90
87
|
*/
|
|
91
|
-
export declare function clearQueue<R extends
|
|
88
|
+
export declare function clearQueue<R extends AnyRegistry = RedisQueueRegistry, K extends keyof R & string = keyof R & string>(instance: RedisQueueProvider<R, K> | RedisQueueConsumer<R, K> | RedisQueueBatchConsumer<R, K>): Promise<void>;
|
|
92
89
|
/**
|
|
93
90
|
* 测试辅助函数:获取队列中的所有任务详情
|
|
94
91
|
*
|
|
@@ -108,5 +105,5 @@ export declare function clearQueue<R extends Record<string, any> = RedisQueueReg
|
|
|
108
105
|
* expect(failedTasks[0].data).toMatchObject({ id: 123 })
|
|
109
106
|
* ```
|
|
110
107
|
*/
|
|
111
|
-
export declare function getQueueTasks<R extends
|
|
108
|
+
export declare function getQueueTasks<R extends AnyRegistry = RedisQueueRegistry, K extends keyof R & string = keyof R & string>(provider: RedisQueueProvider<R, K>, status?: 'pending' | 'processing' | 'completed' | 'failed'): Promise<Task<R[K]>[]>;
|
|
112
109
|
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../source/redis-queue/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../source/redis-queue/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAC9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAoCnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,kBAAkB,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAgCpP"}
|
|
@@ -39,14 +39,9 @@ export async function dispatchQueueTask(consumer, taskIds) {
|
|
|
39
39
|
if (taskIds.length === 0) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const queueKey = consumer.queueKey;
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
const pendingQueue = consumer.pendingQueue;
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
const processingQueue = consumer.processingQueue;
|
|
42
|
+
// 访问 protected 成员用于测试:通过结构化类型断言,避免 @ts-ignore
|
|
43
|
+
const internals = consumer;
|
|
44
|
+
const { redis, pendingQueue, processingQueue } = internals;
|
|
50
45
|
if (!redis || !redis.isOpen) {
|
|
51
46
|
throw new Error('Redis client is not connected');
|
|
52
47
|
}
|
|
@@ -71,7 +66,7 @@ export async function dispatchQueueTask(consumer, taskIds) {
|
|
|
71
66
|
`;
|
|
72
67
|
// 持续处理直到所有任务完成或失败
|
|
73
68
|
let remainingTasks = [...taskIds];
|
|
74
|
-
|
|
69
|
+
const maxAttempts = 100; // 防止无限循环
|
|
75
70
|
let attempts = 0;
|
|
76
71
|
while (remainingTasks.length > 0 && attempts < maxAttempts) {
|
|
77
72
|
attempts++;
|
|
@@ -83,26 +78,22 @@ export async function dispatchQueueTask(consumer, taskIds) {
|
|
|
83
78
|
// 处理任务
|
|
84
79
|
if (consumer instanceof RedisQueueConsumer) {
|
|
85
80
|
// RedisQueueConsumer: 逐个处理任务
|
|
86
|
-
const promises = remainingTasks.map(taskId =>
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
consumer.processTask(taskId).catch(() => {
|
|
81
|
+
const promises = remainingTasks.map(taskId => internals.processTask(taskId).catch(() => {
|
|
89
82
|
// 忽略错误,让 consumer 内部处理
|
|
90
83
|
}));
|
|
91
84
|
await Promise.all(promises);
|
|
92
85
|
}
|
|
93
86
|
else {
|
|
94
87
|
// RedisQueueBatchConsumer: 按照 consumer 的 batchSize 分批处理任务
|
|
95
|
-
// @ts-ignore
|
|
96
88
|
const batchConsumer = consumer;
|
|
97
89
|
const batchSize = batchConsumer.config?.batchSize || 10;
|
|
98
90
|
// 分批处理任务
|
|
99
91
|
for (let i = 0; i < remainingTasks.length; i += batchSize) {
|
|
100
92
|
const batch = remainingTasks.slice(i, i + batchSize);
|
|
101
93
|
try {
|
|
102
|
-
// @ts-ignore
|
|
103
94
|
await batchConsumer.processBatch(batch);
|
|
104
95
|
}
|
|
105
|
-
catch
|
|
96
|
+
catch {
|
|
106
97
|
// 批次处理失败是正常的,consumer 会处理重试逻辑
|
|
107
98
|
}
|
|
108
99
|
}
|
|
@@ -112,8 +103,7 @@ export async function dispatchQueueTask(consumer, taskIds) {
|
|
|
112
103
|
// 检查还有哪些任务在 pending 队列中(需要重试)
|
|
113
104
|
const stillPending = [];
|
|
114
105
|
for (const taskId of remainingTasks) {
|
|
115
|
-
|
|
116
|
-
const task = await consumer.getTask(taskId);
|
|
106
|
+
const task = await internals.getTask(taskId);
|
|
117
107
|
if (task && task.status === 'pending') {
|
|
118
108
|
stillPending.push(taskId);
|
|
119
109
|
}
|
|
@@ -177,8 +167,7 @@ export async function waitQueueCompletion(instance, predicate, options = {}) {
|
|
|
177
167
|
*/
|
|
178
168
|
export async function clearQueue(instance) {
|
|
179
169
|
// 访问 protected 属性需要类型断言
|
|
180
|
-
const redis = instance
|
|
181
|
-
const queueKey = instance.queueKey;
|
|
170
|
+
const { redis, queueKey } = instance;
|
|
182
171
|
if (!redis || !redis.isOpen) {
|
|
183
172
|
return;
|
|
184
173
|
}
|
|
@@ -208,10 +197,7 @@ export async function clearQueue(instance) {
|
|
|
208
197
|
* ```
|
|
209
198
|
*/
|
|
210
199
|
export async function getQueueTasks(provider, status) {
|
|
211
|
-
|
|
212
|
-
const redis = provider.redis;
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
const queueKey = provider.queueKey;
|
|
200
|
+
const { redis, queueKey } = provider;
|
|
215
201
|
if (!redis || !redis.isOpen) {
|
|
216
202
|
return [];
|
|
217
203
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.test.d.ts","sourceRoot":"","sources":["../../source/redis-queue/test-helpers.test.ts"],"names":[],"mappings":"AAcA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"test-helpers.test.d.ts","sourceRoot":"","sources":["../../source/redis-queue/test-helpers.test.ts"],"names":[],"mappings":"AAcA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAGD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,kBAAkB;QAC1B,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,YAAY,CAAA;KACtC;CACF"}
|
|
@@ -12,10 +12,6 @@ const REDIS_URL = process.env.REDIS_URL || 'redis://localhost:6379';
|
|
|
12
12
|
*/
|
|
13
13
|
describe('Redis Queue Test Helpers', () => {
|
|
14
14
|
// 每次运行使用唯一的队列名,避免测试间干扰
|
|
15
|
-
let testQueueKey;
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
testQueueKey = `test:helpers:${Date.now()}:${Math.random().toString(36).slice(2, 9)}`;
|
|
18
|
-
});
|
|
19
15
|
describe('RedisQueueConsumer.dispatch', () => {
|
|
20
16
|
let provider;
|
|
21
17
|
let consumer;
|
|
@@ -172,11 +168,9 @@ describe('Redis Queue Test Helpers', () => {
|
|
|
172
168
|
expect(stats.completed).toBe(100);
|
|
173
169
|
});
|
|
174
170
|
it('应该处理批量任务失败', async () => {
|
|
175
|
-
let attemptCount = 0;
|
|
176
171
|
const failingConsumer = new RedisQueueBatchConsumer(queueKey, { redisUrl: REDIS_URL, batchSize: 2,
|
|
177
172
|
maxRetries: 0, // 不重试
|
|
178
|
-
handler: async (
|
|
179
|
-
attemptCount++;
|
|
173
|
+
handler: async () => {
|
|
180
174
|
throw new Error('Batch processing failed');
|
|
181
175
|
},
|
|
182
176
|
});
|
|
@@ -232,7 +226,7 @@ describe('Redis Queue Test Helpers', () => {
|
|
|
232
226
|
beforeEach(async () => {
|
|
233
227
|
const queueKey = `test:wait:${Date.now()}:${Math.random().toString(36).slice(2, 9)}`;
|
|
234
228
|
provider = new RedisQueueProvider(queueKey, { redisUrl: REDIS_URL });
|
|
235
|
-
consumer = new RedisQueueConsumer(queueKey, { redisUrl: REDIS_URL, handler: async (
|
|
229
|
+
consumer = new RedisQueueConsumer(queueKey, { redisUrl: REDIS_URL, handler: async () => catchIt(() => { }),
|
|
236
230
|
});
|
|
237
231
|
await provider.connect();
|
|
238
232
|
await consumer.connect();
|
|
@@ -244,11 +238,11 @@ describe('Redis Queue Test Helpers', () => {
|
|
|
244
238
|
});
|
|
245
239
|
it('应该等待队列完成所有任务', async () => {
|
|
246
240
|
// 添加任务
|
|
247
|
-
|
|
241
|
+
await provider.enqueue([
|
|
248
242
|
{ id: '1' },
|
|
249
243
|
{ id: '2' },
|
|
250
244
|
{ id: '3' },
|
|
251
|
-
])
|
|
245
|
+
]);
|
|
252
246
|
// consumer.connect() 已经启动了轮询,等待所有任务完成
|
|
253
247
|
await waitQueueCompletion(consumer, stats => stats.pending === 0 && stats.processing === 0 && stats.completed === 3);
|
|
254
248
|
const stats = await consumer.statistics();
|
|
@@ -262,10 +256,10 @@ describe('Redis Queue Test Helpers', () => {
|
|
|
262
256
|
await expect(waitQueueCompletion(consumer, stats => stats.completed === 1, { timeout: 100, interval: 10 })).rejects.toThrow(/timeout/);
|
|
263
257
|
});
|
|
264
258
|
it('应该支持自定义检查间隔', async () => {
|
|
265
|
-
|
|
259
|
+
await provider.enqueue([
|
|
266
260
|
{ id: '1' },
|
|
267
261
|
{ id: '2' },
|
|
268
|
-
])
|
|
262
|
+
]);
|
|
269
263
|
const startTime = Date.now();
|
|
270
264
|
// 使用较长的检查间隔
|
|
271
265
|
await waitQueueCompletion(consumer, stats => stats.completed === 2, { interval: 500 });
|
|
@@ -287,7 +281,7 @@ describe('Redis Queue Test Helpers', () => {
|
|
|
287
281
|
beforeEach(async () => {
|
|
288
282
|
const queueKey = `test:clear:${Date.now()}:${Math.random().toString(36).slice(2, 9)}`;
|
|
289
283
|
provider = new RedisQueueProvider(queueKey, { redisUrl: REDIS_URL });
|
|
290
|
-
consumer = new RedisQueueConsumer(queueKey, { redisUrl: REDIS_URL, handler: async (
|
|
284
|
+
consumer = new RedisQueueConsumer(queueKey, { redisUrl: REDIS_URL, handler: async () => catchIt(() => { }),
|
|
291
285
|
});
|
|
292
286
|
await provider.connect();
|
|
293
287
|
await consumer.connect();
|
|
@@ -62,6 +62,13 @@ export interface RedisQueueRegistry {
|
|
|
62
62
|
* 任务状态
|
|
63
63
|
*/
|
|
64
64
|
export type Status = 'pending' | 'processing' | 'completed' | 'failed';
|
|
65
|
+
/**
|
|
66
|
+
* Registry 泛型约束:接受任意以字符串为键的对象类型(含 interface / declare module 扩展)。
|
|
67
|
+
*
|
|
68
|
+
* 这里必须用 `any`:`Record<string, unknown>` 会拒绝没有显式索引签名的 interface,
|
|
69
|
+
* 而注册表正是通过 interface / declare module 扩展的,改成 unknown 属破坏性变更。
|
|
70
|
+
*/
|
|
71
|
+
export type AnyRegistry = Record<string, any>;
|
|
65
72
|
/**
|
|
66
73
|
* 任务数据类型,支持可选的 id 字段用于幂等性
|
|
67
74
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../source/redis-queue/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,MAAM,WAAW,kBAAkB;CAElC;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,YAAY,GAA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AE,MAAM,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA"}
|
package/output/schema/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA2B5C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;;;;kBAMlF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC;;;kBAKxD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,kCAE/B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC;;;kBAKvD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;;;;;;;;;;kBAMvF;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,CAAC;;;mBAK7D;AAED;;;;;;GAMG;AACH,wBAAg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6
6
|
"description": "",
|
|
@@ -27,19 +27,27 @@
|
|
|
27
27
|
"fastify": "^5.5.0",
|
|
28
28
|
"redis": "^5.11.0",
|
|
29
29
|
"zod": "^4.1.0",
|
|
30
|
-
"@taicode/common-base": "^3.7.
|
|
30
|
+
"@taicode/common-base": "^3.7.13"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@eslint/js": "^9.39.3",
|
|
33
34
|
"@types/node": "^22.19.13",
|
|
35
|
+
"@yinxulai/eslint-plugin-peculiar": "^1.0.6",
|
|
36
|
+
"eslint": "^9.39.3",
|
|
37
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
38
|
+
"eslint-plugin-import": "^2.32.0",
|
|
34
39
|
"fastify": "^5.7.4",
|
|
40
|
+
"globals": "^16.5.0",
|
|
35
41
|
"redis": "^5.11.0",
|
|
42
|
+
"typescript-eslint": "^8.56.1",
|
|
36
43
|
"vitest": "^3.2.4",
|
|
37
44
|
"zod": "^4.3.6",
|
|
38
|
-
"@taicode/common-base": "^3.7.
|
|
45
|
+
"@taicode/common-base": "^3.7.13"
|
|
39
46
|
},
|
|
40
47
|
"scripts": {
|
|
41
48
|
"test": "vitest run",
|
|
42
49
|
"test:ci": "vitest run",
|
|
50
|
+
"lint": "eslint && tsc --noEmit",
|
|
43
51
|
"typecheck": "tsc --noEmit",
|
|
44
52
|
"build": "tsc -p tsconfig.json",
|
|
45
53
|
"dev": "tsc -p tsconfig.json --watch"
|