@klappay/types 1.0.4 → 1.0.6
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/README.md +9 -8
- package/dist/index.d.mts +709 -30
- package/dist/index.d.ts +709 -30
- package/dist/index.js +457 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +433 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/environment.ts","../src/networks.ts","../src/pagination.ts","../src/tokens.ts","../src/charges.ts","../src/distributions.ts","../src/webhook-events.ts","../src/webhooks.ts","../src/api-keys.ts","../src/users.ts","../src/auth.ts","../src/organization.ts","../src/invitations.ts","../src/timeline.ts","../src/verify.ts","../src/health.ts","../src/sandbox.ts","../src/capabilities.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const ErrorPayloadSchema = z.object({\n error: z.object({\n code: z\n .string()\n .describe(\n 'A stable, machine-readable error identifier (e.g. `validation_error`, `invalid_credentials`).',\n ),\n message: z\n .string()\n .describe(\n 'Human-readable explanation, safe to log or show a developer — not meant for end users.',\n ),\n param: z\n .string()\n .optional()\n .describe('Which request field the error refers to, when applicable.'),\n }),\n})\n\nexport type ErrorPayload = z.infer<typeof ErrorPayloadSchema>\n","import { z } from 'zod'\n\nexport const EnvironmentSchema = z\n .enum(['live', 'test'])\n .describe(\n '`live` or `test`, matching the `klap_live_.../klap_test_...` prefix of the API key that created or is scoped to this resource. `live` settles on Base mainnet with real funds; `test` settles on Base Sepolia, a separate testnet — real on-chain activity, but never real money.',\n )\nexport type Environment = z.infer<typeof EnvironmentSchema>\n","import { z } from 'zod'\n\nexport const NetworkSchema = z\n .enum(['base', 'optimism', 'polygon', 'ethereum', 'arbitrum', 'avalanche', 'bnb'])\n .describe('The blockchain a charge/payment is on.')\n\nexport type Network = z.infer<typeof NetworkSchema>\n\nexport const NETWORK_LABELS: Record<Network, string> = {\n base: 'Base',\n optimism: 'Optimism',\n polygon: 'Polygon',\n ethereum: 'Ethereum',\n arbitrum: 'Arbitrum',\n avalanche: 'Avalanche',\n bnb: 'BNB Chain',\n}\n\nexport const NETWORK_EXPLORERS: Record<Network, string> = {\n base: 'https://basescan.org',\n optimism: 'https://optimistic.etherscan.io',\n polygon: 'https://polygonscan.com',\n ethereum: 'https://etherscan.io',\n arbitrum: 'https://arbiscan.io',\n avalanche: 'https://snowtrace.io',\n bnb: 'https://bscscan.com',\n}\n\nexport const EVM_NETWORKS = [\n 'base',\n 'optimism',\n 'polygon',\n 'ethereum',\n 'arbitrum',\n 'avalanche',\n 'bnb',\n] as const\nexport type EvmNetwork = (typeof EVM_NETWORKS)[number]\n\nexport const OPERATIONAL_NETWORKS = [\n 'base',\n 'arbitrum',\n 'optimism',\n 'polygon',\n 'ethereum',\n 'avalanche',\n 'bnb',\n] as const\nexport type OperationalNetwork = (typeof OPERATIONAL_NETWORKS)[number]\n","import { z } from 'zod'\n\nexport const PAGINATION_LIMIT_MIN = 1\nexport const PAGINATION_LIMIT_MAX = 100\nexport const PAGINATION_LIMIT_DEFAULT = 20\n\nexport const PaginationQuerySchema = z.object({\n limit: z.coerce\n .number()\n .min(PAGINATION_LIMIT_MIN)\n .max(PAGINATION_LIMIT_MAX)\n .default(PAGINATION_LIMIT_DEFAULT)\n .describe(\n `Max items to return per page (${PAGINATION_LIMIT_MIN}–${PAGINATION_LIMIT_MAX}, default ${PAGINATION_LIMIT_DEFAULT}).`,\n ),\n cursor: z\n .string()\n .max(500)\n .optional()\n .describe(\n \"Opaque — pass the previous response's `nextCursor` verbatim to fetch the next page. Never construct or parse this value yourself; its shape is not part of the public contract and may change.\",\n ),\n})\n\nexport type PaginationQuery = z.infer<typeof PaginationQuerySchema>\n\nexport type PaginationQueryRequest = z.input<typeof PaginationQuerySchema>\n\nexport function paginatedSchema<T extends z.ZodTypeAny>(itemSchema: T) {\n return z.object({\n data: z.array(itemSchema),\n nextCursor: z\n .string()\n .nullable()\n .describe('Pass as `cursor` to fetch the next page. `null` when there are no more results.'),\n hasMore: z.boolean(),\n })\n}\n","import { z } from 'zod'\nimport type { Environment } from './environment'\nimport { OPERATIONAL_NETWORKS } from './networks'\nimport type { Network } from './networks'\n\nexport const TokenSchema = z\n .enum(['USDC', 'USDT'])\n .describe(\n `Which stablecoin the payer will send. Support depends on both \\`network\\` and \\`environment\\` — not every token/network/environment combination is deployed; today, both \\`USDC\\` and \\`USDT\\` are deployed on every operational network's \\`live\\` side except BNB Chain (\\`${OPERATIONAL_NETWORKS.join(', ')}\\`), but \\`test\\` coverage varies per network — Base, Optimism, and Ethereum each have a \\`test\\` environment (\\`USDC\\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \\`422 token_not_supported\\`, not silently accepted. **BNB Chain's \\`USDC\\` address is Binance-Peg USDC, not an official Circle deployment** — Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \\`TOKEN_ADDRESSES\\` entry (all verified directly against their real issuer). Accepted at the payer's own risk — Klap does not verify or guarantee Binance's collateral backing it. \\`USDT\\` on BNB Chain is Tether's own official issuance, same trust model as everywhere else. More tokens/networks are expected to be added over time — check \\`TOKEN_ADDRESSES\\` in \\`@klappay/types\\` (or a future \\`GET /v1/networks\\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`,\n )\nexport type Token = z.infer<typeof TokenSchema>\n\nexport const TOKEN_DECIMALS = 6\n\nexport const TOKEN_ADDRESSES: Record<\n Token,\n Partial<Record<Network, Partial<Record<Environment, `0x${string}`>>>>\n> = {\n USDC: {\n base: {\n live: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n test: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n },\n optimism: {\n live: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',\n test: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7',\n },\n polygon: { live: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' },\n ethereum: {\n live: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n test: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n },\n arbitrum: { live: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' },\n avalanche: { live: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' },\n bnb: { live: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' },\n },\n USDT: {\n base: { live: '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2' },\n optimism: { live: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58' },\n polygon: { live: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F' },\n ethereum: { live: '0xdAC17F958D2ee523a2206206994597C13D831ec7' },\n arbitrum: { live: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9' },\n avalanche: { live: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7' },\n bnb: { live: '0x55d398326f99059fF775485246999027B3197955' },\n },\n}\n","import { z } from 'zod'\nimport { EnvironmentSchema } from './environment'\nimport { NetworkSchema, OPERATIONAL_NETWORKS } from './networks'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\nimport { TokenSchema } from './tokens'\n\nexport const ChargeStatusSchema = z\n .enum(['pending', 'partially_paid', 'confirmed', 'expired', 'underpaid'])\n .describe(\n 'Payment progress, from the payer side. `pending`: created, nothing received yet. `partially_paid`: some funds received, less than `amount`. `confirmed`: full amount received (or more — see `isOverpaid`). `expired`: `expiresAt` passed with zero funds received. `underpaid`: `expiresAt` passed while `partially_paid`. This never reflects whether funds actually reached the merchant — see `settlementStatus` for that.',\n )\n\nexport type ChargeStatus = z.infer<typeof ChargeStatusSchema>\n\nexport const SettlementStatusSchema = z\n .enum(['pending', 'completed', 'failed'])\n .describe(\n \"Progress of the payout to the merchant's wallet, a separate step from `status` — `status: confirmed` only means the payment was detected on-chain, not that the merchant has been paid yet. `pending`: payment detected, payout not yet attempted. `completed`: the merchant's wallet has the funds. `failed`: the payout attempt failed and retries were exhausted (rare; contact support). `null` on the parent `Charge` means no payout has been attempted yet — nothing has been received, or the charge is still in progress.\",\n )\nexport type SettlementStatus = z.infer<typeof SettlementStatusSchema>\n\nexport const ChargeModeSchema = z\n .enum(['standard', 'continuous'])\n .describe(\n \"`standard` (default): the usual lifecycle — accumulates transfers toward one resolution (`confirmed`/`expired`/`underpaid`), settles once. `continuous`: never resolves — `status` stays `pending` for the charge's entire life, and every credited transfer settles independently instead of accumulating toward one confirmation (see `charge.contribution_received`/`charge.contribution_settled`). Requires both `amount` and `expiresIn` to be omitted — there's no goal to accumulate toward and no deadline for something meant to run indefinitely (a link in a creator's bio, a permanent collection address). Not inferred from omitting those two fields — an explicit, deliberate choice, since silently changing a charge's entire settlement lifecycle based on which optional fields happened to be left out would be a footgun.\",\n )\nexport type ChargeMode = z.infer<typeof ChargeModeSchema>\n\nexport const CHARGE_EXPIRES_IN_MIN_SECONDS = 60\nexport const CHARGE_EXPIRES_IN_MAX_SECONDS = 365 * 24 * 60 * 60\n\nexport const CHARGE_ACCEPTED_PAYMENTS_MAX = 14\n\nexport const AcceptedPaymentSchema = z.object({\n token: TokenSchema,\n network: NetworkSchema,\n})\nexport type AcceptedPayment = z.infer<typeof AcceptedPaymentSchema>\n\nconst AcceptedPaymentsSchema = z\n .array(AcceptedPaymentSchema)\n .min(1, 'At least one accepted payment is required.')\n .max(CHARGE_ACCEPTED_PAYMENTS_MAX)\n .superRefine((pairs, ctx) => {\n const seen = new Set<string>()\n pairs.forEach((pair, index) => {\n const key = `${pair.token}:${pair.network}`\n if (seen.has(key)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Duplicate accepted payment: ${pair.token} on ${pair.network}.`,\n path: [index],\n })\n }\n seen.add(key)\n if (!(OPERATIONAL_NETWORKS as readonly string[]).includes(pair.network)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Network \"${pair.network}\" isn't live yet — only ${OPERATIONAL_NETWORKS.join(', ')} today.`,\n path: [index, 'network'],\n })\n }\n })\n })\n .describe(\n `Every \\`(token, network)\\` pair the payer is allowed to pay with — at least one, up to ${CHARGE_ACCEPTED_PAYMENTS_MAX}. This list is also the only restriction knob: the payer can use any combination of the pairs listed here, and every transfer on one of them is credited and sums toward the charge total (see \\`paidWith\\`) — e.g. a charge accepting USDC and USDT can be confirmed by $9 in USDC plus $1 in USDT, or by USDC arriving on two different accepted networks. To require payment in one specific token on one specific network, list only that single pair — a transfer on any pair not in this list is still recorded (for audit) but never credited. Each network must be live (see \\`GET /v1/networks\\` for the current matrix) — an unconfigured \\`(token, network)\\` combination for your environment is rejected with \\`422 token_not_supported\\`.`,\n )\n\nexport const CHARGE_AMOUNT_MAX = 999_999_999_999\n\nexport const CreateChargeSchema = z\n .object({\n mode: ChargeModeSchema.default('standard'),\n amount: z\n .number()\n .positive()\n .max(CHARGE_AMOUNT_MAX)\n .optional()\n .describe(\n 'Amount to charge, in `currency` units (e.g. `49.9` = $49.90) — up to 6 decimal places; anything more precise is silently truncated. Omit entirely for a charge that accepts any amount — the first credited transfer of any size confirms it, and `isOverpaid` never applies (there is no target to exceed).',\n ),\n currency: z\n .literal('USD')\n .default('USD')\n .describe('Always `USD` today — the only supported currency.'),\n acceptedPayments: AcceptedPaymentsSchema,\n expiresIn: z\n .number()\n .int()\n .min(CHARGE_EXPIRES_IN_MIN_SECONDS)\n .max(CHARGE_EXPIRES_IN_MAX_SECONDS)\n .optional()\n .describe(\n 'Seconds, not minutes or milliseconds — how long the charge stays open, min 60, max 31,536,000 = 365 days. Omit entirely for a charge that never expires (`expiresAt` is `null`) — useful for donations, investments, or any charge with no natural deadline. Cannot be extended or shortened after creation either way.',\n ),\n idempotencyKey: z\n .string()\n .min(1)\n .max(255)\n .optional()\n .describe(\n 'Scoped to your organization. Replaying the same key returns the original charge unchanged instead of creating a duplicate — safe to retry a request after a timeout without double-charging.',\n ),\n externalRef: z\n .string()\n .min(1)\n .max(255)\n .optional()\n .describe(\n 'An opaque correlation id from your own system (e.g. an order id) — echoed back on the charge and in every webhook payload. Not interpreted or validated by Klap.',\n ),\n source: z\n .string()\n .min(1)\n .max(64)\n .optional()\n .describe(\n 'Free-form label for what created this charge (e.g. `\"checkout\"`, `\"invoice\"`) — useful if you create charges from more than one flow and want to tell them apart later. Not a fixed enum; use whatever values make sense to you.',\n ),\n metadata: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Arbitrary key/value data to attach to the charge, returned as-is on every read.'),\n })\n .superRefine((input, ctx) => {\n if (\n input.mode === 'continuous' &&\n (input.amount !== undefined || input.expiresIn !== undefined)\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'mode: \"continuous\" requires both amount and expiresIn to be omitted.',\n path: ['mode'],\n })\n }\n })\n\nexport type CreateChargeInput = z.infer<typeof CreateChargeSchema>\n\nexport type CreateChargeRequest = z.input<typeof CreateChargeSchema>\n\nexport const ChargeSchema = z.object({\n id: z\n .string()\n .describe('Klap-generated id, e.g. `ch_...`. Use this to look up the charge later.'),\n mode: ChargeModeSchema,\n amount: z\n .number()\n .nullable()\n .describe(\n 'The amount originally requested, in `currency` units (up to 6 decimal places). `null` if `amount` was omitted at creation — this charge accepts any amount, and the first credited transfer confirms it.',\n ),\n amountReceived: z\n .number()\n .nullable()\n .describe(\n 'Cumulative amount actually received on-chain so far, in `currency` units (up to 6 decimal places). `null` until the first transfer arrives. Can exceed `amount` — see `isOverpaid` — unless `amount` itself is `null`, in which case `isOverpaid` never applies.',\n ),\n isOverpaid: z\n .boolean()\n .describe(\n '`true` if `amountReceived` ended up greater than `amount`. Klap never refunds the difference automatically — see the docs for why.',\n ),\n currency: z.string().describe('Always `USD` today — the only supported currency.'),\n acceptedPayments: z\n .array(AcceptedPaymentSchema)\n .describe(\n 'Every `(token, network)` pair this charge was configured to accept, unchanged after creation.',\n ),\n paidWith: z\n .array(AcceptedPaymentSchema)\n .describe(\n 'Every distinct `(token, network)` pair that has actually contributed a credited transfer so far — empty until the first one arrives. Can hold more than one entry: a charge accepting several pairs can be paid across a combination of them, and every entry here sums toward `amountReceived`.',\n ),\n address: z\n .string()\n .describe(\n 'The on-chain address the payer must send funds to — identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time — funds sent here go directly to the merchant, Klap never custodies them.',\n ),\n status: ChargeStatusSchema,\n settlementStatus: SettlementStatusSchema.nullable(),\n environment: EnvironmentSchema,\n apiKeyId: z\n .string()\n .nullable()\n .describe(\n 'Which of your API keys created this charge. `null` for a charge created before this field existed.',\n ),\n txHash: z\n .string()\n .nullable()\n .describe(\n 'Transaction hash of the most recent transfer detected for this charge. `null` until a payment is detected.',\n ),\n externalRef: z.string().nullable(),\n source: z.string().nullable(),\n metadata: z.record(z.string(), z.unknown()).nullable(),\n createdAt: z.string().datetime(),\n expiresAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When this charge stops accepting payment, if still `pending`/`partially_paid` by then. `null` if `expiresIn` was omitted at creation — the charge never expires on its own and must be dealt with manually (or left open indefinitely).',\n ),\n confirmedAt: z\n .string()\n .datetime()\n .nullable()\n .describe('When `status` first reached `confirmed`. `null` until then.'),\n settledAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n \"When `settlementStatus` first reached `completed` — the merchant's wallet actually has the funds. `null` until then, including while `settlementStatus` is `pending`/`failed`.\",\n ),\n lastActivityAt: z\n .string()\n .datetime()\n .describe(\n 'When a transfer was last credited toward this charge, or `createdAt` if none has arrived yet. Only meaningful for a charge with no `expiresAt` — see `pausedAt`.',\n ),\n pausedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'Only ever set for a charge with no `expiresAt`: `null` means Klap is actively watching this address in real time (the normal case). A timestamp means no contribution arrived for longer than the inactivity window (90 days for a charge with a goal `amount`, 365 days for one without), so real-time watching was stopped — the charge itself is never closed, a transfer can still arrive and land, just detected on a much slower fallback poll instead of instantly. Clears automatically (and real-time watching resumes) the moment that happens.',\n ),\n})\n\nexport type Charge = z.infer<typeof ChargeSchema>\n\nexport const ListChargesSchema = z\n .object({\n status: ChargeStatusSchema.optional(),\n token: TokenSchema.optional().describe(\n 'Filters on `paidWith.token` — the pair actually paid, not accepted.',\n ),\n network: NetworkSchema.optional().describe(\n 'Filters on `paidWith.network` — the pair actually paid, not accepted.',\n ),\n environment: EnvironmentSchema.optional(),\n since: z\n .string()\n .datetime()\n .optional()\n .describe(\n 'Only return charges created at or after this timestamp (filters on `createdAt`, not on when the status last changed). If polling as a fallback for missed webhooks, use a window at least as wide as the longest `expiresIn` your charges use, or you can miss a long-lived charge that changed status outside a narrower window.',\n ),\n isOverpaid: z\n .enum(['true', 'false'])\n .transform((v) => v === 'true')\n .optional(),\n })\n .extend(PaginationQuerySchema.shape)\n\nexport type ListChargesInput = z.infer<typeof ListChargesSchema>\n\nexport type ListChargesRequest = z.input<typeof ListChargesSchema>\n\nexport const PaginatedChargesSchema = paginatedSchema(ChargeSchema)\n\nexport type PaginatedCharges = z.infer<typeof PaginatedChargesSchema>\n\nexport const ChargeStatusEventSchema = z.object({\n id: z.string(),\n status: ChargeStatusSchema,\n settlementStatus: SettlementStatusSchema.nullable(),\n amount: z.number().nullable(),\n amountReceived: z.number().nullable(),\n paidWith: z.array(AcceptedPaymentSchema),\n})\n\nexport type ChargeStatusEvent = z.infer<typeof ChargeStatusEventSchema>\n","import { z } from 'zod'\nimport { NetworkSchema } from './networks'\nimport { TokenSchema } from './tokens'\n\nexport const PendingDistributionRecipientSchema = z.object({\n address: z.string().describe('On-chain recipient address.'),\n percentAllocation: z\n .number()\n .describe(\"This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).\"),\n})\n\nexport const PendingDistributionSchema = z.object({\n splitAddress: z.string().describe('The on-chain 0xSplits address to call `distribute()` on.'),\n network: NetworkSchema,\n token: TokenSchema,\n recipients: z\n .array(PendingDistributionRecipientSchema)\n .describe(\n 'The exact recipient list to pass to `distribute()` — the split contract only stores a hash of this config, so the caller must supply the identical array to prove it matches. Always present, never reconstructed from partial data.',\n ),\n distributorFeePercent: z\n .number()\n .describe(\n 'Percentage of the split balance paid to whoever calls `distribute()` first (e.g. `0.1` = 0.1%). Frozen at charge creation, same for every distribution today.',\n ),\n estimatedRewardAmount: z\n .number()\n .describe(\n \"Estimate only, in the charge's `currency` units, based on the amount Klap detected on-chain — not a live read of the split's current balance. Read the balance yourself before submitting a transaction; a stale estimate is harmless (see the docs), never a reason to skip that check.\",\n ),\n availableSince: z\n .string()\n .datetime()\n .describe('When this distribution entered its grace period.'),\n graceEndsAt: z\n .string()\n .datetime()\n .describe(\n \"When Klap's own worker may claim this distribution. Racing to call `distribute()` after this timestamp is possible but increasingly likely to lose to the worker.\",\n ),\n})\n\nexport type PendingDistribution = z.infer<typeof PendingDistributionSchema>\n\nexport const PendingDistributionEventSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('distribution.available'),\n distribution: PendingDistributionSchema,\n }),\n z.object({\n type: z.literal('distribution.claimed'),\n splitAddress: z\n .string()\n .describe('No longer claimable — either settled by someone, or picked up by the worker.'),\n }),\n])\n\nexport type PendingDistributionEvent = z.infer<typeof PendingDistributionEventSchema>\n","import { z } from 'zod'\n\nexport const ChargeWebhookEventTypeSchema = z\n .enum([\n 'charge.created',\n 'charge.partially_paid',\n 'charge.confirmed',\n 'charge.expired',\n 'charge.underpaid',\n 'charge.settled',\n 'charge.settlement_failed',\n 'charge.overpaid',\n 'charge.paused',\n 'charge.reactivated',\n 'charge.contribution_received',\n 'charge.contribution_settled',\n ])\n .describe(\n 'Note the distinction between `charge.confirmed` and `charge.settled`: `confirmed` means the payment was detected on-chain; `settled` means the merchant\\'s wallet actually received the funds — a separate, later step. Subscribe to `confirmed` if you only need \"will I get paid,\" or `settled` if you need \"has the money actually arrived.\" `charge.overpaid` fires alongside `charge.confirmed`/`charge.partially_paid` whenever the cumulative amount received ends up above `amount` (see `Charge.isOverpaid`). Every event in this category carries the full `Charge` object as `data`, except `charge.paused`/`charge.reactivated`/`charge.contribution_received`/`charge.contribution_settled` (see below). `charge.paused` fires when a charge with no `expiresAt` has had no contribution for longer than its inactivity window (90 days for a charge with a goal `amount`, 365 days for one without) — Klap stops watching its address in real time, but the charge itself is never closed; `charge.reactivated` fires the moment a transfer lands on a paused charge, detected by the same fallback poller used for missed webhooks (so with much higher latency than normal — pausing trades that away deliberately, see `docs/payments.md`). `charge.contribution_received`/`charge.contribution_settled` are exclusive to `mode: continuous` charges (see `Charge.mode`) — a continuous charge never fires `charge.confirmed`/`charge.settled` at all, since `status` never leaves `pending`; instead every individual transfer fires `contribution_received` on detection and `contribution_settled` once its payout completes, one pair-scoped event per contribution instead of one event for the whole charge. `data` for `charge.paused`: `{ chargeId, lastActivityAt, pausedAt }`; for `charge.reactivated`: `{ chargeId, reactivatedAt }`; for `charge.contribution_received`: `{ chargeId, token, network, amount, txHash, payerAddress }`; for `charge.contribution_settled`: `{ chargeId, token, network, amount, txHash, distributorAddress }`.',\n )\n\nexport const AccountWebhookEventTypeSchema = z\n .enum([\n 'payout_address.changed',\n 'api_key.created',\n 'api_key.revoked',\n 'webhook.created',\n 'webhook.deleted',\n 'webhook.secret_rotated',\n 'fee_tier.updated',\n 'member.removed',\n 'member.role_changed',\n 'member.invited',\n ])\n .describe(\n 'Account and configuration changes — not tied to any single charge. `data` per event: `payout_address.changed`: `{ organizationId, from, to }` (`from` nullable); `api_key.created`/`api_key.revoked`: `{ apiKeyId, name, environment, hint }`; `webhook.created`/`webhook.deleted`/`webhook.secret_rotated`: `{ webhookId, url }`; `fee_tier.updated`: `{ organizationId, previousFeePercent, newFeePercent }`; `member.removed`: `{ userId, email, role }`; `member.role_changed`: `{ userId, email, role, previousRole }`; `member.invited`: `{ organizationId, email, role, invitedByUserId }`.',\n )\n\nexport const WebhookDeliveryEventTypeSchema = z\n .enum(['webhook.delivery_failed', 'webhook.delivery_recovered', 'webhook.endpoint_unhealthy'])\n .describe(\n \"Meta-events about the health of your own webhook endpoints — useful for monitoring without polling `GET /v1/webhooks/{id}/deliveries`. `webhook.endpoint_unhealthy` fires once when a webhook's failure rate over the trailing 24h crosses 20%, and `webhook.delivery_recovered` fires once when a delivery to that webhook next succeeds. `data` for every event in this category: `{ webhookId, url, failureRatio? }` (`failureRatio` only present on `webhook.endpoint_unhealthy`).\",\n )\n\nexport const SecurityWebhookEventTypeSchema = z\n .enum([\n 'auth.login',\n 'auth.login_failed',\n 'auth.suspicious_activity',\n 'auth.email_verified',\n 'auth.password_reset_requested',\n 'auth.password_reset_completed',\n ])\n .describe(\n 'Account security signals. `auth.suspicious_activity` is a soft heuristic (login from an IP not seen on this account before), not a block — evaluate it, not enforce against it. `auth.password_reset_requested` only ever dispatches when the requested email actually matches an account (there is nowhere to notify otherwise) — `POST /v1/auth/forgot-password` itself always returns the same generic response either way, so this event never becomes a second channel for the same enumeration question the endpoint response deliberately avoids answering. `data` per event: `auth.login`: `{ userId, ipAddress }`; `auth.login_failed`: `{ email, ipAddress }`; `auth.suspicious_activity`: `{ userId, ipAddress, previousIpAddress }`; `auth.email_verified`/`auth.password_reset_requested`/`auth.password_reset_completed`: `{ userId, email }`.',\n )\n\nexport const WebhookEventTypeSchema = z.union([\n ChargeWebhookEventTypeSchema,\n AccountWebhookEventTypeSchema,\n WebhookDeliveryEventTypeSchema,\n SecurityWebhookEventTypeSchema,\n])\n\nexport type WebhookEventType = z.infer<typeof WebhookEventTypeSchema>\n\nexport const WebhookCategorySchema = z\n .enum(['payments', 'account', 'webhooks', 'security'])\n .describe(\n 'Subscribe to every event in a category via `eventCategories` instead of listing events one by one — new events added to a category later arrive automatically, no subscription update needed.',\n )\nexport type WebhookCategory = z.infer<typeof WebhookCategorySchema>\n\nfunction buildCategoryMap(): Record<WebhookEventType, WebhookCategory> {\n const map = {} as Record<WebhookEventType, WebhookCategory>\n for (const event of ChargeWebhookEventTypeSchema.options) map[event] = 'payments'\n for (const event of AccountWebhookEventTypeSchema.options) map[event] = 'account'\n for (const event of WebhookDeliveryEventTypeSchema.options) map[event] = 'webhooks'\n for (const event of SecurityWebhookEventTypeSchema.options) map[event] = 'security'\n return map\n}\n\n/** Single source of truth for which category each event belongs to — see `webhook-events.test.ts` for the completeness check. */\nexport const EVENT_CATEGORY_MAP = buildCategoryMap()\n\nexport const WEBHOOK_EVENT_CATEGORIES: Record<WebhookCategory, readonly WebhookEventType[]> = {\n payments: ChargeWebhookEventTypeSchema.options,\n account: AccountWebhookEventTypeSchema.options,\n webhooks: WebhookDeliveryEventTypeSchema.options,\n security: SecurityWebhookEventTypeSchema.options,\n}\n\nexport const TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([\n 'charge.created',\n 'charge.paused',\n 'charge.reactivated',\n 'charge.contribution_received',\n 'charge.contribution_settled',\n]).describe(\n \"Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into — everything except `charge.created` (a charge already exists by the time you have an id to trigger against), `charge.paused`/`charge.reactivated` (driven by a background worker on real inactivity, not a payment state — nothing meaningful to simulate or wait for on a fresh sandbox charge), and `charge.contribution_received`/`charge.contribution_settled` (exclusive to `mode: continuous` charges, which this trigger endpoint does not support simulating today — see `POST /v1/charges/{id}/trigger`'s own description).\",\n)\n\nexport type TriggerableChargeEvent = z.infer<typeof TriggerableChargeEventSchema>\n\nexport const NonChargeTriggerableEventSchema = z.union([\n AccountWebhookEventTypeSchema,\n WebhookDeliveryEventTypeSchema,\n SecurityWebhookEventTypeSchema,\n])\nexport type NonChargeTriggerableEvent = z.infer<typeof NonChargeTriggerableEventSchema>\n","import { z } from 'zod'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\nimport { EVENT_CATEGORY_MAP, WebhookCategorySchema, WebhookEventTypeSchema } from './webhook-events'\n\nexport const WEBHOOK_EVENTS_WILDCARD = '*'\n\nexport const CreateWebhookSchema = z\n .object({\n url: z\n .string()\n .max(2048)\n .url()\n .describe(\n 'Must be HTTPS and resolve to a public address — private/internal IPs are rejected.',\n ),\n events: z\n .array(z.union([WebhookEventTypeSchema, z.literal(WEBHOOK_EVENTS_WILDCARD)]))\n .max(Object.keys(EVENT_CATEGORY_MAP).length + 1)\n .default([])\n .describe(\n 'Individual event types to receive, or `\"*\"` for every event (combine with `excludeEvents` to opt back out of specific ones). Omit in favor of `eventCategories` if you want whole categories instead.',\n ),\n eventCategories: z\n .array(WebhookCategorySchema)\n .max(WebhookCategorySchema.options.length)\n .default([])\n .describe(\n 'Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required.',\n ),\n excludeEvents: z\n .array(WebhookEventTypeSchema)\n .max(Object.keys(EVENT_CATEGORY_MAP).length)\n .default([])\n .describe(\n 'Event types to exclude even if selected via `events: [\"*\"]` or `eventCategories`.',\n ),\n })\n .refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {\n message: 'must select at least one event via `events` or `eventCategories`',\n path: ['events'],\n })\n\nexport type CreateWebhookInput = z.infer<typeof CreateWebhookSchema>\n\nexport type CreateWebhookRequest = z.input<typeof CreateWebhookSchema>\n\nexport const WebhookSchema = z.object({\n id: z.string(),\n url: z.string(),\n events: z.array(WebhookEventTypeSchema),\n eventCategories: z.array(WebhookCategorySchema),\n excludeEvents: z.array(WebhookEventTypeSchema),\n isWildcard: z.boolean(),\n secret: z\n .string()\n .describe(\n \"The signing secret, used to verify the `X-Klap-Signature` header on every delivery. Returned in full only this once — store it now, it is not recoverable afterward. Header format: `t=<unix-seconds>,v1=<hex-encoded HMAC-SHA256>`. Compute the expected signature as `HMAC-SHA256(secret, \\\"${t}.${raw request body}\\\")` (hex-encoded) and compare it to `v1` using a constant-time comparison; as a replay-protection measure, also reject if `t` is too far from the current time — Klap does not enforce or check any particular tolerance server-side, so the exact threshold is entirely the receiver's own policy call. An official SDK's `constructEvent()`/`verifySignature()` do this for you, defaulting to a 300-second tolerance, overridable via `constructEvent`'s `toleranceSeconds` option — see github.com/klappay for available SDKs.\",\n ),\n createdAt: z.string().datetime(),\n})\n\nexport type Webhook = z.infer<typeof WebhookSchema>\n\nexport const WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({\n hint: z\n .string()\n .describe('A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).'),\n})\nexport type WebhookListItem = z.infer<typeof WebhookListItemSchema>\n\nexport const WebhookPayloadSchema = z.object({\n id: z\n .string()\n .describe('Unique id for this specific delivery — also sent as the `X-Klap-Delivery` header.'),\n event: WebhookEventTypeSchema,\n createdAt: z.string().datetime(),\n data: z\n .unknown()\n .describe(\n 'Event-specific data. Charge events (`charge.*`) carry the full `Charge` object; account/security/webhook-delivery events carry a smaller, event-specific object — see `WebhookEventDataMap`/`TypedWebhookPayload` for the exact shape per event, or docs/webhooks.md.',\n ),\n})\n\nexport type WebhookPayload = z.infer<typeof WebhookPayloadSchema>\n\nexport const WebhookDeliveryStatusSchema = z.enum(['pending', 'delivered', 'failed'])\nexport type WebhookDeliveryStatus = z.infer<typeof WebhookDeliveryStatusSchema>\n\nexport const WebhookDeliverySchema = z.object({\n id: z.string(),\n webhookId: z.string(),\n event: WebhookEventTypeSchema,\n status: WebhookDeliveryStatusSchema.describe(\n '`pending`: still retrying. `delivered`: got a 2xx response. `failed`: retries exhausted (5 attempts over ~24h) — use `POST /v1/webhooks/{id}/deliveries/{deliveryId}/retry` to try again manually.',\n ),\n attempts: z.number(),\n responseCode: z\n .number()\n .nullable()\n .describe(\n 'HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all.',\n ),\n nextRetryAt: z.string().datetime().nullable(),\n deliveredAt: z.string().datetime().nullable(),\n createdAt: z.string().datetime(),\n})\n\nexport type WebhookDelivery = z.infer<typeof WebhookDeliverySchema>\n\nexport const ListWebhookDeliveriesSchema = PaginationQuerySchema\n\nexport type ListWebhookDeliveriesInput = z.infer<typeof ListWebhookDeliveriesSchema>\n\nexport type ListWebhookDeliveriesRequest = z.input<typeof ListWebhookDeliveriesSchema>\n\nexport const PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema)\n\nexport type PaginatedWebhookDeliveries = z.infer<typeof PaginatedWebhookDeliveriesSchema>\n","import { z } from 'zod'\nimport { EnvironmentSchema } from './environment'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\n\nexport const CreateApiKeySchema = z.object({\n name: z\n .string()\n .min(1)\n .max(64)\n .describe(\n 'A label to help you tell keys apart (e.g. `\"production backend\"`). Not used for anything functional.',\n ),\n environment: EnvironmentSchema.describe(\n '`live` keys move real funds on Base mainnet; `test` keys settle on Base Sepolia (a real testnet, no real money) and additionally unlock `POST /v1/sandbox/*` for simulating events with zero on-chain activity at all.',\n ),\n})\n\nexport type CreateApiKeyInput = z.infer<typeof CreateApiKeySchema>\n\nexport const ApiKeySchema = z.object({\n id: z.string(),\n name: z.string(),\n environment: EnvironmentSchema.describe(\n '`live` keys authenticate real charges on Base mainnet; `test` keys authenticate the same charge lifecycle on Base Sepolia (a real testnet) and additionally unlock `/v1/sandbox/*` for synthetic event simulation.',\n ),\n key: z\n .string()\n .optional()\n .describe(\n 'The full secret key (`klap_live_...` / `klap_test_...`), used as the `Authorization: Bearer` value on `/v1/charges`, `/v1/webhooks`, and `/v1/sandbox` requests. Present only in the response to `POST /v1/api-keys` — never returned again afterward, so store it immediately.',\n ),\n hint: z\n .string()\n .describe(\n \"A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't.\",\n ),\n createdAt: z.string().datetime(),\n lastUsedAt: z\n .string()\n .datetime()\n .nullable()\n .describe('Updated on every successful authenticated request. `null` if never used.'),\n createdByUserId: z\n .string()\n .nullable()\n .describe(\n 'Which member of the organization created this key. `null` for a key created before this field existed.',\n ),\n})\n\nexport type ApiKey = z.infer<typeof ApiKeySchema>\n\nexport const ListApiKeysSchema = PaginationQuerySchema\n\nexport type ListApiKeysInput = z.infer<typeof ListApiKeysSchema>\n\nexport type ListApiKeysRequest = z.input<typeof ListApiKeysSchema>\n\nexport const PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema)\n\nexport type PaginatedApiKeys = z.infer<typeof PaginatedApiKeysSchema>\n","import { z } from 'zod'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\n\nexport const UserRoleSchema = z\n .enum(['owner', 'admin', 'member'])\n .describe(\n \"`owner`: full access, and the organization must always keep at least one. `admin`: can manage `member`s but not other `admin`s. `member`: no management permissions. You can only manage a member with a strictly lower role than your own, unless you're an `owner`.\",\n )\nexport type UserRole = z.infer<typeof UserRoleSchema>\n\nexport const UpdateUserRoleSchema = z.object({\n role: UserRoleSchema,\n})\n\nexport type UpdateUserRoleInput = z.infer<typeof UpdateUserRoleSchema>\n\nexport const UserSchema = z.object({\n id: z.string(),\n email: z.string(),\n name: z.string().nullable(),\n role: UserRoleSchema.describe('Your role within the organization this user was fetched from.'),\n emailVerifiedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When this address was confirmed via the emailed verification link. `null` until then. Required (non-null) for two specific actions: creating a `live` API key (`POST /v1/api-keys`) and changing `Organization.payoutAddress` (`PATCH /v1/organization`) — everything else works regardless of verification status.',\n ),\n createdAt: z.string().datetime(),\n})\n\nexport type User = z.infer<typeof UserSchema>\n\nexport const ListUsersSchema = PaginationQuerySchema\n\nexport type ListUsersInput = z.infer<typeof ListUsersSchema>\n\nexport type ListUsersRequest = z.input<typeof ListUsersSchema>\n\nexport const PaginatedUsersSchema = paginatedSchema(UserSchema)\n\nexport type PaginatedUsers = z.infer<typeof PaginatedUsersSchema>\n","import { z } from 'zod'\nimport { UserSchema } from './users'\n\nexport const NormalizedEmailSchema = z\n .string()\n .trim()\n .max(255)\n .toLowerCase()\n .email()\n .transform((email) => email.normalize('NFC'))\n .describe(\n \"Trimmed, lowercased, and NFC-normalized server-side before use — case/whitespace don't matter.\",\n )\n\nexport const SignupSchema = z.object({\n email: NormalizedEmailSchema,\n password: z.string().min(8).max(128).describe('8-128 characters. No other complexity rule.'),\n})\n\nexport type SignupInput = z.infer<typeof SignupSchema>\n\nexport const LoginSchema = z.object({\n email: NormalizedEmailSchema,\n password: z.string().min(1).max(128),\n})\n\nexport type LoginInput = z.infer<typeof LoginSchema>\n\nexport const VerifyEmailSchema = z.object({\n token: z\n .string()\n .min(1)\n .describe('The token from the verification email — passed as-is, not the account email.'),\n})\nexport type VerifyEmailInput = z.infer<typeof VerifyEmailSchema>\n\nexport const ForgotPasswordSchema = z.object({\n email: NormalizedEmailSchema,\n})\nexport type ForgotPasswordInput = z.infer<typeof ForgotPasswordSchema>\n\nexport const ResetPasswordSchema = z.object({\n token: z.string().min(1).describe('The token from the password reset email.'),\n newPassword: z.string().min(8).max(128),\n})\nexport type ResetPasswordInput = z.infer<typeof ResetPasswordSchema>\n\nexport const MessageResponseSchema = z.object({\n message: z.string().describe('Human-readable confirmation, safe to show a user directly.'),\n})\nexport type MessageResponse = z.infer<typeof MessageResponseSchema>\n\nexport const AuthResponseSchema = z.object({\n token: z\n .string()\n .describe(\n 'Session JWT, valid 7 days — use as `Authorization: Bearer <token>` on every `/v1/organizations/*` request (which nests API keys, members, and invitations — see `GET /v1/organizations`). This token identifies only you; it carries no organization or role — every `/v1/organizations/{id}/*` request is authorized fresh against your actual membership in that specific organization. This is a separate credential from an API key: it authenticates a human/dashboard session, not payment operations. Create an API key with it before you can create charges.',\n ),\n user: UserSchema.omit({ createdAt: true, role: true }),\n})\n\nexport type AuthResponse = z.infer<typeof AuthResponseSchema>\n","import { z } from 'zod'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\nimport { UserRoleSchema } from './users'\n\nexport const UpdateOrganizationSchema = z.object({\n name: z.string().min(1).max(255).optional().describe(\"The organization's display name.\"),\n payoutAddress: z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a valid EVM address')\n .optional()\n .describe(\n \"The wallet that receives the merchant's share of every future charge. Changing this only affects charges created after the change — an already-created charge's payout split is frozen from creation and is never retroactively affected. Required before you can create any charge. Any casing is accepted — EIP-55 checksum casing is not required or verified.\",\n ),\n})\n\nexport type UpdateOrganizationInput = z.infer<typeof UpdateOrganizationSchema>\n\nexport const OrganizationSchema = z.object({\n id: z.string(),\n name: z.string(),\n payoutAddress: z\n .string()\n .nullable()\n .describe('`null` until configured — `POST /v1/charges` fails until this is set.'),\n currentFeePercent: z\n .number()\n .describe(\n 'Your current platform fee percentage, based on trailing monthly volume — lower volume tiers pay a higher percentage. `1.5` means 1.5%, not a 0–1 fraction. Frozen onto each charge at creation, so this can change between charges without affecting ones already created.',\n ),\n feeUpdatedAt: z.string().datetime().nullable(),\n createdAt: z.string().datetime(),\n})\n\nexport type Organization = z.infer<typeof OrganizationSchema>\n\nexport const OrganizationWithRoleSchema = OrganizationSchema.extend({\n role: UserRoleSchema.describe('Your own role within this specific organization.'),\n})\n\nexport type OrganizationWithRole = z.infer<typeof OrganizationWithRoleSchema>\n\nexport const PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema)\n\nexport type PaginatedOrganizations = z.infer<typeof PaginatedOrganizationsSchema>\n\nexport const ListOrganizationsSchema = PaginationQuerySchema\n\nexport type ListOrganizationsInput = z.infer<typeof ListOrganizationsSchema>\n\nexport type ListOrganizationsRequest = z.input<typeof ListOrganizationsSchema>\n","import { z } from 'zod'\nimport { NormalizedEmailSchema } from './auth'\nimport { UserRoleSchema } from './users'\n\nexport const InviteUserSchema = z.object({\n email: NormalizedEmailSchema,\n role: UserRoleSchema.default('member').describe(\n 'The role the invitee will hold once they accept — subject to the same management-hierarchy rule as `PATCH /v1/organizations/{id}/users/{userId}`: an `admin` inviter cannot invite an `admin` or `owner`.',\n ),\n})\n\nexport type InviteUserInput = z.infer<typeof InviteUserSchema>\n\nexport type InviteUserRequest = z.input<typeof InviteUserSchema>\n\nexport const AcceptInvitationSchema = z.object({\n token: z.string().min(1).describe('The token from the invitation email.'),\n password: z\n .string()\n .min(8)\n .max(128)\n .optional()\n .describe(\n 'Required only if the invited email has no existing Klap account — a new account is created along with the membership. Ignored if the account already exists.',\n ),\n})\n\nexport type AcceptInvitationInput = z.infer<typeof AcceptInvitationSchema>\n\nexport const InvitationSchema = z.object({\n id: z.string(),\n organizationId: z.string(),\n email: z.string(),\n role: UserRoleSchema,\n invitedByUserId: z.string().describe('Which member of the organization sent this invitation.'),\n expiresAt: z.string().datetime(),\n createdAt: z.string().datetime(),\n})\n\nexport type Invitation = z.infer<typeof InvitationSchema>\n","import { z } from 'zod'\nimport { NetworkSchema } from './networks'\nimport { TokenSchema } from './tokens'\nimport { WebhookEventTypeSchema } from './webhook-events'\n\nexport const TransactionSourceSchema = z\n .enum(['moralis_webhook', 'reconciliation_job', 'sandbox'])\n .describe(\n 'How this transfer was detected: `moralis_webhook` (the normal path), `reconciliation_job` (a fallback poller caught it after the webhook was missed or delayed), or `sandbox` (simulated via `POST /v1/sandbox/charges/{id}/trigger`, no real on-chain transfer).',\n )\nexport type TransactionSource = z.infer<typeof TransactionSourceSchema>\n\nexport const TimelineEventTypeSchema = z\n .enum([\n 'charge.created',\n 'charge.expired',\n 'transaction.detected',\n 'split.distributed',\n 'webhook.dispatched',\n 'webhook.delivered',\n 'webhook.failed',\n ])\n .describe(\n '`charge.created`: the charge was created. `charge.expired`: `expiresAt` passed with no full payment. `transaction.detected`: a raw on-chain transfer was seen (see the `event`-shaped fields below for details — a charge can have more than one, e.g. a partial payment followed by the rest). `split.distributed`: a payout to the merchant completed on-chain, for one contributing `(token, network)` pair — a charge settled across more than one pair emits one of these per pair (see the `token`/`network` fields below). `webhook.dispatched`/`webhook.delivered`/`webhook.failed`: one specific delivery *attempt* for one webhook subscription — `failed` here means this single attempt failed, not that all retries were exhausted (see `WebhookDeliveryStatusSchema` for the exhausted-all-retries state).',\n )\nexport type TimelineEventType = z.infer<typeof TimelineEventTypeSchema>\n\nexport const TimelineEventSchema = z.object({\n type: TimelineEventTypeSchema,\n at: z.string().datetime(),\n txHash: z\n .string()\n .optional()\n .describe('Present for `transaction.detected` and `split.distributed` events only.'),\n amount: z\n .number()\n .optional()\n .describe(\n 'Present for `transaction.detected` events only — the amount that specific transfer carried.',\n ),\n source: TransactionSourceSchema.optional().describe(\n 'Present for `transaction.detected` events only.',\n ),\n token: TokenSchema.optional().describe(\n 'Present for `transaction.detected` and `split.distributed` events — which token this specific transfer, or settlement, used. A charge can accept (and be settled across) more than one `(token, network)` pair (see `Charge.acceptedPayments`); this is how to tell which one a given event actually used.',\n ),\n network: NetworkSchema.optional().describe(\n 'Present for `transaction.detected` and `split.distributed` events — which network this specific transfer, or settlement, used.',\n ),\n causedTransition: z\n .boolean()\n .optional()\n .describe(\n \"Present for `transaction.detected` events only. `true` if this specific transfer changed the charge's status (e.g. PENDING→CONFIRMED) — a charge paid in installments can have more than one such event.\",\n ),\n event: WebhookEventTypeSchema.optional().describe(\n 'Present for `webhook.*` events only — which event type this delivery was for.',\n ),\n responseCode: z\n .number()\n .nullable()\n .optional()\n .describe(\n 'Present for `webhook.*` events only — HTTP status your endpoint returned, or `null` if the request never connected.',\n ),\n attempts: z\n .number()\n .optional()\n .describe(\n 'Present for `webhook.*` events only — how many delivery attempts have been made so far.',\n ),\n})\nexport type TimelineEvent = z.infer<typeof TimelineEventSchema>\n","import { z } from 'zod'\nimport { NetworkSchema } from './networks'\nimport { TokenSchema } from './tokens'\n\nexport const SplitRecipientRoleSchema = z\n .enum(['merchant', 'klap_fee', 'distributor_incentive'])\n .describe(\n '`merchant`: the payout recipient. `klap_fee`: the platform fee. `distributor_incentive`: the (usually small) reward paid to whoever triggered the on-chain settlement — may be Klap or a third party, see `address`.',\n )\nexport type SplitRecipientRole = z.infer<typeof SplitRecipientRoleSchema>\n\nexport const VerifySplitEntrySchema = z.object({\n role: SplitRecipientRoleSchema,\n address: z\n .string()\n .nullable()\n .describe(\n 'On-chain recipient address for this share. For `distributor_incentive`, this is `null` until settlement actually happens — there is no fixed address, it goes to whoever calls the settlement transaction.',\n ),\n percentAllocation: z\n .number()\n .describe(\"This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%).\"),\n amountUSD: z.number(),\n})\n\nexport const VerifyPaymentSchema = z.object({\n token: TokenSchema,\n network: NetworkSchema,\n amountReceived: z\n .number()\n .describe('Cumulative amount received on this specific `(token, network)` pair.'),\n txHash: z\n .string()\n .describe('The on-chain transaction hash of the most recent transfer on this pair.'),\n explorerTxUrl: z.string().describe('Direct link to `txHash` on the relevant block explorer.'),\n split: z\n .array(VerifySplitEntrySchema)\n .describe(\n \"The exact breakdown of where this pair's payment went — merchant's share, Klap's fee, and (once settled) the settlement incentive.\",\n ),\n splitTxHash: z\n .string()\n .nullable()\n .describe(\n 'Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then.',\n ),\n settledAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n \"When settlement completed for this pair — the merchant's wallet actually has the funds. `null` until then.\",\n ),\n})\nexport type VerifyPayment = z.infer<typeof VerifyPaymentSchema>\n\nexport const VerifyChargeSchema = z.object({\n id: z.string(),\n amount: z\n .number()\n .nullable()\n .describe('The amount originally requested. `null` if the charge accepted any amount.'),\n amountReceived: z\n .number()\n .describe(\n 'The actual cumulative amount received across every contributing pair — can exceed `amount` on an overpayment.',\n ),\n confirmedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When the charge reached `confirmed`. `null` for a `mode: continuous` charge — it never reaches a single confirmed moment (`status` stays `pending` for its whole life, see `Charge.mode`); use each entry in `payments[].settledAt` for per-contribution timing instead.',\n ),\n splitAddress: z\n .string()\n .describe(\n 'The on-chain address the payment was sent to — identical across every accepted network.',\n ),\n payments: z\n .array(VerifyPaymentSchema)\n .describe(\n 'One entry per `(token, network)` pair that actually contributed funds — a charge accepting several pairs can be confirmed by a combination of them, each proven and settled independently.',\n ),\n})\n\nexport type VerifyCharge = z.infer<typeof VerifyChargeSchema>\n","import { z } from 'zod'\n\nexport const HealthSchema = z.object({\n status: z\n .enum(['ok', 'error'])\n .describe(\n '`error` when the database connectivity check fails — the HTTP status code mirrors this (503 instead of 200), so a plain uptime check (not just a JSON-aware one) still catches a DB outage.',\n ),\n version: z.string(),\n timestamp: z.string().datetime(),\n db: z\n .enum(['ok', 'error'])\n .describe('Result of a real database connectivity check, not just a process-alive check.'),\n pendingWebhooks: z\n .number()\n .describe('Count of webhook deliveries still awaiting a successful attempt.'),\n oldestPendingChargeAgeSeconds: z\n .number()\n .nullable()\n .describe('Age of the oldest still-unpaid charge, in seconds. `null` if there are none.'),\n lastMoralisEventAgeSeconds: z\n .number()\n .nullable()\n .describe(\n 'Seconds since the last on-chain payment notification was received — a cheap signal for whether payment detection is currently working. `null` if none have ever been received.',\n ),\n})\n\nexport type Health = z.infer<typeof HealthSchema>\n","import { z } from 'zod'\nimport { CHARGE_AMOUNT_MAX } from './charges'\nimport { NonChargeTriggerableEventSchema, TriggerableChargeEventSchema } from './webhook-events'\n\nexport const SandboxTriggerSchema = z.object({\n event: TriggerableChargeEventSchema,\n amount: z\n .number()\n .positive()\n .max(CHARGE_AMOUNT_MAX)\n .optional()\n .describe(\n 'Used with `charge.partially_paid` (amount to simulate as received so far — must be less than the charge amount, defaults to half of it if omitted) and with `charge.overpaid` (amount received — must be greater than the charge amount, defaults to 1.5x it if omitted). Ignored for every other event.',\n ),\n})\n\nexport type SandboxTriggerInput = z.infer<typeof SandboxTriggerSchema>\n\nexport const SandboxEventTriggerSchema = z.object({\n event: NonChargeTriggerableEventSchema.describe(\n 'Any account, security, or webhook-delivery event — simulates it with synthetic data against your own webhooks, no real state change or precondition required (unlike `POST /v1/sandbox/charges/{id}/trigger`, which acts on a real charge).',\n ),\n})\n\nexport type SandboxEventTriggerInput = z.infer<typeof SandboxEventTriggerSchema>\n","import { z } from 'zod'\nimport { AcceptedPaymentSchema } from './charges'\n\nexport const CapabilitiesSchema = z.object({\n acceptedPayments: z\n .array(AcceptedPaymentSchema)\n .describe(\n 'Every `(token, network)` pair actually configured for your environment right now — read straight from the same lookup `POST /v1/charges` validates `acceptedPayments` against, so it can never list a pair that charge creation would then reject. Use this to build a picker UI instead of hardcoding the matrix client-side.',\n ),\n})\nexport type Capabilities = z.infer<typeof CapabilitiesSchema>\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,OAAO,EAAE,OAAO;AAAA,IACd,MAAM,EACH,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,SAAS,EACN,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,OAAO,EACJ,OAAO,EACP,SAAS,EACT,SAAS,2DAA2D;AAAA,EACzE,CAAC;AACH,CAAC;;;ACnBD,SAAS,KAAAA,UAAS;AAEX,IAAM,oBAAoBA,GAC9B,KAAK,CAAC,QAAQ,MAAM,CAAC,EACrB;AAAA,EACC;AACF;;;ACNF,SAAS,KAAAC,UAAS;AAEX,IAAM,gBAAgBA,GAC1B,KAAK,CAAC,QAAQ,YAAY,WAAW,YAAY,YAAY,aAAa,KAAK,CAAC,EAChF,SAAS,wCAAwC;AAI7C,IAAM,iBAA0C;AAAA,EACrD,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,KAAK;AACP;AAEO,IAAM,oBAA6C;AAAA,EACxD,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,KAAK;AACP;AAEO,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC/CA,SAAS,KAAAC,UAAS;AAEX,IAAM,uBAAuB;AAC7B,IAAM,uBAAuB;AAC7B,IAAM,2BAA2B;AAEjC,IAAM,wBA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D,SAAS,KAAAC,WAAS;AAEX,IAAM,eAAeA,IAAE,OAAO;AAAA,EACnC,QAAQA,IACL,KAAK,CAAC,MAAM,OAAO,CAAC,EACpB;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAASA,IAAE,OAAO;AAAA,EAClB,WAAWA,IAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,IAAIA,IACD,KAAK,CAAC,MAAM,OAAO,CAAC,EACpB,SAAS,+EAA+E;AAAA,EAC3F,iBAAiBA,IACd,OAAO,EACP,SAAS,kEAAkE;AAAA,EAC9E,+BAA+BA,IAC5B,OAAO,EACP,SAAS,EACT,SAAS,8EAA8E;AAAA,EAC1F,4BAA4BA,IACzB,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;;;AC1BD,SAAS,KAAAC,WAAS;AAIX,IAAM,uBAAuBC,IAAE,OAAO;AAAA,EAC3C,OAAO;AAAA,EACP,QAAQA,IACL,OAAO,EACP,SAAS,EACT,IAAI,iBAAiB,EACrB,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;AAIM,IAAM,4BAA4BA,IAAE,OAAO;AAAA,EAChD,OAAO,gCAAgC;AAAA,IACrC;AAAA,EACF;AACF,CAAC;;;ACtBD,SAAS,KAAAC,WAAS;AAGX,IAAM,qBAAqBC,IAAE,OAAO;AAAA,EACzC,kBAAkBA,IACf,MAAM,qBAAqB,EAC3B;AAAA,IACC;AAAA,EACF;AACJ,CAAC;","names":["z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/environment.ts","../src/networks.ts","../src/pagination.ts","../src/tokens.ts","../src/charges.ts","../src/distributions.ts","../src/metrics.ts","../src/webhook-events.ts","../src/webhooks.ts","../src/api-keys.ts","../src/users.ts","../src/auth.ts","../src/organization.ts","../src/invitations.ts","../src/timeline.ts","../src/verify.ts","../src/health.ts","../src/sandbox.ts","../src/capabilities.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const ErrorPayloadSchema = z.object({\n error: z.object({\n code: z\n .string()\n .describe(\n 'A stable, machine-readable error identifier (e.g. `validation_error`, `invalid_credentials`).',\n ),\n message: z\n .string()\n .describe(\n 'Human-readable explanation, safe to log or show a developer — not meant for end users.',\n ),\n param: z\n .string()\n .optional()\n .describe('Which request field the error refers to, when applicable.'),\n }),\n})\n\nexport type ErrorPayload = z.infer<typeof ErrorPayloadSchema>\n","import { z } from 'zod'\n\nexport const EnvironmentSchema = z\n .enum(['live', 'test'])\n .describe(\n '`live` or `test`, matching the `klap_live_.../klap_test_...` prefix of the API key that created or is scoped to this resource. `live` settles on Base mainnet with real funds; `test` settles on Base Sepolia, a separate testnet — real on-chain activity, but never real money.',\n )\nexport type Environment = z.infer<typeof EnvironmentSchema>\n","import { z } from 'zod'\n\nexport const NetworkSchema = z\n .enum(['base', 'optimism', 'polygon', 'ethereum', 'arbitrum', 'avalanche', 'bnb'])\n .describe('The blockchain a charge/payment is on.')\n\nexport type Network = z.infer<typeof NetworkSchema>\n\nexport const NETWORK_LABELS: Record<Network, string> = {\n base: 'Base',\n optimism: 'Optimism',\n polygon: 'Polygon',\n ethereum: 'Ethereum',\n arbitrum: 'Arbitrum',\n avalanche: 'Avalanche',\n bnb: 'BNB Chain',\n}\n\nexport const NETWORK_EXPLORERS: Record<Network, string> = {\n base: 'https://basescan.org',\n optimism: 'https://optimistic.etherscan.io',\n polygon: 'https://polygonscan.com',\n ethereum: 'https://etherscan.io',\n arbitrum: 'https://arbiscan.io',\n avalanche: 'https://snowtrace.io',\n bnb: 'https://bscscan.com',\n}\n\nexport const EVM_NETWORKS = [\n 'base',\n 'optimism',\n 'polygon',\n 'ethereum',\n 'arbitrum',\n 'avalanche',\n 'bnb',\n] as const\nexport type EvmNetwork = (typeof EVM_NETWORKS)[number]\n\nexport const OPERATIONAL_NETWORKS = [\n 'base',\n 'arbitrum',\n 'optimism',\n 'polygon',\n 'ethereum',\n 'avalanche',\n 'bnb',\n] as const\nexport type OperationalNetwork = (typeof OPERATIONAL_NETWORKS)[number]\n","import { z } from 'zod'\n\nexport const PAGINATION_LIMIT_MIN = 1\nexport const PAGINATION_LIMIT_MAX = 100\nexport const PAGINATION_LIMIT_DEFAULT = 20\n\nexport const PaginationQuerySchema = z.object({\n limit: z.coerce\n .number()\n .min(PAGINATION_LIMIT_MIN)\n .max(PAGINATION_LIMIT_MAX)\n .default(PAGINATION_LIMIT_DEFAULT)\n .describe(\n `Max items to return per page (${PAGINATION_LIMIT_MIN}–${PAGINATION_LIMIT_MAX}, default ${PAGINATION_LIMIT_DEFAULT}).`,\n ),\n cursor: z\n .string()\n .max(500)\n .optional()\n .describe(\n \"Opaque — pass the previous response's `nextCursor` verbatim to fetch the next page. Never construct or parse this value yourself; its shape is not part of the public contract and may change.\",\n ),\n})\n\nexport type PaginationQuery = z.infer<typeof PaginationQuerySchema>\n\nexport type PaginationQueryRequest = z.input<typeof PaginationQuerySchema>\n\nexport function paginatedSchema<T extends z.ZodTypeAny>(itemSchema: T) {\n return z.object({\n data: z.array(itemSchema),\n nextCursor: z\n .string()\n .nullable()\n .describe('Pass as `cursor` to fetch the next page. `null` when there are no more results.'),\n hasMore: z.boolean(),\n })\n}\n","import { z } from 'zod'\nimport type { Environment } from './environment'\nimport { OPERATIONAL_NETWORKS } from './networks'\nimport type { Network } from './networks'\n\nexport const TokenSchema = z\n .enum(['USDC', 'USDT'])\n .describe(\n `Which stablecoin the payer will send. Support depends on both \\`network\\` and \\`environment\\` — not every token/network/environment combination is deployed; today, both \\`USDC\\` and \\`USDT\\` are deployed on every operational network's \\`live\\` side except BNB Chain (\\`${OPERATIONAL_NETWORKS.join(', ')}\\`), but \\`test\\` coverage varies per network — Base, Optimism, and Ethereum each have a \\`test\\` environment (\\`USDC\\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \\`422 token_not_supported\\`, not silently accepted. **BNB Chain's \\`USDC\\` address is Binance-Peg USDC, not an official Circle deployment** — Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \\`TOKEN_ADDRESSES\\` entry (all verified directly against their real issuer). Accepted at the payer's own risk — Klappay does not verify or guarantee Binance's collateral backing it. \\`USDT\\` on BNB Chain is Tether's own official issuance, same trust model as everywhere else. More tokens/networks are expected to be added over time — check \\`TOKEN_ADDRESSES\\` in \\`@klappay/types\\` (or a future \\`GET /v1/networks\\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`,\n )\nexport type Token = z.infer<typeof TokenSchema>\n\nexport const TOKEN_DECIMALS = 6\n\nexport const TOKEN_ADDRESSES: Record<\n Token,\n Partial<Record<Network, Partial<Record<Environment, `0x${string}`>>>>\n> = {\n USDC: {\n base: {\n live: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n test: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n },\n optimism: {\n live: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',\n test: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7',\n },\n polygon: { live: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' },\n ethereum: {\n live: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n test: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n },\n arbitrum: { live: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' },\n avalanche: { live: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' },\n bnb: { live: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' },\n },\n USDT: {\n base: { live: '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2' },\n optimism: { live: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58' },\n polygon: { live: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F' },\n ethereum: { live: '0xdAC17F958D2ee523a2206206994597C13D831ec7' },\n arbitrum: { live: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9' },\n avalanche: { live: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7' },\n bnb: { live: '0x55d398326f99059fF775485246999027B3197955' },\n },\n}\n","import { z } from 'zod'\nimport { EnvironmentSchema } from './environment'\nimport { NetworkSchema, OPERATIONAL_NETWORKS } from './networks'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\nimport { TokenSchema } from './tokens'\n\nexport const ChargeStatusSchema = z\n .enum(['pending', 'partially_paid', 'confirmed', 'expired', 'underpaid'])\n .describe(\n 'Payment progress, from the payer side. `pending`: created, nothing received yet. `partially_paid`: some funds received, less than `amount`. `confirmed`: full amount received (or more — see `isOverpaid`). `expired`: `expiresAt` passed with zero funds received. `underpaid`: `expiresAt` passed while `partially_paid`. This never reflects whether funds actually reached the merchant — see `settlementStatus` for that.',\n )\n\nexport type ChargeStatus = z.infer<typeof ChargeStatusSchema>\n\nexport const SettlementStatusSchema = z\n .enum(['pending', 'completed', 'failed'])\n .describe(\n \"Progress of the payout to the merchant's wallet, a separate step from `status` — `status: confirmed` only means the payment was detected on-chain, not that the merchant has been paid yet. `pending`: payment detected, payout not yet attempted. `completed`: the merchant's wallet has the funds. `failed`: the payout attempt failed and retries were exhausted (rare; contact support). `null` on the parent `Charge` means no payout has been attempted yet — nothing has been received, or the charge is still in progress.\",\n )\nexport type SettlementStatus = z.infer<typeof SettlementStatusSchema>\n\nexport const ChargeModeSchema = z\n .enum(['standard', 'continuous'])\n .describe(\n \"`standard` (default): the usual lifecycle — accumulates transfers toward one resolution (`confirmed`/`expired`/`underpaid`), settles once. `continuous`: never resolves — `status` stays `pending` for the charge's entire life, and every credited transfer settles independently instead of accumulating toward one confirmation (see `charge.contribution_received`/`charge.contribution_settled`). Requires both `amount` and `expiresIn` to be omitted — there's no goal to accumulate toward and no deadline for something meant to run indefinitely (a link in a creator's bio, a permanent collection address). Not inferred from omitting those two fields — an explicit, deliberate choice, since silently changing a charge's entire settlement lifecycle based on which optional fields happened to be left out would be a footgun.\",\n )\nexport type ChargeMode = z.infer<typeof ChargeModeSchema>\n\nexport const CHARGE_EXPIRES_IN_MIN_SECONDS = 60\nexport const CHARGE_EXPIRES_IN_MAX_SECONDS = 365 * 24 * 60 * 60\n\nexport const CHARGE_ACCEPTED_PAYMENTS_MAX = 14\n\nexport const AcceptedPaymentSchema = z.object({\n token: TokenSchema,\n network: NetworkSchema,\n})\nexport type AcceptedPayment = z.infer<typeof AcceptedPaymentSchema>\n\nconst AcceptedPaymentsSchema = z\n .array(AcceptedPaymentSchema)\n .min(1, 'At least one accepted payment is required.')\n .max(CHARGE_ACCEPTED_PAYMENTS_MAX)\n .superRefine((pairs, ctx) => {\n const seen = new Set<string>()\n pairs.forEach((pair, index) => {\n const key = `${pair.token}:${pair.network}`\n if (seen.has(key)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Duplicate accepted payment: ${pair.token} on ${pair.network}.`,\n path: [index],\n })\n }\n seen.add(key)\n if (!(OPERATIONAL_NETWORKS as readonly string[]).includes(pair.network)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Network \"${pair.network}\" isn't live yet — only ${OPERATIONAL_NETWORKS.join(', ')} today.`,\n path: [index, 'network'],\n })\n }\n })\n })\n .describe(\n `Every \\`(token, network)\\` pair the payer is allowed to pay with — at least one, up to ${CHARGE_ACCEPTED_PAYMENTS_MAX}. This list is also the only restriction knob: the payer can use any combination of the pairs listed here, and every transfer on one of them is credited and sums toward the charge total (see \\`paidWith\\`) — e.g. a charge accepting USDC and USDT can be confirmed by $9 in USDC plus $1 in USDT, or by USDC arriving on two different accepted networks. To require payment in one specific token on one specific network, list only that single pair — a transfer on any pair not in this list is still recorded (for audit) but never credited. Each network must be live (see \\`GET /v1/networks\\` for the current matrix) — an unconfigured \\`(token, network)\\` combination for your environment is rejected with \\`422 token_not_supported\\`.`,\n )\n\nexport const CHARGE_AMOUNT_MAX = 999_999_999_999\n\nexport const CreateChargeSchema = z\n .object({\n mode: ChargeModeSchema.default('standard'),\n amount: z\n .number()\n .positive()\n .max(CHARGE_AMOUNT_MAX)\n .optional()\n .describe(\n 'Amount to charge, in `currency` units (e.g. `49.9` = $49.90) — up to 6 decimal places; anything more precise is silently truncated. Omit entirely for a charge that accepts any amount — the first credited transfer of any size confirms it, and `isOverpaid` never applies (there is no target to exceed).',\n ),\n currency: z\n .literal('USD')\n .default('USD')\n .describe('Always `USD` today — the only supported currency.'),\n acceptedPayments: AcceptedPaymentsSchema,\n expiresIn: z\n .number()\n .int()\n .min(CHARGE_EXPIRES_IN_MIN_SECONDS)\n .max(CHARGE_EXPIRES_IN_MAX_SECONDS)\n .optional()\n .describe(\n 'Seconds, not minutes or milliseconds — how long the charge stays open, min 60, max 31,536,000 = 365 days. Omit entirely for a charge that never expires (`expiresAt` is `null`) — useful for donations, investments, or any charge with no natural deadline. Cannot be extended or shortened after creation either way.',\n ),\n idempotencyKey: z\n .string()\n .min(1)\n .max(255)\n .optional()\n .describe(\n 'Scoped to your organization. Replaying the same key returns the original charge unchanged instead of creating a duplicate — safe to retry a request after a timeout without double-charging.',\n ),\n externalRef: z\n .string()\n .min(1)\n .max(255)\n .optional()\n .describe(\n 'An opaque correlation id from your own system (e.g. an order id) — echoed back on the charge and in every webhook payload. Not interpreted or validated by Klappay.',\n ),\n source: z\n .string()\n .min(1)\n .max(64)\n .optional()\n .describe(\n 'Free-form label for what created this charge (e.g. `\"checkout\"`, `\"invoice\"`) — useful if you create charges from more than one flow and want to tell them apart later. Not a fixed enum; use whatever values make sense to you.',\n ),\n metadata: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Arbitrary key/value data to attach to the charge, returned as-is on every read.'),\n })\n .superRefine((input, ctx) => {\n if (\n input.mode === 'continuous' &&\n (input.amount !== undefined || input.expiresIn !== undefined)\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'mode: \"continuous\" requires both amount and expiresIn to be omitted.',\n path: ['mode'],\n })\n }\n })\n\nexport type CreateChargeInput = z.infer<typeof CreateChargeSchema>\n\nexport type CreateChargeRequest = z.input<typeof CreateChargeSchema>\n\nexport const ChargeSchema = z.object({\n id: z\n .string()\n .describe('Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later.'),\n mode: ChargeModeSchema,\n amount: z\n .number()\n .nullable()\n .describe(\n 'The amount originally requested, in `currency` units (up to 6 decimal places). `null` if `amount` was omitted at creation — this charge accepts any amount, and the first credited transfer confirms it.',\n ),\n amountReceived: z\n .number()\n .nullable()\n .describe(\n 'Cumulative amount actually received on-chain so far, in `currency` units (up to 6 decimal places). `null` until the first transfer arrives. Can exceed `amount` — see `isOverpaid` — unless `amount` itself is `null`, in which case `isOverpaid` never applies.',\n ),\n isOverpaid: z\n .boolean()\n .describe(\n '`true` if `amountReceived` ended up greater than `amount`. Klappay never refunds the difference automatically — see the docs for why.',\n ),\n currency: z.string().describe('Always `USD` today — the only supported currency.'),\n acceptedPayments: z\n .array(AcceptedPaymentSchema)\n .describe(\n 'Every `(token, network)` pair this charge was configured to accept, unchanged after creation.',\n ),\n paidWith: z\n .array(AcceptedPaymentSchema)\n .describe(\n 'Every distinct `(token, network)` pair that has actually contributed a credited transfer so far — empty until the first one arrives. Can hold more than one entry: a charge accepting several pairs can be paid across a combination of them, and every entry here sums toward `amountReceived`.',\n ),\n address: z\n .string()\n .describe(\n 'The on-chain address the payer must send funds to — identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time — funds sent here go directly to the merchant, Klappay never custodies them.',\n ),\n status: ChargeStatusSchema,\n settlementStatus: SettlementStatusSchema.nullable(),\n environment: EnvironmentSchema,\n apiKeyId: z\n .string()\n .nullable()\n .describe(\n 'Which of your API keys created this charge. `null` for a charge created before this field existed.',\n ),\n txHash: z\n .string()\n .nullable()\n .describe(\n 'Transaction hash of the most recent transfer detected for this charge. `null` until a payment is detected.',\n ),\n externalRef: z.string().nullable(),\n source: z.string().nullable(),\n metadata: z.record(z.string(), z.unknown()).nullable(),\n createdAt: z.string().datetime(),\n expiresAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When this charge stops accepting payment, if still `pending`/`partially_paid` by then. `null` if `expiresIn` was omitted at creation — the charge never expires on its own and must be dealt with manually (or left open indefinitely).',\n ),\n confirmedAt: z\n .string()\n .datetime()\n .nullable()\n .describe('When `status` first reached `confirmed`. `null` until then.'),\n settledAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n \"When `settlementStatus` first reached `completed` — the merchant's wallet actually has the funds. `null` until then, including while `settlementStatus` is `pending`/`failed`.\",\n ),\n lastActivityAt: z\n .string()\n .datetime()\n .describe(\n 'When a transfer was last credited toward this charge, or `createdAt` if none has arrived yet. Only meaningful for a charge with no `expiresAt` — see `pausedAt`.',\n ),\n pausedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'Only ever set for a charge with no `expiresAt`: `null` means Klappay is actively watching this address in real time (the normal case). A timestamp means no contribution arrived for longer than the inactivity window (90 days for a charge with a goal `amount`, 365 days for one without), so real-time watching was stopped — the charge itself is never closed, a transfer can still arrive and land, just detected on a much slower fallback poll instead of instantly. Clears automatically (and real-time watching resumes) the moment that happens.',\n ),\n})\n\nexport type Charge = z.infer<typeof ChargeSchema>\n\nexport const ListChargesSchema = z\n .object({\n status: ChargeStatusSchema.optional(),\n token: TokenSchema.optional().describe(\n 'Filters on `paidWith.token` — the pair actually paid, not accepted.',\n ),\n network: NetworkSchema.optional().describe(\n 'Filters on `paidWith.network` — the pair actually paid, not accepted.',\n ),\n environment: EnvironmentSchema.optional(),\n since: z\n .string()\n .datetime()\n .optional()\n .describe(\n 'Only return charges created at or after this timestamp (filters on `createdAt`, not on when the status last changed). If polling as a fallback for missed webhooks, use a window at least as wide as the longest `expiresIn` your charges use, or you can miss a long-lived charge that changed status outside a narrower window.',\n ),\n isOverpaid: z\n .enum(['true', 'false'])\n .transform((v) => v === 'true')\n .optional(),\n })\n .extend(PaginationQuerySchema.shape)\n\nexport type ListChargesInput = z.infer<typeof ListChargesSchema>\n\nexport type ListChargesRequest = z.input<typeof ListChargesSchema>\n\nexport const PaginatedChargesSchema = paginatedSchema(ChargeSchema)\n\nexport type PaginatedCharges = z.infer<typeof PaginatedChargesSchema>\n\nexport const ChargeStatusEventSchema = z.object({\n id: z.string(),\n status: ChargeStatusSchema,\n settlementStatus: SettlementStatusSchema.nullable(),\n amount: z.number().nullable(),\n amountReceived: z.number().nullable(),\n paidWith: z.array(AcceptedPaymentSchema),\n})\n\nexport type ChargeStatusEvent = z.infer<typeof ChargeStatusEventSchema>\n","import { z } from 'zod'\nimport { NetworkSchema } from './networks'\nimport { TokenSchema } from './tokens'\n\nexport const SplitDistributionStatusSchema = z\n .enum(['pending', 'processing', 'completed', 'failed'])\n .describe(\n \"Status of one payout attempt to the merchant, for a single `(token, network)` pair — a charge that settles across more than one pair has one of these per pair. `pending`: queued, not yet claimed by a distributor. `processing`: a distributor (Klappay's own worker, or anyone racing to call `distribute()` first, see `PendingDistributionSchema`) has claimed it and is submitting the on-chain transaction. `completed`: the merchant's wallet has the funds. `failed`: every automatic retry was exhausted.\",\n )\nexport type SplitDistributionStatus = z.infer<typeof SplitDistributionStatusSchema>\n\nexport const PendingDistributionRecipientSchema = z.object({\n address: z.string().describe('On-chain recipient address.'),\n percentAllocation: z\n .number()\n .describe(\"This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).\"),\n})\n\nexport const PendingDistributionSchema = z.object({\n splitAddress: z.string().describe('The on-chain 0xSplits address to call `distribute()` on.'),\n network: NetworkSchema,\n token: TokenSchema,\n recipients: z\n .array(PendingDistributionRecipientSchema)\n .describe(\n 'The exact recipient list to pass to `distribute()` — the split contract only stores a hash of this config, so the caller must supply the identical array to prove it matches. Always present, never reconstructed from partial data.',\n ),\n distributorFeePercent: z\n .number()\n .describe(\n 'Percentage of the split balance paid to whoever calls `distribute()` first (e.g. `0.1` = 0.1%). Frozen at charge creation, same for every distribution today.',\n ),\n estimatedRewardAmount: z\n .number()\n .describe(\n \"Estimate only, in the charge's `currency` units, based on the amount Klappay detected on-chain — not a live read of the split's current balance. Read the balance yourself before submitting a transaction; a stale estimate is harmless (see the docs), never a reason to skip that check.\",\n ),\n availableSince: z\n .string()\n .datetime()\n .describe('When this distribution entered its grace period.'),\n graceEndsAt: z\n .string()\n .datetime()\n .describe(\n \"When Klappay's own worker may claim this distribution. Racing to call `distribute()` after this timestamp is possible but increasingly likely to lose to the worker.\",\n ),\n})\n\nexport type PendingDistribution = z.infer<typeof PendingDistributionSchema>\n\nexport const PendingDistributionEventSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('distribution.available'),\n distribution: PendingDistributionSchema,\n }),\n z.object({\n type: z.literal('distribution.claimed'),\n splitAddress: z\n .string()\n .describe('No longer claimable — either settled by someone, or picked up by the worker.'),\n }),\n])\n\nexport type PendingDistributionEvent = z.infer<typeof PendingDistributionEventSchema>\n","import { z } from 'zod'\nimport { EnvironmentSchema } from './environment'\n\nexport const MetricsResourceSchema = z\n .enum(['charges', 'transactions', 'distributions'])\n .describe(\n 'Which underlying dataset to query. `charges`: one row per charge. `transactions`: one row per detected on-chain transfer — a charge paid in installments has more than one. `distributions`: one row per payout attempt to the merchant, one per `(token, network)` pair a charge settled across.',\n )\nexport type MetricsResource = z.infer<typeof MetricsResourceSchema>\n\nexport const MetricsAggregationSchema = z\n .enum(['count', 'sum', 'avg', 'min', 'max'])\n .describe(\n '`count` counts matching rows and never takes `field`. `sum`/`avg`/`min`/`max` require `field` to be set to one of the resource’s numeric fields.',\n )\nexport type MetricsAggregation = z.infer<typeof MetricsAggregationSchema>\n\nexport const MetricsFilterOperatorSchema = z\n .enum(['eq', 'neq', 'in', 'gt', 'gte', 'lt', 'lte'])\n .describe(\n '`in` expects an array value (max 50 entries); every other operator expects a single scalar.',\n )\nexport type MetricsFilterOperator = z.infer<typeof MetricsFilterOperatorSchema>\n\nexport const MetricsDateGranularitySchema = z\n .enum(['day', 'week', 'month'])\n .describe(\n 'Bucket width for a `date_bucket` `groupBy` entry — Postgres `date_trunc` semantics (UTC).',\n )\nexport type MetricsDateGranularity = z.infer<typeof MetricsDateGranularitySchema>\n\nconst metricsQueryEnvironmentSchema = EnvironmentSchema.describe(\n \"Which environment's data to query — `live` or `test`. Independent of your session (a dashboard user isn't scoped to one environment the way an API key is) — scopes the query to charges/transactions/distributions created under a `live` or `test` API key respectively.\",\n)\n\nexport const MAX_METRICS_QUERY_DATE_RANGE_DAYS = 366\nexport const METRICS_QUERY_MAX_ROW_LIMIT = 1000\nexport const METRICS_QUERY_DEFAULT_ROW_LIMIT = 100\nexport const METRICS_QUERY_MAX_GROUP_BY = 3\nexport const METRICS_QUERY_MAX_FILTERS = 20\nexport const METRICS_QUERY_MAX_METRICS = 10\n\nconst METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/\n\nconst metricAliasSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n METRIC_ALIAS_PATTERN,\n 'Must start with a letter or underscore, and contain only letters, digits, and underscores — this becomes a SQL column alias.',\n )\n .optional()\n\nconst MetricsFilterValueSchema = z.union([\n z.string().max(255),\n z.number(),\n z.boolean(),\n z\n .array(z.union([z.string().max(255), z.number()]))\n .min(1)\n .max(50),\n])\n\nconst orderBySchema = z\n .object({\n key: z\n .string()\n .min(1)\n .max(64)\n .regex(\n METRIC_ALIAS_PATTERN,\n 'Must start with a letter or underscore, and contain only letters, digits, and underscores — every valid output column name already looks like this.',\n )\n .describe(\n 'An output column name from this same query — either a `groupBy` field name, or a metric’s `alias` (or its default name: `${aggregation}` for `count`, `${aggregation}_${field}` otherwise, e.g. `sum_amount`). Must match `^[a-zA-Z_][a-zA-Z0-9_]*$` — every real output column name already does, so this only ever rejects a value that could never have been one.',\n ),\n direction: z.enum(['asc', 'desc']),\n })\n .describe(\n 'Sort the result rows by any output column — including the bucket field itself for a `date_bucket` query (e.g. `createdAt`). Omit to get ascending-by-bucket order for a date-bucketed query, or implementation-defined (not guaranteed stable) order otherwise.',\n )\n\nconst limitSchema = z\n .number()\n .int()\n .min(1)\n .max(METRICS_QUERY_MAX_ROW_LIMIT)\n .default(METRICS_QUERY_DEFAULT_ROW_LIMIT)\n .describe(\n `Max rows to return, ${1}–${METRICS_QUERY_MAX_ROW_LIMIT}, default ${METRICS_QUERY_DEFAULT_ROW_LIMIT}. If more rows matched, \\`meta.truncated\\` is \\`true\\` on the response — narrow the query instead of just raising this.`,\n )\n\nexport const ChargesQueryFieldSchema = z\n .enum(['status', 'mode', 'source', 'apiKeyId', 'currency', 'isOverpaid', 'externalRef'])\n .describe(\n \"A `Charge` field to filter or group by — see `ChargeStatusSchema`/`ChargeModeSchema` for `status`/`mode`'s own possible values (charges.md). `source`/`externalRef` are free-form strings your own integration set at creation, not a fixed enum.\",\n )\nexport type ChargesQueryField = z.infer<typeof ChargesQueryFieldSchema>\n\nexport const ChargesMetricFieldSchema = z\n .enum(['amount', 'amountReceived', 'feePercent'])\n .describe(\n 'A `Charge` numeric field to aggregate. `amount`/`amountReceived` are decimal currency amounts (requested vs. actually received — see `charges.md`). `feePercent` is the platform fee frozen on the charge at creation, e.g. `1.5` means 1.5%.',\n )\nexport type ChargesMetricField = z.infer<typeof ChargesMetricFieldSchema>\n\nexport const ChargesDateFieldSchema = z\n .enum(['createdAt', 'confirmedAt', 'lastActivityAt'])\n .describe(\n 'A `Charge` timestamp to filter/bucket by. `confirmedAt` is `null` until the charge reaches `confirmed` — a `dateRange`/`date_bucket` on it implicitly excludes every charge that never confirmed.',\n )\nexport type ChargesDateField = z.infer<typeof ChargesDateFieldSchema>\n\nconst ChargesFilterSchema = z.object({\n field: ChargesQueryFieldSchema,\n operator: MetricsFilterOperatorSchema,\n value: MetricsFilterValueSchema,\n})\n\nconst ChargesGroupBySchema = z.union([\n z.object({ type: z.literal('field'), field: ChargesQueryFieldSchema }),\n z.object({\n type: z.literal('date_bucket'),\n field: ChargesDateFieldSchema,\n granularity: MetricsDateGranularitySchema,\n }),\n])\n\nconst ChargesMetricSchema = z.object({\n aggregation: MetricsAggregationSchema,\n field: ChargesMetricFieldSchema.optional(),\n alias: metricAliasSchema,\n})\n\nconst ChargesMetricsQuerySchema = z.object({\n resource: z.literal('charges'),\n environment: metricsQueryEnvironmentSchema,\n dateRange: z.object({\n field: ChargesDateFieldSchema,\n from: z.string().max(64).datetime(),\n to: z.string().max(64).datetime(),\n }),\n groupBy: z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),\n metrics: z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),\n filters: z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),\n orderBy: orderBySchema.optional(),\n limit: limitSchema,\n})\n\nexport const TransactionsQueryFieldSchema = z\n .enum(['network', 'token', 'source', 'causedTransition'])\n .describe(\n \"A `Transaction` field to filter or group by — see `NetworkSchema`/`TokenSchema`/`TransactionSourceSchema` for their possible values. `causedTransition` is `true` only for the transfer(s) that actually flipped the charge's `status` — a charge paid in installments can have more than one; filtering/grouping on it excludes no-op duplicate transfers (see `TimelineEvent.causedTransition` in charges.md for the full explanation).\",\n )\nexport type TransactionsQueryField = z.infer<typeof TransactionsQueryFieldSchema>\n\nexport const TransactionsMetricFieldSchema = z\n .enum(['amount'])\n .describe(\"The transfer amount, in the charge's `currency` units.\")\nexport type TransactionsMetricField = z.infer<typeof TransactionsMetricFieldSchema>\n\nexport const TransactionsDateFieldSchema = z\n .enum(['detectedAt'])\n .describe('When Klappay detected this transfer on-chain (not when it was mined).')\nexport type TransactionsDateField = z.infer<typeof TransactionsDateFieldSchema>\n\nconst TransactionsFilterSchema = z.object({\n field: TransactionsQueryFieldSchema,\n operator: MetricsFilterOperatorSchema,\n value: MetricsFilterValueSchema,\n})\n\nconst TransactionsGroupBySchema = z.union([\n z.object({ type: z.literal('field'), field: TransactionsQueryFieldSchema }),\n z.object({\n type: z.literal('date_bucket'),\n field: TransactionsDateFieldSchema,\n granularity: MetricsDateGranularitySchema,\n }),\n])\n\nconst TransactionsMetricSchema = z.object({\n aggregation: MetricsAggregationSchema,\n field: TransactionsMetricFieldSchema.optional(),\n alias: metricAliasSchema,\n})\n\nconst TransactionsMetricsQuerySchema = z.object({\n resource: z.literal('transactions'),\n environment: metricsQueryEnvironmentSchema,\n dateRange: z.object({\n field: TransactionsDateFieldSchema,\n from: z.string().max(64).datetime(),\n to: z.string().max(64).datetime(),\n }),\n groupBy: z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),\n metrics: z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),\n filters: z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),\n orderBy: orderBySchema.optional(),\n limit: limitSchema,\n})\n\nexport const DistributionsQueryFieldSchema = z\n .enum(['status', 'network', 'token'])\n .describe(\n 'A `SplitDistribution` field to filter or group by — see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values.',\n )\nexport type DistributionsQueryField = z.infer<typeof DistributionsQueryFieldSchema>\n\nexport const DistributionsMetricFieldSchema = z\n .enum(['attempts'])\n .describe(\n \"How many times a payout was attempted for this settlement so far — incremented on every attempt, whether it succeeded or is being retried after failing. A high `attempts` alongside `status: 'failed'` means every automatic retry was exhausted.\",\n )\nexport type DistributionsMetricField = z.infer<typeof DistributionsMetricFieldSchema>\n\nexport const DistributionsDateFieldSchema = z\n .enum(['createdAt', 'completedAt'])\n .describe(\n '`createdAt`: when this settlement was queued. `completedAt`: when it actually paid out — `null` until `status` reaches `completed`, so a `dateRange`/`date_bucket` on it implicitly excludes every distribution still pending/processing/failed.',\n )\nexport type DistributionsDateField = z.infer<typeof DistributionsDateFieldSchema>\n\nconst DistributionsFilterSchema = z.object({\n field: DistributionsQueryFieldSchema,\n operator: MetricsFilterOperatorSchema,\n value: MetricsFilterValueSchema,\n})\n\nconst DistributionsGroupBySchema = z.union([\n z.object({ type: z.literal('field'), field: DistributionsQueryFieldSchema }),\n z.object({\n type: z.literal('date_bucket'),\n field: DistributionsDateFieldSchema,\n granularity: MetricsDateGranularitySchema,\n }),\n])\n\nconst DistributionsMetricSchema = z.object({\n aggregation: MetricsAggregationSchema,\n field: DistributionsMetricFieldSchema.optional(),\n alias: metricAliasSchema,\n})\n\nconst DistributionsMetricsQuerySchema = z.object({\n resource: z.literal('distributions'),\n environment: metricsQueryEnvironmentSchema,\n dateRange: z.object({\n field: DistributionsDateFieldSchema,\n from: z.string().max(64).datetime(),\n to: z.string().max(64).datetime(),\n }),\n groupBy: z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),\n metrics: z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),\n filters: z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),\n orderBy: orderBySchema.optional(),\n limit: limitSchema,\n})\n\nconst ONE_DAY_MS = 24 * 60 * 60 * 1000\n\nexport const MetricsQuerySchema = z\n .discriminatedUnion('resource', [\n ChargesMetricsQuerySchema,\n TransactionsMetricsQuerySchema,\n DistributionsMetricsQuerySchema,\n ])\n .superRefine((input, ctx) => {\n const from = new Date(input.dateRange.from)\n const to = new Date(input.dateRange.to)\n if (from >= to) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: '`dateRange.from` must be before `dateRange.to`.',\n path: ['dateRange', 'from'],\n })\n }\n const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS\n if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `\\`dateRange\\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,\n path: ['dateRange', 'to'],\n })\n }\n const dateBucketCount = input.groupBy.filter((entry) => entry.type === 'date_bucket').length\n if (dateBucketCount > 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'At most one `date_bucket` entry is allowed in `groupBy`.',\n path: ['groupBy'],\n })\n }\n input.metrics.forEach((metric, index) => {\n if (metric.aggregation !== 'count' && metric.field === undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: '`field` is required unless `aggregation` is `count`.',\n path: ['metrics', index, 'field'],\n })\n }\n })\n const aliases = input.metrics\n .map((metric) => metric.alias)\n .filter((alias) => alias !== undefined)\n if (new Set(aliases).size !== aliases.length) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Every `metrics[].alias` must be unique.',\n path: ['metrics'],\n })\n }\n const reservedNames = new Set(['bucket', ...input.groupBy.map((entry) => entry.field)])\n input.metrics.forEach((metric, index) => {\n if (metric.alias !== undefined && reservedNames.has(metric.alias)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `\\`alias\\` \"${metric.alias}\" collides with a \\`groupBy\\` field name (or the reserved word \"bucket\") — choose a different alias.`,\n path: ['metrics', index, 'alias'],\n })\n }\n })\n })\n\nexport type MetricsQuery = z.infer<typeof MetricsQuerySchema>\nexport type MetricsQueryRequest = z.input<typeof MetricsQuerySchema>\n\nexport const MetricsQueryResultRowSchema = z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.null()]),\n)\nexport type MetricsQueryResultRow = z.infer<typeof MetricsQueryResultRowSchema>\n\nexport const MetricsQueryScopeSchema = z\n .enum(['owner_admin', 'member'])\n .describe(\n '`member`: results were automatically restricted to data tied to API keys you personally created — rows with no resolvable creator were excluded, not counted, and not surfaced any other way. `owner_admin`: the full organization’s data was queried, no restriction applied.',\n )\nexport type MetricsQueryScope = z.infer<typeof MetricsQueryScopeSchema>\n\nexport const MetricsQueryResultSchema = z.object({\n data: z.array(MetricsQueryResultRowSchema),\n meta: z.object({\n resource: MetricsResourceSchema,\n environment: EnvironmentSchema,\n scope: MetricsQueryScopeSchema,\n rowCount: z.number().int().describe('Number of rows in `data`.'),\n truncated: z\n .boolean()\n .describe(\n '`true` if more rows matched than `limit` allowed — `data` holds only the first `limit`.',\n ),\n }),\n})\nexport type MetricsQueryResult = z.infer<typeof MetricsQueryResultSchema>\n","import { z } from 'zod'\n\nexport const ChargeWebhookEventTypeSchema = z\n .enum([\n 'charge.created',\n 'charge.partially_paid',\n 'charge.confirmed',\n 'charge.expired',\n 'charge.underpaid',\n 'charge.settled',\n 'charge.settlement_failed',\n 'charge.overpaid',\n 'charge.paused',\n 'charge.reactivated',\n 'charge.contribution_received',\n 'charge.contribution_settled',\n ])\n .describe(\n 'Note the distinction between `charge.confirmed` and `charge.settled`: `confirmed` means the payment was detected on-chain; `settled` means the merchant\\'s wallet actually received the funds — a separate, later step. Subscribe to `confirmed` if you only need \"will I get paid,\" or `settled` if you need \"has the money actually arrived.\" `charge.overpaid` fires alongside `charge.confirmed`/`charge.partially_paid` whenever the cumulative amount received ends up above `amount` (see `Charge.isOverpaid`). Every event in this category carries the full `Charge` object as `data`, except `charge.paused`/`charge.reactivated`/`charge.contribution_received`/`charge.contribution_settled` (see below). `charge.paused` fires when a charge with no `expiresAt` has had no contribution for longer than its inactivity window (90 days for a charge with a goal `amount`, 365 days for one without) — Klappay stops watching its address in real time, but the charge itself is never closed; `charge.reactivated` fires the moment a transfer lands on a paused charge, detected by the same fallback poller used for missed webhooks (so with much higher latency than normal — pausing trades that away deliberately, see `docs/payments.md`). `charge.contribution_received`/`charge.contribution_settled` are exclusive to `mode: continuous` charges (see `Charge.mode`) — a continuous charge never fires `charge.confirmed`/`charge.settled` at all, since `status` never leaves `pending`; instead every individual transfer fires `contribution_received` on detection and `contribution_settled` once its payout completes, one pair-scoped event per contribution instead of one event for the whole charge. `data` for `charge.paused`: `{ chargeId, lastActivityAt, pausedAt }`; for `charge.reactivated`: `{ chargeId, reactivatedAt }`; for `charge.contribution_received`: `{ chargeId, token, network, amount, txHash, payerAddress }`; for `charge.contribution_settled`: `{ chargeId, token, network, amount, txHash, distributorAddress }`.',\n )\n\nexport const AccountWebhookEventTypeSchema = z\n .enum([\n 'payout_address.changed',\n 'api_key.created',\n 'api_key.revoked',\n 'webhook.created',\n 'webhook.deleted',\n 'webhook.secret_rotated',\n 'fee_tier.updated',\n 'member.removed',\n 'member.role_changed',\n 'member.invited',\n ])\n .describe(\n 'Account and configuration changes — not tied to any single charge. `data` per event: `payout_address.changed`: `{ organizationId, from, to }` (`from` nullable); `api_key.created`/`api_key.revoked`: `{ apiKeyId, name, environment, hint }`; `webhook.created`/`webhook.deleted`/`webhook.secret_rotated`: `{ webhookId, url }`; `fee_tier.updated`: `{ organizationId, previousFeePercent, newFeePercent }`; `member.removed`: `{ userId, email, role }`; `member.role_changed`: `{ userId, email, role, previousRole }`; `member.invited`: `{ organizationId, email, role, invitedByUserId }`.',\n )\n\nexport const WebhookDeliveryEventTypeSchema = z\n .enum(['webhook.delivery_failed', 'webhook.delivery_recovered', 'webhook.endpoint_unhealthy'])\n .describe(\n \"Meta-events about the health of your own webhook endpoints — useful for monitoring without polling `GET /v1/webhooks/{id}/deliveries`. `webhook.endpoint_unhealthy` fires once when a webhook's failure rate over the trailing 24h crosses 20%, and `webhook.delivery_recovered` fires once when a delivery to that webhook next succeeds. `data` for every event in this category: `{ webhookId, url, failureRatio? }` (`failureRatio` only present on `webhook.endpoint_unhealthy`).\",\n )\n\nexport const SecurityWebhookEventTypeSchema = z\n .enum([\n 'auth.login',\n 'auth.login_failed',\n 'auth.suspicious_activity',\n 'auth.email_verified',\n 'auth.password_reset_requested',\n 'auth.password_reset_completed',\n ])\n .describe(\n 'Account security signals. `auth.suspicious_activity` is a soft heuristic (login from an IP not seen on this account before), not a block — evaluate it, not enforce against it. `auth.password_reset_requested` only ever dispatches when the requested email actually matches an account (there is nowhere to notify otherwise) — `POST /v1/auth/forgot-password` itself always returns the same generic response either way, so this event never becomes a second channel for the same enumeration question the endpoint response deliberately avoids answering. `data` per event: `auth.login`: `{ userId, ipAddress }`; `auth.login_failed`: `{ email, ipAddress }`; `auth.suspicious_activity`: `{ userId, ipAddress, previousIpAddress }`; `auth.email_verified`/`auth.password_reset_requested`/`auth.password_reset_completed`: `{ userId, email }`.',\n )\n\nexport const WebhookEventTypeSchema = z.union([\n ChargeWebhookEventTypeSchema,\n AccountWebhookEventTypeSchema,\n WebhookDeliveryEventTypeSchema,\n SecurityWebhookEventTypeSchema,\n])\n\nexport type WebhookEventType = z.infer<typeof WebhookEventTypeSchema>\n\nexport const WebhookCategorySchema = z\n .enum(['payments', 'account', 'webhooks', 'security'])\n .describe(\n 'Subscribe to every event in a category via `eventCategories` instead of listing events one by one — new events added to a category later arrive automatically, no subscription update needed.',\n )\nexport type WebhookCategory = z.infer<typeof WebhookCategorySchema>\n\nfunction buildCategoryMap(): Record<WebhookEventType, WebhookCategory> {\n const map = {} as Record<WebhookEventType, WebhookCategory>\n for (const event of ChargeWebhookEventTypeSchema.options) map[event] = 'payments'\n for (const event of AccountWebhookEventTypeSchema.options) map[event] = 'account'\n for (const event of WebhookDeliveryEventTypeSchema.options) map[event] = 'webhooks'\n for (const event of SecurityWebhookEventTypeSchema.options) map[event] = 'security'\n return map\n}\n\nexport const EVENT_CATEGORY_MAP = buildCategoryMap()\n\nexport const WEBHOOK_EVENT_CATEGORIES: Record<WebhookCategory, readonly WebhookEventType[]> = {\n payments: ChargeWebhookEventTypeSchema.options,\n account: AccountWebhookEventTypeSchema.options,\n webhooks: WebhookDeliveryEventTypeSchema.options,\n security: SecurityWebhookEventTypeSchema.options,\n}\n\nexport const TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([\n 'charge.created',\n 'charge.paused',\n 'charge.reactivated',\n 'charge.contribution_received',\n 'charge.contribution_settled',\n]).describe(\n \"Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into — everything except `charge.created` (a charge already exists by the time you have an id to trigger against), `charge.paused`/`charge.reactivated` (driven by a background worker on real inactivity, not a payment state — nothing meaningful to simulate or wait for on a fresh sandbox charge), and `charge.contribution_received`/`charge.contribution_settled` (exclusive to `mode: continuous` charges, which this trigger endpoint does not support simulating today — see `POST /v1/charges/{id}/trigger`'s own description).\",\n)\n\nexport type TriggerableChargeEvent = z.infer<typeof TriggerableChargeEventSchema>\n\nexport const NonChargeTriggerableEventSchema = z.union([\n AccountWebhookEventTypeSchema,\n WebhookDeliveryEventTypeSchema,\n SecurityWebhookEventTypeSchema,\n])\nexport type NonChargeTriggerableEvent = z.infer<typeof NonChargeTriggerableEventSchema>\n","import { z } from 'zod'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\nimport { EVENT_CATEGORY_MAP, WebhookCategorySchema, WebhookEventTypeSchema } from './webhook-events'\n\nexport const WEBHOOK_EVENTS_WILDCARD = '*'\n\nexport const CreateWebhookSchema = z\n .object({\n url: z\n .string()\n .max(2048)\n .url()\n .describe(\n 'Must be HTTPS and resolve to a public address — private/internal IPs are rejected.',\n ),\n events: z\n .array(z.union([WebhookEventTypeSchema, z.literal(WEBHOOK_EVENTS_WILDCARD)]))\n .max(Object.keys(EVENT_CATEGORY_MAP).length + 1)\n .default([])\n .describe(\n 'Individual event types to receive, or `\"*\"` for every event (combine with `excludeEvents` to opt back out of specific ones). Omit in favor of `eventCategories` if you want whole categories instead.',\n ),\n eventCategories: z\n .array(WebhookCategorySchema)\n .max(WebhookCategorySchema.options.length)\n .default([])\n .describe(\n 'Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required.',\n ),\n excludeEvents: z\n .array(WebhookEventTypeSchema)\n .max(Object.keys(EVENT_CATEGORY_MAP).length)\n .default([])\n .describe(\n 'Event types to exclude even if selected via `events: [\"*\"]` or `eventCategories`.',\n ),\n })\n .refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {\n message: 'must select at least one event via `events` or `eventCategories`',\n path: ['events'],\n })\n\nexport type CreateWebhookInput = z.infer<typeof CreateWebhookSchema>\n\nexport type CreateWebhookRequest = z.input<typeof CreateWebhookSchema>\n\nexport const WebhookSchema = z.object({\n id: z.string(),\n url: z.string(),\n events: z.array(WebhookEventTypeSchema),\n eventCategories: z.array(WebhookCategorySchema),\n excludeEvents: z.array(WebhookEventTypeSchema),\n isWildcard: z.boolean(),\n secret: z\n .string()\n .describe(\n \"The signing secret, used to verify the `X-Klappay-Signature` header on every delivery. Returned in full only this once — store it now, it is not recoverable afterward. Header format: `t=<unix-seconds>,v1=<hex-encoded HMAC-SHA256>`. Compute the expected signature as `HMAC-SHA256(secret, \\\"${t}.${raw request body}\\\")` (hex-encoded) and compare it to `v1` using a constant-time comparison; as a replay-protection measure, also reject if `t` is too far from the current time — Klappay does not enforce or check any particular tolerance server-side, so the exact threshold is entirely the receiver's own policy call. An official SDK's `constructEvent()`/`verifySignature()` do this for you, defaulting to a 300-second tolerance, overridable via `constructEvent`'s `toleranceSeconds` option — see github.com/klappay for available SDKs.\",\n ),\n createdAt: z.string().datetime(),\n})\n\nexport type Webhook = z.infer<typeof WebhookSchema>\n\nexport const WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({\n hint: z\n .string()\n .describe('A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).'),\n})\nexport type WebhookListItem = z.infer<typeof WebhookListItemSchema>\n\nexport const WebhookPayloadSchema = z.object({\n id: z\n .string()\n .describe(\n 'Unique id for this specific delivery — also sent as the `X-Klappay-Delivery` header.',\n ),\n event: WebhookEventTypeSchema,\n createdAt: z.string().datetime(),\n data: z\n .unknown()\n .describe(\n 'Event-specific data. Charge events (`charge.*`) carry the full `Charge` object; account/security/webhook-delivery events carry a smaller, event-specific object — see `WebhookEventDataMap`/`TypedWebhookPayload` for the exact shape per event, or docs/webhooks.md.',\n ),\n})\n\nexport type WebhookPayload = z.infer<typeof WebhookPayloadSchema>\n\nexport const WebhookDeliveryStatusSchema = z.enum(['pending', 'delivered', 'failed'])\nexport type WebhookDeliveryStatus = z.infer<typeof WebhookDeliveryStatusSchema>\n\nexport const WebhookDeliverySchema = z.object({\n id: z.string(),\n webhookId: z.string(),\n event: WebhookEventTypeSchema,\n status: WebhookDeliveryStatusSchema.describe(\n '`pending`: still retrying. `delivered`: got a 2xx response. `failed`: retries exhausted (5 attempts over ~24h) — use `POST /v1/webhooks/{id}/deliveries/{deliveryId}/retry` to try again manually.',\n ),\n attempts: z.number(),\n responseCode: z\n .number()\n .nullable()\n .describe(\n 'HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all.',\n ),\n nextRetryAt: z.string().datetime().nullable(),\n deliveredAt: z.string().datetime().nullable(),\n createdAt: z.string().datetime(),\n})\n\nexport type WebhookDelivery = z.infer<typeof WebhookDeliverySchema>\n\nexport const ListWebhookDeliveriesSchema = PaginationQuerySchema\n\nexport type ListWebhookDeliveriesInput = z.infer<typeof ListWebhookDeliveriesSchema>\n\nexport type ListWebhookDeliveriesRequest = z.input<typeof ListWebhookDeliveriesSchema>\n\nexport const PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema)\n\nexport type PaginatedWebhookDeliveries = z.infer<typeof PaginatedWebhookDeliveriesSchema>\n","import { z } from 'zod'\nimport { EnvironmentSchema } from './environment'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\n\nexport const CreateApiKeySchema = z.object({\n name: z\n .string()\n .min(1)\n .max(64)\n .describe(\n 'A label to help you tell keys apart (e.g. `\"production backend\"`). Not used for anything functional.',\n ),\n environment: EnvironmentSchema.describe(\n '`live` keys move real funds on Base mainnet; `test` keys settle on Base Sepolia (a real testnet, no real money) and additionally unlock `POST /v1/sandbox/*` for simulating events with zero on-chain activity at all.',\n ),\n})\n\nexport type CreateApiKeyInput = z.infer<typeof CreateApiKeySchema>\n\nexport const ApiKeySchema = z.object({\n id: z.string(),\n name: z.string(),\n environment: EnvironmentSchema.describe(\n '`live` keys authenticate real charges on Base mainnet; `test` keys authenticate the same charge lifecycle on Base Sepolia (a real testnet) and additionally unlock `/v1/sandbox/*` for synthetic event simulation.',\n ),\n key: z\n .string()\n .optional()\n .describe(\n 'The full secret key (`klap_live_...` / `klap_test_...`), used as the `Authorization: Bearer` value on `/v1/charges`, `/v1/webhooks`, and `/v1/sandbox` requests. Present only in the response to `POST /v1/api-keys` — never returned again afterward, so store it immediately.',\n ),\n hint: z\n .string()\n .describe(\n \"A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't.\",\n ),\n createdAt: z.string().datetime(),\n lastUsedAt: z\n .string()\n .datetime()\n .nullable()\n .describe('Updated on every successful authenticated request. `null` if never used.'),\n createdByUserId: z\n .string()\n .nullable()\n .describe(\n 'Which member of the organization created this key. `null` for a key created before this field existed.',\n ),\n})\n\nexport type ApiKey = z.infer<typeof ApiKeySchema>\n\nexport const ListApiKeysSchema = PaginationQuerySchema\n\nexport type ListApiKeysInput = z.infer<typeof ListApiKeysSchema>\n\nexport type ListApiKeysRequest = z.input<typeof ListApiKeysSchema>\n\nexport const PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema)\n\nexport type PaginatedApiKeys = z.infer<typeof PaginatedApiKeysSchema>\n","import { z } from 'zod'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\n\nexport const UserRoleSchema = z\n .enum(['owner', 'admin', 'member'])\n .describe(\n \"`owner`: full access, and the organization must always keep at least one. `admin`: can manage `member`s but not other `admin`s. `member`: no management permissions. You can only manage a member with a strictly lower role than your own, unless you're an `owner`.\",\n )\nexport type UserRole = z.infer<typeof UserRoleSchema>\n\nexport const UpdateUserRoleSchema = z.object({\n role: UserRoleSchema,\n})\n\nexport type UpdateUserRoleInput = z.infer<typeof UpdateUserRoleSchema>\n\nexport const UserSchema = z.object({\n id: z.string(),\n email: z.string(),\n name: z.string().nullable(),\n role: UserRoleSchema.describe('Your role within the organization this user was fetched from.'),\n emailVerifiedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When this address was confirmed via the emailed verification link. `null` until then. Required (non-null) for two specific actions: creating a `live` API key (`POST /v1/api-keys`) and changing `Organization.payoutAddress` (`PATCH /v1/organization`) — everything else works regardless of verification status.',\n ),\n createdAt: z.string().datetime(),\n})\n\nexport type User = z.infer<typeof UserSchema>\n\nexport const ListUsersSchema = PaginationQuerySchema\n\nexport type ListUsersInput = z.infer<typeof ListUsersSchema>\n\nexport type ListUsersRequest = z.input<typeof ListUsersSchema>\n\nexport const PaginatedUsersSchema = paginatedSchema(UserSchema)\n\nexport type PaginatedUsers = z.infer<typeof PaginatedUsersSchema>\n","import { z } from 'zod'\nimport { UserSchema } from './users'\n\nexport const NormalizedEmailSchema = z\n .string()\n .trim()\n .max(255)\n .toLowerCase()\n .email()\n .transform((email) => email.normalize('NFC'))\n .describe(\n \"Trimmed, lowercased, and NFC-normalized server-side before use — case/whitespace don't matter.\",\n )\n\nexport const SignupSchema = z.object({\n email: NormalizedEmailSchema,\n password: z.string().min(8).max(128).describe('8-128 characters. No other complexity rule.'),\n})\n\nexport type SignupInput = z.infer<typeof SignupSchema>\n\nexport const LoginSchema = z.object({\n email: NormalizedEmailSchema,\n password: z.string().min(1).max(128),\n})\n\nexport type LoginInput = z.infer<typeof LoginSchema>\n\nexport const VerifyEmailSchema = z.object({\n token: z\n .string()\n .min(1)\n .describe('The token from the verification email — passed as-is, not the account email.'),\n})\nexport type VerifyEmailInput = z.infer<typeof VerifyEmailSchema>\n\nexport const ForgotPasswordSchema = z.object({\n email: NormalizedEmailSchema,\n})\nexport type ForgotPasswordInput = z.infer<typeof ForgotPasswordSchema>\n\nexport const ResetPasswordSchema = z.object({\n token: z.string().min(1).describe('The token from the password reset email.'),\n newPassword: z.string().min(8).max(128),\n})\nexport type ResetPasswordInput = z.infer<typeof ResetPasswordSchema>\n\nexport const MessageResponseSchema = z.object({\n message: z.string().describe('Human-readable confirmation, safe to show a user directly.'),\n})\nexport type MessageResponse = z.infer<typeof MessageResponseSchema>\n\nexport const AuthResponseSchema = z.object({\n token: z\n .string()\n .describe(\n 'Session JWT, valid 7 days — use as `Authorization: Bearer <token>` on every `/v1/organizations/*` request (which nests API keys, members, and invitations — see `GET /v1/organizations`). This token identifies only you; it carries no organization or role — every `/v1/organizations/{id}/*` request is authorized fresh against your actual membership in that specific organization. This is a separate credential from an API key: it authenticates a human/dashboard session, not payment operations. Create an API key with it before you can create charges.',\n ),\n user: UserSchema.omit({ createdAt: true, role: true }),\n})\n\nexport type AuthResponse = z.infer<typeof AuthResponseSchema>\n","import { z } from 'zod'\nimport { PaginationQuerySchema, paginatedSchema } from './pagination'\nimport { UserRoleSchema } from './users'\n\nexport const UpdateOrganizationSchema = z.object({\n name: z.string().min(1).max(255).optional().describe(\"The organization's display name.\"),\n payoutAddress: z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a valid EVM address')\n .optional()\n .describe(\n \"The wallet that receives the merchant's share of every future charge. Changing this only affects charges created after the change — an already-created charge's payout split is frozen from creation and is never retroactively affected. Required before you can create any charge. Any casing is accepted — EIP-55 checksum casing is not required or verified.\",\n ),\n})\n\nexport type UpdateOrganizationInput = z.infer<typeof UpdateOrganizationSchema>\n\nexport const OrganizationSchema = z.object({\n id: z.string(),\n name: z.string(),\n payoutAddress: z\n .string()\n .nullable()\n .describe('`null` until configured — `POST /v1/charges` fails until this is set.'),\n currentFeePercent: z\n .number()\n .describe(\n \"Your current platform fee percentage — `1.5` means 1.5%, not a 0–1 fraction. Funds the infrastructure Klappay runs on your behalf (on-chain monitoring, settlement, webhook delivery, support) the same way any payment processor's fee does; this is not optional or removable. Dynamic, not fixed: it's based on your trailing monthly volume, with lower volume paying a higher percentage — higher-volume organizations, or ones with a specific negotiated arrangement, can be assigned a different rate at Klappay's discretion. Frozen onto each charge at creation, so a rate change never retroactively affects a charge already created; see `feeUpdatedAt` for when it last changed. Contact Klappay if you'd like your rate reviewed.\",\n ),\n feeUpdatedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up.',\n ),\n createdAt: z.string().datetime(),\n})\n\nexport type Organization = z.infer<typeof OrganizationSchema>\n\nexport const OrganizationWithRoleSchema = OrganizationSchema.extend({\n role: UserRoleSchema.describe('Your own role within this specific organization.'),\n})\n\nexport type OrganizationWithRole = z.infer<typeof OrganizationWithRoleSchema>\n\nexport const PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema)\n\nexport type PaginatedOrganizations = z.infer<typeof PaginatedOrganizationsSchema>\n\nexport const ListOrganizationsSchema = PaginationQuerySchema\n\nexport type ListOrganizationsInput = z.infer<typeof ListOrganizationsSchema>\n\nexport type ListOrganizationsRequest = z.input<typeof ListOrganizationsSchema>\n","import { z } from 'zod'\nimport { NormalizedEmailSchema } from './auth'\nimport { UserRoleSchema } from './users'\n\nexport const InviteUserSchema = z.object({\n email: NormalizedEmailSchema,\n role: UserRoleSchema.default('member').describe(\n 'The role the invitee will hold once they accept — subject to the same management-hierarchy rule as `PATCH /v1/organizations/{id}/users/{userId}`: an `admin` inviter cannot invite an `admin` or `owner`.',\n ),\n})\n\nexport type InviteUserInput = z.infer<typeof InviteUserSchema>\n\nexport type InviteUserRequest = z.input<typeof InviteUserSchema>\n\nexport const AcceptInvitationSchema = z.object({\n token: z.string().min(1).describe('The token from the invitation email.'),\n password: z\n .string()\n .min(8)\n .max(128)\n .optional()\n .describe(\n 'Required only if the invited email has no existing Klappay account — a new account is created along with the membership. Ignored if the account already exists.',\n ),\n})\n\nexport type AcceptInvitationInput = z.infer<typeof AcceptInvitationSchema>\n\nexport const InvitationSchema = z.object({\n id: z.string(),\n organizationId: z.string(),\n email: z.string(),\n role: UserRoleSchema,\n invitedByUserId: z.string().describe('Which member of the organization sent this invitation.'),\n expiresAt: z.string().datetime(),\n createdAt: z.string().datetime(),\n})\n\nexport type Invitation = z.infer<typeof InvitationSchema>\n","import { z } from 'zod'\nimport { NetworkSchema } from './networks'\nimport { TokenSchema } from './tokens'\nimport { WebhookEventTypeSchema } from './webhook-events'\n\nexport const TransactionSourceSchema = z\n .enum(['moralis_webhook', 'reconciliation_job', 'sandbox'])\n .describe(\n 'How this transfer was detected: `moralis_webhook` (the normal path), `reconciliation_job` (a fallback poller caught it after the webhook was missed or delayed), or `sandbox` (simulated via `POST /v1/sandbox/charges/{id}/trigger`, no real on-chain transfer).',\n )\nexport type TransactionSource = z.infer<typeof TransactionSourceSchema>\n\nexport const TimelineEventTypeSchema = z\n .enum([\n 'charge.created',\n 'charge.expired',\n 'transaction.detected',\n 'split.distributed',\n 'webhook.dispatched',\n 'webhook.delivered',\n 'webhook.failed',\n ])\n .describe(\n '`charge.created`: the charge was created. `charge.expired`: `expiresAt` passed with no full payment. `transaction.detected`: a raw on-chain transfer was seen (see the `event`-shaped fields below for details — a charge can have more than one, e.g. a partial payment followed by the rest). `split.distributed`: a payout to the merchant completed on-chain, for one contributing `(token, network)` pair — a charge settled across more than one pair emits one of these per pair (see the `token`/`network` fields below). `webhook.dispatched`/`webhook.delivered`/`webhook.failed`: one specific delivery *attempt* for one webhook subscription — `failed` here means this single attempt failed, not that all retries were exhausted (see `WebhookDeliveryStatusSchema` for the exhausted-all-retries state).',\n )\nexport type TimelineEventType = z.infer<typeof TimelineEventTypeSchema>\n\nexport const TimelineEventSchema = z.object({\n type: TimelineEventTypeSchema,\n at: z.string().datetime(),\n txHash: z\n .string()\n .optional()\n .describe('Present for `transaction.detected` and `split.distributed` events only.'),\n amount: z\n .number()\n .optional()\n .describe(\n 'Present for `transaction.detected` events only — the amount that specific transfer carried.',\n ),\n source: TransactionSourceSchema.optional().describe(\n 'Present for `transaction.detected` events only.',\n ),\n token: TokenSchema.optional().describe(\n 'Present for `transaction.detected` and `split.distributed` events — which token this specific transfer, or settlement, used. A charge can accept (and be settled across) more than one `(token, network)` pair (see `Charge.acceptedPayments`); this is how to tell which one a given event actually used.',\n ),\n network: NetworkSchema.optional().describe(\n 'Present for `transaction.detected` and `split.distributed` events — which network this specific transfer, or settlement, used.',\n ),\n causedTransition: z\n .boolean()\n .optional()\n .describe(\n \"Present for `transaction.detected` events only. `true` if this specific transfer changed the charge's status (e.g. PENDING→CONFIRMED) — a charge paid in installments can have more than one such event.\",\n ),\n event: WebhookEventTypeSchema.optional().describe(\n 'Present for `webhook.*` events only — which event type this delivery was for.',\n ),\n responseCode: z\n .number()\n .nullable()\n .optional()\n .describe(\n 'Present for `webhook.*` events only — HTTP status your endpoint returned, or `null` if the request never connected.',\n ),\n attempts: z\n .number()\n .optional()\n .describe(\n 'Present for `webhook.*` events only — how many delivery attempts have been made so far.',\n ),\n})\nexport type TimelineEvent = z.infer<typeof TimelineEventSchema>\n","import { z } from 'zod'\nimport { NetworkSchema } from './networks'\nimport { TokenSchema } from './tokens'\n\nexport const SplitRecipientRoleSchema = z\n .enum(['merchant', 'klap_fee', 'distributor_incentive'])\n .describe(\n '`merchant`: the payout recipient. `klap_fee`: the platform fee. `distributor_incentive`: the (usually small) reward paid to whoever triggered the on-chain settlement — may be Klappay or a third party, see `address`.',\n )\nexport type SplitRecipientRole = z.infer<typeof SplitRecipientRoleSchema>\n\nexport const VerifySplitEntrySchema = z.object({\n role: SplitRecipientRoleSchema,\n address: z\n .string()\n .nullable()\n .describe(\n 'On-chain recipient address for this share. For `distributor_incentive`, this is `null` until settlement actually happens — there is no fixed address, it goes to whoever calls the settlement transaction.',\n ),\n percentAllocation: z\n .number()\n .describe(\"This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%).\"),\n amountUSD: z.number(),\n})\n\nexport const VerifyPaymentSchema = z.object({\n token: TokenSchema,\n network: NetworkSchema,\n amountReceived: z\n .number()\n .describe('Cumulative amount received on this specific `(token, network)` pair.'),\n txHash: z\n .string()\n .describe('The on-chain transaction hash of the most recent transfer on this pair.'),\n explorerTxUrl: z.string().describe('Direct link to `txHash` on the relevant block explorer.'),\n split: z\n .array(VerifySplitEntrySchema)\n .describe(\n \"The exact breakdown of where this pair's payment went — merchant's share, Klappay's fee, and (once settled) the settlement incentive.\",\n ),\n splitTxHash: z\n .string()\n .nullable()\n .describe(\n 'Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then.',\n ),\n settledAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n \"When settlement completed for this pair — the merchant's wallet actually has the funds. `null` until then.\",\n ),\n})\nexport type VerifyPayment = z.infer<typeof VerifyPaymentSchema>\n\nexport const VerifyChargeSchema = z.object({\n id: z.string(),\n amount: z\n .number()\n .nullable()\n .describe('The amount originally requested. `null` if the charge accepted any amount.'),\n amountReceived: z\n .number()\n .describe(\n 'The actual cumulative amount received across every contributing pair — can exceed `amount` on an overpayment.',\n ),\n confirmedAt: z\n .string()\n .datetime()\n .nullable()\n .describe(\n 'When the charge reached `confirmed`. `null` for a `mode: continuous` charge — it never reaches a single confirmed moment (`status` stays `pending` for its whole life, see `Charge.mode`); use each entry in `payments[].settledAt` for per-contribution timing instead.',\n ),\n splitAddress: z\n .string()\n .describe(\n 'The on-chain address the payment was sent to — identical across every accepted network.',\n ),\n payments: z\n .array(VerifyPaymentSchema)\n .describe(\n 'One entry per `(token, network)` pair that actually contributed funds — a charge accepting several pairs can be confirmed by a combination of them, each proven and settled independently.',\n ),\n})\n\nexport type VerifyCharge = z.infer<typeof VerifyChargeSchema>\n","import { z } from 'zod'\n\nexport const HealthSchema = z.object({\n status: z\n .enum(['ok', 'error'])\n .describe(\n '`error` when the database connectivity check fails — the HTTP status code mirrors this (503 instead of 200), so a plain uptime check (not just a JSON-aware one) still catches a DB outage.',\n ),\n version: z.string(),\n timestamp: z.string().datetime(),\n db: z\n .enum(['ok', 'error'])\n .describe('Result of a real database connectivity check, not just a process-alive check.'),\n pendingWebhooks: z\n .number()\n .describe('Count of webhook deliveries still awaiting a successful attempt.'),\n oldestPendingChargeAgeSeconds: z\n .number()\n .nullable()\n .describe('Age of the oldest still-unpaid charge, in seconds. `null` if there are none.'),\n lastMoralisEventAgeSeconds: z\n .number()\n .nullable()\n .describe(\n 'Seconds since the last on-chain payment notification was received — a cheap signal for whether payment detection is currently working. `null` if none have ever been received.',\n ),\n})\n\nexport type Health = z.infer<typeof HealthSchema>\n","import { z } from 'zod'\nimport { CHARGE_AMOUNT_MAX } from './charges'\nimport { NonChargeTriggerableEventSchema, TriggerableChargeEventSchema } from './webhook-events'\n\nexport const SandboxTriggerSchema = z.object({\n event: TriggerableChargeEventSchema,\n amount: z\n .number()\n .positive()\n .max(CHARGE_AMOUNT_MAX)\n .optional()\n .describe(\n 'Used with `charge.partially_paid` (amount to simulate as received so far — must be less than the charge amount, defaults to half of it if omitted) and with `charge.overpaid` (amount received — must be greater than the charge amount, defaults to 1.5x it if omitted). Ignored for every other event.',\n ),\n})\n\nexport type SandboxTriggerInput = z.infer<typeof SandboxTriggerSchema>\n\nexport const SandboxEventTriggerSchema = z.object({\n event: NonChargeTriggerableEventSchema.describe(\n 'Any account, security, or webhook-delivery event — simulates it with synthetic data against your own webhooks, no real state change or precondition required (unlike `POST /v1/sandbox/charges/{id}/trigger`, which acts on a real charge).',\n ),\n})\n\nexport type SandboxEventTriggerInput = z.infer<typeof SandboxEventTriggerSchema>\n","import { z } from 'zod'\nimport { AcceptedPaymentSchema } from './charges'\n\nexport const CapabilitiesSchema = z.object({\n acceptedPayments: z\n .array(AcceptedPaymentSchema)\n .describe(\n 'Every `(token, network)` pair actually configured for your environment right now — read straight from the same lookup `POST /v1/charges` validates `acceptedPayments` against, so it can never list a pair that charge creation would then reject. Use this to build a picker UI instead of hardcoding the matrix client-side.',\n ),\n})\nexport type Capabilities = z.infer<typeof CapabilitiesSchema>\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,OAAO,EAAE,OAAO;AAAA,IACd,MAAM,EACH,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,SAAS,EACN,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,OAAO,EACJ,OAAO,EACP,SAAS,EACT,SAAS,2DAA2D;AAAA,EACzE,CAAC;AACH,CAAC;;;ACnBD,SAAS,KAAAA,UAAS;AAEX,IAAM,oBAAoBA,GAC9B,KAAK,CAAC,QAAQ,MAAM,CAAC,EACrB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A,IACC;AAAA,EACF;AAAA,EACF,SAASA,IAAE,OAAO;AAAA,EAClB,WAAWA,IAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,IAAIA,IACD,KAAK,CAAC,MAAM,OAAO,CAAC,EACpB,SAAS,+EAA+E;AAAA,EAC3F,iBAAiBA,IACd,OAAO,EACP,SAAS,kEAAkE;AAAA,EAC9E,+BAA+BA,IAC5B,OAAO,EACP,SAAS,EACT,SAAS,8EAA8E;AAAA,EAC1F,4BAA4BA,IACzB,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;;;AC1BD,SAAS,KAAAC,WAAS;AAIX,IAAM,uBAAuBC,IAAE,OAAO;AAAA,EAC3C,OAAO;AAAA,EACP,QAAQA,IACL,OAAO,EACP,SAAS,EACT,IAAI,iBAAiB,EACrB,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;AAIM,IAAM,4BAA4BA,IAAE,OAAO;AAAA,EAChD,OAAO,gCAAgC;AAAA,IACrC;AAAA,EACF;AACF,CAAC;;;ACtBD,SAAS,KAAAC,WAAS;AAGX,IAAM,qBAAqBC,IAAE,OAAO;AAAA,EACzC,kBAAkBA,IACf,MAAM,qBAAqB,EAC3B;AAAA,IACC;AAAA,EACF;AACJ,CAAC;","names":["z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klappay/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "TypeScript types and Zod schemas for the
|
|
5
|
+
"description": "TypeScript types and Zod schemas for the Klappay Core API — the request/response contracts, published separately so integrators get them without needing access to the (closed-source) API implementation.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"klap",
|
|
8
8
|
"payments",
|