@raytio/mcp-server 9.3.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/persist/mcp_resource_contract.json +52 -23
- package/dist/authorization.d.ts.map +1 -1
- package/dist/authorization.js +2 -0
- package/dist/authorization.js.map +1 -1
- package/dist/tools/_shared/finance-idempotency.d.ts +52 -0
- package/dist/tools/_shared/finance-idempotency.d.ts.map +1 -0
- package/dist/tools/_shared/finance-idempotency.js +79 -0
- package/dist/tools/_shared/finance-idempotency.js.map +1 -0
- package/dist/tools/_shared/money.d.ts +10 -0
- package/dist/tools/_shared/money.d.ts.map +1 -0
- package/dist/tools/_shared/money.js +90 -0
- package/dist/tools/_shared/money.js.map +1 -0
- package/dist/tools/_shared/soft-deactivate.d.ts +2 -1
- package/dist/tools/_shared/soft-deactivate.d.ts.map +1 -1
- package/dist/tools/_shared/soft-deactivate.js +2 -1
- package/dist/tools/_shared/soft-deactivate.js.map +1 -1
- package/dist/tools/domains.d.ts.map +1 -1
- package/dist/tools/domains.js +18 -0
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/fap/fap-invoice-hold-place.d.ts +14 -0
- package/dist/tools/fap/fap-invoice-hold-place.d.ts.map +1 -0
- package/dist/tools/fap/fap-invoice-hold-place.js +62 -0
- package/dist/tools/fap/fap-invoice-hold-place.js.map +1 -0
- package/dist/tools/fap/fap-invoice-hold-release.d.ts +19 -0
- package/dist/tools/fap/fap-invoice-hold-release.d.ts.map +1 -0
- package/dist/tools/fap/fap-invoice-hold-release.js +65 -0
- package/dist/tools/fap/fap-invoice-hold-release.js.map +1 -0
- package/dist/tools/fap/fap-supplier-bill-create.d.ts +14 -0
- package/dist/tools/fap/fap-supplier-bill-create.d.ts.map +1 -0
- package/dist/tools/fap/fap-supplier-bill-create.js +90 -0
- package/dist/tools/fap/fap-supplier-bill-create.js.map +1 -0
- package/dist/tools/fap/fap-supplier-bill-line-add.d.ts +8 -0
- package/dist/tools/fap/fap-supplier-bill-line-add.d.ts.map +1 -0
- package/dist/tools/fap/fap-supplier-bill-line-add.js +75 -0
- package/dist/tools/fap/fap-supplier-bill-line-add.js.map +1 -0
- package/dist/tools/fap/fap-supplier-create.d.ts +9 -0
- package/dist/tools/fap/fap-supplier-create.d.ts.map +1 -0
- package/dist/tools/fap/fap-supplier-create.js +53 -0
- package/dist/tools/fap/fap-supplier-create.js.map +1 -0
- package/dist/tools/fap/fap-supplier-status-set.d.ts +8 -0
- package/dist/tools/fap/fap-supplier-status-set.d.ts.map +1 -0
- package/dist/tools/fap/fap-supplier-status-set.js +62 -0
- package/dist/tools/fap/fap-supplier-status-set.js.map +1 -0
- package/dist/tools/fap/fap-supplier-update.d.ts +8 -0
- package/dist/tools/fap/fap-supplier-update.d.ts.map +1 -0
- package/dist/tools/fap/fap-supplier-update.js +51 -0
- package/dist/tools/fap/fap-supplier-update.js.map +1 -0
- package/dist/tools/fap/generated-reads.d.ts +5 -0
- package/dist/tools/fap/generated-reads.d.ts.map +1 -0
- package/dist/tools/fap/generated-reads.js +19 -0
- package/dist/tools/fap/generated-reads.js.map +1 -0
- package/dist/tools/fap/index.d.ts +5 -0
- package/dist/tools/fap/index.d.ts.map +1 -0
- package/dist/tools/fap/index.js +21 -0
- package/dist/tools/fap/index.js.map +1 -0
- package/dist/tools/far/far-cash-receipt-record.d.ts +22 -0
- package/dist/tools/far/far-cash-receipt-record.d.ts.map +1 -0
- package/dist/tools/far/far-cash-receipt-record.js +96 -0
- package/dist/tools/far/far-cash-receipt-record.js.map +1 -0
- package/dist/tools/far/far-customer-create.d.ts +12 -0
- package/dist/tools/far/far-customer-create.d.ts.map +1 -0
- package/dist/tools/far/far-customer-create.js +54 -0
- package/dist/tools/far/far-customer-create.js.map +1 -0
- package/dist/tools/far/far-customer-invoice-create.d.ts +13 -0
- package/dist/tools/far/far-customer-invoice-create.d.ts.map +1 -0
- package/dist/tools/far/far-customer-invoice-create.js +76 -0
- package/dist/tools/far/far-customer-invoice-create.js.map +1 -0
- package/dist/tools/far/far-customer-invoice-line-add.d.ts +10 -0
- package/dist/tools/far/far-customer-invoice-line-add.d.ts.map +1 -0
- package/dist/tools/far/far-customer-invoice-line-add.js +77 -0
- package/dist/tools/far/far-customer-invoice-line-add.js.map +1 -0
- package/dist/tools/far/far-customer-status-set.d.ts +15 -0
- package/dist/tools/far/far-customer-status-set.d.ts.map +1 -0
- package/dist/tools/far/far-customer-status-set.js +70 -0
- package/dist/tools/far/far-customer-status-set.js.map +1 -0
- package/dist/tools/far/far-customer-update.d.ts +10 -0
- package/dist/tools/far/far-customer-update.d.ts.map +1 -0
- package/dist/tools/far/far-customer-update.js +51 -0
- package/dist/tools/far/far-customer-update.js.map +1 -0
- package/dist/tools/far/generated-reads.d.ts +5 -0
- package/dist/tools/far/generated-reads.d.ts.map +1 -0
- package/dist/tools/far/generated-reads.js +25 -0
- package/dist/tools/far/generated-reads.js.map +1 -0
- package/dist/tools/far/index.d.ts +5 -0
- package/dist/tools/far/index.d.ts.map +1 -0
- package/dist/tools/far/index.js +19 -0
- package/dist/tools/far/index.js.map +1 -0
- package/dist/tools/role-mapping.d.ts.map +1 -1
- package/dist/tools/role-mapping.js +12 -0
- package/dist/tools/role-mapping.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_ERROR, errorResponse, successResponse } from '../types.js';
|
|
3
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
4
|
+
import { currencyCodeSchema } from '../_shared/money.js';
|
|
5
|
+
import { financeWriteHeaders, idempotencyKeySchema, } from '../_shared/finance-idempotency.js';
|
|
6
|
+
/**
|
|
7
|
+
* Explicit-schema update for `fap_suppliers`. Status/approval columns
|
|
8
|
+
* are excluded — use `fap_supplier_status_set` for lifecycle
|
|
9
|
+
* transitions so a reason is recorded on the audit trail.
|
|
10
|
+
*/
|
|
11
|
+
export const fapSupplierUpdateTool = {
|
|
12
|
+
name: 'fap_supplier_update',
|
|
13
|
+
description: 'Update a FAP supplier with an explicit safe field set. Status/approval ' +
|
|
14
|
+
'columns are excluded — use fap_supplier_status_set for lifecycle transitions. ' +
|
|
15
|
+
'Retry-safe (converges on the same target state).',
|
|
16
|
+
inputSchema: z.object({
|
|
17
|
+
id: z.string().min(1).describe('UUID of the supplier'),
|
|
18
|
+
supplier_code: z.string().max(64).nullable().optional(),
|
|
19
|
+
supplier_class_code: z.string().max(64).nullable().optional(),
|
|
20
|
+
supplier_type_code: z.string().max(64).nullable().optional(),
|
|
21
|
+
invoice_currency_code: currencyCodeSchema.nullable().optional(),
|
|
22
|
+
payment_term_id: z.string().nullable().optional(),
|
|
23
|
+
idempotency_key: idempotencyKeySchema,
|
|
24
|
+
}),
|
|
25
|
+
capabilities: [cap('fap_suppliers', 'UPDATE')],
|
|
26
|
+
sideEffect: 'state_change',
|
|
27
|
+
confirmation: 'none',
|
|
28
|
+
idempotency: 'natural_key',
|
|
29
|
+
handler: async (args, ctx) => {
|
|
30
|
+
const { id, idempotency_key, ...rest } = args;
|
|
31
|
+
const body = {};
|
|
32
|
+
for (const [k, v] of Object.entries(rest)) {
|
|
33
|
+
if (v !== undefined)
|
|
34
|
+
body[k] = v;
|
|
35
|
+
}
|
|
36
|
+
if (Object.keys(body).length === 0) {
|
|
37
|
+
return errorResponse(API_ERROR, 'Update payload is empty — supply at least one field to change.');
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const rows = await ctx.apiClient.patch(`${ctx.apiClient.dbBasePath}/fap_suppliers?id=eq.${id}&select=*`, body, { headers: financeWriteHeaders(idempotency_key) });
|
|
41
|
+
if (!rows || rows.length === 0) {
|
|
42
|
+
return errorResponse(API_ERROR, `FAP supplier ${id} not found or not accessible`);
|
|
43
|
+
}
|
|
44
|
+
return successResponse(rows[0]);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return errorResponse(API_ERROR, `Failed to update FAP supplier: ${error.message}`);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=fap-supplier-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fap-supplier-update.js","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAS;IACzC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,yEAAyE;QACzE,gFAAgF;QAChF,kDAAkD;IACpD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACtD,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QACvD,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAC7D,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAC5D,qBAAqB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAC/D,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CA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a,CAAC,SAAS,EAAE,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
import { CatalogueReport } from '../../generated-reads/index.js';
|
|
3
|
+
export declare const fapGeneratedReadReport: CatalogueReport;
|
|
4
|
+
export declare const fapGeneratedReadTools: Tool[];
|
|
5
|
+
//# sourceMappingURL=generated-reads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-reads.d.ts","sourceRoot":"","sources":["../../../src/tools/fap/generated-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAGL,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAgBxC,eAAO,MAAM,sBAAsB,EAAE,eAIjC,CAAC;AAEL,eAAO,MAAM,qBAAqB,EAAE,IAAI,EAGvC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { buildGeneratedReadCatalogue, buildGeneratedReadCatalogueReport, } from '../../generated-reads/index.js';
|
|
2
|
+
import { loadPersistResourceContract } from '../../contracts/persist-resource-contract.js';
|
|
3
|
+
/**
|
|
4
|
+
* Bounded read tools for the FAP module (WI-0003504).
|
|
5
|
+
*
|
|
6
|
+
* Emits describe/list/get for every FAP resource that declares a read
|
|
7
|
+
* operation. Sensitive resources (`fap_invoice_holds`,
|
|
8
|
+
* `fap_payment_schedules`) are explicitly opted in — the WI acceptance
|
|
9
|
+
* criteria call for bounded reads over payables and payment schedules,
|
|
10
|
+
* and neither resource carries credential-shaped columns the redaction
|
|
11
|
+
* guardrail would need to blank.
|
|
12
|
+
*/
|
|
13
|
+
const contract = loadPersistResourceContract();
|
|
14
|
+
export const fapGeneratedReadReport = buildGeneratedReadCatalogueReport(contract, {
|
|
15
|
+
modules: ['fap'],
|
|
16
|
+
includeSensitive: true,
|
|
17
|
+
});
|
|
18
|
+
export const fapGeneratedReadTools = buildGeneratedReadCatalogue(contract, { modules: ['fap'], includeSensitive: true });
|
|
19
|
+
//# sourceMappingURL=generated-reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-reads.js","sourceRoot":"","sources":["../../../src/tools/fap/generated-reads.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,GAElC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F;;;;;;;;;GASG;AAEH,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,sBAAsB,GACjC,iCAAiC,CAAC,QAAQ,EAAE;IAC1C,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,gBAAgB,EAAE,IAAI;CACvB,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,qBAAqB,GAAW,2BAA2B,CACtE,QAAQ,EACR,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/fap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAoBtC,eAAO,MAAM,QAAQ,EAAE,IAAI,EAAiD,CAAC;AAE7E,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAA0B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { fapGeneratedReadTools } from './generated-reads.js';
|
|
2
|
+
import { fapSupplierCreateTool } from './fap-supplier-create.js';
|
|
3
|
+
import { fapSupplierUpdateTool } from './fap-supplier-update.js';
|
|
4
|
+
import { fapSupplierStatusSetTool } from './fap-supplier-status-set.js';
|
|
5
|
+
import { fapSupplierBillCreateTool } from './fap-supplier-bill-create.js';
|
|
6
|
+
import { fapSupplierBillLineAddTool } from './fap-supplier-bill-line-add.js';
|
|
7
|
+
import { fapInvoiceHoldPlaceTool } from './fap-invoice-hold-place.js';
|
|
8
|
+
import { fapInvoiceHoldReleaseTool } from './fap-invoice-hold-release.js';
|
|
9
|
+
const fapWriteTools = [
|
|
10
|
+
fapSupplierCreateTool,
|
|
11
|
+
fapSupplierUpdateTool,
|
|
12
|
+
fapSupplierStatusSetTool,
|
|
13
|
+
fapSupplierBillCreateTool,
|
|
14
|
+
fapSupplierBillLineAddTool,
|
|
15
|
+
fapInvoiceHoldPlaceTool,
|
|
16
|
+
fapInvoiceHoldReleaseTool,
|
|
17
|
+
];
|
|
18
|
+
export const fapTools = [...fapGeneratedReadTools, ...fapWriteTools];
|
|
19
|
+
/** Read-only slice used by the `fap-readonly` selectable sub-domain. */
|
|
20
|
+
export const fapReadOnlyTools = fapGeneratedReadTools;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/fap/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,aAAa,GAAW;IAC5B,qBAAqB;IACrB,qBAAqB;IACrB,wBAAwB;IACxB,yBAAyB;IACzB,0BAA0B;IAC1B,uBAAuB;IACvB,yBAAyB;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAW,CAAC,GAAG,qBAAqB,EAAE,GAAG,aAAa,CAAC,CAAC;AAE7E,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAW,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Payment semantic tool: record a cash receipt against a customer.
|
|
4
|
+
* Moves value on the ledger, so the tool requires:
|
|
5
|
+
*
|
|
6
|
+
* - `confirm: true` to prevent accidental invocation;
|
|
7
|
+
* - a positive `receipt_amount` validated at the MCP boundary;
|
|
8
|
+
* - a 3-letter ISO currency code;
|
|
9
|
+
* - a `receipt_number`. It is stored as `receipt_code`, which is
|
|
10
|
+
* unique per organisation (`t_far_cash_receipts_code_uk`), so a
|
|
11
|
+
* retry fails with a duplicate-key error. Without it Persist
|
|
12
|
+
* generates a new code on every insert, and Persist ignores
|
|
13
|
+
* `Idempotency-Key` (WI-0008817), so an `idempotency_key` alone
|
|
14
|
+
* would record the payment twice.
|
|
15
|
+
*
|
|
16
|
+
* The generated bounded read framework filters `far_cash_receipts` out
|
|
17
|
+
* of the auto-read surface (sensitivity=`sensitive`); the module opts
|
|
18
|
+
* it back in with credential redaction, and this dedicated tool is the
|
|
19
|
+
* ONLY approved write path.
|
|
20
|
+
*/
|
|
21
|
+
export declare const farCashReceiptRecordTool: Tool;
|
|
22
|
+
//# sourceMappingURL=far-cash-receipt-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-cash-receipt-record.d.ts","sourceRoot":"","sources":["../../../src/tools/far/far-cash-receipt-record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAatC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,EAAE,IAiFtC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_ERROR, errorResponse, successResponse } from '../types.js';
|
|
3
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
4
|
+
import { currencyCodeSchema, positiveMoneySchema, } from '../_shared/money.js';
|
|
5
|
+
import { confirmFlagSchema, financeWriteHeaders, idempotencyKeySchema, } from '../_shared/finance-idempotency.js';
|
|
6
|
+
/**
|
|
7
|
+
* Payment semantic tool: record a cash receipt against a customer.
|
|
8
|
+
* Moves value on the ledger, so the tool requires:
|
|
9
|
+
*
|
|
10
|
+
* - `confirm: true` to prevent accidental invocation;
|
|
11
|
+
* - a positive `receipt_amount` validated at the MCP boundary;
|
|
12
|
+
* - a 3-letter ISO currency code;
|
|
13
|
+
* - a `receipt_number`. It is stored as `receipt_code`, which is
|
|
14
|
+
* unique per organisation (`t_far_cash_receipts_code_uk`), so a
|
|
15
|
+
* retry fails with a duplicate-key error. Without it Persist
|
|
16
|
+
* generates a new code on every insert, and Persist ignores
|
|
17
|
+
* `Idempotency-Key` (WI-0008817), so an `idempotency_key` alone
|
|
18
|
+
* would record the payment twice.
|
|
19
|
+
*
|
|
20
|
+
* The generated bounded read framework filters `far_cash_receipts` out
|
|
21
|
+
* of the auto-read surface (sensitivity=`sensitive`); the module opts
|
|
22
|
+
* it back in with credential redaction, and this dedicated tool is the
|
|
23
|
+
* ONLY approved write path.
|
|
24
|
+
*/
|
|
25
|
+
export const farCashReceiptRecordTool = {
|
|
26
|
+
name: 'far_cash_receipt_record',
|
|
27
|
+
description: 'Record a cash receipt against a customer (far_cash_receipts). Requires ' +
|
|
28
|
+
'confirm=true, a positive receipt_amount, ISO currency, and a receipt_number. ' +
|
|
29
|
+
'receipt_number is unique within the organisation: a retry with the same ' +
|
|
30
|
+
'receipt_number fails with a duplicate-key error instead of recording the payment twice.',
|
|
31
|
+
inputSchema: z
|
|
32
|
+
.object({
|
|
33
|
+
customer_id: z.string().min(1).describe('UUID of the customer'),
|
|
34
|
+
customer_site_use_id: z.string().min(1).optional(),
|
|
35
|
+
receipt_amount: positiveMoneySchema.describe('Positive amount to record'),
|
|
36
|
+
receipt_currency_code: currencyCodeSchema,
|
|
37
|
+
receipt_date: z.string().min(1).describe('ISO 8601 date the funds cleared'),
|
|
38
|
+
receipt_number: z
|
|
39
|
+
.string()
|
|
40
|
+
.min(1)
|
|
41
|
+
.max(30)
|
|
42
|
+
.describe('Business receipt number, unique within the organisation. Required so a retry ' +
|
|
43
|
+
'cannot record the same payment twice.'),
|
|
44
|
+
receipt_type: z
|
|
45
|
+
.string()
|
|
46
|
+
.max(20)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe('Receipt type from the FAR_CASH_RECEIPTS_RECEIPT_TYPE lookup (e.g. CASH, MISC)'),
|
|
49
|
+
customer_reference: z.string().max(30).optional(),
|
|
50
|
+
customer_bank_account_id: z.string().min(1).optional(),
|
|
51
|
+
remittance_bank_account_use_id: z.string().min(1).optional(),
|
|
52
|
+
exchange_rate: z.number().positive().optional(),
|
|
53
|
+
exchange_rate_type: z.string().max(30).optional(),
|
|
54
|
+
exchange_date: z.string().min(1).optional(),
|
|
55
|
+
confirm: confirmFlagSchema,
|
|
56
|
+
idempotency_key: idempotencyKeySchema,
|
|
57
|
+
})
|
|
58
|
+
.refine((v) => v.exchange_rate === undefined || v.exchange_rate_type !== undefined, {
|
|
59
|
+
message: 'exchange_rate requires exchange_rate_type (and typically exchange_date)',
|
|
60
|
+
}),
|
|
61
|
+
capabilities: [cap('far_cash_receipts', 'INSERT')],
|
|
62
|
+
sideEffect: 'payment',
|
|
63
|
+
confirmation: 'caller_confirms',
|
|
64
|
+
idempotency: 'natural_key',
|
|
65
|
+
handler: async (args, ctx) => {
|
|
66
|
+
const input = args;
|
|
67
|
+
const body = {
|
|
68
|
+
customer_id: input.customer_id,
|
|
69
|
+
receipt_code: input.receipt_number,
|
|
70
|
+
receipt_amount: input.receipt_amount,
|
|
71
|
+
receipt_currency_code: input.receipt_currency_code,
|
|
72
|
+
receipt_date: input.receipt_date,
|
|
73
|
+
};
|
|
74
|
+
for (const field of [
|
|
75
|
+
'customer_site_use_id',
|
|
76
|
+
'receipt_type',
|
|
77
|
+
'customer_reference',
|
|
78
|
+
'customer_bank_account_id',
|
|
79
|
+
'remittance_bank_account_use_id',
|
|
80
|
+
'exchange_rate',
|
|
81
|
+
'exchange_rate_type',
|
|
82
|
+
'exchange_date',
|
|
83
|
+
]) {
|
|
84
|
+
if (input[field] !== undefined)
|
|
85
|
+
body[field] = input[field];
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/far_cash_receipts?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
|
|
89
|
+
return successResponse(rows[0]);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return errorResponse(API_ERROR, `Failed to record FAR cash receipt: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=far-cash-receipt-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-cash-receipt-record.js","sourceRoot":"","sources":["../../../src/tools/far/far-cash-receipt-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,wBAAw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B,EACxD,IAAI,EACJ,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CACxD,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,sCAAsC,KAAK,CAAC,OAAO,EAAE,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Explicit-schema create for `far_customers`. The generated bounded
|
|
4
|
+
* read framework refuses to auto-generate mutations for FAR/FAP
|
|
5
|
+
* resources (WI-0003501 / WI-0003504), so every writeable field is
|
|
6
|
+
* spelled out here and consequential defaults (approval status,
|
|
7
|
+
* status) are OMITTED — the backend applies its own initial state,
|
|
8
|
+
* which prevents a caller from provisioning an already-approved
|
|
9
|
+
* customer via MCP.
|
|
10
|
+
*/
|
|
11
|
+
export declare const farCustomerCreateTool: Tool;
|
|
12
|
+
//# sourceMappingURL=far-customer-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-create.d.ts","sourceRoot":"","sources":["../../../src/tools/far/far-customer-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAQtC;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,IA0CnC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_ERROR, errorResponse, successResponse } from '../types.js';
|
|
3
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
4
|
+
import { financeWriteHeaders, idempotencyKeySchema, } from '../_shared/finance-idempotency.js';
|
|
5
|
+
/**
|
|
6
|
+
* Explicit-schema create for `far_customers`. The generated bounded
|
|
7
|
+
* read framework refuses to auto-generate mutations for FAR/FAP
|
|
8
|
+
* resources (WI-0003501 / WI-0003504), so every writeable field is
|
|
9
|
+
* spelled out here and consequential defaults (approval status,
|
|
10
|
+
* status) are OMITTED — the backend applies its own initial state,
|
|
11
|
+
* which prevents a caller from provisioning an already-approved
|
|
12
|
+
* customer via MCP.
|
|
13
|
+
*/
|
|
14
|
+
export const farCustomerCreateTool = {
|
|
15
|
+
name: 'far_customer_create',
|
|
16
|
+
description: 'Create a new FAR customer with an explicit safe field set. Approval/status ' +
|
|
17
|
+
'fields are intentionally excluded — the persist layer assigns the initial ' +
|
|
18
|
+
'lifecycle state. One customer per party, and customer_code is unique, within the ' +
|
|
19
|
+
'tenant: a retry fails with a duplicate-key error instead of creating a second customer.',
|
|
20
|
+
inputSchema: z.object({
|
|
21
|
+
party_id: z.string().min(1).describe('UUID of the PRM party this customer represents'),
|
|
22
|
+
customer_code: z.string().min(1).max(64).optional().describe('Optional stable code'),
|
|
23
|
+
customer_class_code: z.string().max(64).optional(),
|
|
24
|
+
customer_type_code: z.string().max(64).optional(),
|
|
25
|
+
payment_term_id: z.string().min(1).optional(),
|
|
26
|
+
idempotency_key: idempotencyKeySchema,
|
|
27
|
+
}),
|
|
28
|
+
capabilities: [cap('far_customers', 'INSERT')],
|
|
29
|
+
sideEffect: 'state_change',
|
|
30
|
+
confirmation: 'none',
|
|
31
|
+
idempotency: 'natural_key',
|
|
32
|
+
handler: async (args, ctx) => {
|
|
33
|
+
const input = args;
|
|
34
|
+
const body = { party_id: input.party_id };
|
|
35
|
+
const optional = [
|
|
36
|
+
'customer_code',
|
|
37
|
+
'customer_class_code',
|
|
38
|
+
'customer_type_code',
|
|
39
|
+
'payment_term_id',
|
|
40
|
+
];
|
|
41
|
+
for (const field of optional) {
|
|
42
|
+
if (input[field] !== undefined)
|
|
43
|
+
body[field] = input[field];
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/far_customers?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
|
|
47
|
+
return successResponse(rows[0]);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return errorResponse(API_ERROR, `Failed to create FAR customer: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=far-customer-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-create.js","sourceRoot":"","sources":["../../../src/tools/far/far-customer-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAS;IACzC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,6EAA6E;QAC7E,4EAA4E;QAC5E,mFAAmF;QACjF,yFAAyF;IAC7F,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gDAAgD,CAAC;QACtF,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACpF,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;QAClD,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,C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js';
|
|
2
|
+
/**
|
|
3
|
+
* Explicit-schema create for an FAR customer invoice (transaction
|
|
4
|
+
* header). The `transaction_status` column is read-only per the pinned
|
|
5
|
+
* contract — the persist layer assigns the initial state — so we omit
|
|
6
|
+
* every lifecycle-transition column from this generic path.
|
|
7
|
+
*
|
|
8
|
+
* Unique key: `t_far_cust_tx_headers_uk` (transaction_code, org_id,
|
|
9
|
+
* tenant_id), so a retry with the same transaction_code fails with a
|
|
10
|
+
* duplicate-key error.
|
|
11
|
+
*/
|
|
12
|
+
export declare const farCustomerInvoiceCreateTool: Tool;
|
|
13
|
+
//# sourceMappingURL=far-customer-invoice-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-invoice-create.d.ts","sourceRoot":"","sources":["../../../src/tools/far/far-customer-invoice-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,EAAE,IAmE1C,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_ERROR, errorResponse, successResponse } from '../types.js';
|
|
3
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
4
|
+
import { currencyCodeSchema } from '../_shared/money.js';
|
|
5
|
+
import { financeWriteHeaders, idempotencyKeySchema, } from '../_shared/finance-idempotency.js';
|
|
6
|
+
/**
|
|
7
|
+
* Explicit-schema create for an FAR customer invoice (transaction
|
|
8
|
+
* header). The `transaction_status` column is read-only per the pinned
|
|
9
|
+
* contract — the persist layer assigns the initial state — so we omit
|
|
10
|
+
* every lifecycle-transition column from this generic path.
|
|
11
|
+
*
|
|
12
|
+
* Unique key: `t_far_cust_tx_headers_uk` (transaction_code, org_id,
|
|
13
|
+
* tenant_id), so a retry with the same transaction_code fails with a
|
|
14
|
+
* duplicate-key error.
|
|
15
|
+
*/
|
|
16
|
+
export const farCustomerInvoiceCreateTool = {
|
|
17
|
+
name: 'far_customer_invoice_create',
|
|
18
|
+
description: 'Create a customer invoice (far_customer_transaction_headers). transaction_status ' +
|
|
19
|
+
'is read-only and assigned by persist. transaction_code is unique within the ' +
|
|
20
|
+
'organisation: a retry with the same transaction_code fails with a duplicate-key ' +
|
|
21
|
+
'error instead of creating a second invoice.',
|
|
22
|
+
inputSchema: z.object({
|
|
23
|
+
sold_to_customer_id: z.string().min(1).describe('UUID of the customer being billed'),
|
|
24
|
+
sold_to_customer_site_id: z.string().min(1).optional(),
|
|
25
|
+
transaction_code: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1)
|
|
28
|
+
.max(64)
|
|
29
|
+
.describe('Business invoice/transaction reference (natural key column)'),
|
|
30
|
+
transaction_date: z.string().min(1).describe('ISO 8601 date (YYYY-MM-DD)'),
|
|
31
|
+
transaction_currency_code: currencyCodeSchema,
|
|
32
|
+
transaction_type: z
|
|
33
|
+
.string()
|
|
34
|
+
.max(32)
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Transaction type from the FAR_CUSTOMER_TRANSACTION_HEADERS_TRANSACTION_TYPE lookup ' +
|
|
37
|
+
'(INVOICE, CREDIT_MEMO, DEBIT_MEMO). Defaults to INVOICE.'),
|
|
38
|
+
payment_term_id: z.string().min(1).optional(),
|
|
39
|
+
payment_method_id: z.string().min(1).optional(),
|
|
40
|
+
customer_po_number: z.string().max(64).optional(),
|
|
41
|
+
customer_reference: z.string().max(255).optional(),
|
|
42
|
+
idempotency_key: idempotencyKeySchema,
|
|
43
|
+
}),
|
|
44
|
+
capabilities: [cap('far_customer_transaction_headers', 'INSERT')],
|
|
45
|
+
sideEffect: 'state_change',
|
|
46
|
+
confirmation: 'none',
|
|
47
|
+
idempotency: 'natural_key',
|
|
48
|
+
handler: async (args, ctx) => {
|
|
49
|
+
const input = args;
|
|
50
|
+
const body = {
|
|
51
|
+
sold_to_customer_id: input.sold_to_customer_id,
|
|
52
|
+
transaction_code: input.transaction_code,
|
|
53
|
+
transaction_date: input.transaction_date,
|
|
54
|
+
transaction_currency_code: input.transaction_currency_code,
|
|
55
|
+
};
|
|
56
|
+
for (const field of [
|
|
57
|
+
'sold_to_customer_site_id',
|
|
58
|
+
'transaction_type',
|
|
59
|
+
'payment_term_id',
|
|
60
|
+
'payment_method_id',
|
|
61
|
+
'customer_po_number',
|
|
62
|
+
'customer_reference',
|
|
63
|
+
]) {
|
|
64
|
+
if (input[field] !== undefined)
|
|
65
|
+
body[field] = input[field];
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/far_customer_transaction_headers?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
|
|
69
|
+
return successResponse(rows[0]);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
return errorResponse(API_ERROR, `Failed to create FAR customer invoice: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=far-customer-invoice-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-invoice-create.js","sourceRoot":"","sources":["../../../src/tools/far/far-customer-invoice-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAS;IAChD,IAAI,EAAE,6BAA6B;IACnC,WAAW,EACT,mFAAmF;QACnF,8EAA8E;QAC9E,kFAAkF;QAClF,6CAA6C;IAC/C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,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,IAA2B,CAAC;QAC1C,MAAM,IAAI,GAAwB;YAChC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;YAC9C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,yBAAyB,EAAE,KAAK,CAAC,yBAAyB;SAC3D,CAAC;QACF,KAAK,MAAM,KAAK,IAAI;YAClB,0BAA0B;YAC1B,kBAAkB;YAClB,iBAAiB;YACjB,mBAAmB;YACnB,oBAAoB;YACpB,oBAAoB;SACrB,EAAE,CAAC;YACF,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CACnC,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,4CAA4C,EACvE,IAAI,EACJ,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CACxD,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Explicit-schema tool for adding a line to a FAR customer invoice.
|
|
4
|
+
* The invoice header must already exist and be in a modifiable state —
|
|
5
|
+
* the persist layer enforces the guard; MCP does not need to
|
|
6
|
+
* pre-check it. Retry-safe via
|
|
7
|
+
* (customer_transaction_header_id, customer_transaction_line_number).
|
|
8
|
+
*/
|
|
9
|
+
export declare const farCustomerInvoiceLineAddTool: Tool;
|
|
10
|
+
//# sourceMappingURL=far-customer-invoice-line-add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-invoice-line-add.d.ts","sourceRoot":"","sources":["../../../src/tools/far/far-customer-invoice-line-add.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAYtC;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,EAAE,IA2E3C,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_ERROR, errorResponse, successResponse } from '../types.js';
|
|
3
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
4
|
+
import { positiveMoneySchema, signedMoneySchema, } from '../_shared/money.js';
|
|
5
|
+
import { financeWriteHeaders, idempotencyKeySchema, } from '../_shared/finance-idempotency.js';
|
|
6
|
+
/**
|
|
7
|
+
* Explicit-schema tool for adding a line to a FAR customer invoice.
|
|
8
|
+
* The invoice header must already exist and be in a modifiable state —
|
|
9
|
+
* the persist layer enforces the guard; MCP does not need to
|
|
10
|
+
* pre-check it. Retry-safe via
|
|
11
|
+
* (customer_transaction_header_id, customer_transaction_line_number).
|
|
12
|
+
*/
|
|
13
|
+
export const farCustomerInvoiceLineAddTool = {
|
|
14
|
+
name: 'far_customer_invoice_line_add',
|
|
15
|
+
description: 'Append a line to an existing customer invoice. Amount/qty validated at the ' +
|
|
16
|
+
'MCP boundary. Natural key: (customer_transaction_header_id, customer_transaction_line_number). ' +
|
|
17
|
+
'Retry-safe.',
|
|
18
|
+
inputSchema: z.object({
|
|
19
|
+
customer_transaction_header_id: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.describe('UUID of the invoice header this line belongs to'),
|
|
23
|
+
sold_to_customer_id: z
|
|
24
|
+
.string()
|
|
25
|
+
.min(1)
|
|
26
|
+
.describe('UUID of the customer (must match the header)'),
|
|
27
|
+
customer_transaction_line_number: z
|
|
28
|
+
.number()
|
|
29
|
+
.int()
|
|
30
|
+
.positive()
|
|
31
|
+
.describe('1-based line number, unique within the header'),
|
|
32
|
+
customer_transaction_line_qty: signedMoneySchema.describe('Line quantity — signed to permit credit-note negative lines'),
|
|
33
|
+
extended_transaction_price: positiveMoneySchema.describe('Line total (qty × unit_transaction_price) — must be > 0'),
|
|
34
|
+
unit_transaction_price: positiveMoneySchema.describe('Unit price at the invoice currency — must be > 0'),
|
|
35
|
+
unit_list_price: positiveMoneySchema.optional(),
|
|
36
|
+
extended_list_price: positiveMoneySchema.optional(),
|
|
37
|
+
customer_transaction_line_item_id: z.string().min(1).optional(),
|
|
38
|
+
customer_transaction_line_item_description: z.string().max(255).optional(),
|
|
39
|
+
customer_transaction_line_uom: z.string().max(32).optional(),
|
|
40
|
+
customer_transaction_line_reference: z.string().max(255).optional(),
|
|
41
|
+
idempotency_key: idempotencyKeySchema,
|
|
42
|
+
}),
|
|
43
|
+
capabilities: [cap('far_customer_transaction_lines', 'INSERT')],
|
|
44
|
+
sideEffect: 'state_change',
|
|
45
|
+
confirmation: 'none',
|
|
46
|
+
idempotency: 'natural_key',
|
|
47
|
+
handler: async (args, ctx) => {
|
|
48
|
+
const input = args;
|
|
49
|
+
const body = {
|
|
50
|
+
customer_transaction_header_id: input.customer_transaction_header_id,
|
|
51
|
+
sold_to_customer_id: input.sold_to_customer_id,
|
|
52
|
+
customer_transaction_line_number: input.customer_transaction_line_number,
|
|
53
|
+
customer_transaction_line_qty: input.customer_transaction_line_qty,
|
|
54
|
+
extended_transaction_price: input.extended_transaction_price,
|
|
55
|
+
unit_transaction_price: input.unit_transaction_price,
|
|
56
|
+
};
|
|
57
|
+
for (const field of [
|
|
58
|
+
'unit_list_price',
|
|
59
|
+
'extended_list_price',
|
|
60
|
+
'customer_transaction_line_item_id',
|
|
61
|
+
'customer_transaction_line_item_description',
|
|
62
|
+
'customer_transaction_line_uom',
|
|
63
|
+
'customer_transaction_line_reference',
|
|
64
|
+
]) {
|
|
65
|
+
if (input[field] !== undefined)
|
|
66
|
+
body[field] = input[field];
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/far_customer_transaction_lines?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
|
|
70
|
+
return successResponse(rows[0]);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return errorResponse(API_ERROR, `Failed to add FAR customer invoice line: ${error.message}`);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=far-customer-invoice-line-add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-invoice-line-add.js","sourceRoot":"","sources":["../../../src/tools/far/far-customer-invoice-line-add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAS;IACjD,IAAI,EAAE,+BAA+B;IACrC,WAAW,EACT,6EAA6E;QAC7E,iGAAiG;QACjG,aAAa;IACf,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,8BAA8B,EAAE,CAAC;aAC9B,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,iDAAiD,CAAC;QAC9D,mBAAmB,EAAE,CAAC;aACnB,MAAM,EAA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9C,gCAAgC,EAAE,KAAK,CAAC,gCAAgC;YACxE,6BAA6B,EAAE,KAAK,CAAC,6BAA6B;YAClE,0BAA0B,EAAE,KAAK,CAAC,0BAA0B;YAC5D,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;SACrD,CAAC;QACF,KAAK,MAAM,KAAK,IAAI;YAClB,iBAAiB;YACjB,qBAAqB;YACrB,mCAAmC;YACnC,4CAA4C;YAC5C,+BAA+B;YAC/B,qCAAqC;SACtC,EAAE,CAAC;YACF,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS;gBAAE,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CACnC,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,0CAA0C,EACrE,IAAI,EACJ,EAAE,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CACxD,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,4CAA4C,KAAK,CAAC,OAAO,EAAE,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Semantic tool for a customer lifecycle transition. Wrapping this as a
|
|
4
|
+
* dedicated tool (rather than exposing status columns on the generic
|
|
5
|
+
* update path) records a reason and gives the caller a single fact to
|
|
6
|
+
* reason about ("set status to A") rather than a bag of columns.
|
|
7
|
+
*
|
|
8
|
+
* Callers must supply a target `customer_status_code` OR
|
|
9
|
+
* `customer_approval_status_code`; both may be supplied together.
|
|
10
|
+
* The tool reads the row first: the reason is merged into the existing
|
|
11
|
+
* `metadata`, and a customer already in the target state is returned
|
|
12
|
+
* unchanged, so a retry keeps the original reason.
|
|
13
|
+
*/
|
|
14
|
+
export declare const farCustomerStatusSetTool: Tool;
|
|
15
|
+
//# sourceMappingURL=far-customer-status-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"far-customer-status-set.d.ts","sourceRoot":"","sources":["../../../src/tools/far/far-customer-status-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAKtC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,EAAE,IAoEtC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
3
|
+
import { idempotencyKeySchema, reasonSchema } from '../_shared/finance-idempotency.js';
|
|
4
|
+
import { softDeactivate } from '../_shared/soft-deactivate.js';
|
|
5
|
+
/**
|
|
6
|
+
* Semantic tool for a customer lifecycle transition. Wrapping this as a
|
|
7
|
+
* dedicated tool (rather than exposing status columns on the generic
|
|
8
|
+
* update path) records a reason and gives the caller a single fact to
|
|
9
|
+
* reason about ("set status to A") rather than a bag of columns.
|
|
10
|
+
*
|
|
11
|
+
* Callers must supply a target `customer_status_code` OR
|
|
12
|
+
* `customer_approval_status_code`; both may be supplied together.
|
|
13
|
+
* The tool reads the row first: the reason is merged into the existing
|
|
14
|
+
* `metadata`, and a customer already in the target state is returned
|
|
15
|
+
* unchanged, so a retry keeps the original reason.
|
|
16
|
+
*/
|
|
17
|
+
export const farCustomerStatusSetTool = {
|
|
18
|
+
name: 'far_customer_status_set',
|
|
19
|
+
description: 'Transition an FAR customer lifecycle status. Accepts customer_status_code and/or ' +
|
|
20
|
+
'customer_approval_status_code; requires a `reason`, merged into the customer metadata. ' +
|
|
21
|
+
'A customer already in the target state is returned unchanged, so retries are safe.',
|
|
22
|
+
inputSchema: z
|
|
23
|
+
.object({
|
|
24
|
+
id: z.string().min(1).describe('UUID of the customer'),
|
|
25
|
+
customer_status_code: z
|
|
26
|
+
.string()
|
|
27
|
+
.max(64)
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('Target status from the FAR_CUSTOMERS_CUSTOMER_STATUS lookup ' +
|
|
30
|
+
'(e.g. A = Active, I = Inactive, P = Pending)'),
|
|
31
|
+
customer_approval_status_code: z
|
|
32
|
+
.string()
|
|
33
|
+
.max(64)
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Target approval status from the FAR_CUSTOMERS_CUSTOMER_APPROVAL_STATUS lookup ' +
|
|
36
|
+
'(e.g. A = Approved, P = Pending, R = Rejected)'),
|
|
37
|
+
reason: reasonSchema.describe('Human-readable justification, stored in metadata'),
|
|
38
|
+
idempotency_key: idempotencyKeySchema,
|
|
39
|
+
})
|
|
40
|
+
.refine((v) => v.customer_status_code !== undefined ||
|
|
41
|
+
v.customer_approval_status_code !== undefined, {
|
|
42
|
+
message: 'supply customer_status_code and/or customer_approval_status_code — at least one is required.',
|
|
43
|
+
}),
|
|
44
|
+
capabilities: [cap('far_customers', 'UPDATE')],
|
|
45
|
+
sideEffect: 'state_change',
|
|
46
|
+
confirmation: 'caller_provides_reason',
|
|
47
|
+
idempotency: 'natural_key',
|
|
48
|
+
handler: async (args, ctx) => {
|
|
49
|
+
const input = args;
|
|
50
|
+
const target = {};
|
|
51
|
+
if (input.customer_status_code !== undefined) {
|
|
52
|
+
target.customer_status_code = input.customer_status_code;
|
|
53
|
+
}
|
|
54
|
+
if (input.customer_approval_status_code !== undefined) {
|
|
55
|
+
target.customer_approval_status_code = input.customer_approval_status_code;
|
|
56
|
+
}
|
|
57
|
+
return softDeactivate(ctx, {
|
|
58
|
+
table: 'far_customers',
|
|
59
|
+
id: input.id,
|
|
60
|
+
label: 'FAR customer',
|
|
61
|
+
verb: 'set status of',
|
|
62
|
+
isDone: (row) => Object.entries(target).every(([k, v]) => row[k] === v),
|
|
63
|
+
changes: () => target,
|
|
64
|
+
reasonKey: 'status_change_reason',
|
|
65
|
+
reason: input.reason,
|
|
66
|
+
idempotencyKey: input.idempotency_key,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=far-customer-status-set.js.map
|