@usethrottle/mcp 0.4.4 → 0.5.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/README.md +7 -0
- package/dist/contract-index.json +1 -1
- package/dist/docs-index.json +1 -1
- package/dist/lib.cjs +1267 -895
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.d.cts +1 -1
- package/dist/lib.d.ts +1 -1
- package/dist/lib.js +1267 -895
- package/dist/lib.js.map +1 -1
- package/dist/mcp.js +743 -147
- package/dist/mcp.js.map +1 -1
- package/package.json +2 -2
package/dist/mcp.js
CHANGED
|
@@ -826,7 +826,7 @@ var ACTIONS = [
|
|
|
826
826
|
{
|
|
827
827
|
id: "receivables_aging",
|
|
828
828
|
title: "Receivables aging",
|
|
829
|
-
description: 'Outstanding receivables bucketed by age \u2014 answers "what is overdue and by how long".',
|
|
829
|
+
description: 'Outstanding receivables bucketed by age \u2014 answers "what is overdue and by how long". Totals come back per currency in byCurrency, never summed across currencies.',
|
|
830
830
|
kind: "read",
|
|
831
831
|
scopes: ["invoices:read"],
|
|
832
832
|
input: [
|
|
@@ -972,7 +972,7 @@ var ACTIONS = [
|
|
|
972
972
|
{
|
|
973
973
|
id: "list_abandoned_carts",
|
|
974
974
|
title: "List abandoned carts",
|
|
975
|
-
description: "Carts that were started but never finalized, with recovery status \u2014 the abandoned-cart recovery list.",
|
|
975
|
+
description: "Carts that were started but never finalized, with recovery status \u2014 the abandoned-cart recovery list. The summary value comes back per currency in byCurrency, never summed.",
|
|
976
976
|
kind: "read",
|
|
977
977
|
scopes: ["carts:read"],
|
|
978
978
|
input: [
|
|
@@ -1213,7 +1213,7 @@ var ACTIONS = [
|
|
|
1213
1213
|
{
|
|
1214
1214
|
id: "get_sales_timeseries",
|
|
1215
1215
|
title: "Sales over time",
|
|
1216
|
-
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
|
|
1216
|
+
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. Amounts come back per currency in byCurrency, never as one total; report each currency separately.`,
|
|
1217
1217
|
kind: "read",
|
|
1218
1218
|
scopes: ["orders:read"],
|
|
1219
1219
|
input: [
|
|
@@ -1238,7 +1238,7 @@ var ACTIONS = [
|
|
|
1238
1238
|
{
|
|
1239
1239
|
id: "get_business_summary",
|
|
1240
1240
|
title: "Business summary",
|
|
1241
|
-
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.",
|
|
1241
|
+
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. Money comes back per currency in byCurrency (revenue, MRR, receivables, quotes), never summed across currencies; report each currency separately.",
|
|
1242
1242
|
kind: "read",
|
|
1243
1243
|
scopes: [],
|
|
1244
1244
|
sectionScopes: ["orders:read", "subscriptions:read", "invoices:read", "quotes:read"],
|
|
@@ -1270,7 +1270,7 @@ var ACTIONS = [
|
|
|
1270
1270
|
{
|
|
1271
1271
|
id: "get_top_products",
|
|
1272
1272
|
title: "Top products",
|
|
1273
|
-
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.",
|
|
1273
|
+
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. Revenue is per currency (byCurrency on each row and in the totals); rows rank by the main currency, and revenue is never summed across currencies.",
|
|
1274
1274
|
kind: "read",
|
|
1275
1275
|
scopes: ["orders:read"],
|
|
1276
1276
|
input: [
|
|
@@ -1295,7 +1295,7 @@ var ACTIONS = [
|
|
|
1295
1295
|
{
|
|
1296
1296
|
id: "get_attention_digest",
|
|
1297
1297
|
title: "Attention digest",
|
|
1298
|
-
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.",
|
|
1298
|
+
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. Dispute and overdue-invoice amounts come back per currency in byCurrency, never summed.",
|
|
1299
1299
|
kind: "read",
|
|
1300
1300
|
scopes: [],
|
|
1301
1301
|
sectionScopes: ["payment_disputes:read", "subscriptions:read", "invoices:read", "webhook_deliveries:read"],
|
|
@@ -1316,7 +1316,7 @@ var ACTIONS = [
|
|
|
1316
1316
|
{
|
|
1317
1317
|
id: "get_customer_growth",
|
|
1318
1318
|
title: "Customer growth",
|
|
1319
|
-
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.",
|
|
1319
|
+
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. Revenue is per currency in byCurrency (top customers rank by the main currency); customer counts stay all-currency.",
|
|
1320
1320
|
kind: "read",
|
|
1321
1321
|
scopes: ["customers:read"],
|
|
1322
1322
|
input: [
|
|
@@ -1344,7 +1344,7 @@ var ACTIONS = [
|
|
|
1344
1344
|
{
|
|
1345
1345
|
id: "get_revenue_breakdown",
|
|
1346
1346
|
title: "Revenue breakdown",
|
|
1347
|
-
description: "Revenue split by one dimension over a date range \u2014 payment method, order source, or currency. Amounts are gross; refunds are not deducted.",
|
|
1347
|
+
description: "Revenue split by one dimension over a date range \u2014 payment method, order source, or currency. Amounts are gross; refunds are not deducted. Amounts are per currency in byCurrency; with dimension=currency each row carries only its own currency.",
|
|
1348
1348
|
kind: "read",
|
|
1349
1349
|
scopes: ["orders:read"],
|
|
1350
1350
|
input: [
|
|
@@ -1401,7 +1401,7 @@ var ACTIONS = [
|
|
|
1401
1401
|
{
|
|
1402
1402
|
id: "get_subscription_movement",
|
|
1403
1403
|
title: "Subscription movement",
|
|
1404
|
-
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.",
|
|
1404
|
+
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. MRR change is per currency in byCurrency, never summed across currencies.",
|
|
1405
1405
|
kind: "read",
|
|
1406
1406
|
scopes: ["subscriptions:read"],
|
|
1407
1407
|
input: [
|
|
@@ -1419,15 +1419,15 @@ var ACTIONS = [
|
|
|
1419
1419
|
requests: [{ method: "GET", path: "/api/v1/analytics/subscriptions" }],
|
|
1420
1420
|
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1421
1421
|
guardrails: [
|
|
1422
|
-
"newSubscriptions, churnedSubscriptions and
|
|
1423
|
-
"
|
|
1424
|
-
"totals is the sum over the full series (the series is never truncated), so totals.newSubscriptions/.churnedSubscriptions
|
|
1422
|
+
"newSubscriptions, churnedSubscriptions and the MRR change (byCurrency) 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.",
|
|
1423
|
+
"The MRR change 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 the MRR change.",
|
|
1424
|
+
"totals is the sum over the full series (the series is never truncated), so totals.newSubscriptions/.churnedSubscriptions always equal the corresponding sums of series[], and totals.byCurrency[] equals the per-currency sums of series[].byCurrency."
|
|
1425
1425
|
]
|
|
1426
1426
|
},
|
|
1427
1427
|
{
|
|
1428
1428
|
id: "get_discount_performance",
|
|
1429
1429
|
title: "Discount performance",
|
|
1430
|
-
description: "Discount code performance over a date range: redemption count, revenue on discounted orders, and total discount given per code.",
|
|
1430
|
+
description: "Discount code performance over a date range: redemption count, revenue on discounted orders, and total discount given per code. Revenue and discount given are per currency in byCurrency; codes rank by the main currency.",
|
|
1431
1431
|
kind: "read",
|
|
1432
1432
|
scopes: ["discounts:read"],
|
|
1433
1433
|
input: [
|
|
@@ -1445,9 +1445,9 @@ var ACTIONS = [
|
|
|
1445
1445
|
requests: [{ method: "GET", path: "/api/v1/analytics/discounts" }],
|
|
1446
1446
|
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1447
1447
|
guardrails: [
|
|
1448
|
-
'
|
|
1449
|
-
"Only orders with status <> draft and a gross-eligible payment_status are counted; refunds are not deducted from
|
|
1450
|
-
"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.
|
|
1448
|
+
'In byCurrency, amount (discounted revenue) and discountGiven are DIFFERENT measures: amount is the gross order total on orders that redeemed the code; discountGiven is the discount amount taken off those same orders. Never describe the amount as "given away" or discountGiven as revenue.',
|
|
1449
|
+
"Only orders with status <> draft and a gross-eligible payment_status are counted; refunds are not deducted from the discounted revenue amount, because that needs payment_refunds:read.",
|
|
1450
|
+
"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.byCurrency[].discountGiven stay valid even when rows is truncated by limit."
|
|
1451
1451
|
]
|
|
1452
1452
|
},
|
|
1453
1453
|
// ------------------------------------------------------------ sandbox write
|
|
@@ -2659,12 +2659,565 @@ function applyModifiers(field, type) {
|
|
|
2659
2659
|
return field.default === void 0 ? described.optional() : described.default(field.default);
|
|
2660
2660
|
}
|
|
2661
2661
|
|
|
2662
|
+
// ../money/dist/index.js
|
|
2663
|
+
var CURRENCY_ROWS = [
|
|
2664
|
+
["AED", 2, "AED", false],
|
|
2665
|
+
["AFN", 2, "AFN", false],
|
|
2666
|
+
["ALL", 2, "ALL", false],
|
|
2667
|
+
["AMD", 2, "AMD", false],
|
|
2668
|
+
["AOA", 2, "AOA", false],
|
|
2669
|
+
["ARS", 2, "ARS", false],
|
|
2670
|
+
["AUD", 2, "A$", false],
|
|
2671
|
+
["AWG", 2, "AWG", false],
|
|
2672
|
+
["AZN", 2, "AZN", false],
|
|
2673
|
+
["BAM", 2, "BAM", false],
|
|
2674
|
+
["BBD", 2, "BBD", false],
|
|
2675
|
+
["BDT", 2, "BDT", false],
|
|
2676
|
+
["BHD", 3, "BHD", false],
|
|
2677
|
+
["BIF", 0, "BIF", false],
|
|
2678
|
+
["BMD", 2, "BMD", false],
|
|
2679
|
+
["BND", 2, "BND", false],
|
|
2680
|
+
["BOB", 2, "BOB", false],
|
|
2681
|
+
["BOV", 2, "BOV", true],
|
|
2682
|
+
["BRL", 2, "R$", false],
|
|
2683
|
+
["BSD", 2, "BSD", false],
|
|
2684
|
+
["BTN", 2, "BTN", false],
|
|
2685
|
+
["BWP", 2, "BWP", false],
|
|
2686
|
+
["BYN", 2, "BYN", false],
|
|
2687
|
+
["BZD", 2, "BZD", false],
|
|
2688
|
+
["CAD", 2, "CA$", false],
|
|
2689
|
+
["CDF", 2, "CDF", false],
|
|
2690
|
+
["CHE", 2, "CHE", true],
|
|
2691
|
+
["CHF", 2, "CHF", false],
|
|
2692
|
+
["CHW", 2, "CHW", true],
|
|
2693
|
+
["CLF", 4, "CLF", true],
|
|
2694
|
+
["CLP", 0, "CLP", false],
|
|
2695
|
+
["CNY", 2, "CN\xA5", false],
|
|
2696
|
+
["COP", 2, "COP", false],
|
|
2697
|
+
["COU", 2, "COU", true],
|
|
2698
|
+
["CRC", 2, "CRC", false],
|
|
2699
|
+
["CUP", 2, "CUP", false],
|
|
2700
|
+
["CVE", 2, "CVE", false],
|
|
2701
|
+
["CZK", 2, "CZK", false],
|
|
2702
|
+
["DJF", 0, "DJF", false],
|
|
2703
|
+
["DKK", 2, "DKK", false],
|
|
2704
|
+
["DOP", 2, "DOP", false],
|
|
2705
|
+
["DZD", 2, "DZD", false],
|
|
2706
|
+
["EGP", 2, "EGP", false],
|
|
2707
|
+
["ERN", 2, "ERN", false],
|
|
2708
|
+
["ETB", 2, "ETB", false],
|
|
2709
|
+
["EUR", 2, "\u20AC", false],
|
|
2710
|
+
["FJD", 2, "FJD", false],
|
|
2711
|
+
["FKP", 2, "FKP", false],
|
|
2712
|
+
["GBP", 2, "\xA3", false],
|
|
2713
|
+
["GEL", 2, "GEL", false],
|
|
2714
|
+
["GHS", 2, "GHS", false],
|
|
2715
|
+
["GIP", 2, "GIP", false],
|
|
2716
|
+
["GMD", 2, "GMD", false],
|
|
2717
|
+
["GNF", 0, "GNF", false],
|
|
2718
|
+
["GTQ", 2, "GTQ", false],
|
|
2719
|
+
["GYD", 2, "GYD", false],
|
|
2720
|
+
["HKD", 2, "HK$", false],
|
|
2721
|
+
["HNL", 2, "HNL", false],
|
|
2722
|
+
["HTG", 2, "HTG", false],
|
|
2723
|
+
["HUF", 2, "HUF", false],
|
|
2724
|
+
["IDR", 2, "IDR", false],
|
|
2725
|
+
["ILS", 2, "\u20AA", false],
|
|
2726
|
+
["INR", 2, "\u20B9", false],
|
|
2727
|
+
["IQD", 3, "IQD", false],
|
|
2728
|
+
["IRR", 2, "IRR", false],
|
|
2729
|
+
["ISK", 0, "ISK", false],
|
|
2730
|
+
["JMD", 2, "JMD", false],
|
|
2731
|
+
["JOD", 3, "JOD", false],
|
|
2732
|
+
["JPY", 0, "\xA5", false],
|
|
2733
|
+
["KES", 2, "KES", false],
|
|
2734
|
+
["KGS", 2, "KGS", false],
|
|
2735
|
+
["KHR", 2, "KHR", false],
|
|
2736
|
+
["KMF", 0, "KMF", false],
|
|
2737
|
+
["KPW", 2, "KPW", false],
|
|
2738
|
+
["KRW", 0, "\u20A9", false],
|
|
2739
|
+
["KWD", 3, "KWD", false],
|
|
2740
|
+
["KYD", 2, "KYD", false],
|
|
2741
|
+
["KZT", 2, "KZT", false],
|
|
2742
|
+
["LAK", 2, "LAK", false],
|
|
2743
|
+
["LBP", 2, "LBP", false],
|
|
2744
|
+
["LKR", 2, "LKR", false],
|
|
2745
|
+
["LRD", 2, "LRD", false],
|
|
2746
|
+
["LSL", 2, "LSL", false],
|
|
2747
|
+
["LYD", 3, "LYD", false],
|
|
2748
|
+
["MAD", 2, "MAD", false],
|
|
2749
|
+
["MDL", 2, "MDL", false],
|
|
2750
|
+
["MGA", 2, "MGA", false],
|
|
2751
|
+
["MKD", 2, "MKD", false],
|
|
2752
|
+
["MMK", 2, "MMK", false],
|
|
2753
|
+
["MNT", 2, "MNT", false],
|
|
2754
|
+
["MOP", 2, "MOP", false],
|
|
2755
|
+
["MRU", 2, "MRU", false],
|
|
2756
|
+
["MUR", 2, "MUR", false],
|
|
2757
|
+
["MVR", 2, "MVR", false],
|
|
2758
|
+
["MWK", 2, "MWK", false],
|
|
2759
|
+
["MXN", 2, "MX$", false],
|
|
2760
|
+
["MXV", 2, "MXV", true],
|
|
2761
|
+
["MYR", 2, "MYR", false],
|
|
2762
|
+
["MZN", 2, "MZN", false],
|
|
2763
|
+
["NAD", 2, "NAD", false],
|
|
2764
|
+
["NGN", 2, "NGN", false],
|
|
2765
|
+
["NIO", 2, "NIO", false],
|
|
2766
|
+
["NOK", 2, "NOK", false],
|
|
2767
|
+
["NPR", 2, "NPR", false],
|
|
2768
|
+
["NZD", 2, "NZ$", false],
|
|
2769
|
+
["OMR", 3, "OMR", false],
|
|
2770
|
+
["PAB", 2, "PAB", false],
|
|
2771
|
+
["PEN", 2, "PEN", false],
|
|
2772
|
+
["PGK", 2, "PGK", false],
|
|
2773
|
+
["PHP", 2, "\u20B1", false],
|
|
2774
|
+
["PKR", 2, "PKR", false],
|
|
2775
|
+
["PLN", 2, "PLN", false],
|
|
2776
|
+
["PYG", 0, "PYG", false],
|
|
2777
|
+
["QAR", 2, "QAR", false],
|
|
2778
|
+
["RON", 2, "RON", false],
|
|
2779
|
+
["RSD", 2, "RSD", false],
|
|
2780
|
+
["RUB", 2, "RUB", false],
|
|
2781
|
+
["RWF", 0, "RWF", false],
|
|
2782
|
+
["SAR", 2, "SAR", false],
|
|
2783
|
+
["SBD", 2, "SBD", false],
|
|
2784
|
+
["SCR", 2, "SCR", false],
|
|
2785
|
+
["SDG", 2, "SDG", false],
|
|
2786
|
+
["SEK", 2, "SEK", false],
|
|
2787
|
+
["SGD", 2, "SGD", false],
|
|
2788
|
+
["SHP", 2, "SHP", false],
|
|
2789
|
+
["SLE", 2, "SLE", false],
|
|
2790
|
+
["SOS", 2, "SOS", false],
|
|
2791
|
+
["SRD", 2, "SRD", false],
|
|
2792
|
+
["SSP", 2, "SSP", false],
|
|
2793
|
+
["STN", 2, "STN", false],
|
|
2794
|
+
["SVC", 2, "SVC", false],
|
|
2795
|
+
["SYP", 2, "SYP", false],
|
|
2796
|
+
["SZL", 2, "SZL", false],
|
|
2797
|
+
["THB", 2, "THB", false],
|
|
2798
|
+
["TJS", 2, "TJS", false],
|
|
2799
|
+
["TMT", 2, "TMT", false],
|
|
2800
|
+
["TND", 3, "TND", false],
|
|
2801
|
+
["TOP", 2, "TOP", false],
|
|
2802
|
+
["TRY", 2, "TRY", false],
|
|
2803
|
+
["TTD", 2, "TTD", false],
|
|
2804
|
+
["TWD", 2, "NT$", false],
|
|
2805
|
+
["TZS", 2, "TZS", false],
|
|
2806
|
+
["UAH", 2, "UAH", false],
|
|
2807
|
+
["UGX", 0, "UGX", false],
|
|
2808
|
+
["USD", 2, "$", false],
|
|
2809
|
+
["USN", 2, "USN", true],
|
|
2810
|
+
["UYI", 0, "UYI", true],
|
|
2811
|
+
["UYU", 2, "UYU", false],
|
|
2812
|
+
["UYW", 4, "UYW", true],
|
|
2813
|
+
["UZS", 2, "UZS", false],
|
|
2814
|
+
["VED", 2, "VED", false],
|
|
2815
|
+
["VES", 2, "VES", false],
|
|
2816
|
+
["VND", 0, "\u20AB", false],
|
|
2817
|
+
["VUV", 0, "VUV", false],
|
|
2818
|
+
["WST", 2, "WST", false],
|
|
2819
|
+
["XAD", 2, "XAD", true],
|
|
2820
|
+
["XAF", 0, "FCFA", false],
|
|
2821
|
+
["XCD", 2, "EC$", false],
|
|
2822
|
+
["XCG", 2, "Cg.", false],
|
|
2823
|
+
["XOF", 0, "F\u202FCFA", false],
|
|
2824
|
+
["XPF", 0, "CFPF", false],
|
|
2825
|
+
["YER", 2, "YER", false],
|
|
2826
|
+
["ZAR", 2, "ZAR", false],
|
|
2827
|
+
["ZMW", 2, "ZMW", false],
|
|
2828
|
+
["ZWG", 2, "ZWG", false]
|
|
2829
|
+
];
|
|
2830
|
+
var BY_CODE = new Map(
|
|
2831
|
+
CURRENCY_ROWS.map(([code, minorUnits, symbol, fund]) => [code, { minorUnits, symbol, fund }])
|
|
2832
|
+
);
|
|
2833
|
+
var CURRENCIES = Object.freeze(
|
|
2834
|
+
CURRENCY_ROWS.map(([code, minorUnits, symbol]) => Object.freeze({ code, minorUnits, symbol }))
|
|
2835
|
+
);
|
|
2836
|
+
var UNCONFIRMED = /* @__PURE__ */ new Set([
|
|
2837
|
+
"AFN",
|
|
2838
|
+
"BTN",
|
|
2839
|
+
"CDF",
|
|
2840
|
+
"CLP",
|
|
2841
|
+
"COP",
|
|
2842
|
+
"CVE",
|
|
2843
|
+
"ERN",
|
|
2844
|
+
"HUF",
|
|
2845
|
+
"IDR",
|
|
2846
|
+
"IRR",
|
|
2847
|
+
"ISK",
|
|
2848
|
+
"KPW",
|
|
2849
|
+
"LBP",
|
|
2850
|
+
"LRD",
|
|
2851
|
+
"LSL",
|
|
2852
|
+
"MGA",
|
|
2853
|
+
"SDG",
|
|
2854
|
+
"SSP",
|
|
2855
|
+
"SYP",
|
|
2856
|
+
"TJS",
|
|
2857
|
+
"TMT",
|
|
2858
|
+
"TWD",
|
|
2859
|
+
"UGX",
|
|
2860
|
+
"VED",
|
|
2861
|
+
"VES",
|
|
2862
|
+
"ZWG"
|
|
2863
|
+
]);
|
|
2864
|
+
var UNCONFIRMED_EXPONENT_CODES = Object.freeze({
|
|
2865
|
+
has: (code) => UNCONFIRMED.has(code),
|
|
2866
|
+
get size() {
|
|
2867
|
+
return UNCONFIRMED.size;
|
|
2868
|
+
},
|
|
2869
|
+
forEach: (fn, thisArg) => UNCONFIRMED.forEach((v) => fn.call(thisArg, v, v, UNCONFIRMED_EXPONENT_CODES)),
|
|
2870
|
+
keys: () => UNCONFIRMED.keys(),
|
|
2871
|
+
values: () => UNCONFIRMED.values(),
|
|
2872
|
+
entries: () => UNCONFIRMED.entries(),
|
|
2873
|
+
[Symbol.iterator]: () => UNCONFIRMED.values()
|
|
2874
|
+
});
|
|
2875
|
+
function currencyRow(code) {
|
|
2876
|
+
return BY_CODE.get(code);
|
|
2877
|
+
}
|
|
2878
|
+
function isKnownCurrency(code) {
|
|
2879
|
+
return BY_CODE.has(code);
|
|
2880
|
+
}
|
|
2881
|
+
var NBSP = "\xA0";
|
|
2882
|
+
function normalizeCode(code) {
|
|
2883
|
+
return typeof code === "string" ? code.trim().toUpperCase() : "";
|
|
2884
|
+
}
|
|
2885
|
+
function roundHalfAwayFromZero(n) {
|
|
2886
|
+
return n < 0 ? -Math.round(-n) : Math.round(n);
|
|
2887
|
+
}
|
|
2888
|
+
function decimalDigits(abs, exponent, grouped) {
|
|
2889
|
+
const raw = Number.isSafeInteger(abs) ? String(abs) : BigInt(abs).toString();
|
|
2890
|
+
const padded = raw.padStart(exponent + 1, "0");
|
|
2891
|
+
const cut = padded.length - exponent;
|
|
2892
|
+
let integer = padded.slice(0, cut);
|
|
2893
|
+
if (grouped) integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
2894
|
+
return exponent === 0 ? integer : `${integer}.${padded.slice(cut)}`;
|
|
2895
|
+
}
|
|
2896
|
+
function formatMoney(minor, code, opts) {
|
|
2897
|
+
if (typeof minor !== "number" || !Number.isFinite(minor)) return "\u2014";
|
|
2898
|
+
const c = normalizeCode(code);
|
|
2899
|
+
const row = currencyRow(c);
|
|
2900
|
+
const n = roundHalfAwayFromZero(minor);
|
|
2901
|
+
const sign = n < 0 ? "-" : "";
|
|
2902
|
+
const digits = decimalDigits(Math.abs(n), row?.minorUnits ?? 2, true);
|
|
2903
|
+
if (c === "") return sign + digits;
|
|
2904
|
+
if (row === void 0) return `${sign}${digits}${NBSP}${c}`;
|
|
2905
|
+
const separator = new RegExp("\\p{Sc}$", "u").test(row.symbol) ? "" : NBSP;
|
|
2906
|
+
const text = `${sign}${row.symbol}${separator}${digits}`;
|
|
2907
|
+
return opts?.display === "symbol-code" && row.symbol !== c ? `${text}${NBSP}${c}` : text;
|
|
2908
|
+
}
|
|
2909
|
+
function moneyValue(amount, currency) {
|
|
2910
|
+
return { amount, currency: normalizeCode(currency), display: formatMoney(amount, currency) };
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
// src/money.ts
|
|
2914
|
+
var M = "money";
|
|
2915
|
+
var DROP = "drop";
|
|
2916
|
+
var MK = (values) => ({ __moneyKeyed: values });
|
|
2917
|
+
var CURRENCY_OF = (sibling, spec) => ({ __currencyOf: { sibling, spec } });
|
|
2918
|
+
var DROP_WHEN = (field, equals) => ({ __dropWhen: { field, equals } });
|
|
2919
|
+
var ORDERS_WINDOW = { grossCents: DROP, avgOrderCents: DROP, refundsCents: DROP, netCents: DROP };
|
|
2920
|
+
var QUOTE_BUCKET = { totalCents: DROP };
|
|
2921
|
+
var LINE_ITEM = {
|
|
2922
|
+
unitPrice: M,
|
|
2923
|
+
subtotal: M,
|
|
2924
|
+
discountAmount: M,
|
|
2925
|
+
taxAmount: M,
|
|
2926
|
+
total: M,
|
|
2927
|
+
// amount: a trial line's renewal price; schedule: per-unit installment amounts.
|
|
2928
|
+
recurring: { amount: M, scheduleUnitTotal: M, schedule: [{ amount: M }] }
|
|
2929
|
+
};
|
|
2930
|
+
var ORDER = {
|
|
2931
|
+
subtotal: M,
|
|
2932
|
+
discountTotal: M,
|
|
2933
|
+
shippingTotal: M,
|
|
2934
|
+
taxTotal: M,
|
|
2935
|
+
total: M,
|
|
2936
|
+
capturedAmount: M,
|
|
2937
|
+
refundedAmount: M,
|
|
2938
|
+
compAmount: M,
|
|
2939
|
+
shippingMethod: { amount: M },
|
|
2940
|
+
lineItems: [LINE_ITEM]
|
|
2941
|
+
};
|
|
2942
|
+
var PAYMENT = { amount: M, capturedAmount: M, usdAmountMinor: DROP };
|
|
2943
|
+
var TRANSACTION = { amount: M };
|
|
2944
|
+
var RETURN = { refundAmount: M, items: [{ amount: M }] };
|
|
2945
|
+
var FULFILLMENT = { detail: { shippingCost: M, insuranceAmount: M } };
|
|
2946
|
+
var SUBSCRIPTION = {
|
|
2947
|
+
amount: M,
|
|
2948
|
+
pendingAmount: M,
|
|
2949
|
+
scheduleTotal: M,
|
|
2950
|
+
nextPaymentAmount: M,
|
|
2951
|
+
paymentSchedule: [{ amount: M, discount: M, net: M }],
|
|
2952
|
+
renewalIssue: { charge: { amount: M } }
|
|
2953
|
+
};
|
|
2954
|
+
var QUOTE_ITEM = {
|
|
2955
|
+
unitPrice: M,
|
|
2956
|
+
subtotal: M,
|
|
2957
|
+
discountAmount: M,
|
|
2958
|
+
taxAmount: M,
|
|
2959
|
+
total: M,
|
|
2960
|
+
recurring: { schedule: [{ amount: M }] }
|
|
2961
|
+
};
|
|
2962
|
+
var QUOTE_REVISION = {
|
|
2963
|
+
subtotal: M,
|
|
2964
|
+
discountTotal: M,
|
|
2965
|
+
shippingTotal: M,
|
|
2966
|
+
taxTotal: M,
|
|
2967
|
+
total: M,
|
|
2968
|
+
depositAmount: M,
|
|
2969
|
+
shippingFlatAmount: M,
|
|
2970
|
+
// MC4-R82: a fixed deposit's `value` is a minor-unit amount (unlabelled, and
|
|
2971
|
+
// `depositAmount` carries it); a percent deposit's `value` is its percent and stays.
|
|
2972
|
+
paymentTerms: { deposit: { value: DROP_WHEN("type", "fixed") } },
|
|
2973
|
+
items: [QUOTE_ITEM],
|
|
2974
|
+
acceptanceSelections: { effectiveTotal: M }
|
|
2975
|
+
};
|
|
2976
|
+
var QUOTE_SUMMARY = { total: M, acceptance: { effectiveTotal: M, effectiveGoodsTotal: M } };
|
|
2977
|
+
var QUOTE = {
|
|
2978
|
+
...QUOTE_SUMMARY,
|
|
2979
|
+
revisions: [QUOTE_REVISION],
|
|
2980
|
+
// `revision_issued` records the total, `accepted` the effective total, `price_overridden` the new prices.
|
|
2981
|
+
timeline: [{ data: { total: M, effectiveTotal: M, items: [{ unitPrice: M }] } }]
|
|
2982
|
+
};
|
|
2983
|
+
var INVOICE = {
|
|
2984
|
+
subtotal: M,
|
|
2985
|
+
taxTotal: M,
|
|
2986
|
+
shippingTotal: M,
|
|
2987
|
+
discountTotal: M,
|
|
2988
|
+
total: M,
|
|
2989
|
+
amountRefunded: M,
|
|
2990
|
+
billingSnapshot: {
|
|
2991
|
+
lineItems: [{ unitPrice: M, taxAmount: M, discountAmount: M, total: M }],
|
|
2992
|
+
totals: {
|
|
2993
|
+
subtotal: M,
|
|
2994
|
+
taxTotal: M,
|
|
2995
|
+
shippingTotal: M,
|
|
2996
|
+
discountTotal: M,
|
|
2997
|
+
total: M,
|
|
2998
|
+
orderTotal: M,
|
|
2999
|
+
amountPaid: M,
|
|
3000
|
+
compWaived: M,
|
|
3001
|
+
balanceDue: M
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
var DISCOUNT = {
|
|
3006
|
+
value: DROP_WHEN("type", "fixed_amount"),
|
|
3007
|
+
// `min_order`: the legacy alias legacyMinimumOf still reads on old rows.
|
|
3008
|
+
conditions: { minOrder: DROP, min_order: DROP },
|
|
3009
|
+
amounts: MK({ value: M, minOrder: M })
|
|
3010
|
+
};
|
|
3011
|
+
var CART = {
|
|
3012
|
+
subtotal: M,
|
|
3013
|
+
taxTotal: M,
|
|
3014
|
+
discountTotal: M,
|
|
3015
|
+
shippingTotal: M,
|
|
3016
|
+
total: M,
|
|
3017
|
+
lineItems: [LINE_ITEM],
|
|
3018
|
+
items: [LINE_ITEM],
|
|
3019
|
+
appliedDiscount: { amount: M },
|
|
3020
|
+
selectedShipping: { rateAmount: M },
|
|
3021
|
+
taxLines: [{ amount: M }]
|
|
3022
|
+
};
|
|
3023
|
+
var EVENT_DATA = {
|
|
3024
|
+
amount: M,
|
|
3025
|
+
capturedAmount: M,
|
|
3026
|
+
subtotal: M,
|
|
3027
|
+
taxTotal: M,
|
|
3028
|
+
shippingTotal: M,
|
|
3029
|
+
discountTotal: M,
|
|
3030
|
+
total: M,
|
|
3031
|
+
compAmount: M,
|
|
3032
|
+
refundedAmount: M,
|
|
3033
|
+
paymentAmount: M,
|
|
3034
|
+
amountRefunded: M,
|
|
3035
|
+
totalRefunded: M,
|
|
3036
|
+
refundAmount: M,
|
|
3037
|
+
totalAmount: M,
|
|
3038
|
+
unitPrice: M,
|
|
3039
|
+
rateAmount: M,
|
|
3040
|
+
scheduleTotal: M,
|
|
3041
|
+
nextPaymentAmount: M,
|
|
3042
|
+
order: { ...ORDER, items: [LINE_ITEM] },
|
|
3043
|
+
payment: PAYMENT,
|
|
3044
|
+
subscription: SUBSCRIPTION,
|
|
3045
|
+
previous: { amount: M },
|
|
3046
|
+
pending: { amount: M },
|
|
3047
|
+
recurring: { amount: M },
|
|
3048
|
+
cart: CART,
|
|
3049
|
+
lineItems: [LINE_ITEM],
|
|
3050
|
+
items: [{ ...LINE_ITEM, amount: M }],
|
|
3051
|
+
quote: QUOTE_SUMMARY,
|
|
3052
|
+
revision: QUOTE_REVISION,
|
|
3053
|
+
charge: { amount: M, amountCents: M }
|
|
3054
|
+
};
|
|
3055
|
+
var EVENT = { data: EVENT_DATA };
|
|
3056
|
+
var DELIVERY = { payload: { data: EVENT_DATA } };
|
|
3057
|
+
var SESSION = {
|
|
3058
|
+
recurringTerms: { firstChargeAmountMinor: M },
|
|
3059
|
+
subscriptions: [{ amount: M, firstChargeAmount: M, schedule: [{ net: M }] }]
|
|
3060
|
+
};
|
|
3061
|
+
var page2 = (row) => ({ data: [row] });
|
|
3062
|
+
var MONEY_SPECS = {
|
|
3063
|
+
search_orders: page2(ORDER),
|
|
3064
|
+
get_order: {
|
|
3065
|
+
order: ORDER,
|
|
3066
|
+
payments: [PAYMENT],
|
|
3067
|
+
returns: CURRENCY_OF("order", [RETURN]),
|
|
3068
|
+
fulfillments: CURRENCY_OF("order", [FULFILLMENT])
|
|
3069
|
+
},
|
|
3070
|
+
search_payments: page2(PAYMENT),
|
|
3071
|
+
get_payment: { payment: PAYMENT, transactions: [TRANSACTION] },
|
|
3072
|
+
get_customer: { subscriptions: [SUBSCRIPTION] },
|
|
3073
|
+
list_subscriptions: page2(SUBSCRIPTION),
|
|
3074
|
+
get_subscription: SUBSCRIPTION,
|
|
3075
|
+
search_quotes: page2(QUOTE_SUMMARY),
|
|
3076
|
+
get_quote: QUOTE,
|
|
3077
|
+
list_invoices: page2(INVOICE),
|
|
3078
|
+
get_invoice: INVOICE,
|
|
3079
|
+
search_discounts: page2(DISCOUNT),
|
|
3080
|
+
get_discount: DISCOUNT,
|
|
3081
|
+
search_events: page2(EVENT),
|
|
3082
|
+
list_webhook_deliveries: page2(DELIVERY),
|
|
3083
|
+
get_webhook_delivery: DELIVERY,
|
|
3084
|
+
explain_checkout_failure: {
|
|
3085
|
+
session: SESSION,
|
|
3086
|
+
cart: CART,
|
|
3087
|
+
events: [EVENT],
|
|
3088
|
+
recentWebhookDeliveries: [DELIVERY]
|
|
3089
|
+
},
|
|
3090
|
+
// Writes that return a record. Each added line item echoes its cart's
|
|
3091
|
+
// `currency`; the sibling cart's is the fallback for one that does not.
|
|
3092
|
+
seed_test_data: { cart: CART, lineItems: CURRENCY_OF("cart", [LINE_ITEM]), order: ORDER },
|
|
3093
|
+
create_quote: { quote: QUOTE_SUMMARY, revision: QUOTE_REVISION, items: [QUOTE_ITEM] },
|
|
3094
|
+
manage_subscription: SUBSCRIPTION,
|
|
3095
|
+
set_subscription_payment_method: SUBSCRIPTION,
|
|
3096
|
+
// GET /api/v1/stores: `settings.shipping` is stamped with its own currency
|
|
3097
|
+
// (MC1-R74); an unstamped one takes the store's.
|
|
3098
|
+
list_applications: [{ settings: { shipping: { flatRateCents: M, freeThresholdCents: M } } }],
|
|
3099
|
+
// ---------------------------------------------------------------- analytics
|
|
3100
|
+
get_sales_timeseries: {
|
|
3101
|
+
totalGrossCents: DROP,
|
|
3102
|
+
series: [{ grossCents: DROP }],
|
|
3103
|
+
comparison: { totalGrossCents: DROP }
|
|
3104
|
+
},
|
|
3105
|
+
get_business_summary: {
|
|
3106
|
+
orders: { current: ORDERS_WINDOW, previous: ORDERS_WINDOW, deltaPct: DROP },
|
|
3107
|
+
subscriptions: { mrr: { currentCents: DROP, periodStartCents: DROP, deltaPct: DROP } },
|
|
3108
|
+
receivables: { outstandingCents: DROP },
|
|
3109
|
+
quotes: { sent: QUOTE_BUCKET, accepted: QUOTE_BUCKET, expired: QUOTE_BUCKET, declined: QUOTE_BUCKET }
|
|
3110
|
+
},
|
|
3111
|
+
get_attention_digest: {
|
|
3112
|
+
disputes: { totalCents: DROP },
|
|
3113
|
+
overdueInvoices: { totalCents: DROP }
|
|
3114
|
+
},
|
|
3115
|
+
get_top_products: {
|
|
3116
|
+
rows: [{ revenueCents: DROP }],
|
|
3117
|
+
totals: { revenueCents: DROP }
|
|
3118
|
+
},
|
|
3119
|
+
get_customer_growth: {
|
|
3120
|
+
topCustomers: [{ revenueCents: DROP }],
|
|
3121
|
+
totals: { revenueCents: DROP }
|
|
3122
|
+
},
|
|
3123
|
+
get_revenue_breakdown: {
|
|
3124
|
+
rows: [{ grossCents: DROP }],
|
|
3125
|
+
totals: { grossCents: DROP }
|
|
3126
|
+
},
|
|
3127
|
+
get_subscription_movement: {
|
|
3128
|
+
series: [{ mrrDeltaCents: DROP }],
|
|
3129
|
+
totals: { netMrrDeltaCents: DROP }
|
|
3130
|
+
},
|
|
3131
|
+
get_discount_performance: {
|
|
3132
|
+
rows: [{ discountedRevenueCents: DROP, discountGivenCents: DROP }],
|
|
3133
|
+
totals: { discountedRevenueCents: DROP, discountGivenCents: DROP }
|
|
3134
|
+
},
|
|
3135
|
+
receivables_aging: {
|
|
3136
|
+
buckets: [{ total_amount: DROP }],
|
|
3137
|
+
total_outstanding_amount: DROP
|
|
3138
|
+
},
|
|
3139
|
+
// The handler returns `{ carts, summary }`; `summary` is the
|
|
3140
|
+
// /abandoned-carts/summary payload, or optional()'s unavailable string.
|
|
3141
|
+
list_abandoned_carts: {
|
|
3142
|
+
carts: [{ total: M }],
|
|
3143
|
+
summary: { abandonedValue: DROP }
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
var isPlainObject3 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
3147
|
+
var join = (path, key) => path ? `${path}.${key}` : key;
|
|
3148
|
+
function knownCode(v) {
|
|
3149
|
+
if (typeof v !== "string") return void 0;
|
|
3150
|
+
const code = v.trim().toUpperCase();
|
|
3151
|
+
return isKnownCurrency(code) ? code : void 0;
|
|
3152
|
+
}
|
|
3153
|
+
function walk2(spec, value, currency, path, unwrapped) {
|
|
3154
|
+
if (spec === DROP) return value;
|
|
3155
|
+
if (spec === M) {
|
|
3156
|
+
if (typeof value !== "number") return value;
|
|
3157
|
+
if (!currency) {
|
|
3158
|
+
unwrapped.push(path);
|
|
3159
|
+
return value;
|
|
3160
|
+
}
|
|
3161
|
+
return moneyValue(value, currency);
|
|
3162
|
+
}
|
|
3163
|
+
if (Array.isArray(spec)) {
|
|
3164
|
+
if (!Array.isArray(value)) return value;
|
|
3165
|
+
return value.map((item, i) => walk2(spec[0], item, currency, `${path}[${i}]`, unwrapped));
|
|
3166
|
+
}
|
|
3167
|
+
if ("__currencyOf" in spec || "__dropWhen" in spec) {
|
|
3168
|
+
throw new Error(`money spec at "${path}": CURRENCY_OF and DROP_WHEN are only valid as an object child`);
|
|
3169
|
+
}
|
|
3170
|
+
if (!isPlainObject3(value)) return value;
|
|
3171
|
+
if ("__moneyKeyed" in spec) {
|
|
3172
|
+
const inner = spec.__moneyKeyed;
|
|
3173
|
+
return Object.fromEntries(
|
|
3174
|
+
Object.entries(value).map(([code, item]) => [
|
|
3175
|
+
code,
|
|
3176
|
+
walk2(inner, item, knownCode(code), join(path, code), unwrapped)
|
|
3177
|
+
])
|
|
3178
|
+
);
|
|
3179
|
+
}
|
|
3180
|
+
const own = "currency" in value ? knownCode(value.currency) : currency;
|
|
3181
|
+
const out = { ...value };
|
|
3182
|
+
for (const [key, child] of Object.entries(spec)) {
|
|
3183
|
+
if (!(key in value)) continue;
|
|
3184
|
+
if (child === DROP) {
|
|
3185
|
+
delete out[key];
|
|
3186
|
+
continue;
|
|
3187
|
+
}
|
|
3188
|
+
if (typeof child === "object" && "__dropWhen" in child) {
|
|
3189
|
+
const { field, equals } = child.__dropWhen;
|
|
3190
|
+
if (value[field] === equals) delete out[key];
|
|
3191
|
+
continue;
|
|
3192
|
+
}
|
|
3193
|
+
if (typeof child === "object" && "__currencyOf" in child) {
|
|
3194
|
+
const { sibling, spec: inner } = child.__currencyOf;
|
|
3195
|
+
const record = value[sibling];
|
|
3196
|
+
const siblingCurrency = isPlainObject3(record) ? knownCode(record.currency) : void 0;
|
|
3197
|
+
out[key] = walk2(inner, value[key], siblingCurrency, join(path, key), unwrapped);
|
|
3198
|
+
continue;
|
|
3199
|
+
}
|
|
3200
|
+
out[key] = walk2(child, value[key], own, join(path, key), unwrapped);
|
|
3201
|
+
}
|
|
3202
|
+
return out;
|
|
3203
|
+
}
|
|
3204
|
+
function applyMoneySpec(spec, value) {
|
|
3205
|
+
const unwrapped = [];
|
|
3206
|
+
return { value: walk2(spec, value, void 0, "", unwrapped), unwrapped };
|
|
3207
|
+
}
|
|
3208
|
+
function decorateMoney(actionId, value) {
|
|
3209
|
+
const spec = MONEY_SPECS[actionId];
|
|
3210
|
+
return spec ? applyMoneySpec(spec, value) : { value, unwrapped: [] };
|
|
3211
|
+
}
|
|
3212
|
+
|
|
2662
3213
|
// src/projection.ts
|
|
2663
3214
|
var S = "scalar";
|
|
2664
3215
|
var T = "text";
|
|
2665
3216
|
var PASS = "pass";
|
|
2666
3217
|
var section = (shape) => ({ __section: shape });
|
|
2667
3218
|
var oneOf = (values) => ({ __oneOf: new Set(values) });
|
|
3219
|
+
var mapOf = (shape) => ({ __map: shape });
|
|
3220
|
+
var CURRENCY_KEY = /^[A-Z]{3}$/;
|
|
2668
3221
|
function isPrimitive(value) {
|
|
2669
3222
|
return value === null || ["string", "number", "boolean"].includes(typeof value);
|
|
2670
3223
|
}
|
|
@@ -2683,6 +3236,12 @@ function project(value, shape) {
|
|
|
2683
3236
|
if (!isPrimitive(value)) return void 0;
|
|
2684
3237
|
return typeof value === "string" && !shape.__oneOf.has(value) ? null : value;
|
|
2685
3238
|
}
|
|
3239
|
+
if ("__map" in shape) {
|
|
3240
|
+
if (value === null) return null;
|
|
3241
|
+
if (typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3242
|
+
const entries = Object.entries(value).filter(([code]) => CURRENCY_KEY.test(code)).map(([code, item]) => [code, project(item, shape.__map)]).filter(([, projected]) => projected !== void 0);
|
|
3243
|
+
return Object.fromEntries(entries);
|
|
3244
|
+
}
|
|
2686
3245
|
if (Array.isArray(shape)) {
|
|
2687
3246
|
return Array.isArray(value) ? value.map((item) => project(item, shape[0])) : void 0;
|
|
2688
3247
|
}
|
|
@@ -2702,8 +3261,10 @@ function project(value, shape) {
|
|
|
2702
3261
|
}
|
|
2703
3262
|
return out;
|
|
2704
3263
|
}
|
|
3264
|
+
var MONEY = { amount: S, currency: S, display: T };
|
|
3265
|
+
var byCurrency = (extra = {}) => [{ ...MONEY, ...extra }];
|
|
2705
3266
|
var PAGINATION = { cursor: S, nextCursor: S, hasMore: S };
|
|
2706
|
-
var
|
|
3267
|
+
var page3 = (row) => ({ data: [row], pagination: PAGINATION });
|
|
2707
3268
|
var ADDRESS = { countryCode: S };
|
|
2708
3269
|
var CUSTOMER_REF = { id: S };
|
|
2709
3270
|
var APPLICATION = { id: S, name: T, slug: S };
|
|
@@ -2738,23 +3299,23 @@ var LINE_RECURRING = {
|
|
|
2738
3299
|
intervalCount: S,
|
|
2739
3300
|
totalPayments: S,
|
|
2740
3301
|
trialDays: S,
|
|
2741
|
-
// A custom installment schedule: amounts
|
|
2742
|
-
schedule: [{ amount:
|
|
3302
|
+
// A custom installment schedule: amounts are money, gaps are numbers and unit tokens, no free text.
|
|
3303
|
+
schedule: [{ amount: MONEY, intervalUnit: S, intervalCount: S }]
|
|
2743
3304
|
};
|
|
2744
|
-
var
|
|
3305
|
+
var LINE_ITEM2 = {
|
|
2745
3306
|
id: S,
|
|
2746
3307
|
type: S,
|
|
2747
3308
|
quantity: S,
|
|
2748
|
-
unitPrice:
|
|
2749
|
-
subtotal:
|
|
2750
|
-
discountAmount:
|
|
2751
|
-
taxAmount:
|
|
2752
|
-
total:
|
|
3309
|
+
unitPrice: MONEY,
|
|
3310
|
+
subtotal: MONEY,
|
|
3311
|
+
discountAmount: MONEY,
|
|
3312
|
+
taxAmount: MONEY,
|
|
3313
|
+
total: MONEY,
|
|
2753
3314
|
// amount = renewal price on a trial line (whose unitPrice is 0); count = the old display mirror.
|
|
2754
|
-
recurring: { ...LINE_RECURRING, amount:
|
|
3315
|
+
recurring: { ...LINE_RECURRING, amount: MONEY, count: S, scheduleUnitTotal: MONEY },
|
|
2755
3316
|
subscriptionId: S
|
|
2756
3317
|
};
|
|
2757
|
-
var
|
|
3318
|
+
var ORDER2 = {
|
|
2758
3319
|
id: S,
|
|
2759
3320
|
orderNumber: S,
|
|
2760
3321
|
status: S,
|
|
@@ -2763,14 +3324,14 @@ var ORDER = {
|
|
|
2763
3324
|
type: S,
|
|
2764
3325
|
source: S,
|
|
2765
3326
|
currency: S,
|
|
2766
|
-
subtotal:
|
|
2767
|
-
discountTotal:
|
|
2768
|
-
shippingTotal:
|
|
2769
|
-
taxTotal:
|
|
2770
|
-
total:
|
|
2771
|
-
capturedAmount:
|
|
2772
|
-
refundedAmount:
|
|
2773
|
-
compAmount:
|
|
3327
|
+
subtotal: MONEY,
|
|
3328
|
+
discountTotal: MONEY,
|
|
3329
|
+
shippingTotal: MONEY,
|
|
3330
|
+
taxTotal: MONEY,
|
|
3331
|
+
total: MONEY,
|
|
3332
|
+
capturedAmount: MONEY,
|
|
3333
|
+
refundedAmount: MONEY,
|
|
3334
|
+
compAmount: MONEY,
|
|
2774
3335
|
onHold: S,
|
|
2775
3336
|
taxReverseCharge: S,
|
|
2776
3337
|
customerId: S,
|
|
@@ -2780,20 +3341,20 @@ var ORDER = {
|
|
|
2780
3341
|
shippingAddress: ADDRESS,
|
|
2781
3342
|
billingAddress: ADDRESS,
|
|
2782
3343
|
fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
|
|
2783
|
-
lineItems: [
|
|
3344
|
+
lineItems: [LINE_ITEM2],
|
|
2784
3345
|
createdAt: S,
|
|
2785
3346
|
completedAt: S,
|
|
2786
3347
|
cancelledAt: S,
|
|
2787
3348
|
closedAt: S
|
|
2788
3349
|
};
|
|
2789
|
-
var
|
|
3350
|
+
var PAYMENT2 = {
|
|
2790
3351
|
id: S,
|
|
2791
3352
|
orderId: S,
|
|
2792
3353
|
status: S,
|
|
2793
3354
|
method: S,
|
|
2794
3355
|
processor: S,
|
|
2795
|
-
amount:
|
|
2796
|
-
capturedAmount:
|
|
3356
|
+
amount: MONEY,
|
|
3357
|
+
capturedAmount: MONEY,
|
|
2797
3358
|
currency: S,
|
|
2798
3359
|
cardBrand: S,
|
|
2799
3360
|
disputed: S,
|
|
@@ -2808,17 +3369,17 @@ var PAYMENT = {
|
|
|
2808
3369
|
voidedAt: S,
|
|
2809
3370
|
createdAt: S
|
|
2810
3371
|
};
|
|
2811
|
-
var
|
|
3372
|
+
var RETURN2 = {
|
|
2812
3373
|
id: S,
|
|
2813
3374
|
orderId: S,
|
|
2814
3375
|
status: S,
|
|
2815
3376
|
restock: S,
|
|
2816
|
-
refundAmount:
|
|
3377
|
+
refundAmount: MONEY,
|
|
2817
3378
|
refundPaymentId: S,
|
|
2818
3379
|
createdAt: S,
|
|
2819
3380
|
items: [{ lineItemId: S, quantity: S }]
|
|
2820
3381
|
};
|
|
2821
|
-
var
|
|
3382
|
+
var FULFILLMENT2 = {
|
|
2822
3383
|
id: S,
|
|
2823
3384
|
orderId: S,
|
|
2824
3385
|
type: S,
|
|
@@ -2828,12 +3389,12 @@ var FULFILLMENT = {
|
|
|
2828
3389
|
detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
|
|
2829
3390
|
};
|
|
2830
3391
|
var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
|
|
2831
|
-
var
|
|
3392
|
+
var SUBSCRIPTION2 = {
|
|
2832
3393
|
id: S,
|
|
2833
3394
|
status: S,
|
|
2834
3395
|
planName: T,
|
|
2835
3396
|
planReference: T,
|
|
2836
|
-
amount:
|
|
3397
|
+
amount: MONEY,
|
|
2837
3398
|
currency: S,
|
|
2838
3399
|
interval: S,
|
|
2839
3400
|
quantity: S,
|
|
@@ -2855,22 +3416,22 @@ var SUBSCRIPTION = {
|
|
|
2855
3416
|
failureCount: S,
|
|
2856
3417
|
pendingPlanName: T,
|
|
2857
3418
|
pendingPlanReference: T,
|
|
2858
|
-
pendingAmount:
|
|
3419
|
+
pendingAmount: MONEY,
|
|
2859
3420
|
pendingInterval: S,
|
|
2860
3421
|
pendingQuantity: S,
|
|
2861
3422
|
pendingIntervalUnit: S,
|
|
2862
3423
|
pendingIntervalCount: S,
|
|
2863
|
-
scheduleTotal:
|
|
2864
|
-
nextPaymentAmount:
|
|
3424
|
+
scheduleTotal: MONEY,
|
|
3425
|
+
nextPaymentAmount: MONEY,
|
|
2865
3426
|
// A physical subscription (0236): the method is an enum, and the ship-to is
|
|
2866
3427
|
// kept to its country like every other address here.
|
|
2867
3428
|
deliveryMethod: S,
|
|
2868
3429
|
shippingAddress: ADDRESS,
|
|
2869
3430
|
paymentSchedule: [{
|
|
2870
3431
|
index: S,
|
|
2871
|
-
amount:
|
|
2872
|
-
discount:
|
|
2873
|
-
net:
|
|
3432
|
+
amount: MONEY,
|
|
3433
|
+
discount: MONEY,
|
|
3434
|
+
net: MONEY,
|
|
2874
3435
|
intervalUnit: S,
|
|
2875
3436
|
intervalCount: S,
|
|
2876
3437
|
status: S,
|
|
@@ -2878,13 +3439,13 @@ var SUBSCRIPTION = {
|
|
|
2878
3439
|
}],
|
|
2879
3440
|
createdAt: S
|
|
2880
3441
|
};
|
|
2881
|
-
var
|
|
3442
|
+
var QUOTE_SUMMARY2 = {
|
|
2882
3443
|
id: S,
|
|
2883
3444
|
quoteNumber: S,
|
|
2884
3445
|
status: S,
|
|
2885
3446
|
source: S,
|
|
2886
3447
|
currency: S,
|
|
2887
|
-
total:
|
|
3448
|
+
total: MONEY,
|
|
2888
3449
|
customerId: S,
|
|
2889
3450
|
orderId: S,
|
|
2890
3451
|
expiresAt: S,
|
|
@@ -2892,18 +3453,18 @@ var QUOTE_SUMMARY = {
|
|
|
2892
3453
|
declinedAt: S,
|
|
2893
3454
|
createdAt: S
|
|
2894
3455
|
};
|
|
2895
|
-
var
|
|
2896
|
-
...
|
|
3456
|
+
var QUOTE2 = {
|
|
3457
|
+
...QUOTE_SUMMARY2,
|
|
2897
3458
|
revisions: [{
|
|
2898
3459
|
id: S,
|
|
2899
3460
|
revisionNumber: S,
|
|
2900
3461
|
state: S,
|
|
2901
|
-
subtotal:
|
|
2902
|
-
discountTotal:
|
|
2903
|
-
shippingTotal:
|
|
2904
|
-
taxTotal:
|
|
2905
|
-
total:
|
|
2906
|
-
depositAmount:
|
|
3462
|
+
subtotal: MONEY,
|
|
3463
|
+
discountTotal: MONEY,
|
|
3464
|
+
shippingTotal: MONEY,
|
|
3465
|
+
taxTotal: MONEY,
|
|
3466
|
+
total: MONEY,
|
|
3467
|
+
depositAmount: MONEY,
|
|
2907
3468
|
shippingMode: S,
|
|
2908
3469
|
issuedAt: S,
|
|
2909
3470
|
expiresAt: S,
|
|
@@ -2911,11 +3472,11 @@ var QUOTE = {
|
|
|
2911
3472
|
items: [{
|
|
2912
3473
|
type: S,
|
|
2913
3474
|
quantity: S,
|
|
2914
|
-
unitPrice:
|
|
2915
|
-
subtotal:
|
|
2916
|
-
discountAmount:
|
|
2917
|
-
taxAmount:
|
|
2918
|
-
total:
|
|
3475
|
+
unitPrice: MONEY,
|
|
3476
|
+
subtotal: MONEY,
|
|
3477
|
+
discountAmount: MONEY,
|
|
3478
|
+
taxAmount: MONEY,
|
|
3479
|
+
total: MONEY,
|
|
2919
3480
|
optional: S,
|
|
2920
3481
|
optionalSelected: S,
|
|
2921
3482
|
recurring: LINE_RECURRING
|
|
@@ -2925,7 +3486,7 @@ var QUOTE = {
|
|
|
2925
3486
|
comments: [{ authorType: S, visibility: S, createdAt: S }],
|
|
2926
3487
|
timeline: [{ type: S, actorType: S, createdAt: S }]
|
|
2927
3488
|
};
|
|
2928
|
-
var
|
|
3489
|
+
var INVOICE2 = {
|
|
2929
3490
|
id: S,
|
|
2930
3491
|
number: S,
|
|
2931
3492
|
status: S,
|
|
@@ -2933,12 +3494,12 @@ var INVOICE = {
|
|
|
2933
3494
|
sourceId: S,
|
|
2934
3495
|
customerId: S,
|
|
2935
3496
|
currency: S,
|
|
2936
|
-
subtotal:
|
|
2937
|
-
discountTotal:
|
|
2938
|
-
shippingTotal:
|
|
2939
|
-
taxTotal:
|
|
2940
|
-
total:
|
|
2941
|
-
amountRefunded:
|
|
3497
|
+
subtotal: MONEY,
|
|
3498
|
+
discountTotal: MONEY,
|
|
3499
|
+
shippingTotal: MONEY,
|
|
3500
|
+
taxTotal: MONEY,
|
|
3501
|
+
total: MONEY,
|
|
3502
|
+
amountRefunded: MONEY,
|
|
2942
3503
|
issuedAt: S,
|
|
2943
3504
|
dueAt: S,
|
|
2944
3505
|
periodStart: S,
|
|
@@ -2947,12 +3508,12 @@ var INVOICE = {
|
|
|
2947
3508
|
billingSnapshot: {
|
|
2948
3509
|
planName: T,
|
|
2949
3510
|
period: { start: S, end: S },
|
|
2950
|
-
lineItems: [{ quantity: S, unitPrice:
|
|
2951
|
-
totals: { currency: S, subtotal:
|
|
3511
|
+
lineItems: [{ quantity: S, unitPrice: MONEY, discountAmount: MONEY, taxAmount: MONEY, total: MONEY }],
|
|
3512
|
+
totals: { currency: S, subtotal: MONEY, discountTotal: MONEY, shippingTotal: MONEY, taxTotal: MONEY, total: MONEY },
|
|
2952
3513
|
payment: { method: S, brand: S, status: S }
|
|
2953
3514
|
}
|
|
2954
3515
|
};
|
|
2955
|
-
var
|
|
3516
|
+
var DISCOUNT2 = {
|
|
2956
3517
|
id: S,
|
|
2957
3518
|
code: T,
|
|
2958
3519
|
name: T,
|
|
@@ -2964,9 +3525,13 @@ var DISCOUNT = {
|
|
|
2964
3525
|
usageCount: S,
|
|
2965
3526
|
usageLimit: S,
|
|
2966
3527
|
maxRedemptionsPerCustomer: S,
|
|
2967
|
-
createdAt: S
|
|
3528
|
+
createdAt: S,
|
|
3529
|
+
// Per currency, main one included. The decorator drops a fixed discount's legacy `value`
|
|
3530
|
+
// (MC4-R77), so this is where its amount is. A percentage discount's `amounts` hold only
|
|
3531
|
+
// a minimum, so `value` is money whenever it is present.
|
|
3532
|
+
amounts: mapOf({ value: MONEY, minOrder: MONEY })
|
|
2968
3533
|
};
|
|
2969
|
-
var
|
|
3534
|
+
var EVENT2 = {
|
|
2970
3535
|
id: S,
|
|
2971
3536
|
type: S,
|
|
2972
3537
|
entityType: S,
|
|
@@ -2976,18 +3541,18 @@ var EVENT = {
|
|
|
2976
3541
|
status: S,
|
|
2977
3542
|
previousStatus: S,
|
|
2978
3543
|
action: S,
|
|
2979
|
-
amount:
|
|
3544
|
+
amount: MONEY,
|
|
2980
3545
|
currency: S,
|
|
2981
3546
|
attempt: S,
|
|
2982
3547
|
orderId: S,
|
|
2983
3548
|
paymentId: S,
|
|
2984
|
-
order: { id: S, orderNumber: S, status: S, paymentStatus: S, currency: S, total:
|
|
2985
|
-
payment: { id: S, orderId: S, status: S, method: S, amount:
|
|
2986
|
-
subscription: { id: S, status: S, planName: T, amount:
|
|
3549
|
+
order: { id: S, orderNumber: S, status: S, paymentStatus: S, currency: S, total: MONEY },
|
|
3550
|
+
payment: { id: S, orderId: S, status: S, method: S, amount: MONEY, currency: S },
|
|
3551
|
+
subscription: { id: S, status: S, planName: T, amount: MONEY, currency: S, interval: S },
|
|
2987
3552
|
fulfillment: { id: S, orderId: S, type: S, status: S }
|
|
2988
3553
|
}
|
|
2989
3554
|
};
|
|
2990
|
-
var
|
|
3555
|
+
var DELIVERY2 = {
|
|
2991
3556
|
id: S,
|
|
2992
3557
|
endpointId: S,
|
|
2993
3558
|
eventId: S,
|
|
@@ -3000,8 +3565,11 @@ var DELIVERY = {
|
|
|
3000
3565
|
createdAt: S,
|
|
3001
3566
|
replayOf: S
|
|
3002
3567
|
};
|
|
3003
|
-
var
|
|
3004
|
-
var ORDER_PERIOD = {
|
|
3568
|
+
var COUNT_BY_CURRENCY = { count: S, byCurrency: byCurrency({ count: S }) };
|
|
3569
|
+
var ORDER_PERIOD = {
|
|
3570
|
+
orderCount: S,
|
|
3571
|
+
byCurrency: byCurrency({ orderCount: S, avgOrder: MONEY, refunds: MONEY, net: MONEY })
|
|
3572
|
+
};
|
|
3005
3573
|
var OAUTH_PROJECTIONS = {
|
|
3006
3574
|
whoami: {
|
|
3007
3575
|
type: S,
|
|
@@ -3013,36 +3581,37 @@ var OAUTH_PROJECTIONS = {
|
|
|
3013
3581
|
search_docs: PASS,
|
|
3014
3582
|
describe_endpoint: PASS,
|
|
3015
3583
|
validate_payload: PASS,
|
|
3016
|
-
search_orders:
|
|
3584
|
+
search_orders: page3(ORDER2),
|
|
3017
3585
|
get_order: {
|
|
3018
|
-
order:
|
|
3019
|
-
payments: section([
|
|
3020
|
-
returns: section([
|
|
3021
|
-
fulfillments: section([
|
|
3586
|
+
order: ORDER2,
|
|
3587
|
+
payments: section([PAYMENT2]),
|
|
3588
|
+
returns: section([RETURN2]),
|
|
3589
|
+
fulfillments: section([FULFILLMENT2])
|
|
3022
3590
|
},
|
|
3023
|
-
search_customers:
|
|
3591
|
+
search_customers: page3(CUSTOMER),
|
|
3024
3592
|
get_customer: {
|
|
3025
3593
|
customer: CUSTOMER,
|
|
3026
3594
|
addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
|
|
3027
|
-
subscriptions: section([
|
|
3028
|
-
},
|
|
3029
|
-
list_subscriptions:
|
|
3030
|
-
get_subscription:
|
|
3031
|
-
search_quotes:
|
|
3032
|
-
get_quote:
|
|
3033
|
-
list_invoices:
|
|
3034
|
-
get_invoice:
|
|
3595
|
+
subscriptions: section([SUBSCRIPTION2])
|
|
3596
|
+
},
|
|
3597
|
+
list_subscriptions: page3(SUBSCRIPTION2),
|
|
3598
|
+
get_subscription: SUBSCRIPTION2,
|
|
3599
|
+
search_quotes: page3(QUOTE_SUMMARY2),
|
|
3600
|
+
get_quote: QUOTE2,
|
|
3601
|
+
list_invoices: page3(INVOICE2),
|
|
3602
|
+
get_invoice: INVOICE2,
|
|
3035
3603
|
receivables_aging: {
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
total_outstanding_count: S
|
|
3604
|
+
currency: S,
|
|
3605
|
+
buckets: [{ key: S, label: T, count: S, byCurrency: byCurrency({ count: S }) }],
|
|
3606
|
+
total_outstanding_count: S,
|
|
3607
|
+
byCurrency: byCurrency({ count: S })
|
|
3039
3608
|
},
|
|
3040
|
-
search_discounts:
|
|
3041
|
-
get_discount:
|
|
3042
|
-
search_payments:
|
|
3609
|
+
search_discounts: page3(DISCOUNT2),
|
|
3610
|
+
get_discount: DISCOUNT2,
|
|
3611
|
+
search_payments: page3(PAYMENT2),
|
|
3043
3612
|
get_payment: {
|
|
3044
|
-
payment:
|
|
3045
|
-
transactions: section([{ id: S, type: S, status: S, amount:
|
|
3613
|
+
payment: PAYMENT2,
|
|
3614
|
+
transactions: section([{ id: S, type: S, status: S, amount: MONEY, currency: S, createdAt: S }])
|
|
3046
3615
|
},
|
|
3047
3616
|
list_abandoned_carts: {
|
|
3048
3617
|
carts: section([{
|
|
@@ -3051,14 +3620,20 @@ var OAUTH_PROJECTIONS = {
|
|
|
3051
3620
|
currency: S,
|
|
3052
3621
|
itemCount: S,
|
|
3053
3622
|
recoveryStatus: S,
|
|
3054
|
-
total:
|
|
3623
|
+
total: MONEY,
|
|
3055
3624
|
customer: { id: S }
|
|
3056
3625
|
}]),
|
|
3057
|
-
summary: section({
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3626
|
+
summary: section({
|
|
3627
|
+
abandonedCount: S,
|
|
3628
|
+
currency: S,
|
|
3629
|
+
byCurrency: byCurrency({ count: S }),
|
|
3630
|
+
recoveryEmailsSent: S,
|
|
3631
|
+
sinceDays: S
|
|
3632
|
+
})
|
|
3633
|
+
},
|
|
3634
|
+
search_events: page3(EVENT2),
|
|
3635
|
+
list_webhook_deliveries: page3(DELIVERY2),
|
|
3636
|
+
get_webhook_delivery: DELIVERY2,
|
|
3062
3637
|
explain_checkout_failure: {
|
|
3063
3638
|
note: T,
|
|
3064
3639
|
hint: T,
|
|
@@ -3083,13 +3658,13 @@ var OAUTH_PROJECTIONS = {
|
|
|
3083
3658
|
planName: T,
|
|
3084
3659
|
trialDays: S,
|
|
3085
3660
|
currency: S,
|
|
3086
|
-
firstChargeAmountMinor:
|
|
3661
|
+
firstChargeAmountMinor: MONEY
|
|
3087
3662
|
},
|
|
3088
3663
|
hasSubscriptions: S,
|
|
3089
3664
|
// One entry per subscription line. No `name`: it is the line's name.
|
|
3090
3665
|
subscriptions: [{
|
|
3091
3666
|
lineItemId: S,
|
|
3092
|
-
amount:
|
|
3667
|
+
amount: MONEY,
|
|
3093
3668
|
quantity: S,
|
|
3094
3669
|
interval: S,
|
|
3095
3670
|
intervalUnit: S,
|
|
@@ -3100,27 +3675,27 @@ var OAUTH_PROJECTIONS = {
|
|
|
3100
3675
|
planChargedToday: S,
|
|
3101
3676
|
taxApplies: S,
|
|
3102
3677
|
scheduleGapUnits: [S],
|
|
3103
|
-
schedule: [{ net:
|
|
3678
|
+
schedule: [{ net: MONEY, dueAt: S }]
|
|
3104
3679
|
}]
|
|
3105
3680
|
},
|
|
3106
3681
|
cart: section({
|
|
3107
3682
|
id: S,
|
|
3108
3683
|
status: S,
|
|
3109
3684
|
currency: S,
|
|
3110
|
-
subtotal:
|
|
3111
|
-
discountTotal:
|
|
3112
|
-
shippingTotal:
|
|
3113
|
-
taxTotal:
|
|
3114
|
-
total:
|
|
3685
|
+
subtotal: MONEY,
|
|
3686
|
+
discountTotal: MONEY,
|
|
3687
|
+
shippingTotal: MONEY,
|
|
3688
|
+
taxTotal: MONEY,
|
|
3689
|
+
total: MONEY,
|
|
3115
3690
|
itemCount: S,
|
|
3116
|
-
items: [
|
|
3117
|
-
lineItems: [
|
|
3691
|
+
items: [LINE_ITEM2],
|
|
3692
|
+
lineItems: [LINE_ITEM2]
|
|
3118
3693
|
}),
|
|
3119
|
-
events: [
|
|
3694
|
+
events: [EVENT2],
|
|
3120
3695
|
eventsUnavailable: T,
|
|
3121
|
-
recentWebhookDeliveries: section([
|
|
3696
|
+
recentWebhookDeliveries: section([DELIVERY2])
|
|
3122
3697
|
},
|
|
3123
|
-
list_extension_installations:
|
|
3698
|
+
list_extension_installations: page3({
|
|
3124
3699
|
id: S,
|
|
3125
3700
|
extensionId: S,
|
|
3126
3701
|
extensionName: T,
|
|
@@ -3163,27 +3738,38 @@ var OAUTH_PROJECTIONS = {
|
|
|
3163
3738
|
},
|
|
3164
3739
|
get_workspace_settings: { name: T, slug: S, brandColor: S, logoUrl: T, onboardingCompletedAt: S },
|
|
3165
3740
|
// What happened and to which record; not which team member did it.
|
|
3166
|
-
get_audit_log:
|
|
3741
|
+
get_audit_log: page3({ id: S, action: S, resourceType: S, resourceId: S, createdAt: S }),
|
|
3167
3742
|
list_applications: [{ id: S, name: T, slug: S, currency: S, isActive: S }],
|
|
3168
3743
|
// Analytics: computed aggregates, listed field by field all the same.
|
|
3169
3744
|
get_business_summary: {
|
|
3170
3745
|
period: S,
|
|
3746
|
+
currency: S,
|
|
3171
3747
|
range: RANGE,
|
|
3172
|
-
orders: section({
|
|
3748
|
+
orders: section({
|
|
3749
|
+
current: ORDER_PERIOD,
|
|
3750
|
+
previous: ORDER_PERIOD,
|
|
3751
|
+
deltaByCurrency: [{ currency: S, deltaPct: S }]
|
|
3752
|
+
}),
|
|
3173
3753
|
subscriptions: section({
|
|
3174
|
-
mrr: {
|
|
3754
|
+
mrr: { byCurrency: byCurrency({ periodStart: MONEY, deltaPct: S }) },
|
|
3175
3755
|
newSubscriptions: S,
|
|
3176
3756
|
cancelledSubscriptions: S,
|
|
3177
3757
|
churnRate: S,
|
|
3178
3758
|
note: T
|
|
3179
3759
|
}),
|
|
3180
|
-
receivables: section({
|
|
3181
|
-
quotes: section({
|
|
3760
|
+
receivables: section({ outstandingCount: S, byCurrency: byCurrency({ count: S }) }),
|
|
3761
|
+
quotes: section({
|
|
3762
|
+
sent: COUNT_BY_CURRENCY,
|
|
3763
|
+
accepted: COUNT_BY_CURRENCY,
|
|
3764
|
+
declined: COUNT_BY_CURRENCY,
|
|
3765
|
+
expired: COUNT_BY_CURRENCY
|
|
3766
|
+
})
|
|
3182
3767
|
},
|
|
3183
3768
|
get_attention_digest: {
|
|
3184
|
-
|
|
3769
|
+
currency: S,
|
|
3770
|
+
disputes: section({ open: S, byCurrency: byCurrency({ count: S }) }),
|
|
3185
3771
|
subscriptionsInDunning: section(S),
|
|
3186
|
-
overdueInvoices: section(
|
|
3772
|
+
overdueInvoices: section(COUNT_BY_CURRENCY),
|
|
3187
3773
|
unhealthyWebhooks: section([{ endpointId: S, failureRate: S, attempts7d: S }])
|
|
3188
3774
|
},
|
|
3189
3775
|
get_sales_timeseries: {
|
|
@@ -3192,30 +3778,33 @@ var OAUTH_PROJECTIONS = {
|
|
|
3192
3778
|
currency: S,
|
|
3193
3779
|
days: S,
|
|
3194
3780
|
note: T,
|
|
3195
|
-
series: [{ date: S,
|
|
3196
|
-
|
|
3197
|
-
|
|
3781
|
+
series: [{ date: S, orders: S, paidOrders: S, byCurrency: byCurrency({ paidOrders: S }) }],
|
|
3782
|
+
totalOrders: S,
|
|
3783
|
+
totalPaidOrders: S,
|
|
3784
|
+
byCurrency: byCurrency({ paidOrders: S })
|
|
3198
3785
|
},
|
|
3199
3786
|
// get_top_products has no entry, so it is not offered over OAuth: it ranks
|
|
3200
3787
|
// products by line-item reference id or name, which a buyer can type.
|
|
3201
3788
|
get_customer_growth: {
|
|
3202
3789
|
application: APPLICATION,
|
|
3203
3790
|
range: RANGE,
|
|
3791
|
+
currency: S,
|
|
3204
3792
|
note: T,
|
|
3205
3793
|
topBy: S,
|
|
3206
3794
|
signups: { total: S, series: [{ date: S, signups: S }] },
|
|
3207
3795
|
ordersByCustomerType: { newCustomerOrders: S, returningCustomerOrders: S },
|
|
3208
3796
|
// The ranking, by id: a top customer's name and email stay behind.
|
|
3209
|
-
topCustomers: [{ customerId: S, orderCount: S,
|
|
3210
|
-
totals: { customerCount: S, orderCount: S,
|
|
3797
|
+
topCustomers: [{ customerId: S, orderCount: S, byCurrency: byCurrency({ orderCount: S }) }],
|
|
3798
|
+
totals: { customerCount: S, orderCount: S, byCurrency: byCurrency({ orderCount: S, customerCount: S }) }
|
|
3211
3799
|
},
|
|
3212
3800
|
get_revenue_breakdown: {
|
|
3213
3801
|
application: APPLICATION,
|
|
3214
3802
|
range: RANGE,
|
|
3803
|
+
currency: S,
|
|
3215
3804
|
dimension: S,
|
|
3216
3805
|
note: T,
|
|
3217
|
-
rows: [{ key: S, orderCount: S,
|
|
3218
|
-
totals: { orderCount: S,
|
|
3806
|
+
rows: [{ key: S, orderCount: S, byCurrency: byCurrency({ orderCount: S }) }],
|
|
3807
|
+
totals: { orderCount: S, byCurrency: byCurrency({ orderCount: S }) }
|
|
3219
3808
|
},
|
|
3220
3809
|
get_funnel_conversion: {
|
|
3221
3810
|
application: APPLICATION,
|
|
@@ -3228,21 +3817,28 @@ var OAUTH_PROJECTIONS = {
|
|
|
3228
3817
|
get_subscription_movement: {
|
|
3229
3818
|
application: APPLICATION,
|
|
3230
3819
|
range: RANGE,
|
|
3820
|
+
currency: S,
|
|
3231
3821
|
note: T,
|
|
3232
|
-
series: [{ date: S, newSubscriptions: S, churnedSubscriptions: S,
|
|
3233
|
-
totals: { newSubscriptions: S, churnedSubscriptions: S,
|
|
3822
|
+
series: [{ date: S, newSubscriptions: S, churnedSubscriptions: S, byCurrency: byCurrency() }],
|
|
3823
|
+
totals: { newSubscriptions: S, churnedSubscriptions: S, byCurrency: byCurrency() }
|
|
3234
3824
|
},
|
|
3235
3825
|
get_discount_performance: {
|
|
3236
3826
|
application: APPLICATION,
|
|
3237
3827
|
range: RANGE,
|
|
3828
|
+
currency: S,
|
|
3238
3829
|
note: T,
|
|
3239
|
-
rows: [{
|
|
3240
|
-
|
|
3830
|
+
rows: [{
|
|
3831
|
+
discountId: S,
|
|
3832
|
+
code: T,
|
|
3833
|
+
redemptions: S,
|
|
3834
|
+
byCurrency: byCurrency({ redemptions: S, discountGiven: MONEY })
|
|
3835
|
+
}],
|
|
3836
|
+
totals: { redemptions: S, byCurrency: byCurrency({ redemptions: S, discountGiven: MONEY }) }
|
|
3241
3837
|
}
|
|
3242
3838
|
};
|
|
3243
3839
|
|
|
3244
3840
|
// src/server.ts
|
|
3245
|
-
var VERSION = true ? "0.
|
|
3841
|
+
var VERSION = true ? "0.5.0" : "0.0.0-dev";
|
|
3246
3842
|
function registerableActions(policy) {
|
|
3247
3843
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
3248
3844
|
return actionsForChannel("mcp").filter((action) => {
|
|
@@ -3269,9 +3865,9 @@ function buildInstructions(identity, actions, policy) {
|
|
|
3269
3865
|
"Conventions:",
|
|
3270
3866
|
"- 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.",
|
|
3271
3867
|
'- 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.',
|
|
3272
|
-
"- 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
|
|
3868
|
+
"- 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 report each application's figures separately, per currency, or ask which application they mean; never add amounts across applications or currencies.",
|
|
3273
3869
|
'- List tools return { data, pagination }. When pagination.hasMore is true, pass pagination.cursor back as "cursor" rather than raising "limit".',
|
|
3274
|
-
"-
|
|
3870
|
+
"- Money values are `{ amount, currency, display }`: `amount` is integer minor units of `currency` (its ISO 4217 exponent), and `display` is the formatted string to show. Totals come back per currency as arrays; never add amounts in different currencies, and never convert them.",
|
|
3275
3871
|
"- 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.",
|
|
3276
3872
|
"- API errors come back as text with a stable code. On insufficient_scopes, tell the user which scope to add \u2014 do not retry.",
|
|
3277
3873
|
"- 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."
|
|
@@ -3355,7 +3951,7 @@ function createServer(options) {
|
|
|
3355
3951
|
isError: true
|
|
3356
3952
|
};
|
|
3357
3953
|
}
|
|
3358
|
-
const result = stripRawProcessorData(await handler(ctx, args ?? {}));
|
|
3954
|
+
const result = decorateMoney(action.id, stripRawProcessorData(await handler(ctx, args ?? {}))).value;
|
|
3359
3955
|
const shown = redactPii ? redactShopperPii(project(result, OAUTH_PROJECTIONS[action.id])) : result;
|
|
3360
3956
|
return { content: [{ type: "text", text: formatResult(shown) }] };
|
|
3361
3957
|
} catch (error) {
|