@peable.to/contracts 0.4.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 -137
- 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 -134
- 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 -171
- 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 -165
- package/dist/esm/openapi.js +0 -161
- package/dist/types/openapi.d.ts +0 -148
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Peable Tax vocabulary (ADR 0011, ADR 0020): the closed value sets the tax
|
|
2
|
+
// contracts are built from, and the database mirrors as CHECKs. Zod-free, so
|
|
3
|
+
// Orbit and the shared types read them at runtime without constructing a schema.
|
|
4
|
+
// ── Collection (ADR 0011) ────────────────────────────────────────────────────
|
|
5
|
+
/**
|
|
6
|
+
* How a registration lets the seller collect. `standard`/`simplified` cover one
|
|
7
|
+
* country; the EU One-Stop-Shop schemes cover every EU member state from one
|
|
8
|
+
* identification state; the US is per state; Canadian PST/QST is per province.
|
|
9
|
+
*/
|
|
10
|
+
export const TAX_REGISTRATION_SCHEMES = [
|
|
11
|
+
'standard',
|
|
12
|
+
'simplified',
|
|
13
|
+
'eu_oss_union',
|
|
14
|
+
'eu_oss_non_union',
|
|
15
|
+
'us_state_sales_tax',
|
|
16
|
+
'ca_provincial',
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Location evidence a jurisdiction accepts. There is deliberately no language,
|
|
20
|
+
* currency, locale or timezone: none of them is evidence of where a customer
|
|
21
|
+
* lives, and Peable cannot be told otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export const TAX_LOCATION_EVIDENCE_TYPES = [
|
|
24
|
+
'billing_address',
|
|
25
|
+
'ip_address',
|
|
26
|
+
'payment_method_country',
|
|
27
|
+
'bank_country',
|
|
28
|
+
'sim_country',
|
|
29
|
+
'landline_country',
|
|
30
|
+
];
|
|
31
|
+
/** Whether a line's amount includes its tax (`inclusive`) or tax is added on top. */
|
|
32
|
+
export const TAX_BEHAVIORS = ['inclusive', 'exclusive'];
|
|
33
|
+
/** `active` once the owner approved; any edit returns the settings to `draft`. */
|
|
34
|
+
export const TAX_SETTINGS_STATUSES = ['draft', 'active'];
|
|
35
|
+
/**
|
|
36
|
+
* Which provider account calculates for a merchant. `platform`: Peable's own
|
|
37
|
+
* provider account, available only to official Oxy applications, whose seller
|
|
38
|
+
* is the platform's legal entity. `none`: no provider; sales in a registered
|
|
39
|
+
* jurisdiction cannot be calculated and fail closed.
|
|
40
|
+
*/
|
|
41
|
+
export const TAX_CALCULATION_ACCOUNTS = ['platform', 'none'];
|
|
42
|
+
/** `pending_approval` until the owner approves; `scheduled` before `active_from`. */
|
|
43
|
+
export const TAX_REGISTRATION_STATUSES = [
|
|
44
|
+
'pending_approval',
|
|
45
|
+
'scheduled',
|
|
46
|
+
'active',
|
|
47
|
+
'expired',
|
|
48
|
+
];
|
|
49
|
+
/** Only `sufficient` evidence can be calculated against. */
|
|
50
|
+
export const TAX_EVIDENCE_STATUSES = ['sufficient', 'insufficient', 'conflicting'];
|
|
51
|
+
/**
|
|
52
|
+
* Why a calculation's tax is what it is: `collect` (a registration covers the
|
|
53
|
+
* customer and the provider calculated), `not_registered` (no registration
|
|
54
|
+
* covers them: zero tax, recorded as such), `nontaxable` (every line used the
|
|
55
|
+
* nontaxable code).
|
|
56
|
+
*/
|
|
57
|
+
export const TAX_COLLECTIONS = ['collect', 'not_registered', 'nontaxable'];
|
|
58
|
+
/** A sale, or a refund (or credit note) of one. */
|
|
59
|
+
export const TAX_TRANSACTION_TYPES = ['transaction', 'reversal'];
|
|
60
|
+
/**
|
|
61
|
+
* The product tax codes Peable accepts, starting with digital services and
|
|
62
|
+
* SaaS — what every Oxy application sells. Ids are Stripe Tax's tax codes, so a
|
|
63
|
+
* code means the same thing to Peable and to the provider calculating it.
|
|
64
|
+
* Adding a category is adding a row here; classifying a product is the seller's
|
|
65
|
+
* decision.
|
|
66
|
+
*/
|
|
67
|
+
export const TAX_CODES = Object.freeze([
|
|
68
|
+
{
|
|
69
|
+
id: 'txcd_00000000',
|
|
70
|
+
name: 'Nontaxable',
|
|
71
|
+
description: 'A product that is not subject to tax anywhere. No tax is calculated.',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'txcd_10000000',
|
|
75
|
+
name: 'General - Electronically Supplied Services',
|
|
76
|
+
description: 'A service delivered electronically over the internet with minimal human involvement.',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'txcd_10103000',
|
|
80
|
+
name: 'Software as a service (SaaS) - personal use',
|
|
81
|
+
description: 'Hosted software accessed online, sold to consumers for personal use.',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'txcd_10103001',
|
|
85
|
+
name: 'Software as a service (SaaS) - business use',
|
|
86
|
+
description: 'Hosted software accessed online, sold to businesses for business use.',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'txcd_10202000',
|
|
90
|
+
name: 'Downloadable Software - personal use',
|
|
91
|
+
description: 'Software downloaded to the customer’s device, for personal use.',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'txcd_10202003',
|
|
95
|
+
name: 'Downloadable Software - business use',
|
|
96
|
+
description: 'Software downloaded to the customer’s device, for business use.',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'txcd_10701100',
|
|
100
|
+
name: 'Website Hosting',
|
|
101
|
+
description: 'Hosting of a website or web application on the seller’s servers.',
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
/** The code of a product that is taxed nowhere. */
|
|
105
|
+
export const NONTAXABLE_TAX_CODE = 'txcd_00000000';
|
|
106
|
+
/** The code a merchant's settings start with: electronically supplied services. */
|
|
107
|
+
export const DEFAULT_TAX_CODE = 'txcd_10000000';
|
|
108
|
+
const KNOWN_TAX_CODES = new Set(TAX_CODES.map((code) => code.id));
|
|
109
|
+
/** Whether `id` is one of {@link TAX_CODES}. */
|
|
110
|
+
export function isKnownTaxCode(id) {
|
|
111
|
+
return KNOWN_TAX_CODES.has(id);
|
|
112
|
+
}
|
|
113
|
+
// ── Business compliance (ADR 0020) ───────────────────────────────────────────
|
|
114
|
+
/** `unknown` is an answer, not a gap: the owner says they do not know yet. */
|
|
115
|
+
export const TAX_LEGAL_ENTITY_TYPES = [
|
|
116
|
+
'corporation',
|
|
117
|
+
'limited_liability_company',
|
|
118
|
+
'partnership',
|
|
119
|
+
'sole_proprietorship',
|
|
120
|
+
'nonprofit',
|
|
121
|
+
'public_body',
|
|
122
|
+
'other',
|
|
123
|
+
'unknown',
|
|
124
|
+
];
|
|
125
|
+
export const TAX_CUSTOMER_TYPES = ['consumers', 'businesses', 'both', 'unknown'];
|
|
126
|
+
export const TAX_SUPPLY_TYPES = [
|
|
127
|
+
'digital_services',
|
|
128
|
+
'software_as_a_service',
|
|
129
|
+
'physical_goods',
|
|
130
|
+
'professional_services',
|
|
131
|
+
'other',
|
|
132
|
+
];
|
|
133
|
+
/**
|
|
134
|
+
* Where the business ACTUALLY operates. `head_office` and `fixed_establishment`
|
|
135
|
+
* are the owner's statement of establishment (the EU rule reads them); any
|
|
136
|
+
* location in a US state is physical presence there.
|
|
137
|
+
*/
|
|
138
|
+
export const TAX_OPERATING_LOCATION_KINDS = [
|
|
139
|
+
'head_office',
|
|
140
|
+
'fixed_establishment',
|
|
141
|
+
'office',
|
|
142
|
+
'warehouse',
|
|
143
|
+
'employees',
|
|
144
|
+
'inventory',
|
|
145
|
+
'other',
|
|
146
|
+
];
|
|
147
|
+
/**
|
|
148
|
+
* Where the business stands with a tax authority, IN ITS OWN WORDS.
|
|
149
|
+
*
|
|
150
|
+
* - `unknown` — the owner does not know; an assessment escalates it.
|
|
151
|
+
* - `not_registered` — the owner says there is no registration.
|
|
152
|
+
* - `application_pending` — an application was made outside Peable and the
|
|
153
|
+
* authority has not answered: an ambiguous outcome, never treated as
|
|
154
|
+
* registered.
|
|
155
|
+
* - `registered` — the owner says the authority registered the business, from
|
|
156
|
+
* `effective_from`.
|
|
157
|
+
* - `rejected` — the authority refused the application.
|
|
158
|
+
* - `ended` — the registration ended at `effective_to`.
|
|
159
|
+
*/
|
|
160
|
+
export const TAX_REGISTRATION_DECLARATION_STATUSES = [
|
|
161
|
+
'unknown',
|
|
162
|
+
'not_registered',
|
|
163
|
+
'application_pending',
|
|
164
|
+
'registered',
|
|
165
|
+
'rejected',
|
|
166
|
+
'ended',
|
|
167
|
+
];
|
|
168
|
+
export const TAX_FILING_FREQUENCIES = ['monthly', 'quarterly', 'annual', 'unknown'];
|
|
169
|
+
export const TAX_DOCUMENT_KINDS = [
|
|
170
|
+
'registration_certificate',
|
|
171
|
+
'authority_correspondence',
|
|
172
|
+
'incorporation_record',
|
|
173
|
+
'filing_confirmation',
|
|
174
|
+
'payment_receipt',
|
|
175
|
+
'other',
|
|
176
|
+
];
|
|
177
|
+
/** `provided`: an available document is attached; `unavailable`: only removed ones are. */
|
|
178
|
+
export const TAX_DOCUMENT_CHECKLIST_STATUSES = ['provided', 'missing', 'unavailable'];
|
|
179
|
+
/** The tax a jurisdiction rule is about. */
|
|
180
|
+
export const TAX_TYPES = ['vat', 'sales_tax'];
|
|
181
|
+
/** The window a rule's threshold is measured over. */
|
|
182
|
+
export const TAX_THRESHOLD_PERIODS = [
|
|
183
|
+
'current_or_previous_calendar_year',
|
|
184
|
+
'preceding_twelve_calendar_months',
|
|
185
|
+
];
|
|
186
|
+
/** Whether a tax professional has signed a rule off. */
|
|
187
|
+
export const TAX_RULE_REVIEW_STATUSES = ['unreviewed', 'reviewed'];
|
|
188
|
+
/**
|
|
189
|
+
* What an assessment found for one jurisdiction.
|
|
190
|
+
*
|
|
191
|
+
* - `registration_declared` — the owner declares a registration in force.
|
|
192
|
+
* - `likely_required` — the rule indicates an obligation; a person decides.
|
|
193
|
+
* - `approaching_threshold` — at or above 80% of the threshold.
|
|
194
|
+
* - `not_indicated` — nothing in the recorded facts indicates one.
|
|
195
|
+
* - `uncertain` — the facts are missing or contradictory; escalated.
|
|
196
|
+
* - `unsupported` — sales exist where no supported rule applies.
|
|
197
|
+
*/
|
|
198
|
+
export const TAX_OBLIGATION_OUTCOMES = [
|
|
199
|
+
'registration_declared',
|
|
200
|
+
'likely_required',
|
|
201
|
+
'approaching_threshold',
|
|
202
|
+
'not_indicated',
|
|
203
|
+
'uncertain',
|
|
204
|
+
'unsupported',
|
|
205
|
+
];
|
|
206
|
+
export const TAX_REVIEW_ITEM_STATUSES = ['open', 'resolved', 'dismissed'];
|
|
207
|
+
export const TAX_REVIEW_SEVERITIES = ['action_required', 'review'];
|
|
208
|
+
/** What the owner decided. None of them activates collection. */
|
|
209
|
+
export const TAX_REVIEW_DECISIONS = [
|
|
210
|
+
'will_register',
|
|
211
|
+
'registered_outside_peable',
|
|
212
|
+
'not_required',
|
|
213
|
+
'accepted_risk',
|
|
214
|
+
'facts_corrected',
|
|
215
|
+
'dismissed',
|
|
216
|
+
];
|
|
217
|
+
/** Who recorded a compliance change: the owner, a service credential, or Peable itself. */
|
|
218
|
+
export const TAX_ACTOR_TYPES = ['user', 'service', 'system'];
|
|
219
|
+
export const TAX_DEADLINE_KINDS = ['return', 'payment', 'registration'];
|
|
220
|
+
export const TAX_DEADLINE_STATUSES = ['upcoming', 'due_soon', 'passed'];
|
|
221
|
+
export const TAX_COMPLIANCE_CAPABILITY_STATUSES = [
|
|
222
|
+
'available',
|
|
223
|
+
'limited',
|
|
224
|
+
'not_available',
|
|
225
|
+
'out_of_scope',
|
|
226
|
+
];
|
|
227
|
+
/** VAT/sales tax, corporate income tax and annual company filings are different obligations. */
|
|
228
|
+
export const TAX_COMPLIANCE_CAPABILITY_CATEGORIES = [
|
|
229
|
+
'vat_sales_tax',
|
|
230
|
+
'corporate_income_tax',
|
|
231
|
+
'annual_company_filings',
|
|
232
|
+
'workflow',
|
|
233
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The date of the one wire (ADR 0014 D2): echoed as `Peable-Version` on every
|
|
3
|
+
* response, the `api_version` every event is stored under, and the only value
|
|
4
|
+
* a caller may send in `Peable-Version`. One constant, so the header, the
|
|
5
|
+
* stored events and the SDK's `apiVersion` cannot name two different wires.
|
|
6
|
+
*/
|
|
7
|
+
export const PEABLE_API_VERSION = '2026-11-03';
|
|
8
|
+
/** Every wire date the gateway serves. Dated versions side by side are a later decision (ADR 0014 D2). */
|
|
9
|
+
export const PEABLE_API_VERSIONS = [PEABLE_API_VERSION];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Stripe's address and shipping shapes — as returned (every field present,
|
|
4
|
+
* `null` when not given) and as a request carries them (every field optional).
|
|
5
|
+
* Shared by every object that holds one: intents, customers, payment methods,
|
|
6
|
+
* checkout sessions.
|
|
7
|
+
*/
|
|
8
|
+
export declare const addressSchema: z.ZodObject<{
|
|
9
|
+
line1: z.ZodNullable<z.ZodString>;
|
|
10
|
+
line2: z.ZodNullable<z.ZodString>;
|
|
11
|
+
city: z.ZodNullable<z.ZodString>;
|
|
12
|
+
state: z.ZodNullable<z.ZodString>;
|
|
13
|
+
postal_code: z.ZodNullable<z.ZodString>;
|
|
14
|
+
country: z.ZodNullable<z.ZodString>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export type Address = z.output<typeof addressSchema>;
|
|
17
|
+
export declare const shippingSchema: z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
20
|
+
address: z.ZodObject<{
|
|
21
|
+
line1: z.ZodNullable<z.ZodString>;
|
|
22
|
+
line2: z.ZodNullable<z.ZodString>;
|
|
23
|
+
city: z.ZodNullable<z.ZodString>;
|
|
24
|
+
state: z.ZodNullable<z.ZodString>;
|
|
25
|
+
postal_code: z.ZodNullable<z.ZodString>;
|
|
26
|
+
country: z.ZodNullable<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
carrier: z.ZodNullable<z.ZodString>;
|
|
29
|
+
tracking_number: z.ZodNullable<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
export type Shipping = z.output<typeof shippingSchema>;
|
|
32
|
+
/** An address as a request carries it: every field optional. */
|
|
33
|
+
export declare const addressParams: z.ZodObject<{
|
|
34
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
35
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
36
|
+
city: z.ZodOptional<z.ZodString>;
|
|
37
|
+
state: z.ZodOptional<z.ZodString>;
|
|
38
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
39
|
+
country: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export type AddressParams = z.input<typeof addressParams>;
|
|
42
|
+
/** Shipping as a request carries it: only `name` and `address` are required. */
|
|
43
|
+
export declare const shippingParams: z.ZodObject<{
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
46
|
+
address: z.ZodObject<{
|
|
47
|
+
line1: z.ZodOptional<z.ZodString>;
|
|
48
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
49
|
+
city: z.ZodOptional<z.ZodString>;
|
|
50
|
+
state: z.ZodOptional<z.ZodString>;
|
|
51
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
52
|
+
country: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
carrier: z.ZodOptional<z.ZodString>;
|
|
55
|
+
tracking_number: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
export type ShippingParams = z.input<typeof shippingParams>;
|
|
58
|
+
export declare const emailParam: z.ZodEmail;
|
|
59
|
+
/** A request address in the stored (and wire) shape: every field present. */
|
|
60
|
+
export declare function toAddress(input: z.output<typeof addressParams>): Address;
|
|
61
|
+
/** Request shipping in the stored (and wire) shape. */
|
|
62
|
+
export declare function toShipping(input: z.output<typeof shippingParams>): Shipping;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The envelopes every resource shares (ADR 0014 D1): the list, the search
|
|
4
|
+
* result, the deleted tombstone and the error.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* One page of a list, newest first. `url` is the path that was listed, so a
|
|
8
|
+
* page carries enough to fetch the next one without the caller remembering
|
|
9
|
+
* where it came from.
|
|
10
|
+
*/
|
|
11
|
+
export declare function listOf<T extends z.ZodType>(item: T): z.ZodObject<{
|
|
12
|
+
object: z.ZodLiteral<"list">;
|
|
13
|
+
data: z.ZodArray<T>;
|
|
14
|
+
has_more: z.ZodBoolean;
|
|
15
|
+
url: z.ZodString;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
/**
|
|
18
|
+
* One page of a search. Pages FORWARD only, by an opaque `next_page` token
|
|
19
|
+
* passed back as `page`, bound to the query it came from.
|
|
20
|
+
*/
|
|
21
|
+
export declare function searchResultOf<T extends z.ZodType>(item: T): z.ZodObject<{
|
|
22
|
+
object: z.ZodLiteral<"search_result">;
|
|
23
|
+
data: z.ZodArray<T>;
|
|
24
|
+
has_more: z.ZodBoolean;
|
|
25
|
+
next_page: z.ZodNullable<z.ZodString>;
|
|
26
|
+
url: z.ZodString;
|
|
27
|
+
total_count: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
/** A deleted object, as its `DELETE` answers: `{id, object, deleted: true}`. */
|
|
30
|
+
export declare function deletedOf<T extends string>(object: T): z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
object: z.ZodLiteral<T>;
|
|
33
|
+
deleted: z.ZodLiteral<true>;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
/** The error object inside every non-2xx answer. */
|
|
36
|
+
export declare const apiErrorSchema: z.ZodObject<{
|
|
37
|
+
type: z.ZodEnum<{
|
|
38
|
+
api_error: "api_error";
|
|
39
|
+
authentication_error: "authentication_error";
|
|
40
|
+
card_error: "card_error";
|
|
41
|
+
idempotency_error: "idempotency_error";
|
|
42
|
+
invalid_request_error: "invalid_request_error";
|
|
43
|
+
permission_error: "permission_error";
|
|
44
|
+
rate_limit_error: "rate_limit_error";
|
|
45
|
+
}>;
|
|
46
|
+
code: z.ZodOptional<z.ZodString>;
|
|
47
|
+
decline_code: z.ZodOptional<z.ZodString>;
|
|
48
|
+
param: z.ZodOptional<z.ZodString>;
|
|
49
|
+
message: z.ZodString;
|
|
50
|
+
doc_url: z.ZodOptional<z.ZodURL>;
|
|
51
|
+
request_id: z.ZodNullable<z.ZodString>;
|
|
52
|
+
payment_intent: z.ZodOptional<z.ZodLazy<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
53
|
+
invoice: z.ZodOptional<z.ZodLazy<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
54
|
+
refresh_url: z.ZodOptional<z.ZodURL>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
/** `{ error: {...} }` — every non-2xx answer. */
|
|
57
|
+
export declare const errorEnvelopeSchema: z.ZodObject<{
|
|
58
|
+
error: z.ZodObject<{
|
|
59
|
+
type: z.ZodEnum<{
|
|
60
|
+
api_error: "api_error";
|
|
61
|
+
authentication_error: "authentication_error";
|
|
62
|
+
card_error: "card_error";
|
|
63
|
+
idempotency_error: "idempotency_error";
|
|
64
|
+
invalid_request_error: "invalid_request_error";
|
|
65
|
+
permission_error: "permission_error";
|
|
66
|
+
rate_limit_error: "rate_limit_error";
|
|
67
|
+
}>;
|
|
68
|
+
code: z.ZodOptional<z.ZodString>;
|
|
69
|
+
decline_code: z.ZodOptional<z.ZodString>;
|
|
70
|
+
param: z.ZodOptional<z.ZodString>;
|
|
71
|
+
message: z.ZodString;
|
|
72
|
+
doc_url: z.ZodOptional<z.ZodURL>;
|
|
73
|
+
request_id: z.ZodNullable<z.ZodString>;
|
|
74
|
+
payment_intent: z.ZodOptional<z.ZodLazy<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
75
|
+
invoice: z.ZodOptional<z.ZodLazy<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
76
|
+
refresh_url: z.ZodOptional<z.ZodURL>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
export type ApiError = z.output<typeof apiErrorSchema>;
|
|
80
|
+
export type ErrorEnvelope = z.output<typeof errorEnvelopeSchema>;
|
|
81
|
+
/** One page of a list of `T` — the type of every `listOf(…)` answer. */
|
|
82
|
+
export type List<T> = Omit<z.output<ReturnType<typeof listOf<z.ZodNever>>>, 'data'> & {
|
|
83
|
+
data: T[];
|
|
84
|
+
};
|
|
85
|
+
/** One page of a search over `T` — the type of every `searchResultOf(…)` answer. */
|
|
86
|
+
export type SearchResult<T> = Omit<z.output<ReturnType<typeof searchResultOf<z.ZodNever>>>, 'data'> & {
|
|
87
|
+
data: T[];
|
|
88
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The object registry: every named wire object (`Customer`, `PaymentIntent`, …)
|
|
4
|
+
* is defined ONCE, here in `packages/contracts`, and registered under its
|
|
5
|
+
* OpenAPI component name and its `object` value.
|
|
6
|
+
*
|
|
7
|
+
* Three things read it:
|
|
8
|
+
*
|
|
9
|
+
* - `expandable(type)` — a reference that `expand[]` can replace with the
|
|
10
|
+
* object it names validates against the registered schema;
|
|
11
|
+
* - the OpenAPI generator — every registered object is a
|
|
12
|
+
* `#/components/schemas/<Name>` and every reference to it is a `$ref`;
|
|
13
|
+
* - {@link Expand} — the TypeScript half, which turns a reference's marker
|
|
14
|
+
* into the object type, so `Customer['invoice_settings']['default_payment_method']`
|
|
15
|
+
* is `string | PaymentMethod | null` without the schemas referencing each
|
|
16
|
+
* other at the type level (which TypeScript cannot infer, and which the
|
|
17
|
+
* declaration emitter would elide to `any`).
|
|
18
|
+
*/
|
|
19
|
+
/** OpenAPI-facing metadata a schema can carry. */
|
|
20
|
+
export interface ContractMeta {
|
|
21
|
+
/** The component name: `#/components/schemas/<id>`. */
|
|
22
|
+
id?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
/** Example values, rendered in the reference and the OpenAPI document. */
|
|
26
|
+
examples?: readonly unknown[];
|
|
27
|
+
deprecated?: boolean;
|
|
28
|
+
/** On an expandable reference: the `object` type `expand[]` replaces it with. */
|
|
29
|
+
'x-peable-expandable'?: string;
|
|
30
|
+
/** Replaces the generated JSON Schema of this node (a query integer's wire spelling). */
|
|
31
|
+
jsonSchema?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/** The one registry every contract schema's metadata lives in. */
|
|
34
|
+
export declare const contractRegistry: z.core.$ZodRegistry<ContractMeta, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
35
|
+
declare const refBrand: unique symbol;
|
|
36
|
+
/**
|
|
37
|
+
* The TYPE of an expandable reference before {@link Expand} resolves it. Never
|
|
38
|
+
* a runtime value: at runtime the reference is an id string or the object.
|
|
39
|
+
*/
|
|
40
|
+
export interface Ref<K extends string> {
|
|
41
|
+
readonly [refBrand]: K;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* `object` value → wire type, for every object a reference can expand into.
|
|
45
|
+
*
|
|
46
|
+
* Each resource module adds its own entries by declaration merging:
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* declare module '../common/objects' {
|
|
50
|
+
* interface ObjectMap { customer: Customer }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* so a resource is registered by the same file that defines it.
|
|
55
|
+
*/
|
|
56
|
+
export interface ObjectMap {
|
|
57
|
+
}
|
|
58
|
+
/** Every object type a reference can name. */
|
|
59
|
+
export type ObjectType = keyof ObjectMap;
|
|
60
|
+
/**
|
|
61
|
+
* A schema's output with every {@link Ref} replaced by the object it names —
|
|
62
|
+
* the wire type. Homomorphic, so optional and readonly modifiers survive.
|
|
63
|
+
*/
|
|
64
|
+
export type Expand<T> = T extends Ref<infer K> ? K extends keyof ObjectMap ? ObjectMap[K] : never : T extends readonly (infer U)[] ? Expand<U>[] : T extends object ? {
|
|
65
|
+
[P in keyof T]: Expand<T[P]>;
|
|
66
|
+
} : T;
|
|
67
|
+
/** The wire type a schema describes (its output, references resolved). */
|
|
68
|
+
export type Wire<S extends z.ZodType> = Expand<z.output<S>>;
|
|
69
|
+
/** The parameters a request schema accepts as sent on the wire (its input). */
|
|
70
|
+
export type Params<S extends z.ZodType> = z.input<S>;
|
|
71
|
+
/**
|
|
72
|
+
* Register a wire object: its `object` value (the key references use) and its
|
|
73
|
+
* component name. Returns the schema so a definition reads as one expression.
|
|
74
|
+
*/
|
|
75
|
+
export declare function defineObject<T extends z.ZodType>(type: string, id: string, schema: T, meta?: Omit<ContractMeta, 'id'>): T;
|
|
76
|
+
/**
|
|
77
|
+
* Register a named schema that is not an expandable object — a tombstone, a
|
|
78
|
+
* shared sub-object, a polymorphic payload — as `#/components/schemas/<id>`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function defineComponent<T extends z.ZodType>(id: string, schema: T, meta?: Omit<ContractMeta, 'id'>): T;
|
|
81
|
+
/** The registered schema of `type`, or `undefined`. */
|
|
82
|
+
export declare function objectSchema(type: string): z.ZodType | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* The registered schema of `type`. Resolved lazily (a reference is declared
|
|
85
|
+
* before the module defining its target has loaded), and loud when nothing
|
|
86
|
+
* registers it: a reference to an unknown object is a contract bug.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveObject(type: string): z.ZodType;
|
|
89
|
+
/** Every registered object type, in registration order. */
|
|
90
|
+
export declare function objectTypes(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* A reference `expand[]` can replace: the id (`cus_…`) or, expanded, the
|
|
93
|
+
* object. The naming rule (`lib/expand.ts` in the backend): an expandable
|
|
94
|
+
* reference is spelled WITHOUT `_id`, and a field without `_id` that is not
|
|
95
|
+
* expandable is a bug.
|
|
96
|
+
*/
|
|
97
|
+
export declare function expandable<K extends string>(type: K, description?: string): z.ZodType<string | Ref<K>, string | Ref<K>>;
|
|
98
|
+
/**
|
|
99
|
+
* A field that always carries the FULL object `type` names (never an id): a
|
|
100
|
+
* subscription item's `price`, a payer view's `payment_intent`, a report run's
|
|
101
|
+
* result `file`. Validated against the registered schema and typed through
|
|
102
|
+
* {@link Ref}, so {@link Expand} resolves it to that object's wire type.
|
|
103
|
+
*/
|
|
104
|
+
export declare function embedded<K extends string>(type: K, description?: string): z.ZodType<Ref<K>, Ref<K>>;
|
|
105
|
+
/** Attach OpenAPI metadata to a schema without changing its type. */
|
|
106
|
+
export declare function describe<T extends z.ZodType>(schema: T, meta: ContractMeta): T;
|
|
107
|
+
export {};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* An integer in a query string. Arrives as a string from a URL, as a number
|
|
4
|
+
* from a typed caller; both are the same request.
|
|
5
|
+
*/
|
|
6
|
+
export declare function queryInteger(bounds?: {
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
}): z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>;
|
|
10
|
+
/** `true` / `false` in a query string (or a real boolean from a typed caller). */
|
|
11
|
+
export declare const queryBoolean: z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
|
|
12
|
+
true: "true";
|
|
13
|
+
false: "false";
|
|
14
|
+
}>]>, z.ZodTransform<boolean, boolean | "true" | "false">>;
|
|
15
|
+
/** The latest representable instant (9999-12-31T23:59:59Z), the bound of every Unix-seconds parameter. */
|
|
16
|
+
export declare const MAX_UNIX_SECONDS = 253402300799;
|
|
17
|
+
/** Unix seconds in a body. */
|
|
18
|
+
export declare const unixSecondsParam: z.ZodNumber;
|
|
19
|
+
/** Unix seconds in a query string. */
|
|
20
|
+
export declare const queryUnixSeconds: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>;
|
|
21
|
+
/** A range over a Unix-seconds field; each bound optional, together a conjunction. */
|
|
22
|
+
export interface RangeFilter {
|
|
23
|
+
readonly gt?: number | undefined;
|
|
24
|
+
readonly gte?: number | undefined;
|
|
25
|
+
readonly lt?: number | undefined;
|
|
26
|
+
readonly lte?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `created=X` (exactly that second) or `created[gt|gte|lt|lte]=X`. The bare
|
|
30
|
+
* form is normalized to the range `[X, X]` so the repository reads one shape.
|
|
31
|
+
*/
|
|
32
|
+
export declare const rangeParam: z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>, z.ZodTransform<RangeFilter, number>>, z.ZodPipe<z.ZodObject<{
|
|
33
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
34
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
35
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
36
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
37
|
+
}, z.core.$strict>, z.ZodTransform<RangeFilter, {
|
|
38
|
+
gt?: number | undefined;
|
|
39
|
+
gte?: number | undefined;
|
|
40
|
+
lt?: number | undefined;
|
|
41
|
+
lte?: number | undefined;
|
|
42
|
+
}>>]>;
|
|
43
|
+
/**
|
|
44
|
+
* `expand[]=a&expand[]=b` arrives as an array; `expand=a` as a string. Both
|
|
45
|
+
* mean the same request. Dot paths, at most four levels; on a list every path
|
|
46
|
+
* starts with `data.`.
|
|
47
|
+
*/
|
|
48
|
+
export declare const expandParam: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>;
|
|
49
|
+
/** The public id of a cursor. Bounded so a cursor is never an unbounded index probe. */
|
|
50
|
+
export declare const cursorParam: z.ZodString;
|
|
51
|
+
/** An object id in a body or query. */
|
|
52
|
+
export declare const idParam: z.ZodString;
|
|
53
|
+
/** The list limit: 1–100, default 10. */
|
|
54
|
+
export declare const limitParam: z.ZodPipe<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>, z.ZodTransform<number, number | undefined>>;
|
|
55
|
+
/** The parameters every list accepts. */
|
|
56
|
+
export declare const listShape: {
|
|
57
|
+
limit: z.ZodPipe<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>, z.ZodTransform<number, number | undefined>>;
|
|
58
|
+
starting_after: z.ZodOptional<z.ZodString>;
|
|
59
|
+
ending_before: z.ZodOptional<z.ZodString>;
|
|
60
|
+
created: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>, z.ZodTransform<RangeFilter, number>>, z.ZodPipe<z.ZodObject<{
|
|
61
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
62
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
63
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
64
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
65
|
+
}, z.core.$strict>, z.ZodTransform<RangeFilter, {
|
|
66
|
+
gt?: number | undefined;
|
|
67
|
+
gte?: number | undefined;
|
|
68
|
+
lt?: number | undefined;
|
|
69
|
+
lte?: number | undefined;
|
|
70
|
+
}>>]>>;
|
|
71
|
+
expand: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A list query: the shared parameters plus the route's own filters.
|
|
75
|
+
*
|
|
76
|
+
* `.strict()`: an unknown parameter is a 400 naming it, never silently ignored
|
|
77
|
+
* — `?stauts=settled` answering every intent is a filter the caller believes
|
|
78
|
+
* they applied.
|
|
79
|
+
*/
|
|
80
|
+
export declare function listQuery<S extends z.ZodRawShape>(filters: S): z.ZodObject<{
|
|
81
|
+
limit: z.ZodPipe<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>, z.ZodTransform<number, number | undefined>>;
|
|
82
|
+
starting_after: z.ZodOptional<z.ZodString>;
|
|
83
|
+
ending_before: z.ZodOptional<z.ZodString>;
|
|
84
|
+
created: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>, z.ZodTransform<RangeFilter, number>>, z.ZodPipe<z.ZodObject<{
|
|
85
|
+
gt: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
86
|
+
gte: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
87
|
+
lt: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
88
|
+
lte: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>;
|
|
89
|
+
}, z.core.$strict>, z.ZodTransform<RangeFilter, {
|
|
90
|
+
gt?: number | undefined;
|
|
91
|
+
gte?: number | undefined;
|
|
92
|
+
lt?: number | undefined;
|
|
93
|
+
lte?: number | undefined;
|
|
94
|
+
}>>]>>;
|
|
95
|
+
expand: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>;
|
|
96
|
+
} & S extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strict>;
|
|
97
|
+
/** A retrieve's query: `expand[]` and nothing else unless the route says so. */
|
|
98
|
+
export declare function retrieveQuery<S extends z.ZodRawShape>(extra: S): z.ZodObject<{
|
|
99
|
+
expand: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>;
|
|
100
|
+
} & S extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strict>;
|
|
101
|
+
/** The query of a route that takes `expand[]` only. */
|
|
102
|
+
export declare const expandOnlyQuery: z.ZodObject<{
|
|
103
|
+
expand: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
/** The query of a route that takes no parameters at all. */
|
|
106
|
+
export declare const emptyQuery: z.ZodObject<{}, z.core.$strict>;
|
|
107
|
+
/** The parameters every `GET /v1/<objects>/search` accepts. */
|
|
108
|
+
export declare const searchShape: {
|
|
109
|
+
query: z.ZodString;
|
|
110
|
+
limit: z.ZodPipe<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>, z.ZodTransform<number, number | undefined>>;
|
|
111
|
+
page: z.ZodOptional<z.ZodString>;
|
|
112
|
+
expand: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>;
|
|
113
|
+
};
|
|
114
|
+
/** A search query. */
|
|
115
|
+
export declare const searchQuery: z.ZodObject<{
|
|
116
|
+
query: z.ZodString;
|
|
117
|
+
limit: z.ZodPipe<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>, z.ZodNumber>>, z.ZodTransform<number, number | undefined>>;
|
|
118
|
+
page: z.ZodOptional<z.ZodString>;
|
|
119
|
+
expand: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>, z.ZodArray<z.ZodString>>>;
|
|
120
|
+
}, z.core.$strict>;
|
|
121
|
+
/** The parameters every list accepts, as a caller sends them. */
|
|
122
|
+
export type ListParams = z.input<ReturnType<typeof listQuery<Record<never, z.ZodType>>>>;
|
|
123
|
+
/** A Unix-seconds range as a caller sends it: bounds, each optional. */
|
|
124
|
+
export type RangeQuery = Extract<z.input<typeof rangeParam>, object>;
|
|
125
|
+
/** The parameter a single read or write accepts to expand its answer. */
|
|
126
|
+
export interface ExpandParams {
|
|
127
|
+
/** Dot paths, at most four levels deep (`['payment_intent.connected_account']`). */
|
|
128
|
+
expand?: string[];
|
|
129
|
+
}
|
|
130
|
+
/** The parameters every search accepts, as a caller sends them. */
|
|
131
|
+
export type SearchParams = z.input<typeof searchQuery>;
|
|
132
|
+
export declare const METADATA_MAX_KEYS = 50;
|
|
133
|
+
export declare const METADATA_KEY_MAX = 40;
|
|
134
|
+
export declare const METADATA_VALUE_MAX = 500;
|
|
135
|
+
/** A metadata update, as the repository applies it. */
|
|
136
|
+
export interface MetadataPatch {
|
|
137
|
+
readonly set: Record<string, string>;
|
|
138
|
+
readonly unset: readonly string[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The bag a create stores. Empty values are dropped: there is nothing to unset
|
|
142
|
+
* yet.
|
|
143
|
+
*/
|
|
144
|
+
export declare const metadataCreateParam: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<Record<string, string>, Record<string, string>>>;
|
|
145
|
+
/**
|
|
146
|
+
* The patch an update applies: named keys are set, a key sent as `""` is
|
|
147
|
+
* removed, keys not named are kept. The 50-key limit is then judged on the
|
|
148
|
+
* merged result, which only the database can see.
|
|
149
|
+
*/
|
|
150
|
+
export declare const metadataUpdateParam: z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<MetadataPatch, Record<string, string>>>;
|
|
151
|
+
/** The answer when the MERGED bag would exceed the key limit. */
|
|
152
|
+
export declare const METADATA_LIMIT_MESSAGE = "metadata holds at most 50 keys";
|
|
153
|
+
/** `""` clears a field on an update, Stripe's rule. */
|
|
154
|
+
export declare const clearable: <T extends z.ZodType>(schema: T) => z.ZodUnion<readonly [T, z.ZodLiteral<"">]>;
|
|
155
|
+
/** Bounded text. */
|
|
156
|
+
export declare const text: (max: number) => z.ZodString;
|