@raytio/mcp-server 10.2.0 → 10.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.
- package/README.md +2 -0
- package/contracts/persist/mcp_resource_contract.json +4 -4
- package/dist/authorization.d.ts.map +1 -1
- package/dist/authorization.js +4 -0
- package/dist/authorization.js.map +1 -1
- package/dist/generated-reads/guardrails.js +1 -1
- package/dist/generated-reads/guardrails.js.map +1 -1
- package/dist/generated-reads/resource-tools.d.ts.map +1 -1
- package/dist/generated-reads/resource-tools.js +8 -5
- package/dist/generated-reads/resource-tools.js.map +1 -1
- package/dist/tools/_shared/date-range.d.ts +16 -0
- package/dist/tools/_shared/date-range.d.ts.map +1 -0
- package/dist/tools/_shared/date-range.js +28 -0
- package/dist/tools/_shared/date-range.js.map +1 -0
- package/dist/tools/_shared/side-effect.d.ts.map +1 -1
- package/dist/tools/_shared/side-effect.js +3 -1
- package/dist/tools/_shared/side-effect.js.map +1 -1
- package/dist/tools/_shared/soft-deactivate.d.ts +2 -0
- package/dist/tools/_shared/soft-deactivate.d.ts.map +1 -1
- package/dist/tools/_shared/soft-deactivate.js +3 -0
- package/dist/tools/_shared/soft-deactivate.js.map +1 -1
- package/dist/tools/domains.d.ts.map +1 -1
- package/dist/tools/domains.js +39 -1
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/gpm/generated-reads.d.ts +5 -0
- package/dist/tools/gpm/generated-reads.d.ts.map +1 -0
- package/dist/tools/gpm/generated-reads.js +28 -0
- package/dist/tools/gpm/generated-reads.js.map +1 -0
- package/dist/tools/gpm/gpm-item-deactivate.d.ts +11 -0
- package/dist/tools/gpm/gpm-item-deactivate.d.ts.map +1 -0
- package/dist/tools/gpm/gpm-item-deactivate.js +45 -0
- package/dist/tools/gpm/gpm-item-deactivate.js.map +1 -0
- package/dist/tools/gpm/gpm-item-register.d.ts +21 -0
- package/dist/tools/gpm/gpm-item-register.d.ts.map +1 -0
- package/dist/tools/gpm/gpm-item-register.js +149 -0
- package/dist/tools/gpm/gpm-item-register.js.map +1 -0
- package/dist/tools/gpm/index.d.ts +5 -0
- package/dist/tools/gpm/index.d.ts.map +1 -0
- package/dist/tools/gpm/index.js +10 -0
- package/dist/tools/gpm/index.js.map +1 -0
- package/dist/tools/imports/index.d.ts +16 -93
- package/dist/tools/imports/index.d.ts.map +1 -1
- package/dist/tools/imports/index.js +11 -3
- package/dist/tools/imports/index.js.map +1 -1
- package/dist/tools/pbm/generated-reads.d.ts +5 -0
- package/dist/tools/pbm/generated-reads.d.ts.map +1 -0
- package/dist/tools/pbm/generated-reads.js +32 -0
- package/dist/tools/pbm/generated-reads.js.map +1 -0
- package/dist/tools/pbm/index.d.ts +5 -0
- package/dist/tools/pbm/index.d.ts.map +1 -0
- package/dist/tools/pbm/index.js +17 -0
- package/dist/tools/pbm/index.js.map +1 -0
- package/dist/tools/pbm/pbm-customer-entitlement-override-set.d.ts +26 -0
- package/dist/tools/pbm/pbm-customer-entitlement-override-set.d.ts.map +1 -0
- package/dist/tools/pbm/pbm-customer-entitlement-override-set.js +78 -0
- package/dist/tools/pbm/pbm-customer-entitlement-override-set.js.map +1 -0
- package/dist/tools/pbm/pbm-subscription-cancel.d.ts +21 -0
- package/dist/tools/pbm/pbm-subscription-cancel.d.ts.map +1 -0
- package/dist/tools/pbm/pbm-subscription-cancel.js +86 -0
- package/dist/tools/pbm/pbm-subscription-cancel.js.map +1 -0
- package/dist/tools/pbm/pbm-subscription-create.d.ts +20 -0
- package/dist/tools/pbm/pbm-subscription-create.d.ts.map +1 -0
- package/dist/tools/pbm/pbm-subscription-create.js +90 -0
- package/dist/tools/pbm/pbm-subscription-create.js.map +1 -0
- package/dist/tools/pbm/pbm-subscription-line-add.d.ts +13 -0
- package/dist/tools/pbm/pbm-subscription-line-add.d.ts.map +1 -0
- package/dist/tools/pbm/pbm-subscription-line-add.js +65 -0
- package/dist/tools/pbm/pbm-subscription-line-add.js.map +1 -0
- package/dist/tools/pbm/pbm-subscription-line-end.d.ts +12 -0
- package/dist/tools/pbm/pbm-subscription-line-end.d.ts.map +1 -0
- package/dist/tools/pbm/pbm-subscription-line-end.js +49 -0
- package/dist/tools/pbm/pbm-subscription-line-end.js.map +1 -0
- package/dist/tools/pcm/generated-reads.d.ts +5 -0
- package/dist/tools/pcm/generated-reads.d.ts.map +1 -0
- package/dist/tools/pcm/generated-reads.js +26 -0
- package/dist/tools/pcm/generated-reads.js.map +1 -0
- package/dist/tools/pcm/index.d.ts +5 -0
- package/dist/tools/pcm/index.d.ts.map +1 -0
- package/dist/tools/pcm/index.js +16 -0
- package/dist/tools/pcm/index.js.map +1 -0
- package/dist/tools/pcm/pcm-price-list-deactivate.d.ts +11 -0
- package/dist/tools/pcm/pcm-price-list-deactivate.d.ts.map +1 -0
- package/dist/tools/pcm/pcm-price-list-deactivate.js +46 -0
- package/dist/tools/pcm/pcm-price-list-deactivate.js.map +1 -0
- package/dist/tools/pcm/pcm-price-list-register.d.ts +21 -0
- package/dist/tools/pcm/pcm-price-list-register.d.ts.map +1 -0
- package/dist/tools/pcm/pcm-price-list-register.js +96 -0
- package/dist/tools/pcm/pcm-price-list-register.js.map +1 -0
- package/dist/tools/pcm/pcm-price-list-version-create.d.ts +19 -0
- package/dist/tools/pcm/pcm-price-list-version-create.d.ts.map +1 -0
- package/dist/tools/pcm/pcm-price-list-version-create.js +85 -0
- package/dist/tools/pcm/pcm-price-list-version-create.js.map +1 -0
- package/dist/tools/qom/generated-reads.d.ts +5 -0
- package/dist/tools/qom/generated-reads.d.ts.map +1 -0
- package/dist/tools/qom/generated-reads.js +22 -0
- package/dist/tools/qom/generated-reads.js.map +1 -0
- package/dist/tools/qom/index.d.ts +5 -0
- package/dist/tools/qom/index.d.ts.map +1 -0
- package/dist/tools/qom/index.js +23 -0
- package/dist/tools/qom/index.js.map +1 -0
- package/dist/tools/qom/qom-order-cancel.d.ts +16 -0
- package/dist/tools/qom/qom-order-cancel.d.ts.map +1 -0
- package/dist/tools/qom/qom-order-cancel.js +56 -0
- package/dist/tools/qom/qom-order-cancel.js.map +1 -0
- package/dist/tools/qom/qom-order-create.d.ts +24 -0
- package/dist/tools/qom/qom-order-create.d.ts.map +1 -0
- package/dist/tools/qom/qom-order-create.js +133 -0
- package/dist/tools/qom/qom-order-create.js.map +1 -0
- package/dist/tools/qom/qom-order-hold-place.d.ts +11 -0
- package/dist/tools/qom/qom-order-hold-place.d.ts.map +1 -0
- package/dist/tools/qom/qom-order-hold-place.js +50 -0
- package/dist/tools/qom/qom-order-hold-place.js.map +1 -0
- package/dist/tools/qom/qom-order-hold-release.d.ts +8 -0
- package/dist/tools/qom/qom-order-hold-release.d.ts.map +1 -0
- package/dist/tools/qom/qom-order-hold-release.js +42 -0
- package/dist/tools/qom/qom-order-hold-release.js.map +1 -0
- package/dist/tools/qom/qom-order-line-add.d.ts +18 -0
- package/dist/tools/qom/qom-order-line-add.d.ts.map +1 -0
- package/dist/tools/qom/qom-order-line-add.js +101 -0
- package/dist/tools/qom/qom-order-line-add.js.map +1 -0
- package/dist/tools/qom/qom-quote-create.d.ts +20 -0
- package/dist/tools/qom/qom-quote-create.d.ts.map +1 -0
- package/dist/tools/qom/qom-quote-create.js +142 -0
- package/dist/tools/qom/qom-quote-create.js.map +1 -0
- package/dist/tools/qom/qom-quote-line-add.d.ts +13 -0
- package/dist/tools/qom/qom-quote-line-add.d.ts.map +1 -0
- package/dist/tools/qom/qom-quote-line-add.js +92 -0
- package/dist/tools/qom/qom-quote-line-add.js.map +1 -0
- package/dist/tools/qom/qom-quote-version-create.d.ts +10 -0
- package/dist/tools/qom/qom-quote-version-create.d.ts.map +1 -0
- package/dist/tools/qom/qom-quote-version-create.js +69 -0
- package/dist/tools/qom/qom-quote-version-create.js.map +1 -0
- package/dist/tools/role-mapping.d.ts.map +1 -1
- package/dist/tools/role-mapping.js +15 -8
- package/dist/tools/role-mapping.js.map +1 -1
- package/package.json +1 -1
|
@@ -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 { confirmFlagSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
|
|
5
|
+
import { END_AFTER_START_MESSAGE, endsAfterStart, isoDateTimeSchema, } from '../_shared/date-range.js';
|
|
6
|
+
const CURRENCY_REGEX = /^[A-Z]{3}$/;
|
|
7
|
+
/** Values of the Persist PCM_PRICE_LISTS_VISIBILITY lookup. */
|
|
8
|
+
export const PCM_PRICE_LIST_VISIBILITIES = ['PARTY', 'AUTHENTICATED', 'PUBLIC'];
|
|
9
|
+
/**
|
|
10
|
+
* Register a price list (`pcm_price_lists`), the container that price
|
|
11
|
+
* list versions and lines attach to.
|
|
12
|
+
*
|
|
13
|
+
* Unique key: `t_pcm_price_lists_ui` on (price_list_name,
|
|
14
|
+
* price_list_type) among active price lists in the tenant, so a retry
|
|
15
|
+
* fails with a duplicate-key error instead of creating a second list.
|
|
16
|
+
*
|
|
17
|
+
* `pcm_price_lists` is not routed by organisation: Persist fills a
|
|
18
|
+
* missing `org_id` with the tenant's lowest organisation id, so the tool
|
|
19
|
+
* requires it.
|
|
20
|
+
*
|
|
21
|
+
* `visibility=PUBLIC` makes Persist write a wildcard viewer tuple, so
|
|
22
|
+
* anyone, including unauthenticated callers, can read the list. The
|
|
23
|
+
* tool needs `allow_public=true` as well as `confirm=true` for that.
|
|
24
|
+
*/
|
|
25
|
+
export const pcmPriceListRegisterTool = {
|
|
26
|
+
name: 'pcm_price_list_register',
|
|
27
|
+
description: 'Register a price list (pcm_price_lists). Requires confirm=true and org_id. ' +
|
|
28
|
+
'price_list_name + price_list_type must be unique among active price lists in the tenant: ' +
|
|
29
|
+
'a retry fails with a duplicate-key error instead of creating a second list. ' +
|
|
30
|
+
'visibility is PARTY (default), AUTHENTICATED or PUBLIC; PUBLIC makes the list readable by ' +
|
|
31
|
+
'anyone, including unauthenticated callers, and also needs allow_public=true.',
|
|
32
|
+
inputSchema: z
|
|
33
|
+
.object({
|
|
34
|
+
price_list_name: z
|
|
35
|
+
.string()
|
|
36
|
+
.min(1)
|
|
37
|
+
.max(256)
|
|
38
|
+
.describe('Price list name, unique with price_list_type among active lists'),
|
|
39
|
+
price_list_type: z
|
|
40
|
+
.string()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(32)
|
|
43
|
+
.describe('A pcm_price_list_price_list_type_lookup lookup_value_code'),
|
|
44
|
+
price_list_currency: z
|
|
45
|
+
.string()
|
|
46
|
+
.regex(CURRENCY_REGEX, 'price_list_currency must be a 3-letter uppercase ISO 4217 code')
|
|
47
|
+
.describe('ISO 4217 currency code enabled in fnd_currencies (e.g. NZD, AUD)'),
|
|
48
|
+
price_list_description: z.string().max(2048).optional(),
|
|
49
|
+
visibility: z
|
|
50
|
+
.enum(PCM_PRICE_LIST_VISIBILITIES)
|
|
51
|
+
.optional()
|
|
52
|
+
.describe('Who can read the list: PARTY (default), AUTHENTICATED or PUBLIC'),
|
|
53
|
+
allow_public: z
|
|
54
|
+
.literal(true)
|
|
55
|
+
.optional()
|
|
56
|
+
.describe('Must be true when visibility is PUBLIC'),
|
|
57
|
+
org_id: z
|
|
58
|
+
.string()
|
|
59
|
+
.uuid()
|
|
60
|
+
.describe('UUID of the owning organisation (required: Persist does not route price lists)'),
|
|
61
|
+
start_date: isoDateTimeSchema('ISO 8601 effective start (defaults to now)').optional(),
|
|
62
|
+
end_date: isoDateTimeSchema('ISO 8601 end, after start_date').optional(),
|
|
63
|
+
confirm: confirmFlagSchema,
|
|
64
|
+
idempotency_key: unenforcedIdempotencyKeySchema,
|
|
65
|
+
})
|
|
66
|
+
.refine((v) => endsAfterStart(v.start_date, v.end_date), { message: END_AFTER_START_MESSAGE })
|
|
67
|
+
.refine((v) => v.visibility !== 'PUBLIC' || v.allow_public === true, {
|
|
68
|
+
message: 'visibility PUBLIC makes the price list readable by anyone: set allow_public=true',
|
|
69
|
+
path: ['allow_public'],
|
|
70
|
+
}),
|
|
71
|
+
capabilities: [cap('pcm_price_lists', 'INSERT')],
|
|
72
|
+
sideEffect: 'provisioning',
|
|
73
|
+
confirmation: 'caller_confirms',
|
|
74
|
+
idempotency: 'natural_key',
|
|
75
|
+
handler: async (args, ctx) => {
|
|
76
|
+
const input = args;
|
|
77
|
+
const body = {
|
|
78
|
+
price_list_name: input.price_list_name,
|
|
79
|
+
price_list_type: input.price_list_type,
|
|
80
|
+
price_list_currency: input.price_list_currency,
|
|
81
|
+
org_id: input.org_id,
|
|
82
|
+
};
|
|
83
|
+
for (const field of ['price_list_description', 'visibility', 'start_date', 'end_date']) {
|
|
84
|
+
if (input[field] !== undefined)
|
|
85
|
+
body[field] = input[field];
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/pcm_price_lists?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
|
|
89
|
+
return successResponse(rows[0]);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return errorResponse(API_ERROR, `Failed to register PCM price list: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=pcm-price-list-register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pcm-price-list-register.js","sourceRoot":"","sources":["../../../src/tools/pcm/pcm-price-list-register.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;AACnC,OAAO,EACL,uBAAuB,EACvB,cAAc,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,CAAC,IAAI,CACnC,GAAG,GAAG,CAAC,SAAS,CAAC,UAAU,2BAA2B,EACtD,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,CAAC,SAAS,EAAE,sCAAsC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a price list version (`pcm_price_list_versions`). Persist has
|
|
4
|
+
* no publish step: a version is used once its date range is current.
|
|
5
|
+
* Lines are loaded separately through the shared PCM_PRICE_LIST_LINES
|
|
6
|
+
* import, which MCP cannot drive until WI-0009453.
|
|
7
|
+
*
|
|
8
|
+
* Persist does not route versions to their price list's organisation and
|
|
9
|
+
* fills a missing `org_id` with the tenant's lowest organisation id. The
|
|
10
|
+
* managed price-line import only loads into a version in its destination
|
|
11
|
+
* organisation, so the tool reads the price list and stores the version
|
|
12
|
+
* in the list's organisation, refusing a different `org_id`.
|
|
13
|
+
*
|
|
14
|
+
* Unique key: `t_pcm_price_list_versions_uk2` on (price_list_id,
|
|
15
|
+
* price_list_version_name, org_id), so a retry fails with a duplicate-key
|
|
16
|
+
* error instead of creating a second version.
|
|
17
|
+
*/
|
|
18
|
+
export declare const pcmPriceListVersionCreateTool: Tool;
|
|
19
|
+
//# sourceMappingURL=pcm-price-list-version-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pcm-price-list-version-create.d.ts","sourceRoot":"","sources":["../../../src/tools/pcm/pcm-price-list-version-create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AActC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,6BAA6B,EAAE,IA+E3C,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import { END_AFTER_START_MESSAGE, endsAfterStart, isoDateTimeSchema, } from '../_shared/date-range.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create a price list version (`pcm_price_list_versions`). Persist has
|
|
8
|
+
* no publish step: a version is used once its date range is current.
|
|
9
|
+
* Lines are loaded separately through the shared PCM_PRICE_LIST_LINES
|
|
10
|
+
* import, which MCP cannot drive until WI-0009453.
|
|
11
|
+
*
|
|
12
|
+
* Persist does not route versions to their price list's organisation and
|
|
13
|
+
* fills a missing `org_id` with the tenant's lowest organisation id. The
|
|
14
|
+
* managed price-line import only loads into a version in its destination
|
|
15
|
+
* organisation, so the tool reads the price list and stores the version
|
|
16
|
+
* in the list's organisation, refusing a different `org_id`.
|
|
17
|
+
*
|
|
18
|
+
* Unique key: `t_pcm_price_list_versions_uk2` on (price_list_id,
|
|
19
|
+
* price_list_version_name, org_id), so a retry fails with a duplicate-key
|
|
20
|
+
* error instead of creating a second version.
|
|
21
|
+
*/
|
|
22
|
+
export const pcmPriceListVersionCreateTool = {
|
|
23
|
+
name: 'pcm_price_list_version_create',
|
|
24
|
+
description: 'Create a version of an active price list (pcm_price_list_versions). Requires confirm=true. ' +
|
|
25
|
+
'The version is stored in the price list\'s organisation; a different org_id is refused. ' +
|
|
26
|
+
'There is no separate publish step: the version applies while its date range is current. ' +
|
|
27
|
+
'MCP cannot load its lines yet. ' +
|
|
28
|
+
'price_list_version_name is unique within the price list: a retry fails with a duplicate-key ' +
|
|
29
|
+
'error instead of creating a second version.',
|
|
30
|
+
inputSchema: z
|
|
31
|
+
.object({
|
|
32
|
+
price_list_id: z.string().uuid().describe('UUID of the parent pcm_price_lists row'),
|
|
33
|
+
price_list_version_name: z
|
|
34
|
+
.string()
|
|
35
|
+
.min(1)
|
|
36
|
+
.max(256)
|
|
37
|
+
.describe('Version label, unique within the price list'),
|
|
38
|
+
price_list_version_description: z.string().max(2048).optional(),
|
|
39
|
+
start_date: isoDateTimeSchema('ISO 8601 effective start (defaults to now)').optional(),
|
|
40
|
+
end_date: isoDateTimeSchema('ISO 8601 end, after start_date').optional(),
|
|
41
|
+
org_id: z
|
|
42
|
+
.string()
|
|
43
|
+
.uuid()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Optional. Must equal the price list\'s org_id, which is used when omitted.'),
|
|
46
|
+
confirm: confirmFlagSchema,
|
|
47
|
+
idempotency_key: unenforcedIdempotencyKeySchema,
|
|
48
|
+
})
|
|
49
|
+
.refine((v) => endsAfterStart(v.start_date, v.end_date), { message: END_AFTER_START_MESSAGE }),
|
|
50
|
+
capabilities: [cap('pcm_price_list_versions', 'INSERT'), cap('pcm_price_lists', 'SELECT')],
|
|
51
|
+
sideEffect: 'provisioning',
|
|
52
|
+
confirmation: 'caller_confirms',
|
|
53
|
+
idempotency: 'natural_key',
|
|
54
|
+
handler: async (args, ctx) => {
|
|
55
|
+
const input = args;
|
|
56
|
+
try {
|
|
57
|
+
const lists = await ctx.apiClient.get(`${ctx.apiClient.dbBasePath}/pcm_price_lists?id=eq.${input.price_list_id}&select=id,org_id,active`);
|
|
58
|
+
const list = lists?.[0];
|
|
59
|
+
if (!list) {
|
|
60
|
+
return errorResponse(API_ERROR, `PCM price list ${input.price_list_id} not found or not accessible`);
|
|
61
|
+
}
|
|
62
|
+
if (list.active === false) {
|
|
63
|
+
return errorResponse(API_ERROR, `PCM price list ${input.price_list_id} is inactive: versions can only be added to an active list`);
|
|
64
|
+
}
|
|
65
|
+
if (input.org_id !== undefined && input.org_id !== list.org_id) {
|
|
66
|
+
return errorResponse(API_ERROR, `org_id ${input.org_id} differs from the price list's organisation ${list.org_id}`);
|
|
67
|
+
}
|
|
68
|
+
const body = {
|
|
69
|
+
price_list_id: input.price_list_id,
|
|
70
|
+
price_list_version_name: input.price_list_version_name,
|
|
71
|
+
org_id: list.org_id,
|
|
72
|
+
};
|
|
73
|
+
for (const field of ['price_list_version_description', 'start_date', 'end_date']) {
|
|
74
|
+
if (input[field] !== undefined)
|
|
75
|
+
body[field] = input[field];
|
|
76
|
+
}
|
|
77
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/pcm_price_list_versions?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
|
|
78
|
+
return successResponse(rows[0]);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return errorResponse(API_ERROR, `Failed to create PCM price list version: ${error.message}`);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=pcm-price-list-version-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pcm-price-list-version-create.js","sourceRoot":"","sources":["../../../src/tools/pcm/pcm-price-list-version-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,iBAAiB,EACjB,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAS;IACjD,IAAI,EAAE,+BAA+B;IACrC,WAAW,EACT,6FAA6F;QAC7F,0FAA0F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E,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,4CAA4C,KAAK,CAAC,OAAO,EAAE,CAC5D,CAAC;QACJ,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 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 @@
|
|
|
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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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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { API_ERROR, errorResponse, successResponse } from '../types.js';
|
|
3
|
+
import { cap } from '../../capabilities/tool-capability.js';
|
|
4
|
+
import { redactRow } from '../../generated-reads/index.js';
|
|
5
|
+
import { confirmFlagSchema, unenforcedIdempotencyKeySchema, writeHeadersWithIdempotency, } from '../_shared/side-effect.js';
|
|
6
|
+
/**
|
|
7
|
+
* Provisioning semantic tool: create a QOM order header
|
|
8
|
+
* (`qom_order_headers`). The tool requires `confirm: true` and a
|
|
9
|
+
* business `order_code`, because the unique key
|
|
10
|
+
* (tenant_id, org_id, order_code) is what stops a retry creating a
|
|
11
|
+
* second order. Persist would generate a code if none were sent.
|
|
12
|
+
*
|
|
13
|
+
* `order_status` is limited to DRAFT and OPEN: Persist accepts any
|
|
14
|
+
* lookup value, so a caller could otherwise create an order already
|
|
15
|
+
* PAID or FULFILLED. `order_type` omits MARKETPLACE_GUEST, which belongs
|
|
16
|
+
* to the guest cart RPCs.
|
|
17
|
+
*
|
|
18
|
+
* `is_open`, `is_on_hold`, `is_cancelled` are intentionally NOT
|
|
19
|
+
* writable through this tool — they belong to `qom_order_cancel`,
|
|
20
|
+
* `qom_order_hold_place` and `qom_order_hold_release`.
|
|
21
|
+
* `guest_session_token_hash` is a credential-shaped field: it is not an
|
|
22
|
+
* input and is removed from the returned row.
|
|
23
|
+
*
|
|
24
|
+
* `source_deal_id` links the order back to the SFA deal it was
|
|
25
|
+
* quoted from, if any.
|
|
26
|
+
*/
|
|
27
|
+
export const qomOrderCreateTool = {
|
|
28
|
+
name: 'qom_order_create',
|
|
29
|
+
description: 'Create a new sales order (qom_order_headers) as DRAFT or OPEN. Requires confirm=true. ' +
|
|
30
|
+
'is_open, is_on_hold and is_cancelled cannot be set here: use qom_order_cancel, ' +
|
|
31
|
+
'qom_order_hold_place or qom_order_hold_release. One order per order_code in an ' +
|
|
32
|
+
'organisation: a retry fails with a duplicate-key error instead of creating a second order.',
|
|
33
|
+
inputSchema: z.object({
|
|
34
|
+
order_code: z
|
|
35
|
+
.string()
|
|
36
|
+
.min(1)
|
|
37
|
+
.max(32)
|
|
38
|
+
.describe('Business order reference, unique within the organisation (required)'),
|
|
39
|
+
order_status: z.enum(['DRAFT', 'OPEN']).describe('Initial order status (required)'),
|
|
40
|
+
order_type: z
|
|
41
|
+
.enum(['SALES_ORDER', 'STANDARD', 'SUBSCRIPTION'])
|
|
42
|
+
.describe('Order type (required)'),
|
|
43
|
+
order_date: z.string().min(1).optional().describe('ISO 8601 order date'),
|
|
44
|
+
order_currency_code: z.string().length(3).optional(),
|
|
45
|
+
sold_to_customer_id: z.string().min(1).optional(),
|
|
46
|
+
sold_to_customer_site_id: z.string().min(1).optional(),
|
|
47
|
+
sold_to_party_contact_point_id: z.string().min(1).optional(),
|
|
48
|
+
ship_to_customer_id: z.string().min(1).optional(),
|
|
49
|
+
ship_to_customer_site_id: z.string().min(1).optional(),
|
|
50
|
+
ship_to_party_contact_point_id: z.string().min(1).optional(),
|
|
51
|
+
payment_term_id: z.string().min(1).optional(),
|
|
52
|
+
payment_method_id: z.string().min(1).optional(),
|
|
53
|
+
price_list_version_id: z.string().min(1).optional(),
|
|
54
|
+
priced_date: z.string().min(1).optional(),
|
|
55
|
+
request_arrival_date: z.string().min(1).optional(),
|
|
56
|
+
request_ship_date: z.string().min(1).optional(),
|
|
57
|
+
earliest_arrival_date: z.string().min(1).optional(),
|
|
58
|
+
latest_arrival_date: z.string().min(1).optional(),
|
|
59
|
+
earliest_ship_date: z.string().min(1).optional(),
|
|
60
|
+
latest_ship_date: z.string().min(1).optional(),
|
|
61
|
+
allow_partial_ship: z.boolean().optional(),
|
|
62
|
+
shipment_terms_name: z.string().max(32).optional(),
|
|
63
|
+
shipping_instructions: z.string().max(2048).optional(),
|
|
64
|
+
packing_instructions: z.string().max(2048).optional(),
|
|
65
|
+
customer_po_number: z.string().max(64).optional(),
|
|
66
|
+
customer_reference: z.string().max(256).optional(),
|
|
67
|
+
sales_channel_name: z.string().max(32).optional(),
|
|
68
|
+
salesperson_number: z.number().int().optional(),
|
|
69
|
+
source_deal_id: z
|
|
70
|
+
.string()
|
|
71
|
+
.min(1)
|
|
72
|
+
.optional()
|
|
73
|
+
.describe('UUID of the sfa_deals row this order was quoted from'),
|
|
74
|
+
org_id: z.string().min(1).optional(),
|
|
75
|
+
metadata: z.record(z.unknown()).optional(),
|
|
76
|
+
confirm: confirmFlagSchema,
|
|
77
|
+
idempotency_key: unenforcedIdempotencyKeySchema,
|
|
78
|
+
}),
|
|
79
|
+
capabilities: [cap('qom_order_headers', 'INSERT')],
|
|
80
|
+
sideEffect: 'provisioning',
|
|
81
|
+
confirmation: 'caller_confirms',
|
|
82
|
+
idempotency: 'natural_key',
|
|
83
|
+
handler: async (args, ctx) => {
|
|
84
|
+
const input = args;
|
|
85
|
+
const body = {
|
|
86
|
+
order_code: input.order_code,
|
|
87
|
+
order_status: input.order_status,
|
|
88
|
+
order_type: input.order_type,
|
|
89
|
+
};
|
|
90
|
+
for (const field of [
|
|
91
|
+
'order_date',
|
|
92
|
+
'order_currency_code',
|
|
93
|
+
'sold_to_customer_id',
|
|
94
|
+
'sold_to_customer_site_id',
|
|
95
|
+
'sold_to_party_contact_point_id',
|
|
96
|
+
'ship_to_customer_id',
|
|
97
|
+
'ship_to_customer_site_id',
|
|
98
|
+
'ship_to_party_contact_point_id',
|
|
99
|
+
'payment_term_id',
|
|
100
|
+
'payment_method_id',
|
|
101
|
+
'price_list_version_id',
|
|
102
|
+
'priced_date',
|
|
103
|
+
'request_arrival_date',
|
|
104
|
+
'request_ship_date',
|
|
105
|
+
'earliest_arrival_date',
|
|
106
|
+
'latest_arrival_date',
|
|
107
|
+
'earliest_ship_date',
|
|
108
|
+
'latest_ship_date',
|
|
109
|
+
'allow_partial_ship',
|
|
110
|
+
'shipment_terms_name',
|
|
111
|
+
'shipping_instructions',
|
|
112
|
+
'packing_instructions',
|
|
113
|
+
'customer_po_number',
|
|
114
|
+
'customer_reference',
|
|
115
|
+
'sales_channel_name',
|
|
116
|
+
'salesperson_number',
|
|
117
|
+
'source_deal_id',
|
|
118
|
+
'org_id',
|
|
119
|
+
'metadata',
|
|
120
|
+
]) {
|
|
121
|
+
if (input[field] !== undefined)
|
|
122
|
+
body[field] = input[field];
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const rows = await ctx.apiClient.post(`${ctx.apiClient.dbBasePath}/qom_order_headers?select=*`, body, { headers: writeHeadersWithIdempotency(input.idempotency_key) });
|
|
126
|
+
return successResponse(redactRow(rows[0]));
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
return errorResponse(API_ERROR, `Failed to create QOM order: ${error.message}`);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=qom-order-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qom-order-create.js","sourceRoot":"","sources":["../../../src/tools/qom/qom-order-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,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;GAoB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AChC,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC;QACF,KAAK,MAAM,KAAK,IAAI;YAClB,YAAY;YACZ,qBAAqB;YACrB,qBAAqB;YACrB,0BAA0B;YAC1B,gCAAgC;YAChC,qBAAqB;YACrB,0BAA0B;YAC1B,gCAAgC;YAChC,iBAAiB;YACjB,mBAAmB;YACnB,uBAAuB;YACvB,aAAa;YACb,sBAAsB;YACtB,mBAAmB;YACnB,uBAAuB;YACvB,qBAAqB;YACrB,oBAAoB;YACpB,kBAAkB;YAClB,oBAAoB;YACpB,qBAAqB;YACrB,uBAAuB;YACvB,sBAAsB;YACtB,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;YACpB,gBAAgB;YAChB,QAAQ;YACR,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,6BAA6B,EACxD,IAAI,EACJ,EAAE,OAAO,EAAE,2BAA2B,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAChE,CAAC;YACF,OAAO,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,aAAa,CAClB,SAAS,EACT,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tool } from '../registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* State-transition semantic tool: flag a QOM order as on hold
|
|
4
|
+
* (`qom_order_headers.is_on_hold=true`).
|
|
5
|
+
*
|
|
6
|
+
* Nothing in Persist or persist-functions reads `is_on_hold` on an
|
|
7
|
+
* order, so the flag records intent and does not stop payment or
|
|
8
|
+
* fulfilment. The reason is merged into `metadata.hold_reason`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const qomOrderHoldPlaceTool: Tool;
|
|
11
|
+
//# sourceMappingURL=qom-order-hold-place.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qom-order-hold-place.d.ts","sourceRoot":"","sources":["../../../src/tools/qom/qom-order-hold-place.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAYtC;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,IAoCnC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 FINISHED_STATUSES = ['CANCELLED', 'EXPIRED', 'FULFILLED'];
|
|
7
|
+
/**
|
|
8
|
+
* State-transition semantic tool: flag a QOM order as on hold
|
|
9
|
+
* (`qom_order_headers.is_on_hold=true`).
|
|
10
|
+
*
|
|
11
|
+
* Nothing in Persist or persist-functions reads `is_on_hold` on an
|
|
12
|
+
* order, so the flag records intent and does not stop payment or
|
|
13
|
+
* fulfilment. The reason is merged into `metadata.hold_reason`.
|
|
14
|
+
*/
|
|
15
|
+
export const qomOrderHoldPlaceTool = {
|
|
16
|
+
name: 'qom_order_hold_place',
|
|
17
|
+
description: 'Flag a QOM order as on hold (is_on_hold=true) and merge the reason into metadata. The flag ' +
|
|
18
|
+
'is a record only: Persist does not read it, so it does not stop payment or fulfilment. ' +
|
|
19
|
+
'Refused for CANCELLED, EXPIRED and FULFILLED orders. Requires confirm=true and a reason. ' +
|
|
20
|
+
'An order already on hold is returned unchanged, so retries are safe.',
|
|
21
|
+
inputSchema: z.object({
|
|
22
|
+
id: z.string().min(1).describe('UUID of the order to hold'),
|
|
23
|
+
reason: reasonSchema.describe('Human-readable reason, merged into metadata'),
|
|
24
|
+
confirm: confirmFlagSchema,
|
|
25
|
+
idempotency_key: unenforcedIdempotencyKeySchema,
|
|
26
|
+
}),
|
|
27
|
+
capabilities: [cap('qom_order_headers', 'UPDATE')],
|
|
28
|
+
sideEffect: 'state_change',
|
|
29
|
+
confirmation: 'caller_confirms',
|
|
30
|
+
idempotency: 'natural_key',
|
|
31
|
+
handler: async (args, ctx) => {
|
|
32
|
+
const input = args;
|
|
33
|
+
return softDeactivate(ctx, {
|
|
34
|
+
table: 'qom_order_headers',
|
|
35
|
+
id: input.id,
|
|
36
|
+
label: 'QOM order',
|
|
37
|
+
verb: 'place hold on',
|
|
38
|
+
isDone: (row) => row.is_on_hold === true,
|
|
39
|
+
reject: (row) => FINISHED_STATUSES.includes(row.order_status)
|
|
40
|
+
? `QOM order ${input.id} is ${row.order_status} and cannot be put on hold`
|
|
41
|
+
: undefined,
|
|
42
|
+
changes: () => ({ is_on_hold: true }),
|
|
43
|
+
reasonKey: 'hold_reason',
|
|
44
|
+
reason: input.reason,
|
|
45
|
+
idempotencyKey: input.idempotency_key,
|
|
46
|
+
present: redactRow,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=qom-order-hold-place.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qom-order-hold-place.js","sourceRoot":"","sources":["../../../src/tools/qom/qom-order-hold-place.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,uCAAuC,CAAC;AAC5D,OAAO,E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