@strimz/shared-types 0.1.1 → 0.3.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 (65) hide show
  1. package/dist/api-keys.cjs +6 -1
  2. package/dist/api-keys.cjs.map +1 -1
  3. package/dist/api-keys.d.cts +12 -12
  4. package/dist/api-keys.d.ts +12 -12
  5. package/dist/api-keys.js +6 -1
  6. package/dist/api-keys.js.map +1 -1
  7. package/dist/events.cjs +25 -3
  8. package/dist/events.cjs.map +1 -1
  9. package/dist/events.d.cts +12 -12
  10. package/dist/events.d.ts +12 -12
  11. package/dist/events.js +25 -3
  12. package/dist/events.js.map +1 -1
  13. package/dist/index.cjs +186 -4
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +296 -11
  16. package/dist/index.d.ts +296 -11
  17. package/dist/index.js +164 -5
  18. package/dist/index.js.map +1 -1
  19. package/dist/merchants.cjs +59 -1
  20. package/dist/merchants.cjs.map +1 -1
  21. package/dist/merchants.d.cts +171 -1
  22. package/dist/merchants.d.ts +171 -1
  23. package/dist/merchants.js +55 -2
  24. package/dist/merchants.js.map +1 -1
  25. package/dist/payment-sessions.cjs +6 -2
  26. package/dist/payment-sessions.cjs.map +1 -1
  27. package/dist/payment-sessions.d.cts +19 -3
  28. package/dist/payment-sessions.d.ts +19 -3
  29. package/dist/payment-sessions.js +6 -3
  30. package/dist/payment-sessions.js.map +1 -1
  31. package/dist/refunds.cjs +12 -0
  32. package/dist/refunds.cjs.map +1 -1
  33. package/dist/refunds.d.cts +134 -1
  34. package/dist/refunds.d.ts +134 -1
  35. package/dist/refunds.js +11 -1
  36. package/dist/refunds.js.map +1 -1
  37. package/dist/storefronts.cjs +18 -0
  38. package/dist/storefronts.cjs.map +1 -1
  39. package/dist/storefronts.d.cts +37 -1
  40. package/dist/storefronts.d.ts +37 -1
  41. package/dist/storefronts.js +17 -1
  42. package/dist/storefronts.js.map +1 -1
  43. package/dist/subscriptions.cjs +5 -0
  44. package/dist/subscriptions.cjs.map +1 -1
  45. package/dist/subscriptions.d.cts +13 -1
  46. package/dist/subscriptions.d.ts +13 -1
  47. package/dist/subscriptions.js +5 -1
  48. package/dist/subscriptions.js.map +1 -1
  49. package/dist/webhooks.cjs +6 -0
  50. package/dist/webhooks.cjs.map +1 -1
  51. package/dist/webhooks.d.cts +60 -1
  52. package/dist/webhooks.d.ts +60 -1
  53. package/dist/webhooks.js +6 -1
  54. package/dist/webhooks.js.map +1 -1
  55. package/package.json +1 -1
  56. package/src/api-keys.ts +5 -0
  57. package/src/contact.ts +26 -0
  58. package/src/index.ts +2 -0
  59. package/src/merchants.ts +84 -0
  60. package/src/notifications.ts +88 -0
  61. package/src/payment-sessions.ts +24 -2
  62. package/src/refunds.ts +19 -0
  63. package/src/storefronts.ts +24 -0
  64. package/src/subscriptions.ts +7 -0
  65. package/src/webhooks.ts +12 -0
package/dist/refunds.d.ts CHANGED
@@ -87,5 +87,138 @@ declare const submitRefundSignatureInputSchema: z.ZodObject<{
87
87
  refundTxHash: string;
88
88
  }>;
89
89
  type SubmitRefundSignatureInput = z.infer<typeof submitRefundSignatureInputSchema>;
90
+ /**
91
+ * Response envelope for `POST /v1/refunds`. The API returns the newly
92
+ * created refund plus the concrete ERC-20 transfer the merchant now
93
+ * has to sign from their payout wallet.
94
+ */
95
+ declare const refundSigningInstructionsSchema: z.ZodObject<{
96
+ token: z.ZodEffects<z.ZodString, string, string>;
97
+ to: z.ZodEffects<z.ZodString, string, string>;
98
+ amount: z.ZodEffects<z.ZodString, string, string>;
99
+ note: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ amount: string;
102
+ note: string;
103
+ token: string;
104
+ to: string;
105
+ }, {
106
+ amount: string;
107
+ note: string;
108
+ token: string;
109
+ to: string;
110
+ }>;
111
+ type RefundSigningInstructions = z.infer<typeof refundSigningInstructionsSchema>;
112
+ declare const refundCreateOutputSchema: z.ZodObject<{
113
+ refund: z.ZodObject<{
114
+ id: z.ZodString;
115
+ merchantId: z.ZodString;
116
+ transactionId: z.ZodString;
117
+ amount: z.ZodEffects<z.ZodString, string, string>;
118
+ currency: z.ZodEnum<["USDC", "EURC"]>;
119
+ reason: z.ZodEnum<["customer_request", "product_issue", "duplicate_charge", "fraudulent", "other"]>;
120
+ note: z.ZodNullable<z.ZodString>;
121
+ status: z.ZodEnum<["pending", "awaiting_signature", "submitted", "completed", "failed", "cancelled"]>;
122
+ payerAddress: z.ZodEffects<z.ZodString, string, string>;
123
+ refundTxHash: z.ZodNullable<z.ZodString>;
124
+ failureReason: z.ZodNullable<z.ZodString>;
125
+ initiatedBy: z.ZodString;
126
+ createdAt: z.ZodString;
127
+ completedAt: z.ZodNullable<z.ZodString>;
128
+ }, "strip", z.ZodTypeAny, {
129
+ status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
130
+ id: string;
131
+ merchantId: string;
132
+ createdAt: string;
133
+ amount: string;
134
+ currency: "USDC" | "EURC";
135
+ payerAddress: string;
136
+ reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
137
+ failureReason: string | null;
138
+ transactionId: string;
139
+ note: string | null;
140
+ refundTxHash: string | null;
141
+ initiatedBy: string;
142
+ completedAt: string | null;
143
+ }, {
144
+ status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
145
+ id: string;
146
+ merchantId: string;
147
+ createdAt: string;
148
+ amount: string;
149
+ currency: "USDC" | "EURC";
150
+ payerAddress: string;
151
+ reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
152
+ failureReason: string | null;
153
+ transactionId: string;
154
+ note: string | null;
155
+ refundTxHash: string | null;
156
+ initiatedBy: string;
157
+ completedAt: string | null;
158
+ }>;
159
+ signingInstructions: z.ZodObject<{
160
+ token: z.ZodEffects<z.ZodString, string, string>;
161
+ to: z.ZodEffects<z.ZodString, string, string>;
162
+ amount: z.ZodEffects<z.ZodString, string, string>;
163
+ note: z.ZodString;
164
+ }, "strip", z.ZodTypeAny, {
165
+ amount: string;
166
+ note: string;
167
+ token: string;
168
+ to: string;
169
+ }, {
170
+ amount: string;
171
+ note: string;
172
+ token: string;
173
+ to: string;
174
+ }>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ refund: {
177
+ status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
178
+ id: string;
179
+ merchantId: string;
180
+ createdAt: string;
181
+ amount: string;
182
+ currency: "USDC" | "EURC";
183
+ payerAddress: string;
184
+ reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
185
+ failureReason: string | null;
186
+ transactionId: string;
187
+ note: string | null;
188
+ refundTxHash: string | null;
189
+ initiatedBy: string;
190
+ completedAt: string | null;
191
+ };
192
+ signingInstructions: {
193
+ amount: string;
194
+ note: string;
195
+ token: string;
196
+ to: string;
197
+ };
198
+ }, {
199
+ refund: {
200
+ status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
201
+ id: string;
202
+ merchantId: string;
203
+ createdAt: string;
204
+ amount: string;
205
+ currency: "USDC" | "EURC";
206
+ payerAddress: string;
207
+ reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
208
+ failureReason: string | null;
209
+ transactionId: string;
210
+ note: string | null;
211
+ refundTxHash: string | null;
212
+ initiatedBy: string;
213
+ completedAt: string | null;
214
+ };
215
+ signingInstructions: {
216
+ amount: string;
217
+ note: string;
218
+ token: string;
219
+ to: string;
220
+ };
221
+ }>;
222
+ type RefundCreateOutput = z.infer<typeof refundCreateOutputSchema>;
90
223
 
91
- export { type CreateRefundInput, type Refund, type RefundReason, type RefundStatus, type SubmitRefundSignatureInput, createRefundInputSchema, refundReasonSchema, refundSchema, refundStatusSchema, submitRefundSignatureInputSchema };
224
+ export { type CreateRefundInput, type Refund, type RefundCreateOutput, type RefundReason, type RefundSigningInstructions, type RefundStatus, type SubmitRefundSignatureInput, createRefundInputSchema, refundCreateOutputSchema, refundReasonSchema, refundSchema, refundSigningInstructionsSchema, refundStatusSchema, submitRefundSignatureInputSchema };
package/dist/refunds.js CHANGED
@@ -69,7 +69,17 @@ var submitRefundSignatureInputSchema = z.object({
69
69
  id: idSchema,
70
70
  refundTxHash: evmTxHashSchema
71
71
  });
72
+ var refundSigningInstructionsSchema = z.object({
73
+ token: evmAddressSchema,
74
+ to: evmAddressSchema,
75
+ amount: tokenAmountSchema,
76
+ note: z.string()
77
+ });
78
+ var refundCreateOutputSchema = z.object({
79
+ refund: refundSchema,
80
+ signingInstructions: refundSigningInstructionsSchema
81
+ });
72
82
 
73
- export { createRefundInputSchema, refundReasonSchema, refundSchema, refundStatusSchema, submitRefundSignatureInputSchema };
83
+ export { createRefundInputSchema, refundCreateOutputSchema, refundReasonSchema, refundSchema, refundSigningInstructionsSchema, refundStatusSchema, submitRefundSignatureInputSchema };
74
84
  //# sourceMappingURL=refunds.js.map
75
85
  //# sourceMappingURL=refunds.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/refunds.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,C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AAeA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA,EAAS;AAAA,EAC5C,WAAA,EAAa,QAAA;AAAA,EACb,SAAA,EAAW,kBAAA;AAAA,EACX,WAAA,EAAa,mBAAmB,QAAA;AAClC,CAAC;AAGM,IAAM,uBAAA,GAA0BA,EAAE,MAAA,CAAO;AAAA,EAC9C,aAAA,EAAe,QAAA;AAAA,EACf,MAAA,EAAQ,iBAAA;AAAA,EACR,MAAA,EAAQ,kBAAA;AAAA,EACR,MAAMA,CAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA;AAC5B,CAAC;AAGM,IAAM,gCAAA,GAAmCA,EAAE,MAAA,CAAO;AAAA,EACvD,EAAA,EAAI,QAAA;AAAA,EACJ,YAAA,EAAc;AAChB,CAAC","file":"refunds.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 * Refund. A merchant-initiated return of funds to a payer.\n *\n * Refunds are executed off-chain (from the merchant's wallet to the payer's\n * wallet). Strimz records the intent, validates constraints, and reconciles\n * via the merchant-signed on-chain transfer.\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 refundReasonSchema = z.enum([\n 'customer_request',\n 'product_issue',\n 'duplicate_charge',\n 'fraudulent',\n 'other',\n])\nexport type RefundReason = z.infer<typeof refundReasonSchema>\n\nexport const refundStatusSchema = z.enum([\n 'pending',\n 'awaiting_signature',\n 'submitted',\n 'completed',\n 'failed',\n 'cancelled',\n])\nexport type RefundStatus = z.infer<typeof refundStatusSchema>\n\nexport const refundSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n transactionId: idSchema,\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n reason: refundReasonSchema,\n note: z.string().max(500).nullable(),\n status: refundStatusSchema,\n payerAddress: evmAddressSchema,\n refundTxHash: evmTxHashSchema.nullable(),\n failureReason: z.string().max(500).nullable(),\n initiatedBy: idSchema,\n createdAt: isoTimestampSchema,\n completedAt: isoTimestampSchema.nullable(),\n})\nexport type Refund = z.infer<typeof refundSchema>\n\nexport const createRefundInputSchema = z.object({\n transactionId: idSchema,\n amount: tokenAmountSchema,\n reason: refundReasonSchema,\n note: z.string().max(500).optional(),\n})\nexport type CreateRefundInput = z.infer<typeof createRefundInputSchema>\n\nexport const submitRefundSignatureInputSchema = z.object({\n id: idSchema,\n refundTxHash: evmTxHashSchema,\n})\nexport type SubmitRefundSignatureInput = z.infer<typeof submitRefundSignatureInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/refunds.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,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CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA;AAC5B,CAAC;AAGM,IAAM,gCAAA,GAAmCA,EAAE,MAAA,CAAO;AAAA,EACvD,EAAA,EAAI,QAAA;AAAA,EACJ,YAAA,EAAc;AAChB,CAAC;AAQM,IAAM,+BAAA,GAAkCA,EAAE,MAAA,CAAO;AAAA,EACtD,KAAA,EAAO,gBAAA;AAAA,EACP,EAAA,EAAI,gBAAA;AAAA,EACJ,MAAA,EAAQ,iBAAA;AAAA,EACR,IAAA,EAAMA,EAAE,MAAA;AACV,CAAC;AAGM,IAAM,wBAAA,GAA2BA,EAAE,MAAA,CAAO;AAAA,EAC/C,MAAA,EAAQ,YAAA;AAAA,EACR,mBAAA,EAAqB;AACvB,CAAC","file":"refunds.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 * Refund. A merchant-initiated return of funds to a payer.\n *\n * Refunds are executed off-chain (from the merchant's wallet to the payer's\n * wallet). Strimz records the intent, validates constraints, and reconciles\n * via the merchant-signed on-chain transfer.\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 refundReasonSchema = z.enum([\n 'customer_request',\n 'product_issue',\n 'duplicate_charge',\n 'fraudulent',\n 'other',\n])\nexport type RefundReason = z.infer<typeof refundReasonSchema>\n\nexport const refundStatusSchema = z.enum([\n 'pending',\n 'awaiting_signature',\n 'submitted',\n 'completed',\n 'failed',\n 'cancelled',\n])\nexport type RefundStatus = z.infer<typeof refundStatusSchema>\n\nexport const refundSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n transactionId: idSchema,\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n reason: refundReasonSchema,\n note: z.string().max(500).nullable(),\n status: refundStatusSchema,\n payerAddress: evmAddressSchema,\n refundTxHash: evmTxHashSchema.nullable(),\n failureReason: z.string().max(500).nullable(),\n initiatedBy: idSchema,\n createdAt: isoTimestampSchema,\n completedAt: isoTimestampSchema.nullable(),\n})\nexport type Refund = z.infer<typeof refundSchema>\n\nexport const createRefundInputSchema = z.object({\n transactionId: idSchema,\n amount: tokenAmountSchema,\n reason: refundReasonSchema,\n note: z.string().max(500).optional(),\n})\nexport type CreateRefundInput = z.infer<typeof createRefundInputSchema>\n\nexport const submitRefundSignatureInputSchema = z.object({\n id: idSchema,\n refundTxHash: evmTxHashSchema,\n})\nexport type SubmitRefundSignatureInput = z.infer<typeof submitRefundSignatureInputSchema>\n\n/**\n * Response envelope for `POST /v1/refunds`. The API returns the newly\n * created refund plus the concrete ERC-20 transfer the merchant now\n * has to sign from their payout wallet.\n */\nexport const refundSigningInstructionsSchema = z.object({\n token: evmAddressSchema,\n to: evmAddressSchema,\n amount: tokenAmountSchema,\n note: z.string(),\n})\nexport type RefundSigningInstructions = z.infer<typeof refundSigningInstructionsSchema>\n\nexport const refundCreateOutputSchema = z.object({\n refund: refundSchema,\n signingInstructions: refundSigningInstructionsSchema,\n})\nexport type RefundCreateOutput = z.infer<typeof refundCreateOutputSchema>\n"]}
@@ -109,6 +109,10 @@ zod.z.object({
109
109
  createdAt: isoTimestampSchema,
110
110
  updatedAt: isoTimestampSchema
111
111
  });
112
+ zod.z.object({
113
+ active: zod.z.boolean(),
114
+ subscriptionId: idSchema.nullable()
115
+ });
112
116
  zod.z.object({
113
117
  planId: idSchema,
114
118
  customer: zod.z.object({
@@ -212,9 +216,23 @@ var createStorefrontProductInputSchema = storefrontProductSchema.omit({
212
216
  }).extend({
213
217
  imageUrl: httpsUrlSchema.optional()
214
218
  });
219
+ var storefrontCheckoutInputSchema = zod.z.object({
220
+ customerEmail: zod.z.string().email().optional(),
221
+ returnPath: zod.z.string().max(200).optional()
222
+ });
223
+ var storefrontCheckoutResponseSchema = zod.z.object({
224
+ /** Fully-qualified checkout URL — payer redirects here to sign. */
225
+ checkoutUrl: zod.z.string().url(),
226
+ /** Payment-session id (one-time) or plan id (subscription). */
227
+ ref: idSchema,
228
+ /** Which downstream checkout the URL points at. */
229
+ kind: zod.z.enum(["payment_session", "subscription_plan"])
230
+ });
215
231
 
216
232
  exports.createStorefrontInputSchema = createStorefrontInputSchema;
217
233
  exports.createStorefrontProductInputSchema = createStorefrontProductInputSchema;
234
+ exports.storefrontCheckoutInputSchema = storefrontCheckoutInputSchema;
235
+ exports.storefrontCheckoutResponseSchema = storefrontCheckoutResponseSchema;
218
236
  exports.storefrontProductSchema = storefrontProductSchema;
219
237
  exports.storefrontProductTypeSchema = storefrontProductTypeSchema;
220
238
  exports.storefrontSchema = storefrontSchema;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/subscriptions.ts","../src/storefronts.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;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;AAOjC,IAAM,iBAAA,GAAoBA,KAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,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X,SAAA,EAAW;AACb,CAAC,EACA,MAAA,CAAO;AAAA,EACN,QAAA,EAAU,eAAe,QAAA;AAC3B,CAAC","file":"storefronts.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 * 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","/**\n * Storefronts. Hosted product catalog with checkout baked in.\n */\n\nimport { z } from 'zod'\nimport {\n httpsUrlSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\nimport { subscriptionIntervalSchema } from './subscriptions.js'\n\nexport const storefrontStatusSchema = z.enum(['draft', 'published', 'archived'])\nexport type StorefrontStatus = z.infer<typeof storefrontStatusSchema>\n\nexport const storefrontSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n slug: z\n .string()\n .min(3)\n .max(40)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'slug must be lowercase alphanumeric with hyphens'),\n name: z.string().min(2).max(120),\n description: z.string().max(2000).nullable(),\n logoUrl: httpsUrlSchema.nullable(),\n coverImageUrl: httpsUrlSchema.nullable(),\n accentColor: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .nullable(),\n socialLinks: z.array(httpsUrlSchema).max(10).default([]),\n status: storefrontStatusSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type Storefront = z.infer<typeof storefrontSchema>\n\nexport const createStorefrontInputSchema = storefrontSchema.pick({\n slug: true,\n name: true,\n description: true,\n logoUrl: true,\n coverImageUrl: true,\n accentColor: true,\n socialLinks: true,\n})\nexport type CreateStorefrontInput = z.infer<typeof createStorefrontInputSchema>\n\n// ---------- Products ----------\n\nexport const storefrontProductTypeSchema = z.enum(['one_time', 'subscription'])\nexport type StorefrontProductType = z.infer<typeof storefrontProductTypeSchema>\n\nexport const storefrontProductSchema = z.object({\n id: idSchema,\n storefrontId: idSchema,\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n imageUrl: httpsUrlSchema.nullable(),\n price: tokenAmountSchema,\n currency: paymentCurrencySchema,\n type: storefrontProductTypeSchema,\n interval: subscriptionIntervalSchema.nullable(),\n intervalCount: z.number().int().min(1).max(365).nullable(),\n /** null = unlimited stock. */\n stock: z.number().int().min(0).nullable(),\n planId: idSchema.nullable(),\n isActive: z.boolean(),\n sortOrder: z.number().int().nonnegative().default(0),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type StorefrontProduct = z.infer<typeof storefrontProductSchema>\n\nexport const createStorefrontProductInputSchema = storefrontProductSchema\n .omit({\n id: true,\n storefrontId: true,\n planId: true,\n createdAt: true,\n updatedAt: true,\n })\n .extend({\n imageUrl: httpsUrlSchema.optional(),\n })\nexport type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>\n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pD,eAAeA,KAAAA,CAAE,MAAA,EAAO,CAAE,KAAA,GAAQ,QAAA,EAAS;AAAA,EAC3C,YAAYA,KAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA;AAClC,CAAC;AAIM,IAAM,gCAAA,GAAmCA,MAAE,MAAA,CAAO;AAAA;AAAA,EAEvD,WAAA,EAAaA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI;AAAA;AAAA,EAE5B,GAAA,EAAK,QAAA;AAAA;AAAA,EAEL,MAAMA,KAAAA,CAAE,IAAA,CAAK,CAAC,iBAAA,EAAmB,mBAAmB,CAAC;AACvD,CAAC","file":"storefronts.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 * 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\n/** Whether a wallet already subscribes to a given plan, and which one. */\nexport const subscriptionStatusResultSchema = z.object({\n active: z.boolean(),\n subscriptionId: idSchema.nullable(),\n})\nexport type SubscriptionStatusResult = z.infer<typeof subscriptionStatusResultSchema>\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","/**\n * Storefronts. Hosted product catalog with checkout baked in.\n */\n\nimport { z } from 'zod'\nimport {\n httpsUrlSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\nimport { subscriptionIntervalSchema } from './subscriptions.js'\n\nexport const storefrontStatusSchema = z.enum(['draft', 'published', 'archived'])\nexport type StorefrontStatus = z.infer<typeof storefrontStatusSchema>\n\nexport const storefrontSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n slug: z\n .string()\n .min(3)\n .max(40)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'slug must be lowercase alphanumeric with hyphens'),\n name: z.string().min(2).max(120),\n description: z.string().max(2000).nullable(),\n logoUrl: httpsUrlSchema.nullable(),\n coverImageUrl: httpsUrlSchema.nullable(),\n accentColor: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .nullable(),\n socialLinks: z.array(httpsUrlSchema).max(10).default([]),\n status: storefrontStatusSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type Storefront = z.infer<typeof storefrontSchema>\n\nexport const createStorefrontInputSchema = storefrontSchema.pick({\n slug: true,\n name: true,\n description: true,\n logoUrl: true,\n coverImageUrl: true,\n accentColor: true,\n socialLinks: true,\n})\nexport type CreateStorefrontInput = z.infer<typeof createStorefrontInputSchema>\n\n// ---------- Products ----------\n\nexport const storefrontProductTypeSchema = z.enum(['one_time', 'subscription'])\nexport type StorefrontProductType = z.infer<typeof storefrontProductTypeSchema>\n\nexport const storefrontProductSchema = z.object({\n id: idSchema,\n storefrontId: idSchema,\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n imageUrl: httpsUrlSchema.nullable(),\n price: tokenAmountSchema,\n currency: paymentCurrencySchema,\n type: storefrontProductTypeSchema,\n interval: subscriptionIntervalSchema.nullable(),\n intervalCount: z.number().int().min(1).max(365).nullable(),\n /** null = unlimited stock. */\n stock: z.number().int().min(0).nullable(),\n planId: idSchema.nullable(),\n isActive: z.boolean(),\n sortOrder: z.number().int().nonnegative().default(0),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type StorefrontProduct = z.infer<typeof storefrontProductSchema>\n\nexport const createStorefrontProductInputSchema = storefrontProductSchema\n .omit({\n id: true,\n storefrontId: true,\n planId: true,\n createdAt: true,\n updatedAt: true,\n })\n .extend({\n imageUrl: httpsUrlSchema.optional(),\n })\nexport type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>\n\n/**\n * Payload for the public `/store/:slug/products/:id/checkout` endpoint.\n * Optional customer email flows through into the payment session so\n * the receipt lands in the buyer's inbox after the tx confirms.\n * `returnPath` is used to synthesise the success + cancel URLs when\n * the merchant hasn't wired their own.\n */\nexport const storefrontCheckoutInputSchema = z.object({\n customerEmail: z.string().email().optional(),\n returnPath: z.string().max(200).optional(),\n})\nexport type StorefrontCheckoutInput = z.infer<typeof storefrontCheckoutInputSchema>\n\n/** Response shape from the public product-checkout endpoint. */\nexport const storefrontCheckoutResponseSchema = z.object({\n /** Fully-qualified checkout URL — payer redirects here to sign. */\n checkoutUrl: z.string().url(),\n /** Payment-session id (one-time) or plan id (subscription). */\n ref: idSchema,\n /** Which downstream checkout the URL points at. */\n kind: z.enum(['payment_session', 'subscription_plan']),\n})\nexport type StorefrontCheckoutResponse = z.infer<typeof storefrontCheckoutResponseSchema>\n"]}
@@ -173,5 +173,41 @@ declare const createStorefrontProductInputSchema: z.ZodObject<{
173
173
  sortOrder?: number | undefined;
174
174
  }>;
175
175
  type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>;
176
+ /**
177
+ * Payload for the public `/store/:slug/products/:id/checkout` endpoint.
178
+ * Optional customer email flows through into the payment session so
179
+ * the receipt lands in the buyer's inbox after the tx confirms.
180
+ * `returnPath` is used to synthesise the success + cancel URLs when
181
+ * the merchant hasn't wired their own.
182
+ */
183
+ declare const storefrontCheckoutInputSchema: z.ZodObject<{
184
+ customerEmail: z.ZodOptional<z.ZodString>;
185
+ returnPath: z.ZodOptional<z.ZodString>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ customerEmail?: string | undefined;
188
+ returnPath?: string | undefined;
189
+ }, {
190
+ customerEmail?: string | undefined;
191
+ returnPath?: string | undefined;
192
+ }>;
193
+ type StorefrontCheckoutInput = z.infer<typeof storefrontCheckoutInputSchema>;
194
+ /** Response shape from the public product-checkout endpoint. */
195
+ declare const storefrontCheckoutResponseSchema: z.ZodObject<{
196
+ /** Fully-qualified checkout URL — payer redirects here to sign. */
197
+ checkoutUrl: z.ZodString;
198
+ /** Payment-session id (one-time) or plan id (subscription). */
199
+ ref: z.ZodString;
200
+ /** Which downstream checkout the URL points at. */
201
+ kind: z.ZodEnum<["payment_session", "subscription_plan"]>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ kind: "payment_session" | "subscription_plan";
204
+ checkoutUrl: string;
205
+ ref: string;
206
+ }, {
207
+ kind: "payment_session" | "subscription_plan";
208
+ checkoutUrl: string;
209
+ ref: string;
210
+ }>;
211
+ type StorefrontCheckoutResponse = z.infer<typeof storefrontCheckoutResponseSchema>;
176
212
 
177
- export { type CreateStorefrontInput, type CreateStorefrontProductInput, type Storefront, type StorefrontProduct, type StorefrontProductType, type StorefrontStatus, createStorefrontInputSchema, createStorefrontProductInputSchema, storefrontProductSchema, storefrontProductTypeSchema, storefrontSchema, storefrontStatusSchema };
213
+ export { type CreateStorefrontInput, type CreateStorefrontProductInput, type Storefront, type StorefrontCheckoutInput, type StorefrontCheckoutResponse, type StorefrontProduct, type StorefrontProductType, type StorefrontStatus, createStorefrontInputSchema, createStorefrontProductInputSchema, storefrontCheckoutInputSchema, storefrontCheckoutResponseSchema, storefrontProductSchema, storefrontProductTypeSchema, storefrontSchema, storefrontStatusSchema };
@@ -173,5 +173,41 @@ declare const createStorefrontProductInputSchema: z.ZodObject<{
173
173
  sortOrder?: number | undefined;
174
174
  }>;
175
175
  type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>;
176
+ /**
177
+ * Payload for the public `/store/:slug/products/:id/checkout` endpoint.
178
+ * Optional customer email flows through into the payment session so
179
+ * the receipt lands in the buyer's inbox after the tx confirms.
180
+ * `returnPath` is used to synthesise the success + cancel URLs when
181
+ * the merchant hasn't wired their own.
182
+ */
183
+ declare const storefrontCheckoutInputSchema: z.ZodObject<{
184
+ customerEmail: z.ZodOptional<z.ZodString>;
185
+ returnPath: z.ZodOptional<z.ZodString>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ customerEmail?: string | undefined;
188
+ returnPath?: string | undefined;
189
+ }, {
190
+ customerEmail?: string | undefined;
191
+ returnPath?: string | undefined;
192
+ }>;
193
+ type StorefrontCheckoutInput = z.infer<typeof storefrontCheckoutInputSchema>;
194
+ /** Response shape from the public product-checkout endpoint. */
195
+ declare const storefrontCheckoutResponseSchema: z.ZodObject<{
196
+ /** Fully-qualified checkout URL — payer redirects here to sign. */
197
+ checkoutUrl: z.ZodString;
198
+ /** Payment-session id (one-time) or plan id (subscription). */
199
+ ref: z.ZodString;
200
+ /** Which downstream checkout the URL points at. */
201
+ kind: z.ZodEnum<["payment_session", "subscription_plan"]>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ kind: "payment_session" | "subscription_plan";
204
+ checkoutUrl: string;
205
+ ref: string;
206
+ }, {
207
+ kind: "payment_session" | "subscription_plan";
208
+ checkoutUrl: string;
209
+ ref: string;
210
+ }>;
211
+ type StorefrontCheckoutResponse = z.infer<typeof storefrontCheckoutResponseSchema>;
176
212
 
177
- export { type CreateStorefrontInput, type CreateStorefrontProductInput, type Storefront, type StorefrontProduct, type StorefrontProductType, type StorefrontStatus, createStorefrontInputSchema, createStorefrontProductInputSchema, storefrontProductSchema, storefrontProductTypeSchema, storefrontSchema, storefrontStatusSchema };
213
+ export { type CreateStorefrontInput, type CreateStorefrontProductInput, type Storefront, type StorefrontCheckoutInput, type StorefrontCheckoutResponse, type StorefrontProduct, type StorefrontProductType, type StorefrontStatus, createStorefrontInputSchema, createStorefrontProductInputSchema, storefrontCheckoutInputSchema, storefrontCheckoutResponseSchema, storefrontProductSchema, storefrontProductTypeSchema, storefrontSchema, storefrontStatusSchema };
@@ -107,6 +107,10 @@ z.object({
107
107
  createdAt: isoTimestampSchema,
108
108
  updatedAt: isoTimestampSchema
109
109
  });
110
+ z.object({
111
+ active: z.boolean(),
112
+ subscriptionId: idSchema.nullable()
113
+ });
110
114
  z.object({
111
115
  planId: idSchema,
112
116
  customer: z.object({
@@ -210,7 +214,19 @@ var createStorefrontProductInputSchema = storefrontProductSchema.omit({
210
214
  }).extend({
211
215
  imageUrl: httpsUrlSchema.optional()
212
216
  });
217
+ var storefrontCheckoutInputSchema = z.object({
218
+ customerEmail: z.string().email().optional(),
219
+ returnPath: z.string().max(200).optional()
220
+ });
221
+ var storefrontCheckoutResponseSchema = z.object({
222
+ /** Fully-qualified checkout URL — payer redirects here to sign. */
223
+ checkoutUrl: z.string().url(),
224
+ /** Payment-session id (one-time) or plan id (subscription). */
225
+ ref: idSchema,
226
+ /** Which downstream checkout the URL points at. */
227
+ kind: z.enum(["payment_session", "subscription_plan"])
228
+ });
213
229
 
214
- export { createStorefrontInputSchema, createStorefrontProductInputSchema, storefrontProductSchema, storefrontProductTypeSchema, storefrontSchema, storefrontStatusSchema };
230
+ export { createStorefrontInputSchema, createStorefrontProductInputSchema, storefrontCheckoutInputSchema, storefrontCheckoutResponseSchema, storefrontProductSchema, storefrontProductTypeSchema, storefrontSchema, storefrontStatusSchema };
215
231
  //# sourceMappingURL=storefronts.js.map
216
232
  //# sourceMappingURL=storefronts.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common.ts","../src/subscriptions.ts","../src/storefronts.ts"],"names":["z"],"mappings":";;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,QAAA,EAAU,eAAe,QAAA,EAAS;AAAA,EAClC,KAAA,EAAO,iBAAA;AAAA,EACP,QAAA,EAAU,qBAAA;AAAA,EACV,IAAA,EAAM,2BAAA;AAAA,EACN,QAAA,EAAU,2BAA2B,QAAA,EAAS;AAAA,EAC9C,aAAA,EAAeA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA;AAAA,EAEzD,KAAA,EAAOA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EACxC,MAAA,EAAQ,SAAS,QAAA,EAAS;AAAA,EAC1B,QAAA,EAAUA,EAAE,OAAA,EAAQ;AAAA,EACpB,SAAA,EAAWA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,WAAA,EAAY,CAAE,OAAA,CAAQ,CAAC,CAAA;AAAA,EACnD,SAAA,EAAW,kBAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAC;AAGM,IAAM,kCAAA,GAAqC,wBAC/C,IAAA,CAAK;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,YAAA,EAAc,IAAA;AAAA,EACd,MAAA,EAAQ,IAAA;AAAA,EACR,SAAA,EAAW,IAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAC,EACA,MAAA,CAAO;AAAA,EACN,QAAA,EAAU,eAAe,QAAA;AAC3B,CAAC","file":"storefronts.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","/**\n * Storefronts. Hosted product catalog with checkout baked in.\n */\n\nimport { z } from 'zod'\nimport {\n httpsUrlSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\nimport { subscriptionIntervalSchema } from './subscriptions.js'\n\nexport const storefrontStatusSchema = z.enum(['draft', 'published', 'archived'])\nexport type StorefrontStatus = z.infer<typeof storefrontStatusSchema>\n\nexport const storefrontSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n slug: z\n .string()\n .min(3)\n .max(40)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'slug must be lowercase alphanumeric with hyphens'),\n name: z.string().min(2).max(120),\n description: z.string().max(2000).nullable(),\n logoUrl: httpsUrlSchema.nullable(),\n coverImageUrl: httpsUrlSchema.nullable(),\n accentColor: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .nullable(),\n socialLinks: z.array(httpsUrlSchema).max(10).default([]),\n status: storefrontStatusSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type Storefront = z.infer<typeof storefrontSchema>\n\nexport const createStorefrontInputSchema = storefrontSchema.pick({\n slug: true,\n name: true,\n description: true,\n logoUrl: true,\n coverImageUrl: true,\n accentColor: true,\n socialLinks: true,\n})\nexport type CreateStorefrontInput = z.infer<typeof createStorefrontInputSchema>\n\n// ---------- Products ----------\n\nexport const storefrontProductTypeSchema = z.enum(['one_time', 'subscription'])\nexport type StorefrontProductType = z.infer<typeof storefrontProductTypeSchema>\n\nexport const storefrontProductSchema = z.object({\n id: idSchema,\n storefrontId: idSchema,\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n imageUrl: httpsUrlSchema.nullable(),\n price: tokenAmountSchema,\n currency: paymentCurrencySchema,\n type: storefrontProductTypeSchema,\n interval: subscriptionIntervalSchema.nullable(),\n intervalCount: z.number().int().min(1).max(365).nullable(),\n /** null = unlimited stock. */\n stock: z.number().int().min(0).nullable(),\n planId: idSchema.nullable(),\n isActive: z.boolean(),\n sortOrder: z.number().int().nonnegative().default(0),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type StorefrontProduct = z.infer<typeof storefrontProductSchema>\n\nexport const createStorefrontProductInputSchema = storefrontProductSchema\n .omit({\n id: true,\n storefrontId: true,\n planId: true,\n createdAt: true,\n updatedAt: true,\n })\n .extend({\n imageUrl: httpsUrlSchema.optional(),\n })\nexport type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>\n"]}
1
+ {"version":3,"sources":["../src/common.ts","../src/subscriptions.ts","../src/storefronts.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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AAC","file":"storefronts.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\n/** Whether a wallet already subscribes to a given plan, and which one. */\nexport const subscriptionStatusResultSchema = z.object({\n active: z.boolean(),\n subscriptionId: idSchema.nullable(),\n})\nexport type SubscriptionStatusResult = z.infer<typeof subscriptionStatusResultSchema>\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","/**\n * Storefronts. Hosted product catalog with checkout baked in.\n */\n\nimport { z } from 'zod'\nimport {\n httpsUrlSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\nimport { subscriptionIntervalSchema } from './subscriptions.js'\n\nexport const storefrontStatusSchema = z.enum(['draft', 'published', 'archived'])\nexport type StorefrontStatus = z.infer<typeof storefrontStatusSchema>\n\nexport const storefrontSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n slug: z\n .string()\n .min(3)\n .max(40)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'slug must be lowercase alphanumeric with hyphens'),\n name: z.string().min(2).max(120),\n description: z.string().max(2000).nullable(),\n logoUrl: httpsUrlSchema.nullable(),\n coverImageUrl: httpsUrlSchema.nullable(),\n accentColor: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .nullable(),\n socialLinks: z.array(httpsUrlSchema).max(10).default([]),\n status: storefrontStatusSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type Storefront = z.infer<typeof storefrontSchema>\n\nexport const createStorefrontInputSchema = storefrontSchema.pick({\n slug: true,\n name: true,\n description: true,\n logoUrl: true,\n coverImageUrl: true,\n accentColor: true,\n socialLinks: true,\n})\nexport type CreateStorefrontInput = z.infer<typeof createStorefrontInputSchema>\n\n// ---------- Products ----------\n\nexport const storefrontProductTypeSchema = z.enum(['one_time', 'subscription'])\nexport type StorefrontProductType = z.infer<typeof storefrontProductTypeSchema>\n\nexport const storefrontProductSchema = z.object({\n id: idSchema,\n storefrontId: idSchema,\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n imageUrl: httpsUrlSchema.nullable(),\n price: tokenAmountSchema,\n currency: paymentCurrencySchema,\n type: storefrontProductTypeSchema,\n interval: subscriptionIntervalSchema.nullable(),\n intervalCount: z.number().int().min(1).max(365).nullable(),\n /** null = unlimited stock. */\n stock: z.number().int().min(0).nullable(),\n planId: idSchema.nullable(),\n isActive: z.boolean(),\n sortOrder: z.number().int().nonnegative().default(0),\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type StorefrontProduct = z.infer<typeof storefrontProductSchema>\n\nexport const createStorefrontProductInputSchema = storefrontProductSchema\n .omit({\n id: true,\n storefrontId: true,\n planId: true,\n createdAt: true,\n updatedAt: true,\n })\n .extend({\n imageUrl: httpsUrlSchema.optional(),\n })\nexport type CreateStorefrontProductInput = z.infer<typeof createStorefrontProductInputSchema>\n\n/**\n * Payload for the public `/store/:slug/products/:id/checkout` endpoint.\n * Optional customer email flows through into the payment session so\n * the receipt lands in the buyer's inbox after the tx confirms.\n * `returnPath` is used to synthesise the success + cancel URLs when\n * the merchant hasn't wired their own.\n */\nexport const storefrontCheckoutInputSchema = z.object({\n customerEmail: z.string().email().optional(),\n returnPath: z.string().max(200).optional(),\n})\nexport type StorefrontCheckoutInput = z.infer<typeof storefrontCheckoutInputSchema>\n\n/** Response shape from the public product-checkout endpoint. */\nexport const storefrontCheckoutResponseSchema = z.object({\n /** Fully-qualified checkout URL — payer redirects here to sign. */\n checkoutUrl: z.string().url(),\n /** Payment-session id (one-time) or plan id (subscription). */\n ref: idSchema,\n /** Which downstream checkout the URL points at. */\n kind: z.enum(['payment_session', 'subscription_plan']),\n})\nexport type StorefrontCheckoutResponse = z.infer<typeof storefrontCheckoutResponseSchema>\n"]}
@@ -111,6 +111,10 @@ var subscriptionSchema = zod.z.object({
111
111
  createdAt: isoTimestampSchema,
112
112
  updatedAt: isoTimestampSchema
113
113
  });
114
+ var subscriptionStatusResultSchema = zod.z.object({
115
+ active: zod.z.boolean(),
116
+ subscriptionId: idSchema.nullable()
117
+ });
114
118
  var createSubscriptionInputSchema = zod.z.object({
115
119
  planId: idSchema,
116
120
  customer: zod.z.object({
@@ -170,6 +174,7 @@ exports.subscriptionIntervalSchema = subscriptionIntervalSchema;
170
174
  exports.subscriptionPlanSchema = subscriptionPlanSchema;
171
175
  exports.subscriptionPlanStatusSchema = subscriptionPlanStatusSchema;
172
176
  exports.subscriptionSchema = subscriptionSchema;
177
+ exports.subscriptionStatusResultSchema = subscriptionStatusResultSchema;
173
178
  exports.subscriptionStatusSchema = subscriptionStatusSchema;
174
179
  //# sourceMappingURL=subscriptions.cjs.map
175
180
  //# sourceMappingURL=subscriptions.cjs.map