feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
23
packages/core/src/guards.ts
Normal file
23
packages/core/src/guards.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// packages/core/src/guards.ts
|
||||
// 앱·서버 간 중복되던 순수 런타임 타입 가드 및 LIKE 패턴 이스케이프 정본 (W5-05).
|
||||
// 오류 클래스는 표면마다 다르므로 throw 대신 boolean 판정 함수만 제공한다.
|
||||
|
||||
const RFC_UUID_PATTERN =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
||||
|
||||
export function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
export function isUuid(value: unknown): value is string {
|
||||
return typeof value === 'string' && RFC_UUID_PATTERN.test(value)
|
||||
}
|
||||
|
||||
export function escapeLikePattern(value: string): string {
|
||||
return value.replace(/[\\%_]/g, (character) => `\\${character}`)
|
||||
}
|
||||
|
||||
export function escapePostgrestLikePattern(value: string): string {
|
||||
const escaped = value.replace(/[\\%_*]/g, (character) => `\\${character}`)
|
||||
return `*${escaped}*`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue