@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.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
@@ -45,6 +45,7 @@ function add(group, resource, actions, labels, opts = {}) {
45
45
  }
46
46
  add("Orders", "orders", ["read", "write"], { read: "View orders", write: "Manage orders" });
47
47
  add("Quotes", "quotes", ["read", "write"], { read: "View quotes", write: "Manage quotes" });
48
+ add("Forms", "forms", ["read", "write"], { read: "View site forms and their submissions", write: "Manage site forms" }, { sensitive: true });
48
49
  add("Orders", "order_cancellations", ["write"], { write: "Cancel orders" });
49
50
  add("Orders", "order_returns", ["read", "write"], { read: "View returns", write: "Process returns" });
50
51
  add("Orders", "order_comps", ["write"], { write: "Comp orders (write off the balance)" }, { sensitive: true });
@@ -70,6 +71,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
70
71
  add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
71
72
  add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
72
73
  add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
74
+ add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
75
+ REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
73
76
  add(
74
77
  "Customer accounts",
75
78
  "customer_accounts",
@@ -129,6 +132,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
129
132
  add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
130
133
  add("Webhooks & Events", "events", ["read"], { read: "View events" });
131
134
  add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
135
+ add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
132
136
  add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
133
137
  add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
134
138
  add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
@@ -210,8 +214,10 @@ var PREFIX_RULES = [
210
214
  ["cart.", "carts:read"],
211
215
  ["order.", "orders:read"],
212
216
  ["quote.", "quotes:read"],
217
+ ["form.", "forms:read"],
213
218
  ["return.", "order_returns:read"],
214
219
  ["payment.", "payments:read"],
220
+ ["customer_group.", "customer_groups:read"],
215
221
  ["customer.", "customers:read"],
216
222
  ["subscription.", "subscriptions:read"],
217
223
  ["fulfillment.", "fulfillments:read"],
@@ -1451,6 +1457,103 @@ var ACTIONS = [
1451
1457
  "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
1458
  ]
1453
1459
  },
1460
+ // ------------------------------------------------------------ customer groups
1461
+ {
1462
+ id: "list_customer_groups",
1463
+ title: "List customer groups",
1464
+ 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.",
1465
+ kind: "read",
1466
+ scopes: ["customer_groups:read"],
1467
+ input: [],
1468
+ requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
1469
+ channels: ["mcp"]
1470
+ },
1471
+ {
1472
+ id: "get_customer_group",
1473
+ title: "Get a customer group",
1474
+ description: "Fetch one customer group by id.",
1475
+ kind: "read",
1476
+ scopes: ["customer_groups:read"],
1477
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1478
+ requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
1479
+ channels: ["mcp"]
1480
+ },
1481
+ {
1482
+ id: "create_customer_group",
1483
+ title: "Create a customer group",
1484
+ 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.",
1485
+ kind: "write",
1486
+ scopes: ["customer_groups:write"],
1487
+ input: [
1488
+ { name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
1489
+ { name: "kind", type: "string", required: true, description: "fixed or percent." },
1490
+ { name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
1491
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true },
1492
+ { name: "taxExempt", type: "boolean", required: false, description: "Members are exempt from tax. Needs taxExemptReason.", default: false },
1493
+ { name: "taxExemptReason", type: "string", required: false, description: "Avalara entity-use code (A-R) that explains the exemption. Required when taxExempt is true." }
1494
+ ],
1495
+ requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
1496
+ channels: ["mcp"],
1497
+ idempotent: true
1498
+ },
1499
+ {
1500
+ id: "update_customer_group",
1501
+ title: "Update a customer group",
1502
+ description: "Change fields on a customer group. Only the fields supplied are touched.",
1503
+ kind: "write",
1504
+ scopes: ["customer_groups:write"],
1505
+ input: [
1506
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1507
+ { name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
1508
+ { name: "kind", type: "string", required: false, description: "fixed or percent." },
1509
+ { 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)." },
1510
+ { name: "enabled", type: "boolean", required: false, description: "Whether the group is active." },
1511
+ { name: "taxExempt", type: "boolean", required: false, description: "Members are exempt from tax. Needs taxExemptReason." },
1512
+ { name: "taxExemptReason", type: "string", required: false, description: "Avalara entity-use code (A-R). Set null to clear when taxExempt is false." }
1513
+ ],
1514
+ requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
1515
+ channels: ["mcp"],
1516
+ idempotent: true
1517
+ },
1518
+ {
1519
+ id: "delete_customer_group",
1520
+ title: "Delete a customer group",
1521
+ description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
1522
+ kind: "write",
1523
+ scopes: ["customer_groups:write"],
1524
+ input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
1525
+ requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
1526
+ channels: ["mcp"],
1527
+ idempotent: true
1528
+ },
1529
+ {
1530
+ id: "add_customer_group_members",
1531
+ title: "Add customers to a group",
1532
+ description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
1533
+ kind: "write",
1534
+ scopes: ["customer_groups:write"],
1535
+ input: [
1536
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1537
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1538
+ ],
1539
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
1540
+ channels: ["mcp"],
1541
+ idempotent: true
1542
+ },
1543
+ {
1544
+ id: "remove_customer_group_members",
1545
+ title: "Remove customers from a group",
1546
+ description: "Remove up to 100 customers from a group; the response counts removed.",
1547
+ kind: "write",
1548
+ scopes: ["customer_groups:write"],
1549
+ input: [
1550
+ { name: "id", type: "string", required: true, description: "Customer group id." },
1551
+ { name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
1552
+ ],
1553
+ requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
1554
+ channels: ["mcp"],
1555
+ idempotent: true
1556
+ },
1454
1557
  {
1455
1558
  id: "create_checkout_link",
1456
1559
  title: "Create a checkout link",
@@ -1773,6 +1876,9 @@ details: ${JSON.stringify(e.details)}` : "";
1773
1876
  return `Error: ${e?.message ?? String(error)}`;
1774
1877
  }
1775
1878
 
1879
+ // src/handlers.ts
1880
+ import { randomUUID } from "crypto";
1881
+
1776
1882
  // ../errors/dist/index.js
1777
1883
  var ThrottleError = class extends Error {
1778
1884
  code;
@@ -1888,6 +1994,10 @@ var ThrottleClient = class {
1888
1994
  const body = await this.requestJson("PATCH", path, options);
1889
1995
  return body && typeof body === "object" && "data" in body ? body.data : body;
1890
1996
  }
1997
+ async delete(path, options = {}) {
1998
+ const body = await this.requestJson("DELETE", path, options);
1999
+ return body && typeof body === "object" && "data" in body ? body.data : body;
2000
+ }
1891
2001
  };
1892
2002
  async function optional(load) {
1893
2003
  try {
@@ -2423,6 +2533,41 @@ var HANDLERS = {
2423
2533
  },
2424
2534
  idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
2425
2535
  }),
2536
+ // ----------------------------------------------------------- customer groups
2537
+ list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
2538
+ get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
2539
+ create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
2540
+ body: {
2541
+ name: args.name,
2542
+ kind: args.kind,
2543
+ percentBps: args.percentBps,
2544
+ enabled: args.enabled,
2545
+ taxExempt: args.taxExempt,
2546
+ taxExemptReason: args.taxExemptReason
2547
+ },
2548
+ // Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
2549
+ idempotencyKey: `mcp-create-customer-group-${Date.now()}-${randomUUID()}`
2550
+ }),
2551
+ // A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
2552
+ update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
2553
+ body: {
2554
+ name: args.name,
2555
+ kind: args.kind,
2556
+ percentBps: args.percentBps,
2557
+ enabled: args.enabled,
2558
+ taxExempt: args.taxExempt,
2559
+ taxExemptReason: args.taxExemptReason
2560
+ }
2561
+ }),
2562
+ delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
2563
+ add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
2564
+ body: { customerIds: args.customerIds },
2565
+ idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${randomUUID()}`
2566
+ }),
2567
+ remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
2568
+ body: { customerIds: args.customerIds },
2569
+ idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${randomUUID()}`
2570
+ }),
2426
2571
  create_checkout_link: async (ctx, args) => {
2427
2572
  const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
2428
2573
  if (lineItems.length === 0) {
@@ -3503,6 +3648,20 @@ var FULFILLMENT2 = {
3503
3648
  detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
3504
3649
  };
3505
3650
  var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
3651
+ var CUSTOMER_GROUP = {
3652
+ id: S,
3653
+ name: T,
3654
+ kind: S,
3655
+ percentBps: S,
3656
+ enabled: S,
3657
+ taxExempt: S,
3658
+ taxExemptReason: T,
3659
+ version: S,
3660
+ memberCount: S,
3661
+ discountCount: S,
3662
+ createdAt: S,
3663
+ updatedAt: S
3664
+ };
3506
3665
  var SUBSCRIPTION2 = {
3507
3666
  id: S,
3508
3667
  status: S,
@@ -3708,6 +3867,9 @@ var OAUTH_PROJECTIONS = {
3708
3867
  addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
3709
3868
  subscriptions: section([SUBSCRIPTION2])
3710
3869
  },
3870
+ // Group names are merchant-written (T); the rest is Throttle-generated.
3871
+ list_customer_groups: [CUSTOMER_GROUP],
3872
+ get_customer_group: CUSTOMER_GROUP,
3711
3873
  list_subscriptions: page3(SUBSCRIPTION2),
3712
3874
  get_subscription: SUBSCRIPTION2,
3713
3875
  search_quotes: page3(QUOTE_SUMMARY2),
@@ -3968,7 +4130,7 @@ var OAUTH_PROJECTIONS = {
3968
4130
  };
3969
4131
 
3970
4132
  // src/server.ts
3971
- var VERSION = true ? "0.6.0" : "0.0.0-dev";
4133
+ var VERSION = true ? "0.8.0" : "0.0.0-dev";
3972
4134
  function registerableActions(policy) {
3973
4135
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3974
4136
  return actionsForChannel("mcp").filter((action) => {