@klappay/types 1.1.2 → 2.0.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
@@ -20,28 +20,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- AcceptInvitationSchema: () => AcceptInvitationSchema,
23
+ API_KEY_SCOPES: () => API_KEY_SCOPES,
24
24
  AcceptedPaymentSchema: () => AcceptedPaymentSchema,
25
- AccountWebhookEventTypeSchema: () => AccountWebhookEventTypeSchema,
26
- ApiKeySchema: () => ApiKeySchema,
27
- AuthResponseSchema: () => AuthResponseSchema,
25
+ ApiKeyScopeSchema: () => ApiKeyScopeSchema,
28
26
  CHARGE_ACCEPTED_PAYMENTS_MAX: () => CHARGE_ACCEPTED_PAYMENTS_MAX,
29
27
  CHARGE_AMOUNT_MAX: () => CHARGE_AMOUNT_MAX,
30
28
  CHARGE_EXPIRES_IN_MAX_SECONDS: () => CHARGE_EXPIRES_IN_MAX_SECONDS,
31
29
  CHARGE_EXPIRES_IN_MIN_SECONDS: () => CHARGE_EXPIRES_IN_MIN_SECONDS,
32
30
  CapabilitiesSchema: () => CapabilitiesSchema,
33
- ChangeEmailSchema: () => ChangeEmailSchema,
34
- ChangeNameSchema: () => ChangeNameSchema,
35
- ChangePasswordSchema: () => ChangePasswordSchema,
36
- ChargeModeSchema: () => ChargeModeSchema,
37
31
  ChargeSchema: () => ChargeSchema,
38
32
  ChargeStatusSchema: () => ChargeStatusSchema,
39
33
  ChargeWebhookEventTypeSchema: () => ChargeWebhookEventTypeSchema,
40
34
  ChargesDateFieldSchema: () => ChargesDateFieldSchema,
41
35
  ChargesMetricFieldSchema: () => ChargesMetricFieldSchema,
42
36
  ChargesQueryFieldSchema: () => ChargesQueryFieldSchema,
43
- ConfirmEmailChangeSchema: () => ConfirmEmailChangeSchema,
44
- CreateApiKeySchema: () => CreateApiKeySchema,
45
37
  CreateChargeSchema: () => CreateChargeSchema,
46
38
  CreateWebhookSchema: () => CreateWebhookSchema,
47
39
  DistributionsDateFieldSchema: () => DistributionsDateFieldSchema,
@@ -51,62 +43,40 @@ __export(index_exports, {
51
43
  EVM_NETWORKS: () => EVM_NETWORKS,
52
44
  EnvironmentSchema: () => EnvironmentSchema,
53
45
  ErrorPayloadSchema: () => ErrorPayloadSchema,
54
- ForgotPasswordSchema: () => ForgotPasswordSchema,
55
46
  GetChargeQrCodeQuerySchema: () => GetChargeQrCodeQuerySchema,
56
47
  HealthSchema: () => HealthSchema,
57
- InvitationSchema: () => InvitationSchema,
58
- InviteUserSchema: () => InviteUserSchema,
59
- ListApiKeysSchema: () => ListApiKeysSchema,
60
48
  ListChargesSchema: () => ListChargesSchema,
61
- ListOrganizationsSchema: () => ListOrganizationsSchema,
62
- ListUsersSchema: () => ListUsersSchema,
63
49
  ListWebhookDeliveriesSchema: () => ListWebhookDeliveriesSchema,
64
50
  ListenPendingDistributionsQuerySchema: () => ListenPendingDistributionsQuerySchema,
65
- LoginSchema: () => LoginSchema,
66
51
  MAX_METRICS_QUERY_DATE_RANGE_DAYS: () => MAX_METRICS_QUERY_DATE_RANGE_DAYS,
67
52
  METRICS_QUERY_DEFAULT_ROW_LIMIT: () => METRICS_QUERY_DEFAULT_ROW_LIMIT,
68
53
  METRICS_QUERY_MAX_FILTERS: () => METRICS_QUERY_MAX_FILTERS,
69
54
  METRICS_QUERY_MAX_GROUP_BY: () => METRICS_QUERY_MAX_GROUP_BY,
70
55
  METRICS_QUERY_MAX_METRICS: () => METRICS_QUERY_MAX_METRICS,
71
56
  METRICS_QUERY_MAX_ROW_LIMIT: () => METRICS_QUERY_MAX_ROW_LIMIT,
72
- MessageResponseSchema: () => MessageResponseSchema,
73
57
  MetricsAggregationSchema: () => MetricsAggregationSchema,
74
58
  MetricsDateGranularitySchema: () => MetricsDateGranularitySchema,
75
59
  MetricsFilterOperatorSchema: () => MetricsFilterOperatorSchema,
76
60
  MetricsQueryResultRowSchema: () => MetricsQueryResultRowSchema,
77
61
  MetricsQueryResultSchema: () => MetricsQueryResultSchema,
78
62
  MetricsQuerySchema: () => MetricsQuerySchema,
79
- MetricsQueryScopeSchema: () => MetricsQueryScopeSchema,
80
63
  MetricsResourceSchema: () => MetricsResourceSchema,
81
64
  NETWORK_EXPLORERS: () => NETWORK_EXPLORERS,
82
65
  NETWORK_LABELS: () => NETWORK_LABELS,
83
66
  NetworkSchema: () => NetworkSchema,
84
- NonChargeTriggerableEventSchema: () => NonChargeTriggerableEventSchema,
85
- NormalizedEmailSchema: () => NormalizedEmailSchema,
86
67
  OPERATIONAL_NETWORKS: () => OPERATIONAL_NETWORKS,
87
- OrganizationSchema: () => OrganizationSchema,
88
- OrganizationWithRoleSchema: () => OrganizationWithRoleSchema,
89
68
  PAGINATION_LIMIT_DEFAULT: () => PAGINATION_LIMIT_DEFAULT,
90
69
  PAGINATION_LIMIT_MAX: () => PAGINATION_LIMIT_MAX,
91
70
  PAGINATION_LIMIT_MIN: () => PAGINATION_LIMIT_MIN,
92
- PaginatedApiKeysSchema: () => PaginatedApiKeysSchema,
93
71
  PaginatedChargesSchema: () => PaginatedChargesSchema,
94
- PaginatedOrganizationsSchema: () => PaginatedOrganizationsSchema,
95
72
  PaginatedPendingDistributionsSchema: () => PaginatedPendingDistributionsSchema,
96
- PaginatedUsersSchema: () => PaginatedUsersSchema,
97
73
  PaginatedWebhookDeliveriesSchema: () => PaginatedWebhookDeliveriesSchema,
98
74
  PaginationQuerySchema: () => PaginationQuerySchema,
99
75
  PendingDistributionEventSchema: () => PendingDistributionEventSchema,
100
76
  PendingDistributionRecipientSchema: () => PendingDistributionRecipientSchema,
101
77
  PendingDistributionSchema: () => PendingDistributionSchema,
102
- PublicChargeSchema: () => PublicChargeSchema,
103
- ResetPasswordSchema: () => ResetPasswordSchema,
104
- SandboxEventTriggerSchema: () => SandboxEventTriggerSchema,
105
78
  SandboxTriggerSchema: () => SandboxTriggerSchema,
106
- SecurityWebhookEventTypeSchema: () => SecurityWebhookEventTypeSchema,
107
- SelfUserSchema: () => SelfUserSchema,
108
79
  SettlementStatusSchema: () => SettlementStatusSchema,
109
- SignupSchema: () => SignupSchema,
110
80
  SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
111
81
  TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
112
82
  TOKEN_DECIMALS: () => TOKEN_DECIMALS,
@@ -118,11 +88,6 @@ __export(index_exports, {
118
88
  TransactionsMetricFieldSchema: () => TransactionsMetricFieldSchema,
119
89
  TransactionsQueryFieldSchema: () => TransactionsQueryFieldSchema,
120
90
  TriggerableChargeEventSchema: () => TriggerableChargeEventSchema,
121
- UpdateOrganizationSchema: () => UpdateOrganizationSchema,
122
- UpdateUserRoleSchema: () => UpdateUserRoleSchema,
123
- UserRoleSchema: () => UserRoleSchema,
124
- UserSchema: () => UserSchema,
125
- VerifyEmailSchema: () => VerifyEmailSchema,
126
91
  WEBHOOK_EVENTS_WILDCARD: () => WEBHOOK_EVENTS_WILDCARD,
127
92
  WEBHOOK_EVENT_CATEGORIES: () => WEBHOOK_EVENT_CATEGORIES,
128
93
  WebhookCategorySchema: () => WebhookCategorySchema,
@@ -142,7 +107,7 @@ var import_zod = require("zod");
142
107
  var ErrorPayloadSchema = import_zod.z.object({
143
108
  error: import_zod.z.object({
144
109
  code: import_zod.z.string().describe(
145
- "A stable, machine-readable error identifier (e.g. `validation_error`, `invalid_credentials`)."
110
+ "A stable, machine-readable error identifier (e.g. `validation_error`, `charge_not_found`)."
146
111
  ),
147
112
  message: import_zod.z.string().describe(
148
113
  "Human-readable explanation, safe to log or show a developer \u2014 not meant for end users."
@@ -157,9 +122,27 @@ var EnvironmentSchema = import_zod2.z.enum(["live", "test"]).describe(
157
122
  "`live` or `test`, matching the `klap_live_.../klap_test_...` prefix of the API key that created or is scoped to this resource. `live` settles on Base mainnet with real funds; `test` settles on Base Sepolia, a separate testnet \u2014 real on-chain activity, but never real money."
158
123
  );
159
124
 
160
- // src/networks.ts
125
+ // src/api-key-scopes.ts
161
126
  var import_zod3 = require("zod");
162
- var NetworkSchema = import_zod3.z.enum(["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]).describe("The blockchain a charge/payment is on.");
127
+ var ApiKeyScopeSchema = import_zod3.z.enum([
128
+ "charges:read",
129
+ "charges:write",
130
+ "webhooks:read",
131
+ "webhooks:write",
132
+ "webhooks:manage_secret",
133
+ "metrics:read",
134
+ "metrics:charges:read",
135
+ "metrics:transactions:read",
136
+ "metrics:distributions:read",
137
+ "sandbox:trigger"
138
+ ]).describe(
139
+ "What an API key is allowed to do, independent of `tenantId`/`environment` (which scope *whose* data, not *what actions*). A key with none of these can still authenticate but every scoped route rejects it with `403 insufficient_scope`. `metrics:read` alone grants every metrics resource; `metrics:{resource}:read` grants only that one \u2014 a key can hold either or both."
140
+ );
141
+ var API_KEY_SCOPES = ApiKeyScopeSchema.options;
142
+
143
+ // src/networks.ts
144
+ var import_zod4 = require("zod");
145
+ var NetworkSchema = import_zod4.z.enum(["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]).describe("The blockchain a charge/payment is on.");
163
146
  var NETWORK_LABELS = {
164
147
  base: "Base",
165
148
  optimism: "Optimism",
@@ -198,29 +181,29 @@ var OPERATIONAL_NETWORKS = [
198
181
  ];
199
182
 
200
183
  // src/pagination.ts
201
- var import_zod4 = require("zod");
184
+ var import_zod5 = require("zod");
202
185
  var PAGINATION_LIMIT_MIN = 1;
203
186
  var PAGINATION_LIMIT_MAX = 100;
204
187
  var PAGINATION_LIMIT_DEFAULT = 20;
205
- var PaginationQuerySchema = import_zod4.z.object({
206
- limit: import_zod4.z.coerce.number().min(PAGINATION_LIMIT_MIN).max(PAGINATION_LIMIT_MAX).default(PAGINATION_LIMIT_DEFAULT).describe(
188
+ var PaginationQuerySchema = import_zod5.z.object({
189
+ limit: import_zod5.z.coerce.number().min(PAGINATION_LIMIT_MIN).max(PAGINATION_LIMIT_MAX).default(PAGINATION_LIMIT_DEFAULT).describe(
207
190
  `Max items to return per page (${PAGINATION_LIMIT_MIN}\u2013${PAGINATION_LIMIT_MAX}, default ${PAGINATION_LIMIT_DEFAULT}).`
208
191
  ),
209
- cursor: import_zod4.z.string().max(500).optional().describe(
192
+ cursor: import_zod5.z.string().max(500).optional().describe(
210
193
  "Opaque \u2014 pass the previous response's `nextCursor` verbatim to fetch the next page. Never construct or parse this value yourself; its shape is not part of the public contract and may change."
211
194
  )
212
195
  });
213
196
  function paginatedSchema(itemSchema) {
214
- return import_zod4.z.object({
215
- data: import_zod4.z.array(itemSchema),
216
- nextCursor: import_zod4.z.string().nullable().describe("Pass as `cursor` to fetch the next page. `null` when there are no more results."),
217
- hasMore: import_zod4.z.boolean()
197
+ return import_zod5.z.object({
198
+ data: import_zod5.z.array(itemSchema),
199
+ nextCursor: import_zod5.z.string().nullable().describe("Pass as `cursor` to fetch the next page. `null` when there are no more results."),
200
+ hasMore: import_zod5.z.boolean()
218
201
  });
219
202
  }
220
203
 
221
204
  // src/tokens.ts
222
- var import_zod5 = require("zod");
223
- var TokenSchema = import_zod5.z.enum(["USDC", "USDT"]).describe(
205
+ var import_zod6 = require("zod");
206
+ var TokenSchema = import_zod6.z.enum(["USDC", "USDT"]).describe(
224
207
  `Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 not every token/network/environment combination is deployed; today, both \`USDC\` and \`USDT\` are deployed on every operational network's \`live\` side except BNB Chain (\`${OPERATIONAL_NETWORKS.join(", ")}\`), but \`test\` coverage varies per network \u2014 Base, Optimism, and Ethereum each have a \`test\` environment (\`USDC\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \`422 token_not_supported\`, not silently accepted. **BNB Chain's \`USDC\` address is Binance-Peg USDC, not an official Circle deployment** \u2014 Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \`TOKEN_ADDRESSES\` entry (all verified directly against their real issuer). Accepted at the payer's own risk \u2014 Klappay does not verify or guarantee Binance's collateral backing it. \`USDT\` on BNB Chain is Tether's own official issuance, same trust model as everywhere else. More tokens/networks are expected to be added over time \u2014 check \`TOKEN_ADDRESSES\` in \`@klappay/types\` (or a future \`GET /v1/networks\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`
225
208
  );
226
209
  var TOKEN_DECIMALS = 6;
@@ -255,30 +238,27 @@ var TOKEN_ADDRESSES = {
255
238
  };
256
239
 
257
240
  // src/charges.ts
258
- var import_zod6 = require("zod");
259
- var ChargeStatusSchema = import_zod6.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid", "canceled"]).describe(
260
- "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."
241
+ var import_zod7 = require("zod");
242
+ var ChargeStatusSchema = import_zod7.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid"]).describe(
243
+ "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`. Every status is reached automatically, on its own timeline \u2014 there is no merchant-initiated cancellation. This never reflects whether funds actually reached the merchant \u2014 see `settlementStatus` for that."
261
244
  );
262
- var SettlementStatusSchema = import_zod6.z.enum(["pending", "completed", "failed"]).describe(
245
+ var SettlementStatusSchema = import_zod7.z.enum(["pending", "completed", "failed"]).describe(
263
246
  "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."
264
247
  );
265
- var ChargeModeSchema = import_zod6.z.enum(["standard", "continuous"]).describe(
266
- "`standard` (default): the usual lifecycle \u2014 accumulates transfers toward one resolution (`confirmed`/`expired`/`underpaid`), settles once. `continuous`: never resolves \u2014 `status` stays `pending` for the charge's entire life, and every credited transfer settles independently instead of accumulating toward one confirmation (see `charge.contribution_received`/`charge.contribution_settled`). Requires both `amount` and `expiresIn` to be omitted \u2014 there's no goal to accumulate toward and no deadline for something meant to run indefinitely (a link in a creator's bio, a permanent collection address). Not inferred from omitting those two fields \u2014 an explicit, deliberate choice, since silently changing a charge's entire settlement lifecycle based on which optional fields happened to be left out would be a footgun."
267
- );
268
248
  var CHARGE_EXPIRES_IN_MIN_SECONDS = 60;
269
- var CHARGE_EXPIRES_IN_MAX_SECONDS = 365 * 24 * 60 * 60;
249
+ var CHARGE_EXPIRES_IN_MAX_SECONDS = 3600;
270
250
  var CHARGE_ACCEPTED_PAYMENTS_MAX = 14;
271
- var AcceptedPaymentSchema = import_zod6.z.object({
251
+ var AcceptedPaymentSchema = import_zod7.z.object({
272
252
  token: TokenSchema,
273
253
  network: NetworkSchema
274
254
  });
275
- var AcceptedPaymentsSchema = import_zod6.z.array(AcceptedPaymentSchema).min(1, "At least one accepted payment is required.").max(CHARGE_ACCEPTED_PAYMENTS_MAX).superRefine((pairs, ctx) => {
255
+ var AcceptedPaymentsSchema = import_zod7.z.array(AcceptedPaymentSchema).min(1, "At least one accepted payment is required.").max(CHARGE_ACCEPTED_PAYMENTS_MAX).superRefine((pairs, ctx) => {
276
256
  const seen = /* @__PURE__ */ new Set();
277
257
  pairs.forEach((pair, index) => {
278
258
  const key = `${pair.token}:${pair.network}`;
279
259
  if (seen.has(key)) {
280
260
  ctx.addIssue({
281
- code: import_zod6.z.ZodIssueCode.custom,
261
+ code: import_zod7.z.ZodIssueCode.custom,
282
262
  message: `Duplicate accepted payment: ${pair.token} on ${pair.network}.`,
283
263
  path: [index]
284
264
  });
@@ -286,7 +266,7 @@ var AcceptedPaymentsSchema = import_zod6.z.array(AcceptedPaymentSchema).min(1, "
286
266
  seen.add(key);
287
267
  if (!OPERATIONAL_NETWORKS.includes(pair.network)) {
288
268
  ctx.addIssue({
289
- code: import_zod6.z.ZodIssueCode.custom,
269
+ code: import_zod7.z.ZodIssueCode.custom,
290
270
  message: `Network "${pair.network}" isn't live yet \u2014 only ${OPERATIONAL_NETWORKS.join(", ")} today.`,
291
271
  path: [index, "network"]
292
272
  });
@@ -296,88 +276,70 @@ var AcceptedPaymentsSchema = import_zod6.z.array(AcceptedPaymentSchema).min(1, "
296
276
  `Every \`(token, network)\` pair the payer is allowed to pay with \u2014 at least one, up to ${CHARGE_ACCEPTED_PAYMENTS_MAX}. This list is also the only restriction knob: the payer can use any combination of the pairs listed here, and every transfer on one of them is credited and sums toward the charge total (see \`paidWith\`) \u2014 e.g. a charge accepting USDC and USDT can be confirmed by $9 in USDC plus $1 in USDT, or by USDC arriving on two different accepted networks. To require payment in one specific token on one specific network, list only that single pair \u2014 a transfer on any pair not in this list is still recorded (for audit) but never credited. Each network must be live (see \`GET /v1/networks\` for the current matrix) \u2014 an unconfigured \`(token, network)\` combination for your environment is rejected with \`422 token_not_supported\`.`
297
277
  );
298
278
  var CHARGE_AMOUNT_MAX = 999999999999;
299
- var CreateChargeSchema = import_zod6.z.object({
300
- mode: ChargeModeSchema.default("standard"),
301
- amount: import_zod6.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
302
- "Amount to charge, in `currency` units (e.g. `49.9` = $49.90) \u2014 up to 6 decimal places; anything more precise is silently truncated. Omit entirely for a charge that accepts any amount \u2014 the first credited transfer of any size confirms it, and `isOverpaid` never applies (there is no target to exceed)."
279
+ var CreateChargeSchema = import_zod7.z.object({
280
+ amount: import_zod7.z.number().positive().max(CHARGE_AMOUNT_MAX).describe(
281
+ "Amount to charge, in `currency` units (e.g. `49.9` = $49.90) \u2014 up to 6 decimal places; anything more precise is silently truncated. Required \u2014 every charge has a target amount, the first credited transfer that reaches it confirms the charge."
303
282
  ),
304
- currency: import_zod6.z.literal("USD").default("USD").describe("Always `USD` today \u2014 the only supported currency."),
283
+ currency: import_zod7.z.literal("USD").default("USD").describe("Always `USD` today \u2014 the only supported currency."),
305
284
  acceptedPayments: AcceptedPaymentsSchema,
306
- expiresIn: import_zod6.z.number().int().min(CHARGE_EXPIRES_IN_MIN_SECONDS).max(CHARGE_EXPIRES_IN_MAX_SECONDS).optional().describe(
307
- "Seconds, not minutes or milliseconds \u2014 how long the charge stays open, min 60, max 31,536,000 = 365 days. Omit entirely for a charge that never expires (`expiresAt` is `null`) \u2014 useful for donations, investments, or any charge with no natural deadline. Cannot be extended or shortened after creation either way."
285
+ expiresIn: import_zod7.z.number().int().min(CHARGE_EXPIRES_IN_MIN_SECONDS).max(CHARGE_EXPIRES_IN_MAX_SECONDS).describe(
286
+ "Seconds, not minutes or milliseconds \u2014 how long the charge stays open before it expires. Required, min 60, max 3600 (60 minutes) \u2014 sized off the slowest chain Klappay supports today (Ethereum mainnet, where a safely-confirmed transfer takes up to ~15 minutes), leaving real margin for payer-side delay (gas spikes, wallet friction) on top of that. Cannot be extended or shortened after creation."
308
287
  ),
309
- idempotencyKey: import_zod6.z.string().min(1).max(255).optional().describe(
310
- "Scoped to your organization. Replaying the same key returns the original charge unchanged instead of creating a duplicate \u2014 safe to retry a request after a timeout without double-charging."
288
+ idempotencyKey: import_zod7.z.string().min(1).max(255).optional().describe(
289
+ "Scoped to your tenant. Replaying the same key returns the original charge unchanged instead of creating a duplicate \u2014 safe to retry a request after a timeout without double-charging."
311
290
  ),
312
- externalRef: import_zod6.z.string().min(1).max(255).optional().describe(
291
+ externalRef: import_zod7.z.string().min(1).max(255).optional().describe(
313
292
  "An opaque correlation id from your own system (e.g. an order id) \u2014 echoed back on the charge and in every webhook payload. Not interpreted or validated by Klappay."
314
293
  ),
315
- source: import_zod6.z.string().min(1).max(64).optional().describe(
294
+ source: import_zod7.z.string().min(1).max(64).optional().describe(
316
295
  'Free-form label for what created this charge (e.g. `"checkout"`, `"invoice"`) \u2014 useful if you create charges from more than one flow and want to tell them apart later. Not a fixed enum; use whatever values make sense to you.'
317
296
  ),
318
- metadata: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional().describe("Arbitrary key/value data to attach to the charge, returned as-is on every read.")
319
- }).superRefine((input, ctx) => {
320
- if (input.mode === "continuous" && (input.amount !== void 0 || input.expiresIn !== void 0)) {
321
- ctx.addIssue({
322
- code: import_zod6.z.ZodIssueCode.custom,
323
- message: 'mode: "continuous" requires both amount and expiresIn to be omitted.',
324
- path: ["mode"]
325
- });
326
- }
297
+ metadata: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).optional().describe("Arbitrary key/value data to attach to the charge, returned as-is on every read.")
327
298
  });
328
- var ChargeSchema = import_zod6.z.object({
329
- id: import_zod6.z.string().describe("Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later."),
330
- mode: ChargeModeSchema,
331
- amount: import_zod6.z.number().nullable().describe(
332
- "The amount originally requested, in `currency` units (up to 6 decimal places). `null` if `amount` was omitted at creation \u2014 this charge accepts any amount, and the first credited transfer confirms it."
333
- ),
334
- amountReceived: import_zod6.z.number().nullable().describe(
335
- "Cumulative amount actually received on-chain so far, in `currency` units (up to 6 decimal places). `null` until the first transfer arrives. Can exceed `amount` \u2014 see `isOverpaid` \u2014 unless `amount` itself is `null`, in which case `isOverpaid` never applies."
299
+ var ChargeSchema = import_zod7.z.object({
300
+ id: import_zod7.z.string().describe("Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later."),
301
+ amount: import_zod7.z.number().describe("The amount originally requested, in `currency` units (up to 6 decimal places)."),
302
+ amountReceived: import_zod7.z.number().nullable().describe(
303
+ "Cumulative amount actually received on-chain so far, in `currency` units (up to 6 decimal places). `null` until the first transfer arrives. Can exceed `amount` \u2014 see `isOverpaid`."
336
304
  ),
337
- isOverpaid: import_zod6.z.boolean().describe(
305
+ isOverpaid: import_zod7.z.boolean().describe(
338
306
  "`true` if `amountReceived` ended up greater than `amount`. Klappay never refunds the difference automatically \u2014 see the docs for why."
339
307
  ),
340
- currency: import_zod6.z.string().describe("Always `USD` today \u2014 the only supported currency."),
341
- acceptedPayments: import_zod6.z.array(AcceptedPaymentSchema).describe(
308
+ currency: import_zod7.z.string().describe("Always `USD` today \u2014 the only supported currency."),
309
+ acceptedPayments: import_zod7.z.array(AcceptedPaymentSchema).describe(
342
310
  "Every `(token, network)` pair this charge was configured to accept, unchanged after creation."
343
311
  ),
344
- paidWith: import_zod6.z.array(AcceptedPaymentSchema).describe(
312
+ paidWith: import_zod7.z.array(AcceptedPaymentSchema).describe(
345
313
  "Every distinct `(token, network)` pair that has actually contributed a credited transfer so far \u2014 empty until the first one arrives. Can hold more than one entry: a charge accepting several pairs can be paid across a combination of them, and every entry here sums toward `amountReceived`."
346
314
  ),
347
- address: import_zod6.z.string().describe(
315
+ address: import_zod7.z.string().describe(
348
316
  "The on-chain address the payer must send funds to \u2014 identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time \u2014 funds sent here go directly to the merchant, Klappay never custodies them."
349
317
  ),
350
318
  status: ChargeStatusSchema,
351
319
  settlementStatus: SettlementStatusSchema.nullable(),
352
320
  environment: EnvironmentSchema,
353
- apiKeyId: import_zod6.z.string().nullable().describe(
321
+ apiKeyId: import_zod7.z.string().nullable().describe(
354
322
  "Which of your API keys created this charge. `null` for a charge created before this field existed."
355
323
  ),
356
- txHash: import_zod6.z.string().nullable().describe(
324
+ txHash: import_zod7.z.string().nullable().describe(
357
325
  "Transaction hash of the most recent transfer detected for this charge. `null` until a payment is detected."
358
326
  ),
359
- externalRef: import_zod6.z.string().nullable(),
360
- source: import_zod6.z.string().nullable(),
361
- metadata: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).nullable(),
362
- createdAt: import_zod6.z.string().datetime(),
363
- expiresAt: import_zod6.z.string().datetime().nullable().describe(
364
- "When this charge stops accepting payment, if still `pending`/`partially_paid` by then. `null` if `expiresIn` was omitted at creation \u2014 the charge never expires on its own and must be dealt with manually (or left open indefinitely)."
327
+ externalRef: import_zod7.z.string().nullable(),
328
+ source: import_zod7.z.string().nullable(),
329
+ metadata: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).nullable(),
330
+ createdAt: import_zod7.z.string().datetime(),
331
+ expiresAt: import_zod7.z.string().datetime().describe(
332
+ "When this charge stops accepting payment, if still `pending`/`partially_paid` by then."
365
333
  ),
366
- confirmedAt: import_zod6.z.string().datetime().nullable().describe("When `status` first reached `confirmed`. `null` until then."),
367
- settledAt: import_zod6.z.string().datetime().nullable().describe(
334
+ confirmedAt: import_zod7.z.string().datetime().nullable().describe("When `status` first reached `confirmed`. `null` until then."),
335
+ settledAt: import_zod7.z.string().datetime().nullable().describe(
368
336
  "When `settlementStatus` first reached `completed` \u2014 the merchant's wallet actually has the funds. `null` until then, including while `settlementStatus` is `pending`/`failed`."
369
337
  ),
370
- lastActivityAt: import_zod6.z.string().datetime().describe(
371
- "When a transfer was last credited toward this charge, or `createdAt` if none has arrived yet. Only meaningful for a charge with no `expiresAt` \u2014 see `pausedAt`."
372
- ),
373
- pausedAt: import_zod6.z.string().datetime().nullable().describe(
374
- "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."
375
- ),
376
- canceledAt: import_zod6.z.string().datetime().nullable().describe(
377
- "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."
338
+ lastActivityAt: import_zod7.z.string().datetime().describe(
339
+ "When a transfer was last credited toward this charge, or `createdAt` if none has arrived yet."
378
340
  )
379
341
  });
380
- var ListChargesSchema = import_zod6.z.object({
342
+ var ListChargesSchema = import_zod7.z.object({
381
343
  status: ChargeStatusSchema.optional(),
382
344
  token: TokenSchema.optional().describe(
383
345
  "Filters on `paidWith.token` \u2014 the pair actually paid, not accepted."
@@ -386,47 +348,19 @@ var ListChargesSchema = import_zod6.z.object({
386
348
  "Filters on `paidWith.network` \u2014 the pair actually paid, not accepted."
387
349
  ),
388
350
  environment: EnvironmentSchema.optional(),
389
- since: import_zod6.z.string().datetime().optional().describe(
351
+ since: import_zod7.z.string().datetime().optional().describe(
390
352
  "Only return charges created at or after this timestamp (filters on `createdAt`, not on when the status last changed). If polling as a fallback for missed webhooks, use a window at least as wide as the longest `expiresIn` your charges use, or you can miss a long-lived charge that changed status outside a narrower window."
391
353
  ),
392
- isOverpaid: import_zod6.z.enum(["true", "false"]).transform((v) => v === "true").optional()
354
+ isOverpaid: import_zod7.z.enum(["true", "false"]).transform((v) => v === "true").optional()
393
355
  }).extend(PaginationQuerySchema.shape);
394
356
  var PaginatedChargesSchema = paginatedSchema(ChargeSchema);
395
- var GetChargeQrCodeQuerySchema = import_zod6.z.object({
357
+ var GetChargeQrCodeQuerySchema = import_zod7.z.object({
396
358
  token: TokenSchema.optional().describe(
397
359
  "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."
398
360
  ),
399
361
  network: NetworkSchema.optional()
400
362
  });
401
363
 
402
- // src/public-charges.ts
403
- var import_zod7 = require("zod");
404
- var PublicChargeSchema = import_zod7.z.object({
405
- id: import_zod7.z.string(),
406
- mode: ChargeModeSchema,
407
- status: ChargeStatusSchema,
408
- settlementStatus: SettlementStatusSchema.nullable(),
409
- amount: import_zod7.z.number().nullable(),
410
- amountReceived: import_zod7.z.number().nullable(),
411
- isOverpaid: import_zod7.z.boolean(),
412
- currency: import_zod7.z.string(),
413
- acceptedPayments: import_zod7.z.array(AcceptedPaymentSchema),
414
- paidWith: import_zod7.z.array(AcceptedPaymentSchema),
415
- address: import_zod7.z.string(),
416
- environment: EnvironmentSchema,
417
- txHash: import_zod7.z.string().nullable(),
418
- metadata: import_zod7.z.record(import_zod7.z.unknown()).nullable().describe(
419
- "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."
420
- ),
421
- createdAt: import_zod7.z.string().datetime(),
422
- expiresAt: import_zod7.z.string().datetime().nullable(),
423
- confirmedAt: import_zod7.z.string().datetime().nullable(),
424
- settledAt: import_zod7.z.string().datetime().nullable(),
425
- lastActivityAt: import_zod7.z.string().datetime(),
426
- pausedAt: import_zod7.z.string().datetime().nullable(),
427
- canceledAt: import_zod7.z.string().datetime().nullable()
428
- });
429
-
430
364
  // src/distributions.ts
431
365
  var import_zod8 = require("zod");
432
366
  var SplitDistributionStatusSchema = import_zod8.z.enum(["pending", "processing", "completed", "failed"]).describe(
@@ -482,11 +416,11 @@ var MetricsAggregationSchema = import_zod9.z.enum(["count", "sum", "avg", "min",
482
416
  var MetricsFilterOperatorSchema = import_zod9.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
483
417
  "`in` expects an array value (max 50 entries); every other operator expects a single scalar."
484
418
  );
485
- var MetricsDateGranularitySchema = import_zod9.z.enum(["day", "week", "month"]).describe(
419
+ var MetricsDateGranularitySchema = import_zod9.z.enum(["day", "week", "month", "year"]).describe(
486
420
  "Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
487
421
  );
488
422
  var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
489
- "Which environment's data to query \u2014 `live` or `test`. Independent of your session (a dashboard user isn't scoped to one environment the way an API key is) \u2014 scopes the query to charges/transactions/distributions created under a `live` or `test` API key respectively."
423
+ "Which environment's data to query \u2014 `live` or `test`. Must match the environment of the API key used to authenticate \u2014 scopes the query to charges/transactions/distributions created under a `live` or `test` API key respectively."
490
424
  );
491
425
  var MAX_METRICS_QUERY_DATE_RANGE_DAYS = 366;
492
426
  var METRICS_QUERY_MAX_ROW_LIMIT = 1e3;
@@ -519,14 +453,14 @@ var orderBySchema = import_zod9.z.object({
519
453
  var limitSchema = import_zod9.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
520
454
  `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.`
521
455
  );
522
- var ChargesQueryFieldSchema = import_zod9.z.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
523
- "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."
456
+ var ChargesQueryFieldSchema = import_zod9.z.enum(["status", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
457
+ "A `Charge` field to filter or group by \u2014 see `ChargeStatusSchema` for `status`'s own possible values (charges.md). `source`/`externalRef` are free-form strings your own integration set at creation, not a fixed enum."
524
458
  );
525
459
  var ChargesMetricFieldSchema = import_zod9.z.enum(["amount", "amountReceived", "feePercent"]).describe(
526
460
  "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%."
527
461
  );
528
- var ChargesDateFieldSchema = import_zod9.z.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
529
- "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."
462
+ var ChargesDateFieldSchema = import_zod9.z.enum(["createdAt", "confirmedAt", "lastActivityAt", "expiresAt"]).describe(
463
+ "A `Charge` timestamp to filter/bucket by. `confirmedAt` is `null` until the charge reaches `confirmed` \u2014 a `dateRange`/`date_bucket` on it implicitly excludes every charge that never confirmed. `expiresAt` is always present (set at creation), useful for e.g. finding charges expiring soon or measuring how close to expiry charges typically resolve."
530
464
  );
531
465
  var ChargesFilterSchema = import_zod9.z.object({
532
466
  field: ChargesQueryFieldSchema,
@@ -597,14 +531,14 @@ var TransactionsMetricsQuerySchema = import_zod9.z.object({
597
531
  orderBy: orderBySchema.optional(),
598
532
  limit: limitSchema
599
533
  });
600
- var DistributionsQueryFieldSchema = import_zod9.z.enum(["status", "network", "token"]).describe(
601
- "A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values."
534
+ var DistributionsQueryFieldSchema = import_zod9.z.enum(["status", "network", "token", "distributorAddress"]).describe(
535
+ "A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values. `distributorAddress` is the public on-chain address that actually called `distribute()` for a `completed` distribution \u2014 Klappay's own operator address if settled by Klappay's own worker, a community keeper's address if settled externally (or `null` on the rare case that lookup failed), `null` for every non-`completed` status."
602
536
  );
603
537
  var DistributionsMetricFieldSchema = import_zod9.z.enum(["attempts"]).describe(
604
538
  "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."
605
539
  );
606
- var DistributionsDateFieldSchema = import_zod9.z.enum(["createdAt", "completedAt"]).describe(
607
- "`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."
540
+ var DistributionsDateFieldSchema = import_zod9.z.enum(["createdAt", "processingStartedAt", "completedAt"]).describe(
541
+ "`createdAt`: when this settlement was queued. `processingStartedAt`: when a worker began its most recent attempt at the payout \u2014 `null` until the first attempt, then overwritten on every subsequent retry, so it reflects the *latest* attempt's start, not the first. `completedAt`: when it actually paid out \u2014 `null` until `status` reaches `completed`, so a `dateRange`/`date_bucket` on it implicitly excludes every distribution still pending/processing/failed."
608
542
  );
609
543
  var DistributionsFilterSchema = import_zod9.z.object({
610
544
  field: DistributionsQueryFieldSchema,
@@ -701,15 +635,11 @@ var MetricsQueryResultRowSchema = import_zod9.z.record(
701
635
  import_zod9.z.string(),
702
636
  import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number(), import_zod9.z.boolean(), import_zod9.z.null()])
703
637
  );
704
- var MetricsQueryScopeSchema = import_zod9.z.enum(["owner_admin", "member"]).describe(
705
- "`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."
706
- );
707
638
  var MetricsQueryResultSchema = import_zod9.z.object({
708
639
  data: import_zod9.z.array(MetricsQueryResultRowSchema),
709
640
  meta: import_zod9.z.object({
710
641
  resource: MetricsResourceSchema,
711
642
  environment: EnvironmentSchema,
712
- scope: MetricsQueryScopeSchema,
713
643
  rowCount: import_zod9.z.number().int().describe("Number of rows in `data`."),
714
644
  truncated: import_zod9.z.boolean().describe(
715
645
  "`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
@@ -727,86 +657,43 @@ var ChargeWebhookEventTypeSchema = import_zod10.z.enum([
727
657
  "charge.underpaid",
728
658
  "charge.settled",
729
659
  "charge.settlement_failed",
730
- "charge.overpaid",
731
- "charge.paused",
732
- "charge.reactivated",
733
- "charge.contribution_received",
734
- "charge.contribution_settled",
735
- "charge.canceled",
736
- "charge.paid_after_cancel"
660
+ "charge.overpaid"
737
661
  ]).describe(
738
- '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 }`.'
739
- );
740
- var AccountWebhookEventTypeSchema = import_zod10.z.enum([
741
- "payout_address.changed",
742
- "api_key.created",
743
- "api_key.revoked",
744
- "webhook.created",
745
- "webhook.deleted",
746
- "webhook.secret_rotated",
747
- "fee_tier.updated",
748
- "member.removed",
749
- "member.role_changed",
750
- "member.invited"
751
- ]).describe(
752
- "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 }`."
662
+ '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`.'
753
663
  );
754
664
  var WebhookDeliveryEventTypeSchema = import_zod10.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
755
665
  "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`)."
756
666
  );
757
- var SecurityWebhookEventTypeSchema = import_zod10.z.enum([
758
- "auth.login",
759
- "auth.login_failed",
760
- "auth.suspicious_activity",
761
- "auth.email_verified",
762
- "auth.password_reset_requested",
763
- "auth.password_reset_completed",
764
- "auth.password_changed",
765
- "auth.email_change_requested",
766
- "auth.email_changed"
767
- ]).describe(
768
- "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 }`."
769
- );
770
667
  var WebhookEventTypeSchema = import_zod10.z.union([
771
668
  ChargeWebhookEventTypeSchema,
772
- AccountWebhookEventTypeSchema,
773
- WebhookDeliveryEventTypeSchema,
774
- SecurityWebhookEventTypeSchema
669
+ WebhookDeliveryEventTypeSchema
775
670
  ]);
776
- var WebhookCategorySchema = import_zod10.z.enum(["payments", "account", "webhooks", "security"]).describe(
671
+ var WebhookCategorySchema = import_zod10.z.enum(["payments", "webhooks"]).describe(
777
672
  "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."
778
673
  );
779
674
  function buildCategoryMap() {
780
675
  const map = {};
781
676
  for (const event of ChargeWebhookEventTypeSchema.options) map[event] = "payments";
782
- for (const event of AccountWebhookEventTypeSchema.options) map[event] = "account";
783
677
  for (const event of WebhookDeliveryEventTypeSchema.options) map[event] = "webhooks";
784
- for (const event of SecurityWebhookEventTypeSchema.options) map[event] = "security";
678
+ for (const event of WebhookEventTypeSchema.options.flatMap((schema) => schema.options)) {
679
+ if (!(event in map)) {
680
+ throw new Error(
681
+ `buildCategoryMap: "${event}" has no category \u2014 a new event sub-schema was unioned into WebhookEventTypeSchema without a matching loop added here.`
682
+ );
683
+ }
684
+ }
785
685
  return map;
786
686
  }
787
687
  var EVENT_CATEGORY_MAP = buildCategoryMap();
788
688
  var WEBHOOK_EVENT_CATEGORIES = {
789
689
  payments: ChargeWebhookEventTypeSchema.options,
790
- account: AccountWebhookEventTypeSchema.options,
791
- webhooks: WebhookDeliveryEventTypeSchema.options,
792
- security: SecurityWebhookEventTypeSchema.options
690
+ webhooks: WebhookDeliveryEventTypeSchema.options
793
691
  };
794
692
  var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
795
- "charge.created",
796
- "charge.paused",
797
- "charge.reactivated",
798
- "charge.contribution_received",
799
- "charge.contribution_settled",
800
- "charge.canceled",
801
- "charge.paid_after_cancel"
693
+ "charge.created"
802
694
  ]).describe(
803
- "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)."
695
+ "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)."
804
696
  );
805
- var NonChargeTriggerableEventSchema = import_zod10.z.union([
806
- AccountWebhookEventTypeSchema,
807
- WebhookDeliveryEventTypeSchema,
808
- SecurityWebhookEventTypeSchema
809
- ]);
810
697
 
811
698
  // src/webhooks.ts
812
699
  var import_zod11 = require("zod");
@@ -831,7 +718,7 @@ var CreateWebhookSchema = import_zod11.z.object({
831
718
  var WebhookSchema = import_zod11.z.object({
832
719
  id: import_zod11.z.string(),
833
720
  environment: EnvironmentSchema.nullable().describe(
834
- "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."
721
+ "Which environment's API key created this webhook \u2014 `live` or `test`. Every event is only ever delivered to a webhook whose `environment` matches the event's own (or to a webhook with `environment: null`, which receives every environment \u2014 the case for every webhook created before this field existed)."
835
722
  ),
836
723
  url: import_zod11.z.string(),
837
724
  events: import_zod11.z.array(WebhookEventTypeSchema),
@@ -853,7 +740,7 @@ var WebhookPayloadSchema = import_zod11.z.object({
853
740
  event: WebhookEventTypeSchema,
854
741
  createdAt: import_zod11.z.string().datetime(),
855
742
  data: import_zod11.z.unknown().describe(
856
- "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."
743
+ "Event-specific data. Charge events (`charge.*`) carry the full `Charge` object; webhook-delivery events carry a smaller, event-specific object \u2014 see `WebhookEventDataMap`/`TypedWebhookPayload` for the exact shape per event, or docs/webhooks.md."
857
744
  )
858
745
  });
859
746
  var WebhookDeliveryStatusSchema = import_zod11.z.enum(["pending", "delivered", "failed"]);
@@ -875,178 +762,27 @@ var WebhookDeliverySchema = import_zod11.z.object({
875
762
  var ListWebhookDeliveriesSchema = PaginationQuerySchema;
876
763
  var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
877
764
 
878
- // src/api-keys.ts
879
- var import_zod12 = require("zod");
880
- var CreateApiKeySchema = import_zod12.z.object({
881
- name: import_zod12.z.string().min(1).max(64).describe(
882
- 'A label to help you tell keys apart (e.g. `"production backend"`). Not used for anything functional.'
883
- ),
884
- environment: EnvironmentSchema.describe(
885
- "`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."
886
- )
887
- });
888
- var ApiKeySchema = import_zod12.z.object({
889
- id: import_zod12.z.string(),
890
- name: import_zod12.z.string(),
891
- environment: EnvironmentSchema.describe(
892
- "`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."
893
- ),
894
- key: import_zod12.z.string().optional().describe(
895
- "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."
896
- ),
897
- hint: import_zod12.z.string().describe(
898
- "A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't."
899
- ),
900
- createdAt: import_zod12.z.string().datetime(),
901
- lastUsedAt: import_zod12.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
902
- createdByUserId: import_zod12.z.string().nullable().describe(
903
- "Which member of the organization created this key. `null` for a key created before this field existed."
904
- )
905
- });
906
- var ListApiKeysSchema = PaginationQuerySchema;
907
- var PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema);
908
-
909
- // src/users.ts
910
- var import_zod13 = require("zod");
911
- var UserRoleSchema = import_zod13.z.enum(["owner", "admin", "member"]).describe(
912
- "`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`."
913
- );
914
- var UpdateUserRoleSchema = import_zod13.z.object({
915
- role: UserRoleSchema
916
- });
917
- var UserSchema = import_zod13.z.object({
918
- id: import_zod13.z.string(),
919
- email: import_zod13.z.string(),
920
- name: import_zod13.z.string().nullable(),
921
- role: UserRoleSchema.describe("Your role within the organization this user was fetched from."),
922
- emailVerifiedAt: import_zod13.z.string().datetime().nullable().describe(
923
- "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."
924
- ),
925
- createdAt: import_zod13.z.string().datetime()
926
- });
927
- var ListUsersSchema = PaginationQuerySchema;
928
- var PaginatedUsersSchema = paginatedSchema(UserSchema);
929
-
930
- // src/auth.ts
931
- var import_zod14 = require("zod");
932
- var NormalizedEmailSchema = import_zod14.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
933
- "Trimmed, lowercased, and NFC-normalized server-side before use \u2014 case/whitespace don't matter."
934
- );
935
- var SignupSchema = import_zod14.z.object({
936
- email: NormalizedEmailSchema,
937
- password: import_zod14.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
938
- });
939
- var LoginSchema = import_zod14.z.object({
940
- email: NormalizedEmailSchema,
941
- password: import_zod14.z.string().min(1).max(128)
942
- });
943
- var VerifyEmailSchema = import_zod14.z.object({
944
- token: import_zod14.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
945
- });
946
- var ForgotPasswordSchema = import_zod14.z.object({
947
- email: NormalizedEmailSchema
948
- });
949
- var ResetPasswordSchema = import_zod14.z.object({
950
- token: import_zod14.z.string().min(1).describe("The token from the password reset email."),
951
- newPassword: import_zod14.z.string().min(8).max(128)
952
- });
953
- var MessageResponseSchema = import_zod14.z.object({
954
- message: import_zod14.z.string().describe("Human-readable confirmation, safe to show a user directly.")
955
- });
956
- var SelfUserSchema = UserSchema.omit({ createdAt: true, role: true });
957
- var AuthResponseSchema = import_zod14.z.object({
958
- token: import_zod14.z.string().describe(
959
- "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."
960
- ),
961
- user: SelfUserSchema
962
- });
963
- var ChangeNameSchema = import_zod14.z.object({
964
- name: import_zod14.z.string().min(1).max(255).describe("Your display name.")
965
- });
966
- var ChangePasswordSchema = import_zod14.z.object({
967
- currentPassword: import_zod14.z.string().min(1).max(128),
968
- newPassword: import_zod14.z.string().min(8).max(128)
969
- });
970
- var ChangeEmailSchema = import_zod14.z.object({
971
- currentPassword: import_zod14.z.string().min(1).max(128),
972
- newEmail: NormalizedEmailSchema
973
- });
974
- var ConfirmEmailChangeSchema = import_zod14.z.object({
975
- token: import_zod14.z.string().min(1).describe("The token from the confirmation email sent to your current address.")
976
- });
977
-
978
- // src/organization.ts
979
- var import_zod15 = require("zod");
980
- var UpdateOrganizationSchema = import_zod15.z.object({
981
- name: import_zod15.z.string().min(1).max(255).optional().describe("The organization's display name."),
982
- payoutAddress: import_zod15.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
983
- "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."
984
- )
985
- });
986
- var OrganizationSchema = import_zod15.z.object({
987
- id: import_zod15.z.string(),
988
- name: import_zod15.z.string(),
989
- payoutAddress: import_zod15.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
990
- currentFeePercent: import_zod15.z.number().describe(
991
- "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."
992
- ),
993
- feeUpdatedAt: import_zod15.z.string().datetime().nullable().describe(
994
- "When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up."
995
- ),
996
- createdAt: import_zod15.z.string().datetime()
997
- });
998
- var OrganizationWithRoleSchema = OrganizationSchema.extend({
999
- role: UserRoleSchema.describe("Your own role within this specific organization.")
1000
- });
1001
- var PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema);
1002
- var ListOrganizationsSchema = PaginationQuerySchema;
1003
-
1004
- // src/invitations.ts
1005
- var import_zod16 = require("zod");
1006
- var InviteUserSchema = import_zod16.z.object({
1007
- email: NormalizedEmailSchema,
1008
- role: UserRoleSchema.default("member").describe(
1009
- "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`."
1010
- )
1011
- });
1012
- var AcceptInvitationSchema = import_zod16.z.object({
1013
- token: import_zod16.z.string().min(1).describe("The token from the invitation email."),
1014
- password: import_zod16.z.string().min(8).max(128).optional().describe(
1015
- "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."
1016
- )
1017
- });
1018
- var InvitationSchema = import_zod16.z.object({
1019
- id: import_zod16.z.string(),
1020
- organizationId: import_zod16.z.string(),
1021
- email: import_zod16.z.string(),
1022
- role: UserRoleSchema,
1023
- invitedByUserId: import_zod16.z.string().describe("Which member of the organization sent this invitation."),
1024
- expiresAt: import_zod16.z.string().datetime(),
1025
- createdAt: import_zod16.z.string().datetime()
1026
- });
1027
-
1028
765
  // src/timeline.ts
1029
- var import_zod17 = require("zod");
1030
- var TransactionSourceSchema = import_zod17.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
766
+ var import_zod12 = require("zod");
767
+ var TransactionSourceSchema = import_zod12.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
1031
768
  "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)."
1032
769
  );
1033
- var TimelineEventTypeSchema = import_zod17.z.enum([
770
+ var TimelineEventTypeSchema = import_zod12.z.enum([
1034
771
  "charge.created",
1035
772
  "charge.expired",
1036
- "charge.canceled",
1037
773
  "transaction.detected",
1038
774
  "split.distributed",
1039
775
  "webhook.dispatched",
1040
776
  "webhook.delivered",
1041
777
  "webhook.failed"
1042
778
  ]).describe(
1043
- "`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)."
779
+ "`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)."
1044
780
  );
1045
- var TimelineEventSchema = import_zod17.z.object({
781
+ var TimelineEventSchema = import_zod12.z.object({
1046
782
  type: TimelineEventTypeSchema,
1047
- at: import_zod17.z.string().datetime(),
1048
- txHash: import_zod17.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
1049
- amount: import_zod17.z.number().optional().describe(
783
+ at: import_zod12.z.string().datetime(),
784
+ txHash: import_zod12.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
785
+ amount: import_zod12.z.number().optional().describe(
1050
786
  "Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
1051
787
  ),
1052
788
  source: TransactionSourceSchema.optional().describe(
@@ -1058,81 +794,68 @@ var TimelineEventSchema = import_zod17.z.object({
1058
794
  network: NetworkSchema.optional().describe(
1059
795
  "Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
1060
796
  ),
1061
- causedTransition: import_zod17.z.boolean().optional().describe(
797
+ causedTransition: import_zod12.z.boolean().optional().describe(
1062
798
  "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."
1063
799
  ),
1064
800
  event: WebhookEventTypeSchema.optional().describe(
1065
801
  "Present for `webhook.*` events only \u2014 which event type this delivery was for."
1066
802
  ),
1067
- responseCode: import_zod17.z.number().nullable().optional().describe(
803
+ responseCode: import_zod12.z.number().nullable().optional().describe(
1068
804
  "Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
1069
805
  ),
1070
- attempts: import_zod17.z.number().optional().describe(
806
+ attempts: import_zod12.z.number().optional().describe(
1071
807
  "Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
1072
808
  )
1073
809
  });
1074
810
 
1075
811
  // src/health.ts
1076
- var import_zod18 = require("zod");
1077
- var HealthSchema = import_zod18.z.object({
1078
- status: import_zod18.z.enum(["ok", "error"]).describe(
812
+ var import_zod13 = require("zod");
813
+ var HealthSchema = import_zod13.z.object({
814
+ status: import_zod13.z.enum(["ok", "error"]).describe(
1079
815
  "`error` when the database connectivity check fails \u2014 the HTTP status code mirrors this (503 instead of 200), so a plain uptime check (not just a JSON-aware one) still catches a DB outage."
1080
816
  ),
1081
- version: import_zod18.z.string(),
1082
- timestamp: import_zod18.z.string().datetime(),
1083
- db: import_zod18.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
1084
- pendingWebhooks: import_zod18.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
1085
- oldestPendingChargeAgeSeconds: import_zod18.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
1086
- lastMoralisEventAgeSeconds: import_zod18.z.number().nullable().describe(
817
+ version: import_zod13.z.string(),
818
+ timestamp: import_zod13.z.string().datetime(),
819
+ db: import_zod13.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
820
+ pendingWebhooks: import_zod13.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
821
+ oldestPendingChargeAgeSeconds: import_zod13.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
822
+ lastMoralisEventAgeSeconds: import_zod13.z.number().nullable().describe(
1087
823
  "Seconds since the last on-chain payment notification was received \u2014 a cheap signal for whether payment detection is currently working. `null` if none have ever been received."
1088
824
  )
1089
825
  });
1090
826
 
1091
827
  // src/sandbox.ts
1092
- var import_zod19 = require("zod");
1093
- var SandboxTriggerSchema = import_zod19.z.object({
828
+ var import_zod14 = require("zod");
829
+ var SandboxTriggerSchema = import_zod14.z.object({
1094
830
  event: TriggerableChargeEventSchema,
1095
- amount: import_zod19.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
831
+ amount: import_zod14.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
1096
832
  "Used with `charge.partially_paid` (amount to simulate as received so far \u2014 must be less than the charge amount, defaults to half of it if omitted) and with `charge.overpaid` (amount received \u2014 must be greater than the charge amount, defaults to 1.5x it if omitted). Ignored for every other event."
1097
833
  )
1098
834
  });
1099
- var SandboxEventTriggerSchema = import_zod19.z.object({
1100
- event: NonChargeTriggerableEventSchema.describe(
1101
- "Any account, security, or webhook-delivery event \u2014 simulates it with synthetic data against your own webhooks, no real state change or precondition required (unlike `POST /v1/sandbox/charges/{id}/trigger`, which acts on a real charge)."
1102
- )
1103
- });
1104
835
 
1105
836
  // src/capabilities.ts
1106
- var import_zod20 = require("zod");
1107
- var CapabilitiesSchema = import_zod20.z.object({
1108
- acceptedPayments: import_zod20.z.array(AcceptedPaymentSchema).describe(
837
+ var import_zod15 = require("zod");
838
+ var CapabilitiesSchema = import_zod15.z.object({
839
+ acceptedPayments: import_zod15.z.array(AcceptedPaymentSchema).describe(
1109
840
  "Every `(token, network)` pair actually configured for your environment right now \u2014 read straight from the same lookup `POST /v1/charges` validates `acceptedPayments` against, so it can never list a pair that charge creation would then reject. Use this to build a picker UI instead of hardcoding the matrix client-side."
1110
841
  )
1111
842
  });
1112
843
  // Annotate the CommonJS export names for ESM import in node:
1113
844
  0 && (module.exports = {
1114
- AcceptInvitationSchema,
845
+ API_KEY_SCOPES,
1115
846
  AcceptedPaymentSchema,
1116
- AccountWebhookEventTypeSchema,
1117
- ApiKeySchema,
1118
- AuthResponseSchema,
847
+ ApiKeyScopeSchema,
1119
848
  CHARGE_ACCEPTED_PAYMENTS_MAX,
1120
849
  CHARGE_AMOUNT_MAX,
1121
850
  CHARGE_EXPIRES_IN_MAX_SECONDS,
1122
851
  CHARGE_EXPIRES_IN_MIN_SECONDS,
1123
852
  CapabilitiesSchema,
1124
- ChangeEmailSchema,
1125
- ChangeNameSchema,
1126
- ChangePasswordSchema,
1127
- ChargeModeSchema,
1128
853
  ChargeSchema,
1129
854
  ChargeStatusSchema,
1130
855
  ChargeWebhookEventTypeSchema,
1131
856
  ChargesDateFieldSchema,
1132
857
  ChargesMetricFieldSchema,
1133
858
  ChargesQueryFieldSchema,
1134
- ConfirmEmailChangeSchema,
1135
- CreateApiKeySchema,
1136
859
  CreateChargeSchema,
1137
860
  CreateWebhookSchema,
1138
861
  DistributionsDateFieldSchema,
@@ -1142,62 +865,40 @@ var CapabilitiesSchema = import_zod20.z.object({
1142
865
  EVM_NETWORKS,
1143
866
  EnvironmentSchema,
1144
867
  ErrorPayloadSchema,
1145
- ForgotPasswordSchema,
1146
868
  GetChargeQrCodeQuerySchema,
1147
869
  HealthSchema,
1148
- InvitationSchema,
1149
- InviteUserSchema,
1150
- ListApiKeysSchema,
1151
870
  ListChargesSchema,
1152
- ListOrganizationsSchema,
1153
- ListUsersSchema,
1154
871
  ListWebhookDeliveriesSchema,
1155
872
  ListenPendingDistributionsQuerySchema,
1156
- LoginSchema,
1157
873
  MAX_METRICS_QUERY_DATE_RANGE_DAYS,
1158
874
  METRICS_QUERY_DEFAULT_ROW_LIMIT,
1159
875
  METRICS_QUERY_MAX_FILTERS,
1160
876
  METRICS_QUERY_MAX_GROUP_BY,
1161
877
  METRICS_QUERY_MAX_METRICS,
1162
878
  METRICS_QUERY_MAX_ROW_LIMIT,
1163
- MessageResponseSchema,
1164
879
  MetricsAggregationSchema,
1165
880
  MetricsDateGranularitySchema,
1166
881
  MetricsFilterOperatorSchema,
1167
882
  MetricsQueryResultRowSchema,
1168
883
  MetricsQueryResultSchema,
1169
884
  MetricsQuerySchema,
1170
- MetricsQueryScopeSchema,
1171
885
  MetricsResourceSchema,
1172
886
  NETWORK_EXPLORERS,
1173
887
  NETWORK_LABELS,
1174
888
  NetworkSchema,
1175
- NonChargeTriggerableEventSchema,
1176
- NormalizedEmailSchema,
1177
889
  OPERATIONAL_NETWORKS,
1178
- OrganizationSchema,
1179
- OrganizationWithRoleSchema,
1180
890
  PAGINATION_LIMIT_DEFAULT,
1181
891
  PAGINATION_LIMIT_MAX,
1182
892
  PAGINATION_LIMIT_MIN,
1183
- PaginatedApiKeysSchema,
1184
893
  PaginatedChargesSchema,
1185
- PaginatedOrganizationsSchema,
1186
894
  PaginatedPendingDistributionsSchema,
1187
- PaginatedUsersSchema,
1188
895
  PaginatedWebhookDeliveriesSchema,
1189
896
  PaginationQuerySchema,
1190
897
  PendingDistributionEventSchema,
1191
898
  PendingDistributionRecipientSchema,
1192
899
  PendingDistributionSchema,
1193
- PublicChargeSchema,
1194
- ResetPasswordSchema,
1195
- SandboxEventTriggerSchema,
1196
900
  SandboxTriggerSchema,
1197
- SecurityWebhookEventTypeSchema,
1198
- SelfUserSchema,
1199
901
  SettlementStatusSchema,
1200
- SignupSchema,
1201
902
  SplitDistributionStatusSchema,
1202
903
  TOKEN_ADDRESSES,
1203
904
  TOKEN_DECIMALS,
@@ -1209,11 +910,6 @@ var CapabilitiesSchema = import_zod20.z.object({
1209
910
  TransactionsMetricFieldSchema,
1210
911
  TransactionsQueryFieldSchema,
1211
912
  TriggerableChargeEventSchema,
1212
- UpdateOrganizationSchema,
1213
- UpdateUserRoleSchema,
1214
- UserRoleSchema,
1215
- UserSchema,
1216
- VerifyEmailSchema,
1217
913
  WEBHOOK_EVENTS_WILDCARD,
1218
914
  WEBHOOK_EVENT_CATEGORIES,
1219
915
  WebhookCategorySchema,