@mrbody/angofind 1.0.1
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/README.md +16 -0
- package/dist/GraphQL/contribuinte.d.ts +1 -0
- package/dist/GraphQL/index.d.ts +4 -0
- package/dist/GraphQL/nif.d.ts +1 -0
- package/dist/GraphQL/publication.d.ts +1 -0
- package/dist/GraphQL/publicationURL.d.ts +1 -0
- package/dist/angoFind.d.ts +26 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +143 -0
- package/dist/request.d.ts +15 -0
- package/dist/types/BiData.d.ts +22 -0
- package/dist/types/ContribuinteArgs.d.ts +3 -0
- package/dist/types/ContribuinteData.d.ts +11 -0
- package/dist/types/GuePublication.d.ts +8 -0
- package/dist/types/GuePublicationURL.d.ts +12 -0
- package/dist/types/NifArgs.d.ts +3 -0
- package/dist/types/PublicationArgs.d.ts +6 -0
- package/dist/types/PublicationURLArgs.d.ts +3 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# angofind-lib
|
|
2
|
+
|
|
3
|
+
To install dependencies:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
To run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run index.ts
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This project was created using `bun init` in bun v1.4.0. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
|
16
|
+
# angofind-sdk
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GET_CONTRIBUINTE = "\n query GetContribuinte($nif: String!) {\n Contribuinte(nif: $nif) {\n nif\n nome\n denominacao\n estado\n reparticaoFiscal\n tipoContribuinte\n dataInicioAtividade\n atividadePrincipal\n rawText\n }\n }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GET_NIF = "\n query GetNif($ref: String!) {\n Nif(ref: $ref) {\n numero\n nome_completo\n denominacao\n nome\n email\n telemovel\n numero_contacto\n data_constituicao\n nif_administrador\n utente_morada2\n apelido\n nif\n data_nasc\n genero\n naturalidade\n pai_nome_completo\n mae_nome_completo\n estado_civil\n data_emissao\n emissao_local\n }\n }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GET_PUBLICATION = "\n query GetPublication($empresa: String, $nome: String, $ndi: String, $telefone: String) {\n Publication(empresa: $empresa, nome: $nome, ndi: $ndi, telefone: $telefone) {\n posicao\n nome\n dataPublicacao\n nif\n origem\n link\n }\n }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GET_PUBLICATION_URL = "\n query GetPublicationURL($url: String!) {\n PublicationURL(url: $url) {\n source\n registrationNumber\n companyName\n capital\n subject\n headquarters\n partner\n manager\n signedDate\n rawText\n }\n }\n";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BiData } from "./types/BiData";
|
|
2
|
+
import type { ContribuinteData } from "./types/ContribuinteData";
|
|
3
|
+
import type { GuePublication } from "./types/GuePublication";
|
|
4
|
+
import type { GuePublicationURL } from "./types/GuePublicationURL";
|
|
5
|
+
import type { PublicationArgs } from "./types/PublicationArgs";
|
|
6
|
+
import { RequestOptions } from "./request";
|
|
7
|
+
export declare class AngoFind {
|
|
8
|
+
private requester;
|
|
9
|
+
constructor(config: RequestOptions);
|
|
10
|
+
/**
|
|
11
|
+
* Busca empresas no portal GUE por empresa, nome, NDI ou telefone
|
|
12
|
+
*/
|
|
13
|
+
getPublication(params: PublicationArgs): Promise<GuePublication[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Obtém detalhes extraídos da publicação do GUE a partir da URL
|
|
16
|
+
*/
|
|
17
|
+
getPublicationURL(url: string): Promise<GuePublicationURL>;
|
|
18
|
+
/**
|
|
19
|
+
* Consulta informações fiscais/identidade pelo NIF ou BI (DTSER)
|
|
20
|
+
*/
|
|
21
|
+
getNif(ref: string): Promise<BiData>;
|
|
22
|
+
/**
|
|
23
|
+
* Consulta informações do Contribuinte no Portal da AGT / MINFIN
|
|
24
|
+
*/
|
|
25
|
+
getContribuinte(nif: string): Promise<ContribuinteData>;
|
|
26
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AngoFind } from "./angoFind";
|
|
2
|
+
export * from "./GraphQL";
|
|
3
|
+
export type * from "./types/BiData";
|
|
4
|
+
export type * from "./types/ContribuinteArgs";
|
|
5
|
+
export type * from "./types/ContribuinteData";
|
|
6
|
+
export type * from "./types/GuePublication";
|
|
7
|
+
export type * from "./types/GuePublicationURL";
|
|
8
|
+
export type * from "./types/NifArgs";
|
|
9
|
+
export type * from "./types/PublicationArgs";
|
|
10
|
+
export type * from "./types/PublicationURLArgs";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// request.ts
|
|
2
|
+
class Request {
|
|
3
|
+
server;
|
|
4
|
+
apiKey;
|
|
5
|
+
option;
|
|
6
|
+
constructor({ server = "https://angofind.vercel.app/api/graphql", apiKey, option = {} }) {
|
|
7
|
+
if (!apiKey) {
|
|
8
|
+
throw new Error("API_KEY não fornecida");
|
|
9
|
+
}
|
|
10
|
+
this.server = server;
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
this.option = option;
|
|
13
|
+
}
|
|
14
|
+
async send(query, variables) {
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch(this.server, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
"x-api-key": this.apiKey,
|
|
21
|
+
...this.option.headers || {}
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
query,
|
|
25
|
+
variables
|
|
26
|
+
}),
|
|
27
|
+
...this.option
|
|
28
|
+
});
|
|
29
|
+
const result = await response.json();
|
|
30
|
+
if (result.errors) {
|
|
31
|
+
throw new Error(result.errors.map((e) => e.message).join(", "));
|
|
32
|
+
}
|
|
33
|
+
return result.data;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error("Erro na requisição GraphQL:", error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// GraphQL/publication.ts
|
|
42
|
+
var GET_PUBLICATION = `
|
|
43
|
+
query GetPublication($empresa: String, $nome: String, $ndi: String, $telefone: String) {
|
|
44
|
+
Publication(empresa: $empresa, nome: $nome, ndi: $ndi, telefone: $telefone) {
|
|
45
|
+
posicao
|
|
46
|
+
nome
|
|
47
|
+
dataPublicacao
|
|
48
|
+
nif
|
|
49
|
+
origem
|
|
50
|
+
link
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
// GraphQL/publicationURL.ts
|
|
55
|
+
var GET_PUBLICATION_URL = `
|
|
56
|
+
query GetPublicationURL($url: String!) {
|
|
57
|
+
PublicationURL(url: $url) {
|
|
58
|
+
source
|
|
59
|
+
registrationNumber
|
|
60
|
+
companyName
|
|
61
|
+
capital
|
|
62
|
+
subject
|
|
63
|
+
headquarters
|
|
64
|
+
partner
|
|
65
|
+
manager
|
|
66
|
+
signedDate
|
|
67
|
+
rawText
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
// GraphQL/nif.ts
|
|
72
|
+
var GET_NIF = `
|
|
73
|
+
query GetNif($ref: String!) {
|
|
74
|
+
Nif(ref: $ref) {
|
|
75
|
+
numero
|
|
76
|
+
nome_completo
|
|
77
|
+
denominacao
|
|
78
|
+
nome
|
|
79
|
+
email
|
|
80
|
+
telemovel
|
|
81
|
+
numero_contacto
|
|
82
|
+
data_constituicao
|
|
83
|
+
nif_administrador
|
|
84
|
+
utente_morada2
|
|
85
|
+
apelido
|
|
86
|
+
nif
|
|
87
|
+
data_nasc
|
|
88
|
+
genero
|
|
89
|
+
naturalidade
|
|
90
|
+
pai_nome_completo
|
|
91
|
+
mae_nome_completo
|
|
92
|
+
estado_civil
|
|
93
|
+
data_emissao
|
|
94
|
+
emissao_local
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
// GraphQL/contribuinte.ts
|
|
99
|
+
var GET_CONTRIBUINTE = `
|
|
100
|
+
query GetContribuinte($nif: String!) {
|
|
101
|
+
Contribuinte(nif: $nif) {
|
|
102
|
+
nif
|
|
103
|
+
nome
|
|
104
|
+
denominacao
|
|
105
|
+
estado
|
|
106
|
+
reparticaoFiscal
|
|
107
|
+
tipoContribuinte
|
|
108
|
+
dataInicioAtividade
|
|
109
|
+
atividadePrincipal
|
|
110
|
+
rawText
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
// angoFind.ts
|
|
115
|
+
class AngoFind {
|
|
116
|
+
requester;
|
|
117
|
+
constructor(config) {
|
|
118
|
+
this.requester = new Request(config);
|
|
119
|
+
}
|
|
120
|
+
async getPublication(params) {
|
|
121
|
+
const data = await this.requester.send(GET_PUBLICATION, params);
|
|
122
|
+
return data.Publication;
|
|
123
|
+
}
|
|
124
|
+
async getPublicationURL(url) {
|
|
125
|
+
const data = await this.requester.send(GET_PUBLICATION_URL, { url });
|
|
126
|
+
return data.PublicationURL;
|
|
127
|
+
}
|
|
128
|
+
async getNif(ref) {
|
|
129
|
+
const data = await this.requester.send(GET_NIF, { ref });
|
|
130
|
+
return data.Nif;
|
|
131
|
+
}
|
|
132
|
+
async getContribuinte(nif2) {
|
|
133
|
+
const data = await this.requester.send(GET_CONTRIBUINTE, { nif: nif2 });
|
|
134
|
+
return data.Contribuinte;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
AngoFind,
|
|
139
|
+
GET_CONTRIBUINTE,
|
|
140
|
+
GET_NIF,
|
|
141
|
+
GET_PUBLICATION,
|
|
142
|
+
GET_PUBLICATION_URL
|
|
143
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface RequestOptions {
|
|
2
|
+
server?: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
option?: RequestInit;
|
|
5
|
+
}
|
|
6
|
+
export declare class Request {
|
|
7
|
+
private server;
|
|
8
|
+
private apiKey;
|
|
9
|
+
private option;
|
|
10
|
+
constructor({ server, apiKey, option }: RequestOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Executa requisições POST genéricas no GraphQL
|
|
13
|
+
*/
|
|
14
|
+
send<T>(query: string, variables?: Record<string, any>): Promise<T>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface BiData {
|
|
2
|
+
numero?: string | null;
|
|
3
|
+
nome_completo?: string | null;
|
|
4
|
+
denominacao?: string | null;
|
|
5
|
+
nome?: string | null;
|
|
6
|
+
email?: string | null;
|
|
7
|
+
telemovel?: string | null;
|
|
8
|
+
numero_contacto?: string | null;
|
|
9
|
+
data_constituicao?: string | null;
|
|
10
|
+
nif_administrador?: string | null;
|
|
11
|
+
utente_morada2?: string | null;
|
|
12
|
+
apelido?: string | null;
|
|
13
|
+
nif?: string | null;
|
|
14
|
+
data_nasc?: string | null;
|
|
15
|
+
genero?: string | null;
|
|
16
|
+
naturalidade?: string | null;
|
|
17
|
+
pai_nome_completo?: string | null;
|
|
18
|
+
mae_nome_completo?: string | null;
|
|
19
|
+
estado_civil?: string | null;
|
|
20
|
+
data_emissao?: string | null;
|
|
21
|
+
emissao_local?: string | null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ContribuinteData {
|
|
2
|
+
nif?: string | null;
|
|
3
|
+
nome?: string | null;
|
|
4
|
+
denominacao?: string | null;
|
|
5
|
+
estado?: string | null;
|
|
6
|
+
reparticaoFiscal?: string | null;
|
|
7
|
+
tipoContribuinte?: string | null;
|
|
8
|
+
dataInicioAtividade?: string | null;
|
|
9
|
+
atividadePrincipal?: string | null;
|
|
10
|
+
rawText?: string | null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface GuePublicationURL {
|
|
2
|
+
source?: string | null;
|
|
3
|
+
registrationNumber?: string | null;
|
|
4
|
+
companyName?: string | null;
|
|
5
|
+
capital?: string | null;
|
|
6
|
+
subject?: string | null;
|
|
7
|
+
headquarters?: string | null;
|
|
8
|
+
partner?: string | null;
|
|
9
|
+
manager?: string | null;
|
|
10
|
+
signedDate?: string | null;
|
|
11
|
+
rawText?: string | null;
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mrbody/angofind",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Official JavaScript SDK for the AngoFind API",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "bun build index.ts --outdir dist --target node && tsc --declaration --emitDeclarationOnly",
|
|
15
|
+
"dev": "bun run index.ts",
|
|
16
|
+
"pack": "mkdir -p packages && npm pack && mv *.tgz packages/",
|
|
17
|
+
"prepublishOnly": "bun run build && npm run pack"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/bun": "latest"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"typescript": "^7"
|
|
24
|
+
}
|
|
25
|
+
}
|