@usethrottle/mcp 0.6.0 → 0.7.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
@@ -118,6 +118,10 @@ var ThrottleClient = class {
118
118
  const body = await this.requestJson("PATCH", path, options);
119
119
  return body && typeof body === "object" && "data" in body ? body.data : body;
120
120
  }
121
+ async delete(path, options = {}) {
122
+ const body = await this.requestJson("DELETE", path, options);
123
+ return body && typeof body === "object" && "data" in body ? body.data : body;
124
+ }
121
125
  };
122
126
  async function optional(load) {
123
127
  try {
@@ -196,6 +200,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
196
200
  add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
197
201
  add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
198
202
  add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
203
+ add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
204
+ REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
199
205
  add(
200
206
  "Customer accounts",
201
207
  "customer_accounts",
@@ -255,6 +261,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
255
261
  add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
256
262
  add("Webhooks & Events", "events", ["read"], { read: "View events" });
257
263
  add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
264
+ add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
258
265
  add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
259
266
  add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
260
267
  add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
@@ -338,6 +345,7 @@ var PREFIX_RULES = [
338
345
  ["quote.", "quotes:read"],
339
346
  ["return.", "order_returns:read"],
340
347
  ["payment.", "payments:read"],
348
+ ["customer_group.", "customer_groups:read"],
341
349
  ["customer.", "customers:read"],
342
350
  ["subscription.", "subscriptions:read"],
343
351
  ["fulfillment.", "fulfillments:read"],
@@ -1577,6 +1585,99 @@ var ACTIONS = [
1577
1585
  "The updated record is echoed back with email, phone, firstName, lastName and name nulled unless the credential holds customer_pii:read, which OAuth connections cannot hold \u2014 the update still applied, only the response is redacted."
1578
1586
  ]
1579
1587
  },
1588
+ // ------------------------------------------------------------ customer groups
1589
+ {
1590
+ id: "list_customer_groups",
1591
+ title: "List customer groups",
1592
+ description: "List the customer groups of the application (at most 50), with member and discount counts. A customer belongs to at most one group; a group can be fixed or a percent group with a percentBps rate.",
1593
+ kind: "read",
1594
+ scopes: ["customer_groups:read"],
1595
+ input: [],
1596
+ requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
1597
+ channels: ["mcp"]
1598
+ },
1599
+ {
1600
+ id: "get_customer_group",
1601
+ title: "Get a customer group",
1602
+ description: "Fetch one customer group by id.",
1603
+ kind: "read",
1604
+ scopes: ["customer_groups:read"],
1605
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1606
+ requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
1607
+ channels: ["mcp"]
1608
+ },
1609
+ {
1610
+ id: "create_customer_group",
1611
+ title: "Create a customer group",
1612
+ description: "Create a customer group. kind is fixed or percent; a percent group requires percentBps (1-10000, 1500 = 15%) and a fixed group must not have one.",
1613
+ kind: "write",
1614
+ scopes: ["customer_groups:write"],
1615
+ input: [
1616
+ { name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
1617
+ { name: "kind", type: "string", required: true, description: "fixed or percent." },
1618
+ { name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
1619
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true }
1620
+ ],
1621
+ requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
1622
+ channels: ["mcp"],
1623
+ idempotent: true
1624
+ },
1625
+ {
1626
+ id: "update_customer_group",
1627
+ title: "Update a customer group",
1628
+ description: "Change fields on a customer group. Only the fields supplied are touched.",
1629
+ kind: "write",
1630
+ scopes: ["customer_groups:write"],
1631
+ input: [
1632
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1633
+ { name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
1634
+ { name: "kind", type: "string", required: false, description: "fixed or percent." },
1635
+ { name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. To make the group fixed, set kind to fixed (the rate is cleared)." },
1636
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active." }
1637
+ ],
1638
+ requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
1639
+ channels: ["mcp"],
1640
+ idempotent: true
1641
+ },
1642
+ {
1643
+ id: "delete_customer_group",
1644
+ title: "Delete a customer group",
1645
+ description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
1646
+ kind: "write",
1647
+ scopes: ["customer_groups:write"],
1648
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1649
+ requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
1650
+ channels: ["mcp"],
1651
+ idempotent: true
1652
+ },
1653
+ {
1654
+ id: "add_customer_group_members",
1655
+ title: "Add customers to a group",
1656
+ description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
1657
+ kind: "write",
1658
+ scopes: ["customer_groups:write"],
1659
+ input: [
1660
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1661
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1662
+ ],
1663
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
1664
+ channels: ["mcp"],
1665
+ idempotent: true
1666
+ },
1667
+ {
1668
+ id: "remove_customer_group_members",
1669
+ title: "Remove customers from a group",
1670
+ description: "Remove up to 100 customers from a group; the response counts removed.",
1671
+ kind: "write",
1672
+ scopes: ["customer_groups:write"],
1673
+ input: [
1674
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1675
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1676
+ ],
1677
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
1678
+ channels: ["mcp"],
1679
+ idempotent: true
1680
+ },
1580
1681
  {
1581
1682
  id: "create_checkout_link",
1582
1683
  title: "Create a checkout link",
@@ -1899,6 +2000,9 @@ details: ${JSON.stringify(e.details)}` : "";
1899
2000
  return `Error: ${e?.message ?? String(error)}`;
1900
2001
  }
1901
2002
 
2003
+ // src/handlers.ts
2004
+ import { randomUUID } from "crypto";
2005
+
1902
2006
  // src/contract.ts
1903
2007
  var RETIRED_FIELDS = {
1904
2008
  storeId: "applicationId",
@@ -2422,6 +2526,27 @@ var HANDLERS = {
2422
2526
  },
2423
2527
  idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
2424
2528
  }),
2529
+ // ----------------------------------------------------------- customer groups
2530
+ list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
2531
+ get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
2532
+ create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
2533
+ body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled },
2534
+ // Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
2535
+ idempotencyKey: `mcp-create-customer-group-${Date.now()}-${randomUUID()}`
2536
+ }),
2537
+ // A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
2538
+ update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
2539
+ body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled }
2540
+ }),
2541
+ delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
2542
+ add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
2543
+ body: { customerIds: args.customerIds },
2544
+ idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${randomUUID()}`
2545
+ }),
2546
+ remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
2547
+ body: { customerIds: args.customerIds },
2548
+ idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${randomUUID()}`
2549
+ }),
2425
2550
  create_checkout_link: async (ctx, args) => {
2426
2551
  const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
2427
2552
  if (lineItems.length === 0) {
@@ -3419,6 +3544,18 @@ var FULFILLMENT2 = {
3419
3544
  detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
3420
3545
  };
3421
3546
  var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
3547
+ var CUSTOMER_GROUP = {
3548
+ id: S,
3549
+ name: T,
3550
+ kind: S,
3551
+ percentBps: S,
3552
+ enabled: S,
3553
+ version: S,
3554
+ memberCount: S,
3555
+ discountCount: S,
3556
+ createdAt: S,
3557
+ updatedAt: S
3558
+ };
3422
3559
  var SUBSCRIPTION2 = {
3423
3560
  id: S,
3424
3561
  status: S,
@@ -3624,6 +3761,9 @@ var OAUTH_PROJECTIONS = {
3624
3761
  addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
3625
3762
  subscriptions: section([SUBSCRIPTION2])
3626
3763
  },
3764
+ // Group names are merchant-written (T); the rest is Throttle-generated.
3765
+ list_customer_groups: [CUSTOMER_GROUP],
3766
+ get_customer_group: CUSTOMER_GROUP,
3627
3767
  list_subscriptions: page3(SUBSCRIPTION2),
3628
3768
  get_subscription: SUBSCRIPTION2,
3629
3769
  search_quotes: page3(QUOTE_SUMMARY2),
@@ -3884,7 +4024,7 @@ var OAUTH_PROJECTIONS = {
3884
4024
  };
3885
4025
 
3886
4026
  // src/server.ts
3887
- var VERSION = true ? "0.6.0" : "0.0.0-dev";
4027
+ var VERSION = true ? "0.7.0" : "0.0.0-dev";
3888
4028
  function registerableActions(policy) {
3889
4029
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3890
4030
  return actionsForChannel("mcp").filter((action) => {