@strimz/shared-types 0.1.0 → 0.2.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 (97) hide show
  1. package/README.md +66 -36
  2. package/dist/agents.cjs.map +1 -1
  3. package/dist/agents.d.cts +1 -1
  4. package/dist/agents.d.ts +1 -1
  5. package/dist/agents.js.map +1 -1
  6. package/dist/api-keys.cjs +8 -3
  7. package/dist/api-keys.cjs.map +1 -1
  8. package/dist/api-keys.d.cts +15 -16
  9. package/dist/api-keys.d.ts +15 -16
  10. package/dist/api-keys.js +8 -3
  11. package/dist/api-keys.js.map +1 -1
  12. package/dist/common.cjs.map +1 -1
  13. package/dist/common.d.cts +2 -2
  14. package/dist/common.d.ts +2 -2
  15. package/dist/common.js.map +1 -1
  16. package/dist/compliance.cjs.map +1 -1
  17. package/dist/compliance.d.cts +1 -1
  18. package/dist/compliance.d.ts +1 -1
  19. package/dist/compliance.js.map +1 -1
  20. package/dist/customers.cjs.map +1 -1
  21. package/dist/customers.d.cts +1 -1
  22. package/dist/customers.d.ts +1 -1
  23. package/dist/customers.js.map +1 -1
  24. package/dist/events.cjs +24 -6
  25. package/dist/events.cjs.map +1 -1
  26. package/dist/events.d.cts +12 -12
  27. package/dist/events.d.ts +12 -12
  28. package/dist/events.js +24 -6
  29. package/dist/events.js.map +1 -1
  30. package/dist/index.cjs +188 -11
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +302 -17
  33. package/dist/index.d.ts +302 -17
  34. package/dist/index.js +167 -12
  35. package/dist/index.js.map +1 -1
  36. package/dist/invoices.cjs.map +1 -1
  37. package/dist/invoices.d.cts +1 -1
  38. package/dist/invoices.d.ts +1 -1
  39. package/dist/invoices.js.map +1 -1
  40. package/dist/merchants.cjs +59 -1
  41. package/dist/merchants.cjs.map +1 -1
  42. package/dist/merchants.d.cts +171 -1
  43. package/dist/merchants.d.ts +171 -1
  44. package/dist/merchants.js +55 -2
  45. package/dist/merchants.js.map +1 -1
  46. package/dist/payment-sessions.cjs +6 -2
  47. package/dist/payment-sessions.cjs.map +1 -1
  48. package/dist/payment-sessions.d.cts +20 -4
  49. package/dist/payment-sessions.d.ts +20 -4
  50. package/dist/payment-sessions.js +6 -3
  51. package/dist/payment-sessions.js.map +1 -1
  52. package/dist/refunds.cjs +12 -0
  53. package/dist/refunds.cjs.map +1 -1
  54. package/dist/refunds.d.cts +135 -2
  55. package/dist/refunds.d.ts +135 -2
  56. package/dist/refunds.js +11 -1
  57. package/dist/refunds.js.map +1 -1
  58. package/dist/storefronts.cjs +16 -2
  59. package/dist/storefronts.cjs.map +1 -1
  60. package/dist/storefronts.d.cts +38 -2
  61. package/dist/storefronts.d.ts +38 -2
  62. package/dist/storefronts.js +15 -3
  63. package/dist/storefronts.js.map +1 -1
  64. package/dist/subscriptions.cjs +2 -2
  65. package/dist/subscriptions.cjs.map +1 -1
  66. package/dist/subscriptions.d.cts +3 -3
  67. package/dist/subscriptions.d.ts +3 -3
  68. package/dist/subscriptions.js +2 -2
  69. package/dist/subscriptions.js.map +1 -1
  70. package/dist/transactions.cjs.map +1 -1
  71. package/dist/transactions.d.cts +2 -2
  72. package/dist/transactions.d.ts +2 -2
  73. package/dist/transactions.js.map +1 -1
  74. package/dist/webhooks.cjs +7 -1
  75. package/dist/webhooks.cjs.map +1 -1
  76. package/dist/webhooks.d.cts +63 -4
  77. package/dist/webhooks.d.ts +63 -4
  78. package/dist/webhooks.js +7 -2
  79. package/dist/webhooks.js.map +1 -1
  80. package/package.json +2 -2
  81. package/src/agents.ts +1 -1
  82. package/src/api-keys.ts +9 -5
  83. package/src/common.ts +2 -2
  84. package/src/compliance.ts +1 -1
  85. package/src/contact.ts +26 -0
  86. package/src/customers.ts +1 -1
  87. package/src/index.ts +2 -0
  88. package/src/invoices.ts +1 -1
  89. package/src/merchants.ts +84 -0
  90. package/src/notifications.ts +88 -0
  91. package/src/payment-sessions.ts +25 -3
  92. package/src/refunds.ts +20 -1
  93. package/src/storefronts.ts +25 -1
  94. package/src/subscriptions.ts +3 -3
  95. package/src/tokens.ts +7 -7
  96. package/src/transactions.ts +2 -2
  97. package/src/webhooks.ts +15 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/subscriptions.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAG3C,IAAM,gBAAA,GAAmB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAG5B,IAAM,kBAAkB,CAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D,CAAA;AAGlE,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAG5C,CAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC;AAG0B,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOjC,IAAM,iBAAA,GAAoB,CAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,CAAC,CAAA,IAAK,IAAI,cAAc,CAAA;AAGtB,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,MAAA,CAAO,gBAAgB;AAGtE,IAAM,kBAAA,GAAqB,CAAA,CAC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n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Subscriptions — plans, active subscriptions, and individual charges.\n *\n * Design notes:\n * - A SubscriptionPlan is the template a merchant defines.\n * - A Subscription is an active, customer-scoped instance of a plan.\n * - Each billing period produces a SubscriptionCharge with a unique\n * chargeAttemptId used to enforce idempotency at the contract level.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n metadataSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\n// ---------- Plans ----------\n\nexport const subscriptionIntervalSchema = z.enum([\n 'daily',\n 'weekly',\n 'monthly',\n 'quarterly',\n 'yearly',\n])\nexport type SubscriptionInterval = z.infer<typeof subscriptionIntervalSchema>\n\nexport const subscriptionPlanStatusSchema = z.enum(['active', 'archived'])\nexport type SubscriptionPlanStatus = z.infer<typeof subscriptionPlanStatusSchema>\n\nexport const subscriptionPlanSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n /**\n * On-chain StrimzRegistry merchant id (uint96) as a decimal string.\n * See `paymentSessionSchema.chainMerchantId`. Null when the merchant\n * hasn't been registered on-chain yet — the hosted enrolment page\n * refuses to take signatures in that state.\n */\n chainMerchantId: z\n .string()\n .regex(/^[0-9]+$/u, 'must be a non-negative decimal integer string')\n .nullable(),\n /**\n * ERC-20 token contract address resolved from `currency` — the\n * EIP-2612 `verifyingContract` the wallet signs over.\n */\n tokenAddress: evmAddressSchema.nullable(),\n /**\n * Charge cadence in seconds, derived from `interval` + `intervalCount`\n * so the meta-tx layer can pass a uint32 to StrimzSubscriptions\n * without re-deriving the conversion on the client.\n */\n intervalSeconds: z.number().int().positive(),\n name: z.string().min(1).max(120),\n description: z.string().max(500).nullable(),\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n interval: subscriptionIntervalSchema,\n intervalCount: z.number().int().min(1).max(365),\n trialPeriodDays: z.number().int().min(0).max(365).nullable(),\n status: subscriptionPlanStatusSchema,\n metadata: metadataSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type SubscriptionPlan = z.infer<typeof subscriptionPlanSchema>\n\nexport const createSubscriptionPlanInputSchema = z.object({\n name: z.string().min(1).max(120),\n description: z.string().max(500).optional(),\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n interval: subscriptionIntervalSchema,\n intervalCount: z.number().int().min(1).max(365).default(1),\n trialPeriodDays: z.number().int().min(0).max(365).optional(),\n metadata: metadataSchema.optional(),\n})\nexport type CreateSubscriptionPlanInput = z.infer<typeof createSubscriptionPlanInputSchema>\n\n// ---------- Subscriptions ----------\n\nexport const subscriptionStatusSchema = z.enum([\n 'trialing',\n 'active',\n 'at_risk',\n 'paused',\n 'cancelled',\n 'lapsed',\n])\nexport type SubscriptionStatus = z.infer<typeof subscriptionStatusSchema>\n\nexport const subscriptionSchema = z.object({\n id: idSchema,\n onchainSubscriptionId: z.number().int().nonnegative().nullable(),\n merchantId: idSchema,\n customerId: idSchema,\n planId: idSchema,\n status: subscriptionStatusSchema,\n payerAddress: evmAddressSchema,\n currency: paymentCurrencySchema,\n amount: tokenAmountSchema,\n interval: subscriptionIntervalSchema,\n intervalCount: z.number().int().min(1),\n trialEndsAt: isoTimestampSchema.nullable(),\n currentPeriodStartAt: isoTimestampSchema,\n currentPeriodEndAt: isoTimestampSchema,\n nextChargeAt: isoTimestampSchema.nullable(),\n gracePeriodHours: z.number().int().min(0).max(72),\n cancelledAt: isoTimestampSchema.nullable(),\n metadata: metadataSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type Subscription = z.infer<typeof subscriptionSchema>\n\nexport const createSubscriptionInputSchema = z.object({\n planId: idSchema,\n customer: z.object({\n walletAddress: evmAddressSchema,\n email: z.string().email().optional(),\n externalRef: z.string().max(120).optional(),\n }),\n gracePeriodHours: z.union([z.literal(24), z.literal(48), z.literal(72)]).default(48),\n metadata: metadataSchema.optional(),\n})\nexport type CreateSubscriptionInput = z.infer<typeof createSubscriptionInputSchema>\n\nexport const cancelSubscriptionInputSchema = z.object({\n id: idSchema,\n reason: z.string().max(500).optional(),\n})\nexport type CancelSubscriptionInput = z.infer<typeof cancelSubscriptionInputSchema>\n\n// ---------- Charges ----------\n\nexport const subscriptionChargeOutcomeSchema = z.enum([\n 'charged',\n 'insufficient_funds',\n 'revoked_approval',\n 'cancelled',\n 'skipped',\n])\nexport type SubscriptionChargeOutcome = z.infer<typeof subscriptionChargeOutcomeSchema>\n\nexport const subscriptionChargeStatusSchema = z.enum([\n 'pending',\n 'in_flight',\n 'succeeded',\n 'failed',\n 'retrying',\n 'abandoned',\n])\nexport type SubscriptionChargeStatus = z.infer<typeof subscriptionChargeStatusSchema>\n\nexport const subscriptionChargeSchema = z.object({\n id: idSchema,\n subscriptionId: idSchema,\n merchantId: idSchema,\n chargeAttemptId: z.string().length(66, 'must be a 32-byte 0x-prefixed hex string'),\n periodStartAt: isoTimestampSchema,\n periodEndAt: isoTimestampSchema,\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n status: subscriptionChargeStatusSchema,\n outcome: subscriptionChargeOutcomeSchema.nullable(),\n attemptNumber: z.number().int().min(1),\n scheduledAt: isoTimestampSchema,\n executedAt: isoTimestampSchema.nullable(),\n onchainTxHash: evmTxHashSchema.nullable(),\n failureReason: z.string().max(500).nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type SubscriptionCharge = z.infer<typeof subscriptionChargeSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/subscriptions.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAG3C,IAAM,gBAAA,GAAmB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAG5B,IAAM,kBAAkB,CAAA,CAC5B,MAAA,EAAO,CACP,KA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;AAAA,EACZ,iBAAiBA,CAAAA,CAAE,MAAA,EAAO,CAAE,MAAA,CAAO,IAAI,0CAA0C,CAAA;AAAA,EACjF,aAAA,EAAe,kBAAA;AAAA,EACf,WAAA,EAAa,kBAAA;AAAA,EACb,MAAA,EAAQ,iBAAA;AAAA,EACR,QAAA,EAAU,qBAAA;AAAA,EACV,MAAA,EAAQ,8BAAA;AAAA,EACR,OAAA,EAAS,gCAAgC,QAAA,EAAS;AAAA,EAClD,eAAeA,CAAAA,CAAE,MAAA,GAAS,GAAA,EAAI,CAAE,IAAI,CAAC,CAAA;AAAA,EACrC,WAAA,EAAa,kBAAA;AAAA,EACb,UAAA,EAAY,mBAAmB,QAAA,EAAS;AAAA,EACxC,aAAA,EAAe,gBAAgB,QAAA,EAAS;AAAA,EACxC,eAAeA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA,EAAS;AAAA,EAC5C,SAAA,EAAW,kBAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAC","file":"subscriptions.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Subscriptions: plans, active subscriptions, and individual charges.\n *\n * Design notes:\n * - A SubscriptionPlan is the template a merchant defines.\n * - A Subscription is an active, customer-scoped instance of a plan.\n * - Each billing period produces a SubscriptionCharge with a unique\n * chargeAttemptId used to enforce idempotency at the contract level.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n metadataSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\n// ---------- Plans ----------\n\nexport const subscriptionIntervalSchema = z.enum([\n 'daily',\n 'weekly',\n 'monthly',\n 'quarterly',\n 'yearly',\n])\nexport type SubscriptionInterval = z.infer<typeof subscriptionIntervalSchema>\n\nexport const subscriptionPlanStatusSchema = z.enum(['active', 'archived'])\nexport type SubscriptionPlanStatus = z.infer<typeof subscriptionPlanStatusSchema>\n\nexport const subscriptionPlanSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n /**\n * On-chain StrimzRegistry merchant id (uint96) as a decimal string.\n * See `paymentSessionSchema.chainMerchantId`. Null when the merchant\n * hasn't been registered on-chain yet. The hosted enrolment page\n * refuses to take signatures in that state.\n */\n chainMerchantId: z\n .string()\n .regex(/^[0-9]+$/u, 'must be a non-negative decimal integer string')\n .nullable(),\n /**\n * ERC-20 token contract address resolved from `currency`. This is the\n * EIP-2612 `verifyingContract` the wallet signs over.\n */\n tokenAddress: evmAddressSchema.nullable(),\n /**\n * Charge cadence in seconds, derived from `interval` + `intervalCount`\n * so the meta-tx layer can pass a uint32 to StrimzSubscriptions\n * without re-deriving the conversion on the client.\n */\n intervalSeconds: z.number().int().positive(),\n name: z.string().min(1).max(120),\n description: z.string().max(500).nullable(),\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n interval: subscriptionIntervalSchema,\n intervalCount: z.number().int().min(1).max(365),\n trialPeriodDays: z.number().int().min(0).max(365).nullable(),\n status: subscriptionPlanStatusSchema,\n metadata: metadataSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type SubscriptionPlan = z.infer<typeof subscriptionPlanSchema>\n\nexport const createSubscriptionPlanInputSchema = z.object({\n name: z.string().min(1).max(120),\n description: z.string().max(500).optional(),\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n interval: subscriptionIntervalSchema,\n intervalCount: z.number().int().min(1).max(365).default(1),\n trialPeriodDays: z.number().int().min(0).max(365).optional(),\n metadata: metadataSchema.optional(),\n})\nexport type CreateSubscriptionPlanInput = z.infer<typeof createSubscriptionPlanInputSchema>\n\n// ---------- Subscriptions ----------\n\nexport const subscriptionStatusSchema = z.enum([\n 'trialing',\n 'active',\n 'at_risk',\n 'paused',\n 'cancelled',\n 'lapsed',\n])\nexport type SubscriptionStatus = z.infer<typeof subscriptionStatusSchema>\n\nexport const subscriptionSchema = z.object({\n id: idSchema,\n onchainSubscriptionId: z.number().int().nonnegative().nullable(),\n merchantId: idSchema,\n customerId: idSchema,\n planId: idSchema,\n status: subscriptionStatusSchema,\n payerAddress: evmAddressSchema,\n currency: paymentCurrencySchema,\n amount: tokenAmountSchema,\n interval: subscriptionIntervalSchema,\n intervalCount: z.number().int().min(1),\n trialEndsAt: isoTimestampSchema.nullable(),\n currentPeriodStartAt: isoTimestampSchema,\n currentPeriodEndAt: isoTimestampSchema,\n nextChargeAt: isoTimestampSchema.nullable(),\n gracePeriodHours: z.number().int().min(0).max(72),\n cancelledAt: isoTimestampSchema.nullable(),\n metadata: metadataSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type Subscription = z.infer<typeof subscriptionSchema>\n\nexport const createSubscriptionInputSchema = z.object({\n planId: idSchema,\n customer: z.object({\n walletAddress: evmAddressSchema,\n email: z.string().email().optional(),\n externalRef: z.string().max(120).optional(),\n }),\n gracePeriodHours: z.union([z.literal(24), z.literal(48), z.literal(72)]).default(48),\n metadata: metadataSchema.optional(),\n})\nexport type CreateSubscriptionInput = z.infer<typeof createSubscriptionInputSchema>\n\nexport const cancelSubscriptionInputSchema = z.object({\n id: idSchema,\n reason: z.string().max(500).optional(),\n})\nexport type CancelSubscriptionInput = z.infer<typeof cancelSubscriptionInputSchema>\n\n// ---------- Charges ----------\n\nexport const subscriptionChargeOutcomeSchema = z.enum([\n 'charged',\n 'insufficient_funds',\n 'revoked_approval',\n 'cancelled',\n 'skipped',\n])\nexport type SubscriptionChargeOutcome = z.infer<typeof subscriptionChargeOutcomeSchema>\n\nexport const subscriptionChargeStatusSchema = z.enum([\n 'pending',\n 'in_flight',\n 'succeeded',\n 'failed',\n 'retrying',\n 'abandoned',\n])\nexport type SubscriptionChargeStatus = z.infer<typeof subscriptionChargeStatusSchema>\n\nexport const subscriptionChargeSchema = z.object({\n id: idSchema,\n subscriptionId: idSchema,\n merchantId: idSchema,\n chargeAttemptId: z.string().length(66, 'must be a 32-byte 0x-prefixed hex string'),\n periodStartAt: isoTimestampSchema,\n periodEndAt: isoTimestampSchema,\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n status: subscriptionChargeStatusSchema,\n outcome: subscriptionChargeOutcomeSchema.nullable(),\n attemptNumber: z.number().int().min(1),\n scheduledAt: isoTimestampSchema,\n executedAt: isoTimestampSchema.nullable(),\n onchainTxHash: evmTxHashSchema.nullable(),\n failureReason: z.string().max(500).nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type SubscriptionCharge = z.infer<typeof subscriptionChargeSchema>\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/transactions.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAG3C,IAAM,gBAAA,GAAmBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAG5B,IAAM,kBAAkBA,KAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D,CAAA;AAGlEA,KAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAG5CA,KAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC;AAG0BA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOjC,IAAM,iBAAA,GAAoBA,KAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,CAAC,CAAA,IAAK,IAAI,cAAc,CAAA;AAGtBA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EA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,MAAA,EAAQ,MAAM,CAAC;AAI9BA,MAAE,IAAA,CAAK,CAAC,QAAQ,QAAA,EAAU,UAAA,EAAY,YAAY,CAAC;AAIjDA,KAAA,CAAE,IAAA,CAAK,CAAC,SAAA,EAAW,SAAS,CAAC;;;ACtF1D,IAAM,qBAAA,GAAwBA,MAAE,IAAA,CAAK;AAAA,EAC1C,UAAA;AAAA,EACA,qBAAA;AAAA,EACA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,0BAA0BA,KAAAA,CAAE,IAAA,CAAK,CAAC,SAAA,EAAW,WAAA,EAAa,QAAQ,CAAC;AAGzE,IAAM,iBAAA,GAAoBA,MAAE,MAAA,CAAO;AAAA,EACxC,EAAA,EAAI,QAAA;AAAA,EACJ,UAAA,EAAY,QAAA;AAAA,EACZ,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ,uBAAA;AAAA,EACR,SAAA,EAAW,SAAS,QAAA,EAAS;AAAA,EAC7B,cAAA,EAAgB,SAAS,QAAA,EAAS;AAAA,EAClC,oBAAA,EAAsB,SAAS,QAAA,EAAS;AAAA,EACxC,QAAA,EAAU,SAAS,QAAA,EAAS;AAAA,EAC5B,UAAA,EAAY,SAAS,QAAA,EAAS;AAAA,EAC9B,MAAA,EAAQ,iBAAA;AAAA,EACR,SAAA,EAAW,iBAAA;AAAA,EACX,SAAA,EAAW,iBAAA;AAAA,EACX,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,gBAAA;AAAA,EACd,eAAA,EAAiB,gBAAA;AAAA,EACjB,aAAA,EAAe,eAAA;AAAA,EACf,aAAaA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,WAAA,EAAY;AAAA,EAC1C,cAAA,EAAgB,kBAAA;AAAA,EAChB,SAAA,EAAW;AACb,CAAC","file":"transactions.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Transaction — the record of a confirmed on-chain payment.\n *\n * Every transaction corresponds to either a paid PaymentSession, a\n * SubscriptionCharge, or a Refund. The indexer writes these from the\n * `PaymentExecuted`, `SubscriptionCharged`, and `RefundRecorded` events.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\nexport const transactionKindSchema = z.enum([\n 'one_shot',\n 'subscription_charge',\n 'refund',\n 'invoice_payment',\n 'storefront_purchase',\n])\nexport type TransactionKind = z.infer<typeof transactionKindSchema>\n\nexport const transactionStatusSchema = z.enum(['pending', 'confirmed', 'failed'])\nexport type TransactionStatus = z.infer<typeof transactionStatusSchema>\n\nexport const transactionSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n kind: transactionKindSchema,\n status: transactionStatusSchema,\n sessionId: idSchema.nullable(),\n subscriptionId: idSchema.nullable(),\n subscriptionChargeId: idSchema.nullable(),\n refundId: idSchema.nullable(),\n customerId: idSchema.nullable(),\n amount: tokenAmountSchema,\n feeAmount: tokenAmountSchema,\n netAmount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n payerAddress: evmAddressSchema,\n merchantAddress: evmAddressSchema,\n onchainTxHash: evmTxHashSchema,\n blockNumber: z.number().int().nonnegative(),\n blockTimestamp: isoTimestampSchema,\n createdAt: isoTimestampSchema,\n})\nexport type Transaction = z.infer<typeof transactionSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/transactions.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAG3C,IAAM,gBAAA,GAAmBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAG5B,IAAM,kBAAkBA,KAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D,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S,QAAA,EAAS;AAAA,EACxC,QAAA,EAAU,SAAS,QAAA,EAAS;AAAA,EAC5B,UAAA,EAAY,SAAS,QAAA,EAAS;AAAA,EAC9B,MAAA,EAAQ,iBAAA;AAAA,EACR,SAAA,EAAW,iBAAA;AAAA,EACX,SAAA,EAAW,iBAAA;AAAA,EACX,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,gBAAA;AAAA,EACd,eAAA,EAAiB,gBAAA;AAAA,EACjB,aAAA,EAAe,eAAA;AAAA,EACf,aAAaA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,WAAA,EAAY;AAAA,EAC1C,cAAA,EAAgB,kBAAA;AAAA,EAChB,SAAA,EAAW;AACb,CAAC","file":"transactions.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Transaction. The record of a confirmed on-chain payment.\n *\n * Every transaction corresponds to either a paid PaymentSession, a\n * SubscriptionCharge, or a Refund. Records are derived from the\n * `PaymentExecuted`, `SubscriptionCharged`, and `RefundRecorded` events.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\nexport const transactionKindSchema = z.enum([\n 'one_shot',\n 'subscription_charge',\n 'refund',\n 'invoice_payment',\n 'storefront_purchase',\n])\nexport type TransactionKind = z.infer<typeof transactionKindSchema>\n\nexport const transactionStatusSchema = z.enum(['pending', 'confirmed', 'failed'])\nexport type TransactionStatus = z.infer<typeof transactionStatusSchema>\n\nexport const transactionSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n kind: transactionKindSchema,\n status: transactionStatusSchema,\n sessionId: idSchema.nullable(),\n subscriptionId: idSchema.nullable(),\n subscriptionChargeId: idSchema.nullable(),\n refundId: idSchema.nullable(),\n customerId: idSchema.nullable(),\n amount: tokenAmountSchema,\n feeAmount: tokenAmountSchema,\n netAmount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n payerAddress: evmAddressSchema,\n merchantAddress: evmAddressSchema,\n onchainTxHash: evmTxHashSchema,\n blockNumber: z.number().int().nonnegative(),\n blockTimestamp: isoTimestampSchema,\n createdAt: isoTimestampSchema,\n})\nexport type Transaction = z.infer<typeof transactionSchema>\n"]}
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  /**
4
- * Transaction — the record of a confirmed on-chain payment.
4
+ * Transaction. The record of a confirmed on-chain payment.
5
5
  *
6
6
  * Every transaction corresponds to either a paid PaymentSession, a
7
- * SubscriptionCharge, or a Refund. The indexer writes these from the
7
+ * SubscriptionCharge, or a Refund. Records are derived from the
8
8
  * `PaymentExecuted`, `SubscriptionCharged`, and `RefundRecorded` events.
9
9
  */
10
10
 
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  /**
4
- * Transaction — the record of a confirmed on-chain payment.
4
+ * Transaction. The record of a confirmed on-chain payment.
5
5
  *
6
6
  * Every transaction corresponds to either a paid PaymentSession, a
7
- * SubscriptionCharge, or a Refund. The indexer writes these from the
7
+ * SubscriptionCharge, or a Refund. Records are derived from the
8
8
  * `PaymentExecuted`, `SubscriptionCharged`, and `RefundRecorded` events.
9
9
  */
10
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/transactions.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAG3C,IAAM,gBAAA,GAAmB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAG5B,IAAM,kBAAkB,CAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D,CAAA;AAGlE,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAG5C,C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A,EAAW,iBAAA;AAAA,EACX,SAAA,EAAW,iBAAA;AAAA,EACX,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,gBAAA;AAAA,EACd,eAAA,EAAiB,gBAAA;AAAA,EACjB,aAAA,EAAe,eAAA;AAAA,EACf,aAAaA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,WAAA,EAAY;AAAA,EAC1C,cAAA,EAAgB,kBAAA;AAAA,EAChB,SAAA,EAAW;AACb,CAAC","file":"transactions.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Transaction — the record of a confirmed on-chain payment.\n *\n * Every transaction corresponds to either a paid PaymentSession, a\n * SubscriptionCharge, or a Refund. The indexer writes these from the\n * `PaymentExecuted`, `SubscriptionCharged`, and `RefundRecorded` events.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\nexport const transactionKindSchema = z.enum([\n 'one_shot',\n 'subscription_charge',\n 'refund',\n 'invoice_payment',\n 'storefront_purchase',\n])\nexport type TransactionKind = z.infer<typeof transactionKindSchema>\n\nexport const transactionStatusSchema = z.enum(['pending', 'confirmed', 'failed'])\nexport type TransactionStatus = z.infer<typeof transactionStatusSchema>\n\nexport const transactionSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n kind: transactionKindSchema,\n status: transactionStatusSchema,\n sessionId: idSchema.nullable(),\n subscriptionId: idSchema.nullable(),\n subscriptionChargeId: idSchema.nullable(),\n refundId: idSchema.nullable(),\n customerId: idSchema.nullable(),\n amount: tokenAmountSchema,\n feeAmount: tokenAmountSchema,\n netAmount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n payerAddress: evmAddressSchema,\n merchantAddress: evmAddressSchema,\n onchainTxHash: evmTxHashSchema,\n blockNumber: z.number().int().nonnegative(),\n blockTimestamp: isoTimestampSchema,\n createdAt: isoTimestampSchema,\n})\nexport type Transaction = z.infer<typeof transactionSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/transactions.ts"],"names":["z"],"mappings":";;;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AM,0BAA0BA,CAAAA,CAAE,IAAA,CAAK,CAAC,SAAA,EAAW,WAAA,EAAa,QAAQ,CAAC;AAGzE,IAAM,iBAAA,GAAoBA,EAAE,MAAA,CAAO;AAAA,EACxC,EAAA,EAAI,QAAA;AAAA,EACJ,UAAA,EAAY,QAAA;AAAA,EACZ,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ,uBAAA;AAAA,EACR,SAAA,EAAW,SAAS,QAAA,EAAS;AAAA,EAC7B,cAAA,EAAgB,SAAS,QAAA,EAAS;AAAA,EAClC,oBAAA,EAAsB,SAAS,QAAA,EAAS;AAAA,EACxC,QAAA,EAAU,SAAS,QAAA,EAAS;AAAA,EAC5B,UAAA,EAAY,SAAS,QAAA,EAAS;AAAA,EAC9B,MAAA,EAAQ,iBAAA;AAAA,EACR,SAAA,EAAW,iBAAA;AAAA,EACX,SAAA,EAAW,iBAAA;AAAA,EACX,QAAA,EAAU,qBAAA;AAAA,EACV,YAAA,EAAc,gBAAA;AAAA,EACd,eAAA,EAAiB,gBAAA;AAAA,EACjB,aAAA,EAAe,eAAA;AAAA,EACf,aAAaA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,WAAA,EAAY;AAAA,EAC1C,cAAA,EAAgB,kBAAA;AAAA,EAChB,SAAA,EAAW;AACb,CAAC","file":"transactions.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Transaction. The record of a confirmed on-chain payment.\n *\n * Every transaction corresponds to either a paid PaymentSession, a\n * SubscriptionCharge, or a Refund. Records are derived from the\n * `PaymentExecuted`, `SubscriptionCharged`, and `RefundRecorded` events.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\nexport const transactionKindSchema = z.enum([\n 'one_shot',\n 'subscription_charge',\n 'refund',\n 'invoice_payment',\n 'storefront_purchase',\n])\nexport type TransactionKind = z.infer<typeof transactionKindSchema>\n\nexport const transactionStatusSchema = z.enum(['pending', 'confirmed', 'failed'])\nexport type TransactionStatus = z.infer<typeof transactionStatusSchema>\n\nexport const transactionSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n kind: transactionKindSchema,\n status: transactionStatusSchema,\n sessionId: idSchema.nullable(),\n subscriptionId: idSchema.nullable(),\n subscriptionChargeId: idSchema.nullable(),\n refundId: idSchema.nullable(),\n customerId: idSchema.nullable(),\n amount: tokenAmountSchema,\n feeAmount: tokenAmountSchema,\n netAmount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n payerAddress: evmAddressSchema,\n merchantAddress: evmAddressSchema,\n onchainTxHash: evmTxHashSchema,\n blockNumber: z.number().int().nonnegative(),\n blockTimestamp: isoTimestampSchema,\n createdAt: isoTimestampSchema,\n})\nexport type Transaction = z.infer<typeof transactionSchema>\n"]}
package/dist/webhooks.cjs CHANGED
@@ -76,7 +76,7 @@ var createWebhookEndpointInputSchema = zod.z.object({
76
76
  });
77
77
  var createWebhookEndpointOutputSchema = zod.z.object({
78
78
  endpoint: webhookEndpointSchema,
79
- /** Full signing secret — shown exactly once. */
79
+ /** Full signing secret. Shown exactly once. */
80
80
  signingSecret: zod.z.string()
81
81
  });
82
82
  var webhookDeliveryStatusSchema = zod.z.enum([
@@ -100,6 +100,11 @@ var webhookDeliverySchema = zod.z.object({
100
100
  deliveredAt: isoTimestampSchema.nullable(),
101
101
  createdAt: isoTimestampSchema
102
102
  });
103
+ var webhookDeliveryDetailSchema = webhookDeliverySchema.extend({
104
+ deliveryId: zod.z.string(),
105
+ responseBody: zod.z.string().nullable(),
106
+ requestPayload: zod.z.record(zod.z.string(), zod.z.unknown())
107
+ });
103
108
  var replayDeliveryInputSchema = zod.z.object({
104
109
  id: idSchema
105
110
  });
@@ -107,6 +112,7 @@ var replayDeliveryInputSchema = zod.z.object({
107
112
  exports.createWebhookEndpointInputSchema = createWebhookEndpointInputSchema;
108
113
  exports.createWebhookEndpointOutputSchema = createWebhookEndpointOutputSchema;
109
114
  exports.replayDeliveryInputSchema = replayDeliveryInputSchema;
115
+ exports.webhookDeliveryDetailSchema = webhookDeliveryDetailSchema;
110
116
  exports.webhookDeliverySchema = webhookDeliverySchema;
111
117
  exports.webhookDeliveryStatusSchema = webhookDeliveryStatusSchema;
112
118
  exports.webhookEndpointSchema = webhookEndpointSchema;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJA,KAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlEA,KAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAGnE,IAAM,cAAA,GAAiBA,KAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC,CAAA;AAG0BA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOPA,KAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,CAAC,CAAA,IAAK,IAAI,cAAc;AAGtBA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,MAAA,CAAO,gBAAgB;AAGtE,IAAM,kBAAA,GAAqBA,KAAA,CAC/B,MAAA,EAAO,CACP,QAAA,CAAS,EAAE,MAAA,EAAQ,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AAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed here (not imported from\n * `@strimz/shared-config`) so Zod can produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret — shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJA,KAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlEA,KAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE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,EAASA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA;AAAA,EACtC,YAAA,EAAcA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAYA,MAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,KAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAQM,IAAM,2BAAA,GAA8B,sBAAsB,MAAA,CAAO;AAAA,EACtE,UAAA,EAAYA,MAAE,MAAA,EAAO;AAAA,EACrB,YAAA,EAAcA,KAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAClC,cAAA,EAAgBA,MAAE,MAAA,CAAOA,KAAAA,CAAE,QAAO,EAAGA,KAAAA,CAAE,SAAS;AAClD,CAAC;AAGM,IAAM,yBAAA,GAA4BA,MAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\n/**\n * Detail projection returned by GET /v1/webhook-deliveries/:id.\n * Carries the payload envelope, response body, and the deliveryId\n * header the receiver saw. Kept separate so list responses stay slim.\n */\nexport const webhookDeliveryDetailSchema = webhookDeliverySchema.extend({\n deliveryId: z.string(),\n responseBody: z.string().nullable(),\n requestPayload: z.record(z.string(), z.unknown()),\n})\nexport type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
@@ -9,8 +9,8 @@ import { z } from 'zod';
9
9
  */
10
10
 
11
11
  /**
12
- * Every webhook event name in the system. Listed here (not imported from
13
- * `@strimz/shared-config`) so Zod can produce a concrete string union.
12
+ * Every webhook event name in the system. Listed inline so Zod can
13
+ * produce a concrete string union.
14
14
  */
15
15
  declare const webhookEventNameSchema: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
16
16
  type WebhookEventName = z.infer<typeof webhookEventNameSchema>;
@@ -109,7 +109,7 @@ declare const createWebhookEndpointOutputSchema: z.ZodObject<{
109
109
  signingSecretPrefix: string;
110
110
  lastDeliveredAt: string | null;
111
111
  }>;
112
- /** Full signing secret — shown exactly once. */
112
+ /** Full signing secret. Shown exactly once. */
113
113
  signingSecret: z.ZodString;
114
114
  }, "strip", z.ZodTypeAny, {
115
115
  endpoint: {
@@ -189,6 +189,65 @@ declare const webhookDeliverySchema: z.ZodObject<{
189
189
  deliveredAt: string | null;
190
190
  }>;
191
191
  type WebhookDelivery = z.infer<typeof webhookDeliverySchema>;
192
+ /**
193
+ * Detail projection returned by GET /v1/webhook-deliveries/:id.
194
+ * Carries the payload envelope, response body, and the deliveryId
195
+ * header the receiver saw. Kept separate so list responses stay slim.
196
+ */
197
+ declare const webhookDeliveryDetailSchema: z.ZodObject<{
198
+ id: z.ZodString;
199
+ merchantId: z.ZodString;
200
+ endpointId: z.ZodString;
201
+ eventId: z.ZodString;
202
+ eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
203
+ status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
204
+ attempt: z.ZodNumber;
205
+ responseCode: z.ZodNullable<z.ZodNumber>;
206
+ responseMs: z.ZodNullable<z.ZodNumber>;
207
+ lastError: z.ZodNullable<z.ZodString>;
208
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
209
+ deliveredAt: z.ZodNullable<z.ZodString>;
210
+ createdAt: z.ZodString;
211
+ } & {
212
+ deliveryId: z.ZodString;
213
+ responseBody: z.ZodNullable<z.ZodString>;
214
+ requestPayload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
215
+ }, "strip", z.ZodTypeAny, {
216
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
217
+ id: string;
218
+ merchantId: string;
219
+ createdAt: string;
220
+ endpointId: string;
221
+ eventId: string;
222
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
223
+ attempt: number;
224
+ responseCode: number | null;
225
+ responseMs: number | null;
226
+ lastError: string | null;
227
+ nextAttemptAt: string | null;
228
+ deliveredAt: string | null;
229
+ deliveryId: string;
230
+ responseBody: string | null;
231
+ requestPayload: Record<string, unknown>;
232
+ }, {
233
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
234
+ id: string;
235
+ merchantId: string;
236
+ createdAt: string;
237
+ endpointId: string;
238
+ eventId: string;
239
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
240
+ attempt: number;
241
+ responseCode: number | null;
242
+ responseMs: number | null;
243
+ lastError: string | null;
244
+ nextAttemptAt: string | null;
245
+ deliveredAt: string | null;
246
+ deliveryId: string;
247
+ responseBody: string | null;
248
+ requestPayload: Record<string, unknown>;
249
+ }>;
250
+ type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>;
192
251
  declare const replayDeliveryInputSchema: z.ZodObject<{
193
252
  id: z.ZodString;
194
253
  }, "strip", z.ZodTypeAny, {
@@ -198,4 +257,4 @@ declare const replayDeliveryInputSchema: z.ZodObject<{
198
257
  }>;
199
258
  type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>;
200
259
 
201
- export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
260
+ export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliveryDetailSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
@@ -9,8 +9,8 @@ import { z } from 'zod';
9
9
  */
10
10
 
11
11
  /**
12
- * Every webhook event name in the system. Listed here (not imported from
13
- * `@strimz/shared-config`) so Zod can produce a concrete string union.
12
+ * Every webhook event name in the system. Listed inline so Zod can
13
+ * produce a concrete string union.
14
14
  */
15
15
  declare const webhookEventNameSchema: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
16
16
  type WebhookEventName = z.infer<typeof webhookEventNameSchema>;
@@ -109,7 +109,7 @@ declare const createWebhookEndpointOutputSchema: z.ZodObject<{
109
109
  signingSecretPrefix: string;
110
110
  lastDeliveredAt: string | null;
111
111
  }>;
112
- /** Full signing secret — shown exactly once. */
112
+ /** Full signing secret. Shown exactly once. */
113
113
  signingSecret: z.ZodString;
114
114
  }, "strip", z.ZodTypeAny, {
115
115
  endpoint: {
@@ -189,6 +189,65 @@ declare const webhookDeliverySchema: z.ZodObject<{
189
189
  deliveredAt: string | null;
190
190
  }>;
191
191
  type WebhookDelivery = z.infer<typeof webhookDeliverySchema>;
192
+ /**
193
+ * Detail projection returned by GET /v1/webhook-deliveries/:id.
194
+ * Carries the payload envelope, response body, and the deliveryId
195
+ * header the receiver saw. Kept separate so list responses stay slim.
196
+ */
197
+ declare const webhookDeliveryDetailSchema: z.ZodObject<{
198
+ id: z.ZodString;
199
+ merchantId: z.ZodString;
200
+ endpointId: z.ZodString;
201
+ eventId: z.ZodString;
202
+ eventName: z.ZodEnum<["payment.created", "payment.completed", "payment.failed", "subscription.created", "subscription.charged", "subscription.charge_failed", "subscription.recovery_attempt", "subscription.recovery_outcome", "subscription.cancelled", "subscription.lapsed", "refund.created", "refund.completed", "refund.failed", "invoice.created", "invoice.paid", "invoice.overdue", "agent.action_executed", "agent.job_proposed", "agent.job_completed", "agent.job_disputed", "compliance.wallet_flagged", "compliance.wallet_blocked"]>;
203
+ status: z.ZodEnum<["pending", "delivered", "retrying", "permanently_failed"]>;
204
+ attempt: z.ZodNumber;
205
+ responseCode: z.ZodNullable<z.ZodNumber>;
206
+ responseMs: z.ZodNullable<z.ZodNumber>;
207
+ lastError: z.ZodNullable<z.ZodString>;
208
+ nextAttemptAt: z.ZodNullable<z.ZodString>;
209
+ deliveredAt: z.ZodNullable<z.ZodString>;
210
+ createdAt: z.ZodString;
211
+ } & {
212
+ deliveryId: z.ZodString;
213
+ responseBody: z.ZodNullable<z.ZodString>;
214
+ requestPayload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
215
+ }, "strip", z.ZodTypeAny, {
216
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
217
+ id: string;
218
+ merchantId: string;
219
+ createdAt: string;
220
+ endpointId: string;
221
+ eventId: string;
222
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
223
+ attempt: number;
224
+ responseCode: number | null;
225
+ responseMs: number | null;
226
+ lastError: string | null;
227
+ nextAttemptAt: string | null;
228
+ deliveredAt: string | null;
229
+ deliveryId: string;
230
+ responseBody: string | null;
231
+ requestPayload: Record<string, unknown>;
232
+ }, {
233
+ status: "pending" | "retrying" | "delivered" | "permanently_failed";
234
+ id: string;
235
+ merchantId: string;
236
+ createdAt: string;
237
+ endpointId: string;
238
+ eventId: string;
239
+ eventName: "payment.created" | "payment.completed" | "payment.failed" | "subscription.created" | "subscription.charged" | "subscription.charge_failed" | "subscription.recovery_attempt" | "subscription.recovery_outcome" | "subscription.cancelled" | "subscription.lapsed" | "refund.created" | "refund.completed" | "refund.failed" | "invoice.created" | "invoice.paid" | "invoice.overdue" | "agent.action_executed" | "agent.job_proposed" | "agent.job_completed" | "agent.job_disputed" | "compliance.wallet_flagged" | "compliance.wallet_blocked";
240
+ attempt: number;
241
+ responseCode: number | null;
242
+ responseMs: number | null;
243
+ lastError: string | null;
244
+ nextAttemptAt: string | null;
245
+ deliveredAt: string | null;
246
+ deliveryId: string;
247
+ responseBody: string | null;
248
+ requestPayload: Record<string, unknown>;
249
+ }>;
250
+ type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>;
192
251
  declare const replayDeliveryInputSchema: z.ZodObject<{
193
252
  id: z.ZodString;
194
253
  }, "strip", z.ZodTypeAny, {
@@ -198,4 +257,4 @@ declare const replayDeliveryInputSchema: z.ZodObject<{
198
257
  }>;
199
258
  type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>;
200
259
 
201
- export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
260
+ export { type CreateWebhookEndpointInput, type CreateWebhookEndpointOutput, type ReplayDeliveryInput, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEventName, createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliveryDetailSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
package/dist/webhooks.js CHANGED
@@ -74,7 +74,7 @@ var createWebhookEndpointInputSchema = z.object({
74
74
  });
75
75
  var createWebhookEndpointOutputSchema = z.object({
76
76
  endpoint: webhookEndpointSchema,
77
- /** Full signing secret — shown exactly once. */
77
+ /** Full signing secret. Shown exactly once. */
78
78
  signingSecret: z.string()
79
79
  });
80
80
  var webhookDeliveryStatusSchema = z.enum([
@@ -98,10 +98,15 @@ var webhookDeliverySchema = z.object({
98
98
  deliveredAt: isoTimestampSchema.nullable(),
99
99
  createdAt: isoTimestampSchema
100
100
  });
101
+ var webhookDeliveryDetailSchema = webhookDeliverySchema.extend({
102
+ deliveryId: z.string(),
103
+ responseBody: z.string().nullable(),
104
+ requestPayload: z.record(z.string(), z.unknown())
105
+ });
101
106
  var replayDeliveryInputSchema = z.object({
102
107
  id: idSchema
103
108
  });
104
109
 
105
- export { createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
110
+ export { createWebhookEndpointInputSchema, createWebhookEndpointOutputSchema, replayDeliveryInputSchema, webhookDeliveryDetailSchema, webhookDeliverySchema, webhookDeliveryStatusSchema, webhookEndpointSchema, webhookEndpointStatusSchema, webhookEventNameSchema };
106
111
  //# sourceMappingURL=webhooks.js.map
107
112
  //# sourceMappingURL=webhooks.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJ,CAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlE,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAGnE,IAAM,cAAA,GAAiB,CAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC,CAAA;AAG0B,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOP,CAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,CAAC,CAAA,IAAK,IAAI,cAAc;AAGtB,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,MAAA,CAAO,gBAAgB;AAGtE,IAAM,kBAAA,GAAqB,CAAA,CA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M,yBAAA,GAA4BA,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed here (not imported from\n * `@strimz/shared-config`) so Zod can produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret — shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/webhooks.ts"],"names":["z"],"mappings":";;;AAQO,IAAM,QAAA,GAAW,CAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAGlB,CAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa;AAGJ,CAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D;AAGlE,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,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R,OAAA,EAASA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA;AAAA,EACtC,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAYA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7C,WAAWA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAI,EAAE,QAAA,EAAS;AAAA,EACzC,aAAA,EAAe,mBAAmB,QAAA,EAAS;AAAA,EAC3C,WAAA,EAAa,mBAAmB,QAAA,EAAS;AAAA,EACzC,SAAA,EAAW;AACb,CAAC;AAQM,IAAM,2BAAA,GAA8B,sBAAsB,MAAA,CAAO;AAAA,EACtE,UAAA,EAAYA,EAAE,MAAA,EAAO;AAAA,EACrB,YAAA,EAAcA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAClC,cAAA,EAAgBA,EAAE,MAAA,CAAOA,CAAAA,CAAE,QAAO,EAAGA,CAAAA,CAAE,SAAS;AAClD,CAAC;AAGM,IAAM,yBAAA,GAA4BA,EAAE,MAAA,CAAO;AAAA,EAChD,EAAA,EAAI;AACN,CAAC","file":"webhooks.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Webhook endpoints and deliveries.\n *\n * Endpoint = the URL the merchant registered.\n * Event = the thing that happened.\n * Delivery = one attempt to POST a specific event to a specific endpoint.\n */\n\nimport { z } from 'zod'\nimport { httpsUrlSchema, idSchema, isoTimestampSchema, modeSchema } from './common.js'\n\n// ---------- Event name ----------\n\n/**\n * Every webhook event name in the system. Listed inline so Zod can\n * produce a concrete string union.\n */\nexport const webhookEventNameSchema = z.enum([\n 'payment.created',\n 'payment.completed',\n 'payment.failed',\n 'subscription.created',\n 'subscription.charged',\n 'subscription.charge_failed',\n 'subscription.recovery_attempt',\n 'subscription.recovery_outcome',\n 'subscription.cancelled',\n 'subscription.lapsed',\n 'refund.created',\n 'refund.completed',\n 'refund.failed',\n 'invoice.created',\n 'invoice.paid',\n 'invoice.overdue',\n 'agent.action_executed',\n 'agent.job_proposed',\n 'agent.job_completed',\n 'agent.job_disputed',\n 'compliance.wallet_flagged',\n 'compliance.wallet_blocked',\n])\nexport type WebhookEventName = z.infer<typeof webhookEventNameSchema>\n\n// ---------- Endpoints ----------\n\nexport const webhookEndpointStatusSchema = z.enum(['active', 'disabled'])\nexport type WebhookEndpointStatus = z.infer<typeof webhookEndpointStatusSchema>\n\nexport const webhookEndpointSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n mode: modeSchema,\n url: httpsUrlSchema,\n description: z.string().max(200).nullable(),\n events: z.array(webhookEventNameSchema).nonempty(),\n status: webhookEndpointStatusSchema,\n signingSecretPrefix: z.string().min(4).max(12),\n lastDeliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type WebhookEndpoint = z.infer<typeof webhookEndpointSchema>\n\nexport const createWebhookEndpointInputSchema = z.object({\n url: httpsUrlSchema,\n events: z.array(webhookEventNameSchema).nonempty(),\n description: z.string().max(200).optional(),\n mode: modeSchema,\n})\nexport type CreateWebhookEndpointInput = z.infer<typeof createWebhookEndpointInputSchema>\n\nexport const createWebhookEndpointOutputSchema = z.object({\n endpoint: webhookEndpointSchema,\n /** Full signing secret. Shown exactly once. */\n signingSecret: z.string(),\n})\nexport type CreateWebhookEndpointOutput = z.infer<typeof createWebhookEndpointOutputSchema>\n\n// ---------- Deliveries ----------\n\nexport const webhookDeliveryStatusSchema = z.enum([\n 'pending',\n 'delivered',\n 'retrying',\n 'permanently_failed',\n])\nexport type WebhookDeliveryStatus = z.infer<typeof webhookDeliveryStatusSchema>\n\nexport const webhookDeliverySchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n endpointId: idSchema,\n eventId: idSchema,\n eventName: webhookEventNameSchema,\n status: webhookDeliveryStatusSchema,\n attempt: z.number().int().min(1).max(6),\n responseCode: z.number().int().min(100).max(599).nullable(),\n responseMs: z.number().int().min(0).nullable(),\n lastError: z.string().max(1000).nullable(),\n nextAttemptAt: isoTimestampSchema.nullable(),\n deliveredAt: isoTimestampSchema.nullable(),\n createdAt: isoTimestampSchema,\n})\nexport type WebhookDelivery = z.infer<typeof webhookDeliverySchema>\n\n/**\n * Detail projection returned by GET /v1/webhook-deliveries/:id.\n * Carries the payload envelope, response body, and the deliveryId\n * header the receiver saw. Kept separate so list responses stay slim.\n */\nexport const webhookDeliveryDetailSchema = webhookDeliverySchema.extend({\n deliveryId: z.string(),\n responseBody: z.string().nullable(),\n requestPayload: z.record(z.string(), z.unknown()),\n})\nexport type WebhookDeliveryDetail = z.infer<typeof webhookDeliveryDetailSchema>\n\nexport const replayDeliveryInputSchema = z.object({\n id: idSchema,\n})\nexport type ReplayDeliveryInput = z.infer<typeof replayDeliveryInputSchema>\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strimz/shared-types",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Zod schemas and inferred TypeScript types for every Strimz platform entity, API input, and webhook event.",
5
5
  "license": "MIT",
6
6
  "author": "Strimz <hello@strimz.finance>",
@@ -113,7 +113,7 @@
113
113
  ],
114
114
  "dependencies": {
115
115
  "zod": "^3.24.1",
116
- "@strimz/shared-config": "0.1.0"
116
+ "@strimz/shared-config": "0.1.1"
117
117
  },
118
118
  "devDependencies": {
119
119
  "eslint": "^9.18.0",
package/src/agents.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * AI AutoPay Agent — identity, configuration, activity log, and ERC-8183 jobs.
2
+ * AI AutoPay Agent. Identity, configuration, activity log, and ERC-8183 jobs.
3
3
  */
4
4
 
5
5
  import { z } from 'zod'