@treeunfe/nfce 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +10 -0
- package/README.md +255 -0
- package/package.json +4 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
> @treeunfe/nfce@1.0.
|
|
2
|
+
> @treeunfe/nfce@1.0.6 build /home/runner/work/treeunfe-dfe/treeunfe-dfe/packages/nfce
|
|
3
3
|
> rollup -c
|
|
4
4
|
|
|
5
|
-
(node:
|
|
5
|
+
(node:3702) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/treeunfe-dfe/treeunfe-dfe/packages/nfce/rollup.config.js is not specified and it doesn't parse as CommonJS.
|
|
6
6
|
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
7
|
To eliminate this warning, add "type": "module" to /home/runner/work/treeunfe-dfe/treeunfe-dfe/packages/nfce/package.json.
|
|
8
8
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
9
9
|
[36m
|
|
10
10
|
[1msrc/index.ts[22m → [1mdist/index.cjs[22m...[39m
|
|
11
11
|
[1m[33m(!) [plugin typescript] @rollup/plugin-typescript: outputToFilesystem option is defaulting to true.[39m[22m
|
|
12
|
-
[32mcreated [1mdist/index.cjs[22m in [
|
|
12
|
+
[32mcreated [1mdist/index.cjs[22m in [1m5.4s[22m[39m
|
|
13
13
|
[36m
|
|
14
14
|
[1msrc/index.ts[22m → [1mdist/index.mjs[22m...[39m
|
|
15
|
-
[32mcreated [1mdist/index.mjs[22m in [1m2.
|
|
15
|
+
[32mcreated [1mdist/index.mjs[22m in [1m2.3s[22m[39m
|
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# Treeunfe DFe 🪄
|
|
2
|
+
|
|
3
|
+
> Biblioteca Node.js open source para integração com webservices da SEFAZ, desenvolvida e mantida pela **Treeunfe**.
|
|
4
|
+
|
|
5
|
+
[](https://www.gnu.org/licenses/gpl-3.0.pt-br.html)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
## 📖 Sobre
|
|
10
|
+
|
|
11
|
+
**Treeunfe DFe** é uma biblioteca open source desenvolvida e mantida pela empresa **Treeunfe**, projetada para simplificar a integração com os webservices da SEFAZ. A biblioteca oferece uma solução robusta e modular para automação de processos relacionados a documentos fiscais eletrônicos.
|
|
12
|
+
|
|
13
|
+
### ✨ Características
|
|
14
|
+
|
|
15
|
+
- 🚀 **Open Source**: Código aberto e gratuito para uso
|
|
16
|
+
- 🔄 **Atualizações Frequentes**: Mantida ativamente pela Treeunfe com atualizações regulares
|
|
17
|
+
- 📦 **Modular**: Instale apenas os módulos que você precisa
|
|
18
|
+
- 🛠️ **TypeScript**: Totalmente tipado para melhor experiência de desenvolvimento
|
|
19
|
+
- 📚 **Documentação Completa**: Documentação detalhada e exemplos práticos
|
|
20
|
+
|
|
21
|
+
## 🏢 Sobre a Treeunfe
|
|
22
|
+
|
|
23
|
+
A **Treeunfe** é uma empresa especializada em soluções fiscais e tributárias. Esta biblioteca é mantida ativamente pela equipe Treeunfe, garantindo atualizações frequentes, correções de bugs e suporte às últimas normas técnicas da SEFAZ.
|
|
24
|
+
|
|
25
|
+
## 📦 Instalação
|
|
26
|
+
|
|
27
|
+
A biblioteca é modular, permitindo instalar apenas os módulos necessários:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Instalar módulo NFe
|
|
31
|
+
npm install @treeunfe/nfe @treeunfe/types @treeunfe/shared
|
|
32
|
+
|
|
33
|
+
# Instalar módulo NFCe
|
|
34
|
+
npm install @treeunfe/nfce @treeunfe/types @treeunfe/shared
|
|
35
|
+
|
|
36
|
+
# Instalar módulo CTe
|
|
37
|
+
npm install @treeunfe/cte @treeunfe/types @treeunfe/shared
|
|
38
|
+
|
|
39
|
+
# Instalar módulo NFSe
|
|
40
|
+
npm install @treeunfe/nfse @treeunfe/types @treeunfe/shared
|
|
41
|
+
|
|
42
|
+
# Instalar módulo DANFE (geração de PDF)
|
|
43
|
+
npm install @treeunfe/danfe
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 🚀 Início Rápido
|
|
47
|
+
|
|
48
|
+
### Exemplo: NFe
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { NFe, TreeunfeDFeService } from '@treeunfe/nfe';
|
|
52
|
+
import { TreeunfeDFeProps } from '@treeunfe/types';
|
|
53
|
+
import path from 'path';
|
|
54
|
+
|
|
55
|
+
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
56
|
+
|
|
57
|
+
// Inicializar serviço
|
|
58
|
+
const treeunfeDFeService = new TreeunfeDFeService();
|
|
59
|
+
const nfeHandler = new NFe(treeunfeDFeService);
|
|
60
|
+
|
|
61
|
+
// Configurar ambiente
|
|
62
|
+
await nfeHandler.LoadEnvironment({
|
|
63
|
+
config: {
|
|
64
|
+
dfe: {
|
|
65
|
+
baixarXMLDistribuicao: true,
|
|
66
|
+
pathXMLDistribuicao: "tmp/DistribuicaoDFe/NFe",
|
|
67
|
+
armazenarXMLAutorizacao: true,
|
|
68
|
+
pathXMLAutorizacao: "tmp/Autorizacao/NFe",
|
|
69
|
+
armazenarXMLRetorno: true,
|
|
70
|
+
pathXMLRetorno: "tmp/RequestLogs/NFe",
|
|
71
|
+
armazenarXMLConsulta: true,
|
|
72
|
+
pathXMLConsulta: "tmp/RequestLogs/NFe",
|
|
73
|
+
|
|
74
|
+
pathCertificado: path.resolve(__dirname, "certificado.pfx"),
|
|
75
|
+
senhaCertificado: "sua_senha_aqui",
|
|
76
|
+
UF: "SP",
|
|
77
|
+
CPFCNPJ: "00000000000000",
|
|
78
|
+
},
|
|
79
|
+
nfe: {
|
|
80
|
+
ambiente: 2, // 1 = Produção, 2 = Homologação
|
|
81
|
+
versaoDF: "4.00",
|
|
82
|
+
tokenCSC: 'seu_token_csc',
|
|
83
|
+
idCSRT: '01'
|
|
84
|
+
},
|
|
85
|
+
lib: {
|
|
86
|
+
connection: {
|
|
87
|
+
timeout: 30000,
|
|
88
|
+
},
|
|
89
|
+
log: {
|
|
90
|
+
exibirLogNoConsole: true,
|
|
91
|
+
armazenarLogs: true,
|
|
92
|
+
pathLogs: 'tmp/Logs/NFe'
|
|
93
|
+
},
|
|
94
|
+
useOpenSSL: false,
|
|
95
|
+
useForSchemaValidation: 'validateSchemaJsBased',
|
|
96
|
+
}
|
|
97
|
+
} as TreeunfeDFeProps
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Consultar status do serviço
|
|
101
|
+
await nfeHandler.ConsultaStatusServico();
|
|
102
|
+
|
|
103
|
+
// Consultar protocolo
|
|
104
|
+
await nfeHandler.ConsultaProtocolo('00000000000000000000000000000000000000000000');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Exemplo: NFSe
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { NFSe } from '@treeunfe/nfse';
|
|
111
|
+
import { TreeunfeDFeService } from '@treeunfe/nfe';
|
|
112
|
+
import { TreeunfeDFeProps } from '@treeunfe/types';
|
|
113
|
+
import path from 'path';
|
|
114
|
+
|
|
115
|
+
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
116
|
+
|
|
117
|
+
// Inicializar serviço
|
|
118
|
+
const treeunfeDFeService = new TreeunfeDFeService();
|
|
119
|
+
const nfseHandler = new NFSe(treeunfeDFeService);
|
|
120
|
+
|
|
121
|
+
// Configurar ambiente
|
|
122
|
+
await nfseHandler.LoadEnvironment({
|
|
123
|
+
config: {
|
|
124
|
+
dfe: {
|
|
125
|
+
baixarXMLDistribuicao: true,
|
|
126
|
+
pathXMLDistribuicao: "tmp/DistribuicaoDFe/NFSe",
|
|
127
|
+
armazenarXMLAutorizacao: true,
|
|
128
|
+
pathXMLAutorizacao: "tmp/Autorizacao/NFSe",
|
|
129
|
+
armazenarXMLRetorno: true,
|
|
130
|
+
pathXMLRetorno: "tmp/RequestLogs/NFSe",
|
|
131
|
+
|
|
132
|
+
pathCertificado: path.resolve(__dirname, "certificado.pfx"),
|
|
133
|
+
senhaCertificado: "sua_senha_aqui",
|
|
134
|
+
UF: "SP",
|
|
135
|
+
CPFCNPJ: "00000000000000",
|
|
136
|
+
},
|
|
137
|
+
nfse: {
|
|
138
|
+
ambiente: 2, // 1 = Produção, 2 = Homologação
|
|
139
|
+
versao: "1.00"
|
|
140
|
+
},
|
|
141
|
+
lib: {
|
|
142
|
+
connection: {
|
|
143
|
+
timeout: 30000,
|
|
144
|
+
},
|
|
145
|
+
log: {
|
|
146
|
+
exibirLogNoConsole: true,
|
|
147
|
+
armazenarLogs: true,
|
|
148
|
+
pathLogs: 'tmp/Logs/NFSe'
|
|
149
|
+
},
|
|
150
|
+
useOpenSSL: false,
|
|
151
|
+
useForSchemaValidation: 'validateSchemaJsBased',
|
|
152
|
+
}
|
|
153
|
+
} as TreeunfeDFeProps
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Consultar NFSe por chave
|
|
157
|
+
await nfseHandler.Consulta({
|
|
158
|
+
chaveAcesso: '00000000000000000000000000000000000000000000'
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 📚 Funcionalidades
|
|
163
|
+
|
|
164
|
+
### NFe (Nota Fiscal Eletrônica)
|
|
165
|
+
- ✅ Autorização de NFe
|
|
166
|
+
- ✅ Consulta de Protocolo
|
|
167
|
+
- ✅ Consulta de Status do Serviço
|
|
168
|
+
- ✅ Distribuição DFe (por NSU, Último NSU ou Chave)
|
|
169
|
+
- ✅ Inutilização de NFe
|
|
170
|
+
- ✅ Recepção de Eventos (Cancelamento, Carta de Correção, EPEC, etc.)
|
|
171
|
+
- ✅ Geração de DANFE
|
|
172
|
+
|
|
173
|
+
### NFCe (Nota Fiscal de Consumidor Eletrônica)
|
|
174
|
+
- ✅ Autorização de NFCe
|
|
175
|
+
- ✅ Consulta de Protocolo
|
|
176
|
+
- ✅ Geração de QR Code
|
|
177
|
+
- ✅ Geração de DANFE
|
|
178
|
+
|
|
179
|
+
### CTe (Conhecimento de Transporte Eletrônico)
|
|
180
|
+
- ✅ Distribuição DFe (por NSU, Último NSU ou Chave)
|
|
181
|
+
- ✅ Download automático de documentos CT-e
|
|
182
|
+
|
|
183
|
+
### NFSe (Nota Fiscal de Serviços Eletrônica)
|
|
184
|
+
- ✅ Autorização de NFSe
|
|
185
|
+
- ✅ Consulta de NFSe
|
|
186
|
+
- ✅ Consulta de Parâmetros Municipais
|
|
187
|
+
- ✅ Registro de Eventos (Cancelamento, etc.)
|
|
188
|
+
- ✅ Distribuição por NSU
|
|
189
|
+
|
|
190
|
+
## 📖 Documentação
|
|
191
|
+
|
|
192
|
+
Para documentação completa, exemplos detalhados e referência da API, acesse:
|
|
193
|
+
|
|
194
|
+
**🔗 [Documentação Completa](https://nfewizard-org.github.io/)**
|
|
195
|
+
|
|
196
|
+
## ⚙️ Requisitos
|
|
197
|
+
|
|
198
|
+
- **Node.js**: Versão 16 ou superior
|
|
199
|
+
- **Certificado**: Certificado A1 (arquivo .pfx)
|
|
200
|
+
- **TypeScript**: Recomendado (mas não obrigatório)
|
|
201
|
+
|
|
202
|
+
### Validação de Schema
|
|
203
|
+
|
|
204
|
+
Por padrão, a biblioteca utiliza validação baseada em Java. Para ambientes sem suporte ao JDK (como Vercel, AWS Lambda sem layers), configure:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
lib: {
|
|
208
|
+
useForSchemaValidation: 'validateSchemaJsBased'
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 🤝 Contribuindo
|
|
213
|
+
|
|
214
|
+
Contribuições são bem-vindas! Este é um projeto open source mantido pela Treeunfe, e sua colaboração é muito apreciada.
|
|
215
|
+
|
|
216
|
+
### Como Contribuir
|
|
217
|
+
|
|
218
|
+
1. **Reportar Bugs**: Abra uma issue descrevendo o problema
|
|
219
|
+
2. **Sugerir Funcionalidades**: Compartilhe suas ideias
|
|
220
|
+
3. **Enviar Pull Requests**: Contribua com código, documentação ou melhorias
|
|
221
|
+
4. **Espalhar a Palavra**: Compartilhe o projeto com outros desenvolvedores
|
|
222
|
+
|
|
223
|
+
### Ao Abrir uma Issue
|
|
224
|
+
|
|
225
|
+
Por favor, inclua as seguintes informações:
|
|
226
|
+
|
|
227
|
+
```markdown
|
|
228
|
+
## Parametrização
|
|
229
|
+
- UF: SP
|
|
230
|
+
- Certificado: A1
|
|
231
|
+
- Método: NFE_ConsultaStatusServico
|
|
232
|
+
- Status: ✅ Funcionando / ❌ Com erro
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Inclua também os logs gerados no diretório configurado em `pathLogs` (arquivos `app.jsonl`, `error.jsonl` e `http.jsonl`).
|
|
236
|
+
|
|
237
|
+
## 📝 Licença
|
|
238
|
+
|
|
239
|
+
Este projeto é licenciado sob a [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.pt-br.html).
|
|
240
|
+
|
|
241
|
+
## 🏢 Mantido por Treeunfe
|
|
242
|
+
|
|
243
|
+
Desenvolvido e mantido com ❤️ pela equipe **Treeunfe**.
|
|
244
|
+
|
|
245
|
+
- 🌐 Website: [Treeunfe](https://treeunfe.com.br)
|
|
246
|
+
- 📧 Suporte: suporte@treeunfe.com.br
|
|
247
|
+
- 💬 Issues: [GitHub Issues](https://github.com/treeunfe/treeunfe-dfe/issues)
|
|
248
|
+
|
|
249
|
+
## ⭐ Agradecimentos
|
|
250
|
+
|
|
251
|
+
Agradecemos a todos os contribuidores e usuários que tornam este projeto possível!
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
**Treeunfe DFe** - Simplificando a integração com a SEFAZ 🚀
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeunfe/nfce",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Operações NFCe para Treeunfe DFe",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -36,15 +36,14 @@
|
|
|
36
36
|
"url": "https://github.com/treeunfe/treeunfe-dfe",
|
|
37
37
|
"directory": "packages/nfce"
|
|
38
38
|
},
|
|
39
|
-
"readme": "../../README.md",
|
|
40
39
|
"dependencies": {
|
|
41
40
|
"axios": "^1.7.7",
|
|
42
41
|
"date-fns": "^2.30.0",
|
|
43
42
|
"xml2js": "^0.6.2",
|
|
44
43
|
"sha1": "^1.1.1",
|
|
45
|
-
"@treeunfe/types": "1.0.
|
|
46
|
-
"@treeunfe/shared": "1.0.
|
|
47
|
-
"@treeunfe/danfe": "1.0.
|
|
44
|
+
"@treeunfe/types": "1.0.5",
|
|
45
|
+
"@treeunfe/shared": "1.0.5",
|
|
46
|
+
"@treeunfe/danfe": "1.0.5"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@rollup/plugin-commonjs": "^25.0.7",
|