@strimz/shared-types 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/agents.cjs +148 -0
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +317 -0
- package/dist/agents.d.ts +317 -0
- package/dist/agents.js +137 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.cjs +91 -0
- package/dist/api-keys.cjs.map +1 -0
- package/dist/api-keys.d.cts +155 -0
- package/dist/api-keys.d.ts +155 -0
- package/dist/api-keys.js +84 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/common.cjs +56 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +82 -0
- package/dist/common.d.ts +82 -0
- package/dist/common.js +37 -0
- package/dist/common.js.map +1 -0
- package/dist/compliance.cjs +61 -0
- package/dist/compliance.cjs.map +1 -0
- package/dist/compliance.d.cts +59 -0
- package/dist/compliance.d.ts +59 -0
- package/dist/compliance.js +56 -0
- package/dist/compliance.js.map +1 -0
- package/dist/customers.cjs +56 -0
- package/dist/customers.cjs.map +1 -0
- package/dist/customers.d.cts +64 -0
- package/dist/customers.d.ts +64 -0
- package/dist/customers.js +53 -0
- package/dist/customers.js.map +1 -0
- package/dist/events.cjs +675 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +7907 -0
- package/dist/events.d.ts +7907 -0
- package/dist/events.js +650 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +976 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.js +858 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.cjs +72 -0
- package/dist/invoices.cjs.map +1 -0
- package/dist/invoices.d.cts +159 -0
- package/dist/invoices.d.ts +159 -0
- package/dist/invoices.js +67 -0
- package/dist/invoices.js.map +1 -0
- package/dist/merchants.cjs +104 -0
- package/dist/merchants.cjs.map +1 -0
- package/dist/merchants.d.cts +259 -0
- package/dist/merchants.d.ts +259 -0
- package/dist/merchants.js +93 -0
- package/dist/merchants.js.map +1 -0
- package/dist/payment-sessions.cjs +125 -0
- package/dist/payment-sessions.cjs.map +1 -0
- package/dist/payment-sessions.d.cts +180 -0
- package/dist/payment-sessions.d.ts +180 -0
- package/dist/payment-sessions.js +120 -0
- package/dist/payment-sessions.js.map +1 -0
- package/dist/refunds.cjs +81 -0
- package/dist/refunds.cjs.map +1 -0
- package/dist/refunds.d.cts +91 -0
- package/dist/refunds.d.ts +91 -0
- package/dist/refunds.js +75 -0
- package/dist/refunds.js.map +1 -0
- package/dist/storefronts.cjs +223 -0
- package/dist/storefronts.cjs.map +1 -0
- package/dist/storefronts.d.cts +177 -0
- package/dist/storefronts.d.ts +177 -0
- package/dist/storefronts.js +216 -0
- package/dist/storefronts.js.map +1 -0
- package/dist/subscriptions.cjs +175 -0
- package/dist/subscriptions.cjs.map +1 -0
- package/dist/subscriptions.d.cts +290 -0
- package/dist/subscriptions.d.ts +290 -0
- package/dist/subscriptions.js +163 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/transactions.cjs +67 -0
- package/dist/transactions.cjs.map +1 -0
- package/dist/transactions.d.cts +78 -0
- package/dist/transactions.d.ts +78 -0
- package/dist/transactions.js +63 -0
- package/dist/transactions.js.map +1 -0
- package/dist/webhooks.cjs +116 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +201 -0
- package/dist/webhooks.d.ts +201 -0
- package/dist/webhooks.js +107 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +134 -0
- package/src/agents.ts +149 -0
- package/src/api-keys.ts +78 -0
- package/src/common.ts +113 -0
- package/src/compliance.ts +40 -0
- package/src/customers.ts +40 -0
- package/src/events.ts +176 -0
- package/src/index.ts +23 -0
- package/src/invoices.ts +53 -0
- package/src/merchants.ts +104 -0
- package/src/payment-sessions.ts +131 -0
- package/src/refunds.ts +68 -0
- package/src/storefronts.ts +89 -0
- package/src/subscriptions.ts +180 -0
- package/src/tokens.ts +60 -0
- package/src/transactions.ts +52 -0
- package/src/webhooks.ts +109 -0
package/dist/events.cjs
ADDED
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/events.ts
|
|
6
|
+
var idSchema = zod.z.string().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/, "id must be URL-safe");
|
|
7
|
+
var evmAddressSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a 0x-prefixed 40-character hex EVM address").transform((v) => v.toLowerCase());
|
|
8
|
+
var evmTxHashSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/, "must be a 0x-prefixed 64-character hex EVM transaction hash");
|
|
9
|
+
var emailSchema = zod.z.string().email().trim().toLowerCase().max(320);
|
|
10
|
+
var httpsUrlSchema = zod.z.string().url().refine((v) => v.startsWith("https://"), {
|
|
11
|
+
message: "must be an https:// URL"
|
|
12
|
+
});
|
|
13
|
+
zod.z.string().url();
|
|
14
|
+
var tokenAmountSchema = zod.z.string().regex(/^[0-9]+$/, "must be a non-negative integer string (base-10)").refine((v) => BigInt(v) >= 0n, "must be >= 0");
|
|
15
|
+
zod.z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
16
|
+
var isoTimestampSchema = zod.z.string().datetime({ offset: true, message: "must be an ISO-8601 timestamp" });
|
|
17
|
+
zod.z.string().length(2).regex(/^[A-Z]{2}$/, "must be an ISO-3166 alpha-2 country code");
|
|
18
|
+
zod.z.object({
|
|
19
|
+
limit: zod.z.number().int().min(1).max(100).default(25),
|
|
20
|
+
cursor: zod.z.string().min(1).max(200).nullish()
|
|
21
|
+
});
|
|
22
|
+
var metadataSchema = zod.z.record(
|
|
23
|
+
zod.z.string().min(1).max(40),
|
|
24
|
+
zod.z.union([zod.z.string().max(500), zod.z.number(), zod.z.boolean(), zod.z.null()])
|
|
25
|
+
).refine((m) => Object.keys(m).length <= 50, "at most 50 metadata keys").default({});
|
|
26
|
+
var modeSchema = zod.z.enum(["test", "live"]);
|
|
27
|
+
var paymentCurrencySchema = zod.z.enum(["USDC", "EURC"]);
|
|
28
|
+
zod.z.enum(["USDC", "EURC", "USYC"]);
|
|
29
|
+
zod.z.enum(["free", "growth", "business", "enterprise"]);
|
|
30
|
+
zod.z.enum(["testnet", "mainnet"]);
|
|
31
|
+
var paymentSessionStatusSchema = zod.z.enum([
|
|
32
|
+
"created",
|
|
33
|
+
"awaiting_payment",
|
|
34
|
+
"submitted",
|
|
35
|
+
"confirmed",
|
|
36
|
+
"failed",
|
|
37
|
+
"expired",
|
|
38
|
+
"cancelled"
|
|
39
|
+
]);
|
|
40
|
+
var paymentSessionSchema = zod.z.object({
|
|
41
|
+
id: idSchema,
|
|
42
|
+
merchantId: idSchema,
|
|
43
|
+
/**
|
|
44
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
45
|
+
* Set when the merchant has been registered on-chain; null when the
|
|
46
|
+
* merchant exists in our DB but the registry transaction hasn't
|
|
47
|
+
* been broadcast yet. Hosted checkout uses this to populate the
|
|
48
|
+
* meta-tx calldata; if null, the checkout refuses to accept
|
|
49
|
+
* payments.
|
|
50
|
+
*/
|
|
51
|
+
chainMerchantId: zod.z.string().regex(/^[0-9]+$/u, "must be a non-negative decimal integer string").nullable(),
|
|
52
|
+
/**
|
|
53
|
+
* ERC-20 token contract address resolved from `currency` on the
|
|
54
|
+
* active chain (Arc Testnet / Mainnet). Used as the `verifyingContract`
|
|
55
|
+
* in the EIP-712 domain for both EIP-3009 and EIP-2612 signing.
|
|
56
|
+
* Null on the (vanishingly unlikely) path where the API has no
|
|
57
|
+
* configured address for the session's currency.
|
|
58
|
+
*/
|
|
59
|
+
tokenAddress: evmAddressSchema.nullable(),
|
|
60
|
+
customerId: idSchema.nullable(),
|
|
61
|
+
status: paymentSessionStatusSchema,
|
|
62
|
+
amount: tokenAmountSchema,
|
|
63
|
+
currency: paymentCurrencySchema,
|
|
64
|
+
feeAmount: tokenAmountSchema,
|
|
65
|
+
netAmount: tokenAmountSchema,
|
|
66
|
+
description: zod.z.string().max(500).nullable(),
|
|
67
|
+
payerWalletAddress: evmAddressSchema.nullable(),
|
|
68
|
+
payerEmail: zod.z.string().email().nullable(),
|
|
69
|
+
successUrl: zod.z.string().url().nullable(),
|
|
70
|
+
cancelUrl: zod.z.string().url().nullable(),
|
|
71
|
+
sourceChain: zod.z.enum(["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]).nullable(),
|
|
72
|
+
bridgeTxHash: evmTxHashSchema.nullable(),
|
|
73
|
+
onchainTxHash: evmTxHashSchema.nullable(),
|
|
74
|
+
checkoutUrl: zod.z.string().url(),
|
|
75
|
+
metadata: metadataSchema,
|
|
76
|
+
expiresAt: isoTimestampSchema,
|
|
77
|
+
createdAt: isoTimestampSchema,
|
|
78
|
+
updatedAt: isoTimestampSchema
|
|
79
|
+
});
|
|
80
|
+
zod.z.object({
|
|
81
|
+
amount: tokenAmountSchema,
|
|
82
|
+
currency: paymentCurrencySchema,
|
|
83
|
+
description: zod.z.string().max(500).optional(),
|
|
84
|
+
customer: zod.z.object({
|
|
85
|
+
walletAddress: evmAddressSchema.optional(),
|
|
86
|
+
email: zod.z.string().email().optional(),
|
|
87
|
+
externalRef: zod.z.string().max(120).optional()
|
|
88
|
+
}).optional(),
|
|
89
|
+
successUrl: zod.z.string().url().optional(),
|
|
90
|
+
cancelUrl: zod.z.string().url().optional(),
|
|
91
|
+
/** Minutes until the session expires. Default 30, max 60*24 (one day). */
|
|
92
|
+
expiresInMinutes: zod.z.number().int().min(1).max(60 * 24).default(30),
|
|
93
|
+
/**
|
|
94
|
+
* Allowed source chains a payer can bridge USDC from via CCTP. Omit to
|
|
95
|
+
* accept every CCTP-supported chain.
|
|
96
|
+
*/
|
|
97
|
+
supportedSourceChains: zod.z.array(
|
|
98
|
+
zod.z.enum(["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"])
|
|
99
|
+
).optional(),
|
|
100
|
+
metadata: metadataSchema.optional()
|
|
101
|
+
});
|
|
102
|
+
zod.z.object({
|
|
103
|
+
sourceChain: zod.z.enum([
|
|
104
|
+
"arc",
|
|
105
|
+
"ethereum",
|
|
106
|
+
"base",
|
|
107
|
+
"polygon",
|
|
108
|
+
"arbitrum",
|
|
109
|
+
"optimism",
|
|
110
|
+
"avalanche",
|
|
111
|
+
"solana"
|
|
112
|
+
]),
|
|
113
|
+
onchainTxHash: evmTxHashSchema,
|
|
114
|
+
bridgeTxHash: evmTxHashSchema.optional(),
|
|
115
|
+
payerWalletAddress: evmAddressSchema
|
|
116
|
+
});
|
|
117
|
+
var transactionKindSchema = zod.z.enum([
|
|
118
|
+
"one_shot",
|
|
119
|
+
"subscription_charge",
|
|
120
|
+
"refund",
|
|
121
|
+
"invoice_payment",
|
|
122
|
+
"storefront_purchase"
|
|
123
|
+
]);
|
|
124
|
+
var transactionStatusSchema = zod.z.enum(["pending", "confirmed", "failed"]);
|
|
125
|
+
var transactionSchema = zod.z.object({
|
|
126
|
+
id: idSchema,
|
|
127
|
+
merchantId: idSchema,
|
|
128
|
+
kind: transactionKindSchema,
|
|
129
|
+
status: transactionStatusSchema,
|
|
130
|
+
sessionId: idSchema.nullable(),
|
|
131
|
+
subscriptionId: idSchema.nullable(),
|
|
132
|
+
subscriptionChargeId: idSchema.nullable(),
|
|
133
|
+
refundId: idSchema.nullable(),
|
|
134
|
+
customerId: idSchema.nullable(),
|
|
135
|
+
amount: tokenAmountSchema,
|
|
136
|
+
feeAmount: tokenAmountSchema,
|
|
137
|
+
netAmount: tokenAmountSchema,
|
|
138
|
+
currency: paymentCurrencySchema,
|
|
139
|
+
payerAddress: evmAddressSchema,
|
|
140
|
+
merchantAddress: evmAddressSchema,
|
|
141
|
+
onchainTxHash: evmTxHashSchema,
|
|
142
|
+
blockNumber: zod.z.number().int().nonnegative(),
|
|
143
|
+
blockTimestamp: isoTimestampSchema,
|
|
144
|
+
createdAt: isoTimestampSchema
|
|
145
|
+
});
|
|
146
|
+
var subscriptionIntervalSchema = zod.z.enum([
|
|
147
|
+
"daily",
|
|
148
|
+
"weekly",
|
|
149
|
+
"monthly",
|
|
150
|
+
"quarterly",
|
|
151
|
+
"yearly"
|
|
152
|
+
]);
|
|
153
|
+
var subscriptionPlanStatusSchema = zod.z.enum(["active", "archived"]);
|
|
154
|
+
zod.z.object({
|
|
155
|
+
id: idSchema,
|
|
156
|
+
merchantId: idSchema,
|
|
157
|
+
/**
|
|
158
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
159
|
+
* See `paymentSessionSchema.chainMerchantId`. Null when the merchant
|
|
160
|
+
* hasn't been registered on-chain yet — the hosted enrolment page
|
|
161
|
+
* refuses to take signatures in that state.
|
|
162
|
+
*/
|
|
163
|
+
chainMerchantId: zod.z.string().regex(/^[0-9]+$/u, "must be a non-negative decimal integer string").nullable(),
|
|
164
|
+
/**
|
|
165
|
+
* ERC-20 token contract address resolved from `currency` — the
|
|
166
|
+
* EIP-2612 `verifyingContract` the wallet signs over.
|
|
167
|
+
*/
|
|
168
|
+
tokenAddress: evmAddressSchema.nullable(),
|
|
169
|
+
/**
|
|
170
|
+
* Charge cadence in seconds, derived from `interval` + `intervalCount`
|
|
171
|
+
* so the meta-tx layer can pass a uint32 to StrimzSubscriptions
|
|
172
|
+
* without re-deriving the conversion on the client.
|
|
173
|
+
*/
|
|
174
|
+
intervalSeconds: zod.z.number().int().positive(),
|
|
175
|
+
name: zod.z.string().min(1).max(120),
|
|
176
|
+
description: zod.z.string().max(500).nullable(),
|
|
177
|
+
amount: tokenAmountSchema,
|
|
178
|
+
currency: paymentCurrencySchema,
|
|
179
|
+
interval: subscriptionIntervalSchema,
|
|
180
|
+
intervalCount: zod.z.number().int().min(1).max(365),
|
|
181
|
+
trialPeriodDays: zod.z.number().int().min(0).max(365).nullable(),
|
|
182
|
+
status: subscriptionPlanStatusSchema,
|
|
183
|
+
metadata: metadataSchema,
|
|
184
|
+
createdAt: isoTimestampSchema,
|
|
185
|
+
updatedAt: isoTimestampSchema
|
|
186
|
+
});
|
|
187
|
+
zod.z.object({
|
|
188
|
+
name: zod.z.string().min(1).max(120),
|
|
189
|
+
description: zod.z.string().max(500).optional(),
|
|
190
|
+
amount: tokenAmountSchema,
|
|
191
|
+
currency: paymentCurrencySchema,
|
|
192
|
+
interval: subscriptionIntervalSchema,
|
|
193
|
+
intervalCount: zod.z.number().int().min(1).max(365).default(1),
|
|
194
|
+
trialPeriodDays: zod.z.number().int().min(0).max(365).optional(),
|
|
195
|
+
metadata: metadataSchema.optional()
|
|
196
|
+
});
|
|
197
|
+
var subscriptionStatusSchema = zod.z.enum([
|
|
198
|
+
"trialing",
|
|
199
|
+
"active",
|
|
200
|
+
"at_risk",
|
|
201
|
+
"paused",
|
|
202
|
+
"cancelled",
|
|
203
|
+
"lapsed"
|
|
204
|
+
]);
|
|
205
|
+
var subscriptionSchema = zod.z.object({
|
|
206
|
+
id: idSchema,
|
|
207
|
+
onchainSubscriptionId: zod.z.number().int().nonnegative().nullable(),
|
|
208
|
+
merchantId: idSchema,
|
|
209
|
+
customerId: idSchema,
|
|
210
|
+
planId: idSchema,
|
|
211
|
+
status: subscriptionStatusSchema,
|
|
212
|
+
payerAddress: evmAddressSchema,
|
|
213
|
+
currency: paymentCurrencySchema,
|
|
214
|
+
amount: tokenAmountSchema,
|
|
215
|
+
interval: subscriptionIntervalSchema,
|
|
216
|
+
intervalCount: zod.z.number().int().min(1),
|
|
217
|
+
trialEndsAt: isoTimestampSchema.nullable(),
|
|
218
|
+
currentPeriodStartAt: isoTimestampSchema,
|
|
219
|
+
currentPeriodEndAt: isoTimestampSchema,
|
|
220
|
+
nextChargeAt: isoTimestampSchema.nullable(),
|
|
221
|
+
gracePeriodHours: zod.z.number().int().min(0).max(72),
|
|
222
|
+
cancelledAt: isoTimestampSchema.nullable(),
|
|
223
|
+
metadata: metadataSchema,
|
|
224
|
+
createdAt: isoTimestampSchema,
|
|
225
|
+
updatedAt: isoTimestampSchema
|
|
226
|
+
});
|
|
227
|
+
zod.z.object({
|
|
228
|
+
planId: idSchema,
|
|
229
|
+
customer: zod.z.object({
|
|
230
|
+
walletAddress: evmAddressSchema,
|
|
231
|
+
email: zod.z.string().email().optional(),
|
|
232
|
+
externalRef: zod.z.string().max(120).optional()
|
|
233
|
+
}),
|
|
234
|
+
gracePeriodHours: zod.z.union([zod.z.literal(24), zod.z.literal(48), zod.z.literal(72)]).default(48),
|
|
235
|
+
metadata: metadataSchema.optional()
|
|
236
|
+
});
|
|
237
|
+
zod.z.object({
|
|
238
|
+
id: idSchema,
|
|
239
|
+
reason: zod.z.string().max(500).optional()
|
|
240
|
+
});
|
|
241
|
+
var subscriptionChargeOutcomeSchema = zod.z.enum([
|
|
242
|
+
"charged",
|
|
243
|
+
"insufficient_funds",
|
|
244
|
+
"revoked_approval",
|
|
245
|
+
"cancelled",
|
|
246
|
+
"skipped"
|
|
247
|
+
]);
|
|
248
|
+
var subscriptionChargeStatusSchema = zod.z.enum([
|
|
249
|
+
"pending",
|
|
250
|
+
"in_flight",
|
|
251
|
+
"succeeded",
|
|
252
|
+
"failed",
|
|
253
|
+
"retrying",
|
|
254
|
+
"abandoned"
|
|
255
|
+
]);
|
|
256
|
+
var subscriptionChargeSchema = zod.z.object({
|
|
257
|
+
id: idSchema,
|
|
258
|
+
subscriptionId: idSchema,
|
|
259
|
+
merchantId: idSchema,
|
|
260
|
+
chargeAttemptId: zod.z.string().length(66, "must be a 32-byte 0x-prefixed hex string"),
|
|
261
|
+
periodStartAt: isoTimestampSchema,
|
|
262
|
+
periodEndAt: isoTimestampSchema,
|
|
263
|
+
amount: tokenAmountSchema,
|
|
264
|
+
currency: paymentCurrencySchema,
|
|
265
|
+
status: subscriptionChargeStatusSchema,
|
|
266
|
+
outcome: subscriptionChargeOutcomeSchema.nullable(),
|
|
267
|
+
attemptNumber: zod.z.number().int().min(1),
|
|
268
|
+
scheduledAt: isoTimestampSchema,
|
|
269
|
+
executedAt: isoTimestampSchema.nullable(),
|
|
270
|
+
onchainTxHash: evmTxHashSchema.nullable(),
|
|
271
|
+
failureReason: zod.z.string().max(500).nullable(),
|
|
272
|
+
createdAt: isoTimestampSchema,
|
|
273
|
+
updatedAt: isoTimestampSchema
|
|
274
|
+
});
|
|
275
|
+
var refundReasonSchema = zod.z.enum([
|
|
276
|
+
"customer_request",
|
|
277
|
+
"product_issue",
|
|
278
|
+
"duplicate_charge",
|
|
279
|
+
"fraudulent",
|
|
280
|
+
"other"
|
|
281
|
+
]);
|
|
282
|
+
var refundStatusSchema = zod.z.enum([
|
|
283
|
+
"pending",
|
|
284
|
+
"awaiting_signature",
|
|
285
|
+
"submitted",
|
|
286
|
+
"completed",
|
|
287
|
+
"failed",
|
|
288
|
+
"cancelled"
|
|
289
|
+
]);
|
|
290
|
+
var refundSchema = zod.z.object({
|
|
291
|
+
id: idSchema,
|
|
292
|
+
merchantId: idSchema,
|
|
293
|
+
transactionId: idSchema,
|
|
294
|
+
amount: tokenAmountSchema,
|
|
295
|
+
currency: paymentCurrencySchema,
|
|
296
|
+
reason: refundReasonSchema,
|
|
297
|
+
note: zod.z.string().max(500).nullable(),
|
|
298
|
+
status: refundStatusSchema,
|
|
299
|
+
payerAddress: evmAddressSchema,
|
|
300
|
+
refundTxHash: evmTxHashSchema.nullable(),
|
|
301
|
+
failureReason: zod.z.string().max(500).nullable(),
|
|
302
|
+
initiatedBy: idSchema,
|
|
303
|
+
createdAt: isoTimestampSchema,
|
|
304
|
+
completedAt: isoTimestampSchema.nullable()
|
|
305
|
+
});
|
|
306
|
+
zod.z.object({
|
|
307
|
+
transactionId: idSchema,
|
|
308
|
+
amount: tokenAmountSchema,
|
|
309
|
+
reason: refundReasonSchema,
|
|
310
|
+
note: zod.z.string().max(500).optional()
|
|
311
|
+
});
|
|
312
|
+
zod.z.object({
|
|
313
|
+
id: idSchema,
|
|
314
|
+
refundTxHash: evmTxHashSchema
|
|
315
|
+
});
|
|
316
|
+
var invoiceStatusSchema = zod.z.enum(["draft", "sent", "paid", "overdue", "void"]);
|
|
317
|
+
var invoiceLineItemSchema = zod.z.object({
|
|
318
|
+
description: zod.z.string().min(1).max(500),
|
|
319
|
+
quantity: zod.z.number().int().min(1).max(1e4),
|
|
320
|
+
unitAmount: tokenAmountSchema
|
|
321
|
+
});
|
|
322
|
+
var invoiceSchema = zod.z.object({
|
|
323
|
+
id: idSchema,
|
|
324
|
+
merchantId: idSchema,
|
|
325
|
+
number: zod.z.string().min(1).max(40),
|
|
326
|
+
customerName: zod.z.string().min(1).max(200).nullable(),
|
|
327
|
+
customerEmail: emailSchema.nullable(),
|
|
328
|
+
lineItems: zod.z.array(invoiceLineItemSchema).nonempty(),
|
|
329
|
+
subtotal: tokenAmountSchema,
|
|
330
|
+
total: tokenAmountSchema,
|
|
331
|
+
currency: paymentCurrencySchema,
|
|
332
|
+
status: invoiceStatusSchema,
|
|
333
|
+
note: zod.z.string().max(2e3).nullable(),
|
|
334
|
+
sessionId: idSchema.nullable(),
|
|
335
|
+
dueAt: isoTimestampSchema,
|
|
336
|
+
paidAt: isoTimestampSchema.nullable(),
|
|
337
|
+
sentAt: isoTimestampSchema.nullable(),
|
|
338
|
+
createdAt: isoTimestampSchema,
|
|
339
|
+
updatedAt: isoTimestampSchema
|
|
340
|
+
});
|
|
341
|
+
zod.z.object({
|
|
342
|
+
customerName: zod.z.string().min(1).max(200).optional(),
|
|
343
|
+
customerEmail: emailSchema.optional(),
|
|
344
|
+
lineItems: zod.z.array(invoiceLineItemSchema).nonempty(),
|
|
345
|
+
currency: paymentCurrencySchema,
|
|
346
|
+
note: zod.z.string().max(2e3).optional(),
|
|
347
|
+
dueInDays: zod.z.number().int().min(1).max(90).default(7)
|
|
348
|
+
});
|
|
349
|
+
zod.z.object({
|
|
350
|
+
id: idSchema,
|
|
351
|
+
/** ERC-8004 on-chain identity address. */
|
|
352
|
+
onchainAddress: evmAddressSchema,
|
|
353
|
+
/** Public key or agent credential digest, as emitted by ERC-8004. */
|
|
354
|
+
credentialDigest: zod.z.string().regex(/^0x[a-fA-F0-9]+$/),
|
|
355
|
+
name: zod.z.string().min(1).max(120),
|
|
356
|
+
version: zod.z.string().min(1).max(40),
|
|
357
|
+
reputationScore: zod.z.number().min(0).max(100).nullable(),
|
|
358
|
+
registeredAt: isoTimestampSchema
|
|
359
|
+
});
|
|
360
|
+
var agentCapabilitySchema = zod.z.enum([
|
|
361
|
+
"identity",
|
|
362
|
+
"recovery",
|
|
363
|
+
"routing",
|
|
364
|
+
"cashflow",
|
|
365
|
+
"commerce",
|
|
366
|
+
"pricing_intelligence"
|
|
367
|
+
]);
|
|
368
|
+
var agentMerchantConfigSchema = zod.z.object({
|
|
369
|
+
merchantId: idSchema,
|
|
370
|
+
enabledCapabilities: zod.z.array(agentCapabilitySchema).default([]),
|
|
371
|
+
recovery: zod.z.object({
|
|
372
|
+
gracePeriodHours: zod.z.union([zod.z.literal(24), zod.z.literal(48), zod.z.literal(72)]).default(48),
|
|
373
|
+
strategy: zod.z.enum(["once", "twice", "until_grace_ends"]).default("twice"),
|
|
374
|
+
notificationTemplate: zod.z.string().max(2e3).nullable()
|
|
375
|
+
}),
|
|
376
|
+
cashflow: zod.z.object({
|
|
377
|
+
digestEnabled: zod.z.boolean().default(false),
|
|
378
|
+
anomalySensitivity: zod.z.enum(["low", "medium", "high"]).default("medium"),
|
|
379
|
+
autoConvertToYield: zod.z.boolean().default(false),
|
|
380
|
+
minimumLiquidReserveCents: zod.z.number().int().nonnegative().default(1e5)
|
|
381
|
+
}),
|
|
382
|
+
commerce: zod.z.object({
|
|
383
|
+
requireHumanApprovalAboveUsdCents: zod.z.number().int().nonnegative().default(1e5),
|
|
384
|
+
approvedVendors: zod.z.array(evmAddressSchema).default([]),
|
|
385
|
+
monthlySpendCapUsdCents: zod.z.number().int().nonnegative().nullable()
|
|
386
|
+
}),
|
|
387
|
+
updatedAt: isoTimestampSchema
|
|
388
|
+
});
|
|
389
|
+
agentMerchantConfigSchema.omit({ merchantId: true, updatedAt: true }).partial();
|
|
390
|
+
var agentActionTypeSchema = zod.z.enum([
|
|
391
|
+
"recovery_notification_sent",
|
|
392
|
+
"recovery_retry_scheduled",
|
|
393
|
+
"recovery_retry_executed",
|
|
394
|
+
"recovery_abandoned",
|
|
395
|
+
"routing_bridge_initiated",
|
|
396
|
+
"routing_payment_completed",
|
|
397
|
+
"cashflow_digest_sent",
|
|
398
|
+
"cashflow_anomaly_flagged",
|
|
399
|
+
"cashflow_yield_converted",
|
|
400
|
+
"commerce_job_created",
|
|
401
|
+
"commerce_job_approved",
|
|
402
|
+
"commerce_job_completed",
|
|
403
|
+
"commerce_job_disputed"
|
|
404
|
+
]);
|
|
405
|
+
var agentActionOutcomeSchema = zod.z.enum(["success", "failure", "pending", "skipped"]);
|
|
406
|
+
var agentActivityLogSchema = zod.z.object({
|
|
407
|
+
id: idSchema,
|
|
408
|
+
merchantId: idSchema,
|
|
409
|
+
capability: agentCapabilitySchema,
|
|
410
|
+
actionType: agentActionTypeSchema,
|
|
411
|
+
outcome: agentActionOutcomeSchema,
|
|
412
|
+
subscriptionId: idSchema.nullable(),
|
|
413
|
+
transactionId: idSchema.nullable(),
|
|
414
|
+
jobId: idSchema.nullable(),
|
|
415
|
+
metadata: metadataSchema,
|
|
416
|
+
createdAt: isoTimestampSchema
|
|
417
|
+
});
|
|
418
|
+
var agentJobStatusSchema = zod.z.enum([
|
|
419
|
+
"proposed",
|
|
420
|
+
"accepted",
|
|
421
|
+
"in_progress",
|
|
422
|
+
"delivered",
|
|
423
|
+
"approved",
|
|
424
|
+
"completed",
|
|
425
|
+
"disputed",
|
|
426
|
+
"cancelled"
|
|
427
|
+
]);
|
|
428
|
+
var agentJobSchema = zod.z.object({
|
|
429
|
+
id: idSchema,
|
|
430
|
+
merchantId: idSchema,
|
|
431
|
+
/** On-chain job id from StrimzAgentEscrow. */
|
|
432
|
+
onchainJobId: zod.z.number().int().nonnegative().nullable(),
|
|
433
|
+
vendorAddress: evmAddressSchema,
|
|
434
|
+
description: zod.z.string().min(1).max(2e3),
|
|
435
|
+
amount: tokenAmountSchema,
|
|
436
|
+
currency: zod.z.enum(["USDC", "EURC"]),
|
|
437
|
+
status: agentJobStatusSchema,
|
|
438
|
+
assessorAddress: evmAddressSchema,
|
|
439
|
+
deliverableHash: zod.z.string().regex(/^0x[a-fA-F0-9]+$/).nullable(),
|
|
440
|
+
escrowTxHash: evmTxHashSchema.nullable(),
|
|
441
|
+
releaseTxHash: evmTxHashSchema.nullable(),
|
|
442
|
+
createdAt: isoTimestampSchema,
|
|
443
|
+
completedAt: isoTimestampSchema.nullable()
|
|
444
|
+
});
|
|
445
|
+
zod.z.object({
|
|
446
|
+
vendorAddress: evmAddressSchema,
|
|
447
|
+
description: zod.z.string().min(1).max(2e3),
|
|
448
|
+
amount: tokenAmountSchema,
|
|
449
|
+
currency: zod.z.enum(["USDC", "EURC"]),
|
|
450
|
+
assessorAddress: evmAddressSchema.optional()
|
|
451
|
+
});
|
|
452
|
+
var complianceProviderSchema = zod.z.enum(["trm", "elliptic", "disabled"]);
|
|
453
|
+
var complianceStatusSchema = zod.z.enum(["clear", "flagged", "blocked", "error"]);
|
|
454
|
+
var complianceScreeningContextSchema = zod.z.enum([
|
|
455
|
+
"merchant_onboarding",
|
|
456
|
+
"payer_checkout",
|
|
457
|
+
"subscriber_signup",
|
|
458
|
+
"refund_recipient"
|
|
459
|
+
]);
|
|
460
|
+
var complianceLogSchema = zod.z.object({
|
|
461
|
+
id: idSchema,
|
|
462
|
+
walletAddress: evmAddressSchema,
|
|
463
|
+
provider: complianceProviderSchema,
|
|
464
|
+
status: complianceStatusSchema,
|
|
465
|
+
riskScore: zod.z.number().min(0).max(100).nullable(),
|
|
466
|
+
flags: zod.z.array(zod.z.string().max(120)).default([]),
|
|
467
|
+
context: complianceScreeningContextSchema,
|
|
468
|
+
merchantId: idSchema.nullable(),
|
|
469
|
+
sessionId: idSchema.nullable(),
|
|
470
|
+
subscriptionId: idSchema.nullable(),
|
|
471
|
+
providerRequestId: zod.z.string().max(200).nullable(),
|
|
472
|
+
createdAt: isoTimestampSchema
|
|
473
|
+
});
|
|
474
|
+
var webhookEventNameSchema = zod.z.enum([
|
|
475
|
+
"payment.created",
|
|
476
|
+
"payment.completed",
|
|
477
|
+
"payment.failed",
|
|
478
|
+
"subscription.created",
|
|
479
|
+
"subscription.charged",
|
|
480
|
+
"subscription.charge_failed",
|
|
481
|
+
"subscription.recovery_attempt",
|
|
482
|
+
"subscription.recovery_outcome",
|
|
483
|
+
"subscription.cancelled",
|
|
484
|
+
"subscription.lapsed",
|
|
485
|
+
"refund.created",
|
|
486
|
+
"refund.completed",
|
|
487
|
+
"refund.failed",
|
|
488
|
+
"invoice.created",
|
|
489
|
+
"invoice.paid",
|
|
490
|
+
"invoice.overdue",
|
|
491
|
+
"agent.action_executed",
|
|
492
|
+
"agent.job_proposed",
|
|
493
|
+
"agent.job_completed",
|
|
494
|
+
"agent.job_disputed",
|
|
495
|
+
"compliance.wallet_flagged",
|
|
496
|
+
"compliance.wallet_blocked"
|
|
497
|
+
]);
|
|
498
|
+
var webhookEndpointStatusSchema = zod.z.enum(["active", "disabled"]);
|
|
499
|
+
var webhookEndpointSchema = zod.z.object({
|
|
500
|
+
id: idSchema,
|
|
501
|
+
merchantId: idSchema,
|
|
502
|
+
mode: modeSchema,
|
|
503
|
+
url: httpsUrlSchema,
|
|
504
|
+
description: zod.z.string().max(200).nullable(),
|
|
505
|
+
events: zod.z.array(webhookEventNameSchema).nonempty(),
|
|
506
|
+
status: webhookEndpointStatusSchema,
|
|
507
|
+
signingSecretPrefix: zod.z.string().min(4).max(12),
|
|
508
|
+
lastDeliveredAt: isoTimestampSchema.nullable(),
|
|
509
|
+
createdAt: isoTimestampSchema,
|
|
510
|
+
updatedAt: isoTimestampSchema
|
|
511
|
+
});
|
|
512
|
+
zod.z.object({
|
|
513
|
+
url: httpsUrlSchema,
|
|
514
|
+
events: zod.z.array(webhookEventNameSchema).nonempty(),
|
|
515
|
+
description: zod.z.string().max(200).optional(),
|
|
516
|
+
mode: modeSchema
|
|
517
|
+
});
|
|
518
|
+
zod.z.object({
|
|
519
|
+
endpoint: webhookEndpointSchema,
|
|
520
|
+
/** Full signing secret — shown exactly once. */
|
|
521
|
+
signingSecret: zod.z.string()
|
|
522
|
+
});
|
|
523
|
+
var webhookDeliveryStatusSchema = zod.z.enum([
|
|
524
|
+
"pending",
|
|
525
|
+
"delivered",
|
|
526
|
+
"retrying",
|
|
527
|
+
"permanently_failed"
|
|
528
|
+
]);
|
|
529
|
+
zod.z.object({
|
|
530
|
+
id: idSchema,
|
|
531
|
+
merchantId: idSchema,
|
|
532
|
+
endpointId: idSchema,
|
|
533
|
+
eventId: idSchema,
|
|
534
|
+
eventName: webhookEventNameSchema,
|
|
535
|
+
status: webhookDeliveryStatusSchema,
|
|
536
|
+
attempt: zod.z.number().int().min(1).max(6),
|
|
537
|
+
responseCode: zod.z.number().int().min(100).max(599).nullable(),
|
|
538
|
+
responseMs: zod.z.number().int().min(0).nullable(),
|
|
539
|
+
lastError: zod.z.string().max(1e3).nullable(),
|
|
540
|
+
nextAttemptAt: isoTimestampSchema.nullable(),
|
|
541
|
+
deliveredAt: isoTimestampSchema.nullable(),
|
|
542
|
+
createdAt: isoTimestampSchema
|
|
543
|
+
});
|
|
544
|
+
zod.z.object({
|
|
545
|
+
id: idSchema
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
// src/events.ts
|
|
549
|
+
var envelope = (name, data) => zod.z.object({
|
|
550
|
+
id: idSchema,
|
|
551
|
+
type: zod.z.literal(name),
|
|
552
|
+
apiVersion: zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
553
|
+
mode: modeSchema,
|
|
554
|
+
createdAt: isoTimestampSchema,
|
|
555
|
+
data
|
|
556
|
+
});
|
|
557
|
+
var paymentCreatedEventSchema = envelope("payment.created", paymentSessionSchema);
|
|
558
|
+
var paymentCompletedEventSchema = envelope(
|
|
559
|
+
"payment.completed",
|
|
560
|
+
zod.z.object({ session: paymentSessionSchema, transaction: transactionSchema })
|
|
561
|
+
);
|
|
562
|
+
var paymentFailedEventSchema = envelope(
|
|
563
|
+
"payment.failed",
|
|
564
|
+
zod.z.object({ session: paymentSessionSchema, reason: zod.z.string() })
|
|
565
|
+
);
|
|
566
|
+
var subscriptionCreatedEventSchema = envelope("subscription.created", subscriptionSchema);
|
|
567
|
+
var subscriptionChargedEventSchema = envelope(
|
|
568
|
+
"subscription.charged",
|
|
569
|
+
zod.z.object({
|
|
570
|
+
subscription: subscriptionSchema,
|
|
571
|
+
charge: subscriptionChargeSchema,
|
|
572
|
+
transaction: transactionSchema
|
|
573
|
+
})
|
|
574
|
+
);
|
|
575
|
+
var subscriptionChargeFailedEventSchema = envelope(
|
|
576
|
+
"subscription.charge_failed",
|
|
577
|
+
zod.z.object({ subscription: subscriptionSchema, charge: subscriptionChargeSchema })
|
|
578
|
+
);
|
|
579
|
+
var subscriptionRecoveryAttemptEventSchema = envelope(
|
|
580
|
+
"subscription.recovery_attempt",
|
|
581
|
+
zod.z.object({ subscription: subscriptionSchema, attemptNumber: zod.z.number().int().min(1) })
|
|
582
|
+
);
|
|
583
|
+
var subscriptionRecoveryOutcomeEventSchema = envelope(
|
|
584
|
+
"subscription.recovery_outcome",
|
|
585
|
+
zod.z.object({
|
|
586
|
+
subscription: subscriptionSchema,
|
|
587
|
+
outcome: zod.z.enum(["recovered", "churned"])
|
|
588
|
+
})
|
|
589
|
+
);
|
|
590
|
+
var subscriptionCancelledEventSchema = envelope(
|
|
591
|
+
"subscription.cancelled",
|
|
592
|
+
subscriptionSchema
|
|
593
|
+
);
|
|
594
|
+
var subscriptionLapsedEventSchema = envelope("subscription.lapsed", subscriptionSchema);
|
|
595
|
+
var refundCreatedEventSchema = envelope("refund.created", refundSchema);
|
|
596
|
+
var refundCompletedEventSchema = envelope(
|
|
597
|
+
"refund.completed",
|
|
598
|
+
zod.z.object({ refund: refundSchema, transaction: transactionSchema })
|
|
599
|
+
);
|
|
600
|
+
var refundFailedEventSchema = envelope(
|
|
601
|
+
"refund.failed",
|
|
602
|
+
zod.z.object({ refund: refundSchema, reason: zod.z.string() })
|
|
603
|
+
);
|
|
604
|
+
var invoiceCreatedEventSchema = envelope("invoice.created", invoiceSchema);
|
|
605
|
+
var invoicePaidEventSchema = envelope(
|
|
606
|
+
"invoice.paid",
|
|
607
|
+
zod.z.object({ invoice: invoiceSchema, transaction: transactionSchema })
|
|
608
|
+
);
|
|
609
|
+
var invoiceOverdueEventSchema = envelope("invoice.overdue", invoiceSchema);
|
|
610
|
+
var agentActionExecutedEventSchema = envelope(
|
|
611
|
+
"agent.action_executed",
|
|
612
|
+
agentActivityLogSchema
|
|
613
|
+
);
|
|
614
|
+
var agentJobProposedEventSchema = envelope("agent.job_proposed", agentJobSchema);
|
|
615
|
+
var agentJobCompletedEventSchema = envelope("agent.job_completed", agentJobSchema);
|
|
616
|
+
var agentJobDisputedEventSchema = envelope("agent.job_disputed", agentJobSchema);
|
|
617
|
+
var complianceWalletFlaggedEventSchema = envelope(
|
|
618
|
+
"compliance.wallet_flagged",
|
|
619
|
+
complianceLogSchema
|
|
620
|
+
);
|
|
621
|
+
var complianceWalletBlockedEventSchema = envelope(
|
|
622
|
+
"compliance.wallet_blocked",
|
|
623
|
+
complianceLogSchema
|
|
624
|
+
);
|
|
625
|
+
var webhookEventSchema = zod.z.discriminatedUnion("type", [
|
|
626
|
+
paymentCreatedEventSchema,
|
|
627
|
+
paymentCompletedEventSchema,
|
|
628
|
+
paymentFailedEventSchema,
|
|
629
|
+
subscriptionCreatedEventSchema,
|
|
630
|
+
subscriptionChargedEventSchema,
|
|
631
|
+
subscriptionChargeFailedEventSchema,
|
|
632
|
+
subscriptionRecoveryAttemptEventSchema,
|
|
633
|
+
subscriptionRecoveryOutcomeEventSchema,
|
|
634
|
+
subscriptionCancelledEventSchema,
|
|
635
|
+
subscriptionLapsedEventSchema,
|
|
636
|
+
refundCreatedEventSchema,
|
|
637
|
+
refundCompletedEventSchema,
|
|
638
|
+
refundFailedEventSchema,
|
|
639
|
+
invoiceCreatedEventSchema,
|
|
640
|
+
invoicePaidEventSchema,
|
|
641
|
+
invoiceOverdueEventSchema,
|
|
642
|
+
agentActionExecutedEventSchema,
|
|
643
|
+
agentJobProposedEventSchema,
|
|
644
|
+
agentJobCompletedEventSchema,
|
|
645
|
+
agentJobDisputedEventSchema,
|
|
646
|
+
complianceWalletFlaggedEventSchema,
|
|
647
|
+
complianceWalletBlockedEventSchema
|
|
648
|
+
]);
|
|
649
|
+
|
|
650
|
+
exports.agentActionExecutedEventSchema = agentActionExecutedEventSchema;
|
|
651
|
+
exports.agentJobCompletedEventSchema = agentJobCompletedEventSchema;
|
|
652
|
+
exports.agentJobDisputedEventSchema = agentJobDisputedEventSchema;
|
|
653
|
+
exports.agentJobProposedEventSchema = agentJobProposedEventSchema;
|
|
654
|
+
exports.complianceWalletBlockedEventSchema = complianceWalletBlockedEventSchema;
|
|
655
|
+
exports.complianceWalletFlaggedEventSchema = complianceWalletFlaggedEventSchema;
|
|
656
|
+
exports.invoiceCreatedEventSchema = invoiceCreatedEventSchema;
|
|
657
|
+
exports.invoiceOverdueEventSchema = invoiceOverdueEventSchema;
|
|
658
|
+
exports.invoicePaidEventSchema = invoicePaidEventSchema;
|
|
659
|
+
exports.paymentCompletedEventSchema = paymentCompletedEventSchema;
|
|
660
|
+
exports.paymentCreatedEventSchema = paymentCreatedEventSchema;
|
|
661
|
+
exports.paymentFailedEventSchema = paymentFailedEventSchema;
|
|
662
|
+
exports.refundCompletedEventSchema = refundCompletedEventSchema;
|
|
663
|
+
exports.refundCreatedEventSchema = refundCreatedEventSchema;
|
|
664
|
+
exports.refundFailedEventSchema = refundFailedEventSchema;
|
|
665
|
+
exports.subscriptionCancelledEventSchema = subscriptionCancelledEventSchema;
|
|
666
|
+
exports.subscriptionChargeFailedEventSchema = subscriptionChargeFailedEventSchema;
|
|
667
|
+
exports.subscriptionChargedEventSchema = subscriptionChargedEventSchema;
|
|
668
|
+
exports.subscriptionCreatedEventSchema = subscriptionCreatedEventSchema;
|
|
669
|
+
exports.subscriptionLapsedEventSchema = subscriptionLapsedEventSchema;
|
|
670
|
+
exports.subscriptionRecoveryAttemptEventSchema = subscriptionRecoveryAttemptEventSchema;
|
|
671
|
+
exports.subscriptionRecoveryOutcomeEventSchema = subscriptionRecoveryOutcomeEventSchema;
|
|
672
|
+
exports.webhookEventNameSchema = webhookEventNameSchema;
|
|
673
|
+
exports.webhookEventSchema = webhookEventSchema;
|
|
674
|
+
//# sourceMappingURL=events.cjs.map
|
|
675
|
+
//# sourceMappingURL=events.cjs.map
|