Public API¶
Client¶
| Method | Usage | Notes |
|---|---|---|
get<T>(path, options?) |
Typed read. | Compatible with cache and query options. |
post<T>(path, options?) |
Creation or command. | Use json and idempotencyKey when the operation can be replayed. |
put<T>(path, options?) |
Replacement. | Prefer If-Match when the backend supports optimistic locking. |
patch<T>(path, options?) |
Partial update. | Minimal payload and runtime schema for critical payloads. |
delete<T>(path, options?) |
Deletion. | Be careful with automatic retries without idempotency. |
Parsers¶
| Parser | Usage | Notes |
|---|---|---|
createApiParserRestClassic |
Classic REST envelope. | Adapts data, message, and errors. |
createApiParserLaravel |
Laravel validation errors. | Normalizes issues and messages. |
createApiParserNest |
NestJS responses and exceptions. | Good choice for TypeScript backends. |
createApiParserGraphQL |
data/errors payload. |
allowPartialData keeps a partial response. |
createApiParserStructured |
Envelopes with metadata. | Exposes category, severity, retryable, i18n, traceId, and spanId. |
createShapeParser |
Proprietary envelopes. | Prefer it when no preset matches the backend. |
Guards¶
| Guard | Usage | Notes |
|---|---|---|
retryGuard |
Configurable retry. | Restrict it to transient errors and document exclusions. |
bearerRefreshGuard |
Bearer token single-flight refresh. | Protects concurrent 401 responses. |
cookieSafeRefreshGuard |
Cookie session refresh. | Single-flight, 429 cooldown, anti-loop. |
csrfGuard |
CSRF token on mutations. | Reads cookie, storage, or header. |
correlationIdGuard |
Request/response correlation id. | Feeds logger, Sentry, and OTel. |
idempotencyGuard |
Idempotency header on mutations. | Preserves an existing key. |
unauthorizedGuard |
Central hook for 401/403. | Logout, redirect, or session invalidation. |
instrumentGuard |
Custom measurement and instrumentation. | Wraps timing or internal reporting. |