@nubiia/mcp-freematica 0.6.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/LICENSE +21 -0
- package/README.md +485 -0
- package/dist/clients/base-client.d.ts +31 -0
- package/dist/clients/base-client.js +102 -0
- package/dist/clients/base-client.js.map +1 -0
- package/dist/clients/fiql-builder.d.ts +118 -0
- package/dist/clients/fiql-builder.js +257 -0
- package/dist/clients/fiql-builder.js.map +1 -0
- package/dist/clients/freematica-client.d.ts +659 -0
- package/dist/clients/freematica-client.js +1327 -0
- package/dist/clients/freematica-client.js.map +1 -0
- package/dist/clients/hardened-base-client.d.ts +143 -0
- package/dist/clients/hardened-base-client.js +366 -0
- package/dist/clients/hardened-base-client.js.map +1 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +71 -0
- package/dist/logger.js +114 -0
- package/dist/logger.js.map +1 -0
- package/dist/schemas/albaranes.d.ts +124 -0
- package/dist/schemas/albaranes.js +250 -0
- package/dist/schemas/albaranes.js.map +1 -0
- package/dist/schemas/cartera.d.ts +70 -0
- package/dist/schemas/cartera.js +104 -0
- package/dist/schemas/cartera.js.map +1 -0
- package/dist/schemas/contratos.d.ts +7 -0
- package/dist/schemas/contratos.js +2 -0
- package/dist/schemas/contratos.js.map +1 -0
- package/dist/schemas/facturas-electronicas.d.ts +60 -0
- package/dist/schemas/facturas-electronicas.js +79 -0
- package/dist/schemas/facturas-electronicas.js.map +1 -0
- package/dist/schemas/facturas-ventas.d.ts +118 -0
- package/dist/schemas/facturas-ventas.js +153 -0
- package/dist/schemas/facturas-ventas.js.map +1 -0
- package/dist/schemas/filters.d.ts +92 -0
- package/dist/schemas/filters.js +76 -0
- package/dist/schemas/filters.js.map +1 -0
- package/dist/schemas/master-data.d.ts +26 -0
- package/dist/schemas/master-data.js +86 -0
- package/dist/schemas/master-data.js.map +1 -0
- package/dist/schemas/pagination.d.ts +14 -0
- package/dist/schemas/pagination.js +27 -0
- package/dist/schemas/pagination.js.map +1 -0
- package/dist/schemas/pedidos-compras.d.ts +92 -0
- package/dist/schemas/pedidos-compras.js +189 -0
- package/dist/schemas/pedidos-compras.js.map +1 -0
- package/dist/server-instructions.d.ts +1 -0
- package/dist/server-instructions.js +83 -0
- package/dist/server-instructions.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.js +41 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/albaranes.d.ts +16 -0
- package/dist/tools/albaranes.js +202 -0
- package/dist/tools/albaranes.js.map +1 -0
- package/dist/tools/calendarios.d.ts +13 -0
- package/dist/tools/calendarios.js +82 -0
- package/dist/tools/calendarios.js.map +1 -0
- package/dist/tools/cartera.d.ts +13 -0
- package/dist/tools/cartera.js +78 -0
- package/dist/tools/cartera.js.map +1 -0
- package/dist/tools/clientes.d.ts +3 -0
- package/dist/tools/clientes.js +48 -0
- package/dist/tools/clientes.js.map +1 -0
- package/dist/tools/contabilidad.d.ts +14 -0
- package/dist/tools/contabilidad.js +259 -0
- package/dist/tools/contabilidad.js.map +1 -0
- package/dist/tools/contactos-clientes.d.ts +3 -0
- package/dist/tools/contactos-clientes.js +25 -0
- package/dist/tools/contactos-clientes.js.map +1 -0
- package/dist/tools/contratos.d.ts +10 -0
- package/dist/tools/contratos.js +35 -0
- package/dist/tools/contratos.js.map +1 -0
- package/dist/tools/facturas-compras.d.ts +13 -0
- package/dist/tools/facturas-compras.js +131 -0
- package/dist/tools/facturas-compras.js.map +1 -0
- package/dist/tools/facturas-electronicas.d.ts +17 -0
- package/dist/tools/facturas-electronicas.js +268 -0
- package/dist/tools/facturas-electronicas.js.map +1 -0
- package/dist/tools/facturas-ventas.d.ts +16 -0
- package/dist/tools/facturas-ventas.js +181 -0
- package/dist/tools/facturas-ventas.js.map +1 -0
- package/dist/tools/helpers.d.ts +17 -0
- package/dist/tools/helpers.js +36 -0
- package/dist/tools/helpers.js.map +1 -0
- package/dist/tools/localizaciones.d.ts +17 -0
- package/dist/tools/localizaciones.js +192 -0
- package/dist/tools/localizaciones.js.map +1 -0
- package/dist/tools/master-data.d.ts +10 -0
- package/dist/tools/master-data.js +70 -0
- package/dist/tools/master-data.js.map +1 -0
- package/dist/tools/oportunidades-negocio.d.ts +3 -0
- package/dist/tools/oportunidades-negocio.js +68 -0
- package/dist/tools/oportunidades-negocio.js.map +1 -0
- package/dist/tools/pedidos-compras.d.ts +14 -0
- package/dist/tools/pedidos-compras.js +105 -0
- package/dist/tools/pedidos-compras.js.map +1 -0
- package/dist/tools/personal.d.ts +13 -0
- package/dist/tools/personal.js +154 -0
- package/dist/tools/personal.js.map +1 -0
- package/dist/tools/prl.d.ts +47 -0
- package/dist/tools/prl.js +242 -0
- package/dist/tools/prl.js.map +1 -0
- package/dist/tools/proveedores.d.ts +14 -0
- package/dist/tools/proveedores.js +122 -0
- package/dist/tools/proveedores.js.map +1 -0
- package/dist/transports/http.d.ts +12 -0
- package/dist/transports/http.js +110 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/stdio.d.ts +12 -0
- package/dist/transports/stdio.js +15 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/types/api-envelope.d.ts +27 -0
- package/dist/types/api-envelope.js +2 -0
- package/dist/types/api-envelope.js.map +1 -0
- package/dist/types/clientes.d.ts +9 -0
- package/dist/types/clientes.js +2 -0
- package/dist/types/clientes.js.map +1 -0
- package/dist/types/contactos-clientes.d.ts +7 -0
- package/dist/types/contactos-clientes.js +2 -0
- package/dist/types/contactos-clientes.js.map +1 -0
- package/dist/types/contratos.d.ts +8 -0
- package/dist/types/contratos.js +2 -0
- package/dist/types/contratos.js.map +1 -0
- package/dist/types/master-data.d.ts +9 -0
- package/dist/types/master-data.js +2 -0
- package/dist/types/master-data.js.map +1 -0
- package/dist/types/oportunidades-negocio.d.ts +8 -0
- package/dist/types/oportunidades-negocio.js +2 -0
- package/dist/types/oportunidades-negocio.js.map +1 -0
- package/dist/utils/size-guardrail.d.ts +22 -0
- package/dist/utils/size-guardrail.js +31 -0
- package/dist/utils/size-guardrail.js.map +1 -0
- package/package.json +90 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const AuthConfigSchema: z.ZodObject<{
|
|
3
|
+
FREEMATICA_BASE_URL: z.ZodDefault<z.ZodString>;
|
|
4
|
+
FREEMATICA_AUTH_TOKEN: z.ZodString;
|
|
5
|
+
FREEMATICA_AUTH_COMPANY: z.ZodString;
|
|
6
|
+
FREEMATICA_AUTH_ORGANIZATION: z.ZodString;
|
|
7
|
+
FREEMATICA_AUTH_APP: z.ZodString;
|
|
8
|
+
FREEMATICA_AUTH_SESSION: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
FREEMATICA_BASE_URL: string;
|
|
11
|
+
FREEMATICA_AUTH_TOKEN: string;
|
|
12
|
+
FREEMATICA_AUTH_COMPANY: string;
|
|
13
|
+
FREEMATICA_AUTH_ORGANIZATION: string;
|
|
14
|
+
FREEMATICA_AUTH_APP: string;
|
|
15
|
+
FREEMATICA_AUTH_SESSION: string;
|
|
16
|
+
}, {
|
|
17
|
+
FREEMATICA_AUTH_TOKEN: string;
|
|
18
|
+
FREEMATICA_AUTH_COMPANY: string;
|
|
19
|
+
FREEMATICA_AUTH_ORGANIZATION: string;
|
|
20
|
+
FREEMATICA_AUTH_APP: string;
|
|
21
|
+
FREEMATICA_AUTH_SESSION: string;
|
|
22
|
+
FREEMATICA_BASE_URL?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
declare const HttpConfigSchema: z.ZodObject<{
|
|
25
|
+
MCP_PORT: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
MCP_ALLOWED_ORIGINS: z.ZodDefault<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
MCP_PORT: number;
|
|
29
|
+
MCP_ALLOWED_ORIGINS: string;
|
|
30
|
+
}, {
|
|
31
|
+
MCP_PORT?: number | undefined;
|
|
32
|
+
MCP_ALLOWED_ORIGINS?: string | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Configuración de hardening del cliente HTTP.
|
|
36
|
+
*
|
|
37
|
+
* Todas las variables tienen valores por defecto seguros que no requieren
|
|
38
|
+
* configuración explícita en la mayoría de los entornos.
|
|
39
|
+
*/
|
|
40
|
+
declare const HardeningConfigSchema: z.ZodObject<{
|
|
41
|
+
/**
|
|
42
|
+
* Timeout por petición HTTP en milisegundos.
|
|
43
|
+
* Por defecto: 30000 (30 segundos).
|
|
44
|
+
*/
|
|
45
|
+
FREEMATICA_TIMEOUT_MS: z.ZodDefault<z.ZodNumber>;
|
|
46
|
+
/**
|
|
47
|
+
* Número máximo de reintentos para errores 5xx y errores de red.
|
|
48
|
+
* Los errores 4xx nunca se reintentan.
|
|
49
|
+
* Por defecto: 3.
|
|
50
|
+
*/
|
|
51
|
+
FREEMATICA_MAX_RETRIES: z.ZodDefault<z.ZodNumber>;
|
|
52
|
+
/**
|
|
53
|
+
* Nivel de logging de pino.
|
|
54
|
+
* Valores válidos: trace | debug | info | warn | error | fatal.
|
|
55
|
+
* Por defecto: info.
|
|
56
|
+
*/
|
|
57
|
+
LOG_LEVEL: z.ZodDefault<z.ZodEnum<["trace", "debug", "info", "warn", "error", "fatal"]>>;
|
|
58
|
+
/**
|
|
59
|
+
* Número de fallos consecutivos antes de abrir el circuit breaker.
|
|
60
|
+
* Por defecto: 5.
|
|
61
|
+
*/
|
|
62
|
+
FREEMATICA_CIRCUIT_BREAKER_THRESHOLD: z.ZodDefault<z.ZodNumber>;
|
|
63
|
+
/**
|
|
64
|
+
* Tiempo en ms que el circuit breaker permanece abierto antes de pasar
|
|
65
|
+
* a half-open para intentar recuperarse.
|
|
66
|
+
* Por defecto: 30000 (30 segundos).
|
|
67
|
+
*/
|
|
68
|
+
FREEMATICA_CIRCUIT_BREAKER_TIMEOUT_MS: z.ZodDefault<z.ZodNumber>;
|
|
69
|
+
/**
|
|
70
|
+
* Tamaño máximo de respuesta aceptado por freematica_export_asientos en
|
|
71
|
+
* megabytes. Si la respuesta del API supera este umbral, los datos se
|
|
72
|
+
* truncan y se añade un campo `warning` a la respuesta de la tool.
|
|
73
|
+
*
|
|
74
|
+
* Se recomienda usar rangos de fecha cortos (max. 1 mes) para evitar
|
|
75
|
+
* alcanzar este límite.
|
|
76
|
+
*
|
|
77
|
+
* Por defecto: 10 (10 MB).
|
|
78
|
+
* Mínimo: 1 MB. Máximo: 500 MB.
|
|
79
|
+
*/
|
|
80
|
+
FREEMATICA_MAX_RESPONSE_SIZE_MB: z.ZodDefault<z.ZodNumber>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
FREEMATICA_TIMEOUT_MS: number;
|
|
83
|
+
FREEMATICA_MAX_RETRIES: number;
|
|
84
|
+
LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
85
|
+
FREEMATICA_CIRCUIT_BREAKER_THRESHOLD: number;
|
|
86
|
+
FREEMATICA_CIRCUIT_BREAKER_TIMEOUT_MS: number;
|
|
87
|
+
FREEMATICA_MAX_RESPONSE_SIZE_MB: number;
|
|
88
|
+
}, {
|
|
89
|
+
FREEMATICA_TIMEOUT_MS?: number | undefined;
|
|
90
|
+
FREEMATICA_MAX_RETRIES?: number | undefined;
|
|
91
|
+
LOG_LEVEL?: "trace" | "debug" | "info" | "warn" | "error" | "fatal" | undefined;
|
|
92
|
+
FREEMATICA_CIRCUIT_BREAKER_THRESHOLD?: number | undefined;
|
|
93
|
+
FREEMATICA_CIRCUIT_BREAKER_TIMEOUT_MS?: number | undefined;
|
|
94
|
+
FREEMATICA_MAX_RESPONSE_SIZE_MB?: number | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
export type AuthConfig = z.infer<typeof AuthConfigSchema>;
|
|
97
|
+
export type HttpConfig = z.infer<typeof HttpConfigSchema>;
|
|
98
|
+
export type HardeningConfig = z.infer<typeof HardeningConfigSchema>;
|
|
99
|
+
export type Config = AuthConfig & HttpConfig & HardeningConfig;
|
|
100
|
+
export declare function loadAuthConfig(): AuthConfig;
|
|
101
|
+
export declare function loadHttpConfig(): HttpConfig;
|
|
102
|
+
export declare function loadHardeningConfig(): HardeningConfig;
|
|
103
|
+
export declare function loadConfig(): Config;
|
|
104
|
+
export {};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const AuthConfigSchema = z.object({
|
|
3
|
+
FREEMATICA_BASE_URL: z
|
|
4
|
+
.string()
|
|
5
|
+
.url()
|
|
6
|
+
.default('https://api-p01.clientservicepanel.com/restsat/api'),
|
|
7
|
+
FREEMATICA_AUTH_TOKEN: z.string().min(1),
|
|
8
|
+
FREEMATICA_AUTH_COMPANY: z.string().min(1),
|
|
9
|
+
FREEMATICA_AUTH_ORGANIZATION: z.string().min(1),
|
|
10
|
+
FREEMATICA_AUTH_APP: z.string().min(1),
|
|
11
|
+
FREEMATICA_AUTH_SESSION: z.string().min(1),
|
|
12
|
+
});
|
|
13
|
+
const HttpConfigSchema = z.object({
|
|
14
|
+
MCP_PORT: z.coerce.number().int().min(1).max(65535).default(3000),
|
|
15
|
+
MCP_ALLOWED_ORIGINS: z.string().default('*'),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Configuración de hardening del cliente HTTP.
|
|
19
|
+
*
|
|
20
|
+
* Todas las variables tienen valores por defecto seguros que no requieren
|
|
21
|
+
* configuración explícita en la mayoría de los entornos.
|
|
22
|
+
*/
|
|
23
|
+
const HardeningConfigSchema = z.object({
|
|
24
|
+
/**
|
|
25
|
+
* Timeout por petición HTTP en milisegundos.
|
|
26
|
+
* Por defecto: 30000 (30 segundos).
|
|
27
|
+
*/
|
|
28
|
+
FREEMATICA_TIMEOUT_MS: z.coerce.number().int().min(1000).max(300_000).default(30_000),
|
|
29
|
+
/**
|
|
30
|
+
* Número máximo de reintentos para errores 5xx y errores de red.
|
|
31
|
+
* Los errores 4xx nunca se reintentan.
|
|
32
|
+
* Por defecto: 3.
|
|
33
|
+
*/
|
|
34
|
+
FREEMATICA_MAX_RETRIES: z.coerce.number().int().min(0).max(10).default(3),
|
|
35
|
+
/**
|
|
36
|
+
* Nivel de logging de pino.
|
|
37
|
+
* Valores válidos: trace | debug | info | warn | error | fatal.
|
|
38
|
+
* Por defecto: info.
|
|
39
|
+
*/
|
|
40
|
+
LOG_LEVEL: z
|
|
41
|
+
.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])
|
|
42
|
+
.default('info'),
|
|
43
|
+
/**
|
|
44
|
+
* Número de fallos consecutivos antes de abrir el circuit breaker.
|
|
45
|
+
* Por defecto: 5.
|
|
46
|
+
*/
|
|
47
|
+
FREEMATICA_CIRCUIT_BREAKER_THRESHOLD: z.coerce.number().int().min(1).max(100).default(5),
|
|
48
|
+
/**
|
|
49
|
+
* Tiempo en ms que el circuit breaker permanece abierto antes de pasar
|
|
50
|
+
* a half-open para intentar recuperarse.
|
|
51
|
+
* Por defecto: 30000 (30 segundos).
|
|
52
|
+
*/
|
|
53
|
+
FREEMATICA_CIRCUIT_BREAKER_TIMEOUT_MS: z.coerce
|
|
54
|
+
.number()
|
|
55
|
+
.int()
|
|
56
|
+
.min(1000)
|
|
57
|
+
.max(3_600_000)
|
|
58
|
+
.default(30_000),
|
|
59
|
+
/**
|
|
60
|
+
* Tamaño máximo de respuesta aceptado por freematica_export_asientos en
|
|
61
|
+
* megabytes. Si la respuesta del API supera este umbral, los datos se
|
|
62
|
+
* truncan y se añade un campo `warning` a la respuesta de la tool.
|
|
63
|
+
*
|
|
64
|
+
* Se recomienda usar rangos de fecha cortos (max. 1 mes) para evitar
|
|
65
|
+
* alcanzar este límite.
|
|
66
|
+
*
|
|
67
|
+
* Por defecto: 10 (10 MB).
|
|
68
|
+
* Mínimo: 1 MB. Máximo: 500 MB.
|
|
69
|
+
*/
|
|
70
|
+
FREEMATICA_MAX_RESPONSE_SIZE_MB: z.coerce
|
|
71
|
+
.number()
|
|
72
|
+
.int()
|
|
73
|
+
.min(1)
|
|
74
|
+
.max(500)
|
|
75
|
+
.default(10),
|
|
76
|
+
});
|
|
77
|
+
function formatZodError(err) {
|
|
78
|
+
const issues = err.issues
|
|
79
|
+
.map((i) => ` - ${i.path.join('.')}: ${i.message}`)
|
|
80
|
+
.join('\n');
|
|
81
|
+
return (`[freematica-mcp] Invalid configuration:\n${issues}\n\n` +
|
|
82
|
+
`Set the missing/invalid environment variables and restart.`);
|
|
83
|
+
}
|
|
84
|
+
export function loadAuthConfig() {
|
|
85
|
+
const result = AuthConfigSchema.safeParse(process.env);
|
|
86
|
+
if (!result.success)
|
|
87
|
+
throw new Error(formatZodError(result.error));
|
|
88
|
+
return result.data;
|
|
89
|
+
}
|
|
90
|
+
export function loadHttpConfig() {
|
|
91
|
+
const result = HttpConfigSchema.safeParse(process.env);
|
|
92
|
+
if (!result.success)
|
|
93
|
+
throw new Error(formatZodError(result.error));
|
|
94
|
+
return result.data;
|
|
95
|
+
}
|
|
96
|
+
export function loadHardeningConfig() {
|
|
97
|
+
const result = HardeningConfigSchema.safeParse(process.env);
|
|
98
|
+
if (!result.success)
|
|
99
|
+
throw new Error(formatZodError(result.error));
|
|
100
|
+
return result.data;
|
|
101
|
+
}
|
|
102
|
+
export function loadConfig() {
|
|
103
|
+
return { ...loadAuthConfig(), ...loadHttpConfig(), ...loadHardeningConfig() };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CA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KAAK,CAAC,CAAC,CAAC;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,MAAM,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,GAAG,mBAAmB,EAAE,EAAE,CAAC;AAChF,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { loadAuthConfig } from './config.js';
|
|
3
|
+
import { FreematicaClient } from './clients/freematica-client.js';
|
|
4
|
+
function parseArg(name) {
|
|
5
|
+
const prefix = `--${name}=`;
|
|
6
|
+
const arg = process.argv.find((a) => a.startsWith(prefix));
|
|
7
|
+
return arg ? arg.slice(prefix.length) : undefined;
|
|
8
|
+
}
|
|
9
|
+
const TRANSPORT = parseArg('transport') ?? process.env.MCP_TRANSPORT ?? 'stdio';
|
|
10
|
+
async function main() {
|
|
11
|
+
const auth = loadAuthConfig();
|
|
12
|
+
const client = new FreematicaClient({
|
|
13
|
+
baseUrl: auth.FREEMATICA_BASE_URL,
|
|
14
|
+
authHeaders: {
|
|
15
|
+
'x-auth-token': auth.FREEMATICA_AUTH_TOKEN,
|
|
16
|
+
'x-auth-company': auth.FREEMATICA_AUTH_COMPANY,
|
|
17
|
+
'x-auth-organization': auth.FREEMATICA_AUTH_ORGANIZATION,
|
|
18
|
+
'x-auth-app': auth.FREEMATICA_AUTH_APP,
|
|
19
|
+
'x-auth-session': auth.FREEMATICA_AUTH_SESSION,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (TRANSPORT === 'http') {
|
|
23
|
+
const { loadHttpConfig } = await import('./config.js');
|
|
24
|
+
const { createHttpApp } = await import('./transports/http.js');
|
|
25
|
+
const http = loadHttpConfig();
|
|
26
|
+
const { app, shutdown } = await createHttpApp({
|
|
27
|
+
port: http.MCP_PORT,
|
|
28
|
+
client,
|
|
29
|
+
allowedOrigins: http.MCP_ALLOWED_ORIGINS,
|
|
30
|
+
});
|
|
31
|
+
process.on('SIGTERM', () => {
|
|
32
|
+
void shutdown().then(() => process.exit(0));
|
|
33
|
+
});
|
|
34
|
+
process.on('SIGINT', () => {
|
|
35
|
+
void shutdown().then(() => process.exit(0));
|
|
36
|
+
});
|
|
37
|
+
app.listen(http.MCP_PORT, () => {
|
|
38
|
+
console.error(`[freematica-mcp] HTTP transport listening on port ${http.MCP_PORT} | base=${auth.FREEMATICA_BASE_URL}`);
|
|
39
|
+
console.error(`[freematica-mcp] MCP endpoint: http://localhost:${http.MCP_PORT}/mcp`);
|
|
40
|
+
console.error(`[freematica-mcp] Health endpoint: http://localhost:${http.MCP_PORT}/health`);
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (TRANSPORT !== 'stdio') {
|
|
45
|
+
console.error(`[freematica-mcp] Unknown transport "${TRANSPORT}". Valid: stdio, http. Defaulting to stdio.`);
|
|
46
|
+
}
|
|
47
|
+
console.error(`[freematica-mcp] Starting stdio transport v0.6.0 | base=${auth.FREEMATICA_BASE_URL}`);
|
|
48
|
+
const { startStdio } = await import('./transports/stdio.js');
|
|
49
|
+
await startStdio({ client });
|
|
50
|
+
}
|
|
51
|
+
main().catch((err) => {
|
|
52
|
+
console.error('[freematica-mcp] FATAL:', err instanceof Error ? err.message : err);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,CAAC;IAC5B,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC;AAED,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC;AAEhF,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAE9B,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;QAClC,OAAO,EAAE,IAAI,CAAC,mBAAmB;QACjC,WAAW,EAAE;YACX,cAAc,EAAE,IAAI,CAAC,qBAAqB;YAC1C,gBAAgB,EAAE,IAAI,CAAC,uBAAuB;YAC9C,qBAAqB,EAAE,IAAI,CAAC,4BAA4B;YACxD,YAAY,EAAE,IAAI,CAAC,mBAAmB;YACtC,gBAAgB,EAAE,IAAI,CA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1B,OAAO,CAAC,KAAK,CACX,uCAAuC,SAAS,6CAA6C,CAC9F,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAAK,CACX,2DAA2D,IAAI,CAAC,mBAAmB,EAAE,CACtF,CAAC;IACF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAC7D,MAAM,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
/**
|
|
3
|
+
* Nombres de los headers de autenticación de Freemática que NUNCA deben
|
|
4
|
+
* aparecer en ningún log, en ningún nivel (incluido debug y trace).
|
|
5
|
+
*
|
|
6
|
+
* Se usa tanto para sanitizar headers antes de loguear como para verificar
|
|
7
|
+
* que el logger no filtra datos sensibles.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AUTH_HEADER_NAMES: readonly ["x-auth-token", "x-auth-company", "x-auth-organization", "x-auth-app", "x-auth-session"];
|
|
10
|
+
export type AuthHeaderName = (typeof AUTH_HEADER_NAMES)[number];
|
|
11
|
+
/**
|
|
12
|
+
* Niveles de log configurables vía la variable de entorno `LOG_LEVEL`.
|
|
13
|
+
*
|
|
14
|
+
* El nivel por defecto es `info`.
|
|
15
|
+
*
|
|
16
|
+
* @see https://getpino.io/#/docs/api?id=level-string
|
|
17
|
+
*/
|
|
18
|
+
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
19
|
+
/**
|
|
20
|
+
* Sanitiza un objeto de headers eliminando todas las claves de autenticación.
|
|
21
|
+
*
|
|
22
|
+
* Retorna un nuevo objeto sin modificar el original. Las claves se comparan
|
|
23
|
+
* en lowercase para cubrir variaciones de capitalización.
|
|
24
|
+
*
|
|
25
|
+
* @param headers - Headers HTTP a sanitizar.
|
|
26
|
+
* @returns Copia de `headers` sin los headers x-auth-*.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeHeaders(headers: Record<string, unknown>): Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Crea una instancia del logger pino con la configuración estándar.
|
|
31
|
+
*
|
|
32
|
+
* La función acepta opcionalmente un stream destino para permitir testing:
|
|
33
|
+
* en tests se puede pasar un stream writable en memoria para verificar que
|
|
34
|
+
* los headers sensibles NUNCA aparecen en el output.
|
|
35
|
+
*
|
|
36
|
+
* Configurado con:
|
|
37
|
+
* - Nivel configurable vía `LOG_LEVEL` (default: `info`)
|
|
38
|
+
* - Serializer `req` que sanitiza headers x-auth-* automáticamente
|
|
39
|
+
*
|
|
40
|
+
* @param destination - Stream destino opcional (por defecto: `pino.destination(1)` = stdout).
|
|
41
|
+
* @returns Instancia del logger pino.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Logger de producción (singleton)
|
|
45
|
+
* import { logger } from './logger.js';
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Logger de test con stream en memoria
|
|
49
|
+
* import { createLogger } from './logger.js';
|
|
50
|
+
* import { Writable } from 'node:stream';
|
|
51
|
+
* const chunks: string[] = [];
|
|
52
|
+
* const dest = new Writable({ write(chunk, _, cb) { chunks.push(chunk.toString()); cb(); } });
|
|
53
|
+
* const testLogger = createLogger(dest);
|
|
54
|
+
* testLogger.info({ headers: { 'x-auth-token': 'SECRET' } }, 'req');
|
|
55
|
+
* // Verificar que 'SECRET' no aparece en chunks
|
|
56
|
+
*/
|
|
57
|
+
export declare function createLogger(destination?: pino.DestinationStream): pino.Logger;
|
|
58
|
+
/**
|
|
59
|
+
* Logger singleton de la aplicación.
|
|
60
|
+
*
|
|
61
|
+
* Configurado con:
|
|
62
|
+
* - Nivel configurable vía `LOG_LEVEL` (default: `info`)
|
|
63
|
+
* - Serializer `req` que sanitiza headers x-auth-* automáticamente
|
|
64
|
+
*
|
|
65
|
+
* Uso:
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { logger } from './logger.js';
|
|
68
|
+
* logger.info({ requestId: 'uuid', method: 'GET', path: '/clientes' }, 'HTTP request');
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const logger: pino.Logger<never, boolean>;
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
/**
|
|
3
|
+
* Nombres de los headers de autenticación de Freemática que NUNCA deben
|
|
4
|
+
* aparecer en ningún log, en ningún nivel (incluido debug y trace).
|
|
5
|
+
*
|
|
6
|
+
* Se usa tanto para sanitizar headers antes de loguear como para verificar
|
|
7
|
+
* que el logger no filtra datos sensibles.
|
|
8
|
+
*/
|
|
9
|
+
export const AUTH_HEADER_NAMES = [
|
|
10
|
+
'x-auth-token',
|
|
11
|
+
'x-auth-company',
|
|
12
|
+
'x-auth-organization',
|
|
13
|
+
'x-auth-app',
|
|
14
|
+
'x-auth-session',
|
|
15
|
+
];
|
|
16
|
+
const VALID_LEVELS = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];
|
|
17
|
+
function resolveLogLevel() {
|
|
18
|
+
const raw = (process.env['LOG_LEVEL'] ?? 'info').toLowerCase();
|
|
19
|
+
if (VALID_LEVELS.includes(raw))
|
|
20
|
+
return raw;
|
|
21
|
+
// Nivel inválido → fallback a info (no lanzar porque puede romper startup)
|
|
22
|
+
process.stderr.write(`[freematica-mcp] WARNING: LOG_LEVEL="${raw}" no es válido. Usando "info".\n`);
|
|
23
|
+
return 'info';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sanitiza un objeto de headers eliminando todas las claves de autenticación.
|
|
27
|
+
*
|
|
28
|
+
* Retorna un nuevo objeto sin modificar el original. Las claves se comparan
|
|
29
|
+
* en lowercase para cubrir variaciones de capitalización.
|
|
30
|
+
*
|
|
31
|
+
* @param headers - Headers HTTP a sanitizar.
|
|
32
|
+
* @returns Copia de `headers` sin los headers x-auth-*.
|
|
33
|
+
*/
|
|
34
|
+
export function sanitizeHeaders(headers) {
|
|
35
|
+
const sanitized = {};
|
|
36
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
37
|
+
if (!AUTH_HEADER_NAMES.includes(key.toLowerCase())) {
|
|
38
|
+
sanitized[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return sanitized;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Serializer de pino para objetos `req` (peticiones HTTP salientes).
|
|
45
|
+
*
|
|
46
|
+
* Elimina headers de autenticación del objeto antes de serializar. Nunca
|
|
47
|
+
* incluye el body de la petición para evitar filtrar credenciales o PII.
|
|
48
|
+
*
|
|
49
|
+
* @param req - Objeto de petición con headers y metadatos.
|
|
50
|
+
* @returns Representación sanitizada para el log.
|
|
51
|
+
*/
|
|
52
|
+
function reqSerializer(req) {
|
|
53
|
+
if (typeof req !== 'object' || req === null)
|
|
54
|
+
return req;
|
|
55
|
+
const r = req;
|
|
56
|
+
return {
|
|
57
|
+
method: r.method,
|
|
58
|
+
path: r.path,
|
|
59
|
+
// Sanitizar headers: nunca x-auth-*
|
|
60
|
+
headers: r.headers ? sanitizeHeaders(r.headers) : undefined,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Crea una instancia del logger pino con la configuración estándar.
|
|
65
|
+
*
|
|
66
|
+
* La función acepta opcionalmente un stream destino para permitir testing:
|
|
67
|
+
* en tests se puede pasar un stream writable en memoria para verificar que
|
|
68
|
+
* los headers sensibles NUNCA aparecen en el output.
|
|
69
|
+
*
|
|
70
|
+
* Configurado con:
|
|
71
|
+
* - Nivel configurable vía `LOG_LEVEL` (default: `info`)
|
|
72
|
+
* - Serializer `req` que sanitiza headers x-auth-* automáticamente
|
|
73
|
+
*
|
|
74
|
+
* @param destination - Stream destino opcional (por defecto: `pino.destination(1)` = stdout).
|
|
75
|
+
* @returns Instancia del logger pino.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Logger de producción (singleton)
|
|
79
|
+
* import { logger } from './logger.js';
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Logger de test con stream en memoria
|
|
83
|
+
* import { createLogger } from './logger.js';
|
|
84
|
+
* import { Writable } from 'node:stream';
|
|
85
|
+
* const chunks: string[] = [];
|
|
86
|
+
* const dest = new Writable({ write(chunk, _, cb) { chunks.push(chunk.toString()); cb(); } });
|
|
87
|
+
* const testLogger = createLogger(dest);
|
|
88
|
+
* testLogger.info({ headers: { 'x-auth-token': 'SECRET' } }, 'req');
|
|
89
|
+
* // Verificar que 'SECRET' no aparece en chunks
|
|
90
|
+
*/
|
|
91
|
+
export function createLogger(destination) {
|
|
92
|
+
return pino({
|
|
93
|
+
level: resolveLogLevel(),
|
|
94
|
+
serializers: {
|
|
95
|
+
req: reqSerializer,
|
|
96
|
+
err: pino.stdSerializers.err,
|
|
97
|
+
},
|
|
98
|
+
}, destination);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Logger singleton de la aplicación.
|
|
102
|
+
*
|
|
103
|
+
* Configurado con:
|
|
104
|
+
* - Nivel configurable vía `LOG_LEVEL` (default: `info`)
|
|
105
|
+
* - Serializer `req` que sanitiza headers x-auth-* automáticamente
|
|
106
|
+
*
|
|
107
|
+
* Uso:
|
|
108
|
+
* ```ts
|
|
109
|
+
* import { logger } from './logger.js';
|
|
110
|
+
* logger.info({ requestId: 'uuid', method: 'GET', path: '/clientes' }, 'HTTP request');
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export const logger = createLogger();
|
|
114
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc;IACd,gBAAgB;IAChB,qBAAqB;IACrB,YAAY;IACZ,gBAAgB;CACR,CAAC;AAaX,MAAM,YAAY,GAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAEtF,SAAS,eAAe;IACtB,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAe,CAAC;QAAE,OAAO,GAAe,CAAC;IACnE,2EAA2E;IAC3E,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,wCAAwC,GAAG,kCAAkC,CAC9E,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgC;IAC9D,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAoB,CAAC,EAAE,CAAC;YACrE,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,aAAa,CACpB,GAAoF;IAEpF,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC;IACxD,MAAM,CAAC,GAAG,GAA4E,CAAC;IACvF,OAAO;QACL,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,oCAAoC;QACpC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;KAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,YAAY,CAAC,WAAoC;IAC/D,OAAO,IAAI,CACT;QACE,KAAK,EAAE,eAAe,EAAE;QACxB,WAAW,EAAE;YACX,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG;SAC7B;KACF,EACD,WAAW,CACZ,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Filtros tipados para `freematica_list_albaranes_ventas`.
|
|
4
|
+
*
|
|
5
|
+
* El endpoint GET /pven/v2/albaranes-ventas usa exclusivamente query params
|
|
6
|
+
* nativos. `codEmpresa` es obligatorio según el spec OpenAPI.
|
|
7
|
+
*
|
|
8
|
+
* Mapeo:
|
|
9
|
+
* | Filtro | Query param |
|
|
10
|
+
* |--------------|----------------|
|
|
11
|
+
* | empresa | codEmpresa |
|
|
12
|
+
* | delegacion | codDelegacion |
|
|
13
|
+
* | codCliente | codCliente |
|
|
14
|
+
* | codDocumento | codDocumento |
|
|
15
|
+
* | fechaDesde | desdeFecha |
|
|
16
|
+
* | fechaHasta | hastaFecha |
|
|
17
|
+
* | order | order |
|
|
18
|
+
*/
|
|
19
|
+
export declare const ListAlbaranesVentasFiltersSchema: {
|
|
20
|
+
empresa: z.ZodString;
|
|
21
|
+
delegacion: z.ZodOptional<z.ZodString>;
|
|
22
|
+
codCliente: z.ZodOptional<z.ZodString>;
|
|
23
|
+
codDocumento: z.ZodOptional<z.ZodString>;
|
|
24
|
+
fechaDesde: z.ZodOptional<z.ZodString>;
|
|
25
|
+
fechaHasta: z.ZodOptional<z.ZodString>;
|
|
26
|
+
order: z.ZodOptional<z.ZodString>;
|
|
27
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
28
|
+
items: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
};
|
|
30
|
+
export type ListAlbaranesVentasFilters = {
|
|
31
|
+
page?: number;
|
|
32
|
+
items?: number;
|
|
33
|
+
empresa: string;
|
|
34
|
+
delegacion?: string;
|
|
35
|
+
codCliente?: string;
|
|
36
|
+
codDocumento?: string;
|
|
37
|
+
fechaDesde?: string;
|
|
38
|
+
fechaHasta?: string;
|
|
39
|
+
order?: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Filtros tipados para `freematica_list_albaranes_factura`.
|
|
43
|
+
*
|
|
44
|
+
* Endpoint: GET /pven/v2/albaranes-facturas
|
|
45
|
+
*
|
|
46
|
+
* El filtro `idReg` es un query param nativo. El resto se pasan como FIQL
|
|
47
|
+
* en el parámetro `rQuery`.
|
|
48
|
+
*
|
|
49
|
+
* Mapeo:
|
|
50
|
+
* | Filtro | Mecanismo | Campo |
|
|
51
|
+
* |-------------|-----------|---------------|
|
|
52
|
+
* | idReg | nativo | — |
|
|
53
|
+
* | empresa | FIQL | FVCA_CODEMP |
|
|
54
|
+
* | serie | FIQL | FVCA_SERIEFRA |
|
|
55
|
+
* | numFactura | FIQL | FVCA_NUMFRA |
|
|
56
|
+
* | codCliente | FIQL | FVCA_CODCLI |
|
|
57
|
+
*/
|
|
58
|
+
export declare const ListAlbaranesFacturaFiltersSchema: {
|
|
59
|
+
idReg: z.ZodOptional<z.ZodString>;
|
|
60
|
+
empresa: z.ZodOptional<z.ZodString>;
|
|
61
|
+
serie: z.ZodOptional<z.ZodString>;
|
|
62
|
+
numFactura: z.ZodOptional<z.ZodString>;
|
|
63
|
+
codCliente: z.ZodOptional<z.ZodString>;
|
|
64
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
65
|
+
items: z.ZodDefault<z.ZodNumber>;
|
|
66
|
+
};
|
|
67
|
+
export type ListAlbaranesFacturaFilters = {
|
|
68
|
+
page?: number;
|
|
69
|
+
items?: number;
|
|
70
|
+
idReg?: string;
|
|
71
|
+
empresa?: string;
|
|
72
|
+
serie?: string;
|
|
73
|
+
numFactura?: string;
|
|
74
|
+
codCliente?: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Filtros tipados para `freematica_list_resultados_facturacion`.
|
|
78
|
+
*
|
|
79
|
+
* Endpoint: GET /pvss/v1/facturacion-resultados
|
|
80
|
+
*
|
|
81
|
+
* Todos los filtros se envían como FIQL en el parámetro `rquery`.
|
|
82
|
+
*
|
|
83
|
+
* Mapeo:
|
|
84
|
+
* | Filtro | Campo FIQL |
|
|
85
|
+
* |-------------|--------------|
|
|
86
|
+
* | empresa | FACT_EMP |
|
|
87
|
+
* | delegacion | FACT_DELEG |
|
|
88
|
+
* | codCliente | FACT_COD_CLI |
|
|
89
|
+
* | calendario | FACT_CAL |
|
|
90
|
+
* | mes | FACT_MES |
|
|
91
|
+
* | contrato | FACT_CTRT |
|
|
92
|
+
* | servicio | FACT_SERV |
|
|
93
|
+
* | tipoFac | FACT_TIPFAC |
|
|
94
|
+
* | traspasado | FACT_TRASP |
|
|
95
|
+
* | order | order |
|
|
96
|
+
*/
|
|
97
|
+
export declare const ListResultadosFacturacionFiltersSchema: {
|
|
98
|
+
empresa: z.ZodOptional<z.ZodString>;
|
|
99
|
+
delegacion: z.ZodOptional<z.ZodString>;
|
|
100
|
+
codCliente: z.ZodOptional<z.ZodString>;
|
|
101
|
+
calendario: z.ZodOptional<z.ZodString>;
|
|
102
|
+
mes: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
contrato: z.ZodOptional<z.ZodString>;
|
|
104
|
+
servicio: z.ZodOptional<z.ZodString>;
|
|
105
|
+
tipoFac: z.ZodOptional<z.ZodString>;
|
|
106
|
+
traspasado: z.ZodOptional<z.ZodString>;
|
|
107
|
+
order: z.ZodOptional<z.ZodString>;
|
|
108
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
109
|
+
items: z.ZodDefault<z.ZodNumber>;
|
|
110
|
+
};
|
|
111
|
+
export type ListResultadosFacturacionFilters = {
|
|
112
|
+
page?: number;
|
|
113
|
+
items?: number;
|
|
114
|
+
empresa?: string;
|
|
115
|
+
delegacion?: string;
|
|
116
|
+
codCliente?: string;
|
|
117
|
+
calendario?: string;
|
|
118
|
+
mes?: number;
|
|
119
|
+
contrato?: string;
|
|
120
|
+
servicio?: string;
|
|
121
|
+
tipoFac?: string;
|
|
122
|
+
traspasado?: string;
|
|
123
|
+
order?: string;
|
|
124
|
+
};
|