@useinvio/nfse-sdk 0.2.3 → 1.0.0

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.
@@ -0,0 +1,54 @@
1
+ import { EmitirNotaError, emitirNfse, loadPfx, type DpsJsonRequest } from '@useinvio/nfse-sdk';
2
+
3
+ const pfx = loadPfx('./certificado.pfx', process.env.PFX_PASSWORD!);
4
+
5
+ const nota: DpsJsonRequest = {
6
+ ambiente: 'restrita',
7
+ prestador: {
8
+ cnpj: '12345678000195',
9
+ tpInsc: '2',
10
+ cLocEmi: '4106902',
11
+ serie: '1601',
12
+ opSimpNac: '1',
13
+ regEspTrib: '0',
14
+ },
15
+ servico: {
16
+ cTribNac: '010201',
17
+ xDescServ: 'Desenvolvimento de software',
18
+ cLocPrestacao: '4106902',
19
+ cNBS: '115022000',
20
+ },
21
+ emissao: {
22
+ nDPS: '1',
23
+ dhEmi: '2026-06-15T10:30:00-03:00',
24
+ dCompet: '2026-06-01',
25
+ valores: { vServ: '1500.00' },
26
+ tributacaoMunicipal: {
27
+ tribISSQN: '3',
28
+ cPaisResult: 'BR',
29
+ tpRetISSQN: '1',
30
+ },
31
+ tributacaoFederal: {
32
+ piscofins: { CST: '07' },
33
+ },
34
+ totTrib: {
35
+ pTotTribFed: '0.00',
36
+ pTotTribEst: '0.00',
37
+ pTotTribMun: '5.00',
38
+ },
39
+ },
40
+ };
41
+
42
+ try {
43
+ const resultado = await emitirNfse(nota, pfx);
44
+ console.log(resultado.chaveAcesso);
45
+ console.log(resultado.nfseXml);
46
+ } catch (error) {
47
+ if (!(error instanceof EmitirNotaError)) throw error;
48
+
49
+ console.error(`Emissao rejeitada pela SEFIN: HTTP ${error.status}`);
50
+ for (const rejeicao of error.erros) {
51
+ console.error(`${rejeicao.Codigo}: ${rejeicao.Descricao}`);
52
+ if (rejeicao.Complemento) console.error(rejeicao.Complemento);
53
+ }
54
+ }
@@ -0,0 +1,43 @@
1
+ import { buildDpsFromJson, type DpsJsonRequest } from '@useinvio/nfse-sdk';
2
+
3
+ const nota: DpsJsonRequest = {
4
+ ambiente: 'restrita',
5
+ prestador: {
6
+ cnpj: '12345678000195',
7
+ tpInsc: '2',
8
+ cLocEmi: '4106902',
9
+ serie: '1601',
10
+ opSimpNac: '1',
11
+ regEspTrib: '0',
12
+ },
13
+ servico: {
14
+ cTribNac: '010201',
15
+ xDescServ: 'Desenvolvimento de software',
16
+ cLocPrestacao: '4106902',
17
+ cNBS: '115022000',
18
+ },
19
+ emissao: {
20
+ nDPS: '1',
21
+ dhEmi: '2026-06-15T10:30:00-03:00',
22
+ dCompet: '2026-06-01',
23
+ valores: { vServ: '1500.00' },
24
+ tributacaoMunicipal: {
25
+ tribISSQN: '3',
26
+ cPaisResult: 'BR',
27
+ tpRetISSQN: '1',
28
+ },
29
+ tributacaoFederal: {
30
+ piscofins: { CST: '07' },
31
+ },
32
+ totTrib: {
33
+ pTotTribFed: '0.00',
34
+ pTotTribEst: '0.00',
35
+ pTotTribMun: '5.00',
36
+ },
37
+ },
38
+ };
39
+
40
+ const { id, xml } = buildDpsFromJson(nota);
41
+
42
+ console.log(id);
43
+ console.log(xml);
@@ -0,0 +1,24 @@
1
+ import { EmitirNotaError, emitirNfse, loadPfx, type DpsJsonRequest } from '@useinvio/nfse-sdk';
2
+
3
+ async function emitWithStructuredErrors(nota: DpsJsonRequest) {
4
+ const pfx = loadPfx('./certificado.pfx', process.env.PFX_PASSWORD!);
5
+
6
+ try {
7
+ return await emitirNfse(nota, pfx);
8
+ } catch (error) {
9
+ if (!(error instanceof EmitirNotaError)) throw error;
10
+
11
+ return {
12
+ rejected: true,
13
+ status: error.status,
14
+ dpsId: error.dpsId,
15
+ errors: error.erros.map((rejeicao) => ({
16
+ code: rejeicao.Codigo,
17
+ message: rejeicao.Descricao,
18
+ detail: rejeicao.Complemento,
19
+ })),
20
+ };
21
+ }
22
+ }
23
+
24
+ void emitWithStructuredErrors({} as DpsJsonRequest);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@useinvio/nfse-sdk",
3
- "version": "0.2.3",
4
- "description": "SDK TypeScript para integração técnica com a NFS-e Nacional.",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript SDK for Brazil's national NFS-e: JSON to DPS/XML, XMLDSIG, GZip/Base64, mTLS and SEFIN errors.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -16,6 +16,9 @@
16
16
  "dist/*.d.ts",
17
17
  "dist/*.js",
18
18
  "dist/*.js.map",
19
+ "docs/*.md",
20
+ "examples/*.ts",
21
+ "examples/README.md",
19
22
  "README.md",
20
23
  "JSON_MAPPING.md",
21
24
  "LICENSE"
@@ -29,9 +32,18 @@
29
32
  "keywords": [
30
33
  "nfse",
31
34
  "nfs-e",
35
+ "nfs-e-nacional",
32
36
  "nota-fiscal",
37
+ "nota-fiscal-servico",
38
+ "dps",
33
39
  "sefin",
34
- "sped"
40
+ "sped",
41
+ "xml-dsig",
42
+ "xmldsig",
43
+ "mtls",
44
+ "typescript",
45
+ "brazil",
46
+ "erp"
35
47
  ],
36
48
  "repository": {
37
49
  "type": "git",