PgAuditSink — @gj-kit/toss-payments-postgresql
A public interface from @gj-kit/toss-payments-postgresql. The signature below is taken directly from the 0.5.1 release declaration.
Verified import example
Section titled “Verified import example”import { PgAuditSink } from '@gj-kit/toss-payments-postgresql';Signature, parameters, and return type
Section titled “Signature, parameters, and return type”/** * AuditSink PostgreSQL 구현 (설계 §3.6). * * 코어 계약의 핵심 불변식(core/audit.ts TSDoc): * - `record()`는 코어가 **await하지 않는다**(fire-and-forget) — audit 오류가 결제 * 경로의 지연·실패에 영향을 주지 않는다. insert 실패는 코어 * `AuditOptions.onSinkError`로만 통지되므로 여기서 추가 통지 채널을 만들지 않는다. * - 동일 id 재호출은 `ON CONFLICT (id) DO NOTHING`으로 멱등 — id는 crypto.randomUUID, * 시도 1건 = 엔트리 1건. * - entry는 코어 redaction 통과본이다(Authorization은 구조적 부재) — 이 스토어는 * 내용을 다시 만지지 않고 통짜 jsonb로 보존한다. * - createFileAuditSink의 다중 프로세스 한계를 대체하는 것이 존재 이유 — 다중 인스턴스 * 동시 insert에 안전하다(PK 충돌만 무시). * * v1은 즉시 INSERT(배치 없음) — 코어가 비동기 fire-and-forget이라 결제 경로 지연이 * 없고, in-flight Set + `flush()`로 graceful shutdown 시 유실을 막는다. *//** flush 가능한 AuditSink — graceful shutdown 훅(예: Nest onApplicationShutdown). */interface PgAuditSink extends AuditSink { /** * 코어 계약(`void | Promise<void>`)의 반환을 `Promise<void>`로 협착 선언한다 — * 이 구현은 항상 Promise를 반환하므로(즉시 INSERT), 소비자가 flush/셧다운 코드에서 * `.catch()`를 바로 걸 수 있게 한다. 반환 공변이라 `AuditSink` 대입성은 유지된다. */ record(entry: AuditEntry): Promise<void>; /** 호출 시점까지 시작된(및 flush 중 새로 시작된) 모든 insert의 정착을 기다린다. 실패는 삼킨다. */ flush(): Promise<void>;}This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.
Release context
Section titled “Release context”- Package:
@gj-kit/toss-payments-postgresql - Version:
0.5.1 - Public entry:
. - Source: GitHub