apiempresas 1.3.0 → 1.5.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.
- package/README.md +72 -5
- package/dist/ApiEmpresas.d.ts +14 -2
- package/dist/ApiEmpresas.js +25 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/resources/Companies.d.ts +18 -1
- package/dist/resources/Companies.js +40 -0
- package/dist/resources/Sanctions.d.ts +13 -0
- package/dist/resources/Sanctions.js +32 -0
- package/dist/resources/Tenders.d.ts +15 -0
- package/dist/resources/Tenders.js +31 -0
- package/dist/resources/Webhooks.d.ts +4 -1
- package/dist/resources/Webhooks.js +8 -2
- package/dist/types.d.ts +363 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,13 +83,14 @@ Requiere Node.js 18 o superior (usa `fetch` nativo).
|
|
|
83
83
|
const v = await api.companies.verify('A46103834', {
|
|
84
84
|
name: 'Mercadona SA', // se compara con la razón social
|
|
85
85
|
person: 'Juan Roig Alfonso', // ¿es administrador vigente?
|
|
86
|
-
vat: true
|
|
86
|
+
vat: true, // NIF-IVA en VIES
|
|
87
|
+
iban: 'ES9121000418450200051332' // (1.5.0) ¿está bien formado? No dice de quién es la cuenta
|
|
87
88
|
});
|
|
88
89
|
console.log(v.decision_hint); // 'pass' | 'review' | 'fail'
|
|
89
90
|
console.log(v.flags); // alertas con code, severity y message
|
|
90
91
|
```
|
|
91
92
|
|
|
92
|
-
Cada empresa trae además `status_code` (ACTIVE, INSOLVENCY, EXTINCT...), `status_source`, `status_date` y, en Pro/Business, `financials` (tramo de tamaño y último año de cuentas). Los administradores traen `since`. Desde la 1.3.0 la respuesta lleva también `identifiers` (código LEI) y `legal_form` (forma jurídica con su código ISO 20275) en todos los planes, y en Pro/Business `group` (matriz directa y última según GLEIF) y `ownership` (socio único según el BORME). En `verify`, con `person`, `checks.person.is_sole_shareholder` dice si quien firma es el socio único.
|
|
93
|
+
Cada empresa trae además `status_code` (ACTIVE, INSOLVENCY, EXTINCT...), `status_source`, `status_date` y, en Pro/Business, `financials` (tramo de tamaño y último año de cuentas). Los administradores traen `since`. Desde la 1.3.0 la respuesta lleva también `identifiers` (código LEI) y `legal_form` (forma jurídica con su código ISO 20275) en todos los planes, y en Pro/Business `group` (matriz directa y última según GLEIF) y `ownership` (socio único según el BORME). En `verify`, con `person`, `checks.person.is_sole_shareholder` dice si quien firma es el socio único. Desde la 1.5.0, en Pro/Business, `size` (tramo de empleados con su fuente: Kit Digital, TED o PLACSP; null si no consta) y `address_density` (cuántas sociedades activas comparten la dirección exacta), y en `verify` con `iban`, `checks.iban` (si no es válido, alerta `IBAN_INVALID` y `decision_hint` review). `filter()` admite `size_category` (micro, small, medium, large).
|
|
93
94
|
|
|
94
95
|
### Nombre a CIF (Pro)
|
|
95
96
|
|
|
@@ -119,6 +120,13 @@ await api.watchlist.remove('A28015865');
|
|
|
119
120
|
|
|
120
121
|
```typescript
|
|
121
122
|
const hook = await api.webhooks.create({ url: 'https://tu-servidor.com/apiempresas', event: 'watchlist.*' });
|
|
123
|
+
|
|
124
|
+
// (1.5.0) Sociedades nuevas del BORME del día, con filtros opcionales
|
|
125
|
+
const nuevas = await api.webhooks.create({
|
|
126
|
+
url: 'https://tu-servidor.com/nuevas',
|
|
127
|
+
event: 'company.created',
|
|
128
|
+
filters: { province: ['MADRID', 'BARCELONA'], keywords: ['software', 'informática'], min_capital: 3000 }
|
|
129
|
+
});
|
|
122
130
|
// Guarda hook.secret: con él se comprueba la firma.
|
|
123
131
|
await api.webhooks.test(hook.id); // envía un test.ping y devuelve lo que respondió tu servidor
|
|
124
132
|
|
|
@@ -135,7 +143,7 @@ import { constructWebhookEvent } from 'apiempresas';
|
|
|
135
143
|
app.post('/apiempresas', express.raw({ type: 'application/json' }), (req, res) => {
|
|
136
144
|
try {
|
|
137
145
|
const evento = constructWebhookEvent(req.body, req.header('X-ApiEmpresas-Signature'), process.env.APIEMPRESAS_WEBHOOK_SECRET!);
|
|
138
|
-
// evento.event: company.borme_act | company.status_changed | company.risk_level_changed | test.ping
|
|
146
|
+
// evento.event: company.created | company.borme_act | company.status_changed | company.risk_level_changed | test.ping
|
|
139
147
|
// Usa evento.id (o la cabecera X-ApiEmpresas-Delivery) para no procesar dos veces el mismo envío.
|
|
140
148
|
res.sendStatus(200);
|
|
141
149
|
} catch {
|
|
@@ -146,9 +154,68 @@ app.post('/apiempresas', express.raw({ type: 'application/json' }), (req, res) =
|
|
|
146
154
|
|
|
147
155
|
Si tu servidor no responde 2xx, se reintenta a los 1 min, 5 min, 30 min, 2 h y 6 h.
|
|
148
156
|
|
|
157
|
+
### 8. Licitaciones públicas abiertas (Business) — 1 consulta
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Concursos en plazo: Plataforma de Contratación del Sector Público y plataformas autonómicas
|
|
161
|
+
const { tenders, pagination } = await api.tenders.list({ q: 'limpieza', province: 'Madrid', type: 'services' });
|
|
162
|
+
console.log(pagination.total, tenders[0].title, tenders[0].deadline, tenders[0].url);
|
|
163
|
+
|
|
164
|
+
// Las parecidas a los contratos que una empresa ya ha ganado (ordenadas por match_score)
|
|
165
|
+
const forCompany = await api.tenders.forCompany('A82018474');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 9. Listas de sanciones (Business) — 1 consulta
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// Una empresa y sus administradores vigentes, en las listas de la UE, la ONU y OFAC
|
|
172
|
+
const r = await api.sanctions.screen({ cif: 'A46103834' });
|
|
173
|
+
console.log(r.summary.result); // 'clear' | 'possible_match' | 'match'
|
|
174
|
+
|
|
175
|
+
// Un nombre suelto
|
|
176
|
+
const p = await api.sanctions.screen({ name: 'Vladimir Putin', type: 'person' });
|
|
177
|
+
// Cada coincidencia trae level (strong | possible), list, programs, countries y birth_dates para confirmarla
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
En `companies.verify()` con Business, el resultado incluye `checks.sanctions`.
|
|
181
|
+
|
|
182
|
+
### 10. Subvenciones y ayudas públicas (Business, desde 1.5.0) — 1 consulta
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// Concesiones de la BDNS desde 2022 (Kit Digital incluido)
|
|
186
|
+
const s = await api.companies.subsidies('B12345678', { year: 2025, limit: 50 });
|
|
187
|
+
console.log(s.summary.total_grants, s.summary.total_amount); // importes en texto con dos decimales
|
|
188
|
+
console.log(s.summary.by_year, s.summary.top_calls);
|
|
189
|
+
for (const g of s.grants) console.log(g.grant_date, g.amount, g.call);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 11. Feed de cambios (Business, desde 1.5.0) — 1 consulta por página
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// Todas las sociedades con un acto en el BORME desde una fecha (hasta 30 días atrás)
|
|
196
|
+
const { data, meta } = await api.companies.changes({ since: '2026-10-19', types: ['address', 'officers'], province: 'MADRID' });
|
|
197
|
+
// Siguiente página: api.companies.changes({ ...mismosFiltros, cursor: meta.next_cursor })
|
|
198
|
+
|
|
199
|
+
// O recorre todas las páginas
|
|
200
|
+
for await (const c of api.companies.iterateChanges({ since: '2026-10-19' })) {
|
|
201
|
+
console.log(c.id, c.cif, c.change_types, c.status_code); // usa c.id para no procesar dos veces el mismo cambio
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Solo salen sociedades con CIF: las recién constituidas todavía no lo tienen y llegan por el webhook `company.created`. Los tipos de cambio están en `catalog().change_types`.
|
|
206
|
+
|
|
207
|
+
### 12. Estadísticas del BORME (todos los planes, desde 1.5.0) — 1 consulta
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
const st = await api.stats({ metrics: ['incorporations', 'dissolutions'], province: 'MADRID', from: '2025-01', to: '2025-12' });
|
|
211
|
+
console.log(st.totals.incorporations);
|
|
212
|
+
for (const fila of st.series) console.log(fila.period, fila.incorporations);
|
|
213
|
+
// Por años: api.stats({ group: 'year', from: '2015', to: '2025' })
|
|
214
|
+
```
|
|
215
|
+
|
|
149
216
|
## Entorno de Pruebas (Sandbox)
|
|
150
217
|
|
|
151
|
-
Para probar la integración sin consumir saldo, apunta a la URL del Sandbox con tu misma API Key. Devuelve datos simulados: `A15075062` (empresa encontrada) y `B00000000` (no encontrada).
|
|
218
|
+
Para probar la integración sin consumir saldo, apunta a la URL del Sandbox con tu misma API Key. Devuelve datos simulados: `A15075062` (empresa encontrada) y `B00000000` (no encontrada). Tiene también `subsidies()` y `changes()`; `stats()` y `usage()` no.
|
|
152
219
|
|
|
153
220
|
```typescript
|
|
154
221
|
const api = new ApiEmpresas({
|
|
@@ -168,7 +235,7 @@ console.log(u.stats.remaining_calls, u.stats.wallet_balance, u.stats.quota_reset
|
|
|
168
235
|
|
|
169
236
|
```typescript
|
|
170
237
|
const cat = await api.catalog(); // no gasta consultas; también en el Sandbox
|
|
171
|
-
console.log(cat.province, cat.size_band, cat.radar.priority, cat.webhook_events);
|
|
238
|
+
console.log(cat.province, cat.size_band, cat.radar.priority, cat.webhook_events, cat.change_types);
|
|
172
239
|
```
|
|
173
240
|
|
|
174
241
|
## Manejo de Errores
|
package/dist/ApiEmpresas.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ApiEmpresasOptions, UsageData, CatalogData } from './types';
|
|
1
|
+
import { ApiEmpresasOptions, UsageData, CatalogData, StatsOptions, StatsResult } from './types';
|
|
2
2
|
import { Companies } from './resources/Companies';
|
|
3
3
|
import { Watchlist } from './resources/Watchlist';
|
|
4
4
|
import { Webhooks } from './resources/Webhooks';
|
|
5
|
+
import { Tenders } from './resources/Tenders';
|
|
6
|
+
import { Sanctions } from './resources/Sanctions';
|
|
5
7
|
import { verifyWebhookSignature, constructWebhookEvent } from './webhooks/signature';
|
|
6
8
|
/** Versión del SDK, enviada en el User-Agent. */
|
|
7
|
-
export declare const SDK_VERSION = "1.
|
|
9
|
+
export declare const SDK_VERSION = "1.5.0";
|
|
8
10
|
export declare class ApiEmpresas {
|
|
9
11
|
private apiKey;
|
|
10
12
|
private baseURL;
|
|
@@ -14,6 +16,10 @@ export declare class ApiEmpresas {
|
|
|
14
16
|
watchlist: Watchlist;
|
|
15
17
|
/** (Business) Webhooks. */
|
|
16
18
|
webhooks: Webhooks;
|
|
19
|
+
/** (Business) Licitaciones públicas abiertas. */
|
|
20
|
+
tenders: Tenders;
|
|
21
|
+
/** (Business) Listas de sanciones (UE, ONU, OFAC). */
|
|
22
|
+
sanctions: Sanctions;
|
|
17
23
|
/** Atajos: ApiEmpresas.verifyWebhookSignature(...) sin instanciar el cliente. */
|
|
18
24
|
static verifyWebhookSignature: typeof verifyWebhookSignature;
|
|
19
25
|
static constructWebhookEvent: typeof constructWebhookEvent;
|
|
@@ -28,5 +34,11 @@ export declare class ApiEmpresas {
|
|
|
28
34
|
* prioridades y eventos de webhook. No gasta consultas. También está en el Sandbox.
|
|
29
35
|
*/
|
|
30
36
|
catalog(): Promise<CatalogData>;
|
|
37
|
+
/**
|
|
38
|
+
* (Todos los planes, desde 1.5.0) Estadísticas del BORME por mes o año, para España o una
|
|
39
|
+
* provincia: constituciones, disoluciones, extinciones, concursos, cambios de capital y de
|
|
40
|
+
* domicilio y fusiones, desde 2009. 1 consulta. No está en el Sandbox.
|
|
41
|
+
*/
|
|
42
|
+
stats(options?: StatsOptions): Promise<StatsResult>;
|
|
31
43
|
request<T>(endpoint: string, options?: RequestInit): Promise<T>;
|
|
32
44
|
}
|
package/dist/ApiEmpresas.js
CHANGED
|
@@ -5,9 +5,11 @@ const ApiError_1 = require("./errors/ApiError");
|
|
|
5
5
|
const Companies_1 = require("./resources/Companies");
|
|
6
6
|
const Watchlist_1 = require("./resources/Watchlist");
|
|
7
7
|
const Webhooks_1 = require("./resources/Webhooks");
|
|
8
|
+
const Tenders_1 = require("./resources/Tenders");
|
|
9
|
+
const Sanctions_1 = require("./resources/Sanctions");
|
|
8
10
|
const signature_1 = require("./webhooks/signature");
|
|
9
11
|
/** Versión del SDK, enviada en el User-Agent. */
|
|
10
|
-
exports.SDK_VERSION = '1.
|
|
12
|
+
exports.SDK_VERSION = '1.5.0';
|
|
11
13
|
/**
|
|
12
14
|
* Mensaje legible del cuerpo de error. Según el error, la API lo pone en
|
|
13
15
|
* message, detail, error (texto) o messages (errores de validación).
|
|
@@ -37,6 +39,10 @@ class ApiEmpresas {
|
|
|
37
39
|
watchlist;
|
|
38
40
|
/** (Business) Webhooks. */
|
|
39
41
|
webhooks;
|
|
42
|
+
/** (Business) Licitaciones públicas abiertas. */
|
|
43
|
+
tenders;
|
|
44
|
+
/** (Business) Listas de sanciones (UE, ONU, OFAC). */
|
|
45
|
+
sanctions;
|
|
40
46
|
/** Atajos: ApiEmpresas.verifyWebhookSignature(...) sin instanciar el cliente. */
|
|
41
47
|
static verifyWebhookSignature = signature_1.verifyWebhookSignature;
|
|
42
48
|
static constructWebhookEvent = signature_1.constructWebhookEvent;
|
|
@@ -50,6 +56,8 @@ class ApiEmpresas {
|
|
|
50
56
|
this.companies = new Companies_1.Companies(this);
|
|
51
57
|
this.watchlist = new Watchlist_1.Watchlist(this);
|
|
52
58
|
this.webhooks = new Webhooks_1.Webhooks(this);
|
|
59
|
+
this.tenders = new Tenders_1.Tenders(this);
|
|
60
|
+
this.sanctions = new Sanctions_1.Sanctions(this);
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
55
63
|
* Consumo de tu API Key: consultas del periodo, cupo, saldo de créditos e historial
|
|
@@ -67,6 +75,22 @@ class ApiEmpresas {
|
|
|
67
75
|
const res = await this.request('/catalog');
|
|
68
76
|
return res.data;
|
|
69
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* (Todos los planes, desde 1.5.0) Estadísticas del BORME por mes o año, para España o una
|
|
80
|
+
* provincia: constituciones, disoluciones, extinciones, concursos, cambios de capital y de
|
|
81
|
+
* domicilio y fusiones, desde 2009. 1 consulta. No está en el Sandbox.
|
|
82
|
+
*/
|
|
83
|
+
async stats(options = {}) {
|
|
84
|
+
const params = new URLSearchParams();
|
|
85
|
+
for (const [k, v] of Object.entries(options)) {
|
|
86
|
+
if (v === undefined || v === null || v === '')
|
|
87
|
+
continue;
|
|
88
|
+
params.set(k, Array.isArray(v) ? v.join(',') : String(v));
|
|
89
|
+
}
|
|
90
|
+
const qs = params.toString();
|
|
91
|
+
const res = await this.request(`/stats${qs ? '?' + qs : ''}`);
|
|
92
|
+
return { ...res.data, meta: res.meta };
|
|
93
|
+
}
|
|
70
94
|
async request(endpoint, options = {}) {
|
|
71
95
|
const url = `${this.baseURL}${endpoint}`;
|
|
72
96
|
const headers = new Headers(options.headers || {});
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ export * from './types';
|
|
|
4
4
|
export { Companies } from './resources/Companies';
|
|
5
5
|
export { Watchlist } from './resources/Watchlist';
|
|
6
6
|
export { Webhooks } from './resources/Webhooks';
|
|
7
|
+
export { Tenders } from './resources/Tenders';
|
|
8
|
+
export { Sanctions } from './resources/Sanctions';
|
|
7
9
|
export { verifyWebhookSignature, constructWebhookEvent } from './webhooks/signature';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.constructWebhookEvent = exports.verifyWebhookSignature = exports.Webhooks = exports.Watchlist = exports.Companies = exports.ApiError = exports.ApiEmpresas = void 0;
|
|
17
|
+
exports.constructWebhookEvent = exports.verifyWebhookSignature = exports.Sanctions = exports.Tenders = exports.Webhooks = exports.Watchlist = exports.Companies = exports.ApiError = exports.ApiEmpresas = void 0;
|
|
18
18
|
var ApiEmpresas_1 = require("./ApiEmpresas");
|
|
19
19
|
Object.defineProperty(exports, "ApiEmpresas", { enumerable: true, get: function () { return ApiEmpresas_1.ApiEmpresas; } });
|
|
20
20
|
var ApiError_1 = require("./errors/ApiError");
|
|
@@ -26,6 +26,10 @@ var Watchlist_1 = require("./resources/Watchlist");
|
|
|
26
26
|
Object.defineProperty(exports, "Watchlist", { enumerable: true, get: function () { return Watchlist_1.Watchlist; } });
|
|
27
27
|
var Webhooks_1 = require("./resources/Webhooks");
|
|
28
28
|
Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return Webhooks_1.Webhooks; } });
|
|
29
|
+
var Tenders_1 = require("./resources/Tenders");
|
|
30
|
+
Object.defineProperty(exports, "Tenders", { enumerable: true, get: function () { return Tenders_1.Tenders; } });
|
|
31
|
+
var Sanctions_1 = require("./resources/Sanctions");
|
|
32
|
+
Object.defineProperty(exports, "Sanctions", { enumerable: true, get: function () { return Sanctions_1.Sanctions; } });
|
|
29
33
|
var signature_1 = require("./webhooks/signature");
|
|
30
34
|
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return signature_1.verifyWebhookSignature; } });
|
|
31
35
|
Object.defineProperty(exports, "constructWebhookEvent", { enumerable: true, get: function () { return signature_1.constructWebhookEvent; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiEmpresas } from '../ApiEmpresas';
|
|
2
|
-
import { Company, BatchRequest, BatchResponse, ScoreData, BormeData, SignalsData, VerifyOptions, VerifyResult, FilterOptions, SegmentRow, SegmentMeta, ReconcileItem, ReconcileResult, ReconcileMeta } from '../types';
|
|
2
|
+
import { Company, BatchRequest, BatchResponse, ScoreData, BormeData, SignalsData, VerifyOptions, VerifyResult, FilterOptions, SegmentRow, SegmentMeta, ReconcileItem, ReconcileResult, ReconcileMeta, SubsidiesOptions, SubsidiesResult, ChangesOptions, ChangesResult, CompanyChange } from '../types';
|
|
3
3
|
/** Opciones de get(): admin=true añade administradores y cargos (Pro/Business). */
|
|
4
4
|
export interface GetOptions {
|
|
5
5
|
admin?: boolean;
|
|
@@ -112,6 +112,23 @@ export declare class Companies {
|
|
|
112
112
|
* (Business) Obtiene los contratos públicos y licitaciones adjudicadas a una empresa.
|
|
113
113
|
*/
|
|
114
114
|
contracts(cif: string, page?: number, limit?: number): Promise<any>;
|
|
115
|
+
/**
|
|
116
|
+
* (Business, desde 1.5.0) Subvenciones y ayudas públicas de la BDNS desde 2022 (Kit Digital incluido):
|
|
117
|
+
* resumen por año, instrumento y convocatoria, y las concesiones paginadas. 1 consulta.
|
|
118
|
+
* En Free y Pro, ApiError 403 con el número y el importe en raw.upsell_opportunities.
|
|
119
|
+
*/
|
|
120
|
+
subsidies(cif: string, options?: SubsidiesOptions): Promise<SubsidiesResult>;
|
|
121
|
+
/**
|
|
122
|
+
* (Business, desde 1.5.0) Feed de cambios: todas las sociedades con un acto en el BORME desde una
|
|
123
|
+
* fecha (hasta 30 días atrás), con qué ha cambiado y su estado actual. 1 consulta por página.
|
|
124
|
+
* Solo sociedades con CIF: las recién constituidas llegan por el webhook company.created.
|
|
125
|
+
*/
|
|
126
|
+
changes(options?: ChangesOptions): Promise<ChangesResult>;
|
|
127
|
+
/**
|
|
128
|
+
* (Business, desde 1.5.0) Recorre todas las páginas del feed de cambios (1 consulta por página).
|
|
129
|
+
* for await (const c of api.companies.iterateChanges({ since: '2026-10-19' })) { ... }
|
|
130
|
+
*/
|
|
131
|
+
iterateChanges(options?: ChangesOptions): AsyncGenerator<CompanyChange, void, unknown>;
|
|
115
132
|
/**
|
|
116
133
|
* (Business) Obtiene el perfil de riesgo corporativo y solvencia de una empresa.
|
|
117
134
|
*/
|
|
@@ -42,6 +42,8 @@ class Companies {
|
|
|
42
42
|
params.set('person', options.person);
|
|
43
43
|
if (options.vat)
|
|
44
44
|
params.set('vat', 'true');
|
|
45
|
+
if (options.iban)
|
|
46
|
+
params.set('iban', options.iban);
|
|
45
47
|
const response = await this.client.request(`/companies/verify?${params.toString()}`);
|
|
46
48
|
return response.data;
|
|
47
49
|
}
|
|
@@ -195,6 +197,44 @@ class Companies {
|
|
|
195
197
|
const response = await this.client.request(`/companies/contracts?${params.toString()}`);
|
|
196
198
|
return response.data;
|
|
197
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* (Business, desde 1.5.0) Subvenciones y ayudas públicas de la BDNS desde 2022 (Kit Digital incluido):
|
|
202
|
+
* resumen por año, instrumento y convocatoria, y las concesiones paginadas. 1 consulta.
|
|
203
|
+
* En Free y Pro, ApiError 403 con el número y el importe en raw.upsell_opportunities.
|
|
204
|
+
*/
|
|
205
|
+
async subsidies(cif, options = {}) {
|
|
206
|
+
const params = new URLSearchParams({ cif });
|
|
207
|
+
if (options.year)
|
|
208
|
+
params.set('year', String(options.year));
|
|
209
|
+
if (options.page)
|
|
210
|
+
params.set('page', String(options.page));
|
|
211
|
+
if (options.limit)
|
|
212
|
+
params.set('limit', String(options.limit));
|
|
213
|
+
const response = await this.client.request(`/companies/subsidies?${params.toString()}`);
|
|
214
|
+
return response.data;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* (Business, desde 1.5.0) Feed de cambios: todas las sociedades con un acto en el BORME desde una
|
|
218
|
+
* fecha (hasta 30 días atrás), con qué ha cambiado y su estado actual. 1 consulta por página.
|
|
219
|
+
* Solo sociedades con CIF: las recién constituidas llegan por el webhook company.created.
|
|
220
|
+
*/
|
|
221
|
+
async changes(options = {}) {
|
|
222
|
+
const r = await this.client.request(`/companies/changes${(() => { const q = filterParams(options).toString(); return q ? '?' + q : ''; })()}`);
|
|
223
|
+
return { data: r.data, meta: r.meta };
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* (Business, desde 1.5.0) Recorre todas las páginas del feed de cambios (1 consulta por página).
|
|
227
|
+
* for await (const c of api.companies.iterateChanges({ since: '2026-10-19' })) { ... }
|
|
228
|
+
*/
|
|
229
|
+
async *iterateChanges(options = {}) {
|
|
230
|
+
let cursor = options.cursor;
|
|
231
|
+
do {
|
|
232
|
+
const page = await this.changes({ ...options, cursor });
|
|
233
|
+
for (const c of page.data)
|
|
234
|
+
yield c;
|
|
235
|
+
cursor = page.meta.next_cursor || undefined;
|
|
236
|
+
} while (cursor);
|
|
237
|
+
}
|
|
198
238
|
/**
|
|
199
239
|
* (Business) Obtiene el perfil de riesgo corporativo y solvencia de una empresa.
|
|
200
240
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ApiEmpresas } from '../ApiEmpresas';
|
|
2
|
+
import { SanctionsOptions, SanctionsResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* (Business) Listas de sanciones de la UE, la ONU y OFAC (EE. UU.). 1 consulta por llamada.
|
|
5
|
+
* Cada coincidencia trae su grado (strong o possible): confírmala con la fecha de nacimiento,
|
|
6
|
+
* el país y los documentos antes de decidir.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Sanctions {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(client: ApiEmpresas);
|
|
11
|
+
/** Comprueba una empresa (cif, con sus administradores vigentes) o un nombre (name). */
|
|
12
|
+
screen(options: SanctionsOptions): Promise<SanctionsResult>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Sanctions = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* (Business) Listas de sanciones de la UE, la ONU y OFAC (EE. UU.). 1 consulta por llamada.
|
|
6
|
+
* Cada coincidencia trae su grado (strong o possible): confírmala con la fecha de nacimiento,
|
|
7
|
+
* el país y los documentos antes de decidir.
|
|
8
|
+
*/
|
|
9
|
+
class Sanctions {
|
|
10
|
+
client;
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
/** Comprueba una empresa (cif, con sus administradores vigentes) o un nombre (name). */
|
|
15
|
+
async screen(options) {
|
|
16
|
+
if (!options || (!options.cif && !options.name)) {
|
|
17
|
+
throw new Error("Indica 'cif' o 'name'.");
|
|
18
|
+
}
|
|
19
|
+
const params = new URLSearchParams();
|
|
20
|
+
if (options.cif)
|
|
21
|
+
params.set('cif', options.cif);
|
|
22
|
+
if (options.name)
|
|
23
|
+
params.set('name', options.name);
|
|
24
|
+
if (options.type)
|
|
25
|
+
params.set('type', options.type);
|
|
26
|
+
if (options.directors === false)
|
|
27
|
+
params.set('directors', 'false');
|
|
28
|
+
const r = await this.client.request(`/sanctions/screen?${params.toString()}`);
|
|
29
|
+
return r.data;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.Sanctions = Sanctions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiEmpresas } from '../ApiEmpresas';
|
|
2
|
+
import { TendersOptions, TendersResult } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* (Business) Licitaciones públicas abiertas: Plataforma de Contratación del Sector Público y
|
|
5
|
+
* plataformas autonómicas agregadas. 1 consulta por llamada. En Free y Pro, ApiError 403
|
|
6
|
+
* PLAN_RESTRICTION con el número de licitaciones y 3 de muestra en raw.upsell_opportunities.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Tenders {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(client: ApiEmpresas);
|
|
11
|
+
/** Busca licitaciones. Con cif, las parecidas a los contratos que esa empresa ya ha ganado. */
|
|
12
|
+
list(options?: TendersOptions): Promise<TendersResult>;
|
|
13
|
+
/** Atajo: licitaciones abiertas parecidas a lo que ya ha ganado una empresa. */
|
|
14
|
+
forCompany(cif: string, options?: Omit<TendersOptions, 'cif'>): Promise<TendersResult>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tenders = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* (Business) Licitaciones públicas abiertas: Plataforma de Contratación del Sector Público y
|
|
6
|
+
* plataformas autonómicas agregadas. 1 consulta por llamada. En Free y Pro, ApiError 403
|
|
7
|
+
* PLAN_RESTRICTION con el número de licitaciones y 3 de muestra en raw.upsell_opportunities.
|
|
8
|
+
*/
|
|
9
|
+
class Tenders {
|
|
10
|
+
client;
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
/** Busca licitaciones. Con cif, las parecidas a los contratos que esa empresa ya ha ganado. */
|
|
15
|
+
async list(options = {}) {
|
|
16
|
+
const params = new URLSearchParams();
|
|
17
|
+
for (const [k, v] of Object.entries(options)) {
|
|
18
|
+
if (v === undefined || v === null || v === '')
|
|
19
|
+
continue;
|
|
20
|
+
params.set(k, Array.isArray(v) ? v.join(',') : String(v));
|
|
21
|
+
}
|
|
22
|
+
const qs = params.toString();
|
|
23
|
+
const r = await this.client.request(`/tenders${qs ? '?' + qs : ''}`);
|
|
24
|
+
return { ...r.data, meta: r.meta };
|
|
25
|
+
}
|
|
26
|
+
/** Atajo: licitaciones abiertas parecidas a lo que ya ha ganado una empresa. */
|
|
27
|
+
async forCompany(cif, options = {}) {
|
|
28
|
+
return this.list({ ...options, cif });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Tenders = Tenders;
|
|
@@ -5,7 +5,10 @@ export declare class Webhooks {
|
|
|
5
5
|
private client;
|
|
6
6
|
constructor(client: ApiEmpresas);
|
|
7
7
|
list(): Promise<any[]>;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Guarda el secret que devuelve: con él se comprueba la firma (verifyWebhookSignature).
|
|
10
|
+
* Con event 'company.created' puedes pasar filters (provincia, palabras del objeto social, capital...).
|
|
11
|
+
*/
|
|
9
12
|
create(options: WebhookCreateOptions): Promise<WebhookCreated>;
|
|
10
13
|
remove(id: number): Promise<boolean>;
|
|
11
14
|
/**
|
|
@@ -12,13 +12,19 @@ class Webhooks {
|
|
|
12
12
|
const r = await this.client.request('/webhooks');
|
|
13
13
|
return r.data;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Guarda el secret que devuelve: con él se comprueba la firma (verifyWebhookSignature).
|
|
17
|
+
* Con event 'company.created' puedes pasar filters (provincia, palabras del objeto social, capital...).
|
|
18
|
+
*/
|
|
16
19
|
async create(options) {
|
|
17
20
|
const r = await this.client.request('/webhooks', {
|
|
18
21
|
method: 'POST',
|
|
19
22
|
body: JSON.stringify(options)
|
|
20
23
|
});
|
|
21
|
-
|
|
24
|
+
const out = { id: r.id, event: r.event, secret: r.secret, message: r.message };
|
|
25
|
+
if (r.filters)
|
|
26
|
+
out.filters = r.filters;
|
|
27
|
+
return out;
|
|
22
28
|
}
|
|
23
29
|
async remove(id) {
|
|
24
30
|
const r = await this.client.request(`/webhooks/${encodeURIComponent(String(id))}`, { method: 'DELETE' });
|
package/dist/types.d.ts
CHANGED
|
@@ -56,6 +56,12 @@ export interface Company {
|
|
|
56
56
|
group?: CompanyGroup | null;
|
|
57
57
|
/** Pro/Business (desde 1.3.0): socio único según el BORME. */
|
|
58
58
|
ownership?: CompanyOwnership;
|
|
59
|
+
/** Pro/Business (desde 1.5.0): tramo de empleados con su fuente. null si no consta (nunca se estima). */
|
|
60
|
+
size?: CompanySize | null;
|
|
61
|
+
/** Pro/Business (desde 1.5.0): cuántas sociedades activas tienen la misma dirección exacta. */
|
|
62
|
+
address_density?: CompanyAddressDensity | null;
|
|
63
|
+
/** Todos los planes: fuente y fecha de cada bloque de datos. */
|
|
64
|
+
sources?: Record<string, any>;
|
|
59
65
|
/** Solo con get(cif, { admin: true }) en Pro/Business. since: fecha del nombramiento. */
|
|
60
66
|
administrators?: Array<{
|
|
61
67
|
name: string;
|
|
@@ -114,6 +120,25 @@ export interface CompanyOwnership {
|
|
|
114
120
|
source: 'borme' | 'name' | null;
|
|
115
121
|
as_of: string | null;
|
|
116
122
|
}
|
|
123
|
+
/** Tamaño por plantilla (desde 1.5.0). */
|
|
124
|
+
export interface CompanySize {
|
|
125
|
+
employees_min: number | null;
|
|
126
|
+
employees_max: number | null;
|
|
127
|
+
label: string | null;
|
|
128
|
+
/** micro (<10), small (10-49), medium (50-249) o large (250 o más, o no pyme). */
|
|
129
|
+
category: 'micro' | 'small' | 'medium' | 'large' | null;
|
|
130
|
+
/** kit_digital, kit_consulting, ted o placsp. */
|
|
131
|
+
source: string | null;
|
|
132
|
+
as_of: string | null;
|
|
133
|
+
}
|
|
134
|
+
/** Domicilio compartido (desde 1.5.0). */
|
|
135
|
+
export interface CompanyAddressDensity {
|
|
136
|
+
active_companies_at_address: number;
|
|
137
|
+
/** normal (menos de 10), shared (10-49) o mass (50 o más). */
|
|
138
|
+
level: 'normal' | 'shared' | 'mass';
|
|
139
|
+
match: string;
|
|
140
|
+
as_of: string | null;
|
|
141
|
+
}
|
|
117
142
|
export interface CompanyFinancials {
|
|
118
143
|
size_band?: string | null;
|
|
119
144
|
size_band_label?: string | null;
|
|
@@ -126,6 +151,21 @@ export interface VerifyOptions {
|
|
|
126
151
|
person?: string;
|
|
127
152
|
/** true: comprueba el NIF-IVA intracomunitario en VIES. */
|
|
128
153
|
vat?: boolean;
|
|
154
|
+
/** (desde 1.5.0) IBAN que te han dado: se comprueba que está bien formado. No dice de quién es la cuenta. */
|
|
155
|
+
iban?: string;
|
|
156
|
+
}
|
|
157
|
+
/** Comprobación del IBAN en verify (desde 1.5.0). */
|
|
158
|
+
export interface IbanCheck {
|
|
159
|
+
/** Enmascarado: ES91****************1332. */
|
|
160
|
+
provided: string;
|
|
161
|
+
valid: boolean;
|
|
162
|
+
country: string | null;
|
|
163
|
+
sepa: boolean;
|
|
164
|
+
/** Solo IBAN españoles: entidad (4 cifras) y oficina. */
|
|
165
|
+
bank_code: string | null;
|
|
166
|
+
branch_code: string | null;
|
|
167
|
+
/** Si no es válido: FORMAT, LENGTH, CHECKSUM o NATIONAL_CHECK_DIGITS. */
|
|
168
|
+
reason: 'FORMAT' | 'LENGTH' | 'CHECKSUM' | 'NATIONAL_CHECK_DIGITS' | null;
|
|
129
169
|
}
|
|
130
170
|
export interface VerifyFlag {
|
|
131
171
|
code: string;
|
|
@@ -144,6 +184,10 @@ export interface VerifyResult {
|
|
|
144
184
|
legal_form?: CompanyLegalForm;
|
|
145
185
|
group?: CompanyGroup | null;
|
|
146
186
|
ownership?: CompanyOwnership;
|
|
187
|
+
/** (desde 1.5.0) */
|
|
188
|
+
size?: CompanySize | null;
|
|
189
|
+
/** (desde 1.5.0) Con 10 o más sociedades sale la alerta SHARED_ADDRESS; con 50, MASS_ADDRESS. */
|
|
190
|
+
address_density?: CompanyAddressDensity | null;
|
|
147
191
|
checks: {
|
|
148
192
|
name?: {
|
|
149
193
|
provided: string;
|
|
@@ -168,6 +212,19 @@ export interface VerifyResult {
|
|
|
168
212
|
accounts?: {
|
|
169
213
|
last_accounts_year: number | null;
|
|
170
214
|
};
|
|
215
|
+
/** (desde 1.5.0) Solo si pasas iban. Si no es válido, alerta IBAN_INVALID y decision_hint review. */
|
|
216
|
+
iban?: IbanCheck;
|
|
217
|
+
/** Solo en Business: listas de sanciones (UE, ONU, OFAC) de la empresa y sus administradores. */
|
|
218
|
+
sanctions?: {
|
|
219
|
+
result: SanctionsResultCode;
|
|
220
|
+
strong_matches: number;
|
|
221
|
+
possible_matches: number;
|
|
222
|
+
directors_checked: number;
|
|
223
|
+
company_matches: SanctionMatch[];
|
|
224
|
+
director_matches: SanctionDirectorMatches[];
|
|
225
|
+
/** Fecha de cada lista cargada: { EU: '2026-10-15', UN: ..., OFAC: ... } */
|
|
226
|
+
lists: Record<string, string | null>;
|
|
227
|
+
};
|
|
171
228
|
};
|
|
172
229
|
/** Solo en Business. */
|
|
173
230
|
risk?: {
|
|
@@ -226,6 +283,8 @@ export interface FilterOptions {
|
|
|
226
283
|
founded_to?: string;
|
|
227
284
|
has_phone?: boolean;
|
|
228
285
|
size_band?: Array<'NO_REVENUE' | 'LT_500K' | '500K_1M' | 'GT_1M'> | string;
|
|
286
|
+
/** (desde 1.5.0) Tamaño por plantilla: micro, small, medium, large. */
|
|
287
|
+
size_category?: Array<'micro' | 'small' | 'medium' | 'large'> | string;
|
|
229
288
|
min_accounts_year?: number;
|
|
230
289
|
/** Filas por página (1-1000). */
|
|
231
290
|
limit?: number;
|
|
@@ -243,6 +302,8 @@ export interface SegmentRow {
|
|
|
243
302
|
status_code: StatusCode | null;
|
|
244
303
|
status_source: string | null;
|
|
245
304
|
financials: CompanyFinancials | null;
|
|
305
|
+
/** (desde 1.5.0) */
|
|
306
|
+
size?: CompanySize | null;
|
|
246
307
|
has_phone: boolean;
|
|
247
308
|
}
|
|
248
309
|
export interface SegmentMeta {
|
|
@@ -290,18 +351,37 @@ export interface WatchlistEventsOptions {
|
|
|
290
351
|
page?: number;
|
|
291
352
|
limit?: number;
|
|
292
353
|
}
|
|
293
|
-
export type WebhookEvent = 'company.borme_act' | 'company.status_changed' | 'company.risk_level_changed' | 'watchlist.*' | 'test.ping' | string;
|
|
354
|
+
export type WebhookEvent = 'company.created' | 'company.borme_act' | 'company.status_changed' | 'company.risk_level_changed' | 'watchlist.*' | 'test.ping' | string;
|
|
355
|
+
/** Filtros del evento company.created (desde 1.5.0). Sin filtros llegan todas las sociedades nuevas. */
|
|
356
|
+
export interface CompanyCreatedFilters {
|
|
357
|
+
/** Provincias del Registro Mercantil (hasta 10). Valores en catalog(). */
|
|
358
|
+
province?: string[];
|
|
359
|
+
/** Municipios (hasta 20). */
|
|
360
|
+
municipality?: string[];
|
|
361
|
+
/** Palabras del objeto social o del nombre; basta con una (hasta 20, de 3 caracteres o más). */
|
|
362
|
+
keywords?: string[];
|
|
363
|
+
/** Prefijos CNAE (hasta 20). Las recién constituidas casi nunca lo tienen: mejor keywords. */
|
|
364
|
+
cnae?: string[];
|
|
365
|
+
/** Capital social mínimo en euros. */
|
|
366
|
+
min_capital?: number;
|
|
367
|
+
/** SL, SA, SLP, SLL, SCOOP... */
|
|
368
|
+
legal_form?: string[];
|
|
369
|
+
}
|
|
294
370
|
export interface WebhookCreateOptions {
|
|
295
371
|
url: string;
|
|
296
372
|
event: WebhookEvent;
|
|
297
373
|
/** Si no lo pasas, la API genera uno y lo devuelve. */
|
|
298
374
|
secret?: string;
|
|
375
|
+
/** (desde 1.5.0) Solo con event 'company.created'. */
|
|
376
|
+
filters?: CompanyCreatedFilters;
|
|
299
377
|
}
|
|
300
378
|
export interface WebhookCreated {
|
|
301
379
|
id: number;
|
|
302
380
|
event: string;
|
|
303
381
|
secret: string;
|
|
304
382
|
message?: string;
|
|
383
|
+
/** (desde 1.5.0) Los filtros tal como los ha guardado la API (en mayúsculas). */
|
|
384
|
+
filters?: CompanyCreatedFilters;
|
|
305
385
|
}
|
|
306
386
|
export interface WebhookTestResult {
|
|
307
387
|
delivered: boolean;
|
|
@@ -367,6 +447,11 @@ export interface CatalogData {
|
|
|
367
447
|
score_priority: string[];
|
|
368
448
|
webhook_events: string[];
|
|
369
449
|
watchlist_event_types: string[];
|
|
450
|
+
/** (desde 1.5.0) Tipos de cambio del feed companies.changes(). */
|
|
451
|
+
change_types?: Array<{
|
|
452
|
+
value: string;
|
|
453
|
+
label: string;
|
|
454
|
+
} | string>;
|
|
370
455
|
[key: string]: any;
|
|
371
456
|
}
|
|
372
457
|
/** Cuerpo que recibe tu servidor. */
|
|
@@ -445,3 +530,280 @@ export interface UsageData {
|
|
|
445
530
|
found: boolean;
|
|
446
531
|
}>;
|
|
447
532
|
}
|
|
533
|
+
export interface TendersOptions {
|
|
534
|
+
/** Palabras del título (todas deben aparecer). */
|
|
535
|
+
q?: string;
|
|
536
|
+
/** CPV o su principio; varios en lista o separados por comas ('72,48'). */
|
|
537
|
+
cpv?: string | string[];
|
|
538
|
+
/** Provincia del órgano de contratación (Madrid, Bizkaia, A Coruña...). */
|
|
539
|
+
province?: string;
|
|
540
|
+
type?: 'supplies' | 'services' | 'works';
|
|
541
|
+
/** Código de procedimiento: '1' abierto, '9' abierto simplificado... */
|
|
542
|
+
procedure?: string;
|
|
543
|
+
min_amount?: number;
|
|
544
|
+
max_amount?: number;
|
|
545
|
+
/** AAAA-MM-DD */
|
|
546
|
+
deadline_from?: string;
|
|
547
|
+
deadline_to?: string;
|
|
548
|
+
published_from?: string;
|
|
549
|
+
/** Licitaciones parecidas a los contratos que esta empresa ya ha ganado. */
|
|
550
|
+
cif?: string;
|
|
551
|
+
status?: 'open' | 'prior_notice' | 'all';
|
|
552
|
+
sort?: 'deadline' | 'published' | 'amount' | 'relevance';
|
|
553
|
+
page?: number;
|
|
554
|
+
/** Máximo 100. */
|
|
555
|
+
limit?: number;
|
|
556
|
+
}
|
|
557
|
+
export interface Tender {
|
|
558
|
+
tender_id: string;
|
|
559
|
+
file_number: string | null;
|
|
560
|
+
title: string | null;
|
|
561
|
+
status: 'open' | 'prior_notice' | 'deadline_passed' | 'under_evaluation' | 'awarded' | 'resolved' | 'cancelled' | 'withdrawn' | string;
|
|
562
|
+
contracting_authority: {
|
|
563
|
+
name: string | null;
|
|
564
|
+
nif: string | null;
|
|
565
|
+
city: string | null;
|
|
566
|
+
province: string | null;
|
|
567
|
+
};
|
|
568
|
+
contract_type: 'supplies' | 'services' | 'works' | 'other' | null;
|
|
569
|
+
procedure: string | null;
|
|
570
|
+
procedure_code: string | null;
|
|
571
|
+
amount_excl_vat: number | null;
|
|
572
|
+
amount_incl_vat: number | null;
|
|
573
|
+
estimated_value: number | null;
|
|
574
|
+
currency: 'EUR';
|
|
575
|
+
lots: number | null;
|
|
576
|
+
main_cpv: string | null;
|
|
577
|
+
cpv_codes: string[];
|
|
578
|
+
execution_place: string | null;
|
|
579
|
+
published_date: string | null;
|
|
580
|
+
/** ISO 8601 con desfase horario de Madrid. */
|
|
581
|
+
deadline: string | null;
|
|
582
|
+
/** Días naturales hasta el día del plazo (0 = cierra hoy). */
|
|
583
|
+
days_left: number | null;
|
|
584
|
+
submission_platform: string;
|
|
585
|
+
url: string | null;
|
|
586
|
+
last_updated: string | null;
|
|
587
|
+
/** Solo con cif: parecido con lo que la empresa ya ha ganado. */
|
|
588
|
+
match_score?: number;
|
|
589
|
+
}
|
|
590
|
+
export interface TendersResult {
|
|
591
|
+
/** Solo con cif. */
|
|
592
|
+
company?: {
|
|
593
|
+
cif: string;
|
|
594
|
+
name: string | null;
|
|
595
|
+
contracts_used: number;
|
|
596
|
+
keywords: string[];
|
|
597
|
+
note?: string;
|
|
598
|
+
};
|
|
599
|
+
tenders: Tender[];
|
|
600
|
+
pagination: {
|
|
601
|
+
total: number;
|
|
602
|
+
page: number;
|
|
603
|
+
limit: number;
|
|
604
|
+
total_pages: number;
|
|
605
|
+
has_more: boolean;
|
|
606
|
+
};
|
|
607
|
+
meta: {
|
|
608
|
+
source: string;
|
|
609
|
+
data_updated_at: string | null;
|
|
610
|
+
status_filter: string;
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
export type SanctionsResultCode = 'clear' | 'possible_match' | 'match';
|
|
614
|
+
export interface SanctionsOptions {
|
|
615
|
+
/** CIF: la empresa y sus administradores vigentes. */
|
|
616
|
+
cif?: string;
|
|
617
|
+
/** O un nombre suelto (persona o entidad). */
|
|
618
|
+
name?: string;
|
|
619
|
+
/** Con name: 'person', 'entity' o 'any' (por defecto). */
|
|
620
|
+
type?: 'person' | 'entity' | 'any';
|
|
621
|
+
/** Con cif: false para no comprobar los administradores. */
|
|
622
|
+
directors?: boolean;
|
|
623
|
+
}
|
|
624
|
+
export interface SanctionMatch {
|
|
625
|
+
level: 'strong' | 'possible';
|
|
626
|
+
score: number;
|
|
627
|
+
list: 'EU' | 'UN' | 'OFAC' | string;
|
|
628
|
+
matched_name: string;
|
|
629
|
+
listed_name: string;
|
|
630
|
+
entry_type: 'person' | 'entity' | 'vessel' | 'aircraft' | 'other';
|
|
631
|
+
programs: string[];
|
|
632
|
+
listed_on: string | null;
|
|
633
|
+
countries: string[];
|
|
634
|
+
birth_dates: string[];
|
|
635
|
+
identifiers: string[];
|
|
636
|
+
reference: string;
|
|
637
|
+
url: string | null;
|
|
638
|
+
}
|
|
639
|
+
export interface SanctionDirectorMatches {
|
|
640
|
+
name: string;
|
|
641
|
+
position: string | null;
|
|
642
|
+
matches: SanctionMatch[];
|
|
643
|
+
}
|
|
644
|
+
export interface SanctionsList {
|
|
645
|
+
list: string;
|
|
646
|
+
description: string;
|
|
647
|
+
entries: number;
|
|
648
|
+
list_date: string | null;
|
|
649
|
+
loaded_at: string;
|
|
650
|
+
}
|
|
651
|
+
export interface SanctionsResult {
|
|
652
|
+
/** Con name. */
|
|
653
|
+
query?: {
|
|
654
|
+
name: string;
|
|
655
|
+
type: string;
|
|
656
|
+
};
|
|
657
|
+
matches?: SanctionMatch[];
|
|
658
|
+
/** Con cif. */
|
|
659
|
+
company?: {
|
|
660
|
+
cif: string;
|
|
661
|
+
name: string;
|
|
662
|
+
matches: SanctionMatch[];
|
|
663
|
+
};
|
|
664
|
+
directors?: SanctionDirectorMatches[];
|
|
665
|
+
summary: {
|
|
666
|
+
strong_matches: number;
|
|
667
|
+
possible_matches: number;
|
|
668
|
+
result: SanctionsResultCode;
|
|
669
|
+
directors_checked?: number;
|
|
670
|
+
directors_included?: boolean;
|
|
671
|
+
};
|
|
672
|
+
lists: SanctionsList[];
|
|
673
|
+
checked_at: string;
|
|
674
|
+
note: string;
|
|
675
|
+
}
|
|
676
|
+
export interface SubsidiesOptions {
|
|
677
|
+
/** Solo las concesiones de ese año. */
|
|
678
|
+
year?: number;
|
|
679
|
+
page?: number;
|
|
680
|
+
/** 1-100 (20 por defecto). */
|
|
681
|
+
limit?: number;
|
|
682
|
+
}
|
|
683
|
+
export interface Subsidy {
|
|
684
|
+
grant_date: string | null;
|
|
685
|
+
/** Texto con dos decimales, como en contracts(). */
|
|
686
|
+
amount: string | null;
|
|
687
|
+
currency: 'EUR';
|
|
688
|
+
call: string | null;
|
|
689
|
+
instrument: string | null;
|
|
690
|
+
grant_code: string | null;
|
|
691
|
+
}
|
|
692
|
+
export interface SubsidiesSummary {
|
|
693
|
+
total_grants: number;
|
|
694
|
+
total_amount: string;
|
|
695
|
+
currency: 'EUR';
|
|
696
|
+
first_grant_date: string | null;
|
|
697
|
+
last_grant_date: string | null;
|
|
698
|
+
by_year: Array<{
|
|
699
|
+
year: number | null;
|
|
700
|
+
grants: number;
|
|
701
|
+
amount: string;
|
|
702
|
+
}>;
|
|
703
|
+
by_instrument: Array<{
|
|
704
|
+
instrument: string | null;
|
|
705
|
+
grants: number;
|
|
706
|
+
amount: string;
|
|
707
|
+
}>;
|
|
708
|
+
top_calls: Array<{
|
|
709
|
+
call: string | null;
|
|
710
|
+
grants: number;
|
|
711
|
+
amount: string;
|
|
712
|
+
last_grant_date: string | null;
|
|
713
|
+
}>;
|
|
714
|
+
}
|
|
715
|
+
export interface SubsidiesResult {
|
|
716
|
+
cif: string;
|
|
717
|
+
company_name: string | null;
|
|
718
|
+
year: number | null;
|
|
719
|
+
summary: SubsidiesSummary;
|
|
720
|
+
grants: Subsidy[];
|
|
721
|
+
pagination: {
|
|
722
|
+
total: number;
|
|
723
|
+
page: number;
|
|
724
|
+
limit: number;
|
|
725
|
+
total_pages: number;
|
|
726
|
+
has_more: boolean;
|
|
727
|
+
};
|
|
728
|
+
sources: {
|
|
729
|
+
subsidies: {
|
|
730
|
+
source: 'bdns';
|
|
731
|
+
as_of: string | null;
|
|
732
|
+
from: string;
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
previous_cif_match?: any;
|
|
736
|
+
}
|
|
737
|
+
export type ChangeType = 'incorporation' | 'officers' | 'address' | 'name' | 'purpose' | 'capital' | 'sole_shareholder' | 'dissolution' | 'insolvency' | 'structural' | 'registry_closure' | 'other';
|
|
738
|
+
export interface ChangesOptions {
|
|
739
|
+
/** AAAA-MM-DD (incluida). Por defecto, ayer. Como mucho 30 días atrás. */
|
|
740
|
+
since?: string;
|
|
741
|
+
/** AAAA-MM-DD (incluida). */
|
|
742
|
+
until?: string;
|
|
743
|
+
types?: ChangeType[] | string;
|
|
744
|
+
province?: string;
|
|
745
|
+
/** Prefijos CNAE. */
|
|
746
|
+
cnae?: string[] | string;
|
|
747
|
+
/** 1-1000 (500 por defecto). */
|
|
748
|
+
limit?: number;
|
|
749
|
+
/** meta.next_cursor de la página anterior. */
|
|
750
|
+
cursor?: string;
|
|
751
|
+
}
|
|
752
|
+
export interface CompanyChange {
|
|
753
|
+
/** Estable: úsalo para no procesar dos veces el mismo cambio. */
|
|
754
|
+
id: string;
|
|
755
|
+
date: string;
|
|
756
|
+
cif: string;
|
|
757
|
+
company_name: string | null;
|
|
758
|
+
change_types: ChangeType[];
|
|
759
|
+
/** Tipos de acto tal como los publica el BORME (en español). */
|
|
760
|
+
act_types: string[];
|
|
761
|
+
status_code: StatusCode | null;
|
|
762
|
+
province: string | null;
|
|
763
|
+
cnae: string | null;
|
|
764
|
+
borme_pdf: string | null;
|
|
765
|
+
}
|
|
766
|
+
export interface ChangesMeta {
|
|
767
|
+
since: string;
|
|
768
|
+
until: string | null;
|
|
769
|
+
filters: Record<string, any>;
|
|
770
|
+
count: number;
|
|
771
|
+
limit: number;
|
|
772
|
+
has_more: boolean;
|
|
773
|
+
next_cursor: string | null;
|
|
774
|
+
last_borme_date: string | null;
|
|
775
|
+
}
|
|
776
|
+
export interface ChangesResult {
|
|
777
|
+
data: CompanyChange[];
|
|
778
|
+
meta: ChangesMeta;
|
|
779
|
+
}
|
|
780
|
+
export type StatsMetric = 'incorporations' | 'dissolutions' | 'extinctions' | 'insolvencies' | 'capital_increases' | 'capital_reductions' | 'address_changes' | 'mergers';
|
|
781
|
+
export interface StatsOptions {
|
|
782
|
+
/** Por defecto, todas. */
|
|
783
|
+
metrics?: StatsMetric[] | string;
|
|
784
|
+
/** Nombre de catalog() (MADRID) o código INE (28). Sin ella, toda España. */
|
|
785
|
+
province?: string;
|
|
786
|
+
/** AAAA-MM o AAAA. Por defecto, 11 meses antes de to. */
|
|
787
|
+
from?: string;
|
|
788
|
+
/** AAAA-MM o AAAA. Por defecto, el mes actual. */
|
|
789
|
+
to?: string;
|
|
790
|
+
group?: 'month' | 'year';
|
|
791
|
+
}
|
|
792
|
+
export interface StatsResult {
|
|
793
|
+
province: string | null;
|
|
794
|
+
province_code: string | null;
|
|
795
|
+
group: 'month' | 'year';
|
|
796
|
+
from: string;
|
|
797
|
+
to: string;
|
|
798
|
+
totals: Partial<Record<StatsMetric, number>>;
|
|
799
|
+
/** Una fila por periodo (sin huecos: 0 si no hubo actos). */
|
|
800
|
+
series: Array<{
|
|
801
|
+
period: string;
|
|
802
|
+
} & Partial<Record<StatsMetric, number>>>;
|
|
803
|
+
meta?: {
|
|
804
|
+
source: 'borme';
|
|
805
|
+
last_borme_date: string | null;
|
|
806
|
+
computed_at: string | null;
|
|
807
|
+
notes: string;
|
|
808
|
+
};
|
|
809
|
+
}
|