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