@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/README.md +1 -1
- package/dist/index.d.mts +249 -237
- package/dist/index.d.ts +249 -237
- package/dist/index.js +282 -283
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +277 -278
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -117,8 +117,8 @@ var TOKEN_ADDRESSES = {
|
|
|
117
117
|
|
|
118
118
|
// src/charges.ts
|
|
119
119
|
import { z as z6 } from "zod";
|
|
120
|
-
var ChargeStatusSchema = z6.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid"]).describe(
|
|
121
|
-
"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."
|
|
120
|
+
var ChargeStatusSchema = z6.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid", "canceled"]).describe(
|
|
121
|
+
"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."
|
|
122
122
|
);
|
|
123
123
|
var SettlementStatusSchema = z6.enum(["pending", "completed", "failed"]).describe(
|
|
124
124
|
"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."
|
|
@@ -233,6 +233,9 @@ var ChargeSchema = z6.object({
|
|
|
233
233
|
),
|
|
234
234
|
pausedAt: z6.string().datetime().nullable().describe(
|
|
235
235
|
"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."
|
|
236
|
+
),
|
|
237
|
+
canceledAt: z6.string().datetime().nullable().describe(
|
|
238
|
+
"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."
|
|
236
239
|
)
|
|
237
240
|
});
|
|
238
241
|
var ListChargesSchema = z6.object({
|
|
@@ -250,65 +253,102 @@ var ListChargesSchema = z6.object({
|
|
|
250
253
|
isOverpaid: z6.enum(["true", "false"]).transform((v) => v === "true").optional()
|
|
251
254
|
}).extend(PaginationQuerySchema.shape);
|
|
252
255
|
var PaginatedChargesSchema = paginatedSchema(ChargeSchema);
|
|
253
|
-
var
|
|
254
|
-
|
|
256
|
+
var GetChargeQrCodeQuerySchema = z6.object({
|
|
257
|
+
token: TokenSchema.optional().describe(
|
|
258
|
+
"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."
|
|
259
|
+
),
|
|
260
|
+
network: NetworkSchema.optional()
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// src/public-charges.ts
|
|
264
|
+
import { z as z7 } from "zod";
|
|
265
|
+
var PublicChargeSchema = z7.object({
|
|
266
|
+
id: z7.string(),
|
|
267
|
+
mode: ChargeModeSchema,
|
|
255
268
|
status: ChargeStatusSchema,
|
|
256
269
|
settlementStatus: SettlementStatusSchema.nullable(),
|
|
257
|
-
amount:
|
|
258
|
-
amountReceived:
|
|
259
|
-
|
|
270
|
+
amount: z7.number().nullable(),
|
|
271
|
+
amountReceived: z7.number().nullable(),
|
|
272
|
+
isOverpaid: z7.boolean(),
|
|
273
|
+
currency: z7.string(),
|
|
274
|
+
acceptedPayments: z7.array(AcceptedPaymentSchema),
|
|
275
|
+
paidWith: z7.array(AcceptedPaymentSchema),
|
|
276
|
+
address: z7.string(),
|
|
277
|
+
environment: EnvironmentSchema,
|
|
278
|
+
txHash: z7.string().nullable(),
|
|
279
|
+
metadata: z7.record(z7.unknown()).nullable().describe(
|
|
280
|
+
"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."
|
|
281
|
+
),
|
|
282
|
+
createdAt: z7.string().datetime(),
|
|
283
|
+
expiresAt: z7.string().datetime().nullable(),
|
|
284
|
+
confirmedAt: z7.string().datetime().nullable(),
|
|
285
|
+
settledAt: z7.string().datetime().nullable(),
|
|
286
|
+
lastActivityAt: z7.string().datetime(),
|
|
287
|
+
pausedAt: z7.string().datetime().nullable(),
|
|
288
|
+
canceledAt: z7.string().datetime().nullable()
|
|
289
|
+
});
|
|
290
|
+
var GetPublicChargeQuerySchema = z7.object({
|
|
291
|
+
environment: EnvironmentSchema.describe(
|
|
292
|
+
"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."
|
|
293
|
+
)
|
|
260
294
|
});
|
|
261
295
|
|
|
262
296
|
// src/distributions.ts
|
|
263
|
-
import { z as
|
|
264
|
-
var SplitDistributionStatusSchema =
|
|
297
|
+
import { z as z8 } from "zod";
|
|
298
|
+
var SplitDistributionStatusSchema = z8.enum(["pending", "processing", "completed", "failed"]).describe(
|
|
265
299
|
"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."
|
|
266
300
|
);
|
|
267
|
-
var PendingDistributionRecipientSchema =
|
|
268
|
-
address:
|
|
269
|
-
percentAllocation:
|
|
301
|
+
var PendingDistributionRecipientSchema = z8.object({
|
|
302
|
+
address: z8.string().describe("On-chain recipient address."),
|
|
303
|
+
percentAllocation: z8.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
|
|
270
304
|
});
|
|
271
|
-
var PendingDistributionSchema =
|
|
272
|
-
splitAddress:
|
|
305
|
+
var PendingDistributionSchema = z8.object({
|
|
306
|
+
splitAddress: z8.string().describe("The on-chain 0xSplits address to call `distribute()` on."),
|
|
273
307
|
network: NetworkSchema,
|
|
274
308
|
token: TokenSchema,
|
|
275
|
-
recipients:
|
|
309
|
+
recipients: z8.array(PendingDistributionRecipientSchema).describe(
|
|
276
310
|
"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."
|
|
277
311
|
),
|
|
278
|
-
distributorFeePercent:
|
|
312
|
+
distributorFeePercent: z8.number().describe(
|
|
279
313
|
"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."
|
|
280
314
|
),
|
|
281
|
-
estimatedRewardAmount:
|
|
315
|
+
estimatedRewardAmount: z8.number().describe(
|
|
282
316
|
"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."
|
|
283
317
|
),
|
|
284
|
-
availableSince:
|
|
285
|
-
graceEndsAt:
|
|
318
|
+
availableSince: z8.string().datetime().describe("When this distribution entered its grace period."),
|
|
319
|
+
graceEndsAt: z8.string().datetime().describe(
|
|
286
320
|
"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."
|
|
287
321
|
)
|
|
288
322
|
});
|
|
289
|
-
var
|
|
290
|
-
|
|
291
|
-
|
|
323
|
+
var PaginatedPendingDistributionsSchema = paginatedSchema(PendingDistributionSchema);
|
|
324
|
+
var ListenPendingDistributionsQuerySchema = z8.object({
|
|
325
|
+
limit: z8.coerce.number().int().min(0).max(PAGINATION_LIMIT_MAX).default(0).describe(
|
|
326
|
+
"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."
|
|
327
|
+
)
|
|
328
|
+
});
|
|
329
|
+
var PendingDistributionEventSchema = z8.discriminatedUnion("type", [
|
|
330
|
+
z8.object({
|
|
331
|
+
type: z8.literal("distribution.available"),
|
|
292
332
|
distribution: PendingDistributionSchema
|
|
293
333
|
}),
|
|
294
|
-
|
|
295
|
-
type:
|
|
296
|
-
splitAddress:
|
|
334
|
+
z8.object({
|
|
335
|
+
type: z8.literal("distribution.claimed"),
|
|
336
|
+
splitAddress: z8.string().describe("No longer claimable \u2014 either settled by someone, or picked up by the worker.")
|
|
297
337
|
})
|
|
298
338
|
]);
|
|
299
339
|
|
|
300
340
|
// src/metrics.ts
|
|
301
|
-
import { z as
|
|
302
|
-
var MetricsResourceSchema =
|
|
341
|
+
import { z as z9 } from "zod";
|
|
342
|
+
var MetricsResourceSchema = z9.enum(["charges", "transactions", "distributions"]).describe(
|
|
303
343
|
"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."
|
|
304
344
|
);
|
|
305
|
-
var MetricsAggregationSchema =
|
|
345
|
+
var MetricsAggregationSchema = z9.enum(["count", "sum", "avg", "min", "max"]).describe(
|
|
306
346
|
"`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."
|
|
307
347
|
);
|
|
308
|
-
var MetricsFilterOperatorSchema =
|
|
348
|
+
var MetricsFilterOperatorSchema = z9.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
|
|
309
349
|
"`in` expects an array value (max 50 entries); every other operator expects a single scalar."
|
|
310
350
|
);
|
|
311
|
-
var MetricsDateGranularitySchema =
|
|
351
|
+
var MetricsDateGranularitySchema = z9.enum(["day", "week", "month"]).describe(
|
|
312
352
|
"Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
|
|
313
353
|
);
|
|
314
354
|
var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
|
|
@@ -321,151 +361,151 @@ var METRICS_QUERY_MAX_GROUP_BY = 3;
|
|
|
321
361
|
var METRICS_QUERY_MAX_FILTERS = 20;
|
|
322
362
|
var METRICS_QUERY_MAX_METRICS = 10;
|
|
323
363
|
var METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
324
|
-
var metricAliasSchema =
|
|
364
|
+
var metricAliasSchema = z9.string().min(1).max(64).regex(
|
|
325
365
|
METRIC_ALIAS_PATTERN,
|
|
326
366
|
"Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 this becomes a SQL column alias."
|
|
327
367
|
).optional();
|
|
328
|
-
var MetricsFilterValueSchema =
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
368
|
+
var MetricsFilterValueSchema = z9.union([
|
|
369
|
+
z9.string().max(255),
|
|
370
|
+
z9.number(),
|
|
371
|
+
z9.boolean(),
|
|
372
|
+
z9.array(z9.union([z9.string().max(255), z9.number()])).min(1).max(50)
|
|
333
373
|
]);
|
|
334
|
-
var orderBySchema =
|
|
335
|
-
key:
|
|
374
|
+
var orderBySchema = z9.object({
|
|
375
|
+
key: z9.string().min(1).max(64).regex(
|
|
336
376
|
METRIC_ALIAS_PATTERN,
|
|
337
377
|
"Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 every valid output column name already looks like this."
|
|
338
378
|
).describe(
|
|
339
379
|
"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."
|
|
340
380
|
),
|
|
341
|
-
direction:
|
|
381
|
+
direction: z9.enum(["asc", "desc"])
|
|
342
382
|
}).describe(
|
|
343
383
|
"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."
|
|
344
384
|
);
|
|
345
|
-
var limitSchema =
|
|
385
|
+
var limitSchema = z9.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
|
|
346
386
|
`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.`
|
|
347
387
|
);
|
|
348
|
-
var ChargesQueryFieldSchema =
|
|
388
|
+
var ChargesQueryFieldSchema = z9.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
|
|
349
389
|
"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."
|
|
350
390
|
);
|
|
351
|
-
var ChargesMetricFieldSchema =
|
|
391
|
+
var ChargesMetricFieldSchema = z9.enum(["amount", "amountReceived", "feePercent"]).describe(
|
|
352
392
|
"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%."
|
|
353
393
|
);
|
|
354
|
-
var ChargesDateFieldSchema =
|
|
394
|
+
var ChargesDateFieldSchema = z9.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
|
|
355
395
|
"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."
|
|
356
396
|
);
|
|
357
|
-
var ChargesFilterSchema =
|
|
397
|
+
var ChargesFilterSchema = z9.object({
|
|
358
398
|
field: ChargesQueryFieldSchema,
|
|
359
399
|
operator: MetricsFilterOperatorSchema,
|
|
360
400
|
value: MetricsFilterValueSchema
|
|
361
401
|
});
|
|
362
|
-
var ChargesGroupBySchema =
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
type:
|
|
402
|
+
var ChargesGroupBySchema = z9.union([
|
|
403
|
+
z9.object({ type: z9.literal("field"), field: ChargesQueryFieldSchema }),
|
|
404
|
+
z9.object({
|
|
405
|
+
type: z9.literal("date_bucket"),
|
|
366
406
|
field: ChargesDateFieldSchema,
|
|
367
407
|
granularity: MetricsDateGranularitySchema
|
|
368
408
|
})
|
|
369
409
|
]);
|
|
370
|
-
var ChargesMetricSchema =
|
|
410
|
+
var ChargesMetricSchema = z9.object({
|
|
371
411
|
aggregation: MetricsAggregationSchema,
|
|
372
412
|
field: ChargesMetricFieldSchema.optional(),
|
|
373
413
|
alias: metricAliasSchema
|
|
374
414
|
});
|
|
375
|
-
var ChargesMetricsQuerySchema =
|
|
376
|
-
resource:
|
|
415
|
+
var ChargesMetricsQuerySchema = z9.object({
|
|
416
|
+
resource: z9.literal("charges"),
|
|
377
417
|
environment: metricsQueryEnvironmentSchema,
|
|
378
|
-
dateRange:
|
|
418
|
+
dateRange: z9.object({
|
|
379
419
|
field: ChargesDateFieldSchema,
|
|
380
|
-
from:
|
|
381
|
-
to:
|
|
420
|
+
from: z9.string().max(64).datetime(),
|
|
421
|
+
to: z9.string().max(64).datetime()
|
|
382
422
|
}),
|
|
383
|
-
groupBy:
|
|
384
|
-
metrics:
|
|
385
|
-
filters:
|
|
423
|
+
groupBy: z9.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
424
|
+
metrics: z9.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
425
|
+
filters: z9.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
386
426
|
orderBy: orderBySchema.optional(),
|
|
387
427
|
limit: limitSchema
|
|
388
428
|
});
|
|
389
|
-
var TransactionsQueryFieldSchema =
|
|
429
|
+
var TransactionsQueryFieldSchema = z9.enum(["network", "token", "source", "causedTransition"]).describe(
|
|
390
430
|
"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)."
|
|
391
431
|
);
|
|
392
|
-
var TransactionsMetricFieldSchema =
|
|
393
|
-
var TransactionsDateFieldSchema =
|
|
394
|
-
var TransactionsFilterSchema =
|
|
432
|
+
var TransactionsMetricFieldSchema = z9.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
|
|
433
|
+
var TransactionsDateFieldSchema = z9.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
|
|
434
|
+
var TransactionsFilterSchema = z9.object({
|
|
395
435
|
field: TransactionsQueryFieldSchema,
|
|
396
436
|
operator: MetricsFilterOperatorSchema,
|
|
397
437
|
value: MetricsFilterValueSchema
|
|
398
438
|
});
|
|
399
|
-
var TransactionsGroupBySchema =
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
type:
|
|
439
|
+
var TransactionsGroupBySchema = z9.union([
|
|
440
|
+
z9.object({ type: z9.literal("field"), field: TransactionsQueryFieldSchema }),
|
|
441
|
+
z9.object({
|
|
442
|
+
type: z9.literal("date_bucket"),
|
|
403
443
|
field: TransactionsDateFieldSchema,
|
|
404
444
|
granularity: MetricsDateGranularitySchema
|
|
405
445
|
})
|
|
406
446
|
]);
|
|
407
|
-
var TransactionsMetricSchema =
|
|
447
|
+
var TransactionsMetricSchema = z9.object({
|
|
408
448
|
aggregation: MetricsAggregationSchema,
|
|
409
449
|
field: TransactionsMetricFieldSchema.optional(),
|
|
410
450
|
alias: metricAliasSchema
|
|
411
451
|
});
|
|
412
|
-
var TransactionsMetricsQuerySchema =
|
|
413
|
-
resource:
|
|
452
|
+
var TransactionsMetricsQuerySchema = z9.object({
|
|
453
|
+
resource: z9.literal("transactions"),
|
|
414
454
|
environment: metricsQueryEnvironmentSchema,
|
|
415
|
-
dateRange:
|
|
455
|
+
dateRange: z9.object({
|
|
416
456
|
field: TransactionsDateFieldSchema,
|
|
417
|
-
from:
|
|
418
|
-
to:
|
|
457
|
+
from: z9.string().max(64).datetime(),
|
|
458
|
+
to: z9.string().max(64).datetime()
|
|
419
459
|
}),
|
|
420
|
-
groupBy:
|
|
421
|
-
metrics:
|
|
422
|
-
filters:
|
|
460
|
+
groupBy: z9.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
461
|
+
metrics: z9.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
462
|
+
filters: z9.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
423
463
|
orderBy: orderBySchema.optional(),
|
|
424
464
|
limit: limitSchema
|
|
425
465
|
});
|
|
426
|
-
var DistributionsQueryFieldSchema =
|
|
466
|
+
var DistributionsQueryFieldSchema = z9.enum(["status", "network", "token"]).describe(
|
|
427
467
|
"A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values."
|
|
428
468
|
);
|
|
429
|
-
var DistributionsMetricFieldSchema =
|
|
469
|
+
var DistributionsMetricFieldSchema = z9.enum(["attempts"]).describe(
|
|
430
470
|
"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."
|
|
431
471
|
);
|
|
432
|
-
var DistributionsDateFieldSchema =
|
|
472
|
+
var DistributionsDateFieldSchema = z9.enum(["createdAt", "completedAt"]).describe(
|
|
433
473
|
"`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."
|
|
434
474
|
);
|
|
435
|
-
var DistributionsFilterSchema =
|
|
475
|
+
var DistributionsFilterSchema = z9.object({
|
|
436
476
|
field: DistributionsQueryFieldSchema,
|
|
437
477
|
operator: MetricsFilterOperatorSchema,
|
|
438
478
|
value: MetricsFilterValueSchema
|
|
439
479
|
});
|
|
440
|
-
var DistributionsGroupBySchema =
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
type:
|
|
480
|
+
var DistributionsGroupBySchema = z9.union([
|
|
481
|
+
z9.object({ type: z9.literal("field"), field: DistributionsQueryFieldSchema }),
|
|
482
|
+
z9.object({
|
|
483
|
+
type: z9.literal("date_bucket"),
|
|
444
484
|
field: DistributionsDateFieldSchema,
|
|
445
485
|
granularity: MetricsDateGranularitySchema
|
|
446
486
|
})
|
|
447
487
|
]);
|
|
448
|
-
var DistributionsMetricSchema =
|
|
488
|
+
var DistributionsMetricSchema = z9.object({
|
|
449
489
|
aggregation: MetricsAggregationSchema,
|
|
450
490
|
field: DistributionsMetricFieldSchema.optional(),
|
|
451
491
|
alias: metricAliasSchema
|
|
452
492
|
});
|
|
453
|
-
var DistributionsMetricsQuerySchema =
|
|
454
|
-
resource:
|
|
493
|
+
var DistributionsMetricsQuerySchema = z9.object({
|
|
494
|
+
resource: z9.literal("distributions"),
|
|
455
495
|
environment: metricsQueryEnvironmentSchema,
|
|
456
|
-
dateRange:
|
|
496
|
+
dateRange: z9.object({
|
|
457
497
|
field: DistributionsDateFieldSchema,
|
|
458
|
-
from:
|
|
459
|
-
to:
|
|
498
|
+
from: z9.string().max(64).datetime(),
|
|
499
|
+
to: z9.string().max(64).datetime()
|
|
460
500
|
}),
|
|
461
|
-
groupBy:
|
|
462
|
-
metrics:
|
|
463
|
-
filters:
|
|
501
|
+
groupBy: z9.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
502
|
+
metrics: z9.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
503
|
+
filters: z9.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
464
504
|
orderBy: orderBySchema.optional(),
|
|
465
505
|
limit: limitSchema
|
|
466
506
|
});
|
|
467
507
|
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
468
|
-
var MetricsQuerySchema =
|
|
508
|
+
var MetricsQuerySchema = z9.discriminatedUnion("resource", [
|
|
469
509
|
ChargesMetricsQuerySchema,
|
|
470
510
|
TransactionsMetricsQuerySchema,
|
|
471
511
|
DistributionsMetricsQuerySchema
|
|
@@ -474,7 +514,7 @@ var MetricsQuerySchema = z8.discriminatedUnion("resource", [
|
|
|
474
514
|
const to = new Date(input.dateRange.to);
|
|
475
515
|
if (from >= to) {
|
|
476
516
|
ctx.addIssue({
|
|
477
|
-
code:
|
|
517
|
+
code: z9.ZodIssueCode.custom,
|
|
478
518
|
message: "`dateRange.from` must be before `dateRange.to`.",
|
|
479
519
|
path: ["dateRange", "from"]
|
|
480
520
|
});
|
|
@@ -482,7 +522,7 @@ var MetricsQuerySchema = z8.discriminatedUnion("resource", [
|
|
|
482
522
|
const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS;
|
|
483
523
|
if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {
|
|
484
524
|
ctx.addIssue({
|
|
485
|
-
code:
|
|
525
|
+
code: z9.ZodIssueCode.custom,
|
|
486
526
|
message: `\`dateRange\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,
|
|
487
527
|
path: ["dateRange", "to"]
|
|
488
528
|
});
|
|
@@ -490,7 +530,7 @@ var MetricsQuerySchema = z8.discriminatedUnion("resource", [
|
|
|
490
530
|
const dateBucketCount = input.groupBy.filter((entry) => entry.type === "date_bucket").length;
|
|
491
531
|
if (dateBucketCount > 1) {
|
|
492
532
|
ctx.addIssue({
|
|
493
|
-
code:
|
|
533
|
+
code: z9.ZodIssueCode.custom,
|
|
494
534
|
message: "At most one `date_bucket` entry is allowed in `groupBy`.",
|
|
495
535
|
path: ["groupBy"]
|
|
496
536
|
});
|
|
@@ -498,7 +538,7 @@ var MetricsQuerySchema = z8.discriminatedUnion("resource", [
|
|
|
498
538
|
input.metrics.forEach((metric, index) => {
|
|
499
539
|
if (metric.aggregation !== "count" && metric.field === void 0) {
|
|
500
540
|
ctx.addIssue({
|
|
501
|
-
code:
|
|
541
|
+
code: z9.ZodIssueCode.custom,
|
|
502
542
|
message: "`field` is required unless `aggregation` is `count`.",
|
|
503
543
|
path: ["metrics", index, "field"]
|
|
504
544
|
});
|
|
@@ -507,7 +547,7 @@ var MetricsQuerySchema = z8.discriminatedUnion("resource", [
|
|
|
507
547
|
const aliases = input.metrics.map((metric) => metric.alias).filter((alias) => alias !== void 0);
|
|
508
548
|
if (new Set(aliases).size !== aliases.length) {
|
|
509
549
|
ctx.addIssue({
|
|
510
|
-
code:
|
|
550
|
+
code: z9.ZodIssueCode.custom,
|
|
511
551
|
message: "Every `metrics[].alias` must be unique.",
|
|
512
552
|
path: ["metrics"]
|
|
513
553
|
});
|
|
@@ -516,36 +556,36 @@ var MetricsQuerySchema = z8.discriminatedUnion("resource", [
|
|
|
516
556
|
input.metrics.forEach((metric, index) => {
|
|
517
557
|
if (metric.alias !== void 0 && reservedNames.has(metric.alias)) {
|
|
518
558
|
ctx.addIssue({
|
|
519
|
-
code:
|
|
559
|
+
code: z9.ZodIssueCode.custom,
|
|
520
560
|
message: `\`alias\` "${metric.alias}" collides with a \`groupBy\` field name (or the reserved word "bucket") \u2014 choose a different alias.`,
|
|
521
561
|
path: ["metrics", index, "alias"]
|
|
522
562
|
});
|
|
523
563
|
}
|
|
524
564
|
});
|
|
525
565
|
});
|
|
526
|
-
var MetricsQueryResultRowSchema =
|
|
527
|
-
|
|
528
|
-
|
|
566
|
+
var MetricsQueryResultRowSchema = z9.record(
|
|
567
|
+
z9.string(),
|
|
568
|
+
z9.union([z9.string(), z9.number(), z9.boolean(), z9.null()])
|
|
529
569
|
);
|
|
530
|
-
var MetricsQueryScopeSchema =
|
|
570
|
+
var MetricsQueryScopeSchema = z9.enum(["owner_admin", "member"]).describe(
|
|
531
571
|
"`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."
|
|
532
572
|
);
|
|
533
|
-
var MetricsQueryResultSchema =
|
|
534
|
-
data:
|
|
535
|
-
meta:
|
|
573
|
+
var MetricsQueryResultSchema = z9.object({
|
|
574
|
+
data: z9.array(MetricsQueryResultRowSchema),
|
|
575
|
+
meta: z9.object({
|
|
536
576
|
resource: MetricsResourceSchema,
|
|
537
577
|
environment: EnvironmentSchema,
|
|
538
578
|
scope: MetricsQueryScopeSchema,
|
|
539
|
-
rowCount:
|
|
540
|
-
truncated:
|
|
579
|
+
rowCount: z9.number().int().describe("Number of rows in `data`."),
|
|
580
|
+
truncated: z9.boolean().describe(
|
|
541
581
|
"`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
|
|
542
582
|
)
|
|
543
583
|
})
|
|
544
584
|
});
|
|
545
585
|
|
|
546
586
|
// src/webhook-events.ts
|
|
547
|
-
import { z as
|
|
548
|
-
var ChargeWebhookEventTypeSchema =
|
|
587
|
+
import { z as z10 } from "zod";
|
|
588
|
+
var ChargeWebhookEventTypeSchema = z10.enum([
|
|
549
589
|
"charge.created",
|
|
550
590
|
"charge.partially_paid",
|
|
551
591
|
"charge.confirmed",
|
|
@@ -557,11 +597,13 @@ var ChargeWebhookEventTypeSchema = z9.enum([
|
|
|
557
597
|
"charge.paused",
|
|
558
598
|
"charge.reactivated",
|
|
559
599
|
"charge.contribution_received",
|
|
560
|
-
"charge.contribution_settled"
|
|
600
|
+
"charge.contribution_settled",
|
|
601
|
+
"charge.canceled",
|
|
602
|
+
"charge.paid_after_cancel"
|
|
561
603
|
]).describe(
|
|
562
|
-
'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 }`.'
|
|
604
|
+
'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 }`.'
|
|
563
605
|
);
|
|
564
|
-
var AccountWebhookEventTypeSchema =
|
|
606
|
+
var AccountWebhookEventTypeSchema = z10.enum([
|
|
565
607
|
"payout_address.changed",
|
|
566
608
|
"api_key.created",
|
|
567
609
|
"api_key.revoked",
|
|
@@ -575,10 +617,10 @@ var AccountWebhookEventTypeSchema = z9.enum([
|
|
|
575
617
|
]).describe(
|
|
576
618
|
"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 }`."
|
|
577
619
|
);
|
|
578
|
-
var WebhookDeliveryEventTypeSchema =
|
|
620
|
+
var WebhookDeliveryEventTypeSchema = z10.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
|
|
579
621
|
"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`)."
|
|
580
622
|
);
|
|
581
|
-
var SecurityWebhookEventTypeSchema =
|
|
623
|
+
var SecurityWebhookEventTypeSchema = z10.enum([
|
|
582
624
|
"auth.login",
|
|
583
625
|
"auth.login_failed",
|
|
584
626
|
"auth.suspicious_activity",
|
|
@@ -591,13 +633,13 @@ var SecurityWebhookEventTypeSchema = z9.enum([
|
|
|
591
633
|
]).describe(
|
|
592
634
|
"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 }`."
|
|
593
635
|
);
|
|
594
|
-
var WebhookEventTypeSchema =
|
|
636
|
+
var WebhookEventTypeSchema = z10.union([
|
|
595
637
|
ChargeWebhookEventTypeSchema,
|
|
596
638
|
AccountWebhookEventTypeSchema,
|
|
597
639
|
WebhookDeliveryEventTypeSchema,
|
|
598
640
|
SecurityWebhookEventTypeSchema
|
|
599
641
|
]);
|
|
600
|
-
var WebhookCategorySchema =
|
|
642
|
+
var WebhookCategorySchema = z10.enum(["payments", "account", "webhooks", "security"]).describe(
|
|
601
643
|
"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."
|
|
602
644
|
);
|
|
603
645
|
function buildCategoryMap() {
|
|
@@ -620,108 +662,110 @@ var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
|
|
|
620
662
|
"charge.paused",
|
|
621
663
|
"charge.reactivated",
|
|
622
664
|
"charge.contribution_received",
|
|
623
|
-
"charge.contribution_settled"
|
|
665
|
+
"charge.contribution_settled",
|
|
666
|
+
"charge.canceled",
|
|
667
|
+
"charge.paid_after_cancel"
|
|
624
668
|
]).describe(
|
|
625
|
-
"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),
|
|
669
|
+
"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)."
|
|
626
670
|
);
|
|
627
|
-
var NonChargeTriggerableEventSchema =
|
|
671
|
+
var NonChargeTriggerableEventSchema = z10.union([
|
|
628
672
|
AccountWebhookEventTypeSchema,
|
|
629
673
|
WebhookDeliveryEventTypeSchema,
|
|
630
674
|
SecurityWebhookEventTypeSchema
|
|
631
675
|
]);
|
|
632
676
|
|
|
633
677
|
// src/webhooks.ts
|
|
634
|
-
import { z as
|
|
678
|
+
import { z as z11 } from "zod";
|
|
635
679
|
var WEBHOOK_EVENTS_WILDCARD = "*";
|
|
636
|
-
var CreateWebhookSchema =
|
|
637
|
-
url:
|
|
680
|
+
var CreateWebhookSchema = z11.object({
|
|
681
|
+
url: z11.string().max(2048).url().describe(
|
|
638
682
|
"Must be HTTPS and resolve to a public address \u2014 private/internal IPs are rejected."
|
|
639
683
|
),
|
|
640
|
-
events:
|
|
684
|
+
events: z11.array(z11.union([WebhookEventTypeSchema, z11.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
|
|
641
685
|
'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.'
|
|
642
686
|
),
|
|
643
|
-
eventCategories:
|
|
687
|
+
eventCategories: z11.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
|
|
644
688
|
"Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required."
|
|
645
689
|
),
|
|
646
|
-
excludeEvents:
|
|
690
|
+
excludeEvents: z11.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
|
|
647
691
|
'Event types to exclude even if selected via `events: ["*"]` or `eventCategories`.'
|
|
648
692
|
)
|
|
649
693
|
}).refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {
|
|
650
694
|
message: "must select at least one event via `events` or `eventCategories`",
|
|
651
695
|
path: ["events"]
|
|
652
696
|
});
|
|
653
|
-
var WebhookSchema =
|
|
654
|
-
id:
|
|
697
|
+
var WebhookSchema = z11.object({
|
|
698
|
+
id: z11.string(),
|
|
655
699
|
environment: EnvironmentSchema.nullable().describe(
|
|
656
700
|
"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."
|
|
657
701
|
),
|
|
658
|
-
url:
|
|
659
|
-
events:
|
|
660
|
-
eventCategories:
|
|
661
|
-
excludeEvents:
|
|
662
|
-
isWildcard:
|
|
663
|
-
secret:
|
|
702
|
+
url: z11.string(),
|
|
703
|
+
events: z11.array(WebhookEventTypeSchema),
|
|
704
|
+
eventCategories: z11.array(WebhookCategorySchema),
|
|
705
|
+
excludeEvents: z11.array(WebhookEventTypeSchema),
|
|
706
|
+
isWildcard: z11.boolean(),
|
|
707
|
+
secret: z11.string().describe(
|
|
664
708
|
"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."
|
|
665
709
|
),
|
|
666
|
-
createdAt:
|
|
710
|
+
createdAt: z11.string().datetime()
|
|
667
711
|
});
|
|
668
712
|
var WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({
|
|
669
|
-
hint:
|
|
713
|
+
hint: z11.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
|
|
670
714
|
});
|
|
671
|
-
var WebhookPayloadSchema =
|
|
672
|
-
id:
|
|
715
|
+
var WebhookPayloadSchema = z11.object({
|
|
716
|
+
id: z11.string().describe(
|
|
673
717
|
"Unique id for this specific delivery \u2014 also sent as the `X-Klappay-Delivery` header."
|
|
674
718
|
),
|
|
675
719
|
event: WebhookEventTypeSchema,
|
|
676
|
-
createdAt:
|
|
677
|
-
data:
|
|
720
|
+
createdAt: z11.string().datetime(),
|
|
721
|
+
data: z11.unknown().describe(
|
|
678
722
|
"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."
|
|
679
723
|
)
|
|
680
724
|
});
|
|
681
|
-
var WebhookDeliveryStatusSchema =
|
|
682
|
-
var WebhookDeliverySchema =
|
|
683
|
-
id:
|
|
684
|
-
webhookId:
|
|
725
|
+
var WebhookDeliveryStatusSchema = z11.enum(["pending", "delivered", "failed"]);
|
|
726
|
+
var WebhookDeliverySchema = z11.object({
|
|
727
|
+
id: z11.string(),
|
|
728
|
+
webhookId: z11.string(),
|
|
685
729
|
event: WebhookEventTypeSchema,
|
|
686
730
|
status: WebhookDeliveryStatusSchema.describe(
|
|
687
731
|
"`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."
|
|
688
732
|
),
|
|
689
|
-
attempts:
|
|
690
|
-
responseCode:
|
|
733
|
+
attempts: z11.number(),
|
|
734
|
+
responseCode: z11.number().nullable().describe(
|
|
691
735
|
"HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all."
|
|
692
736
|
),
|
|
693
|
-
nextRetryAt:
|
|
694
|
-
deliveredAt:
|
|
695
|
-
createdAt:
|
|
737
|
+
nextRetryAt: z11.string().datetime().nullable(),
|
|
738
|
+
deliveredAt: z11.string().datetime().nullable(),
|
|
739
|
+
createdAt: z11.string().datetime()
|
|
696
740
|
});
|
|
697
741
|
var ListWebhookDeliveriesSchema = PaginationQuerySchema;
|
|
698
742
|
var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
|
|
699
743
|
|
|
700
744
|
// src/api-keys.ts
|
|
701
|
-
import { z as
|
|
702
|
-
var CreateApiKeySchema =
|
|
703
|
-
name:
|
|
745
|
+
import { z as z12 } from "zod";
|
|
746
|
+
var CreateApiKeySchema = z12.object({
|
|
747
|
+
name: z12.string().min(1).max(64).describe(
|
|
704
748
|
'A label to help you tell keys apart (e.g. `"production backend"`). Not used for anything functional.'
|
|
705
749
|
),
|
|
706
750
|
environment: EnvironmentSchema.describe(
|
|
707
751
|
"`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."
|
|
708
752
|
)
|
|
709
753
|
});
|
|
710
|
-
var ApiKeySchema =
|
|
711
|
-
id:
|
|
712
|
-
name:
|
|
754
|
+
var ApiKeySchema = z12.object({
|
|
755
|
+
id: z12.string(),
|
|
756
|
+
name: z12.string(),
|
|
713
757
|
environment: EnvironmentSchema.describe(
|
|
714
758
|
"`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."
|
|
715
759
|
),
|
|
716
|
-
key:
|
|
760
|
+
key: z12.string().optional().describe(
|
|
717
761
|
"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."
|
|
718
762
|
),
|
|
719
|
-
hint:
|
|
763
|
+
hint: z12.string().describe(
|
|
720
764
|
"A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't."
|
|
721
765
|
),
|
|
722
|
-
createdAt:
|
|
723
|
-
lastUsedAt:
|
|
724
|
-
createdByUserId:
|
|
766
|
+
createdAt: z12.string().datetime(),
|
|
767
|
+
lastUsedAt: z12.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
|
|
768
|
+
createdByUserId: z12.string().nullable().describe(
|
|
725
769
|
"Which member of the organization created this key. `null` for a key created before this field existed."
|
|
726
770
|
)
|
|
727
771
|
});
|
|
@@ -729,93 +773,93 @@ var ListApiKeysSchema = PaginationQuerySchema;
|
|
|
729
773
|
var PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema);
|
|
730
774
|
|
|
731
775
|
// src/users.ts
|
|
732
|
-
import { z as
|
|
733
|
-
var UserRoleSchema =
|
|
776
|
+
import { z as z13 } from "zod";
|
|
777
|
+
var UserRoleSchema = z13.enum(["owner", "admin", "member"]).describe(
|
|
734
778
|
"`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`."
|
|
735
779
|
);
|
|
736
|
-
var UpdateUserRoleSchema =
|
|
780
|
+
var UpdateUserRoleSchema = z13.object({
|
|
737
781
|
role: UserRoleSchema
|
|
738
782
|
});
|
|
739
|
-
var UserSchema =
|
|
740
|
-
id:
|
|
741
|
-
email:
|
|
742
|
-
name:
|
|
783
|
+
var UserSchema = z13.object({
|
|
784
|
+
id: z13.string(),
|
|
785
|
+
email: z13.string(),
|
|
786
|
+
name: z13.string().nullable(),
|
|
743
787
|
role: UserRoleSchema.describe("Your role within the organization this user was fetched from."),
|
|
744
|
-
emailVerifiedAt:
|
|
788
|
+
emailVerifiedAt: z13.string().datetime().nullable().describe(
|
|
745
789
|
"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."
|
|
746
790
|
),
|
|
747
|
-
createdAt:
|
|
791
|
+
createdAt: z13.string().datetime()
|
|
748
792
|
});
|
|
749
793
|
var ListUsersSchema = PaginationQuerySchema;
|
|
750
794
|
var PaginatedUsersSchema = paginatedSchema(UserSchema);
|
|
751
795
|
|
|
752
796
|
// src/auth.ts
|
|
753
|
-
import { z as
|
|
754
|
-
var NormalizedEmailSchema =
|
|
797
|
+
import { z as z14 } from "zod";
|
|
798
|
+
var NormalizedEmailSchema = z14.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
|
|
755
799
|
"Trimmed, lowercased, and NFC-normalized server-side before use \u2014 case/whitespace don't matter."
|
|
756
800
|
);
|
|
757
|
-
var SignupSchema =
|
|
801
|
+
var SignupSchema = z14.object({
|
|
758
802
|
email: NormalizedEmailSchema,
|
|
759
|
-
password:
|
|
803
|
+
password: z14.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
|
|
760
804
|
});
|
|
761
|
-
var LoginSchema =
|
|
805
|
+
var LoginSchema = z14.object({
|
|
762
806
|
email: NormalizedEmailSchema,
|
|
763
|
-
password:
|
|
807
|
+
password: z14.string().min(1).max(128)
|
|
764
808
|
});
|
|
765
|
-
var VerifyEmailSchema =
|
|
766
|
-
token:
|
|
809
|
+
var VerifyEmailSchema = z14.object({
|
|
810
|
+
token: z14.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
|
|
767
811
|
});
|
|
768
|
-
var ForgotPasswordSchema =
|
|
812
|
+
var ForgotPasswordSchema = z14.object({
|
|
769
813
|
email: NormalizedEmailSchema
|
|
770
814
|
});
|
|
771
|
-
var ResetPasswordSchema =
|
|
772
|
-
token:
|
|
773
|
-
newPassword:
|
|
815
|
+
var ResetPasswordSchema = z14.object({
|
|
816
|
+
token: z14.string().min(1).describe("The token from the password reset email."),
|
|
817
|
+
newPassword: z14.string().min(8).max(128)
|
|
774
818
|
});
|
|
775
|
-
var MessageResponseSchema =
|
|
776
|
-
message:
|
|
819
|
+
var MessageResponseSchema = z14.object({
|
|
820
|
+
message: z14.string().describe("Human-readable confirmation, safe to show a user directly.")
|
|
777
821
|
});
|
|
778
822
|
var SelfUserSchema = UserSchema.omit({ createdAt: true, role: true });
|
|
779
|
-
var AuthResponseSchema =
|
|
780
|
-
token:
|
|
823
|
+
var AuthResponseSchema = z14.object({
|
|
824
|
+
token: z14.string().describe(
|
|
781
825
|
"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."
|
|
782
826
|
),
|
|
783
827
|
user: SelfUserSchema
|
|
784
828
|
});
|
|
785
|
-
var ChangeNameSchema =
|
|
786
|
-
name:
|
|
829
|
+
var ChangeNameSchema = z14.object({
|
|
830
|
+
name: z14.string().min(1).max(255).describe("Your display name.")
|
|
787
831
|
});
|
|
788
|
-
var ChangePasswordSchema =
|
|
789
|
-
currentPassword:
|
|
790
|
-
newPassword:
|
|
832
|
+
var ChangePasswordSchema = z14.object({
|
|
833
|
+
currentPassword: z14.string().min(1).max(128),
|
|
834
|
+
newPassword: z14.string().min(8).max(128)
|
|
791
835
|
});
|
|
792
|
-
var ChangeEmailSchema =
|
|
793
|
-
currentPassword:
|
|
836
|
+
var ChangeEmailSchema = z14.object({
|
|
837
|
+
currentPassword: z14.string().min(1).max(128),
|
|
794
838
|
newEmail: NormalizedEmailSchema
|
|
795
839
|
});
|
|
796
|
-
var ConfirmEmailChangeSchema =
|
|
797
|
-
token:
|
|
840
|
+
var ConfirmEmailChangeSchema = z14.object({
|
|
841
|
+
token: z14.string().min(1).describe("The token from the confirmation email sent to your current address.")
|
|
798
842
|
});
|
|
799
843
|
|
|
800
844
|
// src/organization.ts
|
|
801
|
-
import { z as
|
|
802
|
-
var UpdateOrganizationSchema =
|
|
803
|
-
name:
|
|
804
|
-
payoutAddress:
|
|
845
|
+
import { z as z15 } from "zod";
|
|
846
|
+
var UpdateOrganizationSchema = z15.object({
|
|
847
|
+
name: z15.string().min(1).max(255).optional().describe("The organization's display name."),
|
|
848
|
+
payoutAddress: z15.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
|
|
805
849
|
"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."
|
|
806
850
|
)
|
|
807
851
|
});
|
|
808
|
-
var OrganizationSchema =
|
|
809
|
-
id:
|
|
810
|
-
name:
|
|
811
|
-
payoutAddress:
|
|
812
|
-
currentFeePercent:
|
|
852
|
+
var OrganizationSchema = z15.object({
|
|
853
|
+
id: z15.string(),
|
|
854
|
+
name: z15.string(),
|
|
855
|
+
payoutAddress: z15.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
|
|
856
|
+
currentFeePercent: z15.number().describe(
|
|
813
857
|
"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."
|
|
814
858
|
),
|
|
815
|
-
feeUpdatedAt:
|
|
859
|
+
feeUpdatedAt: z15.string().datetime().nullable().describe(
|
|
816
860
|
"When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up."
|
|
817
861
|
),
|
|
818
|
-
createdAt:
|
|
862
|
+
createdAt: z15.string().datetime()
|
|
819
863
|
});
|
|
820
864
|
var OrganizationWithRoleSchema = OrganizationSchema.extend({
|
|
821
865
|
role: UserRoleSchema.describe("Your own role within this specific organization.")
|
|
@@ -824,50 +868,51 @@ var PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema);
|
|
|
824
868
|
var ListOrganizationsSchema = PaginationQuerySchema;
|
|
825
869
|
|
|
826
870
|
// src/invitations.ts
|
|
827
|
-
import { z as
|
|
828
|
-
var InviteUserSchema =
|
|
871
|
+
import { z as z16 } from "zod";
|
|
872
|
+
var InviteUserSchema = z16.object({
|
|
829
873
|
email: NormalizedEmailSchema,
|
|
830
874
|
role: UserRoleSchema.default("member").describe(
|
|
831
875
|
"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`."
|
|
832
876
|
)
|
|
833
877
|
});
|
|
834
|
-
var AcceptInvitationSchema =
|
|
835
|
-
token:
|
|
836
|
-
password:
|
|
878
|
+
var AcceptInvitationSchema = z16.object({
|
|
879
|
+
token: z16.string().min(1).describe("The token from the invitation email."),
|
|
880
|
+
password: z16.string().min(8).max(128).optional().describe(
|
|
837
881
|
"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."
|
|
838
882
|
)
|
|
839
883
|
});
|
|
840
|
-
var InvitationSchema =
|
|
841
|
-
id:
|
|
842
|
-
organizationId:
|
|
843
|
-
email:
|
|
884
|
+
var InvitationSchema = z16.object({
|
|
885
|
+
id: z16.string(),
|
|
886
|
+
organizationId: z16.string(),
|
|
887
|
+
email: z16.string(),
|
|
844
888
|
role: UserRoleSchema,
|
|
845
|
-
invitedByUserId:
|
|
846
|
-
expiresAt:
|
|
847
|
-
createdAt:
|
|
889
|
+
invitedByUserId: z16.string().describe("Which member of the organization sent this invitation."),
|
|
890
|
+
expiresAt: z16.string().datetime(),
|
|
891
|
+
createdAt: z16.string().datetime()
|
|
848
892
|
});
|
|
849
893
|
|
|
850
894
|
// src/timeline.ts
|
|
851
|
-
import { z as
|
|
852
|
-
var TransactionSourceSchema =
|
|
895
|
+
import { z as z17 } from "zod";
|
|
896
|
+
var TransactionSourceSchema = z17.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
|
|
853
897
|
"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)."
|
|
854
898
|
);
|
|
855
|
-
var TimelineEventTypeSchema =
|
|
899
|
+
var TimelineEventTypeSchema = z17.enum([
|
|
856
900
|
"charge.created",
|
|
857
901
|
"charge.expired",
|
|
902
|
+
"charge.canceled",
|
|
858
903
|
"transaction.detected",
|
|
859
904
|
"split.distributed",
|
|
860
905
|
"webhook.dispatched",
|
|
861
906
|
"webhook.delivered",
|
|
862
907
|
"webhook.failed"
|
|
863
908
|
]).describe(
|
|
864
|
-
"`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)."
|
|
909
|
+
"`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)."
|
|
865
910
|
);
|
|
866
|
-
var TimelineEventSchema =
|
|
911
|
+
var TimelineEventSchema = z17.object({
|
|
867
912
|
type: TimelineEventTypeSchema,
|
|
868
|
-
at:
|
|
869
|
-
txHash:
|
|
870
|
-
amount:
|
|
913
|
+
at: z17.string().datetime(),
|
|
914
|
+
txHash: z17.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
|
|
915
|
+
amount: z17.number().optional().describe(
|
|
871
916
|
"Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
|
|
872
917
|
),
|
|
873
918
|
source: TransactionSourceSchema.optional().describe(
|
|
@@ -879,66 +924,20 @@ var TimelineEventSchema = z16.object({
|
|
|
879
924
|
network: NetworkSchema.optional().describe(
|
|
880
925
|
"Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
|
|
881
926
|
),
|
|
882
|
-
causedTransition:
|
|
927
|
+
causedTransition: z17.boolean().optional().describe(
|
|
883
928
|
"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."
|
|
884
929
|
),
|
|
885
930
|
event: WebhookEventTypeSchema.optional().describe(
|
|
886
931
|
"Present for `webhook.*` events only \u2014 which event type this delivery was for."
|
|
887
932
|
),
|
|
888
|
-
responseCode:
|
|
933
|
+
responseCode: z17.number().nullable().optional().describe(
|
|
889
934
|
"Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
|
|
890
935
|
),
|
|
891
|
-
attempts:
|
|
936
|
+
attempts: z17.number().optional().describe(
|
|
892
937
|
"Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
|
|
893
938
|
)
|
|
894
939
|
});
|
|
895
940
|
|
|
896
|
-
// src/verify.ts
|
|
897
|
-
import { z as z17 } from "zod";
|
|
898
|
-
var SplitRecipientRoleSchema = z17.enum(["merchant", "klap_fee", "distributor_incentive"]).describe(
|
|
899
|
-
"`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`."
|
|
900
|
-
);
|
|
901
|
-
var VerifySplitEntrySchema = z17.object({
|
|
902
|
-
role: SplitRecipientRoleSchema,
|
|
903
|
-
address: z17.string().nullable().describe(
|
|
904
|
-
"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."
|
|
905
|
-
),
|
|
906
|
-
percentAllocation: z17.number().describe("This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%)."),
|
|
907
|
-
amountUSD: z17.number()
|
|
908
|
-
});
|
|
909
|
-
var VerifyPaymentSchema = z17.object({
|
|
910
|
-
token: TokenSchema,
|
|
911
|
-
network: NetworkSchema,
|
|
912
|
-
amountReceived: z17.number().describe("Cumulative amount received on this specific `(token, network)` pair."),
|
|
913
|
-
txHash: z17.string().describe("The on-chain transaction hash of the most recent transfer on this pair."),
|
|
914
|
-
explorerTxUrl: z17.string().describe("Direct link to `txHash` on the relevant block explorer."),
|
|
915
|
-
split: z17.array(VerifySplitEntrySchema).describe(
|
|
916
|
-
"The exact breakdown of where this pair's payment went \u2014 merchant's share, Klappay's fee, and (once settled) the settlement incentive."
|
|
917
|
-
),
|
|
918
|
-
splitTxHash: z17.string().nullable().describe(
|
|
919
|
-
"Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then."
|
|
920
|
-
),
|
|
921
|
-
settledAt: z17.string().datetime().nullable().describe(
|
|
922
|
-
"When settlement completed for this pair \u2014 the merchant's wallet actually has the funds. `null` until then."
|
|
923
|
-
)
|
|
924
|
-
});
|
|
925
|
-
var VerifyChargeSchema = z17.object({
|
|
926
|
-
id: z17.string(),
|
|
927
|
-
amount: z17.number().nullable().describe("The amount originally requested. `null` if the charge accepted any amount."),
|
|
928
|
-
amountReceived: z17.number().describe(
|
|
929
|
-
"The actual cumulative amount received across every contributing pair \u2014 can exceed `amount` on an overpayment."
|
|
930
|
-
),
|
|
931
|
-
confirmedAt: z17.string().datetime().nullable().describe(
|
|
932
|
-
"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."
|
|
933
|
-
),
|
|
934
|
-
splitAddress: z17.string().describe(
|
|
935
|
-
"The on-chain address the payment was sent to \u2014 identical across every accepted network."
|
|
936
|
-
),
|
|
937
|
-
payments: z17.array(VerifyPaymentSchema).describe(
|
|
938
|
-
"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."
|
|
939
|
-
)
|
|
940
|
-
});
|
|
941
|
-
|
|
942
941
|
// src/health.ts
|
|
943
942
|
import { z as z18 } from "zod";
|
|
944
943
|
var HealthSchema = z18.object({
|
|
@@ -992,7 +991,6 @@ export {
|
|
|
992
991
|
ChangePasswordSchema,
|
|
993
992
|
ChargeModeSchema,
|
|
994
993
|
ChargeSchema,
|
|
995
|
-
ChargeStatusEventSchema,
|
|
996
994
|
ChargeStatusSchema,
|
|
997
995
|
ChargeWebhookEventTypeSchema,
|
|
998
996
|
ChargesDateFieldSchema,
|
|
@@ -1010,6 +1008,8 @@ export {
|
|
|
1010
1008
|
EnvironmentSchema,
|
|
1011
1009
|
ErrorPayloadSchema,
|
|
1012
1010
|
ForgotPasswordSchema,
|
|
1011
|
+
GetChargeQrCodeQuerySchema,
|
|
1012
|
+
GetPublicChargeQuerySchema,
|
|
1013
1013
|
HealthSchema,
|
|
1014
1014
|
InvitationSchema,
|
|
1015
1015
|
InviteUserSchema,
|
|
@@ -1018,6 +1018,7 @@ export {
|
|
|
1018
1018
|
ListOrganizationsSchema,
|
|
1019
1019
|
ListUsersSchema,
|
|
1020
1020
|
ListWebhookDeliveriesSchema,
|
|
1021
|
+
ListenPendingDistributionsQuerySchema,
|
|
1021
1022
|
LoginSchema,
|
|
1022
1023
|
MAX_METRICS_QUERY_DATE_RANGE_DAYS,
|
|
1023
1024
|
METRICS_QUERY_DEFAULT_ROW_LIMIT,
|
|
@@ -1048,12 +1049,14 @@ export {
|
|
|
1048
1049
|
PaginatedApiKeysSchema,
|
|
1049
1050
|
PaginatedChargesSchema,
|
|
1050
1051
|
PaginatedOrganizationsSchema,
|
|
1052
|
+
PaginatedPendingDistributionsSchema,
|
|
1051
1053
|
PaginatedUsersSchema,
|
|
1052
1054
|
PaginatedWebhookDeliveriesSchema,
|
|
1053
1055
|
PaginationQuerySchema,
|
|
1054
1056
|
PendingDistributionEventSchema,
|
|
1055
1057
|
PendingDistributionRecipientSchema,
|
|
1056
1058
|
PendingDistributionSchema,
|
|
1059
|
+
PublicChargeSchema,
|
|
1057
1060
|
ResetPasswordSchema,
|
|
1058
1061
|
SandboxEventTriggerSchema,
|
|
1059
1062
|
SandboxTriggerSchema,
|
|
@@ -1062,7 +1065,6 @@ export {
|
|
|
1062
1065
|
SettlementStatusSchema,
|
|
1063
1066
|
SignupSchema,
|
|
1064
1067
|
SplitDistributionStatusSchema,
|
|
1065
|
-
SplitRecipientRoleSchema,
|
|
1066
1068
|
TOKEN_ADDRESSES,
|
|
1067
1069
|
TOKEN_DECIMALS,
|
|
1068
1070
|
TimelineEventSchema,
|
|
@@ -1077,10 +1079,7 @@ export {
|
|
|
1077
1079
|
UpdateUserRoleSchema,
|
|
1078
1080
|
UserRoleSchema,
|
|
1079
1081
|
UserSchema,
|
|
1080
|
-
VerifyChargeSchema,
|
|
1081
1082
|
VerifyEmailSchema,
|
|
1082
|
-
VerifyPaymentSchema,
|
|
1083
|
-
VerifySplitEntrySchema,
|
|
1084
1083
|
WEBHOOK_EVENTS_WILDCARD,
|
|
1085
1084
|
WEBHOOK_EVENT_CATEGORIES,
|
|
1086
1085
|
WebhookCategorySchema,
|