@raytio/mcp-server 10.2.0 → 10.3.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 (89) hide show
  1. package/contracts/persist/mcp_resource_contract.json +4 -4
  2. package/dist/authorization.d.ts.map +1 -1
  3. package/dist/authorization.js +2 -0
  4. package/dist/authorization.js.map +1 -1
  5. package/dist/generated-reads/guardrails.js +1 -1
  6. package/dist/generated-reads/guardrails.js.map +1 -1
  7. package/dist/generated-reads/resource-tools.d.ts.map +1 -1
  8. package/dist/generated-reads/resource-tools.js +8 -5
  9. package/dist/generated-reads/resource-tools.js.map +1 -1
  10. package/dist/tools/_shared/soft-deactivate.d.ts +2 -0
  11. package/dist/tools/_shared/soft-deactivate.d.ts.map +1 -1
  12. package/dist/tools/_shared/soft-deactivate.js +3 -0
  13. package/dist/tools/_shared/soft-deactivate.js.map +1 -1
  14. package/dist/tools/domains.d.ts.map +1 -1
  15. package/dist/tools/domains.js +18 -0
  16. package/dist/tools/domains.js.map +1 -1
  17. package/dist/tools/imports/index.d.ts +6 -6
  18. package/dist/tools/pbm/generated-reads.d.ts +5 -0
  19. package/dist/tools/pbm/generated-reads.d.ts.map +1 -0
  20. package/dist/tools/pbm/generated-reads.js +32 -0
  21. package/dist/tools/pbm/generated-reads.js.map +1 -0
  22. package/dist/tools/pbm/index.d.ts +5 -0
  23. package/dist/tools/pbm/index.d.ts.map +1 -0
  24. package/dist/tools/pbm/index.js +17 -0
  25. package/dist/tools/pbm/index.js.map +1 -0
  26. package/dist/tools/pbm/pbm-customer-entitlement-override-set.d.ts +26 -0
  27. package/dist/tools/pbm/pbm-customer-entitlement-override-set.d.ts.map +1 -0
  28. package/dist/tools/pbm/pbm-customer-entitlement-override-set.js +78 -0
  29. package/dist/tools/pbm/pbm-customer-entitlement-override-set.js.map +1 -0
  30. package/dist/tools/pbm/pbm-subscription-cancel.d.ts +21 -0
  31. package/dist/tools/pbm/pbm-subscription-cancel.d.ts.map +1 -0
  32. package/dist/tools/pbm/pbm-subscription-cancel.js +86 -0
  33. package/dist/tools/pbm/pbm-subscription-cancel.js.map +1 -0
  34. package/dist/tools/pbm/pbm-subscription-create.d.ts +20 -0
  35. package/dist/tools/pbm/pbm-subscription-create.d.ts.map +1 -0
  36. package/dist/tools/pbm/pbm-subscription-create.js +90 -0
  37. package/dist/tools/pbm/pbm-subscription-create.js.map +1 -0
  38. package/dist/tools/pbm/pbm-subscription-line-add.d.ts +13 -0
  39. package/dist/tools/pbm/pbm-subscription-line-add.d.ts.map +1 -0
  40. package/dist/tools/pbm/pbm-subscription-line-add.js +65 -0
  41. package/dist/tools/pbm/pbm-subscription-line-add.js.map +1 -0
  42. package/dist/tools/pbm/pbm-subscription-line-end.d.ts +12 -0
  43. package/dist/tools/pbm/pbm-subscription-line-end.d.ts.map +1 -0
  44. package/dist/tools/pbm/pbm-subscription-line-end.js +49 -0
  45. package/dist/tools/pbm/pbm-subscription-line-end.js.map +1 -0
  46. package/dist/tools/qom/generated-reads.d.ts +5 -0
  47. package/dist/tools/qom/generated-reads.d.ts.map +1 -0
  48. package/dist/tools/qom/generated-reads.js +22 -0
  49. package/dist/tools/qom/generated-reads.js.map +1 -0
  50. package/dist/tools/qom/index.d.ts +5 -0
  51. package/dist/tools/qom/index.d.ts.map +1 -0
  52. package/dist/tools/qom/index.js +23 -0
  53. package/dist/tools/qom/index.js.map +1 -0
  54. package/dist/tools/qom/qom-order-cancel.d.ts +16 -0
  55. package/dist/tools/qom/qom-order-cancel.d.ts.map +1 -0
  56. package/dist/tools/qom/qom-order-cancel.js +56 -0
  57. package/dist/tools/qom/qom-order-cancel.js.map +1 -0
  58. package/dist/tools/qom/qom-order-create.d.ts +24 -0
  59. package/dist/tools/qom/qom-order-create.d.ts.map +1 -0
  60. package/dist/tools/qom/qom-order-create.js +133 -0
  61. package/dist/tools/qom/qom-order-create.js.map +1 -0
  62. package/dist/tools/qom/qom-order-hold-place.d.ts +11 -0
  63. package/dist/tools/qom/qom-order-hold-place.d.ts.map +1 -0
  64. package/dist/tools/qom/qom-order-hold-place.js +50 -0
  65. package/dist/tools/qom/qom-order-hold-place.js.map +1 -0
  66. package/dist/tools/qom/qom-order-hold-release.d.ts +8 -0
  67. package/dist/tools/qom/qom-order-hold-release.d.ts.map +1 -0
  68. package/dist/tools/qom/qom-order-hold-release.js +42 -0
  69. package/dist/tools/qom/qom-order-hold-release.js.map +1 -0
  70. package/dist/tools/qom/qom-order-line-add.d.ts +18 -0
  71. package/dist/tools/qom/qom-order-line-add.d.ts.map +1 -0
  72. package/dist/tools/qom/qom-order-line-add.js +101 -0
  73. package/dist/tools/qom/qom-order-line-add.js.map +1 -0
  74. package/dist/tools/qom/qom-quote-create.d.ts +20 -0
  75. package/dist/tools/qom/qom-quote-create.d.ts.map +1 -0
  76. package/dist/tools/qom/qom-quote-create.js +142 -0
  77. package/dist/tools/qom/qom-quote-create.js.map +1 -0
  78. package/dist/tools/qom/qom-quote-line-add.d.ts +13 -0
  79. package/dist/tools/qom/qom-quote-line-add.d.ts.map +1 -0
  80. package/dist/tools/qom/qom-quote-line-add.js +92 -0
  81. package/dist/tools/qom/qom-quote-line-add.js.map +1 -0
  82. package/dist/tools/qom/qom-quote-version-create.d.ts +10 -0
  83. package/dist/tools/qom/qom-quote-version-create.d.ts.map +1 -0
  84. package/dist/tools/qom/qom-quote-version-create.js +69 -0
  85. package/dist/tools/qom/qom-quote-version-create.js.map +1 -0
  86. package/dist/tools/role-mapping.d.ts.map +1 -1
  87. package/dist/tools/role-mapping.js +9 -8
  88. package/dist/tools/role-mapping.js.map +1 -1
  89. package/package.json +1 -1
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ import { API_ERROR, errorResponse, successResponse } from '../types.js';
3
+ import { cap } from '../../capabilities/tool-capability.js';
4
+ import { confirmFlagSchema, reasonSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * Cancellation semantic tool for a PBM billing subscription.
7
+ *
8
+ * Writes the cancellation columns through the
9
+ * `pbm_billing_subscriptions_u` update view. Persist's
10
+ * `call_generate_billing_invoices_cancellation_update` trigger then
11
+ * schedules the final invoice job, but only for an active BILLABLE
12
+ * subscription: on any other status the columns would be stored and
13
+ * nothing would happen. The tool reads the row first and refuses those.
14
+ *
15
+ * It also returns a subscription that already has a cancellation date
16
+ * unchanged. Persist resets `cancellation_request_date` to now on every
17
+ * update of such a row, and a changed reason or action could schedule
18
+ * another job, so a retry must not write.
19
+ *
20
+ * `cancellation_request_date` is not an input because that trigger
21
+ * overwrites whatever is supplied.
22
+ */
23
+ export const pbmSubscriptionCancelTool = {
24
+ name: 'pbm_subscription_cancel',
25
+ description: 'Cancel a BILLABLE PBM billing subscription: records the cancellation and Persist schedules ' +
26
+ 'the final invoice job. The subscription closes when that job runs, so subscription_status ' +
27
+ 'stays BILLABLE until then. Any other status is refused, because no job would be scheduled. ' +
28
+ 'Requires confirm=true and a reason. A subscription already cancelled is returned unchanged, ' +
29
+ 'so retries are safe.',
30
+ inputSchema: z.object({
31
+ id: z
32
+ .string()
33
+ .min(1)
34
+ .describe('UUID of the pbm_billing_subscriptions row to cancel'),
35
+ cancellation_effective_date: z
36
+ .string()
37
+ .min(1)
38
+ .describe('ISO 8601 date cancellation takes effect (required). Persist rejects a date before ' +
39
+ 'the current billing period start.'),
40
+ cancellation_final_invoice_action: z
41
+ .enum(['CYCLE_END', 'PRORATE_CYCLE_END', 'IMMEDIATE', 'PRORATE_IMMEDIATE'])
42
+ .optional()
43
+ .describe('Final invoice policy. Defaults to the value on the subscription, normally CYCLE_END.'),
44
+ reason: reasonSchema.describe('Human-readable reason, stored in cancellation_request_reason'),
45
+ confirm: confirmFlagSchema,
46
+ idempotency_key: unenforcedIdempotencyKeySchema,
47
+ }),
48
+ capabilities: [
49
+ cap('pbm_billing_subscriptions', 'SELECT'),
50
+ cap('pbm_billing_subscriptions_u', 'UPDATE'),
51
+ ],
52
+ sideEffect: 'state_change',
53
+ confirmation: 'caller_confirms',
54
+ idempotency: 'natural_key',
55
+ handler: async (args, ctx) => {
56
+ const input = args;
57
+ const notFound = () => errorResponse(API_ERROR, `PBM billing subscription ${input.id} not found or not accessible`);
58
+ const body = {
59
+ cancellation_effective_date: input.cancellation_effective_date,
60
+ cancellation_request_reason: input.reason,
61
+ };
62
+ if (input.cancellation_final_invoice_action !== undefined) {
63
+ body.cancellation_final_invoice_action = input.cancellation_final_invoice_action;
64
+ }
65
+ try {
66
+ const current = await ctx.apiClient.get(`${ctx.apiClient.dbBasePath}/pbm_billing_subscriptions?id=eq.${input.id}&select=*`);
67
+ if (!current || current.length === 0)
68
+ return notFound();
69
+ const row = current[0];
70
+ if (row.cancellation_effective_date)
71
+ return successResponse(row);
72
+ if (row.subscription_status !== 'BILLABLE' || row.active === false) {
73
+ return errorResponse(API_ERROR, `PBM billing subscription ${input.id} is ${row.subscription_status}: ` +
74
+ 'only an active BILLABLE subscription can be cancelled');
75
+ }
76
+ const rows = await ctx.apiClient.patch(`${ctx.apiClient.dbBasePath}/pbm_billing_subscriptions_u?id=eq.${input.id}&select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
77
+ if (!rows || rows.length === 0)
78
+ return notFound();
79
+ return successResponse(rows[0]);
80
+ }
81
+ catch (error) {
82
+ return errorResponse(API_ERROR, `Failed to cancel PBM billing subscription: ${error.message}`);
83
+ }
84
+ },
85
+ };
86
+ //# sourceMappingURL=pbm-subscription-cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-cancel.js","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-cancel.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,iBAA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AAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,8CAA8C,KAAK,CAAC,OAAO,EAAE,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Provisioning semantic tool: create a PBM billing subscription
4
+ * (`pbm_billing_subscriptions`). Requires `confirm: true`.
5
+ *
6
+ * The subscription starts PENDING, and billing starts when it becomes
7
+ * BILLABLE. MCP has no tool for that step. Persist has no unique key
8
+ * here, so a retry creates a second subscription.
9
+ *
10
+ * Cancellation columns (`cancellation_effective_date`,
11
+ * `cancellation_request_date`, `cancellation_request_reason`,
12
+ * `cancellation_final_invoice_action`) are intentionally NOT writable
13
+ * through this tool — cancellation is a lifecycle event handled by
14
+ * `pbm_subscription_cancel`. `subscription_status` is not an input.
15
+ *
16
+ * Payment method / gateway credentials live in an excluded FXM table
17
+ * (fxm_payment_processor_credentials) and cannot be set through MCP.
18
+ */
19
+ export declare const pbmSubscriptionCreateTool: Tool;
20
+ //# sourceMappingURL=pbm-subscription-create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-create.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,EAAE,IA0EvC,CAAC"}
@@ -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 { confirmFlagSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * Provisioning semantic tool: create a PBM billing subscription
7
+ * (`pbm_billing_subscriptions`). Requires `confirm: true`.
8
+ *
9
+ * The subscription starts PENDING, and billing starts when it becomes
10
+ * BILLABLE. MCP has no tool for that step. Persist has no unique key
11
+ * here, so a retry creates a second subscription.
12
+ *
13
+ * Cancellation columns (`cancellation_effective_date`,
14
+ * `cancellation_request_date`, `cancellation_request_reason`,
15
+ * `cancellation_final_invoice_action`) are intentionally NOT writable
16
+ * through this tool — cancellation is a lifecycle event handled by
17
+ * `pbm_subscription_cancel`. `subscription_status` is not an input.
18
+ *
19
+ * Payment method / gateway credentials live in an excluded FXM table
20
+ * (fxm_payment_processor_credentials) and cannot be set through MCP.
21
+ */
22
+ export const pbmSubscriptionCreateTool = {
23
+ name: 'pbm_subscription_create',
24
+ description: 'Create a PBM billing subscription (pbm_billing_subscriptions). It starts PENDING and is ' +
25
+ 'not billed until it becomes BILLABLE, which MCP cannot do. Requires confirm=true. ' +
26
+ 'Not deduplicated: calling it again creates another subscription, so check ' +
27
+ 'pbm_billing_subscriptions_list filtered on subscribed_to_customer_id before retrying.',
28
+ inputSchema: z.object({
29
+ subscribed_to_customer_id: z
30
+ .string()
31
+ .min(1)
32
+ .describe('UUID of the far_customers row this subscription bills'),
33
+ subscribed_to_party_contact_point_id: z
34
+ .string()
35
+ .min(1)
36
+ .describe('UUID of the party contact point (billing contact) — required'),
37
+ subscribed_to_customer_site_id: z.string().min(1).optional(),
38
+ subscription_name: z.string().max(256).optional(),
39
+ subscription_name_i18n: z.record(z.string()).optional(),
40
+ billing_cycle_month: z.number().int().min(1).max(12).optional(),
41
+ billing_cycle_day_of_month: z.number().int().min(1).max(31).optional(),
42
+ billing_cycle_day_of_week: z.number().int().min(0).max(6).optional(),
43
+ billing_cycle_hour: z.number().int().min(0).max(23).optional(),
44
+ billing_cycle_minute: z.number().int().min(0).max(59).optional(),
45
+ billing_cycle_second: z.number().int().min(0).max(59).optional(),
46
+ subscription_timezone_offset_minutes: z.number().int().optional(),
47
+ start_date: z.string().min(1).optional().describe('ISO 8601 subscription start'),
48
+ end_date: z.string().min(1).optional().describe('ISO 8601 subscription end (rare on create)'),
49
+ metadata: z.record(z.unknown()).optional(),
50
+ confirm: confirmFlagSchema,
51
+ idempotency_key: unenforcedIdempotencyKeySchema,
52
+ }),
53
+ capabilities: [cap('pbm_billing_subscriptions', 'INSERT')],
54
+ sideEffect: 'provisioning',
55
+ confirmation: 'caller_confirms',
56
+ idempotency: 'not_idempotent',
57
+ handler: async (args, ctx) => {
58
+ const input = args;
59
+ const body = {
60
+ subscribed_to_customer_id: input.subscribed_to_customer_id,
61
+ subscribed_to_party_contact_point_id: input.subscribed_to_party_contact_point_id,
62
+ };
63
+ for (const field of [
64
+ 'subscribed_to_customer_site_id',
65
+ 'subscription_name',
66
+ 'subscription_name_i18n',
67
+ 'billing_cycle_month',
68
+ 'billing_cycle_day_of_month',
69
+ 'billing_cycle_day_of_week',
70
+ 'billing_cycle_hour',
71
+ 'billing_cycle_minute',
72
+ 'billing_cycle_second',
73
+ 'subscription_timezone_offset_minutes',
74
+ 'start_date',
75
+ 'end_date',
76
+ 'metadata',
77
+ ]) {
78
+ if (input[field] !== undefined)
79
+ body[field] = input[field];
80
+ }
81
+ try {
82
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/pbm_billing_subscriptions?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
83
+ return successResponse(rows[0]);
84
+ }
85
+ catch (error) {
86
+ return errorResponse(API_ERROR, `Failed to create PBM billing subscription: ${error.message}`);
87
+ }
88
+ },
89
+ };
90
+ //# sourceMappingURL=pbm-subscription-create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-create.js","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-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,EAC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AAK,CAAC,oCAAoC;SAC7C,CAAC;QACF,KAAK,MAAM,KAAK,IAAI;YAClB,gCAAgC;YAChC,mBAAmB;YACnB,wBAAwB;YACxB,qBAAqB;YACrB,4BAA4B;YAC5B,2BAA2B;YAC3B,oBAAoB;YACpB,sBAAsB;YACtB,sBAAsB;YACtB,sCAAsC;YACtC,YAAY;YACZ,UAAU;YACV,UAAU;SACX,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,qCAAqC,EAChE,IAAI,EACJ,EAAE,OAAO,EAAE,2BAA2B,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,8CAA8C,KAAK,CAAC,OAAO,EAAE,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Provisioning semantic tool: add a line (priced item) to a PBM billing
4
+ * subscription (`pbm_billing_subscription_lines`).
5
+ *
6
+ * Persist refuses the insert unless the parent is PENDING, and requires
7
+ * every line on a subscription to share a currency and billing interval.
8
+ * `subscribed_to_customer_id` is set from the parent by a trigger, so it
9
+ * is not an input. There is no unique key on these lines, so a retry
10
+ * adds a second line and the customer would be billed for both.
11
+ */
12
+ export declare const pbmSubscriptionLineAddTool: Tool;
13
+ //# sourceMappingURL=pbm-subscription-line-add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-line-add.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-line-add.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,EAAE,IAuDxC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { API_ERROR, errorResponse, successResponse } from '../types.js';
3
+ import { cap } from '../../capabilities/tool-capability.js';
4
+ import { confirmFlagSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
5
+ /**
6
+ * Provisioning semantic tool: add a line (priced item) to a PBM billing
7
+ * subscription (`pbm_billing_subscription_lines`).
8
+ *
9
+ * Persist refuses the insert unless the parent is PENDING, and requires
10
+ * every line on a subscription to share a currency and billing interval.
11
+ * `subscribed_to_customer_id` is set from the parent by a trigger, so it
12
+ * is not an input. There is no unique key on these lines, so a retry
13
+ * adds a second line and the customer would be billed for both.
14
+ */
15
+ export const pbmSubscriptionLineAddTool = {
16
+ name: 'pbm_subscription_line_add',
17
+ description: 'Add a priced line to a PENDING PBM billing subscription (pbm_billing_subscription_lines). ' +
18
+ 'Persist refuses any other status, and every line must share a currency and billing ' +
19
+ 'interval. Requires confirm=true. Not deduplicated: calling it again adds another line that ' +
20
+ 'would also be billed, so check pbm_billing_subscription_lines_list before retrying.',
21
+ inputSchema: z.object({
22
+ billing_subscription_id: z
23
+ .string()
24
+ .min(1)
25
+ .describe('UUID of the parent pbm_billing_subscriptions row (required)'),
26
+ price_id: z
27
+ .string()
28
+ .min(1)
29
+ .describe('UUID of the pcm_prices row this line bills against (required)'),
30
+ subscribed_qty: z.number().optional().describe('Quantity of the priced item'),
31
+ start_date: z.string().min(1).optional().describe('ISO 8601 line start (defaults to today)'),
32
+ end_date: z.string().min(1).optional().describe('ISO 8601 line end (rarely on create)'),
33
+ metadata: z.record(z.unknown()).optional(),
34
+ confirm: confirmFlagSchema,
35
+ idempotency_key: unenforcedIdempotencyKeySchema,
36
+ }),
37
+ capabilities: [cap('pbm_billing_subscription_lines', 'INSERT')],
38
+ sideEffect: 'provisioning',
39
+ confirmation: 'caller_confirms',
40
+ idempotency: 'not_idempotent',
41
+ handler: async (args, ctx) => {
42
+ const input = args;
43
+ const body = {
44
+ billing_subscription_id: input.billing_subscription_id,
45
+ price_id: input.price_id,
46
+ };
47
+ for (const field of [
48
+ 'subscribed_qty',
49
+ 'start_date',
50
+ 'end_date',
51
+ 'metadata',
52
+ ]) {
53
+ if (input[field] !== undefined)
54
+ body[field] = input[field];
55
+ }
56
+ try {
57
+ const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/pbm_billing_subscription_lines?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
58
+ return successResponse(rows[0]);
59
+ }
60
+ catch (error) {
61
+ return errorResponse(API_ERROR, `Failed to add PBM subscription line: ${error.message}`);
62
+ }
63
+ },
64
+ };
65
+ //# sourceMappingURL=pbm-subscription-line-add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-line-add.js","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-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,iBAAiB,EACjB,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAS;IAC9C,IAAI,EAAE,2BAA2B;IACjC,WAAW,EACT,4FAA4F;QAC5F,qFAAqF;QACrF,6FAA6F;QAC7F,qFAAqF;IACvF,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,uBAAuB,E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,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,2BAA2B,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,wCAAwC,KAAK,CAAC,OAAO,EAAE,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * State-change semantic tool: close a subscription line by setting its
4
+ * `end_date` (`pbm_billing_subscription_lines`). The reason is merged
5
+ * into `metadata.line_end_reason`.
6
+ *
7
+ * Persist's `prevent_subscription_line_for_parent_status` trigger
8
+ * refuses every insert and update unless the parent subscription is
9
+ * PENDING, so this cannot change a subscription that is already billing.
10
+ */
11
+ export declare const pbmSubscriptionLineEndTool: Tool;
12
+ //# sourceMappingURL=pbm-subscription-line-end.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-line-end.d.ts","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-line-end.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAStC;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAE,IAwCxC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ import { cap } from '../../capabilities/tool-capability.js';
3
+ import { confirmFlagSchema, reasonSchema, unenforcedIdempotencyKeySchema, } from '../_shared/side-effect.js';
4
+ import { softDeactivate } from '../_shared/soft-deactivate.js';
5
+ /**
6
+ * State-change semantic tool: close a subscription line by setting its
7
+ * `end_date` (`pbm_billing_subscription_lines`). The reason is merged
8
+ * into `metadata.line_end_reason`.
9
+ *
10
+ * Persist's `prevent_subscription_line_for_parent_status` trigger
11
+ * refuses every insert and update unless the parent subscription is
12
+ * PENDING, so this cannot change a subscription that is already billing.
13
+ */
14
+ export const pbmSubscriptionLineEndTool = {
15
+ name: 'pbm_subscription_line_end',
16
+ description: 'Close a PBM subscription line by setting end_date and merge the reason into metadata. ' +
17
+ 'Persist only allows this while the parent subscription is PENDING, so it cannot change what ' +
18
+ 'a billing subscription charges. Requires confirm=true and a reason. A line already ending ' +
19
+ 'on that date is returned unchanged, so retries are safe.',
20
+ inputSchema: z.object({
21
+ id: z.string().min(1).describe('UUID of the pbm_billing_subscription_lines row to close'),
22
+ end_date: z
23
+ .string()
24
+ .min(1)
25
+ .describe('ISO 8601 date the line ends (required)'),
26
+ reason: reasonSchema.describe('Human-readable reason, merged into metadata'),
27
+ confirm: confirmFlagSchema,
28
+ idempotency_key: unenforcedIdempotencyKeySchema,
29
+ }),
30
+ capabilities: [cap('pbm_billing_subscription_lines', 'UPDATE')],
31
+ sideEffect: 'state_change',
32
+ confirmation: 'caller_confirms',
33
+ idempotency: 'natural_key',
34
+ handler: async (args, ctx) => {
35
+ const input = args;
36
+ return softDeactivate(ctx, {
37
+ table: 'pbm_billing_subscription_lines',
38
+ id: input.id,
39
+ label: 'PBM subscription line',
40
+ verb: 'end',
41
+ isDone: (row) => new Date(row.end_date).getTime() === new Date(input.end_date).getTime(),
42
+ changes: () => ({ end_date: input.end_date }),
43
+ reasonKey: 'line_end_reason',
44
+ reason: input.reason,
45
+ idempotencyKey: input.idempotency_key,
46
+ });
47
+ },
48
+ };
49
+ //# sourceMappingURL=pbm-subscription-line-end.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbm-subscription-line-end.js","sourceRoot":"","sources":["../../../src/tools/pbm/pbm-subscription-line-end.ts"],"names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AC,GAAG,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE;YACxF,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC7C,SAAS,EAAE,iBAAiB;YAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,cAAc,EAAE,KAAK,CAAC,eAAe;SACtC,CAAC,CAAC;IACL,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 qomGeneratedReadReport: CatalogueReport;
4
+ export declare const qomGeneratedReadTools: Tool[];
5
+ //# sourceMappingURL=generated-reads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-reads.d.ts","sourceRoot":"","sources":["../../../src/tools/qom/generated-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAGL,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAsBxC,eAAO,MAAM,sBAAsB,EAAE,eAC8B,CAAC;AAEpE,eAAO,MAAM,qBAAqB,EAAE,IAAI,EAGvC,CAAC"}
@@ -0,0 +1,22 @@
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 QOM module (WI-0003507).
5
+ *
6
+ * The schema-driven catalogue (WI-0003500) emits describe/list/get for
7
+ * every `normal`-sensitivity QOM resource that declares a read
8
+ * operation and has no side effects. All QOM tables are classified
9
+ * `normal` — quote headers, quote versions and lines, order headers
10
+ * and lines, and the batch/interface staging tables — so no
11
+ * `includeSensitive` opt-in is required.
12
+ *
13
+ * Every write on a quote or order lives in a dedicated hand-written
14
+ * tool with explicit confirmation/idempotency semantics (see
15
+ * `qom-quote-*`, `qom-order-*`). Generic PATCHes are refused so
16
+ * totals, transitions, cancellation and hold state stay owned by the
17
+ * persist layer.
18
+ */
19
+ const contract = loadPersistResourceContract();
20
+ export const qomGeneratedReadReport = buildGeneratedReadCatalogueReport(contract, { modules: ['qom'] });
21
+ export const qomGeneratedReadTools = buildGeneratedReadCatalogue(contract, { modules: ['qom'] });
22
+ //# sourceMappingURL=generated-reads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-reads.js","sourceRoot":"","sources":["../../../src/tools/qom/generated-reads.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,GAElC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,sBAAsB,GACjC,iCAAiC,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,qBAAqB,GAAW,2BAA2B,CACtE,QAAQ,EACR,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CACrB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Tool } from '../registry.js';
2
+ export declare const qomTools: Tool[];
3
+ /** Read-only slice used by the `qom-readonly` selectable sub-domain. */
4
+ export declare const qomReadOnlyTools: Tool[];
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/qom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAsBtC,eAAO,MAAM,QAAQ,EAAE,IAAI,EAAiD,CAAC;AAE7E,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAA0B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { qomGeneratedReadTools } from './generated-reads.js';
2
+ import { qomQuoteCreateTool } from './qom-quote-create.js';
3
+ import { qomQuoteVersionCreateTool } from './qom-quote-version-create.js';
4
+ import { qomQuoteLineAddTool } from './qom-quote-line-add.js';
5
+ import { qomOrderCreateTool } from './qom-order-create.js';
6
+ import { qomOrderLineAddTool } from './qom-order-line-add.js';
7
+ import { qomOrderCancelTool } from './qom-order-cancel.js';
8
+ import { qomOrderHoldPlaceTool } from './qom-order-hold-place.js';
9
+ import { qomOrderHoldReleaseTool } from './qom-order-hold-release.js';
10
+ const qomWriteTools = [
11
+ qomQuoteCreateTool,
12
+ qomQuoteVersionCreateTool,
13
+ qomQuoteLineAddTool,
14
+ qomOrderCreateTool,
15
+ qomOrderLineAddTool,
16
+ qomOrderCancelTool,
17
+ qomOrderHoldPlaceTool,
18
+ qomOrderHoldReleaseTool,
19
+ ];
20
+ export const qomTools = [...qomGeneratedReadTools, ...qomWriteTools];
21
+ /** Read-only slice used by the `qom-readonly` selectable sub-domain. */
22
+ export const qomReadOnlyTools = qomGeneratedReadTools;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/qom/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,aAAa,GAAW;IAC5B,kBAAkB;IAClB,yBAAyB;IACzB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,qBAAqB;IACrB,uBAAuB;CACxB,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,16 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Cancellation semantic tool for a QOM order (`qom_order_headers`).
4
+ *
5
+ * Sets `order_status='CANCELLED'`, which is the column Persist's own
6
+ * cancel path writes (`qom_guest_clear_cart`), plus `is_cancelled=true`
7
+ * and `is_open=false`. The reason is merged into `metadata`.
8
+ *
9
+ * Nothing in Persist or persist-functions reacts to the change: no
10
+ * refund, no payment void, no stock release, and the order lines keep
11
+ * their status. The tool therefore only accepts DRAFT and OPEN orders,
12
+ * where no money has moved. Persist does not enforce this
13
+ * (see the Persist work item for QOM order state rules).
14
+ */
15
+ export declare const qomOrderCancelTool: Tool;
16
+ //# sourceMappingURL=qom-order-cancel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qom-order-cancel.d.ts","sourceRoot":"","sources":["../../../src/tools/qom/qom-order-cancel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAYtC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,EAAE,IAqChC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ import { cap } from '../../capabilities/tool-capability.js';
3
+ import { redactRow } from '../../generated-reads/index.js';
4
+ import { confirmFlagSchema, reasonSchema, unenforcedIdempotencyKeySchema, } from '../_shared/side-effect.js';
5
+ import { softDeactivate } from '../_shared/soft-deactivate.js';
6
+ const CANCELLABLE_STATUSES = ['DRAFT', 'OPEN'];
7
+ /**
8
+ * Cancellation semantic tool for a QOM order (`qom_order_headers`).
9
+ *
10
+ * Sets `order_status='CANCELLED'`, which is the column Persist's own
11
+ * cancel path writes (`qom_guest_clear_cart`), plus `is_cancelled=true`
12
+ * and `is_open=false`. The reason is merged into `metadata`.
13
+ *
14
+ * Nothing in Persist or persist-functions reacts to the change: no
15
+ * refund, no payment void, no stock release, and the order lines keep
16
+ * their status. The tool therefore only accepts DRAFT and OPEN orders,
17
+ * where no money has moved. Persist does not enforce this
18
+ * (see the Persist work item for QOM order state rules).
19
+ */
20
+ export const qomOrderCancelTool = {
21
+ name: 'qom_order_cancel',
22
+ description: 'Cancel a DRAFT or OPEN QOM order: sets order_status=CANCELLED, is_cancelled=true and ' +
23
+ 'is_open=false, and merges the reason into metadata. Any other status is refused, because ' +
24
+ 'cancelling triggers no refund or stock release and does not change the order lines. ' +
25
+ 'Requires confirm=true and a reason. An order already cancelled is returned unchanged, so ' +
26
+ 'retries are safe.',
27
+ inputSchema: z.object({
28
+ id: z.string().min(1).describe('UUID of the order to cancel'),
29
+ reason: reasonSchema.describe('Human-readable reason, merged into metadata'),
30
+ confirm: confirmFlagSchema,
31
+ idempotency_key: unenforcedIdempotencyKeySchema,
32
+ }),
33
+ capabilities: [cap('qom_order_headers', 'UPDATE')],
34
+ sideEffect: 'state_change',
35
+ confirmation: 'caller_confirms',
36
+ idempotency: 'natural_key',
37
+ handler: async (args, ctx) => {
38
+ const input = args;
39
+ return softDeactivate(ctx, {
40
+ table: 'qom_order_headers',
41
+ id: input.id,
42
+ label: 'QOM order',
43
+ verb: 'cancel',
44
+ isDone: (row) => row.is_cancelled === true || row.order_status === 'CANCELLED',
45
+ reject: (row) => CANCELLABLE_STATUSES.includes(row.order_status)
46
+ ? undefined
47
+ : `QOM order ${input.id} is ${row.order_status}: only DRAFT or OPEN orders can be cancelled`,
48
+ changes: () => ({ order_status: 'CANCELLED', is_cancelled: true, is_open: false }),
49
+ reasonKey: 'cancellation_reason',
50
+ reason: input.reason,
51
+ idempotencyKey: input.idempotency_key,
52
+ present: redactRow,
53
+ });
54
+ },
55
+ };
56
+ //# sourceMappingURL=qom-order-cancel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qom-order-cancel.js","sourceRoot":"","sources":["../../../src/tools/qom/qom-order-cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAS;IACtC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,uFAAuF;QACvF,2FAA2F;QAC3F,sFAAsF;QACtF,2FAA2F;QAC3F,mBAAmB;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QAC7D,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,6CAA6C,CAAC;QAC5E,OAAO,EAAE,iBAAiB;QAC1B,eAAe,EAAE,8BAA8B;KAChD,CAAC;IACF,YAAY,EAAE,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IAClD,UAAU,EAAE,cAAc;IAC1B,YAAY,EAAE,iBAAiB;IAC/B,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,IAAgE,CAAC;QAC/E,OAAO,cAAc,CAAC,GAAG,EAAE;YACzB,KAAK,EAAE,mBAAmB;YAC1B,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,KAAK,IAAI,IAAI,GAAG,CAAC,YAAY,KAAK,WAAW;YAC9E,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CACd,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;gBAC7C,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,aAAa,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,YAAY,8CAA8C;YAChG,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YAClF,SAAS,EAAE,qBAAqB;YAChC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,cAAc,EAAE,KAAK,CAAC,eAAe;YACrC,OAAO,EAAE,SAAS;SACnB,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Tool } from '../registry.js';
2
+ /**
3
+ * Provisioning semantic tool: create a QOM order header
4
+ * (`qom_order_headers`). The tool requires `confirm: true` and a
5
+ * business `order_code`, because the unique key
6
+ * (tenant_id, org_id, order_code) is what stops a retry creating a
7
+ * second order. Persist would generate a code if none were sent.
8
+ *
9
+ * `order_status` is limited to DRAFT and OPEN: Persist accepts any
10
+ * lookup value, so a caller could otherwise create an order already
11
+ * PAID or FULFILLED. `order_type` omits MARKETPLACE_GUEST, which belongs
12
+ * to the guest cart RPCs.
13
+ *
14
+ * `is_open`, `is_on_hold`, `is_cancelled` are intentionally NOT
15
+ * writable through this tool — they belong to `qom_order_cancel`,
16
+ * `qom_order_hold_place` and `qom_order_hold_release`.
17
+ * `guest_session_token_hash` is a credential-shaped field: it is not an
18
+ * input and is removed from the returned row.
19
+ *
20
+ * `source_deal_id` links the order back to the SFA deal it was
21
+ * quoted from, if any.
22
+ */
23
+ export declare const qomOrderCreateTool: Tool;
24
+ //# sourceMappingURL=qom-order-create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qom-order-create.d.ts","sourceRoot":"","sources":["../../../src/tools/qom/qom-order-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAUtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,EAAE,IA+GhC,CAAC"}