@klappay/types 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  CHECKOUT_PRODUCTS_MAX: () => CHECKOUT_PRODUCTS_MAX,
36
36
  CONFLICTING_SCOPE_PAIRS: () => CONFLICTING_SCOPE_PAIRS,
37
37
  CapabilitiesSchema: () => CapabilitiesSchema,
38
+ ChargeFeePayerSchema: () => ChargeFeePayerSchema,
38
39
  ChargeSchema: () => ChargeSchema,
39
40
  ChargeStatusSchema: () => ChargeStatusSchema,
40
41
  ChargeWebhookEventTypeSchema: () => ChargeWebhookEventTypeSchema,
@@ -44,6 +45,7 @@ __export(index_exports, {
44
45
  CheckChargeRequestSchema: () => CheckChargeRequestSchema,
45
46
  CheckChargeResponseSchema: () => CheckChargeResponseSchema,
46
47
  CheckoutProductSchema: () => CheckoutProductSchema,
48
+ ConfirmationProgressSchema: () => ConfirmationProgressSchema,
47
49
  CreateChargeSchema: () => CreateChargeSchema,
48
50
  CreateRecipientSchema: () => CreateRecipientSchema,
49
51
  CreateSwapQuoteSchema: () => CreateSwapQuoteSchema,
@@ -91,6 +93,7 @@ __export(index_exports, {
91
93
  PendingDistributionRecipientSchema: () => PendingDistributionRecipientSchema,
92
94
  PendingDistributionSchema: () => PendingDistributionSchema,
93
95
  RecipientSchema: () => RecipientSchema,
96
+ RefundEscrowRequestSchema: () => RefundEscrowRequestSchema,
94
97
  ReleaseEscrowRequestSchema: () => ReleaseEscrowRequestSchema,
95
98
  SandboxTriggerSchema: () => SandboxTriggerSchema,
96
99
  SetRecipientPayoutSchema: () => SetRecipientPayoutSchema,
@@ -370,6 +373,11 @@ var ReleaseEscrowRequestSchema = import_zod9.z.object({
370
373
  "The Safe transaction signature authorizing this release, produced by signing a transfer of the escrow's entire current token balance to the charge's already-frozen split address (the same split that would have received the payment on a normal, non-escrow charge) with the private key behind this charge's `escrowReleaserAddress` \u2014 never anything Klappay can produce itself. The destination is fixed by the charge's `splitConfig` (frozen at creation); the amount is read live on-chain at release time, not fixed in advance, so it always matches whatever actually arrived \u2014 reconstruct the exact transaction server-side computes (ERC-20 `transfer(splitAddress, balance)` from the escrow Safe, nonce 0) before signing. Independently verified on-chain before anything moves \u2014 the Safe contract itself rejects a signature that isn't from `escrowReleaserAddress`, never trusted at face value by Klappay."
371
374
  )
372
375
  });
376
+ var RefundEscrowRequestSchema = import_zod9.z.object({
377
+ signature: import_zod9.z.string().regex(/^0x[0-9a-fA-F]+$/, "must be hex-encoded signature bytes").describe(
378
+ "The Safe transaction signature authorizing this refund, produced by signing a transfer of the escrow's entire current token balance back to the address that funded this charge (`Charge.payerAddress`, captured from the credited transfer) with the private key behind this charge's `escrowReleaserAddress` \u2014 never anything Klappay can produce itself. The amount is read live on-chain at refund time, not fixed in advance, so it always matches whatever actually arrived \u2014 reconstruct the exact transaction Klappay computes server-side (ERC-20 `transfer(payerAddress, balance)` from the escrow Safe, nonce 0) before signing. Independently verified on-chain before anything moves \u2014 the Safe contract itself rejects a signature that isn't from `escrowReleaserAddress`, never trusted at face value by Klappay."
379
+ )
380
+ });
373
381
 
374
382
  // src/charges.ts
375
383
  var ChargeStatusSchema = import_zod10.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid"]).describe(
@@ -378,6 +386,9 @@ var ChargeStatusSchema = import_zod10.z.enum(["pending", "partially_paid", "conf
378
386
  var SettlementStatusSchema = import_zod10.z.enum(["pending", "completed", "failed"]).describe(
379
387
  "Progress of the payout to the merchant's wallet, a separate step from `status` \u2014 `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 \u2014 nothing has been received, or the charge is still in progress."
380
388
  );
389
+ var ChargeFeePayerSchema = import_zod10.z.enum(["merchant", "payer"]).describe(
390
+ "Who ends up covering Klappay's `feePercent`. `merchant` (default): `amount` is exactly what you asked for, and Klappay's fee is deducted from your own payout \u2014 you net `amount * (1 - feePercent / 100)`. `payer` : `amount` is grossed up at creation time so that, after the same fee deduction, you still net the amount you originally requested \u2014 the payer sees and sends the larger, fee-inclusive total. Frozen at creation like every other fee input; does not change how `feeAmount`/`merchantAmount` are computed on read, only what `amount` was set to in the first place."
391
+ );
381
392
  var CHARGE_EXPIRES_IN_MIN_SECONDS = 60;
382
393
  var CHARGE_EXPIRES_IN_MAX_SECONDS = 3600;
383
394
  var CHARGE_ACCEPTED_PAYMENTS_MAX = 14;
@@ -447,8 +458,9 @@ var SplitRecipientsInputSchema = import_zod10.z.array(SplitRecipientInputSchema)
447
458
  var CHARGE_AMOUNT_MAX = 999999999999;
448
459
  var CreateChargeSchema = import_zod10.z.object({
449
460
  amount: import_zod10.z.number().positive().max(CHARGE_AMOUNT_MAX).describe(
450
- "Amount to charge, in `currency` units (e.g. `49.9` = $49.90) \u2014 up to 6 decimal places; anything more precise is silently truncated. Required \u2014 every charge has a target amount, the first credited transfer that reaches it confirms the charge."
461
+ "Amount to charge, in `currency` units (e.g. `49.9` = $49.90) \u2014 up to 6 decimal places; anything more precise is silently truncated. Required \u2014 every charge has a target amount, the first credited transfer that reaches it confirms the charge. With `feePayer: 'payer'` (see below), this is your own desired net amount, not the total the payer ends up sending \u2014 the response's `amount` is grossed up to cover `feePercent`, while `merchantAmount` on the response echoes back this exact value."
451
462
  ),
463
+ feePayer: ChargeFeePayerSchema.optional().default("merchant"),
452
464
  currency: import_zod10.z.literal("USD").default("USD").describe("Always `USD` today \u2014 the only supported currency."),
453
465
  acceptedPayments: AcceptedPaymentsSchema,
454
466
  expiresIn: import_zod10.z.number().int().min(CHARGE_EXPIRES_IN_MIN_SECONDS).max(CHARGE_EXPIRES_IN_MAX_SECONDS).describe(
@@ -474,7 +486,17 @@ var CreateChargeSchema = import_zod10.z.object({
474
486
  });
475
487
  var ChargeSchema = import_zod10.z.object({
476
488
  id: import_zod10.z.string().describe("Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later."),
477
- amount: import_zod10.z.number().describe("The amount originally requested, in `currency` units (up to 6 decimal places)."),
489
+ amount: import_zod10.z.number().describe(
490
+ "The exact total the payer must send, in `currency` units (up to 6 decimal places). With `feePayer: 'merchant'` (the default) this is exactly what you requested at creation. With `feePayer: 'payer'` this is grossed up to cover `feePercent` \u2014 see `merchantAmount` for what you requested/will actually net."
491
+ ),
492
+ feePayer: ChargeFeePayerSchema,
493
+ feePercent: import_zod10.z.number().describe(
494
+ "Klappay's fee for this charge, as a percent of `amount` (e.g. `2` = 2%) \u2014 includes any escrow surcharge if this charge is an escrow. Frozen at creation; see `feeAmount`/`merchantAmount` for the actual amounts this works out to."
495
+ ),
496
+ feeAmount: import_zod10.z.number().describe("`amount * feePercent / 100`, in `currency` units \u2014 Klappay's cut of this charge."),
497
+ merchantAmount: import_zod10.z.number().describe(
498
+ "`amount - feeAmount`, in `currency` units \u2014 what you actually net once the payout settles, regardless of `feePayer` (this is always what the split delivers to you; `feePayer` only affects what `amount` was set to at creation)."
499
+ ),
478
500
  amountReceived: import_zod10.z.number().nullable().describe(
479
501
  "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` \u2014 see `isOverpaid`."
480
502
  ),
@@ -524,7 +546,10 @@ var ChargeSchema = import_zod10.z.object({
524
546
  ),
525
547
  escrow: import_zod10.z.object({
526
548
  releaserAddress: import_zod10.z.string().describe("The only address that can ever release this escrow \u2014 never Klappay."),
527
- releasedAt: import_zod10.z.string().datetime().nullable().describe("When the release actually executed on-chain. `null` until then.")
549
+ releasedAt: import_zod10.z.string().datetime().nullable().describe("When the release actually executed on-chain. `null` until then."),
550
+ refundedAt: import_zod10.z.string().datetime().nullable().describe(
551
+ "When the refund actually executed on-chain. `null` until then. Mutually exclusive with `releasedAt` \u2014 an escrow can only ever be released or refunded once, never both."
552
+ )
528
553
  }).nullable().describe(
529
554
  "Present only when this charge was created as an escrow (see `escrow` on the create request) \u2014 `null` for a normal charge."
530
555
  )
@@ -552,9 +577,28 @@ var GetChargeQrCodeQuerySchema = import_zod10.z.object({
552
577
  });
553
578
 
554
579
  // src/charge-check.ts
580
+ var import_zod12 = require("zod");
581
+
582
+ // src/confirmation-progress.ts
555
583
  var import_zod11 = require("zod");
556
- var CheckChargeRequestSchema = import_zod11.z.object({
557
- txHash: import_zod11.z.string().regex(/^0x[0-9a-fA-F]{64}$/, "must be a 32-byte transaction hash").optional().describe(
584
+ var ConfirmationProgressSchema = import_zod11.z.object({
585
+ network: NetworkSchema.describe("Which network the transfer was seen on."),
586
+ blocksSeen: import_zod11.z.number().int().min(0).describe(
587
+ "How many blocks have passed since the transfer's own block, as of this update \u2014 a raw block count, not seconds. Grows toward `blocksRequired` as the network's blocks keep arriving."
588
+ ),
589
+ blocksRequired: import_zod11.z.number().int().min(1).describe(
590
+ "This network's minimum confirmation depth (a fixed, per-network constant) \u2014 the transfer is only credited once `blocksSeen` reaches this value."
591
+ ),
592
+ percent: import_zod11.z.number().int().min(0).max(99).describe(
593
+ '`blocksSeen`/`blocksRequired` as a rounded-down 0-99 percentage, for a progress bar. Never reaches 100 by construction \u2014 once a transfer is deep enough it is credited immediately and this stops being reported at all (the charge event itself is the "done" signal).'
594
+ )
595
+ }).describe(
596
+ "How close an already-detected transfer is to being trusted as final and credited, before its network's minimum confirmation depth is reached (see `docs/payments.md`'s \"Confirmation depth\" section). Only ever present for a transfer that's been seen on-chain but isn't deep enough yet \u2014 absent/null once it's credited (the charge's own status change is what signals that) or if nothing has been detected at all."
597
+ );
598
+
599
+ // src/charge-check.ts
600
+ var CheckChargeRequestSchema = import_zod12.z.object({
601
+ txHash: import_zod12.z.string().regex(/^0x[0-9a-fA-F]{64}$/, "must be a 32-byte transaction hash").optional().describe(
558
602
  "The on-chain transaction hash to verify directly, if you already have it \u2014 e.g. right after a swap-to-pay or wallet-connect transaction is sent. Costs a single RPC call instead of scanning a block range, so the check resolves faster and cheaper. Omit to fall back to scanning recent transfers to this charge's address, the same lookup the background reconciliation pass runs. Never trusted at face value \u2014 whatever this transaction actually contains on-chain is what gets credited, regardless of any amount/token implied elsewhere."
559
603
  ),
560
604
  network: NetworkSchema.optional().describe(
@@ -564,67 +608,70 @@ var CheckChargeRequestSchema = import_zod11.z.object({
564
608
  message: "`txHash` and `network` must be provided together, or both omitted"
565
609
  });
566
610
  var CheckChargeResponseSchema = ChargeSchema.extend({
567
- transactionSender: import_zod11.z.string().nullable().describe(
611
+ transactionSender: import_zod12.z.string().nullable().describe(
568
612
  "The `txHash` transaction's own sender (`from`) \u2014 who actually signed and submitted it on-chain, which stays the payer's own wallet even when the transaction swaps through a router/aggregator on the way to paying, unlike the credited transfer's `from` (which can be the router/pool contract, not the payer). `null` unless `txHash`/`network` was passed in the request and a successful receipt was found for it \u2014 a hint-less background scan, an unaccepted network, or a not-found/reverted transaction all leave this `null`."
613
+ ),
614
+ confirmationProgress: ConfirmationProgressSchema.nullable().describe(
615
+ "Present when this check found a real matching transfer on-chain that has not yet reached its network's required confirmation depth \u2014 use it to render a progress bar while waiting. `null` when nothing new was found, when the charge is already terminal (this check short-circuits with no RPC call), or once the transfer is deep enough to have already been credited (the charge's own `status` field is the signal for that, not this one)."
569
616
  )
570
617
  });
571
618
 
572
619
  // src/distributions.ts
573
- var import_zod12 = require("zod");
574
- var SplitDistributionStatusSchema = import_zod12.z.enum(["pending", "processing", "completed", "failed"]).describe(
620
+ var import_zod13 = require("zod");
621
+ var SplitDistributionStatusSchema = import_zod13.z.enum(["pending", "processing", "completed", "failed"]).describe(
575
622
  "Status of one payout attempt to the merchant, for a single `(token, network)` pair \u2014 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."
576
623
  );
577
- var PendingDistributionRecipientSchema = import_zod12.z.object({
578
- address: import_zod12.z.string().describe("On-chain recipient address."),
579
- percentAllocation: import_zod12.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
624
+ var PendingDistributionRecipientSchema = import_zod13.z.object({
625
+ address: import_zod13.z.string().describe("On-chain recipient address."),
626
+ percentAllocation: import_zod13.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
580
627
  });
581
- var PendingDistributionSchema = import_zod12.z.object({
582
- splitAddress: import_zod12.z.string().describe("The on-chain 0xSplits address to call `distribute()` on."),
628
+ var PendingDistributionSchema = import_zod13.z.object({
629
+ splitAddress: import_zod13.z.string().describe("The on-chain 0xSplits address to call `distribute()` on."),
583
630
  network: NetworkSchema,
584
631
  token: TokenSchema,
585
- recipients: import_zod12.z.array(PendingDistributionRecipientSchema).describe(
632
+ recipients: import_zod13.z.array(PendingDistributionRecipientSchema).describe(
586
633
  "The exact recipient list to pass to `distribute()` \u2014 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."
587
634
  ),
588
- distributorFeePercent: import_zod12.z.number().describe(
635
+ distributorFeePercent: import_zod13.z.number().describe(
589
636
  "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."
590
637
  ),
591
- estimatedRewardAmount: import_zod12.z.number().describe(
638
+ estimatedRewardAmount: import_zod13.z.number().describe(
592
639
  "Estimate only, in the charge's `currency` units, based on the amount Klappay detected on-chain \u2014 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."
593
640
  ),
594
- availableSince: import_zod12.z.string().datetime().describe("When this distribution entered its grace period."),
595
- graceEndsAt: import_zod12.z.string().datetime().describe(
641
+ availableSince: import_zod13.z.string().datetime().describe("When this distribution entered its grace period."),
642
+ graceEndsAt: import_zod13.z.string().datetime().describe(
596
643
  "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."
597
644
  )
598
645
  });
599
646
  var PaginatedPendingDistributionsSchema = paginatedSchema(PendingDistributionSchema);
600
- var ListenPendingDistributionsQuerySchema = import_zod12.z.object({
601
- limit: import_zod12.z.coerce.number().int().min(0).max(PAGINATION_LIMIT_MAX).default(0).describe(
647
+ var ListenPendingDistributionsQuerySchema = import_zod13.z.object({
648
+ limit: import_zod13.z.coerce.number().int().min(0).max(PAGINATION_LIMIT_MAX).default(0).describe(
602
649
  "How many currently-claimable distributions to emit as an initial snapshot right after connecting \u2014 each as a synthetic `distribution.available` event \u2014 before continuing with real-time deltas. `0` (the default, same as omitting it) sends no snapshot at all, matching this endpoint's original behavior: connect first, then call `GET /v1/distributions/pending` yourself to bootstrap. Not a page \u2014 there is no cursor for this snapshot, so if more than `limit` are claimable at connect time, the excess is simply not sent; call `GET /v1/distributions/pending` directly for a complete, paginated listing."
603
650
  )
604
651
  });
605
- var PendingDistributionEventSchema = import_zod12.z.discriminatedUnion("type", [
606
- import_zod12.z.object({
607
- type: import_zod12.z.literal("distribution.available"),
652
+ var PendingDistributionEventSchema = import_zod13.z.discriminatedUnion("type", [
653
+ import_zod13.z.object({
654
+ type: import_zod13.z.literal("distribution.available"),
608
655
  distribution: PendingDistributionSchema
609
656
  }),
610
- import_zod12.z.object({
611
- type: import_zod12.z.literal("distribution.claimed"),
612
- splitAddress: import_zod12.z.string().describe("No longer claimable \u2014 either settled by someone, or picked up by the worker.")
657
+ import_zod13.z.object({
658
+ type: import_zod13.z.literal("distribution.claimed"),
659
+ splitAddress: import_zod13.z.string().describe("No longer claimable \u2014 either settled by someone, or picked up by the worker.")
613
660
  })
614
661
  ]);
615
662
 
616
663
  // src/metrics.ts
617
- var import_zod13 = require("zod");
618
- var MetricsResourceSchema = import_zod13.z.enum(["charges", "transactions", "distributions"]).describe(
664
+ var import_zod14 = require("zod");
665
+ var MetricsResourceSchema = import_zod14.z.enum(["charges", "transactions", "distributions"]).describe(
619
666
  "Which underlying dataset to query. `charges`: one row per charge. `transactions`: one row per detected on-chain transfer \u2014 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."
620
667
  );
621
- var MetricsAggregationSchema = import_zod13.z.enum(["count", "sum", "avg", "min", "max"]).describe(
668
+ var MetricsAggregationSchema = import_zod14.z.enum(["count", "sum", "avg", "min", "max"]).describe(
622
669
  "`count` counts matching rows and never takes `field`. `sum`/`avg`/`min`/`max` require `field` to be set to one of the resource\u2019s numeric fields."
623
670
  );
624
- var MetricsFilterOperatorSchema = import_zod13.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
671
+ var MetricsFilterOperatorSchema = import_zod14.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
625
672
  "`in` expects an array value (max 50 entries); every other operator expects a single scalar."
626
673
  );
627
- var MetricsDateGranularitySchema = import_zod13.z.enum(["day", "week", "month", "year"]).describe(
674
+ var MetricsDateGranularitySchema = import_zod14.z.enum(["day", "week", "month", "year"]).describe(
628
675
  "Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
629
676
  );
630
677
  var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
@@ -637,31 +684,31 @@ var METRICS_QUERY_MAX_GROUP_BY = 3;
637
684
  var METRICS_QUERY_MAX_FILTERS = 20;
638
685
  var METRICS_QUERY_MAX_METRICS = 10;
639
686
  var METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
640
- var metricAliasSchema = import_zod13.z.string().min(1).max(64).regex(
687
+ var metricAliasSchema = import_zod14.z.string().min(1).max(64).regex(
641
688
  METRIC_ALIAS_PATTERN,
642
689
  "Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 this becomes a SQL column alias."
643
690
  ).optional();
644
- var MetricsFilterValueSchema = import_zod13.z.union([
645
- import_zod13.z.string().max(255),
646
- import_zod13.z.number(),
647
- import_zod13.z.boolean(),
648
- import_zod13.z.array(import_zod13.z.union([import_zod13.z.string().max(255), import_zod13.z.number()])).min(1).max(50)
691
+ var MetricsFilterValueSchema = import_zod14.z.union([
692
+ import_zod14.z.string().max(255),
693
+ import_zod14.z.number(),
694
+ import_zod14.z.boolean(),
695
+ import_zod14.z.array(import_zod14.z.union([import_zod14.z.string().max(255), import_zod14.z.number()])).min(1).max(50)
649
696
  ]);
650
- var orderBySchema = import_zod13.z.object({
651
- key: import_zod13.z.string().min(1).max(64).regex(
697
+ var orderBySchema = import_zod14.z.object({
698
+ key: import_zod14.z.string().min(1).max(64).regex(
652
699
  METRIC_ALIAS_PATTERN,
653
700
  "Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 every valid output column name already looks like this."
654
701
  ).describe(
655
702
  "An output column name from this same query \u2014 either a `groupBy` field name, or a metric\u2019s `alias` (or its default name: `${aggregation}` for `count`, `${aggregation}_${field}` otherwise, e.g. `sum_amount`). Must match `^[a-zA-Z_][a-zA-Z0-9_]*$` \u2014 every real output column name already does, so this only ever rejects a value that could never have been one."
656
703
  ),
657
- direction: import_zod13.z.enum(["asc", "desc"])
704
+ direction: import_zod14.z.enum(["asc", "desc"])
658
705
  }).describe(
659
706
  "Sort the result rows by any output column \u2014 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."
660
707
  );
661
- var limitSchema = import_zod13.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
708
+ var limitSchema = import_zod14.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
662
709
  `Max rows to return, ${1}\u2013${METRICS_QUERY_MAX_ROW_LIMIT}, default ${METRICS_QUERY_DEFAULT_ROW_LIMIT}. If more rows matched, \`meta.truncated\` is \`true\` on the response \u2014 narrow the query instead of just raising this.`
663
710
  );
664
- var ChargesQueryFieldSchema = import_zod13.z.enum([
711
+ var ChargesQueryFieldSchema = import_zod14.z.enum([
665
712
  "status",
666
713
  "source",
667
714
  "apiKeyId",
@@ -672,124 +719,124 @@ var ChargesQueryFieldSchema = import_zod13.z.enum([
672
719
  ]).describe(
673
720
  "A `Charge` field to filter or group by \u2014 see `ChargeStatusSchema` for `status`'s own possible values (charges.md). `source`/`externalRef` are free-form strings your own integration set at creation, not a fixed enum. `escrowReleaserAddress` is `null` for a normal charge \u2014 filter `escrowReleaserAddress` with operator `neq`/value `null` to isolate escrow-configured charges (see `escrow` in charges.md)."
674
721
  );
675
- var ChargesMetricFieldSchema = import_zod13.z.enum(["amount", "amountReceived", "feePercent", "escrowFeePercent"]).describe(
722
+ var ChargesMetricFieldSchema = import_zod14.z.enum(["amount", "amountReceived", "feePercent", "escrowFeePercent"]).describe(
676
723
  "A `Charge` numeric field to aggregate. `amount`/`amountReceived` are decimal currency amounts (requested vs. actually received \u2014 see `charges.md`). `feePercent` is the platform fee frozen on the charge at creation, e.g. `1.5` means 1.5%. `escrowFeePercent` is the additional escrow-specific fee component, only present on escrow-configured charges \u2014 see `docs/payments.md`."
677
724
  );
678
- var ChargesDateFieldSchema = import_zod13.z.enum(["createdAt", "confirmedAt", "lastActivityAt", "expiresAt", "escrowReleasedAt"]).describe(
725
+ var ChargesDateFieldSchema = import_zod14.z.enum(["createdAt", "confirmedAt", "lastActivityAt", "expiresAt", "escrowReleasedAt"]).describe(
679
726
  "A `Charge` timestamp to filter/bucket by. `confirmedAt` is `null` until the charge reaches `confirmed` \u2014 a `dateRange`/`date_bucket` on it implicitly excludes every charge that never confirmed. `expiresAt` is always present (set at creation), useful for e.g. finding charges expiring soon or measuring how close to expiry charges typically resolve. `escrowReleasedAt` is `null` until an escrow-configured charge is actually released \u2014 same implicit-exclusion behavior as `confirmedAt`, scoped to escrow charges only."
680
727
  );
681
- var ChargesFilterSchema = import_zod13.z.object({
728
+ var ChargesFilterSchema = import_zod14.z.object({
682
729
  field: ChargesQueryFieldSchema,
683
730
  operator: MetricsFilterOperatorSchema,
684
731
  value: MetricsFilterValueSchema
685
732
  });
686
- var ChargesGroupBySchema = import_zod13.z.union([
687
- import_zod13.z.object({ type: import_zod13.z.literal("field"), field: ChargesQueryFieldSchema }),
688
- import_zod13.z.object({
689
- type: import_zod13.z.literal("date_bucket"),
733
+ var ChargesGroupBySchema = import_zod14.z.union([
734
+ import_zod14.z.object({ type: import_zod14.z.literal("field"), field: ChargesQueryFieldSchema }),
735
+ import_zod14.z.object({
736
+ type: import_zod14.z.literal("date_bucket"),
690
737
  field: ChargesDateFieldSchema,
691
738
  granularity: MetricsDateGranularitySchema
692
739
  })
693
740
  ]);
694
- var ChargesMetricSchema = import_zod13.z.object({
741
+ var ChargesMetricSchema = import_zod14.z.object({
695
742
  aggregation: MetricsAggregationSchema,
696
743
  field: ChargesMetricFieldSchema.optional(),
697
744
  alias: metricAliasSchema
698
745
  });
699
- var ChargesMetricsQuerySchema = import_zod13.z.object({
700
- resource: import_zod13.z.literal("charges"),
746
+ var ChargesMetricsQuerySchema = import_zod14.z.object({
747
+ resource: import_zod14.z.literal("charges"),
701
748
  environment: metricsQueryEnvironmentSchema,
702
- dateRange: import_zod13.z.object({
749
+ dateRange: import_zod14.z.object({
703
750
  field: ChargesDateFieldSchema,
704
- from: import_zod13.z.string().max(64).datetime(),
705
- to: import_zod13.z.string().max(64).datetime()
751
+ from: import_zod14.z.string().max(64).datetime(),
752
+ to: import_zod14.z.string().max(64).datetime()
706
753
  }),
707
- groupBy: import_zod13.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
708
- metrics: import_zod13.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
709
- filters: import_zod13.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
754
+ groupBy: import_zod14.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
755
+ metrics: import_zod14.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
756
+ filters: import_zod14.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
710
757
  orderBy: orderBySchema.optional(),
711
758
  limit: limitSchema
712
759
  });
713
- var TransactionsQueryFieldSchema = import_zod13.z.enum(["network", "token", "source", "causedTransition"]).describe(
760
+ var TransactionsQueryFieldSchema = import_zod14.z.enum(["network", "token", "source", "causedTransition"]).describe(
714
761
  "A `Transaction` field to filter or group by \u2014 see `NetworkSchema`/`TokenSchema`/`TransactionSourceSchema` for their possible values. `causedTransition` is `true` only for the transfer(s) that actually flipped the charge's `status` \u2014 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)."
715
762
  );
716
- var TransactionsMetricFieldSchema = import_zod13.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
717
- var TransactionsDateFieldSchema = import_zod13.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
718
- var TransactionsFilterSchema = import_zod13.z.object({
763
+ var TransactionsMetricFieldSchema = import_zod14.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
764
+ var TransactionsDateFieldSchema = import_zod14.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
765
+ var TransactionsFilterSchema = import_zod14.z.object({
719
766
  field: TransactionsQueryFieldSchema,
720
767
  operator: MetricsFilterOperatorSchema,
721
768
  value: MetricsFilterValueSchema
722
769
  });
723
- var TransactionsGroupBySchema = import_zod13.z.union([
724
- import_zod13.z.object({ type: import_zod13.z.literal("field"), field: TransactionsQueryFieldSchema }),
725
- import_zod13.z.object({
726
- type: import_zod13.z.literal("date_bucket"),
770
+ var TransactionsGroupBySchema = import_zod14.z.union([
771
+ import_zod14.z.object({ type: import_zod14.z.literal("field"), field: TransactionsQueryFieldSchema }),
772
+ import_zod14.z.object({
773
+ type: import_zod14.z.literal("date_bucket"),
727
774
  field: TransactionsDateFieldSchema,
728
775
  granularity: MetricsDateGranularitySchema
729
776
  })
730
777
  ]);
731
- var TransactionsMetricSchema = import_zod13.z.object({
778
+ var TransactionsMetricSchema = import_zod14.z.object({
732
779
  aggregation: MetricsAggregationSchema,
733
780
  field: TransactionsMetricFieldSchema.optional(),
734
781
  alias: metricAliasSchema
735
782
  });
736
- var TransactionsMetricsQuerySchema = import_zod13.z.object({
737
- resource: import_zod13.z.literal("transactions"),
783
+ var TransactionsMetricsQuerySchema = import_zod14.z.object({
784
+ resource: import_zod14.z.literal("transactions"),
738
785
  environment: metricsQueryEnvironmentSchema,
739
- dateRange: import_zod13.z.object({
786
+ dateRange: import_zod14.z.object({
740
787
  field: TransactionsDateFieldSchema,
741
- from: import_zod13.z.string().max(64).datetime(),
742
- to: import_zod13.z.string().max(64).datetime()
788
+ from: import_zod14.z.string().max(64).datetime(),
789
+ to: import_zod14.z.string().max(64).datetime()
743
790
  }),
744
- groupBy: import_zod13.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
745
- metrics: import_zod13.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
746
- filters: import_zod13.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
791
+ groupBy: import_zod14.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
792
+ metrics: import_zod14.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
793
+ filters: import_zod14.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
747
794
  orderBy: orderBySchema.optional(),
748
795
  limit: limitSchema
749
796
  });
750
- var DistributionsQueryFieldSchema = import_zod13.z.enum(["status", "network", "token", "distributorAddress"]).describe(
797
+ var DistributionsQueryFieldSchema = import_zod14.z.enum(["status", "network", "token", "distributorAddress"]).describe(
751
798
  "A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values. `distributorAddress` is the public on-chain address that actually called `distribute()` for a `completed` distribution \u2014 Klappay's own operator address if settled by Klappay's own worker, a community keeper's address if settled externally (or `null` on the rare case that lookup failed), `null` for every non-`completed` status."
752
799
  );
753
- var DistributionsMetricFieldSchema = import_zod13.z.enum(["attempts"]).describe(
800
+ var DistributionsMetricFieldSchema = import_zod14.z.enum(["attempts"]).describe(
754
801
  "How many times a payout was attempted for this settlement so far \u2014 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."
755
802
  );
756
- var DistributionsDateFieldSchema = import_zod13.z.enum(["createdAt", "processingStartedAt", "completedAt"]).describe(
803
+ var DistributionsDateFieldSchema = import_zod14.z.enum(["createdAt", "processingStartedAt", "completedAt"]).describe(
757
804
  "`createdAt`: when this settlement was queued. `processingStartedAt`: when a worker began its most recent attempt at the payout \u2014 `null` until the first attempt, then overwritten on every subsequent retry, so it reflects the *latest* attempt's start, not the first. `completedAt`: when it actually paid out \u2014 `null` until `status` reaches `completed`, so a `dateRange`/`date_bucket` on it implicitly excludes every distribution still pending/processing/failed."
758
805
  );
759
- var DistributionsFilterSchema = import_zod13.z.object({
806
+ var DistributionsFilterSchema = import_zod14.z.object({
760
807
  field: DistributionsQueryFieldSchema,
761
808
  operator: MetricsFilterOperatorSchema,
762
809
  value: MetricsFilterValueSchema
763
810
  });
764
- var DistributionsGroupBySchema = import_zod13.z.union([
765
- import_zod13.z.object({ type: import_zod13.z.literal("field"), field: DistributionsQueryFieldSchema }),
766
- import_zod13.z.object({
767
- type: import_zod13.z.literal("date_bucket"),
811
+ var DistributionsGroupBySchema = import_zod14.z.union([
812
+ import_zod14.z.object({ type: import_zod14.z.literal("field"), field: DistributionsQueryFieldSchema }),
813
+ import_zod14.z.object({
814
+ type: import_zod14.z.literal("date_bucket"),
768
815
  field: DistributionsDateFieldSchema,
769
816
  granularity: MetricsDateGranularitySchema
770
817
  })
771
818
  ]);
772
- var DistributionsMetricSchema = import_zod13.z.object({
819
+ var DistributionsMetricSchema = import_zod14.z.object({
773
820
  aggregation: MetricsAggregationSchema,
774
821
  field: DistributionsMetricFieldSchema.optional(),
775
822
  alias: metricAliasSchema
776
823
  });
777
- var DistributionsMetricsQuerySchema = import_zod13.z.object({
778
- resource: import_zod13.z.literal("distributions"),
824
+ var DistributionsMetricsQuerySchema = import_zod14.z.object({
825
+ resource: import_zod14.z.literal("distributions"),
779
826
  environment: metricsQueryEnvironmentSchema,
780
- dateRange: import_zod13.z.object({
827
+ dateRange: import_zod14.z.object({
781
828
  field: DistributionsDateFieldSchema,
782
- from: import_zod13.z.string().max(64).datetime(),
783
- to: import_zod13.z.string().max(64).datetime()
829
+ from: import_zod14.z.string().max(64).datetime(),
830
+ to: import_zod14.z.string().max(64).datetime()
784
831
  }),
785
- groupBy: import_zod13.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
786
- metrics: import_zod13.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
787
- filters: import_zod13.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
832
+ groupBy: import_zod14.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
833
+ metrics: import_zod14.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
834
+ filters: import_zod14.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
788
835
  orderBy: orderBySchema.optional(),
789
836
  limit: limitSchema
790
837
  });
791
838
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
792
- var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
839
+ var MetricsQuerySchema = import_zod14.z.discriminatedUnion("resource", [
793
840
  ChargesMetricsQuerySchema,
794
841
  TransactionsMetricsQuerySchema,
795
842
  DistributionsMetricsQuerySchema
@@ -798,7 +845,7 @@ var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
798
845
  const to = new Date(input.dateRange.to);
799
846
  if (from >= to) {
800
847
  ctx.addIssue({
801
- code: import_zod13.z.ZodIssueCode.custom,
848
+ code: import_zod14.z.ZodIssueCode.custom,
802
849
  message: "`dateRange.from` must be before `dateRange.to`.",
803
850
  path: ["dateRange", "from"]
804
851
  });
@@ -806,7 +853,7 @@ var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
806
853
  const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS;
807
854
  if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {
808
855
  ctx.addIssue({
809
- code: import_zod13.z.ZodIssueCode.custom,
856
+ code: import_zod14.z.ZodIssueCode.custom,
810
857
  message: `\`dateRange\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,
811
858
  path: ["dateRange", "to"]
812
859
  });
@@ -814,7 +861,7 @@ var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
814
861
  const dateBucketCount = input.groupBy.filter((entry) => entry.type === "date_bucket").length;
815
862
  if (dateBucketCount > 1) {
816
863
  ctx.addIssue({
817
- code: import_zod13.z.ZodIssueCode.custom,
864
+ code: import_zod14.z.ZodIssueCode.custom,
818
865
  message: "At most one `date_bucket` entry is allowed in `groupBy`.",
819
866
  path: ["groupBy"]
820
867
  });
@@ -822,7 +869,7 @@ var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
822
869
  input.metrics.forEach((metric, index) => {
823
870
  if (metric.aggregation !== "count" && metric.field === void 0) {
824
871
  ctx.addIssue({
825
- code: import_zod13.z.ZodIssueCode.custom,
872
+ code: import_zod14.z.ZodIssueCode.custom,
826
873
  message: "`field` is required unless `aggregation` is `count`.",
827
874
  path: ["metrics", index, "field"]
828
875
  });
@@ -831,7 +878,7 @@ var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
831
878
  const aliases = input.metrics.map((metric) => metric.alias).filter((alias) => alias !== void 0);
832
879
  if (new Set(aliases).size !== aliases.length) {
833
880
  ctx.addIssue({
834
- code: import_zod13.z.ZodIssueCode.custom,
881
+ code: import_zod14.z.ZodIssueCode.custom,
835
882
  message: "Every `metrics[].alias` must be unique.",
836
883
  path: ["metrics"]
837
884
  });
@@ -840,32 +887,32 @@ var MetricsQuerySchema = import_zod13.z.discriminatedUnion("resource", [
840
887
  input.metrics.forEach((metric, index) => {
841
888
  if (metric.alias !== void 0 && reservedNames.has(metric.alias)) {
842
889
  ctx.addIssue({
843
- code: import_zod13.z.ZodIssueCode.custom,
890
+ code: import_zod14.z.ZodIssueCode.custom,
844
891
  message: `\`alias\` "${metric.alias}" collides with a \`groupBy\` field name (or the reserved word "bucket") \u2014 choose a different alias.`,
845
892
  path: ["metrics", index, "alias"]
846
893
  });
847
894
  }
848
895
  });
849
896
  });
850
- var MetricsQueryResultRowSchema = import_zod13.z.record(
851
- import_zod13.z.string(),
852
- import_zod13.z.union([import_zod13.z.string(), import_zod13.z.number(), import_zod13.z.boolean(), import_zod13.z.null()])
897
+ var MetricsQueryResultRowSchema = import_zod14.z.record(
898
+ import_zod14.z.string(),
899
+ import_zod14.z.union([import_zod14.z.string(), import_zod14.z.number(), import_zod14.z.boolean(), import_zod14.z.null()])
853
900
  );
854
- var MetricsQueryResultSchema = import_zod13.z.object({
855
- data: import_zod13.z.array(MetricsQueryResultRowSchema),
856
- meta: import_zod13.z.object({
901
+ var MetricsQueryResultSchema = import_zod14.z.object({
902
+ data: import_zod14.z.array(MetricsQueryResultRowSchema),
903
+ meta: import_zod14.z.object({
857
904
  resource: MetricsResourceSchema,
858
905
  environment: EnvironmentSchema,
859
- rowCount: import_zod13.z.number().int().describe("Number of rows in `data`."),
860
- truncated: import_zod13.z.boolean().describe(
906
+ rowCount: import_zod14.z.number().int().describe("Number of rows in `data`."),
907
+ truncated: import_zod14.z.boolean().describe(
861
908
  "`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
862
909
  )
863
910
  })
864
911
  });
865
912
 
866
913
  // src/webhook-events.ts
867
- var import_zod14 = require("zod");
868
- var ChargeWebhookEventTypeSchema = import_zod14.z.enum([
914
+ var import_zod15 = require("zod");
915
+ var ChargeWebhookEventTypeSchema = import_zod15.z.enum([
869
916
  "charge.created",
870
917
  "charge.partially_paid",
871
918
  "charge.confirmed",
@@ -874,18 +921,19 @@ var ChargeWebhookEventTypeSchema = import_zod14.z.enum([
874
921
  "charge.settled",
875
922
  "charge.settlement_failed",
876
923
  "charge.overpaid",
877
- "charge.escrow_released"
924
+ "charge.escrow_released",
925
+ "charge.escrow_refunded"
878
926
  ]).describe(
879
- '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 \u2014 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`). `charge.escrow_released` fires once an escrow-configured charge\'s funds have been moved out of its Safe to the split address by `POST /v1/charges/{id}/release` \u2014 a normal `charge.settled` still follows once the split itself finishes distributing. Every event in this category carries the full `Charge` object as `data`.'
927
+ '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 \u2014 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`). `charge.escrow_released` fires once an escrow-configured charge\'s funds have been moved out of its Safe to the split address by `POST /v1/charges/{id}/release` \u2014 a normal `charge.settled` still follows once the split itself finishes distributing. `charge.escrow_refunded` fires once an escrow-configured charge\'s funds have been moved out of its Safe back to the payer by `POST /v1/charges/{id}/refund` \u2014 mutually exclusive with `charge.escrow_released`, an escrow charge only ever emits one of the two. Every event in this category carries the full `Charge` object as `data`.'
880
928
  );
881
- var WebhookDeliveryEventTypeSchema = import_zod14.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
929
+ var WebhookDeliveryEventTypeSchema = import_zod15.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
882
930
  "Meta-events about the health of your own webhook endpoints \u2014 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`)."
883
931
  );
884
- var WebhookEventTypeSchema = import_zod14.z.union([
932
+ var WebhookEventTypeSchema = import_zod15.z.union([
885
933
  ChargeWebhookEventTypeSchema,
886
934
  WebhookDeliveryEventTypeSchema
887
935
  ]);
888
- var WebhookCategorySchema = import_zod14.z.enum(["payments", "webhooks"]).describe(
936
+ var WebhookCategorySchema = import_zod15.z.enum(["payments", "webhooks"]).describe(
889
937
  "Subscribe to every event in a category via `eventCategories` instead of listing events one by one \u2014 new events added to a category later arrive automatically, no subscription update needed."
890
938
  );
891
939
  function buildCategoryMap() {
@@ -907,122 +955,127 @@ var WEBHOOK_EVENT_CATEGORIES = {
907
955
  webhooks: WebhookDeliveryEventTypeSchema.options
908
956
  };
909
957
  var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
910
- "charge.created"
958
+ "charge.created",
959
+ "charge.escrow_released",
960
+ "charge.escrow_refunded"
911
961
  ]).describe(
912
- "Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into \u2014 everything except `charge.created` (a charge already exists by the time you have an id to trigger against)."
962
+ "Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into \u2014 everything except `charge.created` (a charge already exists by the time you have an id to trigger against) and the two escrow-terminal events, which are reached by actually calling `POST /v1/charges/{id}/release` or `POST /v1/charges/{id}/refund` on a test-environment escrow charge (a real Safe transaction on that network's testnet), not this generic trigger."
913
963
  );
914
964
 
915
965
  // src/webhooks.ts
916
- var import_zod15 = require("zod");
966
+ var import_zod16 = require("zod");
917
967
  var WEBHOOK_EVENTS_WILDCARD = "*";
918
- var CreateWebhookSchema = import_zod15.z.object({
919
- url: import_zod15.z.string().max(2048).url().describe(
968
+ var CreateWebhookSchema = import_zod16.z.object({
969
+ url: import_zod16.z.string().max(2048).url().describe(
920
970
  "Must be HTTPS and resolve to a public address \u2014 private/internal IPs are rejected."
921
971
  ),
922
- events: import_zod15.z.array(import_zod15.z.union([WebhookEventTypeSchema, import_zod15.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
972
+ events: import_zod16.z.array(import_zod16.z.union([WebhookEventTypeSchema, import_zod16.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
923
973
  '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.'
924
974
  ),
925
- eventCategories: import_zod15.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
975
+ eventCategories: import_zod16.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
926
976
  "Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required."
927
977
  ),
928
- excludeEvents: import_zod15.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
978
+ excludeEvents: import_zod16.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
929
979
  'Event types to exclude even if selected via `events: ["*"]` or `eventCategories`.'
930
980
  )
931
981
  }).refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {
932
982
  message: "must select at least one event via `events` or `eventCategories`",
933
983
  path: ["events"]
934
984
  });
935
- var WebhookSchema = import_zod15.z.object({
936
- id: import_zod15.z.string(),
985
+ var WebhookSchema = import_zod16.z.object({
986
+ id: import_zod16.z.string(),
937
987
  environment: EnvironmentSchema.nullable().describe(
938
988
  "Which environment's API key created this webhook \u2014 `live` or `test`. Every event is only ever delivered to a webhook whose `environment` matches the event's own (or to a webhook with `environment: null`, which receives every environment \u2014 the case for every webhook created before this field existed)."
939
989
  ),
940
- url: import_zod15.z.string(),
941
- events: import_zod15.z.array(WebhookEventTypeSchema),
942
- eventCategories: import_zod15.z.array(WebhookCategorySchema),
943
- excludeEvents: import_zod15.z.array(WebhookEventTypeSchema),
944
- isWildcard: import_zod15.z.boolean(),
945
- secret: import_zod15.z.string().describe(
990
+ url: import_zod16.z.string(),
991
+ events: import_zod16.z.array(WebhookEventTypeSchema),
992
+ eventCategories: import_zod16.z.array(WebhookCategorySchema),
993
+ excludeEvents: import_zod16.z.array(WebhookEventTypeSchema),
994
+ isWildcard: import_zod16.z.boolean(),
995
+ secret: import_zod16.z.string().describe(
946
996
  "The signing secret, used to verify the `X-Klappay-Signature` header on every delivery. Returned in full only this once \u2014 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 \u2014 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 \u2014 see github.com/klappay for available SDKs."
947
997
  ),
948
- createdAt: import_zod15.z.string().datetime()
998
+ createdAt: import_zod16.z.string().datetime()
949
999
  });
950
1000
  var WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({
951
- hint: import_zod15.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
1001
+ hint: import_zod16.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
952
1002
  });
953
- var WebhookPayloadSchema = import_zod15.z.object({
954
- id: import_zod15.z.string().describe(
1003
+ var WebhookPayloadSchema = import_zod16.z.object({
1004
+ id: import_zod16.z.string().describe(
955
1005
  "Unique id for this specific delivery \u2014 also sent as the `X-Klappay-Delivery` header."
956
1006
  ),
957
1007
  event: WebhookEventTypeSchema,
958
- createdAt: import_zod15.z.string().datetime(),
959
- data: import_zod15.z.unknown().describe(
1008
+ createdAt: import_zod16.z.string().datetime(),
1009
+ data: import_zod16.z.unknown().describe(
960
1010
  "Event-specific data. Charge events (`charge.*`) carry the full `Charge` object; webhook-delivery events carry a smaller, event-specific object \u2014 see `WebhookEventDataMap`/`TypedWebhookPayload` for the exact shape per event, or docs/webhooks.md."
961
1011
  )
962
1012
  });
963
- var WebhookDeliveryStatusSchema = import_zod15.z.enum(["pending", "delivered", "failed"]);
964
- var WebhookDeliverySchema = import_zod15.z.object({
965
- id: import_zod15.z.string(),
966
- webhookId: import_zod15.z.string(),
1013
+ var WebhookDeliveryStatusSchema = import_zod16.z.enum(["pending", "delivered", "failed"]);
1014
+ var WebhookDeliverySchema = import_zod16.z.object({
1015
+ id: import_zod16.z.string(),
1016
+ webhookId: import_zod16.z.string(),
967
1017
  event: WebhookEventTypeSchema,
968
1018
  status: WebhookDeliveryStatusSchema.describe(
969
1019
  "`pending`: still retrying. `delivered`: got a 2xx response. `failed`: retries exhausted (5 attempts over ~24h) \u2014 use `POST /v1/webhooks/{id}/deliveries/{deliveryId}/retry` to try again manually."
970
1020
  ),
971
- attempts: import_zod15.z.number(),
972
- responseCode: import_zod15.z.number().nullable().describe(
1021
+ attempts: import_zod16.z.number(),
1022
+ responseCode: import_zod16.z.number().nullable().describe(
973
1023
  "HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all."
974
1024
  ),
975
- nextRetryAt: import_zod15.z.string().datetime().nullable(),
976
- deliveredAt: import_zod15.z.string().datetime().nullable(),
977
- createdAt: import_zod15.z.string().datetime()
1025
+ nextRetryAt: import_zod16.z.string().datetime().nullable(),
1026
+ deliveredAt: import_zod16.z.string().datetime().nullable(),
1027
+ createdAt: import_zod16.z.string().datetime()
978
1028
  });
979
1029
  var ListWebhookDeliveriesSchema = PaginationQuerySchema;
980
1030
  var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
981
1031
 
982
1032
  // src/recipients.ts
983
- var import_zod16 = require("zod");
1033
+ var import_zod17 = require("zod");
984
1034
  var EVM_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
985
- var CreateRecipientSchema = import_zod16.z.object({
986
- address: import_zod16.z.string().regex(EVM_ADDRESS_REGEX, "must be a 20-byte hex address").describe("EVM address to register as a trusted split recipient for your organization."),
987
- label: import_zod16.z.string().min(1).max(64).optional().describe('Free-form label for your own bookkeeping (e.g. `"supplier"`) \u2014 never interpreted.')
1035
+ var CreateRecipientSchema = import_zod17.z.object({
1036
+ address: import_zod17.z.string().regex(EVM_ADDRESS_REGEX, "must be a 20-byte hex address").describe("EVM address to register as a trusted split recipient for your organization."),
1037
+ label: import_zod17.z.string().min(1).max(64).optional().describe('Free-form label for your own bookkeeping (e.g. `"supplier"`) \u2014 never interpreted.')
988
1038
  });
989
- var RecipientSchema = import_zod16.z.object({
990
- id: import_zod16.z.string().describe(
1039
+ var RecipientSchema = import_zod17.z.object({
1040
+ id: import_zod17.z.string().describe(
991
1041
  "Klappay-generated id, e.g. `rc_...` \u2014 this, not the raw address, is what a charge's `splitRecipients[].recipientId` references."
992
1042
  ),
993
1043
  environment: EnvironmentSchema,
994
- address: import_zod16.z.string(),
995
- label: import_zod16.z.string().nullable(),
996
- payout: import_zod16.z.boolean().describe(
1044
+ address: import_zod17.z.string(),
1045
+ label: import_zod17.z.string().nullable(),
1046
+ payout: import_zod17.z.boolean().describe(
997
1047
  "Whether this recipient is eligible to be used as an API key's `payoutAddress` (in addition to being referenceable in a split, which every non-revoked recipient already is). Set via `PATCH /v1/recipients/{id}` \u2014 requires the `recipients:manage_payout` scope, deliberately separate from `recipients:write`."
998
1048
  ),
999
- createdAt: import_zod16.z.string().datetime()
1049
+ createdAt: import_zod17.z.string().datetime()
1000
1050
  });
1001
- var SetRecipientPayoutSchema = import_zod16.z.object({
1002
- payout: import_zod16.z.boolean().describe("New payout-eligibility value for this recipient.")
1051
+ var SetRecipientPayoutSchema = import_zod17.z.object({
1052
+ payout: import_zod17.z.boolean().describe("New payout-eligibility value for this recipient.")
1003
1053
  });
1004
1054
 
1005
1055
  // src/timeline.ts
1006
- var import_zod17 = require("zod");
1007
- var TransactionSourceSchema = import_zod17.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
1056
+ var import_zod18 = require("zod");
1057
+ var TransactionSourceSchema = import_zod18.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
1008
1058
  "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)."
1009
1059
  );
1010
- var TimelineEventTypeSchema = import_zod17.z.enum([
1060
+ var TimelineEventTypeSchema = import_zod18.z.enum([
1011
1061
  "charge.created",
1012
1062
  "charge.expired",
1013
1063
  "transaction.detected",
1014
1064
  "split.distributed",
1015
1065
  "webhook.dispatched",
1016
1066
  "webhook.delivered",
1017
- "webhook.failed"
1067
+ "webhook.failed",
1068
+ "transfer.reclaimed"
1018
1069
  ]).describe(
1019
- "`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 \u2014 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 \u2014 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 \u2014 `failed` here means this single attempt failed, not that all retries were exhausted (see `WebhookDeliveryStatusSchema` for the exhausted-all-retries state)."
1070
+ "`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 \u2014 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 \u2014 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 \u2014 `failed` here means this single attempt failed, not that all retries were exhausted (see `WebhookDeliveryStatusSchema` for the exhausted-all-retries state). `transfer.reclaimed`: an on-chain transfer was detected but never reached its network's required confirmation depth before vanishing (reverted, or dropped from the canonical chain) \u2014 see `txHash` below for which transfer."
1020
1071
  );
1021
- var TimelineEventSchema = import_zod17.z.object({
1072
+ var TimelineEventSchema = import_zod18.z.object({
1022
1073
  type: TimelineEventTypeSchema,
1023
- at: import_zod17.z.string().datetime(),
1024
- txHash: import_zod17.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
1025
- amount: import_zod17.z.number().optional().describe(
1074
+ at: import_zod18.z.string().datetime(),
1075
+ txHash: import_zod18.z.string().optional().describe(
1076
+ "Present for `transaction.detected`, `split.distributed`, and `transfer.reclaimed` events only."
1077
+ ),
1078
+ amount: import_zod18.z.number().optional().describe(
1026
1079
  "Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
1027
1080
  ),
1028
1081
  source: TransactionSourceSchema.optional().describe(
@@ -1034,102 +1087,102 @@ var TimelineEventSchema = import_zod17.z.object({
1034
1087
  network: NetworkSchema.optional().describe(
1035
1088
  "Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
1036
1089
  ),
1037
- causedTransition: import_zod17.z.boolean().optional().describe(
1090
+ causedTransition: import_zod18.z.boolean().optional().describe(
1038
1091
  "Present for `transaction.detected` events only. `true` if this specific transfer changed the charge's status (e.g. PENDING\u2192CONFIRMED) \u2014 a charge paid in installments can have more than one such event."
1039
1092
  ),
1040
1093
  event: WebhookEventTypeSchema.optional().describe(
1041
1094
  "Present for `webhook.*` events only \u2014 which event type this delivery was for."
1042
1095
  ),
1043
- responseCode: import_zod17.z.number().nullable().optional().describe(
1096
+ responseCode: import_zod18.z.number().nullable().optional().describe(
1044
1097
  "Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
1045
1098
  ),
1046
- attempts: import_zod17.z.number().optional().describe(
1099
+ attempts: import_zod18.z.number().optional().describe(
1047
1100
  "Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
1048
1101
  )
1049
1102
  });
1050
1103
 
1051
1104
  // src/health.ts
1052
- var import_zod18 = require("zod");
1053
- var HealthSchema = import_zod18.z.object({
1054
- status: import_zod18.z.enum(["ok", "error"]).describe(
1105
+ var import_zod19 = require("zod");
1106
+ var HealthSchema = import_zod19.z.object({
1107
+ status: import_zod19.z.enum(["ok", "error"]).describe(
1055
1108
  "`error` when the database connectivity check fails \u2014 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."
1056
1109
  ),
1057
- version: import_zod18.z.string(),
1058
- timestamp: import_zod18.z.string().datetime(),
1059
- db: import_zod18.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
1060
- pendingWebhooks: import_zod18.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
1061
- oldestPendingChargeAgeSeconds: import_zod18.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
1062
- lastMoralisEventAgeSeconds: import_zod18.z.number().nullable().describe(
1110
+ version: import_zod19.z.string(),
1111
+ timestamp: import_zod19.z.string().datetime(),
1112
+ db: import_zod19.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
1113
+ pendingWebhooks: import_zod19.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
1114
+ oldestPendingChargeAgeSeconds: import_zod19.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
1115
+ lastMoralisEventAgeSeconds: import_zod19.z.number().nullable().describe(
1063
1116
  "Seconds since the last on-chain payment notification was received \u2014 a cheap signal for whether payment detection is currently working. `null` if none have ever been received."
1064
1117
  )
1065
1118
  });
1066
1119
 
1067
1120
  // src/sandbox.ts
1068
- var import_zod19 = require("zod");
1069
- var SandboxTriggerSchema = import_zod19.z.object({
1121
+ var import_zod20 = require("zod");
1122
+ var SandboxTriggerSchema = import_zod20.z.object({
1070
1123
  event: TriggerableChargeEventSchema,
1071
- amount: import_zod19.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
1124
+ amount: import_zod20.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
1072
1125
  "Used with `charge.partially_paid` (amount to simulate as received so far \u2014 must be less than the charge amount, defaults to half of it if omitted) and with `charge.overpaid` (amount received \u2014 must be greater than the charge amount, defaults to 1.5x it if omitted). Ignored for every other event."
1073
1126
  )
1074
1127
  });
1075
1128
 
1076
1129
  // src/capabilities.ts
1077
- var import_zod20 = require("zod");
1078
- var CapabilitiesSchema = import_zod20.z.object({
1079
- acceptedPayments: import_zod20.z.array(AcceptedPaymentSchema).describe(
1130
+ var import_zod21 = require("zod");
1131
+ var CapabilitiesSchema = import_zod21.z.object({
1132
+ acceptedPayments: import_zod21.z.array(AcceptedPaymentSchema).describe(
1080
1133
  "Every `(token, network)` pair actually configured for your environment right now \u2014 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."
1081
1134
  )
1082
1135
  });
1083
1136
 
1084
1137
  // src/swap.ts
1085
- var import_zod21 = require("zod");
1086
- var CreateSwapQuoteSchema = import_zod21.z.object({
1138
+ var import_zod22 = require("zod");
1139
+ var CreateSwapQuoteSchema = import_zod22.z.object({
1087
1140
  inputToken: AltTokenSchema.describe(
1088
1141
  "Which alt-cryptocurrency the payer wants to send \u2014 must be one of this charge's `swapAlternatives`, or `422 token_not_supported`."
1089
1142
  ),
1090
1143
  inputNetwork: NetworkSchema.describe(
1091
1144
  "Which network the payer will send `inputToken` on. Also picks which of this charge's `acceptedPayments` pairs the swap resolves to \u2014 a charge accepting USDC on both Base and Optimism resolves to whichever `inputNetwork` you pass. If the charge accepts more than one token on that same network, Klappay breaks the tie using its own trust ranking for that network (e.g. USDT over USDC on BNB Chain, where \"USDC\" is a third-party Binance-Peg token, not Circle's) \u2014 never a token the charge doesn't actually accept."
1092
1145
  ),
1093
- takerAddress: import_zod21.z.string().regex(/^0x[0-9a-fA-F]{40}$/, "must be a 20-byte hex address").describe(
1146
+ takerAddress: import_zod22.z.string().regex(/^0x[0-9a-fA-F]{40}$/, "must be a 20-byte hex address").describe(
1094
1147
  "The payer's own wallet address \u2014 the account that will sign and submit the swap transaction. Not validated against anything else; any well-formed address is accepted, since Klappay never custodies these funds."
1095
1148
  )
1096
1149
  });
1097
- var SwapQuoteSchema = import_zod21.z.object({
1150
+ var SwapQuoteSchema = import_zod22.z.object({
1098
1151
  inputToken: AltTokenSchema,
1099
1152
  inputNetwork: NetworkSchema,
1100
- inputAmount: import_zod21.z.number().describe(
1153
+ inputAmount: import_zod22.z.number().describe(
1101
1154
  "The ceiling of `inputToken` the payer needs available to sign for, in whole units (not wei/base units) \u2014 not necessarily the exact final cost. Any `inputToken` beyond what the swap actually needs (price moved favorably, less slippage than budgeted) is swapped back and refunded to the payer automatically, in the same transaction \u2014 never a separate step or a Klappay-side refund."
1102
1155
  ),
1103
1156
  outputToken: TokenSchema.describe(
1104
1157
  "Which of this charge's `acceptedPayments` tokens the swap resolves to."
1105
1158
  ),
1106
1159
  outputNetwork: NetworkSchema,
1107
- outputAmount: import_zod21.z.number().describe(
1160
+ outputAmount: import_zod22.z.number().describe(
1108
1161
  "The exact remaining amount owed on this charge (`amount - amountReceived`), in `currency` units \u2014 always what the merchant's split address receives, regardless of `inputAmount`."
1109
1162
  ),
1110
- fees: import_zod21.z.object({
1111
- klappayFee: import_zod21.z.number().describe(
1163
+ fees: import_zod22.z.object({
1164
+ klappayFee: import_zod22.z.number().describe(
1112
1165
  "Klappay's own swap fee (1% today), in `outputToken` units \u2014 paid by the payer, on top of `inputAmount`, separate from the merchant's own `feePercent`. Never subtracted from `outputAmount`."
1113
1166
  ),
1114
- zeroExFee: import_zod21.z.number().nullable().describe(
1167
+ zeroExFee: import_zod22.z.number().nullable().describe(
1115
1168
  "0x's own protocol fee for this specific token pair, in `outputToken` units, or `null` when this pair isn't currently one 0x charges on. Also paid by the payer on top of `inputAmount`, also never subtracted from `outputAmount` \u2014 Klappay never sees this fee, it goes straight to 0x."
1116
1169
  )
1117
1170
  }).describe(
1118
1171
  "Every fee the payer is charged for using swap-to-pay, broken out by who collects it \u2014 both already reflected in `inputAmount`, shown here separately for transparency. Neither ever reduces `outputAmount`."
1119
1172
  ),
1120
- expiresAt: import_zod21.z.string().datetime().describe(
1173
+ expiresAt: import_zod22.z.string().datetime().describe(
1121
1174
  "When this quote's price is no longer safely valid \u2014 a rough guide for the payer's UI countdown only. The actual price guarantee is enforced on-chain by the swap transaction itself (a signed Permit2 deadline, or a minimum-output check for a native-currency sell), not by this timestamp \u2014 submitting after it expires either reverts on-chain or simply gets re-quoted at the current price, never silently executes at a stale rate."
1122
1175
  ),
1123
- transaction: import_zod21.z.object({
1124
- to: import_zod21.z.string().describe("Contract address the payer's wallet must send this transaction to."),
1125
- data: import_zod21.z.string().describe("Calldata \u2014 opaque, must be sent unmodified."),
1126
- value: import_zod21.z.string().describe(
1176
+ transaction: import_zod22.z.object({
1177
+ to: import_zod22.z.string().describe("Contract address the payer's wallet must send this transaction to."),
1178
+ data: import_zod22.z.string().describe("Calldata \u2014 opaque, must be sent unmodified."),
1179
+ value: import_zod22.z.string().describe(
1127
1180
  "Native currency (ETH/BNB/MATIC/AVAX) to attach, in wei \u2014 `\"0\"` when `inputToken` isn't this network's native currency."
1128
1181
  )
1129
1182
  }).describe(
1130
1183
  "Pass this directly to the payer's wallet (e.g. viem/ethers `sendTransaction`) \u2014 Klappay never touches the payer's private key or submits anything on their behalf. If `permit2` is present on this response, sign that first and append the signature to this `data` before sending; if `permit2` is absent, send `transaction` as-is with no extra step."
1131
1184
  ),
1132
- permit2: import_zod21.z.object({ eip712: import_zod21.z.record(import_zod21.z.unknown()) }).nullish().describe(
1185
+ permit2: import_zod22.z.object({ eip712: import_zod22.z.record(import_zod22.z.unknown()) }).nullish().describe(
1133
1186
  "Present only when `inputToken` is an ERC-20 (today, only `BTC`) \u2014 the payer's wallet must sign this EIP-712 message and append the signature to `transaction.data` before sending, since an ERC-20 sell needs a Permit2 allowance signature that a native-currency sell doesn't. `null` (never omitted, in a genuine 0x-backed quote) when `inputToken` is a network's own native currency (ETH/BNB/MATIC/AVAX) \u2014 `transaction` is then ready to sign and send directly, no extra step."
1134
1187
  )
1135
1188
  });
@@ -1150,6 +1203,7 @@ var SwapQuoteSchema = import_zod21.z.object({
1150
1203
  CHECKOUT_PRODUCTS_MAX,
1151
1204
  CONFLICTING_SCOPE_PAIRS,
1152
1205
  CapabilitiesSchema,
1206
+ ChargeFeePayerSchema,
1153
1207
  ChargeSchema,
1154
1208
  ChargeStatusSchema,
1155
1209
  ChargeWebhookEventTypeSchema,
@@ -1159,6 +1213,7 @@ var SwapQuoteSchema = import_zod21.z.object({
1159
1213
  CheckChargeRequestSchema,
1160
1214
  CheckChargeResponseSchema,
1161
1215
  CheckoutProductSchema,
1216
+ ConfirmationProgressSchema,
1162
1217
  CreateChargeSchema,
1163
1218
  CreateRecipientSchema,
1164
1219
  CreateSwapQuoteSchema,
@@ -1206,6 +1261,7 @@ var SwapQuoteSchema = import_zod21.z.object({
1206
1261
  PendingDistributionRecipientSchema,
1207
1262
  PendingDistributionSchema,
1208
1263
  RecipientSchema,
1264
+ RefundEscrowRequestSchema,
1209
1265
  ReleaseEscrowRequestSchema,
1210
1266
  SandboxTriggerSchema,
1211
1267
  SetRecipientPayoutSchema,