@klappay/types 1.0.4 → 1.0.6
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 +9 -8
- package/dist/index.d.mts +709 -30
- package/dist/index.d.ts +709 -30
- package/dist/index.js +457 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +433 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -35,9 +35,15 @@ __export(index_exports, {
|
|
|
35
35
|
ChargeStatusEventSchema: () => ChargeStatusEventSchema,
|
|
36
36
|
ChargeStatusSchema: () => ChargeStatusSchema,
|
|
37
37
|
ChargeWebhookEventTypeSchema: () => ChargeWebhookEventTypeSchema,
|
|
38
|
+
ChargesDateFieldSchema: () => ChargesDateFieldSchema,
|
|
39
|
+
ChargesMetricFieldSchema: () => ChargesMetricFieldSchema,
|
|
40
|
+
ChargesQueryFieldSchema: () => ChargesQueryFieldSchema,
|
|
38
41
|
CreateApiKeySchema: () => CreateApiKeySchema,
|
|
39
42
|
CreateChargeSchema: () => CreateChargeSchema,
|
|
40
43
|
CreateWebhookSchema: () => CreateWebhookSchema,
|
|
44
|
+
DistributionsDateFieldSchema: () => DistributionsDateFieldSchema,
|
|
45
|
+
DistributionsMetricFieldSchema: () => DistributionsMetricFieldSchema,
|
|
46
|
+
DistributionsQueryFieldSchema: () => DistributionsQueryFieldSchema,
|
|
41
47
|
EVENT_CATEGORY_MAP: () => EVENT_CATEGORY_MAP,
|
|
42
48
|
EVM_NETWORKS: () => EVM_NETWORKS,
|
|
43
49
|
EnvironmentSchema: () => EnvironmentSchema,
|
|
@@ -52,7 +58,21 @@ __export(index_exports, {
|
|
|
52
58
|
ListUsersSchema: () => ListUsersSchema,
|
|
53
59
|
ListWebhookDeliveriesSchema: () => ListWebhookDeliveriesSchema,
|
|
54
60
|
LoginSchema: () => LoginSchema,
|
|
61
|
+
MAX_METRICS_QUERY_DATE_RANGE_DAYS: () => MAX_METRICS_QUERY_DATE_RANGE_DAYS,
|
|
62
|
+
METRICS_QUERY_DEFAULT_ROW_LIMIT: () => METRICS_QUERY_DEFAULT_ROW_LIMIT,
|
|
63
|
+
METRICS_QUERY_MAX_FILTERS: () => METRICS_QUERY_MAX_FILTERS,
|
|
64
|
+
METRICS_QUERY_MAX_GROUP_BY: () => METRICS_QUERY_MAX_GROUP_BY,
|
|
65
|
+
METRICS_QUERY_MAX_METRICS: () => METRICS_QUERY_MAX_METRICS,
|
|
66
|
+
METRICS_QUERY_MAX_ROW_LIMIT: () => METRICS_QUERY_MAX_ROW_LIMIT,
|
|
55
67
|
MessageResponseSchema: () => MessageResponseSchema,
|
|
68
|
+
MetricsAggregationSchema: () => MetricsAggregationSchema,
|
|
69
|
+
MetricsDateGranularitySchema: () => MetricsDateGranularitySchema,
|
|
70
|
+
MetricsFilterOperatorSchema: () => MetricsFilterOperatorSchema,
|
|
71
|
+
MetricsQueryResultRowSchema: () => MetricsQueryResultRowSchema,
|
|
72
|
+
MetricsQueryResultSchema: () => MetricsQueryResultSchema,
|
|
73
|
+
MetricsQuerySchema: () => MetricsQuerySchema,
|
|
74
|
+
MetricsQueryScopeSchema: () => MetricsQueryScopeSchema,
|
|
75
|
+
MetricsResourceSchema: () => MetricsResourceSchema,
|
|
56
76
|
NETWORK_EXPLORERS: () => NETWORK_EXPLORERS,
|
|
57
77
|
NETWORK_LABELS: () => NETWORK_LABELS,
|
|
58
78
|
NetworkSchema: () => NetworkSchema,
|
|
@@ -79,6 +99,7 @@ __export(index_exports, {
|
|
|
79
99
|
SecurityWebhookEventTypeSchema: () => SecurityWebhookEventTypeSchema,
|
|
80
100
|
SettlementStatusSchema: () => SettlementStatusSchema,
|
|
81
101
|
SignupSchema: () => SignupSchema,
|
|
102
|
+
SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
|
|
82
103
|
SplitRecipientRoleSchema: () => SplitRecipientRoleSchema,
|
|
83
104
|
TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
|
|
84
105
|
TOKEN_DECIMALS: () => TOKEN_DECIMALS,
|
|
@@ -86,6 +107,9 @@ __export(index_exports, {
|
|
|
86
107
|
TimelineEventTypeSchema: () => TimelineEventTypeSchema,
|
|
87
108
|
TokenSchema: () => TokenSchema,
|
|
88
109
|
TransactionSourceSchema: () => TransactionSourceSchema,
|
|
110
|
+
TransactionsDateFieldSchema: () => TransactionsDateFieldSchema,
|
|
111
|
+
TransactionsMetricFieldSchema: () => TransactionsMetricFieldSchema,
|
|
112
|
+
TransactionsQueryFieldSchema: () => TransactionsQueryFieldSchema,
|
|
89
113
|
TriggerableChargeEventSchema: () => TriggerableChargeEventSchema,
|
|
90
114
|
UpdateOrganizationSchema: () => UpdateOrganizationSchema,
|
|
91
115
|
UpdateUserRoleSchema: () => UpdateUserRoleSchema,
|
|
@@ -193,7 +217,7 @@ function paginatedSchema(itemSchema) {
|
|
|
193
217
|
// src/tokens.ts
|
|
194
218
|
var import_zod5 = require("zod");
|
|
195
219
|
var TokenSchema = import_zod5.z.enum(["USDC", "USDT"]).describe(
|
|
196
|
-
`Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 not every token/network/environment combination is deployed; today, both \`USDC\` and \`USDT\` are deployed on every operational network's \`live\` side except BNB Chain (\`${OPERATIONAL_NETWORKS.join(", ")}\`), but \`test\` coverage varies per network \u2014 Base, Optimism, and Ethereum each have a \`test\` environment (\`USDC\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \`422 token_not_supported\`, not silently accepted. **BNB Chain's \`USDC\` address is Binance-Peg USDC, not an official Circle deployment** \u2014 Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \`TOKEN_ADDRESSES\` entry (all verified directly against their real issuer). Accepted at the payer's own risk \u2014
|
|
220
|
+
`Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 not every token/network/environment combination is deployed; today, both \`USDC\` and \`USDT\` are deployed on every operational network's \`live\` side except BNB Chain (\`${OPERATIONAL_NETWORKS.join(", ")}\`), but \`test\` coverage varies per network \u2014 Base, Optimism, and Ethereum each have a \`test\` environment (\`USDC\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \`422 token_not_supported\`, not silently accepted. **BNB Chain's \`USDC\` address is Binance-Peg USDC, not an official Circle deployment** \u2014 Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \`TOKEN_ADDRESSES\` entry (all verified directly against their real issuer). Accepted at the payer's own risk \u2014 Klappay does not verify or guarantee Binance's collateral backing it. \`USDT\` on BNB Chain is Tether's own official issuance, same trust model as everywhere else. More tokens/networks are expected to be added over time \u2014 check \`TOKEN_ADDRESSES\` in \`@klappay/types\` (or a future \`GET /v1/networks\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`
|
|
197
221
|
);
|
|
198
222
|
var TOKEN_DECIMALS = 6;
|
|
199
223
|
var TOKEN_ADDRESSES = {
|
|
@@ -282,7 +306,7 @@ var CreateChargeSchema = import_zod6.z.object({
|
|
|
282
306
|
"Scoped to your organization. Replaying the same key returns the original charge unchanged instead of creating a duplicate \u2014 safe to retry a request after a timeout without double-charging."
|
|
283
307
|
),
|
|
284
308
|
externalRef: import_zod6.z.string().min(1).max(255).optional().describe(
|
|
285
|
-
"An opaque correlation id from your own system (e.g. an order id) \u2014 echoed back on the charge and in every webhook payload. Not interpreted or validated by
|
|
309
|
+
"An opaque correlation id from your own system (e.g. an order id) \u2014 echoed back on the charge and in every webhook payload. Not interpreted or validated by Klappay."
|
|
286
310
|
),
|
|
287
311
|
source: import_zod6.z.string().min(1).max(64).optional().describe(
|
|
288
312
|
'Free-form label for what created this charge (e.g. `"checkout"`, `"invoice"`) \u2014 useful if you create charges from more than one flow and want to tell them apart later. Not a fixed enum; use whatever values make sense to you.'
|
|
@@ -298,7 +322,7 @@ var CreateChargeSchema = import_zod6.z.object({
|
|
|
298
322
|
}
|
|
299
323
|
});
|
|
300
324
|
var ChargeSchema = import_zod6.z.object({
|
|
301
|
-
id: import_zod6.z.string().describe("
|
|
325
|
+
id: import_zod6.z.string().describe("Klappay-generated id, e.g. `ch_...`. Use this to look up the charge later."),
|
|
302
326
|
mode: ChargeModeSchema,
|
|
303
327
|
amount: import_zod6.z.number().nullable().describe(
|
|
304
328
|
"The amount originally requested, in `currency` units (up to 6 decimal places). `null` if `amount` was omitted at creation \u2014 this charge accepts any amount, and the first credited transfer confirms it."
|
|
@@ -307,7 +331,7 @@ var ChargeSchema = import_zod6.z.object({
|
|
|
307
331
|
"Cumulative amount actually received on-chain so far, in `currency` units (up to 6 decimal places). `null` until the first transfer arrives. Can exceed `amount` \u2014 see `isOverpaid` \u2014 unless `amount` itself is `null`, in which case `isOverpaid` never applies."
|
|
308
332
|
),
|
|
309
333
|
isOverpaid: import_zod6.z.boolean().describe(
|
|
310
|
-
"`true` if `amountReceived` ended up greater than `amount`.
|
|
334
|
+
"`true` if `amountReceived` ended up greater than `amount`. Klappay never refunds the difference automatically \u2014 see the docs for why."
|
|
311
335
|
),
|
|
312
336
|
currency: import_zod6.z.string().describe("Always `USD` today \u2014 the only supported currency."),
|
|
313
337
|
acceptedPayments: import_zod6.z.array(AcceptedPaymentSchema).describe(
|
|
@@ -317,7 +341,7 @@ var ChargeSchema = import_zod6.z.object({
|
|
|
317
341
|
"Every distinct `(token, network)` pair that has actually contributed a credited transfer so far \u2014 empty until the first one arrives. Can hold more than one entry: a charge accepting several pairs can be paid across a combination of them, and every entry here sums toward `amountReceived`."
|
|
318
342
|
),
|
|
319
343
|
address: import_zod6.z.string().describe(
|
|
320
|
-
"The on-chain address the payer must send funds to \u2014 identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time \u2014 funds sent here go directly to the merchant,
|
|
344
|
+
"The on-chain address the payer must send funds to \u2014 identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time \u2014 funds sent here go directly to the merchant, Klappay never custodies them."
|
|
321
345
|
),
|
|
322
346
|
status: ChargeStatusSchema,
|
|
323
347
|
settlementStatus: SettlementStatusSchema.nullable(),
|
|
@@ -343,7 +367,7 @@ var ChargeSchema = import_zod6.z.object({
|
|
|
343
367
|
"When a transfer was last credited toward this charge, or `createdAt` if none has arrived yet. Only meaningful for a charge with no `expiresAt` \u2014 see `pausedAt`."
|
|
344
368
|
),
|
|
345
369
|
pausedAt: import_zod6.z.string().datetime().nullable().describe(
|
|
346
|
-
"Only ever set for a charge with no `expiresAt`: `null` means
|
|
370
|
+
"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."
|
|
347
371
|
)
|
|
348
372
|
});
|
|
349
373
|
var ListChargesSchema = import_zod6.z.object({
|
|
@@ -372,6 +396,9 @@ var ChargeStatusEventSchema = import_zod6.z.object({
|
|
|
372
396
|
|
|
373
397
|
// src/distributions.ts
|
|
374
398
|
var import_zod7 = require("zod");
|
|
399
|
+
var SplitDistributionStatusSchema = import_zod7.z.enum(["pending", "processing", "completed", "failed"]).describe(
|
|
400
|
+
"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."
|
|
401
|
+
);
|
|
375
402
|
var PendingDistributionRecipientSchema = import_zod7.z.object({
|
|
376
403
|
address: import_zod7.z.string().describe("On-chain recipient address."),
|
|
377
404
|
percentAllocation: import_zod7.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
|
|
@@ -387,11 +414,11 @@ var PendingDistributionSchema = import_zod7.z.object({
|
|
|
387
414
|
"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."
|
|
388
415
|
),
|
|
389
416
|
estimatedRewardAmount: import_zod7.z.number().describe(
|
|
390
|
-
"Estimate only, in the charge's `currency` units, based on the amount
|
|
417
|
+
"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."
|
|
391
418
|
),
|
|
392
419
|
availableSince: import_zod7.z.string().datetime().describe("When this distribution entered its grace period."),
|
|
393
420
|
graceEndsAt: import_zod7.z.string().datetime().describe(
|
|
394
|
-
"When
|
|
421
|
+
"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."
|
|
395
422
|
)
|
|
396
423
|
});
|
|
397
424
|
var PendingDistributionEventSchema = import_zod7.z.discriminatedUnion("type", [
|
|
@@ -405,9 +432,255 @@ var PendingDistributionEventSchema = import_zod7.z.discriminatedUnion("type", [
|
|
|
405
432
|
})
|
|
406
433
|
]);
|
|
407
434
|
|
|
408
|
-
// src/
|
|
435
|
+
// src/metrics.ts
|
|
409
436
|
var import_zod8 = require("zod");
|
|
410
|
-
var
|
|
437
|
+
var MetricsResourceSchema = import_zod8.z.enum(["charges", "transactions", "distributions"]).describe(
|
|
438
|
+
"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."
|
|
439
|
+
);
|
|
440
|
+
var MetricsAggregationSchema = import_zod8.z.enum(["count", "sum", "avg", "min", "max"]).describe(
|
|
441
|
+
"`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."
|
|
442
|
+
);
|
|
443
|
+
var MetricsFilterOperatorSchema = import_zod8.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
|
|
444
|
+
"`in` expects an array value (max 50 entries); every other operator expects a single scalar."
|
|
445
|
+
);
|
|
446
|
+
var MetricsDateGranularitySchema = import_zod8.z.enum(["day", "week", "month"]).describe(
|
|
447
|
+
"Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
|
|
448
|
+
);
|
|
449
|
+
var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
|
|
450
|
+
"Which environment's data to query \u2014 `live` or `test`. Independent of your session (a dashboard user isn't scoped to one environment the way an API key is) \u2014 scopes the query to charges/transactions/distributions created under a `live` or `test` API key respectively."
|
|
451
|
+
);
|
|
452
|
+
var MAX_METRICS_QUERY_DATE_RANGE_DAYS = 366;
|
|
453
|
+
var METRICS_QUERY_MAX_ROW_LIMIT = 1e3;
|
|
454
|
+
var METRICS_QUERY_DEFAULT_ROW_LIMIT = 100;
|
|
455
|
+
var METRICS_QUERY_MAX_GROUP_BY = 3;
|
|
456
|
+
var METRICS_QUERY_MAX_FILTERS = 20;
|
|
457
|
+
var METRICS_QUERY_MAX_METRICS = 10;
|
|
458
|
+
var METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
459
|
+
var metricAliasSchema = import_zod8.z.string().min(1).max(64).regex(
|
|
460
|
+
METRIC_ALIAS_PATTERN,
|
|
461
|
+
"Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 this becomes a SQL column alias."
|
|
462
|
+
).optional();
|
|
463
|
+
var MetricsFilterValueSchema = import_zod8.z.union([
|
|
464
|
+
import_zod8.z.string().max(255),
|
|
465
|
+
import_zod8.z.number(),
|
|
466
|
+
import_zod8.z.boolean(),
|
|
467
|
+
import_zod8.z.array(import_zod8.z.union([import_zod8.z.string().max(255), import_zod8.z.number()])).min(1).max(50)
|
|
468
|
+
]);
|
|
469
|
+
var orderBySchema = import_zod8.z.object({
|
|
470
|
+
key: import_zod8.z.string().min(1).max(64).regex(
|
|
471
|
+
METRIC_ALIAS_PATTERN,
|
|
472
|
+
"Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 every valid output column name already looks like this."
|
|
473
|
+
).describe(
|
|
474
|
+
"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."
|
|
475
|
+
),
|
|
476
|
+
direction: import_zod8.z.enum(["asc", "desc"])
|
|
477
|
+
}).describe(
|
|
478
|
+
"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."
|
|
479
|
+
);
|
|
480
|
+
var limitSchema = import_zod8.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
|
|
481
|
+
`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.`
|
|
482
|
+
);
|
|
483
|
+
var ChargesQueryFieldSchema = import_zod8.z.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
|
|
484
|
+
"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."
|
|
485
|
+
);
|
|
486
|
+
var ChargesMetricFieldSchema = import_zod8.z.enum(["amount", "amountReceived", "feePercent"]).describe(
|
|
487
|
+
"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%."
|
|
488
|
+
);
|
|
489
|
+
var ChargesDateFieldSchema = import_zod8.z.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
|
|
490
|
+
"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."
|
|
491
|
+
);
|
|
492
|
+
var ChargesFilterSchema = import_zod8.z.object({
|
|
493
|
+
field: ChargesQueryFieldSchema,
|
|
494
|
+
operator: MetricsFilterOperatorSchema,
|
|
495
|
+
value: MetricsFilterValueSchema
|
|
496
|
+
});
|
|
497
|
+
var ChargesGroupBySchema = import_zod8.z.union([
|
|
498
|
+
import_zod8.z.object({ type: import_zod8.z.literal("field"), field: ChargesQueryFieldSchema }),
|
|
499
|
+
import_zod8.z.object({
|
|
500
|
+
type: import_zod8.z.literal("date_bucket"),
|
|
501
|
+
field: ChargesDateFieldSchema,
|
|
502
|
+
granularity: MetricsDateGranularitySchema
|
|
503
|
+
})
|
|
504
|
+
]);
|
|
505
|
+
var ChargesMetricSchema = import_zod8.z.object({
|
|
506
|
+
aggregation: MetricsAggregationSchema,
|
|
507
|
+
field: ChargesMetricFieldSchema.optional(),
|
|
508
|
+
alias: metricAliasSchema
|
|
509
|
+
});
|
|
510
|
+
var ChargesMetricsQuerySchema = import_zod8.z.object({
|
|
511
|
+
resource: import_zod8.z.literal("charges"),
|
|
512
|
+
environment: metricsQueryEnvironmentSchema,
|
|
513
|
+
dateRange: import_zod8.z.object({
|
|
514
|
+
field: ChargesDateFieldSchema,
|
|
515
|
+
from: import_zod8.z.string().max(64).datetime(),
|
|
516
|
+
to: import_zod8.z.string().max(64).datetime()
|
|
517
|
+
}),
|
|
518
|
+
groupBy: import_zod8.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
519
|
+
metrics: import_zod8.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
520
|
+
filters: import_zod8.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
521
|
+
orderBy: orderBySchema.optional(),
|
|
522
|
+
limit: limitSchema
|
|
523
|
+
});
|
|
524
|
+
var TransactionsQueryFieldSchema = import_zod8.z.enum(["network", "token", "source", "causedTransition"]).describe(
|
|
525
|
+
"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)."
|
|
526
|
+
);
|
|
527
|
+
var TransactionsMetricFieldSchema = import_zod8.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
|
|
528
|
+
var TransactionsDateFieldSchema = import_zod8.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
|
|
529
|
+
var TransactionsFilterSchema = import_zod8.z.object({
|
|
530
|
+
field: TransactionsQueryFieldSchema,
|
|
531
|
+
operator: MetricsFilterOperatorSchema,
|
|
532
|
+
value: MetricsFilterValueSchema
|
|
533
|
+
});
|
|
534
|
+
var TransactionsGroupBySchema = import_zod8.z.union([
|
|
535
|
+
import_zod8.z.object({ type: import_zod8.z.literal("field"), field: TransactionsQueryFieldSchema }),
|
|
536
|
+
import_zod8.z.object({
|
|
537
|
+
type: import_zod8.z.literal("date_bucket"),
|
|
538
|
+
field: TransactionsDateFieldSchema,
|
|
539
|
+
granularity: MetricsDateGranularitySchema
|
|
540
|
+
})
|
|
541
|
+
]);
|
|
542
|
+
var TransactionsMetricSchema = import_zod8.z.object({
|
|
543
|
+
aggregation: MetricsAggregationSchema,
|
|
544
|
+
field: TransactionsMetricFieldSchema.optional(),
|
|
545
|
+
alias: metricAliasSchema
|
|
546
|
+
});
|
|
547
|
+
var TransactionsMetricsQuerySchema = import_zod8.z.object({
|
|
548
|
+
resource: import_zod8.z.literal("transactions"),
|
|
549
|
+
environment: metricsQueryEnvironmentSchema,
|
|
550
|
+
dateRange: import_zod8.z.object({
|
|
551
|
+
field: TransactionsDateFieldSchema,
|
|
552
|
+
from: import_zod8.z.string().max(64).datetime(),
|
|
553
|
+
to: import_zod8.z.string().max(64).datetime()
|
|
554
|
+
}),
|
|
555
|
+
groupBy: import_zod8.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
556
|
+
metrics: import_zod8.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
557
|
+
filters: import_zod8.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
558
|
+
orderBy: orderBySchema.optional(),
|
|
559
|
+
limit: limitSchema
|
|
560
|
+
});
|
|
561
|
+
var DistributionsQueryFieldSchema = import_zod8.z.enum(["status", "network", "token"]).describe(
|
|
562
|
+
"A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values."
|
|
563
|
+
);
|
|
564
|
+
var DistributionsMetricFieldSchema = import_zod8.z.enum(["attempts"]).describe(
|
|
565
|
+
"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."
|
|
566
|
+
);
|
|
567
|
+
var DistributionsDateFieldSchema = import_zod8.z.enum(["createdAt", "completedAt"]).describe(
|
|
568
|
+
"`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."
|
|
569
|
+
);
|
|
570
|
+
var DistributionsFilterSchema = import_zod8.z.object({
|
|
571
|
+
field: DistributionsQueryFieldSchema,
|
|
572
|
+
operator: MetricsFilterOperatorSchema,
|
|
573
|
+
value: MetricsFilterValueSchema
|
|
574
|
+
});
|
|
575
|
+
var DistributionsGroupBySchema = import_zod8.z.union([
|
|
576
|
+
import_zod8.z.object({ type: import_zod8.z.literal("field"), field: DistributionsQueryFieldSchema }),
|
|
577
|
+
import_zod8.z.object({
|
|
578
|
+
type: import_zod8.z.literal("date_bucket"),
|
|
579
|
+
field: DistributionsDateFieldSchema,
|
|
580
|
+
granularity: MetricsDateGranularitySchema
|
|
581
|
+
})
|
|
582
|
+
]);
|
|
583
|
+
var DistributionsMetricSchema = import_zod8.z.object({
|
|
584
|
+
aggregation: MetricsAggregationSchema,
|
|
585
|
+
field: DistributionsMetricFieldSchema.optional(),
|
|
586
|
+
alias: metricAliasSchema
|
|
587
|
+
});
|
|
588
|
+
var DistributionsMetricsQuerySchema = import_zod8.z.object({
|
|
589
|
+
resource: import_zod8.z.literal("distributions"),
|
|
590
|
+
environment: metricsQueryEnvironmentSchema,
|
|
591
|
+
dateRange: import_zod8.z.object({
|
|
592
|
+
field: DistributionsDateFieldSchema,
|
|
593
|
+
from: import_zod8.z.string().max(64).datetime(),
|
|
594
|
+
to: import_zod8.z.string().max(64).datetime()
|
|
595
|
+
}),
|
|
596
|
+
groupBy: import_zod8.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
597
|
+
metrics: import_zod8.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
598
|
+
filters: import_zod8.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
599
|
+
orderBy: orderBySchema.optional(),
|
|
600
|
+
limit: limitSchema
|
|
601
|
+
});
|
|
602
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
603
|
+
var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
604
|
+
ChargesMetricsQuerySchema,
|
|
605
|
+
TransactionsMetricsQuerySchema,
|
|
606
|
+
DistributionsMetricsQuerySchema
|
|
607
|
+
]).superRefine((input, ctx) => {
|
|
608
|
+
const from = new Date(input.dateRange.from);
|
|
609
|
+
const to = new Date(input.dateRange.to);
|
|
610
|
+
if (from >= to) {
|
|
611
|
+
ctx.addIssue({
|
|
612
|
+
code: import_zod8.z.ZodIssueCode.custom,
|
|
613
|
+
message: "`dateRange.from` must be before `dateRange.to`.",
|
|
614
|
+
path: ["dateRange", "from"]
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS;
|
|
618
|
+
if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {
|
|
619
|
+
ctx.addIssue({
|
|
620
|
+
code: import_zod8.z.ZodIssueCode.custom,
|
|
621
|
+
message: `\`dateRange\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,
|
|
622
|
+
path: ["dateRange", "to"]
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
const dateBucketCount = input.groupBy.filter((entry) => entry.type === "date_bucket").length;
|
|
626
|
+
if (dateBucketCount > 1) {
|
|
627
|
+
ctx.addIssue({
|
|
628
|
+
code: import_zod8.z.ZodIssueCode.custom,
|
|
629
|
+
message: "At most one `date_bucket` entry is allowed in `groupBy`.",
|
|
630
|
+
path: ["groupBy"]
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
input.metrics.forEach((metric, index) => {
|
|
634
|
+
if (metric.aggregation !== "count" && metric.field === void 0) {
|
|
635
|
+
ctx.addIssue({
|
|
636
|
+
code: import_zod8.z.ZodIssueCode.custom,
|
|
637
|
+
message: "`field` is required unless `aggregation` is `count`.",
|
|
638
|
+
path: ["metrics", index, "field"]
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
const aliases = input.metrics.map((metric) => metric.alias).filter((alias) => alias !== void 0);
|
|
643
|
+
if (new Set(aliases).size !== aliases.length) {
|
|
644
|
+
ctx.addIssue({
|
|
645
|
+
code: import_zod8.z.ZodIssueCode.custom,
|
|
646
|
+
message: "Every `metrics[].alias` must be unique.",
|
|
647
|
+
path: ["metrics"]
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
const reservedNames = /* @__PURE__ */ new Set(["bucket", ...input.groupBy.map((entry) => entry.field)]);
|
|
651
|
+
input.metrics.forEach((metric, index) => {
|
|
652
|
+
if (metric.alias !== void 0 && reservedNames.has(metric.alias)) {
|
|
653
|
+
ctx.addIssue({
|
|
654
|
+
code: import_zod8.z.ZodIssueCode.custom,
|
|
655
|
+
message: `\`alias\` "${metric.alias}" collides with a \`groupBy\` field name (or the reserved word "bucket") \u2014 choose a different alias.`,
|
|
656
|
+
path: ["metrics", index, "alias"]
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
var MetricsQueryResultRowSchema = import_zod8.z.record(
|
|
662
|
+
import_zod8.z.string(),
|
|
663
|
+
import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number(), import_zod8.z.boolean(), import_zod8.z.null()])
|
|
664
|
+
);
|
|
665
|
+
var MetricsQueryScopeSchema = import_zod8.z.enum(["owner_admin", "member"]).describe(
|
|
666
|
+
"`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."
|
|
667
|
+
);
|
|
668
|
+
var MetricsQueryResultSchema = import_zod8.z.object({
|
|
669
|
+
data: import_zod8.z.array(MetricsQueryResultRowSchema),
|
|
670
|
+
meta: import_zod8.z.object({
|
|
671
|
+
resource: MetricsResourceSchema,
|
|
672
|
+
environment: EnvironmentSchema,
|
|
673
|
+
scope: MetricsQueryScopeSchema,
|
|
674
|
+
rowCount: import_zod8.z.number().int().describe("Number of rows in `data`."),
|
|
675
|
+
truncated: import_zod8.z.boolean().describe(
|
|
676
|
+
"`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
|
|
677
|
+
)
|
|
678
|
+
})
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
// src/webhook-events.ts
|
|
682
|
+
var import_zod9 = require("zod");
|
|
683
|
+
var ChargeWebhookEventTypeSchema = import_zod9.z.enum([
|
|
411
684
|
"charge.created",
|
|
412
685
|
"charge.partially_paid",
|
|
413
686
|
"charge.confirmed",
|
|
@@ -421,9 +694,9 @@ var ChargeWebhookEventTypeSchema = import_zod8.z.enum([
|
|
|
421
694
|
"charge.contribution_received",
|
|
422
695
|
"charge.contribution_settled"
|
|
423
696
|
]).describe(
|
|
424
|
-
'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
|
|
697
|
+
'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 }`.'
|
|
425
698
|
);
|
|
426
|
-
var AccountWebhookEventTypeSchema =
|
|
699
|
+
var AccountWebhookEventTypeSchema = import_zod9.z.enum([
|
|
427
700
|
"payout_address.changed",
|
|
428
701
|
"api_key.created",
|
|
429
702
|
"api_key.revoked",
|
|
@@ -437,10 +710,10 @@ var AccountWebhookEventTypeSchema = import_zod8.z.enum([
|
|
|
437
710
|
]).describe(
|
|
438
711
|
"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 }`."
|
|
439
712
|
);
|
|
440
|
-
var WebhookDeliveryEventTypeSchema =
|
|
713
|
+
var WebhookDeliveryEventTypeSchema = import_zod9.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
|
|
441
714
|
"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`)."
|
|
442
715
|
);
|
|
443
|
-
var SecurityWebhookEventTypeSchema =
|
|
716
|
+
var SecurityWebhookEventTypeSchema = import_zod9.z.enum([
|
|
444
717
|
"auth.login",
|
|
445
718
|
"auth.login_failed",
|
|
446
719
|
"auth.suspicious_activity",
|
|
@@ -450,13 +723,13 @@ var SecurityWebhookEventTypeSchema = import_zod8.z.enum([
|
|
|
450
723
|
]).describe(
|
|
451
724
|
"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. `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`: `{ userId, email }`."
|
|
452
725
|
);
|
|
453
|
-
var WebhookEventTypeSchema =
|
|
726
|
+
var WebhookEventTypeSchema = import_zod9.z.union([
|
|
454
727
|
ChargeWebhookEventTypeSchema,
|
|
455
728
|
AccountWebhookEventTypeSchema,
|
|
456
729
|
WebhookDeliveryEventTypeSchema,
|
|
457
730
|
SecurityWebhookEventTypeSchema
|
|
458
731
|
]);
|
|
459
|
-
var WebhookCategorySchema =
|
|
732
|
+
var WebhookCategorySchema = import_zod9.z.enum(["payments", "account", "webhooks", "security"]).describe(
|
|
460
733
|
"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."
|
|
461
734
|
);
|
|
462
735
|
function buildCategoryMap() {
|
|
@@ -483,99 +756,101 @@ var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
|
|
|
483
756
|
]).describe(
|
|
484
757
|
"Every charge event that represents a payment-progress state transition a sandbox charge can be pushed into \u2014 everything except `charge.created` (a charge already exists by the time you have an id to trigger against), `charge.paused`/`charge.reactivated` (driven by a background worker on real inactivity, not a payment state \u2014 nothing meaningful to simulate or wait for on a fresh sandbox charge), and `charge.contribution_received`/`charge.contribution_settled` (exclusive to `mode: continuous` charges, which this trigger endpoint does not support simulating today \u2014 see `POST /v1/charges/{id}/trigger`'s own description)."
|
|
485
758
|
);
|
|
486
|
-
var NonChargeTriggerableEventSchema =
|
|
759
|
+
var NonChargeTriggerableEventSchema = import_zod9.z.union([
|
|
487
760
|
AccountWebhookEventTypeSchema,
|
|
488
761
|
WebhookDeliveryEventTypeSchema,
|
|
489
762
|
SecurityWebhookEventTypeSchema
|
|
490
763
|
]);
|
|
491
764
|
|
|
492
765
|
// src/webhooks.ts
|
|
493
|
-
var
|
|
766
|
+
var import_zod10 = require("zod");
|
|
494
767
|
var WEBHOOK_EVENTS_WILDCARD = "*";
|
|
495
|
-
var CreateWebhookSchema =
|
|
496
|
-
url:
|
|
768
|
+
var CreateWebhookSchema = import_zod10.z.object({
|
|
769
|
+
url: import_zod10.z.string().max(2048).url().describe(
|
|
497
770
|
"Must be HTTPS and resolve to a public address \u2014 private/internal IPs are rejected."
|
|
498
771
|
),
|
|
499
|
-
events:
|
|
772
|
+
events: import_zod10.z.array(import_zod10.z.union([WebhookEventTypeSchema, import_zod10.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
|
|
500
773
|
'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.'
|
|
501
774
|
),
|
|
502
|
-
eventCategories:
|
|
775
|
+
eventCategories: import_zod10.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
|
|
503
776
|
"Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required."
|
|
504
777
|
),
|
|
505
|
-
excludeEvents:
|
|
778
|
+
excludeEvents: import_zod10.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
|
|
506
779
|
'Event types to exclude even if selected via `events: ["*"]` or `eventCategories`.'
|
|
507
780
|
)
|
|
508
781
|
}).refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {
|
|
509
782
|
message: "must select at least one event via `events` or `eventCategories`",
|
|
510
783
|
path: ["events"]
|
|
511
784
|
});
|
|
512
|
-
var WebhookSchema =
|
|
513
|
-
id:
|
|
514
|
-
url:
|
|
515
|
-
events:
|
|
516
|
-
eventCategories:
|
|
517
|
-
excludeEvents:
|
|
518
|
-
isWildcard:
|
|
519
|
-
secret:
|
|
520
|
-
"The signing secret, used to verify the `X-
|
|
785
|
+
var WebhookSchema = import_zod10.z.object({
|
|
786
|
+
id: import_zod10.z.string(),
|
|
787
|
+
url: import_zod10.z.string(),
|
|
788
|
+
events: import_zod10.z.array(WebhookEventTypeSchema),
|
|
789
|
+
eventCategories: import_zod10.z.array(WebhookCategorySchema),
|
|
790
|
+
excludeEvents: import_zod10.z.array(WebhookEventTypeSchema),
|
|
791
|
+
isWildcard: import_zod10.z.boolean(),
|
|
792
|
+
secret: import_zod10.z.string().describe(
|
|
793
|
+
"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."
|
|
521
794
|
),
|
|
522
|
-
createdAt:
|
|
795
|
+
createdAt: import_zod10.z.string().datetime()
|
|
523
796
|
});
|
|
524
797
|
var WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({
|
|
525
|
-
hint:
|
|
798
|
+
hint: import_zod10.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
|
|
526
799
|
});
|
|
527
|
-
var WebhookPayloadSchema =
|
|
528
|
-
id:
|
|
800
|
+
var WebhookPayloadSchema = import_zod10.z.object({
|
|
801
|
+
id: import_zod10.z.string().describe(
|
|
802
|
+
"Unique id for this specific delivery \u2014 also sent as the `X-Klappay-Delivery` header."
|
|
803
|
+
),
|
|
529
804
|
event: WebhookEventTypeSchema,
|
|
530
|
-
createdAt:
|
|
531
|
-
data:
|
|
805
|
+
createdAt: import_zod10.z.string().datetime(),
|
|
806
|
+
data: import_zod10.z.unknown().describe(
|
|
532
807
|
"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."
|
|
533
808
|
)
|
|
534
809
|
});
|
|
535
|
-
var WebhookDeliveryStatusSchema =
|
|
536
|
-
var WebhookDeliverySchema =
|
|
537
|
-
id:
|
|
538
|
-
webhookId:
|
|
810
|
+
var WebhookDeliveryStatusSchema = import_zod10.z.enum(["pending", "delivered", "failed"]);
|
|
811
|
+
var WebhookDeliverySchema = import_zod10.z.object({
|
|
812
|
+
id: import_zod10.z.string(),
|
|
813
|
+
webhookId: import_zod10.z.string(),
|
|
539
814
|
event: WebhookEventTypeSchema,
|
|
540
815
|
status: WebhookDeliveryStatusSchema.describe(
|
|
541
816
|
"`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."
|
|
542
817
|
),
|
|
543
|
-
attempts:
|
|
544
|
-
responseCode:
|
|
818
|
+
attempts: import_zod10.z.number(),
|
|
819
|
+
responseCode: import_zod10.z.number().nullable().describe(
|
|
545
820
|
"HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all."
|
|
546
821
|
),
|
|
547
|
-
nextRetryAt:
|
|
548
|
-
deliveredAt:
|
|
549
|
-
createdAt:
|
|
822
|
+
nextRetryAt: import_zod10.z.string().datetime().nullable(),
|
|
823
|
+
deliveredAt: import_zod10.z.string().datetime().nullable(),
|
|
824
|
+
createdAt: import_zod10.z.string().datetime()
|
|
550
825
|
});
|
|
551
826
|
var ListWebhookDeliveriesSchema = PaginationQuerySchema;
|
|
552
827
|
var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
|
|
553
828
|
|
|
554
829
|
// src/api-keys.ts
|
|
555
|
-
var
|
|
556
|
-
var CreateApiKeySchema =
|
|
557
|
-
name:
|
|
830
|
+
var import_zod11 = require("zod");
|
|
831
|
+
var CreateApiKeySchema = import_zod11.z.object({
|
|
832
|
+
name: import_zod11.z.string().min(1).max(64).describe(
|
|
558
833
|
'A label to help you tell keys apart (e.g. `"production backend"`). Not used for anything functional.'
|
|
559
834
|
),
|
|
560
835
|
environment: EnvironmentSchema.describe(
|
|
561
836
|
"`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."
|
|
562
837
|
)
|
|
563
838
|
});
|
|
564
|
-
var ApiKeySchema =
|
|
565
|
-
id:
|
|
566
|
-
name:
|
|
839
|
+
var ApiKeySchema = import_zod11.z.object({
|
|
840
|
+
id: import_zod11.z.string(),
|
|
841
|
+
name: import_zod11.z.string(),
|
|
567
842
|
environment: EnvironmentSchema.describe(
|
|
568
843
|
"`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."
|
|
569
844
|
),
|
|
570
|
-
key:
|
|
845
|
+
key: import_zod11.z.string().optional().describe(
|
|
571
846
|
"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."
|
|
572
847
|
),
|
|
573
|
-
hint:
|
|
848
|
+
hint: import_zod11.z.string().describe(
|
|
574
849
|
"A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't."
|
|
575
850
|
),
|
|
576
|
-
createdAt:
|
|
577
|
-
lastUsedAt:
|
|
578
|
-
createdByUserId:
|
|
851
|
+
createdAt: import_zod11.z.string().datetime(),
|
|
852
|
+
lastUsedAt: import_zod11.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
|
|
853
|
+
createdByUserId: import_zod11.z.string().nullable().describe(
|
|
579
854
|
"Which member of the organization created this key. `null` for a key created before this field existed."
|
|
580
855
|
)
|
|
581
856
|
});
|
|
@@ -583,76 +858,78 @@ var ListApiKeysSchema = PaginationQuerySchema;
|
|
|
583
858
|
var PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema);
|
|
584
859
|
|
|
585
860
|
// src/users.ts
|
|
586
|
-
var
|
|
587
|
-
var UserRoleSchema =
|
|
861
|
+
var import_zod12 = require("zod");
|
|
862
|
+
var UserRoleSchema = import_zod12.z.enum(["owner", "admin", "member"]).describe(
|
|
588
863
|
"`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`."
|
|
589
864
|
);
|
|
590
|
-
var UpdateUserRoleSchema =
|
|
865
|
+
var UpdateUserRoleSchema = import_zod12.z.object({
|
|
591
866
|
role: UserRoleSchema
|
|
592
867
|
});
|
|
593
|
-
var UserSchema =
|
|
594
|
-
id:
|
|
595
|
-
email:
|
|
596
|
-
name:
|
|
868
|
+
var UserSchema = import_zod12.z.object({
|
|
869
|
+
id: import_zod12.z.string(),
|
|
870
|
+
email: import_zod12.z.string(),
|
|
871
|
+
name: import_zod12.z.string().nullable(),
|
|
597
872
|
role: UserRoleSchema.describe("Your role within the organization this user was fetched from."),
|
|
598
|
-
emailVerifiedAt:
|
|
873
|
+
emailVerifiedAt: import_zod12.z.string().datetime().nullable().describe(
|
|
599
874
|
"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."
|
|
600
875
|
),
|
|
601
|
-
createdAt:
|
|
876
|
+
createdAt: import_zod12.z.string().datetime()
|
|
602
877
|
});
|
|
603
878
|
var ListUsersSchema = PaginationQuerySchema;
|
|
604
879
|
var PaginatedUsersSchema = paginatedSchema(UserSchema);
|
|
605
880
|
|
|
606
881
|
// src/auth.ts
|
|
607
|
-
var
|
|
608
|
-
var NormalizedEmailSchema =
|
|
882
|
+
var import_zod13 = require("zod");
|
|
883
|
+
var NormalizedEmailSchema = import_zod13.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
|
|
609
884
|
"Trimmed, lowercased, and NFC-normalized server-side before use \u2014 case/whitespace don't matter."
|
|
610
885
|
);
|
|
611
|
-
var SignupSchema =
|
|
886
|
+
var SignupSchema = import_zod13.z.object({
|
|
612
887
|
email: NormalizedEmailSchema,
|
|
613
|
-
password:
|
|
888
|
+
password: import_zod13.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
|
|
614
889
|
});
|
|
615
|
-
var LoginSchema =
|
|
890
|
+
var LoginSchema = import_zod13.z.object({
|
|
616
891
|
email: NormalizedEmailSchema,
|
|
617
|
-
password:
|
|
892
|
+
password: import_zod13.z.string().min(1).max(128)
|
|
618
893
|
});
|
|
619
|
-
var VerifyEmailSchema =
|
|
620
|
-
token:
|
|
894
|
+
var VerifyEmailSchema = import_zod13.z.object({
|
|
895
|
+
token: import_zod13.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
|
|
621
896
|
});
|
|
622
|
-
var ForgotPasswordSchema =
|
|
897
|
+
var ForgotPasswordSchema = import_zod13.z.object({
|
|
623
898
|
email: NormalizedEmailSchema
|
|
624
899
|
});
|
|
625
|
-
var ResetPasswordSchema =
|
|
626
|
-
token:
|
|
627
|
-
newPassword:
|
|
900
|
+
var ResetPasswordSchema = import_zod13.z.object({
|
|
901
|
+
token: import_zod13.z.string().min(1).describe("The token from the password reset email."),
|
|
902
|
+
newPassword: import_zod13.z.string().min(8).max(128)
|
|
628
903
|
});
|
|
629
|
-
var MessageResponseSchema =
|
|
630
|
-
message:
|
|
904
|
+
var MessageResponseSchema = import_zod13.z.object({
|
|
905
|
+
message: import_zod13.z.string().describe("Human-readable confirmation, safe to show a user directly.")
|
|
631
906
|
});
|
|
632
|
-
var AuthResponseSchema =
|
|
633
|
-
token:
|
|
907
|
+
var AuthResponseSchema = import_zod13.z.object({
|
|
908
|
+
token: import_zod13.z.string().describe(
|
|
634
909
|
"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."
|
|
635
910
|
),
|
|
636
911
|
user: UserSchema.omit({ createdAt: true, role: true })
|
|
637
912
|
});
|
|
638
913
|
|
|
639
914
|
// src/organization.ts
|
|
640
|
-
var
|
|
641
|
-
var UpdateOrganizationSchema =
|
|
642
|
-
name:
|
|
643
|
-
payoutAddress:
|
|
915
|
+
var import_zod14 = require("zod");
|
|
916
|
+
var UpdateOrganizationSchema = import_zod14.z.object({
|
|
917
|
+
name: import_zod14.z.string().min(1).max(255).optional().describe("The organization's display name."),
|
|
918
|
+
payoutAddress: import_zod14.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
|
|
644
919
|
"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."
|
|
645
920
|
)
|
|
646
921
|
});
|
|
647
|
-
var OrganizationSchema =
|
|
648
|
-
id:
|
|
649
|
-
name:
|
|
650
|
-
payoutAddress:
|
|
651
|
-
currentFeePercent:
|
|
652
|
-
"Your current platform fee percentage, based on trailing monthly volume
|
|
922
|
+
var OrganizationSchema = import_zod14.z.object({
|
|
923
|
+
id: import_zod14.z.string(),
|
|
924
|
+
name: import_zod14.z.string(),
|
|
925
|
+
payoutAddress: import_zod14.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
|
|
926
|
+
currentFeePercent: import_zod14.z.number().describe(
|
|
927
|
+
"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."
|
|
653
928
|
),
|
|
654
|
-
feeUpdatedAt:
|
|
655
|
-
|
|
929
|
+
feeUpdatedAt: import_zod14.z.string().datetime().nullable().describe(
|
|
930
|
+
"When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up."
|
|
931
|
+
),
|
|
932
|
+
createdAt: import_zod14.z.string().datetime()
|
|
656
933
|
});
|
|
657
934
|
var OrganizationWithRoleSchema = OrganizationSchema.extend({
|
|
658
935
|
role: UserRoleSchema.describe("Your own role within this specific organization.")
|
|
@@ -661,35 +938,35 @@ var PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema);
|
|
|
661
938
|
var ListOrganizationsSchema = PaginationQuerySchema;
|
|
662
939
|
|
|
663
940
|
// src/invitations.ts
|
|
664
|
-
var
|
|
665
|
-
var InviteUserSchema =
|
|
941
|
+
var import_zod15 = require("zod");
|
|
942
|
+
var InviteUserSchema = import_zod15.z.object({
|
|
666
943
|
email: NormalizedEmailSchema,
|
|
667
944
|
role: UserRoleSchema.default("member").describe(
|
|
668
945
|
"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`."
|
|
669
946
|
)
|
|
670
947
|
});
|
|
671
|
-
var AcceptInvitationSchema =
|
|
672
|
-
token:
|
|
673
|
-
password:
|
|
674
|
-
"Required only if the invited email has no existing
|
|
948
|
+
var AcceptInvitationSchema = import_zod15.z.object({
|
|
949
|
+
token: import_zod15.z.string().min(1).describe("The token from the invitation email."),
|
|
950
|
+
password: import_zod15.z.string().min(8).max(128).optional().describe(
|
|
951
|
+
"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."
|
|
675
952
|
)
|
|
676
953
|
});
|
|
677
|
-
var InvitationSchema =
|
|
678
|
-
id:
|
|
679
|
-
organizationId:
|
|
680
|
-
email:
|
|
954
|
+
var InvitationSchema = import_zod15.z.object({
|
|
955
|
+
id: import_zod15.z.string(),
|
|
956
|
+
organizationId: import_zod15.z.string(),
|
|
957
|
+
email: import_zod15.z.string(),
|
|
681
958
|
role: UserRoleSchema,
|
|
682
|
-
invitedByUserId:
|
|
683
|
-
expiresAt:
|
|
684
|
-
createdAt:
|
|
959
|
+
invitedByUserId: import_zod15.z.string().describe("Which member of the organization sent this invitation."),
|
|
960
|
+
expiresAt: import_zod15.z.string().datetime(),
|
|
961
|
+
createdAt: import_zod15.z.string().datetime()
|
|
685
962
|
});
|
|
686
963
|
|
|
687
964
|
// src/timeline.ts
|
|
688
|
-
var
|
|
689
|
-
var TransactionSourceSchema =
|
|
965
|
+
var import_zod16 = require("zod");
|
|
966
|
+
var TransactionSourceSchema = import_zod16.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
|
|
690
967
|
"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)."
|
|
691
968
|
);
|
|
692
|
-
var TimelineEventTypeSchema =
|
|
969
|
+
var TimelineEventTypeSchema = import_zod16.z.enum([
|
|
693
970
|
"charge.created",
|
|
694
971
|
"charge.expired",
|
|
695
972
|
"transaction.detected",
|
|
@@ -700,11 +977,11 @@ var TimelineEventTypeSchema = import_zod15.z.enum([
|
|
|
700
977
|
]).describe(
|
|
701
978
|
"`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)."
|
|
702
979
|
);
|
|
703
|
-
var TimelineEventSchema =
|
|
980
|
+
var TimelineEventSchema = import_zod16.z.object({
|
|
704
981
|
type: TimelineEventTypeSchema,
|
|
705
|
-
at:
|
|
706
|
-
txHash:
|
|
707
|
-
amount:
|
|
982
|
+
at: import_zod16.z.string().datetime(),
|
|
983
|
+
txHash: import_zod16.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
|
|
984
|
+
amount: import_zod16.z.number().optional().describe(
|
|
708
985
|
"Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
|
|
709
986
|
),
|
|
710
987
|
source: TransactionSourceSchema.optional().describe(
|
|
@@ -716,100 +993,100 @@ var TimelineEventSchema = import_zod15.z.object({
|
|
|
716
993
|
network: NetworkSchema.optional().describe(
|
|
717
994
|
"Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
|
|
718
995
|
),
|
|
719
|
-
causedTransition:
|
|
996
|
+
causedTransition: import_zod16.z.boolean().optional().describe(
|
|
720
997
|
"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."
|
|
721
998
|
),
|
|
722
999
|
event: WebhookEventTypeSchema.optional().describe(
|
|
723
1000
|
"Present for `webhook.*` events only \u2014 which event type this delivery was for."
|
|
724
1001
|
),
|
|
725
|
-
responseCode:
|
|
1002
|
+
responseCode: import_zod16.z.number().nullable().optional().describe(
|
|
726
1003
|
"Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
|
|
727
1004
|
),
|
|
728
|
-
attempts:
|
|
1005
|
+
attempts: import_zod16.z.number().optional().describe(
|
|
729
1006
|
"Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
|
|
730
1007
|
)
|
|
731
1008
|
});
|
|
732
1009
|
|
|
733
1010
|
// src/verify.ts
|
|
734
|
-
var
|
|
735
|
-
var SplitRecipientRoleSchema =
|
|
736
|
-
"`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
|
|
1011
|
+
var import_zod17 = require("zod");
|
|
1012
|
+
var SplitRecipientRoleSchema = import_zod17.z.enum(["merchant", "klap_fee", "distributor_incentive"]).describe(
|
|
1013
|
+
"`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`."
|
|
737
1014
|
);
|
|
738
|
-
var VerifySplitEntrySchema =
|
|
1015
|
+
var VerifySplitEntrySchema = import_zod17.z.object({
|
|
739
1016
|
role: SplitRecipientRoleSchema,
|
|
740
|
-
address:
|
|
1017
|
+
address: import_zod17.z.string().nullable().describe(
|
|
741
1018
|
"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."
|
|
742
1019
|
),
|
|
743
|
-
percentAllocation:
|
|
744
|
-
amountUSD:
|
|
1020
|
+
percentAllocation: import_zod17.z.number().describe("This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%)."),
|
|
1021
|
+
amountUSD: import_zod17.z.number()
|
|
745
1022
|
});
|
|
746
|
-
var VerifyPaymentSchema =
|
|
1023
|
+
var VerifyPaymentSchema = import_zod17.z.object({
|
|
747
1024
|
token: TokenSchema,
|
|
748
1025
|
network: NetworkSchema,
|
|
749
|
-
amountReceived:
|
|
750
|
-
txHash:
|
|
751
|
-
explorerTxUrl:
|
|
752
|
-
split:
|
|
753
|
-
"The exact breakdown of where this pair's payment went \u2014 merchant's share,
|
|
1026
|
+
amountReceived: import_zod17.z.number().describe("Cumulative amount received on this specific `(token, network)` pair."),
|
|
1027
|
+
txHash: import_zod17.z.string().describe("The on-chain transaction hash of the most recent transfer on this pair."),
|
|
1028
|
+
explorerTxUrl: import_zod17.z.string().describe("Direct link to `txHash` on the relevant block explorer."),
|
|
1029
|
+
split: import_zod17.z.array(VerifySplitEntrySchema).describe(
|
|
1030
|
+
"The exact breakdown of where this pair's payment went \u2014 merchant's share, Klappay's fee, and (once settled) the settlement incentive."
|
|
754
1031
|
),
|
|
755
|
-
splitTxHash:
|
|
1032
|
+
splitTxHash: import_zod17.z.string().nullable().describe(
|
|
756
1033
|
"Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then."
|
|
757
1034
|
),
|
|
758
|
-
settledAt:
|
|
1035
|
+
settledAt: import_zod17.z.string().datetime().nullable().describe(
|
|
759
1036
|
"When settlement completed for this pair \u2014 the merchant's wallet actually has the funds. `null` until then."
|
|
760
1037
|
)
|
|
761
1038
|
});
|
|
762
|
-
var VerifyChargeSchema =
|
|
763
|
-
id:
|
|
764
|
-
amount:
|
|
765
|
-
amountReceived:
|
|
1039
|
+
var VerifyChargeSchema = import_zod17.z.object({
|
|
1040
|
+
id: import_zod17.z.string(),
|
|
1041
|
+
amount: import_zod17.z.number().nullable().describe("The amount originally requested. `null` if the charge accepted any amount."),
|
|
1042
|
+
amountReceived: import_zod17.z.number().describe(
|
|
766
1043
|
"The actual cumulative amount received across every contributing pair \u2014 can exceed `amount` on an overpayment."
|
|
767
1044
|
),
|
|
768
|
-
confirmedAt:
|
|
1045
|
+
confirmedAt: import_zod17.z.string().datetime().nullable().describe(
|
|
769
1046
|
"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."
|
|
770
1047
|
),
|
|
771
|
-
splitAddress:
|
|
1048
|
+
splitAddress: import_zod17.z.string().describe(
|
|
772
1049
|
"The on-chain address the payment was sent to \u2014 identical across every accepted network."
|
|
773
1050
|
),
|
|
774
|
-
payments:
|
|
1051
|
+
payments: import_zod17.z.array(VerifyPaymentSchema).describe(
|
|
775
1052
|
"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."
|
|
776
1053
|
)
|
|
777
1054
|
});
|
|
778
1055
|
|
|
779
1056
|
// src/health.ts
|
|
780
|
-
var
|
|
781
|
-
var HealthSchema =
|
|
782
|
-
status:
|
|
1057
|
+
var import_zod18 = require("zod");
|
|
1058
|
+
var HealthSchema = import_zod18.z.object({
|
|
1059
|
+
status: import_zod18.z.enum(["ok", "error"]).describe(
|
|
783
1060
|
"`error` when the database connectivity check fails \u2014 the HTTP status code mirrors this (503 instead of 200), so a plain uptime check (not just a JSON-aware one) still catches a DB outage."
|
|
784
1061
|
),
|
|
785
|
-
version:
|
|
786
|
-
timestamp:
|
|
787
|
-
db:
|
|
788
|
-
pendingWebhooks:
|
|
789
|
-
oldestPendingChargeAgeSeconds:
|
|
790
|
-
lastMoralisEventAgeSeconds:
|
|
1062
|
+
version: import_zod18.z.string(),
|
|
1063
|
+
timestamp: import_zod18.z.string().datetime(),
|
|
1064
|
+
db: import_zod18.z.enum(["ok", "error"]).describe("Result of a real database connectivity check, not just a process-alive check."),
|
|
1065
|
+
pendingWebhooks: import_zod18.z.number().describe("Count of webhook deliveries still awaiting a successful attempt."),
|
|
1066
|
+
oldestPendingChargeAgeSeconds: import_zod18.z.number().nullable().describe("Age of the oldest still-unpaid charge, in seconds. `null` if there are none."),
|
|
1067
|
+
lastMoralisEventAgeSeconds: import_zod18.z.number().nullable().describe(
|
|
791
1068
|
"Seconds since the last on-chain payment notification was received \u2014 a cheap signal for whether payment detection is currently working. `null` if none have ever been received."
|
|
792
1069
|
)
|
|
793
1070
|
});
|
|
794
1071
|
|
|
795
1072
|
// src/sandbox.ts
|
|
796
|
-
var
|
|
797
|
-
var SandboxTriggerSchema =
|
|
1073
|
+
var import_zod19 = require("zod");
|
|
1074
|
+
var SandboxTriggerSchema = import_zod19.z.object({
|
|
798
1075
|
event: TriggerableChargeEventSchema,
|
|
799
|
-
amount:
|
|
1076
|
+
amount: import_zod19.z.number().positive().max(CHARGE_AMOUNT_MAX).optional().describe(
|
|
800
1077
|
"Used with `charge.partially_paid` (amount to simulate as received so far \u2014 must be less than the charge amount, defaults to half of it if omitted) and with `charge.overpaid` (amount received \u2014 must be greater than the charge amount, defaults to 1.5x it if omitted). Ignored for every other event."
|
|
801
1078
|
)
|
|
802
1079
|
});
|
|
803
|
-
var SandboxEventTriggerSchema =
|
|
1080
|
+
var SandboxEventTriggerSchema = import_zod19.z.object({
|
|
804
1081
|
event: NonChargeTriggerableEventSchema.describe(
|
|
805
1082
|
"Any account, security, or webhook-delivery event \u2014 simulates it with synthetic data against your own webhooks, no real state change or precondition required (unlike `POST /v1/sandbox/charges/{id}/trigger`, which acts on a real charge)."
|
|
806
1083
|
)
|
|
807
1084
|
});
|
|
808
1085
|
|
|
809
1086
|
// src/capabilities.ts
|
|
810
|
-
var
|
|
811
|
-
var CapabilitiesSchema =
|
|
812
|
-
acceptedPayments:
|
|
1087
|
+
var import_zod20 = require("zod");
|
|
1088
|
+
var CapabilitiesSchema = import_zod20.z.object({
|
|
1089
|
+
acceptedPayments: import_zod20.z.array(AcceptedPaymentSchema).describe(
|
|
813
1090
|
"Every `(token, network)` pair actually configured for your environment right now \u2014 read straight from the same lookup `POST /v1/charges` validates `acceptedPayments` against, so it can never list a pair that charge creation would then reject. Use this to build a picker UI instead of hardcoding the matrix client-side."
|
|
814
1091
|
)
|
|
815
1092
|
});
|
|
@@ -830,9 +1107,15 @@ var CapabilitiesSchema = import_zod19.z.object({
|
|
|
830
1107
|
ChargeStatusEventSchema,
|
|
831
1108
|
ChargeStatusSchema,
|
|
832
1109
|
ChargeWebhookEventTypeSchema,
|
|
1110
|
+
ChargesDateFieldSchema,
|
|
1111
|
+
ChargesMetricFieldSchema,
|
|
1112
|
+
ChargesQueryFieldSchema,
|
|
833
1113
|
CreateApiKeySchema,
|
|
834
1114
|
CreateChargeSchema,
|
|
835
1115
|
CreateWebhookSchema,
|
|
1116
|
+
DistributionsDateFieldSchema,
|
|
1117
|
+
DistributionsMetricFieldSchema,
|
|
1118
|
+
DistributionsQueryFieldSchema,
|
|
836
1119
|
EVENT_CATEGORY_MAP,
|
|
837
1120
|
EVM_NETWORKS,
|
|
838
1121
|
EnvironmentSchema,
|
|
@@ -847,7 +1130,21 @@ var CapabilitiesSchema = import_zod19.z.object({
|
|
|
847
1130
|
ListUsersSchema,
|
|
848
1131
|
ListWebhookDeliveriesSchema,
|
|
849
1132
|
LoginSchema,
|
|
1133
|
+
MAX_METRICS_QUERY_DATE_RANGE_DAYS,
|
|
1134
|
+
METRICS_QUERY_DEFAULT_ROW_LIMIT,
|
|
1135
|
+
METRICS_QUERY_MAX_FILTERS,
|
|
1136
|
+
METRICS_QUERY_MAX_GROUP_BY,
|
|
1137
|
+
METRICS_QUERY_MAX_METRICS,
|
|
1138
|
+
METRICS_QUERY_MAX_ROW_LIMIT,
|
|
850
1139
|
MessageResponseSchema,
|
|
1140
|
+
MetricsAggregationSchema,
|
|
1141
|
+
MetricsDateGranularitySchema,
|
|
1142
|
+
MetricsFilterOperatorSchema,
|
|
1143
|
+
MetricsQueryResultRowSchema,
|
|
1144
|
+
MetricsQueryResultSchema,
|
|
1145
|
+
MetricsQuerySchema,
|
|
1146
|
+
MetricsQueryScopeSchema,
|
|
1147
|
+
MetricsResourceSchema,
|
|
851
1148
|
NETWORK_EXPLORERS,
|
|
852
1149
|
NETWORK_LABELS,
|
|
853
1150
|
NetworkSchema,
|
|
@@ -874,6 +1171,7 @@ var CapabilitiesSchema = import_zod19.z.object({
|
|
|
874
1171
|
SecurityWebhookEventTypeSchema,
|
|
875
1172
|
SettlementStatusSchema,
|
|
876
1173
|
SignupSchema,
|
|
1174
|
+
SplitDistributionStatusSchema,
|
|
877
1175
|
SplitRecipientRoleSchema,
|
|
878
1176
|
TOKEN_ADDRESSES,
|
|
879
1177
|
TOKEN_DECIMALS,
|
|
@@ -881,6 +1179,9 @@ var CapabilitiesSchema = import_zod19.z.object({
|
|
|
881
1179
|
TimelineEventTypeSchema,
|
|
882
1180
|
TokenSchema,
|
|
883
1181
|
TransactionSourceSchema,
|
|
1182
|
+
TransactionsDateFieldSchema,
|
|
1183
|
+
TransactionsMetricFieldSchema,
|
|
1184
|
+
TransactionsQueryFieldSchema,
|
|
884
1185
|
TriggerableChargeEventSchema,
|
|
885
1186
|
UpdateOrganizationSchema,
|
|
886
1187
|
UpdateUserRoleSchema,
|