@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/mcp.js CHANGED
@@ -169,6 +169,7 @@ function add(group, resource, actions, labels, opts = {}) {
169
169
  publishableOnly: opts.publishableOnly ?? false,
170
170
  // extension default true for commerce scopes; Taxonomy B passes false
171
171
  extensionAllowed: opts.extensionAllowed ?? true,
172
+ ...opts.oauthOnly ? { oauthOnly: true } : {},
172
173
  implies
173
174
  };
174
175
  }
@@ -203,6 +204,11 @@ add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in t
203
204
  add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
204
205
  add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
205
206
  REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
207
+ add("Builder", "builder:site", ["read", "write"], { read: "View the site design and settings", write: "Edit the site design and settings" }, { extensionAllowed: false, oauthOnly: true });
208
+ add("Builder", "builder:pages", ["read", "write"], { read: "View pages and drafts", write: "Create and edit page drafts" }, { extensionAllowed: false, oauthOnly: true });
209
+ add("Builder", "builder:widgets", ["read", "write"], { read: "View widgets", write: "Create and edit widgets" }, { extensionAllowed: false, oauthOnly: true });
210
+ add("Builder", "builder:media", ["read", "write"], { read: "View the media library", write: "Upload to the media library" }, { extensionAllowed: false, oauthOnly: true });
211
+ add("Connected apps", "oauth_grants", ["read", "write"], { read: "View Builder OAuth connections", write: "Revoke Builder OAuth connections" });
206
212
  add(
207
213
  "Customer accounts",
208
214
  "customer_accounts",
@@ -257,6 +263,7 @@ add("Scripts", "extension_scripts", ["read", "write"], {
257
263
  read: "View an extension's buyer-facing scripts",
258
264
  write: "Create, edit and delete an extension's buyer-facing scripts"
259
265
  }, { extensionAllowed: false });
266
+ add("Extensions", "extension_presence", ["read"], { read: "Check whether an extension is installed" });
260
267
  add("Connectors", "connectors", ["read", "write"], { read: "View connectors", write: "Manage connectors" });
261
268
  add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks", write: "Manage webhooks" });
262
269
  add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
@@ -267,6 +274,7 @@ add("Applications", "applications", ["read", "write"], { read: "View application
267
274
  add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
268
275
  add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
269
276
  add("Workspace", "branding", ["write"], { write: "Upload branding assets" });
277
+ add("Media", "media", ["read", "write"], { read: "View the media library", write: "Upload and manage media library images" }, { extensionAllowed: true, publishableAllowed: false });
270
278
  var HUMAN = { extensionAllowed: false };
271
279
  add("Team", "team_members", ["read", "write"], { read: "View members", write: "Manage members" }, HUMAN);
272
280
  add("Team", "team_invites", ["read", "write"], { read: "View invites", write: "Manage invites" }, HUMAN);
@@ -320,7 +328,7 @@ var ALL_SCOPE_IDS = Object.keys(REG);
320
328
  var SCOPE_GROUPS = (() => {
321
329
  const out = {};
322
330
  for (const def of Object.values(REG)) {
323
- if (def.id === "*") continue;
331
+ if (def.id === "*" || def.oauthOnly) continue;
324
332
  (out[def.group] ??= []).push(def.id);
325
333
  }
326
334
  return out;
@@ -388,6 +396,14 @@ function validateScopesForOAuth(scopes, opts = {}) {
388
396
  invalid.push(id);
389
397
  continue;
390
398
  }
399
+ if (id.startsWith("builder:") !== Boolean(opts.builder)) {
400
+ invalid.push(id);
401
+ continue;
402
+ }
403
+ if (def.resource === "oauth_grants") {
404
+ invalid.push(id);
405
+ continue;
406
+ }
391
407
  if (def.sensitive && !(opts.connector && CONNECTOR_GRANTABLE_SENSITIVE_SCOPES.includes(id))) invalid.push(id);
392
408
  }
393
409
  return { ok: invalid.length === 0, invalid };
@@ -482,6 +498,16 @@ function stripRawProcessorData(value) {
482
498
 
483
499
  // ../action-catalog/src/actions.ts
484
500
  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.";
501
+ var ORDER_STATUSES = [
502
+ "draft",
503
+ "awaiting_payment",
504
+ "awaiting_fulfillment",
505
+ "awaiting_shipment",
506
+ "partially_shipped",
507
+ "shipped",
508
+ "completed",
509
+ "cancelled"
510
+ ];
485
511
  var ACTIONS = [
486
512
  // ---------------------------------------------------------------- identity
487
513
  {
@@ -585,7 +611,20 @@ var ACTIONS = [
585
611
  scopes: ["orders:read"],
586
612
  input: [
587
613
  { name: "q", type: "string", required: false, description: "Free-text search." },
588
- { name: "status", type: "string", required: false, description: "Order status filter." },
614
+ {
615
+ name: "status",
616
+ type: "string",
617
+ required: false,
618
+ description: "Lifecycle status filter.",
619
+ enum: ORDER_STATUSES
620
+ },
621
+ {
622
+ name: "effectiveStatus",
623
+ type: "string",
624
+ required: false,
625
+ description: "Filter on the derived effectiveStatus: the lifecycle status unless the order is cancelled, on hold, refunded, partially refunded or disputed.",
626
+ enum: [...ORDER_STATUSES, "on_hold", "refunded", "partially_refunded", "disputed"]
627
+ },
589
628
  { name: "paymentStatus", type: "string", required: false, description: "Payment status filter." },
590
629
  {
591
630
  name: "createdAfter",
@@ -864,8 +903,8 @@ var ACTIONS = [
864
903
  name: "type",
865
904
  type: "string",
866
905
  required: false,
867
- description: "Filter by discount type.",
868
- enum: ["percentage", "fixed_amount"]
906
+ description: "Filter by discount type. A free_shipping code makes shipping free instead of taking money off goods.",
907
+ enum: ["percentage", "fixed_amount", "free_shipping"]
869
908
  },
870
909
  { name: "isActive", type: "boolean", required: false, description: "Filter by active state." },
871
910
  { name: "createdAfter", type: "string", required: false, description: "ISO 8601 date lower bound." },
@@ -885,7 +924,7 @@ var ACTIONS = [
885
924
  {
886
925
  id: "get_discount",
887
926
  title: "Get one discount",
888
- description: "Read a single discount code: value, conditions, usage limits and redemption count.",
927
+ 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.",
889
928
  kind: "read",
890
929
  scopes: ["discounts:read"],
891
930
  input: [
@@ -1725,7 +1764,13 @@ var ACTIONS = [
1725
1764
  name: "discountCode",
1726
1765
  type: "string",
1727
1766
  required: false,
1728
- description: "Discount code to apply to the session."
1767
+ description: "Goods discount code to apply to the session. A free-shipping code here is refused: use shippingDiscountCode."
1768
+ },
1769
+ {
1770
+ name: "shippingDiscountCode",
1771
+ type: "string",
1772
+ required: false,
1773
+ description: "Free-shipping code to apply to the session, alongside discountCode."
1729
1774
  },
1730
1775
  {
1731
1776
  name: "netN",
@@ -1922,6 +1967,24 @@ function trigger(id, title, eventType, description) {
1922
1967
  }
1923
1968
  var TRIGGERS = [
1924
1969
  trigger("new_order", "New order", "order.created", "Fires when an order is created."),
1970
+ trigger(
1971
+ "order_awaiting_shipment",
1972
+ "Order awaiting shipment",
1973
+ "order.awaiting_shipment",
1974
+ "Fires when an order is being prepared and nothing has shipped yet."
1975
+ ),
1976
+ trigger(
1977
+ "order_shipped",
1978
+ "Order shipped",
1979
+ "order.shipped",
1980
+ "Fires when everything an order has to ship has been handed to the carrier."
1981
+ ),
1982
+ trigger(
1983
+ "order_completed",
1984
+ "Order completed",
1985
+ "order.completed",
1986
+ "Fires when an order is completed: marked completed after shipping, or finished with nothing to ship."
1987
+ ),
1925
1988
  trigger(
1926
1989
  "payment_captured",
1927
1990
  "Payment captured",
@@ -2243,6 +2306,7 @@ var HANDLERS = {
2243
2306
  {
2244
2307
  q: args.q,
2245
2308
  status: args.status,
2309
+ effectiveStatus: args.effectiveStatus,
2246
2310
  paymentStatus: args.paymentStatus,
2247
2311
  createdAfter: args.createdAfter,
2248
2312
  createdBefore: args.createdBefore,
@@ -2596,7 +2660,8 @@ var HANDLERS = {
2596
2660
  returnUrl: args.returnUrl,
2597
2661
  cancelUrl: args.cancelUrl,
2598
2662
  customerEmail: args.customerEmail,
2599
- discountCode: args.discountCode
2663
+ discountCode: args.discountCode,
2664
+ shippingDiscountCode: args.shippingDiscountCode
2600
2665
  },
2601
2666
  idempotencyKey: `mcp-checkout-link-session-${stamp}`
2602
2667
  });
@@ -3097,6 +3162,7 @@ var ORDER = {
3097
3162
  subtotal: M,
3098
3163
  discountTotal: M,
3099
3164
  shippingTotal: M,
3165
+ shippingDiscountTotal: M,
3100
3166
  taxTotal: M,
3101
3167
  total: M,
3102
3168
  capturedAmount: M,
@@ -3188,10 +3254,13 @@ var CART = {
3188
3254
  taxTotal: M,
3189
3255
  discountTotal: M,
3190
3256
  shippingTotal: M,
3257
+ shippingDiscountTotal: M,
3191
3258
  total: M,
3192
3259
  lineItems: [LINE_ITEM],
3193
3260
  items: [LINE_ITEM],
3194
3261
  appliedDiscount: { amount: M },
3262
+ // A free-shipping code: its reduction, the shortfall to its minimum and its cap.
3263
+ appliedShippingDiscount: { amount: M, amountToMinimum: M, cap: M },
3195
3264
  selectedShipping: { rateAmount: M },
3196
3265
  taxLines: [{ amount: M }]
3197
3266
  };
@@ -3418,6 +3487,7 @@ function project(value, shape) {
3418
3487
  return Object.fromEntries(entries);
3419
3488
  }
3420
3489
  if (Array.isArray(shape)) {
3490
+ if (value === null) return null;
3421
3491
  return Array.isArray(value) ? value.map((item) => project(item, shape[0])) : void 0;
3422
3492
  }
3423
3493
  if ("__section" in shape) {
@@ -3443,7 +3513,16 @@ var page3 = (row) => ({ data: [row], pagination: PAGINATION });
3443
3513
  var ADDRESS = { countryCode: S };
3444
3514
  var CUSTOMER_REF = { id: S };
3445
3515
  var APPLICATION = { id: S, name: T, slug: S };
3446
- var LIFECYCLE_LABELS = ["Draft", "Pending", "Processing", "Partially fulfilled", "Fulfilled", "Cancelled", "Closed"];
3516
+ var LIFECYCLE_LABELS = [
3517
+ "Draft",
3518
+ "Awaiting Payment",
3519
+ "Awaiting Fulfillment",
3520
+ "Awaiting Shipment",
3521
+ "Partially Shipped",
3522
+ "Shipped",
3523
+ "Completed",
3524
+ "Cancelled"
3525
+ ];
3447
3526
  var DISPLAY_QUALIFIERS = [
3448
3527
  "Comped",
3449
3528
  "Awaiting payment",
@@ -3494,6 +3573,7 @@ var ORDER2 = {
3494
3573
  id: S,
3495
3574
  orderNumber: S,
3496
3575
  status: S,
3576
+ effectiveStatus: S,
3497
3577
  displayStatus: DISPLAY_STATUS,
3498
3578
  paymentStatus: S,
3499
3579
  type: S,
@@ -3502,6 +3582,7 @@ var ORDER2 = {
3502
3582
  subtotal: MONEY,
3503
3583
  discountTotal: MONEY,
3504
3584
  shippingTotal: MONEY,
3585
+ shippingDiscountTotal: MONEY,
3505
3586
  taxTotal: MONEY,
3506
3587
  total: MONEY,
3507
3588
  capturedAmount: MONEY,
@@ -3718,7 +3799,15 @@ var DISCOUNT2 = {
3718
3799
  // Per currency, main one included. The decorator drops a fixed discount's legacy `value`
3719
3800
  // (MC4-R77), so this is where its amount is. A percentage discount's `amounts` hold only
3720
3801
  // a minimum, so `value` is money whenever it is present.
3721
- amounts: mapOf({ value: MONEY, minOrder: MONEY })
3802
+ amounts: mapOf({ value: MONEY, minOrder: MONEY }),
3803
+ // A free_shipping code's rules (null = all regions / any option). `value` is 0 on that type;
3804
+ // its optional cap is amounts[CUR].value.
3805
+ conditions: {
3806
+ shipping: {
3807
+ zoneIds: [S],
3808
+ targets: [{ kind: S, methodId: S, provider: S, carrier: T, serviceCode: S }]
3809
+ }
3810
+ }
3722
3811
  };
3723
3812
  var EVENT2 = {
3724
3813
  id: S,
@@ -3877,6 +3966,7 @@ var OAUTH_PROJECTIONS = {
3877
3966
  subtotal: MONEY,
3878
3967
  discountTotal: MONEY,
3879
3968
  shippingTotal: MONEY,
3969
+ shippingDiscountTotal: MONEY,
3880
3970
  taxTotal: MONEY,
3881
3971
  total: MONEY,
3882
3972
  itemCount: S,
@@ -4046,7 +4136,7 @@ var OAUTH_PROJECTIONS = {
4046
4136
  };
4047
4137
 
4048
4138
  // src/server.ts
4049
- var VERSION = true ? "0.8.0" : "0.0.0-dev";
4139
+ var VERSION = true ? "0.10.0" : "0.0.0-dev";
4050
4140
  function registerableActions(policy) {
4051
4141
  const isProduction = policy.identity.environment.providerEnvironment === "production";
4052
4142
  return actionsForChannel("mcp").filter((action) => {