Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Bug report
description: Something in @bullcode/fiscal behaves wrongly
labels: [bug]
body:
- type: markdown
attributes:
value: |
Do not paste certificates, passwords, CPF, signed XML or real taxpayer data. Anonymize XML and remove its `<Signature>`.
Report security problems privately: Security > Report a vulnerability.
- type: input
id: version
attributes:
label: Version
placeholder: 0.3.4
validations:
required: true
- type: dropdown
id: environment
attributes:
label: Sefin environment
options: [produção restrita, produção, not related]
validations:
required: true
- type: textarea
id: what
attributes:
label: What happened
description: The call, the input (anonymized), the result and the Sefin codes, if any.
validations:
required: true
- type: textarea
id: expected
attributes:
label: What you expected
validations:
required: true
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Security vulnerability
url: https://github.com/bullcodeapps/fiscal/security/advisories/new
about: Report it privately, never in a public issue.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Feature request
description: A fiscal document, field or flow the library does not support yet
labels: [enhancement]
body:
- type: textarea
id: need
attributes:
label: What you need
description: The scenario, and the official layout or technical note that defines it (Anexo, NT, code).
validations:
required: true
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
dev-dependencies:
dependency-type: development
open-pull-requests-limit: 5
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
actions:
patterns: ["*"]
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## What and why

## Checklist

- [ ] `pnpm typecheck`, `pnpm test` and `pnpm check:docs` pass
- [ ] `docs/` and TSDoc describe any behavior change
- [ ] `CHANGELOG.md` has an entry, and `package.json` has the new version if this PR is a release
- [ ] No certificates, personal data or real taxpayer data (see AGENTS.md)
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: test (node ${{ matrix.node }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [20, 22, 24]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm typecheck
- run: pnpm test
- run: pnpm check:docs
- run: pnpm dlx publint@0.3

ci:
if: always()
needs: test
runs-on: ubuntu-latest
steps:
- run: test "${{ needs.test.result }}" = success
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

# Publishes when a merge to main carries a version that npm does not have yet.
# npm authenticates this workflow through trusted publishing (OIDC), so no token is stored.
on:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
runs-on: ubuntu-latest
environment: npm
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: pnpm

- name: Read version
id: version
run: |
version=$(node -p "require('./package.json').version")
echo "version=$version" >> "$GITHUB_OUTPUT"
if npm view "@bullcode/fiscal@$version" version >/dev/null 2>&1; then
echo "published=true" >> "$GITHUB_OUTPUT"
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi

- run: pnpm install --frozen-lockfile
if: steps.version.outputs.published == 'false'

# Trusted publishing needs npm 11.5.1 or later.
- run: npm install -g npm@^11.5.1
if: steps.version.outputs.published == 'false'

# prepublishOnly runs typecheck, tests and check:docs (which builds dist).
- run: npm publish --provenance --access public
if: steps.version.outputs.published == 'false'

- name: Tag and GitHub release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: |
tag="v$VERSION"
if gh release view "$tag" >/dev/null 2>&1; then exit 0; fi
awk -v h="## $tag " 'index($0, h) == 1 { on = 1; next } on && /^## / { exit } on' CHANGELOG.md > notes.md
gh release create "$tag" --target "$GITHUB_SHA" --title "$tag" --notes-file notes.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
password*.txt
.env*
.doc-snippets/
dist
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ pnpm check:docs # builds, then type-checks every ts block in README.md and doc

## Releases

`dist` is committed because consumers install from git tags and never build. Before tagging:
Consumers install from npm. `main` is protected: every change goes through a PR with green CI.

1. Bump `version` in `package.json`.
2. Run `pnpm check:docs` (it builds) and commit `dist` with the source change.
3. Tag `vX.Y.Z`.
To release, bump `version` in `package.json` and add the `CHANGELOG.md` entry in a PR. When it merges,
`.github/workflows/release.yml` publishes to npm through trusted publishing (with provenance), tags `vX.Y.Z` and
creates the GitHub release. `prepublishOnly` runs typecheck, tests and `check:docs` (which builds `dist`).

## Tests

Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

Install a version with `pnpm add github:bullcodeapps/fiscal#<tag>`.
Install with `pnpm add @bullcode/fiscal`.

## v0.3.4 (2026-11-13)

- Published on npm as `@bullcode/fiscal`. `dist` is no longer committed, so install from npm. Git tags up to
v0.3.3 keep their committed `dist`.
- Releases publish from CI with npm provenance. CI runs on Node 20, 22 and 24.

## v0.3.3 (2026-11-13)

Expand Down
7 changes: 7 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Code of Conduct

This project follows the [Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).

Report unacceptable behavior to the maintainers privately, through
[Security > Report a vulnerability](https://github.com/bullcodeapps/fiscal/security/advisories/new) with
"Code of Conduct" in the title. Maintainers keep reports confidential and act on them as the Covenant describes.
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing

Thanks for helping. Bug reports, fixes for Sefin rejections and new fiscal documents are welcome.

## Before you start

- For a large change (a new document type, a new public API), open an issue first.
- Never commit certificates, passwords, personal data or real taxpayer data. Anonymize any XML captured from
Sefin and remove its `<Signature>` elements. [AGENTS.md](./AGENTS.md) has the full rules.
- Report security problems privately. See [SECURITY.md](./SECURITY.md).

## Development

```sh
pnpm install
pnpm typecheck
pnpm test
pnpm check:docs # builds, then type-checks every ts block in README.md and docs/
```

[AGENTS.md](./AGENTS.md) describes the layout, the test fixtures and the schema checks.

## Pull requests

- Keep each PR to one change. CI must pass on Node 20, 22 and 24.
- Update `docs/` and the TSDoc in the same PR when behavior changes. Agents in consumer apps read those files.
- Add an entry to `CHANGELOG.md`.
- Every Sefin rule the XSD does not express gets a check in `src/nfse/dps.ts`, with the Sefin code in the
message, and a test.

## Releases

A maintainer bumps `version` in `package.json` and adds the `CHANGELOG.md` entry in a PR. When that PR merges
to `main`, the Release workflow publishes to npm with provenance, tags `vX.Y.Z` and creates the GitHub release.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# @bullcode/fiscal

[![CI](https://github.com/bullcodeapps/fiscal/actions/workflows/ci.yml/badge.svg)](https://github.com/bullcodeapps/fiscal/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/@bullcode/fiscal)](https://www.npmjs.com/package/@bullcode/fiscal)
[![skills.sh](https://skills.sh/b/bullcodeapps/fiscal)](https://skills.sh/bullcodeapps/fiscal)
[![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)

Brazilian fiscal documents for Node.js (>= 20.11, ESM and CommonJS). Today it issues NFS-e Nacional directly
against Sefin Nacional, with no intermediary and no per-note fee: it loads the A1 e-CNPJ certificate, builds and
signs the DPS, emits over mTLS, reconciles after timeouts, cancels, imports notes from the ADN and renders the
Expand All @@ -11,10 +16,10 @@ DANFSe PDF. The library is stateless: storage of certificates, DPS numbering and
## Install

```sh
pnpm add github:bullcodeapps/fiscal#v0.3.3
pnpm add @bullcode/fiscal # or: npm install @bullcode/fiscal
```

`dist` is committed, so installs never build.
Releases and changes: [npm](https://www.npmjs.com/package/@bullcode/fiscal), [CHANGELOG.md](./CHANGELOG.md).

## Quick start

Expand Down Expand Up @@ -61,7 +66,7 @@ A production integration also needs persistence, numbering and the retry loop. T
- [docs/codes.md](./docs/codes.md): where to look up each tax code, municipality adhesion, common Sefin rejections
- [docs/errors.md](./docs/errors.md): every error the library defines and how to fix it

The docs ship inside the package, at `node_modules/@bullcode/fiscal/docs/`.
The docs ship inside the package, at `node_modules/@bullcode/fiscal/docs/`, and always match the installed version.

## Using with AI coding agents

Expand All @@ -80,7 +85,8 @@ installed version, in this order, and prefer them over prior knowledge:
4. node_modules/@bullcode/fiscal/docs/errors.md
```

Agents that support [Agent Skills](https://agentskills.io) can also install the skill in `skills/nfse-integration`:
Agents that support [Agent Skills](https://agentskills.io) can also install the skill in `skills/nfse-integration`
([skills.sh](https://skills.sh/bullcodeapps/fiscal/nfse-integration)):

```sh
npx skills add bullcodeapps/fiscal
Expand All @@ -92,7 +98,7 @@ npx skills add bullcodeapps/fiscal
pnpm install
pnpm typecheck
pnpm test
pnpm build # run and commit dist before tagging a release
pnpm build
```

`packageManager` pins pnpm 10. See [AGENTS.md](./AGENTS.md) for contributor notes.
Expand All @@ -118,6 +124,11 @@ pnpm build && node scripts/smoke-export-restricted.mjs cert.pfx password.txt #
pnpm build && node scripts/cancel-restricted.mjs cert.pfx password.txt <accessKey>
```

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) and the [Code of Conduct](./CODE_OF_CONDUCT.md). Report security
problems privately, as [SECURITY.md](./SECURITY.md) describes.

## License

[MIT](./LICENSE)
61 changes: 0 additions & 61 deletions dist/chunk-Q3O3QATY.js

This file was deleted.

40 changes: 0 additions & 40 deletions dist/environment-Cf62aP_K.d.cts

This file was deleted.

Loading
Loading