@ksefnik/mcp 0.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/LICENSE +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +72 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/confirm-match.d.ts +18 -0
- package/dist/tools/confirm-match.d.ts.map +1 -0
- package/dist/tools/confirm-match.js +11 -0
- package/dist/tools/confirm-match.js.map +1 -0
- package/dist/tools/get-unmatched.d.ts +59 -0
- package/dist/tools/get-unmatched.d.ts.map +1 -0
- package/dist/tools/get-unmatched.js +14 -0
- package/dist/tools/get-unmatched.js.map +1 -0
- package/dist/tools/import-bank.d.ts +27 -0
- package/dist/tools/import-bank.d.ts.map +1 -0
- package/dist/tools/import-bank.js +9 -0
- package/dist/tools/import-bank.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/query-invoices.d.ts +51 -0
- package/dist/tools/query-invoices.d.ts.map +1 -0
- package/dist/tools/query-invoices.js +12 -0
- package/dist/tools/query-invoices.js.map +1 -0
- package/dist/tools/reconcile.d.ts +68 -0
- package/dist/tools/reconcile.d.ts.map +1 -0
- package/dist/tools/reconcile.js +8 -0
- package/dist/tools/reconcile.js.map +1 -0
- package/dist/tools/send-invoice.d.ts +15 -0
- package/dist/tools/send-invoice.d.ts.map +1 -0
- package/dist/tools/send-invoice.js +10 -0
- package/dist/tools/send-invoice.js.map +1 -0
- package/dist/tools/sync-invoices.d.ts +57 -0
- package/dist/tools/sync-invoices.d.ts.map +1 -0
- package/dist/tools/sync-invoices.js +23 -0
- package/dist/tools/sync-invoices.js.map +1 -0
- package/dist/tools/validate-invoice.d.ts +15 -0
- package/dist/tools/validate-invoice.d.ts.map +1 -0
- package/dist/tools/validate-invoice.js +13 -0
- package/dist/tools/validate-invoice.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CodeFormers-it
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,cAAc,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,cAAc,kBAAkB,CAAA"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAU5C,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAsExD"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { syncInvoicesSchema, syncInvoices } from './tools/sync-invoices.js';
|
|
3
|
+
import { importBankSchema, importBank } from './tools/import-bank.js';
|
|
4
|
+
import { reconcile } from './tools/reconcile.js';
|
|
5
|
+
import { getUnmatchedSchema, getUnmatched } from './tools/get-unmatched.js';
|
|
6
|
+
import { queryInvoicesSchema, queryInvoices } from './tools/query-invoices.js';
|
|
7
|
+
import { sendInvoiceSchema, sendInvoiceTool } from './tools/send-invoice.js';
|
|
8
|
+
import { validateInvoiceSchema, validateInvoiceTool } from './tools/validate-invoice.js';
|
|
9
|
+
import { confirmMatchSchema, confirmMatch } from './tools/confirm-match.js';
|
|
10
|
+
export function createMcpServer(ksef) {
|
|
11
|
+
const server = new McpServer({
|
|
12
|
+
name: 'ksefnik',
|
|
13
|
+
version: '0.0.1',
|
|
14
|
+
});
|
|
15
|
+
server.registerTool('sync-invoices', {
|
|
16
|
+
description: 'Fetch invoices from KSeF for a given date range',
|
|
17
|
+
inputSchema: syncInvoicesSchema.shape,
|
|
18
|
+
}, async (input) => {
|
|
19
|
+
const result = await syncInvoices(ksef, input);
|
|
20
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
21
|
+
});
|
|
22
|
+
server.registerTool('import-bank', {
|
|
23
|
+
description: 'Import bank statement content (auto-detects format)',
|
|
24
|
+
inputSchema: importBankSchema.shape,
|
|
25
|
+
}, async (input) => {
|
|
26
|
+
const result = await importBank(ksef, input);
|
|
27
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
28
|
+
});
|
|
29
|
+
server.registerTool('reconcile', {
|
|
30
|
+
description: 'Run reconciliation pipeline on stored invoices and transactions',
|
|
31
|
+
}, async () => {
|
|
32
|
+
const result = await reconcile(ksef);
|
|
33
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
34
|
+
});
|
|
35
|
+
server.registerTool('get-unmatched', {
|
|
36
|
+
description: 'Get unmatched invoices and transactions from a reconciliation report',
|
|
37
|
+
inputSchema: getUnmatchedSchema.shape,
|
|
38
|
+
}, async (input) => {
|
|
39
|
+
const result = await getUnmatched(ksef, input);
|
|
40
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
41
|
+
});
|
|
42
|
+
server.registerTool('query-invoices', {
|
|
43
|
+
description: 'Query stored invoices by NIP, date range, or invoice number',
|
|
44
|
+
inputSchema: queryInvoicesSchema.shape,
|
|
45
|
+
}, async (input) => {
|
|
46
|
+
const result = await queryInvoices(ksef, input);
|
|
47
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
48
|
+
});
|
|
49
|
+
server.registerTool('send-invoice', {
|
|
50
|
+
description: 'Send invoice XML to KSeF',
|
|
51
|
+
inputSchema: sendInvoiceSchema.shape,
|
|
52
|
+
}, async (input) => {
|
|
53
|
+
const result = await sendInvoiceTool(ksef, input);
|
|
54
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
55
|
+
});
|
|
56
|
+
server.registerTool('validate-invoice', {
|
|
57
|
+
description: 'Validate an invoice against 20 Polish tax rules',
|
|
58
|
+
inputSchema: validateInvoiceSchema.shape,
|
|
59
|
+
}, async (input) => {
|
|
60
|
+
const result = validateInvoiceTool(ksef, input);
|
|
61
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
62
|
+
});
|
|
63
|
+
server.registerTool('confirm-match', {
|
|
64
|
+
description: 'Confirm or reject a reconciliation match',
|
|
65
|
+
inputSchema: confirmMatchSchema.shape,
|
|
66
|
+
}, async (input) => {
|
|
67
|
+
const result = confirmMatch(input);
|
|
68
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
69
|
+
});
|
|
70
|
+
return server;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const confirmMatchSchema: z.ZodObject<{
|
|
3
|
+
matchId: z.ZodString;
|
|
4
|
+
confirmed: z.ZodBoolean;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
matchId: string;
|
|
7
|
+
confirmed: boolean;
|
|
8
|
+
}, {
|
|
9
|
+
matchId: string;
|
|
10
|
+
confirmed: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export type ConfirmMatchInput = z.infer<typeof confirmMatchSchema>;
|
|
13
|
+
export declare function confirmMatch(input: ConfirmMatchInput): {
|
|
14
|
+
matchId: string;
|
|
15
|
+
confirmed: boolean;
|
|
16
|
+
success: boolean;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=confirm-match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-match.d.ts","sourceRoot":"","sources":["../../src/tools/confirm-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAElE,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB;;;;EAIpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const confirmMatchSchema = z.object({
|
|
3
|
+
matchId: z.string(),
|
|
4
|
+
confirmed: z.boolean(),
|
|
5
|
+
});
|
|
6
|
+
export function confirmMatch(input) {
|
|
7
|
+
// In the free tier, confirmation is a no-op acknowledgment
|
|
8
|
+
// Pro tier will persist confirmation state
|
|
9
|
+
return { matchId: input.matchId, confirmed: input.confirmed, success: true };
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=confirm-match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-match.js","sourceRoot":"","sources":["../../src/tools/confirm-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;CACvB,CAAC,CAAA;AAIF,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,2DAA2D;IAC3D,2CAA2C;IAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const getUnmatchedSchema: z.ZodObject<{
|
|
4
|
+
reportId: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
reportId: string;
|
|
7
|
+
}, {
|
|
8
|
+
reportId: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type GetUnmatchedInput = z.infer<typeof getUnmatchedSchema>;
|
|
11
|
+
export declare function getUnmatched(ksef: Ksefnik, input: GetUnmatchedInput): Promise<{
|
|
12
|
+
error: string;
|
|
13
|
+
unmatchedInvoices?: undefined;
|
|
14
|
+
unmatchedTransactions?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
unmatchedInvoices: {
|
|
17
|
+
id: string;
|
|
18
|
+
invoiceNumber: string;
|
|
19
|
+
sellerNIP: string;
|
|
20
|
+
grossAmount: number;
|
|
21
|
+
currency: "PLN";
|
|
22
|
+
issueDate: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
description?: string | undefined;
|
|
25
|
+
netAmount?: number | undefined;
|
|
26
|
+
buyerNIP?: string | undefined;
|
|
27
|
+
vatAmount?: number | undefined;
|
|
28
|
+
salesDate?: string | undefined;
|
|
29
|
+
dueDate?: string | undefined;
|
|
30
|
+
ksefReference?: string | undefined;
|
|
31
|
+
sellerName?: string | undefined;
|
|
32
|
+
buyerName?: string | undefined;
|
|
33
|
+
lineItems?: {
|
|
34
|
+
lineNumber: number;
|
|
35
|
+
description: string;
|
|
36
|
+
netAmount: number;
|
|
37
|
+
unit?: string | undefined;
|
|
38
|
+
quantity?: number | undefined;
|
|
39
|
+
unitNetPrice?: number | undefined;
|
|
40
|
+
vatRate?: number | undefined;
|
|
41
|
+
}[] | undefined;
|
|
42
|
+
rawXml?: string | undefined;
|
|
43
|
+
}[];
|
|
44
|
+
unmatchedTransactions: {
|
|
45
|
+
description: string;
|
|
46
|
+
id: string;
|
|
47
|
+
date: string;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
amount: number;
|
|
50
|
+
bank: "mt940" | "mbank" | "ing" | "pko" | "santander" | "other";
|
|
51
|
+
raw: string;
|
|
52
|
+
senderName?: string | undefined;
|
|
53
|
+
senderNIP?: string | undefined;
|
|
54
|
+
recipientName?: string | undefined;
|
|
55
|
+
recipientNIP?: string | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
error?: undefined;
|
|
58
|
+
}>;
|
|
59
|
+
//# sourceMappingURL=get-unmatched.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-unmatched.d.ts","sourceRoot":"","sources":["../../src/tools/get-unmatched.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,kBAAkB;;;;;;EAE7B,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAElE,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;gBAQylQ,CAAC;oBAA0C,CAAC;wBAA8C,CAAC;mBAAyC,CAAC;;;;;;;;;;;;;;;;;;GADvyQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const getUnmatchedSchema = z.object({
|
|
3
|
+
reportId: z.string(),
|
|
4
|
+
});
|
|
5
|
+
export async function getUnmatched(ksef, input) {
|
|
6
|
+
const report = await ksef.storage.getReport(input.reportId);
|
|
7
|
+
if (!report)
|
|
8
|
+
return { error: 'Report not found' };
|
|
9
|
+
return {
|
|
10
|
+
unmatchedInvoices: report.unmatchedInvoices,
|
|
11
|
+
unmatchedTransactions: report.unmatchedTransactions,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=get-unmatched.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-unmatched.js","sourceRoot":"","sources":["../../src/tools/get-unmatched.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAa,EAAE,KAAwB;IACxE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC3D,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAA;IACjD,OAAO;QACL,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;KACpD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const importBankSchema: z.ZodObject<{
|
|
4
|
+
content: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
content: string;
|
|
7
|
+
}, {
|
|
8
|
+
content: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type ImportBankInput = z.infer<typeof importBankSchema>;
|
|
11
|
+
export declare function importBank(ksef: Ksefnik, input: ImportBankInput): Promise<{
|
|
12
|
+
transactions: {
|
|
13
|
+
id: string;
|
|
14
|
+
date: string;
|
|
15
|
+
description: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
amount: number;
|
|
18
|
+
bank: "mbank" | "mt940" | "ing" | "pko" | "santander" | "other";
|
|
19
|
+
raw: string;
|
|
20
|
+
senderName?: string | undefined;
|
|
21
|
+
senderNIP?: string | undefined;
|
|
22
|
+
recipientName?: string | undefined;
|
|
23
|
+
recipientNIP?: string | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
count: number;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=import-bank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-bank.d.ts","sourceRoot":"","sources":["../../src/tools/import-bank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,gBAAgB;;;;;;EAE3B,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE9D,wBAAsB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe;;;;;;;;;;;;;;;GAGrE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const importBankSchema = z.object({
|
|
3
|
+
content: z.string(),
|
|
4
|
+
});
|
|
5
|
+
export async function importBank(ksef, input) {
|
|
6
|
+
const transactions = await ksef.bank.importFromString(input.content);
|
|
7
|
+
return { transactions, count: transactions.length };
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=import-bank.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-bank.js","sourceRoot":"","sources":["../../src/tools/import-bank.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAa,EAAE,KAAsB;IACpE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACpE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,CAAA;AACrD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { syncInvoices, syncInvoicesSchema } from './sync-invoices.js';
|
|
2
|
+
export { importBank, importBankSchema } from './import-bank.js';
|
|
3
|
+
export { reconcile } from './reconcile.js';
|
|
4
|
+
export { getUnmatched, getUnmatchedSchema } from './get-unmatched.js';
|
|
5
|
+
export { queryInvoices, queryInvoicesSchema } from './query-invoices.js';
|
|
6
|
+
export { sendInvoiceTool, sendInvoiceSchema } from './send-invoice.js';
|
|
7
|
+
export { validateInvoiceTool, validateInvoiceSchema } from './validate-invoice.js';
|
|
8
|
+
export { confirmMatch, confirmMatchSchema } from './confirm-match.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { syncInvoices, syncInvoicesSchema } from './sync-invoices.js';
|
|
2
|
+
export { importBank, importBankSchema } from './import-bank.js';
|
|
3
|
+
export { reconcile } from './reconcile.js';
|
|
4
|
+
export { getUnmatched, getUnmatchedSchema } from './get-unmatched.js';
|
|
5
|
+
export { queryInvoices, queryInvoicesSchema } from './query-invoices.js';
|
|
6
|
+
export { sendInvoiceTool, sendInvoiceSchema } from './send-invoice.js';
|
|
7
|
+
export { validateInvoiceTool, validateInvoiceSchema } from './validate-invoice.js';
|
|
8
|
+
export { confirmMatch, confirmMatchSchema } from './confirm-match.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const queryInvoicesSchema: z.ZodObject<{
|
|
4
|
+
nip: z.ZodOptional<z.ZodString>;
|
|
5
|
+
from: z.ZodOptional<z.ZodString>;
|
|
6
|
+
to: z.ZodOptional<z.ZodString>;
|
|
7
|
+
invoiceNumber: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
nip?: string | undefined;
|
|
10
|
+
from?: string | undefined;
|
|
11
|
+
to?: string | undefined;
|
|
12
|
+
invoiceNumber?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
nip?: string | undefined;
|
|
15
|
+
from?: string | undefined;
|
|
16
|
+
to?: string | undefined;
|
|
17
|
+
invoiceNumber?: string | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export type QueryInvoicesInput = z.infer<typeof queryInvoicesSchema>;
|
|
20
|
+
export declare function queryInvoices(ksef: Ksefnik, input: QueryInvoicesInput): Promise<{
|
|
21
|
+
invoices: {
|
|
22
|
+
id: string;
|
|
23
|
+
invoiceNumber: string;
|
|
24
|
+
sellerNIP: string;
|
|
25
|
+
grossAmount: number;
|
|
26
|
+
currency: "PLN";
|
|
27
|
+
issueDate: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
description?: string | undefined;
|
|
30
|
+
netAmount?: number | undefined;
|
|
31
|
+
buyerNIP?: string | undefined;
|
|
32
|
+
vatAmount?: number | undefined;
|
|
33
|
+
salesDate?: string | undefined;
|
|
34
|
+
dueDate?: string | undefined;
|
|
35
|
+
ksefReference?: string | undefined;
|
|
36
|
+
sellerName?: string | undefined;
|
|
37
|
+
buyerName?: string | undefined;
|
|
38
|
+
lineItems?: {
|
|
39
|
+
lineNumber: number;
|
|
40
|
+
description: string;
|
|
41
|
+
netAmount: number;
|
|
42
|
+
unit?: string | undefined;
|
|
43
|
+
quantity?: number | undefined;
|
|
44
|
+
unitNetPrice?: number | undefined;
|
|
45
|
+
vatRate?: number | undefined;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
rawXml?: string | undefined;
|
|
48
|
+
}[];
|
|
49
|
+
count: number;
|
|
50
|
+
}>;
|
|
51
|
+
//# sourceMappingURL=query-invoices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-invoices.d.ts","sourceRoot":"","sources":["../../src/tools/query-invoices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;EAK9B,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAEpE,wBAAsB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;gBAIs4E,CAAC;oBAAsC,CAAC;wBAA0C,CAAC;mBAAqC,CAAC;;;;;GAD1kF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const queryInvoicesSchema = z.object({
|
|
3
|
+
nip: z.string().optional(),
|
|
4
|
+
from: z.string().date().optional(),
|
|
5
|
+
to: z.string().date().optional(),
|
|
6
|
+
invoiceNumber: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
export async function queryInvoices(ksef, input) {
|
|
9
|
+
const invoices = await ksef.storage.getInvoices(input);
|
|
10
|
+
return { invoices, count: invoices.length };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=query-invoices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-invoices.js","sourceRoot":"","sources":["../../src/tools/query-invoices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAClC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAChC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAa,EAAE,KAAyB;IAC1E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IACtD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
export declare function reconcile(ksef: Ksefnik): Promise<{
|
|
3
|
+
id: string;
|
|
4
|
+
matched: {
|
|
5
|
+
id: string;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
invoiceId: string;
|
|
8
|
+
transactionId: string;
|
|
9
|
+
confidence: number;
|
|
10
|
+
passName: string;
|
|
11
|
+
reasons: string[];
|
|
12
|
+
confirmed: boolean;
|
|
13
|
+
transactionIds?: string[] | undefined;
|
|
14
|
+
}[];
|
|
15
|
+
unmatchedInvoices: {
|
|
16
|
+
id: string;
|
|
17
|
+
invoiceNumber: string;
|
|
18
|
+
sellerNIP: string;
|
|
19
|
+
grossAmount: number;
|
|
20
|
+
currency: "PLN";
|
|
21
|
+
issueDate: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
netAmount?: number | undefined;
|
|
25
|
+
buyerNIP?: string | undefined;
|
|
26
|
+
vatAmount?: number | undefined;
|
|
27
|
+
salesDate?: string | undefined;
|
|
28
|
+
dueDate?: string | undefined;
|
|
29
|
+
ksefReference?: string | undefined;
|
|
30
|
+
sellerName?: string | undefined;
|
|
31
|
+
buyerName?: string | undefined;
|
|
32
|
+
lineItems?: {
|
|
33
|
+
lineNumber: number;
|
|
34
|
+
description: string;
|
|
35
|
+
netAmount: number;
|
|
36
|
+
unit?: string | undefined;
|
|
37
|
+
quantity?: number | undefined;
|
|
38
|
+
unitNetPrice?: number | undefined;
|
|
39
|
+
vatRate?: number | undefined;
|
|
40
|
+
}[] | undefined;
|
|
41
|
+
rawXml?: string | undefined;
|
|
42
|
+
}[];
|
|
43
|
+
unmatchedTransactions: {
|
|
44
|
+
description: string;
|
|
45
|
+
id: string;
|
|
46
|
+
date: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
amount: number;
|
|
49
|
+
bank: "mt940" | "mbank" | "ing" | "pko" | "santander" | "other";
|
|
50
|
+
raw: string;
|
|
51
|
+
senderName?: string | undefined;
|
|
52
|
+
senderNIP?: string | undefined;
|
|
53
|
+
recipientName?: string | undefined;
|
|
54
|
+
recipientNIP?: string | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
summary: {
|
|
57
|
+
totalInvoices: number;
|
|
58
|
+
totalTransactions: number;
|
|
59
|
+
matchedCount: number;
|
|
60
|
+
unmatchedInvoiceCount: number;
|
|
61
|
+
unmatchedTransactionCount: number;
|
|
62
|
+
averageConfidence: number;
|
|
63
|
+
passBreakdown: Record<string, number>;
|
|
64
|
+
};
|
|
65
|
+
runAt: string;
|
|
66
|
+
durationMs: number;
|
|
67
|
+
}>;
|
|
68
|
+
//# sourceMappingURL=reconcile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/tools/reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO;;;;;;;;;;;sBAOimP,CAAC;;;;;;;;;;mBAAuQ,CAAC;iBAAuC,CAAC;gBAAsC,CAAC;iBAAuC,CAAC;iBAAuC,CAAC;eAAqC,CAAC;qBAA2C,CAAC;kBAAwC,CAAC;iBAAuC,CAAC;iBAAuC,CAAC;;;;gBAAoH,CAAC;oBAA0C,CAAC;wBAA8C,CAAC;mBAAyC,CAAC;;cAA6D,CAAC;;;;;;;;;;kBAAsS,CAAC;iBAAuC,CAAC;qBAA2C,CAAC;oBAA0C,CAAC;;;;;;;;;;;;;GAD79R"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export async function reconcile(ksef) {
|
|
2
|
+
const invoices = await ksef.invoices.list();
|
|
3
|
+
const transactions = await ksef.bank.list();
|
|
4
|
+
const report = await ksef.reconciliation.run(invoices, transactions);
|
|
5
|
+
await ksef.storage.saveReport(report);
|
|
6
|
+
return report;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=reconcile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile.js","sourceRoot":"","sources":["../../src/tools/reconcile.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAa;IAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC3C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;IACpE,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACrC,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const sendInvoiceSchema: z.ZodObject<{
|
|
4
|
+
xml: z.ZodString;
|
|
5
|
+
nip: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
nip: string;
|
|
8
|
+
xml: string;
|
|
9
|
+
}, {
|
|
10
|
+
nip: string;
|
|
11
|
+
xml: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type SendInvoiceInput = z.infer<typeof sendInvoiceSchema>;
|
|
14
|
+
export declare function sendInvoiceTool(ksef: Ksefnik, input: SendInvoiceInput): Promise<import("@ksefnik/shared").SendInvoiceResult>;
|
|
15
|
+
//# sourceMappingURL=send-invoice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-invoice.d.ts","sourceRoot":"","sources":["../../src/tools/send-invoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;;;;;;;;EAG5B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEhE,wBAAsB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,wDAG3E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const sendInvoiceSchema = z.object({
|
|
3
|
+
xml: z.string(),
|
|
4
|
+
nip: z.string(),
|
|
5
|
+
});
|
|
6
|
+
export async function sendInvoiceTool(ksef, input) {
|
|
7
|
+
const result = await ksef.invoices.send(input);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=send-invoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-invoice.js","sourceRoot":"","sources":["../../src/tools/send-invoice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAa,EAAE,KAAuB;IAC1E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC9C,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const syncInvoicesSchema: z.ZodObject<{
|
|
4
|
+
dateFrom: z.ZodString;
|
|
5
|
+
dateTo: z.ZodString;
|
|
6
|
+
nip: z.ZodOptional<z.ZodString>;
|
|
7
|
+
/**
|
|
8
|
+
* `sales` = invoices issued by this company (Subject1 on KSeF side),
|
|
9
|
+
* `cost` = invoices received by this company (Subject2).
|
|
10
|
+
* Defaults to `cost` for backwards compatibility with the MVP.
|
|
11
|
+
*/
|
|
12
|
+
subject: z.ZodOptional<z.ZodEnum<["sales", "cost"]>>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
dateFrom: string;
|
|
15
|
+
dateTo: string;
|
|
16
|
+
nip?: string | undefined;
|
|
17
|
+
subject?: "sales" | "cost" | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
dateFrom: string;
|
|
20
|
+
dateTo: string;
|
|
21
|
+
nip?: string | undefined;
|
|
22
|
+
subject?: "sales" | "cost" | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export type SyncInvoicesInput = z.infer<typeof syncInvoicesSchema>;
|
|
25
|
+
export declare function syncInvoices(ksef: Ksefnik, input: SyncInvoicesInput): Promise<{
|
|
26
|
+
invoices: {
|
|
27
|
+
id: string;
|
|
28
|
+
invoiceNumber: string;
|
|
29
|
+
sellerNIP: string;
|
|
30
|
+
grossAmount: number;
|
|
31
|
+
currency: "PLN";
|
|
32
|
+
issueDate: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
description?: string | undefined;
|
|
35
|
+
netAmount?: number | undefined;
|
|
36
|
+
buyerNIP?: string | undefined;
|
|
37
|
+
vatAmount?: number | undefined;
|
|
38
|
+
salesDate?: string | undefined;
|
|
39
|
+
dueDate?: string | undefined;
|
|
40
|
+
ksefReference?: string | undefined;
|
|
41
|
+
sellerName?: string | undefined;
|
|
42
|
+
buyerName?: string | undefined;
|
|
43
|
+
lineItems?: {
|
|
44
|
+
lineNumber: number;
|
|
45
|
+
description: string;
|
|
46
|
+
netAmount: number;
|
|
47
|
+
unit?: string | undefined;
|
|
48
|
+
quantity?: number | undefined;
|
|
49
|
+
unitNetPrice?: number | undefined;
|
|
50
|
+
vatRate?: number | undefined;
|
|
51
|
+
}[] | undefined;
|
|
52
|
+
rawXml?: string | undefined;
|
|
53
|
+
}[];
|
|
54
|
+
count: number;
|
|
55
|
+
subject: "sales" | "cost";
|
|
56
|
+
}>;
|
|
57
|
+
//# sourceMappingURL=sync-invoices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-invoices.d.ts","sourceRoot":"","sources":["../../src/tools/sync-invoices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,kBAAkB;;;;IAI7B;;;;OAIG;;;;;;;;;;;;EAEH,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAElE,wBAAsB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;gBAUmgE,CAAC;oBAAsC,CAAC;wBAA0C,CAAC;mBAAqC,CAAC;;;;;;GADrsE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const syncInvoicesSchema = z.object({
|
|
3
|
+
dateFrom: z.string().date(),
|
|
4
|
+
dateTo: z.string().date(),
|
|
5
|
+
nip: z.string().optional(),
|
|
6
|
+
/**
|
|
7
|
+
* `sales` = invoices issued by this company (Subject1 on KSeF side),
|
|
8
|
+
* `cost` = invoices received by this company (Subject2).
|
|
9
|
+
* Defaults to `cost` for backwards compatibility with the MVP.
|
|
10
|
+
*/
|
|
11
|
+
subject: z.enum(['sales', 'cost']).optional(),
|
|
12
|
+
});
|
|
13
|
+
export async function syncInvoices(ksef, input) {
|
|
14
|
+
const subjectType = input.subject === 'sales' ? 'Subject1' : 'Subject2';
|
|
15
|
+
const invoices = await ksef.invoices.fetch({
|
|
16
|
+
from: input.dateFrom,
|
|
17
|
+
to: input.dateTo,
|
|
18
|
+
nip: input.nip,
|
|
19
|
+
subjectType,
|
|
20
|
+
});
|
|
21
|
+
return { invoices, count: invoices.length, subject: input.subject ?? 'cost' };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=sync-invoices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-invoices.js","sourceRoot":"","sources":["../../src/tools/sync-invoices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B;;;;OAIG;IACH,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC9C,CAAC,CAAA;AAIF,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAa,EAAE,KAAwB;IACxE,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAA;IACvE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACzC,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,EAAE,EAAE,KAAK,CAAC,MAAM;QAChB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,WAAW;KACZ,CAAC,CAAA;IACF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,MAAM,EAAE,CAAA;AAC/E,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Ksefnik } from '@ksefnik/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const validateInvoiceSchema: z.ZodObject<{
|
|
4
|
+
invoice: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
invoice: Record<string, unknown>;
|
|
7
|
+
}, {
|
|
8
|
+
invoice: Record<string, unknown>;
|
|
9
|
+
}>;
|
|
10
|
+
export type ValidateInvoiceInput = z.infer<typeof validateInvoiceSchema>;
|
|
11
|
+
export declare function validateInvoiceTool(ksef: Ksefnik, input: ValidateInvoiceInput): {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
errors: import("@ksefnik/core").ValidationResult[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=validate-invoice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-invoice.d.ts","sourceRoot":"","sources":["../../src/tools/validate-invoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,qBAAqB;;;;;;EAEhC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAExE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB;;;EAO7E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const validateInvoiceSchema = z.object({
|
|
3
|
+
invoice: z.record(z.unknown()),
|
|
4
|
+
});
|
|
5
|
+
export function validateInvoiceTool(ksef, input) {
|
|
6
|
+
const reports = ksef.validation.validate([input.invoice]);
|
|
7
|
+
const report = reports[0];
|
|
8
|
+
return {
|
|
9
|
+
valid: report.valid,
|
|
10
|
+
errors: report.results.filter((r) => !r.valid),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=validate-invoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-invoice.js","sourceRoot":"","sources":["../../src/tools/validate-invoice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CAC/B,CAAC,CAAA;AAIF,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,KAA2B;IAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,OAAkB,CAAC,CAAC,CAAA;IACpE,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAE,CAAA;IAC1B,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC/C,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ksefnik/mcp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Model Context Protocol server for Ksefnik — exposes KSeF reconciliation tools to Claude, Cursor and other MCP clients",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "CodeFormers",
|
|
7
|
+
"homepage": "https://ksefnik.pl",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/CodeFormers-it/ksefnik.git",
|
|
11
|
+
"directory": "packages/mcp"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["ksef", "ksefnik", "mcp", "model-context-protocol", "claude", "einvoice"],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"files": ["dist", "!dist/**/__tests__", "!dist/**/*.test.*", "README.md", "LICENSE"],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc --build",
|
|
29
|
+
"dev": "tsc --build --watch",
|
|
30
|
+
"typecheck": "tsc --noEmit"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@ksefnik/shared": "workspace:^",
|
|
34
|
+
"@ksefnik/core": "workspace:^",
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.12",
|
|
36
|
+
"zod": "^3.24"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.7"
|
|
40
|
+
}
|
|
41
|
+
}
|