@strimz/shared-types 0.7.0 → 0.9.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/dist/analytics.cjs +558 -0
- package/dist/analytics.cjs.map +1 -0
- package/dist/analytics.d.cts +1719 -0
- package/dist/analytics.d.ts +1719 -0
- package/dist/analytics.js +530 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api-keys.d.cts +20 -20
- package/dist/api-keys.d.ts +20 -20
- package/dist/compliance.d.cts +6 -6
- package/dist/compliance.d.ts +6 -6
- package/dist/customers.d.cts +7 -7
- package/dist/customers.d.ts +7 -7
- package/dist/events.cjs +0 -10
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +1885 -1885
- package/dist/events.d.ts +1885 -1885
- package/dist/events.js +0 -10
- package/dist/events.js.map +1 -1
- package/dist/index.cjs +216 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.js +190 -11
- package/dist/index.js.map +1 -1
- package/dist/invoices.d.cts +16 -16
- package/dist/invoices.d.ts +16 -16
- package/dist/merchants.d.cts +29 -29
- package/dist/merchants.d.ts +29 -29
- package/dist/payment-sessions.d.cts +19 -19
- package/dist/payment-sessions.d.ts +19 -19
- package/dist/refunds.d.cts +50 -50
- package/dist/refunds.d.ts +50 -50
- package/dist/storefronts.cjs +0 -10
- package/dist/storefronts.cjs.map +1 -1
- package/dist/storefronts.d.cts +24 -24
- package/dist/storefronts.d.ts +24 -24
- package/dist/storefronts.js +0 -10
- package/dist/storefronts.js.map +1 -1
- package/dist/subscriptions.cjs +0 -11
- package/dist/subscriptions.cjs.map +1 -1
- package/dist/subscriptions.d.cts +43 -81
- package/dist/subscriptions.d.ts +43 -81
- package/dist/subscriptions.js +1 -11
- package/dist/subscriptions.js.map +1 -1
- package/dist/transactions.d.cts +16 -16
- package/dist/transactions.d.ts +16 -16
- package/dist/webhooks.d.cts +28 -28
- package/dist/webhooks.d.ts +28 -28
- package/package.json +6 -1
- package/src/analytics.ts +275 -0
- package/src/index.ts +1 -0
- package/src/subscriptions.ts +0 -13
package/dist/refunds.d.cts
CHANGED
|
@@ -29,32 +29,32 @@ declare const refundSchema: z.ZodObject<{
|
|
|
29
29
|
completedAt: z.ZodNullable<z.ZodString>;
|
|
30
30
|
}, "strip", z.ZodTypeAny, {
|
|
31
31
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
32
|
-
id: string;
|
|
33
|
-
merchantId: string;
|
|
34
|
-
createdAt: string;
|
|
35
32
|
amount: string;
|
|
36
33
|
currency: "USDC" | "EURC";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
failureReason: string | null;
|
|
40
|
-
transactionId: string;
|
|
34
|
+
merchantId: string;
|
|
35
|
+
id: string;
|
|
41
36
|
note: string | null;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
transactionId: string;
|
|
39
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
40
|
+
payerAddress: string;
|
|
42
41
|
refundTxHash: string | null;
|
|
42
|
+
failureReason: string | null;
|
|
43
43
|
initiatedBy: string;
|
|
44
44
|
completedAt: string | null;
|
|
45
45
|
}, {
|
|
46
46
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
47
|
-
id: string;
|
|
48
|
-
merchantId: string;
|
|
49
|
-
createdAt: string;
|
|
50
47
|
amount: string;
|
|
51
48
|
currency: "USDC" | "EURC";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
failureReason: string | null;
|
|
55
|
-
transactionId: string;
|
|
49
|
+
merchantId: string;
|
|
50
|
+
id: string;
|
|
56
51
|
note: string | null;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
transactionId: string;
|
|
54
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
55
|
+
payerAddress: string;
|
|
57
56
|
refundTxHash: string | null;
|
|
57
|
+
failureReason: string | null;
|
|
58
58
|
initiatedBy: string;
|
|
59
59
|
completedAt: string | null;
|
|
60
60
|
}>;
|
|
@@ -66,13 +66,13 @@ declare const createRefundInputSchema: z.ZodObject<{
|
|
|
66
66
|
note: z.ZodOptional<z.ZodString>;
|
|
67
67
|
}, "strip", z.ZodTypeAny, {
|
|
68
68
|
amount: string;
|
|
69
|
-
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
70
69
|
transactionId: string;
|
|
70
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
71
71
|
note?: string | undefined;
|
|
72
72
|
}, {
|
|
73
73
|
amount: string;
|
|
74
|
-
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
75
74
|
transactionId: string;
|
|
75
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
76
76
|
note?: string | undefined;
|
|
77
77
|
}>;
|
|
78
78
|
type CreateRefundInput = z.input<typeof createRefundInputSchema>;
|
|
@@ -101,14 +101,14 @@ declare const refundSigningInstructionsSchema: z.ZodObject<{
|
|
|
101
101
|
note: z.ZodString;
|
|
102
102
|
}, "strip", z.ZodTypeAny, {
|
|
103
103
|
amount: string;
|
|
104
|
+
to: string;
|
|
104
105
|
note: string;
|
|
105
106
|
token: string;
|
|
106
|
-
to: string;
|
|
107
107
|
}, {
|
|
108
108
|
amount: string;
|
|
109
|
+
to: string;
|
|
109
110
|
note: string;
|
|
110
111
|
token: string;
|
|
111
|
-
to: string;
|
|
112
112
|
}>;
|
|
113
113
|
type RefundSigningInstructions = z.infer<typeof refundSigningInstructionsSchema>;
|
|
114
114
|
declare const refundCreateOutputSchema: z.ZodObject<{
|
|
@@ -129,32 +129,32 @@ declare const refundCreateOutputSchema: z.ZodObject<{
|
|
|
129
129
|
completedAt: z.ZodNullable<z.ZodString>;
|
|
130
130
|
}, "strip", z.ZodTypeAny, {
|
|
131
131
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
132
|
-
id: string;
|
|
133
|
-
merchantId: string;
|
|
134
|
-
createdAt: string;
|
|
135
132
|
amount: string;
|
|
136
133
|
currency: "USDC" | "EURC";
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
failureReason: string | null;
|
|
140
|
-
transactionId: string;
|
|
134
|
+
merchantId: string;
|
|
135
|
+
id: string;
|
|
141
136
|
note: string | null;
|
|
137
|
+
createdAt: string;
|
|
138
|
+
transactionId: string;
|
|
139
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
140
|
+
payerAddress: string;
|
|
142
141
|
refundTxHash: string | null;
|
|
142
|
+
failureReason: string | null;
|
|
143
143
|
initiatedBy: string;
|
|
144
144
|
completedAt: string | null;
|
|
145
145
|
}, {
|
|
146
146
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
147
|
-
id: string;
|
|
148
|
-
merchantId: string;
|
|
149
|
-
createdAt: string;
|
|
150
147
|
amount: string;
|
|
151
148
|
currency: "USDC" | "EURC";
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
failureReason: string | null;
|
|
155
|
-
transactionId: string;
|
|
149
|
+
merchantId: string;
|
|
150
|
+
id: string;
|
|
156
151
|
note: string | null;
|
|
152
|
+
createdAt: string;
|
|
153
|
+
transactionId: string;
|
|
154
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
155
|
+
payerAddress: string;
|
|
157
156
|
refundTxHash: string | null;
|
|
157
|
+
failureReason: string | null;
|
|
158
158
|
initiatedBy: string;
|
|
159
159
|
completedAt: string | null;
|
|
160
160
|
}>;
|
|
@@ -165,60 +165,60 @@ declare const refundCreateOutputSchema: z.ZodObject<{
|
|
|
165
165
|
note: z.ZodString;
|
|
166
166
|
}, "strip", z.ZodTypeAny, {
|
|
167
167
|
amount: string;
|
|
168
|
+
to: string;
|
|
168
169
|
note: string;
|
|
169
170
|
token: string;
|
|
170
|
-
to: string;
|
|
171
171
|
}, {
|
|
172
172
|
amount: string;
|
|
173
|
+
to: string;
|
|
173
174
|
note: string;
|
|
174
175
|
token: string;
|
|
175
|
-
to: string;
|
|
176
176
|
}>;
|
|
177
177
|
}, "strip", z.ZodTypeAny, {
|
|
178
178
|
refund: {
|
|
179
179
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
180
|
-
id: string;
|
|
181
|
-
merchantId: string;
|
|
182
|
-
createdAt: string;
|
|
183
180
|
amount: string;
|
|
184
181
|
currency: "USDC" | "EURC";
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
failureReason: string | null;
|
|
188
|
-
transactionId: string;
|
|
182
|
+
merchantId: string;
|
|
183
|
+
id: string;
|
|
189
184
|
note: string | null;
|
|
185
|
+
createdAt: string;
|
|
186
|
+
transactionId: string;
|
|
187
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
188
|
+
payerAddress: string;
|
|
190
189
|
refundTxHash: string | null;
|
|
190
|
+
failureReason: string | null;
|
|
191
191
|
initiatedBy: string;
|
|
192
192
|
completedAt: string | null;
|
|
193
193
|
};
|
|
194
194
|
signingInstructions: {
|
|
195
195
|
amount: string;
|
|
196
|
+
to: string;
|
|
196
197
|
note: string;
|
|
197
198
|
token: string;
|
|
198
|
-
to: string;
|
|
199
199
|
};
|
|
200
200
|
}, {
|
|
201
201
|
refund: {
|
|
202
202
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
203
|
-
id: string;
|
|
204
|
-
merchantId: string;
|
|
205
|
-
createdAt: string;
|
|
206
203
|
amount: string;
|
|
207
204
|
currency: "USDC" | "EURC";
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
failureReason: string | null;
|
|
211
|
-
transactionId: string;
|
|
205
|
+
merchantId: string;
|
|
206
|
+
id: string;
|
|
212
207
|
note: string | null;
|
|
208
|
+
createdAt: string;
|
|
209
|
+
transactionId: string;
|
|
210
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
211
|
+
payerAddress: string;
|
|
213
212
|
refundTxHash: string | null;
|
|
213
|
+
failureReason: string | null;
|
|
214
214
|
initiatedBy: string;
|
|
215
215
|
completedAt: string | null;
|
|
216
216
|
};
|
|
217
217
|
signingInstructions: {
|
|
218
218
|
amount: string;
|
|
219
|
+
to: string;
|
|
219
220
|
note: string;
|
|
220
221
|
token: string;
|
|
221
|
-
to: string;
|
|
222
222
|
};
|
|
223
223
|
}>;
|
|
224
224
|
type RefundCreateOutput = z.infer<typeof refundCreateOutputSchema>;
|
package/dist/refunds.d.ts
CHANGED
|
@@ -29,32 +29,32 @@ declare const refundSchema: z.ZodObject<{
|
|
|
29
29
|
completedAt: z.ZodNullable<z.ZodString>;
|
|
30
30
|
}, "strip", z.ZodTypeAny, {
|
|
31
31
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
32
|
-
id: string;
|
|
33
|
-
merchantId: string;
|
|
34
|
-
createdAt: string;
|
|
35
32
|
amount: string;
|
|
36
33
|
currency: "USDC" | "EURC";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
failureReason: string | null;
|
|
40
|
-
transactionId: string;
|
|
34
|
+
merchantId: string;
|
|
35
|
+
id: string;
|
|
41
36
|
note: string | null;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
transactionId: string;
|
|
39
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
40
|
+
payerAddress: string;
|
|
42
41
|
refundTxHash: string | null;
|
|
42
|
+
failureReason: string | null;
|
|
43
43
|
initiatedBy: string;
|
|
44
44
|
completedAt: string | null;
|
|
45
45
|
}, {
|
|
46
46
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
47
|
-
id: string;
|
|
48
|
-
merchantId: string;
|
|
49
|
-
createdAt: string;
|
|
50
47
|
amount: string;
|
|
51
48
|
currency: "USDC" | "EURC";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
failureReason: string | null;
|
|
55
|
-
transactionId: string;
|
|
49
|
+
merchantId: string;
|
|
50
|
+
id: string;
|
|
56
51
|
note: string | null;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
transactionId: string;
|
|
54
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
55
|
+
payerAddress: string;
|
|
57
56
|
refundTxHash: string | null;
|
|
57
|
+
failureReason: string | null;
|
|
58
58
|
initiatedBy: string;
|
|
59
59
|
completedAt: string | null;
|
|
60
60
|
}>;
|
|
@@ -66,13 +66,13 @@ declare const createRefundInputSchema: z.ZodObject<{
|
|
|
66
66
|
note: z.ZodOptional<z.ZodString>;
|
|
67
67
|
}, "strip", z.ZodTypeAny, {
|
|
68
68
|
amount: string;
|
|
69
|
-
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
70
69
|
transactionId: string;
|
|
70
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
71
71
|
note?: string | undefined;
|
|
72
72
|
}, {
|
|
73
73
|
amount: string;
|
|
74
|
-
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
75
74
|
transactionId: string;
|
|
75
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
76
76
|
note?: string | undefined;
|
|
77
77
|
}>;
|
|
78
78
|
type CreateRefundInput = z.input<typeof createRefundInputSchema>;
|
|
@@ -101,14 +101,14 @@ declare const refundSigningInstructionsSchema: z.ZodObject<{
|
|
|
101
101
|
note: z.ZodString;
|
|
102
102
|
}, "strip", z.ZodTypeAny, {
|
|
103
103
|
amount: string;
|
|
104
|
+
to: string;
|
|
104
105
|
note: string;
|
|
105
106
|
token: string;
|
|
106
|
-
to: string;
|
|
107
107
|
}, {
|
|
108
108
|
amount: string;
|
|
109
|
+
to: string;
|
|
109
110
|
note: string;
|
|
110
111
|
token: string;
|
|
111
|
-
to: string;
|
|
112
112
|
}>;
|
|
113
113
|
type RefundSigningInstructions = z.infer<typeof refundSigningInstructionsSchema>;
|
|
114
114
|
declare const refundCreateOutputSchema: z.ZodObject<{
|
|
@@ -129,32 +129,32 @@ declare const refundCreateOutputSchema: z.ZodObject<{
|
|
|
129
129
|
completedAt: z.ZodNullable<z.ZodString>;
|
|
130
130
|
}, "strip", z.ZodTypeAny, {
|
|
131
131
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
132
|
-
id: string;
|
|
133
|
-
merchantId: string;
|
|
134
|
-
createdAt: string;
|
|
135
132
|
amount: string;
|
|
136
133
|
currency: "USDC" | "EURC";
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
failureReason: string | null;
|
|
140
|
-
transactionId: string;
|
|
134
|
+
merchantId: string;
|
|
135
|
+
id: string;
|
|
141
136
|
note: string | null;
|
|
137
|
+
createdAt: string;
|
|
138
|
+
transactionId: string;
|
|
139
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
140
|
+
payerAddress: string;
|
|
142
141
|
refundTxHash: string | null;
|
|
142
|
+
failureReason: string | null;
|
|
143
143
|
initiatedBy: string;
|
|
144
144
|
completedAt: string | null;
|
|
145
145
|
}, {
|
|
146
146
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
147
|
-
id: string;
|
|
148
|
-
merchantId: string;
|
|
149
|
-
createdAt: string;
|
|
150
147
|
amount: string;
|
|
151
148
|
currency: "USDC" | "EURC";
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
failureReason: string | null;
|
|
155
|
-
transactionId: string;
|
|
149
|
+
merchantId: string;
|
|
150
|
+
id: string;
|
|
156
151
|
note: string | null;
|
|
152
|
+
createdAt: string;
|
|
153
|
+
transactionId: string;
|
|
154
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
155
|
+
payerAddress: string;
|
|
157
156
|
refundTxHash: string | null;
|
|
157
|
+
failureReason: string | null;
|
|
158
158
|
initiatedBy: string;
|
|
159
159
|
completedAt: string | null;
|
|
160
160
|
}>;
|
|
@@ -165,60 +165,60 @@ declare const refundCreateOutputSchema: z.ZodObject<{
|
|
|
165
165
|
note: z.ZodString;
|
|
166
166
|
}, "strip", z.ZodTypeAny, {
|
|
167
167
|
amount: string;
|
|
168
|
+
to: string;
|
|
168
169
|
note: string;
|
|
169
170
|
token: string;
|
|
170
|
-
to: string;
|
|
171
171
|
}, {
|
|
172
172
|
amount: string;
|
|
173
|
+
to: string;
|
|
173
174
|
note: string;
|
|
174
175
|
token: string;
|
|
175
|
-
to: string;
|
|
176
176
|
}>;
|
|
177
177
|
}, "strip", z.ZodTypeAny, {
|
|
178
178
|
refund: {
|
|
179
179
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
180
|
-
id: string;
|
|
181
|
-
merchantId: string;
|
|
182
|
-
createdAt: string;
|
|
183
180
|
amount: string;
|
|
184
181
|
currency: "USDC" | "EURC";
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
failureReason: string | null;
|
|
188
|
-
transactionId: string;
|
|
182
|
+
merchantId: string;
|
|
183
|
+
id: string;
|
|
189
184
|
note: string | null;
|
|
185
|
+
createdAt: string;
|
|
186
|
+
transactionId: string;
|
|
187
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
188
|
+
payerAddress: string;
|
|
190
189
|
refundTxHash: string | null;
|
|
190
|
+
failureReason: string | null;
|
|
191
191
|
initiatedBy: string;
|
|
192
192
|
completedAt: string | null;
|
|
193
193
|
};
|
|
194
194
|
signingInstructions: {
|
|
195
195
|
amount: string;
|
|
196
|
+
to: string;
|
|
196
197
|
note: string;
|
|
197
198
|
token: string;
|
|
198
|
-
to: string;
|
|
199
199
|
};
|
|
200
200
|
}, {
|
|
201
201
|
refund: {
|
|
202
202
|
status: "submitted" | "failed" | "cancelled" | "pending" | "awaiting_signature" | "completed";
|
|
203
|
-
id: string;
|
|
204
|
-
merchantId: string;
|
|
205
|
-
createdAt: string;
|
|
206
203
|
amount: string;
|
|
207
204
|
currency: "USDC" | "EURC";
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
failureReason: string | null;
|
|
211
|
-
transactionId: string;
|
|
205
|
+
merchantId: string;
|
|
206
|
+
id: string;
|
|
212
207
|
note: string | null;
|
|
208
|
+
createdAt: string;
|
|
209
|
+
transactionId: string;
|
|
210
|
+
reason: "customer_request" | "product_issue" | "duplicate_charge" | "fraudulent" | "other";
|
|
211
|
+
payerAddress: string;
|
|
213
212
|
refundTxHash: string | null;
|
|
213
|
+
failureReason: string | null;
|
|
214
214
|
initiatedBy: string;
|
|
215
215
|
completedAt: string | null;
|
|
216
216
|
};
|
|
217
217
|
signingInstructions: {
|
|
218
218
|
amount: string;
|
|
219
|
+
to: string;
|
|
219
220
|
note: string;
|
|
220
221
|
token: string;
|
|
221
|
-
to: string;
|
|
222
222
|
};
|
|
223
223
|
}>;
|
|
224
224
|
type RefundCreateOutput = z.infer<typeof refundCreateOutputSchema>;
|
package/dist/storefronts.cjs
CHANGED
|
@@ -118,16 +118,6 @@ zod.z.object({
|
|
|
118
118
|
trialDays: zod.z.number().int().min(0),
|
|
119
119
|
trialEndsAt: isoTimestampSchema.nullable()
|
|
120
120
|
});
|
|
121
|
-
zod.z.object({
|
|
122
|
-
planId: idSchema,
|
|
123
|
-
customer: zod.z.object({
|
|
124
|
-
walletAddress: evmAddressSchema,
|
|
125
|
-
email: zod.z.string().email().optional(),
|
|
126
|
-
externalRef: zod.z.string().max(120).optional()
|
|
127
|
-
}),
|
|
128
|
-
gracePeriodHours: zod.z.union([zod.z.literal(24), zod.z.literal(48), zod.z.literal(72)]).default(48),
|
|
129
|
-
metadata: metadataSchema.optional()
|
|
130
|
-
});
|
|
131
121
|
zod.z.object({
|
|
132
122
|
id: idSchema,
|
|
133
123
|
reason: zod.z.string().max(500).optional()
|
package/dist/storefronts.cjs.map
CHANGED
|
@@ -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,CAAC,CAAA,IAAK,IAAI,cAAc,CAAA;AAGtBA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,GAAA,CAAI,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AAClC,CAAC;AAKM,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.input<typeof paginationInputSchema>\nexport type PaginationParsed = z.output<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.input<typeof createSubscriptionPlanInputSchema>\nexport type CreateSubscriptionPlanParsed = z.output<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 subscriptionEnrolmentTermsSchema = z.object({\n startAt: z.string().regex(/^\\d+$/),\n trialDays: z.number().int().min(0),\n trialEndsAt: isoTimestampSchema.nullable(),\n})\nexport type SubscriptionEnrolmentTerms = z.infer<typeof subscriptionEnrolmentTermsSchema>\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.input<typeof createSubscriptionInputSchema>\nexport type CreateSubscriptionParsed = z.output<typeof createSubscriptionInputSchema>\n\nexport const cancelSubscriptionInputSchema = z.object({\n id: idSchema,\n reason: z.string().max(500).optional(),\n})\nexport type CancelSubscriptionInput = z.input<typeof cancelSubscriptionInputSchema>\nexport type CancelSubscriptionParsed = z.output<typeof cancelSubscriptionInputSchema>\n\n// ---------- Charges ----------\n\n// One value per contract ChargeOutcome. `skipped` is the fallback for\n// outcomes a future contract appends.\nexport const subscriptionChargeOutcomeSchema = z.enum([\n 'charged',\n 'insufficient_funds',\n 'revoked_approval',\n 'cancelled',\n 'not_due',\n 'ended',\n 'duplicate',\n 'unknown',\n 'merchant_inactive',\n 'transfer_failed',\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.input<typeof createStorefrontInputSchema>\nexport type CreateStorefrontParsed = z.output<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 planId: idSchema.optional(),\n })\n .superRefine((input, ctx) => {\n if (input.type === 'subscription' && !input.planId) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['planId'],\n message: 'subscription products need a planId',\n })\n }\n if (input.type === 'one_time' && input.planId) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['planId'],\n message: 'one_time products cannot carry a planId',\n })\n }\n })\nexport type CreateStorefrontProductInput = z.input<typeof createStorefrontProductInputSchema>\nexport type CreateStorefrontProductParsed = z.output<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.input<typeof storefrontCheckoutInputSchema>\nexport type StorefrontCheckoutParsed = z.output<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"]}
|
|
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;AA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AAA,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.input<typeof paginationInputSchema>\nexport type PaginationParsed = z.output<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.input<typeof createSubscriptionPlanInputSchema>\nexport type CreateSubscriptionPlanParsed = z.output<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 subscriptionEnrolmentTermsSchema = z.object({\n startAt: z.string().regex(/^\\d+$/),\n trialDays: z.number().int().min(0),\n trialEndsAt: isoTimestampSchema.nullable(),\n})\nexport type SubscriptionEnrolmentTerms = z.infer<typeof subscriptionEnrolmentTermsSchema>\n\nexport const cancelSubscriptionInputSchema = z.object({\n id: idSchema,\n reason: z.string().max(500).optional(),\n})\nexport type CancelSubscriptionInput = z.input<typeof cancelSubscriptionInputSchema>\nexport type CancelSubscriptionParsed = z.output<typeof cancelSubscriptionInputSchema>\n\n// ---------- Charges ----------\n\n// One value per contract ChargeOutcome. `skipped` is the fallback for\n// outcomes a future contract appends.\nexport const subscriptionChargeOutcomeSchema = z.enum([\n 'charged',\n 'insufficient_funds',\n 'revoked_approval',\n 'cancelled',\n 'not_due',\n 'ended',\n 'duplicate',\n 'unknown',\n 'merchant_inactive',\n 'transfer_failed',\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.input<typeof createStorefrontInputSchema>\nexport type CreateStorefrontParsed = z.output<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 planId: idSchema.optional(),\n })\n .superRefine((input, ctx) => {\n if (input.type === 'subscription' && !input.planId) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['planId'],\n message: 'subscription products need a planId',\n })\n }\n if (input.type === 'one_time' && input.planId) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['planId'],\n message: 'one_time products cannot carry a planId',\n })\n }\n })\nexport type CreateStorefrontProductInput = z.input<typeof createStorefrontProductInputSchema>\nexport type CreateStorefrontProductParsed = z.output<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.input<typeof storefrontCheckoutInputSchema>\nexport type StorefrontCheckoutParsed = z.output<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"]}
|