Skip to content

feat: generate typed SDK from OpenAPI and prepare v6 - #121

Open
javorosas wants to merge 84 commits into
mainfrom
chore/sdk-6-release-and-tooling
Open

javorosas wants to merge 84 commits into
mainfrom
chore/sdk-6-release-and-tooling

Conversation

@javorosas

@javorosas javorosas commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Generate SDK request and response types, public model aliases, resource methods, and response date plans from the published OpenAPI contract. Preserve the HTTP transport, existing resource aliases, binary downloads and uploads, and local webhook signature verification.

Invoice responses form a status-based union of InvoiceDraft, InvoicePending, InvoiceFailed and InvoiceStamped. Valid and canceled invoices expose the required UUID and fiscal stamp fields after narrowing by status. The creation input remains unchanged, and the existing InvoiceStatus enum is preserved. The fiscal stamp original string is required and non-null on stamped invoices; stamp metadata includes its version and optional legend, while the invoice UUID remains the sole fiscal identifier.

Prepare SDK 6.0.0 with ESM and CommonJS package exports and matching declarations. Declared response timestamps become Date values; calendar dates and opaque metadata remain unchanged. Customer updates distinguish omitted fields from explicit null, including the separate edit-link input variant. ZIP requests support provenance filters and package freshness timestamps without a public forced-refresh option.

The specification is pinned to FacturAPI/facturapi-docs#311, which incorporates the renderer compatibility fixes from docs #313 and the shared fiscal stamp contract. Generated bindings follow the named cancellation-status schema while preserving the existing SDK enum. Deploy and verify the API guarantee for historical stamped invoices, then merge docs #311 before releasing this PR. Generation reads that immutable public source; runtime builds use tracked generated files.

Modernize build and declaration generation, dependencies, linting, package export checks, and browser coverage. Migration guidance remains in README; consumer changes are summarized in the 6.0.0 changelog.

Release coordination

After this PR merges, npm publication of 6.0.0 runs only after successful CI for the exact main push commit, and only if the version is not already published. Review the release and migration guidance before merging. The Node installation documentation PR FacturAPI/facturapi-docs#304 should follow publication because its direct CommonJS constructor example requires SDK 6.

This PR supersedes #120. PR #119 has merged. Its payroll catalog methods are included, ZIP methods are retained, and the published 5.2.0 changelog entry is preserved.

Validation

  • Build, TypeScript contracts, generated-source reproducibility, and lint checks pass.
  • 53 Node tests and 10 web runtime tests pass.
  • Five native package compatibility checks pass; CI also covers Node 18.
  • Three Chromium smoke tests pass.
  • ZIP tests verify provenance payloads and hydration of generated_at/content_as_of; type tests reject public refresh.

Tooling refreshed: ESLint 10.12, Prettier 3.9.10, typescript-eslint 8.71.2, Vite 8.3.4, Vitest 5.0.4, jsdom 30.1.2, globals and Node types. TypeScript stays on 6; Playwright stays on 1.63 under the dependency release-age policy. All validation above passed after these updates.

Review fixes preserve existing cancellation and organization response fields, correct series listing to an array, keep published changelog entries byte-identical to main, and clarify migration guidance. Built-package compatibility covers FIEL upload, receipt customer assignment and API health. No format check is added to CI; pre-commit fixes remain local.

@javorosas javorosas changed the title Prepare SDK 6.0 release and modernize tooling and package exports feat: generate typed SDK from OpenAPI and prepare v6 Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Invoice creation currently returns untyped fields and leaves response timestamps as strings.

Review effort: Balanced
Findings: None

What changed in this PR

This PR prepares the SDK for v6 by generating its public types and resource methods from a pinned OpenAPI contract. It builds on the response-date work in #120 and coordinates with the public contract corrections in facturapi-docs#303.

Changes:

  • Generate typed methods, models, and response-date plans while retaining the existing transport and webhook validation.
  • Add ESM and CommonJS packaging, compatibility checks, and SDK generation checks.
  • Update consumer migration guidance and release notes.
File Description
vitest.web.config.mts Configures web unit tests.
vitest.node.config.mts Configures Node unit tests.
vite.config.ts Removes the old build configuration.
vite.config.mts Configures ESM and CommonJS bundles.
test/​node/​sdk-generation.node.test.ts Tests date-plan discovery.
test/​node/​runtime-compat.node.test.ts Extends runtime response tests.
test/​compat/​node18-compat.test.cjs Checks CommonJS compatibility.
test/​compat/​esm-compat.test.mjs Checks native ESM imports.
test/​browser/​runtime-smoke.browser.spec.ts Updates the browser bundle path.
test-d/​runtime-types.test-d.ts Tests public type contracts.
test-d/​package-exports.mts Checks ESM declarations.
test-d/​package-exports.cts Checks CommonJS declarations.
src/​wrapper.ts Applies generated response-date plans.
src/​types/​webhook.ts Uses generated webhook types.
src/​types/​runtime.ts Defines portable binary types.
src/​types/​retention.ts Exposes generated retention aliases.
src/​types/​receipt.ts Exposes generated receipt aliases.
src/​types/​product.ts Exposes the generated product alias.
src/​types/​organization.ts Exposes generated organization aliases.
src/​types/​invoice.ts Exposes generated invoice aliases.
src/​types/​index.ts Exports generated models.
src/​types/​customer.ts Exposes generated customer aliases.
src/​types/​complements.ts Exposes generated complement aliases.
src/​types/​common.ts Exposes generated common aliases.
src/​tools/​webhooks.ts Generates webhook methods.
src/​tools/​tools.ts Adds the API health method.
src/​tools/​comercioExteriorCatalogs.ts Generates catalog search typing.
src/​tools/​catalogs.ts Generates catalog search typing.
src/​tools/​cartaPorteCatalogs.ts Generates Carta Porte catalog methods.
src/​runtime/​webhooks.ts Preserves signature validation and hydrates events.
src/​runtime/​uploads.ts Prepares binary uploads.
src/​runtime/​dates.ts Applies date plans to responses.
src/​resources/​retentions.ts Generates typed retention methods.
src/​resources/​receipts.ts Generates typed receipt methods and overloads.
src/​resources/​products.ts Generates typed product methods.
src/​resources/​customers.ts Generates typed customer methods.
src/​generated/​models.ts Exports generated model aliases.
src/​generated/​dates.ts Stores generated date plans.
src/​generated/​contracts.ts Defines operation request and response types.
src/​enums.ts Adds complement enum members.
scripts/​sync-openapi.mjs Syncs the pinned public contract.
scripts/​sdk/​models.json Maps public model names.
scripts/​sdk/​enums.json Maps semantic enum bindings.
scripts/​sdk/​date-plans.mjs Compiles date plans from types.
scripts/​generate-sdk.mjs Generates SDK files from OpenAPI.
scripts/​commonjs-types.mjs Produces CommonJS declarations.
rolldown.config.mjs Configures declaration bundling.
README.md Updates usage and migration guidance.
package.json Prepares v6 exports, scripts, and dependencies.
openapi/​source.json Pins the public contract revision.
eslint.config.mjs Adds the updated lint configuration.
eslint.config.js Removes the old lint configuration.
CHANGELOG.md Documents consumer-facing v6 changes.
AGENTS.md Documents contributor generation practices.
.prettierignore Excludes generated artifacts from formatting.
.gitignore Ignores test and browser reports.
.github/​workflows/​ci.yml Adds generation and compatibility checks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The broad generated SDK, runtime, packaging, and release changes warrant final human review; a documentation nit also remains.

0 open findings

🧠 Review effort: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants