Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
727af63
FAC-2305 Hydrate response dates to match SDK types
javorosas Sep 22, 2026
98345d0
FAC-2305 Prepare SDK 5.1.1 release
javorosas Sep 22, 2026
b6ea489
FAC-2305 Preserve string-valued response dates
javorosas Sep 22, 2026
f700987
FAC-2305 Complete date contract audit for SDK 6.0
javorosas Sep 22, 2026
d8a90a4
FAC-2305 Cover cancellation status check date
javorosas Sep 23, 2026
57f387c
fix: allow nullable customer response dates
javorosas Sep 28, 2026
ed39200
chore: update SDK tooling and patch vulnerable dependencies
javorosas Sep 29, 2026
43e8c38
fix: publish explicit ESM and CommonJS package exports
javorosas Sep 29, 2026
7bea28b
chore: move release and tooling changes to a separate PR
javorosas Sep 29, 2026
7a149f8
chore: remove generated test output
javorosas Sep 29, 2026
322a440
chore: prepare SDK 6 release with modern tooling and package exports
javorosas Sep 29, 2026
dec6ffb
chore: use Rolldown for declaration bundling and remove unused hooks
javorosas Sep 29, 2026
7abfd33
docs: improve SDK onboarding and CommonJS examples
javorosas Sep 29, 2026
d3fd965
docs: guide upgrades from SDK 3 through 5 and focus release notes on …
javorosas Sep 29, 2026
e3a245c
fix: parse webhook events after remote signature validation
javorosas Sep 30, 2026
4fa6981
docs: simplify first invoice example
javorosas Sep 30, 2026
5040e6a
docs: preserve published changelog entries
javorosas Sep 30, 2026
eee0409
docs: preserve historical changelog policy
javorosas Sep 30, 2026
7dd2d4f
feat: generate SDK contracts and resource methods from OpenAPI
javorosas Sep 30, 2026
6655e58
chore: update YAML parser security fixes
javorosas Sep 30, 2026
639ebdc
feat: refine generated CFDI input relationships
javorosas Sep 30, 2026
de7cce4
fix: align optional invoice inputs and simplify release notes
javorosas Sep 30, 2026
a8f330a
fix: align generated draft customer response types
javorosas Sep 30, 2026
5ed43a8
chore: mark generated SDK artifacts for focused reviews
javorosas Sep 30, 2026
f6c73a3
refactor: derive SDK operation bindings from OpenAPI
javorosas Sep 30, 2026
f898526
refactor: verify OpenAPI by hash and improve generated method docs
javorosas Oct 1, 2026
d367e3a
refactor: pin OpenAPI generation to a documentation commit
javorosas Oct 1, 2026
7c609ef
fix: type invoice creation responses and hydrate their dates
javorosas Oct 1, 2026
2ebc9da
chore: sync specification with invoice variant labels
javorosas Oct 1, 2026
e1da518
chore: sync grouped invoice creation schemas
javorosas Oct 1, 2026
6e926bc
test: cover invoice status discrimination in public types
javorosas Oct 1, 2026
a10dc5c
fix: align date formats and improve generated method documentation
javorosas Oct 1, 2026
914e0f5
fix: preserve CommonJS types and align payment contracts
javorosas Oct 1, 2026
39724da
docs: clarify download objects and add local SDK playground
javorosas Oct 1, 2026
465ccb6
fix: emit plain JSDoc descriptions for union autocomplete
javorosas Oct 1, 2026
9146680
fix: allow incomplete customers when requesting an edit link
javorosas Oct 1, 2026
9ac8d35
fix: align conditional customer, cancellation and global invoice types
javorosas Oct 1, 2026
f73b4a6
feat: add typed customer creation methods
javorosas Oct 2, 2026
fa64706
docs: highlight v6 developer experience and migration cases
javorosas Oct 2, 2026
32b048a
docs: describe current JavaScript SDK capabilities
javorosas Oct 2, 2026
d53f026
docs: clarify compatibility version references
javorosas Oct 2, 2026
f1ba639
fix: align partial updates, stream uploads and payment summary types
javorosas Oct 2, 2026
1e6d402
fix: hydrate timestamps in calendar date unions
javorosas Oct 2, 2026
2c3b548
fix: standardize input aliases and expose payroll catalogs
javorosas Oct 12, 2026
ba33e85
fix: keep shared property names neutral
javorosas Oct 12, 2026
a5a7d01
refactor: remove redundant manual model aliases
javorosas Oct 12, 2026
b5c1c12
refactor: align invoice item types with public schemas
javorosas Oct 12, 2026
6ce29d2
fix: align invoice and receipt response types
javorosas Oct 12, 2026
8159d1d
refactor: share invoice response types with drafts
javorosas Oct 12, 2026
586ac13
fix: accept nullable customer email inputs
javorosas Oct 12, 2026
5eb2c45
fix: preserve guaranteed customer and item response fields
javorosas Oct 12, 2026
9b67858
refactor: separate customer input contracts from responses
javorosas Oct 12, 2026
8f4fda5
fix: align edit link inputs and preserve field documentation
javorosas Oct 12, 2026
f9ac6cc
fix: resolve YAML merges and align nullable customer inputs
javorosas Oct 12, 2026
f4b2e85
fix: align retained tax response field names
javorosas Oct 12, 2026
dcd65ac
fix: generate SDK from portable YAML definitions
javorosas Oct 12, 2026
0bb470d
fix: distinguish null from omitted customer update fields
javorosas Oct 13, 2026
7c6c009
fix: type explicit null clearing for customer edit-link updates
javorosas Oct 13, 2026
dc41746
fix: sync SDK with merged public documentation contract
javorosas Oct 14, 2026
357e962
docs: include monthly ZIP capabilities in v6 changelog
javorosas Oct 14, 2026
4805865
merge: integrate released v5.2 changes into SDK v6
javorosas Oct 14, 2026
0edc91e
chore: update SDK tooling and preserve v5.2 release notes
javorosas Oct 14, 2026
2fef9dd
chore: enforce semicolon formatting with pre-commit fixes
javorosas Oct 14, 2026
3ed465b
docs: describe ZIP requests without create-or-retrieve details
javorosas Oct 14, 2026
63ea086
chore: pin SDK specification to merged documentation main
javorosas Oct 14, 2026
c3f2740
fix: gate npm publishing on successful main CI
javorosas Oct 14, 2026
aaedd12
docs: document concrete v5 type migration cases
javorosas Oct 14, 2026
5058a72
fix: preserve array response for organization series listing
javorosas Oct 14, 2026
d3270b8
fix: preserve documented cancellation and public response fields
javorosas Oct 14, 2026
080a3de
docs: clarify v6 release delta and preserve published changelog
javorosas Oct 14, 2026
173fdec
fix: address release review documentation and package coverage
javorosas Oct 14, 2026
2ca54bc
chore: pin SDK to public response-contract corrections
javorosas Oct 14, 2026
fc991e0
fix: sync audited API contracts and customer updates
javorosas Oct 14, 2026
1b42d4a
docs: clarify audited v5 response type migrations
javorosas Oct 14, 2026
16e1524
feat: distinguish invoice responses by status
javorosas Oct 15, 2026
e402395
fix: require complement strings on stamped invoices
javorosas Oct 15, 2026
ae8697f
fix: sync product docs and foreign trade receiver inputs
javorosas Oct 15, 2026
f8ab2b6
fix: reflect nullable customer response emails
javorosas Oct 15, 2026
d575258
chore: pin merged public API specification
javorosas Oct 15, 2026
e1f69db
fix: reflect fiscal stamp metadata and nullable original strings
javorosas Oct 16, 2026
c15eb26
fix: use the invoice UUID without duplicating it in stamp
javorosas Oct 16, 2026
64c4343
fix: guarantee the original stamp string after invoice status narrowing
javorosas Oct 16, 2026
6f38a8d
fix: follow shared stamp and cancellation response schemas
javorosas Oct 20, 2026
911a086
chore: sync OpenAPI source with latest docs
javorosas Oct 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Keep generated artifacts tracked, but collapse their diffs on GitHub.
src/generated/contracts.ts linguist-generated=true
src/generated/dates.ts linguist-generated=true
src/generated/input.ts linguist-generated=true
src/generated/models.ts linguist-generated=true
src/generated/output.ts linguist-generated=true
src/resources/customers.ts linguist-generated=true
src/resources/invoices.ts linguist-generated=true
src/resources/organizations.ts linguist-generated=true
src/resources/products.ts linguist-generated=true
src/resources/receipts.ts linguist-generated=true
src/resources/retentions.ts linguist-generated=true
src/tools/cartaPorteCatalogs.ts linguist-generated=true
src/tools/catalogs.ts linguist-generated=true
src/tools/nominaCatalogs.ts linguist-generated=true
src/tools/comercioExteriorCatalogs.ts linguist-generated=true
src/tools/tools.ts linguist-generated=true
src/tools/webhooks.ts linguist-generated=true
src/types/common.ts linguist-generated=true
src/types/complements.ts linguist-generated=true
src/types/customer.ts linguist-generated=true
src/types/invoice.ts linguist-generated=true
src/types/organization.ts linguist-generated=true
src/types/receipt.ts linguist-generated=true
32 changes: 7 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@ on:
workflow_dispatch:

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Check formatting
run: pnpm run format:check

- name: Run linter
run: pnpm run lint

build-dist:
runs-on: ubuntu-latest
steps:
Expand All @@ -53,6 +29,9 @@ jobs:
- name: Build package
run: pnpm run build

- name: Verify generated SDK
run: pnpm run generate:sdk:check

- name: Upload dist artifact
uses: actions/upload-artifact@v7
with:
Expand Down Expand Up @@ -80,7 +59,7 @@ jobs:
path: dist

- name: Run Node 18 runtime compatibility smoke
run: node --test test/compat/node18-compat.test.cjs
run: node --test test/compat/*.test.cjs test/compat/*.test.mjs

node-runtime:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -149,6 +128,9 @@ jobs:
- name: Run type contract tests
run: pnpm run test:types

- name: Lint
run: pnpm run lint

browser-smoke:
runs-on: ubuntu-latest
steps:
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
name: Deploy to npm

on:
push:
branches:
- main
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]

permissions:
id-token: write # Required for OIDC authentication
contents: read

jobs:
deploy:
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'
env:
RELEASE_SHA: ${{ github.event.workflow_run.head_sha }}
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha }}
persist-credentials: false

- name: Setup pnpm
uses: pnpm/action-setup@v6
Expand Down Expand Up @@ -101,7 +111,7 @@ jobs:
fields: [
{ type: 'mrkdwn', text: `*Package:* \`${packageName}@${version}\`` },
{ type: 'mrkdwn', text: `*Branch:* \`${process.env.GITHUB_REF_NAME}\`` },
{ type: 'mrkdwn', text: `*Commit:* \`${process.env.GITHUB_SHA}\`` },
{ type: 'mrkdwn', text: `*Commit:* \`${process.env.RELEASE_SHA}\`` },
{ type: 'mrkdwn', text: `*Actor:* \`${process.env.GITHUB_ACTOR}\`` },
],
},
Expand All @@ -113,7 +123,7 @@ jobs:
'*Useful links*',
`• npm: <https://www.npmjs.com/package/${packageName}/v/${version}|View package>`,
`• Workflow run: <${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}|Open run>`,
`• Changelog: <${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/blob/${process.env.GITHUB_SHA}/CHANGELOG.md|Read changes>`,
`• Changelog: <${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/blob/${process.env.RELEASE_SHA}/CHANGELOG.md|Read changes>`,
].join('\n'),
},
},
Expand Down Expand Up @@ -156,7 +166,7 @@ jobs:
text: [
`*Node SDK ${packageJson.version} publish failed*`,
`• Workflow run: <${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}|Open run>`,
`• Commit: \`${process.env.GITHUB_SHA}\``,
`• Commit: \`${process.env.RELEASE_SHA}\``,
].join('\n'),
},
},
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
test.js
lib/
dist/
test-results/
playwright-report/

# Created by https://www.gitignore.io/api/node,macos,linux,windows,visualstudiocode

Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_/
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec lint-staged
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dist/
coverage/
test-results/
playwright-report/

# Preserve published changelog entries as written.
CHANGELOG.md
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
"eslint.enable": true
}
30 changes: 30 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributor instructions

## Consumer documentation

- Write `CHANGELOG.md` for developers who consume the SDK. Document observable behavior, public API and type changes, compatibility requirements, fixes, and any action required to upgrade.
- Keep build tools, bundlers, test runners, lint/format configuration, CI setup, and development-only dependency updates out of the changelog. Explain those in pull request descriptions instead.
- Summarize type changes by consumer capability or correction, not by individual fields or implementation steps. Put detailed upgrade cases in the README migration guide.
- Keep changelog entries factual and concise. Use a friendly, task-oriented tone in the README; occasional emojis belong there, not in new changelog entries.
- Preserve published changelog entries as written. Apply editorial changes only to new entries; correct historical entries only when a concrete factual error has been verified.
- Keep migration guidance in the README. State which integrations need no code changes as explicitly as those that do. Verify historical behavior against released source before documenting a migration; do not infer a breaking change from a version number alone.

## OpenAPI generation

- Generate resource methods, request/response types, model aliases, and response date plans with `pnpm generate:sdk`. Do not edit files carrying a generation banner.
- `openapi/source.json` pins a complete public FacturAPI/facturapi-docs commit SHA. `pnpm sync:openapi` resolves docs `main` to its current commit, downloads the spec from that exact commit, and records it only after parsing succeeds. An explicit public branch, tag or full SHA is supported for coordinated PRs. Run `pnpm generate:sdk` after syncing.
- Generation always downloads the YAML from the recorded commit into memory; it never follows a moving branch or writes a spec snapshot. Builds and runtime tests use tracked generated files and need no spec download. Commit public documentation changes and sync their public ref before generating; do not record local filesystem paths or pin unpublished local changes.
- Generate method summaries, argument descriptions and return documentation from OpenAPI. Keep SDK-specific binary upload/download and local webhook verification guidance in the generator; attach documentation to every public overload and use absolute documentation links.
- `openapi-typescript` resolves the OpenAPI contract; the TypeScript compiler resolves the resulting types for date plans. Do not add a second JSON Schema interpreter or a handwritten date-path inventory.
- `scripts/sdk/resources.json` maps public resource/method names to operation IDs. Use a string operation ID for normal endpoints; HTTP bindings and signatures are derived from the spec. Add overrides only for established argument names, optionality/nullability, fixed download formats, multipart/local-signature behavior, or response overloads. Do not repeat inferred path/body/query bindings. Every public HTTP operation must have a binding; adding an operation intentionally fails generation until its public method is chosen.
- Use `bodySchema` for an explicit SDK convenience method that selects a specific input variant from the public spec while preserving the original HTTP operation. Keep `create()` available for dynamic or incomplete customer inputs; do not add runtime validation or rewrite the supplied body.
- Use `querySchema` to bind a grouped query contract from the public spec when separate OpenAPI query parameters cannot express dependencies between them. Keep conditional values and required fields in that schema rather than repeating them in generator code. TypeScript cannot express arbitrary string exclusions (`not`); do not invent a narrower country catalog to work around that limitation.
- Use `bodyByQueryFlag` only for a verified relationship between a query flag and an input schema that OpenAPI cannot express across parameters and request bodies. Keep both input schemas in the public spec; require a literal `true` to select the incomplete body and preserve the normal input for dynamic booleans.
- Preserve the SDK convention that a declared request body is a required method argument unless the operation explicitly marks it optional (`required: false`) or a compatibility override says otherwise. Optional query objects accept null by default; explicit overrides preserve existing exceptions.
- `scripts/sdk/models.json` preserves public model names. `scripts/sdk/enums.json` binds existing runtime enums to their semantic schema locations; never bind enums merely because their numeric/string values happen to match. Named enum drift must be corrected explicitly.
- Preserve the real HTTP transport, binary behavior, and local cryptography. Test external HTTP boundaries with fixtures; do not replace these implementations with mocks.
- Run `pnpm generate:sdk:check`, `pnpm test`, `pnpm lint`, and browser tests for generation changes. Cover input strings/Date values, nullable dates, complement discriminants, opaque metadata/XML, and additions to the contract.
- This repository is public. Never copy private implementation sources, paths, identifiers, diagnostics, or planning context into generated files, tests, commits, PR descriptions, or review replies.
- Keep the source commit metadata and generated sources tracked; do not commit a downloaded spec. Mark generated artifacts with `linguist-generated` in `.gitattributes` so reviews focus on the generator, bindings, runtime, and tests; keep handwritten configuration visible. Update the attributes when adding generated output files.
- Describe current SDK capabilities in the README without release announcements; version references are appropriate when they explain verified compatibility or when a capability became available. Put release improvements in the changelog. The SDK supports Node.js and browsers; keep titles and summaries accurate for both.
- Input schema names end in `Input`, including reusable input fragments. Keep intentionally shared shapes neutral. Correct inconsistent schema names in the public spec instead of adding direction guesses or per-schema patches to the generator; preserve published SDK aliases in `scripts/sdk/models.json`.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [6.0.0] Unreleased

### Breaking

- Response timestamps are consistently returned as `Date` objects. SAT stamp timestamps and calendar dates remain strings.
- Request and response types now follow the API contract, with more precise CFDI and complement inputs. TypeScript integrations may need adjustments; see the [migration guide from v3, v4, and v5](README.md#actualizar-desde-v3-v4-o-v5).
- Certificate deletion returns its update timestamp, global receipt invoicing may return `null`, and domain availability requires an explicit domain. See the concrete v5 migration cases in the README.
- Series mutations return arrays, retention addendas use `string[]`, and uninvoiced receipts expose a nullable invoice reference. These type corrections match existing API responses.
- Import from `facturapi`; direct imports into internal package files such as `facturapi/dist/...` are no longer supported.

### Fixed

- Correct request typing for partial product updates and native Node.js file uploads.
- Webhook signature validation consistently returns parsed events with converted dates in Node.js and browsers.

### Added

- Autocompletion and editor documentation for request fields, method arguments, and responses across SDK operations.
- More precise input types for CFDI variants, drafts, structured complements, and customer creation. Related fields are checked by TypeScript in supported cases, helping catch incomplete or incompatible inputs before sending a request.
- Invoice responses distinguish draft, pending, failed, and stamped states; checking the status exposes the guaranteed UUID and stamp fields.
- Receipt invoicing distinguishes invoice creation from `dry_run` summaries in its return types.
- Methods to create national, foreign, and generic RFC customers with specific input types; assign receipt customers with `receipts.updateCustomer`; upload FIEL certificates; and check API health.
- Filter invoice searches and monthly ZIP requests with `sat_imported`, inspect ZIP freshness with `is_current`, and access `generated_at` and `content_as_of` as `Date` objects.
- CommonJS supports `const Facturapi = require('facturapi')` directly, while retaining `.default` compatibility. CommonJS and ESM include matching TypeScript definitions.

## [5.2.0] 2026-10-07

### Added
Expand Down
Loading
Loading