@usethrottle/mcp 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -498,6 +498,16 @@ function stripRawProcessorData(value) {
498
498
 
499
499
  // ../action-catalog/src/actions.ts
500
500
  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.";
501
+ var ORDER_STATUSES = [
502
+ "draft",
503
+ "awaiting_payment",
504
+ "awaiting_fulfillment",
505
+ "awaiting_shipment",
506
+ "partially_shipped",
507
+ "shipped",
508
+ "completed",
509
+ "cancelled"
510
+ ];
501
511
  var ACTIONS = [
502
512
  // ---------------------------------------------------------------- identity
503
513
  {
@@ -601,7 +611,20 @@ var ACTIONS = [
601
611
  scopes: ["orders:read"],
602
612
  input: [
603
613
  { name: "q", type: "string", required: false, description: "Free-text search." },
604
- { name: "status", type: "string", required: false, description: "Order status filter." },
614
+ {
615
+ name: "status",
616
+ type: "string",
617
+ required: false,
618
+ description: "Lifecycle status filter.",
619
+ enum: ORDER_STATUSES
620
+ },
621
+ {
622
+ name: "effectiveStatus",
623
+ type: "string",
624
+ required: false,
625
+ description: "Filter on the derived effectiveStatus: the lifecycle status unless the order is cancelled, on hold, refunded, partially refunded or disputed.",
626
+ enum: [...ORDER_STATUSES, "on_hold", "refunded", "partially_refunded", "disputed"]
627
+ },
605
628
  { name: "paymentStatus", type: "string", required: false, description: "Payment status filter." },
606
629
  {
607
630
  name: "createdAfter",
@@ -1603,6 +1626,17 @@ var ACTIONS = [
1603
1626
  "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."
1604
1627
  ]
1605
1628
  },
1629
+ // ------------------------------------------------------------ order fees
1630
+ {
1631
+ id: "list_fees",
1632
+ title: "List order fees",
1633
+ description: "List the order fee definitions of the application (convenience, handling, insurance fees), in display order: kind (percentage or flat), rate in basis points, flat/min/max/min-order amounts per currency, taxable, which orders they apply to and the customer groups they are limited to. Fees only charge while the application has order fees turned on.",
1634
+ kind: "read",
1635
+ scopes: ["applications:read"],
1636
+ input: [],
1637
+ requests: [{ method: "GET", path: "/api/v1/fees" }],
1638
+ channels: ["mcp"]
1639
+ },
1606
1640
  // ------------------------------------------------------------ customer groups
1607
1641
  {
1608
1642
  id: "list_customer_groups",
@@ -1944,6 +1978,24 @@ function trigger(id, title, eventType, description) {
1944
1978
  }
1945
1979
  var TRIGGERS = [
1946
1980
  trigger("new_order", "New order", "order.created", "Fires when an order is created."),
1981
+ trigger(
1982
+ "order_awaiting_shipment",
1983
+ "Order awaiting shipment",
1984
+ "order.awaiting_shipment",
1985
+ "Fires when an order is being prepared and nothing has shipped yet."
1986
+ ),
1987
+ trigger(
1988
+ "order_shipped",
1989
+ "Order shipped",
1990
+ "order.shipped",
1991
+ "Fires when everything an order has to ship has been handed to the carrier."
1992
+ ),
1993
+ trigger(
1994
+ "order_completed",
1995
+ "Order completed",
1996
+ "order.completed",
1997
+ "Fires when an order is completed: marked completed after shipping, or finished with nothing to ship."
1998
+ ),
1947
1999
  trigger(
1948
2000
  "payment_captured",
1949
2001
  "Payment captured",
@@ -2265,6 +2317,7 @@ var HANDLERS = {
2265
2317
  {
2266
2318
  q: args.q,
2267
2319
  status: args.status,
2320
+ effectiveStatus: args.effectiveStatus,
2268
2321
  paymentStatus: args.paymentStatus,
2269
2322
  createdAfter: args.createdAfter,
2270
2323
  createdBefore: args.createdBefore,
@@ -2554,6 +2607,8 @@ var HANDLERS = {
2554
2607
  },
2555
2608
  idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
2556
2609
  }),
2610
+ // ----------------------------------------------------------- order fees
2611
+ list_fees: async (ctx) => ctx.client.get("/api/v1/fees"),
2557
2612
  // ----------------------------------------------------------- customer groups
2558
2613
  list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
2559
2614
  get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
@@ -3116,11 +3171,14 @@ var LINE_ITEM = {
3116
3171
  // amount: a trial line's renewal price; schedule: per-unit installment amounts.
3117
3172
  recurring: { amount: M, scheduleUnitTotal: M, schedule: [{ amount: M }] }
3118
3173
  };
3174
+ var FEE = { baseAmount: M, amount: M, taxAmount: M };
3119
3175
  var ORDER = {
3120
3176
  subtotal: M,
3121
3177
  discountTotal: M,
3122
3178
  shippingTotal: M,
3123
3179
  shippingDiscountTotal: M,
3180
+ feeTotal: M,
3181
+ fees: [FEE],
3124
3182
  taxTotal: M,
3125
3183
  total: M,
3126
3184
  capturedAmount: M,
@@ -3148,7 +3206,8 @@ var SUBSCRIPTION = {
3148
3206
  scheduleTotal: M,
3149
3207
  nextPaymentAmount: M,
3150
3208
  paymentSchedule: [{ amount: M, discount: M, net: M }],
3151
- renewalIssue: { charge: { amount: M } }
3209
+ renewalIssue: { charge: { amount: M } },
3210
+ fees: [FEE]
3152
3211
  };
3153
3212
  var QUOTE_ITEM = {
3154
3213
  unitPrice: M,
@@ -3162,6 +3221,8 @@ var QUOTE_REVISION = {
3162
3221
  subtotal: M,
3163
3222
  discountTotal: M,
3164
3223
  shippingTotal: M,
3224
+ feeTotal: M,
3225
+ fees: [FEE],
3165
3226
  taxTotal: M,
3166
3227
  total: M,
3167
3228
  depositAmount: M,
@@ -3184,15 +3245,19 @@ var INVOICE = {
3184
3245
  taxTotal: M,
3185
3246
  shippingTotal: M,
3186
3247
  discountTotal: M,
3248
+ feeTotal: M,
3249
+ fees: [{ amount: M }],
3187
3250
  total: M,
3188
3251
  amountRefunded: M,
3189
3252
  billingSnapshot: {
3190
3253
  lineItems: [{ unitPrice: M, taxAmount: M, discountAmount: M, total: M }],
3254
+ fees: [FEE],
3191
3255
  totals: {
3192
3256
  subtotal: M,
3193
3257
  taxTotal: M,
3194
3258
  shippingTotal: M,
3195
3259
  discountTotal: M,
3260
+ feeTotal: M,
3196
3261
  total: M,
3197
3262
  orderTotal: M,
3198
3263
  amountPaid: M,
@@ -3213,6 +3278,8 @@ var CART = {
3213
3278
  discountTotal: M,
3214
3279
  shippingTotal: M,
3215
3280
  shippingDiscountTotal: M,
3281
+ feeTotal: M,
3282
+ fees: [FEE],
3216
3283
  total: M,
3217
3284
  lineItems: [LINE_ITEM],
3218
3285
  items: [LINE_ITEM],
@@ -3298,6 +3365,8 @@ var MONEY_SPECS = {
3298
3365
  // GET /api/v1/stores: `settings.shipping` is stamped with its own currency
3299
3366
  // (MC1-R74); an unstamped one takes the store's.
3300
3367
  list_applications: [{ settings: { shipping: { flatRateCents: M, freeThresholdCents: M } } }],
3368
+ // GET /api/v1/fees: fee definitions hold per-currency amounts, keyed by the currency code.
3369
+ list_fees: [{ flatAmounts: MK(M), minAmounts: MK(M), maxAmounts: MK(M), minOrderAmounts: MK(M) }],
3301
3370
  // ---------------------------------------------------------------- analytics
3302
3371
  get_sales_timeseries: {
3303
3372
  totalGrossCents: DROP,
@@ -3471,7 +3540,16 @@ var page3 = (row) => ({ data: [row], pagination: PAGINATION });
3471
3540
  var ADDRESS = { countryCode: S };
3472
3541
  var CUSTOMER_REF = { id: S };
3473
3542
  var APPLICATION = { id: S, name: T, slug: S };
3474
- var LIFECYCLE_LABELS = ["Draft", "Pending", "Processing", "Partially fulfilled", "Fulfilled", "Cancelled", "Closed"];
3543
+ var LIFECYCLE_LABELS = [
3544
+ "Draft",
3545
+ "Awaiting Payment",
3546
+ "Awaiting Fulfillment",
3547
+ "Awaiting Shipment",
3548
+ "Partially Shipped",
3549
+ "Shipped",
3550
+ "Completed",
3551
+ "Cancelled"
3552
+ ];
3475
3553
  var DISPLAY_QUALIFIERS = [
3476
3554
  "Comped",
3477
3555
  "Awaiting payment",
@@ -3518,10 +3596,24 @@ var LINE_ITEM2 = {
3518
3596
  recurring: { ...LINE_RECURRING, amount: MONEY, count: S, scheduleUnitTotal: MONEY },
3519
3597
  subscriptionId: S
3520
3598
  };
3599
+ var FEE2 = {
3600
+ id: S,
3601
+ source: S,
3602
+ label: T,
3603
+ kind: S,
3604
+ rateBps: S,
3605
+ baseAmount: MONEY,
3606
+ amount: MONEY,
3607
+ taxable: S,
3608
+ taxAmount: MONEY,
3609
+ appliesToOneTime: S,
3610
+ appliesToSubscription: S
3611
+ };
3521
3612
  var ORDER2 = {
3522
3613
  id: S,
3523
3614
  orderNumber: S,
3524
3615
  status: S,
3616
+ effectiveStatus: S,
3525
3617
  displayStatus: DISPLAY_STATUS,
3526
3618
  paymentStatus: S,
3527
3619
  type: S,
@@ -3531,6 +3623,8 @@ var ORDER2 = {
3531
3623
  discountTotal: MONEY,
3532
3624
  shippingTotal: MONEY,
3533
3625
  shippingDiscountTotal: MONEY,
3626
+ feeTotal: MONEY,
3627
+ fees: [FEE2],
3534
3628
  taxTotal: MONEY,
3535
3629
  total: MONEY,
3536
3630
  capturedAmount: MONEY,
@@ -3641,6 +3735,7 @@ var SUBSCRIPTION2 = {
3641
3735
  pendingIntervalCount: S,
3642
3736
  scheduleTotal: MONEY,
3643
3737
  nextPaymentAmount: MONEY,
3738
+ fees: [FEE2],
3644
3739
  // A physical subscription (0236): the method is an enum, and the ship-to is
3645
3740
  // kept to its country like every other address here.
3646
3741
  deliveryMethod: S,
@@ -3680,6 +3775,8 @@ var QUOTE2 = {
3680
3775
  subtotal: MONEY,
3681
3776
  discountTotal: MONEY,
3682
3777
  shippingTotal: MONEY,
3778
+ feeTotal: MONEY,
3779
+ fees: [FEE2],
3683
3780
  taxTotal: MONEY,
3684
3781
  total: MONEY,
3685
3782
  depositAmount: MONEY,
@@ -3715,6 +3812,8 @@ var INVOICE2 = {
3715
3812
  subtotal: MONEY,
3716
3813
  discountTotal: MONEY,
3717
3814
  shippingTotal: MONEY,
3815
+ feeTotal: MONEY,
3816
+ fees: [{ label: T, amount: MONEY }],
3718
3817
  taxTotal: MONEY,
3719
3818
  total: MONEY,
3720
3819
  amountRefunded: MONEY,
@@ -3727,7 +3826,7 @@ var INVOICE2 = {
3727
3826
  planName: T,
3728
3827
  period: { start: S, end: S },
3729
3828
  lineItems: [{ quantity: S, unitPrice: MONEY, discountAmount: MONEY, taxAmount: MONEY, total: MONEY }],
3730
- totals: { currency: S, subtotal: MONEY, discountTotal: MONEY, shippingTotal: MONEY, taxTotal: MONEY, total: MONEY },
3829
+ totals: { currency: S, subtotal: MONEY, discountTotal: MONEY, shippingTotal: MONEY, feeTotal: MONEY, taxTotal: MONEY, total: MONEY },
3731
3830
  payment: { method: S, brand: S, status: S }
3732
3831
  }
3733
3832
  };
@@ -3915,6 +4014,8 @@ var OAUTH_PROJECTIONS = {
3915
4014
  discountTotal: MONEY,
3916
4015
  shippingTotal: MONEY,
3917
4016
  shippingDiscountTotal: MONEY,
4017
+ feeTotal: MONEY,
4018
+ fees: [FEE2],
3918
4019
  taxTotal: MONEY,
3919
4020
  total: MONEY,
3920
4021
  itemCount: S,
@@ -3985,6 +4086,25 @@ var OAUTH_PROJECTIONS = {
3985
4086
  get_workspace_settings: { name: T, slug: S, brandColor: S, logoUrl: T, onboardingCompletedAt: S },
3986
4087
  // What happened and to which record; not which team member did it.
3987
4088
  get_audit_log: page3({ id: S, action: S, resourceType: S, resourceId: S, createdAt: S }),
4089
+ list_fees: [{
4090
+ id: S,
4091
+ name: T,
4092
+ kind: S,
4093
+ rateBps: S,
4094
+ flatAmounts: mapOf(MONEY),
4095
+ minAmounts: mapOf(MONEY),
4096
+ maxAmounts: mapOf(MONEY),
4097
+ minOrderAmounts: mapOf(MONEY),
4098
+ taxable: S,
4099
+ taxCode: S,
4100
+ appliesToOneTime: S,
4101
+ appliesToSubscription: S,
4102
+ customerGroupIds: [S],
4103
+ active: S,
4104
+ sortOrder: S,
4105
+ createdAt: S,
4106
+ updatedAt: S
4107
+ }],
3988
4108
  list_applications: [{ id: S, name: T, slug: S, currency: S, isActive: S }],
3989
4109
  // Analytics: computed aggregates, listed field by field all the same.
3990
4110
  get_business_summary: {
@@ -4084,7 +4204,7 @@ var OAUTH_PROJECTIONS = {
4084
4204
  };
4085
4205
 
4086
4206
  // src/server.ts
4087
- var VERSION = true ? "0.9.0" : "0.0.0-dev";
4207
+ var VERSION = true ? "0.11.0" : "0.0.0-dev";
4088
4208
  function registerableActions(policy) {
4089
4209
  const isProduction = policy.identity.environment.providerEnvironment === "production";
4090
4210
  return actionsForChannel("mcp").filter((action) => {