@klappay/types 1.0.4 → 1.0.5

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,9 +35,15 @@ __export(index_exports, {
35
35
  ChargeStatusEventSchema: () => ChargeStatusEventSchema,
36
36
  ChargeStatusSchema: () => ChargeStatusSchema,
37
37
  ChargeWebhookEventTypeSchema: () => ChargeWebhookEventTypeSchema,
38
+ ChargesDateFieldSchema: () => ChargesDateFieldSchema,
39
+ ChargesMetricFieldSchema: () => ChargesMetricFieldSchema,
40
+ ChargesQueryFieldSchema: () => ChargesQueryFieldSchema,
38
41
  CreateApiKeySchema: () => CreateApiKeySchema,
39
42
  CreateChargeSchema: () => CreateChargeSchema,
40
43
  CreateWebhookSchema: () => CreateWebhookSchema,
44
+ DistributionsDateFieldSchema: () => DistributionsDateFieldSchema,
45
+ DistributionsMetricFieldSchema: () => DistributionsMetricFieldSchema,
46
+ DistributionsQueryFieldSchema: () => DistributionsQueryFieldSchema,
41
47
  EVENT_CATEGORY_MAP: () => EVENT_CATEGORY_MAP,
42
48
  EVM_NETWORKS: () => EVM_NETWORKS,
43
49
  EnvironmentSchema: () => EnvironmentSchema,
@@ -52,7 +58,21 @@ __export(index_exports, {
52
58
  ListUsersSchema: () => ListUsersSchema,
53
59
  ListWebhookDeliveriesSchema: () => ListWebhookDeliveriesSchema,
54
60
  LoginSchema: () => LoginSchema,
61
+ MAX_METRICS_QUERY_DATE_RANGE_DAYS: () => MAX_METRICS_QUERY_DATE_RANGE_DAYS,
62
+ METRICS_QUERY_DEFAULT_ROW_LIMIT: () => METRICS_QUERY_DEFAULT_ROW_LIMIT,
63
+ METRICS_QUERY_MAX_FILTERS: () => METRICS_QUERY_MAX_FILTERS,
64
+ METRICS_QUERY_MAX_GROUP_BY: () => METRICS_QUERY_MAX_GROUP_BY,
65
+ METRICS_QUERY_MAX_METRICS: () => METRICS_QUERY_MAX_METRICS,
66
+ METRICS_QUERY_MAX_ROW_LIMIT: () => METRICS_QUERY_MAX_ROW_LIMIT,
55
67
  MessageResponseSchema: () => MessageResponseSchema,
68
+ MetricsAggregationSchema: () => MetricsAggregationSchema,
69
+ MetricsDateGranularitySchema: () => MetricsDateGranularitySchema,
70
+ MetricsFilterOperatorSchema: () => MetricsFilterOperatorSchema,
71
+ MetricsQueryResultRowSchema: () => MetricsQueryResultRowSchema,
72
+ MetricsQueryResultSchema: () => MetricsQueryResultSchema,
73
+ MetricsQuerySchema: () => MetricsQuerySchema,
74
+ MetricsQueryScopeSchema: () => MetricsQueryScopeSchema,
75
+ MetricsResourceSchema: () => MetricsResourceSchema,
56
76
  NETWORK_EXPLORERS: () => NETWORK_EXPLORERS,
57
77
  NETWORK_LABELS: () => NETWORK_LABELS,
58
78
  NetworkSchema: () => NetworkSchema,
@@ -79,6 +99,7 @@ __export(index_exports, {
79
99
  SecurityWebhookEventTypeSchema: () => SecurityWebhookEventTypeSchema,
80
100
  SettlementStatusSchema: () => SettlementStatusSchema,
81
101
  SignupSchema: () => SignupSchema,
102
+ SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
82
103
  SplitRecipientRoleSchema: () => SplitRecipientRoleSchema,
83
104
  TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
84
105
  TOKEN_DECIMALS: () => TOKEN_DECIMALS,
@@ -86,6 +107,9 @@ __export(index_exports, {
86
107
  TimelineEventTypeSchema: () => TimelineEventTypeSchema,
87
108
  TokenSchema: () => TokenSchema,
88
109
  TransactionSourceSchema: () => TransactionSourceSchema,
110
+ TransactionsDateFieldSchema: () => TransactionsDateFieldSchema,
111
+ TransactionsMetricFieldSchema: () => TransactionsMetricFieldSchema,
112
+ TransactionsQueryFieldSchema: () => TransactionsQueryFieldSchema,
89
113
  TriggerableChargeEventSchema: () => TriggerableChargeEventSchema,
90
114
  UpdateOrganizationSchema: () => UpdateOrganizationSchema,
91
115
  UpdateUserRoleSchema: () => UpdateUserRoleSchema,
@@ -193,7 +217,7 @@ function paginatedSchema(itemSchema) {
193
217
  // src/tokens.ts
194
218
  var import_zod5 = require("zod");
195
219
  var TokenSchema = import_zod5.z.enum(["USDC", "USDT"]).describe(
196
- `Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 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 \u2014 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** \u2014 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 \u2014 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 \u2014 check \`TOKEN_ADDRESSES\` in \`@klappay/types\` (or a future \`GET /v1/networks\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`
220
+ `Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 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 \u2014 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** \u2014 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 \u2014 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 \u2014 check \`TOKEN_ADDRESSES\` in \`@klappay/types\` (or a future \`GET /v1/networks\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`
197
221
  );
198
222
  var TOKEN_DECIMALS = 6;
199
223
  var TOKEN_ADDRESSES = {
@@ -282,7 +306,7 @@ var CreateChargeSchema = import_zod6.z.object({
282
306
  "Scoped to your organization. Replaying the same key returns the original charge unchanged instead of creating a duplicate \u2014 safe to retry a request after a timeout without double-charging."
283
307
  ),
284
308
  externalRef: import_zod6.z.string().min(1).max(255).optional().describe(
285
- "An opaque correlation id from your own system (e.g. an order id) \u2014 echoed back on the charge and in every webhook payload. Not interpreted or validated by Klap."
309
+ "An opaque correlation id from your own system (e.g. an order id) \u2014 echoed back on the charge and in every webhook payload. Not interpreted or validated by Klappay."
286
310
  ),
287
311
  source: import_zod6.z.string().min(1).max(64).optional().describe(
288
312
  'Free-form label for what created this charge (e.g. `"checkout"`, `"invoice"`) \u2014 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.'
@@ -298,7 +322,7 @@ var CreateChargeSchema = import_zod6.z.object({
298
322
  }
299
323
  });
300
324
  var ChargeSchema = import_zod6.z.object({
301
- id: import_zod6.z.string().describe("Klap-generated id, e.g. `ch_...`. Use this to look up the charge later."),
325
+ id: import_zod6.z.string().describe("Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later."),
302
326
  mode: ChargeModeSchema,
303
327
  amount: import_zod6.z.number().nullable().describe(
304
328
  "The amount originally requested, in `currency` units (up to 6 decimal places). `null` if `amount` was omitted at creation \u2014 this charge accepts any amount, and the first credited transfer confirms it."
@@ -307,7 +331,7 @@ var ChargeSchema = import_zod6.z.object({
307
331
  "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` \u2014 unless `amount` itself is `null`, in which case `isOverpaid` never applies."
308
332
  ),
309
333
  isOverpaid: import_zod6.z.boolean().describe(
310
- "`true` if `amountReceived` ended up greater than `amount`. Klap never refunds the difference automatically \u2014 see the docs for why."
334
+ "`true` if `amountReceived` ended up greater than `amount`. Klappay never refunds the difference automatically \u2014 see the docs for why."
311
335
  ),
312
336
  currency: import_zod6.z.string().describe("Always `USD` today \u2014 the only supported currency."),
313
337
  acceptedPayments: import_zod6.z.array(AcceptedPaymentSchema).describe(
@@ -317,7 +341,7 @@ var ChargeSchema = import_zod6.z.object({
317
341
  "Every distinct `(token, network)` pair that has actually contributed a credited transfer so far \u2014 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`."
318
342
  ),
319
343
  address: import_zod6.z.string().describe(
320
- "The on-chain address the payer must send funds to \u2014 identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time \u2014 funds sent here go directly to the merchant, Klap never custodies them."
344
+ "The on-chain address the payer must send funds to \u2014 identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time \u2014 funds sent here go directly to the merchant, Klappay never custodies them."
321
345
  ),
322
346
  status: ChargeStatusSchema,
323
347
  settlementStatus: SettlementStatusSchema.nullable(),
@@ -343,7 +367,7 @@ var ChargeSchema = import_zod6.z.object({
343
367
  "When a transfer was last credited toward this charge, or `createdAt` if none has arrived yet. Only meaningful for a charge with no `expiresAt` \u2014 see `pausedAt`."
344
368
  ),
345
369
  pausedAt: import_zod6.z.string().datetime().nullable().describe(
346
- "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 \u2014 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."
370
+ "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 \u2014 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."
347
371
  )
348
372
  });
349
373
  var ListChargesSchema = import_zod6.z.object({
@@ -372,6 +396,9 @@ var ChargeStatusEventSchema = import_zod6.z.object({
372
396
 
373
397
  // src/distributions.ts
374
398
  var import_zod7 = require("zod");
399
+ var SplitDistributionStatusSchema = import_zod7.z.enum(["pending", "processing", "completed", "failed"]).describe(
400
+ "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."
401
+ );
375
402
  var PendingDistributionRecipientSchema = import_zod7.z.object({
376
403
  address: import_zod7.z.string().describe("On-chain recipient address."),
377
404
  percentAllocation: import_zod7.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
@@ -387,11 +414,11 @@ var PendingDistributionSchema = import_zod7.z.object({
387
414
  "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."
388
415
  ),
389
416
  estimatedRewardAmount: import_zod7.z.number().describe(
390
- "Estimate only, in the charge's `currency` units, based on the amount Klap 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."
417
+ "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."
391
418
  ),
392
419
  availableSince: import_zod7.z.string().datetime().describe("When this distribution entered its grace period."),
393
420
  graceEndsAt: import_zod7.z.string().datetime().describe(
394
- "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."
421
+ "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."
395
422
  )
396
423
  });
397
424
  var PendingDistributionEventSchema = import_zod7.z.discriminatedUnion("type", [
@@ -405,9 +432,252 @@ var PendingDistributionEventSchema = import_zod7.z.discriminatedUnion("type", [
405
432
  })
406
433
  ]);
407
434
 
408
- // src/webhook-events.ts
435
+ // src/metrics.ts
409
436
  var import_zod8 = require("zod");
410
- var ChargeWebhookEventTypeSchema = import_zod8.z.enum([
437
+ var MetricsResourceSchema = import_zod8.z.enum(["charges", "transactions", "distributions"]).describe(
438
+ "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."
439
+ );
440
+ var MetricsAggregationSchema = import_zod8.z.enum(["count", "sum", "avg", "min", "max"]).describe(
441
+ "`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."
442
+ );
443
+ var MetricsFilterOperatorSchema = import_zod8.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
444
+ "`in` expects an array value (max 50 entries); every other operator expects a single scalar."
445
+ );
446
+ var MetricsDateGranularitySchema = import_zod8.z.enum(["day", "week", "month"]).describe(
447
+ "Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
448
+ );
449
+ var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
450
+ "Which environment's data to query \u2014 `live` or `test`. Independent of your session (a dashboard user isn't scoped to one environment the way an API key is) \u2014 scopes the query to charges/transactions/distributions created under a `live` or `test` API key respectively."
451
+ );
452
+ var MAX_METRICS_QUERY_DATE_RANGE_DAYS = 366;
453
+ var METRICS_QUERY_MAX_ROW_LIMIT = 1e3;
454
+ var METRICS_QUERY_DEFAULT_ROW_LIMIT = 100;
455
+ var METRICS_QUERY_MAX_GROUP_BY = 3;
456
+ var METRICS_QUERY_MAX_FILTERS = 20;
457
+ var METRICS_QUERY_MAX_METRICS = 10;
458
+ var METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
459
+ var metricAliasSchema = import_zod8.z.string().min(1).max(64).regex(
460
+ METRIC_ALIAS_PATTERN,
461
+ "Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 this becomes a SQL column alias."
462
+ ).optional();
463
+ var MetricsFilterValueSchema = import_zod8.z.union([
464
+ import_zod8.z.string().max(255),
465
+ import_zod8.z.number(),
466
+ import_zod8.z.boolean(),
467
+ import_zod8.z.array(import_zod8.z.union([import_zod8.z.string().max(255), import_zod8.z.number()])).min(1).max(50)
468
+ ]);
469
+ var orderBySchema = import_zod8.z.object({
470
+ key: import_zod8.z.string().min(1).max(64).describe(
471
+ "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`)."
472
+ ),
473
+ direction: import_zod8.z.enum(["asc", "desc"])
474
+ }).describe(
475
+ "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."
476
+ );
477
+ var limitSchema = import_zod8.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
478
+ `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.`
479
+ );
480
+ var ChargesQueryFieldSchema = import_zod8.z.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
481
+ "A `Charge` field to filter or group by \u2014 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."
482
+ );
483
+ var ChargesMetricFieldSchema = import_zod8.z.enum(["amount", "amountReceived", "feePercent"]).describe(
484
+ "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%."
485
+ );
486
+ var ChargesDateFieldSchema = import_zod8.z.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
487
+ "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."
488
+ );
489
+ var ChargesFilterSchema = import_zod8.z.object({
490
+ field: ChargesQueryFieldSchema,
491
+ operator: MetricsFilterOperatorSchema,
492
+ value: MetricsFilterValueSchema
493
+ });
494
+ var ChargesGroupBySchema = import_zod8.z.union([
495
+ import_zod8.z.object({ type: import_zod8.z.literal("field"), field: ChargesQueryFieldSchema }),
496
+ import_zod8.z.object({
497
+ type: import_zod8.z.literal("date_bucket"),
498
+ field: ChargesDateFieldSchema,
499
+ granularity: MetricsDateGranularitySchema
500
+ })
501
+ ]);
502
+ var ChargesMetricSchema = import_zod8.z.object({
503
+ aggregation: MetricsAggregationSchema,
504
+ field: ChargesMetricFieldSchema.optional(),
505
+ alias: metricAliasSchema
506
+ });
507
+ var ChargesMetricsQuerySchema = import_zod8.z.object({
508
+ resource: import_zod8.z.literal("charges"),
509
+ environment: metricsQueryEnvironmentSchema,
510
+ dateRange: import_zod8.z.object({
511
+ field: ChargesDateFieldSchema,
512
+ from: import_zod8.z.string().max(64).datetime(),
513
+ to: import_zod8.z.string().max(64).datetime()
514
+ }),
515
+ groupBy: import_zod8.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
516
+ metrics: import_zod8.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
517
+ filters: import_zod8.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
518
+ orderBy: orderBySchema.optional(),
519
+ limit: limitSchema
520
+ });
521
+ var TransactionsQueryFieldSchema = import_zod8.z.enum(["network", "token", "source", "causedTransition"]).describe(
522
+ "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)."
523
+ );
524
+ var TransactionsMetricFieldSchema = import_zod8.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
525
+ var TransactionsDateFieldSchema = import_zod8.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
526
+ var TransactionsFilterSchema = import_zod8.z.object({
527
+ field: TransactionsQueryFieldSchema,
528
+ operator: MetricsFilterOperatorSchema,
529
+ value: MetricsFilterValueSchema
530
+ });
531
+ var TransactionsGroupBySchema = import_zod8.z.union([
532
+ import_zod8.z.object({ type: import_zod8.z.literal("field"), field: TransactionsQueryFieldSchema }),
533
+ import_zod8.z.object({
534
+ type: import_zod8.z.literal("date_bucket"),
535
+ field: TransactionsDateFieldSchema,
536
+ granularity: MetricsDateGranularitySchema
537
+ })
538
+ ]);
539
+ var TransactionsMetricSchema = import_zod8.z.object({
540
+ aggregation: MetricsAggregationSchema,
541
+ field: TransactionsMetricFieldSchema.optional(),
542
+ alias: metricAliasSchema
543
+ });
544
+ var TransactionsMetricsQuerySchema = import_zod8.z.object({
545
+ resource: import_zod8.z.literal("transactions"),
546
+ environment: metricsQueryEnvironmentSchema,
547
+ dateRange: import_zod8.z.object({
548
+ field: TransactionsDateFieldSchema,
549
+ from: import_zod8.z.string().max(64).datetime(),
550
+ to: import_zod8.z.string().max(64).datetime()
551
+ }),
552
+ groupBy: import_zod8.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
553
+ metrics: import_zod8.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
554
+ filters: import_zod8.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
555
+ orderBy: orderBySchema.optional(),
556
+ limit: limitSchema
557
+ });
558
+ var DistributionsQueryFieldSchema = import_zod8.z.enum(["status", "network", "token"]).describe(
559
+ "A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values."
560
+ );
561
+ var DistributionsMetricFieldSchema = import_zod8.z.enum(["attempts"]).describe(
562
+ "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."
563
+ );
564
+ var DistributionsDateFieldSchema = import_zod8.z.enum(["createdAt", "completedAt"]).describe(
565
+ "`createdAt`: when this settlement was queued. `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."
566
+ );
567
+ var DistributionsFilterSchema = import_zod8.z.object({
568
+ field: DistributionsQueryFieldSchema,
569
+ operator: MetricsFilterOperatorSchema,
570
+ value: MetricsFilterValueSchema
571
+ });
572
+ var DistributionsGroupBySchema = import_zod8.z.union([
573
+ import_zod8.z.object({ type: import_zod8.z.literal("field"), field: DistributionsQueryFieldSchema }),
574
+ import_zod8.z.object({
575
+ type: import_zod8.z.literal("date_bucket"),
576
+ field: DistributionsDateFieldSchema,
577
+ granularity: MetricsDateGranularitySchema
578
+ })
579
+ ]);
580
+ var DistributionsMetricSchema = import_zod8.z.object({
581
+ aggregation: MetricsAggregationSchema,
582
+ field: DistributionsMetricFieldSchema.optional(),
583
+ alias: metricAliasSchema
584
+ });
585
+ var DistributionsMetricsQuerySchema = import_zod8.z.object({
586
+ resource: import_zod8.z.literal("distributions"),
587
+ environment: metricsQueryEnvironmentSchema,
588
+ dateRange: import_zod8.z.object({
589
+ field: DistributionsDateFieldSchema,
590
+ from: import_zod8.z.string().max(64).datetime(),
591
+ to: import_zod8.z.string().max(64).datetime()
592
+ }),
593
+ groupBy: import_zod8.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
594
+ metrics: import_zod8.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
595
+ filters: import_zod8.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
596
+ orderBy: orderBySchema.optional(),
597
+ limit: limitSchema
598
+ });
599
+ var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
600
+ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
601
+ ChargesMetricsQuerySchema,
602
+ TransactionsMetricsQuerySchema,
603
+ DistributionsMetricsQuerySchema
604
+ ]).superRefine((input, ctx) => {
605
+ const from = new Date(input.dateRange.from);
606
+ const to = new Date(input.dateRange.to);
607
+ if (from >= to) {
608
+ ctx.addIssue({
609
+ code: import_zod8.z.ZodIssueCode.custom,
610
+ message: "`dateRange.from` must be before `dateRange.to`.",
611
+ path: ["dateRange", "from"]
612
+ });
613
+ }
614
+ const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS;
615
+ if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {
616
+ ctx.addIssue({
617
+ code: import_zod8.z.ZodIssueCode.custom,
618
+ message: `\`dateRange\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,
619
+ path: ["dateRange", "to"]
620
+ });
621
+ }
622
+ const dateBucketCount = input.groupBy.filter((entry) => entry.type === "date_bucket").length;
623
+ if (dateBucketCount > 1) {
624
+ ctx.addIssue({
625
+ code: import_zod8.z.ZodIssueCode.custom,
626
+ message: "At most one `date_bucket` entry is allowed in `groupBy`.",
627
+ path: ["groupBy"]
628
+ });
629
+ }
630
+ input.metrics.forEach((metric, index) => {
631
+ if (metric.aggregation !== "count" && metric.field === void 0) {
632
+ ctx.addIssue({
633
+ code: import_zod8.z.ZodIssueCode.custom,
634
+ message: "`field` is required unless `aggregation` is `count`.",
635
+ path: ["metrics", index, "field"]
636
+ });
637
+ }
638
+ });
639
+ const aliases = input.metrics.map((metric) => metric.alias).filter((alias) => alias !== void 0);
640
+ if (new Set(aliases).size !== aliases.length) {
641
+ ctx.addIssue({
642
+ code: import_zod8.z.ZodIssueCode.custom,
643
+ message: "Every `metrics[].alias` must be unique.",
644
+ path: ["metrics"]
645
+ });
646
+ }
647
+ const reservedNames = /* @__PURE__ */ new Set(["bucket", ...input.groupBy.map((entry) => entry.field)]);
648
+ input.metrics.forEach((metric, index) => {
649
+ if (metric.alias !== void 0 && reservedNames.has(metric.alias)) {
650
+ ctx.addIssue({
651
+ code: import_zod8.z.ZodIssueCode.custom,
652
+ message: `\`alias\` "${metric.alias}" collides with a \`groupBy\` field name (or the reserved word "bucket") \u2014 choose a different alias.`,
653
+ path: ["metrics", index, "alias"]
654
+ });
655
+ }
656
+ });
657
+ });
658
+ var MetricsQueryResultRowSchema = import_zod8.z.record(
659
+ import_zod8.z.string(),
660
+ import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number(), import_zod8.z.boolean(), import_zod8.z.null()])
661
+ );
662
+ var MetricsQueryScopeSchema = import_zod8.z.enum(["owner_admin", "member"]).describe(
663
+ "`member`: results were automatically restricted to data tied to API keys you personally created \u2014 rows with no resolvable creator were excluded, not counted, and not surfaced any other way. `owner_admin`: the full organization\u2019s data was queried, no restriction applied."
664
+ );
665
+ var MetricsQueryResultSchema = import_zod8.z.object({
666
+ data: import_zod8.z.array(MetricsQueryResultRowSchema),
667
+ meta: import_zod8.z.object({
668
+ resource: MetricsResourceSchema,
669
+ environment: EnvironmentSchema,
670
+ scope: MetricsQueryScopeSchema,
671
+ rowCount: import_zod8.z.number().int().describe("Number of rows in `data`."),
672
+ truncated: import_zod8.z.boolean().describe(
673
+ "`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
674
+ )
675
+ })
676
+ });
677
+
678
+ // src/webhook-events.ts
679
+ var import_zod9 = require("zod");
680
+ var ChargeWebhookEventTypeSchema = import_zod9.z.enum([
411
681
  "charge.created",
412
682
  "charge.partially_paid",
413
683
  "charge.confirmed",
@@ -421,9 +691,9 @@ var ChargeWebhookEventTypeSchema = import_zod8.z.enum([
421
691
  "charge.contribution_received",
422
692
  "charge.contribution_settled"
423
693
  ]).describe(
424
- '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`). 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) \u2014 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 \u2014 pausing trades that away deliberately, see `docs/payments.md`). `charge.contribution_received`/`charge.contribution_settled` are exclusive to `mode: continuous` charges (see `Charge.mode`) \u2014 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 }`.'
694
+ '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`). 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) \u2014 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 \u2014 pausing trades that away deliberately, see `docs/payments.md`). `charge.contribution_received`/`charge.contribution_settled` are exclusive to `mode: continuous` charges (see `Charge.mode`) \u2014 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 }`.'
425
695
  );
426
- var AccountWebhookEventTypeSchema = import_zod8.z.enum([
696
+ var AccountWebhookEventTypeSchema = import_zod9.z.enum([
427
697
  "payout_address.changed",
428
698
  "api_key.created",
429
699
  "api_key.revoked",
@@ -437,10 +707,10 @@ var AccountWebhookEventTypeSchema = import_zod8.z.enum([
437
707
  ]).describe(
438
708
  "Account and configuration changes \u2014 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 }`."
439
709
  );
440
- var WebhookDeliveryEventTypeSchema = import_zod8.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
710
+ var WebhookDeliveryEventTypeSchema = import_zod9.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
441
711
  "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`)."
442
712
  );
443
- var SecurityWebhookEventTypeSchema = import_zod8.z.enum([
713
+ var SecurityWebhookEventTypeSchema = import_zod9.z.enum([
444
714
  "auth.login",
445
715
  "auth.login_failed",
446
716
  "auth.suspicious_activity",
@@ -450,13 +720,13 @@ var SecurityWebhookEventTypeSchema = import_zod8.z.enum([
450
720
  ]).describe(
451
721
  "Account security signals. `auth.suspicious_activity` is a soft heuristic (login from an IP not seen on this account before), not a block \u2014 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) \u2014 `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 }`."
452
722
  );
453
- var WebhookEventTypeSchema = import_zod8.z.union([
723
+ var WebhookEventTypeSchema = import_zod9.z.union([
454
724
  ChargeWebhookEventTypeSchema,
455
725
  AccountWebhookEventTypeSchema,
456
726
  WebhookDeliveryEventTypeSchema,
457
727
  SecurityWebhookEventTypeSchema
458
728
  ]);
459
- var WebhookCategorySchema = import_zod8.z.enum(["payments", "account", "webhooks", "security"]).describe(
729
+ var WebhookCategorySchema = import_zod9.z.enum(["payments", "account", "webhooks", "security"]).describe(
460
730
  "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."
461
731
  );
462
732
  function buildCategoryMap() {
@@ -483,99 +753,101 @@ var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
483
753
  ]).describe(
484
754
  "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), `charge.paused`/`charge.reactivated` (driven by a background worker on real inactivity, not a payment state \u2014 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 \u2014 see `POST /v1/charges/{id}/trigger`'s own description)."
485
755
  );
486
- var NonChargeTriggerableEventSchema = import_zod8.z.union([
756
+ var NonChargeTriggerableEventSchema = import_zod9.z.union([
487
757
  AccountWebhookEventTypeSchema,
488
758
  WebhookDeliveryEventTypeSchema,
489
759
  SecurityWebhookEventTypeSchema
490
760
  ]);
491
761
 
492
762
  // src/webhooks.ts
493
- var import_zod9 = require("zod");
763
+ var import_zod10 = require("zod");
494
764
  var WEBHOOK_EVENTS_WILDCARD = "*";
495
- var CreateWebhookSchema = import_zod9.z.object({
496
- url: import_zod9.z.string().max(2048).url().describe(
765
+ var CreateWebhookSchema = import_zod10.z.object({
766
+ url: import_zod10.z.string().max(2048).url().describe(
497
767
  "Must be HTTPS and resolve to a public address \u2014 private/internal IPs are rejected."
498
768
  ),
499
- events: import_zod9.z.array(import_zod9.z.union([WebhookEventTypeSchema, import_zod9.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
769
+ events: import_zod10.z.array(import_zod10.z.union([WebhookEventTypeSchema, import_zod10.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
500
770
  '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.'
501
771
  ),
502
- eventCategories: import_zod9.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
772
+ eventCategories: import_zod10.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
503
773
  "Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required."
504
774
  ),
505
- excludeEvents: import_zod9.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
775
+ excludeEvents: import_zod10.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
506
776
  'Event types to exclude even if selected via `events: ["*"]` or `eventCategories`.'
507
777
  )
508
778
  }).refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {
509
779
  message: "must select at least one event via `events` or `eventCategories`",
510
780
  path: ["events"]
511
781
  });
512
- var WebhookSchema = import_zod9.z.object({
513
- id: import_zod9.z.string(),
514
- url: import_zod9.z.string(),
515
- events: import_zod9.z.array(WebhookEventTypeSchema),
516
- eventCategories: import_zod9.z.array(WebhookCategorySchema),
517
- excludeEvents: import_zod9.z.array(WebhookEventTypeSchema),
518
- isWildcard: import_zod9.z.boolean(),
519
- secret: import_zod9.z.string().describe(
520
- "The signing secret, used to verify the `X-Klap-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 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 \u2014 see github.com/klappay for available SDKs."
782
+ var WebhookSchema = import_zod10.z.object({
783
+ id: import_zod10.z.string(),
784
+ url: import_zod10.z.string(),
785
+ events: import_zod10.z.array(WebhookEventTypeSchema),
786
+ eventCategories: import_zod10.z.array(WebhookCategorySchema),
787
+ excludeEvents: import_zod10.z.array(WebhookEventTypeSchema),
788
+ isWildcard: import_zod10.z.boolean(),
789
+ secret: import_zod10.z.string().describe(
790
+ "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."
521
791
  ),
522
- createdAt: import_zod9.z.string().datetime()
792
+ createdAt: import_zod10.z.string().datetime()
523
793
  });
524
794
  var WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({
525
- hint: import_zod9.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
795
+ hint: import_zod10.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
526
796
  });
527
- var WebhookPayloadSchema = import_zod9.z.object({
528
- id: import_zod9.z.string().describe("Unique id for this specific delivery \u2014 also sent as the `X-Klap-Delivery` header."),
797
+ var WebhookPayloadSchema = import_zod10.z.object({
798
+ id: import_zod10.z.string().describe(
799
+ "Unique id for this specific delivery \u2014 also sent as the `X-Klappay-Delivery` header."
800
+ ),
529
801
  event: WebhookEventTypeSchema,
530
- createdAt: import_zod9.z.string().datetime(),
531
- data: import_zod9.z.unknown().describe(
802
+ createdAt: import_zod10.z.string().datetime(),
803
+ data: import_zod10.z.unknown().describe(
532
804
  "Event-specific data. Charge events (`charge.*`) carry the full `Charge` object; account/security/webhook-delivery events carry a smaller, event-specific object \u2014 see `WebhookEventDataMap`/`TypedWebhookPayload` for the exact shape per event, or docs/webhooks.md."
533
805
  )
534
806
  });
535
- var WebhookDeliveryStatusSchema = import_zod9.z.enum(["pending", "delivered", "failed"]);
536
- var WebhookDeliverySchema = import_zod9.z.object({
537
- id: import_zod9.z.string(),
538
- webhookId: import_zod9.z.string(),
807
+ var WebhookDeliveryStatusSchema = import_zod10.z.enum(["pending", "delivered", "failed"]);
808
+ var WebhookDeliverySchema = import_zod10.z.object({
809
+ id: import_zod10.z.string(),
810
+ webhookId: import_zod10.z.string(),
539
811
  event: WebhookEventTypeSchema,
540
812
  status: WebhookDeliveryStatusSchema.describe(
541
813
  "`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."
542
814
  ),
543
- attempts: import_zod9.z.number(),
544
- responseCode: import_zod9.z.number().nullable().describe(
815
+ attempts: import_zod10.z.number(),
816
+ responseCode: import_zod10.z.number().nullable().describe(
545
817
  "HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all."
546
818
  ),
547
- nextRetryAt: import_zod9.z.string().datetime().nullable(),
548
- deliveredAt: import_zod9.z.string().datetime().nullable(),
549
- createdAt: import_zod9.z.string().datetime()
819
+ nextRetryAt: import_zod10.z.string().datetime().nullable(),
820
+ deliveredAt: import_zod10.z.string().datetime().nullable(),
821
+ createdAt: import_zod10.z.string().datetime()
550
822
  });
551
823
  var ListWebhookDeliveriesSchema = PaginationQuerySchema;
552
824
  var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
553
825
 
554
826
  // src/api-keys.ts
555
- var import_zod10 = require("zod");
556
- var CreateApiKeySchema = import_zod10.z.object({
557
- name: import_zod10.z.string().min(1).max(64).describe(
827
+ var import_zod11 = require("zod");
828
+ var CreateApiKeySchema = import_zod11.z.object({
829
+ name: import_zod11.z.string().min(1).max(64).describe(
558
830
  'A label to help you tell keys apart (e.g. `"production backend"`). Not used for anything functional.'
559
831
  ),
560
832
  environment: EnvironmentSchema.describe(
561
833
  "`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."
562
834
  )
563
835
  });
564
- var ApiKeySchema = import_zod10.z.object({
565
- id: import_zod10.z.string(),
566
- name: import_zod10.z.string(),
836
+ var ApiKeySchema = import_zod11.z.object({
837
+ id: import_zod11.z.string(),
838
+ name: import_zod11.z.string(),
567
839
  environment: EnvironmentSchema.describe(
568
840
  "`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."
569
841
  ),
570
- key: import_zod10.z.string().optional().describe(
842
+ key: import_zod11.z.string().optional().describe(
571
843
  "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` \u2014 never returned again afterward, so store it immediately."
572
844
  ),
573
- hint: import_zod10.z.string().describe(
845
+ hint: import_zod11.z.string().describe(
574
846
  "A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't."
575
847
  ),
576
- createdAt: import_zod10.z.string().datetime(),
577
- lastUsedAt: import_zod10.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
578
- createdByUserId: import_zod10.z.string().nullable().describe(
848
+ createdAt: import_zod11.z.string().datetime(),
849
+ lastUsedAt: import_zod11.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
850
+ createdByUserId: import_zod11.z.string().nullable().describe(
579
851
  "Which member of the organization created this key. `null` for a key created before this field existed."
580
852
  )
581
853
  });
@@ -583,76 +855,78 @@ var ListApiKeysSchema = PaginationQuerySchema;
583
855
  var PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema);
584
856
 
585
857
  // src/users.ts
586
- var import_zod11 = require("zod");
587
- var UserRoleSchema = import_zod11.z.enum(["owner", "admin", "member"]).describe(
858
+ var import_zod12 = require("zod");
859
+ var UserRoleSchema = import_zod12.z.enum(["owner", "admin", "member"]).describe(
588
860
  "`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`."
589
861
  );
590
- var UpdateUserRoleSchema = import_zod11.z.object({
862
+ var UpdateUserRoleSchema = import_zod12.z.object({
591
863
  role: UserRoleSchema
592
864
  });
593
- var UserSchema = import_zod11.z.object({
594
- id: import_zod11.z.string(),
595
- email: import_zod11.z.string(),
596
- name: import_zod11.z.string().nullable(),
865
+ var UserSchema = import_zod12.z.object({
866
+ id: import_zod12.z.string(),
867
+ email: import_zod12.z.string(),
868
+ name: import_zod12.z.string().nullable(),
597
869
  role: UserRoleSchema.describe("Your role within the organization this user was fetched from."),
598
- emailVerifiedAt: import_zod11.z.string().datetime().nullable().describe(
870
+ emailVerifiedAt: import_zod12.z.string().datetime().nullable().describe(
599
871
  "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`) \u2014 everything else works regardless of verification status."
600
872
  ),
601
- createdAt: import_zod11.z.string().datetime()
873
+ createdAt: import_zod12.z.string().datetime()
602
874
  });
603
875
  var ListUsersSchema = PaginationQuerySchema;
604
876
  var PaginatedUsersSchema = paginatedSchema(UserSchema);
605
877
 
606
878
  // src/auth.ts
607
- var import_zod12 = require("zod");
608
- var NormalizedEmailSchema = import_zod12.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
879
+ var import_zod13 = require("zod");
880
+ var NormalizedEmailSchema = import_zod13.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
609
881
  "Trimmed, lowercased, and NFC-normalized server-side before use \u2014 case/whitespace don't matter."
610
882
  );
611
- var SignupSchema = import_zod12.z.object({
883
+ var SignupSchema = import_zod13.z.object({
612
884
  email: NormalizedEmailSchema,
613
- password: import_zod12.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
885
+ password: import_zod13.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
614
886
  });
615
- var LoginSchema = import_zod12.z.object({
887
+ var LoginSchema = import_zod13.z.object({
616
888
  email: NormalizedEmailSchema,
617
- password: import_zod12.z.string().min(1).max(128)
889
+ password: import_zod13.z.string().min(1).max(128)
618
890
  });
619
- var VerifyEmailSchema = import_zod12.z.object({
620
- token: import_zod12.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
891
+ var VerifyEmailSchema = import_zod13.z.object({
892
+ token: import_zod13.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
621
893
  });
622
- var ForgotPasswordSchema = import_zod12.z.object({
894
+ var ForgotPasswordSchema = import_zod13.z.object({
623
895
  email: NormalizedEmailSchema
624
896
  });
625
- var ResetPasswordSchema = import_zod12.z.object({
626
- token: import_zod12.z.string().min(1).describe("The token from the password reset email."),
627
- newPassword: import_zod12.z.string().min(8).max(128)
897
+ var ResetPasswordSchema = import_zod13.z.object({
898
+ token: import_zod13.z.string().min(1).describe("The token from the password reset email."),
899
+ newPassword: import_zod13.z.string().min(8).max(128)
628
900
  });
629
- var MessageResponseSchema = import_zod12.z.object({
630
- message: import_zod12.z.string().describe("Human-readable confirmation, safe to show a user directly.")
901
+ var MessageResponseSchema = import_zod13.z.object({
902
+ message: import_zod13.z.string().describe("Human-readable confirmation, safe to show a user directly.")
631
903
  });
632
- var AuthResponseSchema = import_zod12.z.object({
633
- token: import_zod12.z.string().describe(
904
+ var AuthResponseSchema = import_zod13.z.object({
905
+ token: import_zod13.z.string().describe(
634
906
  "Session JWT, valid 7 days \u2014 use as `Authorization: Bearer <token>` on every `/v1/organizations/*` request (which nests API keys, members, and invitations \u2014 see `GET /v1/organizations`). This token identifies only you; it carries no organization or role \u2014 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."
635
907
  ),
636
908
  user: UserSchema.omit({ createdAt: true, role: true })
637
909
  });
638
910
 
639
911
  // src/organization.ts
640
- var import_zod13 = require("zod");
641
- var UpdateOrganizationSchema = import_zod13.z.object({
642
- name: import_zod13.z.string().min(1).max(255).optional().describe("The organization's display name."),
643
- payoutAddress: import_zod13.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
912
+ var import_zod14 = require("zod");
913
+ var UpdateOrganizationSchema = import_zod14.z.object({
914
+ name: import_zod14.z.string().min(1).max(255).optional().describe("The organization's display name."),
915
+ payoutAddress: import_zod14.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
644
916
  "The wallet that receives the merchant's share of every future charge. Changing this only affects charges created after the change \u2014 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 \u2014 EIP-55 checksum casing is not required or verified."
645
917
  )
646
918
  });
647
- var OrganizationSchema = import_zod13.z.object({
648
- id: import_zod13.z.string(),
649
- name: import_zod13.z.string(),
650
- payoutAddress: import_zod13.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
651
- currentFeePercent: import_zod13.z.number().describe(
652
- "Your current platform fee percentage, based on trailing monthly volume \u2014 lower volume tiers pay a higher percentage. `1.5` means 1.5%, not a 0\u20131 fraction. Frozen onto each charge at creation, so this can change between charges without affecting ones already created."
919
+ var OrganizationSchema = import_zod14.z.object({
920
+ id: import_zod14.z.string(),
921
+ name: import_zod14.z.string(),
922
+ payoutAddress: import_zod14.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
923
+ currentFeePercent: import_zod14.z.number().describe(
924
+ "Your current platform fee percentage \u2014 `1.5` means 1.5%, not a 0\u20131 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 \u2014 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."
653
925
  ),
654
- feeUpdatedAt: import_zod13.z.string().datetime().nullable(),
655
- createdAt: import_zod13.z.string().datetime()
926
+ feeUpdatedAt: import_zod14.z.string().datetime().nullable().describe(
927
+ "When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up."
928
+ ),
929
+ createdAt: import_zod14.z.string().datetime()
656
930
  });
657
931
  var OrganizationWithRoleSchema = OrganizationSchema.extend({
658
932
  role: UserRoleSchema.describe("Your own role within this specific organization.")
@@ -661,35 +935,35 @@ var PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema);
661
935
  var ListOrganizationsSchema = PaginationQuerySchema;
662
936
 
663
937
  // src/invitations.ts
664
- var import_zod14 = require("zod");
665
- var InviteUserSchema = import_zod14.z.object({
938
+ var import_zod15 = require("zod");
939
+ var InviteUserSchema = import_zod15.z.object({
666
940
  email: NormalizedEmailSchema,
667
941
  role: UserRoleSchema.default("member").describe(
668
942
  "The role the invitee will hold once they accept \u2014 subject to the same management-hierarchy rule as `PATCH /v1/organizations/{id}/users/{userId}`: an `admin` inviter cannot invite an `admin` or `owner`."
669
943
  )
670
944
  });
671
- var AcceptInvitationSchema = import_zod14.z.object({
672
- token: import_zod14.z.string().min(1).describe("The token from the invitation email."),
673
- password: import_zod14.z.string().min(8).max(128).optional().describe(
674
- "Required only if the invited email has no existing Klap account \u2014 a new account is created along with the membership. Ignored if the account already exists."
945
+ var AcceptInvitationSchema = import_zod15.z.object({
946
+ token: import_zod15.z.string().min(1).describe("The token from the invitation email."),
947
+ password: import_zod15.z.string().min(8).max(128).optional().describe(
948
+ "Required only if the invited email has no existing Klappay account \u2014 a new account is created along with the membership. Ignored if the account already exists."
675
949
  )
676
950
  });
677
- var InvitationSchema = import_zod14.z.object({
678
- id: import_zod14.z.string(),
679
- organizationId: import_zod14.z.string(),
680
- email: import_zod14.z.string(),
951
+ var InvitationSchema = import_zod15.z.object({
952
+ id: import_zod15.z.string(),
953
+ organizationId: import_zod15.z.string(),
954
+ email: import_zod15.z.string(),
681
955
  role: UserRoleSchema,
682
- invitedByUserId: import_zod14.z.string().describe("Which member of the organization sent this invitation."),
683
- expiresAt: import_zod14.z.string().datetime(),
684
- createdAt: import_zod14.z.string().datetime()
956
+ invitedByUserId: import_zod15.z.string().describe("Which member of the organization sent this invitation."),
957
+ expiresAt: import_zod15.z.string().datetime(),
958
+ createdAt: import_zod15.z.string().datetime()
685
959
  });
686
960
 
687
961
  // src/timeline.ts
688
- var import_zod15 = require("zod");
689
- var TransactionSourceSchema = import_zod15.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
962
+ var import_zod16 = require("zod");
963
+ var TransactionSourceSchema = import_zod16.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
690
964
  "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)."
691
965
  );
692
- var TimelineEventTypeSchema = import_zod15.z.enum([
966
+ var TimelineEventTypeSchema = import_zod16.z.enum([
693
967
  "charge.created",
694
968
  "charge.expired",
695
969
  "transaction.detected",
@@ -700,11 +974,11 @@ var TimelineEventTypeSchema = import_zod15.z.enum([
700
974
  ]).describe(
701
975
  "`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)."
702
976
  );
703
- var TimelineEventSchema = import_zod15.z.object({
977
+ var TimelineEventSchema = import_zod16.z.object({
704
978
  type: TimelineEventTypeSchema,
705
- at: import_zod15.z.string().datetime(),
706
- txHash: import_zod15.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
707
- amount: import_zod15.z.number().optional().describe(
979
+ at: import_zod16.z.string().datetime(),
980
+ txHash: import_zod16.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
981
+ amount: import_zod16.z.number().optional().describe(
708
982
  "Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
709
983
  ),
710
984
  source: TransactionSourceSchema.optional().describe(
@@ -716,100 +990,100 @@ var TimelineEventSchema = import_zod15.z.object({
716
990
  network: NetworkSchema.optional().describe(
717
991
  "Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
718
992
  ),
719
- causedTransition: import_zod15.z.boolean().optional().describe(
993
+ causedTransition: import_zod16.z.boolean().optional().describe(
720
994
  "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."
721
995
  ),
722
996
  event: WebhookEventTypeSchema.optional().describe(
723
997
  "Present for `webhook.*` events only \u2014 which event type this delivery was for."
724
998
  ),
725
- responseCode: import_zod15.z.number().nullable().optional().describe(
999
+ responseCode: import_zod16.z.number().nullable().optional().describe(
726
1000
  "Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
727
1001
  ),
728
- attempts: import_zod15.z.number().optional().describe(
1002
+ attempts: import_zod16.z.number().optional().describe(
729
1003
  "Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
730
1004
  )
731
1005
  });
732
1006
 
733
1007
  // src/verify.ts
734
- var import_zod16 = require("zod");
735
- var SplitRecipientRoleSchema = import_zod16.z.enum(["merchant", "klap_fee", "distributor_incentive"]).describe(
736
- "`merchant`: the payout recipient. `klap_fee`: the platform fee. `distributor_incentive`: the (usually small) reward paid to whoever triggered the on-chain settlement \u2014 may be Klap or a third party, see `address`."
1008
+ var import_zod17 = require("zod");
1009
+ var SplitRecipientRoleSchema = import_zod17.z.enum(["merchant", "klap_fee", "distributor_incentive"]).describe(
1010
+ "`merchant`: the payout recipient. `klap_fee`: the platform fee. `distributor_incentive`: the (usually small) reward paid to whoever triggered the on-chain settlement \u2014 may be Klappay or a third party, see `address`."
737
1011
  );
738
- var VerifySplitEntrySchema = import_zod16.z.object({
1012
+ var VerifySplitEntrySchema = import_zod17.z.object({
739
1013
  role: SplitRecipientRoleSchema,
740
- address: import_zod16.z.string().nullable().describe(
1014
+ address: import_zod17.z.string().nullable().describe(
741
1015
  "On-chain recipient address for this share. For `distributor_incentive`, this is `null` until settlement actually happens \u2014 there is no fixed address, it goes to whoever calls the settlement transaction."
742
1016
  ),
743
- percentAllocation: import_zod16.z.number().describe("This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%)."),
744
- amountUSD: import_zod16.z.number()
1017
+ percentAllocation: import_zod17.z.number().describe("This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%)."),
1018
+ amountUSD: import_zod17.z.number()
745
1019
  });
746
- var VerifyPaymentSchema = import_zod16.z.object({
1020
+ var VerifyPaymentSchema = import_zod17.z.object({
747
1021
  token: TokenSchema,
748
1022
  network: NetworkSchema,
749
- amountReceived: import_zod16.z.number().describe("Cumulative amount received on this specific `(token, network)` pair."),
750
- txHash: import_zod16.z.string().describe("The on-chain transaction hash of the most recent transfer on this pair."),
751
- explorerTxUrl: import_zod16.z.string().describe("Direct link to `txHash` on the relevant block explorer."),
752
- split: import_zod16.z.array(VerifySplitEntrySchema).describe(
753
- "The exact breakdown of where this pair's payment went \u2014 merchant's share, Klap's fee, and (once settled) the settlement incentive."
1023
+ amountReceived: import_zod17.z.number().describe("Cumulative amount received on this specific `(token, network)` pair."),
1024
+ txHash: import_zod17.z.string().describe("The on-chain transaction hash of the most recent transfer on this pair."),
1025
+ explorerTxUrl: import_zod17.z.string().describe("Direct link to `txHash` on the relevant block explorer."),
1026
+ split: import_zod17.z.array(VerifySplitEntrySchema).describe(
1027
+ "The exact breakdown of where this pair's payment went \u2014 merchant's share, Klappay's fee, and (once settled) the settlement incentive."
754
1028
  ),
755
- splitTxHash: import_zod16.z.string().nullable().describe(
1029
+ splitTxHash: import_zod17.z.string().nullable().describe(
756
1030
  "Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then."
757
1031
  ),
758
- settledAt: import_zod16.z.string().datetime().nullable().describe(
1032
+ settledAt: import_zod17.z.string().datetime().nullable().describe(
759
1033
  "When settlement completed for this pair \u2014 the merchant's wallet actually has the funds. `null` until then."
760
1034
  )
761
1035
  });
762
- var VerifyChargeSchema = import_zod16.z.object({
763
- id: import_zod16.z.string(),
764
- amount: import_zod16.z.number().nullable().describe("The amount originally requested. `null` if the charge accepted any amount."),
765
- amountReceived: import_zod16.z.number().describe(
1036
+ var VerifyChargeSchema = import_zod17.z.object({
1037
+ id: import_zod17.z.string(),
1038
+ amount: import_zod17.z.number().nullable().describe("The amount originally requested. `null` if the charge accepted any amount."),
1039
+ amountReceived: import_zod17.z.number().describe(
766
1040
  "The actual cumulative amount received across every contributing pair \u2014 can exceed `amount` on an overpayment."
767
1041
  ),
768
- confirmedAt: import_zod16.z.string().datetime().nullable().describe(
1042
+ confirmedAt: import_zod17.z.string().datetime().nullable().describe(
769
1043
  "When the charge reached `confirmed`. `null` for a `mode: continuous` charge \u2014 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."
770
1044
  ),
771
- splitAddress: import_zod16.z.string().describe(
1045
+ splitAddress: import_zod17.z.string().describe(
772
1046
  "The on-chain address the payment was sent to \u2014 identical across every accepted network."
773
1047
  ),
774
- payments: import_zod16.z.array(VerifyPaymentSchema).describe(
1048
+ payments: import_zod17.z.array(VerifyPaymentSchema).describe(
775
1049
  "One entry per `(token, network)` pair that actually contributed funds \u2014 a charge accepting several pairs can be confirmed by a combination of them, each proven and settled independently."
776
1050
  )
777
1051
  });
778
1052
 
779
1053
  // src/health.ts
780
- var import_zod17 = require("zod");
781
- var HealthSchema = import_zod17.z.object({
782
- status: import_zod17.z.enum(["ok", "error"]).describe(
1054
+ var import_zod18 = require("zod");
1055
+ var HealthSchema = import_zod18.z.object({
1056
+ status: import_zod18.z.enum(["ok", "error"]).describe(
783
1057
  "`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."
784
1058
  ),
785
- version: import_zod17.z.string(),
786
- timestamp: import_zod17.z.string().datetime(),
787
- db: import_zod17.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
788
- pendingWebhooks: import_zod17.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
789
- oldestPendingChargeAgeSeconds: import_zod17.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
790
- lastMoralisEventAgeSeconds: import_zod17.z.number().nullable().describe(
1059
+ version: import_zod18.z.string(),
1060
+ timestamp: import_zod18.z.string().datetime(),
1061
+ db: import_zod18.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
1062
+ pendingWebhooks: import_zod18.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
1063
+ oldestPendingChargeAgeSeconds: import_zod18.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
1064
+ lastMoralisEventAgeSeconds: import_zod18.z.number().nullable().describe(
791
1065
  "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."
792
1066
  )
793
1067
  });
794
1068
 
795
1069
  // src/sandbox.ts
796
- var import_zod18 = require("zod");
797
- var SandboxTriggerSchema = import_zod18.z.object({
1070
+ var import_zod19 = require("zod");
1071
+ var SandboxTriggerSchema = import_zod19.z.object({
798
1072
  event: TriggerableChargeEventSchema,
799
- amount: import_zod18.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
1073
+ amount: import_zod19.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
800
1074
  "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."
801
1075
  )
802
1076
  });
803
- var SandboxEventTriggerSchema = import_zod18.z.object({
1077
+ var SandboxEventTriggerSchema = import_zod19.z.object({
804
1078
  event: NonChargeTriggerableEventSchema.describe(
805
1079
  "Any account, security, or webhook-delivery event \u2014 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)."
806
1080
  )
807
1081
  });
808
1082
 
809
1083
  // src/capabilities.ts
810
- var import_zod19 = require("zod");
811
- var CapabilitiesSchema = import_zod19.z.object({
812
- acceptedPayments: import_zod19.z.array(AcceptedPaymentSchema).describe(
1084
+ var import_zod20 = require("zod");
1085
+ var CapabilitiesSchema = import_zod20.z.object({
1086
+ acceptedPayments: import_zod20.z.array(AcceptedPaymentSchema).describe(
813
1087
  "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."
814
1088
  )
815
1089
  });
@@ -830,9 +1104,15 @@ var CapabilitiesSchema = import_zod19.z.object({
830
1104
  ChargeStatusEventSchema,
831
1105
  ChargeStatusSchema,
832
1106
  ChargeWebhookEventTypeSchema,
1107
+ ChargesDateFieldSchema,
1108
+ ChargesMetricFieldSchema,
1109
+ ChargesQueryFieldSchema,
833
1110
  CreateApiKeySchema,
834
1111
  CreateChargeSchema,
835
1112
  CreateWebhookSchema,
1113
+ DistributionsDateFieldSchema,
1114
+ DistributionsMetricFieldSchema,
1115
+ DistributionsQueryFieldSchema,
836
1116
  EVENT_CATEGORY_MAP,
837
1117
  EVM_NETWORKS,
838
1118
  EnvironmentSchema,
@@ -847,7 +1127,21 @@ var CapabilitiesSchema = import_zod19.z.object({
847
1127
  ListUsersSchema,
848
1128
  ListWebhookDeliveriesSchema,
849
1129
  LoginSchema,
1130
+ MAX_METRICS_QUERY_DATE_RANGE_DAYS,
1131
+ METRICS_QUERY_DEFAULT_ROW_LIMIT,
1132
+ METRICS_QUERY_MAX_FILTERS,
1133
+ METRICS_QUERY_MAX_GROUP_BY,
1134
+ METRICS_QUERY_MAX_METRICS,
1135
+ METRICS_QUERY_MAX_ROW_LIMIT,
850
1136
  MessageResponseSchema,
1137
+ MetricsAggregationSchema,
1138
+ MetricsDateGranularitySchema,
1139
+ MetricsFilterOperatorSchema,
1140
+ MetricsQueryResultRowSchema,
1141
+ MetricsQueryResultSchema,
1142
+ MetricsQuerySchema,
1143
+ MetricsQueryScopeSchema,
1144
+ MetricsResourceSchema,
851
1145
  NETWORK_EXPLORERS,
852
1146
  NETWORK_LABELS,
853
1147
  NetworkSchema,
@@ -874,6 +1168,7 @@ var CapabilitiesSchema = import_zod19.z.object({
874
1168
  SecurityWebhookEventTypeSchema,
875
1169
  SettlementStatusSchema,
876
1170
  SignupSchema,
1171
+ SplitDistributionStatusSchema,
877
1172
  SplitRecipientRoleSchema,
878
1173
  TOKEN_ADDRESSES,
879
1174
  TOKEN_DECIMALS,
@@ -881,6 +1176,9 @@ var CapabilitiesSchema = import_zod19.z.object({
881
1176
  TimelineEventTypeSchema,
882
1177
  TokenSchema,
883
1178
  TransactionSourceSchema,
1179
+ TransactionsDateFieldSchema,
1180
+ TransactionsMetricFieldSchema,
1181
+ TransactionsQueryFieldSchema,
884
1182
  TriggerableChargeEventSchema,
885
1183
  UpdateOrganizationSchema,
886
1184
  UpdateUserRoleSchema,