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