@usethrottle/mcp 0.2.0 → 0.2.1
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/README.md +9 -2
- package/dist/contract-index.json +1 -1
- package/dist/docs-index.json +1 -1
- package/dist/lib.cjs +1776 -150
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.d.cts +58 -4
- package/dist/lib.d.ts +58 -4
- package/dist/lib.js +1776 -150
- package/dist/lib.js.map +1 -1
- package/dist/mcp.js +1776 -150
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(lib_exports);
|
|
|
32
32
|
|
|
33
33
|
// src/server.ts
|
|
34
34
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
35
|
+
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
35
36
|
|
|
36
37
|
// ../core-scopes/src/scopes.ts
|
|
37
38
|
function hasScope(granted, required) {
|
|
@@ -60,6 +61,8 @@ function add(group, resource, actions, labels, opts = {}) {
|
|
|
60
61
|
staffOnly: opts.staffOnly ?? false,
|
|
61
62
|
// publishable defaults false; only the curated set below is true
|
|
62
63
|
publishableAllowed: opts.publishableAllowed ?? false,
|
|
64
|
+
// publishableOnly defaults false; only customer_accounts:write sets it
|
|
65
|
+
publishableOnly: opts.publishableOnly ?? false,
|
|
63
66
|
// extension default true for commerce scopes; Taxonomy B passes false
|
|
64
67
|
extensionAllowed: opts.extensionAllowed ?? true,
|
|
65
68
|
implies
|
|
@@ -70,19 +73,36 @@ add("Orders", "orders", ["read", "write"], { read: "View orders", write: "Manage
|
|
|
70
73
|
add("Quotes", "quotes", ["read", "write"], { read: "View quotes", write: "Manage quotes" });
|
|
71
74
|
add("Orders", "order_cancellations", ["write"], { write: "Cancel orders" });
|
|
72
75
|
add("Orders", "order_returns", ["read", "write"], { read: "View returns", write: "Process returns" });
|
|
76
|
+
add("Orders", "order_comps", ["write"], { write: "Comp orders (write off the balance)" }, { sensitive: true });
|
|
77
|
+
add("Orders", "order_holds", ["write"], { write: "Freeze and unfreeze orders" });
|
|
78
|
+
add(
|
|
79
|
+
"Imports",
|
|
80
|
+
"imports",
|
|
81
|
+
["read", "write"],
|
|
82
|
+
{ read: "View data imports", write: "Run and undo data imports" },
|
|
83
|
+
{ extensionAllowed: false }
|
|
84
|
+
);
|
|
73
85
|
add("Payments", "payments", ["read", "write"], { read: "View payments", write: "Create payments" });
|
|
74
86
|
add("Payments", "payment_authorizations", ["write"], { write: "Authorize payments" });
|
|
75
87
|
add("Payments", "payment_captures", ["write"], { write: "Capture payments" });
|
|
76
88
|
add("Payments", "payment_refunds", ["read", "write"], { read: "View refunds", write: "Refund payments" }, { sensitive: true });
|
|
77
89
|
add("Payments", "payment_voids", ["write"], { write: "Void payments" }, { sensitive: true });
|
|
90
|
+
add("Payments", "payment_records", ["write"], { write: "Record payments received outside Throttle" }, { sensitive: true });
|
|
78
91
|
add("Payments", "payment_disputes", ["read", "write"], { read: "View disputes", write: "Handle disputes" }, { sensitive: true });
|
|
79
92
|
add("Payments", "payment_methods", ["read", "write"], { read: "View payment methods", write: "Tokenize payment methods" }, { sensitive: true });
|
|
80
93
|
add("Customers", "customers", ["read", "write"], { read: "View customers", write: "Manage customers" });
|
|
81
94
|
add("Customers", "customer_pii", ["read"], { read: "View customer PII" }, { sensitive: true });
|
|
82
95
|
add("Customers", "customer_addresses", ["read", "write"], { read: "View addresses", write: "Manage addresses" });
|
|
83
96
|
add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
|
|
97
|
+
add(
|
|
98
|
+
"Customer accounts",
|
|
99
|
+
"customer_accounts",
|
|
100
|
+
["write"],
|
|
101
|
+
{ write: "Let shoppers register, sign in and manage their account" },
|
|
102
|
+
{ publishableAllowed: true, publishableOnly: true, extensionAllowed: false }
|
|
103
|
+
);
|
|
84
104
|
add("Carts", "carts", ["read", "write"], { read: "View carts", write: "Manage carts" });
|
|
85
|
-
add("Carts", "cart_items", ["
|
|
105
|
+
add("Carts", "cart_items", ["write"], { write: "Manage line items" });
|
|
86
106
|
add("Carts", "checkout_sessions", ["read", "write"], { read: "View checkout sessions", write: "Manage checkout sessions" });
|
|
87
107
|
add("Discounts", "discounts", ["read", "write"], { read: "View discounts", write: "Manage discounts" });
|
|
88
108
|
add("Subscriptions", "subscriptions", ["read", "write"], { read: "View subscriptions", write: "Manage subscriptions" });
|
|
@@ -103,8 +123,32 @@ add("Shipping & Tax", "shipping_quotes", ["write"], { write: "Request shipping q
|
|
|
103
123
|
add("Shipping & Tax", "tax_calculations", ["write"], { write: "Calculate tax" }, { publishableAllowed: true });
|
|
104
124
|
add("Shipping & Tax", "shipping_tax_quote_tokens", ["read", "write"], { read: "View quote tokens", write: "Manage quote tokens" });
|
|
105
125
|
add("Shipping & Tax", "shipping_tax_snapshots", ["write"], { write: "Accept external snapshots" });
|
|
126
|
+
add(
|
|
127
|
+
"Scripts",
|
|
128
|
+
"storefront_scripts",
|
|
129
|
+
["read", "write"],
|
|
130
|
+
{
|
|
131
|
+
read: "Load storefront scripts",
|
|
132
|
+
// `write` covers exactly one thing: reporting a script's own load outcome
|
|
133
|
+
// from the merchant's storefront, so the health panel stops being
|
|
134
|
+
// hosted-checkout-only. On checkout the session id in the URL is the
|
|
135
|
+
// capability that scopes that write; a storefront page has no session, so
|
|
136
|
+
// the pk it already holds is what scopes it instead. It writes nothing but
|
|
137
|
+
// load telemetry — authoring stays on `application_scripts:write`, which
|
|
138
|
+
// is not publishable-allowed.
|
|
139
|
+
write: "Report storefront script load outcomes"
|
|
140
|
+
},
|
|
141
|
+
{ publishableAllowed: true }
|
|
142
|
+
);
|
|
143
|
+
add("Scripts", "application_scripts", ["read", "write"], {
|
|
144
|
+
read: "View merchant-authored scripts",
|
|
145
|
+
write: "Create, edit and disable merchant-authored scripts"
|
|
146
|
+
}, { extensionAllowed: false });
|
|
147
|
+
add("Scripts", "extension_scripts", ["read", "write"], {
|
|
148
|
+
read: "View an extension's buyer-facing scripts",
|
|
149
|
+
write: "Create, edit and delete an extension's buyer-facing scripts"
|
|
150
|
+
}, { extensionAllowed: false });
|
|
106
151
|
add("Connectors", "connectors", ["read", "write"], { read: "View connectors", write: "Manage connectors" });
|
|
107
|
-
add("Connectors", "connector_activations", ["write"], { write: "Activate/deactivate connectors" });
|
|
108
152
|
add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks", write: "Manage webhooks" });
|
|
109
153
|
add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
|
|
110
154
|
add("Webhooks & Events", "events", ["read"], { read: "View events" });
|
|
@@ -120,7 +164,7 @@ add("Platform billing", "billing", ["read", "write"], { read: "View billing", wr
|
|
|
120
164
|
add("Platform billing", "billing_payment_methods", ["read", "write"], { read: "View billing cards", write: "Manage billing cards" }, HUMAN);
|
|
121
165
|
add("Email", "email_templates", ["read", "write"], { read: "View email templates", write: "Edit email templates" }, HUMAN);
|
|
122
166
|
add("Email", "email_settings", ["read", "write"], { read: "View email settings", write: "Edit email settings" }, HUMAN);
|
|
123
|
-
add("Go-live", "go_live", ["
|
|
167
|
+
add("Go-live", "go_live", ["write"], { write: "Submit go-live" }, HUMAN);
|
|
124
168
|
add("Partner", "partner", ["read", "write"], { read: "View partner profile", write: "Edit partner profile" }, HUMAN);
|
|
125
169
|
add("Partner", "affiliates", ["read", "write"], { read: "View affiliates", write: "Manage affiliates" }, HUMAN);
|
|
126
170
|
add("Notifications", "notifications", ["write"], { write: "Send notifications" }, HUMAN);
|
|
@@ -144,6 +188,7 @@ REG["extensions:install"] = {
|
|
|
144
188
|
sensitive: false,
|
|
145
189
|
staffOnly: false,
|
|
146
190
|
publishableAllowed: false,
|
|
191
|
+
publishableOnly: false,
|
|
147
192
|
extensionAllowed: false,
|
|
148
193
|
implies: []
|
|
149
194
|
};
|
|
@@ -156,6 +201,7 @@ REG["*"] = {
|
|
|
156
201
|
sensitive: true,
|
|
157
202
|
staffOnly: false,
|
|
158
203
|
publishableAllowed: false,
|
|
204
|
+
publishableOnly: false,
|
|
159
205
|
extensionAllowed: false,
|
|
160
206
|
implies: []
|
|
161
207
|
};
|
|
@@ -175,6 +221,9 @@ var EVENT_SCOPE_OVERRIDES = {
|
|
|
175
221
|
"payment.refunded": "payment_refunds:read",
|
|
176
222
|
"payment.partially_refunded": "payment_refunds:read",
|
|
177
223
|
"payment.refund_failed": "payment_refunds:read",
|
|
224
|
+
// Money returned, so it belongs with the other refund events rather than
|
|
225
|
+
// behind the broad subscriptions:read the `subscription.` prefix would give.
|
|
226
|
+
"subscription.invoice_refunded": "payment_refunds:read",
|
|
178
227
|
"payment.disputed": "payment_disputes:read",
|
|
179
228
|
"payment.dispute_cleared": "payment_disputes:read",
|
|
180
229
|
"fulfillment.digital.delivered": "fulfillment_digital:read"
|
|
@@ -191,9 +240,17 @@ var PREFIX_RULES = [
|
|
|
191
240
|
["fulfillment.", "fulfillments:read"],
|
|
192
241
|
["discount.", "discounts:read"],
|
|
193
242
|
["invoice.", "invoices:read"],
|
|
243
|
+
["import.", "imports:read"],
|
|
194
244
|
["shipping_tax.", "shipping_tax:read"],
|
|
195
245
|
["workspace.", "billing:read"],
|
|
196
|
-
|
|
246
|
+
// `extensions:read` is a human scope (extensions must never watch other
|
|
247
|
+
// extensions), so only a workspace endpoint can SUBSCRIBE to this family.
|
|
248
|
+
// The uninstalled installation's own endpoint is addressed directly by the
|
|
249
|
+
// uninstall path and needs no subscription at all.
|
|
250
|
+
["extension.", "extensions:read"],
|
|
251
|
+
// Subscribing to script outcomes needs script read — the payload names the
|
|
252
|
+
// script key and its hash, which is the merchant's script inventory.
|
|
253
|
+
["script.", "application_scripts:read"]
|
|
197
254
|
];
|
|
198
255
|
function eventReadScope(type) {
|
|
199
256
|
if (EVENT_SCOPE_OVERRIDES[type]) return EVENT_SCOPE_OVERRIDES[type];
|
|
@@ -205,8 +262,90 @@ function eventReadScope(type) {
|
|
|
205
262
|
|
|
206
263
|
// ../core-scopes/src/issuance.ts
|
|
207
264
|
var PUBLISHABLE_SCOPES = Object.values(SCOPE_REGISTRY).filter((d) => d.publishableAllowed).map((d) => d.id);
|
|
265
|
+
var CONNECTOR_GRANTABLE_SENSITIVE_SCOPES = ["customer_pii:read"];
|
|
266
|
+
function validateScopesForOAuth(scopes, opts = {}) {
|
|
267
|
+
const invalid = [];
|
|
268
|
+
for (const id of scopes) {
|
|
269
|
+
if (id === "*") {
|
|
270
|
+
invalid.push(id);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const def = SCOPE_REGISTRY[id];
|
|
274
|
+
if (!def || def.staffOnly) {
|
|
275
|
+
invalid.push(id);
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (def.sensitive && !(opts.connector && CONNECTOR_GRANTABLE_SENSITIVE_SCOPES.includes(id))) invalid.push(id);
|
|
279
|
+
}
|
|
280
|
+
return { ok: invalid.length === 0, invalid };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// ../core-scopes/src/shopper-pii.ts
|
|
284
|
+
var PERSON_KEYS = /* @__PURE__ */ new Set([
|
|
285
|
+
"email",
|
|
286
|
+
"customerEmail",
|
|
287
|
+
"billingEmail",
|
|
288
|
+
"buyerEmail",
|
|
289
|
+
"authorEmail",
|
|
290
|
+
"authorName",
|
|
291
|
+
"phone",
|
|
292
|
+
"firstName",
|
|
293
|
+
"lastName",
|
|
294
|
+
"addressLine1",
|
|
295
|
+
"addressLine2",
|
|
296
|
+
"billingAddressLines",
|
|
297
|
+
"processorResponse",
|
|
298
|
+
"shareToken",
|
|
299
|
+
"company",
|
|
300
|
+
"externalId",
|
|
301
|
+
"externalCustomerId",
|
|
302
|
+
// Free-form: contents cannot be inspected for a person, so the field goes.
|
|
303
|
+
"metadata",
|
|
304
|
+
"notes",
|
|
305
|
+
"internalNotes",
|
|
306
|
+
"buyerNote",
|
|
307
|
+
"buyerReference",
|
|
308
|
+
"changeSummary",
|
|
309
|
+
"declinedReason",
|
|
310
|
+
"compReason",
|
|
311
|
+
"holdReason",
|
|
312
|
+
"body",
|
|
313
|
+
"acceptance",
|
|
314
|
+
"acceptanceSelections",
|
|
315
|
+
"clientContext",
|
|
316
|
+
"ipAddress",
|
|
317
|
+
"userAgent",
|
|
318
|
+
"vatNumber",
|
|
319
|
+
"buyerVatNumber",
|
|
320
|
+
"taxExemptionNumber"
|
|
321
|
+
]);
|
|
322
|
+
var PERSON_CONTAINERS = /* @__PURE__ */ new Set(["customer", "buyer"]);
|
|
323
|
+
function isPlainObject(value) {
|
|
324
|
+
if (value === null || typeof value !== "object") return false;
|
|
325
|
+
const proto = Object.getPrototypeOf(value);
|
|
326
|
+
return proto === Object.prototype || proto === null;
|
|
327
|
+
}
|
|
328
|
+
function walk(value, parentKey, depth) {
|
|
329
|
+
if (depth > 32) return value;
|
|
330
|
+
if (Array.isArray(value)) return value.map((item) => walk(item, parentKey, depth + 1));
|
|
331
|
+
if (!isPlainObject(value)) return value;
|
|
332
|
+
const out = {};
|
|
333
|
+
const isPerson = parentKey !== null && PERSON_CONTAINERS.has(parentKey);
|
|
334
|
+
for (const [key, child] of Object.entries(value)) {
|
|
335
|
+
if (PERSON_KEYS.has(key) || isPerson && key === "name") {
|
|
336
|
+
out[key] = child === void 0 ? child : null;
|
|
337
|
+
} else {
|
|
338
|
+
out[key] = walk(child, key, depth + 1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return out;
|
|
342
|
+
}
|
|
343
|
+
function redactShopperPii(value) {
|
|
344
|
+
return walk(value, null, 0);
|
|
345
|
+
}
|
|
208
346
|
|
|
209
347
|
// ../action-catalog/src/actions.ts
|
|
348
|
+
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.";
|
|
210
349
|
var ACTIONS = [
|
|
211
350
|
// ---------------------------------------------------------------- identity
|
|
212
351
|
{
|
|
@@ -223,7 +362,7 @@ var ACTIONS = [
|
|
|
223
362
|
{
|
|
224
363
|
id: "search_docs",
|
|
225
364
|
title: "Search the Throttle developer docs",
|
|
226
|
-
description: "Full-text search over the Throttle developer documentation. Returns titles, canonical
|
|
365
|
+
description: "Full-text search over the Throttle developer documentation. Returns titles, canonical usethrottle.dev/docs URLs, and matching excerpts. Prefer this over recalling API details from memory.",
|
|
227
366
|
kind: "read",
|
|
228
367
|
scopes: [],
|
|
229
368
|
input: [
|
|
@@ -260,7 +399,7 @@ var ACTIONS = [
|
|
|
260
399
|
{
|
|
261
400
|
id: "validate_payload",
|
|
262
401
|
title: "Validate a request body against the API contract",
|
|
263
|
-
description: "Check a request body against the published contract before sending it. Names every unsupported field and gives its canonical replacement \u2014 Throttle is strict camelCase and rejects retired aliases such as line_items, unit_price, customer_id and storeId.",
|
|
402
|
+
description: "Check a request body against the published contract before sending it. Names every unsupported field and gives its canonical replacement \u2014 Throttle is strict camelCase and rejects retired aliases such as line_items, unit_price, customer_id and storeId. Full reference: https://usethrottle.dev/docs/developers/api-reference.",
|
|
264
403
|
kind: "read",
|
|
265
404
|
scopes: [],
|
|
266
405
|
input: [
|
|
@@ -275,15 +414,22 @@ var ACTIONS = [
|
|
|
275
414
|
{
|
|
276
415
|
id: "api_get",
|
|
277
416
|
title: "Read any Throttle API endpoint",
|
|
278
|
-
description: "Escape hatch for reads the curated tools do not cover: performs a GET against any /api/v1 path and returns the response. Cannot write. Confirm the path with describe_endpoint first if unsure.",
|
|
417
|
+
description: "Escape hatch for reads the curated tools do not cover: performs a GET against any /api/v1 path and returns the response. Cannot write. Confirm the path with describe_endpoint first if unsure. Full reference: https://usethrottle.dev/docs/developers/api-reference.",
|
|
279
418
|
kind: "read",
|
|
280
419
|
scopes: [],
|
|
420
|
+
credentialScoped: true,
|
|
281
421
|
input: [
|
|
282
422
|
{
|
|
283
423
|
name: "path",
|
|
284
424
|
type: "string",
|
|
285
425
|
required: true,
|
|
286
426
|
description: "Path beginning with /api/v1, query string included."
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "applicationId",
|
|
430
|
+
type: "string",
|
|
431
|
+
required: false,
|
|
432
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
287
433
|
}
|
|
288
434
|
],
|
|
289
435
|
requests: [],
|
|
@@ -305,11 +451,33 @@ var ACTIONS = [
|
|
|
305
451
|
{ name: "q", type: "string", required: false, description: "Free-text search." },
|
|
306
452
|
{ name: "status", type: "string", required: false, description: "Order status filter." },
|
|
307
453
|
{ name: "paymentStatus", type: "string", required: false, description: "Payment status filter." },
|
|
454
|
+
{
|
|
455
|
+
name: "createdAfter",
|
|
456
|
+
type: "string",
|
|
457
|
+
required: false,
|
|
458
|
+
description: "ISO 8601 lower bound on creation time, exclusive. For a single day, pass that day's midnight and the next day's midnight."
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
name: "createdBefore",
|
|
462
|
+
type: "string",
|
|
463
|
+
required: false,
|
|
464
|
+
description: "ISO 8601 upper bound on creation time, exclusive."
|
|
465
|
+
},
|
|
308
466
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
309
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
467
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
468
|
+
{
|
|
469
|
+
name: "applicationId",
|
|
470
|
+
type: "string",
|
|
471
|
+
required: false,
|
|
472
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
473
|
+
}
|
|
310
474
|
],
|
|
311
475
|
requests: [{ method: "GET", path: "/api/v1/orders" }],
|
|
312
|
-
channels: ["mcp", "zapier", "make", "n8n"]
|
|
476
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
477
|
+
guardrails: [
|
|
478
|
+
OAUTH_WITHHELD,
|
|
479
|
+
"Over an OAuth connection, q matches the order id, order number and status fields only."
|
|
480
|
+
]
|
|
313
481
|
},
|
|
314
482
|
{
|
|
315
483
|
id: "get_order",
|
|
@@ -317,7 +485,16 @@ var ACTIONS = [
|
|
|
317
485
|
description: "Full picture of a single order: the order itself plus its payments, returns and fulfillments in one response.",
|
|
318
486
|
kind: "read",
|
|
319
487
|
scopes: ["orders:read"],
|
|
320
|
-
|
|
488
|
+
sectionScopes: ["payments:read", "order_returns:read", "fulfillments:read"],
|
|
489
|
+
input: [
|
|
490
|
+
{ name: "id", type: "string", required: true, description: "Order id." },
|
|
491
|
+
{
|
|
492
|
+
name: "applicationId",
|
|
493
|
+
type: "string",
|
|
494
|
+
required: false,
|
|
495
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
496
|
+
}
|
|
497
|
+
],
|
|
321
498
|
requests: [
|
|
322
499
|
{ method: "GET", path: "/api/v1/orders/:id" },
|
|
323
500
|
{ method: "GET", path: "/api/v1/orders/:id/payments" },
|
|
@@ -326,23 +503,45 @@ var ACTIONS = [
|
|
|
326
503
|
],
|
|
327
504
|
channels: ["mcp"],
|
|
328
505
|
guardrails: [
|
|
329
|
-
"Sub-reads need their own scopes (payments:read, order_returns:read, fulfillments:read). Skip a section the credential cannot read and say so in the result rather than failing the whole call."
|
|
506
|
+
"Sub-reads need their own scopes (payments:read, order_returns:read, fulfillments:read). Skip a section the credential cannot read and say so in the result rather than failing the whole call.",
|
|
507
|
+
OAUTH_WITHHELD
|
|
330
508
|
]
|
|
331
509
|
},
|
|
332
510
|
// ---------------------------------------------------------------- customers
|
|
333
511
|
{
|
|
334
512
|
id: "search_customers",
|
|
335
513
|
title: "Search customers",
|
|
336
|
-
description: "Find customers by name, email or external id.",
|
|
514
|
+
description: "Find customers by name, email or external id, or list them by creation date. Over an OAuth connection (ChatGPT, Claude) text search is not available \u2014 list by date instead \u2014 because every field it could match is withheld there.",
|
|
337
515
|
kind: "read",
|
|
338
516
|
scopes: ["customers:read"],
|
|
339
517
|
input: [
|
|
340
518
|
{ name: "q", type: "string", required: false, description: "Free-text search." },
|
|
519
|
+
{
|
|
520
|
+
name: "createdAfter",
|
|
521
|
+
type: "string",
|
|
522
|
+
required: false,
|
|
523
|
+
description: "ISO 8601 lower bound on creation time, exclusive. For a single day, pass that day's midnight and the next day's midnight."
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: "createdBefore",
|
|
527
|
+
type: "string",
|
|
528
|
+
required: false,
|
|
529
|
+
description: "ISO 8601 upper bound on creation time, exclusive."
|
|
530
|
+
},
|
|
341
531
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
342
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
532
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
533
|
+
{
|
|
534
|
+
name: "applicationId",
|
|
535
|
+
type: "string",
|
|
536
|
+
required: false,
|
|
537
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
538
|
+
}
|
|
343
539
|
],
|
|
344
540
|
requests: [{ method: "GET", path: "/api/v1/customers" }],
|
|
345
|
-
channels: ["mcp", "zapier", "make", "n8n"]
|
|
541
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
542
|
+
guardrails: [
|
|
543
|
+
'email, phone, firstName, lastName, name and metadata are withheld (null, or absent from the result) unless the credential holds customer_pii:read, which OAuth connections cannot hold. Over an OAuth connection company, externalId and externalCustomerId are withheld too, and q is refused. Do not describe a missing name/email as "no name on file"; say it is withheld.'
|
|
544
|
+
]
|
|
346
545
|
},
|
|
347
546
|
{
|
|
348
547
|
id: "get_customer",
|
|
@@ -350,7 +549,16 @@ var ACTIONS = [
|
|
|
350
549
|
description: "Full picture of a single customer: the record plus their subscriptions and addresses in one response.",
|
|
351
550
|
kind: "read",
|
|
352
551
|
scopes: ["customers:read"],
|
|
353
|
-
|
|
552
|
+
sectionScopes: ["customer_addresses:read", "subscriptions:read"],
|
|
553
|
+
input: [
|
|
554
|
+
{ name: "id", type: "string", required: true, description: "Customer id." },
|
|
555
|
+
{
|
|
556
|
+
name: "applicationId",
|
|
557
|
+
type: "string",
|
|
558
|
+
required: false,
|
|
559
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
560
|
+
}
|
|
561
|
+
],
|
|
354
562
|
requests: [
|
|
355
563
|
{ method: "GET", path: "/api/v1/customers/:id" },
|
|
356
564
|
{ method: "GET", path: "/api/v1/customers/:id/addresses" },
|
|
@@ -358,7 +566,9 @@ var ACTIONS = [
|
|
|
358
566
|
],
|
|
359
567
|
channels: ["mcp"],
|
|
360
568
|
guardrails: [
|
|
361
|
-
"Sub-reads need customer_addresses:read / subscriptions:read. Omit a section the credential cannot read instead of failing."
|
|
569
|
+
"Sub-reads need customer_addresses:read / subscriptions:read. Omit a section the credential cannot read instead of failing.",
|
|
570
|
+
"email, phone, firstName, lastName, name and metadata on the customer record are withheld (null, or absent from the result) unless the credential holds customer_pii:read, which OAuth connections cannot hold. Say PII is redacted rather than reporting the buyer as anonymous.",
|
|
571
|
+
OAUTH_WITHHELD
|
|
362
572
|
]
|
|
363
573
|
},
|
|
364
574
|
// ------------------------------------------------------------- subscriptions
|
|
@@ -371,8 +581,26 @@ var ACTIONS = [
|
|
|
371
581
|
input: [
|
|
372
582
|
{ name: "customerId", type: "string", required: false, description: "Filter by customer." },
|
|
373
583
|
{ name: "status", type: "string", required: false, description: "Filter by status." },
|
|
584
|
+
{
|
|
585
|
+
name: "createdAfter",
|
|
586
|
+
type: "string",
|
|
587
|
+
required: false,
|
|
588
|
+
description: "ISO 8601 lower bound on creation time, exclusive. For a single day, pass that day's midnight and the next day's midnight."
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
name: "createdBefore",
|
|
592
|
+
type: "string",
|
|
593
|
+
required: false,
|
|
594
|
+
description: "ISO 8601 upper bound on creation time, exclusive."
|
|
595
|
+
},
|
|
374
596
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
375
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
597
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
598
|
+
{
|
|
599
|
+
name: "applicationId",
|
|
600
|
+
type: "string",
|
|
601
|
+
required: false,
|
|
602
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
603
|
+
}
|
|
376
604
|
],
|
|
377
605
|
requests: [{ method: "GET", path: "/api/v1/subscriptions" }],
|
|
378
606
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
@@ -383,7 +611,15 @@ var ACTIONS = [
|
|
|
383
611
|
description: "Read a single subscription including its current period and pending changes.",
|
|
384
612
|
kind: "read",
|
|
385
613
|
scopes: ["subscriptions:read"],
|
|
386
|
-
input: [
|
|
614
|
+
input: [
|
|
615
|
+
{ name: "id", type: "string", required: true, description: "Subscription id." },
|
|
616
|
+
{
|
|
617
|
+
name: "applicationId",
|
|
618
|
+
type: "string",
|
|
619
|
+
required: false,
|
|
620
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
621
|
+
}
|
|
622
|
+
],
|
|
387
623
|
requests: [{ method: "GET", path: "/api/v1/subscriptions/:id" }],
|
|
388
624
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
389
625
|
},
|
|
@@ -396,8 +632,26 @@ var ACTIONS = [
|
|
|
396
632
|
scopes: ["quotes:read"],
|
|
397
633
|
input: [
|
|
398
634
|
{ name: "status", type: "string", required: false, description: "Filter by quote status." },
|
|
635
|
+
{
|
|
636
|
+
name: "createdAfter",
|
|
637
|
+
type: "string",
|
|
638
|
+
required: false,
|
|
639
|
+
description: "ISO 8601 lower bound on creation time, exclusive. For a single day, pass that day's midnight and the next day's midnight."
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
name: "createdBefore",
|
|
643
|
+
type: "string",
|
|
644
|
+
required: false,
|
|
645
|
+
description: "ISO 8601 upper bound on creation time, exclusive."
|
|
646
|
+
},
|
|
399
647
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
400
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
648
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
649
|
+
{
|
|
650
|
+
name: "applicationId",
|
|
651
|
+
type: "string",
|
|
652
|
+
required: false,
|
|
653
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
654
|
+
}
|
|
401
655
|
],
|
|
402
656
|
requests: [{ method: "GET", path: "/api/v1/quotes" }],
|
|
403
657
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
@@ -405,12 +659,21 @@ var ACTIONS = [
|
|
|
405
659
|
{
|
|
406
660
|
id: "get_quote",
|
|
407
661
|
title: "Get one quote",
|
|
408
|
-
description: "Read a single quote with its line items
|
|
662
|
+
description: "Read a single quote: status, totals, and each revision with its line items and payment terms.",
|
|
409
663
|
kind: "read",
|
|
410
664
|
scopes: ["quotes:read"],
|
|
411
|
-
input: [
|
|
665
|
+
input: [
|
|
666
|
+
{ name: "id", type: "string", required: true, description: "Quote id." },
|
|
667
|
+
{
|
|
668
|
+
name: "applicationId",
|
|
669
|
+
type: "string",
|
|
670
|
+
required: false,
|
|
671
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
672
|
+
}
|
|
673
|
+
],
|
|
412
674
|
requests: [{ method: "GET", path: "/api/v1/quotes/:id" }],
|
|
413
|
-
channels: ["mcp", "zapier", "make", "n8n"]
|
|
675
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
676
|
+
guardrails: [OAUTH_WITHHELD]
|
|
414
677
|
},
|
|
415
678
|
// ----------------------------------------------------------------- invoices
|
|
416
679
|
{
|
|
@@ -422,10 +685,17 @@ var ACTIONS = [
|
|
|
422
685
|
input: [
|
|
423
686
|
{ name: "status", type: "string", required: false, description: "Filter by invoice status." },
|
|
424
687
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
425
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
688
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
689
|
+
{
|
|
690
|
+
name: "applicationId",
|
|
691
|
+
type: "string",
|
|
692
|
+
required: false,
|
|
693
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
694
|
+
}
|
|
426
695
|
],
|
|
427
696
|
requests: [{ method: "GET", path: "/api/v1/invoices" }],
|
|
428
|
-
channels: ["mcp", "zapier", "make", "n8n"]
|
|
697
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
698
|
+
guardrails: [OAUTH_WITHHELD]
|
|
429
699
|
},
|
|
430
700
|
{
|
|
431
701
|
id: "receivables_aging",
|
|
@@ -433,7 +703,14 @@ var ACTIONS = [
|
|
|
433
703
|
description: 'Outstanding receivables bucketed by age \u2014 answers "what is overdue and by how long".',
|
|
434
704
|
kind: "read",
|
|
435
705
|
scopes: ["invoices:read"],
|
|
436
|
-
input: [
|
|
706
|
+
input: [
|
|
707
|
+
{
|
|
708
|
+
name: "applicationId",
|
|
709
|
+
type: "string",
|
|
710
|
+
required: false,
|
|
711
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
712
|
+
}
|
|
713
|
+
],
|
|
437
714
|
requests: [{ method: "GET", path: "/api/v1/invoices/aging" }],
|
|
438
715
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
439
716
|
},
|
|
@@ -458,7 +735,13 @@ var ACTIONS = [
|
|
|
458
735
|
{ name: "createdAfter", type: "string", required: false, description: "ISO 8601 date lower bound." },
|
|
459
736
|
{ name: "createdBefore", type: "string", required: false, description: "ISO 8601 date upper bound." },
|
|
460
737
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
461
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
738
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
739
|
+
{
|
|
740
|
+
name: "applicationId",
|
|
741
|
+
type: "string",
|
|
742
|
+
required: false,
|
|
743
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
744
|
+
}
|
|
462
745
|
],
|
|
463
746
|
requests: [{ method: "GET", path: "/api/v1/discounts" }],
|
|
464
747
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
@@ -469,7 +752,15 @@ var ACTIONS = [
|
|
|
469
752
|
description: "Read a single discount code: value, conditions, usage limits and redemption count.",
|
|
470
753
|
kind: "read",
|
|
471
754
|
scopes: ["discounts:read"],
|
|
472
|
-
input: [
|
|
755
|
+
input: [
|
|
756
|
+
{ name: "id", type: "string", required: true, description: "Discount id." },
|
|
757
|
+
{
|
|
758
|
+
name: "applicationId",
|
|
759
|
+
type: "string",
|
|
760
|
+
required: false,
|
|
761
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
762
|
+
}
|
|
763
|
+
],
|
|
473
764
|
requests: [{ method: "GET", path: "/api/v1/discounts/:id" }],
|
|
474
765
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
475
766
|
},
|
|
@@ -496,7 +787,13 @@ var ACTIONS = [
|
|
|
496
787
|
{ name: "amountMin", type: "number", required: false, description: "Minimum amount, minor units." },
|
|
497
788
|
{ name: "amountMax", type: "number", required: false, description: "Maximum amount, minor units." },
|
|
498
789
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
499
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
790
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
791
|
+
{
|
|
792
|
+
name: "applicationId",
|
|
793
|
+
type: "string",
|
|
794
|
+
required: false,
|
|
795
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
796
|
+
}
|
|
500
797
|
],
|
|
501
798
|
requests: [{ method: "GET", path: "/api/v1/payments" }],
|
|
502
799
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
@@ -507,7 +804,15 @@ var ACTIONS = [
|
|
|
507
804
|
description: "Read a single payment plus its full transaction history (authorize/capture/refund/void attempts).",
|
|
508
805
|
kind: "read",
|
|
509
806
|
scopes: ["payments:read"],
|
|
510
|
-
input: [
|
|
807
|
+
input: [
|
|
808
|
+
{ name: "id", type: "string", required: true, description: "Payment id." },
|
|
809
|
+
{
|
|
810
|
+
name: "applicationId",
|
|
811
|
+
type: "string",
|
|
812
|
+
required: false,
|
|
813
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
814
|
+
}
|
|
815
|
+
],
|
|
511
816
|
requests: [
|
|
512
817
|
{ method: "GET", path: "/api/v1/payments/:id" },
|
|
513
818
|
{ method: "GET", path: "/api/v1/payments/:id/transactions" }
|
|
@@ -524,9 +829,18 @@ var ACTIONS = [
|
|
|
524
829
|
description: "Read a single issued invoice: line items, totals, status and the billing snapshot at issue time.",
|
|
525
830
|
kind: "read",
|
|
526
831
|
scopes: ["invoices:read"],
|
|
527
|
-
input: [
|
|
832
|
+
input: [
|
|
833
|
+
{ name: "id", type: "string", required: true, description: "Invoice id." },
|
|
834
|
+
{
|
|
835
|
+
name: "applicationId",
|
|
836
|
+
type: "string",
|
|
837
|
+
required: false,
|
|
838
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
839
|
+
}
|
|
840
|
+
],
|
|
528
841
|
requests: [{ method: "GET", path: "/api/v1/invoices/:id" }],
|
|
529
|
-
channels: ["mcp", "zapier", "make", "n8n"]
|
|
842
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
843
|
+
guardrails: [OAUTH_WITHHELD]
|
|
530
844
|
},
|
|
531
845
|
// ------------------------------------------------------------------ carts
|
|
532
846
|
{
|
|
@@ -538,7 +852,13 @@ var ACTIONS = [
|
|
|
538
852
|
input: [
|
|
539
853
|
{ name: "sinceDays", type: "number", required: false, description: "How many days back to look." },
|
|
540
854
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
541
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
855
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
856
|
+
{
|
|
857
|
+
name: "applicationId",
|
|
858
|
+
type: "string",
|
|
859
|
+
required: false,
|
|
860
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
861
|
+
}
|
|
542
862
|
],
|
|
543
863
|
requests: [
|
|
544
864
|
{ method: "GET", path: "/api/v1/abandoned-carts" },
|
|
@@ -559,7 +879,13 @@ var ACTIONS = [
|
|
|
559
879
|
{ name: "entityType", type: "string", required: false, description: "Entity type filter." },
|
|
560
880
|
{ name: "entityId", type: "string", required: false, description: "Entity id filter." },
|
|
561
881
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
562
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
882
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
883
|
+
{
|
|
884
|
+
name: "applicationId",
|
|
885
|
+
type: "string",
|
|
886
|
+
required: false,
|
|
887
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
888
|
+
}
|
|
563
889
|
],
|
|
564
890
|
requests: [{ method: "GET", path: "/api/v1/events" }],
|
|
565
891
|
channels: ["mcp", "n8n"]
|
|
@@ -567,13 +893,30 @@ var ACTIONS = [
|
|
|
567
893
|
{
|
|
568
894
|
id: "list_webhook_deliveries",
|
|
569
895
|
title: "List webhook deliveries",
|
|
570
|
-
description: "Recent outbound webhook deliveries, filterable by endpoint and
|
|
896
|
+
description: "Recent outbound webhook deliveries, filterable by endpoint, status and event type.",
|
|
571
897
|
kind: "read",
|
|
572
898
|
scopes: ["webhook_deliveries:read"],
|
|
573
899
|
input: [
|
|
574
900
|
{ name: "endpointId", type: "string", required: false, description: "Filter by endpoint." },
|
|
575
|
-
{
|
|
576
|
-
|
|
901
|
+
{
|
|
902
|
+
name: "status",
|
|
903
|
+
type: "string",
|
|
904
|
+
required: false,
|
|
905
|
+
description: "Filter by delivery status: pending, delivered, failed or dead_letter."
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
name: "eventType",
|
|
909
|
+
type: "string",
|
|
910
|
+
required: false,
|
|
911
|
+
description: "Filter by exact event type, e.g. payment.failed."
|
|
912
|
+
},
|
|
913
|
+
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
914
|
+
{
|
|
915
|
+
name: "applicationId",
|
|
916
|
+
type: "string",
|
|
917
|
+
required: false,
|
|
918
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
919
|
+
}
|
|
577
920
|
],
|
|
578
921
|
requests: [{ method: "GET", path: "/api/v1/webhook-deliveries" }],
|
|
579
922
|
channels: ["mcp", "n8n"]
|
|
@@ -584,7 +927,15 @@ var ACTIONS = [
|
|
|
584
927
|
description: "Full delivery record: the signed payload we sent, the response we got back, and every attempt.",
|
|
585
928
|
kind: "read",
|
|
586
929
|
scopes: ["webhook_deliveries:read"],
|
|
587
|
-
input: [
|
|
930
|
+
input: [
|
|
931
|
+
{ name: "id", type: "string", required: true, description: "Delivery id." },
|
|
932
|
+
{
|
|
933
|
+
name: "applicationId",
|
|
934
|
+
type: "string",
|
|
935
|
+
required: false,
|
|
936
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
937
|
+
}
|
|
938
|
+
],
|
|
588
939
|
requests: [{ method: "GET", path: "/api/v1/webhook-deliveries/:id" }],
|
|
589
940
|
channels: ["mcp", "n8n"]
|
|
590
941
|
},
|
|
@@ -594,12 +945,19 @@ var ACTIONS = [
|
|
|
594
945
|
description: "Diagnose a failing checkout in one call: session state, its cart, the events it emitted, and any webhook deliveries that followed. Use this before asking the user to reproduce anything.",
|
|
595
946
|
kind: "read",
|
|
596
947
|
scopes: ["checkout_sessions:read"],
|
|
948
|
+
sectionScopes: ["events:read", "webhook_deliveries:read"],
|
|
597
949
|
input: [
|
|
598
950
|
{
|
|
599
951
|
name: "id",
|
|
600
952
|
type: "string",
|
|
601
953
|
required: true,
|
|
602
954
|
description: "Checkout session id (or cart id \u2014 the tool resolves the session)."
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
name: "applicationId",
|
|
958
|
+
type: "string",
|
|
959
|
+
required: false,
|
|
960
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
603
961
|
}
|
|
604
962
|
],
|
|
605
963
|
requests: [
|
|
@@ -610,7 +968,8 @@ var ACTIONS = [
|
|
|
610
968
|
],
|
|
611
969
|
channels: ["mcp"],
|
|
612
970
|
guardrails: [
|
|
613
|
-
"Report which sections were unavailable rather than failing the call when a sub-read is unscoped."
|
|
971
|
+
"Report which sections were unavailable rather than failing the call when a sub-read is unscoped.",
|
|
972
|
+
OAUTH_WITHHELD
|
|
614
973
|
]
|
|
615
974
|
},
|
|
616
975
|
// ------------------------------------------------------------- extensions
|
|
@@ -629,7 +988,13 @@ var ACTIONS = [
|
|
|
629
988
|
enum: ["active", "suspended", "uninstalled"]
|
|
630
989
|
},
|
|
631
990
|
{ name: "limit", type: "number", required: false, description: "Page size." },
|
|
632
|
-
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." }
|
|
991
|
+
{ name: "cursor", type: "string", required: false, description: "Pagination cursor." },
|
|
992
|
+
{
|
|
993
|
+
name: "applicationId",
|
|
994
|
+
type: "string",
|
|
995
|
+
required: false,
|
|
996
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
997
|
+
}
|
|
633
998
|
],
|
|
634
999
|
requests: [{ method: "GET", path: "/api/v1/installations" }],
|
|
635
1000
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
@@ -641,7 +1006,14 @@ var ACTIONS = [
|
|
|
641
1006
|
description: "Read the payment-routing cascade, active routing connectors, and card/other decline rules \u2014 what determines which processor handles a payment and what happens on a decline.",
|
|
642
1007
|
kind: "read",
|
|
643
1008
|
scopes: ["connectors:read"],
|
|
644
|
-
input: [
|
|
1009
|
+
input: [
|
|
1010
|
+
{
|
|
1011
|
+
name: "applicationId",
|
|
1012
|
+
type: "string",
|
|
1013
|
+
required: false,
|
|
1014
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1015
|
+
}
|
|
1016
|
+
],
|
|
645
1017
|
requests: [
|
|
646
1018
|
{ method: "GET", path: "/api/v1/payment-routing" },
|
|
647
1019
|
{ method: "GET", path: "/api/v1/routing-connectors" },
|
|
@@ -659,7 +1031,15 @@ var ACTIONS = [
|
|
|
659
1031
|
description: 'Answers "am I ready to go live?" \u2014 active connectors, webhook endpoints and their recent delivery health, and the environment this credential is pinned to.',
|
|
660
1032
|
kind: "read",
|
|
661
1033
|
scopes: [],
|
|
662
|
-
|
|
1034
|
+
sectionScopes: ["connectors:read", "webhooks:read"],
|
|
1035
|
+
input: [
|
|
1036
|
+
{
|
|
1037
|
+
name: "applicationId",
|
|
1038
|
+
type: "string",
|
|
1039
|
+
required: false,
|
|
1040
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1041
|
+
}
|
|
1042
|
+
],
|
|
663
1043
|
requests: [
|
|
664
1044
|
{ method: "GET", path: "/api/v1/whoami" },
|
|
665
1045
|
{ method: "GET", path: "/api/v1/connectors" },
|
|
@@ -675,7 +1055,7 @@ var ACTIONS = [
|
|
|
675
1055
|
{
|
|
676
1056
|
id: "get_workspace_settings",
|
|
677
1057
|
title: "Get workspace settings",
|
|
678
|
-
description: "Read this workspace's identity
|
|
1058
|
+
description: "Read this workspace's identity: name, slug, branding and onboarding state. Payment terms are set per application and environment, not here.",
|
|
679
1059
|
kind: "read",
|
|
680
1060
|
scopes: ["merchant:read"],
|
|
681
1061
|
input: [],
|
|
@@ -694,12 +1074,48 @@ var ACTIONS = [
|
|
|
694
1074
|
requests: [{ method: "GET", path: "/api/v1/audit-log" }],
|
|
695
1075
|
channels: ["mcp", "zapier", "make", "n8n"]
|
|
696
1076
|
},
|
|
1077
|
+
{
|
|
1078
|
+
id: "list_applications",
|
|
1079
|
+
title: "List applications in this workspace",
|
|
1080
|
+
description: 'List every application in this workspace you have access to, so you can pass one of their ids as applicationId on other read and analytics tools. Note: the underlying route is the legacy-named /v1/stores (kept for contract stability) \u2014 the resource it returns is applications, not a separate "stores" concept.',
|
|
1081
|
+
kind: "read",
|
|
1082
|
+
scopes: ["applications:read"],
|
|
1083
|
+
input: [],
|
|
1084
|
+
requests: [{ method: "GET", path: "/api/v1/stores" }],
|
|
1085
|
+
channels: ["mcp", "zapier", "make", "n8n"]
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
id: "get_sales_timeseries",
|
|
1089
|
+
title: "Sales over time",
|
|
1090
|
+
description: `Order count and gross revenue bucketed by day, week or month over any date range, in the merchant's timezone, optionally compared to the previous period or the same range last year. Use this for "how much did we sell on/last/between\u2026" instead of paging search_orders and adding it up.`,
|
|
1091
|
+
kind: "read",
|
|
1092
|
+
scopes: ["orders:read"],
|
|
1093
|
+
input: [
|
|
1094
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1095
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1096
|
+
{ name: "groupBy", type: "string", required: false, description: "Bucket size.", enum: ["day", "week", "month"], default: "day" },
|
|
1097
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for bucket boundaries, e.g. America/New_York. Defaults to UTC \u2014 ask the user rather than assuming UTC when the answer depends on day boundaries." },
|
|
1098
|
+
{ name: "compareTo", type: "string", required: false, description: "Add a comparison total.", enum: ["previous_period", "previous_year", "none"], default: "none" },
|
|
1099
|
+
{
|
|
1100
|
+
name: "applicationId",
|
|
1101
|
+
type: "string",
|
|
1102
|
+
required: false,
|
|
1103
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1104
|
+
}
|
|
1105
|
+
],
|
|
1106
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/orders-timeseries" }],
|
|
1107
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1108
|
+
guardrails: [
|
|
1109
|
+
"Revenue is GROSS. Refunds are not deducted, because that needs payment_refunds:read, which OAuth connections cannot hold. Never describe the figure as net."
|
|
1110
|
+
]
|
|
1111
|
+
},
|
|
697
1112
|
{
|
|
698
1113
|
id: "get_business_summary",
|
|
699
1114
|
title: "Business summary",
|
|
700
|
-
description: "How are we doing? Orders/revenue, subscription MRR, receivables and quotes pipeline
|
|
1115
|
+
description: "How are we doing? Orders/revenue, subscription MRR, receivables and quotes pipeline over a date range, compared to the immediately preceding window of equal length. Note: period=week|month|quarter means the TRAILING 7/30/90 days, not a calendar period \u2014 pass from/to for calendar months.",
|
|
701
1116
|
kind: "read",
|
|
702
1117
|
scopes: [],
|
|
1118
|
+
sectionScopes: ["orders:read", "subscriptions:read", "invoices:read", "quotes:read"],
|
|
703
1119
|
input: [
|
|
704
1120
|
{
|
|
705
1121
|
name: "period",
|
|
@@ -708,6 +1124,15 @@ var ACTIONS = [
|
|
|
708
1124
|
description: "Reporting window.",
|
|
709
1125
|
enum: ["week", "month", "quarter"],
|
|
710
1126
|
default: "month"
|
|
1127
|
+
},
|
|
1128
|
+
{ name: "from", type: "string", required: false, description: "ISO 8601 start of range. Overrides period." },
|
|
1129
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range. Defaults to now." },
|
|
1130
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for period boundaries. Defaults to UTC." },
|
|
1131
|
+
{
|
|
1132
|
+
name: "applicationId",
|
|
1133
|
+
type: "string",
|
|
1134
|
+
required: false,
|
|
1135
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
711
1136
|
}
|
|
712
1137
|
],
|
|
713
1138
|
requests: [{ method: "GET", path: "/api/v1/analytics/business-summary" }],
|
|
@@ -716,19 +1141,189 @@ var ACTIONS = [
|
|
|
716
1141
|
"Each section needs its own scope (orders:read, subscriptions:read, invoices:read, quotes:read). A section without its scope is reported as omitted rather than failing the whole call."
|
|
717
1142
|
]
|
|
718
1143
|
},
|
|
1144
|
+
{
|
|
1145
|
+
id: "get_top_products",
|
|
1146
|
+
title: "Top products",
|
|
1147
|
+
description: "Best-selling products over a date range, by revenue or units sold. Line items come from the merchant's own cart payload, so a product is identified by its external reference id when present and by name otherwise. The response carries both the top-N rows (by the chosen sort) and range-wide totals across every matching product, so you can compute what share of total revenue/units the top N represent.",
|
|
1148
|
+
kind: "read",
|
|
1149
|
+
scopes: ["orders:read"],
|
|
1150
|
+
input: [
|
|
1151
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1152
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1153
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for range boundaries. Defaults to UTC." },
|
|
1154
|
+
{ name: "by", type: "string", required: false, description: "Sort key.", enum: ["revenue", "units"], default: "revenue" },
|
|
1155
|
+
{ name: "limit", type: "number", required: false, description: "Max rows to return (1-100). Defaults to 20." },
|
|
1156
|
+
{
|
|
1157
|
+
name: "applicationId",
|
|
1158
|
+
type: "string",
|
|
1159
|
+
required: false,
|
|
1160
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1161
|
+
}
|
|
1162
|
+
],
|
|
1163
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/products" }],
|
|
1164
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1165
|
+
guardrails: [
|
|
1166
|
+
"Revenue is GROSS. Refunds are not deducted, because that needs payment_refunds:read, which OAuth connections cannot hold. Never describe the figure as net."
|
|
1167
|
+
]
|
|
1168
|
+
},
|
|
719
1169
|
{
|
|
720
1170
|
id: "get_attention_digest",
|
|
721
1171
|
title: "Attention digest",
|
|
722
1172
|
description: "What needs attention right now? Open disputes, subscriptions in dunning, overdue Net-N invoices, and webhooks with degraded delivery health \u2014 a point-in-time snapshot, not a time range.",
|
|
723
1173
|
kind: "read",
|
|
724
1174
|
scopes: [],
|
|
725
|
-
|
|
1175
|
+
sectionScopes: ["payment_disputes:read", "subscriptions:read", "invoices:read", "webhook_deliveries:read"],
|
|
1176
|
+
input: [
|
|
1177
|
+
{
|
|
1178
|
+
name: "applicationId",
|
|
1179
|
+
type: "string",
|
|
1180
|
+
required: false,
|
|
1181
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1182
|
+
}
|
|
1183
|
+
],
|
|
726
1184
|
requests: [{ method: "GET", path: "/api/v1/analytics/attention-digest" }],
|
|
727
1185
|
channels: ["mcp", "zapier", "make", "n8n"],
|
|
728
1186
|
guardrails: [
|
|
729
1187
|
"Each section needs its own scope (payment_disputes:read, subscriptions:read, invoices:read, webhook_deliveries:read). A section without its scope is reported as omitted rather than failing the whole call."
|
|
730
1188
|
]
|
|
731
1189
|
},
|
|
1190
|
+
{
|
|
1191
|
+
id: "get_customer_growth",
|
|
1192
|
+
title: "Customer growth",
|
|
1193
|
+
description: "Customer growth over a date range: signups per day/week/month, how many orders came from first-time versus returning customers, and the highest-value customers in the window.",
|
|
1194
|
+
kind: "read",
|
|
1195
|
+
scopes: ["customers:read"],
|
|
1196
|
+
input: [
|
|
1197
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1198
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1199
|
+
{ name: "groupBy", type: "string", required: false, description: "Signup series bucket size.", enum: ["day", "week", "month"], default: "day" },
|
|
1200
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for bucket boundaries. Defaults to UTC." },
|
|
1201
|
+
{ name: "topBy", type: "string", required: false, description: "Sort key for top customers.", enum: ["revenue", "orders"], default: "revenue" },
|
|
1202
|
+
{ name: "topLimit", type: "number", required: false, description: "Max top-customers rows to return (1-50). Defaults to 10." },
|
|
1203
|
+
{
|
|
1204
|
+
name: "applicationId",
|
|
1205
|
+
type: "string",
|
|
1206
|
+
required: false,
|
|
1207
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1208
|
+
}
|
|
1209
|
+
],
|
|
1210
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/customers" }],
|
|
1211
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1212
|
+
guardrails: [
|
|
1213
|
+
"Revenue is GROSS. Refunds are not deducted, because that needs payment_refunds:read, which OAuth connections cannot hold. Never describe the figure as net.",
|
|
1214
|
+
"topCustomers is a top-N list; use the accompanying totals for range-wide customer/order/revenue counts instead of summing the returned rows.",
|
|
1215
|
+
"topCustomers[].email and .name come back null unless the credential holds customer_pii:read, which OAuth connections cannot hold. Identify a top customer by id, not by a null name."
|
|
1216
|
+
]
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
id: "get_revenue_breakdown",
|
|
1220
|
+
title: "Revenue breakdown",
|
|
1221
|
+
description: "Revenue split by one dimension over a date range \u2014 payment method, order source, or currency. Amounts are gross; refunds are not deducted.",
|
|
1222
|
+
kind: "read",
|
|
1223
|
+
scopes: ["orders:read"],
|
|
1224
|
+
input: [
|
|
1225
|
+
{
|
|
1226
|
+
name: "dimension",
|
|
1227
|
+
type: "string",
|
|
1228
|
+
required: true,
|
|
1229
|
+
description: "Breakdown dimension.",
|
|
1230
|
+
enum: ["paymentMethod", "source", "currency"]
|
|
1231
|
+
},
|
|
1232
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1233
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1234
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for range boundaries. Defaults to UTC." },
|
|
1235
|
+
{
|
|
1236
|
+
name: "applicationId",
|
|
1237
|
+
type: "string",
|
|
1238
|
+
required: false,
|
|
1239
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1240
|
+
}
|
|
1241
|
+
],
|
|
1242
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/revenue-breakdown" }],
|
|
1243
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1244
|
+
guardrails: [
|
|
1245
|
+
"Revenue is GROSS. Refunds are not deducted, because that needs payment_refunds:read, which OAuth connections cannot hold. Never describe the figure as net.",
|
|
1246
|
+
"dimension is required; it is never defaulted, so omitting it fails the call instead of silently picking a dimension.",
|
|
1247
|
+
"For dimension=paymentMethod, an order paid via more than one method can appear in more than one row, so rows can sum to more than totals (a separate whole-range aggregate over orders alone)."
|
|
1248
|
+
]
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
id: "get_funnel_conversion",
|
|
1252
|
+
title: "Checkout funnel",
|
|
1253
|
+
description: "Checkout funnel over a date range: carts created, checkout sessions started, orders completed, with the drop-off between each stage.",
|
|
1254
|
+
kind: "read",
|
|
1255
|
+
scopes: ["carts:read"],
|
|
1256
|
+
input: [
|
|
1257
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1258
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1259
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for range boundaries. Defaults to UTC." },
|
|
1260
|
+
{
|
|
1261
|
+
name: "applicationId",
|
|
1262
|
+
type: "string",
|
|
1263
|
+
required: false,
|
|
1264
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1265
|
+
}
|
|
1266
|
+
],
|
|
1267
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/funnel" }],
|
|
1268
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1269
|
+
guardrails: [
|
|
1270
|
+
"Each stage needs its own scope (carts:read, checkout_sessions:read, orders:read), checked independently \u2014 an OAuth grant carries literal scopes with no legacy expansion, so a credential can hold carts:read without the other two. An omitted stage is reported as such rather than failing the whole call.",
|
|
1271
|
+
"conversionRate and dropOff[].ratePct are null (unknown) when a stage they depend on is omitted, and 0 only when the stage was readable with a true zero count. Never treat a null here as 0.",
|
|
1272
|
+
'dropOff[].ratePct is the percentage of "from" that did NOT reach "to" (loss), not a conversion rate. The step-conversion rate is 100 - ratePct.'
|
|
1273
|
+
]
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
id: "get_subscription_movement",
|
|
1277
|
+
title: "Subscription movement",
|
|
1278
|
+
description: "Subscription movement over a date range: new subscriptions, cancellations and net MRR change per day/week/month. Figures are reconstructed from subscription timestamps, not a stored historical snapshot.",
|
|
1279
|
+
kind: "read",
|
|
1280
|
+
scopes: ["subscriptions:read"],
|
|
1281
|
+
input: [
|
|
1282
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1283
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1284
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for bucket boundaries. Defaults to UTC." },
|
|
1285
|
+
{ name: "groupBy", type: "string", required: false, description: "Bucket size.", enum: ["day", "week", "month"], default: "day" },
|
|
1286
|
+
{
|
|
1287
|
+
name: "applicationId",
|
|
1288
|
+
type: "string",
|
|
1289
|
+
required: false,
|
|
1290
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1291
|
+
}
|
|
1292
|
+
],
|
|
1293
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/subscriptions" }],
|
|
1294
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1295
|
+
guardrails: [
|
|
1296
|
+
"newSubscriptions, churnedSubscriptions and mrrDeltaCents are reconstructed per bucket from subscription created_at/cancelled_at timestamps, not a stored historical MRR snapshot \u2014 never present this series as an audited historical MRR ledger.",
|
|
1297
|
+
"mrrDeltaCents for a bucket only credits subscriptions created in that bucket that are still active right now, and only debits subscriptions cancelled in that bucket that already existed when it started. A subscription created AND cancelled inside the same bucket still counts toward both newSubscriptions and churnedSubscriptions but contributes 0 to mrrDeltaCents.",
|
|
1298
|
+
"totals is the sum over the full series (the series is never truncated), so totals.newSubscriptions/.churnedSubscriptions/.netMrrDeltaCents always equal the corresponding sums of series[]."
|
|
1299
|
+
]
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
id: "get_discount_performance",
|
|
1303
|
+
title: "Discount performance",
|
|
1304
|
+
description: "Discount code performance over a date range: redemption count, revenue on discounted orders, and total discount given per code.",
|
|
1305
|
+
kind: "read",
|
|
1306
|
+
scopes: ["discounts:read"],
|
|
1307
|
+
input: [
|
|
1308
|
+
{ name: "from", type: "string", required: false, description: 'ISO 8601 start of range, exclusive. Defaults to 30 days before "to".' },
|
|
1309
|
+
{ name: "to", type: "string", required: false, description: "ISO 8601 end of range, exclusive. Defaults to now." },
|
|
1310
|
+
{ name: "timezone", type: "string", required: false, description: "IANA timezone for range boundaries. Defaults to UTC." },
|
|
1311
|
+
{ name: "limit", type: "number", required: false, description: "Max rows to return. Defaults to 20." },
|
|
1312
|
+
{
|
|
1313
|
+
name: "applicationId",
|
|
1314
|
+
type: "string",
|
|
1315
|
+
required: false,
|
|
1316
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1317
|
+
}
|
|
1318
|
+
],
|
|
1319
|
+
requests: [{ method: "GET", path: "/api/v1/analytics/discounts" }],
|
|
1320
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1321
|
+
guardrails: [
|
|
1322
|
+
'discountedRevenueCents and discountGivenCents are DIFFERENT measures: discountedRevenueCents is the gross order total on orders that redeemed the code; discountGivenCents is the discount amount taken off those same orders. Never describe discountedRevenueCents as "given away" or discountGivenCents as revenue.',
|
|
1323
|
+
"Only orders with status <> draft and a gross-eligible payment_status are counted; refunds are not deducted from discountedRevenueCents, because that needs payment_refunds:read.",
|
|
1324
|
+
"rows are the top N codes by discount given; totals is a SEPARATE whole-range aggregate (not a reduction over rows), so totals.redemptions / totals.discountGivenCents stay valid even when rows is truncated by limit."
|
|
1325
|
+
]
|
|
1326
|
+
},
|
|
732
1327
|
// ------------------------------------------------------------ sandbox write
|
|
733
1328
|
{
|
|
734
1329
|
id: "seed_test_data",
|
|
@@ -754,6 +1349,151 @@ var ACTIONS = [
|
|
|
754
1349
|
"Seeds a finalized DRAFT order \u2014 it does not capture a payment, which needs a browser-side tokenised payment method."
|
|
755
1350
|
]
|
|
756
1351
|
},
|
|
1352
|
+
// ---------------------------------------------------------- inbound writes
|
|
1353
|
+
// The no-code channels are mostly used in the "something happened elsewhere,
|
|
1354
|
+
// put it into Throttle" direction — a form submission, a new CRM contact, a
|
|
1355
|
+
// spreadsheet row. These three are that direction.
|
|
1356
|
+
{
|
|
1357
|
+
id: "create_customer",
|
|
1358
|
+
title: "Create a customer",
|
|
1359
|
+
description: "Create a customer record. Use search_customers first if the buyer may already exist \u2014 this does not de-duplicate by email.",
|
|
1360
|
+
kind: "write",
|
|
1361
|
+
scopes: ["customers:write"],
|
|
1362
|
+
input: [
|
|
1363
|
+
{ name: "email", type: "string", required: true, description: "The buyer's email address." },
|
|
1364
|
+
{ name: "firstName", type: "string", required: false, description: "Given name." },
|
|
1365
|
+
{ name: "lastName", type: "string", required: false, description: "Family name." },
|
|
1366
|
+
{ name: "phone", type: "string", required: false, description: "Contact phone number." },
|
|
1367
|
+
{ name: "company", type: "string", required: false, description: "The buyer's company." },
|
|
1368
|
+
{
|
|
1369
|
+
name: "externalId",
|
|
1370
|
+
type: "string",
|
|
1371
|
+
required: false,
|
|
1372
|
+
description: "This customer's id in your own system. Resolvable later via get_customer."
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
name: "netN",
|
|
1376
|
+
type: "number",
|
|
1377
|
+
required: false,
|
|
1378
|
+
description: "Invoice terms in days for this customer specifically, 0-365. Omit to use the workspace default; 0 means due on issue."
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
name: "acceptsMarketing",
|
|
1382
|
+
type: "boolean",
|
|
1383
|
+
required: false,
|
|
1384
|
+
description: "Whether the buyer opted into marketing email.",
|
|
1385
|
+
default: false
|
|
1386
|
+
}
|
|
1387
|
+
],
|
|
1388
|
+
requests: [{ method: "POST", path: "/api/v1/customers" }],
|
|
1389
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1390
|
+
idempotent: true,
|
|
1391
|
+
guardrails: [
|
|
1392
|
+
"The created 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 customer is still created with the values sent, only the response is redacted."
|
|
1393
|
+
]
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
id: "update_customer",
|
|
1397
|
+
title: "Update a customer",
|
|
1398
|
+
description: "Change fields on an existing customer. Only the fields supplied are touched; everything else is left alone.",
|
|
1399
|
+
kind: "write",
|
|
1400
|
+
scopes: ["customers:write"],
|
|
1401
|
+
input: [
|
|
1402
|
+
{ name: "id", type: "string", required: true, description: "Customer id." },
|
|
1403
|
+
{ name: "email", type: "string", required: false, description: "The buyer's email address." },
|
|
1404
|
+
{ name: "firstName", type: "string", required: false, description: "Given name." },
|
|
1405
|
+
{ name: "lastName", type: "string", required: false, description: "Family name." },
|
|
1406
|
+
{ name: "phone", type: "string", required: false, description: "Contact phone number." },
|
|
1407
|
+
{ name: "company", type: "string", required: false, description: "The buyer's company." },
|
|
1408
|
+
{
|
|
1409
|
+
name: "externalId",
|
|
1410
|
+
type: "string",
|
|
1411
|
+
required: false,
|
|
1412
|
+
description: "This customer's id in your own system. Pass null to clear it."
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
name: "netN",
|
|
1416
|
+
type: "number",
|
|
1417
|
+
required: false,
|
|
1418
|
+
description: "Invoice terms in days for this customer specifically, 0-365."
|
|
1419
|
+
},
|
|
1420
|
+
{
|
|
1421
|
+
name: "acceptsMarketing",
|
|
1422
|
+
type: "boolean",
|
|
1423
|
+
required: false,
|
|
1424
|
+
description: "Whether the buyer opted into marketing email."
|
|
1425
|
+
}
|
|
1426
|
+
],
|
|
1427
|
+
requests: [{ method: "PATCH", path: "/api/v1/customers/:id" }],
|
|
1428
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1429
|
+
idempotent: true,
|
|
1430
|
+
guardrails: [
|
|
1431
|
+
"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."
|
|
1432
|
+
]
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
id: "create_checkout_link",
|
|
1436
|
+
title: "Create a checkout link",
|
|
1437
|
+
description: "Build a cart from line items and return a hosted checkout URL the buyer can pay at. Prices are in minor units (2500 = $25.00).",
|
|
1438
|
+
kind: "write",
|
|
1439
|
+
scopes: ["carts:write", "cart_items:write", "checkout_sessions:write"],
|
|
1440
|
+
input: [
|
|
1441
|
+
{
|
|
1442
|
+
name: "lineItems",
|
|
1443
|
+
type: "array",
|
|
1444
|
+
required: true,
|
|
1445
|
+
description: "What the buyer is paying for: { name, unitPrice, quantity }. unitPrice is an integer in minor units."
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
name: "returnUrl",
|
|
1449
|
+
type: "string",
|
|
1450
|
+
required: true,
|
|
1451
|
+
description: "Absolute URL the buyer lands on after paying."
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
name: "cancelUrl",
|
|
1455
|
+
type: "string",
|
|
1456
|
+
required: true,
|
|
1457
|
+
description: "Absolute URL the buyer lands on if they abandon checkout."
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
name: "customerId",
|
|
1461
|
+
type: "string",
|
|
1462
|
+
required: false,
|
|
1463
|
+
description: "Attach the cart to an existing customer."
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
name: "customerEmail",
|
|
1467
|
+
type: "string",
|
|
1468
|
+
required: false,
|
|
1469
|
+
description: "Pre-fill the buyer email without needing a customer record."
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
name: "discountCode",
|
|
1473
|
+
type: "string",
|
|
1474
|
+
required: false,
|
|
1475
|
+
description: "Discount code to apply to the session."
|
|
1476
|
+
},
|
|
1477
|
+
{
|
|
1478
|
+
name: "netN",
|
|
1479
|
+
type: "number",
|
|
1480
|
+
required: false,
|
|
1481
|
+
description: "Invoice terms in days for this cart, 0-365. Omit to pay in full at checkout."
|
|
1482
|
+
}
|
|
1483
|
+
],
|
|
1484
|
+
// Three calls: the API has no single "checkout link" endpoint, and a
|
|
1485
|
+
// checkout session requires a cart that already holds its line items.
|
|
1486
|
+
requests: [
|
|
1487
|
+
{ method: "POST", path: "/api/v1/carts" },
|
|
1488
|
+
{ method: "POST", path: "/api/v1/carts/:id/items" },
|
|
1489
|
+
{ method: "POST", path: "/api/v1/checkout/sessions" }
|
|
1490
|
+
],
|
|
1491
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1492
|
+
idempotent: true,
|
|
1493
|
+
guardrails: [
|
|
1494
|
+
"The returned URL is buyer-facing and takes real payment in a production environment."
|
|
1495
|
+
]
|
|
1496
|
+
},
|
|
757
1497
|
// -------------------------------------------------------------- money/mail
|
|
758
1498
|
{
|
|
759
1499
|
id: "create_quote",
|
|
@@ -782,7 +1522,8 @@ var ACTIONS = [
|
|
|
782
1522
|
requests: [{ method: "POST", path: "/api/v1/quotes/:id/issue" }],
|
|
783
1523
|
channels: ["mcp", "zapier", "make", "n8n"],
|
|
784
1524
|
idempotent: true,
|
|
785
|
-
guardrails: ['Sends mail to a real buyer. Never call it speculatively or to "check" a quote.']
|
|
1525
|
+
guardrails: ['Sends mail to a real buyer. Never call it speculatively or to "check" a quote.'],
|
|
1526
|
+
destructive: true
|
|
786
1527
|
},
|
|
787
1528
|
{
|
|
788
1529
|
id: "refund_payment",
|
|
@@ -801,12 +1542,20 @@ var ACTIONS = [
|
|
|
801
1542
|
{ name: "reason", type: "string", required: false, description: "Reason recorded on the refund." }
|
|
802
1543
|
],
|
|
803
1544
|
requests: [{ method: "POST", path: "/api/v1/payments/:id/refund" }],
|
|
804
|
-
|
|
1545
|
+
// NOT zapier/make. `payment_refunds:write` is `sensitive` in the scope
|
|
1546
|
+
// registry, and `validateScopesForOAuth` rejects every sensitive scope — so
|
|
1547
|
+
// an OAuth grant, which is the only credential a public Zapier or Make app
|
|
1548
|
+
// can hold, can never carry it. Listing the action on those channels would
|
|
1549
|
+
// ship a connector action that 403s on every call. MCP and n8n keep it:
|
|
1550
|
+
// both authenticate with an `sk_` key, which CAN hold the scope.
|
|
1551
|
+
// `oauth-grantable-scopes` in the catalog tests enforces this.
|
|
1552
|
+
channels: ["mcp", "n8n"],
|
|
805
1553
|
idempotent: true,
|
|
806
1554
|
guardrails: [
|
|
807
1555
|
"Moves money and is irreversible. Confirm with the user first.",
|
|
808
1556
|
"The API treats an omitted amount as a FULL refund, so this action requires it explicitly."
|
|
809
|
-
]
|
|
1557
|
+
],
|
|
1558
|
+
destructive: true
|
|
810
1559
|
},
|
|
811
1560
|
{
|
|
812
1561
|
id: "manage_subscription",
|
|
@@ -849,7 +1598,8 @@ var ACTIONS = [
|
|
|
849
1598
|
requests: [{ method: "POST", path: "/api/v1/subscriptions/:id/cancel" }],
|
|
850
1599
|
channels: ["mcp", "zapier", "make", "n8n"],
|
|
851
1600
|
idempotent: true,
|
|
852
|
-
guardrails: ["Ends billing for a paying customer. Confirm with the user first."]
|
|
1601
|
+
guardrails: ["Ends billing for a paying customer. Confirm with the user first."],
|
|
1602
|
+
destructive: true
|
|
853
1603
|
},
|
|
854
1604
|
{
|
|
855
1605
|
id: "replay_webhook_delivery",
|
|
@@ -861,7 +1611,8 @@ var ACTIONS = [
|
|
|
861
1611
|
requests: [{ method: "POST", path: "/api/v1/webhook-deliveries/:id/replay" }],
|
|
862
1612
|
channels: ["mcp", "n8n"],
|
|
863
1613
|
idempotent: true,
|
|
864
|
-
guardrails: ["The receiving system will process the event again. Confirm it is idempotent first."]
|
|
1614
|
+
guardrails: ["The receiving system will process the event again. Confirm it is idempotent first."],
|
|
1615
|
+
destructive: true
|
|
865
1616
|
},
|
|
866
1617
|
{
|
|
867
1618
|
id: "send_test_webhook",
|
|
@@ -875,7 +1626,8 @@ var ACTIONS = [
|
|
|
875
1626
|
],
|
|
876
1627
|
requests: [{ method: "POST", path: "/api/v1/webhook-endpoints/:id/test" }],
|
|
877
1628
|
channels: ["mcp", "n8n"],
|
|
878
|
-
idempotent: true
|
|
1629
|
+
idempotent: true,
|
|
1630
|
+
destructive: true
|
|
879
1631
|
}
|
|
880
1632
|
];
|
|
881
1633
|
|
|
@@ -1004,18 +1756,43 @@ function buildQuery(query) {
|
|
|
1004
1756
|
const qs = params.toString();
|
|
1005
1757
|
return qs ? `?${qs}` : "";
|
|
1006
1758
|
}
|
|
1759
|
+
var API_KEY_PREFIX_RE = /^(sk_|pk_)/;
|
|
1007
1760
|
var ThrottleClient = class {
|
|
1008
1761
|
constructor(auth, fetchImpl = fetch) {
|
|
1009
1762
|
this.auth = auth;
|
|
1010
1763
|
this.fetchImpl = fetchImpl;
|
|
1011
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Swap the credential every later request is sent with. The hosted remote
|
|
1767
|
+
* server builds one client per MCP session at `initialize`, but an OAuth
|
|
1768
|
+
* access token lives one hour and the MCP client refreshes it underneath
|
|
1769
|
+
* the session — each request then arrives with a newer bearer than the one
|
|
1770
|
+
* the session was opened with. Without this, the session keeps calling the
|
|
1771
|
+
* REST API with the token it was born with and every tool fails with a 401
|
|
1772
|
+
* the moment that first token expires, even though the caller is still
|
|
1773
|
+
* perfectly authenticated.
|
|
1774
|
+
*/
|
|
1775
|
+
setApiKey(apiKey) {
|
|
1776
|
+
this.auth = { ...this.auth, apiKey };
|
|
1777
|
+
}
|
|
1012
1778
|
async requestJson(method, path, options = {}) {
|
|
1013
1779
|
const url = `${this.auth.apiBaseUrl.replace(/\/$/, "")}${path}${buildQuery(options.query)}`;
|
|
1014
1780
|
const headers = {
|
|
1015
1781
|
"content-type": "application/json",
|
|
1016
|
-
"x-api-key": this.auth.apiKey
|
|
1782
|
+
"x-api-key": this.auth.apiKey,
|
|
1783
|
+
// Also sent as Authorization: Bearer — required for an OAuth access
|
|
1784
|
+
// token (the remote server's oauth_token sessions), which the auth
|
|
1785
|
+
// middleware only ever recognizes via this header (peeked by issuer),
|
|
1786
|
+
// never via x-api-key. For an sk_/pk_ key this is a no-op: the
|
|
1787
|
+
// middleware already treats `Authorization: Bearer sk_.../pk_...`
|
|
1788
|
+
// identically to `X-API-Key`, so existing stdio-CLI callers are
|
|
1789
|
+
// unaffected.
|
|
1790
|
+
Authorization: `Bearer ${this.auth.apiKey}`
|
|
1017
1791
|
};
|
|
1018
1792
|
if (options.idempotencyKey) headers["idempotency-key"] = options.idempotencyKey;
|
|
1793
|
+
if (options.applicationId && !API_KEY_PREFIX_RE.test(this.auth.apiKey)) {
|
|
1794
|
+
headers["x-throttle-application-id"] = options.applicationId;
|
|
1795
|
+
}
|
|
1019
1796
|
const sendsBody = method === "POST" || method === "PATCH" || method === "PUT";
|
|
1020
1797
|
const body = options.body !== void 0 ? JSON.stringify(options.body) : sendsBody ? "{}" : void 0;
|
|
1021
1798
|
const res = await this.fetchImpl(url, { method, headers, body });
|
|
@@ -1037,12 +1814,12 @@ var ThrottleClient = class {
|
|
|
1037
1814
|
return parsed;
|
|
1038
1815
|
}
|
|
1039
1816
|
/** Unwraps the `{ data }` envelope. Key presence, not `??` — `{data: null}` unwraps to null. */
|
|
1040
|
-
async get(path, query) {
|
|
1041
|
-
const body = await this.requestJson("GET", path, { query });
|
|
1817
|
+
async get(path, query, options) {
|
|
1818
|
+
const body = await this.requestJson("GET", path, { query, applicationId: options?.applicationId });
|
|
1042
1819
|
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
1043
1820
|
}
|
|
1044
|
-
async list(path, query) {
|
|
1045
|
-
const body = await this.requestJson("GET", path, { query });
|
|
1821
|
+
async list(path, query, options) {
|
|
1822
|
+
const body = await this.requestJson("GET", path, { query, applicationId: options?.applicationId });
|
|
1046
1823
|
const data = "data" in body ? body.data : body;
|
|
1047
1824
|
const meta = body.meta;
|
|
1048
1825
|
return { data: Array.isArray(data) ? data : [], pagination: meta?.pagination ?? null };
|
|
@@ -1051,6 +1828,10 @@ var ThrottleClient = class {
|
|
|
1051
1828
|
const body = await this.requestJson("POST", path, options);
|
|
1052
1829
|
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
1053
1830
|
}
|
|
1831
|
+
async patch(path, options = {}) {
|
|
1832
|
+
const body = await this.requestJson("PATCH", path, options);
|
|
1833
|
+
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
1834
|
+
}
|
|
1054
1835
|
};
|
|
1055
1836
|
async function optional(load) {
|
|
1056
1837
|
try {
|
|
@@ -1199,7 +1980,7 @@ function validatePayload(index, input) {
|
|
|
1199
1980
|
}
|
|
1200
1981
|
|
|
1201
1982
|
// src/docs.ts
|
|
1202
|
-
var DOCS_ORIGIN = "https://
|
|
1983
|
+
var DOCS_ORIGIN = "https://usethrottle.dev/docs";
|
|
1203
1984
|
function excerptAround(text, needle, radius = 160) {
|
|
1204
1985
|
const at = text.toLowerCase().indexOf(needle.toLowerCase());
|
|
1205
1986
|
if (at < 0) return text.slice(0, radius * 2).trim();
|
|
@@ -1283,27 +2064,35 @@ var HANDLERS = {
|
|
|
1283
2064
|
// ------------------------------------------------------------- generic read
|
|
1284
2065
|
api_get: async (ctx, args) => {
|
|
1285
2066
|
const path = String(args.path ?? "");
|
|
1286
|
-
|
|
2067
|
+
const resolved = new URL(path, "https://throttle.invalid").pathname;
|
|
2068
|
+
if (!path.startsWith("/api/v1/") || !resolved.startsWith("/api/v1/") || /(^|[\/\\])\.(\.)?([\/\\?#]|$)|%2e/i.test(path)) {
|
|
1287
2069
|
throw new Error(
|
|
1288
2070
|
`Refusing to call "${path}". api_get only reads paths beginning with /api/v1/ on the configured Throttle host.`
|
|
1289
2071
|
);
|
|
1290
2072
|
}
|
|
1291
|
-
return ctx.client.get(path);
|
|
2073
|
+
return ctx.client.get(path, void 0, { applicationId: args.applicationId });
|
|
1292
2074
|
},
|
|
1293
2075
|
// ------------------------------------------------------------------ orders
|
|
1294
|
-
search_orders: async (ctx, args) => ctx.client.list(
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
2076
|
+
search_orders: async (ctx, args) => ctx.client.list(
|
|
2077
|
+
"/api/v1/orders",
|
|
2078
|
+
{
|
|
2079
|
+
q: args.q,
|
|
2080
|
+
status: args.status,
|
|
2081
|
+
paymentStatus: args.paymentStatus,
|
|
2082
|
+
createdAfter: args.createdAfter,
|
|
2083
|
+
createdBefore: args.createdBefore,
|
|
2084
|
+
...page(args)
|
|
2085
|
+
},
|
|
2086
|
+
{ applicationId: args.applicationId }
|
|
2087
|
+
),
|
|
1300
2088
|
get_order: async (ctx, args) => {
|
|
1301
2089
|
const id = String(args.id);
|
|
1302
|
-
const
|
|
2090
|
+
const opts = { applicationId: args.applicationId };
|
|
2091
|
+
const order = await ctx.client.get(`/api/v1/orders/${id}`, void 0, opts);
|
|
1303
2092
|
const [payments, returns, fulfillments] = await Promise.all([
|
|
1304
|
-
optional(() => ctx.client.list(`/api/v1/orders/${id}/payments
|
|
1305
|
-
optional(() => ctx.client.list(`/api/v1/orders/${id}/returns
|
|
1306
|
-
optional(() => ctx.client.list(`/api/v1/orders/${id}/fulfillments
|
|
2093
|
+
optional(() => ctx.client.list(`/api/v1/orders/${id}/payments`, void 0, opts)),
|
|
2094
|
+
optional(() => ctx.client.list(`/api/v1/orders/${id}/returns`, void 0, opts)),
|
|
2095
|
+
optional(() => ctx.client.list(`/api/v1/orders/${id}/fulfillments`, void 0, opts))
|
|
1307
2096
|
]);
|
|
1308
2097
|
return {
|
|
1309
2098
|
order,
|
|
@@ -1313,13 +2102,23 @@ var HANDLERS = {
|
|
|
1313
2102
|
};
|
|
1314
2103
|
},
|
|
1315
2104
|
// --------------------------------------------------------------- customers
|
|
1316
|
-
search_customers: async (ctx, args) => ctx.client.list(
|
|
2105
|
+
search_customers: async (ctx, args) => ctx.client.list(
|
|
2106
|
+
"/api/v1/customers",
|
|
2107
|
+
{
|
|
2108
|
+
q: args.q,
|
|
2109
|
+
createdAfter: args.createdAfter,
|
|
2110
|
+
createdBefore: args.createdBefore,
|
|
2111
|
+
...page(args)
|
|
2112
|
+
},
|
|
2113
|
+
{ applicationId: args.applicationId }
|
|
2114
|
+
),
|
|
1317
2115
|
get_customer: async (ctx, args) => {
|
|
1318
2116
|
const id = String(args.id);
|
|
1319
|
-
const
|
|
2117
|
+
const opts = { applicationId: args.applicationId };
|
|
2118
|
+
const customer = await ctx.client.get(`/api/v1/customers/${id}`, void 0, opts);
|
|
1320
2119
|
const [addresses, subscriptions] = await Promise.all([
|
|
1321
|
-
optional(() => ctx.client.list(`/api/v1/customers/${id}/addresses
|
|
1322
|
-
optional(() => ctx.client.list("/api/v1/subscriptions", { customerId: id }))
|
|
2120
|
+
optional(() => ctx.client.list(`/api/v1/customers/${id}/addresses`, void 0, opts)),
|
|
2121
|
+
optional(() => ctx.client.list("/api/v1/subscriptions", { customerId: id }, opts))
|
|
1323
2122
|
]);
|
|
1324
2123
|
return {
|
|
1325
2124
|
customer,
|
|
@@ -1328,60 +2127,101 @@ var HANDLERS = {
|
|
|
1328
2127
|
};
|
|
1329
2128
|
},
|
|
1330
2129
|
// ----------------------------------------------------------- subscriptions
|
|
1331
|
-
list_subscriptions: async (ctx, args) => ctx.client.list(
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
2130
|
+
list_subscriptions: async (ctx, args) => ctx.client.list(
|
|
2131
|
+
"/api/v1/subscriptions",
|
|
2132
|
+
{
|
|
2133
|
+
customerId: args.customerId,
|
|
2134
|
+
status: args.status,
|
|
2135
|
+
createdAfter: args.createdAfter,
|
|
2136
|
+
createdBefore: args.createdBefore,
|
|
2137
|
+
...page(args)
|
|
2138
|
+
},
|
|
2139
|
+
{ applicationId: args.applicationId }
|
|
2140
|
+
),
|
|
2141
|
+
get_subscription: async (ctx, args) => ctx.client.get(`/api/v1/subscriptions/${String(args.id)}`, void 0, {
|
|
2142
|
+
applicationId: args.applicationId
|
|
1335
2143
|
}),
|
|
1336
|
-
get_subscription: async (ctx, args) => ctx.client.get(`/api/v1/subscriptions/${String(args.id)}`),
|
|
1337
2144
|
// ------------------------------------------------------------------ quotes
|
|
1338
|
-
search_quotes: async (ctx, args) => ctx.client.list(
|
|
1339
|
-
|
|
2145
|
+
search_quotes: async (ctx, args) => ctx.client.list(
|
|
2146
|
+
"/api/v1/quotes",
|
|
2147
|
+
{
|
|
2148
|
+
status: args.status,
|
|
2149
|
+
createdAfter: args.createdAfter,
|
|
2150
|
+
createdBefore: args.createdBefore,
|
|
2151
|
+
...page(args)
|
|
2152
|
+
},
|
|
2153
|
+
{ applicationId: args.applicationId }
|
|
2154
|
+
),
|
|
2155
|
+
get_quote: async (ctx, args) => ctx.client.get(`/api/v1/quotes/${String(args.id)}`, void 0, {
|
|
2156
|
+
applicationId: args.applicationId
|
|
2157
|
+
}),
|
|
1340
2158
|
// ---------------------------------------------------------------- invoices
|
|
1341
|
-
list_invoices: async (ctx, args) => ctx.client.list(
|
|
1342
|
-
|
|
2159
|
+
list_invoices: async (ctx, args) => ctx.client.list(
|
|
2160
|
+
"/api/v1/invoices",
|
|
2161
|
+
{ status: args.status, ...page(args) },
|
|
2162
|
+
{ applicationId: args.applicationId }
|
|
2163
|
+
),
|
|
2164
|
+
receivables_aging: async (ctx, args) => ctx.client.get("/api/v1/invoices/aging", void 0, { applicationId: args.applicationId }),
|
|
1343
2165
|
// --------------------------------------------------------------- discounts
|
|
1344
|
-
search_discounts: async (ctx, args) => ctx.client.list(
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
2166
|
+
search_discounts: async (ctx, args) => ctx.client.list(
|
|
2167
|
+
"/api/v1/discounts",
|
|
2168
|
+
{
|
|
2169
|
+
q: args.q,
|
|
2170
|
+
code: args.code,
|
|
2171
|
+
type: args.type,
|
|
2172
|
+
isActive: args.isActive,
|
|
2173
|
+
createdAfter: args.createdAfter,
|
|
2174
|
+
createdBefore: args.createdBefore,
|
|
2175
|
+
...page(args)
|
|
2176
|
+
},
|
|
2177
|
+
{ applicationId: args.applicationId }
|
|
2178
|
+
),
|
|
2179
|
+
get_discount: async (ctx, args) => ctx.client.get(`/api/v1/discounts/${String(args.id)}`, void 0, {
|
|
2180
|
+
applicationId: args.applicationId
|
|
1352
2181
|
}),
|
|
1353
|
-
get_discount: async (ctx, args) => ctx.client.get(`/api/v1/discounts/${String(args.id)}`),
|
|
1354
2182
|
// ---------------------------------------------------------------- payments
|
|
1355
|
-
search_payments: async (ctx, args) => ctx.client.list(
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
2183
|
+
search_payments: async (ctx, args) => ctx.client.list(
|
|
2184
|
+
"/api/v1/payments",
|
|
2185
|
+
{
|
|
2186
|
+
method: args.method,
|
|
2187
|
+
status: args.status,
|
|
2188
|
+
// The route only accepts these as snake_case query params -- confirmed
|
|
2189
|
+
// by reading its querystring schema directly, not assumed from the
|
|
2190
|
+
// platform's usual camelCase convention.
|
|
2191
|
+
order_id: args.orderId,
|
|
2192
|
+
aging: args.aging,
|
|
2193
|
+
due_from: args.dueFrom,
|
|
2194
|
+
due_to: args.dueTo,
|
|
2195
|
+
amount_min: args.amountMin,
|
|
2196
|
+
amount_max: args.amountMax,
|
|
2197
|
+
...page(args)
|
|
2198
|
+
},
|
|
2199
|
+
{ applicationId: args.applicationId }
|
|
2200
|
+
),
|
|
1369
2201
|
get_payment: async (ctx, args) => {
|
|
1370
2202
|
const id = String(args.id);
|
|
1371
|
-
const
|
|
1372
|
-
const
|
|
2203
|
+
const opts = { applicationId: args.applicationId };
|
|
2204
|
+
const payment = await ctx.client.get(`/api/v1/payments/${id}`, void 0, opts);
|
|
2205
|
+
const transactions = await optional(
|
|
2206
|
+
() => ctx.client.list(`/api/v1/payments/${id}/transactions`, void 0, opts)
|
|
2207
|
+
);
|
|
1373
2208
|
return {
|
|
1374
2209
|
payment,
|
|
1375
2210
|
transactions: transactions.ok ? transactions.value.data : transactions.unavailable
|
|
1376
2211
|
};
|
|
1377
2212
|
},
|
|
1378
2213
|
// ---------------------------------------------------------------- invoices
|
|
1379
|
-
get_invoice: async (ctx, args) => ctx.client.get(`/api/v1/invoices/${String(args.id)}
|
|
2214
|
+
get_invoice: async (ctx, args) => ctx.client.get(`/api/v1/invoices/${String(args.id)}`, void 0, {
|
|
2215
|
+
applicationId: args.applicationId
|
|
2216
|
+
}),
|
|
1380
2217
|
// ------------------------------------------------------------------ carts
|
|
1381
2218
|
list_abandoned_carts: async (ctx, args) => {
|
|
2219
|
+
const opts = { applicationId: args.applicationId };
|
|
1382
2220
|
const [carts, summary] = await Promise.all([
|
|
1383
|
-
optional(() => ctx.client.list("/api/v1/abandoned-carts", { ...page(args) })),
|
|
1384
|
-
optional(
|
|
2221
|
+
optional(() => ctx.client.list("/api/v1/abandoned-carts", { ...page(args) }, opts)),
|
|
2222
|
+
optional(
|
|
2223
|
+
() => ctx.client.get("/api/v1/abandoned-carts/summary", { sinceDays: args.sinceDays }, opts)
|
|
2224
|
+
)
|
|
1385
2225
|
]);
|
|
1386
2226
|
return {
|
|
1387
2227
|
carts: carts.ok ? carts.value.data : carts.unavailable,
|
|
@@ -1389,18 +2229,29 @@ var HANDLERS = {
|
|
|
1389
2229
|
};
|
|
1390
2230
|
},
|
|
1391
2231
|
// --------------------------------------------------------------- debugging
|
|
1392
|
-
search_events: async (ctx, args) => ctx.client.list(
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
2232
|
+
search_events: async (ctx, args) => ctx.client.list(
|
|
2233
|
+
"/api/v1/events",
|
|
2234
|
+
{
|
|
2235
|
+
type: args.type,
|
|
2236
|
+
entityType: args.entityType,
|
|
2237
|
+
entityId: args.entityId,
|
|
2238
|
+
...page(args)
|
|
2239
|
+
},
|
|
2240
|
+
{ applicationId: args.applicationId }
|
|
2241
|
+
),
|
|
2242
|
+
list_webhook_deliveries: async (ctx, args) => ctx.client.list(
|
|
2243
|
+
"/api/v1/webhook-deliveries",
|
|
2244
|
+
{
|
|
2245
|
+
endpointId: args.endpointId,
|
|
2246
|
+
status: args.status,
|
|
2247
|
+
eventType: args.eventType,
|
|
2248
|
+
limit: args.limit
|
|
2249
|
+
},
|
|
2250
|
+
{ applicationId: args.applicationId }
|
|
2251
|
+
),
|
|
2252
|
+
get_webhook_delivery: async (ctx, args) => ctx.client.get(`/api/v1/webhook-deliveries/${String(args.id)}`, void 0, {
|
|
2253
|
+
applicationId: args.applicationId
|
|
1402
2254
|
}),
|
|
1403
|
-
get_webhook_delivery: async (ctx, args) => ctx.client.get(`/api/v1/webhook-deliveries/${String(args.id)}`),
|
|
1404
2255
|
send_test_webhook: async (ctx, args) => ctx.client.post(`/api/v1/webhook-endpoints/${String(args.id)}/test`, {
|
|
1405
2256
|
body: { eventType: args.eventType },
|
|
1406
2257
|
idempotencyKey: `mcp-send-test-webhook-${String(args.id)}-${Date.now()}`
|
|
@@ -1410,18 +2261,21 @@ var HANDLERS = {
|
|
|
1410
2261
|
}),
|
|
1411
2262
|
explain_checkout_failure: async (ctx, args) => {
|
|
1412
2263
|
const id = String(args.id);
|
|
1413
|
-
const
|
|
2264
|
+
const opts = { applicationId: args.applicationId };
|
|
2265
|
+
const session = await optional(
|
|
2266
|
+
() => ctx.client.get(`/api/v1/checkout-sessions/${id}`, void 0, opts)
|
|
2267
|
+
);
|
|
1414
2268
|
if (!session.ok) {
|
|
1415
2269
|
return {
|
|
1416
|
-
note: `No checkout session ${id} (${session.unavailable}). If this is a cart id,
|
|
2270
|
+
note: `No checkout session ${id} (${session.unavailable}). If this is a cart id, use search_events for its activity (or read /api/v1/carts/${id} with api_get, where that tool is available).`
|
|
1417
2271
|
};
|
|
1418
2272
|
}
|
|
1419
2273
|
const cartId = session.value?.cartId ?? void 0;
|
|
1420
2274
|
const [cart, sessionEvents, cartEvents, deliveries] = await Promise.all([
|
|
1421
|
-
optional(() => ctx.client.get(`/api/v1/checkout-sessions/${id}/cart
|
|
1422
|
-
optional(() => ctx.client.list("/api/v1/events", { entityId: id, limit: 25 })),
|
|
1423
|
-
cartId ? optional(() => ctx.client.list("/api/v1/events", { entityId: cartId, limit: 25 })) : Promise.resolve({ ok: true, value: { data: [], pagination: null } }),
|
|
1424
|
-
optional(() => ctx.client.list("/api/v1/webhook-deliveries", { limit: 15 }))
|
|
2275
|
+
optional(() => ctx.client.get(`/api/v1/checkout-sessions/${id}/cart`, void 0, opts)),
|
|
2276
|
+
optional(() => ctx.client.list("/api/v1/events", { entityId: id, limit: 25 }, opts)),
|
|
2277
|
+
cartId ? optional(() => ctx.client.list("/api/v1/events", { entityId: cartId, limit: 25 }, opts)) : Promise.resolve({ ok: true, value: { data: [], pagination: null } }),
|
|
2278
|
+
optional(() => ctx.client.list("/api/v1/webhook-deliveries", { limit: 15 }, opts))
|
|
1425
2279
|
]);
|
|
1426
2280
|
return {
|
|
1427
2281
|
session: session.value,
|
|
@@ -1481,6 +2335,73 @@ var HANDLERS = {
|
|
|
1481
2335
|
note: "Seeded a finalized DRAFT order. No payment was captured \u2014 that needs a browser-tokenised payment method, which a server-side key cannot produce."
|
|
1482
2336
|
};
|
|
1483
2337
|
},
|
|
2338
|
+
// ---------------------------------------------------------- inbound writes
|
|
2339
|
+
create_customer: async (ctx, args) => ctx.client.post("/api/v1/customers", {
|
|
2340
|
+
// `createCustomerBody` is `.strict()`, so only fields it declares may be
|
|
2341
|
+
// sent; `undefined` values drop out at JSON.stringify.
|
|
2342
|
+
body: {
|
|
2343
|
+
email: args.email,
|
|
2344
|
+
firstName: args.firstName,
|
|
2345
|
+
lastName: args.lastName,
|
|
2346
|
+
phone: args.phone,
|
|
2347
|
+
company: args.company,
|
|
2348
|
+
externalId: args.externalId,
|
|
2349
|
+
netN: args.netN,
|
|
2350
|
+
acceptsMarketing: args.acceptsMarketing
|
|
2351
|
+
},
|
|
2352
|
+
idempotencyKey: `mcp-create-customer-${String(args.email)}-${Date.now()}`
|
|
2353
|
+
}),
|
|
2354
|
+
update_customer: async (ctx, args) => ctx.client.patch(`/api/v1/customers/${String(args.id)}`, {
|
|
2355
|
+
// `id` is the path parameter, not a body field — `updateCustomerBody` is
|
|
2356
|
+
// `.strict()` and would reject it. A null `externalId` is meaningful
|
|
2357
|
+
// (it clears the value), so only `undefined` is dropped.
|
|
2358
|
+
body: {
|
|
2359
|
+
email: args.email,
|
|
2360
|
+
firstName: args.firstName,
|
|
2361
|
+
lastName: args.lastName,
|
|
2362
|
+
phone: args.phone,
|
|
2363
|
+
company: args.company,
|
|
2364
|
+
externalId: args.externalId,
|
|
2365
|
+
netN: args.netN,
|
|
2366
|
+
acceptsMarketing: args.acceptsMarketing
|
|
2367
|
+
},
|
|
2368
|
+
idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
|
|
2369
|
+
}),
|
|
2370
|
+
create_checkout_link: async (ctx, args) => {
|
|
2371
|
+
const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
|
|
2372
|
+
if (lineItems.length === 0) {
|
|
2373
|
+
throw new Error("create_checkout_link: lineItems must contain at least one item.");
|
|
2374
|
+
}
|
|
2375
|
+
const stamp = Date.now();
|
|
2376
|
+
const applicationId = ctx.identity.application?.id;
|
|
2377
|
+
const cart = await ctx.client.post("/api/v1/carts", {
|
|
2378
|
+
body: {
|
|
2379
|
+
applicationId,
|
|
2380
|
+
customerId: args.customerId,
|
|
2381
|
+
customerEmail: args.customerEmail,
|
|
2382
|
+
netN: args.netN
|
|
2383
|
+
},
|
|
2384
|
+
idempotencyKey: `mcp-checkout-link-cart-${stamp}`
|
|
2385
|
+
});
|
|
2386
|
+
for (const [index, item] of lineItems.entries()) {
|
|
2387
|
+
await ctx.client.post(`/api/v1/carts/${cart?.id}/items`, {
|
|
2388
|
+
body: item,
|
|
2389
|
+
idempotencyKey: `mcp-checkout-link-item-${stamp}-${index}`
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2392
|
+
const session = await ctx.client.post("/api/v1/checkout/sessions", {
|
|
2393
|
+
body: {
|
|
2394
|
+
applicationId,
|
|
2395
|
+
cartId: cart?.id,
|
|
2396
|
+
returnUrl: args.returnUrl,
|
|
2397
|
+
cancelUrl: args.cancelUrl,
|
|
2398
|
+
customerEmail: args.customerEmail,
|
|
2399
|
+
discountCode: args.discountCode
|
|
2400
|
+
},
|
|
2401
|
+
idempotencyKey: `mcp-checkout-link-session-${stamp}`
|
|
2402
|
+
});
|
|
2403
|
+
return { cartId: cart?.id, ...session };
|
|
2404
|
+
},
|
|
1484
2405
|
// -------------------------------------------------------------- money/mail
|
|
1485
2406
|
manage_subscription: async (ctx, args) => {
|
|
1486
2407
|
const id = String(args.id);
|
|
@@ -1510,17 +2431,118 @@ var HANDLERS = {
|
|
|
1510
2431
|
idempotencyKey: `mcp-create-quote-${String(args.customerId)}-${Date.now()}`
|
|
1511
2432
|
})
|
|
1512
2433
|
),
|
|
1513
|
-
|
|
1514
|
-
|
|
2434
|
+
get_sales_timeseries: async (ctx, args) => ctx.client.get(
|
|
2435
|
+
"/api/v1/analytics/orders-timeseries",
|
|
2436
|
+
{
|
|
2437
|
+
from: args.from,
|
|
2438
|
+
to: args.to,
|
|
2439
|
+
groupBy: args.groupBy,
|
|
2440
|
+
timezone: args.timezone,
|
|
2441
|
+
compareTo: args.compareTo
|
|
2442
|
+
},
|
|
2443
|
+
{ applicationId: args.applicationId }
|
|
2444
|
+
),
|
|
2445
|
+
get_business_summary: async (ctx, args) => ctx.client.get(
|
|
2446
|
+
"/api/v1/analytics/business-summary",
|
|
2447
|
+
{
|
|
2448
|
+
period: args.period,
|
|
2449
|
+
from: args.from,
|
|
2450
|
+
to: args.to,
|
|
2451
|
+
timezone: args.timezone
|
|
2452
|
+
},
|
|
2453
|
+
{ applicationId: args.applicationId }
|
|
2454
|
+
),
|
|
2455
|
+
get_attention_digest: async (ctx, args) => ctx.client.get("/api/v1/analytics/attention-digest", void 0, {
|
|
2456
|
+
applicationId: args.applicationId
|
|
2457
|
+
}),
|
|
2458
|
+
get_top_products: async (ctx, args) => ctx.client.get(
|
|
2459
|
+
"/api/v1/analytics/products",
|
|
2460
|
+
{
|
|
2461
|
+
from: args.from,
|
|
2462
|
+
to: args.to,
|
|
2463
|
+
timezone: args.timezone,
|
|
2464
|
+
by: args.by,
|
|
2465
|
+
limit: args.limit
|
|
2466
|
+
},
|
|
2467
|
+
{ applicationId: args.applicationId }
|
|
2468
|
+
),
|
|
2469
|
+
// `.get()`, not `.list()` — the response is a single object (`{ data: {
|
|
2470
|
+
// range, signups, ordersByCustomerType, topCustomers, totals } }`), and
|
|
2471
|
+
// `.list()` only unwraps arrays: it would silently return an empty list
|
|
2472
|
+
// instead of the real payload.
|
|
2473
|
+
get_customer_growth: async (ctx, args) => ctx.client.get(
|
|
2474
|
+
"/api/v1/analytics/customers",
|
|
2475
|
+
{
|
|
2476
|
+
from: args.from,
|
|
2477
|
+
to: args.to,
|
|
2478
|
+
groupBy: args.groupBy,
|
|
2479
|
+
timezone: args.timezone,
|
|
2480
|
+
topBy: args.topBy,
|
|
2481
|
+
topLimit: args.topLimit
|
|
2482
|
+
},
|
|
2483
|
+
{ applicationId: args.applicationId }
|
|
2484
|
+
),
|
|
2485
|
+
// `.get()`, not `.list()` — the response is a single object (`{ data: {
|
|
2486
|
+
// range, dimension, rows, totals, note } }`), not a paginated array.
|
|
2487
|
+
get_revenue_breakdown: async (ctx, args) => ctx.client.get(
|
|
2488
|
+
"/api/v1/analytics/revenue-breakdown",
|
|
2489
|
+
{
|
|
2490
|
+
dimension: args.dimension,
|
|
2491
|
+
from: args.from,
|
|
2492
|
+
to: args.to,
|
|
2493
|
+
timezone: args.timezone
|
|
2494
|
+
},
|
|
2495
|
+
{ applicationId: args.applicationId }
|
|
2496
|
+
),
|
|
2497
|
+
// `.get()`, not `.list()` — the response is a single object (`{ data: {
|
|
2498
|
+
// range, stages, conversionRate, dropOff, note } }`), not a paginated array.
|
|
2499
|
+
get_funnel_conversion: async (ctx, args) => ctx.client.get(
|
|
2500
|
+
"/api/v1/analytics/funnel",
|
|
2501
|
+
{
|
|
2502
|
+
from: args.from,
|
|
2503
|
+
to: args.to,
|
|
2504
|
+
timezone: args.timezone
|
|
2505
|
+
},
|
|
2506
|
+
{ applicationId: args.applicationId }
|
|
2507
|
+
),
|
|
2508
|
+
// `.get()`, not `.list()` — the response is a single object (`{ data: {
|
|
2509
|
+
// range, series, totals, note } }`), not a paginated array.
|
|
2510
|
+
get_subscription_movement: async (ctx, args) => ctx.client.get(
|
|
2511
|
+
"/api/v1/analytics/subscriptions",
|
|
2512
|
+
{
|
|
2513
|
+
from: args.from,
|
|
2514
|
+
to: args.to,
|
|
2515
|
+
timezone: args.timezone,
|
|
2516
|
+
groupBy: args.groupBy
|
|
2517
|
+
},
|
|
2518
|
+
{ applicationId: args.applicationId }
|
|
2519
|
+
),
|
|
2520
|
+
// `.get()`, not `.list()` — the response is a single object (`{ data: {
|
|
2521
|
+
// range, rows, totals, note } }`), not a paginated array.
|
|
2522
|
+
get_discount_performance: async (ctx, args) => ctx.client.get(
|
|
2523
|
+
"/api/v1/analytics/discounts",
|
|
2524
|
+
{
|
|
2525
|
+
from: args.from,
|
|
2526
|
+
to: args.to,
|
|
2527
|
+
timezone: args.timezone,
|
|
2528
|
+
limit: args.limit
|
|
2529
|
+
},
|
|
2530
|
+
{ applicationId: args.applicationId }
|
|
2531
|
+
),
|
|
1515
2532
|
// ------------------------------------------------------------- extensions
|
|
1516
|
-
list_extension_installations: async (ctx, args) => ctx.client.list(
|
|
2533
|
+
list_extension_installations: async (ctx, args) => ctx.client.list(
|
|
2534
|
+
"/api/v1/installations",
|
|
2535
|
+
{ status: args.status, ...page(args) },
|
|
2536
|
+
{ applicationId: args.applicationId }
|
|
2537
|
+
),
|
|
1517
2538
|
// ------------------------------------------------------------- connectors
|
|
1518
|
-
get_connector_routing: async (ctx) => {
|
|
2539
|
+
get_connector_routing: async (ctx, args) => {
|
|
2540
|
+
const opts = { applicationId: args.applicationId };
|
|
1519
2541
|
const [paymentRouting, routingConnectors, cardDecline, otherDecline] = await Promise.all([
|
|
1520
|
-
optional(() => ctx.client.get("/api/v1/payment-routing")),
|
|
1521
|
-
optional(() => ctx.client.get("/api/v1/routing-connectors")),
|
|
1522
|
-
optional(() => ctx.client.get("/api/v1/card-decline")),
|
|
1523
|
-
optional(() => ctx.client.get("/api/v1/other-decline"))
|
|
2542
|
+
optional(() => ctx.client.get("/api/v1/payment-routing", void 0, opts)),
|
|
2543
|
+
optional(() => ctx.client.get("/api/v1/routing-connectors", void 0, opts)),
|
|
2544
|
+
optional(() => ctx.client.get("/api/v1/card-decline", void 0, opts)),
|
|
2545
|
+
optional(() => ctx.client.get("/api/v1/other-decline", void 0, opts))
|
|
1524
2546
|
]);
|
|
1525
2547
|
return {
|
|
1526
2548
|
paymentRouting: paymentRouting.ok ? paymentRouting.value : paymentRouting.unavailable,
|
|
@@ -1529,24 +2551,37 @@ var HANDLERS = {
|
|
|
1529
2551
|
otherDecline: otherDecline.ok ? otherDecline.value : otherDecline.unavailable
|
|
1530
2552
|
};
|
|
1531
2553
|
},
|
|
1532
|
-
get_integration_status: async (ctx) => {
|
|
2554
|
+
get_integration_status: async (ctx, args) => {
|
|
2555
|
+
const opts = { applicationId: args.applicationId };
|
|
1533
2556
|
const [connectors, endpoints, coverage] = await Promise.all([
|
|
1534
|
-
optional(() => ctx.client.list("/api/v1/connectors")),
|
|
1535
|
-
optional(() => ctx.client.list("/api/v1/webhook-endpoints")),
|
|
1536
|
-
optional(() => ctx.client.get("/api/v1/webhook-endpoints/coverage"))
|
|
2557
|
+
optional(() => ctx.client.list("/api/v1/connectors", void 0, opts)),
|
|
2558
|
+
optional(() => ctx.client.list("/api/v1/webhook-endpoints", void 0, opts)),
|
|
2559
|
+
optional(() => ctx.client.get("/api/v1/webhook-endpoints/coverage", void 0, opts))
|
|
1537
2560
|
]);
|
|
2561
|
+
const overridden = Boolean(args.applicationId) && args.applicationId !== ctx.identity.application?.id;
|
|
1538
2562
|
return {
|
|
1539
2563
|
environment: ctx.identity.environment,
|
|
1540
2564
|
workspace: ctx.identity.workspace,
|
|
1541
|
-
|
|
2565
|
+
applicationId: args.applicationId ?? ctx.identity.application?.id ?? null,
|
|
2566
|
+
application: overridden ? void 0 : ctx.identity.application,
|
|
1542
2567
|
connectors: connectors.ok ? connectors.value.data : connectors.unavailable,
|
|
1543
2568
|
webhookEndpoints: endpoints.ok ? endpoints.value.data : endpoints.unavailable,
|
|
1544
2569
|
unsubscribedEvents: coverage.ok ? coverage.value : coverage.unavailable
|
|
1545
2570
|
};
|
|
1546
2571
|
},
|
|
1547
2572
|
// --------------------------------------------------------------- workspace
|
|
2573
|
+
// No applicationId forwarding here: /api/v1/merchants/me is workspace-only
|
|
2574
|
+
// (`WHERE workspace_id = ...`, never reads auth.applicationId) — an
|
|
2575
|
+
// applicationId field on this tool would be a silent no-op affordance.
|
|
1548
2576
|
get_workspace_settings: async (ctx) => ctx.client.get("/api/v1/merchants/me"),
|
|
1549
|
-
|
|
2577
|
+
// No applicationId forwarding here either: /api/v1/audit-log filters by
|
|
2578
|
+
// workspaceId (and optionally environmentId), never applicationId.
|
|
2579
|
+
get_audit_log: async (ctx, args) => ctx.client.list("/api/v1/audit-log", { limit: args.limit }),
|
|
2580
|
+
// --------------------------------------------------------- applications
|
|
2581
|
+
// `.get()`, not `.list()` — the legacy /v1/stores route returns a bare
|
|
2582
|
+
// array with no `meta.pagination`, and the brief calls for `.get()` here
|
|
2583
|
+
// specifically.
|
|
2584
|
+
list_applications: async (ctx) => ctx.client.get("/api/v1/stores")
|
|
1550
2585
|
};
|
|
1551
2586
|
|
|
1552
2587
|
// src/input.ts
|
|
@@ -1581,15 +2616,548 @@ function applyModifiers(field, type) {
|
|
|
1581
2616
|
return field.default === void 0 ? described.optional() : described.default(field.default);
|
|
1582
2617
|
}
|
|
1583
2618
|
|
|
2619
|
+
// src/projection.ts
|
|
2620
|
+
var S = "scalar";
|
|
2621
|
+
var T = "text";
|
|
2622
|
+
var PASS = "pass";
|
|
2623
|
+
var section = (shape) => ({ __section: shape });
|
|
2624
|
+
var oneOf = (values) => ({ __oneOf: new Set(values) });
|
|
2625
|
+
function isPrimitive(value) {
|
|
2626
|
+
return value === null || ["string", "number", "boolean"].includes(typeof value);
|
|
2627
|
+
}
|
|
2628
|
+
var TOKEN = /^[^\s@]{0,200}$/;
|
|
2629
|
+
var OMITTED = { omitted: S, grantable: T, reason: T };
|
|
2630
|
+
var UNAVAILABLE = /^(not readable with this credential \(missing scope\)|not found|unavailable \([^\s@]{0,100}\))$/;
|
|
2631
|
+
function project(value, shape) {
|
|
2632
|
+
if (value === void 0) return void 0;
|
|
2633
|
+
if (shape === PASS) return value;
|
|
2634
|
+
if (shape === S) {
|
|
2635
|
+
if (!isPrimitive(value)) return void 0;
|
|
2636
|
+
return typeof value === "string" && !TOKEN.test(value) ? null : value;
|
|
2637
|
+
}
|
|
2638
|
+
if (shape === T) return isPrimitive(value) ? value : void 0;
|
|
2639
|
+
if ("__oneOf" in shape) {
|
|
2640
|
+
if (!isPrimitive(value)) return void 0;
|
|
2641
|
+
return typeof value === "string" && !shape.__oneOf.has(value) ? null : value;
|
|
2642
|
+
}
|
|
2643
|
+
if (Array.isArray(shape)) {
|
|
2644
|
+
return Array.isArray(value) ? value.map((item) => project(item, shape[0])) : void 0;
|
|
2645
|
+
}
|
|
2646
|
+
if ("__section" in shape) {
|
|
2647
|
+
if (typeof value === "string") return UNAVAILABLE.test(value) ? value : null;
|
|
2648
|
+
if (value && typeof value === "object" && value.omitted === true) {
|
|
2649
|
+
return project(value, OMITTED);
|
|
2650
|
+
}
|
|
2651
|
+
return project(value, shape.__section);
|
|
2652
|
+
}
|
|
2653
|
+
if (value === null) return null;
|
|
2654
|
+
if (typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
2655
|
+
const out = {};
|
|
2656
|
+
for (const [key, child] of Object.entries(shape)) {
|
|
2657
|
+
const projected = project(value[key], child);
|
|
2658
|
+
if (projected !== void 0) out[key] = projected;
|
|
2659
|
+
}
|
|
2660
|
+
return out;
|
|
2661
|
+
}
|
|
2662
|
+
var PAGINATION = { cursor: S, nextCursor: S, hasMore: S };
|
|
2663
|
+
var page2 = (row) => ({ data: [row], pagination: PAGINATION });
|
|
2664
|
+
var ADDRESS = { countryCode: S };
|
|
2665
|
+
var CUSTOMER_REF = { id: S };
|
|
2666
|
+
var APPLICATION = { id: S, name: T, slug: S };
|
|
2667
|
+
var LIFECYCLE_LABELS = ["Draft", "Pending", "Processing", "Partially fulfilled", "Fulfilled", "Cancelled", "Closed"];
|
|
2668
|
+
var DISPLAY_QUALIFIERS = [
|
|
2669
|
+
"Comped",
|
|
2670
|
+
"Awaiting payment",
|
|
2671
|
+
"Authorized",
|
|
2672
|
+
"Partially paid",
|
|
2673
|
+
"Partially refunded",
|
|
2674
|
+
"Refunded",
|
|
2675
|
+
"Payment failed",
|
|
2676
|
+
"Voided",
|
|
2677
|
+
"Payment processing",
|
|
2678
|
+
"Disputed",
|
|
2679
|
+
"Authorization expired",
|
|
2680
|
+
"Returned",
|
|
2681
|
+
"Partially returned",
|
|
2682
|
+
"Delivered",
|
|
2683
|
+
"In transit"
|
|
2684
|
+
];
|
|
2685
|
+
var ORDER_DISPLAY_STATUSES = new Set(
|
|
2686
|
+
LIFECYCLE_LABELS.flatMap((l) => [l, ...DISPLAY_QUALIFIERS.map((q) => `${l} \xB7 ${q}`)])
|
|
2687
|
+
);
|
|
2688
|
+
var DISPLAY_STATUS = oneOf(ORDER_DISPLAY_STATUSES);
|
|
2689
|
+
var RANGE = { from: S, to: S, timezone: S, groupBy: S };
|
|
2690
|
+
var LINE_ITEM = {
|
|
2691
|
+
id: S,
|
|
2692
|
+
type: S,
|
|
2693
|
+
quantity: S,
|
|
2694
|
+
unitPrice: S,
|
|
2695
|
+
subtotal: S,
|
|
2696
|
+
discountAmount: S,
|
|
2697
|
+
taxAmount: S,
|
|
2698
|
+
total: S,
|
|
2699
|
+
recurring: S
|
|
2700
|
+
};
|
|
2701
|
+
var ORDER = {
|
|
2702
|
+
id: S,
|
|
2703
|
+
orderNumber: S,
|
|
2704
|
+
status: S,
|
|
2705
|
+
displayStatus: DISPLAY_STATUS,
|
|
2706
|
+
paymentStatus: S,
|
|
2707
|
+
type: S,
|
|
2708
|
+
source: S,
|
|
2709
|
+
currency: S,
|
|
2710
|
+
subtotal: S,
|
|
2711
|
+
discountTotal: S,
|
|
2712
|
+
shippingTotal: S,
|
|
2713
|
+
taxTotal: S,
|
|
2714
|
+
total: S,
|
|
2715
|
+
capturedAmount: S,
|
|
2716
|
+
refundedAmount: S,
|
|
2717
|
+
compAmount: S,
|
|
2718
|
+
onHold: S,
|
|
2719
|
+
taxReverseCharge: S,
|
|
2720
|
+
customerId: S,
|
|
2721
|
+
customer: CUSTOMER_REF,
|
|
2722
|
+
subscriptionId: S,
|
|
2723
|
+
shippingAddress: ADDRESS,
|
|
2724
|
+
billingAddress: ADDRESS,
|
|
2725
|
+
fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
|
|
2726
|
+
lineItems: [LINE_ITEM],
|
|
2727
|
+
createdAt: S,
|
|
2728
|
+
completedAt: S,
|
|
2729
|
+
cancelledAt: S,
|
|
2730
|
+
closedAt: S
|
|
2731
|
+
};
|
|
2732
|
+
var PAYMENT = {
|
|
2733
|
+
id: S,
|
|
2734
|
+
orderId: S,
|
|
2735
|
+
status: S,
|
|
2736
|
+
method: S,
|
|
2737
|
+
processor: S,
|
|
2738
|
+
amount: S,
|
|
2739
|
+
capturedAmount: S,
|
|
2740
|
+
currency: S,
|
|
2741
|
+
cardBrand: S,
|
|
2742
|
+
disputed: S,
|
|
2743
|
+
disputeOpenedAt: S,
|
|
2744
|
+
errorCode: S,
|
|
2745
|
+
netN: S,
|
|
2746
|
+
netNSource: S,
|
|
2747
|
+
authorizedAt: S,
|
|
2748
|
+
capturedAt: S,
|
|
2749
|
+
voidedAt: S,
|
|
2750
|
+
createdAt: S
|
|
2751
|
+
};
|
|
2752
|
+
var RETURN = {
|
|
2753
|
+
id: S,
|
|
2754
|
+
orderId: S,
|
|
2755
|
+
status: S,
|
|
2756
|
+
restock: S,
|
|
2757
|
+
refundAmount: S,
|
|
2758
|
+
refundPaymentId: S,
|
|
2759
|
+
createdAt: S,
|
|
2760
|
+
items: [{ lineItemId: S, quantity: S }]
|
|
2761
|
+
};
|
|
2762
|
+
var FULFILLMENT = {
|
|
2763
|
+
id: S,
|
|
2764
|
+
orderId: S,
|
|
2765
|
+
type: S,
|
|
2766
|
+
status: S,
|
|
2767
|
+
createdAt: S,
|
|
2768
|
+
lineItems: [{ lineItemId: S, quantity: S }],
|
|
2769
|
+
detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
|
|
2770
|
+
};
|
|
2771
|
+
var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
|
|
2772
|
+
var SUBSCRIPTION = {
|
|
2773
|
+
id: S,
|
|
2774
|
+
status: S,
|
|
2775
|
+
planName: T,
|
|
2776
|
+
planReference: T,
|
|
2777
|
+
amount: S,
|
|
2778
|
+
currency: S,
|
|
2779
|
+
interval: S,
|
|
2780
|
+
quantity: S,
|
|
2781
|
+
intervalUnit: S,
|
|
2782
|
+
intervalCount: S,
|
|
2783
|
+
totalPayments: S,
|
|
2784
|
+
paymentsMade: S,
|
|
2785
|
+
completedAt: S,
|
|
2786
|
+
customerId: S,
|
|
2787
|
+
customer: CUSTOMER_REF,
|
|
2788
|
+
currentPeriodStart: S,
|
|
2789
|
+
currentPeriodEnd: S,
|
|
2790
|
+
billingAnchorAt: S,
|
|
2791
|
+
cancelAtPeriodEnd: S,
|
|
2792
|
+
trialEnd: S,
|
|
2793
|
+
pausedAt: S,
|
|
2794
|
+
cancelledAt: S,
|
|
2795
|
+
lastPaymentAt: S,
|
|
2796
|
+
failureCount: S,
|
|
2797
|
+
pendingPlanName: T,
|
|
2798
|
+
pendingPlanReference: T,
|
|
2799
|
+
pendingAmount: S,
|
|
2800
|
+
pendingInterval: S,
|
|
2801
|
+
pendingQuantity: S,
|
|
2802
|
+
pendingIntervalUnit: S,
|
|
2803
|
+
pendingIntervalCount: S,
|
|
2804
|
+
createdAt: S
|
|
2805
|
+
};
|
|
2806
|
+
var QUOTE_SUMMARY = {
|
|
2807
|
+
id: S,
|
|
2808
|
+
quoteNumber: S,
|
|
2809
|
+
status: S,
|
|
2810
|
+
source: S,
|
|
2811
|
+
currency: S,
|
|
2812
|
+
total: S,
|
|
2813
|
+
customerId: S,
|
|
2814
|
+
orderId: S,
|
|
2815
|
+
expiresAt: S,
|
|
2816
|
+
acceptedAt: S,
|
|
2817
|
+
declinedAt: S,
|
|
2818
|
+
createdAt: S
|
|
2819
|
+
};
|
|
2820
|
+
var QUOTE = {
|
|
2821
|
+
...QUOTE_SUMMARY,
|
|
2822
|
+
revisions: [{
|
|
2823
|
+
id: S,
|
|
2824
|
+
revisionNumber: S,
|
|
2825
|
+
state: S,
|
|
2826
|
+
subtotal: S,
|
|
2827
|
+
discountTotal: S,
|
|
2828
|
+
shippingTotal: S,
|
|
2829
|
+
taxTotal: S,
|
|
2830
|
+
total: S,
|
|
2831
|
+
depositAmount: S,
|
|
2832
|
+
shippingMode: S,
|
|
2833
|
+
issuedAt: S,
|
|
2834
|
+
expiresAt: S,
|
|
2835
|
+
paymentTerms: { mode: S, netN: S, balanceNetN: S, deposit: { type: S, value: S } },
|
|
2836
|
+
items: [{
|
|
2837
|
+
type: S,
|
|
2838
|
+
quantity: S,
|
|
2839
|
+
unitPrice: S,
|
|
2840
|
+
subtotal: S,
|
|
2841
|
+
discountAmount: S,
|
|
2842
|
+
taxAmount: S,
|
|
2843
|
+
total: S,
|
|
2844
|
+
optional: S,
|
|
2845
|
+
optionalSelected: S
|
|
2846
|
+
}]
|
|
2847
|
+
}],
|
|
2848
|
+
// Who commented and when, never what they wrote.
|
|
2849
|
+
comments: [{ authorType: S, visibility: S, createdAt: S }],
|
|
2850
|
+
timeline: [{ type: S, actorType: S, createdAt: S }]
|
|
2851
|
+
};
|
|
2852
|
+
var INVOICE = {
|
|
2853
|
+
id: S,
|
|
2854
|
+
number: S,
|
|
2855
|
+
status: S,
|
|
2856
|
+
sourceType: S,
|
|
2857
|
+
sourceId: S,
|
|
2858
|
+
customerId: S,
|
|
2859
|
+
currency: S,
|
|
2860
|
+
subtotal: S,
|
|
2861
|
+
discountTotal: S,
|
|
2862
|
+
shippingTotal: S,
|
|
2863
|
+
taxTotal: S,
|
|
2864
|
+
total: S,
|
|
2865
|
+
amountRefunded: S,
|
|
2866
|
+
issuedAt: S,
|
|
2867
|
+
dueAt: S,
|
|
2868
|
+
periodStart: S,
|
|
2869
|
+
periodEnd: S,
|
|
2870
|
+
createdAt: S,
|
|
2871
|
+
billingSnapshot: {
|
|
2872
|
+
planName: T,
|
|
2873
|
+
period: { start: S, end: S },
|
|
2874
|
+
lineItems: [{ quantity: S, unitPrice: S, discountAmount: S, taxAmount: S, total: S }],
|
|
2875
|
+
totals: { currency: S, subtotal: S, discountTotal: S, shippingTotal: S, taxTotal: S, total: S },
|
|
2876
|
+
payment: { method: S, brand: S, status: S }
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2879
|
+
var DISCOUNT = {
|
|
2880
|
+
id: S,
|
|
2881
|
+
code: T,
|
|
2882
|
+
name: T,
|
|
2883
|
+
type: S,
|
|
2884
|
+
value: S,
|
|
2885
|
+
isActive: S,
|
|
2886
|
+
startsAt: S,
|
|
2887
|
+
endsAt: S,
|
|
2888
|
+
usageCount: S,
|
|
2889
|
+
usageLimit: S,
|
|
2890
|
+
maxRedemptionsPerCustomer: S,
|
|
2891
|
+
createdAt: S
|
|
2892
|
+
};
|
|
2893
|
+
var EVENT = {
|
|
2894
|
+
id: S,
|
|
2895
|
+
type: S,
|
|
2896
|
+
entityType: S,
|
|
2897
|
+
entityId: S,
|
|
2898
|
+
createdAt: S,
|
|
2899
|
+
data: {
|
|
2900
|
+
status: S,
|
|
2901
|
+
previousStatus: S,
|
|
2902
|
+
action: S,
|
|
2903
|
+
amount: S,
|
|
2904
|
+
currency: S,
|
|
2905
|
+
attempt: S,
|
|
2906
|
+
orderId: S,
|
|
2907
|
+
paymentId: S,
|
|
2908
|
+
order: { id: S, orderNumber: S, status: S, paymentStatus: S, currency: S, total: S },
|
|
2909
|
+
payment: { id: S, orderId: S, status: S, method: S, amount: S, currency: S },
|
|
2910
|
+
subscription: { id: S, status: S, planName: T, amount: S, currency: S, interval: S },
|
|
2911
|
+
fulfillment: { id: S, orderId: S, type: S, status: S }
|
|
2912
|
+
}
|
|
2913
|
+
};
|
|
2914
|
+
var DELIVERY = {
|
|
2915
|
+
id: S,
|
|
2916
|
+
endpointId: S,
|
|
2917
|
+
eventId: S,
|
|
2918
|
+
eventType: S,
|
|
2919
|
+
status: S,
|
|
2920
|
+
attemptCount: S,
|
|
2921
|
+
lastStatus: S,
|
|
2922
|
+
deliveredAt: S,
|
|
2923
|
+
nextRetryAt: S,
|
|
2924
|
+
createdAt: S,
|
|
2925
|
+
replayOf: S
|
|
2926
|
+
};
|
|
2927
|
+
var MONEY_COUNT = { count: S, totalCents: S };
|
|
2928
|
+
var ORDER_PERIOD = { orderCount: S, grossCents: S, netCents: S, refundsCents: S, avgOrderCents: S };
|
|
2929
|
+
var OAUTH_PROJECTIONS = {
|
|
2930
|
+
whoami: {
|
|
2931
|
+
type: S,
|
|
2932
|
+
workspace: { name: T, slug: S },
|
|
2933
|
+
application: APPLICATION,
|
|
2934
|
+
environment: { slug: S, kind: S, providerEnvironment: S },
|
|
2935
|
+
note: T
|
|
2936
|
+
},
|
|
2937
|
+
search_docs: PASS,
|
|
2938
|
+
describe_endpoint: PASS,
|
|
2939
|
+
validate_payload: PASS,
|
|
2940
|
+
search_orders: page2(ORDER),
|
|
2941
|
+
get_order: {
|
|
2942
|
+
order: ORDER,
|
|
2943
|
+
payments: section([PAYMENT]),
|
|
2944
|
+
returns: section([RETURN]),
|
|
2945
|
+
fulfillments: section([FULFILLMENT])
|
|
2946
|
+
},
|
|
2947
|
+
search_customers: page2(CUSTOMER),
|
|
2948
|
+
get_customer: {
|
|
2949
|
+
customer: CUSTOMER,
|
|
2950
|
+
addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
|
|
2951
|
+
subscriptions: section([SUBSCRIPTION])
|
|
2952
|
+
},
|
|
2953
|
+
list_subscriptions: page2(SUBSCRIPTION),
|
|
2954
|
+
get_subscription: SUBSCRIPTION,
|
|
2955
|
+
search_quotes: page2(QUOTE_SUMMARY),
|
|
2956
|
+
get_quote: QUOTE,
|
|
2957
|
+
list_invoices: page2(INVOICE),
|
|
2958
|
+
get_invoice: INVOICE,
|
|
2959
|
+
receivables_aging: {
|
|
2960
|
+
buckets: [{ key: S, label: T, count: S, total_amount: S }],
|
|
2961
|
+
total_outstanding_amount: S,
|
|
2962
|
+
total_outstanding_count: S
|
|
2963
|
+
},
|
|
2964
|
+
search_discounts: page2(DISCOUNT),
|
|
2965
|
+
get_discount: DISCOUNT,
|
|
2966
|
+
search_payments: page2(PAYMENT),
|
|
2967
|
+
get_payment: {
|
|
2968
|
+
payment: PAYMENT,
|
|
2969
|
+
transactions: section([{ id: S, type: S, status: S, amount: S, currency: S, createdAt: S }])
|
|
2970
|
+
},
|
|
2971
|
+
list_abandoned_carts: {
|
|
2972
|
+
carts: section([{
|
|
2973
|
+
id: S,
|
|
2974
|
+
abandonedAt: S,
|
|
2975
|
+
currency: S,
|
|
2976
|
+
itemCount: S,
|
|
2977
|
+
recoveryStatus: S,
|
|
2978
|
+
total: S,
|
|
2979
|
+
customer: { id: S }
|
|
2980
|
+
}]),
|
|
2981
|
+
summary: section({ abandonedCount: S, abandonedValue: S, recoveryEmailsSent: S, sinceDays: S })
|
|
2982
|
+
},
|
|
2983
|
+
search_events: page2(EVENT),
|
|
2984
|
+
list_webhook_deliveries: page2(DELIVERY),
|
|
2985
|
+
get_webhook_delivery: DELIVERY,
|
|
2986
|
+
explain_checkout_failure: {
|
|
2987
|
+
note: T,
|
|
2988
|
+
hint: T,
|
|
2989
|
+
session: {
|
|
2990
|
+
id: S,
|
|
2991
|
+
status: S,
|
|
2992
|
+
cartId: S,
|
|
2993
|
+
customerId: S,
|
|
2994
|
+
expiresAt: S,
|
|
2995
|
+
completedAt: S,
|
|
2996
|
+
allowedMethods: [S],
|
|
2997
|
+
collect: { shippingAddress: S, billingAddress: S, vatNumber: S },
|
|
2998
|
+
shippingAddress: ADDRESS,
|
|
2999
|
+
billingAddress: ADDRESS,
|
|
3000
|
+
recurringTerms: {
|
|
3001
|
+
interval: S,
|
|
3002
|
+
intervalUnit: S,
|
|
3003
|
+
intervalCount: S,
|
|
3004
|
+
totalPayments: S,
|
|
3005
|
+
taxApplies: S,
|
|
3006
|
+
planChargedToday: S,
|
|
3007
|
+
planName: T,
|
|
3008
|
+
trialDays: S,
|
|
3009
|
+
currency: S,
|
|
3010
|
+
firstChargeAmountMinor: S
|
|
3011
|
+
}
|
|
3012
|
+
},
|
|
3013
|
+
cart: section({
|
|
3014
|
+
id: S,
|
|
3015
|
+
status: S,
|
|
3016
|
+
currency: S,
|
|
3017
|
+
subtotal: S,
|
|
3018
|
+
discountTotal: S,
|
|
3019
|
+
shippingTotal: S,
|
|
3020
|
+
taxTotal: S,
|
|
3021
|
+
total: S,
|
|
3022
|
+
itemCount: S,
|
|
3023
|
+
items: [LINE_ITEM],
|
|
3024
|
+
lineItems: [LINE_ITEM]
|
|
3025
|
+
}),
|
|
3026
|
+
events: [EVENT],
|
|
3027
|
+
eventsUnavailable: T,
|
|
3028
|
+
recentWebhookDeliveries: section([DELIVERY])
|
|
3029
|
+
},
|
|
3030
|
+
list_extension_installations: page2({
|
|
3031
|
+
id: S,
|
|
3032
|
+
extensionId: S,
|
|
3033
|
+
extensionName: T,
|
|
3034
|
+
extensionSlug: S,
|
|
3035
|
+
versionId: S,
|
|
3036
|
+
status: S,
|
|
3037
|
+
environmentSlug: S,
|
|
3038
|
+
installedAt: S,
|
|
3039
|
+
uninstalledAt: S
|
|
3040
|
+
}),
|
|
3041
|
+
get_connector_routing: {
|
|
3042
|
+
paymentRouting: section({
|
|
3043
|
+
defaultCascade: [S],
|
|
3044
|
+
rules: [{ cascade: [S], conditions: [{ type: S, op: S, currency: S, min: S, max: S, values: [S] }] }]
|
|
3045
|
+
}),
|
|
3046
|
+
cardDecline: section({ rules: [{ errorCode: S, conditions: [{ type: S, op: S, values: [S] }] }] }),
|
|
3047
|
+
otherDecline: section({ rules: [{ errorCode: S, conditions: [{ type: S, op: S, values: [S] }] }] }),
|
|
3048
|
+
routingConnectors: section([{ id: S, displayName: T, method: S }])
|
|
3049
|
+
},
|
|
3050
|
+
get_integration_status: {
|
|
3051
|
+
environment: { slug: S, kind: S, providerEnvironment: S },
|
|
3052
|
+
workspace: { name: T, slug: S },
|
|
3053
|
+
applicationId: S,
|
|
3054
|
+
application: APPLICATION,
|
|
3055
|
+
connectors: section([{
|
|
3056
|
+
id: S,
|
|
3057
|
+
displayName: T,
|
|
3058
|
+
method: S,
|
|
3059
|
+
type: S,
|
|
3060
|
+
status: S,
|
|
3061
|
+
active: S,
|
|
3062
|
+
position: S,
|
|
3063
|
+
acceptedCountries: [S],
|
|
3064
|
+
acceptedCurrencies: [S],
|
|
3065
|
+
threeDSecureEnabled: S,
|
|
3066
|
+
createdAt: S
|
|
3067
|
+
}]),
|
|
3068
|
+
webhookEndpoints: section([{ id: S, isActive: S, enabledEvents: [S], createdAt: S }]),
|
|
3069
|
+
unsubscribedEvents: section({ windowDays: S, unsubscribed: [{ type: S, count: S, lastEmittedAt: S }] })
|
|
3070
|
+
},
|
|
3071
|
+
get_workspace_settings: { name: T, slug: S, brandColor: S, logoUrl: T, onboardingCompletedAt: S },
|
|
3072
|
+
// What happened and to which record; not which team member did it.
|
|
3073
|
+
get_audit_log: page2({ id: S, action: S, resourceType: S, resourceId: S, createdAt: S }),
|
|
3074
|
+
list_applications: [{ id: S, name: T, slug: S, currency: S, isActive: S }],
|
|
3075
|
+
// Analytics: computed aggregates, listed field by field all the same.
|
|
3076
|
+
get_business_summary: {
|
|
3077
|
+
period: S,
|
|
3078
|
+
range: RANGE,
|
|
3079
|
+
orders: section({ current: ORDER_PERIOD, previous: ORDER_PERIOD, deltaPct: S }),
|
|
3080
|
+
subscriptions: section({
|
|
3081
|
+
mrr: { currentCents: S, periodStartCents: S, deltaPct: S },
|
|
3082
|
+
newSubscriptions: S,
|
|
3083
|
+
cancelledSubscriptions: S,
|
|
3084
|
+
churnRate: S,
|
|
3085
|
+
note: T
|
|
3086
|
+
}),
|
|
3087
|
+
receivables: section({ outstandingCents: S, outstandingCount: S }),
|
|
3088
|
+
quotes: section({ sent: MONEY_COUNT, accepted: MONEY_COUNT, declined: MONEY_COUNT, expired: MONEY_COUNT })
|
|
3089
|
+
},
|
|
3090
|
+
get_attention_digest: {
|
|
3091
|
+
disputes: section({ open: S, totalCents: S }),
|
|
3092
|
+
subscriptionsInDunning: section(S),
|
|
3093
|
+
overdueInvoices: section(MONEY_COUNT),
|
|
3094
|
+
unhealthyWebhooks: section([{ endpointId: S, failureRate: S, attempts7d: S }])
|
|
3095
|
+
},
|
|
3096
|
+
get_sales_timeseries: {
|
|
3097
|
+
application: APPLICATION,
|
|
3098
|
+
range: RANGE,
|
|
3099
|
+
currency: S,
|
|
3100
|
+
days: S,
|
|
3101
|
+
note: T,
|
|
3102
|
+
series: [{ date: S, grossCents: S, orders: S }],
|
|
3103
|
+
totalGrossCents: S,
|
|
3104
|
+
totalOrders: S
|
|
3105
|
+
},
|
|
3106
|
+
// get_top_products has no entry, so it is not offered over OAuth: it ranks
|
|
3107
|
+
// products by line-item reference id or name, which a buyer can type.
|
|
3108
|
+
get_customer_growth: {
|
|
3109
|
+
application: APPLICATION,
|
|
3110
|
+
range: RANGE,
|
|
3111
|
+
note: T,
|
|
3112
|
+
topBy: S,
|
|
3113
|
+
signups: { total: S, series: [{ date: S, signups: S }] },
|
|
3114
|
+
ordersByCustomerType: { newCustomerOrders: S, returningCustomerOrders: S },
|
|
3115
|
+
// The ranking, by id: a top customer's name and email stay behind.
|
|
3116
|
+
topCustomers: [{ customerId: S, orderCount: S, revenueCents: S }],
|
|
3117
|
+
totals: { customerCount: S, orderCount: S, revenueCents: S }
|
|
3118
|
+
},
|
|
3119
|
+
get_revenue_breakdown: {
|
|
3120
|
+
application: APPLICATION,
|
|
3121
|
+
range: RANGE,
|
|
3122
|
+
dimension: S,
|
|
3123
|
+
note: T,
|
|
3124
|
+
rows: [{ key: S, orderCount: S, grossCents: S }],
|
|
3125
|
+
totals: { orderCount: S, grossCents: S }
|
|
3126
|
+
},
|
|
3127
|
+
get_funnel_conversion: {
|
|
3128
|
+
application: APPLICATION,
|
|
3129
|
+
range: RANGE,
|
|
3130
|
+
note: T,
|
|
3131
|
+
conversionRate: S,
|
|
3132
|
+
stages: [{ name: S, count: S }],
|
|
3133
|
+
dropOff: [{ from: S, to: S, ratePct: S }]
|
|
3134
|
+
},
|
|
3135
|
+
get_subscription_movement: {
|
|
3136
|
+
application: APPLICATION,
|
|
3137
|
+
range: RANGE,
|
|
3138
|
+
note: T,
|
|
3139
|
+
series: [{ date: S, newSubscriptions: S, churnedSubscriptions: S, mrrDeltaCents: S }],
|
|
3140
|
+
totals: { newSubscriptions: S, churnedSubscriptions: S, netMrrDeltaCents: S }
|
|
3141
|
+
},
|
|
3142
|
+
get_discount_performance: {
|
|
3143
|
+
application: APPLICATION,
|
|
3144
|
+
range: RANGE,
|
|
3145
|
+
note: T,
|
|
3146
|
+
rows: [{ discountId: S, code: T, redemptions: S, discountedRevenueCents: S, discountGivenCents: S }],
|
|
3147
|
+
totals: { redemptions: S, discountedRevenueCents: S, discountGivenCents: S }
|
|
3148
|
+
}
|
|
3149
|
+
};
|
|
3150
|
+
|
|
1584
3151
|
// src/server.ts
|
|
1585
|
-
var VERSION =
|
|
3152
|
+
var VERSION = true ? "0.2.1" : "0.0.0-dev";
|
|
1586
3153
|
function registerableActions(policy) {
|
|
1587
3154
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
1588
3155
|
return actionsForChannel("mcp").filter((action) => {
|
|
1589
3156
|
if (!HANDLERS[action.id]) return false;
|
|
3157
|
+
if (action.credentialScoped && policy.allowCredentialScoped === false) return false;
|
|
1590
3158
|
if (!canRunAction(policy.identity.scopes, action)) return false;
|
|
1591
3159
|
if (action.kind === "read") return true;
|
|
1592
|
-
if (action.sandboxOnly) return !isProduction;
|
|
3160
|
+
if (action.sandboxOnly) return !isProduction && (policy.allowSandboxWrites ?? true);
|
|
1593
3161
|
if (!policy.allowWrites) return false;
|
|
1594
3162
|
return !isProduction || policy.allowLiveWrites;
|
|
1595
3163
|
});
|
|
@@ -1606,11 +3174,14 @@ function buildInstructions(identity, actions, policy) {
|
|
|
1606
3174
|
`Throttle MCP ${VERSION}. Connected to ${where}, environment "${identity.environment.slug}" (${isProduction ? "PRODUCTION \u2014 live data" : "non-production \u2014 not live data"}).`,
|
|
1607
3175
|
"",
|
|
1608
3176
|
"Conventions:",
|
|
1609
|
-
"-
|
|
3177
|
+
"- The workspace and environment are fixed for this session and cannot be switched from inside a tool call. Call whoami if you need to state where you are.",
|
|
3178
|
+
'- The application can vary per call: pass "applicationId" on a read or analytics tool to reach a different application in this workspace, and call list_applications to see which ones this connection can reach. Omitting applicationId uses the application this connection was authorized for.',
|
|
3179
|
+
"- Every analytics result covers exactly ONE application and names it in `application`. Say which application a figure describes. If the user asks about their business as a whole and this connection reaches more than one application, do not answer from the default alone \u2014 call list_applications, then query each and add them up, or ask which application they mean.",
|
|
1610
3180
|
'- List tools return { data, pagination }. When pagination.hasMore is true, pass pagination.cursor back as "cursor" rather than raising "limit".',
|
|
1611
3181
|
"- Amounts are integer minor units (2500 = $25.00).",
|
|
1612
3182
|
"- Throttle rejects snake_case on public request bodies. Before writing integration code, confirm shapes with describe_endpoint and check bodies with validate_payload instead of guessing field names.",
|
|
1613
|
-
"- API errors come back as text with a stable code. On insufficient_scopes, tell the user which scope to add \u2014 do not retry."
|
|
3183
|
+
"- API errors come back as text with a stable code. On insufficient_scopes, tell the user which scope to add \u2014 do not retry.",
|
|
3184
|
+
"- Analytics results may mark a section `omitted`. That means UNKNOWN, never zero. When `grantable` is false the data cannot be read over this connection at all \u2014 say so rather than reporting an absence."
|
|
1614
3185
|
];
|
|
1615
3186
|
if (liveWrites.length === 0) {
|
|
1616
3187
|
lines.push(
|
|
@@ -1628,8 +3199,31 @@ function buildInstructions(identity, actions, policy) {
|
|
|
1628
3199
|
}
|
|
1629
3200
|
return lines.join("\n");
|
|
1630
3201
|
}
|
|
3202
|
+
function declareSecuritySchemes(server, actions) {
|
|
3203
|
+
const inner = server.server;
|
|
3204
|
+
const handlers = inner._requestHandlers;
|
|
3205
|
+
const original = handlers?.get("tools/list");
|
|
3206
|
+
if (!original) return;
|
|
3207
|
+
const schemes = new Map(
|
|
3208
|
+
actions.map((a) => [
|
|
3209
|
+
a.id,
|
|
3210
|
+
[{
|
|
3211
|
+
type: "oauth2",
|
|
3212
|
+
scopes: [.../* @__PURE__ */ new Set([...a.scopes, ...a.sectionScopes ?? []])].filter((scope) => validateScopesForOAuth([scope]).ok)
|
|
3213
|
+
}]
|
|
3214
|
+
])
|
|
3215
|
+
);
|
|
3216
|
+
inner.setRequestHandler(import_types.ListToolsRequestSchema, async (request, extra) => {
|
|
3217
|
+
const result = await original(request, extra);
|
|
3218
|
+
return {
|
|
3219
|
+
...result,
|
|
3220
|
+
tools: result.tools.map((tool) => ({ ...tool, securitySchemes: schemes.get(tool.name) ?? [{ type: "oauth2", scopes: [] }] }))
|
|
3221
|
+
};
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
1631
3224
|
function createServer(options) {
|
|
1632
|
-
const
|
|
3225
|
+
const redactPii = options.identity.type === "oauth_token" && !hasScope(options.identity.scopes, "customer_pii:read");
|
|
3226
|
+
const actions = registerableActions(options).filter((a) => !redactPii || OAUTH_PROJECTIONS[a.id] !== void 0);
|
|
1633
3227
|
const server = new import_mcp.McpServer(
|
|
1634
3228
|
{ name: "throttle", version: VERSION },
|
|
1635
3229
|
{ instructions: buildInstructions(options.identity, actions, options) }
|
|
@@ -1642,25 +3236,57 @@ function createServer(options) {
|
|
|
1642
3236
|
};
|
|
1643
3237
|
for (const action of actions) {
|
|
1644
3238
|
const handler = HANDLERS[action.id];
|
|
1645
|
-
server.
|
|
3239
|
+
server.registerTool(
|
|
1646
3240
|
action.id,
|
|
1647
|
-
|
|
1648
|
-
|
|
3241
|
+
{
|
|
3242
|
+
title: action.title,
|
|
3243
|
+
description: describeForModel(action),
|
|
3244
|
+
inputSchema: fieldsToZodShape(action.input),
|
|
3245
|
+
// Every hint is an explicit boolean: directory reviews (OpenAI's in
|
|
3246
|
+
// particular) read a missing value as "unknown", not as false.
|
|
3247
|
+
annotations: {
|
|
3248
|
+
title: action.title,
|
|
3249
|
+
readOnlyHint: action.kind === "read",
|
|
3250
|
+
destructiveHint: action.kind === "write" && Boolean(action.destructive),
|
|
3251
|
+
idempotentHint: Boolean(action.idempotent),
|
|
3252
|
+
// Every tool is bounded to the connected workspace; none reaches the
|
|
3253
|
+
// public internet or an open-ended set of external entities.
|
|
3254
|
+
openWorldHint: false
|
|
3255
|
+
}
|
|
3256
|
+
},
|
|
1649
3257
|
async (args) => {
|
|
1650
3258
|
try {
|
|
3259
|
+
if (redactPii && action.id === "search_customers" && typeof args?.q === "string" && args.q.trim() !== "") {
|
|
3260
|
+
return {
|
|
3261
|
+
content: [{ type: "text", text: "Customer text search is not available over this connection, because names, emails, phone numbers and external ids are withheld. List customers by creation date (createdAfter/createdBefore), or open one by its Throttle id from an order, quote or subscription." }],
|
|
3262
|
+
isError: true
|
|
3263
|
+
};
|
|
3264
|
+
}
|
|
1651
3265
|
const result = await handler(ctx, args ?? {});
|
|
1652
|
-
|
|
3266
|
+
const shown = redactPii ? redactShopperPii(project(result, OAUTH_PROJECTIONS[action.id])) : result;
|
|
3267
|
+
return { content: [{ type: "text", text: formatResult(shown) }] };
|
|
1653
3268
|
} catch (error) {
|
|
1654
3269
|
return {
|
|
1655
3270
|
content: [{ type: "text", text: formatError(error) }],
|
|
1656
|
-
isError: true
|
|
3271
|
+
isError: true,
|
|
3272
|
+
...options.authChallenge && isCredentialRejection(error) ? {
|
|
3273
|
+
_meta: {
|
|
3274
|
+
"mcp/www_authenticate": [
|
|
3275
|
+
`${options.authChallenge}, error="invalid_token", error_description="The connected credential was rejected. Sign in again to continue."`
|
|
3276
|
+
]
|
|
3277
|
+
}
|
|
3278
|
+
} : {}
|
|
1657
3279
|
};
|
|
1658
3280
|
}
|
|
1659
3281
|
}
|
|
1660
3282
|
);
|
|
1661
3283
|
}
|
|
3284
|
+
if (options.authChallenge) declareSecuritySchemes(server, actions);
|
|
1662
3285
|
return server;
|
|
1663
3286
|
}
|
|
3287
|
+
function isCredentialRejection(error) {
|
|
3288
|
+
return error?.statusCode === 401;
|
|
3289
|
+
}
|
|
1664
3290
|
function describeForModel(action) {
|
|
1665
3291
|
const parts = [action.description];
|
|
1666
3292
|
if (action.guardrails && action.guardrails.length > 0) {
|