@raytio/mcp-server 9.3.0 → 9.4.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.
Files changed (90) hide show
  1. package/dist/authorization.d.ts.map +1 -1
  2. package/dist/authorization.js +2 -0
  3. package/dist/authorization.js.map +1 -1
  4. package/dist/tools/_shared/finance-idempotency.d.ts +52 -0
  5. package/dist/tools/_shared/finance-idempotency.d.ts.map +1 -0
  6. package/dist/tools/_shared/finance-idempotency.js +79 -0
  7. package/dist/tools/_shared/finance-idempotency.js.map +1 -0
  8. package/dist/tools/_shared/money.d.ts +10 -0
  9. package/dist/tools/_shared/money.d.ts.map +1 -0
  10. package/dist/tools/_shared/money.js +90 -0
  11. package/dist/tools/_shared/money.js.map +1 -0
  12. package/dist/tools/_shared/soft-deactivate.d.ts +2 -1
  13. package/dist/tools/_shared/soft-deactivate.d.ts.map +1 -1
  14. package/dist/tools/_shared/soft-deactivate.js +2 -1
  15. package/dist/tools/_shared/soft-deactivate.js.map +1 -1
  16. package/dist/tools/domains.d.ts.map +1 -1
  17. package/dist/tools/domains.js +18 -0
  18. package/dist/tools/domains.js.map +1 -1
  19. package/dist/tools/fap/fap-invoice-hold-place.d.ts +14 -0
  20. package/dist/tools/fap/fap-invoice-hold-place.d.ts.map +1 -0
  21. package/dist/tools/fap/fap-invoice-hold-place.js +62 -0
  22. package/dist/tools/fap/fap-invoice-hold-place.js.map +1 -0
  23. package/dist/tools/fap/fap-invoice-hold-release.d.ts +19 -0
  24. package/dist/tools/fap/fap-invoice-hold-release.d.ts.map +1 -0
  25. package/dist/tools/fap/fap-invoice-hold-release.js +65 -0
  26. package/dist/tools/fap/fap-invoice-hold-release.js.map +1 -0
  27. package/dist/tools/fap/fap-supplier-bill-create.d.ts +14 -0
  28. package/dist/tools/fap/fap-supplier-bill-create.d.ts.map +1 -0
  29. package/dist/tools/fap/fap-supplier-bill-create.js +90 -0
  30. package/dist/tools/fap/fap-supplier-bill-create.js.map +1 -0
  31. package/dist/tools/fap/fap-supplier-bill-line-add.d.ts +8 -0
  32. package/dist/tools/fap/fap-supplier-bill-line-add.d.ts.map +1 -0
  33. package/dist/tools/fap/fap-supplier-bill-line-add.js +75 -0
  34. package/dist/tools/fap/fap-supplier-bill-line-add.js.map +1 -0
  35. package/dist/tools/fap/fap-supplier-create.d.ts +9 -0
  36. package/dist/tools/fap/fap-supplier-create.d.ts.map +1 -0
  37. package/dist/tools/fap/fap-supplier-create.js +53 -0
  38. package/dist/tools/fap/fap-supplier-create.js.map +1 -0
  39. package/dist/tools/fap/fap-supplier-status-set.d.ts +8 -0
  40. package/dist/tools/fap/fap-supplier-status-set.d.ts.map +1 -0
  41. package/dist/tools/fap/fap-supplier-status-set.js +62 -0
  42. package/dist/tools/fap/fap-supplier-status-set.js.map +1 -0
  43. package/dist/tools/fap/fap-supplier-update.d.ts +8 -0
  44. package/dist/tools/fap/fap-supplier-update.d.ts.map +1 -0
  45. package/dist/tools/fap/fap-supplier-update.js +51 -0
  46. package/dist/tools/fap/fap-supplier-update.js.map +1 -0
  47. package/dist/tools/fap/generated-reads.d.ts +5 -0
  48. package/dist/tools/fap/generated-reads.d.ts.map +1 -0
  49. package/dist/tools/fap/generated-reads.js +19 -0
  50. package/dist/tools/fap/generated-reads.js.map +1 -0
  51. package/dist/tools/fap/index.d.ts +5 -0
  52. package/dist/tools/fap/index.d.ts.map +1 -0
  53. package/dist/tools/fap/index.js +21 -0
  54. package/dist/tools/fap/index.js.map +1 -0
  55. package/dist/tools/far/far-cash-receipt-record.d.ts +27 -0
  56. package/dist/tools/far/far-cash-receipt-record.d.ts.map +1 -0
  57. package/dist/tools/far/far-cash-receipt-record.js +101 -0
  58. package/dist/tools/far/far-cash-receipt-record.js.map +1 -0
  59. package/dist/tools/far/far-customer-create.d.ts +12 -0
  60. package/dist/tools/far/far-customer-create.d.ts.map +1 -0
  61. package/dist/tools/far/far-customer-create.js +54 -0
  62. package/dist/tools/far/far-customer-create.js.map +1 -0
  63. package/dist/tools/far/far-customer-invoice-create.d.ts +13 -0
  64. package/dist/tools/far/far-customer-invoice-create.d.ts.map +1 -0
  65. package/dist/tools/far/far-customer-invoice-create.js +76 -0
  66. package/dist/tools/far/far-customer-invoice-create.js.map +1 -0
  67. package/dist/tools/far/far-customer-invoice-line-add.d.ts +10 -0
  68. package/dist/tools/far/far-customer-invoice-line-add.d.ts.map +1 -0
  69. package/dist/tools/far/far-customer-invoice-line-add.js +77 -0
  70. package/dist/tools/far/far-customer-invoice-line-add.js.map +1 -0
  71. package/dist/tools/far/far-customer-status-set.d.ts +15 -0
  72. package/dist/tools/far/far-customer-status-set.d.ts.map +1 -0
  73. package/dist/tools/far/far-customer-status-set.js +70 -0
  74. package/dist/tools/far/far-customer-status-set.js.map +1 -0
  75. package/dist/tools/far/far-customer-update.d.ts +10 -0
  76. package/dist/tools/far/far-customer-update.d.ts.map +1 -0
  77. package/dist/tools/far/far-customer-update.js +51 -0
  78. package/dist/tools/far/far-customer-update.js.map +1 -0
  79. package/dist/tools/far/generated-reads.d.ts +5 -0
  80. package/dist/tools/far/generated-reads.d.ts.map +1 -0
  81. package/dist/tools/far/generated-reads.js +25 -0
  82. package/dist/tools/far/generated-reads.js.map +1 -0
  83. package/dist/tools/far/index.d.ts +5 -0
  84. package/dist/tools/far/index.d.ts.map +1 -0
  85. package/dist/tools/far/index.js +19 -0
  86. package/dist/tools/far/index.js.map +1 -0
  87. package/dist/tools/role-mapping.d.ts.map +1 -1
  88. package/dist/tools/role-mapping.js +12 -0
  89. package/dist/tools/role-mapping.js.map +1 -1
  90. package/package.json +1 -1
@@ -0,0 +1,90 @@
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 FAP supplier bill / invoice
8
+ * (transaction header). `transaction_status` is read-only per the
9
+ * pinned contract — new bills land in the persist-assigned default
10
+ * state. Approval status is excluded from this generic path (use
11
+ * status/approval-specific tools once backend endpoints exist).
12
+ *
13
+ * Unique key: `t_fap_supp_tx_hdrs_invoice_uk` (bill_from_supplier_id,
14
+ * invoice_number, tenant_id), so a retry with the same invoice_number
15
+ * fails with a duplicate-key error.
16
+ */
17
+ export const fapSupplierBillCreateTool = {
18
+ name: 'fap_supplier_bill_create',
19
+ description: 'Record a supplier bill (fap_supplier_transaction_headers). transaction_status ' +
20
+ 'is assigned by persist. invoice_number is unique per supplier: a retry with the same ' +
21
+ 'invoice_number fails with a duplicate-key error instead of recording a second bill.',
22
+ inputSchema: z.object({
23
+ bill_from_supplier_id: z
24
+ .string()
25
+ .min(1)
26
+ .describe('UUID of the supplier issuing the bill'),
27
+ bill_from_supplier_site_id: z.string().min(1).optional(),
28
+ bill_from_supplier_contact_point_id: z.string().min(1).optional(),
29
+ invoice_number: z
30
+ .string()
31
+ .min(1)
32
+ .max(64)
33
+ .describe('Supplier invoice number (natural key column)'),
34
+ transaction_date: z.string().min(1).describe('ISO 8601 invoice date'),
35
+ transaction_currency_code: currencyCodeSchema,
36
+ transaction_type: z
37
+ .string()
38
+ .max(32)
39
+ .optional()
40
+ .describe('Transaction type from the FAP_SUPPLIER_TRANSACTION_HEADERS_TRANSACTION_TYPE lookup ' +
41
+ '(e.g. INVOICE, CREDIT_MEMO, DEBIT_MEMO, PREPAYMENT)'),
42
+ our_po_number: z.string().max(64).optional(),
43
+ supplier_reference: z.string().max(255).optional(),
44
+ payment_term_id: z
45
+ .string()
46
+ .min(1)
47
+ .optional()
48
+ .describe('UUID of the payment term. Required when the supplier (or supplier site use) has no ' +
49
+ 'default payment term; Persist rejects the bill with PAYMENT_TERM_REQUIRED otherwise.'),
50
+ ship_from_party_id: z.string().min(1).optional(),
51
+ ship_from_party_site_id: z.string().min(1).optional(),
52
+ ship_from_party_contact_point_id: z.string().min(1).optional(),
53
+ idempotency_key: idempotencyKeySchema,
54
+ }),
55
+ capabilities: [cap('fap_supplier_transaction_headers', 'INSERT')],
56
+ sideEffect: 'state_change',
57
+ confirmation: 'none',
58
+ idempotency: 'natural_key',
59
+ handler: async (args, ctx) => {
60
+ const input = args;
61
+ const body = {
62
+ bill_from_supplier_id: input.bill_from_supplier_id,
63
+ invoice_number: input.invoice_number,
64
+ transaction_date: input.transaction_date,
65
+ transaction_currency_code: input.transaction_currency_code,
66
+ };
67
+ for (const field of [
68
+ 'bill_from_supplier_site_id',
69
+ 'bill_from_supplier_contact_point_id',
70
+ 'transaction_type',
71
+ 'our_po_number',
72
+ 'supplier_reference',
73
+ 'payment_term_id',
74
+ 'ship_from_party_id',
75
+ 'ship_from_party_site_id',
76
+ 'ship_from_party_contact_point_id',
77
+ ]) {
78
+ if (input[field] !== undefined)
79
+ body[field] = input[field];
80
+ }
81
+ try {
82
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/fap_supplier_transaction_headers?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
83
+ return successResponse(rows[0]);
84
+ }
85
+ catch (error) {
86
+ return errorResponse(API_ERROR, `Failed to create FAP supplier bill: ${error.message}`);
87
+ }
88
+ },
89
+ };
90
+ //# sourceMappingURL=fap-supplier-bill-create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-bill-create.js","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-bill-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;;;;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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,uCAAuC,KAAK,CAAC,OAAO,EAAE,CACvD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Explicit-schema tool for appending a line to an FAP supplier bill.
4
+ * Amount and qty are validated at the MCP boundary. Retry-safe via
5
+ * (supplier_transaction_header_id, supplier_transaction_line_number).
6
+ */
7
+ export declare const fapSupplierBillLineAddTool: Tool;
8
+ //# sourceMappingURL=fap-supplier-bill-line-add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-bill-line-add.d.ts","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-bill-line-add.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAYtC;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,IA2ExC,CAAC"}
@@ -0,0 +1,75 @@
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 appending a line to an FAP supplier bill.
8
+ * Amount and qty are validated at the MCP boundary. Retry-safe via
9
+ * (supplier_transaction_header_id, supplier_transaction_line_number).
10
+ */
11
+ export const fapSupplierBillLineAddTool = {
12
+ name: 'fap_supplier_bill_line_add',
13
+ description: 'Append a line to an existing supplier bill. Amount/qty validated at the MCP ' +
14
+ 'boundary. Natural key: (supplier_transaction_header_id, supplier_transaction_line_number). ' +
15
+ 'Retry-safe.',
16
+ inputSchema: z.object({
17
+ supplier_transaction_header_id: z
18
+ .string()
19
+ .min(1)
20
+ .describe('UUID of the bill header this line belongs to'),
21
+ bill_from_supplier_id: z
22
+ .string()
23
+ .min(1)
24
+ .describe('UUID of the supplier (must match the header)'),
25
+ supplier_transaction_line_number: z
26
+ .number()
27
+ .int()
28
+ .positive()
29
+ .describe('1-based line number, unique within the header'),
30
+ supplier_transaction_line_qty: signedMoneySchema.describe('Line quantity — signed to permit debit-memo negative lines'),
31
+ extended_transaction_price: positiveMoneySchema.describe('Line total (qty × unit_transaction_price) — must be > 0'),
32
+ unit_transaction_price: positiveMoneySchema.describe('Unit price at the bill currency — must be > 0'),
33
+ unit_list_price: positiveMoneySchema.optional(),
34
+ extended_list_price: positiveMoneySchema.optional(),
35
+ supplier_transaction_line_item_id: z.string().min(1).optional(),
36
+ supplier_transaction_line_item_description: z.string().max(255).optional(),
37
+ supplier_transaction_line_uom: z.string().max(32).optional(),
38
+ supplier_transaction_line_reference: z.string().max(255).optional(),
39
+ idempotency_key: idempotencyKeySchema,
40
+ }),
41
+ capabilities: [cap('fap_supplier_transaction_lines', 'INSERT')],
42
+ sideEffect: 'state_change',
43
+ confirmation: 'none',
44
+ idempotency: 'natural_key',
45
+ handler: async (args, ctx) => {
46
+ const input = args;
47
+ const body = {
48
+ supplier_transaction_header_id: input.supplier_transaction_header_id,
49
+ bill_from_supplier_id: input.bill_from_supplier_id,
50
+ supplier_transaction_line_number: input.supplier_transaction_line_number,
51
+ supplier_transaction_line_qty: input.supplier_transaction_line_qty,
52
+ extended_transaction_price: input.extended_transaction_price,
53
+ unit_transaction_price: input.unit_transaction_price,
54
+ };
55
+ for (const field of [
56
+ 'unit_list_price',
57
+ 'extended_list_price',
58
+ 'supplier_transaction_line_item_id',
59
+ 'supplier_transaction_line_item_description',
60
+ 'supplier_transaction_line_uom',
61
+ 'supplier_transaction_line_reference',
62
+ ]) {
63
+ if (input[field] !== undefined)
64
+ body[field] = input[field];
65
+ }
66
+ try {
67
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/fap_supplier_transaction_lines?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
68
+ return successResponse(rows[0]);
69
+ }
70
+ catch (error) {
71
+ return errorResponse(API_ERROR, `Failed to add FAP supplier bill line: ${error.message}`);
72
+ }
73
+ },
74
+ };
75
+ //# sourceMappingURL=fap-supplier-bill-line-add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-bill-line-add.js","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-bill-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;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAS;IAC9C,IAAI,EAAE,4BAA4B;IAClC,WAAW,EACT,8EAA8E;QAC9E,6FAA6F;QAC7F,aAAa;IACf,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,8BAA8B,EAAE,CAAC;aAC9B,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,8CAA8C,CAAC;QAC3D,qBAAqB,EAAE,CAAC;aACrB,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CAAC,8CAA8C,CAAC;QAC3D,gCAAgC,EAAE,CAAC;aAChC,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,CAAC,+CAA+C,CAAC;QAC5D,6BAA6B,EAAE,iBAAiB,CAAC,QAAQ,CACvD,4DAA4D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rB,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,yCAAyC,KAAK,CAAC,OAAO,EAAE,CACzD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Explicit-schema create for `fap_suppliers`. Approval and status
4
+ * columns are DELIBERATELY excluded — the persist layer assigns the
5
+ * initial lifecycle state so a caller cannot bootstrap an already-
6
+ * approved supplier via MCP.
7
+ */
8
+ export declare const fapSupplierCreateTool: Tool;
9
+ //# sourceMappingURL=fap-supplier-create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-create.d.ts","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,IA2CnC,CAAC"}
@@ -0,0 +1,53 @@
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 `fap_suppliers`. Approval and status
8
+ * columns are DELIBERATELY excluded — the persist layer assigns the
9
+ * initial lifecycle state so a caller cannot bootstrap an already-
10
+ * approved supplier via MCP.
11
+ */
12
+ export const fapSupplierCreateTool = {
13
+ name: 'fap_supplier_create',
14
+ description: 'Create a new FAP supplier with an explicit safe field set. Approval/status ' +
15
+ 'columns are excluded — persist assigns the initial lifecycle state. ' +
16
+ 'One supplier per party, and supplier_code is unique, within the tenant: a retry ' +
17
+ 'fails with a duplicate-key error instead of creating a second supplier.',
18
+ inputSchema: z.object({
19
+ party_id: z.string().min(1).describe('UUID of the PRM party this supplier represents'),
20
+ supplier_code: z.string().min(1).max(64).optional(),
21
+ supplier_class_code: z.string().max(64).optional(),
22
+ supplier_type_code: z.string().max(64).optional(),
23
+ invoice_currency_code: currencyCodeSchema.optional(),
24
+ payment_term_id: z.string().min(1).optional(),
25
+ idempotency_key: idempotencyKeySchema,
26
+ }),
27
+ capabilities: [cap('fap_suppliers', 'INSERT')],
28
+ sideEffect: 'state_change',
29
+ confirmation: 'none',
30
+ idempotency: 'natural_key',
31
+ handler: async (args, ctx) => {
32
+ const input = args;
33
+ const body = { party_id: input.party_id };
34
+ for (const field of [
35
+ 'supplier_code',
36
+ 'supplier_class_code',
37
+ 'supplier_type_code',
38
+ 'invoice_currency_code',
39
+ 'payment_term_id',
40
+ ]) {
41
+ if (input[field] !== undefined)
42
+ body[field] = input[field];
43
+ }
44
+ try {
45
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/fap_suppliers?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
46
+ return successResponse(rows[0]);
47
+ }
48
+ catch (error) {
49
+ return errorResponse(API_ERROR, `Failed to create FAP supplier: ${error.message}`);
50
+ }
51
+ },
52
+ };
53
+ //# sourceMappingURL=fap-supplier-create.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,EAAE,QAAQ,CAAC,CAAC;IAC9C,UAAU,EAAE,cAAc;IAC1B,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,IAA2B,CAAC;QAC1C,MAAM,IAAI,GAAwB,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/D,KAAK,MAAM,KAAK,IAAI;YAClB,eAAe;YACf,qBAAqB;YACrB,oBAAoB;YACpB,uBAAuB;YACvB,iBAAiB;SAClB,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,yBAAyB,EACpD,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,CAAC,SAAS,EAAE,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Semantic supplier lifecycle transition — mirrors far_customer_status_set.
4
+ * Reads the row first: the reason is merged into the existing `metadata`,
5
+ * and a supplier already in the target state is returned unchanged.
6
+ */
7
+ export declare const fapSupplierStatusSetTool: Tool;
8
+ //# sourceMappingURL=fap-supplier-status-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-status-set.d.ts","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-status-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAKtC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,IAmEtC,CAAC"}
@@ -0,0 +1,62 @@
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 supplier lifecycle transition — mirrors far_customer_status_set.
7
+ * Reads the row first: the reason is merged into the existing `metadata`,
8
+ * and a supplier already in the target state is returned unchanged.
9
+ */
10
+ export const fapSupplierStatusSetTool = {
11
+ name: 'fap_supplier_status_set',
12
+ description: 'Transition a FAP supplier lifecycle status. Accepts supplier_status_code and/or ' +
13
+ 'supplier_approval_status_code; requires a `reason`, merged into the supplier metadata. ' +
14
+ 'A supplier already in the target state is returned unchanged, so retries are safe.',
15
+ inputSchema: z
16
+ .object({
17
+ id: z.string().min(1).describe('UUID of the supplier'),
18
+ supplier_status_code: z
19
+ .string()
20
+ .max(64)
21
+ .optional()
22
+ .describe('Target status from the FAP_SUPPLIERS_SUPPLIER_STATUS lookup (e.g. A = Active, I = Inactive)'),
23
+ supplier_approval_status_code: z
24
+ .string()
25
+ .max(64)
26
+ .optional()
27
+ .describe('Target approval status from the FAP_SUPPLIERS_SUPPLIER_APPROVAL_STATUS lookup ' +
28
+ '(e.g. A = Approved, P = Pending, R = Rejected)'),
29
+ reason: reasonSchema.describe('Human-readable justification, stored in metadata'),
30
+ idempotency_key: idempotencyKeySchema,
31
+ })
32
+ .refine((v) => v.supplier_status_code !== undefined ||
33
+ v.supplier_approval_status_code !== undefined, {
34
+ message: 'supply supplier_status_code and/or supplier_approval_status_code — at least one is required.',
35
+ }),
36
+ capabilities: [cap('fap_suppliers', 'UPDATE')],
37
+ sideEffect: 'state_change',
38
+ confirmation: 'caller_provides_reason',
39
+ idempotency: 'natural_key',
40
+ handler: async (args, ctx) => {
41
+ const input = args;
42
+ const target = {};
43
+ if (input.supplier_status_code !== undefined) {
44
+ target.supplier_status_code = input.supplier_status_code;
45
+ }
46
+ if (input.supplier_approval_status_code !== undefined) {
47
+ target.supplier_approval_status_code = input.supplier_approval_status_code;
48
+ }
49
+ return softDeactivate(ctx, {
50
+ table: 'fap_suppliers',
51
+ id: input.id,
52
+ label: 'FAP supplier',
53
+ verb: 'set status of',
54
+ isDone: (row) => Object.entries(target).every(([k, v]) => row[k] === v),
55
+ changes: () => target,
56
+ reasonKey: 'status_change_reason',
57
+ reason: input.reason,
58
+ idempotencyKey: input.idempotency_key,
59
+ });
60
+ },
61
+ };
62
+ //# sourceMappingURL=fap-supplier-status-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-status-set.js","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-status-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAS;IAC5C,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EACT,kFAAkF;QAClF,yFAAyF;QACzF,oFAAoF;IACtF,WAAW,EAAE,CAAC;SACX,MAAM,CAAC;QACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACtD,oBAAoB,EAAE,CAAC;aACpB,MAAM,EAAE;aACR,GAAG,CAAC,EAAE,CAAC;aACP,QAAQ,EAAE;aACV,QAAQ,C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AE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM;YACrB,SAAS,EAAE,sBAAsB;YACjC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,cAAc,EAAE,KAAK,CAAC,eAAe;SACtC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Explicit-schema update for `fap_suppliers`. Status/approval columns
4
+ * are excluded — use `fap_supplier_status_set` for lifecycle
5
+ * transitions so a reason is recorded on the audit trail.
6
+ */
7
+ export declare const fapSupplierUpdateTool: Tool;
8
+ //# sourceMappingURL=fap-supplier-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fap-supplier-update.d.ts","sourceRoot":"","sources":["../../../src/tools/fap/fap-supplier-update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,IAgDnC,CAAC"}
@@ -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,CAA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AC;YAC1C,IAAI,CAAC,KAAK,SAAS;gBAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,aAAa,CAClB,SAAS,EACT,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,KAAK,CACpC,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,wBAAwB,EAAE,WAAW,EAChE,IAAI,EACJ,EAAE,OAAO,EAAE,mBAAmB,CAAC,eAAe,CAAC,EAAE,CAClD,CAAC;YACF,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAO,aAAa,CAAC,SAAS,EAAE,gBAAgB,EAAE,8BAA8B,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,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,5 @@
1
+ import { Tool } from '../registry.js';
2
+ export declare const fapTools: Tool[];
3
+ /** Read-only slice used by the `fap-readonly` selectable sub-domain. */
4
+ export declare const fapReadOnlyTools: Tool[];
5
+ //# sourceMappingURL=index.d.ts.map
@@ -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,27 @@
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_pk`), so a retry
11
+ * fails with a duplicate-key error. Without it Persist generates a
12
+ * new code on every insert, and Persist ignores `Idempotency-Key`
13
+ * (WI-0008817), so an `idempotency_key` alone would record the
14
+ * payment twice.
15
+ *
16
+ * This follows dev and the resource contract. The Persist repo SQL
17
+ * differs: its view exposes `receipt_code` and it has no unique key on
18
+ * that column, so a database built from the repo would not match
19
+ * until that is resolved (WI-0009298, WI-0009313).
20
+ *
21
+ * The generated bounded read framework filters `far_cash_receipts` out
22
+ * of the auto-read surface (sensitivity=`sensitive`); the module opts
23
+ * it back in with credential redaction, and this dedicated tool is the
24
+ * ONLY approved write path.
25
+ */
26
+ export declare const farCashReceiptRecordTool: Tool;
27
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,EAAE,IAiFtC,CAAC"}
@@ -0,0 +1,101 @@
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_pk`), so a retry
15
+ * fails with a duplicate-key error. Without it Persist generates a
16
+ * new code on every insert, and Persist ignores `Idempotency-Key`
17
+ * (WI-0008817), so an `idempotency_key` alone would record the
18
+ * payment twice.
19
+ *
20
+ * This follows dev and the resource contract. The Persist repo SQL
21
+ * differs: its view exposes `receipt_code` and it has no unique key on
22
+ * that column, so a database built from the repo would not match
23
+ * until that is resolved (WI-0009298, WI-0009313).
24
+ *
25
+ * The generated bounded read framework filters `far_cash_receipts` out
26
+ * of the auto-read surface (sensitivity=`sensitive`); the module opts
27
+ * it back in with credential redaction, and this dedicated tool is the
28
+ * ONLY approved write path.
29
+ */
30
+ export const farCashReceiptRecordTool = {
31
+ name: 'far_cash_receipt_record',
32
+ description: 'Record a cash receipt against a customer (far_cash_receipts). Requires ' +
33
+ 'confirm=true, a positive receipt_amount, ISO currency, and a receipt_number. ' +
34
+ 'receipt_number is unique within the organisation: a retry with the same ' +
35
+ 'receipt_number fails with a duplicate-key error instead of recording the payment twice.',
36
+ inputSchema: z
37
+ .object({
38
+ customer_id: z.string().min(1).describe('UUID of the customer'),
39
+ customer_site_use_id: z.string().min(1).optional(),
40
+ receipt_amount: positiveMoneySchema.describe('Positive amount to record'),
41
+ receipt_currency_code: currencyCodeSchema,
42
+ receipt_date: z.string().min(1).describe('ISO 8601 date the funds cleared'),
43
+ receipt_number: z
44
+ .string()
45
+ .min(1)
46
+ .max(30)
47
+ .describe('Business receipt number, unique within the organisation. Required so a retry ' +
48
+ 'cannot record the same payment twice.'),
49
+ receipt_type: z
50
+ .string()
51
+ .max(20)
52
+ .optional()
53
+ .describe('Receipt type from the FAR_CASH_RECEIPTS_RECEIPT_TYPE lookup (e.g. CASH, MISC)'),
54
+ customer_reference: z.string().max(30).optional(),
55
+ customer_bank_account_id: z.string().min(1).optional(),
56
+ remittance_bank_account_use_id: z.string().min(1).optional(),
57
+ exchange_rate: z.number().positive().optional(),
58
+ exchange_rate_type: z.string().max(30).optional(),
59
+ exchange_date: z.string().min(1).optional(),
60
+ confirm: confirmFlagSchema,
61
+ idempotency_key: idempotencyKeySchema,
62
+ })
63
+ .refine((v) => v.exchange_rate === undefined || v.exchange_rate_type !== undefined, {
64
+ message: 'exchange_rate requires exchange_rate_type (and typically exchange_date)',
65
+ }),
66
+ capabilities: [cap('far_cash_receipts', 'INSERT')],
67
+ sideEffect: 'payment',
68
+ confirmation: 'caller_confirms',
69
+ idempotency: 'natural_key',
70
+ handler: async (args, ctx) => {
71
+ const input = args;
72
+ const body = {
73
+ customer_id: input.customer_id,
74
+ receipt_number: input.receipt_number,
75
+ receipt_amount: input.receipt_amount,
76
+ receipt_currency_code: input.receipt_currency_code,
77
+ receipt_date: input.receipt_date,
78
+ };
79
+ for (const field of [
80
+ 'customer_site_use_id',
81
+ 'receipt_type',
82
+ 'customer_reference',
83
+ 'customer_bank_account_id',
84
+ 'remittance_bank_account_use_id',
85
+ 'exchange_rate',
86
+ 'exchange_rate_type',
87
+ 'exchange_date',
88
+ ]) {
89
+ if (input[field] !== undefined)
90
+ body[field] = input[field];
91
+ }
92
+ try {
93
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/far_cash_receipts?select=*`, body, { headers: financeWriteHeaders(input.idempotency_key) });
94
+ return successResponse(rows[0]);
95
+ }
96
+ catch (error) {
97
+ return errorResponse(API_ERROR, `Failed to record FAR cash receipt: ${error.message}`);
98
+ }
99
+ },
100
+ };
101
+ //# sourceMappingURL=far-cash-receipt-record.js.map