@peable.to/contracts 0.3.0 → 1.0.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/cjs/common/address.js +81 -0
- package/dist/cjs/common/envelopes.js +101 -0
- package/dist/cjs/common/objects.js +85 -0
- package/dist/cjs/common/params.js +211 -0
- package/dist/cjs/common/primitives.js +39 -0
- package/dist/cjs/contributions.js +22 -0
- package/dist/cjs/index.js +40 -97
- package/dist/cjs/openapi/document.js +297 -0
- package/dist/cjs/openapi/index.js +7 -0
- package/dist/cjs/openapi/webhooks.js +17 -0
- package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
- package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
- package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
- package/dist/cjs/resources/billingEngine/index.js +43 -0
- package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
- package/dist/cjs/resources/billingEngine/invoices.js +509 -0
- package/dist/cjs/resources/billingEngine/params.js +43 -0
- package/dist/cjs/resources/billingEngine/public.js +326 -0
- package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
- package/dist/cjs/resources/catalog/billing.js +755 -0
- package/dist/cjs/resources/catalog/billingSettings.js +131 -0
- package/dist/cjs/resources/catalog/coupons.js +222 -0
- package/dist/cjs/resources/catalog/entitlements.js +257 -0
- package/dist/cjs/resources/catalog/index.js +58 -0
- package/dist/cjs/resources/catalog/meters.js +279 -0
- package/dist/cjs/resources/catalog/prices.js +423 -0
- package/dist/cjs/resources/catalog/products.js +228 -0
- package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
- package/dist/cjs/resources/catalog/shared.js +75 -0
- package/dist/cjs/resources/catalog/testClocks.js +127 -0
- package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
- package/dist/cjs/resources/checkout/contributions.js +172 -0
- package/dist/cjs/resources/checkout/files.js +133 -0
- package/dist/cjs/resources/checkout/index.js +57 -0
- package/dist/cjs/resources/checkout/merchants.js +290 -0
- package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
- package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
- package/dist/cjs/resources/checkout/shared.js +368 -0
- package/dist/cjs/resources/connect/account.js +332 -0
- package/dist/cjs/resources/connect/applicationFees.js +113 -0
- package/dist/cjs/resources/connect/balance.js +212 -0
- package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
- package/dist/cjs/resources/connect/index.js +51 -0
- package/dist/cjs/resources/connect/onboarding.js +82 -0
- package/dist/cjs/resources/connect/payouts.js +196 -0
- package/dist/cjs/resources/connect/reporting.js +235 -0
- package/dist/cjs/resources/connect/requestLogs.js +110 -0
- package/dist/cjs/resources/connect/transfers.js +227 -0
- package/dist/cjs/resources/core/customers.js +194 -0
- package/dist/cjs/resources/core/index.js +23 -0
- package/dist/cjs/resources/core/paymentMethods.js +134 -0
- package/dist/cjs/resources/events/events.js +357 -0
- package/dist/cjs/resources/events/index.js +29 -0
- package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
- package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
- package/dist/cjs/resources/payments/charges.js +157 -0
- package/dist/cjs/resources/payments/disputes.js +204 -0
- package/dist/cjs/resources/payments/index.js +41 -0
- package/dist/cjs/resources/payments/paymentIntents.js +529 -0
- package/dist/cjs/resources/payments/refunds.js +245 -0
- package/dist/cjs/resources/payments/setupIntents.js +158 -0
- package/dist/cjs/resources/payments/social.js +182 -0
- package/dist/cjs/resources/payments/testHelpers.js +39 -0
- package/dist/cjs/resources/tax/assessments.js +217 -0
- package/dist/cjs/resources/tax/businessProfile.js +99 -0
- package/dist/cjs/resources/tax/calculations.js +176 -0
- package/dist/cjs/resources/tax/capabilities.js +42 -0
- package/dist/cjs/resources/tax/codes.js +37 -0
- package/dist/cjs/resources/tax/complianceActions.js +56 -0
- package/dist/cjs/resources/tax/deadlines.js +59 -0
- package/dist/cjs/resources/tax/documents.js +128 -0
- package/dist/cjs/resources/tax/index.js +80 -0
- package/dist/cjs/resources/tax/locationEvidence.js +131 -0
- package/dist/cjs/resources/tax/operatingLocations.js +98 -0
- package/dist/cjs/resources/tax/products.js +67 -0
- package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
- package/dist/cjs/resources/tax/registrations.js +82 -0
- package/dist/cjs/resources/tax/reports.js +92 -0
- package/dist/cjs/resources/tax/reviewItems.js +116 -0
- package/dist/cjs/resources/tax/ruleSet.js +68 -0
- package/dist/cjs/resources/tax/salesDestinations.js +94 -0
- package/dist/cjs/resources/tax/settings.js +104 -0
- package/dist/cjs/resources/tax/shared.js +62 -0
- package/dist/cjs/resources/tax/transactions.js +102 -0
- package/dist/cjs/route.js +22 -0
- package/dist/cjs/routes.js +31 -0
- package/dist/cjs/vocabulary/billingPortal.js +15 -0
- package/dist/cjs/vocabulary/catalog.js +110 -0
- package/dist/cjs/vocabulary/checkout.js +53 -0
- package/dist/cjs/vocabulary/connect.js +95 -0
- package/dist/cjs/vocabulary/errors.js +174 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/index.js +37 -0
- package/dist/cjs/vocabulary/invoices.js +52 -0
- package/dist/cjs/vocabulary/lists.js +22 -0
- package/dist/cjs/vocabulary/merchants.js +23 -0
- package/dist/cjs/vocabulary/money.js +104 -0
- package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
- package/dist/cjs/vocabulary/payments.js +195 -0
- package/dist/cjs/vocabulary/reporting.js +27 -0
- package/dist/cjs/vocabulary/subscriptions.js +60 -0
- package/dist/cjs/vocabulary/tax.js +237 -0
- package/dist/cjs/vocabulary/version.js +12 -0
- package/dist/esm/common/address.js +76 -0
- package/dist/esm/common/envelopes.js +95 -0
- package/dist/esm/common/objects.js +74 -0
- package/dist/esm/common/params.js +203 -0
- package/dist/esm/common/primitives.js +35 -0
- package/dist/esm/contributions.js +5 -0
- package/dist/esm/index.js +26 -94
- package/dist/esm/openapi/document.js +294 -0
- package/dist/esm/openapi/index.js +2 -0
- package/dist/esm/openapi/webhooks.js +14 -0
- package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
- package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
- package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
- package/dist/esm/resources/billingEngine/index.js +26 -0
- package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
- package/dist/esm/resources/billingEngine/invoices.js +506 -0
- package/dist/esm/resources/billingEngine/params.js +39 -0
- package/dist/esm/resources/billingEngine/public.js +323 -0
- package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
- package/dist/esm/resources/catalog/billing.js +752 -0
- package/dist/esm/resources/catalog/billingSettings.js +128 -0
- package/dist/esm/resources/catalog/coupons.js +219 -0
- package/dist/esm/resources/catalog/entitlements.js +254 -0
- package/dist/esm/resources/catalog/index.js +38 -0
- package/dist/esm/resources/catalog/meters.js +276 -0
- package/dist/esm/resources/catalog/prices.js +419 -0
- package/dist/esm/resources/catalog/products.js +225 -0
- package/dist/esm/resources/catalog/promotionCodes.js +171 -0
- package/dist/esm/resources/catalog/shared.js +67 -0
- package/dist/esm/resources/catalog/testClocks.js +124 -0
- package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
- package/dist/esm/resources/checkout/contributions.js +167 -0
- package/dist/esm/resources/checkout/files.js +130 -0
- package/dist/esm/resources/checkout/index.js +25 -0
- package/dist/esm/resources/checkout/merchants.js +287 -0
- package/dist/esm/resources/checkout/paymentLinks.js +327 -0
- package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
- package/dist/esm/resources/checkout/shared.js +363 -0
- package/dist/esm/resources/connect/account.js +329 -0
- package/dist/esm/resources/connect/applicationFees.js +110 -0
- package/dist/esm/resources/connect/balance.js +209 -0
- package/dist/esm/resources/connect/connectedAccounts.js +257 -0
- package/dist/esm/resources/connect/index.js +34 -0
- package/dist/esm/resources/connect/onboarding.js +79 -0
- package/dist/esm/resources/connect/payouts.js +193 -0
- package/dist/esm/resources/connect/reporting.js +232 -0
- package/dist/esm/resources/connect/requestLogs.js +107 -0
- package/dist/esm/resources/connect/transfers.js +224 -0
- package/dist/esm/resources/core/customers.js +191 -0
- package/dist/esm/resources/core/index.js +6 -0
- package/dist/esm/resources/core/paymentMethods.js +131 -0
- package/dist/esm/resources/events/events.js +353 -0
- package/dist/esm/resources/events/index.js +12 -0
- package/dist/esm/resources/events/webhookDeliveries.js +90 -0
- package/dist/esm/resources/events/webhookEndpoints.js +212 -0
- package/dist/esm/resources/payments/charges.js +154 -0
- package/dist/esm/resources/payments/disputes.js +201 -0
- package/dist/esm/resources/payments/index.js +24 -0
- package/dist/esm/resources/payments/paymentIntents.js +526 -0
- package/dist/esm/resources/payments/refunds.js +242 -0
- package/dist/esm/resources/payments/setupIntents.js +155 -0
- package/dist/esm/resources/payments/social.js +179 -0
- package/dist/esm/resources/payments/testHelpers.js +36 -0
- package/dist/esm/resources/tax/assessments.js +214 -0
- package/dist/esm/resources/tax/businessProfile.js +96 -0
- package/dist/esm/resources/tax/calculations.js +173 -0
- package/dist/esm/resources/tax/capabilities.js +39 -0
- package/dist/esm/resources/tax/codes.js +34 -0
- package/dist/esm/resources/tax/complianceActions.js +53 -0
- package/dist/esm/resources/tax/deadlines.js +56 -0
- package/dist/esm/resources/tax/documents.js +125 -0
- package/dist/esm/resources/tax/index.js +63 -0
- package/dist/esm/resources/tax/locationEvidence.js +128 -0
- package/dist/esm/resources/tax/operatingLocations.js +95 -0
- package/dist/esm/resources/tax/products.js +64 -0
- package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
- package/dist/esm/resources/tax/registrations.js +79 -0
- package/dist/esm/resources/tax/reports.js +89 -0
- package/dist/esm/resources/tax/reviewItems.js +113 -0
- package/dist/esm/resources/tax/ruleSet.js +65 -0
- package/dist/esm/resources/tax/salesDestinations.js +91 -0
- package/dist/esm/resources/tax/settings.js +101 -0
- package/dist/esm/resources/tax/shared.js +58 -0
- package/dist/esm/resources/tax/transactions.js +99 -0
- package/dist/esm/route.js +16 -0
- package/dist/esm/routes.js +27 -0
- package/dist/esm/vocabulary/billingPortal.js +12 -0
- package/dist/esm/vocabulary/catalog.js +106 -0
- package/dist/esm/vocabulary/checkout.js +50 -0
- package/dist/esm/vocabulary/connect.js +92 -0
- package/dist/esm/vocabulary/errors.js +169 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/index.js +21 -0
- package/dist/esm/vocabulary/invoices.js +49 -0
- package/dist/esm/vocabulary/lists.js +19 -0
- package/dist/esm/vocabulary/merchants.js +20 -0
- package/dist/esm/vocabulary/money.js +98 -0
- package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
- package/dist/esm/vocabulary/payments.js +192 -0
- package/dist/esm/vocabulary/reporting.js +24 -0
- package/dist/esm/vocabulary/subscriptions.js +57 -0
- package/dist/esm/vocabulary/tax.js +233 -0
- package/dist/esm/vocabulary/version.js +9 -0
- package/dist/types/common/address.d.ts +62 -0
- package/dist/types/common/envelopes.d.ts +88 -0
- package/dist/types/common/objects.d.ts +107 -0
- package/dist/types/common/params.d.ts +156 -0
- package/dist/types/common/primitives.d.ts +56 -0
- package/dist/types/contributions.d.ts +1 -0
- package/dist/types/index.d.ts +16 -134
- package/dist/types/openapi/document.d.ts +16 -0
- package/dist/types/openapi/index.d.ts +2 -0
- package/dist/types/openapi/webhooks.d.ts +15 -0
- package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
- package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
- package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
- package/dist/types/resources/billingEngine/index.d.ts +6071 -0
- package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
- package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
- package/dist/types/resources/billingEngine/params.d.ts +51 -0
- package/dist/types/resources/billingEngine/public.d.ts +1860 -0
- package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
- package/dist/types/resources/catalog/billing.d.ts +1723 -0
- package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
- package/dist/types/resources/catalog/coupons.d.ts +403 -0
- package/dist/types/resources/catalog/entitlements.d.ts +422 -0
- package/dist/types/resources/catalog/index.d.ts +3155 -0
- package/dist/types/resources/catalog/meters.d.ts +474 -0
- package/dist/types/resources/catalog/prices.d.ts +1091 -0
- package/dist/types/resources/catalog/products.d.ts +430 -0
- package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
- package/dist/types/resources/catalog/shared.d.ts +34 -0
- package/dist/types/resources/catalog/testClocks.d.ts +220 -0
- package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
- package/dist/types/resources/checkout/contributions.d.ts +375 -0
- package/dist/types/resources/checkout/files.d.ts +280 -0
- package/dist/types/resources/checkout/index.d.ts +5678 -0
- package/dist/types/resources/checkout/merchants.d.ts +395 -0
- package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
- package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
- package/dist/types/resources/checkout/shared.d.ts +419 -0
- package/dist/types/resources/connect/account.d.ts +483 -0
- package/dist/types/resources/connect/applicationFees.d.ts +198 -0
- package/dist/types/resources/connect/balance.d.ts +399 -0
- package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
- package/dist/types/resources/connect/index.d.ts +2094 -0
- package/dist/types/resources/connect/onboarding.d.ts +95 -0
- package/dist/types/resources/connect/payouts.d.ts +527 -0
- package/dist/types/resources/connect/reporting.d.ts +506 -0
- package/dist/types/resources/connect/requestLogs.d.ts +236 -0
- package/dist/types/resources/connect/transfers.d.ts +436 -0
- package/dist/types/resources/core/customers.d.ts +619 -0
- package/dist/types/resources/core/index.d.ts +679 -0
- package/dist/types/resources/core/paymentMethods.d.ts +336 -0
- package/dist/types/resources/events/events.d.ts +731 -0
- package/dist/types/resources/events/index.d.ts +1727 -0
- package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
- package/dist/types/resources/payments/charges.d.ts +390 -0
- package/dist/types/resources/payments/disputes.d.ts +822 -0
- package/dist/types/resources/payments/index.d.ts +3517 -0
- package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
- package/dist/types/resources/payments/refunds.d.ts +684 -0
- package/dist/types/resources/payments/setupIntents.d.ts +391 -0
- package/dist/types/resources/payments/social.d.ts +266 -0
- package/dist/types/resources/payments/testHelpers.d.ts +178 -0
- package/dist/types/resources/tax/assessments.d.ts +787 -0
- package/dist/types/resources/tax/businessProfile.d.ts +134 -0
- package/dist/types/resources/tax/calculations.d.ts +261 -0
- package/dist/types/resources/tax/capabilities.d.ts +81 -0
- package/dist/types/resources/tax/codes.d.ts +29 -0
- package/dist/types/resources/tax/complianceActions.d.ts +97 -0
- package/dist/types/resources/tax/deadlines.d.ts +133 -0
- package/dist/types/resources/tax/documents.d.ts +257 -0
- package/dist/types/resources/tax/index.d.ts +1946 -0
- package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
- package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
- package/dist/types/resources/tax/products.d.ts +68 -0
- package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
- package/dist/types/resources/tax/registrations.d.ts +103 -0
- package/dist/types/resources/tax/reports.d.ts +129 -0
- package/dist/types/resources/tax/reviewItems.d.ts +226 -0
- package/dist/types/resources/tax/ruleSet.d.ts +219 -0
- package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
- package/dist/types/resources/tax/settings.d.ts +122 -0
- package/dist/types/resources/tax/shared.d.ts +43 -0
- package/dist/types/resources/tax/transactions.d.ts +404 -0
- package/dist/types/route.d.ts +86 -0
- package/dist/types/routes.d.ts +23 -0
- package/dist/types/vocabulary/billingPortal.d.ts +15 -0
- package/dist/types/vocabulary/catalog.d.ts +97 -0
- package/dist/types/vocabulary/checkout.d.ts +49 -0
- package/dist/types/vocabulary/connect.d.ts +62 -0
- package/dist/types/vocabulary/errors.d.ts +145 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/index.d.ts +17 -0
- package/dist/types/vocabulary/invoices.d.ts +39 -0
- package/dist/types/vocabulary/lists.d.ts +9 -0
- package/dist/types/vocabulary/merchants.d.ts +9 -0
- package/dist/types/vocabulary/money.d.ts +59 -0
- package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
- package/dist/types/vocabulary/payments.d.ts +117 -0
- package/dist/types/vocabulary/reporting.d.ts +18 -0
- package/dist/types/vocabulary/subscriptions.d.ts +45 -0
- package/dist/types/vocabulary/tax.d.ts +163 -0
- package/dist/types/vocabulary/version.d.ts +10 -0
- package/package.json +51 -11
- package/dist/cjs/openapi.js +0 -138
- package/dist/esm/openapi.js +0 -134
- package/dist/types/openapi.d.ts +0 -145
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
3
|
+
import { network, unixSeconds } from '../../common/primitives.js';
|
|
4
|
+
import { defineRoute } from '../../route.js';
|
|
5
|
+
import { merchantDisplaySchema } from '../checkout/shared.js';
|
|
6
|
+
/**
|
|
7
|
+
* The SELLER-facing half of FairCoin connected accounts (ADR 0012 D3).
|
|
8
|
+
*
|
|
9
|
+
* A platform mints an onboarding link for a seller's account; the SELLER opens
|
|
10
|
+
* it signed in with Oxy and registers the watch-only key their FairCoin will be
|
|
11
|
+
* paid to. These routes are `auth: 'user'` — the seller's own session, never a
|
|
12
|
+
* service token — because the key that decides who receives a seller's money is
|
|
13
|
+
* accepted only from the seller. A platform cannot reach them at all, and the
|
|
14
|
+
* link token alone is not enough without the session it names.
|
|
15
|
+
*/
|
|
16
|
+
export const connectOnboardingSchema = defineObject('connect_onboarding', 'ConnectOnboarding', z
|
|
17
|
+
.object({
|
|
18
|
+
object: z.literal('connect_onboarding'),
|
|
19
|
+
account_id: z.string().describe('The `ca_…` being onboarded.'),
|
|
20
|
+
// The platform's public display, as a payer would see it: never a
|
|
21
|
+
// webhook secret, never a key.
|
|
22
|
+
platform: merchantDisplaySchema.describe("Who is asking: the PLATFORM's public display, as a payer would see it."),
|
|
23
|
+
network: network.describe('The chain the seller will be paid on. Their key must be for it.'),
|
|
24
|
+
expires_at: unixSeconds.describe('When this link stops working.'),
|
|
25
|
+
return_url: z.string().describe('Where to send the seller once the key is registered.'),
|
|
26
|
+
})
|
|
27
|
+
.strict());
|
|
28
|
+
/** The answer to a successful registration. */
|
|
29
|
+
export const connectOnboardingCompleteSchema = defineComponent('ConnectOnboardingComplete', z
|
|
30
|
+
.object({
|
|
31
|
+
object: z.literal('connect_onboarding'),
|
|
32
|
+
account_id: z.string(),
|
|
33
|
+
status: z.literal('active'),
|
|
34
|
+
return_url: z.string(),
|
|
35
|
+
})
|
|
36
|
+
.strict());
|
|
37
|
+
/**
|
|
38
|
+
* An extended public key is 111 characters in base58check; the bound is a
|
|
39
|
+
* request-size guard with headroom, not a format check — the non-custody
|
|
40
|
+
* firewall (`assertWatchOnly`) is.
|
|
41
|
+
*/
|
|
42
|
+
const XPUB_MAX_LENGTH = 200;
|
|
43
|
+
/** `POST /v1/connect/onboarding/{token}/faircoin` — the seller's watch-only ACCOUNT xpub. */
|
|
44
|
+
export const registerFaircoinKeyParams = z
|
|
45
|
+
.object({
|
|
46
|
+
xpub: z
|
|
47
|
+
.string()
|
|
48
|
+
.trim()
|
|
49
|
+
.min(1)
|
|
50
|
+
.max(XPUB_MAX_LENGTH)
|
|
51
|
+
.describe('A watch-only extended PUBLIC key. A private extended key is refused (`watch_only_violation`) and never stored.'),
|
|
52
|
+
})
|
|
53
|
+
.strict();
|
|
54
|
+
const tokenParam = { token: 'The onboarding link token (the last segment of its `url`).' };
|
|
55
|
+
export const connectOnboardingRoutes = [
|
|
56
|
+
defineRoute({
|
|
57
|
+
operationId: 'retrieveConnectOnboarding',
|
|
58
|
+
method: 'get',
|
|
59
|
+
path: '/v1/connect/onboarding/{token}',
|
|
60
|
+
tag: 'Connect onboarding',
|
|
61
|
+
summary: 'Retrieve an onboarding link',
|
|
62
|
+
description: 'What the seller is being asked to do. Looking consumes nothing. An expired link answers 410 `link_expired` with the platform’s `refresh_url`.',
|
|
63
|
+
auth: 'user',
|
|
64
|
+
params: tokenParam,
|
|
65
|
+
response: connectOnboardingSchema,
|
|
66
|
+
}),
|
|
67
|
+
defineRoute({
|
|
68
|
+
operationId: 'registerConnectOnboardingFaircoinKey',
|
|
69
|
+
method: 'post',
|
|
70
|
+
path: '/v1/connect/onboarding/{token}/faircoin',
|
|
71
|
+
tag: 'Connect onboarding',
|
|
72
|
+
summary: "Register the seller's FairCoin key",
|
|
73
|
+
description: 'The ONLY way a key reaches a connected account: runs the non-custody firewall, consumes the link and tells the platform (`connected_account.updated`), in one transaction. The key is immutable once registered and never appears on any response.',
|
|
74
|
+
auth: 'user',
|
|
75
|
+
params: tokenParam,
|
|
76
|
+
body: registerFaircoinKeyParams,
|
|
77
|
+
response: connectOnboardingCompleteSchema,
|
|
78
|
+
}),
|
|
79
|
+
];
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, idParam, listQuery, metadataCreateParam } from '../../common/params.js';
|
|
5
|
+
import { amount, livemode, metadata, signedAmount, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { PAYOUT_DESTINATION_TYPES, PAYOUT_METHODS, PAYOUT_RECONCILIATION_STATUSES, PAYOUT_STATUSES, } from '../../vocabulary/connect.js';
|
|
8
|
+
import { CURRENCY_CODES, isBaseUnitString } from '../../vocabulary/money.js';
|
|
9
|
+
import { balanceTransactionSchema } from './balance.js';
|
|
10
|
+
/**
|
|
11
|
+
* Payouts (`po_…`) — the provider moving the merchant's balance to the
|
|
12
|
+
* merchant's bank (ADR 0015 §4). Executed by the provider, always; Orbit
|
|
13
|
+
* instructs (a manual payout) or mirrors (a scheduled one). The bank account
|
|
14
|
+
* itself stays at the provider and is never on this object.
|
|
15
|
+
*/
|
|
16
|
+
export const payoutSchema = defineObject('payout', 'Payout', z
|
|
17
|
+
.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
object: z.literal('payout'),
|
|
20
|
+
livemode,
|
|
21
|
+
account: z.string().describe('The account (`ca_…`) paid out.'),
|
|
22
|
+
amount,
|
|
23
|
+
currency: z.string().describe('Upper-case ISO 4217 code.'),
|
|
24
|
+
status: z.enum(PAYOUT_STATUSES),
|
|
25
|
+
arrival_date: unixSeconds
|
|
26
|
+
.nullable()
|
|
27
|
+
.describe('When the funds are expected in the bank, as the provider estimates.'),
|
|
28
|
+
automatic: z
|
|
29
|
+
.boolean()
|
|
30
|
+
.describe("`true` when the provider's schedule created it, `false` for `POST /v1/payouts`."),
|
|
31
|
+
method: z.enum(PAYOUT_METHODS),
|
|
32
|
+
type: z.enum(PAYOUT_DESTINATION_TYPES),
|
|
33
|
+
description: z.string().nullable(),
|
|
34
|
+
statement_descriptor: z.string().nullable(),
|
|
35
|
+
failure_code: z
|
|
36
|
+
.string()
|
|
37
|
+
.nullable()
|
|
38
|
+
.describe("The provider's failure code when `failed`; never its prose."),
|
|
39
|
+
balance_transaction: z
|
|
40
|
+
.string()
|
|
41
|
+
.nullable()
|
|
42
|
+
.describe("The payout's own `txn_…` once ingested."),
|
|
43
|
+
metadata,
|
|
44
|
+
created: unixSeconds,
|
|
45
|
+
})
|
|
46
|
+
.strict(), {
|
|
47
|
+
examples: [
|
|
48
|
+
{
|
|
49
|
+
id: 'po_0193b8f31e2d4c5a9b60',
|
|
50
|
+
object: 'payout',
|
|
51
|
+
livemode: false,
|
|
52
|
+
account: 'ca_0193b8f2c1a87d3e9f4a',
|
|
53
|
+
amount: '150000',
|
|
54
|
+
currency: 'EUR',
|
|
55
|
+
status: 'in_transit',
|
|
56
|
+
arrival_date: 1793923200,
|
|
57
|
+
automatic: false,
|
|
58
|
+
method: 'standard',
|
|
59
|
+
type: 'bank_account',
|
|
60
|
+
description: 'November payout',
|
|
61
|
+
statement_descriptor: 'ROSEN PAYOUT',
|
|
62
|
+
failure_code: null,
|
|
63
|
+
balance_transaction: 'txn_0193b8f31f0a7e3d2c41',
|
|
64
|
+
metadata: {},
|
|
65
|
+
created: 1793750400,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* `GET /v1/reports/payout_reconciliation?payout=po_…` — the balance
|
|
71
|
+
* transactions one payout paid out, with their totals. A list page with the
|
|
72
|
+
* report's fields beside it.
|
|
73
|
+
*/
|
|
74
|
+
export const payoutReconciliationReportSchema = defineComponent('PayoutReconciliationReport', z
|
|
75
|
+
.object({
|
|
76
|
+
object: z.literal('list'),
|
|
77
|
+
data: z.array(balanceTransactionSchema),
|
|
78
|
+
has_more: z.boolean(),
|
|
79
|
+
url: z.string(),
|
|
80
|
+
payout: z.string().describe('The payout (`po_…`) reconciled.'),
|
|
81
|
+
status: z
|
|
82
|
+
.enum(PAYOUT_RECONCILIATION_STATUSES)
|
|
83
|
+
.describe('`complete` once the payout is `paid` and its transactions were read from the provider; `pending` before — the set is not final and the totals may grow.'),
|
|
84
|
+
currency: z.string(),
|
|
85
|
+
summary: z
|
|
86
|
+
.object({
|
|
87
|
+
count: z.number().int().nonnegative(),
|
|
88
|
+
amount: signedAmount,
|
|
89
|
+
fee: signedAmount,
|
|
90
|
+
net: signedAmount,
|
|
91
|
+
})
|
|
92
|
+
.strict()
|
|
93
|
+
.describe('Over EVERY transaction of the payout, not just this page.'),
|
|
94
|
+
})
|
|
95
|
+
.strict());
|
|
96
|
+
/** `POST /v1/payouts` — a payout instruction for an account on a manual schedule. */
|
|
97
|
+
export const createPayoutParams = z
|
|
98
|
+
.object({
|
|
99
|
+
amount: z
|
|
100
|
+
.string()
|
|
101
|
+
.refine(isBaseUnitString, 'amount must be a minor-unit integer string')
|
|
102
|
+
.refine((value) => value !== '0', 'amount must be positive'),
|
|
103
|
+
currency: z.enum(CURRENCY_CODES),
|
|
104
|
+
description: z.string().max(1000).optional(),
|
|
105
|
+
statement_descriptor: z.string().min(1).max(22).optional(),
|
|
106
|
+
method: z.enum(PAYOUT_METHODS).optional().describe('Defaults to `standard`.'),
|
|
107
|
+
metadata: metadataCreateParam.optional(),
|
|
108
|
+
})
|
|
109
|
+
.strict();
|
|
110
|
+
export const listPayoutsQuery = listQuery({ status: z.enum(PAYOUT_STATUSES).optional() });
|
|
111
|
+
/** `POST /v1/payouts/{id}/cancel` takes no parameters. */
|
|
112
|
+
export const cancelPayoutParams = z.object({}).strict();
|
|
113
|
+
export const payoutReconciliationQuery = listQuery({
|
|
114
|
+
payout: idParam.describe('The payout (`po_…`) to reconcile.'),
|
|
115
|
+
});
|
|
116
|
+
const payoutIdParam = { id: 'The payout (`po_…`).' };
|
|
117
|
+
export const payoutRoutes = [
|
|
118
|
+
defineRoute({
|
|
119
|
+
operationId: 'listPayouts',
|
|
120
|
+
method: 'get',
|
|
121
|
+
path: '/v1/payouts',
|
|
122
|
+
tag: 'Payouts',
|
|
123
|
+
summary: 'List payouts',
|
|
124
|
+
auth: 'service',
|
|
125
|
+
scope: 'payments:read',
|
|
126
|
+
peableAccount: true,
|
|
127
|
+
query: listPayoutsQuery,
|
|
128
|
+
response: listOf(payoutSchema),
|
|
129
|
+
sdk: 'payouts.list',
|
|
130
|
+
expandable: 'payout',
|
|
131
|
+
}),
|
|
132
|
+
defineRoute({
|
|
133
|
+
operationId: 'createPayout',
|
|
134
|
+
method: 'post',
|
|
135
|
+
path: '/v1/payouts',
|
|
136
|
+
tag: 'Payouts',
|
|
137
|
+
summary: 'Create a payout',
|
|
138
|
+
description: 'An instruction to the provider, for an account on a `manual` payout schedule. The provider executes it; Orbit never moves the money itself.',
|
|
139
|
+
auth: 'service',
|
|
140
|
+
scope: 'payments:write',
|
|
141
|
+
idempotent: true,
|
|
142
|
+
peableAccount: true,
|
|
143
|
+
body: createPayoutParams,
|
|
144
|
+
response: payoutSchema,
|
|
145
|
+
status: 201,
|
|
146
|
+
sdk: 'payouts.create',
|
|
147
|
+
}),
|
|
148
|
+
defineRoute({
|
|
149
|
+
operationId: 'retrievePayout',
|
|
150
|
+
method: 'get',
|
|
151
|
+
path: '/v1/payouts/{id}',
|
|
152
|
+
tag: 'Payouts',
|
|
153
|
+
summary: 'Retrieve a payout',
|
|
154
|
+
auth: 'service',
|
|
155
|
+
scope: 'payments:read',
|
|
156
|
+
peableAccount: true,
|
|
157
|
+
params: payoutIdParam,
|
|
158
|
+
query: expandOnlyQuery,
|
|
159
|
+
response: payoutSchema,
|
|
160
|
+
sdk: 'payouts.retrieve',
|
|
161
|
+
}),
|
|
162
|
+
defineRoute({
|
|
163
|
+
operationId: 'cancelPayout',
|
|
164
|
+
method: 'post',
|
|
165
|
+
path: '/v1/payouts/{id}/cancel',
|
|
166
|
+
tag: 'Payouts',
|
|
167
|
+
summary: 'Cancel a payout',
|
|
168
|
+
description: 'Only a manual payout the provider still allows to be canceled.',
|
|
169
|
+
auth: 'service',
|
|
170
|
+
scope: 'payments:write',
|
|
171
|
+
idempotent: true,
|
|
172
|
+
peableAccount: true,
|
|
173
|
+
params: payoutIdParam,
|
|
174
|
+
body: cancelPayoutParams,
|
|
175
|
+
response: payoutSchema,
|
|
176
|
+
sdk: 'payouts.cancel',
|
|
177
|
+
}),
|
|
178
|
+
defineRoute({
|
|
179
|
+
operationId: 'retrievePayoutReconciliation',
|
|
180
|
+
method: 'get',
|
|
181
|
+
path: '/v1/reports/payout_reconciliation',
|
|
182
|
+
tag: 'Payouts',
|
|
183
|
+
summary: 'Reconcile a payout',
|
|
184
|
+
description: 'The balance transactions one payout paid out, a page at a time, with totals over all of them.',
|
|
185
|
+
auth: 'service',
|
|
186
|
+
scope: 'payments:read',
|
|
187
|
+
peableAccount: true,
|
|
188
|
+
query: payoutReconciliationQuery,
|
|
189
|
+
response: payoutReconciliationReportSchema,
|
|
190
|
+
sdk: 'reports.payoutReconciliation',
|
|
191
|
+
expandable: 'balance_transaction',
|
|
192
|
+
}),
|
|
193
|
+
];
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { embedded } from '../../common/objects.js';
|
|
3
|
+
import { listOf } from '../../common/envelopes.js';
|
|
4
|
+
import { defineComponent, defineObject, describe } from '../../common/objects.js';
|
|
5
|
+
import { emptyQuery, expandOnlyQuery, listQuery, queryInteger, unixSecondsParam, } from '../../common/params.js';
|
|
6
|
+
import { currency, livemode, unixSeconds } from '../../common/primitives.js';
|
|
7
|
+
import { defineRoute } from '../../route.js';
|
|
8
|
+
import { CURRENCY_CODES } from '../../vocabulary/money.js';
|
|
9
|
+
import { REPORT_RUN_STATUSES, REPORT_TYPE_IDS } from '../../vocabulary/reporting.js';
|
|
10
|
+
/**
|
|
11
|
+
* Reporting (Stripe's `reporting.*`): a merchant asks for a report over an
|
|
12
|
+
* interval, Peable computes it in the background and stores the CSV as a
|
|
13
|
+
* `file_…` of purpose `finance_report_run` — or downloads the same CSV at once,
|
|
14
|
+
* streamed (`GET /v1/reporting/report_types/{id}/csv`). Both are ONE report:
|
|
15
|
+
* the same layout, the same columns, the same computation. The layouts are
|
|
16
|
+
* `REPORT_TYPE_LAYOUTS` in `@peable.to/shared-types/reporting`.
|
|
17
|
+
*/
|
|
18
|
+
const reportTypeId = z.enum(REPORT_TYPE_IDS);
|
|
19
|
+
/** `reporting.report_type` — what can be run, and over which interval data exists. */
|
|
20
|
+
export const reportTypeSchema = defineObject('reporting.report_type', 'ReportType', z
|
|
21
|
+
.object({
|
|
22
|
+
id: reportTypeId.describe('`payments.itemized.1`, …; the trailing number is the layout version.'),
|
|
23
|
+
object: z.literal('reporting.report_type'),
|
|
24
|
+
livemode,
|
|
25
|
+
name: z.string(),
|
|
26
|
+
version: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.describe("The column layout's version — the trailing number of the id."),
|
|
30
|
+
columns: z
|
|
31
|
+
.array(z.string())
|
|
32
|
+
.describe('Every column `parameters.columns` may name, in the order they are written.'),
|
|
33
|
+
default_columns: z.array(z.string()),
|
|
34
|
+
data_available_start: unixSeconds.describe('The earliest `interval_start` with data.'),
|
|
35
|
+
data_available_end: unixSeconds.describe('The latest `interval_end` a run may ask for: now — the data is live.'),
|
|
36
|
+
updated: unixSeconds.describe('When the layout last changed.'),
|
|
37
|
+
})
|
|
38
|
+
.strict(), {
|
|
39
|
+
examples: [
|
|
40
|
+
{
|
|
41
|
+
id: 'balance.summary.1',
|
|
42
|
+
object: 'reporting.report_type',
|
|
43
|
+
livemode: false,
|
|
44
|
+
name: 'Balance summary',
|
|
45
|
+
version: 1,
|
|
46
|
+
columns: [
|
|
47
|
+
'category',
|
|
48
|
+
'description',
|
|
49
|
+
'currency',
|
|
50
|
+
'net_amount',
|
|
51
|
+
'transaction_count',
|
|
52
|
+
'net_amount_decimal',
|
|
53
|
+
],
|
|
54
|
+
default_columns: ['category', 'description', 'currency', 'net_amount'],
|
|
55
|
+
data_available_start: 1790000000,
|
|
56
|
+
data_available_end: 1793750400,
|
|
57
|
+
updated: 1793664000,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
/** What a run was asked to cover. */
|
|
62
|
+
export const reportRunParametersSchema = defineComponent('ReportRunParameters', z
|
|
63
|
+
.object({
|
|
64
|
+
interval_start: unixSeconds.describe('Inclusive.'),
|
|
65
|
+
interval_end: unixSeconds.describe('Exclusive.'),
|
|
66
|
+
columns: z
|
|
67
|
+
.array(z.string())
|
|
68
|
+
.optional()
|
|
69
|
+
.describe("The columns, in the layout's order; the report type's `default_columns` when absent."),
|
|
70
|
+
currency: currency.optional().describe('Only this currency.'),
|
|
71
|
+
})
|
|
72
|
+
.strict());
|
|
73
|
+
/** `reporting.report_run` (`frr_…`). */
|
|
74
|
+
export const reportRunSchema = defineObject('reporting.report_run', 'ReportRun', z
|
|
75
|
+
.object({
|
|
76
|
+
id: z.string(),
|
|
77
|
+
object: z.literal('reporting.report_run'),
|
|
78
|
+
livemode,
|
|
79
|
+
created: unixSeconds,
|
|
80
|
+
report_type: reportTypeId,
|
|
81
|
+
parameters: reportRunParametersSchema,
|
|
82
|
+
status: z.enum(REPORT_RUN_STATUSES),
|
|
83
|
+
error: z.string().nullable().describe('Why a `failed` run failed; `null` otherwise.'),
|
|
84
|
+
result: embedded('file')
|
|
85
|
+
.nullable()
|
|
86
|
+
.describe('The CSV once `succeeded` — a File of purpose `finance_report_run` (`GET /v1/files/{id}/contents` reads it).'),
|
|
87
|
+
succeeded_at: unixSeconds.nullable(),
|
|
88
|
+
})
|
|
89
|
+
.strict(), {
|
|
90
|
+
examples: [
|
|
91
|
+
{
|
|
92
|
+
id: 'frr_0193b8f34d1e4a6b8c27',
|
|
93
|
+
object: 'reporting.report_run',
|
|
94
|
+
livemode: false,
|
|
95
|
+
created: 1793750400,
|
|
96
|
+
report_type: 'balance.summary.1',
|
|
97
|
+
parameters: { interval_start: 1790985600, interval_end: 1793577600 },
|
|
98
|
+
status: 'pending',
|
|
99
|
+
error: null,
|
|
100
|
+
result: null,
|
|
101
|
+
succeeded_at: null,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
});
|
|
105
|
+
const column = z.string().min(1).max(64);
|
|
106
|
+
/** `POST /v1/reporting/report_runs`. */
|
|
107
|
+
export const createReportRunParams = z
|
|
108
|
+
.object({
|
|
109
|
+
report_type: reportTypeId,
|
|
110
|
+
parameters: z
|
|
111
|
+
.object({
|
|
112
|
+
interval_start: unixSecondsParam.describe('Inclusive, Unix seconds.'),
|
|
113
|
+
interval_end: unixSecondsParam.describe('Exclusive, Unix seconds; after `interval_start` and not in the future.'),
|
|
114
|
+
columns: z
|
|
115
|
+
.array(column)
|
|
116
|
+
.min(1)
|
|
117
|
+
.max(64)
|
|
118
|
+
.optional()
|
|
119
|
+
.describe("Columns of the report type's layout, each once."),
|
|
120
|
+
currency: z.enum(CURRENCY_CODES).optional(),
|
|
121
|
+
})
|
|
122
|
+
.strict(),
|
|
123
|
+
})
|
|
124
|
+
.strict();
|
|
125
|
+
export const listReportRunsQuery = listQuery({ report_type: reportTypeId.optional() });
|
|
126
|
+
/**
|
|
127
|
+
* A download's query: a run's `parameters`, spelled as a query string
|
|
128
|
+
* (`columns[]=a&columns[]=b`, or one `columns=a`).
|
|
129
|
+
*/
|
|
130
|
+
export const downloadReportQuery = z
|
|
131
|
+
.object({
|
|
132
|
+
interval_start: queryInteger({ min: 0 }).describe('Inclusive, Unix seconds.'),
|
|
133
|
+
interval_end: queryInteger({ min: 0 }).describe('Exclusive, Unix seconds.'),
|
|
134
|
+
columns: describe(z
|
|
135
|
+
.union([z.string(), z.array(z.string())])
|
|
136
|
+
.transform((value) => (typeof value === 'string' ? [value] : value))
|
|
137
|
+
.pipe(z.array(column).min(1).max(64)), {
|
|
138
|
+
description: "Columns of the report type's layout, each once.",
|
|
139
|
+
jsonSchema: {
|
|
140
|
+
type: 'array',
|
|
141
|
+
items: { type: 'string', minLength: 1, maxLength: 64 },
|
|
142
|
+
minItems: 1,
|
|
143
|
+
maxItems: 64,
|
|
144
|
+
},
|
|
145
|
+
}).optional(),
|
|
146
|
+
currency: z.enum(CURRENCY_CODES).optional(),
|
|
147
|
+
})
|
|
148
|
+
.strict();
|
|
149
|
+
const reportTypeIdParam = { id: 'The report type (`payments.itemized.1`, …).' };
|
|
150
|
+
export const reportingRoutes = [
|
|
151
|
+
defineRoute({
|
|
152
|
+
operationId: 'listReportTypes',
|
|
153
|
+
method: 'get',
|
|
154
|
+
path: '/v1/reporting/report_types',
|
|
155
|
+
tag: 'Reporting',
|
|
156
|
+
summary: 'List report types',
|
|
157
|
+
description: 'Every report Peable produces (a complete set), with the interval data exists for.',
|
|
158
|
+
auth: 'service',
|
|
159
|
+
scope: 'payments:read',
|
|
160
|
+
query: emptyQuery,
|
|
161
|
+
response: listOf(reportTypeSchema),
|
|
162
|
+
sdk: 'reporting.reportTypes.list',
|
|
163
|
+
}),
|
|
164
|
+
defineRoute({
|
|
165
|
+
operationId: 'retrieveReportType',
|
|
166
|
+
method: 'get',
|
|
167
|
+
path: '/v1/reporting/report_types/{id}',
|
|
168
|
+
tag: 'Reporting',
|
|
169
|
+
summary: 'Retrieve a report type',
|
|
170
|
+
auth: 'service',
|
|
171
|
+
scope: 'payments:read',
|
|
172
|
+
params: reportTypeIdParam,
|
|
173
|
+
query: emptyQuery,
|
|
174
|
+
response: reportTypeSchema,
|
|
175
|
+
sdk: 'reporting.reportTypes.retrieve',
|
|
176
|
+
}),
|
|
177
|
+
defineRoute({
|
|
178
|
+
operationId: 'downloadReport',
|
|
179
|
+
method: 'get',
|
|
180
|
+
path: '/v1/reporting/report_types/{id}/csv',
|
|
181
|
+
tag: 'Reporting',
|
|
182
|
+
summary: 'Download a report',
|
|
183
|
+
description: 'The same report a run produces, with the same parameters, streamed at once as CSV instead of stored. Every refusal is the JSON error before the first byte; a read that fails afterwards aborts the response, so a truncated file never ends cleanly.',
|
|
184
|
+
auth: 'service',
|
|
185
|
+
scope: 'payments:read',
|
|
186
|
+
params: reportTypeIdParam,
|
|
187
|
+
query: downloadReportQuery,
|
|
188
|
+
response: { kind: 'binary', contentType: 'text/csv' },
|
|
189
|
+
sdk: 'reporting.reportTypes.download',
|
|
190
|
+
}),
|
|
191
|
+
defineRoute({
|
|
192
|
+
operationId: 'createReportRun',
|
|
193
|
+
method: 'post',
|
|
194
|
+
path: '/v1/reporting/report_runs',
|
|
195
|
+
tag: 'Reporting',
|
|
196
|
+
summary: 'Create a report run',
|
|
197
|
+
description: 'Answers `pending` at once; the CSV is produced in the background and announced with `reporting.report_run.succeeded` (or `.failed`).',
|
|
198
|
+
auth: 'service',
|
|
199
|
+
scope: 'payments:read',
|
|
200
|
+
idempotent: true,
|
|
201
|
+
body: createReportRunParams,
|
|
202
|
+
response: reportRunSchema,
|
|
203
|
+
sdk: 'reporting.reportRuns.create',
|
|
204
|
+
}),
|
|
205
|
+
defineRoute({
|
|
206
|
+
operationId: 'listReportRuns',
|
|
207
|
+
method: 'get',
|
|
208
|
+
path: '/v1/reporting/report_runs',
|
|
209
|
+
tag: 'Reporting',
|
|
210
|
+
summary: 'List report runs',
|
|
211
|
+
auth: 'service',
|
|
212
|
+
scope: 'payments:read',
|
|
213
|
+
query: listReportRunsQuery,
|
|
214
|
+
response: listOf(reportRunSchema),
|
|
215
|
+
sdk: 'reporting.reportRuns.list',
|
|
216
|
+
expandable: 'reporting.report_run',
|
|
217
|
+
}),
|
|
218
|
+
defineRoute({
|
|
219
|
+
operationId: 'retrieveReportRun',
|
|
220
|
+
method: 'get',
|
|
221
|
+
path: '/v1/reporting/report_runs/{id}',
|
|
222
|
+
tag: 'Reporting',
|
|
223
|
+
summary: 'Retrieve a report run',
|
|
224
|
+
auth: 'service',
|
|
225
|
+
scope: 'payments:read',
|
|
226
|
+
params: { id: 'The report run (`frr_…`).' },
|
|
227
|
+
query: expandOnlyQuery,
|
|
228
|
+
response: reportRunSchema,
|
|
229
|
+
sdk: 'reporting.reportRuns.retrieve',
|
|
230
|
+
expandable: 'reporting.report_run',
|
|
231
|
+
}),
|
|
232
|
+
];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery, queryInteger } from '../../common/params.js';
|
|
5
|
+
import { livemode, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { REQUEST_LOG_METHODS, REQUEST_LOG_STATUS_CLASSES } from '../../vocabulary/reporting.js';
|
|
8
|
+
/**
|
|
9
|
+
* One merchant API request, as Peable recorded it (`req_…`) — the request log
|
|
10
|
+
* Orbit and `peable logs tail` read. Its `id` IS the `Request-Id` that request
|
|
11
|
+
* was answered with, so the id a merchant quotes to support and the log row
|
|
12
|
+
* are the same thing.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately thin: method, path (no query string), status, duration and the
|
|
15
|
+
* `Idempotency-Key` it carried. No body, no headers, no query string, no caller
|
|
16
|
+
* address — a log a merchant can read is a log that must not hold what a
|
|
17
|
+
* request carried. Kept 30 days.
|
|
18
|
+
*/
|
|
19
|
+
export const requestLogSchema = defineObject('request_log', 'RequestLog', z
|
|
20
|
+
.object({
|
|
21
|
+
id: z.string().describe("The request's `Request-Id` (`req_…`)."),
|
|
22
|
+
object: z.literal('request_log'),
|
|
23
|
+
livemode,
|
|
24
|
+
method: z.enum(REQUEST_LOG_METHODS),
|
|
25
|
+
path: z.string().describe('The path that was requested, without its query string.'),
|
|
26
|
+
status: z.number().int().describe('The HTTP status it was answered with.'),
|
|
27
|
+
duration_ms: z
|
|
28
|
+
.number()
|
|
29
|
+
.int()
|
|
30
|
+
.nonnegative()
|
|
31
|
+
.describe('How long the gateway took to answer, in milliseconds.'),
|
|
32
|
+
idempotency_key: z
|
|
33
|
+
.string()
|
|
34
|
+
.nullable()
|
|
35
|
+
.describe('The `Idempotency-Key` the request carried, if it carried a valid one.'),
|
|
36
|
+
created: unixSeconds.describe('When it was answered.'),
|
|
37
|
+
})
|
|
38
|
+
.strict(), {
|
|
39
|
+
examples: [
|
|
40
|
+
{
|
|
41
|
+
id: 'req_0193b8f35e9c4f2a7b18',
|
|
42
|
+
object: 'request_log',
|
|
43
|
+
livemode: false,
|
|
44
|
+
method: 'POST',
|
|
45
|
+
path: '/v1/payment_intents',
|
|
46
|
+
status: 201,
|
|
47
|
+
duration_ms: 84,
|
|
48
|
+
idempotency_key: '5f1d3c2e-8a4b-4f6e-9d2c-1b7a0e3f4c5d',
|
|
49
|
+
created: 1793750400,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
/** `status=404` (one code) or `status=4xx` (a class). */
|
|
54
|
+
const requestLogStatusFilter = z
|
|
55
|
+
.union([queryInteger({ min: 100, max: 599 }), z.enum(REQUEST_LOG_STATUS_CLASSES)])
|
|
56
|
+
.describe('One status code (`404`) or a class (`2xx`, `3xx`, `4xx`, `5xx`).');
|
|
57
|
+
const requestLogFilters = {
|
|
58
|
+
status: requestLogStatusFilter.optional(),
|
|
59
|
+
method: z.enum(REQUEST_LOG_METHODS).optional(),
|
|
60
|
+
};
|
|
61
|
+
export const listRequestLogsQuery = listQuery(requestLogFilters);
|
|
62
|
+
/** The live tail's filters: the list's, without paging. */
|
|
63
|
+
export const streamRequestLogsQuery = z.object(requestLogFilters).strict();
|
|
64
|
+
export const requestLogRoutes = [
|
|
65
|
+
defineRoute({
|
|
66
|
+
operationId: 'listRequestLogs',
|
|
67
|
+
method: 'get',
|
|
68
|
+
path: '/v1/request_logs',
|
|
69
|
+
tag: 'Request logs',
|
|
70
|
+
summary: 'List request logs',
|
|
71
|
+
description: 'Your API requests of the last 30 days, newest first, filtered by `status`, `method` and `created`.',
|
|
72
|
+
auth: 'service',
|
|
73
|
+
scope: 'payments:read',
|
|
74
|
+
query: listRequestLogsQuery,
|
|
75
|
+
response: listOf(requestLogSchema),
|
|
76
|
+
sdk: 'requestLogs.list',
|
|
77
|
+
expandable: 'request_log',
|
|
78
|
+
}),
|
|
79
|
+
defineRoute({
|
|
80
|
+
operationId: 'streamRequestLogs',
|
|
81
|
+
method: 'get',
|
|
82
|
+
path: '/v1/request_logs/stream',
|
|
83
|
+
tag: 'Request logs',
|
|
84
|
+
summary: 'Stream request logs',
|
|
85
|
+
description: 'Server-Sent Events: each request as it is answered (`event: request_log`), after a `ready` event. Reconnect with `Last-Event-ID` to resume without a gap. Test mode only; a stream ends after 15 minutes.',
|
|
86
|
+
auth: 'service',
|
|
87
|
+
scope: 'payments:read',
|
|
88
|
+
testModeOnly: true,
|
|
89
|
+
query: streamRequestLogsQuery,
|
|
90
|
+
response: { kind: 'stream', event: requestLogSchema },
|
|
91
|
+
sdk: 'requestLogs.stream',
|
|
92
|
+
}),
|
|
93
|
+
defineRoute({
|
|
94
|
+
operationId: 'retrieveRequestLog',
|
|
95
|
+
method: 'get',
|
|
96
|
+
path: '/v1/request_logs/{id}',
|
|
97
|
+
tag: 'Request logs',
|
|
98
|
+
summary: 'Retrieve a request log',
|
|
99
|
+
description: 'By `Request-Id`; 404 once older than 30 days.',
|
|
100
|
+
auth: 'service',
|
|
101
|
+
scope: 'payments:read',
|
|
102
|
+
params: { id: 'The `Request-Id` (`req_…`).' },
|
|
103
|
+
query: expandOnlyQuery,
|
|
104
|
+
response: requestLogSchema,
|
|
105
|
+
sdk: 'requestLogs.retrieve',
|
|
106
|
+
}),
|
|
107
|
+
];
|