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