@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/lib.d.cts CHANGED
@@ -60,6 +60,7 @@ declare class ThrottleClient {
60
60
  list<T>(path: string, query?: Record<string, unknown>, options?: PerCallOptions): Promise<ListResult<T>>;
61
61
  post<T>(path: string, options?: RequestOptions): Promise<T>;
62
62
  patch<T>(path: string, options?: RequestOptions): Promise<T>;
63
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
63
64
  }
64
65
 
65
66
  /**
package/dist/lib.d.ts CHANGED
@@ -60,6 +60,7 @@ declare class ThrottleClient {
60
60
  list<T>(path: string, query?: Record<string, unknown>, options?: PerCallOptions): Promise<ListResult<T>>;
61
61
  post<T>(path: string, options?: RequestOptions): Promise<T>;
62
62
  patch<T>(path: string, options?: RequestOptions): Promise<T>;
63
+ delete<T>(path: string, options?: RequestOptions): Promise<T>;
63
64
  }
64
65
 
65
66
  /**
package/dist/lib.js CHANGED
@@ -70,6 +70,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
70
70
  add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
71
71
  add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
72
72
  add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
73
+ add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
74
+ REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
73
75
  add(
74
76
  "Customer accounts",
75
77
  "customer_accounts",
@@ -129,6 +131,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
129
131
  add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
130
132
  add("Webhooks & Events", "events", ["read"], { read: "View events" });
131
133
  add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
134
+ add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
132
135
  add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
133
136
  add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
134
137
  add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
@@ -212,6 +215,7 @@ var PREFIX_RULES = [
212
215
  ["quote.", "quotes:read"],
213
216
  ["return.", "order_returns:read"],
214
217
  ["payment.", "payments:read"],
218
+ ["customer_group.", "customer_groups:read"],
215
219
  ["customer.", "customers:read"],
216
220
  ["subscription.", "subscriptions:read"],
217
221
  ["fulfillment.", "fulfillments:read"],
@@ -1451,6 +1455,99 @@ var ACTIONS = [
1451
1455
  "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."
1452
1456
  ]
1453
1457
  },
1458
+ // ------------------------------------------------------------ customer groups
1459
+ {
1460
+ id: "list_customer_groups",
1461
+ title: "List customer groups",
1462
+ 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.",
1463
+ kind: "read",
1464
+ scopes: ["customer_groups:read"],
1465
+ input: [],
1466
+ requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
1467
+ channels: ["mcp"]
1468
+ },
1469
+ {
1470
+ id: "get_customer_group",
1471
+ title: "Get a customer group",
1472
+ description: "Fetch one customer group by id.",
1473
+ kind: "read",
1474
+ scopes: ["customer_groups:read"],
1475
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1476
+ requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
1477
+ channels: ["mcp"]
1478
+ },
1479
+ {
1480
+ id: "create_customer_group",
1481
+ title: "Create a customer group",
1482
+ 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.",
1483
+ kind: "write",
1484
+ scopes: ["customer_groups:write"],
1485
+ input: [
1486
+ { name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
1487
+ { name: "kind", type: "string", required: true, description: "fixed or percent." },
1488
+ { name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
1489
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true }
1490
+ ],
1491
+ requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
1492
+ channels: ["mcp"],
1493
+ idempotent: true
1494
+ },
1495
+ {
1496
+ id: "update_customer_group",
1497
+ title: "Update a customer group",
1498
+ description: "Change fields on a customer group. Only the fields supplied are touched.",
1499
+ kind: "write",
1500
+ scopes: ["customer_groups:write"],
1501
+ input: [
1502
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1503
+ { name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
1504
+ { name: "kind", type: "string", required: false, description: "fixed or percent." },
1505
+ { 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)." },
1506
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active." }
1507
+ ],
1508
+ requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
1509
+ channels: ["mcp"],
1510
+ idempotent: true
1511
+ },
1512
+ {
1513
+ id: "delete_customer_group",
1514
+ title: "Delete a customer group",
1515
+ description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
1516
+ kind: "write",
1517
+ scopes: ["customer_groups:write"],
1518
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1519
+ requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
1520
+ channels: ["mcp"],
1521
+ idempotent: true
1522
+ },
1523
+ {
1524
+ id: "add_customer_group_members",
1525
+ title: "Add customers to a group",
1526
+ description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
1527
+ kind: "write",
1528
+ scopes: ["customer_groups:write"],
1529
+ input: [
1530
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1531
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1532
+ ],
1533
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
1534
+ channels: ["mcp"],
1535
+ idempotent: true
1536
+ },
1537
+ {
1538
+ id: "remove_customer_group_members",
1539
+ title: "Remove customers from a group",
1540
+ description: "Remove up to 100 customers from a group; the response counts removed.",
1541
+ kind: "write",
1542
+ scopes: ["customer_groups:write"],
1543
+ input: [
1544
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1545
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1546
+ ],
1547
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
1548
+ channels: ["mcp"],
1549
+ idempotent: true
1550
+ },
1454
1551
  {
1455
1552
  id: "create_checkout_link",
1456
1553
  title: "Create a checkout link",
@@ -1773,6 +1870,9 @@ details: ${JSON.stringify(e.details)}` : "";
1773
1870
  return `Error: ${e?.message ?? String(error)}`;
1774
1871
  }
1775
1872
 
1873
+ // src/handlers.ts
1874
+ import { randomUUID } from "crypto";
1875
+
1776
1876
  // ../errors/dist/index.js
1777
1877
  var ThrottleError = class extends Error {
1778
1878
  code;
@@ -1888,6 +1988,10 @@ var ThrottleClient = class {
1888
1988
  const body = await this.requestJson("PATCH", path, options);
1889
1989
  return body && typeof body === "object" && "data" in body ? body.data : body;
1890
1990
  }
1991
+ async delete(path, options = {}) {
1992
+ const body = await this.requestJson("DELETE", path, options);
1993
+ return body && typeof body === "object" && "data" in body ? body.data : body;
1994
+ }
1891
1995
  };
1892
1996
  async function optional(load) {
1893
1997
  try {
@@ -2423,6 +2527,27 @@ var HANDLERS = {
2423
2527
  },
2424
2528
  idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
2425
2529
  }),
2530
+ // ----------------------------------------------------------- customer groups
2531
+ list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
2532
+ get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
2533
+ create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
2534
+ body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled },
2535
+ // Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
2536
+ idempotencyKey: `mcp-create-customer-group-${Date.now()}-${randomUUID()}`
2537
+ }),
2538
+ // A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
2539
+ update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
2540
+ body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled }
2541
+ }),
2542
+ delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
2543
+ add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
2544
+ body: { customerIds: args.customerIds },
2545
+ idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${randomUUID()}`
2546
+ }),
2547
+ remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
2548
+ body: { customerIds: args.customerIds },
2549
+ idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${randomUUID()}`
2550
+ }),
2426
2551
  create_checkout_link: async (ctx, args) => {
2427
2552
  const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
2428
2553
  if (lineItems.length === 0) {
@@ -3503,6 +3628,18 @@ var FULFILLMENT2 = {
3503
3628
  detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
3504
3629
  };
3505
3630
  var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
3631
+ var CUSTOMER_GROUP = {
3632
+ id: S,
3633
+ name: T,
3634
+ kind: S,
3635
+ percentBps: S,
3636
+ enabled: S,
3637
+ version: S,
3638
+ memberCount: S,
3639
+ discountCount: S,
3640
+ createdAt: S,
3641
+ updatedAt: S
3642
+ };
3506
3643
  var SUBSCRIPTION2 = {
3507
3644
  id: S,
3508
3645
  status: S,
@@ -3708,6 +3845,9 @@ var OAUTH_PROJECTIONS = {
3708
3845
  addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
3709
3846
  subscriptions: section([SUBSCRIPTION2])
3710
3847
  },
3848
+ // Group names are merchant-written (T); the rest is Throttle-generated.
3849
+ list_customer_groups: [CUSTOMER_GROUP],
3850
+ get_customer_group: CUSTOMER_GROUP,
3711
3851
  list_subscriptions: page3(SUBSCRIPTION2),
3712
3852
  get_subscription: SUBSCRIPTION2,
3713
3853
  search_quotes: page3(QUOTE_SUMMARY2),
@@ -3968,7 +4108,7 @@ var OAUTH_PROJECTIONS = {
3968
4108
  };
3969
4109
 
3970
4110
  // src/server.ts
3971
- var VERSION = true ? "0.6.0" : "0.0.0-dev";
4111
+ var VERSION = true ? "0.7.0" : "0.0.0-dev";
3972
4112
  function registerableActions(policy) {
3973
4113
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3974
4114
  return actionsForChannel("mcp").filter((action) => {