@strimz/shared-types 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/agents.cjs +148 -0
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +317 -0
- package/dist/agents.d.ts +317 -0
- package/dist/agents.js +137 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.cjs +91 -0
- package/dist/api-keys.cjs.map +1 -0
- package/dist/api-keys.d.cts +155 -0
- package/dist/api-keys.d.ts +155 -0
- package/dist/api-keys.js +84 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/common.cjs +56 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +82 -0
- package/dist/common.d.ts +82 -0
- package/dist/common.js +37 -0
- package/dist/common.js.map +1 -0
- package/dist/compliance.cjs +61 -0
- package/dist/compliance.cjs.map +1 -0
- package/dist/compliance.d.cts +59 -0
- package/dist/compliance.d.ts +59 -0
- package/dist/compliance.js +56 -0
- package/dist/compliance.js.map +1 -0
- package/dist/customers.cjs +56 -0
- package/dist/customers.cjs.map +1 -0
- package/dist/customers.d.cts +64 -0
- package/dist/customers.d.ts +64 -0
- package/dist/customers.js +53 -0
- package/dist/customers.js.map +1 -0
- package/dist/events.cjs +675 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +7907 -0
- package/dist/events.d.ts +7907 -0
- package/dist/events.js +650 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +976 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.js +858 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.cjs +72 -0
- package/dist/invoices.cjs.map +1 -0
- package/dist/invoices.d.cts +159 -0
- package/dist/invoices.d.ts +159 -0
- package/dist/invoices.js +67 -0
- package/dist/invoices.js.map +1 -0
- package/dist/merchants.cjs +104 -0
- package/dist/merchants.cjs.map +1 -0
- package/dist/merchants.d.cts +259 -0
- package/dist/merchants.d.ts +259 -0
- package/dist/merchants.js +93 -0
- package/dist/merchants.js.map +1 -0
- package/dist/payment-sessions.cjs +125 -0
- package/dist/payment-sessions.cjs.map +1 -0
- package/dist/payment-sessions.d.cts +180 -0
- package/dist/payment-sessions.d.ts +180 -0
- package/dist/payment-sessions.js +120 -0
- package/dist/payment-sessions.js.map +1 -0
- package/dist/refunds.cjs +81 -0
- package/dist/refunds.cjs.map +1 -0
- package/dist/refunds.d.cts +91 -0
- package/dist/refunds.d.ts +91 -0
- package/dist/refunds.js +75 -0
- package/dist/refunds.js.map +1 -0
- package/dist/storefronts.cjs +223 -0
- package/dist/storefronts.cjs.map +1 -0
- package/dist/storefronts.d.cts +177 -0
- package/dist/storefronts.d.ts +177 -0
- package/dist/storefronts.js +216 -0
- package/dist/storefronts.js.map +1 -0
- package/dist/subscriptions.cjs +175 -0
- package/dist/subscriptions.cjs.map +1 -0
- package/dist/subscriptions.d.cts +290 -0
- package/dist/subscriptions.d.ts +290 -0
- package/dist/subscriptions.js +163 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/transactions.cjs +67 -0
- package/dist/transactions.cjs.map +1 -0
- package/dist/transactions.d.cts +78 -0
- package/dist/transactions.d.ts +78 -0
- package/dist/transactions.js +63 -0
- package/dist/transactions.js.map +1 -0
- package/dist/webhooks.cjs +116 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +201 -0
- package/dist/webhooks.d.ts +201 -0
- package/dist/webhooks.js +107 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +134 -0
- package/src/agents.ts +149 -0
- package/src/api-keys.ts +78 -0
- package/src/common.ts +113 -0
- package/src/compliance.ts +40 -0
- package/src/customers.ts +40 -0
- package/src/events.ts +176 -0
- package/src/index.ts +23 -0
- package/src/invoices.ts +53 -0
- package/src/merchants.ts +104 -0
- package/src/payment-sessions.ts +131 -0
- package/src/refunds.ts +68 -0
- package/src/storefronts.ts +89 -0
- package/src/subscriptions.ts +180 -0
- package/src/tokens.ts +60 -0
- package/src/transactions.ts +52 -0
- package/src/webhooks.ts +109 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/subscriptions.ts
|
|
6
|
+
var idSchema = zod.z.string().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/, "id must be URL-safe");
|
|
7
|
+
var evmAddressSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a 0x-prefixed 40-character hex EVM address").transform((v) => v.toLowerCase());
|
|
8
|
+
var evmTxHashSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/, "must be a 0x-prefixed 64-character hex EVM transaction hash");
|
|
9
|
+
zod.z.string().email().trim().toLowerCase().max(320);
|
|
10
|
+
zod.z.string().url().refine((v) => v.startsWith("https://"), {
|
|
11
|
+
message: "must be an https:// URL"
|
|
12
|
+
});
|
|
13
|
+
zod.z.string().url();
|
|
14
|
+
var tokenAmountSchema = zod.z.string().regex(/^[0-9]+$/, "must be a non-negative integer string (base-10)").refine((v) => BigInt(v) >= 0n, "must be >= 0");
|
|
15
|
+
zod.z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
16
|
+
var isoTimestampSchema = zod.z.string().datetime({ offset: true, message: "must be an ISO-8601 timestamp" });
|
|
17
|
+
zod.z.string().length(2).regex(/^[A-Z]{2}$/, "must be an ISO-3166 alpha-2 country code");
|
|
18
|
+
zod.z.object({
|
|
19
|
+
limit: zod.z.number().int().min(1).max(100).default(25),
|
|
20
|
+
cursor: zod.z.string().min(1).max(200).nullish()
|
|
21
|
+
});
|
|
22
|
+
var metadataSchema = zod.z.record(
|
|
23
|
+
zod.z.string().min(1).max(40),
|
|
24
|
+
zod.z.union([zod.z.string().max(500), zod.z.number(), zod.z.boolean(), zod.z.null()])
|
|
25
|
+
).refine((m) => Object.keys(m).length <= 50, "at most 50 metadata keys").default({});
|
|
26
|
+
zod.z.enum(["test", "live"]);
|
|
27
|
+
var paymentCurrencySchema = zod.z.enum(["USDC", "EURC"]);
|
|
28
|
+
zod.z.enum(["USDC", "EURC", "USYC"]);
|
|
29
|
+
zod.z.enum(["free", "growth", "business", "enterprise"]);
|
|
30
|
+
zod.z.enum(["testnet", "mainnet"]);
|
|
31
|
+
|
|
32
|
+
// src/subscriptions.ts
|
|
33
|
+
var subscriptionIntervalSchema = zod.z.enum([
|
|
34
|
+
"daily",
|
|
35
|
+
"weekly",
|
|
36
|
+
"monthly",
|
|
37
|
+
"quarterly",
|
|
38
|
+
"yearly"
|
|
39
|
+
]);
|
|
40
|
+
var subscriptionPlanStatusSchema = zod.z.enum(["active", "archived"]);
|
|
41
|
+
var subscriptionPlanSchema = zod.z.object({
|
|
42
|
+
id: idSchema,
|
|
43
|
+
merchantId: idSchema,
|
|
44
|
+
/**
|
|
45
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
46
|
+
* See `paymentSessionSchema.chainMerchantId`. Null when the merchant
|
|
47
|
+
* hasn't been registered on-chain yet — the hosted enrolment page
|
|
48
|
+
* refuses to take signatures in that state.
|
|
49
|
+
*/
|
|
50
|
+
chainMerchantId: zod.z.string().regex(/^[0-9]+$/u, "must be a non-negative decimal integer string").nullable(),
|
|
51
|
+
/**
|
|
52
|
+
* ERC-20 token contract address resolved from `currency` — the
|
|
53
|
+
* EIP-2612 `verifyingContract` the wallet signs over.
|
|
54
|
+
*/
|
|
55
|
+
tokenAddress: evmAddressSchema.nullable(),
|
|
56
|
+
/**
|
|
57
|
+
* Charge cadence in seconds, derived from `interval` + `intervalCount`
|
|
58
|
+
* so the meta-tx layer can pass a uint32 to StrimzSubscriptions
|
|
59
|
+
* without re-deriving the conversion on the client.
|
|
60
|
+
*/
|
|
61
|
+
intervalSeconds: zod.z.number().int().positive(),
|
|
62
|
+
name: zod.z.string().min(1).max(120),
|
|
63
|
+
description: zod.z.string().max(500).nullable(),
|
|
64
|
+
amount: tokenAmountSchema,
|
|
65
|
+
currency: paymentCurrencySchema,
|
|
66
|
+
interval: subscriptionIntervalSchema,
|
|
67
|
+
intervalCount: zod.z.number().int().min(1).max(365),
|
|
68
|
+
trialPeriodDays: zod.z.number().int().min(0).max(365).nullable(),
|
|
69
|
+
status: subscriptionPlanStatusSchema,
|
|
70
|
+
metadata: metadataSchema,
|
|
71
|
+
createdAt: isoTimestampSchema,
|
|
72
|
+
updatedAt: isoTimestampSchema
|
|
73
|
+
});
|
|
74
|
+
var createSubscriptionPlanInputSchema = zod.z.object({
|
|
75
|
+
name: zod.z.string().min(1).max(120),
|
|
76
|
+
description: zod.z.string().max(500).optional(),
|
|
77
|
+
amount: tokenAmountSchema,
|
|
78
|
+
currency: paymentCurrencySchema,
|
|
79
|
+
interval: subscriptionIntervalSchema,
|
|
80
|
+
intervalCount: zod.z.number().int().min(1).max(365).default(1),
|
|
81
|
+
trialPeriodDays: zod.z.number().int().min(0).max(365).optional(),
|
|
82
|
+
metadata: metadataSchema.optional()
|
|
83
|
+
});
|
|
84
|
+
var subscriptionStatusSchema = zod.z.enum([
|
|
85
|
+
"trialing",
|
|
86
|
+
"active",
|
|
87
|
+
"at_risk",
|
|
88
|
+
"paused",
|
|
89
|
+
"cancelled",
|
|
90
|
+
"lapsed"
|
|
91
|
+
]);
|
|
92
|
+
var subscriptionSchema = zod.z.object({
|
|
93
|
+
id: idSchema,
|
|
94
|
+
onchainSubscriptionId: zod.z.number().int().nonnegative().nullable(),
|
|
95
|
+
merchantId: idSchema,
|
|
96
|
+
customerId: idSchema,
|
|
97
|
+
planId: idSchema,
|
|
98
|
+
status: subscriptionStatusSchema,
|
|
99
|
+
payerAddress: evmAddressSchema,
|
|
100
|
+
currency: paymentCurrencySchema,
|
|
101
|
+
amount: tokenAmountSchema,
|
|
102
|
+
interval: subscriptionIntervalSchema,
|
|
103
|
+
intervalCount: zod.z.number().int().min(1),
|
|
104
|
+
trialEndsAt: isoTimestampSchema.nullable(),
|
|
105
|
+
currentPeriodStartAt: isoTimestampSchema,
|
|
106
|
+
currentPeriodEndAt: isoTimestampSchema,
|
|
107
|
+
nextChargeAt: isoTimestampSchema.nullable(),
|
|
108
|
+
gracePeriodHours: zod.z.number().int().min(0).max(72),
|
|
109
|
+
cancelledAt: isoTimestampSchema.nullable(),
|
|
110
|
+
metadata: metadataSchema,
|
|
111
|
+
createdAt: isoTimestampSchema,
|
|
112
|
+
updatedAt: isoTimestampSchema
|
|
113
|
+
});
|
|
114
|
+
var createSubscriptionInputSchema = zod.z.object({
|
|
115
|
+
planId: idSchema,
|
|
116
|
+
customer: zod.z.object({
|
|
117
|
+
walletAddress: evmAddressSchema,
|
|
118
|
+
email: zod.z.string().email().optional(),
|
|
119
|
+
externalRef: zod.z.string().max(120).optional()
|
|
120
|
+
}),
|
|
121
|
+
gracePeriodHours: zod.z.union([zod.z.literal(24), zod.z.literal(48), zod.z.literal(72)]).default(48),
|
|
122
|
+
metadata: metadataSchema.optional()
|
|
123
|
+
});
|
|
124
|
+
var cancelSubscriptionInputSchema = zod.z.object({
|
|
125
|
+
id: idSchema,
|
|
126
|
+
reason: zod.z.string().max(500).optional()
|
|
127
|
+
});
|
|
128
|
+
var subscriptionChargeOutcomeSchema = zod.z.enum([
|
|
129
|
+
"charged",
|
|
130
|
+
"insufficient_funds",
|
|
131
|
+
"revoked_approval",
|
|
132
|
+
"cancelled",
|
|
133
|
+
"skipped"
|
|
134
|
+
]);
|
|
135
|
+
var subscriptionChargeStatusSchema = zod.z.enum([
|
|
136
|
+
"pending",
|
|
137
|
+
"in_flight",
|
|
138
|
+
"succeeded",
|
|
139
|
+
"failed",
|
|
140
|
+
"retrying",
|
|
141
|
+
"abandoned"
|
|
142
|
+
]);
|
|
143
|
+
var subscriptionChargeSchema = zod.z.object({
|
|
144
|
+
id: idSchema,
|
|
145
|
+
subscriptionId: idSchema,
|
|
146
|
+
merchantId: idSchema,
|
|
147
|
+
chargeAttemptId: zod.z.string().length(66, "must be a 32-byte 0x-prefixed hex string"),
|
|
148
|
+
periodStartAt: isoTimestampSchema,
|
|
149
|
+
periodEndAt: isoTimestampSchema,
|
|
150
|
+
amount: tokenAmountSchema,
|
|
151
|
+
currency: paymentCurrencySchema,
|
|
152
|
+
status: subscriptionChargeStatusSchema,
|
|
153
|
+
outcome: subscriptionChargeOutcomeSchema.nullable(),
|
|
154
|
+
attemptNumber: zod.z.number().int().min(1),
|
|
155
|
+
scheduledAt: isoTimestampSchema,
|
|
156
|
+
executedAt: isoTimestampSchema.nullable(),
|
|
157
|
+
onchainTxHash: evmTxHashSchema.nullable(),
|
|
158
|
+
failureReason: zod.z.string().max(500).nullable(),
|
|
159
|
+
createdAt: isoTimestampSchema,
|
|
160
|
+
updatedAt: isoTimestampSchema
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
exports.cancelSubscriptionInputSchema = cancelSubscriptionInputSchema;
|
|
164
|
+
exports.createSubscriptionInputSchema = createSubscriptionInputSchema;
|
|
165
|
+
exports.createSubscriptionPlanInputSchema = createSubscriptionPlanInputSchema;
|
|
166
|
+
exports.subscriptionChargeOutcomeSchema = subscriptionChargeOutcomeSchema;
|
|
167
|
+
exports.subscriptionChargeSchema = subscriptionChargeSchema;
|
|
168
|
+
exports.subscriptionChargeStatusSchema = subscriptionChargeStatusSchema;
|
|
169
|
+
exports.subscriptionIntervalSchema = subscriptionIntervalSchema;
|
|
170
|
+
exports.subscriptionPlanSchema = subscriptionPlanSchema;
|
|
171
|
+
exports.subscriptionPlanStatusSchema = subscriptionPlanStatusSchema;
|
|
172
|
+
exports.subscriptionSchema = subscriptionSchema;
|
|
173
|
+
exports.subscriptionStatusSchema = subscriptionStatusSchema;
|
|
174
|
+
//# sourceMappingURL=subscriptions.cjs.map
|
|
175
|
+
//# sourceMappingURL=subscriptions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common.ts","../src/subscriptions.ts"],"names":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GAAkCA,MAAE,IAAA,CAAK;AAAA,EACpD,SAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,8BAAA,GAAiCA,MAAE,IAAA,CAAK;AAAA,EACnD,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,wBAAA,GAA2BA,MAAE,MAAA,CAAO;AAAA,EAC/C,EAAA,EAAI,QAAA;AAAA,EACJ,cAAA,EAAgB,QAAA;AAAA,EAChB,UAAA,EAAY,QAAA;AAAA,EACZ,iBAAiBA,KAAAA,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,KAAAA,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,KAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA,EAAS;AAAA,EAC5C,SAAA,EAAW,kBAAA;AAAA,EACX,SAAA,EAAW;AACb,CAAC","file":"subscriptions.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 * 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"]}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Subscriptions — plans, active subscriptions, and individual charges.
|
|
5
|
+
*
|
|
6
|
+
* Design notes:
|
|
7
|
+
* - A SubscriptionPlan is the template a merchant defines.
|
|
8
|
+
* - A Subscription is an active, customer-scoped instance of a plan.
|
|
9
|
+
* - Each billing period produces a SubscriptionCharge with a unique
|
|
10
|
+
* chargeAttemptId used to enforce idempotency at the contract level.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const subscriptionIntervalSchema: z.ZodEnum<["daily", "weekly", "monthly", "quarterly", "yearly"]>;
|
|
14
|
+
type SubscriptionInterval = z.infer<typeof subscriptionIntervalSchema>;
|
|
15
|
+
declare const subscriptionPlanStatusSchema: z.ZodEnum<["active", "archived"]>;
|
|
16
|
+
type SubscriptionPlanStatus = z.infer<typeof subscriptionPlanStatusSchema>;
|
|
17
|
+
declare const subscriptionPlanSchema: z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
merchantId: z.ZodString;
|
|
20
|
+
/**
|
|
21
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
22
|
+
* See `paymentSessionSchema.chainMerchantId`. Null when the merchant
|
|
23
|
+
* hasn't been registered on-chain yet — the hosted enrolment page
|
|
24
|
+
* refuses to take signatures in that state.
|
|
25
|
+
*/
|
|
26
|
+
chainMerchantId: z.ZodNullable<z.ZodString>;
|
|
27
|
+
/**
|
|
28
|
+
* ERC-20 token contract address resolved from `currency` — the
|
|
29
|
+
* EIP-2612 `verifyingContract` the wallet signs over.
|
|
30
|
+
*/
|
|
31
|
+
tokenAddress: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
|
|
32
|
+
/**
|
|
33
|
+
* Charge cadence in seconds, derived from `interval` + `intervalCount`
|
|
34
|
+
* so the meta-tx layer can pass a uint32 to StrimzSubscriptions
|
|
35
|
+
* without re-deriving the conversion on the client.
|
|
36
|
+
*/
|
|
37
|
+
intervalSeconds: z.ZodNumber;
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
description: z.ZodNullable<z.ZodString>;
|
|
40
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
41
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
42
|
+
interval: z.ZodEnum<["daily", "weekly", "monthly", "quarterly", "yearly"]>;
|
|
43
|
+
intervalCount: z.ZodNumber;
|
|
44
|
+
trialPeriodDays: z.ZodNullable<z.ZodNumber>;
|
|
45
|
+
status: z.ZodEnum<["active", "archived"]>;
|
|
46
|
+
metadata: z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
47
|
+
createdAt: z.ZodString;
|
|
48
|
+
updatedAt: z.ZodString;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
status: "active" | "archived";
|
|
51
|
+
id: string;
|
|
52
|
+
merchantId: string;
|
|
53
|
+
name: string;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
metadata: Record<string, string | number | boolean | null>;
|
|
56
|
+
chainMerchantId: string | null;
|
|
57
|
+
tokenAddress: string | null;
|
|
58
|
+
amount: string;
|
|
59
|
+
currency: "USDC" | "EURC";
|
|
60
|
+
description: string | null;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
intervalSeconds: number;
|
|
63
|
+
interval: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
64
|
+
intervalCount: number;
|
|
65
|
+
trialPeriodDays: number | null;
|
|
66
|
+
}, {
|
|
67
|
+
status: "active" | "archived";
|
|
68
|
+
id: string;
|
|
69
|
+
merchantId: string;
|
|
70
|
+
name: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
chainMerchantId: string | null;
|
|
73
|
+
tokenAddress: string | null;
|
|
74
|
+
amount: string;
|
|
75
|
+
currency: "USDC" | "EURC";
|
|
76
|
+
description: string | null;
|
|
77
|
+
updatedAt: string;
|
|
78
|
+
intervalSeconds: number;
|
|
79
|
+
interval: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
80
|
+
intervalCount: number;
|
|
81
|
+
trialPeriodDays: number | null;
|
|
82
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
type SubscriptionPlan = z.infer<typeof subscriptionPlanSchema>;
|
|
85
|
+
declare const createSubscriptionPlanInputSchema: z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
description: z.ZodOptional<z.ZodString>;
|
|
88
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
89
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
90
|
+
interval: z.ZodEnum<["daily", "weekly", "monthly", "quarterly", "yearly"]>;
|
|
91
|
+
intervalCount: z.ZodDefault<z.ZodNumber>;
|
|
92
|
+
trialPeriodDays: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
metadata: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
name: string;
|
|
96
|
+
amount: string;
|
|
97
|
+
currency: "USDC" | "EURC";
|
|
98
|
+
interval: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
99
|
+
intervalCount: number;
|
|
100
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
101
|
+
description?: string | undefined;
|
|
102
|
+
trialPeriodDays?: number | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
name: string;
|
|
105
|
+
amount: string;
|
|
106
|
+
currency: "USDC" | "EURC";
|
|
107
|
+
interval: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
108
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
109
|
+
description?: string | undefined;
|
|
110
|
+
intervalCount?: number | undefined;
|
|
111
|
+
trialPeriodDays?: number | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
type CreateSubscriptionPlanInput = z.infer<typeof createSubscriptionPlanInputSchema>;
|
|
114
|
+
declare const subscriptionStatusSchema: z.ZodEnum<["trialing", "active", "at_risk", "paused", "cancelled", "lapsed"]>;
|
|
115
|
+
type SubscriptionStatus = z.infer<typeof subscriptionStatusSchema>;
|
|
116
|
+
declare const subscriptionSchema: z.ZodObject<{
|
|
117
|
+
id: z.ZodString;
|
|
118
|
+
onchainSubscriptionId: z.ZodNullable<z.ZodNumber>;
|
|
119
|
+
merchantId: z.ZodString;
|
|
120
|
+
customerId: z.ZodString;
|
|
121
|
+
planId: z.ZodString;
|
|
122
|
+
status: z.ZodEnum<["trialing", "active", "at_risk", "paused", "cancelled", "lapsed"]>;
|
|
123
|
+
payerAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
124
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
125
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
126
|
+
interval: z.ZodEnum<["daily", "weekly", "monthly", "quarterly", "yearly"]>;
|
|
127
|
+
intervalCount: z.ZodNumber;
|
|
128
|
+
trialEndsAt: z.ZodNullable<z.ZodString>;
|
|
129
|
+
currentPeriodStartAt: z.ZodString;
|
|
130
|
+
currentPeriodEndAt: z.ZodString;
|
|
131
|
+
nextChargeAt: z.ZodNullable<z.ZodString>;
|
|
132
|
+
gracePeriodHours: z.ZodNumber;
|
|
133
|
+
cancelledAt: z.ZodNullable<z.ZodString>;
|
|
134
|
+
metadata: z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
135
|
+
createdAt: z.ZodString;
|
|
136
|
+
updatedAt: z.ZodString;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
status: "cancelled" | "active" | "trialing" | "at_risk" | "paused" | "lapsed";
|
|
139
|
+
id: string;
|
|
140
|
+
merchantId: string;
|
|
141
|
+
createdAt: string;
|
|
142
|
+
metadata: Record<string, string | number | boolean | null>;
|
|
143
|
+
customerId: string;
|
|
144
|
+
amount: string;
|
|
145
|
+
currency: "USDC" | "EURC";
|
|
146
|
+
updatedAt: string;
|
|
147
|
+
payerAddress: string;
|
|
148
|
+
interval: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
149
|
+
intervalCount: number;
|
|
150
|
+
onchainSubscriptionId: number | null;
|
|
151
|
+
planId: string;
|
|
152
|
+
trialEndsAt: string | null;
|
|
153
|
+
currentPeriodStartAt: string;
|
|
154
|
+
currentPeriodEndAt: string;
|
|
155
|
+
nextChargeAt: string | null;
|
|
156
|
+
gracePeriodHours: number;
|
|
157
|
+
cancelledAt: string | null;
|
|
158
|
+
}, {
|
|
159
|
+
status: "cancelled" | "active" | "trialing" | "at_risk" | "paused" | "lapsed";
|
|
160
|
+
id: string;
|
|
161
|
+
merchantId: string;
|
|
162
|
+
createdAt: string;
|
|
163
|
+
customerId: string;
|
|
164
|
+
amount: string;
|
|
165
|
+
currency: "USDC" | "EURC";
|
|
166
|
+
updatedAt: string;
|
|
167
|
+
payerAddress: string;
|
|
168
|
+
interval: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
169
|
+
intervalCount: number;
|
|
170
|
+
onchainSubscriptionId: number | null;
|
|
171
|
+
planId: string;
|
|
172
|
+
trialEndsAt: string | null;
|
|
173
|
+
currentPeriodStartAt: string;
|
|
174
|
+
currentPeriodEndAt: string;
|
|
175
|
+
nextChargeAt: string | null;
|
|
176
|
+
gracePeriodHours: number;
|
|
177
|
+
cancelledAt: string | null;
|
|
178
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
type Subscription = z.infer<typeof subscriptionSchema>;
|
|
181
|
+
declare const createSubscriptionInputSchema: z.ZodObject<{
|
|
182
|
+
planId: z.ZodString;
|
|
183
|
+
customer: z.ZodObject<{
|
|
184
|
+
walletAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
185
|
+
email: z.ZodOptional<z.ZodString>;
|
|
186
|
+
externalRef: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
walletAddress: string;
|
|
189
|
+
email?: string | undefined;
|
|
190
|
+
externalRef?: string | undefined;
|
|
191
|
+
}, {
|
|
192
|
+
walletAddress: string;
|
|
193
|
+
email?: string | undefined;
|
|
194
|
+
externalRef?: string | undefined;
|
|
195
|
+
}>;
|
|
196
|
+
gracePeriodHours: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<24>, z.ZodLiteral<48>, z.ZodLiteral<72>]>>;
|
|
197
|
+
metadata: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>;
|
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
|
199
|
+
customer: {
|
|
200
|
+
walletAddress: string;
|
|
201
|
+
email?: string | undefined;
|
|
202
|
+
externalRef?: string | undefined;
|
|
203
|
+
};
|
|
204
|
+
planId: string;
|
|
205
|
+
gracePeriodHours: 24 | 72 | 48;
|
|
206
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
customer: {
|
|
209
|
+
walletAddress: string;
|
|
210
|
+
email?: string | undefined;
|
|
211
|
+
externalRef?: string | undefined;
|
|
212
|
+
};
|
|
213
|
+
planId: string;
|
|
214
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
215
|
+
gracePeriodHours?: 24 | 72 | 48 | undefined;
|
|
216
|
+
}>;
|
|
217
|
+
type CreateSubscriptionInput = z.infer<typeof createSubscriptionInputSchema>;
|
|
218
|
+
declare const cancelSubscriptionInputSchema: z.ZodObject<{
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
221
|
+
}, "strip", z.ZodTypeAny, {
|
|
222
|
+
id: string;
|
|
223
|
+
reason?: string | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
id: string;
|
|
226
|
+
reason?: string | undefined;
|
|
227
|
+
}>;
|
|
228
|
+
type CancelSubscriptionInput = z.infer<typeof cancelSubscriptionInputSchema>;
|
|
229
|
+
declare const subscriptionChargeOutcomeSchema: z.ZodEnum<["charged", "insufficient_funds", "revoked_approval", "cancelled", "skipped"]>;
|
|
230
|
+
type SubscriptionChargeOutcome = z.infer<typeof subscriptionChargeOutcomeSchema>;
|
|
231
|
+
declare const subscriptionChargeStatusSchema: z.ZodEnum<["pending", "in_flight", "succeeded", "failed", "retrying", "abandoned"]>;
|
|
232
|
+
type SubscriptionChargeStatus = z.infer<typeof subscriptionChargeStatusSchema>;
|
|
233
|
+
declare const subscriptionChargeSchema: z.ZodObject<{
|
|
234
|
+
id: z.ZodString;
|
|
235
|
+
subscriptionId: z.ZodString;
|
|
236
|
+
merchantId: z.ZodString;
|
|
237
|
+
chargeAttemptId: z.ZodString;
|
|
238
|
+
periodStartAt: z.ZodString;
|
|
239
|
+
periodEndAt: z.ZodString;
|
|
240
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
241
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
242
|
+
status: z.ZodEnum<["pending", "in_flight", "succeeded", "failed", "retrying", "abandoned"]>;
|
|
243
|
+
outcome: z.ZodNullable<z.ZodEnum<["charged", "insufficient_funds", "revoked_approval", "cancelled", "skipped"]>>;
|
|
244
|
+
attemptNumber: z.ZodNumber;
|
|
245
|
+
scheduledAt: z.ZodString;
|
|
246
|
+
executedAt: z.ZodNullable<z.ZodString>;
|
|
247
|
+
onchainTxHash: z.ZodNullable<z.ZodString>;
|
|
248
|
+
failureReason: z.ZodNullable<z.ZodString>;
|
|
249
|
+
createdAt: z.ZodString;
|
|
250
|
+
updatedAt: z.ZodString;
|
|
251
|
+
}, "strip", z.ZodTypeAny, {
|
|
252
|
+
status: "failed" | "pending" | "in_flight" | "succeeded" | "retrying" | "abandoned";
|
|
253
|
+
id: string;
|
|
254
|
+
merchantId: string;
|
|
255
|
+
createdAt: string;
|
|
256
|
+
subscriptionId: string;
|
|
257
|
+
amount: string;
|
|
258
|
+
currency: "USDC" | "EURC";
|
|
259
|
+
onchainTxHash: string | null;
|
|
260
|
+
updatedAt: string;
|
|
261
|
+
chargeAttemptId: string;
|
|
262
|
+
periodStartAt: string;
|
|
263
|
+
periodEndAt: string;
|
|
264
|
+
outcome: "cancelled" | "charged" | "insufficient_funds" | "revoked_approval" | "skipped" | null;
|
|
265
|
+
attemptNumber: number;
|
|
266
|
+
scheduledAt: string;
|
|
267
|
+
executedAt: string | null;
|
|
268
|
+
failureReason: string | null;
|
|
269
|
+
}, {
|
|
270
|
+
status: "failed" | "pending" | "in_flight" | "succeeded" | "retrying" | "abandoned";
|
|
271
|
+
id: string;
|
|
272
|
+
merchantId: string;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
subscriptionId: string;
|
|
275
|
+
amount: string;
|
|
276
|
+
currency: "USDC" | "EURC";
|
|
277
|
+
onchainTxHash: string | null;
|
|
278
|
+
updatedAt: string;
|
|
279
|
+
chargeAttemptId: string;
|
|
280
|
+
periodStartAt: string;
|
|
281
|
+
periodEndAt: string;
|
|
282
|
+
outcome: "cancelled" | "charged" | "insufficient_funds" | "revoked_approval" | "skipped" | null;
|
|
283
|
+
attemptNumber: number;
|
|
284
|
+
scheduledAt: string;
|
|
285
|
+
executedAt: string | null;
|
|
286
|
+
failureReason: string | null;
|
|
287
|
+
}>;
|
|
288
|
+
type SubscriptionCharge = z.infer<typeof subscriptionChargeSchema>;
|
|
289
|
+
|
|
290
|
+
export { type CancelSubscriptionInput, type CreateSubscriptionInput, type CreateSubscriptionPlanInput, type Subscription, type SubscriptionCharge, type SubscriptionChargeOutcome, type SubscriptionChargeStatus, type SubscriptionInterval, type SubscriptionPlan, type SubscriptionPlanStatus, type SubscriptionStatus, cancelSubscriptionInputSchema, createSubscriptionInputSchema, createSubscriptionPlanInputSchema, subscriptionChargeOutcomeSchema, subscriptionChargeSchema, subscriptionChargeStatusSchema, subscriptionIntervalSchema, subscriptionPlanSchema, subscriptionPlanStatusSchema, subscriptionSchema, subscriptionStatusSchema };
|