@peable.to/contracts 0.4.0 → 1.1.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/dashboard.js +68 -0
- package/dist/cjs/vocabulary/errors.js +175 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/identity.js +12 -0
- package/dist/cjs/vocabulary/index.js +39 -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/dashboard.js +64 -0
- package/dist/esm/vocabulary/errors.js +170 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/identity.js +9 -0
- package/dist/esm/vocabulary/index.js +23 -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/dashboard.d.ts +44 -0
- package/dist/types/vocabulary/errors.d.ts +146 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/identity.d.ts +9 -0
- package/dist/types/vocabulary/index.d.ts +19 -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,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emailParam = exports.shippingParams = exports.addressParams = exports.shippingSchema = exports.addressSchema = void 0;
|
|
4
|
+
exports.toAddress = toAddress;
|
|
5
|
+
exports.toShipping = toShipping;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const objects_1 = require("./objects");
|
|
8
|
+
/**
|
|
9
|
+
* Stripe's address and shipping shapes — as returned (every field present,
|
|
10
|
+
* `null` when not given) and as a request carries them (every field optional).
|
|
11
|
+
* Shared by every object that holds one: intents, customers, payment methods,
|
|
12
|
+
* checkout sessions.
|
|
13
|
+
*/
|
|
14
|
+
exports.addressSchema = zod_1.z
|
|
15
|
+
.object({
|
|
16
|
+
line1: zod_1.z.string().nullable(),
|
|
17
|
+
line2: zod_1.z.string().nullable(),
|
|
18
|
+
city: zod_1.z.string().nullable(),
|
|
19
|
+
state: zod_1.z.string().nullable(),
|
|
20
|
+
postal_code: zod_1.z.string().nullable(),
|
|
21
|
+
country: zod_1.z.string().nullable().describe('ISO 3166-1 alpha-2.'),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
objects_1.contractRegistry.add(exports.addressSchema, { id: 'Address' });
|
|
25
|
+
exports.shippingSchema = zod_1.z
|
|
26
|
+
.object({
|
|
27
|
+
name: zod_1.z.string(),
|
|
28
|
+
phone: zod_1.z.string().nullable(),
|
|
29
|
+
address: exports.addressSchema,
|
|
30
|
+
carrier: zod_1.z.string().nullable(),
|
|
31
|
+
tracking_number: zod_1.z.string().nullable(),
|
|
32
|
+
})
|
|
33
|
+
.strict();
|
|
34
|
+
objects_1.contractRegistry.add(exports.shippingSchema, { id: 'Shipping' });
|
|
35
|
+
const line = zod_1.z.string().max(500);
|
|
36
|
+
/** An address as a request carries it: every field optional. */
|
|
37
|
+
exports.addressParams = zod_1.z
|
|
38
|
+
.object({
|
|
39
|
+
line1: line.optional(),
|
|
40
|
+
line2: line.optional(),
|
|
41
|
+
city: line.optional(),
|
|
42
|
+
state: line.optional(),
|
|
43
|
+
postal_code: zod_1.z.string().max(40).optional(),
|
|
44
|
+
country: zod_1.z
|
|
45
|
+
.string()
|
|
46
|
+
.regex(/^[A-Z]{2}$/, 'country must be an ISO 3166-1 alpha-2 code')
|
|
47
|
+
.optional(),
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
/** Shipping as a request carries it: only `name` and `address` are required. */
|
|
51
|
+
exports.shippingParams = zod_1.z
|
|
52
|
+
.object({
|
|
53
|
+
name: zod_1.z.string().min(1).max(500),
|
|
54
|
+
phone: zod_1.z.string().max(40).optional(),
|
|
55
|
+
address: exports.addressParams,
|
|
56
|
+
carrier: zod_1.z.string().max(200).optional(),
|
|
57
|
+
tracking_number: zod_1.z.string().max(200).optional(),
|
|
58
|
+
})
|
|
59
|
+
.strict();
|
|
60
|
+
exports.emailParam = zod_1.z.email().max(512);
|
|
61
|
+
/** A request address in the stored (and wire) shape: every field present. */
|
|
62
|
+
function toAddress(input) {
|
|
63
|
+
return {
|
|
64
|
+
line1: input.line1 ?? null,
|
|
65
|
+
line2: input.line2 ?? null,
|
|
66
|
+
city: input.city ?? null,
|
|
67
|
+
state: input.state ?? null,
|
|
68
|
+
postal_code: input.postal_code ?? null,
|
|
69
|
+
country: input.country ?? null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Request shipping in the stored (and wire) shape. */
|
|
73
|
+
function toShipping(input) {
|
|
74
|
+
return {
|
|
75
|
+
name: input.name,
|
|
76
|
+
phone: input.phone ?? null,
|
|
77
|
+
address: toAddress(input.address),
|
|
78
|
+
carrier: input.carrier ?? null,
|
|
79
|
+
tracking_number: input.tracking_number ?? null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorEnvelopeSchema = exports.apiErrorSchema = void 0;
|
|
4
|
+
exports.listOf = listOf;
|
|
5
|
+
exports.searchResultOf = searchResultOf;
|
|
6
|
+
exports.deletedOf = deletedOf;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const errors_1 = require("../vocabulary/errors");
|
|
9
|
+
const objects_1 = require("./objects");
|
|
10
|
+
/**
|
|
11
|
+
* The envelopes every resource shares (ADR 0014 D1): the list, the search
|
|
12
|
+
* result, the deleted tombstone and the error.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* One page of a list, newest first. `url` is the path that was listed, so a
|
|
16
|
+
* page carries enough to fetch the next one without the caller remembering
|
|
17
|
+
* where it came from.
|
|
18
|
+
*/
|
|
19
|
+
function listOf(item) {
|
|
20
|
+
return zod_1.z
|
|
21
|
+
.object({
|
|
22
|
+
object: zod_1.z.literal('list'),
|
|
23
|
+
data: zod_1.z.array(item),
|
|
24
|
+
has_more: zod_1.z
|
|
25
|
+
.boolean()
|
|
26
|
+
.describe('Whether another page exists in the direction this one was read.'),
|
|
27
|
+
url: zod_1.z.string().describe('The path that was listed.'),
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One page of a search. Pages FORWARD only, by an opaque `next_page` token
|
|
33
|
+
* passed back as `page`, bound to the query it came from.
|
|
34
|
+
*/
|
|
35
|
+
function searchResultOf(item) {
|
|
36
|
+
return zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
object: zod_1.z.literal('search_result'),
|
|
39
|
+
data: zod_1.z.array(item),
|
|
40
|
+
has_more: zod_1.z.boolean(),
|
|
41
|
+
next_page: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.nullable()
|
|
44
|
+
.describe('Pass as `page` for the next page; `null` on the last one.'),
|
|
45
|
+
url: zod_1.z.string().describe('The path that was searched.'),
|
|
46
|
+
total_count: zod_1.z
|
|
47
|
+
.number()
|
|
48
|
+
.int()
|
|
49
|
+
.nonnegative()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Present only when asked for with `expand[]=total_count`.'),
|
|
52
|
+
})
|
|
53
|
+
.strict();
|
|
54
|
+
}
|
|
55
|
+
/** A deleted object, as its `DELETE` answers: `{id, object, deleted: true}`. */
|
|
56
|
+
function deletedOf(object) {
|
|
57
|
+
return zod_1.z.object({ id: zod_1.z.string(), object: zod_1.z.literal(object), deleted: zod_1.z.literal(true) }).strict();
|
|
58
|
+
}
|
|
59
|
+
/** The error object inside every non-2xx answer. */
|
|
60
|
+
exports.apiErrorSchema = zod_1.z
|
|
61
|
+
.object({
|
|
62
|
+
type: zod_1.z.enum(errors_1.ERROR_TYPES).describe('The broad class a caller branches on first.'),
|
|
63
|
+
// A string rather than the closed `ERROR_CODES`: a `card_error` carries the
|
|
64
|
+
// provider's decline code (`insufficient_funds`, `expired_card`, …), which
|
|
65
|
+
// Peable passes through. Every code Peable itself answers with is an
|
|
66
|
+
// `ErrorCode` (the backend's `sendError` takes nothing else).
|
|
67
|
+
code: zod_1.z
|
|
68
|
+
.string()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe(`The machine-readable reason (one of ${String(errors_1.ERROR_CODES.length)} documented at ${errors_1.ERROR_DOCS_BASE_URL}, or a card network's decline code on a \`card_error\`).`),
|
|
71
|
+
decline_code: zod_1.z
|
|
72
|
+
.string()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("A card issuer's decline reason, on a `card_error`."),
|
|
75
|
+
param: zod_1.z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('The offending request field, in bracket notation (`metadata[order_id]`).'),
|
|
79
|
+
message: zod_1.z.string().describe('A human-readable message, for a developer.'),
|
|
80
|
+
doc_url: zod_1.z.url().optional().describe('The documentation of `code`.'),
|
|
81
|
+
request_id: zod_1.z.string().nullable().describe('The `Request-Id` of this response, for support.'),
|
|
82
|
+
payment_intent: zod_1.z
|
|
83
|
+
.lazy(() => (0, objects_1.resolveObject)('payment_intent'))
|
|
84
|
+
.optional()
|
|
85
|
+
.describe('On a `card_error` from a confirm or an invoice payment: the PaymentIntent, as it now is.'),
|
|
86
|
+
invoice: zod_1.z
|
|
87
|
+
.lazy(() => (0, objects_1.resolveObject)('invoice'))
|
|
88
|
+
.optional()
|
|
89
|
+
.describe('On a failed invoice payment: the invoice, as it now is.'),
|
|
90
|
+
refresh_url: zod_1.z
|
|
91
|
+
.url()
|
|
92
|
+
.optional()
|
|
93
|
+
.describe('On an expired onboarding link: where the seller gets a fresh one.'),
|
|
94
|
+
})
|
|
95
|
+
.strict();
|
|
96
|
+
/** `{ error: {...} }` — every non-2xx answer. */
|
|
97
|
+
exports.errorEnvelopeSchema = zod_1.z.object({ error: exports.apiErrorSchema }).strict();
|
|
98
|
+
objects_1.contractRegistry.add(exports.errorEnvelopeSchema, {
|
|
99
|
+
id: 'Error',
|
|
100
|
+
description: 'Every non-2xx answer. The HTTP status and `error.type` identify the failure.',
|
|
101
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contractRegistry = void 0;
|
|
4
|
+
exports.defineObject = defineObject;
|
|
5
|
+
exports.defineComponent = defineComponent;
|
|
6
|
+
exports.objectSchema = objectSchema;
|
|
7
|
+
exports.resolveObject = resolveObject;
|
|
8
|
+
exports.objectTypes = objectTypes;
|
|
9
|
+
exports.expandable = expandable;
|
|
10
|
+
exports.embedded = embedded;
|
|
11
|
+
exports.describe = describe;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
/** The one registry every contract schema's metadata lives in. */
|
|
14
|
+
exports.contractRegistry = zod_1.z.registry();
|
|
15
|
+
const objectSchemas = new Map();
|
|
16
|
+
/**
|
|
17
|
+
* Register a wire object: its `object` value (the key references use) and its
|
|
18
|
+
* component name. Returns the schema so a definition reads as one expression.
|
|
19
|
+
*/
|
|
20
|
+
function defineObject(type, id, schema, meta = {}) {
|
|
21
|
+
if (objectSchemas.has(type))
|
|
22
|
+
throw new Error(`object type '${type}' is defined twice`);
|
|
23
|
+
objectSchemas.set(type, schema);
|
|
24
|
+
exports.contractRegistry.add(schema, { id, ...meta });
|
|
25
|
+
return schema;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Register a named schema that is not an expandable object — a tombstone, a
|
|
29
|
+
* shared sub-object, a polymorphic payload — as `#/components/schemas/<id>`.
|
|
30
|
+
*/
|
|
31
|
+
function defineComponent(id, schema, meta = {}) {
|
|
32
|
+
exports.contractRegistry.add(schema, { id, ...meta });
|
|
33
|
+
return schema;
|
|
34
|
+
}
|
|
35
|
+
/** The registered schema of `type`, or `undefined`. */
|
|
36
|
+
function objectSchema(type) {
|
|
37
|
+
return objectSchemas.get(type);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The registered schema of `type`. Resolved lazily (a reference is declared
|
|
41
|
+
* before the module defining its target has loaded), and loud when nothing
|
|
42
|
+
* registers it: a reference to an unknown object is a contract bug.
|
|
43
|
+
*/
|
|
44
|
+
function resolveObject(type) {
|
|
45
|
+
const schema = objectSchemas.get(type);
|
|
46
|
+
if (!schema)
|
|
47
|
+
throw new Error(`no wire object is registered as '${type}'`);
|
|
48
|
+
return schema;
|
|
49
|
+
}
|
|
50
|
+
/** Every registered object type, in registration order. */
|
|
51
|
+
function objectTypes() {
|
|
52
|
+
return [...objectSchemas.keys()];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A reference `expand[]` can replace: the id (`cus_…`) or, expanded, the
|
|
56
|
+
* object. The naming rule (`lib/expand.ts` in the backend): an expandable
|
|
57
|
+
* reference is spelled WITHOUT `_id`, and a field without `_id` that is not
|
|
58
|
+
* expandable is a bug.
|
|
59
|
+
*/
|
|
60
|
+
function expandable(type, description) {
|
|
61
|
+
const resolved = zod_1.z.lazy(() => resolveObject(type));
|
|
62
|
+
const union = zod_1.z.union([zod_1.z.string(), resolved]);
|
|
63
|
+
exports.contractRegistry.add(union, {
|
|
64
|
+
'x-peable-expandable': type,
|
|
65
|
+
...(description === undefined ? {} : { description }),
|
|
66
|
+
});
|
|
67
|
+
return union;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A field that always carries the FULL object `type` names (never an id): a
|
|
71
|
+
* subscription item's `price`, a payer view's `payment_intent`, a report run's
|
|
72
|
+
* result `file`. Validated against the registered schema and typed through
|
|
73
|
+
* {@link Ref}, so {@link Expand} resolves it to that object's wire type.
|
|
74
|
+
*/
|
|
75
|
+
function embedded(type, description) {
|
|
76
|
+
const schema = zod_1.z.lazy(() => resolveObject(type));
|
|
77
|
+
return (description === undefined
|
|
78
|
+
? schema
|
|
79
|
+
: schema.describe(description));
|
|
80
|
+
}
|
|
81
|
+
/** Attach OpenAPI metadata to a schema without changing its type. */
|
|
82
|
+
function describe(schema, meta) {
|
|
83
|
+
exports.contractRegistry.add(schema, { ...exports.contractRegistry.get(schema), ...meta });
|
|
84
|
+
return schema;
|
|
85
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.text = exports.clearable = exports.METADATA_LIMIT_MESSAGE = exports.metadataUpdateParam = exports.metadataCreateParam = exports.METADATA_VALUE_MAX = exports.METADATA_KEY_MAX = exports.METADATA_MAX_KEYS = exports.searchQuery = exports.searchShape = exports.emptyQuery = exports.expandOnlyQuery = exports.listShape = exports.limitParam = exports.idParam = exports.cursorParam = exports.expandParam = exports.rangeParam = exports.queryUnixSeconds = exports.unixSecondsParam = exports.MAX_UNIX_SECONDS = exports.queryBoolean = void 0;
|
|
4
|
+
exports.queryInteger = queryInteger;
|
|
5
|
+
exports.listQuery = listQuery;
|
|
6
|
+
exports.retrieveQuery = retrieveQuery;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const lists_1 = require("../vocabulary/lists");
|
|
9
|
+
const objects_1 = require("./objects");
|
|
10
|
+
/**
|
|
11
|
+
* Request-side building blocks (ADR 0014 D1).
|
|
12
|
+
*
|
|
13
|
+
* A request schema has two sides and both matter:
|
|
14
|
+
*
|
|
15
|
+
* - its INPUT (`z.input`) is the wire — what a caller sends, what the SDK's
|
|
16
|
+
* parameter types are, and what the OpenAPI document describes;
|
|
17
|
+
* - its OUTPUT (`z.output`) is what a backend handler receives once parsed —
|
|
18
|
+
* a query integer as a `number`, `expand` always an array, a metadata update
|
|
19
|
+
* as a `{ set, unset }` patch.
|
|
20
|
+
*
|
|
21
|
+
* So the transforms live HERE, beside the shape, and the backend never
|
|
22
|
+
* re-parses what a contract already decided.
|
|
23
|
+
*/
|
|
24
|
+
/** Attach the JSON Schema a node is documented with when its input side is not the wire's spelling. */
|
|
25
|
+
function documentedAs(schema, jsonSchema) {
|
|
26
|
+
objects_1.contractRegistry.add(schema, { ...objects_1.contractRegistry.get(schema), jsonSchema });
|
|
27
|
+
return schema;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* An integer in a query string. Arrives as a string from a URL, as a number
|
|
31
|
+
* from a typed caller; both are the same request.
|
|
32
|
+
*/
|
|
33
|
+
function queryInteger(bounds = {}) {
|
|
34
|
+
let target = zod_1.z.number().int();
|
|
35
|
+
if (bounds.min !== undefined)
|
|
36
|
+
target = target.min(bounds.min);
|
|
37
|
+
if (bounds.max !== undefined)
|
|
38
|
+
target = target.max(bounds.max);
|
|
39
|
+
return documentedAs(zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).transform(Number).pipe(target), {
|
|
40
|
+
type: 'integer',
|
|
41
|
+
...(bounds.min === undefined ? {} : { minimum: bounds.min }),
|
|
42
|
+
...(bounds.max === undefined ? {} : { maximum: bounds.max }),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** `true` / `false` in a query string (or a real boolean from a typed caller). */
|
|
46
|
+
exports.queryBoolean = documentedAs(zod_1.z.union([zod_1.z.boolean(), zod_1.z.enum(['true', 'false'])]).transform((v) => v === true || v === 'true'), { type: 'boolean' });
|
|
47
|
+
/** The latest representable instant (9999-12-31T23:59:59Z), the bound of every Unix-seconds parameter. */
|
|
48
|
+
exports.MAX_UNIX_SECONDS = 253402300799;
|
|
49
|
+
/** Unix seconds in a body. */
|
|
50
|
+
exports.unixSecondsParam = zod_1.z.number().int().min(0).max(exports.MAX_UNIX_SECONDS);
|
|
51
|
+
/** Unix seconds in a query string. */
|
|
52
|
+
exports.queryUnixSeconds = queryInteger({ min: 0, max: exports.MAX_UNIX_SECONDS });
|
|
53
|
+
/**
|
|
54
|
+
* `created=X` (exactly that second) or `created[gt|gte|lt|lte]=X`. The bare
|
|
55
|
+
* form is normalized to the range `[X, X]` so the repository reads one shape.
|
|
56
|
+
*/
|
|
57
|
+
exports.rangeParam = documentedAs(zod_1.z.union([
|
|
58
|
+
exports.queryUnixSeconds.transform((x) => ({ gte: x, lte: x })),
|
|
59
|
+
zod_1.z
|
|
60
|
+
.object({
|
|
61
|
+
gt: exports.queryUnixSeconds.optional(),
|
|
62
|
+
gte: exports.queryUnixSeconds.optional(),
|
|
63
|
+
lt: exports.queryUnixSeconds.optional(),
|
|
64
|
+
lte: exports.queryUnixSeconds.optional(),
|
|
65
|
+
})
|
|
66
|
+
.strict()
|
|
67
|
+
.transform((range) => range),
|
|
68
|
+
]), {
|
|
69
|
+
description: 'Unix seconds: exactly one second, or a range with `gt`, `gte`, `lt`, `lte`.',
|
|
70
|
+
oneOf: [
|
|
71
|
+
{ type: 'integer', minimum: 0 },
|
|
72
|
+
{
|
|
73
|
+
type: 'object',
|
|
74
|
+
additionalProperties: false,
|
|
75
|
+
properties: {
|
|
76
|
+
gt: { type: 'integer', minimum: 0 },
|
|
77
|
+
gte: { type: 'integer', minimum: 0 },
|
|
78
|
+
lt: { type: 'integer', minimum: 0 },
|
|
79
|
+
lte: { type: 'integer', minimum: 0 },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* `expand[]=a&expand[]=b` arrives as an array; `expand=a` as a string. Both
|
|
86
|
+
* mean the same request. Dot paths, at most four levels; on a list every path
|
|
87
|
+
* starts with `data.`.
|
|
88
|
+
*/
|
|
89
|
+
exports.expandParam = documentedAs(zod_1.z
|
|
90
|
+
.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
|
|
91
|
+
.transform((value) => (typeof value === 'string' ? [value] : value))
|
|
92
|
+
.pipe(zod_1.z.array(zod_1.z.string().min(1).max(200)).max(20)), {
|
|
93
|
+
type: 'array',
|
|
94
|
+
items: { type: 'string', maxLength: 200 },
|
|
95
|
+
maxItems: 20,
|
|
96
|
+
description: 'Dot paths of references to replace with the objects they name (at most four levels; `data.`-prefixed on a list).',
|
|
97
|
+
});
|
|
98
|
+
/** The public id of a cursor. Bounded so a cursor is never an unbounded index probe. */
|
|
99
|
+
exports.cursorParam = zod_1.z.string().min(1).max(255);
|
|
100
|
+
/** An object id in a body or query. */
|
|
101
|
+
exports.idParam = zod_1.z.string().min(1).max(255);
|
|
102
|
+
/** The list limit: 1–100, default 10. */
|
|
103
|
+
exports.limitParam = documentedAs(zod_1.z
|
|
104
|
+
.union([zod_1.z.number(), zod_1.z.string()])
|
|
105
|
+
.transform(Number)
|
|
106
|
+
.pipe(zod_1.z.number().int().min(1).max(lists_1.LIST_LIMIT_MAX))
|
|
107
|
+
.optional()
|
|
108
|
+
.transform((value) => value ?? lists_1.LIST_LIMIT_DEFAULT), { type: 'integer', minimum: 1, maximum: lists_1.LIST_LIMIT_MAX, default: lists_1.LIST_LIMIT_DEFAULT });
|
|
109
|
+
/** The parameters every list accepts. */
|
|
110
|
+
exports.listShape = {
|
|
111
|
+
limit: exports.limitParam,
|
|
112
|
+
starting_after: exports.cursorParam
|
|
113
|
+
.optional()
|
|
114
|
+
.describe('The id of the LAST object of the previous page: the next page is older.'),
|
|
115
|
+
ending_before: exports.cursorParam
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('The id of the FIRST object of the current page: the page returned is newer.'),
|
|
118
|
+
created: exports.rangeParam.optional(),
|
|
119
|
+
expand: exports.expandParam.optional(),
|
|
120
|
+
};
|
|
121
|
+
function refuseBothCursors(query, ctx) {
|
|
122
|
+
if (query.starting_after !== undefined && query.ending_before !== undefined) {
|
|
123
|
+
ctx.addIssue({
|
|
124
|
+
code: 'custom',
|
|
125
|
+
path: ['ending_before'],
|
|
126
|
+
message: 'starting_after and ending_before are mutually exclusive',
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A list query: the shared parameters plus the route's own filters.
|
|
132
|
+
*
|
|
133
|
+
* `.strict()`: an unknown parameter is a 400 naming it, never silently ignored
|
|
134
|
+
* — `?stauts=settled` answering every intent is a filter the caller believes
|
|
135
|
+
* they applied.
|
|
136
|
+
*/
|
|
137
|
+
function listQuery(filters) {
|
|
138
|
+
return zod_1.z
|
|
139
|
+
.object({ ...exports.listShape, ...filters })
|
|
140
|
+
.strict()
|
|
141
|
+
.superRefine((query, ctx) => refuseBothCursors(query, ctx));
|
|
142
|
+
}
|
|
143
|
+
/** A retrieve's query: `expand[]` and nothing else unless the route says so. */
|
|
144
|
+
function retrieveQuery(extra) {
|
|
145
|
+
return zod_1.z.object({ expand: exports.expandParam.optional(), ...extra }).strict();
|
|
146
|
+
}
|
|
147
|
+
/** The query of a route that takes `expand[]` only. */
|
|
148
|
+
exports.expandOnlyQuery = retrieveQuery({});
|
|
149
|
+
/** The query of a route that takes no parameters at all. */
|
|
150
|
+
exports.emptyQuery = zod_1.z.object({}).strict();
|
|
151
|
+
/** The parameters every `GET /v1/<objects>/search` accepts. */
|
|
152
|
+
exports.searchShape = {
|
|
153
|
+
query: zod_1.z
|
|
154
|
+
.string({ error: 'query is required' })
|
|
155
|
+
.min(1, 'query is required')
|
|
156
|
+
.max(lists_1.SEARCH_QUERY_MAX_LENGTH, `a query is at most ${String(lists_1.SEARCH_QUERY_MAX_LENGTH)} characters`)
|
|
157
|
+
.describe('Stripe\'s search query language: `email:"jenny@example.com"`, `amount>1000 AND currency:"EUR"`, `metadata[\'order_id\']:\'6735\'`, `name~"shirt"`, `-status:"canceled"`, `customer:null`.'),
|
|
158
|
+
limit: exports.limitParam,
|
|
159
|
+
page: zod_1.z
|
|
160
|
+
.string()
|
|
161
|
+
.min(1)
|
|
162
|
+
.max(512)
|
|
163
|
+
.optional()
|
|
164
|
+
.describe('The `next_page` of the previous page, with the SAME query.'),
|
|
165
|
+
expand: exports.expandParam.optional(),
|
|
166
|
+
};
|
|
167
|
+
/** A search query. */
|
|
168
|
+
exports.searchQuery = zod_1.z.object(exports.searchShape).strict();
|
|
169
|
+
exports.METADATA_MAX_KEYS = 50;
|
|
170
|
+
exports.METADATA_KEY_MAX = 40;
|
|
171
|
+
exports.METADATA_VALUE_MAX = 500;
|
|
172
|
+
const metadataKey = zod_1.z
|
|
173
|
+
.string()
|
|
174
|
+
.min(1, 'metadata keys cannot be empty')
|
|
175
|
+
.max(exports.METADATA_KEY_MAX, `metadata keys are at most ${exports.METADATA_KEY_MAX} characters`)
|
|
176
|
+
// A key is quoted back in bracket notation (`metadata[order_id]`) in every
|
|
177
|
+
// error's `param`; a key containing brackets would make that ambiguous.
|
|
178
|
+
.refine((key) => !/[[\]]/.test(key), 'metadata keys cannot contain square brackets');
|
|
179
|
+
const metadataValue = zod_1.z
|
|
180
|
+
.string()
|
|
181
|
+
.max(exports.METADATA_VALUE_MAX, `metadata values are at most ${exports.METADATA_VALUE_MAX} characters`);
|
|
182
|
+
const metadataBag = zod_1.z
|
|
183
|
+
.record(metadataKey, metadataValue)
|
|
184
|
+
.refine((bag) => Object.keys(bag).length <= exports.METADATA_MAX_KEYS, `metadata holds at most ${exports.METADATA_MAX_KEYS} keys`)
|
|
185
|
+
.describe('At most 50 keys; keys ≤ 40 characters, values ≤ 500.');
|
|
186
|
+
/**
|
|
187
|
+
* The bag a create stores. Empty values are dropped: there is nothing to unset
|
|
188
|
+
* yet.
|
|
189
|
+
*/
|
|
190
|
+
exports.metadataCreateParam = metadataBag.transform((bag) => Object.fromEntries(Object.entries(bag).filter(([, value]) => value !== '')));
|
|
191
|
+
/**
|
|
192
|
+
* The patch an update applies: named keys are set, a key sent as `""` is
|
|
193
|
+
* removed, keys not named are kept. The 50-key limit is then judged on the
|
|
194
|
+
* merged result, which only the database can see.
|
|
195
|
+
*/
|
|
196
|
+
exports.metadataUpdateParam = metadataBag
|
|
197
|
+
.transform((bag) => ({
|
|
198
|
+
set: Object.fromEntries(Object.entries(bag).filter(([, value]) => value !== '')),
|
|
199
|
+
unset: Object.entries(bag)
|
|
200
|
+
.filter(([, value]) => value === '')
|
|
201
|
+
.map(([key]) => key),
|
|
202
|
+
}))
|
|
203
|
+
.describe('A patch: named keys are set, a key sent as `""` is removed, others are kept.');
|
|
204
|
+
/** The answer when the MERGED bag would exceed the key limit. */
|
|
205
|
+
exports.METADATA_LIMIT_MESSAGE = `metadata holds at most ${exports.METADATA_MAX_KEYS} keys`;
|
|
206
|
+
/** `""` clears a field on an update, Stripe's rule. */
|
|
207
|
+
const clearable = (schema) => zod_1.z.union([schema, zod_1.z.literal('')]);
|
|
208
|
+
exports.clearable = clearable;
|
|
209
|
+
/** Bounded text. */
|
|
210
|
+
const text = (max) => zod_1.z.string().max(max);
|
|
211
|
+
exports.text = text;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectName = exports.nullableString = exports.metadata = exports.livemode = exports.network = exports.fiatCurrency = exports.currency = exports.signedAmount = exports.amount = exports.unixSeconds = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const money_1 = require("../vocabulary/money");
|
|
6
|
+
/**
|
|
7
|
+
* The house style's primitives (ADR 0014 D1), as RESPONSE schemas: what the
|
|
8
|
+
* gateway emits. Request-side building blocks (coercing query integers,
|
|
9
|
+
* `expand[]`, metadata patches) are in `params.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/** Every instant on the wire: integer Unix seconds. */
|
|
12
|
+
exports.unixSeconds = zod_1.z.number().int().nonnegative().describe('Unix seconds.');
|
|
13
|
+
/** A base-unit amount: an integer string in the currency's smallest unit (a FAIR amount does not fit a JS number). */
|
|
14
|
+
exports.amount = zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.regex(money_1.BASE_UNIT_PATTERN)
|
|
17
|
+
.describe('Base units of `currency`, as an integer string (cents for EUR, m⊜ for FAIR).');
|
|
18
|
+
/** A signed base-unit amount (a customer balance, a balance transaction's net). */
|
|
19
|
+
exports.signedAmount = zod_1.z
|
|
20
|
+
.string()
|
|
21
|
+
.regex(money_1.SIGNED_BASE_UNIT_PATTERN)
|
|
22
|
+
.describe('Signed base units of `currency`, as an integer string.');
|
|
23
|
+
/** An uppercase ISO 4217 code, or `FAIR`. */
|
|
24
|
+
exports.currency = zod_1.z.enum(money_1.CURRENCY_CODES).describe('Uppercase ISO 4217 code, or `FAIR`.');
|
|
25
|
+
/** A currency the card rail can denominate in. */
|
|
26
|
+
exports.fiatCurrency = zod_1.z.enum(money_1.FIAT_CURRENCY_CODES);
|
|
27
|
+
/** The FairCoin network. */
|
|
28
|
+
exports.network = zod_1.z.enum(money_1.NETWORK_TYPES);
|
|
29
|
+
/** Whether the object exists in live mode (`false`: test mode). */
|
|
30
|
+
exports.livemode = zod_1.z.boolean().describe('`true` in live mode, `false` in test mode.');
|
|
31
|
+
/** The merchant's own key/value bag, as returned. */
|
|
32
|
+
exports.metadata = zod_1.z
|
|
33
|
+
.record(zod_1.z.string(), zod_1.z.string())
|
|
34
|
+
.describe('Your own key/value pairs: at most 50 keys, keys ≤ 40 characters, values ≤ 500.');
|
|
35
|
+
/** A nullable string — the shape of every optional text field on a response. */
|
|
36
|
+
exports.nullableString = zod_1.z.string().nullable();
|
|
37
|
+
/** A literal `object` discriminator. */
|
|
38
|
+
const objectName = (name) => zod_1.z.literal(name);
|
|
39
|
+
exports.objectName = objectName;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatContributionAmount = exports.decimalContributionAmount = exports.createContributionSchema = exports.contributionScopeQuerySchema = exports.contributionPatchSchema = exports.contributionPageQuerySchema = exports.contributionOperationKeySchema = exports.contributionMintSchema = exports.contributionListSchema = exports.contributionLinkSchema = exports.contributionDetailsSchema = exports.contributionCollectionSchema = exports.contributionCollectionListSchema = exports.contributionAmountSchema = void 0;
|
|
4
|
+
// `@peable.to/contracts/contributions` — the contribution schemas and FAIR
|
|
5
|
+
// amount helpers, without the rest of the API's schemas: the hosted checkout
|
|
6
|
+
// and Orbit import this subpath at runtime. The contracts themselves live in
|
|
7
|
+
// `resources/checkout/contributions.ts`, beside the other checkout routes.
|
|
8
|
+
var contributions_1 = require("./resources/checkout/contributions");
|
|
9
|
+
Object.defineProperty(exports, "contributionAmountSchema", { enumerable: true, get: function () { return contributions_1.contributionAmountSchema; } });
|
|
10
|
+
Object.defineProperty(exports, "contributionCollectionListSchema", { enumerable: true, get: function () { return contributions_1.contributionCollectionListSchema; } });
|
|
11
|
+
Object.defineProperty(exports, "contributionCollectionSchema", { enumerable: true, get: function () { return contributions_1.contributionCollectionSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "contributionDetailsSchema", { enumerable: true, get: function () { return contributions_1.contributionDetailsSchema; } });
|
|
13
|
+
Object.defineProperty(exports, "contributionLinkSchema", { enumerable: true, get: function () { return contributions_1.contributionLinkSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "contributionListSchema", { enumerable: true, get: function () { return contributions_1.contributionListSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "contributionMintSchema", { enumerable: true, get: function () { return contributions_1.contributionMintSchema; } });
|
|
16
|
+
Object.defineProperty(exports, "contributionOperationKeySchema", { enumerable: true, get: function () { return contributions_1.contributionOperationKeySchema; } });
|
|
17
|
+
Object.defineProperty(exports, "contributionPageQuerySchema", { enumerable: true, get: function () { return contributions_1.contributionPageQuerySchema; } });
|
|
18
|
+
Object.defineProperty(exports, "contributionPatchSchema", { enumerable: true, get: function () { return contributions_1.contributionPatchSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "contributionScopeQuerySchema", { enumerable: true, get: function () { return contributions_1.contributionScopeQuerySchema; } });
|
|
20
|
+
Object.defineProperty(exports, "createContributionSchema", { enumerable: true, get: function () { return contributions_1.createContributionSchema; } });
|
|
21
|
+
Object.defineProperty(exports, "decimalContributionAmount", { enumerable: true, get: function () { return contributions_1.decimalContributionAmount; } });
|
|
22
|
+
Object.defineProperty(exports, "formatContributionAmount", { enumerable: true, get: function () { return contributions_1.formatContributionAmount; } });
|