@usethrottle/mcp 0.8.0 → 0.10.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/dist/contract-index.json +1 -1
- package/dist/docs-index.json +1 -1
- package/dist/lib.cjs +100 -10
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.js +100 -10
- package/dist/lib.js.map +1 -1
- package/dist/mcp.js +100 -10
- package/dist/mcp.js.map +1 -1
- package/package.json +3 -3
package/dist/lib.js
CHANGED
|
@@ -39,6 +39,7 @@ function add(group, resource, actions, labels, opts = {}) {
|
|
|
39
39
|
publishableOnly: opts.publishableOnly ?? false,
|
|
40
40
|
// extension default true for commerce scopes; Taxonomy B passes false
|
|
41
41
|
extensionAllowed: opts.extensionAllowed ?? true,
|
|
42
|
+
...opts.oauthOnly ? { oauthOnly: true } : {},
|
|
42
43
|
implies
|
|
43
44
|
};
|
|
44
45
|
}
|
|
@@ -73,6 +74,11 @@ add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in t
|
|
|
73
74
|
add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
|
|
74
75
|
add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
|
|
75
76
|
REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
|
|
77
|
+
add("Builder", "builder:site", ["read", "write"], { read: "View the site design and settings", write: "Edit the site design and settings" }, { extensionAllowed: false, oauthOnly: true });
|
|
78
|
+
add("Builder", "builder:pages", ["read", "write"], { read: "View pages and drafts", write: "Create and edit page drafts" }, { extensionAllowed: false, oauthOnly: true });
|
|
79
|
+
add("Builder", "builder:widgets", ["read", "write"], { read: "View widgets", write: "Create and edit widgets" }, { extensionAllowed: false, oauthOnly: true });
|
|
80
|
+
add("Builder", "builder:media", ["read", "write"], { read: "View the media library", write: "Upload to the media library" }, { extensionAllowed: false, oauthOnly: true });
|
|
81
|
+
add("Connected apps", "oauth_grants", ["read", "write"], { read: "View Builder OAuth connections", write: "Revoke Builder OAuth connections" });
|
|
76
82
|
add(
|
|
77
83
|
"Customer accounts",
|
|
78
84
|
"customer_accounts",
|
|
@@ -127,6 +133,7 @@ add("Scripts", "extension_scripts", ["read", "write"], {
|
|
|
127
133
|
read: "View an extension's buyer-facing scripts",
|
|
128
134
|
write: "Create, edit and delete an extension's buyer-facing scripts"
|
|
129
135
|
}, { extensionAllowed: false });
|
|
136
|
+
add("Extensions", "extension_presence", ["read"], { read: "Check whether an extension is installed" });
|
|
130
137
|
add("Connectors", "connectors", ["read", "write"], { read: "View connectors", write: "Manage connectors" });
|
|
131
138
|
add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks", write: "Manage webhooks" });
|
|
132
139
|
add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
|
|
@@ -137,6 +144,7 @@ add("Applications", "applications", ["read", "write"], { read: "View application
|
|
|
137
144
|
add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
|
|
138
145
|
add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
|
|
139
146
|
add("Workspace", "branding", ["write"], { write: "Upload branding assets" });
|
|
147
|
+
add("Media", "media", ["read", "write"], { read: "View the media library", write: "Upload and manage media library images" }, { extensionAllowed: true, publishableAllowed: false });
|
|
140
148
|
var HUMAN = { extensionAllowed: false };
|
|
141
149
|
add("Team", "team_members", ["read", "write"], { read: "View members", write: "Manage members" }, HUMAN);
|
|
142
150
|
add("Team", "team_invites", ["read", "write"], { read: "View invites", write: "Manage invites" }, HUMAN);
|
|
@@ -190,7 +198,7 @@ var ALL_SCOPE_IDS = Object.keys(REG);
|
|
|
190
198
|
var SCOPE_GROUPS = (() => {
|
|
191
199
|
const out = {};
|
|
192
200
|
for (const def of Object.values(REG)) {
|
|
193
|
-
if (def.id === "*") continue;
|
|
201
|
+
if (def.id === "*" || def.oauthOnly) continue;
|
|
194
202
|
(out[def.group] ??= []).push(def.id);
|
|
195
203
|
}
|
|
196
204
|
return out;
|
|
@@ -258,6 +266,14 @@ function validateScopesForOAuth(scopes, opts = {}) {
|
|
|
258
266
|
invalid.push(id);
|
|
259
267
|
continue;
|
|
260
268
|
}
|
|
269
|
+
if (id.startsWith("builder:") !== Boolean(opts.builder)) {
|
|
270
|
+
invalid.push(id);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (def.resource === "oauth_grants") {
|
|
274
|
+
invalid.push(id);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
261
277
|
if (def.sensitive && !(opts.connector && CONNECTOR_GRANTABLE_SENSITIVE_SCOPES.includes(id))) invalid.push(id);
|
|
262
278
|
}
|
|
263
279
|
return { ok: invalid.length === 0, invalid };
|
|
@@ -352,6 +368,16 @@ function stripRawProcessorData(value) {
|
|
|
352
368
|
|
|
353
369
|
// ../action-catalog/src/actions.ts
|
|
354
370
|
var OAUTH_WITHHELD = "Over an OAuth connection (ChatGPT, Claude) these are withheld, because a buyer can type them: line-item and quote-item names, SKUs and reference ids; company; every address line except the country; the merchant's external ids; notes, messages, reasons and metadata. Describe items by quantity and amount, and say the rest is withheld rather than missing.";
|
|
371
|
+
var ORDER_STATUSES = [
|
|
372
|
+
"draft",
|
|
373
|
+
"awaiting_payment",
|
|
374
|
+
"awaiting_fulfillment",
|
|
375
|
+
"awaiting_shipment",
|
|
376
|
+
"partially_shipped",
|
|
377
|
+
"shipped",
|
|
378
|
+
"completed",
|
|
379
|
+
"cancelled"
|
|
380
|
+
];
|
|
355
381
|
var ACTIONS = [
|
|
356
382
|
// ---------------------------------------------------------------- identity
|
|
357
383
|
{
|
|
@@ -455,7 +481,20 @@ var ACTIONS = [
|
|
|
455
481
|
scopes: ["orders:read"],
|
|
456
482
|
input: [
|
|
457
483
|
{ name: "q", type: "string", required: false, description: "Free-text search." },
|
|
458
|
-
{
|
|
484
|
+
{
|
|
485
|
+
name: "status",
|
|
486
|
+
type: "string",
|
|
487
|
+
required: false,
|
|
488
|
+
description: "Lifecycle status filter.",
|
|
489
|
+
enum: ORDER_STATUSES
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
name: "effectiveStatus",
|
|
493
|
+
type: "string",
|
|
494
|
+
required: false,
|
|
495
|
+
description: "Filter on the derived effectiveStatus: the lifecycle status unless the order is cancelled, on hold, refunded, partially refunded or disputed.",
|
|
496
|
+
enum: [...ORDER_STATUSES, "on_hold", "refunded", "partially_refunded", "disputed"]
|
|
497
|
+
},
|
|
459
498
|
{ name: "paymentStatus", type: "string", required: false, description: "Payment status filter." },
|
|
460
499
|
{
|
|
461
500
|
name: "createdAfter",
|
|
@@ -734,8 +773,8 @@ var ACTIONS = [
|
|
|
734
773
|
name: "type",
|
|
735
774
|
type: "string",
|
|
736
775
|
required: false,
|
|
737
|
-
description: "Filter by discount type.",
|
|
738
|
-
enum: ["percentage", "fixed_amount"]
|
|
776
|
+
description: "Filter by discount type. A free_shipping code makes shipping free instead of taking money off goods.",
|
|
777
|
+
enum: ["percentage", "fixed_amount", "free_shipping"]
|
|
739
778
|
},
|
|
740
779
|
{ name: "isActive", type: "boolean", required: false, description: "Filter by active state." },
|
|
741
780
|
{ name: "createdAfter", type: "string", required: false, description: "ISO 8601 date lower bound." },
|
|
@@ -755,7 +794,7 @@ var ACTIONS = [
|
|
|
755
794
|
{
|
|
756
795
|
id: "get_discount",
|
|
757
796
|
title: "Get one discount",
|
|
758
|
-
description: "Read a single discount code: value, conditions, usage limits and redemption count.",
|
|
797
|
+
description: "Read a single discount code: value, conditions, usage limits and redemption count. A free_shipping code has value 0 and conditions.shipping (zoneIds and targets, null = all regions / any shipping option); its optional cap is amounts[CUR].value.",
|
|
759
798
|
kind: "read",
|
|
760
799
|
scopes: ["discounts:read"],
|
|
761
800
|
input: [
|
|
@@ -1595,7 +1634,13 @@ var ACTIONS = [
|
|
|
1595
1634
|
name: "discountCode",
|
|
1596
1635
|
type: "string",
|
|
1597
1636
|
required: false,
|
|
1598
|
-
description: "
|
|
1637
|
+
description: "Goods discount code to apply to the session. A free-shipping code here is refused: use shippingDiscountCode."
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
name: "shippingDiscountCode",
|
|
1641
|
+
type: "string",
|
|
1642
|
+
required: false,
|
|
1643
|
+
description: "Free-shipping code to apply to the session, alongside discountCode."
|
|
1599
1644
|
},
|
|
1600
1645
|
{
|
|
1601
1646
|
name: "netN",
|
|
@@ -1792,6 +1837,24 @@ function trigger(id, title, eventType, description) {
|
|
|
1792
1837
|
}
|
|
1793
1838
|
var TRIGGERS = [
|
|
1794
1839
|
trigger("new_order", "New order", "order.created", "Fires when an order is created."),
|
|
1840
|
+
trigger(
|
|
1841
|
+
"order_awaiting_shipment",
|
|
1842
|
+
"Order awaiting shipment",
|
|
1843
|
+
"order.awaiting_shipment",
|
|
1844
|
+
"Fires when an order is being prepared and nothing has shipped yet."
|
|
1845
|
+
),
|
|
1846
|
+
trigger(
|
|
1847
|
+
"order_shipped",
|
|
1848
|
+
"Order shipped",
|
|
1849
|
+
"order.shipped",
|
|
1850
|
+
"Fires when everything an order has to ship has been handed to the carrier."
|
|
1851
|
+
),
|
|
1852
|
+
trigger(
|
|
1853
|
+
"order_completed",
|
|
1854
|
+
"Order completed",
|
|
1855
|
+
"order.completed",
|
|
1856
|
+
"Fires when an order is completed: marked completed after shipping, or finished with nothing to ship."
|
|
1857
|
+
),
|
|
1795
1858
|
trigger(
|
|
1796
1859
|
"payment_captured",
|
|
1797
1860
|
"Payment captured",
|
|
@@ -2244,6 +2307,7 @@ var HANDLERS = {
|
|
|
2244
2307
|
{
|
|
2245
2308
|
q: args.q,
|
|
2246
2309
|
status: args.status,
|
|
2310
|
+
effectiveStatus: args.effectiveStatus,
|
|
2247
2311
|
paymentStatus: args.paymentStatus,
|
|
2248
2312
|
createdAfter: args.createdAfter,
|
|
2249
2313
|
createdBefore: args.createdBefore,
|
|
@@ -2597,7 +2661,8 @@ var HANDLERS = {
|
|
|
2597
2661
|
returnUrl: args.returnUrl,
|
|
2598
2662
|
cancelUrl: args.cancelUrl,
|
|
2599
2663
|
customerEmail: args.customerEmail,
|
|
2600
|
-
discountCode: args.discountCode
|
|
2664
|
+
discountCode: args.discountCode,
|
|
2665
|
+
shippingDiscountCode: args.shippingDiscountCode
|
|
2601
2666
|
},
|
|
2602
2667
|
idempotencyKey: `mcp-checkout-link-session-${stamp}`
|
|
2603
2668
|
});
|
|
@@ -3181,6 +3246,7 @@ var ORDER = {
|
|
|
3181
3246
|
subtotal: M,
|
|
3182
3247
|
discountTotal: M,
|
|
3183
3248
|
shippingTotal: M,
|
|
3249
|
+
shippingDiscountTotal: M,
|
|
3184
3250
|
taxTotal: M,
|
|
3185
3251
|
total: M,
|
|
3186
3252
|
capturedAmount: M,
|
|
@@ -3272,10 +3338,13 @@ var CART = {
|
|
|
3272
3338
|
taxTotal: M,
|
|
3273
3339
|
discountTotal: M,
|
|
3274
3340
|
shippingTotal: M,
|
|
3341
|
+
shippingDiscountTotal: M,
|
|
3275
3342
|
total: M,
|
|
3276
3343
|
lineItems: [LINE_ITEM],
|
|
3277
3344
|
items: [LINE_ITEM],
|
|
3278
3345
|
appliedDiscount: { amount: M },
|
|
3346
|
+
// A free-shipping code: its reduction, the shortfall to its minimum and its cap.
|
|
3347
|
+
appliedShippingDiscount: { amount: M, amountToMinimum: M, cap: M },
|
|
3279
3348
|
selectedShipping: { rateAmount: M },
|
|
3280
3349
|
taxLines: [{ amount: M }]
|
|
3281
3350
|
};
|
|
@@ -3502,6 +3571,7 @@ function project(value, shape) {
|
|
|
3502
3571
|
return Object.fromEntries(entries);
|
|
3503
3572
|
}
|
|
3504
3573
|
if (Array.isArray(shape)) {
|
|
3574
|
+
if (value === null) return null;
|
|
3505
3575
|
return Array.isArray(value) ? value.map((item) => project(item, shape[0])) : void 0;
|
|
3506
3576
|
}
|
|
3507
3577
|
if ("__section" in shape) {
|
|
@@ -3527,7 +3597,16 @@ var page3 = (row) => ({ data: [row], pagination: PAGINATION });
|
|
|
3527
3597
|
var ADDRESS = { countryCode: S };
|
|
3528
3598
|
var CUSTOMER_REF = { id: S };
|
|
3529
3599
|
var APPLICATION = { id: S, name: T, slug: S };
|
|
3530
|
-
var LIFECYCLE_LABELS = [
|
|
3600
|
+
var LIFECYCLE_LABELS = [
|
|
3601
|
+
"Draft",
|
|
3602
|
+
"Awaiting Payment",
|
|
3603
|
+
"Awaiting Fulfillment",
|
|
3604
|
+
"Awaiting Shipment",
|
|
3605
|
+
"Partially Shipped",
|
|
3606
|
+
"Shipped",
|
|
3607
|
+
"Completed",
|
|
3608
|
+
"Cancelled"
|
|
3609
|
+
];
|
|
3531
3610
|
var DISPLAY_QUALIFIERS = [
|
|
3532
3611
|
"Comped",
|
|
3533
3612
|
"Awaiting payment",
|
|
@@ -3578,6 +3657,7 @@ var ORDER2 = {
|
|
|
3578
3657
|
id: S,
|
|
3579
3658
|
orderNumber: S,
|
|
3580
3659
|
status: S,
|
|
3660
|
+
effectiveStatus: S,
|
|
3581
3661
|
displayStatus: DISPLAY_STATUS,
|
|
3582
3662
|
paymentStatus: S,
|
|
3583
3663
|
type: S,
|
|
@@ -3586,6 +3666,7 @@ var ORDER2 = {
|
|
|
3586
3666
|
subtotal: MONEY,
|
|
3587
3667
|
discountTotal: MONEY,
|
|
3588
3668
|
shippingTotal: MONEY,
|
|
3669
|
+
shippingDiscountTotal: MONEY,
|
|
3589
3670
|
taxTotal: MONEY,
|
|
3590
3671
|
total: MONEY,
|
|
3591
3672
|
capturedAmount: MONEY,
|
|
@@ -3802,7 +3883,15 @@ var DISCOUNT2 = {
|
|
|
3802
3883
|
// Per currency, main one included. The decorator drops a fixed discount's legacy `value`
|
|
3803
3884
|
// (MC4-R77), so this is where its amount is. A percentage discount's `amounts` hold only
|
|
3804
3885
|
// a minimum, so `value` is money whenever it is present.
|
|
3805
|
-
amounts: mapOf({ value: MONEY, minOrder: MONEY })
|
|
3886
|
+
amounts: mapOf({ value: MONEY, minOrder: MONEY }),
|
|
3887
|
+
// A free_shipping code's rules (null = all regions / any option). `value` is 0 on that type;
|
|
3888
|
+
// its optional cap is amounts[CUR].value.
|
|
3889
|
+
conditions: {
|
|
3890
|
+
shipping: {
|
|
3891
|
+
zoneIds: [S],
|
|
3892
|
+
targets: [{ kind: S, methodId: S, provider: S, carrier: T, serviceCode: S }]
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3806
3895
|
};
|
|
3807
3896
|
var EVENT2 = {
|
|
3808
3897
|
id: S,
|
|
@@ -3961,6 +4050,7 @@ var OAUTH_PROJECTIONS = {
|
|
|
3961
4050
|
subtotal: MONEY,
|
|
3962
4051
|
discountTotal: MONEY,
|
|
3963
4052
|
shippingTotal: MONEY,
|
|
4053
|
+
shippingDiscountTotal: MONEY,
|
|
3964
4054
|
taxTotal: MONEY,
|
|
3965
4055
|
total: MONEY,
|
|
3966
4056
|
itemCount: S,
|
|
@@ -4130,7 +4220,7 @@ var OAUTH_PROJECTIONS = {
|
|
|
4130
4220
|
};
|
|
4131
4221
|
|
|
4132
4222
|
// src/server.ts
|
|
4133
|
-
var VERSION = true ? "0.
|
|
4223
|
+
var VERSION = true ? "0.10.0" : "0.0.0-dev";
|
|
4134
4224
|
function registerableActions(policy) {
|
|
4135
4225
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
4136
4226
|
return actionsForChannel("mcp").filter((action) => {
|