@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.js
CHANGED
|
@@ -35,7 +35,6 @@ __export(index_exports, {
|
|
|
35
35
|
ChangePasswordSchema: () => ChangePasswordSchema,
|
|
36
36
|
ChargeModeSchema: () => ChargeModeSchema,
|
|
37
37
|
ChargeSchema: () => ChargeSchema,
|
|
38
|
-
ChargeStatusEventSchema: () => ChargeStatusEventSchema,
|
|
39
38
|
ChargeStatusSchema: () => ChargeStatusSchema,
|
|
40
39
|
ChargeWebhookEventTypeSchema: () => ChargeWebhookEventTypeSchema,
|
|
41
40
|
ChargesDateFieldSchema: () => ChargesDateFieldSchema,
|
|
@@ -54,6 +53,8 @@ __export(index_exports, {
|
|
|
54
53
|
ErrorPayloadSchema: () => ErrorPayloadSchema,
|
|
55
54
|
ForgotPasswordSchema: () => ForgotPasswordSchema,
|
|
56
55
|
GetChargeQrCodeQuerySchema: () => GetChargeQrCodeQuerySchema,
|
|
56
|
+
GetPublicChargeQrCodeQuerySchema: () => GetPublicChargeQrCodeQuerySchema,
|
|
57
|
+
GetPublicChargeQuerySchema: () => GetPublicChargeQuerySchema,
|
|
57
58
|
HealthSchema: () => HealthSchema,
|
|
58
59
|
InvitationSchema: () => InvitationSchema,
|
|
59
60
|
InviteUserSchema: () => InviteUserSchema,
|
|
@@ -62,6 +63,7 @@ __export(index_exports, {
|
|
|
62
63
|
ListOrganizationsSchema: () => ListOrganizationsSchema,
|
|
63
64
|
ListUsersSchema: () => ListUsersSchema,
|
|
64
65
|
ListWebhookDeliveriesSchema: () => ListWebhookDeliveriesSchema,
|
|
66
|
+
ListenPendingDistributionsQuerySchema: () => ListenPendingDistributionsQuerySchema,
|
|
65
67
|
LoginSchema: () => LoginSchema,
|
|
66
68
|
MAX_METRICS_QUERY_DATE_RANGE_DAYS: () => MAX_METRICS_QUERY_DATE_RANGE_DAYS,
|
|
67
69
|
METRICS_QUERY_DEFAULT_ROW_LIMIT: () => METRICS_QUERY_DEFAULT_ROW_LIMIT,
|
|
@@ -92,12 +94,14 @@ __export(index_exports, {
|
|
|
92
94
|
PaginatedApiKeysSchema: () => PaginatedApiKeysSchema,
|
|
93
95
|
PaginatedChargesSchema: () => PaginatedChargesSchema,
|
|
94
96
|
PaginatedOrganizationsSchema: () => PaginatedOrganizationsSchema,
|
|
97
|
+
PaginatedPendingDistributionsSchema: () => PaginatedPendingDistributionsSchema,
|
|
95
98
|
PaginatedUsersSchema: () => PaginatedUsersSchema,
|
|
96
99
|
PaginatedWebhookDeliveriesSchema: () => PaginatedWebhookDeliveriesSchema,
|
|
97
100
|
PaginationQuerySchema: () => PaginationQuerySchema,
|
|
98
101
|
PendingDistributionEventSchema: () => PendingDistributionEventSchema,
|
|
99
102
|
PendingDistributionRecipientSchema: () => PendingDistributionRecipientSchema,
|
|
100
103
|
PendingDistributionSchema: () => PendingDistributionSchema,
|
|
104
|
+
PublicChargeSchema: () => PublicChargeSchema,
|
|
101
105
|
ResetPasswordSchema: () => ResetPasswordSchema,
|
|
102
106
|
SandboxEventTriggerSchema: () => SandboxEventTriggerSchema,
|
|
103
107
|
SandboxTriggerSchema: () => SandboxTriggerSchema,
|
|
@@ -106,7 +110,6 @@ __export(index_exports, {
|
|
|
106
110
|
SettlementStatusSchema: () => SettlementStatusSchema,
|
|
107
111
|
SignupSchema: () => SignupSchema,
|
|
108
112
|
SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
|
|
109
|
-
SplitRecipientRoleSchema: () => SplitRecipientRoleSchema,
|
|
110
113
|
TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
|
|
111
114
|
TOKEN_DECIMALS: () => TOKEN_DECIMALS,
|
|
112
115
|
TimelineEventSchema: () => TimelineEventSchema,
|
|
@@ -121,10 +124,7 @@ __export(index_exports, {
|
|
|
121
124
|
UpdateUserRoleSchema: () => UpdateUserRoleSchema,
|
|
122
125
|
UserRoleSchema: () => UserRoleSchema,
|
|
123
126
|
UserSchema: () => UserSchema,
|
|
124
|
-
VerifyChargeSchema: () => VerifyChargeSchema,
|
|
125
127
|
VerifyEmailSchema: () => VerifyEmailSchema,
|
|
126
|
-
VerifyPaymentSchema: () => VerifyPaymentSchema,
|
|
127
|
-
VerifySplitEntrySchema: () => VerifySplitEntrySchema,
|
|
128
128
|
WEBHOOK_EVENTS_WILDCARD: () => WEBHOOK_EVENTS_WILDCARD,
|
|
129
129
|
WEBHOOK_EVENT_CATEGORIES: () => WEBHOOK_EVENT_CATEGORIES,
|
|
130
130
|
WebhookCategorySchema: () => WebhookCategorySchema,
|
|
@@ -258,8 +258,8 @@ var TOKEN_ADDRESSES = {
|
|
|
258
258
|
|
|
259
259
|
// src/charges.ts
|
|
260
260
|
var import_zod6 = require("zod");
|
|
261
|
-
var ChargeStatusSchema = import_zod6.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid"]).describe(
|
|
262
|
-
"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."
|
|
261
|
+
var ChargeStatusSchema = import_zod6.z.enum(["pending", "partially_paid", "confirmed", "expired", "underpaid", "canceled"]).describe(
|
|
262
|
+
"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."
|
|
263
263
|
);
|
|
264
264
|
var SettlementStatusSchema = import_zod6.z.enum(["pending", "completed", "failed"]).describe(
|
|
265
265
|
"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."
|
|
@@ -374,6 +374,9 @@ var ChargeSchema = import_zod6.z.object({
|
|
|
374
374
|
),
|
|
375
375
|
pausedAt: import_zod6.z.string().datetime().nullable().describe(
|
|
376
376
|
"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."
|
|
377
|
+
),
|
|
378
|
+
canceledAt: import_zod6.z.string().datetime().nullable().describe(
|
|
379
|
+
"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."
|
|
377
380
|
)
|
|
378
381
|
});
|
|
379
382
|
var ListChargesSchema = import_zod6.z.object({
|
|
@@ -397,65 +400,99 @@ var GetChargeQrCodeQuerySchema = import_zod6.z.object({
|
|
|
397
400
|
),
|
|
398
401
|
network: NetworkSchema.optional()
|
|
399
402
|
});
|
|
400
|
-
|
|
401
|
-
|
|
403
|
+
|
|
404
|
+
// src/public-charges.ts
|
|
405
|
+
var import_zod7 = require("zod");
|
|
406
|
+
var PublicChargeSchema = import_zod7.z.object({
|
|
407
|
+
id: import_zod7.z.string(),
|
|
408
|
+
mode: ChargeModeSchema,
|
|
402
409
|
status: ChargeStatusSchema,
|
|
403
410
|
settlementStatus: SettlementStatusSchema.nullable(),
|
|
404
|
-
amount:
|
|
405
|
-
amountReceived:
|
|
406
|
-
|
|
411
|
+
amount: import_zod7.z.number().nullable(),
|
|
412
|
+
amountReceived: import_zod7.z.number().nullable(),
|
|
413
|
+
isOverpaid: import_zod7.z.boolean(),
|
|
414
|
+
currency: import_zod7.z.string(),
|
|
415
|
+
acceptedPayments: import_zod7.z.array(AcceptedPaymentSchema),
|
|
416
|
+
paidWith: import_zod7.z.array(AcceptedPaymentSchema),
|
|
417
|
+
address: import_zod7.z.string(),
|
|
418
|
+
environment: EnvironmentSchema,
|
|
419
|
+
txHash: import_zod7.z.string().nullable(),
|
|
420
|
+
metadata: import_zod7.z.record(import_zod7.z.unknown()).nullable().describe(
|
|
421
|
+
"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."
|
|
422
|
+
),
|
|
423
|
+
createdAt: import_zod7.z.string().datetime(),
|
|
424
|
+
expiresAt: import_zod7.z.string().datetime().nullable(),
|
|
425
|
+
confirmedAt: import_zod7.z.string().datetime().nullable(),
|
|
426
|
+
settledAt: import_zod7.z.string().datetime().nullable(),
|
|
427
|
+
lastActivityAt: import_zod7.z.string().datetime(),
|
|
428
|
+
pausedAt: import_zod7.z.string().datetime().nullable(),
|
|
429
|
+
canceledAt: import_zod7.z.string().datetime().nullable()
|
|
430
|
+
});
|
|
431
|
+
var GetPublicChargeQuerySchema = import_zod7.z.object({
|
|
432
|
+
environment: EnvironmentSchema.describe(
|
|
433
|
+
"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."
|
|
434
|
+
)
|
|
407
435
|
});
|
|
436
|
+
var GetPublicChargeQrCodeQuerySchema = GetPublicChargeQuerySchema.extend(
|
|
437
|
+
GetChargeQrCodeQuerySchema.shape
|
|
438
|
+
);
|
|
408
439
|
|
|
409
440
|
// src/distributions.ts
|
|
410
|
-
var
|
|
411
|
-
var SplitDistributionStatusSchema =
|
|
441
|
+
var import_zod8 = require("zod");
|
|
442
|
+
var SplitDistributionStatusSchema = import_zod8.z.enum(["pending", "processing", "completed", "failed"]).describe(
|
|
412
443
|
"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."
|
|
413
444
|
);
|
|
414
|
-
var PendingDistributionRecipientSchema =
|
|
415
|
-
address:
|
|
416
|
-
percentAllocation:
|
|
445
|
+
var PendingDistributionRecipientSchema = import_zod8.z.object({
|
|
446
|
+
address: import_zod8.z.string().describe("On-chain recipient address."),
|
|
447
|
+
percentAllocation: import_zod8.z.number().describe("This recipient's share of the split, as a percentage (e.g. `99.0991` = 99.0991%).")
|
|
417
448
|
});
|
|
418
|
-
var PendingDistributionSchema =
|
|
419
|
-
splitAddress:
|
|
449
|
+
var PendingDistributionSchema = import_zod8.z.object({
|
|
450
|
+
splitAddress: import_zod8.z.string().describe("The on-chain 0xSplits address to call `distribute()` on."),
|
|
420
451
|
network: NetworkSchema,
|
|
421
452
|
token: TokenSchema,
|
|
422
|
-
recipients:
|
|
453
|
+
recipients: import_zod8.z.array(PendingDistributionRecipientSchema).describe(
|
|
423
454
|
"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."
|
|
424
455
|
),
|
|
425
|
-
distributorFeePercent:
|
|
456
|
+
distributorFeePercent: import_zod8.z.number().describe(
|
|
426
457
|
"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."
|
|
427
458
|
),
|
|
428
|
-
estimatedRewardAmount:
|
|
459
|
+
estimatedRewardAmount: import_zod8.z.number().describe(
|
|
429
460
|
"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."
|
|
430
461
|
),
|
|
431
|
-
availableSince:
|
|
432
|
-
graceEndsAt:
|
|
462
|
+
availableSince: import_zod8.z.string().datetime().describe("When this distribution entered its grace period."),
|
|
463
|
+
graceEndsAt: import_zod8.z.string().datetime().describe(
|
|
433
464
|
"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."
|
|
434
465
|
)
|
|
435
466
|
});
|
|
436
|
-
var
|
|
437
|
-
|
|
438
|
-
|
|
467
|
+
var PaginatedPendingDistributionsSchema = paginatedSchema(PendingDistributionSchema);
|
|
468
|
+
var ListenPendingDistributionsQuerySchema = import_zod8.z.object({
|
|
469
|
+
limit: import_zod8.z.coerce.number().int().min(0).max(PAGINATION_LIMIT_MAX).default(0).describe(
|
|
470
|
+
"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."
|
|
471
|
+
)
|
|
472
|
+
});
|
|
473
|
+
var PendingDistributionEventSchema = import_zod8.z.discriminatedUnion("type", [
|
|
474
|
+
import_zod8.z.object({
|
|
475
|
+
type: import_zod8.z.literal("distribution.available"),
|
|
439
476
|
distribution: PendingDistributionSchema
|
|
440
477
|
}),
|
|
441
|
-
|
|
442
|
-
type:
|
|
443
|
-
splitAddress:
|
|
478
|
+
import_zod8.z.object({
|
|
479
|
+
type: import_zod8.z.literal("distribution.claimed"),
|
|
480
|
+
splitAddress: import_zod8.z.string().describe("No longer claimable \u2014 either settled by someone, or picked up by the worker.")
|
|
444
481
|
})
|
|
445
482
|
]);
|
|
446
483
|
|
|
447
484
|
// src/metrics.ts
|
|
448
|
-
var
|
|
449
|
-
var MetricsResourceSchema =
|
|
485
|
+
var import_zod9 = require("zod");
|
|
486
|
+
var MetricsResourceSchema = import_zod9.z.enum(["charges", "transactions", "distributions"]).describe(
|
|
450
487
|
"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."
|
|
451
488
|
);
|
|
452
|
-
var MetricsAggregationSchema =
|
|
489
|
+
var MetricsAggregationSchema = import_zod9.z.enum(["count", "sum", "avg", "min", "max"]).describe(
|
|
453
490
|
"`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."
|
|
454
491
|
);
|
|
455
|
-
var MetricsFilterOperatorSchema =
|
|
492
|
+
var MetricsFilterOperatorSchema = import_zod9.z.enum(["eq", "neq", "in", "gt", "gte", "lt", "lte"]).describe(
|
|
456
493
|
"`in` expects an array value (max 50 entries); every other operator expects a single scalar."
|
|
457
494
|
);
|
|
458
|
-
var MetricsDateGranularitySchema =
|
|
495
|
+
var MetricsDateGranularitySchema = import_zod9.z.enum(["day", "week", "month"]).describe(
|
|
459
496
|
"Bucket width for a `date_bucket` `groupBy` entry \u2014 Postgres `date_trunc` semantics (UTC)."
|
|
460
497
|
);
|
|
461
498
|
var metricsQueryEnvironmentSchema = EnvironmentSchema.describe(
|
|
@@ -468,151 +505,151 @@ var METRICS_QUERY_MAX_GROUP_BY = 3;
|
|
|
468
505
|
var METRICS_QUERY_MAX_FILTERS = 20;
|
|
469
506
|
var METRICS_QUERY_MAX_METRICS = 10;
|
|
470
507
|
var METRIC_ALIAS_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
471
|
-
var metricAliasSchema =
|
|
508
|
+
var metricAliasSchema = import_zod9.z.string().min(1).max(64).regex(
|
|
472
509
|
METRIC_ALIAS_PATTERN,
|
|
473
510
|
"Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 this becomes a SQL column alias."
|
|
474
511
|
).optional();
|
|
475
|
-
var MetricsFilterValueSchema =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
512
|
+
var MetricsFilterValueSchema = import_zod9.z.union([
|
|
513
|
+
import_zod9.z.string().max(255),
|
|
514
|
+
import_zod9.z.number(),
|
|
515
|
+
import_zod9.z.boolean(),
|
|
516
|
+
import_zod9.z.array(import_zod9.z.union([import_zod9.z.string().max(255), import_zod9.z.number()])).min(1).max(50)
|
|
480
517
|
]);
|
|
481
|
-
var orderBySchema =
|
|
482
|
-
key:
|
|
518
|
+
var orderBySchema = import_zod9.z.object({
|
|
519
|
+
key: import_zod9.z.string().min(1).max(64).regex(
|
|
483
520
|
METRIC_ALIAS_PATTERN,
|
|
484
521
|
"Must start with a letter or underscore, and contain only letters, digits, and underscores \u2014 every valid output column name already looks like this."
|
|
485
522
|
).describe(
|
|
486
523
|
"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."
|
|
487
524
|
),
|
|
488
|
-
direction:
|
|
525
|
+
direction: import_zod9.z.enum(["asc", "desc"])
|
|
489
526
|
}).describe(
|
|
490
527
|
"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."
|
|
491
528
|
);
|
|
492
|
-
var limitSchema =
|
|
529
|
+
var limitSchema = import_zod9.z.number().int().min(1).max(METRICS_QUERY_MAX_ROW_LIMIT).default(METRICS_QUERY_DEFAULT_ROW_LIMIT).describe(
|
|
493
530
|
`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.`
|
|
494
531
|
);
|
|
495
|
-
var ChargesQueryFieldSchema =
|
|
532
|
+
var ChargesQueryFieldSchema = import_zod9.z.enum(["status", "mode", "source", "apiKeyId", "currency", "isOverpaid", "externalRef"]).describe(
|
|
496
533
|
"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."
|
|
497
534
|
);
|
|
498
|
-
var ChargesMetricFieldSchema =
|
|
535
|
+
var ChargesMetricFieldSchema = import_zod9.z.enum(["amount", "amountReceived", "feePercent"]).describe(
|
|
499
536
|
"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%."
|
|
500
537
|
);
|
|
501
|
-
var ChargesDateFieldSchema =
|
|
538
|
+
var ChargesDateFieldSchema = import_zod9.z.enum(["createdAt", "confirmedAt", "lastActivityAt"]).describe(
|
|
502
539
|
"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."
|
|
503
540
|
);
|
|
504
|
-
var ChargesFilterSchema =
|
|
541
|
+
var ChargesFilterSchema = import_zod9.z.object({
|
|
505
542
|
field: ChargesQueryFieldSchema,
|
|
506
543
|
operator: MetricsFilterOperatorSchema,
|
|
507
544
|
value: MetricsFilterValueSchema
|
|
508
545
|
});
|
|
509
|
-
var ChargesGroupBySchema =
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
type:
|
|
546
|
+
var ChargesGroupBySchema = import_zod9.z.union([
|
|
547
|
+
import_zod9.z.object({ type: import_zod9.z.literal("field"), field: ChargesQueryFieldSchema }),
|
|
548
|
+
import_zod9.z.object({
|
|
549
|
+
type: import_zod9.z.literal("date_bucket"),
|
|
513
550
|
field: ChargesDateFieldSchema,
|
|
514
551
|
granularity: MetricsDateGranularitySchema
|
|
515
552
|
})
|
|
516
553
|
]);
|
|
517
|
-
var ChargesMetricSchema =
|
|
554
|
+
var ChargesMetricSchema = import_zod9.z.object({
|
|
518
555
|
aggregation: MetricsAggregationSchema,
|
|
519
556
|
field: ChargesMetricFieldSchema.optional(),
|
|
520
557
|
alias: metricAliasSchema
|
|
521
558
|
});
|
|
522
|
-
var ChargesMetricsQuerySchema =
|
|
523
|
-
resource:
|
|
559
|
+
var ChargesMetricsQuerySchema = import_zod9.z.object({
|
|
560
|
+
resource: import_zod9.z.literal("charges"),
|
|
524
561
|
environment: metricsQueryEnvironmentSchema,
|
|
525
|
-
dateRange:
|
|
562
|
+
dateRange: import_zod9.z.object({
|
|
526
563
|
field: ChargesDateFieldSchema,
|
|
527
|
-
from:
|
|
528
|
-
to:
|
|
564
|
+
from: import_zod9.z.string().max(64).datetime(),
|
|
565
|
+
to: import_zod9.z.string().max(64).datetime()
|
|
529
566
|
}),
|
|
530
|
-
groupBy:
|
|
531
|
-
metrics:
|
|
532
|
-
filters:
|
|
567
|
+
groupBy: import_zod9.z.array(ChargesGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
568
|
+
metrics: import_zod9.z.array(ChargesMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
569
|
+
filters: import_zod9.z.array(ChargesFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
533
570
|
orderBy: orderBySchema.optional(),
|
|
534
571
|
limit: limitSchema
|
|
535
572
|
});
|
|
536
|
-
var TransactionsQueryFieldSchema =
|
|
573
|
+
var TransactionsQueryFieldSchema = import_zod9.z.enum(["network", "token", "source", "causedTransition"]).describe(
|
|
537
574
|
"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)."
|
|
538
575
|
);
|
|
539
|
-
var TransactionsMetricFieldSchema =
|
|
540
|
-
var TransactionsDateFieldSchema =
|
|
541
|
-
var TransactionsFilterSchema =
|
|
576
|
+
var TransactionsMetricFieldSchema = import_zod9.z.enum(["amount"]).describe("The transfer amount, in the charge's `currency` units.");
|
|
577
|
+
var TransactionsDateFieldSchema = import_zod9.z.enum(["detectedAt"]).describe("When Klappay detected this transfer on-chain (not when it was mined).");
|
|
578
|
+
var TransactionsFilterSchema = import_zod9.z.object({
|
|
542
579
|
field: TransactionsQueryFieldSchema,
|
|
543
580
|
operator: MetricsFilterOperatorSchema,
|
|
544
581
|
value: MetricsFilterValueSchema
|
|
545
582
|
});
|
|
546
|
-
var TransactionsGroupBySchema =
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
type:
|
|
583
|
+
var TransactionsGroupBySchema = import_zod9.z.union([
|
|
584
|
+
import_zod9.z.object({ type: import_zod9.z.literal("field"), field: TransactionsQueryFieldSchema }),
|
|
585
|
+
import_zod9.z.object({
|
|
586
|
+
type: import_zod9.z.literal("date_bucket"),
|
|
550
587
|
field: TransactionsDateFieldSchema,
|
|
551
588
|
granularity: MetricsDateGranularitySchema
|
|
552
589
|
})
|
|
553
590
|
]);
|
|
554
|
-
var TransactionsMetricSchema =
|
|
591
|
+
var TransactionsMetricSchema = import_zod9.z.object({
|
|
555
592
|
aggregation: MetricsAggregationSchema,
|
|
556
593
|
field: TransactionsMetricFieldSchema.optional(),
|
|
557
594
|
alias: metricAliasSchema
|
|
558
595
|
});
|
|
559
|
-
var TransactionsMetricsQuerySchema =
|
|
560
|
-
resource:
|
|
596
|
+
var TransactionsMetricsQuerySchema = import_zod9.z.object({
|
|
597
|
+
resource: import_zod9.z.literal("transactions"),
|
|
561
598
|
environment: metricsQueryEnvironmentSchema,
|
|
562
|
-
dateRange:
|
|
599
|
+
dateRange: import_zod9.z.object({
|
|
563
600
|
field: TransactionsDateFieldSchema,
|
|
564
|
-
from:
|
|
565
|
-
to:
|
|
601
|
+
from: import_zod9.z.string().max(64).datetime(),
|
|
602
|
+
to: import_zod9.z.string().max(64).datetime()
|
|
566
603
|
}),
|
|
567
|
-
groupBy:
|
|
568
|
-
metrics:
|
|
569
|
-
filters:
|
|
604
|
+
groupBy: import_zod9.z.array(TransactionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
605
|
+
metrics: import_zod9.z.array(TransactionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
606
|
+
filters: import_zod9.z.array(TransactionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
570
607
|
orderBy: orderBySchema.optional(),
|
|
571
608
|
limit: limitSchema
|
|
572
609
|
});
|
|
573
|
-
var DistributionsQueryFieldSchema =
|
|
610
|
+
var DistributionsQueryFieldSchema = import_zod9.z.enum(["status", "network", "token"]).describe(
|
|
574
611
|
"A `SplitDistribution` field to filter or group by \u2014 see `SplitDistributionStatusSchema`/`NetworkSchema`/`TokenSchema` for their possible values."
|
|
575
612
|
);
|
|
576
|
-
var DistributionsMetricFieldSchema =
|
|
613
|
+
var DistributionsMetricFieldSchema = import_zod9.z.enum(["attempts"]).describe(
|
|
577
614
|
"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."
|
|
578
615
|
);
|
|
579
|
-
var DistributionsDateFieldSchema =
|
|
616
|
+
var DistributionsDateFieldSchema = import_zod9.z.enum(["createdAt", "completedAt"]).describe(
|
|
580
617
|
"`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."
|
|
581
618
|
);
|
|
582
|
-
var DistributionsFilterSchema =
|
|
619
|
+
var DistributionsFilterSchema = import_zod9.z.object({
|
|
583
620
|
field: DistributionsQueryFieldSchema,
|
|
584
621
|
operator: MetricsFilterOperatorSchema,
|
|
585
622
|
value: MetricsFilterValueSchema
|
|
586
623
|
});
|
|
587
|
-
var DistributionsGroupBySchema =
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
type:
|
|
624
|
+
var DistributionsGroupBySchema = import_zod9.z.union([
|
|
625
|
+
import_zod9.z.object({ type: import_zod9.z.literal("field"), field: DistributionsQueryFieldSchema }),
|
|
626
|
+
import_zod9.z.object({
|
|
627
|
+
type: import_zod9.z.literal("date_bucket"),
|
|
591
628
|
field: DistributionsDateFieldSchema,
|
|
592
629
|
granularity: MetricsDateGranularitySchema
|
|
593
630
|
})
|
|
594
631
|
]);
|
|
595
|
-
var DistributionsMetricSchema =
|
|
632
|
+
var DistributionsMetricSchema = import_zod9.z.object({
|
|
596
633
|
aggregation: MetricsAggregationSchema,
|
|
597
634
|
field: DistributionsMetricFieldSchema.optional(),
|
|
598
635
|
alias: metricAliasSchema
|
|
599
636
|
});
|
|
600
|
-
var DistributionsMetricsQuerySchema =
|
|
601
|
-
resource:
|
|
637
|
+
var DistributionsMetricsQuerySchema = import_zod9.z.object({
|
|
638
|
+
resource: import_zod9.z.literal("distributions"),
|
|
602
639
|
environment: metricsQueryEnvironmentSchema,
|
|
603
|
-
dateRange:
|
|
640
|
+
dateRange: import_zod9.z.object({
|
|
604
641
|
field: DistributionsDateFieldSchema,
|
|
605
|
-
from:
|
|
606
|
-
to:
|
|
642
|
+
from: import_zod9.z.string().max(64).datetime(),
|
|
643
|
+
to: import_zod9.z.string().max(64).datetime()
|
|
607
644
|
}),
|
|
608
|
-
groupBy:
|
|
609
|
-
metrics:
|
|
610
|
-
filters:
|
|
645
|
+
groupBy: import_zod9.z.array(DistributionsGroupBySchema).max(METRICS_QUERY_MAX_GROUP_BY).default([]),
|
|
646
|
+
metrics: import_zod9.z.array(DistributionsMetricSchema).min(1).max(METRICS_QUERY_MAX_METRICS),
|
|
647
|
+
filters: import_zod9.z.array(DistributionsFilterSchema).max(METRICS_QUERY_MAX_FILTERS).default([]),
|
|
611
648
|
orderBy: orderBySchema.optional(),
|
|
612
649
|
limit: limitSchema
|
|
613
650
|
});
|
|
614
651
|
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
615
|
-
var MetricsQuerySchema =
|
|
652
|
+
var MetricsQuerySchema = import_zod9.z.discriminatedUnion("resource", [
|
|
616
653
|
ChargesMetricsQuerySchema,
|
|
617
654
|
TransactionsMetricsQuerySchema,
|
|
618
655
|
DistributionsMetricsQuerySchema
|
|
@@ -621,7 +658,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
|
621
658
|
const to = new Date(input.dateRange.to);
|
|
622
659
|
if (from >= to) {
|
|
623
660
|
ctx.addIssue({
|
|
624
|
-
code:
|
|
661
|
+
code: import_zod9.z.ZodIssueCode.custom,
|
|
625
662
|
message: "`dateRange.from` must be before `dateRange.to`.",
|
|
626
663
|
path: ["dateRange", "from"]
|
|
627
664
|
});
|
|
@@ -629,7 +666,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
|
629
666
|
const spanDays = (to.getTime() - from.getTime()) / ONE_DAY_MS;
|
|
630
667
|
if (spanDays > MAX_METRICS_QUERY_DATE_RANGE_DAYS) {
|
|
631
668
|
ctx.addIssue({
|
|
632
|
-
code:
|
|
669
|
+
code: import_zod9.z.ZodIssueCode.custom,
|
|
633
670
|
message: `\`dateRange\` cannot span more than ${MAX_METRICS_QUERY_DATE_RANGE_DAYS} days.`,
|
|
634
671
|
path: ["dateRange", "to"]
|
|
635
672
|
});
|
|
@@ -637,7 +674,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
|
637
674
|
const dateBucketCount = input.groupBy.filter((entry) => entry.type === "date_bucket").length;
|
|
638
675
|
if (dateBucketCount > 1) {
|
|
639
676
|
ctx.addIssue({
|
|
640
|
-
code:
|
|
677
|
+
code: import_zod9.z.ZodIssueCode.custom,
|
|
641
678
|
message: "At most one `date_bucket` entry is allowed in `groupBy`.",
|
|
642
679
|
path: ["groupBy"]
|
|
643
680
|
});
|
|
@@ -645,7 +682,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
|
645
682
|
input.metrics.forEach((metric, index) => {
|
|
646
683
|
if (metric.aggregation !== "count" && metric.field === void 0) {
|
|
647
684
|
ctx.addIssue({
|
|
648
|
-
code:
|
|
685
|
+
code: import_zod9.z.ZodIssueCode.custom,
|
|
649
686
|
message: "`field` is required unless `aggregation` is `count`.",
|
|
650
687
|
path: ["metrics", index, "field"]
|
|
651
688
|
});
|
|
@@ -654,7 +691,7 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
|
654
691
|
const aliases = input.metrics.map((metric) => metric.alias).filter((alias) => alias !== void 0);
|
|
655
692
|
if (new Set(aliases).size !== aliases.length) {
|
|
656
693
|
ctx.addIssue({
|
|
657
|
-
code:
|
|
694
|
+
code: import_zod9.z.ZodIssueCode.custom,
|
|
658
695
|
message: "Every `metrics[].alias` must be unique.",
|
|
659
696
|
path: ["metrics"]
|
|
660
697
|
});
|
|
@@ -663,36 +700,36 @@ var MetricsQuerySchema = import_zod8.z.discriminatedUnion("resource", [
|
|
|
663
700
|
input.metrics.forEach((metric, index) => {
|
|
664
701
|
if (metric.alias !== void 0 && reservedNames.has(metric.alias)) {
|
|
665
702
|
ctx.addIssue({
|
|
666
|
-
code:
|
|
703
|
+
code: import_zod9.z.ZodIssueCode.custom,
|
|
667
704
|
message: `\`alias\` "${metric.alias}" collides with a \`groupBy\` field name (or the reserved word "bucket") \u2014 choose a different alias.`,
|
|
668
705
|
path: ["metrics", index, "alias"]
|
|
669
706
|
});
|
|
670
707
|
}
|
|
671
708
|
});
|
|
672
709
|
});
|
|
673
|
-
var MetricsQueryResultRowSchema =
|
|
674
|
-
|
|
675
|
-
|
|
710
|
+
var MetricsQueryResultRowSchema = import_zod9.z.record(
|
|
711
|
+
import_zod9.z.string(),
|
|
712
|
+
import_zod9.z.union([import_zod9.z.string(), import_zod9.z.number(), import_zod9.z.boolean(), import_zod9.z.null()])
|
|
676
713
|
);
|
|
677
|
-
var MetricsQueryScopeSchema =
|
|
714
|
+
var MetricsQueryScopeSchema = import_zod9.z.enum(["owner_admin", "member"]).describe(
|
|
678
715
|
"`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."
|
|
679
716
|
);
|
|
680
|
-
var MetricsQueryResultSchema =
|
|
681
|
-
data:
|
|
682
|
-
meta:
|
|
717
|
+
var MetricsQueryResultSchema = import_zod9.z.object({
|
|
718
|
+
data: import_zod9.z.array(MetricsQueryResultRowSchema),
|
|
719
|
+
meta: import_zod9.z.object({
|
|
683
720
|
resource: MetricsResourceSchema,
|
|
684
721
|
environment: EnvironmentSchema,
|
|
685
722
|
scope: MetricsQueryScopeSchema,
|
|
686
|
-
rowCount:
|
|
687
|
-
truncated:
|
|
723
|
+
rowCount: import_zod9.z.number().int().describe("Number of rows in `data`."),
|
|
724
|
+
truncated: import_zod9.z.boolean().describe(
|
|
688
725
|
"`true` if more rows matched than `limit` allowed \u2014 `data` holds only the first `limit`."
|
|
689
726
|
)
|
|
690
727
|
})
|
|
691
728
|
});
|
|
692
729
|
|
|
693
730
|
// src/webhook-events.ts
|
|
694
|
-
var
|
|
695
|
-
var ChargeWebhookEventTypeSchema =
|
|
731
|
+
var import_zod10 = require("zod");
|
|
732
|
+
var ChargeWebhookEventTypeSchema = import_zod10.z.enum([
|
|
696
733
|
"charge.created",
|
|
697
734
|
"charge.partially_paid",
|
|
698
735
|
"charge.confirmed",
|
|
@@ -704,11 +741,13 @@ var ChargeWebhookEventTypeSchema = import_zod9.z.enum([
|
|
|
704
741
|
"charge.paused",
|
|
705
742
|
"charge.reactivated",
|
|
706
743
|
"charge.contribution_received",
|
|
707
|
-
"charge.contribution_settled"
|
|
744
|
+
"charge.contribution_settled",
|
|
745
|
+
"charge.canceled",
|
|
746
|
+
"charge.paid_after_cancel"
|
|
708
747
|
]).describe(
|
|
709
|
-
'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 }`.'
|
|
748
|
+
'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 }`.'
|
|
710
749
|
);
|
|
711
|
-
var AccountWebhookEventTypeSchema =
|
|
750
|
+
var AccountWebhookEventTypeSchema = import_zod10.z.enum([
|
|
712
751
|
"payout_address.changed",
|
|
713
752
|
"api_key.created",
|
|
714
753
|
"api_key.revoked",
|
|
@@ -722,10 +761,10 @@ var AccountWebhookEventTypeSchema = import_zod9.z.enum([
|
|
|
722
761
|
]).describe(
|
|
723
762
|
"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 }`."
|
|
724
763
|
);
|
|
725
|
-
var WebhookDeliveryEventTypeSchema =
|
|
764
|
+
var WebhookDeliveryEventTypeSchema = import_zod10.z.enum(["webhook.delivery_failed", "webhook.delivery_recovered", "webhook.endpoint_unhealthy"]).describe(
|
|
726
765
|
"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`)."
|
|
727
766
|
);
|
|
728
|
-
var SecurityWebhookEventTypeSchema =
|
|
767
|
+
var SecurityWebhookEventTypeSchema = import_zod10.z.enum([
|
|
729
768
|
"auth.login",
|
|
730
769
|
"auth.login_failed",
|
|
731
770
|
"auth.suspicious_activity",
|
|
@@ -738,13 +777,13 @@ var SecurityWebhookEventTypeSchema = import_zod9.z.enum([
|
|
|
738
777
|
]).describe(
|
|
739
778
|
"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 }`."
|
|
740
779
|
);
|
|
741
|
-
var WebhookEventTypeSchema =
|
|
780
|
+
var WebhookEventTypeSchema = import_zod10.z.union([
|
|
742
781
|
ChargeWebhookEventTypeSchema,
|
|
743
782
|
AccountWebhookEventTypeSchema,
|
|
744
783
|
WebhookDeliveryEventTypeSchema,
|
|
745
784
|
SecurityWebhookEventTypeSchema
|
|
746
785
|
]);
|
|
747
|
-
var WebhookCategorySchema =
|
|
786
|
+
var WebhookCategorySchema = import_zod10.z.enum(["payments", "account", "webhooks", "security"]).describe(
|
|
748
787
|
"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."
|
|
749
788
|
);
|
|
750
789
|
function buildCategoryMap() {
|
|
@@ -767,108 +806,110 @@ var TriggerableChargeEventSchema = ChargeWebhookEventTypeSchema.exclude([
|
|
|
767
806
|
"charge.paused",
|
|
768
807
|
"charge.reactivated",
|
|
769
808
|
"charge.contribution_received",
|
|
770
|
-
"charge.contribution_settled"
|
|
809
|
+
"charge.contribution_settled",
|
|
810
|
+
"charge.canceled",
|
|
811
|
+
"charge.paid_after_cancel"
|
|
771
812
|
]).describe(
|
|
772
|
-
"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),
|
|
813
|
+
"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)."
|
|
773
814
|
);
|
|
774
|
-
var NonChargeTriggerableEventSchema =
|
|
815
|
+
var NonChargeTriggerableEventSchema = import_zod10.z.union([
|
|
775
816
|
AccountWebhookEventTypeSchema,
|
|
776
817
|
WebhookDeliveryEventTypeSchema,
|
|
777
818
|
SecurityWebhookEventTypeSchema
|
|
778
819
|
]);
|
|
779
820
|
|
|
780
821
|
// src/webhooks.ts
|
|
781
|
-
var
|
|
822
|
+
var import_zod11 = require("zod");
|
|
782
823
|
var WEBHOOK_EVENTS_WILDCARD = "*";
|
|
783
|
-
var CreateWebhookSchema =
|
|
784
|
-
url:
|
|
824
|
+
var CreateWebhookSchema = import_zod11.z.object({
|
|
825
|
+
url: import_zod11.z.string().max(2048).url().describe(
|
|
785
826
|
"Must be HTTPS and resolve to a public address \u2014 private/internal IPs are rejected."
|
|
786
827
|
),
|
|
787
|
-
events:
|
|
828
|
+
events: import_zod11.z.array(import_zod11.z.union([WebhookEventTypeSchema, import_zod11.z.literal(WEBHOOK_EVENTS_WILDCARD)])).max(Object.keys(EVENT_CATEGORY_MAP).length + 1).default([]).describe(
|
|
788
829
|
'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.'
|
|
789
830
|
),
|
|
790
|
-
eventCategories:
|
|
831
|
+
eventCategories: import_zod11.z.array(WebhookCategorySchema).max(WebhookCategorySchema.options.length).default([]).describe(
|
|
791
832
|
"Subscribe to every event in these categories. At least one of `events` or `eventCategories` is required."
|
|
792
833
|
),
|
|
793
|
-
excludeEvents:
|
|
834
|
+
excludeEvents: import_zod11.z.array(WebhookEventTypeSchema).max(Object.keys(EVENT_CATEGORY_MAP).length).default([]).describe(
|
|
794
835
|
'Event types to exclude even if selected via `events: ["*"]` or `eventCategories`.'
|
|
795
836
|
)
|
|
796
837
|
}).refine((v) => v.events.length > 0 || v.eventCategories.length > 0, {
|
|
797
838
|
message: "must select at least one event via `events` or `eventCategories`",
|
|
798
839
|
path: ["events"]
|
|
799
840
|
});
|
|
800
|
-
var WebhookSchema =
|
|
801
|
-
id:
|
|
841
|
+
var WebhookSchema = import_zod11.z.object({
|
|
842
|
+
id: import_zod11.z.string(),
|
|
802
843
|
environment: EnvironmentSchema.nullable().describe(
|
|
803
844
|
"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."
|
|
804
845
|
),
|
|
805
|
-
url:
|
|
806
|
-
events:
|
|
807
|
-
eventCategories:
|
|
808
|
-
excludeEvents:
|
|
809
|
-
isWildcard:
|
|
810
|
-
secret:
|
|
846
|
+
url: import_zod11.z.string(),
|
|
847
|
+
events: import_zod11.z.array(WebhookEventTypeSchema),
|
|
848
|
+
eventCategories: import_zod11.z.array(WebhookCategorySchema),
|
|
849
|
+
excludeEvents: import_zod11.z.array(WebhookEventTypeSchema),
|
|
850
|
+
isWildcard: import_zod11.z.boolean(),
|
|
851
|
+
secret: import_zod11.z.string().describe(
|
|
811
852
|
"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."
|
|
812
853
|
),
|
|
813
|
-
createdAt:
|
|
854
|
+
createdAt: import_zod11.z.string().datetime()
|
|
814
855
|
});
|
|
815
856
|
var WebhookListItemSchema = WebhookSchema.omit({ secret: true }).extend({
|
|
816
|
-
hint:
|
|
857
|
+
hint: import_zod11.z.string().describe("A truncated, safe-to-display form of the secret (e.g. `whsec_...ab12`).")
|
|
817
858
|
});
|
|
818
|
-
var WebhookPayloadSchema =
|
|
819
|
-
id:
|
|
859
|
+
var WebhookPayloadSchema = import_zod11.z.object({
|
|
860
|
+
id: import_zod11.z.string().describe(
|
|
820
861
|
"Unique id for this specific delivery \u2014 also sent as the `X-Klappay-Delivery` header."
|
|
821
862
|
),
|
|
822
863
|
event: WebhookEventTypeSchema,
|
|
823
|
-
createdAt:
|
|
824
|
-
data:
|
|
864
|
+
createdAt: import_zod11.z.string().datetime(),
|
|
865
|
+
data: import_zod11.z.unknown().describe(
|
|
825
866
|
"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."
|
|
826
867
|
)
|
|
827
868
|
});
|
|
828
|
-
var WebhookDeliveryStatusSchema =
|
|
829
|
-
var WebhookDeliverySchema =
|
|
830
|
-
id:
|
|
831
|
-
webhookId:
|
|
869
|
+
var WebhookDeliveryStatusSchema = import_zod11.z.enum(["pending", "delivered", "failed"]);
|
|
870
|
+
var WebhookDeliverySchema = import_zod11.z.object({
|
|
871
|
+
id: import_zod11.z.string(),
|
|
872
|
+
webhookId: import_zod11.z.string(),
|
|
832
873
|
event: WebhookEventTypeSchema,
|
|
833
874
|
status: WebhookDeliveryStatusSchema.describe(
|
|
834
875
|
"`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."
|
|
835
876
|
),
|
|
836
|
-
attempts:
|
|
837
|
-
responseCode:
|
|
877
|
+
attempts: import_zod11.z.number(),
|
|
878
|
+
responseCode: import_zod11.z.number().nullable().describe(
|
|
838
879
|
"HTTP status your endpoint returned on the most recent attempt. `null` if every attempt failed to connect at all."
|
|
839
880
|
),
|
|
840
|
-
nextRetryAt:
|
|
841
|
-
deliveredAt:
|
|
842
|
-
createdAt:
|
|
881
|
+
nextRetryAt: import_zod11.z.string().datetime().nullable(),
|
|
882
|
+
deliveredAt: import_zod11.z.string().datetime().nullable(),
|
|
883
|
+
createdAt: import_zod11.z.string().datetime()
|
|
843
884
|
});
|
|
844
885
|
var ListWebhookDeliveriesSchema = PaginationQuerySchema;
|
|
845
886
|
var PaginatedWebhookDeliveriesSchema = paginatedSchema(WebhookDeliverySchema);
|
|
846
887
|
|
|
847
888
|
// src/api-keys.ts
|
|
848
|
-
var
|
|
849
|
-
var CreateApiKeySchema =
|
|
850
|
-
name:
|
|
889
|
+
var import_zod12 = require("zod");
|
|
890
|
+
var CreateApiKeySchema = import_zod12.z.object({
|
|
891
|
+
name: import_zod12.z.string().min(1).max(64).describe(
|
|
851
892
|
'A label to help you tell keys apart (e.g. `"production backend"`). Not used for anything functional.'
|
|
852
893
|
),
|
|
853
894
|
environment: EnvironmentSchema.describe(
|
|
854
895
|
"`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."
|
|
855
896
|
)
|
|
856
897
|
});
|
|
857
|
-
var ApiKeySchema =
|
|
858
|
-
id:
|
|
859
|
-
name:
|
|
898
|
+
var ApiKeySchema = import_zod12.z.object({
|
|
899
|
+
id: import_zod12.z.string(),
|
|
900
|
+
name: import_zod12.z.string(),
|
|
860
901
|
environment: EnvironmentSchema.describe(
|
|
861
902
|
"`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."
|
|
862
903
|
),
|
|
863
|
-
key:
|
|
904
|
+
key: import_zod12.z.string().optional().describe(
|
|
864
905
|
"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."
|
|
865
906
|
),
|
|
866
|
-
hint:
|
|
907
|
+
hint: import_zod12.z.string().describe(
|
|
867
908
|
"A truncated, always-safe-to-display form of the key (e.g. `klap_live_...ab12`), returned everywhere the full key isn't."
|
|
868
909
|
),
|
|
869
|
-
createdAt:
|
|
870
|
-
lastUsedAt:
|
|
871
|
-
createdByUserId:
|
|
910
|
+
createdAt: import_zod12.z.string().datetime(),
|
|
911
|
+
lastUsedAt: import_zod12.z.string().datetime().nullable().describe("Updated on every successful authenticated request. `null` if never used."),
|
|
912
|
+
createdByUserId: import_zod12.z.string().nullable().describe(
|
|
872
913
|
"Which member of the organization created this key. `null` for a key created before this field existed."
|
|
873
914
|
)
|
|
874
915
|
});
|
|
@@ -876,93 +917,93 @@ var ListApiKeysSchema = PaginationQuerySchema;
|
|
|
876
917
|
var PaginatedApiKeysSchema = paginatedSchema(ApiKeySchema);
|
|
877
918
|
|
|
878
919
|
// src/users.ts
|
|
879
|
-
var
|
|
880
|
-
var UserRoleSchema =
|
|
920
|
+
var import_zod13 = require("zod");
|
|
921
|
+
var UserRoleSchema = import_zod13.z.enum(["owner", "admin", "member"]).describe(
|
|
881
922
|
"`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`."
|
|
882
923
|
);
|
|
883
|
-
var UpdateUserRoleSchema =
|
|
924
|
+
var UpdateUserRoleSchema = import_zod13.z.object({
|
|
884
925
|
role: UserRoleSchema
|
|
885
926
|
});
|
|
886
|
-
var UserSchema =
|
|
887
|
-
id:
|
|
888
|
-
email:
|
|
889
|
-
name:
|
|
927
|
+
var UserSchema = import_zod13.z.object({
|
|
928
|
+
id: import_zod13.z.string(),
|
|
929
|
+
email: import_zod13.z.string(),
|
|
930
|
+
name: import_zod13.z.string().nullable(),
|
|
890
931
|
role: UserRoleSchema.describe("Your role within the organization this user was fetched from."),
|
|
891
|
-
emailVerifiedAt:
|
|
932
|
+
emailVerifiedAt: import_zod13.z.string().datetime().nullable().describe(
|
|
892
933
|
"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."
|
|
893
934
|
),
|
|
894
|
-
createdAt:
|
|
935
|
+
createdAt: import_zod13.z.string().datetime()
|
|
895
936
|
});
|
|
896
937
|
var ListUsersSchema = PaginationQuerySchema;
|
|
897
938
|
var PaginatedUsersSchema = paginatedSchema(UserSchema);
|
|
898
939
|
|
|
899
940
|
// src/auth.ts
|
|
900
|
-
var
|
|
901
|
-
var NormalizedEmailSchema =
|
|
941
|
+
var import_zod14 = require("zod");
|
|
942
|
+
var NormalizedEmailSchema = import_zod14.z.string().trim().max(255).toLowerCase().email().transform((email) => email.normalize("NFC")).describe(
|
|
902
943
|
"Trimmed, lowercased, and NFC-normalized server-side before use \u2014 case/whitespace don't matter."
|
|
903
944
|
);
|
|
904
|
-
var SignupSchema =
|
|
945
|
+
var SignupSchema = import_zod14.z.object({
|
|
905
946
|
email: NormalizedEmailSchema,
|
|
906
|
-
password:
|
|
947
|
+
password: import_zod14.z.string().min(8).max(128).describe("8-128 characters. No other complexity rule.")
|
|
907
948
|
});
|
|
908
|
-
var LoginSchema =
|
|
949
|
+
var LoginSchema = import_zod14.z.object({
|
|
909
950
|
email: NormalizedEmailSchema,
|
|
910
|
-
password:
|
|
951
|
+
password: import_zod14.z.string().min(1).max(128)
|
|
911
952
|
});
|
|
912
|
-
var VerifyEmailSchema =
|
|
913
|
-
token:
|
|
953
|
+
var VerifyEmailSchema = import_zod14.z.object({
|
|
954
|
+
token: import_zod14.z.string().min(1).describe("The token from the verification email \u2014 passed as-is, not the account email.")
|
|
914
955
|
});
|
|
915
|
-
var ForgotPasswordSchema =
|
|
956
|
+
var ForgotPasswordSchema = import_zod14.z.object({
|
|
916
957
|
email: NormalizedEmailSchema
|
|
917
958
|
});
|
|
918
|
-
var ResetPasswordSchema =
|
|
919
|
-
token:
|
|
920
|
-
newPassword:
|
|
959
|
+
var ResetPasswordSchema = import_zod14.z.object({
|
|
960
|
+
token: import_zod14.z.string().min(1).describe("The token from the password reset email."),
|
|
961
|
+
newPassword: import_zod14.z.string().min(8).max(128)
|
|
921
962
|
});
|
|
922
|
-
var MessageResponseSchema =
|
|
923
|
-
message:
|
|
963
|
+
var MessageResponseSchema = import_zod14.z.object({
|
|
964
|
+
message: import_zod14.z.string().describe("Human-readable confirmation, safe to show a user directly.")
|
|
924
965
|
});
|
|
925
966
|
var SelfUserSchema = UserSchema.omit({ createdAt: true, role: true });
|
|
926
|
-
var AuthResponseSchema =
|
|
927
|
-
token:
|
|
967
|
+
var AuthResponseSchema = import_zod14.z.object({
|
|
968
|
+
token: import_zod14.z.string().describe(
|
|
928
969
|
"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."
|
|
929
970
|
),
|
|
930
971
|
user: SelfUserSchema
|
|
931
972
|
});
|
|
932
|
-
var ChangeNameSchema =
|
|
933
|
-
name:
|
|
973
|
+
var ChangeNameSchema = import_zod14.z.object({
|
|
974
|
+
name: import_zod14.z.string().min(1).max(255).describe("Your display name.")
|
|
934
975
|
});
|
|
935
|
-
var ChangePasswordSchema =
|
|
936
|
-
currentPassword:
|
|
937
|
-
newPassword:
|
|
976
|
+
var ChangePasswordSchema = import_zod14.z.object({
|
|
977
|
+
currentPassword: import_zod14.z.string().min(1).max(128),
|
|
978
|
+
newPassword: import_zod14.z.string().min(8).max(128)
|
|
938
979
|
});
|
|
939
|
-
var ChangeEmailSchema =
|
|
940
|
-
currentPassword:
|
|
980
|
+
var ChangeEmailSchema = import_zod14.z.object({
|
|
981
|
+
currentPassword: import_zod14.z.string().min(1).max(128),
|
|
941
982
|
newEmail: NormalizedEmailSchema
|
|
942
983
|
});
|
|
943
|
-
var ConfirmEmailChangeSchema =
|
|
944
|
-
token:
|
|
984
|
+
var ConfirmEmailChangeSchema = import_zod14.z.object({
|
|
985
|
+
token: import_zod14.z.string().min(1).describe("The token from the confirmation email sent to your current address.")
|
|
945
986
|
});
|
|
946
987
|
|
|
947
988
|
// src/organization.ts
|
|
948
|
-
var
|
|
949
|
-
var UpdateOrganizationSchema =
|
|
950
|
-
name:
|
|
951
|
-
payoutAddress:
|
|
989
|
+
var import_zod15 = require("zod");
|
|
990
|
+
var UpdateOrganizationSchema = import_zod15.z.object({
|
|
991
|
+
name: import_zod15.z.string().min(1).max(255).optional().describe("The organization's display name."),
|
|
992
|
+
payoutAddress: import_zod15.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a valid EVM address").optional().describe(
|
|
952
993
|
"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."
|
|
953
994
|
)
|
|
954
995
|
});
|
|
955
|
-
var OrganizationSchema =
|
|
956
|
-
id:
|
|
957
|
-
name:
|
|
958
|
-
payoutAddress:
|
|
959
|
-
currentFeePercent:
|
|
996
|
+
var OrganizationSchema = import_zod15.z.object({
|
|
997
|
+
id: import_zod15.z.string(),
|
|
998
|
+
name: import_zod15.z.string(),
|
|
999
|
+
payoutAddress: import_zod15.z.string().nullable().describe("`null` until configured \u2014 `POST /v1/charges` fails until this is set."),
|
|
1000
|
+
currentFeePercent: import_zod15.z.number().describe(
|
|
960
1001
|
"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."
|
|
961
1002
|
),
|
|
962
|
-
feeUpdatedAt:
|
|
1003
|
+
feeUpdatedAt: import_zod15.z.string().datetime().nullable().describe(
|
|
963
1004
|
"When `currentFeePercent` last changed. `null` if it has never changed since this organization signed up."
|
|
964
1005
|
),
|
|
965
|
-
createdAt:
|
|
1006
|
+
createdAt: import_zod15.z.string().datetime()
|
|
966
1007
|
});
|
|
967
1008
|
var OrganizationWithRoleSchema = OrganizationSchema.extend({
|
|
968
1009
|
role: UserRoleSchema.describe("Your own role within this specific organization.")
|
|
@@ -971,50 +1012,51 @@ var PaginatedOrganizationsSchema = paginatedSchema(OrganizationWithRoleSchema);
|
|
|
971
1012
|
var ListOrganizationsSchema = PaginationQuerySchema;
|
|
972
1013
|
|
|
973
1014
|
// src/invitations.ts
|
|
974
|
-
var
|
|
975
|
-
var InviteUserSchema =
|
|
1015
|
+
var import_zod16 = require("zod");
|
|
1016
|
+
var InviteUserSchema = import_zod16.z.object({
|
|
976
1017
|
email: NormalizedEmailSchema,
|
|
977
1018
|
role: UserRoleSchema.default("member").describe(
|
|
978
1019
|
"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`."
|
|
979
1020
|
)
|
|
980
1021
|
});
|
|
981
|
-
var AcceptInvitationSchema =
|
|
982
|
-
token:
|
|
983
|
-
password:
|
|
1022
|
+
var AcceptInvitationSchema = import_zod16.z.object({
|
|
1023
|
+
token: import_zod16.z.string().min(1).describe("The token from the invitation email."),
|
|
1024
|
+
password: import_zod16.z.string().min(8).max(128).optional().describe(
|
|
984
1025
|
"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."
|
|
985
1026
|
)
|
|
986
1027
|
});
|
|
987
|
-
var InvitationSchema =
|
|
988
|
-
id:
|
|
989
|
-
organizationId:
|
|
990
|
-
email:
|
|
1028
|
+
var InvitationSchema = import_zod16.z.object({
|
|
1029
|
+
id: import_zod16.z.string(),
|
|
1030
|
+
organizationId: import_zod16.z.string(),
|
|
1031
|
+
email: import_zod16.z.string(),
|
|
991
1032
|
role: UserRoleSchema,
|
|
992
|
-
invitedByUserId:
|
|
993
|
-
expiresAt:
|
|
994
|
-
createdAt:
|
|
1033
|
+
invitedByUserId: import_zod16.z.string().describe("Which member of the organization sent this invitation."),
|
|
1034
|
+
expiresAt: import_zod16.z.string().datetime(),
|
|
1035
|
+
createdAt: import_zod16.z.string().datetime()
|
|
995
1036
|
});
|
|
996
1037
|
|
|
997
1038
|
// src/timeline.ts
|
|
998
|
-
var
|
|
999
|
-
var TransactionSourceSchema =
|
|
1039
|
+
var import_zod17 = require("zod");
|
|
1040
|
+
var TransactionSourceSchema = import_zod17.z.enum(["moralis_webhook", "reconciliation_job", "sandbox"]).describe(
|
|
1000
1041
|
"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)."
|
|
1001
1042
|
);
|
|
1002
|
-
var TimelineEventTypeSchema =
|
|
1043
|
+
var TimelineEventTypeSchema = import_zod17.z.enum([
|
|
1003
1044
|
"charge.created",
|
|
1004
1045
|
"charge.expired",
|
|
1046
|
+
"charge.canceled",
|
|
1005
1047
|
"transaction.detected",
|
|
1006
1048
|
"split.distributed",
|
|
1007
1049
|
"webhook.dispatched",
|
|
1008
1050
|
"webhook.delivered",
|
|
1009
1051
|
"webhook.failed"
|
|
1010
1052
|
]).describe(
|
|
1011
|
-
"`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)."
|
|
1053
|
+
"`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)."
|
|
1012
1054
|
);
|
|
1013
|
-
var TimelineEventSchema =
|
|
1055
|
+
var TimelineEventSchema = import_zod17.z.object({
|
|
1014
1056
|
type: TimelineEventTypeSchema,
|
|
1015
|
-
at:
|
|
1016
|
-
txHash:
|
|
1017
|
-
amount:
|
|
1057
|
+
at: import_zod17.z.string().datetime(),
|
|
1058
|
+
txHash: import_zod17.z.string().optional().describe("Present for `transaction.detected` and `split.distributed` events only."),
|
|
1059
|
+
amount: import_zod17.z.number().optional().describe(
|
|
1018
1060
|
"Present for `transaction.detected` events only \u2014 the amount that specific transfer carried."
|
|
1019
1061
|
),
|
|
1020
1062
|
source: TransactionSourceSchema.optional().describe(
|
|
@@ -1026,66 +1068,20 @@ var TimelineEventSchema = import_zod16.z.object({
|
|
|
1026
1068
|
network: NetworkSchema.optional().describe(
|
|
1027
1069
|
"Present for `transaction.detected` and `split.distributed` events \u2014 which network this specific transfer, or settlement, used."
|
|
1028
1070
|
),
|
|
1029
|
-
causedTransition:
|
|
1071
|
+
causedTransition: import_zod17.z.boolean().optional().describe(
|
|
1030
1072
|
"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."
|
|
1031
1073
|
),
|
|
1032
1074
|
event: WebhookEventTypeSchema.optional().describe(
|
|
1033
1075
|
"Present for `webhook.*` events only \u2014 which event type this delivery was for."
|
|
1034
1076
|
),
|
|
1035
|
-
responseCode:
|
|
1077
|
+
responseCode: import_zod17.z.number().nullable().optional().describe(
|
|
1036
1078
|
"Present for `webhook.*` events only \u2014 HTTP status your endpoint returned, or `null` if the request never connected."
|
|
1037
1079
|
),
|
|
1038
|
-
attempts:
|
|
1080
|
+
attempts: import_zod17.z.number().optional().describe(
|
|
1039
1081
|
"Present for `webhook.*` events only \u2014 how many delivery attempts have been made so far."
|
|
1040
1082
|
)
|
|
1041
1083
|
});
|
|
1042
1084
|
|
|
1043
|
-
// src/verify.ts
|
|
1044
|
-
var import_zod17 = require("zod");
|
|
1045
|
-
var SplitRecipientRoleSchema = import_zod17.z.enum(["merchant", "klap_fee", "distributor_incentive"]).describe(
|
|
1046
|
-
"`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`."
|
|
1047
|
-
);
|
|
1048
|
-
var VerifySplitEntrySchema = import_zod17.z.object({
|
|
1049
|
-
role: SplitRecipientRoleSchema,
|
|
1050
|
-
address: import_zod17.z.string().nullable().describe(
|
|
1051
|
-
"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."
|
|
1052
|
-
),
|
|
1053
|
-
percentAllocation: import_zod17.z.number().describe("This entry's share of `amountReceived`, as a percentage (e.g. `99` = 99%)."),
|
|
1054
|
-
amountUSD: import_zod17.z.number()
|
|
1055
|
-
});
|
|
1056
|
-
var VerifyPaymentSchema = import_zod17.z.object({
|
|
1057
|
-
token: TokenSchema,
|
|
1058
|
-
network: NetworkSchema,
|
|
1059
|
-
amountReceived: import_zod17.z.number().describe("Cumulative amount received on this specific `(token, network)` pair."),
|
|
1060
|
-
txHash: import_zod17.z.string().describe("The on-chain transaction hash of the most recent transfer on this pair."),
|
|
1061
|
-
explorerTxUrl: import_zod17.z.string().describe("Direct link to `txHash` on the relevant block explorer."),
|
|
1062
|
-
split: import_zod17.z.array(VerifySplitEntrySchema).describe(
|
|
1063
|
-
"The exact breakdown of where this pair's payment went \u2014 merchant's share, Klappay's fee, and (once settled) the settlement incentive."
|
|
1064
|
-
),
|
|
1065
|
-
splitTxHash: import_zod17.z.string().nullable().describe(
|
|
1066
|
-
"Transaction hash of the payout to the merchant for this pair, once settlement has happened. `null` until then."
|
|
1067
|
-
),
|
|
1068
|
-
settledAt: import_zod17.z.string().datetime().nullable().describe(
|
|
1069
|
-
"When settlement completed for this pair \u2014 the merchant's wallet actually has the funds. `null` until then."
|
|
1070
|
-
)
|
|
1071
|
-
});
|
|
1072
|
-
var VerifyChargeSchema = import_zod17.z.object({
|
|
1073
|
-
id: import_zod17.z.string(),
|
|
1074
|
-
amount: import_zod17.z.number().nullable().describe("The amount originally requested. `null` if the charge accepted any amount."),
|
|
1075
|
-
amountReceived: import_zod17.z.number().describe(
|
|
1076
|
-
"The actual cumulative amount received across every contributing pair \u2014 can exceed `amount` on an overpayment."
|
|
1077
|
-
),
|
|
1078
|
-
confirmedAt: import_zod17.z.string().datetime().nullable().describe(
|
|
1079
|
-
"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."
|
|
1080
|
-
),
|
|
1081
|
-
splitAddress: import_zod17.z.string().describe(
|
|
1082
|
-
"The on-chain address the payment was sent to \u2014 identical across every accepted network."
|
|
1083
|
-
),
|
|
1084
|
-
payments: import_zod17.z.array(VerifyPaymentSchema).describe(
|
|
1085
|
-
"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."
|
|
1086
|
-
)
|
|
1087
|
-
});
|
|
1088
|
-
|
|
1089
1085
|
// src/health.ts
|
|
1090
1086
|
var import_zod18 = require("zod");
|
|
1091
1087
|
var HealthSchema = import_zod18.z.object({
|
|
@@ -1140,7 +1136,6 @@ var CapabilitiesSchema = import_zod20.z.object({
|
|
|
1140
1136
|
ChangePasswordSchema,
|
|
1141
1137
|
ChargeModeSchema,
|
|
1142
1138
|
ChargeSchema,
|
|
1143
|
-
ChargeStatusEventSchema,
|
|
1144
1139
|
ChargeStatusSchema,
|
|
1145
1140
|
ChargeWebhookEventTypeSchema,
|
|
1146
1141
|
ChargesDateFieldSchema,
|
|
@@ -1159,6 +1154,8 @@ var CapabilitiesSchema = import_zod20.z.object({
|
|
|
1159
1154
|
ErrorPayloadSchema,
|
|
1160
1155
|
ForgotPasswordSchema,
|
|
1161
1156
|
GetChargeQrCodeQuerySchema,
|
|
1157
|
+
GetPublicChargeQrCodeQuerySchema,
|
|
1158
|
+
GetPublicChargeQuerySchema,
|
|
1162
1159
|
HealthSchema,
|
|
1163
1160
|
InvitationSchema,
|
|
1164
1161
|
InviteUserSchema,
|
|
@@ -1167,6 +1164,7 @@ var CapabilitiesSchema = import_zod20.z.object({
|
|
|
1167
1164
|
ListOrganizationsSchema,
|
|
1168
1165
|
ListUsersSchema,
|
|
1169
1166
|
ListWebhookDeliveriesSchema,
|
|
1167
|
+
ListenPendingDistributionsQuerySchema,
|
|
1170
1168
|
LoginSchema,
|
|
1171
1169
|
MAX_METRICS_QUERY_DATE_RANGE_DAYS,
|
|
1172
1170
|
METRICS_QUERY_DEFAULT_ROW_LIMIT,
|
|
@@ -1197,12 +1195,14 @@ var CapabilitiesSchema = import_zod20.z.object({
|
|
|
1197
1195
|
PaginatedApiKeysSchema,
|
|
1198
1196
|
PaginatedChargesSchema,
|
|
1199
1197
|
PaginatedOrganizationsSchema,
|
|
1198
|
+
PaginatedPendingDistributionsSchema,
|
|
1200
1199
|
PaginatedUsersSchema,
|
|
1201
1200
|
PaginatedWebhookDeliveriesSchema,
|
|
1202
1201
|
PaginationQuerySchema,
|
|
1203
1202
|
PendingDistributionEventSchema,
|
|
1204
1203
|
PendingDistributionRecipientSchema,
|
|
1205
1204
|
PendingDistributionSchema,
|
|
1205
|
+
PublicChargeSchema,
|
|
1206
1206
|
ResetPasswordSchema,
|
|
1207
1207
|
SandboxEventTriggerSchema,
|
|
1208
1208
|
SandboxTriggerSchema,
|
|
@@ -1211,7 +1211,6 @@ var CapabilitiesSchema = import_zod20.z.object({
|
|
|
1211
1211
|
SettlementStatusSchema,
|
|
1212
1212
|
SignupSchema,
|
|
1213
1213
|
SplitDistributionStatusSchema,
|
|
1214
|
-
SplitRecipientRoleSchema,
|
|
1215
1214
|
TOKEN_ADDRESSES,
|
|
1216
1215
|
TOKEN_DECIMALS,
|
|
1217
1216
|
TimelineEventSchema,
|
|
@@ -1226,10 +1225,7 @@ var CapabilitiesSchema = import_zod20.z.object({
|
|
|
1226
1225
|
UpdateUserRoleSchema,
|
|
1227
1226
|
UserRoleSchema,
|
|
1228
1227
|
UserSchema,
|
|
1229
|
-
VerifyChargeSchema,
|
|
1230
1228
|
VerifyEmailSchema,
|
|
1231
|
-
VerifyPaymentSchema,
|
|
1232
|
-
VerifySplitEntrySchema,
|
|
1233
1229
|
WEBHOOK_EVENTS_WILDCARD,
|
|
1234
1230
|
WEBHOOK_EVENT_CATEGORIES,
|
|
1235
1231
|
WebhookCategorySchema,
|