@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/lib.cjs CHANGED
@@ -76,6 +76,7 @@ function add(group, resource, actions, labels, opts = {}) {
76
76
  publishableOnly: opts.publishableOnly ?? false,
77
77
  // extension default true for commerce scopes; Taxonomy B passes false
78
78
  extensionAllowed: opts.extensionAllowed ?? true,
79
+ ...opts.oauthOnly ? { oauthOnly: true } : {},
79
80
  implies
80
81
  };
81
82
  }
@@ -110,6 +111,11 @@ add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in t
110
111
  add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
111
112
  add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
112
113
  REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
114
+ add("Builder", "builder:site", ["read", "write"], { read: "View the site design and settings", write: "Edit the site design and settings" }, { extensionAllowed: false, oauthOnly: true });
115
+ add("Builder", "builder:pages", ["read", "write"], { read: "View pages and drafts", write: "Create and edit page drafts" }, { extensionAllowed: false, oauthOnly: true });
116
+ add("Builder", "builder:widgets", ["read", "write"], { read: "View widgets", write: "Create and edit widgets" }, { extensionAllowed: false, oauthOnly: true });
117
+ add("Builder", "builder:media", ["read", "write"], { read: "View the media library", write: "Upload to the media library" }, { extensionAllowed: false, oauthOnly: true });
118
+ add("Connected apps", "oauth_grants", ["read", "write"], { read: "View Builder OAuth connections", write: "Revoke Builder OAuth connections" });
113
119
  add(
114
120
  "Customer accounts",
115
121
  "customer_accounts",
@@ -164,6 +170,7 @@ add("Scripts", "extension_scripts", ["read", "write"], {
164
170
  read: "View an extension's buyer-facing scripts",
165
171
  write: "Create, edit and delete an extension's buyer-facing scripts"
166
172
  }, { extensionAllowed: false });
173
+ add("Extensions", "extension_presence", ["read"], { read: "Check whether an extension is installed" });
167
174
  add("Connectors", "connectors", ["read", "write"], { read: "View connectors", write: "Manage connectors" });
168
175
  add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks", write: "Manage webhooks" });
169
176
  add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
@@ -174,6 +181,7 @@ add("Applications", "applications", ["read", "write"], { read: "View application
174
181
  add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
175
182
  add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
176
183
  add("Workspace", "branding", ["write"], { write: "Upload branding assets" });
184
+ add("Media", "media", ["read", "write"], { read: "View the media library", write: "Upload and manage media library images" }, { extensionAllowed: true, publishableAllowed: false });
177
185
  var HUMAN = { extensionAllowed: false };
178
186
  add("Team", "team_members", ["read", "write"], { read: "View members", write: "Manage members" }, HUMAN);
179
187
  add("Team", "team_invites", ["read", "write"], { read: "View invites", write: "Manage invites" }, HUMAN);
@@ -227,7 +235,7 @@ var ALL_SCOPE_IDS = Object.keys(REG);
227
235
  var SCOPE_GROUPS = (() => {
228
236
  const out = {};
229
237
  for (const def of Object.values(REG)) {
230
- if (def.id === "*") continue;
238
+ if (def.id === "*" || def.oauthOnly) continue;
231
239
  (out[def.group] ??= []).push(def.id);
232
240
  }
233
241
  return out;
@@ -295,6 +303,14 @@ function validateScopesForOAuth(scopes, opts = {}) {
295
303
  invalid.push(id);
296
304
  continue;
297
305
  }
306
+ if (id.startsWith("builder:") !== Boolean(opts.builder)) {
307
+ invalid.push(id);
308
+ continue;
309
+ }
310
+ if (def.resource === "oauth_grants") {
311
+ invalid.push(id);
312
+ continue;
313
+ }
298
314
  if (def.sensitive && !(opts.connector && CONNECTOR_GRANTABLE_SENSITIVE_SCOPES.includes(id))) invalid.push(id);
299
315
  }
300
316
  return { ok: invalid.length === 0, invalid };
@@ -389,6 +405,16 @@ function stripRawProcessorData(value) {
389
405
 
390
406
  // ../action-catalog/src/actions.ts
391
407
  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.";
408
+ var ORDER_STATUSES = [
409
+ "draft",
410
+ "awaiting_payment",
411
+ "awaiting_fulfillment",
412
+ "awaiting_shipment",
413
+ "partially_shipped",
414
+ "shipped",
415
+ "completed",
416
+ "cancelled"
417
+ ];
392
418
  var ACTIONS = [
393
419
  // ---------------------------------------------------------------- identity
394
420
  {
@@ -492,7 +518,20 @@ var ACTIONS = [
492
518
  scopes: ["orders:read"],
493
519
  input: [
494
520
  { name: "q", type: "string", required: false, description: "Free-text search." },
495
- { name: "status", type: "string", required: false, description: "Order status filter." },
521
+ {
522
+ name: "status",
523
+ type: "string",
524
+ required: false,
525
+ description: "Lifecycle status filter.",
526
+ enum: ORDER_STATUSES
527
+ },
528
+ {
529
+ name: "effectiveStatus",
530
+ type: "string",
531
+ required: false,
532
+ description: "Filter on the derived effectiveStatus: the lifecycle status unless the order is cancelled, on hold, refunded, partially refunded or disputed.",
533
+ enum: [...ORDER_STATUSES, "on_hold", "refunded", "partially_refunded", "disputed"]
534
+ },
496
535
  { name: "paymentStatus", type: "string", required: false, description: "Payment status filter." },
497
536
  {
498
537
  name: "createdAfter",
@@ -771,8 +810,8 @@ var ACTIONS = [
771
810
  name: "type",
772
811
  type: "string",
773
812
  required: false,
774
- description: "Filter by discount type.",
775
- enum: ["percentage", "fixed_amount"]
813
+ description: "Filter by discount type. A free_shipping code makes shipping free instead of taking money off goods.",
814
+ enum: ["percentage", "fixed_amount", "free_shipping"]
776
815
  },
777
816
  { name: "isActive", type: "boolean", required: false, description: "Filter by active state." },
778
817
  { name: "createdAfter", type: "string", required: false, description: "ISO 8601 date lower bound." },
@@ -792,7 +831,7 @@ var ACTIONS = [
792
831
  {
793
832
  id: "get_discount",
794
833
  title: "Get one discount",
795
- description: "Read a single discount code: value, conditions, usage limits and redemption count.",
834
+ 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.",
796
835
  kind: "read",
797
836
  scopes: ["discounts:read"],
798
837
  input: [
@@ -1632,7 +1671,13 @@ var ACTIONS = [
1632
1671
  name: "discountCode",
1633
1672
  type: "string",
1634
1673
  required: false,
1635
- description: "Discount code to apply to the session."
1674
+ description: "Goods discount code to apply to the session. A free-shipping code here is refused: use shippingDiscountCode."
1675
+ },
1676
+ {
1677
+ name: "shippingDiscountCode",
1678
+ type: "string",
1679
+ required: false,
1680
+ description: "Free-shipping code to apply to the session, alongside discountCode."
1636
1681
  },
1637
1682
  {
1638
1683
  name: "netN",
@@ -1829,6 +1874,24 @@ function trigger(id, title, eventType, description) {
1829
1874
  }
1830
1875
  var TRIGGERS = [
1831
1876
  trigger("new_order", "New order", "order.created", "Fires when an order is created."),
1877
+ trigger(
1878
+ "order_awaiting_shipment",
1879
+ "Order awaiting shipment",
1880
+ "order.awaiting_shipment",
1881
+ "Fires when an order is being prepared and nothing has shipped yet."
1882
+ ),
1883
+ trigger(
1884
+ "order_shipped",
1885
+ "Order shipped",
1886
+ "order.shipped",
1887
+ "Fires when everything an order has to ship has been handed to the carrier."
1888
+ ),
1889
+ trigger(
1890
+ "order_completed",
1891
+ "Order completed",
1892
+ "order.completed",
1893
+ "Fires when an order is completed: marked completed after shipping, or finished with nothing to ship."
1894
+ ),
1832
1895
  trigger(
1833
1896
  "payment_captured",
1834
1897
  "Payment captured",
@@ -2281,6 +2344,7 @@ var HANDLERS = {
2281
2344
  {
2282
2345
  q: args.q,
2283
2346
  status: args.status,
2347
+ effectiveStatus: args.effectiveStatus,
2284
2348
  paymentStatus: args.paymentStatus,
2285
2349
  createdAfter: args.createdAfter,
2286
2350
  createdBefore: args.createdBefore,
@@ -2634,7 +2698,8 @@ var HANDLERS = {
2634
2698
  returnUrl: args.returnUrl,
2635
2699
  cancelUrl: args.cancelUrl,
2636
2700
  customerEmail: args.customerEmail,
2637
- discountCode: args.discountCode
2701
+ discountCode: args.discountCode,
2702
+ shippingDiscountCode: args.shippingDiscountCode
2638
2703
  },
2639
2704
  idempotencyKey: `mcp-checkout-link-session-${stamp}`
2640
2705
  });
@@ -3218,6 +3283,7 @@ var ORDER = {
3218
3283
  subtotal: M,
3219
3284
  discountTotal: M,
3220
3285
  shippingTotal: M,
3286
+ shippingDiscountTotal: M,
3221
3287
  taxTotal: M,
3222
3288
  total: M,
3223
3289
  capturedAmount: M,
@@ -3309,10 +3375,13 @@ var CART = {
3309
3375
  taxTotal: M,
3310
3376
  discountTotal: M,
3311
3377
  shippingTotal: M,
3378
+ shippingDiscountTotal: M,
3312
3379
  total: M,
3313
3380
  lineItems: [LINE_ITEM],
3314
3381
  items: [LINE_ITEM],
3315
3382
  appliedDiscount: { amount: M },
3383
+ // A free-shipping code: its reduction, the shortfall to its minimum and its cap.
3384
+ appliedShippingDiscount: { amount: M, amountToMinimum: M, cap: M },
3316
3385
  selectedShipping: { rateAmount: M },
3317
3386
  taxLines: [{ amount: M }]
3318
3387
  };
@@ -3539,6 +3608,7 @@ function project(value, shape) {
3539
3608
  return Object.fromEntries(entries);
3540
3609
  }
3541
3610
  if (Array.isArray(shape)) {
3611
+ if (value === null) return null;
3542
3612
  return Array.isArray(value) ? value.map((item) => project(item, shape[0])) : void 0;
3543
3613
  }
3544
3614
  if ("__section" in shape) {
@@ -3564,7 +3634,16 @@ var page3 = (row) => ({ data: [row], pagination: PAGINATION });
3564
3634
  var ADDRESS = { countryCode: S };
3565
3635
  var CUSTOMER_REF = { id: S };
3566
3636
  var APPLICATION = { id: S, name: T, slug: S };
3567
- var LIFECYCLE_LABELS = ["Draft", "Pending", "Processing", "Partially fulfilled", "Fulfilled", "Cancelled", "Closed"];
3637
+ var LIFECYCLE_LABELS = [
3638
+ "Draft",
3639
+ "Awaiting Payment",
3640
+ "Awaiting Fulfillment",
3641
+ "Awaiting Shipment",
3642
+ "Partially Shipped",
3643
+ "Shipped",
3644
+ "Completed",
3645
+ "Cancelled"
3646
+ ];
3568
3647
  var DISPLAY_QUALIFIERS = [
3569
3648
  "Comped",
3570
3649
  "Awaiting payment",
@@ -3615,6 +3694,7 @@ var ORDER2 = {
3615
3694
  id: S,
3616
3695
  orderNumber: S,
3617
3696
  status: S,
3697
+ effectiveStatus: S,
3618
3698
  displayStatus: DISPLAY_STATUS,
3619
3699
  paymentStatus: S,
3620
3700
  type: S,
@@ -3623,6 +3703,7 @@ var ORDER2 = {
3623
3703
  subtotal: MONEY,
3624
3704
  discountTotal: MONEY,
3625
3705
  shippingTotal: MONEY,
3706
+ shippingDiscountTotal: MONEY,
3626
3707
  taxTotal: MONEY,
3627
3708
  total: MONEY,
3628
3709
  capturedAmount: MONEY,
@@ -3839,7 +3920,15 @@ var DISCOUNT2 = {
3839
3920
  // Per currency, main one included. The decorator drops a fixed discount's legacy `value`
3840
3921
  // (MC4-R77), so this is where its amount is. A percentage discount's `amounts` hold only
3841
3922
  // a minimum, so `value` is money whenever it is present.
3842
- amounts: mapOf({ value: MONEY, minOrder: MONEY })
3923
+ amounts: mapOf({ value: MONEY, minOrder: MONEY }),
3924
+ // A free_shipping code's rules (null = all regions / any option). `value` is 0 on that type;
3925
+ // its optional cap is amounts[CUR].value.
3926
+ conditions: {
3927
+ shipping: {
3928
+ zoneIds: [S],
3929
+ targets: [{ kind: S, methodId: S, provider: S, carrier: T, serviceCode: S }]
3930
+ }
3931
+ }
3843
3932
  };
3844
3933
  var EVENT2 = {
3845
3934
  id: S,
@@ -3998,6 +4087,7 @@ var OAUTH_PROJECTIONS = {
3998
4087
  subtotal: MONEY,
3999
4088
  discountTotal: MONEY,
4000
4089
  shippingTotal: MONEY,
4090
+ shippingDiscountTotal: MONEY,
4001
4091
  taxTotal: MONEY,
4002
4092
  total: MONEY,
4003
4093
  itemCount: S,
@@ -4167,7 +4257,7 @@ var OAUTH_PROJECTIONS = {
4167
4257
  };
4168
4258
 
4169
4259
  // src/server.ts
4170
- var VERSION = true ? "0.8.0" : "0.0.0-dev";
4260
+ var VERSION = true ? "0.10.0" : "0.0.0-dev";
4171
4261
  function registerableActions(policy) {
4172
4262
  const isProduction = policy.identity.environment.providerEnvironment === "production";
4173
4263
  return actionsForChannel("mcp").filter((action) => {