npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nuvem-fiscal

v0.0.4

Published

TypeScript SDK for Nuvem Fiscal API

Downloads

362

Readme

Nuvem Fiscal SDK (TypeScript)

SDK não-oficial para integração com a API da Nuvem Fiscal. Desenvolvido em TypeScript, com validação de dados via Zod e suporte a Promises.

Funcionalidades

  • Empresas: CRUD completo (Criar, Listar, Consultar, Atualizar, Excluir).
  • NFC-e: Emissão, Consulta, Cancelamento, Listagem, Download de XML e PDF.
  • Autenticação: Gerenciamento automático de tokens OAuth2 (Client Credentials).
  • Tipagem Forte: Interfaces TypeScript e validação em tempo de execução com Zod.

Instalação

npm install nuvem-fiscal-sdk
# ou
pnpm add nuvem-fiscal-sdk
# ou
yarn add nuvem-fiscal-sdk

Configuração

Você pode configurar o cliente passando as credenciais no construtor ou usando variáveis de ambiente.

Variáveis de Ambiente (Recomendado)

Crie um arquivo .env na raiz do seu projeto:

NUVEM_FISCAL_CLIENT_ID=seu_client_id
NUVEM_FISCAL_CLIENT_SECRET=seu_client_secret

Uso Básico

import { NuvemFiscal } from 'nuvem-fiscal-sdk';

const client = new NuvemFiscal();

// Listar empresas
const empresas = await client.empresa.list({ top: 10 });
console.log(empresas.data);

// Emitir NFC-e
const nfce = await client.nfce.emitir({
  ambiente: 'homologacao',
  infNFe: {
    // ... dados da nota
  }
});

Documentação

A documentação completa dos métodos está disponível via JSDoc (autocomplete no VS Code). Para detalhes da API, consulte a Documentação Oficial da Nuvem Fiscal.

Desenvolvimento e Testes

Testes de Integração com Sandbox

Este projeto inclui testes de integração que fazem chamadas reais à API sandbox da Nuvem Fiscal.

Configuração

  1. Copie o arquivo de exemplo de variáveis de ambiente:

    cp .env.example .env.local
  2. Edite .env.local e adicione suas credenciais de sandbox:

    NUVEM_FISCAL_CLIENT_ID=seu_client_id_sandbox
    NUVEM_FISCAL_CLIENT_SECRET=seu_client_secret_sandbox
  3. Execute os testes de integração:

    pnpm test src/integration.test.ts

O que os testes fazem

Os testes de integração (src/integration.test.ts) executam:

  • Listar Empresas: Busca empresas cadastradas no ambiente sandbox
  • Consultar Empresa: Obtém detalhes de uma empresa específica
  • Criar NFCe: Emite uma nota fiscal de consumidor eletrônica de teste
  • Listar NFCe: Lista notas fiscais emitidas
  • Download de XML: Baixa o XML de uma NFCe autorizada (se disponível)

Nota: Os testes fazem chamadas reais à API e podem levar alguns segundos para executar. Certifique-se de ter pelo menos uma empresa cadastrada no ambiente sandbox antes de executar o teste de criação de NFCe.

Executar Todos os Testes

# Testes unitários e de integração
pnpm test

# Apenas testes unitários (mocks)
pnpm test src/client.test.ts

Licença

MIT