shared: - Add class-filter, error-state, route-error, section-error-boundary, widget-boundary components - Add ui/alert component - Add constants directory - Add breached-password, export-utils, permission-bitmap, rate-limit, resolve-action-error, route-permissions, route-resolver, type-guards lib - Add i18n messages (en, zh-CN) for invitation-codes, parent, questions, rbac tests: - Add integration tests for elective - Add tests/setup/empty-stub scripts: - Add update-md.cjs, tmp_append_en.ps1, tmp_merge_en.ps1 utilities
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
/**
|
||
* Upstash SDK 可选依赖类型声明(audit-P1-6)
|
||
*
|
||
* 这两个包通过动态 import 在运行时加载,仅在 `RATE_LIMIT_DRIVER=redis`
|
||
* 时才需要安装。默认内存模式下无需安装。
|
||
*
|
||
* 安装命令:
|
||
* npm install @upstash/ratelimit @upstash/redis
|
||
*
|
||
* 安装后这两个包自带的类型声明将覆盖此处的 any 声明,
|
||
* 提供完整的类型检查。
|
||
*/
|
||
|
||
declare module "@upstash/ratelimit" {
|
||
export class Ratelimit {
|
||
constructor(config: {
|
||
redis: any
|
||
limiter: any
|
||
analytics?: boolean
|
||
prefix?: string
|
||
})
|
||
limit(
|
||
identifier: string,
|
||
): Promise<{
|
||
success: boolean
|
||
limit: number
|
||
remaining: number
|
||
reset: number
|
||
pending: Promise<unknown>
|
||
}>
|
||
reset(identifier: string): Promise<void>
|
||
static slidingWindow(
|
||
max: number,
|
||
window: string,
|
||
): { type: "sliding-window"; max: number; window: string }
|
||
static fixedWindow(
|
||
max: number,
|
||
window: string,
|
||
): { type: "fixed-window"; max: number; window: string }
|
||
static tokenBucket(
|
||
max: number,
|
||
window: string,
|
||
refillRate: number,
|
||
): { type: "token-bucket"; max: number; window: string; refillRate: number }
|
||
}
|
||
}
|
||
|
||
declare module "@upstash/redis" {
|
||
export class Redis {
|
||
constructor(config: {
|
||
url: string
|
||
token: string
|
||
automaticDeserialization?: boolean
|
||
responseEncoding?: "base64" | "none"
|
||
retry?: {
|
||
retries: number
|
||
backoff: (retryCount: number) => number
|
||
}
|
||
})
|
||
get(key: string): Promise<string | null>
|
||
set(key: string, value: string): Promise<"OK">
|
||
del(...keys: string[]): Promise<number>
|
||
incr(key: string): Promise<number>
|
||
expire(key: string, seconds: number): Promise<number>
|
||
pexpire(key: string, milliseconds: number): Promise<number>
|
||
[key: string]: any
|
||
}
|
||
}
|