@klappay/types 1.0.9 → 1.1.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,7 +35,6 @@ __export(index_exports, {
35
35
  ChangePasswordSchema: () => ChangePasswordSchema,
36
36
  ChargeModeSchema: () => ChargeModeSchema,
37
37
  ChargeSchema: () => ChargeSchema,
38
- ChargeStatusEventSchema: () => ChargeStatusEventSchema,
39
38
  ChargeStatusSchema: () => ChargeStatusSchema,
40
39
  ChargeWebhookEventTypeSchema: () => ChargeWebhookEventTypeSchema,
41
40
  ChargesDateFieldSchema: () => ChargesDateFieldSchema,
@@ -54,6 +53,7 @@ __export(index_exports, {
54
53
  ErrorPayloadSchema: () => ErrorPayloadSchema,
55
54
  ForgotPasswordSchema: () => ForgotPasswordSchema,
56
55
  GetChargeQrCodeQuerySchema: () => GetChargeQrCodeQuerySchema,
56
+ GetPublicChargeQuerySchema: () => GetPublicChargeQuerySchema,
57
57
  HealthSchema: () => HealthSchema,
58
58
  InvitationSchema: () => InvitationSchema,
59
59
  InviteUserSchema: () => InviteUserSchema,
@@ -62,6 +62,7 @@ __export(index_exports, {
62
62
  ListOrganizationsSchema: () => ListOrganizationsSchema,
63
63
  ListUsersSchema: () => ListUsersSchema,
64
64
  ListWebhookDeliveriesSchema: () => ListWebhookDeliveriesSchema,
65
+ ListenPendingDistributionsQuerySchema: () => ListenPendingDistributionsQuerySchema,
65
66
  LoginSchema: () => LoginSchema,
66
67
  MAX_METRICS_QUERY_DATE_RANGE_DAYS: () => MAX_METRICS_QUERY_DATE_RANGE_DAYS,
67
68
  METRICS_QUERY_DEFAULT_ROW_LIMIT: () => METRICS_QUERY_DEFAULT_ROW_LIMIT,
@@ -92,12 +93,14 @@ __export(index_exports, {
92
93
  PaginatedApiKeysSchema: () => PaginatedApiKeysSchema,
93
94
  PaginatedChargesSchema: () => PaginatedChargesSchema,
94
95
  PaginatedOrganizationsSchema: () => PaginatedOrganizationsSchema,
96
+ PaginatedPendingDistributionsSchema: () => PaginatedPendingDistributionsSchema,
95
97
  PaginatedUsersSchema: () => PaginatedUsersSchema,
96
98
  PaginatedWebhookDeliveriesSchema: () => PaginatedWebhookDeliveriesSchema,
97
99
  PaginationQuerySchema: () => PaginationQuerySchema,
98
100
  PendingDistributionEventSchema: () => PendingDistributionEventSchema,
99
101
  PendingDistributionRecipientSchema: () => PendingDistributionRecipientSchema,
100
102
  PendingDistributionSchema: () => PendingDistributionSchema,
103
+ PublicChargeSchema: () => PublicChargeSchema,
101
104
  ResetPasswordSchema: () => ResetPasswordSchema,
102
105
  SandboxEventTriggerSchema: () => SandboxEventTriggerSchema,
103
106
  SandboxTriggerSchema: () => SandboxTriggerSchema,
@@ -106,7 +109,6 @@ __export(index_exports, {
106
109
  SettlementStatusSchema: () => SettlementStatusSchema,
107
110
  SignupSchema: () => SignupSchema,
108
111
  SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
109
- SplitRecipientRoleSchema: () => SplitRecipientRoleSchema,
110
112
  TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
111
113
  TOKEN_DECIMALS: () => TOKEN_DECIMALS,
112
114
  TimelineEventSchema: () => TimelineEventSchema,
@@ -121,10 +123,7 @@ __export(index_exports, {
121
123
  UpdateUserRoleSchema: () => UpdateUserRoleSchema,
122
124
  UserRoleSchema: () => UserRoleSchema,
123
125
  UserSchema: () => UserSchema,
124
- VerifyChargeSchema: () => VerifyChargeSchema,
125
126
  VerifyEmailSchema: () => VerifyEmailSchema,
126
- VerifyPaymentSchema: () => VerifyPaymentSchema,
127
- VerifySplitEntrySchema: () => VerifySplitEntrySchema,
128
127
  WEBHOOK_EVENTS_WILDCARD: () => WEBHOOK_EVENTS_WILDCARD,
129
128
  WEBHOOK_EVENT_CATEGORIES: () => WEBHOOK_EVENT_CATEGORIES,
130
129
  WebhookCategorySchema: () => WebhookCategorySchema,
@@ -258,8 +257,8 @@ var TOKEN_ADDRESSES = {
258
257
 
259
258
  // src/charges.ts
260
259
  var import_zod6 = require("zod");
261
- var ChargeStatusSchema = import_zod6.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid"]).describe(
262
- "Payment progress, from the payer side. `pending`: created, nothing received yet. `partially_paid`: some funds received, less than `amount`. `confirmed`: full amount received (or more \u2014 see `isOverpaid`). `expired`: `expiresAt` passed with zero funds received. `underpaid`: `expiresAt` passed while `partially_paid`. This never reflects whether funds actually reached the merchant \u2014 see `settlementStatus` for that."
260
+ var ChargeStatusSchema = import_zod6.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid", "canceled"]).describe(
261
+ "Payment progress, from the payer side. `pending`: created, nothing received yet. `partially_paid`: some funds received, less than `amount`. `confirmed`: full amount received (or more \u2014 see `isOverpaid`). `expired`: `expiresAt` passed with zero funds received. `underpaid`: `expiresAt` passed while `partially_paid`. `canceled`: the merchant explicitly canceled it via `POST /v1/charges/{id}/cancel` before it resolved on its own \u2014 unlike every other terminal status, this one is never reached automatically. This never reflects whether funds actually reached the merchant \u2014 see `settlementStatus` for that."
263
262
  );
264
263
  var SettlementStatusSchema = import_zod6.z.enum(["pending", "completed", "failed"]).describe(
265
264
  "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."
@@ -374,6 +373,9 @@ var ChargeSchema = import_zod6.z.object({
374
373
  ),
375
374
  pausedAt: import_zod6.z.string().datetime().nullable().describe(
376
375
  "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."
376
+ ),
377
+ canceledAt: import_zod6.z.string().datetime().nullable().describe(
378
+ "When `POST /v1/charges/{id}/cancel` was called. `null` unless `status` is `canceled`. Unlike `pausedAt`, this never clears automatically \u2014 real-time watching is stopped the same way, but a transfer landing afterward doesn't revert the charge to `pending`; it fires `charge.paid_after_cancel` instead, since resuming silently would contradict the merchant's explicit cancellation."
377
379
  )
378
380
  });
379
381
  var ListChargesSchema = import_zod6.z.object({
@@ -397,65 +399,96 @@ var GetChargeQrCodeQuerySchema = import_zod6.z.object({
397
399
  ),
398
400
  network: NetworkSchema.optional()
399
401
  });
400
- var ChargeStatusEventSchema = import_zod6.z.object({
401
- id: import_zod6.z.string(),
402
+
403
+ // src/public-charges.ts
404
+ var import_zod7 = require("zod");
405
+ var PublicChargeSchema = import_zod7.z.object({
406
+ id: import_zod7.z.string(),
407
+ mode: ChargeModeSchema,
402
408
  status: ChargeStatusSchema,
403
409
  settlementStatus: SettlementStatusSchema.nullable(),
404
- amount: import_zod6.z.number().nullable(),
405
- amountReceived: import_zod6.z.number().nullable(),
406
- paidWith: import_zod6.z.array(AcceptedPaymentSchema)
410
+ amount: import_zod7.z.number().nullable(),
411
+ amountReceived: import_zod7.z.number().nullable(),
412
+ isOverpaid: import_zod7.z.boolean(),
413
+ currency: import_zod7.z.string(),
414
+ acceptedPayments: import_zod7.z.array(AcceptedPaymentSchema),
415
+ paidWith: import_zod7.z.array(AcceptedPaymentSchema),
416
+ address: import_zod7.z.string(),
417
+ environment: EnvironmentSchema,
418
+ txHash: import_zod7.z.string().nullable(),
419
+ metadata: import_zod7.z.record(import_zod7.z.unknown()).nullable().describe(
420
+ "Redacted \u2014 everything the merchant put in `Charge.metadata` is stripped except the reserved `klappay` key (for Klappay-internal product integrations, e.g. this endpoint's own checkout consumer), if present. `null` if there's no `klappay` key, even when the merchant's own metadata is otherwise non-empty."
421
+ ),
422
+ createdAt: import_zod7.z.string().datetime(),
423
+ expiresAt: import_zod7.z.string().datetime().nullable(),
424
+ confirmedAt: import_zod7.z.string().datetime().nullable(),
425
+ settledAt: import_zod7.z.string().datetime().nullable(),
426
+ lastActivityAt: import_zod7.z.string().datetime(),
427
+ pausedAt: import_zod7.z.string().datetime().nullable(),
428
+ canceledAt: import_zod7.z.string().datetime().nullable()
429
+ });
430
+ var GetPublicChargeQuerySchema = import_zod7.z.object({
431
+ environment: EnvironmentSchema.describe(
432
+ "Which environment this charge is expected to be in. Required, not inferred \u2014 there's no API key here to derive it from, and stating it explicitly catches an integration bug (e.g. a `test` chargeId reaching a `live` checkout flow) instead of silently trusting whatever environment the id happens to belong to. A mismatch is indistinguishable from the charge not existing at all (`404`), same anti-enumeration posture as every other case below."
433
+ )
407
434
  });
408
435
 
409
436
  // src/distributions.ts
410
- var import_zod7 = require("zod");
411
- var SplitDistributionStatusSchema = import_zod7.z.enum(["pending", "processing", "completed", "failed"]).describe(
437
+ var import_zod8 = require("zod");
438
+ var SplitDistributionStatusSchema = import_zod8.z.enum(["pending", "processing", "completed", "failed"]).describe(
412
439
  "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."
413
440
  );
414
- var PendingDistributionRecipientSchema = import_zod7.z.object({
415
- address: import_zod7.z.string().describe("On-chain recipient address."),
416
- percentAllocation: import_zod7.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
441
+ var PendingDistributionRecipientSchema = import_zod8.z.object({
442
+ address: import_zod8.z.string().describe("On-chain recipient address."),
443
+ percentAllocation: import_zod8.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
417
444
  });
418
- var PendingDistributionSchema = import_zod7.z.object({
419
- splitAddress: import_zod7.z.string().describe("The on-chain 0xSplits address to call `distribute()` on."),
445
+ var PendingDistributionSchema = import_zod8.z.object({
446
+ splitAddress: import_zod8.z.string().describe("The on-chain 0xSplits address to call `distribute()` on."),
420
447
  network: NetworkSchema,
421
448
  token: TokenSchema,
422
- recipients: import_zod7.z.array(PendingDistributionRecipientSchema).describe(
449
+ recipients: import_zod8.z.array(PendingDistributionRecipientSchema).describe(
423
450
  "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."
424
451
  ),
425
- distributorFeePercent: import_zod7.z.number().describe(
452
+ distributorFeePercent: import_zod8.z.number().describe(
426
453
  "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."
427
454
  ),
428
- estimatedRewardAmount: import_zod7.z.number().describe(
455
+ estimatedRewardAmount: import_zod8.z.number().describe(
429
456
  "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."
430
457
  ),
431
- availableSince: import_zod7.z.string().datetime().describe("When this distribution entered its grace period."),
432
- graceEndsAt: import_zod7.z.string().datetime().describe(
458
+ availableSince: import_zod8.z.string().datetime().describe("When this distribution entered its grace period."),
459
+ graceEndsAt: import_zod8.z.string().datetime().describe(
433
460
  "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."
434
461
  )
435
462
  });
436
- var PendingDistributionEventSchema = import_zod7.z.discriminatedUnion("type", [
437
- import_zod7.z.object({
438
- type: import_zod7.z.literal("distribution.available"),
463
+ var PaginatedPendingDistributionsSchema = paginatedSchema(PendingDistributionSchema);
464
+ var ListenPendingDistributionsQuerySchema = import_zod8.z.object({
465
+ limit: import_zod8.z.coerce.number().int().min(0).max(PAGINATION_LIMIT_MAX).default(0).describe(
466
+ "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."
467
+ )
468
+ });
469
+ var PendingDistributionEventSchema = import_zod8.z.discriminatedUnion("type", [
470
+ import_zod8.z.object({
471
+ type: import_zod8.z.literal("distribution.available"),
439
472
  distribution: PendingDistributionSchema
440
473
  }),
441
- import_zod7.z.object({
442
- type: import_zod7.z.literal("distribution.claimed"),
443
- splitAddress: import_zod7.z.string().describe("No longer claimable \u2014 either settled by someone, or picked up by the worker.")
474
+ import_zod8.z.object({
475
+ type: import_zod8.z.literal("distribution.claimed"),
476
+ splitAddress: import_zod8.z.string().describe("No longer claimable \u2014 either settled by someone, or picked up by the worker.")
444
477
  })
445
478
  ]);
446
479
 
447
480
  // src/metrics.ts
448
- var import_zod8 = require("zod");
449
- var MetricsResourceSchema = import_zod8.z.enum(["charges", "transactions", "distributions"]).describe(
481
+ var import_zod9 = require("zod");
482
+ var MetricsResourceSchema = import_zod9.z.enum(["charges", "transactions", "distributions"]).describe(
450
483
  "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."
451
484
  );
452
- var MetricsAggregationSchema = import_zod8.z.enum(["count", "sum", "avg", "min", "max"]).describe(
485
+ var MetricsAggregationSchema = import_zod9.z.enum(["count", "sum", "avg", "min", "max"]).describe(
453
486
  "`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."
454
487
  );
455
- var MetricsFilterOperatorSchema = import_zod8.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
488
+ var MetricsFilterOperatorSchema = import_zod9.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
456
489
  "`in` expects an array value (max 50 entries); every other operator expects a single scalar."
457
490
  );
458
- var MetricsDateGranularitySchema = import_zod8.z.enum(["day", "week", "month"]).describe(
491
+ var MetricsDateGranularitySchema = import_zod9.z.enum(["day", "week", "month"]).describe(
459
492
  "Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
460
493
  );
461
494
  var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
@@ -468,151 +501,151 @@ var METRICS_QUERY_MAX_GROUP_BY = 3;
468
501
  var METRICS_QUERY_MAX_FILTERS = 20;
469
502
  var METRICS_QUERY_MAX_METRICS = 10;
470
503
  var METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
471
- var metricAliasSchema = import_zod8.z.string().min(1).max(64).regex(
504
+ var metricAliasSchema = import_zod9.z.string().min(1).max(64).regex(
472
505
  METRIC_ALIAS_PATTERN,
473
506
  "Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 this becomes a SQL column alias."
474
507
  ).optional();
475
- var MetricsFilterValueSchema = import_zod8.z.union([
476
- import_zod8.z.string().max(255),
477
- import_zod8.z.number(),
478
- import_zod8.z.boolean(),
479
- import_zod8.z.array(import_zod8.z.union([import_zod8.z.string().max(255), import_zod8.z.number()])).min(1).max(50)
508
+ var MetricsFilterValueSchema = import_zod9.z.union([
509
+ import_zod9.z.string().max(255),
510
+ import_zod9.z.number(),
511
+ import_zod9.z.boolean(),
512
+ import_zod9.z.array(import_zod9.z.union([import_zod9.z.string().max(255), import_zod9.z.number()])).min(1).max(50)
480
513
  ]);
481
- var orderBySchema = import_zod8.z.object({
482
- key: import_zod8.z.string().min(1).max(64).regex(
514
+ var orderBySchema = import_zod9.z.object({
515
+ key: import_zod9.z.string().min(1).max(64).regex(
483
516
  METRIC_ALIAS_PATTERN,
484
517
  "Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 every valid output column name already looks like this."
485
518
  ).describe(
486
519
  "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."
487
520
  ),
488
- direction: import_zod8.z.enum(["asc", "desc"])
521
+ direction: import_zod9.z.enum(["asc", "desc"])
489
522
  }).describe(
490
523
  "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."
491
524
  );
492
- var limitSchema = import_zod8.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
525
+ var limitSchema = import_zod9.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
493
526
  `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.`
494
527
  );
495
- var ChargesQueryFieldSchema = import_zod8.z.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
528
+ var ChargesQueryFieldSchema = import_zod9.z.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
496
529
  "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."
497
530
  );
498
- var ChargesMetricFieldSchema = import_zod8.z.enum(["amount", "amountReceived", "feePercent"]).describe(
531
+ var ChargesMetricFieldSchema = import_zod9.z.enum(["amount", "amountReceived", "feePercent"]).describe(
499
532
  "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%."
500
533
  );
501
- var ChargesDateFieldSchema = import_zod8.z.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
534
+ var ChargesDateFieldSchema = import_zod9.z.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
502
535
  "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."
503
536
  );
504
- var ChargesFilterSchema = import_zod8.z.object({
537
+ var ChargesFilterSchema = import_zod9.z.object({
505
538
  field: ChargesQueryFieldSchema,
506
539
  operator: MetricsFilterOperatorSchema,
507
540
  value: MetricsFilterValueSchema
508
541
  });
509
- var ChargesGroupBySchema = import_zod8.z.union([
510
- import_zod8.z.object({ type: import_zod8.z.literal("field"), field: ChargesQueryFieldSchema }),
511
- import_zod8.z.object({
512
- type: import_zod8.z.literal("date_bucket"),
542
+ var ChargesGroupBySchema = import_zod9.z.union([
543
+ import_zod9.z.object({ type: import_zod9.z.literal("field"), field: ChargesQueryFieldSchema }),
544
+ import_zod9.z.object({
545
+ type: import_zod9.z.literal("date_bucket"),
513
546
  field: ChargesDateFieldSchema,
514
547
  granularity: MetricsDateGranularitySchema
515
548
  })
516
549
  ]);
517
- var ChargesMetricSchema = import_zod8.z.object({
550
+ var ChargesMetricSchema = import_zod9.z.object({
518
551
  aggregation: MetricsAggregationSchema,
519
552
  field: ChargesMetricFieldSchema.optional(),
520
553
  alias: metricAliasSchema
521
554
  });
522
- var ChargesMetricsQuerySchema = import_zod8.z.object({
523
- resource: import_zod8.z.literal("charges"),
555
+ var ChargesMetricsQuerySchema = import_zod9.z.object({
556
+ resource: import_zod9.z.literal("charges"),
524
557
  environment: metricsQueryEnvironmentSchema,
525
- dateRange: import_zod8.z.object({
558
+ dateRange: import_zod9.z.object({
526
559
  field: ChargesDateFieldSchema,
527
- from: import_zod8.z.string().max(64).datetime(),
528
- to: import_zod8.z.string().max(64).datetime()
560
+ from: import_zod9.z.string().max(64).datetime(),
561
+ to: import_zod9.z.string().max(64).datetime()
529
562
  }),
530
- groupBy: import_zod8.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
531
- metrics: import_zod8.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
532
- filters: import_zod8.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
563
+ groupBy: import_zod9.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
564
+ metrics: import_zod9.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
565
+ filters: import_zod9.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
533
566
  orderBy: orderBySchema.optional(),
534
567
  limit: limitSchema
535
568
  });
536
- var TransactionsQueryFieldSchema = import_zod8.z.enum(["network", "token", "source", "causedTransition"]).describe(
569
+ var TransactionsQueryFieldSchema = import_zod9.z.enum(["network", "token", "source", "causedTransition"]).describe(
537
570
  "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)."
538
571
  );
539
- var TransactionsMetricFieldSchema = import_zod8.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
540
- var TransactionsDateFieldSchema = import_zod8.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
541
- var TransactionsFilterSchema = import_zod8.z.object({
572
+ var TransactionsMetricFieldSchema = import_zod9.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
573
+ var TransactionsDateFieldSchema = import_zod9.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
574
+ var TransactionsFilterSchema = import_zod9.z.object({
542
575
  field: TransactionsQueryFieldSchema,
543
576
  operator: MetricsFilterOperatorSchema,
544
577
  value: MetricsFilterValueSchema
545
578
  });
546
- var TransactionsGroupBySchema = import_zod8.z.union([
547
- import_zod8.z.object({ type: import_zod8.z.literal("field"), field: TransactionsQueryFieldSchema }),
548
- import_zod8.z.object({
549
- type: import_zod8.z.literal("date_bucket"),
579
+ var TransactionsGroupBySchema = import_zod9.z.union([
580
+ import_zod9.z.object({ type: import_zod9.z.literal("field"), field: TransactionsQueryFieldSchema }),
581
+ import_zod9.z.object({
582
+ type: import_zod9.z.literal("date_bucket"),
550
583
  field: TransactionsDateFieldSchema,
551
584
  granularity: MetricsDateGranularitySchema
552
585
  })
553
586
  ]);
554
- var TransactionsMetricSchema = import_zod8.z.object({
587
+ var TransactionsMetricSchema = import_zod9.z.object({
555
588
  aggregation: MetricsAggregationSchema,
556
589
  field: TransactionsMetricFieldSchema.optional(),
557
590
  alias: metricAliasSchema
558
591
  });
559
- var TransactionsMetricsQuerySchema = import_zod8.z.object({
560
- resource: import_zod8.z.literal("transactions"),
592
+ var TransactionsMetricsQuerySchema = import_zod9.z.object({
593
+ resource: import_zod9.z.literal("transactions"),
561
594
  environment: metricsQueryEnvironmentSchema,
562
- dateRange: import_zod8.z.object({
595
+ dateRange: import_zod9.z.object({
563
596
  field: TransactionsDateFieldSchema,
564
- from: import_zod8.z.string().max(64).datetime(),
565
- to: import_zod8.z.string().max(64).datetime()
597
+ from: import_zod9.z.string().max(64).datetime(),
598
+ to: import_zod9.z.string().max(64).datetime()
566
599
  }),
567
- groupBy: import_zod8.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
568
- metrics: import_zod8.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
569
- filters: import_zod8.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
600
+ groupBy: import_zod9.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
601
+ metrics: import_zod9.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
602
+ filters: import_zod9.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
570
603
  orderBy: orderBySchema.optional(),
571
604
  limit: limitSchema
572
605
  });
573
- var DistributionsQueryFieldSchema = import_zod8.z.enum(["status", "network", "token"]).describe(
606
+ var DistributionsQueryFieldSchema = import_zod9.z.enum(["status", "network", "token"]).describe(
574
607
  "A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values."
575
608
  );
576
- var DistributionsMetricFieldSchema = import_zod8.z.enum(["attempts"]).describe(
609
+ var DistributionsMetricFieldSchema = import_zod9.z.enum(["attempts"]).describe(
577
610
  "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."
578
611
  );
579
- var DistributionsDateFieldSchema = import_zod8.z.enum(["createdAt", "completedAt"]).describe(
612
+ var DistributionsDateFieldSchema = import_zod9.z.enum(["createdAt", "completedAt"]).describe(
580
613
  "`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."
581
614
  );
582
- var DistributionsFilterSchema = import_zod8.z.object({
615
+ var DistributionsFilterSchema = import_zod9.z.object({
583
616
  field: DistributionsQueryFieldSchema,
584
617
  operator: MetricsFilterOperatorSchema,
585
618
  value: MetricsFilterValueSchema
586
619
  });
587
- var DistributionsGroupBySchema = import_zod8.z.union([
588
- import_zod8.z.object({ type: import_zod8.z.literal("field"), field: DistributionsQueryFieldSchema }),
589
- import_zod8.z.object({
590
- type: import_zod8.z.literal("date_bucket"),
620
+ var DistributionsGroupBySchema = import_zod9.z.union([
621
+ import_zod9.z.object({ type: import_zod9.z.literal("field"), field: DistributionsQueryFieldSchema }),
622
+ import_zod9.z.object({
623
+ type: import_zod9.z.literal("date_bucket"),
591
624
  field: DistributionsDateFieldSchema,
592
625
  granularity: MetricsDateGranularitySchema
593
626
  })
594
627
  ]);
595
- var DistributionsMetricSchema = import_zod8.z.object({
628
+ var DistributionsMetricSchema = import_zod9.z.object({
596
629
  aggregation: MetricsAggregationSchema,
597
630
  field: DistributionsMetricFieldSchema.optional(),
598
631
  alias: metricAliasSchema
599
632
  });
600
- var DistributionsMetricsQuerySchema = import_zod8.z.object({
601
- resource: import_zod8.z.literal("distributions"),
633
+ var DistributionsMetricsQuerySchema = import_zod9.z.object({
634
+ resource: import_zod9.z.literal("distributions"),
602
635
  environment: metricsQueryEnvironmentSchema,
603
- dateRange: import_zod8.z.object({
636
+ dateRange: import_zod9.z.object({
604
637
  field: DistributionsDateFieldSchema,
605
- from: import_zod8.z.string().max(64).datetime(),
606
- to: import_zod8.z.string().max(64).datetime()
638
+ from: import_zod9.z.string().max(64).datetime(),
639
+ to: import_zod9.z.string().max(64).datetime()
607
640
  }),
608
- groupBy: import_zod8.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
609
- metrics: import_zod8.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
610
- filters: import_zod8.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
641
+ groupBy: import_zod9.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
642
+ metrics: import_zod9.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
643
+ filters: import_zod9.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
611
644
  orderBy: orderBySchema.optional(),
612
645
  limit: limitSchema
613
646
  });
614
647
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
615
- var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
648
+ var MetricsQuerySchema = import_zod9.z.discriminatedUnion("resource", [
616
649
  ChargesMetricsQuerySchema,
617
650
  TransactionsMetricsQuerySchema,
618
651
  DistributionsMetricsQuerySchema
@@ -621,7 +654,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
621
654
  const to = new Date(input.dateRange.to);
622
655
  if (from >= to) {
623
656
  ctx.addIssue({
624
- code: import_zod8.z.ZodIssueCode.custom,
657
+ code: import_zod9.z.ZodIssueCode.custom,
625
658
  message: "`dateRange.from` must be before `dateRange.to`.",
626
659
  path: ["dateRange", "from"]
627
660
  });
@@ -629,7 +662,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
629
662
  const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS;
630
663
  if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {
631
664
  ctx.addIssue({
632
- code: import_zod8.z.ZodIssueCode.custom,
665
+ code: import_zod9.z.ZodIssueCode.custom,
633
666
  message: `\`dateRange\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,
634
667
  path: ["dateRange", "to"]
635
668
  });
@@ -637,7 +670,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
637
670
  const dateBucketCount = input.groupBy.filter((entry) => entry.type === "date_bucket").length;
638
671
  if (dateBucketCount > 1) {
639
672
  ctx.addIssue({
640
- code: import_zod8.z.ZodIssueCode.custom,
673
+ code: import_zod9.z.ZodIssueCode.custom,
641
674
  message: "At most one `date_bucket` entry is allowed in `groupBy`.",
642
675
  path: ["groupBy"]
643
676
  });
@@ -645,7 +678,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
645
678
  input.metrics.forEach((metric, index) => {
646
679
  if (metric.aggregation !== "count" && metric.field === void 0) {
647
680
  ctx.addIssue({
648
- code: import_zod8.z.ZodIssueCode.custom,
681
+ code: import_zod9.z.ZodIssueCode.custom,
649
682
  message: "`field` is required unless `aggregation` is `count`.",
650
683
  path: ["metrics", index, "field"]
651
684
  });
@@ -654,7 +687,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
654
687
  const aliases = input.metrics.map((metric) => metric.alias).filter((alias) => alias !== void 0);
655
688
  if (new Set(aliases).size !== aliases.length) {
656
689
  ctx.addIssue({
657
- code: import_zod8.z.ZodIssueCode.custom,
690
+ code: import_zod9.z.ZodIssueCode.custom,
658
691
  message: "Every `metrics[].alias` must be unique.",
659
692
  path: ["metrics"]
660
693
  });
@@ -663,36 +696,36 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
663
696
  input.metrics.forEach((metric, index) => {
664
697
  if (metric.alias !== void 0 && reservedNames.has(metric.alias)) {
665
698
  ctx.addIssue({
666
- code: import_zod8.z.ZodIssueCode.custom,
699
+ code: import_zod9.z.ZodIssueCode.custom,
667
700
  message: `\`alias\` "${metric.alias}" collides with a \`groupBy\` field name (or the reserved word "bucket") \u2014 choose a different alias.`,
668
701
  path: ["metrics", index, "alias"]
669
702
  });
670
703
  }
671
704
  });
672
705
  });
673
- var MetricsQueryResultRowSchema = import_zod8.z.record(
674
- import_zod8.z.string(),
675
- import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number(), import_zod8.z.boolean(), import_zod8.z.null()])
706
+ var MetricsQueryResultRowSchema = import_zod9.z.record(
707
+ import_zod9.z.string(),
708
+ import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number(), import_zod9.z.boolean(), import_zod9.z.null()])
676
709
  );
677
- var MetricsQueryScopeSchema = import_zod8.z.enum(["owner_admin", "member"]).describe(
710
+ var MetricsQueryScopeSchema = import_zod9.z.enum(["owner_admin", "member"]).describe(
678
711
  "`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."
679
712
  );
680
- var MetricsQueryResultSchema = import_zod8.z.object({
681
- data: import_zod8.z.array(MetricsQueryResultRowSchema),
682
- meta: import_zod8.z.object({
713
+ var MetricsQueryResultSchema = import_zod9.z.object({
714
+ data: import_zod9.z.array(MetricsQueryResultRowSchema),
715
+ meta: import_zod9.z.object({
683
716
  resource: MetricsResourceSchema,
684
717
  environment: EnvironmentSchema,
685
718
  scope: MetricsQueryScopeSchema,
686
- rowCount: import_zod8.z.number().int().describe("Number of rows in `data`."),
687
- truncated: import_zod8.z.boolean().describe(
719
+ rowCount: import_zod9.z.number().int().describe("Number of rows in `data`."),
720
+ truncated: import_zod9.z.boolean().describe(
688
721
  "`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
689
722
  )
690
723
  })
691
724
  });
692
725
 
693
726
  // src/webhook-events.ts
694
- var import_zod9 = require("zod");
695
- var ChargeWebhookEventTypeSchema = import_zod9.z.enum([
727
+ var import_zod10 = require("zod");
728
+ var ChargeWebhookEventTypeSchema = import_zod10.z.enum([
696
729
  "charge.created",
697
730
  "charge.partially_paid",
698
731
  "charge.confirmed",
@@ -704,11 +737,13 @@ var ChargeWebhookEventTypeSchema = import_zod9.z.enum([
704
737
  "charge.paused",
705
738
  "charge.reactivated",
706
739
  "charge.contribution_received",
707
- "charge.contribution_settled"
740
+ "charge.contribution_settled",
741
+ "charge.canceled",
742
+ "charge.paid_after_cancel"
708
743
  ]).describe(
709
- '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 }`.'
744
+ '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`/`charge.paid_after_cancel` (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. `charge.canceled` fires when a merchant explicitly cancels a `pending`/`partially_paid` charge via `POST /v1/charges/{id}/cancel` \u2014 unlike every other terminal status, this one is never reached automatically. `charge.paid_after_cancel` is an anomaly signal: a transfer still landed on a canceled charge\'s address (nothing on-chain can prevent that) \u2014 `status` stays `canceled`, it is never silently resumed, and this event is your cue to manually refund the payer or honor the charge anyway. `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 }`; for `charge.paid_after_cancel`: `{ chargeId, token, network, amount, txHash, payerAddress }`.'
710
745
  );
711
- var AccountWebhookEventTypeSchema = import_zod9.z.enum([
746
+ var AccountWebhookEventTypeSchema = import_zod10.z.enum([
712
747
  "payout_address.changed",
713
748
  "api_key.created",
714
749
  "api_key.revoked",
@@ -722,10 +757,10 @@ var AccountWebhookEventTypeSchema = import_zod9.z.enum([
722
757
  ]).describe(
723
758
  "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 }`."
724
759
  );
725
- var WebhookDeliveryEventTypeSchema = import_zod9.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
760
+ var WebhookDeliveryEventTypeSchema = import_zod10.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
726
761
  "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`)."
727
762
  );
728
- var SecurityWebhookEventTypeSchema = import_zod9.z.enum([
763
+ var SecurityWebhookEventTypeSchema = import_zod10.z.enum([
729
764
  "auth.login",
730
765
  "auth.login_failed",
731
766
  "auth.suspicious_activity",
@@ -738,13 +773,13 @@ var SecurityWebhookEventTypeSchema = import_zod9.z.enum([
738
773
  ]).describe(
739
774
  "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. `auth.password_changed` is the self-service counterpart to `auth.password_reset_completed` \u2014 fires from `POST /v1/auth/change-password` (requires the current password) instead of the unauthenticated forgot-password flow. `auth.email_change_requested`/`auth.email_changed` are the request/complete pair for `POST /v1/auth/change-email` \u2192 `POST /v1/auth/confirm-email-change` \u2014 the change only takes effect, and `email_changed` only fires, once the confirmation link sent to the *current* address is used. `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`/`auth.password_changed`: `{ userId, email }`; `auth.email_change_requested`: `{ userId, email, newEmail }`; `auth.email_changed`: `{ userId, previousEmail, newEmail }`."
740
775
  );
741
- var WebhookEventTypeSchema = import_zod9.z.union([
776
+ var WebhookEventTypeSchema = import_zod10.z.union([
742
777
  ChargeWebhookEventTypeSchema,
743
778
  AccountWebhookEventTypeSchema,
744
779
  WebhookDeliveryEventTypeSchema,
745
780
  SecurityWebhookEventTypeSchema
746
781
  ]);
747
- var WebhookCategorySchema = import_zod9.z.enum(["payments", "account", "webhooks", "security"]).describe(
782
+ var WebhookCategorySchema = import_zod10.z.enum(["payments", "account", "webhooks", "security"]).describe(
748
783
  "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."
749
784
  );
750
785
  function buildCategoryMap() {
@@ -767,108 +802,110 @@ var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
767
802
  "charge.paused",
768
803
  "charge.reactivated",
769
804
  "charge.contribution_received",
770
- "charge.contribution_settled"
805
+ "charge.contribution_settled",
806
+ "charge.canceled",
807
+ "charge.paid_after_cancel"
771
808
  ]).describe(
772
- "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)."
809
+ "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), `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), and `charge.canceled` (already a real, immediate action in `test` mode via `POST /v1/charges/{id}/cancel` itself \u2014 nothing to simulate) along with `charge.paid_after_cancel` (not simulatable without a real transfer to an already-canceled charge)."
773
810
  );
774
- var NonChargeTriggerableEventSchema = import_zod9.z.union([
811
+ var NonChargeTriggerableEventSchema = import_zod10.z.union([
775
812
  AccountWebhookEventTypeSchema,
776
813
  WebhookDeliveryEventTypeSchema,
777
814
  SecurityWebhookEventTypeSchema
778
815
  ]);
779
816
 
780
817
  // src/webhooks.ts
781
- var import_zod10 = require("zod");
818
+ var import_zod11 = require("zod");
782
819
  var WEBHOOK_EVENTS_WILDCARD = "*";
783
- var CreateWebhookSchema = import_zod10.z.object({
784
- url: import_zod10.z.string().max(2048).url().describe(
820
+ var CreateWebhookSchema = import_zod11.z.object({
821
+ url: import_zod11.z.string().max(2048).url().describe(
785
822
  "Must be HTTPS and resolve to a public address \u2014 private/internal IPs are rejected."
786
823
  ),
787
- 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(
824
+ events: import_zod11.z.array(import_zod11.z.union([WebhookEventTypeSchema, import_zod11.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
788
825
  '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.'
789
826
  ),
790
- eventCategories: import_zod10.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
827
+ eventCategories: import_zod11.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
791
828
  "Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required."
792
829
  ),
793
- excludeEvents: import_zod10.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
830
+ excludeEvents: import_zod11.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
794
831
  'Event types to exclude even if selected via `events: ["*"]` or `eventCategories`.'
795
832
  )
796
833
  }).refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {
797
834
  message: "must select at least one event via `events` or `eventCategories`",
798
835
  path: ["events"]
799
836
  });
800
- var WebhookSchema = import_zod10.z.object({
801
- id: import_zod10.z.string(),
837
+ var WebhookSchema = import_zod11.z.object({
838
+ id: import_zod11.z.string(),
802
839
  environment: EnvironmentSchema.nullable().describe(
803
840
  "Which environment's API key created this webhook \u2014 `live` or `test`. Charge/webhook-delivery-health events are 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). Account/security events (`payout_address.changed`, `member.*`, `auth.*`, `fee_tier.updated`) have no environment concept and are delivered regardless."
804
841
  ),
805
- url: import_zod10.z.string(),
806
- events: import_zod10.z.array(WebhookEventTypeSchema),
807
- eventCategories: import_zod10.z.array(WebhookCategorySchema),
808
- excludeEvents: import_zod10.z.array(WebhookEventTypeSchema),
809
- isWildcard: import_zod10.z.boolean(),
810
- secret: import_zod10.z.string().describe(
842
+ url: import_zod11.z.string(),
843
+ events: import_zod11.z.array(WebhookEventTypeSchema),
844
+ eventCategories: import_zod11.z.array(WebhookCategorySchema),
845
+ excludeEvents: import_zod11.z.array(WebhookEventTypeSchema),
846
+ isWildcard: import_zod11.z.boolean(),
847
+ secret: import_zod11.z.string().describe(
811
848
  "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."
812
849
  ),
813
- createdAt: import_zod10.z.string().datetime()
850
+ createdAt: import_zod11.z.string().datetime()
814
851
  });
815
852
  var WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({
816
- hint: import_zod10.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
853
+ hint: import_zod11.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
817
854
  });
818
- var WebhookPayloadSchema = import_zod10.z.object({
819
- id: import_zod10.z.string().describe(
855
+ var WebhookPayloadSchema = import_zod11.z.object({
856
+ id: import_zod11.z.string().describe(
820
857
  "Unique id for this specific delivery \u2014 also sent as the `X-Klappay-Delivery` header."
821
858
  ),
822
859
  event: WebhookEventTypeSchema,
823
- createdAt: import_zod10.z.string().datetime(),
824
- data: import_zod10.z.unknown().describe(
860
+ createdAt: import_zod11.z.string().datetime(),
861
+ data: import_zod11.z.unknown().describe(
825
862
  "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."
826
863
  )
827
864
  });
828
- var WebhookDeliveryStatusSchema = import_zod10.z.enum(["pending", "delivered", "failed"]);
829
- var WebhookDeliverySchema = import_zod10.z.object({
830
- id: import_zod10.z.string(),
831
- webhookId: import_zod10.z.string(),
865
+ var WebhookDeliveryStatusSchema = import_zod11.z.enum(["pending", "delivered", "failed"]);
866
+ var WebhookDeliverySchema = import_zod11.z.object({
867
+ id: import_zod11.z.string(),
868
+ webhookId: import_zod11.z.string(),
832
869
  event: WebhookEventTypeSchema,
833
870
  status: WebhookDeliveryStatusSchema.describe(
834
871
  "`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."
835
872
  ),
836
- attempts: import_zod10.z.number(),
837
- responseCode: import_zod10.z.number().nullable().describe(
873
+ attempts: import_zod11.z.number(),
874
+ responseCode: import_zod11.z.number().nullable().describe(
838
875
  "HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all."
839
876
  ),
840
- nextRetryAt: import_zod10.z.string().datetime().nullable(),
841
- deliveredAt: import_zod10.z.string().datetime().nullable(),
842
- createdAt: import_zod10.z.string().datetime()
877
+ nextRetryAt: import_zod11.z.string().datetime().nullable(),
878
+ deliveredAt: import_zod11.z.string().datetime().nullable(),
879
+ createdAt: import_zod11.z.string().datetime()
843
880
  });
844
881
  var ListWebhookDeliveriesSchema = PaginationQuerySchema;
845
882
  var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
846
883
 
847
884
  // src/api-keys.ts
848
- var import_zod11 = require("zod");
849
- var CreateApiKeySchema = import_zod11.z.object({
850
- name: import_zod11.z.string().min(1).max(64).describe(
885
+ var import_zod12 = require("zod");
886
+ var CreateApiKeySchema = import_zod12.z.object({
887
+ name: import_zod12.z.string().min(1).max(64).describe(
851
888
  'A label to help you tell keys apart (e.g. `"production backend"`). Not used for anything functional.'
852
889
  ),
853
890
  environment: EnvironmentSchema.describe(
854
891
  "`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."
855
892
  )
856
893
  });
857
- var ApiKeySchema = import_zod11.z.object({
858
- id: import_zod11.z.string(),
859
- name: import_zod11.z.string(),
894
+ var ApiKeySchema = import_zod12.z.object({
895
+ id: import_zod12.z.string(),
896
+ name: import_zod12.z.string(),
860
897
  environment: EnvironmentSchema.describe(
861
898
  "`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."
862
899
  ),
863
- key: import_zod11.z.string().optional().describe(
900
+ key: import_zod12.z.string().optional().describe(
864
901
  "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."
865
902
  ),
866
- hint: import_zod11.z.string().describe(
903
+ hint: import_zod12.z.string().describe(
867
904
  "A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't."
868
905
  ),
869
- createdAt: import_zod11.z.string().datetime(),
870
- lastUsedAt: import_zod11.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
871
- createdByUserId: import_zod11.z.string().nullable().describe(
906
+ createdAt: import_zod12.z.string().datetime(),
907
+ lastUsedAt: import_zod12.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
908
+ createdByUserId: import_zod12.z.string().nullable().describe(
872
909
  "Which member of the organization created this key. `null` for a key created before this field existed."
873
910
  )
874
911
  });
@@ -876,93 +913,93 @@ var ListApiKeysSchema = PaginationQuerySchema;
876
913
  var PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema);
877
914
 
878
915
  // src/users.ts
879
- var import_zod12 = require("zod");
880
- var UserRoleSchema = import_zod12.z.enum(["owner", "admin", "member"]).describe(
916
+ var import_zod13 = require("zod");
917
+ var UserRoleSchema = import_zod13.z.enum(["owner", "admin", "member"]).describe(
881
918
  "`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`."
882
919
  );
883
- var UpdateUserRoleSchema = import_zod12.z.object({
920
+ var UpdateUserRoleSchema = import_zod13.z.object({
884
921
  role: UserRoleSchema
885
922
  });
886
- var UserSchema = import_zod12.z.object({
887
- id: import_zod12.z.string(),
888
- email: import_zod12.z.string(),
889
- name: import_zod12.z.string().nullable(),
923
+ var UserSchema = import_zod13.z.object({
924
+ id: import_zod13.z.string(),
925
+ email: import_zod13.z.string(),
926
+ name: import_zod13.z.string().nullable(),
890
927
  role: UserRoleSchema.describe("Your role within the organization this user was fetched from."),
891
- emailVerifiedAt: import_zod12.z.string().datetime().nullable().describe(
928
+ emailVerifiedAt: import_zod13.z.string().datetime().nullable().describe(
892
929
  "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."
893
930
  ),
894
- createdAt: import_zod12.z.string().datetime()
931
+ createdAt: import_zod13.z.string().datetime()
895
932
  });
896
933
  var ListUsersSchema = PaginationQuerySchema;
897
934
  var PaginatedUsersSchema = paginatedSchema(UserSchema);
898
935
 
899
936
  // src/auth.ts
900
- var import_zod13 = require("zod");
901
- var NormalizedEmailSchema = import_zod13.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
937
+ var import_zod14 = require("zod");
938
+ var NormalizedEmailSchema = import_zod14.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
902
939
  "Trimmed, lowercased, and NFC-normalized server-side before use \u2014 case/whitespace don't matter."
903
940
  );
904
- var SignupSchema = import_zod13.z.object({
941
+ var SignupSchema = import_zod14.z.object({
905
942
  email: NormalizedEmailSchema,
906
- password: import_zod13.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
943
+ password: import_zod14.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
907
944
  });
908
- var LoginSchema = import_zod13.z.object({
945
+ var LoginSchema = import_zod14.z.object({
909
946
  email: NormalizedEmailSchema,
910
- password: import_zod13.z.string().min(1).max(128)
947
+ password: import_zod14.z.string().min(1).max(128)
911
948
  });
912
- var VerifyEmailSchema = import_zod13.z.object({
913
- token: import_zod13.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
949
+ var VerifyEmailSchema = import_zod14.z.object({
950
+ token: import_zod14.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
914
951
  });
915
- var ForgotPasswordSchema = import_zod13.z.object({
952
+ var ForgotPasswordSchema = import_zod14.z.object({
916
953
  email: NormalizedEmailSchema
917
954
  });
918
- var ResetPasswordSchema = import_zod13.z.object({
919
- token: import_zod13.z.string().min(1).describe("The token from the password reset email."),
920
- newPassword: import_zod13.z.string().min(8).max(128)
955
+ var ResetPasswordSchema = import_zod14.z.object({
956
+ token: import_zod14.z.string().min(1).describe("The token from the password reset email."),
957
+ newPassword: import_zod14.z.string().min(8).max(128)
921
958
  });
922
- var MessageResponseSchema = import_zod13.z.object({
923
- message: import_zod13.z.string().describe("Human-readable confirmation, safe to show a user directly.")
959
+ var MessageResponseSchema = import_zod14.z.object({
960
+ message: import_zod14.z.string().describe("Human-readable confirmation, safe to show a user directly.")
924
961
  });
925
962
  var SelfUserSchema = UserSchema.omit({ createdAt: true, role: true });
926
- var AuthResponseSchema = import_zod13.z.object({
927
- token: import_zod13.z.string().describe(
963
+ var AuthResponseSchema = import_zod14.z.object({
964
+ token: import_zod14.z.string().describe(
928
965
  "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."
929
966
  ),
930
967
  user: SelfUserSchema
931
968
  });
932
- var ChangeNameSchema = import_zod13.z.object({
933
- name: import_zod13.z.string().min(1).max(255).describe("Your display name.")
969
+ var ChangeNameSchema = import_zod14.z.object({
970
+ name: import_zod14.z.string().min(1).max(255).describe("Your display name.")
934
971
  });
935
- var ChangePasswordSchema = import_zod13.z.object({
936
- currentPassword: import_zod13.z.string().min(1).max(128),
937
- newPassword: import_zod13.z.string().min(8).max(128)
972
+ var ChangePasswordSchema = import_zod14.z.object({
973
+ currentPassword: import_zod14.z.string().min(1).max(128),
974
+ newPassword: import_zod14.z.string().min(8).max(128)
938
975
  });
939
- var ChangeEmailSchema = import_zod13.z.object({
940
- currentPassword: import_zod13.z.string().min(1).max(128),
976
+ var ChangeEmailSchema = import_zod14.z.object({
977
+ currentPassword: import_zod14.z.string().min(1).max(128),
941
978
  newEmail: NormalizedEmailSchema
942
979
  });
943
- var ConfirmEmailChangeSchema = import_zod13.z.object({
944
- token: import_zod13.z.string().min(1).describe("The token from the confirmation email sent to your current address.")
980
+ var ConfirmEmailChangeSchema = import_zod14.z.object({
981
+ token: import_zod14.z.string().min(1).describe("The token from the confirmation email sent to your current address.")
945
982
  });
946
983
 
947
984
  // src/organization.ts
948
- var import_zod14 = require("zod");
949
- var UpdateOrganizationSchema = import_zod14.z.object({
950
- name: import_zod14.z.string().min(1).max(255).optional().describe("The organization's display name."),
951
- payoutAddress: import_zod14.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
985
+ var import_zod15 = require("zod");
986
+ var UpdateOrganizationSchema = import_zod15.z.object({
987
+ name: import_zod15.z.string().min(1).max(255).optional().describe("The organization's display name."),
988
+ payoutAddress: import_zod15.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
952
989
  "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."
953
990
  )
954
991
  });
955
- var OrganizationSchema = import_zod14.z.object({
956
- id: import_zod14.z.string(),
957
- name: import_zod14.z.string(),
958
- payoutAddress: import_zod14.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
959
- currentFeePercent: import_zod14.z.number().describe(
992
+ var OrganizationSchema = import_zod15.z.object({
993
+ id: import_zod15.z.string(),
994
+ name: import_zod15.z.string(),
995
+ payoutAddress: import_zod15.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
996
+ currentFeePercent: import_zod15.z.number().describe(
960
997
  "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."
961
998
  ),
962
- feeUpdatedAt: import_zod14.z.string().datetime().nullable().describe(
999
+ feeUpdatedAt: import_zod15.z.string().datetime().nullable().describe(
963
1000
  "When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up."
964
1001
  ),
965
- createdAt: import_zod14.z.string().datetime()
1002
+ createdAt: import_zod15.z.string().datetime()
966
1003
  });
967
1004
  var OrganizationWithRoleSchema = OrganizationSchema.extend({
968
1005
  role: UserRoleSchema.describe("Your own role within this specific organization.")
@@ -971,50 +1008,51 @@ var PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema);
971
1008
  var ListOrganizationsSchema = PaginationQuerySchema;
972
1009
 
973
1010
  // src/invitations.ts
974
- var import_zod15 = require("zod");
975
- var InviteUserSchema = import_zod15.z.object({
1011
+ var import_zod16 = require("zod");
1012
+ var InviteUserSchema = import_zod16.z.object({
976
1013
  email: NormalizedEmailSchema,
977
1014
  role: UserRoleSchema.default("member").describe(
978
1015
  "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`."
979
1016
  )
980
1017
  });
981
- var AcceptInvitationSchema = import_zod15.z.object({
982
- token: import_zod15.z.string().min(1).describe("The token from the invitation email."),
983
- password: import_zod15.z.string().min(8).max(128).optional().describe(
1018
+ var AcceptInvitationSchema = import_zod16.z.object({
1019
+ token: import_zod16.z.string().min(1).describe("The token from the invitation email."),
1020
+ password: import_zod16.z.string().min(8).max(128).optional().describe(
984
1021
  "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."
985
1022
  )
986
1023
  });
987
- var InvitationSchema = import_zod15.z.object({
988
- id: import_zod15.z.string(),
989
- organizationId: import_zod15.z.string(),
990
- email: import_zod15.z.string(),
1024
+ var InvitationSchema = import_zod16.z.object({
1025
+ id: import_zod16.z.string(),
1026
+ organizationId: import_zod16.z.string(),
1027
+ email: import_zod16.z.string(),
991
1028
  role: UserRoleSchema,
992
- invitedByUserId: import_zod15.z.string().describe("Which member of the organization sent this invitation."),
993
- expiresAt: import_zod15.z.string().datetime(),
994
- createdAt: import_zod15.z.string().datetime()
1029
+ invitedByUserId: import_zod16.z.string().describe("Which member of the organization sent this invitation."),
1030
+ expiresAt: import_zod16.z.string().datetime(),
1031
+ createdAt: import_zod16.z.string().datetime()
995
1032
  });
996
1033
 
997
1034
  // src/timeline.ts
998
- var import_zod16 = require("zod");
999
- var TransactionSourceSchema = import_zod16.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
1035
+ var import_zod17 = require("zod");
1036
+ var TransactionSourceSchema = import_zod17.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
1000
1037
  "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)."
1001
1038
  );
1002
- var TimelineEventTypeSchema = import_zod16.z.enum([
1039
+ var TimelineEventTypeSchema = import_zod17.z.enum([
1003
1040
  "charge.created",
1004
1041
  "charge.expired",
1042
+ "charge.canceled",
1005
1043
  "transaction.detected",
1006
1044
  "split.distributed",
1007
1045
  "webhook.dispatched",
1008
1046
  "webhook.delivered",
1009
1047
  "webhook.failed"
1010
1048
  ]).describe(
1011
- "`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)."
1049
+ "`charge.created`: the charge was created. `charge.expired`: `expiresAt` passed with no full payment. `charge.canceled`: the merchant explicitly canceled it via `POST /v1/charges/{id}/cancel`. `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)."
1012
1050
  );
1013
- var TimelineEventSchema = import_zod16.z.object({
1051
+ var TimelineEventSchema = import_zod17.z.object({
1014
1052
  type: TimelineEventTypeSchema,
1015
- at: import_zod16.z.string().datetime(),
1016
- txHash: import_zod16.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
1017
- amount: import_zod16.z.number().optional().describe(
1053
+ at: import_zod17.z.string().datetime(),
1054
+ txHash: import_zod17.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
1055
+ amount: import_zod17.z.number().optional().describe(
1018
1056
  "Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
1019
1057
  ),
1020
1058
  source: TransactionSourceSchema.optional().describe(
@@ -1026,66 +1064,20 @@ var TimelineEventSchema = import_zod16.z.object({
1026
1064
  network: NetworkSchema.optional().describe(
1027
1065
  "Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
1028
1066
  ),
1029
- causedTransition: import_zod16.z.boolean().optional().describe(
1067
+ causedTransition: import_zod17.z.boolean().optional().describe(
1030
1068
  "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."
1031
1069
  ),
1032
1070
  event: WebhookEventTypeSchema.optional().describe(
1033
1071
  "Present for `webhook.*` events only \u2014 which event type this delivery was for."
1034
1072
  ),
1035
- responseCode: import_zod16.z.number().nullable().optional().describe(
1073
+ responseCode: import_zod17.z.number().nullable().optional().describe(
1036
1074
  "Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
1037
1075
  ),
1038
- attempts: import_zod16.z.number().optional().describe(
1076
+ attempts: import_zod17.z.number().optional().describe(
1039
1077
  "Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
1040
1078
  )
1041
1079
  });
1042
1080
 
1043
- // src/verify.ts
1044
- var import_zod17 = require("zod");
1045
- var SplitRecipientRoleSchema = import_zod17.z.enum(["merchant", "klap_fee", "distributor_incentive"]).describe(
1046
- "`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`."
1047
- );
1048
- var VerifySplitEntrySchema = import_zod17.z.object({
1049
- role: SplitRecipientRoleSchema,
1050
- address: import_zod17.z.string().nullable().describe(
1051
- "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."
1052
- ),
1053
- percentAllocation: import_zod17.z.number().describe("This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%)."),
1054
- amountUSD: import_zod17.z.number()
1055
- });
1056
- var VerifyPaymentSchema = import_zod17.z.object({
1057
- token: TokenSchema,
1058
- network: NetworkSchema,
1059
- amountReceived: import_zod17.z.number().describe("Cumulative amount received on this specific `(token, network)` pair."),
1060
- txHash: import_zod17.z.string().describe("The on-chain transaction hash of the most recent transfer on this pair."),
1061
- explorerTxUrl: import_zod17.z.string().describe("Direct link to `txHash` on the relevant block explorer."),
1062
- split: import_zod17.z.array(VerifySplitEntrySchema).describe(
1063
- "The exact breakdown of where this pair's payment went \u2014 merchant's share, Klappay's fee, and (once settled) the settlement incentive."
1064
- ),
1065
- splitTxHash: import_zod17.z.string().nullable().describe(
1066
- "Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then."
1067
- ),
1068
- settledAt: import_zod17.z.string().datetime().nullable().describe(
1069
- "When settlement completed for this pair \u2014 the merchant's wallet actually has the funds. `null` until then."
1070
- )
1071
- });
1072
- var VerifyChargeSchema = import_zod17.z.object({
1073
- id: import_zod17.z.string(),
1074
- amount: import_zod17.z.number().nullable().describe("The amount originally requested. `null` if the charge accepted any amount."),
1075
- amountReceived: import_zod17.z.number().describe(
1076
- "The actual cumulative amount received across every contributing pair \u2014 can exceed `amount` on an overpayment."
1077
- ),
1078
- confirmedAt: import_zod17.z.string().datetime().nullable().describe(
1079
- "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."
1080
- ),
1081
- splitAddress: import_zod17.z.string().describe(
1082
- "The on-chain address the payment was sent to \u2014 identical across every accepted network."
1083
- ),
1084
- payments: import_zod17.z.array(VerifyPaymentSchema).describe(
1085
- "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."
1086
- )
1087
- });
1088
-
1089
1081
  // src/health.ts
1090
1082
  var import_zod18 = require("zod");
1091
1083
  var HealthSchema = import_zod18.z.object({
@@ -1140,7 +1132,6 @@ var CapabilitiesSchema = import_zod20.z.object({
1140
1132
  ChangePasswordSchema,
1141
1133
  ChargeModeSchema,
1142
1134
  ChargeSchema,
1143
- ChargeStatusEventSchema,
1144
1135
  ChargeStatusSchema,
1145
1136
  ChargeWebhookEventTypeSchema,
1146
1137
  ChargesDateFieldSchema,
@@ -1159,6 +1150,7 @@ var CapabilitiesSchema = import_zod20.z.object({
1159
1150
  ErrorPayloadSchema,
1160
1151
  ForgotPasswordSchema,
1161
1152
  GetChargeQrCodeQuerySchema,
1153
+ GetPublicChargeQuerySchema,
1162
1154
  HealthSchema,
1163
1155
  InvitationSchema,
1164
1156
  InviteUserSchema,
@@ -1167,6 +1159,7 @@ var CapabilitiesSchema = import_zod20.z.object({
1167
1159
  ListOrganizationsSchema,
1168
1160
  ListUsersSchema,
1169
1161
  ListWebhookDeliveriesSchema,
1162
+ ListenPendingDistributionsQuerySchema,
1170
1163
  LoginSchema,
1171
1164
  MAX_METRICS_QUERY_DATE_RANGE_DAYS,
1172
1165
  METRICS_QUERY_DEFAULT_ROW_LIMIT,
@@ -1197,12 +1190,14 @@ var CapabilitiesSchema = import_zod20.z.object({
1197
1190
  PaginatedApiKeysSchema,
1198
1191
  PaginatedChargesSchema,
1199
1192
  PaginatedOrganizationsSchema,
1193
+ PaginatedPendingDistributionsSchema,
1200
1194
  PaginatedUsersSchema,
1201
1195
  PaginatedWebhookDeliveriesSchema,
1202
1196
  PaginationQuerySchema,
1203
1197
  PendingDistributionEventSchema,
1204
1198
  PendingDistributionRecipientSchema,
1205
1199
  PendingDistributionSchema,
1200
+ PublicChargeSchema,
1206
1201
  ResetPasswordSchema,
1207
1202
  SandboxEventTriggerSchema,
1208
1203
  SandboxTriggerSchema,
@@ -1211,7 +1206,6 @@ var CapabilitiesSchema = import_zod20.z.object({
1211
1206
  SettlementStatusSchema,
1212
1207
  SignupSchema,
1213
1208
  SplitDistributionStatusSchema,
1214
- SplitRecipientRoleSchema,
1215
1209
  TOKEN_ADDRESSES,
1216
1210
  TOKEN_DECIMALS,
1217
1211
  TimelineEventSchema,
@@ -1226,10 +1220,7 @@ var CapabilitiesSchema = import_zod20.z.object({
1226
1220
  UpdateUserRoleSchema,
1227
1221
  UserRoleSchema,
1228
1222
  UserSchema,
1229
- VerifyChargeSchema,
1230
1223
  VerifyEmailSchema,
1231
- VerifyPaymentSchema,
1232
- VerifySplitEntrySchema,
1233
1224
  WEBHOOK_EVENTS_WILDCARD,
1234
1225
  WEBHOOK_EVENT_CATEGORIES,
1235
1226
  WebhookCategorySchema,