|
1 | 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html |
2 | 2 |
|
| 3 | +exports[`const values 1`] = ` |
| 4 | +"export type StringConst = "hello"; |
| 5 | +export type NumberConst = 42; |
| 6 | +export type BooleanConst = true; |
| 7 | +export type NullConst = null; |
| 8 | +" |
| 9 | +`; |
| 10 | + |
| 11 | +exports[`const values 2`] = ` |
| 12 | +"import * as v from "valibot"; |
| 13 | +
|
| 14 | +export const stringConstSchema = v.literal("hello"); |
| 15 | +export const numberConstSchema = v.literal(42); |
| 16 | +export const booleanConstSchema = v.literal(true); |
| 17 | +export const nullConstSchema = v.null(); |
| 18 | +" |
| 19 | +`; |
| 20 | + |
| 21 | +exports[`header parameters 1`] = ` |
| 22 | +"export type UploadStatus = "pending" | "complete"; |
| 23 | +export type UploadDataCommandHeader = { |
| 24 | + "content-type": "application/json" | "text/csv" | "application/xml"; |
| 25 | + "content-length": number; |
| 26 | + "x-idempotency-key"?: string | undefined; |
| 27 | + }; |
| 28 | +export type UploadDataCommandParams = { |
| 29 | + uploadId: string; |
| 30 | + }; |
| 31 | +export type UploadDataCommandInput = UploadDataCommandParams; |
| 32 | +" |
| 33 | +`; |
| 34 | + |
| 35 | +exports[`header parameters 2`] = ` |
| 36 | +"import * as v from "valibot"; |
| 37 | +
|
| 38 | +export const uploadStatusSchema = v.picklist(["pending", "complete"]); |
| 39 | +export const uploadDataCommandParamsSchema = v.strictObject({ |
| 40 | + "uploadId": v.string() |
| 41 | + }); |
| 42 | +export const uploadDataCommandHeaderSchema = v.object({ |
| 43 | + "content-type": v.picklist(["application/json", "text/csv", "application/xml"]), |
| 44 | + "content-length": v.pipe(v.number(), v.integer()), |
| 45 | + "x-idempotency-key": v.exactOptional(v.pipe(v.string(), v.uuid())) |
| 46 | + }); |
| 47 | +" |
| 48 | +`; |
| 49 | + |
| 50 | +exports[`header parameters 3`] = ` |
| 51 | +"import { validator } from "hono/validator"; |
| 52 | +import * as v from "valibot"; |
| 53 | +import { PublicValibotHonoError } from "@block65/rest-client"; |
| 54 | +import { uploadDataCommandParamsSchema } from "./valibot.js"; |
| 55 | +
|
| 56 | +function toPublicValibotHonoError(err: unknown): never { |
| 57 | +
|
| 58 | + if (err instanceof v.ValiError) { |
| 59 | + throw PublicValibotHonoError.from(err); |
| 60 | + } |
| 61 | + throw err; |
| 62 | + |
| 63 | +} |
| 64 | +
|
| 65 | +export const uploadData = [ |
| 66 | + validator("param", (value) => { |
| 67 | + return v.parseAsync(uploadDataCommandParamsSchema, value).catch(toPublicValibotHonoError); |
| 68 | + }), |
| 69 | + ] as const; |
| 70 | +" |
| 71 | +`; |
| 72 | + |
3 | 73 | exports[`nullables 1`] = ` |
4 | 74 | "export type MySchemaLolOrNullable = "lol" | "kek" | null; |
5 | 75 | " |
6 | 76 | `; |
| 77 | + |
| 78 | +exports[`top-level type array with null 1`] = ` |
| 79 | +"export type NullableString = string | null; |
| 80 | +export type NullableStringEnum = "active" | "inactive" | null; |
| 81 | +export type NullableInteger = number | null; |
| 82 | +export type MultiType = string | number; |
| 83 | +" |
| 84 | +`; |
| 85 | + |
| 86 | +exports[`top-level type array with null 2`] = ` |
| 87 | +"import * as v from "valibot"; |
| 88 | +
|
| 89 | +export const nullableStringSchema = v.nullable(v.string()); |
| 90 | +export const nullableStringEnumSchema = v.nullable(v.picklist(["active", "inactive"])); |
| 91 | +export const nullableIntegerSchema = v.nullable(v.pipe(v.number(), v.integer())); |
| 92 | +export const multiTypeSchema = v.union([v.string(), v.number()]); |
| 93 | +" |
| 94 | +`; |
| 95 | + |
| 96 | +exports[`top-level type array with null 3`] = ` |
| 97 | +"export const nullableStringEnum = ["active", "inactive"] as const; |
| 98 | +" |
| 99 | +`; |
0 commit comments