@usethrottle/mcp 0.6.0 → 0.8.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
@@ -82,6 +82,7 @@ function add(group, resource, actions, labels, opts = {}) {
82
82
  }
83
83
  add("Orders", "orders", ["read", "write"], { read: "View orders", write: "Manage orders" });
84
84
  add("Quotes", "quotes", ["read", "write"], { read: "View quotes", write: "Manage quotes" });
85
+ add("Forms", "forms", ["read", "write"], { read: "View site forms and their submissions", write: "Manage site forms" }, { sensitive: true });
85
86
  add("Orders", "order_cancellations", ["write"], { write: "Cancel orders" });
86
87
  add("Orders", "order_returns", ["read", "write"], { read: "View returns", write: "Process returns" });
87
88
  add("Orders", "order_comps", ["write"], { write: "Comp orders (write off the balance)" }, { sensitive: true });
@@ -107,6 +108,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
107
108
  add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
108
109
  add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
109
110
  add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
111
+ add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
112
+ REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
110
113
  add(
111
114
  "Customer accounts",
112
115
  "customer_accounts",
@@ -166,6 +169,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
166
169
  add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
167
170
  add("Webhooks & Events", "events", ["read"], { read: "View events" });
168
171
  add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
172
+ add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
169
173
  add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
170
174
  add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
171
175
  add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
@@ -247,8 +251,10 @@ var PREFIX_RULES = [
247
251
  ["cart.", "carts:read"],
248
252
  ["order.", "orders:read"],
249
253
  ["quote.", "quotes:read"],
254
+ ["form.", "forms:read"],
250
255
  ["return.", "order_returns:read"],
251
256
  ["payment.", "payments:read"],
257
+ ["customer_group.", "customer_groups:read"],
252
258
  ["customer.", "customers:read"],
253
259
  ["subscription.", "subscriptions:read"],
254
260
  ["fulfillment.", "fulfillments:read"],
@@ -1488,6 +1494,103 @@ var ACTIONS = [
1488
1494
  "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."
1489
1495
  ]
1490
1496
  },
1497
+ // ------------------------------------------------------------ customer groups
1498
+ {
1499
+ id: "list_customer_groups",
1500
+ title: "List customer groups",
1501
+ 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.",
1502
+ kind: "read",
1503
+ scopes: ["customer_groups:read"],
1504
+ input: [],
1505
+ requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
1506
+ channels: ["mcp"]
1507
+ },
1508
+ {
1509
+ id: "get_customer_group",
1510
+ title: "Get a customer group",
1511
+ description: "Fetch one customer group by id.",
1512
+ kind: "read",
1513
+ scopes: ["customer_groups:read"],
1514
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1515
+ requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
1516
+ channels: ["mcp"]
1517
+ },
1518
+ {
1519
+ id: "create_customer_group",
1520
+ title: "Create a customer group",
1521
+ 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.",
1522
+ kind: "write",
1523
+ scopes: ["customer_groups:write"],
1524
+ input: [
1525
+ { name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
1526
+ { name: "kind", type: "string", required: true, description: "fixed or percent." },
1527
+ { name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
1528
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true },
1529
+ { name: "taxExempt", type: "boolean", required: false, description: "Members are exempt from tax. Needs taxExemptReason.", default: false },
1530
+ { name: "taxExemptReason", type: "string", required: false, description: "Avalara entity-use code (A-R) that explains the exemption. Required when taxExempt is true." }
1531
+ ],
1532
+ requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
1533
+ channels: ["mcp"],
1534
+ idempotent: true
1535
+ },
1536
+ {
1537
+ id: "update_customer_group",
1538
+ title: "Update a customer group",
1539
+ description: "Change fields on a customer group. Only the fields supplied are touched.",
1540
+ kind: "write",
1541
+ scopes: ["customer_groups:write"],
1542
+ input: [
1543
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1544
+ { name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
1545
+ { name: "kind", type: "string", required: false, description: "fixed or percent." },
1546
+ { 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)." },
1547
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active." },
1548
+ { name: "taxExempt", type: "boolean", required: false, description: "Members are exempt from tax. Needs taxExemptReason." },
1549
+ { name: "taxExemptReason", type: "string", required: false, description: "Avalara entity-use code (A-R). Set null to clear when taxExempt is false." }
1550
+ ],
1551
+ requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
1552
+ channels: ["mcp"],
1553
+ idempotent: true
1554
+ },
1555
+ {
1556
+ id: "delete_customer_group",
1557
+ title: "Delete a customer group",
1558
+ description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
1559
+ kind: "write",
1560
+ scopes: ["customer_groups:write"],
1561
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1562
+ requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
1563
+ channels: ["mcp"],
1564
+ idempotent: true
1565
+ },
1566
+ {
1567
+ id: "add_customer_group_members",
1568
+ title: "Add customers to a group",
1569
+ description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
1570
+ kind: "write",
1571
+ scopes: ["customer_groups:write"],
1572
+ input: [
1573
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1574
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1575
+ ],
1576
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
1577
+ channels: ["mcp"],
1578
+ idempotent: true
1579
+ },
1580
+ {
1581
+ id: "remove_customer_group_members",
1582
+ title: "Remove customers from a group",
1583
+ description: "Remove up to 100 customers from a group; the response counts removed.",
1584
+ kind: "write",
1585
+ scopes: ["customer_groups:write"],
1586
+ input: [
1587
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1588
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1589
+ ],
1590
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
1591
+ channels: ["mcp"],
1592
+ idempotent: true
1593
+ },
1491
1594
  {
1492
1595
  id: "create_checkout_link",
1493
1596
  title: "Create a checkout link",
@@ -1810,6 +1913,9 @@ details: ${JSON.stringify(e.details)}` : "";
1810
1913
  return `Error: ${e?.message ?? String(error)}`;
1811
1914
  }
1812
1915
 
1916
+ // src/handlers.ts
1917
+ var import_node_crypto = require("crypto");
1918
+
1813
1919
  // ../errors/dist/index.js
1814
1920
  var ThrottleError = class extends Error {
1815
1921
  code;
@@ -1925,6 +2031,10 @@ var ThrottleClient = class {
1925
2031
  const body = await this.requestJson("PATCH", path, options);
1926
2032
  return body && typeof body === "object" && "data" in body ? body.data : body;
1927
2033
  }
2034
+ async delete(path, options = {}) {
2035
+ const body = await this.requestJson("DELETE", path, options);
2036
+ return body && typeof body === "object" && "data" in body ? body.data : body;
2037
+ }
1928
2038
  };
1929
2039
  async function optional(load) {
1930
2040
  try {
@@ -2460,6 +2570,41 @@ var HANDLERS = {
2460
2570
  },
2461
2571
  idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
2462
2572
  }),
2573
+ // ----------------------------------------------------------- customer groups
2574
+ list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
2575
+ get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
2576
+ create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
2577
+ body: {
2578
+ name: args.name,
2579
+ kind: args.kind,
2580
+ percentBps: args.percentBps,
2581
+ enabled: args.enabled,
2582
+ taxExempt: args.taxExempt,
2583
+ taxExemptReason: args.taxExemptReason
2584
+ },
2585
+ // Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
2586
+ idempotencyKey: `mcp-create-customer-group-${Date.now()}-${(0, import_node_crypto.randomUUID)()}`
2587
+ }),
2588
+ // A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
2589
+ update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
2590
+ body: {
2591
+ name: args.name,
2592
+ kind: args.kind,
2593
+ percentBps: args.percentBps,
2594
+ enabled: args.enabled,
2595
+ taxExempt: args.taxExempt,
2596
+ taxExemptReason: args.taxExemptReason
2597
+ }
2598
+ }),
2599
+ delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
2600
+ add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
2601
+ body: { customerIds: args.customerIds },
2602
+ idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${(0, import_node_crypto.randomUUID)()}`
2603
+ }),
2604
+ remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
2605
+ body: { customerIds: args.customerIds },
2606
+ idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${(0, import_node_crypto.randomUUID)()}`
2607
+ }),
2463
2608
  create_checkout_link: async (ctx, args) => {
2464
2609
  const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
2465
2610
  if (lineItems.length === 0) {
@@ -3540,6 +3685,20 @@ var FULFILLMENT2 = {
3540
3685
  detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
3541
3686
  };
3542
3687
  var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
3688
+ var CUSTOMER_GROUP = {
3689
+ id: S,
3690
+ name: T,
3691
+ kind: S,
3692
+ percentBps: S,
3693
+ enabled: S,
3694
+ taxExempt: S,
3695
+ taxExemptReason: T,
3696
+ version: S,
3697
+ memberCount: S,
3698
+ discountCount: S,
3699
+ createdAt: S,
3700
+ updatedAt: S
3701
+ };
3543
3702
  var SUBSCRIPTION2 = {
3544
3703
  id: S,
3545
3704
  status: S,
@@ -3745,6 +3904,9 @@ var OAUTH_PROJECTIONS = {
3745
3904
  addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
3746
3905
  subscriptions: section([SUBSCRIPTION2])
3747
3906
  },
3907
+ // Group names are merchant-written (T); the rest is Throttle-generated.
3908
+ list_customer_groups: [CUSTOMER_GROUP],
3909
+ get_customer_group: CUSTOMER_GROUP,
3748
3910
  list_subscriptions: page3(SUBSCRIPTION2),
3749
3911
  get_subscription: SUBSCRIPTION2,
3750
3912
  search_quotes: page3(QUOTE_SUMMARY2),
@@ -4005,7 +4167,7 @@ var OAUTH_PROJECTIONS = {
4005
4167
  };
4006
4168
 
4007
4169
  // src/server.ts
4008
- var VERSION = true ? "0.6.0" : "0.0.0-dev";
4170
+ var VERSION = true ? "0.8.0" : "0.0.0-dev";
4009
4171
  function registerableActions(policy) {
4010
4172
  const isProduction = policy.identity.environment.providerEnvironment === "production";
4011
4173
  return actionsForChannel("mcp").filter((action) => {