Skip to content

Normalize fmodata database names#222

Merged
eluce2 merged 2 commits intomainfrom
t3code/25abe115
Apr 24, 2026
Merged

Normalize fmodata database names#222
eluce2 merged 2 commits intomainfrom
t3code/25abe115

Conversation

@eluce2
Copy link
Copy Markdown
Collaborator

@eluce2 eluce2 commented Apr 24, 2026

Summary

  • add configurable database-name normalization for OData, batch, and webhook requests
  • default normal requests strip .fmp12; webhook add/list/remove force it on
  • thread normalize flag through database config, request options, tests, and docs

Testing

  • pnpm run ci
  • added/updated Vitest coverage for default, disabled, per-request override, webhook, and Otto warning paths

Summary by CodeRabbit

  • New Features

    • Database name normalization is now configurable for OData and webhook flows. Control whether the .fmp12 extension is stripped or ensured at the connection level, or override per-request.
  • Documentation

    • Quick-start updated to describe the new normalizeDatabaseName option and differing behavior for standard OData vs webhook flows.
  • Tests

    • Added tests covering normalization defaults, per-request overrides, webhook behavior, and a one-time warning when disabling normalization.

- add per-database and per-request normalization control
- ensure webhook paths use .fmp12 and OData strips it by default
- update docs, tests, and changeset
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: 5a3152c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@proofkit/fmodata Patch
@proofkit/better-auth Patch
@proofkit/typegen Patch
@proofkit/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
proofkit-docs Ready Ready Preview Apr 24, 2026 7:22pm

Request Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

Open in StackBlitz

@proofkit/better-auth

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/better-auth@222

@proofkit/cli

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/cli@222

create-proofkit

pnpm add https://pkg.pr.new/proofsh/proofkit/create-proofkit@222

@proofkit/fmdapi

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/fmdapi@222

@proofkit/fmodata

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/fmodata@222

@proofkit/typegen

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/typegen@222

@proofkit/webviewer

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/webviewer@222

commit: e229b35

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f32aa7c2-f039-4163-9889-847f1f5b0710

📥 Commits

Reviewing files that changed from the base of the PR and between e229b35 and 5a3152c.

📒 Files selected for processing (1)
  • packages/fmodata/src/client/database-name.ts

📝 Walkthrough

Walkthrough

Adds configurable database-name normalization across @proofkit/fmodata: new normalization utilities, Database-level normalizeDatabaseName defaulting to true, per-request override support, webhook operations using extension-ensuring mode, request pipeline and service interfaces updated, docs and tests added.

Changes

Cohort / File(s) Summary
Changeset & Docs
\.changeset/fresh-cooks-kneel.md, apps/docs/content/docs/fmodata/quick-start.mdx, apps/docs/content/docs/fmodata/webhooks.mdx
Adds release changeset; documents connection.database() normalizeDatabaseName option and webhook behavior; removes trailing blank line in webhooks doc.
Normalization Core
packages/fmodata/src/client/database-name.ts
New module implementing .fmp12 detection and normalization helpers (stripFmp12Extension, ensureFmp12Extension, normalizeDatabaseSegment, normalizeDatabasePath) and a DatabaseNameNormalizationMode type.
Database config & metadata
packages/fmodata/src/client/database.ts, packages/fmodata/src/types.ts
Database accepts normalizeDatabaseName?: boolean (default true) and exposes internal getter; ExecuteOptions gains normalizeDatabaseName?: boolean; metadata lookup now uses shared helper.
Request builders & URL construction
packages/fmodata/src/client/batch-builder.ts, packages/fmodata/src/client/builders/table-utils.ts, packages/fmodata/src/client/count-builder.ts, packages/fmodata/src/client/delete-builder.ts, packages/fmodata/src/client/insert-builder.ts, packages/fmodata/src/client/query/query-builder.ts, packages/fmodata/src/client/record-builder.ts, packages/fmodata/src/client/update-builder.ts
Builders and helper createODataRequest now route DB path through normalizeDatabasePath, thread normalizeDatabaseName from options → builder config → connection default.
Webhook handling
packages/fmodata/src/client/webhook-builder.ts
`WebhookManager.add
Effect layer, services & FM connection
packages/fmodata/src/effect.ts, packages/fmodata/src/services.ts, packages/fmodata/src/client/filemaker-odata.ts
requestFromService now accepts normalizeDatabaseName and databaseNameNormalizationMode and requires ODataConfig in environment; ODataConfig adds normalizeDatabaseName; HttpClient.request options extended; FMServerConnection applies normalization with one-time warning for Otto/API-key when disabling normalization.
Testing & mocks
packages/fmodata/src/testing.ts, packages/fmodata/tests/effect-layer-execution.test.ts, packages/fmodata/tests/normalize-database-name.test.ts
Adds tests validating normalization behavior (default strip, DB-level disable, per-request override, webhook ensure, single warning), mock URL pattern compatibility, and optional logger in MockFMServerConnection; test base config includes normalizeDatabaseName: true.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant RequestLayer as requestFromService
  participant ODataConfig
  participant Normalizer as normalizeDatabasePath
  participant HttpClient
  Client->>RequestLayer: make request(url, options)
  RequestLayer->>ODataConfig: read normalizeDatabaseName & mode
  RequestLayer->>Normalizer: normalizeDatabasePath(url, {normalizeDatabaseName, mode})
  Normalizer-->>RequestLayer: normalizedUrl
  RequestLayer->>HttpClient: HttpClient.request(normalizedUrl, mergedOptions)
  HttpClient-->>Client: response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Normalize fmodata database names' accurately captures the main objective of the pull request, which is to add configurable database-name normalization for OData, batch, and webhook requests throughout the fmodata package.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/25abe115

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/fmodata/src/client/database-name.ts`:
- Around line 44-47: Guard the unsafe decodeURIComponent call around
databaseSegment to prevent URIError crashes: wrap the
decodeURIComponent(databaseSegment) used when computing
normalizedDatabaseSegment in a try/catch (inside the code that calls
normalizeDatabaseSegment) and on catch fall back to the raw databaseSegment (or
a safe sanitized value) so normalizeDatabaseSegment(normalizedInput,
options.normalizeDatabaseName, options.mode) always receives a string; ensure
you reference the same symbols (databaseSegment, normalizeDatabaseSegment,
normalizedDatabaseSegment, options.normalizeDatabaseName, options.mode) so the
behavior is preserved for valid input but malformed % sequences do not throw.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cb561235-c5a6-4da5-88ce-e7850c494c30

📥 Commits

Reviewing files that changed from the base of the PR and between 413c2af and e229b35.

📒 Files selected for processing (21)
  • .changeset/fresh-cooks-kneel.md
  • apps/docs/content/docs/fmodata/quick-start.mdx
  • apps/docs/content/docs/fmodata/webhooks.mdx
  • packages/fmodata/src/client/batch-builder.ts
  • packages/fmodata/src/client/builders/table-utils.ts
  • packages/fmodata/src/client/count-builder.ts
  • packages/fmodata/src/client/database-name.ts
  • packages/fmodata/src/client/database.ts
  • packages/fmodata/src/client/delete-builder.ts
  • packages/fmodata/src/client/filemaker-odata.ts
  • packages/fmodata/src/client/insert-builder.ts
  • packages/fmodata/src/client/query/query-builder.ts
  • packages/fmodata/src/client/record-builder.ts
  • packages/fmodata/src/client/update-builder.ts
  • packages/fmodata/src/client/webhook-builder.ts
  • packages/fmodata/src/effect.ts
  • packages/fmodata/src/services.ts
  • packages/fmodata/src/testing.ts
  • packages/fmodata/src/types.ts
  • packages/fmodata/tests/effect-layer-execution.test.ts
  • packages/fmodata/tests/normalize-database-name.test.ts
💤 Files with no reviewable changes (1)
  • apps/docs/content/docs/fmodata/webhooks.mdx

Comment thread packages/fmodata/src/client/database-name.ts
- tolerate invalid percent-encoding in database segments
- keep normalization behavior unchanged for valid inputs
@eluce2 eluce2 merged commit bf9fc95 into main Apr 24, 2026
8 of 10 checks passed
@eluce2 eluce2 deleted the t3code/25abe115 branch April 24, 2026 19:21
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