@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,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.meterRoutes = exports.createBillingMeterEventParams = exports.billingMeterEventSummariesQuery = exports.listBillingMetersQuery = exports.billingMeterStatusParams = exports.updateBillingMeterParams = exports.createBillingMeterParams = exports.billingMeterEventSummarySchema = exports.billingMeterEventSchema = exports.billingMeterSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const envelopes_1 = require("../../common/envelopes");
|
|
6
|
+
const objects_1 = require("../../common/objects");
|
|
7
|
+
const params_1 = require("../../common/params");
|
|
8
|
+
const primitives_1 = require("../../common/primitives");
|
|
9
|
+
const route_1 = require("../../route");
|
|
10
|
+
const catalog_1 = require("../../vocabulary/catalog");
|
|
11
|
+
/**
|
|
12
|
+
* Usage meters (`mtr_…`, ADR 0018 §7): usage events named `event_name`,
|
|
13
|
+
* attributed to a customer by `customer_mapping.event_payload_key` of their
|
|
14
|
+
* payload and measured by `value_settings.event_payload_key`. A metered price
|
|
15
|
+
* (`recurring.meter`) bills its aggregate per period, in arrears.
|
|
16
|
+
*/
|
|
17
|
+
exports.billingMeterSchema = (0, objects_1.defineObject)('billing.meter', 'BillingMeter', zod_1.z
|
|
18
|
+
.object({
|
|
19
|
+
id: zod_1.z.string(),
|
|
20
|
+
object: zod_1.z.literal('billing.meter'),
|
|
21
|
+
livemode: primitives_1.livemode,
|
|
22
|
+
display_name: zod_1.z.string(),
|
|
23
|
+
event_name: zod_1.z.string().describe('The `event_name` of the meter events it counts.'),
|
|
24
|
+
default_aggregation: zod_1.z
|
|
25
|
+
.object({
|
|
26
|
+
formula: zod_1.z
|
|
27
|
+
.enum(catalog_1.METER_AGGREGATIONS)
|
|
28
|
+
.describe("How a period's events combine into the quantity billed."),
|
|
29
|
+
})
|
|
30
|
+
.strict(),
|
|
31
|
+
customer_mapping: zod_1.z
|
|
32
|
+
.object({
|
|
33
|
+
type: zod_1.z.literal('by_id'),
|
|
34
|
+
event_payload_key: zod_1.z
|
|
35
|
+
.string()
|
|
36
|
+
.describe('The payload key carrying the customer (`cus_…`).'),
|
|
37
|
+
})
|
|
38
|
+
.strict(),
|
|
39
|
+
value_settings: zod_1.z
|
|
40
|
+
.object({
|
|
41
|
+
event_payload_key: zod_1.z.string().describe('The payload key carrying the value.'),
|
|
42
|
+
})
|
|
43
|
+
.strict(),
|
|
44
|
+
status: zod_1.z.enum(catalog_1.METER_STATUSES),
|
|
45
|
+
created: primitives_1.unixSeconds,
|
|
46
|
+
updated: primitives_1.unixSeconds,
|
|
47
|
+
})
|
|
48
|
+
.strict(), {
|
|
49
|
+
examples: [
|
|
50
|
+
{
|
|
51
|
+
id: 'mtr_0193b8f2c1a87d3e9f4e',
|
|
52
|
+
object: 'billing.meter',
|
|
53
|
+
livemode: false,
|
|
54
|
+
display_name: 'API calls',
|
|
55
|
+
event_name: 'api_call',
|
|
56
|
+
default_aggregation: { formula: 'sum' },
|
|
57
|
+
customer_mapping: { type: 'by_id', event_payload_key: 'peable_customer_id' },
|
|
58
|
+
value_settings: { event_payload_key: 'value' },
|
|
59
|
+
status: 'active',
|
|
60
|
+
created: 1793750400,
|
|
61
|
+
updated: 1793750400,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* One usage event, `POST /v1/billing/meter_events`. `identifier` makes it
|
|
67
|
+
* idempotent: the same identifier is the same event, forever.
|
|
68
|
+
*/
|
|
69
|
+
exports.billingMeterEventSchema = (0, objects_1.defineObject)('billing.meter_event', 'BillingMeterEvent', zod_1.z
|
|
70
|
+
.object({
|
|
71
|
+
object: zod_1.z.literal('billing.meter_event'),
|
|
72
|
+
livemode: primitives_1.livemode,
|
|
73
|
+
identifier: zod_1.z.string(),
|
|
74
|
+
event_name: zod_1.z.string(),
|
|
75
|
+
payload: zod_1.z
|
|
76
|
+
.record(zod_1.z.string(), zod_1.z.string())
|
|
77
|
+
.describe('The payload as received: the customer key and the value, as strings.'),
|
|
78
|
+
timestamp: primitives_1.unixSeconds,
|
|
79
|
+
created: primitives_1.unixSeconds,
|
|
80
|
+
})
|
|
81
|
+
.strict(), {
|
|
82
|
+
examples: [
|
|
83
|
+
{
|
|
84
|
+
object: 'billing.meter_event',
|
|
85
|
+
livemode: false,
|
|
86
|
+
identifier: 'req_8f3a2c',
|
|
87
|
+
event_name: 'api_call',
|
|
88
|
+
payload: { peable_customer_id: 'cus_0193b8f2c1a87d3e9f4a', value: '25' },
|
|
89
|
+
timestamp: 1793750400,
|
|
90
|
+
created: 1793750400,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
/** A customer's aggregate over a window: `GET /v1/billing/meters/{id}/event_summaries`. */
|
|
95
|
+
exports.billingMeterEventSummarySchema = (0, objects_1.defineObject)('billing.meter_event_summary', 'BillingMeterEventSummary', zod_1.z
|
|
96
|
+
.object({
|
|
97
|
+
id: zod_1.z.string(),
|
|
98
|
+
object: zod_1.z.literal('billing.meter_event_summary'),
|
|
99
|
+
livemode: primitives_1.livemode,
|
|
100
|
+
meter: zod_1.z.string().describe('The meter (`mtr_…`).'),
|
|
101
|
+
aggregated_value: zod_1.z
|
|
102
|
+
.string()
|
|
103
|
+
.describe('The aggregate, as an integer string (it can exceed a JS number).'),
|
|
104
|
+
start_time: primitives_1.unixSeconds,
|
|
105
|
+
end_time: primitives_1.unixSeconds,
|
|
106
|
+
})
|
|
107
|
+
.strict(), {
|
|
108
|
+
examples: [
|
|
109
|
+
{
|
|
110
|
+
id: 'mtrsum_0193b8f2c1a87d3e9f4e_1793750400',
|
|
111
|
+
object: 'billing.meter_event_summary',
|
|
112
|
+
livemode: false,
|
|
113
|
+
meter: 'mtr_0193b8f2c1a87d3e9f4e',
|
|
114
|
+
aggregated_value: '1250',
|
|
115
|
+
start_time: 1793750400,
|
|
116
|
+
end_time: 1796342400,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
const payloadKey = zod_1.z.string().regex(/^[A-Za-z0-9_]{1,100}$/);
|
|
121
|
+
const eventName = zod_1.z.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/);
|
|
122
|
+
const displayName = zod_1.z.string().min(1).max(250);
|
|
123
|
+
exports.createBillingMeterParams = zod_1.z
|
|
124
|
+
.object({
|
|
125
|
+
display_name: displayName,
|
|
126
|
+
event_name: eventName,
|
|
127
|
+
default_aggregation: zod_1.z.object({ formula: zod_1.z.enum(catalog_1.METER_AGGREGATIONS) }).strict(),
|
|
128
|
+
customer_mapping: zod_1.z
|
|
129
|
+
.object({ type: zod_1.z.literal('by_id'), event_payload_key: payloadKey })
|
|
130
|
+
.strict()
|
|
131
|
+
.optional()
|
|
132
|
+
.describe("Default `{ type: 'by_id', event_payload_key: 'peable_customer_id' }`."),
|
|
133
|
+
value_settings: zod_1.z
|
|
134
|
+
.object({ event_payload_key: payloadKey })
|
|
135
|
+
.strict()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("Default `{ event_payload_key: 'value' }`."),
|
|
138
|
+
})
|
|
139
|
+
.strict();
|
|
140
|
+
exports.updateBillingMeterParams = zod_1.z.object({ display_name: displayName.optional() }).strict();
|
|
141
|
+
/** The body of `deactivate` / `reactivate`: nothing. */
|
|
142
|
+
exports.billingMeterStatusParams = zod_1.z.object({}).strict();
|
|
143
|
+
exports.listBillingMetersQuery = (0, params_1.listQuery)({ status: zod_1.z.enum(catalog_1.METER_STATUSES).optional() });
|
|
144
|
+
exports.billingMeterEventSummariesQuery = zod_1.z
|
|
145
|
+
.object({
|
|
146
|
+
customer: params_1.idParam.describe('The customer (`cus_…`) whose usage is aggregated.'),
|
|
147
|
+
start_time: params_1.queryUnixSeconds.describe('The window start (inclusive).'),
|
|
148
|
+
end_time: params_1.queryUnixSeconds.describe('The window end (exclusive), after `start_time`.'),
|
|
149
|
+
})
|
|
150
|
+
.strict();
|
|
151
|
+
exports.createBillingMeterEventParams = zod_1.z
|
|
152
|
+
.object({
|
|
153
|
+
event_name: eventName,
|
|
154
|
+
payload: zod_1.z.record(zod_1.z.string().max(100), zod_1.z.string().max(255)),
|
|
155
|
+
identifier: zod_1.z
|
|
156
|
+
.string()
|
|
157
|
+
.min(1)
|
|
158
|
+
.max(100)
|
|
159
|
+
.optional()
|
|
160
|
+
.describe('Default: a fresh one — pass your own so a retry is not counted twice.'),
|
|
161
|
+
timestamp: params_1.unixSecondsParam
|
|
162
|
+
.optional()
|
|
163
|
+
.describe('Default now. At most 35 days in the past, 5 minutes in the future.'),
|
|
164
|
+
})
|
|
165
|
+
.strict();
|
|
166
|
+
const id = { id: 'The meter (`mtr_…`).' };
|
|
167
|
+
exports.meterRoutes = [
|
|
168
|
+
(0, route_1.defineRoute)({
|
|
169
|
+
operationId: 'createBillingMeter',
|
|
170
|
+
method: 'post',
|
|
171
|
+
path: '/v1/billing/meters',
|
|
172
|
+
tag: 'Meters',
|
|
173
|
+
summary: 'Create a meter',
|
|
174
|
+
auth: 'service',
|
|
175
|
+
scope: 'payments:write',
|
|
176
|
+
idempotent: true,
|
|
177
|
+
body: exports.createBillingMeterParams,
|
|
178
|
+
response: exports.billingMeterSchema,
|
|
179
|
+
sdk: 'billing.meters.create',
|
|
180
|
+
}),
|
|
181
|
+
(0, route_1.defineRoute)({
|
|
182
|
+
operationId: 'listBillingMeters',
|
|
183
|
+
method: 'get',
|
|
184
|
+
path: '/v1/billing/meters',
|
|
185
|
+
tag: 'Meters',
|
|
186
|
+
summary: 'List meters',
|
|
187
|
+
auth: 'service',
|
|
188
|
+
scope: 'payments:read',
|
|
189
|
+
query: exports.listBillingMetersQuery,
|
|
190
|
+
response: (0, envelopes_1.listOf)(exports.billingMeterSchema),
|
|
191
|
+
sdk: 'billing.meters.list',
|
|
192
|
+
expandable: 'billing.meter',
|
|
193
|
+
}),
|
|
194
|
+
(0, route_1.defineRoute)({
|
|
195
|
+
operationId: 'retrieveBillingMeter',
|
|
196
|
+
method: 'get',
|
|
197
|
+
path: '/v1/billing/meters/{id}',
|
|
198
|
+
tag: 'Meters',
|
|
199
|
+
summary: 'Retrieve a meter',
|
|
200
|
+
auth: 'service',
|
|
201
|
+
scope: 'payments:read',
|
|
202
|
+
params: id,
|
|
203
|
+
query: params_1.expandOnlyQuery,
|
|
204
|
+
response: exports.billingMeterSchema,
|
|
205
|
+
sdk: 'billing.meters.retrieve',
|
|
206
|
+
}),
|
|
207
|
+
(0, route_1.defineRoute)({
|
|
208
|
+
operationId: 'updateBillingMeter',
|
|
209
|
+
method: 'post',
|
|
210
|
+
path: '/v1/billing/meters/{id}',
|
|
211
|
+
tag: 'Meters',
|
|
212
|
+
summary: 'Update a meter',
|
|
213
|
+
description: 'Only `display_name` changes.',
|
|
214
|
+
auth: 'service',
|
|
215
|
+
scope: 'payments:write',
|
|
216
|
+
idempotent: true,
|
|
217
|
+
params: id,
|
|
218
|
+
body: exports.updateBillingMeterParams,
|
|
219
|
+
response: exports.billingMeterSchema,
|
|
220
|
+
sdk: 'billing.meters.update',
|
|
221
|
+
}),
|
|
222
|
+
(0, route_1.defineRoute)({
|
|
223
|
+
operationId: 'deactivateBillingMeter',
|
|
224
|
+
method: 'post',
|
|
225
|
+
path: '/v1/billing/meters/{id}/deactivate',
|
|
226
|
+
tag: 'Meters',
|
|
227
|
+
summary: 'Deactivate a meter',
|
|
228
|
+
description: 'An inactive meter accepts no events.',
|
|
229
|
+
auth: 'service',
|
|
230
|
+
scope: 'payments:write',
|
|
231
|
+
idempotent: true,
|
|
232
|
+
params: id,
|
|
233
|
+
body: exports.billingMeterStatusParams,
|
|
234
|
+
response: exports.billingMeterSchema,
|
|
235
|
+
sdk: 'billing.meters.deactivate',
|
|
236
|
+
}),
|
|
237
|
+
(0, route_1.defineRoute)({
|
|
238
|
+
operationId: 'reactivateBillingMeter',
|
|
239
|
+
method: 'post',
|
|
240
|
+
path: '/v1/billing/meters/{id}/reactivate',
|
|
241
|
+
tag: 'Meters',
|
|
242
|
+
summary: 'Reactivate a meter',
|
|
243
|
+
auth: 'service',
|
|
244
|
+
scope: 'payments:write',
|
|
245
|
+
idempotent: true,
|
|
246
|
+
params: id,
|
|
247
|
+
body: exports.billingMeterStatusParams,
|
|
248
|
+
response: exports.billingMeterSchema,
|
|
249
|
+
sdk: 'billing.meters.reactivate',
|
|
250
|
+
}),
|
|
251
|
+
(0, route_1.defineRoute)({
|
|
252
|
+
operationId: 'listBillingMeterEventSummaries',
|
|
253
|
+
method: 'get',
|
|
254
|
+
path: '/v1/billing/meters/{id}/event_summaries',
|
|
255
|
+
tag: 'Meters',
|
|
256
|
+
summary: "A customer's usage over a window",
|
|
257
|
+
description: 'One summary: the aggregate of the window `[start_time, end_time)`.',
|
|
258
|
+
auth: 'service',
|
|
259
|
+
scope: 'payments:read',
|
|
260
|
+
params: id,
|
|
261
|
+
query: exports.billingMeterEventSummariesQuery,
|
|
262
|
+
response: (0, envelopes_1.listOf)(exports.billingMeterEventSummarySchema),
|
|
263
|
+
sdk: 'billing.meters.listEventSummaries',
|
|
264
|
+
}),
|
|
265
|
+
(0, route_1.defineRoute)({
|
|
266
|
+
operationId: 'createBillingMeterEvent',
|
|
267
|
+
method: 'post',
|
|
268
|
+
path: '/v1/billing/meter_events',
|
|
269
|
+
tag: 'Meters',
|
|
270
|
+
summary: 'Record a meter event',
|
|
271
|
+
description: 'The customer must be yours and the value a non-negative integer. A repeated `identifier` answers the stored event.',
|
|
272
|
+
auth: 'service',
|
|
273
|
+
scope: 'payments:write',
|
|
274
|
+
idempotent: true,
|
|
275
|
+
body: exports.createBillingMeterEventParams,
|
|
276
|
+
response: exports.billingMeterEventSchema,
|
|
277
|
+
sdk: 'billing.meterEvents.create',
|
|
278
|
+
}),
|
|
279
|
+
];
|