Skip to content

feat(fmodata): use Effect.ts internally#141

Merged
eluce2 merged 14 commits intomainfrom
effect-ts
Mar 18, 2026
Merged

feat(fmodata): use Effect.ts internally#141
eluce2 merged 14 commits intomainfrom
effect-ts

Conversation

@eluce2
Copy link
Copy Markdown
Collaborator

@eluce2 eluce2 commented Mar 15, 2026

feat(fmodata): use Effect.ts internally for error handling pipelines

Replace manual error-threading boilerplate in all builders with Effect
pipelines. Effect is used as an internal implementation detail — the
public API (Result) is unchanged.

Changes:

  • Add effect dependency, remove unused neverthrow
  • Add src/effect.ts with bridge utilities (fromResult, makeRequestEffect,
    runAsResult, tryEffect, fromValidation)
  • Refactor _makeRequest into an Effect pipeline with extracted helpers
    (_classifyError, _parseHttpError, _checkEmbeddedODataError)
  • Refactor InsertBuilder.execute() to use Effect.gen pipeline
  • Refactor UpdateBuilder.execute() to use Effect.gen pipeline
  • Refactor DeleteBuilder.execute() to use Effect.gen pipeline
  • Refactor QueryBuilder.execute() to use Effect pipe composition
  • Refactor BatchBuilder.execute() to use Effect.gen pipeline

All 873 tests pass with zero type errors.

https://claude.ai/code/session_01VdwR8FRDc9f1qS68z2Sfzo

feat(fmodata): add retry policies, validation accumulation, and tracing spans

Phase 2 of Effect.ts integration:

  • Add opt-in RetryPolicy for transient errors (SchemaLockedError, NetworkError, TimeoutError, HTTP 5xx)
    with exponential backoff and jitter via Effect Schedule
  • Accumulate all validation errors instead of fail-fast, returning all field issues in a single ValidationError
  • Add Effect.withSpan tracing to all builder execute() methods and HTTP requests for zero-cost observability

All changes remain non-breaking — public API (Result, error classes, type guards) is unchanged.

https://claude.ai/code/session_01VdwR8FRDc9f1qS68z2Sfzo

feat(fmodata): add Effect services, MockFMServerConnection, and migrate tests

Phase 3 of Effect.ts integration:

  • Define Effect Services (HttpClient, ODataConfig, ODataLogger) for dependency injection
  • Create MockFMServerConnection with router-style fetch handler and request spy
  • Export testing utilities via @proofkit/fmodata/testing subpath
  • Migrate 22 test files from createMockClient/fetchHandler to MockFMServerConnection
  • All 870 tests passing, 0 type errors, publint passes

https://claude.ai/code/session_01VdwR8FRDc9f1qS68z2Sfzo

fix(fmodata): limit retries to idempotent HTTP methods

fix(fmodata): address remaining PR review findings

fix(fmodata): harden write requests and batch response handling

refactor(fmodata): migrate all builders to Effect DI via Context/Layer pattern

Replace constructor parameter threading (ExecutionContext, databaseName,
useEntityIds, etc.) with Effect's Context.Tag + Layer pattern across all
builders. Each builder now receives an FMODataLayer and extracts config
synchronously via extractConfigFromLayer() for non-Effect methods.

Key changes:

  • All builders (Query, Record, Insert, Update, Delete, Batch) use layer-based DI
  • SchemaManager and WebhookManager converted to use Effect pipelines
  • Database.getMetadata/listTableNames/runScript use requestFromService
  • Removed deprecated makeRequestEffect() and runWithContext() from effect.ts
  • Simplified ExecutionContext interface to just _getLayer()
  • Removed unused BuilderConfig interface from shared-types.ts
  • createDatabaseLayer() enables database-scoped config overrides

https://claude.ai/code/session_01EpwtyTQeyjVu3Qykf6aMBd

fix(fmodata): resolve DI branch lint regressions

Summary by CodeRabbit

  • New Features

    • Route-based testing utilities with request spying and included testing entry in the build
    • New RetryPolicy type and exported isTransientError helper
  • Improvements

    • Layered, effect-driven request pipeline with improved error classification and retry support
    • Centralized runtime/configuration for entity-id and special-column handling; expanded service/type exports
  • Tests

    • Test suites migrated to use the new mock server and spy-driven patterns

Loading
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.

2 participants