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