import * as z from 'zod/mini' import type { Address } from 'viem' import type * as EarnVaults from '../internal/EarnVaults.js' import type * as funding_Catalog from '../internal/funding/Catalog.js' import type * as funding_Deposit from '../internal/funding/Deposit.js' import type * as funding_DepositAddress from '../internal/funding/DepositAddress.js' import type * as funding_Provider from '../internal/funding/Provider.js' import type * as funding_Transfer from '../internal/funding/Transfer.js' import type * as internal_Schema from '../internal/Schema.js' import type * as Webhooks from '../internal/Webhooks.js' /** One authenticated administrator access to a protected admin API route. */ export const AdminAuditLog = z.object({ actor: z.string().check(z.describe('Verified administrator email.')), createdAt: z.string().check(z.describe('When the access completed (ISO 8601).')), id: z.string().check(z.describe('Opaque audit event id (`aud_…`).')), method: z.string().check(z.describe('HTTP method used for the access.')), path: z.string().check(z.describe('Admin API path accessed, without query parameters.')), query: z .nullable(z.string()) .check(z.describe('Query string used for the lookup, or null when absent.')), requestId: z.string().check(z.describe('Request id correlating the access with request logs.')), status: z .number() .check(z.int(), z.describe('HTTP response status returned to the administrator.')), }) /** Columns of the `admin_audit_logs` table. */ export type AdminAuditLog = z.output // Row schemas for database tables (`zod/mini`), the source of truth each // `tables/` module derives its `Table` type from. Nullable fields map to // nullable columns; the domain layer converts `null` back to absent fields. // Domain-owned unions and jsonb values stay typed by their owning module via // `z.custom` (type-only imports) so the two cannot drift. /** An organization's billing configuration; source-agnostic (limits apply to any billing source). */ export const BillingSettings = z.object({ createdAt: z.string().check(z.describe('When the settings row was created (ISO 8601).')), currency: z .enum(['usd']) .check(z.describe('ISO 4217 currency (lowercase) both limits are denominated in.')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Environment these settings apply to; `production` or `sandbox`.')), orgId: z.string().check(z.describe('Organization id (`org_…`) these settings belong to.')), period: z .enum(['month']) .check(z.describe('Window the spend limit applies over; `month` is a UTC calendar month.')), spendLimit: z .nullable(z.string()) .check(z.describe('Spend limit per period as a decimal string in `currency` units, or null for no limit.')), // prettier-ignore txFeeLimit: z .nullable(z.string()) .check(z.describe('Per-transaction fee cap as a decimal string in `currency` units, or null for the platform default.')), // prettier-ignore updatedAt: z.string().check(z.describe('When the settings last changed (ISO 8601).')), }) /** Columns of the `billing_settings` table. */ export type BillingSettings = z.output /** An early-access allowlist entry: a lowercase domain or exact email. */ export const EarlyAccessEntry = z.object({ createdAt: z.string().check(z.describe('When the entry was added (ISO 8601).')), createdBy: z .string() .check(z.describe('Admin email that added the entry, or `migration` for seeded rows.')), entry: z .string() .check(z.describe('Lowercase domain or exact email (contains `@`) granted early access.')), }) /** Columns of the `early_access` table. */ export type EarlyAccessEntry = z.output /** One billing-source type enabled for an organization. */ export const EnabledBillingSource = z.object({ createdAt: z.string().check(z.describe('When the billing source was enabled (ISO 8601).')), createdBy: z .string() .check(z.describe('Identity that enabled the source, or `migration` for backfilled rows.')), orgId: z.string().check(z.describe('Organization id (`org_…`) this source is enabled for.')), source: z .enum(['stripe', 'tempo']) .check(z.describe('Enabled billing-source type; `stripe` or `tempo`.')), }) /** Columns of the `enabled_billing_sources` table. */ export type EnabledBillingSource = z.output /** One curated Earn vault. */ export const EarnVault = z .object({ chainId: z.number().check(z.int(), z.describe('Chain the deployment belongs to.')), createdAt: z.string().check(z.describe('When the vault was registered (ISO 8601).')), description: z .nullable(z.string()) .check(z.describe('Curated vault description, or null when absent.')), label: z.string().check(z.describe('Curated vault label.')), privateInputTokens: z .custom() .check(z.describe('Tokens accepted for private deposits (`jsonb`).')), privateOutputTokens: z .custom() .check(z.describe('Tokens supported for private redemptions (`jsonb`).')), slug: z.string().check(z.describe('Stable URL slug assigned when the vault is registered.')), updatedAt: z.string().check(z.describe('When the vault registration last changed (ISO 8601).')), vaultAddress: z.custom
().check(z.describe('Earn vault address (lowercase).')), zones: z .custom() .check(z.describe('Curated private Zone routes (`jsonb`).')), }) .check(z.describe('One curated Earn vault row.')) /** Columns of the `earn_vaults` table. */ export type EarnVault = z.output /** A pending, expiring offer of organization membership. */ export const Invitation = z.object({ acceptedAt: z .nullable(z.string()) .check(z.describe('When the invitation was accepted (ISO 8601), or null while pending.')), createdAt: z.string().check(z.describe('When the invitation was created (ISO 8601).')), email: z .string() .check(z.describe('Invitee email (stored lowercase); matched against verified emails.')), expiresAt: z.string().check(z.describe('When the invitation expires (ISO 8601).')), grantsEarlyAccess: z .boolean() .check(z.describe("Whether the invitation grants early access; stamped from the inviter's own access at creation.")), // prettier-ignore id: z .string() .check( z.describe('Opaque invitation id (`inv_…`).'), z.meta({ examples: ['inv_1a2b3c4d5e6f7g8h9j0k1m2n'] }), ), invitedBy: z.string().check(z.describe('User or API key id that created the invitation.')), orgId: z.string().check(z.describe('Organization id (`org_…`) the invitation joins.')), revokedAt: z .nullable(z.string()) .check(z.describe('When the invitation was revoked (ISO 8601), or null.')), role: z .enum(['admin', 'member', 'owner']) .check(z.describe('Role granted when the invitation is accepted.')), }) /** Columns of the `invitations` table. */ export type Invitation = z.output /** A reusable bearer link granting organization membership. */ export const InviteLink = z.object({ allowedEmailDomains: z .nullable(z.readonly(z.array(z.string()))) .check(z.describe('Lowercase email domains allowed to redeem, or null for unrestricted.')), createdAt: z.string().check(z.describe('When the link was created (ISO 8601).')), createdBy: z.string().check(z.describe('User id that created the link, or `super_admin`.')), deletedAt: z.nullable(z.string()).check(z.describe('When the link was soft deleted, or null.')), enabled: z.boolean().check(z.describe('Whether the link is enabled.')), expiresAt: z.nullable(z.string()).check(z.describe('When the link expires, or null.')), id: z.string().check(z.describe('Opaque invite-link resource id (`iln_…`).')), lastUsedAt: z .nullable(z.string()) .check(z.describe('When the link last created a membership, or null.')), maxUses: z .nullable(z.number().check(z.int(), z.positive())) .check(z.describe('Maximum redemptions, or null.')), name: z.string().check(z.describe('Link name.')), orgId: z.string().check(z.describe('Organization id (`org_…`).')), role: z.literal('member').check(z.describe('Non-privileged role granted by the link.')), token: z.string().check(z.describe('Opaque invite-link bearer token (`lnk_…`).')), updatedAt: z.string().check(z.describe('When the link was last changed (ISO 8601).')), useCount: z.number().check(z.int(), z.nonnegative(), z.describe('Successful redemption count.')), }) /** Columns of the `invite_links` table. */ export type InviteLink = z.output /** An audit record for one membership created through an invite link. */ export const InviteLinkRedemption = z.object({ createdAt: z.string().check(z.describe('When the link was redeemed (ISO 8601).')), email: z.string().check(z.describe('Verified email used for redemption.')), id: z.string().check(z.describe('Opaque redemption id (`ilr_…`).')), inviteLinkId: z.string().check(z.describe('Invite-link id.')), inviteLinkName: z.string().check(z.describe('Invite-link name at redemption time.')), orgId: z.string().check(z.describe('Organization id.')), userId: z.string().check(z.describe('Redeeming user id.')), }) /** Columns of the `invite_link_redemptions` table. */ export type InviteLinkRedemption = z.output /** A user's role within an organization. */ export const Membership = z.object({ createdAt: z.string().check(z.describe('When the membership was created (ISO 8601).')), orgId: z.string().check(z.describe('Organization id (`org_…`).')), role: z .enum(['admin', 'member', 'owner']) .check(z.describe("The member's role within the organization.")), updatedAt: z.string().check(z.describe('When the membership was last updated (ISO 8601).')), userId: z.string().check(z.describe('Member user id (`usr_…`).')), }) /** Columns of the `memberships` table. */ export type Membership = z.output /** An organization, the top-level tenant that owns API keys. */ export const Organization = z.object({ createdAt: z.string().check(z.describe('When the organization was created (ISO 8601).')), createdBy: z .nullable(z.string()) .check(z.describe('Identity that created the organization (e.g. admin email), or null.')), id: z .string() .check( z.describe('Opaque organization id (`org_…`).'), z.meta({ examples: ['org_1a2b3c4d5e6f7g8h9j0k1m2n'] }), ), name: z .string() .check(z.describe('Human-readable organization name.'), z.meta({ examples: ['Acme, Inc.'] })), sponsorshipSubsidyDurationDays: z .nullable(z.number().check(z.int(), z.positive())) .check(z.describe('Promotional sponsorship duration in days, or null when disabled.')), sponsorshipSubsidyProjectSpendLimit: z .nullable(z.string()) .check(z.describe('Per-project promotional spend cap in decimal USD, or null when disabled.')), updatedAt: z.string().check(z.describe('When the organization was last updated (ISO 8601).')), userId: z .nullable(z.string()) .check( z.describe('Owning user id (`usr_…`), or null for organizations created by the super admin.'), ), }) /** Columns of the `organizations` table. */ export type Organization = z.output /** A project: an app or integration within an organization. */ export const Project = z.object({ createdAt: z.string().check(z.describe('When the project was created (ISO 8601).')), id: z .string() .check( z.describe('Opaque project id (`prj_…`).'), z.meta({ examples: ['prj_1a2b3c4d5e6f7g8h9j0k1m2n'] }), ), name: z .string() .check(z.describe('Human-readable project name.'), z.meta({ examples: ['Checkout'] })), orgId: z.string().check(z.describe('Owning organization id (`org_…`).')), sponsorshipSubsidyStartsAt: z .nullable(z.string()) .check(z.describe('When the project first activated promotional sponsorship, or null.')), sponsorshipSubsidyEndsAt: z .nullable(z.string()) .check(z.describe('When the project promotional sponsorship ends, or null.')), sponsorshipSpendLimit: z .nullable(z.string()) .check(z.describe('Promotional spend cap in fee-token base units, or null.')), updatedAt: z.string().check(z.describe('When the project was last updated (ISO 8601).')), }) /** Columns of the `projects` table. */ export type Project = z.output /** A transaction sponsored by the managed fee payer — the billable unit of fee payer spend. */ export const SponsoredTransaction = z.object({ apiKeyId: z.string().check(z.describe('API key id (`key_…`) that requested sponsorship.')), billable: z .boolean() .check(z.describe('Whether the sponsorship accrues billable spend; false for sandbox.')), chainId: z.number().check(z.describe('Chain the sponsored transaction targets.')), createdAt: z.string().check(z.describe('When the sponsorship was recorded (ISO 8601).')), currency: z .nullable(z.string()) .check(z.describe('Lowercase fee currency the sponsorship settles in (`usd`), or null when the fee token is unverified.')), // prettier-ignore environment: z .enum(['production', 'sandbox']) .check(z.describe('Key environment the sponsorship was requested under.')), feeAmount: z .nullable(z.string()) .check(z.describe('Actual fee paid in fee-token base units, or null until finalized.')), feeMax: z .nullable(z.string()) .check(z.describe('Signed fee cap (`gas × maxFeePerGas`) in base units; pending rows count it against spend limits.')), // prettier-ignore feeToken: z .nullable(z.string()) .check(z.describe('Fee token address, or null when the chain default applied.')), finalizedAt: z .nullable(z.string()) .check(z.describe('When the sponsorship reached a terminal status (ISO 8601), or null.')), id: z .string() .check( z.describe('Opaque sponsored-transaction id (`stx_…`).'), z.meta({ examples: ['stx_1a2b3c4d5e6f7g8h9j0k1m2n'] }), ), meterReportedAt: z .nullable(z.string()) .check(z.describe('When the row was reported to the billing meter (ISO 8601), or null; exactly-once marker.')), // prettier-ignore orgId: z.string().check(z.describe('Organization id (`org_…`) the spend attributes to.')), projectId: z .nullable(z.string()) .check(z.describe('Project id (`prj_…`) the spend attributes to, or null for organization-level spend.')), // prettier-ignore signPayload: z .string() .check(z.describe('Fee-payer sign payload — a stable identity for the sponsored envelope.')), status: z .enum(['failed', 'finalized', 'pending']) .check(z.describe('Pending until a receipt finalizes it or the pending TTL fails it.')), transaction: z .string() .check(z.describe('Serialized sponsored transaction, kept for durable observability.')), transactionHash: z .nullable(z.string()) .check(z.describe('Transaction hash, or null for fill intents until reconciled.')), }) /** Columns of the `sponsored_transactions` table. */ export type SponsoredTransaction = z.output /** A per-hour request-count watermark: the running total already reported to the meter. */ export const RequestUsageBucket = z.object({ bucketStart: z.string().check(z.describe('UTC hour start this bucket covers (ISO 8601).')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Environment the requests were served under; `production` or `sandbox`.')), orgId: z.string().check(z.describe('Organization id (`org_…`) the requests attribute to.')), reportedCount: z .number() .check(z.describe('Cumulative request count already reported to the meter for this bucket.')), updatedAt: z.string().check(z.describe('When the watermark last advanced (ISO 8601).')), }) /** Columns of the `request_usage_buckets` table. */ export type RequestUsageBucket = z.output /** One request-count meter event: a frozen additive delta with its exactly-once state. */ export const RequestUsageMeterEvent = z.object({ bucketStart: z.string().check(z.describe('UTC hour start this event bills for (ISO 8601).')), deltaCount: z .number() .check(z.describe('Frozen request count this event bills; a positive additive delta.')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Environment the requests were served under; `production` or `sandbox`.')), error: z.nullable(z.string()).check(z.describe('Last failure detail while `pending`, or null.')), firstAttemptedAt: z.string().check(z.describe('When this event was first claimed (ISO 8601).')), identifier: z .string() .check(z.describe('Deterministic id; also the Stripe meter-event identifier and idempotency key.')), // prettier-ignore orgId: z.string().check(z.describe('Organization id (`org_…`) the requests attribute to.')), reason: z .nullable(z.string()) .check(z.describe('Skip reason when `state` is `skipped` (`no_customer` | `customer_canceled`), or null.')), // prettier-ignore reportedAt: z .nullable(z.string()) .check(z.describe('When Stripe acknowledged the event (ISO 8601), or null.')), sequence: z .number() .check(z.describe('Reported-count watermark observed when this delta was claimed.')), state: z .enum(['pending', 'reported', 'skipped']) .check(z.describe('Exactly-once state: `pending` retries, `reported` is done, `skipped` is audited.')), // prettier-ignore stripeCustomerId: z.string().check(z.describe('Stripe customer id the event bills against.')), }) /** Columns of the `request_usage_meter_events` table. */ export type RequestUsageMeterEvent = z.output /** An organization's Stripe billing source: the customer link and derived status. */ export const StripeCustomer = z.object({ createdAt: z.string().check(z.describe('When the Stripe source was connected (ISO 8601).')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Environment this Stripe source backs; `production` (live) or `sandbox` (test).')), // prettier-ignore orgId: z.string().check(z.describe('Organization id (`org_…`) this Stripe source belongs to.')), status: z .enum(['active', 'canceled', 'none', 'past_due']) .check(z.describe('Billing status derived from Stripe state; gates production sponsorship.')), stripeCustomerId: z .string() .check(z.describe('Stripe customer id backing this source; never deleted by us.')), updatedAt: z.string().check(z.describe('When the billing status last changed (ISO 8601).')), }) /** Columns of the `stripe_customers` table. */ export type StripeCustomer = z.output /** A developer identity. */ export const User = z.object({ address: z .nullable(z.string()) .check( z.describe( 'Wallet address that signs in as this user (stored lowercase), or null for non-wallet identities.', ), ), createdAt: z.string().check(z.describe('When the user was created (ISO 8601).')), email: z .nullable(z.string()) .check(z.describe('Verified email from the wallet identity token, or null.')), id: z .string() .check( z.describe('Opaque user id (`usr_…`).'), z.meta({ examples: ['usr_1a2b3c4d5e6f7g8h9j0k1m2n'] }), ), updatedAt: z.string().check(z.describe('When the user was last updated (ISO 8601).')), }) /** Columns of the `users` table. */ export type User = z.output /** Metadata for the current funding catalog snapshot. */ export const FundingCatalog = z.object({ id: z.string().check(z.describe('Singleton funding catalog id.')), updatedAt: z.string().check(z.describe('When the funding catalog was last published.')), version: z.string().check(z.describe('Opaque funding catalog version.')), }) /** Columns of the `funding_catalogs` table. */ export type FundingCatalog = z.output /** One chain available to the funding catalog. */ export const FundingChain = z.object({ aliases: z .readonly(z.array(z.string())) .check(z.describe('Caller-facing aliases accepted for the funding chain.')), id: z.string().check(z.describe('CAIP-2 funding chain identifier.')), name: z.string().check(z.describe('Human-readable funding chain name.')), parentChainId: z .nullable(z.string()) .check(z.describe('Parent funding chain identifier for a Zone, or null.')), rpcUrls: z ._default(z.readonly(z.array(z.url())), []) .check(z.describe('Public RPC endpoints used for funding-chain evidence.')), slug: z.string().check(z.describe('Stable funding chain slug.')), }) /** Columns of the `funding_chains` table. */ export type FundingChain = z.output /** One token available to the funding catalog. */ export const FundingToken = z.object({ currency: z.string().check(z.describe('Monetary denomination represented by the token.')), id: z.string().check(z.describe('Stable funding token identifier.')), name: z.string().check(z.describe('Human-readable funding token name.')), symbol: z.string().check(z.describe('Funding token ticker symbol.')), }) /** Columns of the `funding_tokens` table. */ export type FundingToken = z.output /** Chain-specific metadata for one funding token. */ export const FundingChainToken = z.object({ address: z.string().check(z.describe('Token address on the funding chain.')), chainId: z.string().check(z.describe('CAIP-2 identifier of the funding chain.')), decimals: z.number().check(z.int(), z.nonnegative(), z.describe('Token decimal precision.')), name: z.nullable(z.string()).check(z.describe('Chain-specific token name override, or null.')), standard: z.string().check(z.describe('Token standard on the funding chain.')), tokenId: z.string().check(z.describe('Stable funding token identifier.')), }) /** Columns of the `funding_chain_tokens` table. */ export type FundingChainToken = z.output /** One source-to-destination route supported by a funding provider. */ export const FundingRoute = z.object({ capabilities: z .nullable(z.custom()) .check(z.describe('Executable capability (`jsonb`), or null for indicative-only routes.')), configuration: z .nullable(z.custom()) .check(z.describe('Provider-specific route configuration (`jsonb`), or null.')), destinationChainId: z.string().check(z.describe('Destination funding chain identifier.')), destinationTokenId: z.string().check(z.describe('Destination funding token identifier.')), providerId: z.string().check(z.describe('Funding provider identifier.')), sourceChainId: z.string().check(z.describe('Source funding chain identifier.')), sourceTokenId: z.string().check(z.describe('Source funding token identifier.')), }) /** Columns of the `funding_routes` table. */ export type FundingRoute = z.output /** * A reusable funding deposit address. Public route fields live in `snapshot`; * provider routing and correlation remain private. */ export const FundingDepositAddress = z.object({ address: z.string().check(z.describe('Reusable source-chain deposit address.')), apiKeyId: z.string().check(z.describe('API key id (`key_…`) that provisioned the address.')), createdAt: z.string().check(z.describe('When the address was created (ISO 8601).')), deliveryStrategy: z .custom() .check(z.describe('Whether the provider or Tempo delivers the requested destination token.')), destinationTokenKey: z.string().check(z.describe('Customer destination token key.')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Key environment the address belongs to.')), id: z.string().check(z.describe('Funding deposit address id (`fda_…`).')), lastPolledAt: z .nullable(z.string()) .check(z.describe('When provider reconciliation last completed successfully, or null.')), nextPollAt: z.string().check(z.describe('When provider reconciliation is next due.')), orgId: z.string().check(z.describe('Owning organization id (`org_…`).')), pollFailureCount: z.number().check(z.int(), z.describe('Consecutive reconciliation failures.')), pollLeaseUntil: z .nullable(z.string()) .check(z.describe('When the current reconciliation lease expires, or null.')), pollLeaseVersion: z .number() .check(z.int(), z.describe('Fencing token for reconciliation leases.')), projectId: z.nullable(z.string()).check(z.describe('Attributed project id (`prj_…`), or null.')), providerOutputToken: z .custom() .check(z.describe('Token that the provider outputs on Tempo (`jsonb`).')), providerId: z.string().check(z.describe('Selected funding provider id.')), providerRequestIds: z .readonly(z.array(z.string())) .check(z.describe('Private provider request identifiers (`jsonb`).')), providerState: z .nullable(z.custom()) .check(z.describe('Bounded private provider state (`jsonb`), or null.')), recipient: z.string().check(z.describe('Tempo account that receives completed deposits.')), refundAddress: z.string().check(z.describe('Source-chain refund address.')), snapshot: z .custom() .check(z.describe('Public address fields (`jsonb`).')), sourceChainId: z.string().check(z.describe('Source chain CAIP-2 id.')), sourceTokenKey: z.string().check(z.describe('Source token key.')), status: z.custom().check(z.describe('Lifecycle status.')), subsidize: z.boolean().check(z.describe('Whether Tempo guarantees normalized 1:1 delivery.')), updatedAt: z.string().check(z.describe('When the address last materially changed (ISO 8601).')), version: z.number().check(z.int(), z.describe('Material version used to guard updates.')), }) /** Columns of the `funding_deposit_addresses` table. */ export type FundingDepositAddress = z.output /** First Tempo observations of one provider request through polling and webhooks. */ export const FundingDepositRequestObservation = z.object({ depositAddressId: z.string().check(z.describe('Funding deposit address id (`fda_…`).')), pollObservedAt: z .nullable(z.string()) .check(z.describe('When polling first observed the provider request, or null.')), providerRequestId: z.string().check(z.describe('Provider request identifier.')), webhookReceivedAt: z .nullable(z.string()) .check(z.describe('When Tempo first received an authenticated webhook, or null.')), }) /** Columns of the `funding_deposit_request_observations` table. */ export type FundingDepositRequestObservation = z.output /** * One provider-observed deposit. Public route and evidence live in `snapshot`; * reconciliation and settlement state is private. */ export const FundingDeposit = z.object({ createdAt: z.string().check(z.describe('When the deposit was detected (ISO 8601).')), depositAddressId: z.string().check(z.describe('Funding deposit address id (`fda_…`).')), detectionTrigger: z .nullable(z.custom()) .check(z.describe('Mechanism that first detected the deposit, or null for legacy rows.')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Key environment inherited from the deposit address.')), id: z.string().check(z.describe('Funding deposit id (`fdp_…`).')), orgId: z.string().check(z.describe('Owning organization id (`org_…`).')), pollObservedAt: z .nullable(z.string()) .check(z.describe('When polling first observed the provider request, or null.')), projectId: z.nullable(z.string()).check(z.describe('Attributed project id (`prj_…`), or null.')), providerOutputAmount: z .nullable(z.custom>()) .check(z.describe('Provider output amount verified on Tempo (`jsonb`), or null.')), providerOutputToken: z .custom() .check(z.describe('Token output by the provider on Tempo (`jsonb`).')), providerRequestId: z .nullable(z.string()) .check(z.describe('Provider request that first reported the deposit, or null if unavailable.')), providerRequestIds: z .readonly(z.array(z.string())) .check(z.describe('Private provider request identifiers (`jsonb`).')), providerState: z .nullable(z.custom()) .check(z.describe('Bounded private provider state (`jsonb`), or null.')), providerTransactionHashes: z .readonly(z.array(z.string())) .check(z.describe('Private provider-leg transaction references (`jsonb`).')), providerTransferIndex: z .number() .check(z.int(), z.nonnegative(), z.describe('Deposit position within the provider request.')), retryState: z .nullable(z.custom()) .check(z.describe('Bounded private retry state (`jsonb`), or null.')), settlementTransaction: z .nullable(z.string()) .check(z.describe('Persisted settlement transaction bytes, or null.')), settlementTransactionHash: z .nullable(z.string()) .check(z.describe('Persisted settlement transaction hash, or null.')), snapshot: z .custom() .check(z.describe('Public deposit fields (`jsonb`).')), sourceChainId: z.string().check(z.describe('Source chain CAIP-2 id.')), sourceTransactionHash: z .string() .check(z.describe('Provider-observed source transaction reference.')), sourceTransferIndex: z .nullable(z.number().check(z.int())) .check(z.describe('Verified transfer position in the source transaction, or null.')), status: z.custom().check(z.describe('Lifecycle status.')), statusReason: z .nullable(z.custom()) .check(z.describe('Customer-safe status reason (`jsonb`), or null.')), subsidyAmount: z .nullable(z.custom>()) .check(z.describe('Destination token amount supplied by Tempo (`jsonb`), or null.')), tempoGasPaid: z.nullable(z.string()).check(z.describe('Tempo gas paid for settlement, or null.')), updatedAt: z.string().check(z.describe('When the deposit last materially changed (ISO 8601).')), version: z.number().check(z.int(), z.describe('Material version used to guard updates.')), webhookReceivedAt: z .nullable(z.string()) .check(z.describe('When Tempo first received an authenticated provider webhook, or null.')), }) /** Columns of the `funding_deposits` table. */ export type FundingDeposit = z.output /** * A durable funding transfer. Lifecycle state lives in typed columns; the * public quote terms and reconciled fields live in the `snapshot` jsonb and * merge in at serialization (`Transfer.toPublic`). */ export const FundingTransfer = z.object({ apiKeyId: z.string().check(z.describe('API key id (`key_…`) that created the transfer.')), createdAt: z.string().check(z.describe('When the transfer was created (ISO 8601).')), environment: z .enum(['production', 'sandbox']) .check(z.describe('Key environment the transfer belongs to.')), id: z.string().check(z.describe('Transfer id (`ftr_…`, lexically time-ordered).')), method: z .custom() .check(z.describe('Funding method selected at creation.')), mode: z .custom() .check(z.describe('Amount mode selected at creation.')), orgId: z.string().check(z.describe('Owning organization id (`org_…`).')), projectId: z .nullable(z.string()) .check(z.describe('Attributed project id (`prj_…`), or null for organization-attributed keys.')), // prettier-ignore providerId: z.string().check(z.describe('Selected funding provider id.')), providerState: z .nullable(z.custom()) .check(z.describe('Private provider state (`jsonb`), or null. Never serialized publicly.')), // prettier-ignore quoteExpiresAt: z .string() .check(z.describe('When the quoted terms stop being executable (ISO 8601).')), snapshot: z .custom() .check(z.describe('Public quote terms and reconciled fields (`jsonb`).')), status: z.custom().check(z.describe('Lifecycle status.')), statusReason: z .nullable(z.custom()) .check(z.describe('Customer-safe status reason (`jsonb`), or null.')), updatedAt: z.string().check(z.describe('When the transfer last materially changed (ISO 8601).')), version: z .number() .check(z.int(), z.describe('Increments on every material change; guards transitions.')), }) /** Columns of the `funding_transfers` table. */ export type FundingTransfer = z.output /** One immutable public snapshot of a funding transfer at a material version. */ export const FundingTransferEvent = z.object({ createdAt: z.string().check(z.describe('When the version was committed (ISO 8601).')), snapshot: z .custom() .check(z.describe('The complete public transfer at this version (`jsonb`).')), status: z.custom().check(z.describe('Status at this version.')), transferId: z.string().check(z.describe('Transfer id (`ftr_…`) the event belongs to.')), version: z.number().check(z.int(), z.describe('Material version the event records.')), }) /** Columns of the `funding_transfer_events` table. */ export type FundingTransferEvent = z.output /** One verified transaction reference associated with a funding transfer. */ export const FundingTransferTransaction = z.object({ chainId: z.string().check(z.describe('CAIP-2 chain the transaction executed on.')), createdAt: z.string().check(z.describe('When the reference was accepted (ISO 8601).')), role: z .custom() .check(z.describe('What the transaction evidences: `source`, `destination`, or `refund`.')), transactionRef: z .string() .check(z.describe('EVM transaction hash or case-sensitive Solana signature.')), transferId: z.string().check(z.describe('Transfer id (`ftr_…`) the reference belongs to.')), }) /** Columns of the `funding_transfer_transactions` table. */ export type FundingTransferTransaction = z.output /** * An API-key-scoped idempotency claim for funding resource creation. The row * retains recovery checkpoints and completed responses until `expiresAt`. */ export const FundingIdempotencyRequest = z.object({ apiKeyId: z.string().check(z.describe('API key id (`key_…`) the claim is scoped to.')), createdAt: z.string().check(z.describe('When the claim was taken (ISO 8601).')), expiresAt: z.string().check(z.describe('When the claim stops replaying (ISO 8601).')), keyHash: z.string().check(z.describe('SHA-256 of the caller Idempotency-Key.')), requestHash: z.string().check(z.describe('SHA-256 fingerprint of the canonical request.')), response: z .nullable(z.string()) .check(z.describe('Serialized checkpoint or success response, or null while pending.')), status: z .enum(['completed', 'pending', 'provisioned']) .check(z.describe('Claim state for execution, recovery, or replay.')), transferId: z .nullable(z.string()) .check(z.describe('Transfer id (`ftr_…`) the completed claim created, or null.')), }) /** Columns of the `funding_idempotency_requests` table. */ export type FundingIdempotencyRequest = z.output /** * A verified token: one row per curated token, ordered by `position` (list * order is canonical and surfaced to clients). Addresses are stored lowercase; * case-insensitive symbol uniqueness is enforced by a functional index on * `lower(symbol)`. */ export const VerifiedToken = z.object({ address: z.string().check(z.describe('Verified TIP-20 token contract address (lowercase).')), chainId: z.number().check(z.int(), z.describe('Chain the token belongs to.')), currency: z.string().check(z.describe('Display currency, e.g. `USD`.')), decimals: z.number().check(z.int(), z.describe('Decimal precision.')), logoUri: z.nullable(z.string()).check(z.describe('Curated HTTPS logo URL, or null.')), name: z.string().check(z.describe('Display name.')), position: z .number() .check(z.int(), z.describe("Zero-based position in the chain's canonical list order.")), symbol: z.string().check(z.describe('Ticker symbol.'), z.meta({ examples: ['USDC'] })), }) /** Columns of the `verified_tokens` table. */ export type VerifiedToken = z.output /** * A chain's verified-token list metadata — the opaque `version` that drives * the soft-refresh cache and `If-Match` preconditions, bumped on every publish. */ export const VerifiedTokenList = z.object({ chainId: z.number().check(z.int(), z.describe('Chain the list belongs to.')), updatedAt: z.string().check(z.describe('ISO timestamp of the last publish.')), version: z .string() .check(z.describe('Opaque list version (`_`); changes on every publish.')), }) /** Columns of the `verified_token_lists` table. */ export type VerifiedTokenList = z.output /** * An organization's request to add a token to the curated verified list. * Addresses are stored lowercase; a partial unique index allows at most one * pending request per (chain, address) globally. */ export const VerifiedTokenRequest = z.object({ address: z.string().check(z.describe('Requested TIP-20 token contract address (lowercase).')), chainId: z.number().check(z.int(), z.describe('Chain the token belongs to.')), createdAt: z.string().check(z.describe('When the request was created (ISO 8601).')), currency: z.string().check(z.describe('Display currency, e.g. `USD`.')), decimals: z.number().check(z.int(), z.describe('Decimal precision.')), id: z.string().check(z.describe('Opaque request id (`vtr_…`).')), logo: z .nullable(z.string()) .check(z.describe('Inline SVG logo markup uploaded by the requester, or null.')), logoUri: z.nullable(z.string()).check(z.describe('HTTPS logo URL from chain metadata, or null.')), name: z.string().check(z.describe('Display name.')), note: z.nullable(z.string()).check(z.describe('Requester note to reviewers, or null.')), orgId: z.string().check(z.describe('Requesting organization id (`org_…`).')), requestedBy: z .string() .check(z.describe('User id that submitted the request, or `super_admin`.')), reviewNote: z.nullable(z.string()).check(z.describe('Reviewer note shown on denial, or null.')), reviewedAt: z.nullable(z.string()).check(z.describe('When the request was reviewed, or null.')), reviewedBy: z.nullable(z.string()).check(z.describe('Reviewing admin email, or null.')), status: z.enum(['approved', 'denied', 'pending']).check(z.describe('Review status.')), symbol: z.string().check(z.describe('Ticker symbol.'), z.meta({ examples: ['USDC'] })), updatedAt: z.string().check(z.describe('When the request was last changed (ISO 8601).')), }) /** Columns of the `verified_token_requests` table. */ export type VerifiedTokenRequest = z.output /** * A webhook subscription. The `Webhooks.Owner` union maps to (`ownerType`, * `ownerId`); jsonb object columns round-trip as parsed values. `pollerCursor` * replaces the old per-subscription cursor key. */ export const WebhookSubscription = z.object({ chainId: z.number().check(z.int(), z.describe('Chain the subscription listens on.')), context: z .nullable(z.custom()) .check(z.describe('Human context (`jsonb`), or null.')), createdAt: z.string().check(z.describe('ISO timestamp of creation.')), destination: z .custom() .check(z.describe('Delivery destination (`jsonb`).')), environment: z .nullable(z.enum(['production', 'sandbox'])) .check(z.describe('API-key environment for private resource events, or null.')), eventType: z .custom() .check(z.describe('Event type the subscription listens to.')), expiresAt: z .nullable(z.string()) .check(z.describe('ISO expiry timestamp (MPP-owned subscriptions), or null.')), failureCount: z .number() .check(z.int(), z.describe('Consecutive delivery failures; drives auto-disable.')), filters: z .custom() .check(z.describe('Event-type-specific filter predicates (`jsonb`).')), id: z .string() .check( z.describe('Subscription id (`wh_…`, lexically time-ordered).'), z.meta({ examples: ['wh_001718668800000_2ZPE2gvateYEQ0dQslgvkhjx'] }), ), lastDeliveryAt: z .nullable(z.string()) .check(z.describe('ISO timestamp of the last successful delivery, or null.')), ownerId: z .string() .check(z.describe('Owner identifier: `orgId` for `api_key` owners, `payer` for `mpp`.')), ownerType: z.custom().check(z.describe('Owner kind.')), pollerCursor: z .nullable(z.string()) .check(z.describe('Poller keyset cursor, or null before the first tick.')), projectId: z .nullable(z.string()) .check(z.describe('API-key project attribution for private resource events, or null.')), secret: z.string().check(z.describe('HMAC signing secret.')), status: z.custom().check(z.describe('Lifecycle status.')), updatedAt: z .string() .check(z.describe('ISO timestamp of the last mutation (`pollerCursor` writes excluded).')), }) /** Columns of the `webhook_subscriptions` table. */ export type WebhookSubscription = z.output /** * A webhook delivery attempt. Rows are invisible past `expiresAt` (the * retention deadline that replaces the old store TTL) and pruned by the * poller; deleting a subscription cascades to its rows. */ export const WebhookDelivery = z.object({ attempt: z .number() .check( z.int(), z.describe('Consecutive attempt number (1-based) at the time of the delivery.'), ), createdAt: z.string().check(z.describe('ISO timestamp the attempt was recorded.')), envelope: z .custom() .check(z.describe('The exact envelope that was sent (`jsonb`), for verbatim replay.')), error: z .nullable(z.string()) .check(z.describe('Failure reason when `status` is `failed`, or null.')), eventId: z.string().check(z.describe('Idempotent event id the delivery carried (`evt_…`).')), expiresAt: z .string() .check(z.describe('ISO retention deadline; rows past it are invisible and pruned.')), id: z .string() .check( z.describe('Delivery id (`whd_…`, lexically time-ordered).'), z.meta({ examples: ['whd_001718668800000_C1yJkk7CuML98HFthEDk9PsY'] }), ), requestUrl: z.string().check(z.describe('Subscriber callback URL the attempt targeted.')), responseMs: z .nullable(z.number()) .check(z.describe('Wall-clock duration of the attempt in ms, or null.')), responseStatus: z .nullable(z.number()) .check(z.describe('HTTP response status, or null when no response was received.')), status: z.custom().check(z.describe('Outcome status.')), subscriptionId: z .string() .check(z.describe('Owning subscription id (`wh_…`); FK with `ON DELETE CASCADE`.')), }) /** Columns of the `webhook_deliveries` table. */ export type WebhookDelivery = z.output /** An insert-only dedupe record marking a delivery obligation terminal. */ export const WebhookQueueCompletion = z.object({ eventId: z.string().check(z.describe('Idempotent event id (`evt_...`).')), expiresAt: z .string() .check(z.describe('ISO dedupe retention deadline; rows past it are invisible and pruned.')), status: z .enum(['failed', 'skipped', 'succeeded']) .check(z.describe('Terminal delivery-obligation outcome.')), subscriptionId: z .string() .check(z.describe('Owning subscription id (`wh_...`); FK with `ON DELETE CASCADE`.')), }) /** Columns of the `webhook_queue_completions` table. */ export type WebhookQueueCompletion = z.output /** A durable webhook envelope staged before its compact Queue reference is admitted. */ export const WebhookQueueEvent = z.object({ attemptCount: z.number().check(z.describe('Delivery attempts claimed so far.')), attemptingAt: z .nullable(z.string()) .check(z.describe('ISO timestamp of the current claim, or null when unclaimed.')), createdAt: z.string().check(z.describe('ISO timestamp when the envelope was staged.')), envelope: z .custom() .check(z.describe('The full webhook envelope retained outside Cloudflare Queues.')), eventId: z.string().check(z.describe('Idempotent event id (`evt_...`).')), expiresAt: z .nullable(z.string()) .check( z.describe( 'Unwritten since completions took over dedupe; non-null only on rows staged before the split.', ), ), nextAttemptAt: z .nullable(z.string()) .check(z.describe('ISO retry due time, or null when due immediately.')), observedAt: z .nullable(z.string()) .check( z.describe( 'ISO timestamp the coordinator observed the head owing this event, or null on replays.', ), ), status: z .enum(['failed', 'pending', 'skipped', 'succeeded']) .check( z.describe( 'Always `pending` since completions took over terminal state; other values occur only on rows completed before the split.', ), ), subscriptionId: z .string() .check(z.describe('Owning subscription id (`wh_...`); FK with `ON DELETE CASCADE`.')), }) /** Columns of the `webhook_queue_events` table. */ export type WebhookQueueEvent = z.output