Skip to content

feat(client): 0.9.x — Platform readiness & API stabilization - #70

Open
romanindev wants to merge 9 commits into
mainfrom
feature/0.9.x-api-stabilization
Open

feat(client): 0.9.x — Platform readiness & API stabilization #70
romanindev wants to merge 9 commits into
mainfrom
feature/0.9.x-api-stabilization

Conversation

@romanindev

Copy link
Copy Markdown
Contributor

Implements all of the 0.9.x — Platform readiness & API stabilization roadmap items for @dfsync/client. Every change is additive and backward compatible (no breaking changes in the public API). Version bump is handled by Changesets after merge.

Changes (one logical commit each, with a changeset)

Feature Description
operationName Optional, metadata-only request label surfaced in all lifecycle hooks
Extended error metadata requestId / attempt / durationMs on every DfsyncError (constructors unchanged)
Improved retry model retry.maxElapsedMs (budget), retry.jitter (full jitter, off by default), retry.shouldRetry (predicate that can only restrict)
Serializer / parser serializeBody and parseResponse at client/request level; default JSON preserved
Validation API responseSchema safeParse-style adapter contract + ValidationError.issues; explicit precedence over validateResponse
Zod adapter @dfsync/client/adapters/zod subpath export; zod optional peer, zero runtime dep in core
Extension interfaces AuthProvider, TelemetryExporter + createTelemetryHooks; ValidationAdapter / RetryPredicate formalized
Docs Use-case oriented README navigation + pointer to the docs site

Backward compatibility

  • All new options/fields are optional; defaults unchanged (jitter off, no budget, JSON serialization, existing Retry-After and validation semantics preserved).
  • Error constructors are unchanged; DfsyncError is never wrapped in a generic Error.
  • Validation still runs only after successful responses and is never retried.
  • RequestAbortedError kept as-is (roadmap listed AbortError; renaming would be breaking).

romanindev and others added 9 commits July 29, 2026 13:00
Expose an optional, metadata-only operationName in the request context and
all lifecycle hooks for logging, tracing, and telemetry. Field is optional
and omitted from hook contexts when not provided, preserving backward
compatibility.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Enrich every DfsyncError thrown from the request lifecycle with optional
requestId, attempt, and durationMs fields via a dedicated attachErrorContext
helper, called after finalizeExecution and before onError hooks. Error
constructors are left unchanged and the fields are optional, preserving
backward compatibility. Response details remain available on HttpError and
ValidationError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…itions

Add three opt-in retry controls, all backward compatible:

- retry.maxElapsedMs: overall retry budget; stops retrying when the next
  delay would exceed it instead of waiting.
- retry.jitter: full jitter on backoff delays (never on Retry-After).
- retry.shouldRetry: predicate consulted only after built-in rules allow a
  retry, so it can restrict but never widen retries.

Introduces ResolvedRetryConfig for the merged runtime shape and a local
failWithError helper to centralize the terminal error path. Defaults and
existing Retry-After semantics are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add optional serializeBody(body, ctx) and parseResponse(response, ctx) hooks
at client and request level. serializeBody produces a fetch body and an
optional content-type (applied only when the caller has not set one).
parseResponse runs for every response before classification and validation,
so HttpError.data and validateResponse both see the parsed value. Default
JSON behavior is preserved when neither is configured.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Introduce a safeParse-style ValidationAdapter and a responseSchema option at
client and request level. On failure the client throws ValidationError and
surfaces adapter details on the new optional ValidationError.issues field.
Precedence is explicit via resolveResponseValidator: request-level beats
client-level, and within a level responseSchema beats validateResponse.
Validation still runs only after successful responses and is never retried;
the original parsed data is returned (no transformation in this version).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ship zodAdapter(schema) from @dfsync/client/adapters/zod as a lightweight
responseSchema wrapper. zod is an optional peer dependency; the adapter is
typed structurally against safeParse so it adds no runtime dependency to the
core and works across zod versions. Adds a second tsup entry and the exports
map entry for the subpath.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Formalize the auth provider contract as AuthProvider and export AuthContext.
Add a TelemetryExporter interface plus createTelemetryHooks(exporter), which
maps an exporter onto a standard HooksConfig so telemetry reuses the existing
hook mechanism without a new runtime path. Combined with the already-exported
ValidationAdapter and RetryPredicate, this is the minimal, version-stable
extension surface. Additive and backward compatible.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a concise Documentation section grouping guides by use case (reliable
requests, validation & data shape, observability & tracing, extensibility)
and a prominent pointer to the full documentation site. Existing content is
unchanged; the full in-depth docs live on the site.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update ROADMAP.md 0.9.x section to completed/Delivered (reflecting the
shipped RequestAbortedError) and update packages/client/CLAUDE.md current
focus to 1.0.x with a summary of delivered 0.9.x work.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant