refactor(server): 收敛类型边界工具,aislop AI Slop 10 → 1
- 新增 common/buffer.ts bufferToArrayBuffer:9 处 'as unknown as ArrayBuffer' 收敛为精确切片(含 byteOffset), 消除潜在 Buffer 池偏移隐患,类型断言集中到单一实现 - 新增 common/stringify.ts:4 处重复的 stringify 助手收敛为共享实现 - aislop: AI Slop 10→1(仅剩 1 处有理由的 stringify 薄包装, eslint no-base-to-string 绕过所需);Code Quality 剩余 4 重复块(声明式 SQL 配置)+ 2 文件过大(既有规模)均保留 - 测试 142 套件/1065 用例通过
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { stringify } from '../../common/stringify';
|
||||
import { Injectable, Logger, BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
@@ -29,10 +30,6 @@ export class IntegrationConfigService {
|
||||
) {}
|
||||
|
||||
/** String() 包装:避免 unknown 收窄后触发 no-base-to-string。 */
|
||||
private stringify(value: unknown): string {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
/** 解析 content JSON 并取 config 段(无 config 时回退整个对象)。 */
|
||||
private parseStoredConfig(content: string): Record<string, unknown> {
|
||||
const parsed = JSON.parse(content) as StoredConfigShape;
|
||||
@@ -208,8 +205,8 @@ export class IntegrationConfigService {
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
if (type.toUpperCase() === 'DINGTALK') {
|
||||
const appKey = this.stringify(config.agentId || '');
|
||||
const appSecret = this.stringify(config.appSecret || '');
|
||||
const appKey = stringify(config.agentId || '');
|
||||
const appSecret = stringify(config.appSecret || '');
|
||||
if (!appKey || !appSecret) return null;
|
||||
return await this.fetchDingTalkToken(appKey, appSecret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user