forked from block65/openapi-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalibot.ts
More file actions
366 lines (365 loc) · 11 KB
/
valibot.ts
File metadata and controls
366 lines (365 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
/**
* This file was auto generated by @block65/openapi-codegen
*
* WARN: Do not edit directly.
*
* Generated on 2026-04-02T04:52:00.193Z
*
*/
import * as v from "valibot";
export const promoCodeSchema = v.pipe(
v.string(),
v.minLength(1),
v.maxLength(256),
v.regex(/\/^[A-Z0-9]$\//),
);
/** The API version */
export const apiVersionSchema = v.literal("2024-01-01");
export const maxRetriesSchema = v.literal(3);
export const defaultEnabledSchema = v.literal(true);
/** Optional notes field */
export const nullableNotesSchema = v.nullable(v.string());
export const nullableDiscountSchema = v.nullable(v.number());
export const nullableStatusSchema = v.nullable(
v.picklist(["active", "paused", "cancelled"]),
);
export const accountTierSchema = v.picklist(["free", "pro", "enterprise"]);
export const stripeIdSchema = v.pipe(
v.string(),
v.minLength(11),
v.maxLength(255),
v.regex(/^(pm|cus|sub)_\w{8,}$/),
);
export const dateTimeSchema = v.string();
export const billingSubscriptionStatusSchema = v.picklist([
"active",
"inactive",
]);
export const billingSubscriptionIntervalSchema = v.picklist([
"monthly",
"yearly",
]);
export const planSkuSchema = v.picklist([
"donotuse",
"plasku1",
"plasku2",
"plasku3",
"plasku4",
]);
export const idSchema = v.pipe(
v.string(),
v.minLength(1),
v.maxLength(16),
v.regex(/^[a-zA-Z0-9]+$/),
);
export const billingSubscriptionIdentifiersSchema = v.strictObject({
billingAccountId: idSchema,
subscriptionId: idSchema,
});
export const billingSubscriptionSchema = v.intersect([
billingSubscriptionIdentifiersSchema,
v.strictObject({
accountId: v.exactOptional(idSchema),
planSku: planSkuSchema,
interval: billingSubscriptionIntervalSchema,
status: billingSubscriptionStatusSchema,
cycleTime: dateTimeSchema,
trialEndTime: v.exactOptional(dateTimeSchema),
createdTime: dateTimeSchema,
updatedTime: v.exactOptional(dateTimeSchema),
}),
]);
export const billingSubscriptionsSchema = v.array(billingSubscriptionSchema);
export const uuidSchema = v.pipe(v.string(), v.uuid());
export const longRunningOperationFailSchema = v.strictObject({
operationId: uuidSchema,
done: v.boolean(),
result: v.strictObject({
error: v.number(),
}),
});
export const stringU8Schema = v.pipe(
v.string(),
v.minLength(1),
v.maxLength(256),
);
export const billingSubscriptionPromoCodeLongRunningOperationSuccessSchema =
v.strictObject({
operationId: uuidSchema,
done: v.boolean(),
result: v.strictObject({
response: v.strictObject({
promoCode: stringU8Schema,
}),
}),
});
export const longRunningOperationIndeterminateSchema = v.strictObject({
operationId: uuidSchema,
done: v.boolean(),
});
export const billingSubscriptionLroSchema = v.union([
longRunningOperationIndeterminateSchema,
billingSubscriptionPromoCodeLongRunningOperationSuccessSchema,
longRunningOperationFailSchema,
]);
export const updateBillingSubscriptionPromoCodeRequestSchema = v.strictObject({
promoCode: v.union([
stringU8Schema,
v.nullable(v.record(v.string(), v.unknown())),
]),
});
/** Reasonable string to be used as a name of a person, or an object */
export const nameSchema = v.pipe(v.string(), v.minLength(2), v.maxLength(512));
export const updateBillingSubscriptionRequestSchema = v.strictObject({
label: v.exactOptional(nameSchema),
trialEndTime: v.exactOptional(dateTimeSchema),
});
export const createBillingSubscriptionRequestSchema = v.strictObject({
accountId: idSchema,
planSku: planSkuSchema,
interval: billingSubscriptionIntervalSchema,
promoCode: v.exactOptional(stringU8Schema),
});
export const paymentMethodBrandSchema = v.picklist([
"amex",
"diners",
"discover",
"jcb",
"mastercard",
"unionpay",
"visa",
"unknown",
]);
export const paymentMethodIdentifiersSchema = v.strictObject({
billingAccountId: idSchema,
paymentMethodId: idSchema,
});
export const paymentMethodSchema = v.intersect([
paymentMethodIdentifiersSchema,
v.strictObject({
label: nameSchema,
expireTime: dateTimeSchema,
humanId: stringU8Schema,
brand: v.exactOptional(paymentMethodBrandSchema),
}),
]);
export const paymentMethodsSchema = v.array(paymentMethodSchema);
export const paymentMethodDeletedLongRunningOperationSuccessSchema =
v.strictObject({
operationId: uuidSchema,
done: v.boolean(),
result: v.strictObject({
response: v.strictObject({
ok: v.boolean(),
}),
}),
});
export const paymentMethodDeletedLroSchema = v.union([
longRunningOperationIndeterminateSchema,
paymentMethodDeletedLongRunningOperationSuccessSchema,
longRunningOperationFailSchema,
]);
export const paymentMethodLongRunningOperationSuccessSchema = v.strictObject({
operationId: uuidSchema,
done: v.boolean(),
result: v.strictObject({
response: v.strictObject({
clientSecret: v.string(),
}),
}),
});
export const paymentMethodIntendedLroSchema = v.union([
longRunningOperationIndeterminateSchema,
paymentMethodLongRunningOperationSuccessSchema,
longRunningOperationFailSchema,
]);
export const updatePaymentMethodRequestSchema = v.strictObject({
label: v.exactOptional(nameSchema),
isDefault: v.exactOptional(v.boolean()),
});
export const linkBillingAccountRequestSchema = v.strictObject({
accountId: idSchema,
});
export const urlSchema = v.pipe(
v.string(),
v.minLength(1),
v.maxLength(2048),
v.regex(/^https:\/\/.*/),
);
export const billingAccountPortalSchema = v.strictObject({
url: urlSchema,
});
export const originSchema = v.pipe(
v.string(),
v.minLength(1),
v.maxLength(263),
v.regex(/^https:\/\/.*$/),
);
export const billingAccountPortalRequestSchema = v.strictObject({
origin: originSchema,
accountId: idSchema,
});
export const timeZoneSchema = v.pipe(
v.string(),
v.regex(/^\w{1,32}\/\w{1,32}$/),
);
export const billingLocaleSchema = v.picklist(["en"]);
export const billingAccountTypeSchema = v.picklist([
"standard",
"agency",
"reseller",
]);
export const currencySchema = v.picklist(["usd", "aud", "sgd", "myr", "gbp"]);
export const billingAccountStatusSchema = v.picklist(["nominal", "delinquent"]);
export const billingCountrySchema = v.picklist(["us", "au", "sg", "my", "gb"]);
/** Valid email address with fully qualified public top-level domain */
export const emailSchema = v.pipe(
v.string(),
v.email(),
v.minLength(6),
v.maxLength(512),
);
export const billingAccountIdentifiersSchema = v.strictObject({
billingAccountId: idSchema,
});
export const billingAccountSchema = v.intersect([
billingAccountIdentifiersSchema,
v.strictObject({
name: nameSchema,
email: emailSchema,
country: billingCountrySchema,
status: billingAccountStatusSchema,
currency: currencySchema,
type: billingAccountTypeSchema,
createdTime: dateTimeSchema,
updatedTime: v.exactOptional(dateTimeSchema),
locale: v.exactOptional(billingLocaleSchema),
purchaseOrder: v.exactOptional(stringU8Schema),
taxId: v.exactOptional(stringU8Schema),
timeZone: v.exactOptional(timeZoneSchema),
defaultPaymentMethodId: v.exactOptional(idSchema),
}),
]);
export const billingAccountListSchema = v.array(billingAccountSchema);
export const billingAccountUpdateRequestSchema = v.strictObject({
name: v.exactOptional(nameSchema),
email: v.exactOptional(emailSchema),
country: v.exactOptional(billingCountrySchema),
timeZone: v.exactOptional(timeZoneSchema),
currency: v.exactOptional(currencySchema),
locale: v.exactOptional(
v.union([
billingLocaleSchema,
v.nullable(v.record(v.string(), v.unknown())),
]),
),
purchaseOrder: v.exactOptional(
v.union([stringU8Schema, v.nullable(v.record(v.string(), v.unknown()))]),
),
taxId: v.exactOptional(
v.union([stringU8Schema, v.nullable(v.record(v.string(), v.unknown()))]),
),
});
export const billingAccountCreateRequestSchema = v.strictObject({
name: nameSchema,
email: emailSchema,
country: billingCountrySchema,
timeZone: timeZoneSchema,
currency: currencySchema,
locale: v.exactOptional(
v.union([
billingLocaleSchema,
v.nullable(v.record(v.string(), v.unknown())),
]),
),
purchaseOrder: v.exactOptional(
v.union([stringU8Schema, v.nullable(v.record(v.string(), v.unknown()))]),
),
taxId: v.exactOptional(
v.union([stringU8Schema, v.nullable(v.record(v.string(), v.unknown()))]),
),
});
export const longRunningOperationSuccessSchema = v.strictObject({
operationId: uuidSchema,
done: v.boolean(),
result: v.strictObject({
response: v.record(v.string(), v.unknown()),
}),
});
export const longRunningOperationSchema = v.union([
longRunningOperationIndeterminateSchema,
longRunningOperationFailSchema,
longRunningOperationSuccessSchema,
]);
export const getOperationCommandParamsSchema = v.strictObject({
operationId: uuidSchema,
});
export const createBillingAccountCommandBodySchema =
billingAccountCreateRequestSchema;
export const getBillingAccountCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const updateBillingAccountCommandBodySchema =
billingAccountUpdateRequestSchema;
export const updateBillingAccountCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const getBillingAccountPortalCommandBodySchema =
billingAccountPortalRequestSchema;
export const getBillingAccountPortalCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const linkBillingAccountCommandBodySchema =
linkBillingAccountRequestSchema;
export const linkBillingAccountCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const listPaymentMethodsCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const createPaymentMethodCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const getPaymentMethodFromStripeCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
stripePaymentMethodId: stripeIdSchema,
});
export const getPaymentMethodCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
paymentMethodId: idSchema,
});
export const updatePaymentMethodCommandBodySchema =
updatePaymentMethodRequestSchema;
export const updatePaymentMethodCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
paymentMethodId: idSchema,
});
export const deletePaymentMethodCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
paymentMethodId: idSchema,
});
export const listBillingSubscriptionsCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const createBillingSubscriptionCommandBodySchema =
createBillingSubscriptionRequestSchema;
export const createBillingSubscriptionCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
});
export const updateBillingSubscriptionCommandBodySchema =
updateBillingSubscriptionRequestSchema;
export const updateBillingSubscriptionCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
subscriptionId: idSchema,
});
export const cancelSubscriptionCommandParamsSchema = v.strictObject({
billingAccountId: idSchema,
subscriptionId: idSchema,
});
export const updateBillingSubscriptionPromoCodeCommandBodySchema =
updateBillingSubscriptionPromoCodeRequestSchema;
export const updateBillingSubscriptionPromoCodeCommandParamsSchema =
v.strictObject({
billingAccountId: idSchema,
subscriptionId: idSchema,
});