diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts index c439f1fb25..7568e6282e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts @@ -8,7 +8,7 @@ export const vFoo = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), BigInt(0)), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), BigInt(0)), id: v.string() }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts index 40f36f8747..1cc27a779d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts @@ -74,12 +74,12 @@ export const vSimpleStringWithPattern = v.pipe(v.string(), v.maxLength(64), v.re * This is a simple enum with strings */ export const vEnumWithStrings = v.picklist([ - 'Success', - 'Warning', - 'Error', + "Success", + "Warning", + "Error", "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串' + "\"Double Quotes\"", + "Non-ascii: øæåôöØÆÅÔÖ字符串" ]); /** @@ -197,14 +197,8 @@ export const vModelWithStringError = v.object({ * This is a model with one string property */ export const vModelWithNullableString = v.object({ - nullableProp: v.optional(v.union([ - v.string(), - v.null() - ])), - nullableRequiredProp: v.union([ - v.string(), - v.null() - ]) + nullableProp: v.optional(v.union([v.string(), v.null()])), + nullableRequiredProp: v.union([v.string(), v.null()]) }); /** @@ -212,18 +206,18 @@ export const vModelWithNullableString = v.object({ */ export const vModelWithEnum = v.object({ test: v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])), statusCode: v.optional(v.picklist([ - '100', - '200 FOO', - '300 FOO_BAR', - '400 foo-bar', - '500 foo.bar', - '600 foo&bar' + "100", + "200 FOO", + "300 FOO_BAR", + "400 foo-bar", + "500 foo.bar", + "600 foo&bar" ])), bool: v.optional(v.unknown()) }); @@ -240,15 +234,15 @@ export const vModelWithEnumFromDescription = v.object({ */ export const vModelWithNestedEnums = v.object({ dictionaryWithEnum: v.optional(v.record(v.string(), v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]))), dictionaryWithEnumFromDescription: v.optional(v.record(v.string(), v.pipe(v.number(), v.integer()))), arrayWithEnum: v.optional(v.array(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]))), arrayWithDescription: v.optional(v.array(v.pipe(v.number(), v.integer()))) }); @@ -273,9 +267,7 @@ export const vModelWithDictionary = v.object({ * This is a model with one property containing a circular reference */ export const vModelWithCircularReference: v.GenericSchema = v.object({ - prop: v.optional(v.lazy(() => { - return vModelWithCircularReference; - })) + prop: v.optional(v.lazy(() => vModelWithCircularReference)) }); /** @@ -341,13 +333,10 @@ export const vModelWithDuplicateImports = v.object({ /** * This is a model that extends another model */ -export const vModelThatExtends = v.intersect([ - vModelWithString, - v.object({ +export const vModelThatExtends = v.intersect([vModelWithString, v.object({ propExtendsA: v.optional(v.string()), propExtendsB: v.optional(vModelWithString) - }) -]); + })]); /** * This is a model that extends another model @@ -553,19 +542,17 @@ export const vCallWithDefaultParametersData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.object({ - parameterString: v.optional(v.string(), 'Hello World!'), + parameterString: v.optional(v.string(), "Hello World!"), parameterNumber: v.optional(v.number(), 123), parameterBoolean: v.optional(v.boolean(), true), parameterEnum: v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]), parameterModel: v.optional(v.object({ prop: v.optional(v.string()) - }), { - prop: 'Hello World!' - }) + }), { prop: "Hello World!" }) }) }); @@ -573,13 +560,13 @@ export const vCallWithDefaultOptionalParametersData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.optional(v.object({ - parameterString: v.optional(v.string(), 'Hello World!'), + parameterString: v.optional(v.string(), "Hello World!"), parameterNumber: v.optional(v.number(), 123), parameterBoolean: v.optional(v.boolean(), true), parameterEnum: v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ])) })) }); @@ -588,20 +575,14 @@ export const vCallToTestOrderOfParamsData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.object({ - parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), - parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ''), + parameterOptionalStringWithDefault: v.optional(v.string(), "Hello World!"), + parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ""), parameterOptionalStringWithNoDefault: v.optional(v.string()), - parameterStringWithDefault: v.optional(v.string(), 'Hello World!'), - parameterStringWithEmptyDefault: v.optional(v.string(), ''), + parameterStringWithDefault: v.optional(v.string(), "Hello World!"), + parameterStringWithEmptyDefault: v.optional(v.string(), ""), parameterStringWithNoDefault: v.string(), - parameterStringNullableWithNoDefault: v.optional(v.union([ - v.string(), - v.null() - ])), - parameterStringNullableWithDefault: v.optional(v.union([ - v.string(), - v.null() - ]), null) + parameterStringNullableWithNoDefault: v.optional(v.union([v.string(), v.null()])), + parameterStringNullableWithDefault: v.optional(v.union([v.string(), v.null()]), null) }) }); @@ -641,10 +622,7 @@ export const vCallWithResponseAndNoContentResponseData = v.object({ query: v.optional(v.never()) }); -export const vCallWithResponseAndNoContentResponseResponse = v.union([ - v.number(), - v.unknown() -]); +export const vCallWithResponseAndNoContentResponseResponse = v.union([v.number(), v.unknown()]); export const vDummyAData = v.object({ body: v.optional(v.never()), @@ -711,18 +689,18 @@ export const vCollectionFormatData = v.object({ export const vTypesData = v.object({ body: v.optional(v.never()), path: v.optional(v.object({ - id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))) + id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"))) })), query: v.object({ parameterNumber: v.optional(v.number(), 123), - parameterString: v.optional(v.string(), 'default'), + parameterString: v.optional(v.string(), "default"), parameterBoolean: v.optional(v.boolean(), true), parameterArray: v.array(v.string()), parameterDictionary: v.record(v.string(), v.unknown()), parameterEnum: v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]) }) }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts index cbaae04e1c..a70c8c9f49 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts @@ -2,17 +2,8 @@ import * as v from 'valibot'; -export const vFoo = v.nullable(v.picklist([ - 'foo', - 'bar' -])); +export const vFoo = v.nullable(v.picklist(["foo", "bar"])); -export const vBar = v.picklist([ - 'foo', - 'bar' -]); +export const vBar = v.picklist(["foo", "bar"]); -export const vBaz = v.picklist([ - 'foo', - 'bar' -]); +export const vBaz = v.picklist(["foo", "bar"]); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts index c439f1fb25..7568e6282e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts @@ -8,7 +8,7 @@ export const vFoo = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), BigInt(0)), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), BigInt(0)), id: v.string() }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts index cd348f8548..b73822b3e5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts @@ -81,28 +81,25 @@ export const vSimpleFile = v.string(); /** * This is a simple string */ -export const vSimpleStringWithPattern = v.union([ - v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), - v.null() -]); +export const vSimpleStringWithPattern = v.union([v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.null()]); /** * This is a simple enum with strings */ export const vEnumWithStrings = v.picklist([ - 'Success', - 'Warning', - 'Error', + "Success", + "Warning", + "Error", "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串' + "\"Double Quotes\"", + "Non-ascii: øæåôöØÆÅÔÖ字符串" ]); export const vEnumWithReplacedCharacters = v.picklist([ "'Single Quote'", - '"Double Quotes"', - 'øæåôöØÆÅÔÖ字符串', - '' + "\"Double Quotes\"", + "øæåôöØÆÅÔÖ字符串", + "" ]); /** @@ -135,7 +132,7 @@ export const vArrayWithBooleans = v.array(v.boolean()); /** * This is a simple array with strings */ -export const vArrayWithStrings = v.optional(v.array(v.string()), ['test']); +export const vArrayWithStrings = v.optional(v.array(v.string()), ["test"]); /** * This is a simple array with properties @@ -246,27 +243,15 @@ export const vModelFromZendesk = v.string(); * This is a model with one string property */ export const vModelWithNullableString = v.object({ - nullableProp1: v.optional(v.union([ - v.string(), - v.null() - ])), - nullableRequiredProp1: v.union([ - v.string(), - v.null() - ]), - nullableProp2: v.optional(v.union([ - v.string(), - v.null() - ])), - nullableRequiredProp2: v.union([ - v.string(), - v.null() - ]), + nullableProp1: v.optional(v.union([v.string(), v.null()])), + nullableRequiredProp1: v.union([v.string(), v.null()]), + nullableProp2: v.optional(v.union([v.string(), v.null()])), + nullableRequiredProp2: v.union([v.string(), v.null()]), 'foo_bar-enum': v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])) }); @@ -275,18 +260,18 @@ export const vModelWithNullableString = v.object({ */ export const vModelWithEnum = v.object({ 'foo_bar-enum': v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])), statusCode: v.optional(v.picklist([ - '100', - '200 FOO', - '300 FOO_BAR', - '400 foo-bar', - '500 foo.bar', - '600 foo&bar' + "100", + "200 FOO", + "300 FOO_BAR", + "400 foo-bar", + "500 foo.bar", + "600 foo&bar" ])), bool: v.optional(v.unknown()) }); @@ -295,9 +280,7 @@ export const vModelWithEnum = v.object({ * This is a model with one enum with escaped name */ export const vModelWithEnumWithHyphen = v.object({ - 'foo-bar-baz-qux': v.optional(v.picklist([ - '3.0' - ])) + 'foo-bar-baz-qux': v.optional(v.picklist(["3.0"])) }); /** @@ -312,22 +295,22 @@ export const vModelWithEnumFromDescription = v.object({ */ export const vModelWithNestedEnums = v.object({ dictionaryWithEnum: v.optional(v.record(v.string(), v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]))), dictionaryWithEnumFromDescription: v.optional(v.record(v.string(), v.pipe(v.number(), v.integer()))), arrayWithEnum: v.optional(v.array(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]))), arrayWithDescription: v.optional(v.array(v.pipe(v.number(), v.integer()))), 'foo_bar-enum': v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])) }); @@ -360,9 +343,7 @@ export const vDeprecatedModel = v.object({ * This is a model with one property containing a circular reference */ export const vModelWithCircularReference: v.GenericSchema = v.object({ - prop: v.optional(v.lazy(() => { - return vModelWithCircularReference; - })) + prop: v.optional(v.lazy(() => vModelWithCircularReference)) }); /** @@ -409,20 +390,11 @@ export const vModelSquare = v.object({ /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export const vCompositionWithOneOfDiscriminator = v.union([ - v.intersect([ - v.object({ +export const vCompositionWithOneOfDiscriminator = v.union([v.intersect([v.object({ kind: v.literal("circle") - }), - vModelCircle - ]), - v.intersect([ - v.object({ + }), vModelCircle]), v.intersect([v.object({ kind: v.literal("square") - }), - vModelSquare - ]) -]); + }), vModelSquare])]); /** * This is a model with one property with a 'any of' relationship @@ -453,35 +425,18 @@ export const vCompositionWithAnyOfAnonymous = v.object({ * This is a model with nested 'any of' property with a type null */ export const vCompositionWithNestedAnyAndTypeNull = v.object({ - propA: v.optional(v.union([ - v.array(v.union([ - vModelWithDictionary, - v.null() - ])), - v.array(v.union([ - vModelWithArray, - v.null() - ])) - ])) + propA: v.optional(v.union([v.array(v.union([vModelWithDictionary, v.null()])), v.array(v.union([vModelWithArray, v.null()]))])) }); -export const v3eNum1Период = v.picklist([ - 'Bird', - 'Dog' -]); +export const v3eNum1Период = v.picklist(["Bird", "Dog"]); -export const vConstValue = v.picklist([ - 'ConstValue' -]); +export const vConstValue = v.picklist(["ConstValue"]); /** * This is a model with one property with a 'any of' relationship where the options are not $ref */ export const vCompositionWithNestedAnyOfAndNull = v.object({ - propA: v.optional(v.union([ - v.array(v.unknown()), - v.null() - ])) + propA: v.optional(v.union([v.array(v.unknown()), v.null()])) }); /** @@ -503,47 +458,35 @@ export const vCompositionWithOneOfAndNullable = v.object({ * This is a model that contains a simple dictionary within composition */ export const vCompositionWithOneOfAndSimpleDictionary = v.object({ - propA: v.optional(v.union([ - v.boolean(), - v.record(v.string(), v.number()) - ])) + propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.number())])) }); /** * This is a model that contains a dictionary of simple arrays within composition */ export const vCompositionWithOneOfAndSimpleArrayDictionary = v.object({ - propA: v.optional(v.union([ - v.boolean(), - v.record(v.string(), v.array(v.boolean())) - ])) + propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.boolean()))])) }); /** * This is a model that contains a dictionary of complex arrays (composited) within composition */ export const vCompositionWithOneOfAndComplexArrayDictionary = v.object({ - propA: v.optional(v.union([ - v.boolean(), - v.record(v.string(), v.array(v.unknown())) - ])) + propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.unknown()))])) }); /** * This is a model with one property with a 'all of' relationship */ export const vCompositionWithAllOfAndNullable = v.object({ - propA: v.optional(v.union([ - v.intersect([ + propA: v.optional(v.union([v.intersect([ v.object({ boolean: v.optional(v.boolean()) }), vModelWithEnum, vModelWithArray, vModelWithDictionary - ]), - v.null() - ])) + ]), v.null()])) }); /** @@ -572,14 +515,11 @@ export const vCompositionBaseModel = v.object({ /** * This is a model that extends the base model */ -export const vCompositionExtendedModel = v.intersect([ - vCompositionBaseModel, - v.object({ +export const vCompositionExtendedModel = v.intersect([vCompositionBaseModel, v.object({ age: v.number(), firstName: v.string(), lastname: v.string() - }) -]); + })]); /** * This is a model with one nested property @@ -587,10 +527,7 @@ export const vCompositionExtendedModel = v.intersect([ export const vModelWithProperties = v.object({ required: v.string(), requiredAndReadOnly: v.pipe(v.string(), v.readonly()), - requiredAndNullable: v.union([ - v.string(), - v.null() - ]), + requiredAndNullable: v.union([v.string(), v.null()]), string: v.optional(v.string()), number: v.optional(v.number()), boolean: v.optional(v.boolean()), @@ -613,20 +550,11 @@ export const vModelWithReference = v.object({ * This is a model with one nested property */ export const vModelWithNestedProperties = v.object({ - first: v.pipe(v.union([ - v.pipe(v.object({ - second: v.pipe(v.union([ - v.pipe(v.object({ - third: v.pipe(v.union([ - v.pipe(v.string(), v.readonly()), - v.null() - ]), v.readonly()) - }), v.readonly()), - v.null() - ]), v.readonly()) - }), v.readonly()), - v.null() - ]), v.readonly()) + first: v.pipe(v.union([v.pipe(v.object({ + second: v.pipe(v.union([v.pipe(v.object({ + third: v.pipe(v.union([v.pipe(v.string(), v.readonly()), v.null()]), v.readonly()) + }), v.readonly()), v.null()]), v.readonly()) + }), v.readonly()), v.null()]), v.readonly()) }); /** @@ -657,13 +585,10 @@ export const vModelWithDuplicateImports = v.object({ /** * This is a model that extends another model */ -export const vModelThatExtends = v.intersect([ - vModelWithString, - v.object({ +export const vModelThatExtends = v.intersect([vModelWithString, v.object({ propExtendsA: v.optional(v.string()), propExtendsB: v.optional(vModelWithString) - }) -]); + })]); /** * This is a model that extends another model @@ -705,8 +630,8 @@ export const vDefault = v.object({ }); export const vPageable = v.object({ - page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(0)), 0), - size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(1))), + page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"), v.minValue(0)), 0), + size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"), v.minValue(1))), sort: v.optional(v.array(v.string())) }); @@ -726,14 +651,10 @@ export const vFreeFormObjectWithAdditionalPropertiesEqTrue = v.record(v.string() export const vFreeFormObjectWithAdditionalPropertiesEqEmptyObject = v.record(v.string(), v.unknown()); export const vModelWithConst = v.object({ - String: v.optional(v.picklist([ - 'String' - ])), + String: v.optional(v.picklist(["String"])), number: v.optional(v.unknown()), null: v.optional(v.unknown()), - withType: v.optional(v.picklist([ - 'Some string' - ])) + withType: v.optional(v.picklist(["Some string"])) }); /** @@ -744,21 +665,15 @@ export const vModelWithAdditionalPropertiesEqTrue = v.objectWithRest({ }, v.unknown()); export const vNestedAnyOfArraysNullable = v.object({ - nullableArray: v.optional(v.union([ - v.array(v.unknown()), - v.null() - ])) + nullableArray: v.optional(v.union([v.array(v.unknown()), v.null()])) }); /** * An object that can be null */ -export const vNullableObject = v.optional(v.union([ - v.object({ +export const vNullableObject = v.optional(v.union([v.object({ foo: v.optional(v.string()) - }), - v.null() -]), null); + }), v.null()]), null); /** * Some % character @@ -771,46 +686,27 @@ export const vModelWithNullableObject = v.object({ export const vModelWithOneOfEnum = v.union([ v.object({ - foo: v.picklist([ - 'Bar' - ]) + foo: v.picklist(["Bar"]) }), v.object({ - foo: v.picklist([ - 'Baz' - ]) + foo: v.picklist(["Baz"]) }), v.object({ - foo: v.picklist([ - 'Qux' - ]) + foo: v.picklist(["Qux"]) }), v.object({ content: v.pipe(v.string(), v.isoTimestamp()), - foo: v.picklist([ - 'Quux' - ]) + foo: v.picklist(["Quux"]) }), v.object({ - content: v.tuple([ - v.pipe(v.string(), v.isoTimestamp()), - v.pipe(v.string(), v.isoTimestamp()) - ]), - foo: v.picklist([ - 'Corge' - ]) + content: v.tuple([v.pipe(v.string(), v.isoTimestamp()), v.pipe(v.string(), v.isoTimestamp())]), + foo: v.picklist(["Corge"]) }) ]); -export const vModelWithNestedArrayEnumsDataFoo = v.picklist([ - 'foo', - 'bar' -]); +export const vModelWithNestedArrayEnumsDataFoo = v.picklist(["foo", "bar"]); -export const vModelWithNestedArrayEnumsDataBar = v.picklist([ - 'baz', - 'qux' -]); +export const vModelWithNestedArrayEnumsDataBar = v.picklist(["baz", "qux"]); export const vModelWithNestedArrayEnumsData = v.object({ foo: v.optional(v.array(vModelWithNestedArrayEnumsDataFoo)), @@ -840,24 +736,12 @@ export const vModelWithArrayReadOnlyAndWriteOnly = v.object({ propWithNumber: v.optional(v.array(v.number())) }); -export const vModelWithConstantSizeArray = v.tuple([ - v.number(), - v.number() -]); +export const vModelWithConstantSizeArray = v.tuple([v.number(), v.number()]); export const vModelWithAnyOfConstantSizeArray = v.tuple([ - v.union([ - v.number(), - v.string() - ]), - v.union([ - v.number(), - v.string() - ]), - v.union([ - v.number(), - v.string() - ]) + v.union([v.number(), v.string()]), + v.union([v.number(), v.string()]), + v.union([v.number(), v.string()]) ]); export const vModelWithPrefixItemsConstantSizeArray = v.array(v.unknown()); @@ -880,16 +764,7 @@ export const vModelWithAnyOfConstantSizeArrayNullable = v.tuple([ ]) ]); -export const vModelWithAnyOfConstantSizeArrayAndIntersect = v.tuple([ - v.intersect([ - v.number(), - v.string() - ]), - v.intersect([ - v.number(), - v.string() - ]) -]); +export const vModelWithAnyOfConstantSizeArrayAndIntersect = v.tuple([v.intersect([v.number(), v.string()]), v.intersect([v.number(), v.string()])]); export const vModelWithNumericEnumUnion = v.object({ value: v.optional(v.unknown()) @@ -932,16 +807,7 @@ export const vDeleteFooData2 = v.string(); */ export const vImport = v.string(); -export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = v.tuple([ - v.union([ - v.number(), - vImport - ]), - v.union([ - v.number(), - vImport - ]) -]); +export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); export const vSchemaWithFormRestrictedKeys = v.object({ description: v.optional(v.string()), @@ -984,12 +850,9 @@ export const vAdditionalPropertiesUnknownIssue = v.object({}); export const vAdditionalPropertiesUnknownIssue2 = v.object({}); -export const vAdditionalPropertiesUnknownIssue3 = v.intersect([ - v.string(), - v.object({ +export const vAdditionalPropertiesUnknownIssue3 = v.intersect([v.string(), v.object({ entries: v.object({}) - }) -]); + })]); export const vAdditionalPropertiesIntegerIssue = v.objectWithRest({ value: v.pipe(v.number(), v.integer()) @@ -997,36 +860,18 @@ export const vAdditionalPropertiesIntegerIssue = v.objectWithRest({ export const vGenericSchemaDuplicateIssue1SystemBoolean = v.strictObject({ item: v.optional(v.boolean()), - error: v.optional(v.union([ - v.string(), - v.null() - ])), + error: v.optional(v.union([v.string(), v.null()])), hasError: v.optional(v.pipe(v.boolean(), v.readonly())), data: v.optional(v.strictObject({})) }); export const vGenericSchemaDuplicateIssue1SystemString = v.strictObject({ - item: v.optional(v.union([ - v.string(), - v.null() - ])), - error: v.optional(v.union([ - v.string(), - v.null() - ])), + item: v.optional(v.union([v.string(), v.null()])), + error: v.optional(v.union([v.string(), v.null()])), hasError: v.optional(v.pipe(v.boolean(), v.readonly())) }); -export const vOneOfAllOfIssue = v.union([ - v.intersect([ - v.union([ - vConstValue, - vGenericSchemaDuplicateIssue1SystemBoolean - ]), - v3eNum1Период - ]), - vGenericSchemaDuplicateIssue1SystemString -]); +export const vOneOfAllOfIssue = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); export const vExternalSharedExternalSharedModel = v.object({ id: v.string(), @@ -1042,10 +887,7 @@ export const vExternalRefB = vExternalSharedExternalSharedModel; */ export const vModelWithPropertiesWritable = v.object({ required: v.string(), - requiredAndNullable: v.union([ - v.string(), - v.null() - ]), + requiredAndNullable: v.union([v.string(), v.null()]), string: v.optional(v.string()), number: v.optional(v.number()), boolean: v.optional(v.boolean()), @@ -1093,48 +935,21 @@ export const vModelWithArrayReadOnlyAndWriteOnlyWritable = v.object({ propWithNumber: v.optional(v.array(v.number())) }); -export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = v.tuple([ - v.union([ - v.number(), - vImport - ]), - v.union([ - v.number(), - vImport - ]) -]); +export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); export const vAdditionalPropertiesUnknownIssueWritable = v.object({}); -export const vOneOfAllOfIssueWritable = v.union([ - v.intersect([ - v.union([ - vConstValue, - vGenericSchemaDuplicateIssue1SystemBoolean - ]), - v3eNum1Период - ]), - vGenericSchemaDuplicateIssue1SystemString -]); +export const vOneOfAllOfIssueWritable = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); export const vGenericSchemaDuplicateIssue1SystemBooleanWritable = v.strictObject({ item: v.optional(v.boolean()), - error: v.optional(v.union([ - v.string(), - v.null() - ])), + error: v.optional(v.union([v.string(), v.null()])), data: v.optional(v.strictObject({})) }); export const vGenericSchemaDuplicateIssue1SystemStringWritable = v.strictObject({ - item: v.optional(v.union([ - v.string(), - v.null() - ])), - error: v.optional(v.union([ - v.string(), - v.null() - ])) + item: v.optional(v.union([v.string(), v.null()])), + error: v.optional(v.union([v.string(), v.null()])) }); /** @@ -1142,37 +957,19 @@ export const vGenericSchemaDuplicateIssue1SystemStringWritable = v.strictObject( */ export const vSimpleParameter = v.string(); -export const vCompositionWithOneOfAndProperties = v.intersect([ - v.union([ - v.strictObject({ +export const vCompositionWithOneOfAndProperties = v.intersect([v.union([v.strictObject({ foo: vSimpleParameter - }), - v.strictObject({ + }), v.strictObject({ bar: vNonAsciiStringæøåÆøÅöôêÊ字符串 - }) - ]), - v.object({ - baz: v.union([ - v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), - v.null() - ]), - qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0)) - }) -]); + })]), v.object({ + baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint16 to be >= 0"), v.maxValue(65535, "Invalid value: Expected uint16 to be <= 2^16-1"), v.minValue(0)), v.null()]), + qux: v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint8 to be >= 0"), v.maxValue(255, "Invalid value: Expected uint8 to be <= 2^8-1"), v.minValue(0)) + })]); -export const vModelWithOneOfAndProperties = v.intersect([ - v.union([ - vSimpleParameter, - vNonAsciiStringæøåÆøÅöôêÊ字符串 - ]), - v.object({ - baz: v.union([ - v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), - v.null() - ]), - qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0)) - }) -]); +export const vModelWithOneOfAndProperties = v.intersect([v.union([vSimpleParameter, vNonAsciiStringæøåÆøÅöôêÊ字符串]), v.object({ + baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint16 to be >= 0"), v.maxValue(65535, "Invalid value: Expected uint16 to be <= 2^16-1"), v.minValue(0)), v.null()]), + qux: v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint8 to be >= 0"), v.maxValue(255, "Invalid value: Expected uint8 to be <= 2^8-1"), v.minValue(0)) + })]); /** * Parameter with illegal characters @@ -1196,18 +993,12 @@ export const vPatchApiVbyApiVersionNoTagData = v.object({ }); export const vImportData = v.object({ - body: v.union([ - vModelWithReadOnlyAndWriteOnlyWritable, - vModelWithArrayReadOnlyAndWriteOnlyWritable - ]), + body: v.union([vModelWithReadOnlyAndWriteOnlyWritable, vModelWithArrayReadOnlyAndWriteOnlyWritable]), path: v.optional(v.never()), query: v.optional(v.never()) }); -export const vImportResponse = v.union([ - vModelFromZendesk, - vModelWithReadOnlyAndWriteOnly -]); +export const vImportResponse = v.union([vModelFromZendesk, vModelWithReadOnlyAndWriteOnly]); export const vFooWowData = v.object({ body: v.optional(v.never()), @@ -1311,70 +1102,40 @@ export const vDeprecatedCallData = v.object({ path: v.optional(v.never()), query: v.optional(v.never()), headers: v.object({ - parameter: v.union([ - vDeprecatedModel, - v.null() - ]) + parameter: v.union([vDeprecatedModel, v.null()]) }) }); export const vCallWithParametersData = v.object({ - body: v.union([ - v.record(v.string(), v.unknown()), - v.null() - ]), + body: v.union([v.record(v.string(), v.unknown()), v.null()]), path: v.object({ - parameterPath: v.union([ - v.string(), - v.null() - ]), - 'api-version': v.union([ - v.string(), - v.null() - ]) + parameterPath: v.union([v.string(), v.null()]), + 'api-version': v.union([v.string(), v.null()]) }), query: v.object({ foo_ref_enum: v.optional(vModelWithNestedArrayEnumsDataFoo), foo_all_of_enum: vModelWithNestedArrayEnumsDataFoo, - cursor: v.union([ - v.string(), - v.null() - ]) + cursor: v.union([v.string(), v.null()]) }), headers: v.object({ - parameterHeader: v.union([ - v.string(), - v.null() - ]) + parameterHeader: v.union([v.string(), v.null()]) }) }); export const vCallWithWeirdParameterNamesData = v.object({ - body: v.union([ - vModelWithString, - v.null() - ]), + body: v.union([vModelWithString, v.null()]), path: v.object({ 'parameter.path.1': v.optional(v.string()), 'parameter-path-2': v.optional(v.string()), 'PARAMETER-PATH-3': v.optional(v.string()), - 'api-version': v.union([ - v.string(), - v.null() - ]) + 'api-version': v.union([v.string(), v.null()]) }), query: v.object({ default: v.optional(v.string()), - 'parameter-query': v.union([ - v.string(), - v.null() - ]) + 'parameter-query': v.union([v.string(), v.null()]) }), headers: v.object({ - 'parameter.header': v.union([ - v.string(), - v.null() - ]) + 'parameter.header': v.union([v.string(), v.null()]) }) }); @@ -1388,10 +1149,7 @@ export const vGetCallWithOptionalParamData = v.object({ export const vPostCallWithOptionalParamData = v.object({ body: v.optional(v.object({ - offset: v.optional(v.union([ - v.number(), - v.null() - ])) + offset: v.optional(v.union([v.number(), v.null()])) })), path: v.optional(v.never()), query: v.object({ @@ -1399,10 +1157,7 @@ export const vPostCallWithOptionalParamData = v.object({ }) }); -export const vPostCallWithOptionalParamResponse = v.union([ - v.number(), - v.void() -]); +export const vPostCallWithOptionalParamResponse = v.union([v.number(), v.void()]); export const vPostApiVbyApiVersionRequestBodyData = v.object({ body: v.optional(vSimpleRequestBody), @@ -1424,27 +1179,15 @@ export const vCallWithDefaultParametersData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.optional(v.object({ - parameterString: v.optional(v.union([ - v.optional(v.string(), 'Hello World!'), - v.null() - ]), 'Hello World!'), - parameterNumber: v.optional(v.union([ - v.optional(v.number(), 123), - v.null() - ]), 123), - parameterBoolean: v.optional(v.union([ - v.optional(v.boolean(), true), - v.null() - ]), true), + parameterString: v.optional(v.union([v.optional(v.string(), "Hello World!"), v.null()]), "Hello World!"), + parameterNumber: v.optional(v.union([v.optional(v.number(), 123), v.null()]), 123), + parameterBoolean: v.optional(v.union([v.optional(v.boolean(), true), v.null()]), true), parameterEnum: v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ])), - parameterModel: v.optional(v.union([ - vModelWithString, - v.null() - ])) + parameterModel: v.optional(v.union([vModelWithString, v.null()])) })) }); @@ -1452,13 +1195,13 @@ export const vCallWithDefaultOptionalParametersData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.optional(v.object({ - parameterString: v.optional(v.string(), 'Hello World!'), + parameterString: v.optional(v.string(), "Hello World!"), parameterNumber: v.optional(v.number(), 123), parameterBoolean: v.optional(v.boolean(), true), parameterEnum: v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ])), parameterModel: v.optional(vModelWithString) })) @@ -1468,20 +1211,14 @@ export const vCallToTestOrderOfParamsData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.object({ - parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), - parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ''), + parameterOptionalStringWithDefault: v.optional(v.string(), "Hello World!"), + parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ""), parameterOptionalStringWithNoDefault: v.optional(v.string()), - parameterStringWithDefault: v.optional(v.string(), 'Hello World!'), - parameterStringWithEmptyDefault: v.optional(v.string(), ''), + parameterStringWithDefault: v.optional(v.string(), "Hello World!"), + parameterStringWithEmptyDefault: v.optional(v.string(), ""), parameterStringWithNoDefault: v.string(), - parameterStringNullableWithNoDefault: v.optional(v.union([ - v.string(), - v.null() - ])), - parameterStringNullableWithDefault: v.optional(v.union([ - v.string(), - v.null() - ]), null) + parameterStringNullableWithNoDefault: v.optional(v.union([v.string(), v.null()])), + parameterStringNullableWithDefault: v.optional(v.union([v.string(), v.null()]), null) }) }); @@ -1526,10 +1263,7 @@ export const vCallWithResponseAndNoContentResponseData = v.object({ query: v.optional(v.never()) }); -export const vCallWithResponseAndNoContentResponseResponse = v.union([ - v.number(), - v.void() -]); +export const vCallWithResponseAndNoContentResponseResponse = v.union([v.number(), v.void()]); export const vDummyAData = v.object({ body: v.optional(v.never()), @@ -1564,13 +1298,7 @@ export const vCallWithDuplicateResponsesData = v.object({ query: v.optional(v.never()) }); -export const vCallWithDuplicateResponsesResponse = v.union([ - v.intersect([ - vModelWithBoolean, - vModelWithInteger - ]), - vModelWithString -]); +export const vCallWithDuplicateResponsesResponse = v.union([v.intersect([vModelWithBoolean, vModelWithInteger]), vModelWithString]); export const vCallWithResponsesData = v.object({ body: v.optional(v.never()), @@ -1592,60 +1320,30 @@ export const vCollectionFormatData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.object({ - parameterArrayCSV: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArraySSV: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArrayTSV: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArrayPipes: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArrayMulti: v.union([ - v.array(v.string()), - v.null() - ]) + parameterArrayCSV: v.union([v.array(v.string()), v.null()]), + parameterArraySSV: v.union([v.array(v.string()), v.null()]), + parameterArrayTSV: v.union([v.array(v.string()), v.null()]), + parameterArrayPipes: v.union([v.array(v.string()), v.null()]), + parameterArrayMulti: v.union([v.array(v.string()), v.null()]) }) }); export const vTypesData = v.object({ body: v.optional(v.never()), path: v.optional(v.object({ - id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))) + id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"))) })), query: v.object({ parameterNumber: v.optional(v.number(), 123), - parameterString: v.optional(v.union([ - v.optional(v.string(), 'default'), - v.null() - ]), 'default'), - parameterBoolean: v.optional(v.union([ - v.optional(v.boolean(), true), - v.null() - ]), true), - parameterObject: v.optional(v.union([ - v.record(v.string(), v.unknown()), - v.null() - ]), null), - parameterArray: v.union([ - v.array(v.string()), - v.null() - ]), - parameterDictionary: v.union([ - v.record(v.string(), v.unknown()), - v.null() - ]), + parameterString: v.optional(v.union([v.optional(v.string(), "default"), v.null()]), "default"), + parameterBoolean: v.optional(v.union([v.optional(v.boolean(), true), v.null()]), true), + parameterObject: v.optional(v.union([v.record(v.string(), v.unknown()), v.null()]), null), + parameterArray: v.union([v.array(v.string()), v.null()]), + parameterDictionary: v.union([v.record(v.string(), v.unknown()), v.null()]), parameterEnum: v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]) }) }); @@ -1660,10 +1358,7 @@ export const vTypesResponse = v.union([ export const vUploadFileData = v.object({ body: v.string(), path: v.object({ - 'api-version': v.union([ - v.string(), - v.null() - ]) + 'api-version': v.union([v.string(), v.null()]) }), query: v.optional(v.never()) }); @@ -1724,10 +1419,7 @@ export const vMultipartResponseResponse = v.object({ export const vMultipartRequestData = v.object({ body: v.optional(v.object({ content: v.optional(v.string()), - data: v.optional(v.union([ - vModelWithString, - v.null() - ])) + data: v.optional(v.union([vModelWithString, v.null()])) })), path: v.optional(v.never()), query: v.optional(v.never()) @@ -1735,28 +1427,16 @@ export const vMultipartRequestData = v.object({ export const vComplexParamsData = v.object({ body: v.optional(v.object({ - key: v.pipe(v.union([ - v.pipe(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.readonly()), - v.null() - ]), v.readonly()), - name: v.union([ - v.pipe(v.string(), v.maxLength(255)), - v.null() - ]), + key: v.pipe(v.union([v.pipe(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.readonly()), v.null()]), v.readonly()), + name: v.union([v.pipe(v.string(), v.maxLength(255)), v.null()]), enabled: v.optional(v.boolean(), true), type: v.picklist([ - 'Monkey', - 'Horse', - 'Bird' + "Monkey", + "Horse", + "Bird" ]), - listOfModels: v.optional(v.union([ - v.array(vModelWithString), - v.null() - ])), - listOfStrings: v.optional(v.union([ - v.array(v.string()), - v.null() - ])), + listOfModels: v.optional(v.union([v.array(vModelWithString), v.null()])), + listOfStrings: v.optional(v.union([v.array(v.string()), v.null()])), parameters: v.union([ vModelWithString, vModelWithEnum, @@ -1764,15 +1444,12 @@ export const vComplexParamsData = v.object({ vModelWithDictionary ]), user: v.optional(v.pipe(v.object({ - id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')), v.readonly())), - name: v.optional(v.pipe(v.union([ - v.pipe(v.string(), v.readonly()), - v.null() - ]), v.readonly())) + id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1")), v.readonly())), + name: v.optional(v.pipe(v.union([v.pipe(v.string(), v.readonly()), v.null()]), v.readonly())) }), v.readonly())) })), path: v.object({ - id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')), + id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1")), 'api-version': v.string() }), query: v.optional(v.never()) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts index b327f2c83f..c8ad540051 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts @@ -2,21 +2,14 @@ import * as v from 'valibot'; -export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), 'baz'); +export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), "baz"); -export const vFoo: v.GenericSchema = v.optional(v.union([ - v.object({ +export const vFoo: v.GenericSchema = v.optional(v.union([v.object({ foo: v.optional(v.pipe(v.string(), v.regex(/^\d{3}-\d{2}-\d{4}$/))), - bar: v.optional(v.lazy(() => { - return vBar; - })), - baz: v.optional(v.array(v.lazy(() => { - return vFoo; - }))), + bar: v.optional(v.lazy(() => vBar)), + baz: v.optional(v.array(v.lazy(() => vFoo))), qux: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0)), 0) - }), - v.null() -]), null); + }), v.null()]), null); export const vBar = v.object({ foo: v.optional(vFoo) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts index cbaae04e1c..a70c8c9f49 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts @@ -2,17 +2,8 @@ import * as v from 'valibot'; -export const vFoo = v.nullable(v.picklist([ - 'foo', - 'bar' -])); +export const vFoo = v.nullable(v.picklist(["foo", "bar"])); -export const vBar = v.picklist([ - 'foo', - 'bar' -]); +export const vBar = v.picklist(["foo", "bar"]); -export const vBaz = v.picklist([ - 'foo', - 'bar' -]); +export const vBaz = v.picklist(["foo", "bar"]); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts index 00e476013d..3c284eb012 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/integer-formats/valibot.gen.ts @@ -4,47 +4,47 @@ import * as v from 'valibot'; export const vIntegerFormats = v.object({ numberNoFormat: v.optional(v.number()), - numberInt8: v.optional(v.pipe(v.number(), v.minValue(-128, 'Invalid value: Expected int8 to be >= -2^7'), v.maxValue(127, 'Invalid value: Expected int8 to be <= 2^7-1'))), - numberInt16: v.optional(v.pipe(v.number(), v.minValue(-32768, 'Invalid value: Expected int16 to be >= -2^15'), v.maxValue(32767, 'Invalid value: Expected int16 to be <= 2^15-1'))), - numberInt32: v.optional(v.pipe(v.number(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))), + numberInt8: v.optional(v.pipe(v.number(), v.minValue(-128, "Invalid value: Expected int8 to be >= -2^7"), v.maxValue(127, "Invalid value: Expected int8 to be <= 2^7-1"))), + numberInt16: v.optional(v.pipe(v.number(), v.minValue(-32768, "Invalid value: Expected int16 to be >= -2^15"), v.maxValue(32767, "Invalid value: Expected int16 to be <= 2^15-1"))), + numberInt32: v.optional(v.pipe(v.number(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"))), numberInt64: v.optional(v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), - numberUint8: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'))), - numberUint16: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'))), - numberUint32: v.optional(v.pipe(v.number(), v.minValue(0, 'Invalid value: Expected uint32 to be >= 0'), v.maxValue(4294967295, 'Invalid value: Expected uint32 to be <= 2^32-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), + numberUint8: v.optional(v.pipe(v.number(), v.minValue(0, "Invalid value: Expected uint8 to be >= 0"), v.maxValue(255, "Invalid value: Expected uint8 to be <= 2^8-1"))), + numberUint16: v.optional(v.pipe(v.number(), v.minValue(0, "Invalid value: Expected uint16 to be >= 0"), v.maxValue(65535, "Invalid value: Expected uint16 to be <= 2^16-1"))), + numberUint32: v.optional(v.pipe(v.number(), v.minValue(0, "Invalid value: Expected uint32 to be >= 0"), v.maxValue(4294967295, "Invalid value: Expected uint32 to be <= 2^32-1"))), numberUint64: v.optional(v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("0"), "Invalid value: Expected uint64 to be >= 0"), v.maxValue(BigInt("18446744073709551615"), "Invalid value: Expected uint64 to be <= 2^64-1"))), integerNoFormat: v.optional(v.pipe(v.number(), v.integer())), - integerInt8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-128, 'Invalid value: Expected int8 to be >= -2^7'), v.maxValue(127, 'Invalid value: Expected int8 to be <= 2^7-1'))), - integerInt16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-32768, 'Invalid value: Expected int16 to be >= -2^15'), v.maxValue(32767, 'Invalid value: Expected int16 to be <= 2^15-1'))), - integerInt32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))), + integerInt8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-128, "Invalid value: Expected int8 to be >= -2^7"), v.maxValue(127, "Invalid value: Expected int8 to be <= 2^7-1"))), + integerInt16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-32768, "Invalid value: Expected int16 to be >= -2^15"), v.maxValue(32767, "Invalid value: Expected int16 to be <= 2^15-1"))), + integerInt32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"))), integerInt64: v.optional(v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), - integerUint8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'))), - integerUint16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'))), - integerUint32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint32 to be >= 0'), v.maxValue(4294967295, 'Invalid value: Expected uint32 to be <= 2^32-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), + integerUint8: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint8 to be >= 0"), v.maxValue(255, "Invalid value: Expected uint8 to be <= 2^8-1"))), + integerUint16: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint16 to be >= 0"), v.maxValue(65535, "Invalid value: Expected uint16 to be <= 2^16-1"))), + integerUint32: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint32 to be >= 0"), v.maxValue(4294967295, "Invalid value: Expected uint32 to be <= 2^32-1"))), integerUint64: v.optional(v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("0"), "Invalid value: Expected uint64 to be >= 0"), v.maxValue(BigInt("18446744073709551615"), "Invalid value: Expected uint64 to be <= 2^64-1"))), stringInt64: v.optional(v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), stringUint64: v.optional(v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1'))) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("0"), "Invalid value: Expected uint64 to be >= 0"), v.maxValue(BigInt("18446744073709551615"), "Invalid value: Expected uint64 to be <= 2^64-1"))) }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts index c439f1fb25..7568e6282e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts @@ -8,7 +8,7 @@ export const vFoo = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), BigInt(0)), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), BigInt(0)), id: v.string() }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts index 03aef51409..e812c45c09 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts @@ -81,28 +81,25 @@ export const vSimpleFile = v.string(); /** * This is a simple string */ -export const vSimpleStringWithPattern = v.union([ - v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), - v.null() -]); +export const vSimpleStringWithPattern = v.union([v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.null()]); /** * This is a simple enum with strings */ export const vEnumWithStrings = v.picklist([ - 'Success', - 'Warning', - 'Error', + "Success", + "Warning", + "Error", "'Single Quote'", - '"Double Quotes"', - 'Non-ascii: øæåôöØÆÅÔÖ字符串' + "\"Double Quotes\"", + "Non-ascii: øæåôöØÆÅÔÖ字符串" ]); export const vEnumWithReplacedCharacters = v.picklist([ "'Single Quote'", - '"Double Quotes"', - 'øæåôöØÆÅÔÖ字符串', - '' + "\"Double Quotes\"", + "øæåôöØÆÅÔÖ字符串", + "" ]); /** @@ -135,7 +132,7 @@ export const vArrayWithBooleans = v.array(v.boolean()); /** * This is a simple array with strings */ -export const vArrayWithStrings = v.optional(v.array(v.string()), ['test']); +export const vArrayWithStrings = v.optional(v.array(v.string()), ["test"]); /** * This is a simple array with properties @@ -151,10 +148,7 @@ export const vArrayWithProperties = v.array(v.object({ export const vArrayWithAnyOfProperties = v.array(v.unknown()); export const vAnyOfAnyAndNull = v.object({ - data: v.optional(v.union([ - v.unknown(), - v.null() - ])) + data: v.optional(v.union([v.unknown(), v.null()])) }); /** @@ -249,27 +243,15 @@ export const vModelFromZendesk = v.string(); * This is a model with one string property */ export const vModelWithNullableString = v.object({ - nullableProp1: v.optional(v.union([ - v.string(), - v.null() - ])), - nullableRequiredProp1: v.union([ - v.string(), - v.null() - ]), - nullableProp2: v.optional(v.union([ - v.string(), - v.null() - ])), - nullableRequiredProp2: v.union([ - v.string(), - v.null() - ]), + nullableProp1: v.optional(v.union([v.string(), v.null()])), + nullableRequiredProp1: v.union([v.string(), v.null()]), + nullableProp2: v.optional(v.union([v.string(), v.null()])), + nullableRequiredProp2: v.union([v.string(), v.null()]), 'foo_bar-enum': v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])) }); @@ -278,18 +260,18 @@ export const vModelWithNullableString = v.object({ */ export const vModelWithEnum = v.object({ 'foo_bar-enum': v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])), statusCode: v.optional(v.picklist([ - '100', - '200 FOO', - '300 FOO_BAR', - '400 foo-bar', - '500 foo.bar', - '600 foo&bar' + "100", + "200 FOO", + "300 FOO_BAR", + "400 foo-bar", + "500 foo.bar", + "600 foo&bar" ])), bool: v.optional(v.unknown()) }); @@ -298,9 +280,7 @@ export const vModelWithEnum = v.object({ * This is a model with one enum with escaped name */ export const vModelWithEnumWithHyphen = v.object({ - 'foo-bar-baz-qux': v.optional(v.picklist([ - '3.0' - ])) + 'foo-bar-baz-qux': v.optional(v.picklist(["3.0"])) }); /** @@ -315,22 +295,22 @@ export const vModelWithEnumFromDescription = v.object({ */ export const vModelWithNestedEnums = v.object({ dictionaryWithEnum: v.optional(v.record(v.string(), v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]))), dictionaryWithEnumFromDescription: v.optional(v.record(v.string(), v.pipe(v.number(), v.integer()))), arrayWithEnum: v.optional(v.array(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ]))), arrayWithDescription: v.optional(v.array(v.pipe(v.number(), v.integer()))), 'foo_bar-enum': v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error', - 'ØÆÅ字符串' + "Success", + "Warning", + "Error", + "ØÆÅ字符串" ])) }); @@ -363,9 +343,7 @@ export const vDeprecatedModel = v.object({ * This is a model with one property containing a circular reference */ export const vModelWithCircularReference: v.GenericSchema = v.object({ - prop: v.optional(v.lazy(() => { - return vModelWithCircularReference; - })) + prop: v.optional(v.lazy(() => vModelWithCircularReference)) }); /** @@ -412,20 +390,11 @@ export const vModelSquare = v.object({ /** * This is a model with one property with a 'one of' relationship where the options are not $ref */ -export const vCompositionWithOneOfDiscriminator = v.union([ - v.intersect([ - v.object({ +export const vCompositionWithOneOfDiscriminator = v.union([v.intersect([v.object({ kind: v.literal("circle") - }), - vModelCircle - ]), - v.intersect([ - v.object({ + }), vModelCircle]), v.intersect([v.object({ kind: v.literal("square") - }), - vModelSquare - ]) -]); + }), vModelSquare])]); /** * This is a model with one property with a 'any of' relationship @@ -456,16 +425,10 @@ export const vCompositionWithAnyOfAnonymous = v.object({ * This is a model with nested 'any of' property with a type null */ export const vCompositionWithNestedAnyAndTypeNull = v.object({ - propA: v.optional(v.union([ - v.array(v.unknown()), - v.array(v.unknown()) - ])) + propA: v.optional(v.union([v.array(v.unknown()), v.array(v.unknown())])) }); -export const v3eNum1Период = v.picklist([ - 'Bird', - 'Dog' -]); +export const v3eNum1Период = v.picklist(["Bird", "Dog"]); export const vConstValue = v.literal("ConstValue"); @@ -473,10 +436,7 @@ export const vConstValue = v.literal("ConstValue"); * This is a model with one property with a 'any of' relationship where the options are not $ref */ export const vCompositionWithNestedAnyOfAndNull = v.object({ - propA: v.optional(v.union([ - v.array(v.unknown()), - v.null() - ])) + propA: v.optional(v.union([v.array(v.unknown()), v.null()])) }); /** @@ -498,47 +458,35 @@ export const vCompositionWithOneOfAndNullable = v.object({ * This is a model that contains a simple dictionary within composition */ export const vCompositionWithOneOfAndSimpleDictionary = v.object({ - propA: v.optional(v.union([ - v.boolean(), - v.record(v.string(), v.number()) - ])) + propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.number())])) }); /** * This is a model that contains a dictionary of simple arrays within composition */ export const vCompositionWithOneOfAndSimpleArrayDictionary = v.object({ - propA: v.optional(v.union([ - v.boolean(), - v.record(v.string(), v.array(v.boolean())) - ])) + propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.boolean()))])) }); /** * This is a model that contains a dictionary of complex arrays (composited) within composition */ export const vCompositionWithOneOfAndComplexArrayDictionary = v.object({ - propA: v.optional(v.union([ - v.boolean(), - v.record(v.string(), v.array(v.unknown())) - ])) + propA: v.optional(v.union([v.boolean(), v.record(v.string(), v.array(v.unknown()))])) }); /** * This is a model with one property with a 'all of' relationship */ export const vCompositionWithAllOfAndNullable = v.object({ - propA: v.optional(v.union([ - v.intersect([ + propA: v.optional(v.union([v.intersect([ v.object({ boolean: v.optional(v.boolean()) }), vModelWithEnum, vModelWithArray, vModelWithDictionary - ]), - v.null() - ])) + ]), v.null()])) }); /** @@ -567,14 +515,11 @@ export const vCompositionBaseModel = v.object({ /** * This is a model that extends the base model */ -export const vCompositionExtendedModel = v.intersect([ - vCompositionBaseModel, - v.object({ +export const vCompositionExtendedModel = v.intersect([vCompositionBaseModel, v.object({ age: v.number(), firstName: v.string(), lastname: v.string() - }) -]); + })]); /** * This is a model with one nested property @@ -582,10 +527,7 @@ export const vCompositionExtendedModel = v.intersect([ export const vModelWithProperties = v.object({ required: v.string(), requiredAndReadOnly: v.pipe(v.string(), v.readonly()), - requiredAndNullable: v.union([ - v.string(), - v.null() - ]), + requiredAndNullable: v.union([v.string(), v.null()]), string: v.optional(v.string()), number: v.optional(v.number()), boolean: v.optional(v.boolean()), @@ -608,20 +550,11 @@ export const vModelWithReference = v.object({ * This is a model with one nested property */ export const vModelWithNestedProperties = v.object({ - first: v.pipe(v.union([ - v.pipe(v.object({ - second: v.pipe(v.union([ - v.pipe(v.object({ - third: v.pipe(v.union([ - v.pipe(v.string(), v.readonly()), - v.null() - ]), v.readonly()) - }), v.readonly()), - v.null() - ]), v.readonly()) - }), v.readonly()), - v.null() - ]), v.readonly()) + first: v.pipe(v.union([v.pipe(v.object({ + second: v.pipe(v.union([v.pipe(v.object({ + third: v.pipe(v.union([v.pipe(v.string(), v.readonly()), v.null()]), v.readonly()) + }), v.readonly()), v.null()]), v.readonly()) + }), v.readonly()), v.null()]), v.readonly()) }); /** @@ -652,13 +585,10 @@ export const vModelWithDuplicateImports = v.object({ /** * This is a model that extends another model */ -export const vModelThatExtends = v.intersect([ - vModelWithString, - v.object({ +export const vModelThatExtends = v.intersect([vModelWithString, v.object({ propExtendsA: v.optional(v.string()), propExtendsB: v.optional(vModelWithString) - }) -]); + })]); /** * This is a model that extends another model @@ -700,8 +630,8 @@ export const vDefault = v.object({ }); export const vPageable = v.object({ - page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(0)), 0), - size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'), v.minValue(1))), + page: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"), v.minValue(0)), 0), + size: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"), v.minValue(1))), sort: v.optional(v.array(v.string())) }); @@ -735,21 +665,15 @@ export const vModelWithAdditionalPropertiesEqTrue = v.objectWithRest({ }, v.unknown()); export const vNestedAnyOfArraysNullable = v.object({ - nullableArray: v.optional(v.union([ - v.array(v.unknown()), - v.null() - ])) + nullableArray: v.optional(v.union([v.array(v.unknown()), v.null()])) }); /** * An object that can be null */ -export const vNullableObject = v.optional(v.union([ - v.object({ +export const vNullableObject = v.optional(v.union([v.object({ foo: v.optional(v.string()) - }), - v.null() -]), null); + }), v.null()]), null); /** * Some % character @@ -762,46 +686,27 @@ export const vModelWithNullableObject = v.object({ export const vModelWithOneOfEnum = v.union([ v.object({ - foo: v.picklist([ - 'Bar' - ]) + foo: v.picklist(["Bar"]) }), v.object({ - foo: v.picklist([ - 'Baz' - ]) + foo: v.picklist(["Baz"]) }), v.object({ - foo: v.picklist([ - 'Qux' - ]) + foo: v.picklist(["Qux"]) }), v.object({ content: v.pipe(v.string(), v.isoTimestamp()), - foo: v.picklist([ - 'Quux' - ]) + foo: v.picklist(["Quux"]) }), v.object({ - content: v.tuple([ - v.pipe(v.string(), v.isoTimestamp()), - v.string() - ]), - foo: v.picklist([ - 'Corge' - ]) + content: v.tuple([v.pipe(v.string(), v.isoTimestamp()), v.string()]), + foo: v.picklist(["Corge"]) }) ]); -export const vModelWithNestedArrayEnumsDataFoo = v.picklist([ - 'foo', - 'bar' -]); +export const vModelWithNestedArrayEnumsDataFoo = v.picklist(["foo", "bar"]); -export const vModelWithNestedArrayEnumsDataBar = v.picklist([ - 'baz', - 'qux' -]); +export const vModelWithNestedArrayEnumsDataBar = v.picklist(["baz", "qux"]); export const vModelWithNestedArrayEnumsData = v.object({ foo: v.optional(v.array(vModelWithNestedArrayEnumsDataFoo)), @@ -831,32 +736,17 @@ export const vModelWithArrayReadOnlyAndWriteOnly = v.object({ propWithNumber: v.optional(v.array(v.number())) }); -export const vModelWithConstantSizeArray = v.tuple([ - v.number(), - v.number() -]); +export const vModelWithConstantSizeArray = v.tuple([v.number(), v.number()]); export const vModelWithAnyOfConstantSizeArray = v.tuple([ - v.union([ - v.number(), - v.string() - ]), - v.union([ - v.number(), - v.string() - ]), - v.union([ - v.number(), - v.string() - ]) + v.union([v.number(), v.string()]), + v.union([v.number(), v.string()]), + v.union([v.number(), v.string()]) ]); export const vModelWithPrefixItemsConstantSizeArray = v.tuple([ vModelWithInteger, - v.union([ - v.number(), - v.string() - ]), + v.union([v.number(), v.string()]), v.string() ]); @@ -878,16 +768,7 @@ export const vModelWithAnyOfConstantSizeArrayNullable = v.tuple([ ]) ]); -export const vModelWithAnyOfConstantSizeArrayAndIntersect = v.tuple([ - v.intersect([ - v.number(), - v.string() - ]), - v.intersect([ - v.number(), - v.string() - ]) -]); +export const vModelWithAnyOfConstantSizeArrayAndIntersect = v.tuple([v.intersect([v.number(), v.string()]), v.intersect([v.number(), v.string()])]); export const vModelWithNumericEnumUnion = v.object({ value: v.optional(v.unknown()) @@ -930,16 +811,7 @@ export const vDeleteFooData2 = v.string(); */ export const vImport = v.string(); -export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = v.tuple([ - v.union([ - v.number(), - vImport - ]), - v.union([ - v.number(), - vImport - ]) -]); +export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); export const vSchemaWithFormRestrictedKeys = v.object({ description: v.optional(v.string()), @@ -982,12 +854,9 @@ export const vAdditionalPropertiesUnknownIssue = v.object({}); export const vAdditionalPropertiesUnknownIssue2 = v.object({}); -export const vAdditionalPropertiesUnknownIssue3 = v.intersect([ - v.string(), - v.object({ +export const vAdditionalPropertiesUnknownIssue3 = v.intersect([v.string(), v.object({ entries: v.object({}) - }) -]); + })]); export const vAdditionalPropertiesIntegerIssue = v.objectWithRest({ value: v.pipe(v.number(), v.integer()) @@ -995,36 +864,18 @@ export const vAdditionalPropertiesIntegerIssue = v.objectWithRest({ export const vGenericSchemaDuplicateIssue1SystemBoolean = v.strictObject({ item: v.optional(v.boolean()), - error: v.optional(v.union([ - v.string(), - v.null() - ])), + error: v.optional(v.union([v.string(), v.null()])), hasError: v.optional(v.pipe(v.boolean(), v.readonly())), data: v.optional(v.strictObject({})) }); export const vGenericSchemaDuplicateIssue1SystemString = v.strictObject({ - item: v.optional(v.union([ - v.string(), - v.null() - ])), - error: v.optional(v.union([ - v.string(), - v.null() - ])), + item: v.optional(v.union([v.string(), v.null()])), + error: v.optional(v.union([v.string(), v.null()])), hasError: v.optional(v.pipe(v.boolean(), v.readonly())) }); -export const vOneOfAllOfIssue = v.union([ - v.intersect([ - v.union([ - vConstValue, - vGenericSchemaDuplicateIssue1SystemBoolean - ]), - v3eNum1Период - ]), - vGenericSchemaDuplicateIssue1SystemString -]); +export const vOneOfAllOfIssue = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); export const vExternalSharedExternalSharedModel = v.object({ id: v.string(), @@ -1046,10 +897,7 @@ export const vExternalRefB = vExternalSharedExternalSharedModel; */ export const vModelWithPropertiesWritable = v.object({ required: v.string(), - requiredAndNullable: v.union([ - v.string(), - v.null() - ]), + requiredAndNullable: v.union([v.string(), v.null()]), string: v.optional(v.string()), number: v.optional(v.number()), boolean: v.optional(v.boolean()), @@ -1097,48 +945,21 @@ export const vModelWithArrayReadOnlyAndWriteOnlyWritable = v.object({ propWithNumber: v.optional(v.array(v.number())) }); -export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = v.tuple([ - v.union([ - v.number(), - vImport - ]), - v.union([ - v.number(), - vImport - ]) -]); +export const vModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = v.tuple([v.union([v.number(), vImport]), v.union([v.number(), vImport])]); export const vAdditionalPropertiesUnknownIssueWritable = v.object({}); -export const vOneOfAllOfIssueWritable = v.union([ - v.intersect([ - v.union([ - vConstValue, - vGenericSchemaDuplicateIssue1SystemBoolean - ]), - v3eNum1Период - ]), - vGenericSchemaDuplicateIssue1SystemString -]); +export const vOneOfAllOfIssueWritable = v.union([v.intersect([v.union([vConstValue, vGenericSchemaDuplicateIssue1SystemBoolean]), v3eNum1Период]), vGenericSchemaDuplicateIssue1SystemString]); export const vGenericSchemaDuplicateIssue1SystemBooleanWritable = v.strictObject({ item: v.optional(v.boolean()), - error: v.optional(v.union([ - v.string(), - v.null() - ])), + error: v.optional(v.union([v.string(), v.null()])), data: v.optional(v.strictObject({})) }); export const vGenericSchemaDuplicateIssue1SystemStringWritable = v.strictObject({ - item: v.optional(v.union([ - v.string(), - v.null() - ])), - error: v.optional(v.union([ - v.string(), - v.null() - ])) + item: v.optional(v.union([v.string(), v.null()])), + error: v.optional(v.union([v.string(), v.null()])) }); /** @@ -1146,37 +967,19 @@ export const vGenericSchemaDuplicateIssue1SystemStringWritable = v.strictObject( */ export const vSimpleParameter = v.string(); -export const vCompositionWithOneOfAndProperties = v.intersect([ - v.union([ - v.strictObject({ +export const vCompositionWithOneOfAndProperties = v.intersect([v.union([v.strictObject({ foo: vSimpleParameter - }), - v.strictObject({ + }), v.strictObject({ bar: vNonAsciiStringæøåÆøÅöôêÊ字符串 - }) - ]), - v.object({ - baz: v.union([ - v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), - v.null() - ]), - qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0)) - }) -]); + })]), v.object({ + baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint16 to be >= 0"), v.maxValue(65535, "Invalid value: Expected uint16 to be <= 2^16-1"), v.minValue(0)), v.null()]), + qux: v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint8 to be >= 0"), v.maxValue(255, "Invalid value: Expected uint8 to be <= 2^8-1"), v.minValue(0)) + })]); -export const vModelWithOneOfAndProperties = v.intersect([ - v.union([ - vSimpleParameter, - vNonAsciiStringæøåÆøÅöôêÊ字符串 - ]), - v.object({ - baz: v.union([ - v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint16 to be >= 0'), v.maxValue(65535, 'Invalid value: Expected uint16 to be <= 2^16-1'), v.minValue(0)), - v.null() - ]), - qux: v.pipe(v.number(), v.integer(), v.minValue(0, 'Invalid value: Expected uint8 to be >= 0'), v.maxValue(255, 'Invalid value: Expected uint8 to be <= 2^8-1'), v.minValue(0)) - }) -]); +export const vModelWithOneOfAndProperties = v.intersect([v.union([vSimpleParameter, vNonAsciiStringæøåÆøÅöôêÊ字符串]), v.object({ + baz: v.union([v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint16 to be >= 0"), v.maxValue(65535, "Invalid value: Expected uint16 to be <= 2^16-1"), v.minValue(0)), v.null()]), + qux: v.pipe(v.number(), v.integer(), v.minValue(0, "Invalid value: Expected uint8 to be >= 0"), v.maxValue(255, "Invalid value: Expected uint8 to be <= 2^8-1"), v.minValue(0)) + })]); /** * Parameter with illegal characters @@ -1206,18 +1009,12 @@ export const vPatchApiVbyApiVersionNoTagData = v.object({ }); export const vImportData = v.object({ - body: v.union([ - vModelWithReadOnlyAndWriteOnlyWritable, - vModelWithArrayReadOnlyAndWriteOnlyWritable - ]), + body: v.union([vModelWithReadOnlyAndWriteOnlyWritable, vModelWithArrayReadOnlyAndWriteOnlyWritable]), path: v.optional(v.never()), query: v.optional(v.never()) }); -export const vImportResponse = v.union([ - vModelFromZendesk, - vModelWithReadOnlyAndWriteOnly -]); +export const vImportResponse = v.union([vModelFromZendesk, vModelWithReadOnlyAndWriteOnly]); export const vFooWowData = v.object({ body: v.optional(v.never()), @@ -1239,10 +1036,7 @@ export const vApiVVersionODataControllerCountResponse = vModelFromZendesk; export const vGetApiVbyApiVersionSimpleOperationData = v.object({ body: v.optional(v.never()), path: v.object({ - foo_param: v.union([ - v.string(), - v.pipe(v.string(), v.uuid()) - ]) + foo_param: v.union([v.string(), v.pipe(v.string(), v.uuid())]) }), query: v.optional(v.never()) }); @@ -1324,70 +1118,40 @@ export const vDeprecatedCallData = v.object({ path: v.optional(v.never()), query: v.optional(v.never()), headers: v.object({ - parameter: v.union([ - vDeprecatedModel, - v.null() - ]) + parameter: v.union([vDeprecatedModel, v.null()]) }) }); export const vCallWithParametersData = v.object({ - body: v.union([ - v.record(v.string(), v.unknown()), - v.null() - ]), + body: v.union([v.record(v.string(), v.unknown()), v.null()]), path: v.object({ - parameterPath: v.union([ - v.string(), - v.null() - ]), - 'api-version': v.union([ - v.string(), - v.null() - ]) + parameterPath: v.union([v.string(), v.null()]), + 'api-version': v.union([v.string(), v.null()]) }), query: v.object({ foo_ref_enum: v.optional(vModelWithNestedArrayEnumsDataFoo), foo_all_of_enum: vModelWithNestedArrayEnumsDataFoo, - cursor: v.union([ - v.string(), - v.null() - ]) + cursor: v.union([v.string(), v.null()]) }), headers: v.object({ - parameterHeader: v.union([ - v.string(), - v.null() - ]) + parameterHeader: v.union([v.string(), v.null()]) }) }); export const vCallWithWeirdParameterNamesData = v.object({ - body: v.union([ - vModelWithString, - v.null() - ]), + body: v.union([vModelWithString, v.null()]), path: v.object({ 'parameter.path.1': v.optional(v.string()), 'parameter-path-2': v.optional(v.string()), 'PARAMETER-PATH-3': v.optional(v.string()), - 'api-version': v.union([ - v.string(), - v.null() - ]) + 'api-version': v.union([v.string(), v.null()]) }), query: v.object({ default: v.optional(v.string()), - 'parameter-query': v.union([ - v.string(), - v.null() - ]) + 'parameter-query': v.union([v.string(), v.null()]) }), headers: v.object({ - 'parameter.header': v.union([ - v.string(), - v.null() - ]) + 'parameter.header': v.union([v.string(), v.null()]) }) }); @@ -1401,10 +1165,7 @@ export const vGetCallWithOptionalParamData = v.object({ export const vPostCallWithOptionalParamData = v.object({ body: v.optional(v.object({ - offset: v.optional(v.union([ - v.number(), - v.null() - ])) + offset: v.optional(v.union([v.number(), v.null()])) })), path: v.optional(v.never()), query: v.object({ @@ -1412,10 +1173,7 @@ export const vPostCallWithOptionalParamData = v.object({ }) }); -export const vPostCallWithOptionalParamResponse = v.union([ - v.number(), - v.void() -]); +export const vPostCallWithOptionalParamResponse = v.union([v.number(), v.void()]); export const vPostApiVbyApiVersionRequestBodyData = v.object({ body: v.optional(vSimpleRequestBody), @@ -1437,29 +1195,15 @@ export const vCallWithDefaultParametersData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.optional(v.object({ - parameterString: v.optional(v.union([ - v.optional(v.string(), 'Hello World!'), - v.null() - ]), 'Hello World!'), - parameterNumber: v.optional(v.union([ - v.optional(v.number(), 123), - v.null() - ]), 123), - parameterBoolean: v.optional(v.union([ - v.optional(v.boolean(), true), - v.null() - ]), true), + parameterString: v.optional(v.union([v.optional(v.string(), "Hello World!"), v.null()]), "Hello World!"), + parameterNumber: v.optional(v.union([v.optional(v.number(), 123), v.null()]), 123), + parameterBoolean: v.optional(v.union([v.optional(v.boolean(), true), v.null()]), true), parameterEnum: v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ])), - parameterModel: v.optional(v.union([ - v.optional(vModelWithString, { - prop: 'Hello World!' - }), - v.null() - ])) + parameterModel: v.optional(v.union([v.optional(vModelWithString, { prop: "Hello World!" }), v.null()])) })) }); @@ -1467,17 +1211,15 @@ export const vCallWithDefaultOptionalParametersData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.optional(v.object({ - parameterString: v.optional(v.string(), 'Hello World!'), + parameterString: v.optional(v.string(), "Hello World!"), parameterNumber: v.optional(v.number(), 123), parameterBoolean: v.optional(v.boolean(), true), parameterEnum: v.optional(v.picklist([ - 'Success', - 'Warning', - 'Error' + "Success", + "Warning", + "Error" ])), - parameterModel: v.optional(vModelWithString, { - prop: 'Hello World!' - }) + parameterModel: v.optional(vModelWithString, { prop: "Hello World!" }) })) }); @@ -1485,20 +1227,14 @@ export const vCallToTestOrderOfParamsData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.object({ - parameterOptionalStringWithDefault: v.optional(v.string(), 'Hello World!'), - parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ''), + parameterOptionalStringWithDefault: v.optional(v.string(), "Hello World!"), + parameterOptionalStringWithEmptyDefault: v.optional(v.string(), ""), parameterOptionalStringWithNoDefault: v.optional(v.string()), - parameterStringWithDefault: v.optional(v.string(), 'Hello World!'), - parameterStringWithEmptyDefault: v.optional(v.string(), ''), + parameterStringWithDefault: v.optional(v.string(), "Hello World!"), + parameterStringWithEmptyDefault: v.optional(v.string(), ""), parameterStringWithNoDefault: v.string(), - parameterStringNullableWithNoDefault: v.optional(v.union([ - v.string(), - v.null() - ])), - parameterStringNullableWithDefault: v.optional(v.union([ - v.string(), - v.null() - ]), null) + parameterStringNullableWithNoDefault: v.optional(v.union([v.string(), v.null()])), + parameterStringNullableWithDefault: v.optional(v.union([v.string(), v.null()]), null) }) }); @@ -1543,10 +1279,7 @@ export const vCallWithResponseAndNoContentResponseData = v.object({ query: v.optional(v.never()) }); -export const vCallWithResponseAndNoContentResponseResponse = v.union([ - v.number(), - v.void() -]); +export const vCallWithResponseAndNoContentResponseResponse = v.union([v.number(), v.void()]); export const vDummyAData = v.object({ body: v.optional(v.never()), @@ -1581,13 +1314,7 @@ export const vCallWithDuplicateResponsesData = v.object({ query: v.optional(v.never()) }); -export const vCallWithDuplicateResponsesResponse = v.union([ - v.intersect([ - vModelWithBoolean, - vModelWithInteger - ]), - vModelWithString -]); +export const vCallWithDuplicateResponsesResponse = v.union([v.intersect([vModelWithBoolean, vModelWithInteger]), vModelWithString]); export const vCallWithResponsesData = v.object({ body: v.optional(v.never()), @@ -1609,56 +1336,26 @@ export const vCollectionFormatData = v.object({ body: v.optional(v.never()), path: v.optional(v.never()), query: v.object({ - parameterArrayCSV: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArraySSV: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArrayTSV: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArrayPipes: v.union([ - v.array(v.string()), - v.null() - ]), - parameterArrayMulti: v.union([ - v.array(v.string()), - v.null() - ]) + parameterArrayCSV: v.union([v.array(v.string()), v.null()]), + parameterArraySSV: v.union([v.array(v.string()), v.null()]), + parameterArrayTSV: v.union([v.array(v.string()), v.null()]), + parameterArrayPipes: v.union([v.array(v.string()), v.null()]), + parameterArrayMulti: v.union([v.array(v.string()), v.null()]) }) }); export const vTypesData = v.object({ body: v.optional(v.never()), path: v.optional(v.object({ - id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1'))) + id: v.optional(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1"))) })), query: v.object({ parameterNumber: v.optional(v.number(), 123), - parameterString: v.optional(v.union([ - v.optional(v.string(), 'default'), - v.null() - ]), 'default'), - parameterBoolean: v.optional(v.union([ - v.optional(v.boolean(), true), - v.null() - ]), true), - parameterObject: v.optional(v.union([ - v.record(v.string(), v.unknown()), - v.null() - ]), null), - parameterArray: v.union([ - v.array(v.string()), - v.null() - ]), - parameterDictionary: v.union([ - v.record(v.string(), v.unknown()), - v.null() - ]), + parameterString: v.optional(v.union([v.optional(v.string(), "default"), v.null()]), "default"), + parameterBoolean: v.optional(v.union([v.optional(v.boolean(), true), v.null()]), true), + parameterObject: v.optional(v.union([v.record(v.string(), v.unknown()), v.null()]), null), + parameterArray: v.union([v.array(v.string()), v.null()]), + parameterDictionary: v.union([v.record(v.string(), v.unknown()), v.null()]), parameterEnum: v.union([ v.literal("Success"), v.literal("Warning"), @@ -1678,10 +1375,7 @@ export const vTypesResponse = v.union([ export const vUploadFileData = v.object({ body: v.string(), path: v.object({ - 'api-version': v.union([ - v.string(), - v.null() - ]) + 'api-version': v.union([v.string(), v.null()]) }), query: v.optional(v.never()) }); @@ -1742,10 +1436,7 @@ export const vMultipartResponseResponse = v.object({ export const vMultipartRequestData = v.object({ body: v.optional(v.object({ content: v.optional(v.string()), - data: v.optional(v.union([ - vModelWithString, - v.null() - ])) + data: v.optional(v.union([vModelWithString, v.null()])) })), path: v.optional(v.never()), query: v.optional(v.never()) @@ -1753,28 +1444,16 @@ export const vMultipartRequestData = v.object({ export const vComplexParamsData = v.object({ body: v.optional(v.object({ - key: v.pipe(v.union([ - v.pipe(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.readonly()), - v.null() - ]), v.readonly()), - name: v.union([ - v.pipe(v.string(), v.maxLength(255)), - v.null() - ]), + key: v.pipe(v.union([v.pipe(v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), v.readonly()), v.null()]), v.readonly()), + name: v.union([v.pipe(v.string(), v.maxLength(255)), v.null()]), enabled: v.optional(v.boolean(), true), type: v.picklist([ - 'Monkey', - 'Horse', - 'Bird' + "Monkey", + "Horse", + "Bird" ]), - listOfModels: v.optional(v.union([ - v.array(vModelWithString), - v.null() - ])), - listOfStrings: v.optional(v.union([ - v.array(v.string()), - v.null() - ])), + listOfModels: v.optional(v.union([v.array(vModelWithString), v.null()])), + listOfStrings: v.optional(v.union([v.array(v.string()), v.null()])), parameters: v.union([ vModelWithString, vModelWithEnum, @@ -1782,15 +1461,12 @@ export const vComplexParamsData = v.object({ vModelWithDictionary ]), user: v.optional(v.pipe(v.object({ - id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')), v.readonly())), - name: v.optional(v.pipe(v.union([ - v.pipe(v.string(), v.readonly()), - v.null() - ]), v.readonly())) + id: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1")), v.readonly())), + name: v.optional(v.pipe(v.union([v.pipe(v.string(), v.readonly()), v.null()]), v.readonly())) }), v.readonly())) })), path: v.object({ - id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, 'Invalid value: Expected int32 to be >= -2^31'), v.maxValue(2147483647, 'Invalid value: Expected int32 to be <= 2^31-1')), + id: v.pipe(v.number(), v.integer(), v.minValue(-2147483648, "Invalid value: Expected int32 to be >= -2^31"), v.maxValue(2147483647, "Invalid value: Expected int32 to be <= 2^31-1")), 'api-version': v.string() }), query: v.optional(v.never()) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts index 0bf447745a..0577553034 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts @@ -11,27 +11,27 @@ export const vFoo = v.object({ v.literal(1), v.literal(2), v.literal(3), - v.literal('foo'), + v.literal("foo"), v.literal(true) ])), corge: v.optional(v.record(v.string(), v.unknown())), - garply: v.optional(v.literal(BigInt('10'))), + garply: v.optional(v.literal(BigInt("10"))), numberInt8: v.optional(v.literal(100)), numberInt16: v.optional(v.literal(1000)), numberInt32: v.optional(v.literal(100000)), - numberInt64: v.optional(v.literal(BigInt('1000000000000'))), + numberInt64: v.optional(v.literal(BigInt(1000000000000))), numberUint8: v.optional(v.literal(200)), numberUint16: v.optional(v.literal(50000)), numberUint32: v.optional(v.literal(3000000000)), - numberUint64: v.optional(v.literal(BigInt('18000000000000000000'))), + numberUint64: v.optional(v.literal(BigInt(18000000000000000000))), integerInt8: v.optional(v.literal(-100)), integerInt16: v.optional(v.literal(-1000)), integerInt32: v.optional(v.literal(-100000)), - integerInt64: v.optional(v.literal(BigInt('-1000000000000'))), + integerInt64: v.optional(v.literal(BigInt(-1000000000000))), integerUint8: v.optional(v.literal(255)), integerUint16: v.optional(v.literal(65535)), integerUint32: v.optional(v.literal(4294967295)), - integerUint64: v.optional(v.literal(BigInt('18446744073709551615'))), - stringInt64: v.optional(v.literal(BigInt('-9223372036854775808'))), - stringUint64: v.optional(v.literal(BigInt('18446744073709551615'))) + integerUint64: v.optional(v.literal(BigInt("18446744073709551615"))), + stringInt64: v.optional(v.literal(BigInt("-9223372036854775808"))), + stringUint64: v.optional(v.literal(BigInt("18446744073709551615"))) }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts index c3c08a3d9c..04897c7e3f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts @@ -7,5 +7,5 @@ export const vFoo = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'), v.minValue(BigInt(0)), v.maxValue(BigInt(100)))) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"), v.minValue(BigInt(0)), v.maxValue(BigInt(100)))) }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts index 6b7d816f9d..1dc875c6bf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts @@ -3,12 +3,7 @@ import * as v from 'valibot'; export const vBar: v.GenericSchema = v.strictObject({ - bar: v.union([ - v.array(v.lazy(() => { - return vBar; - })), - v.null() - ]) + bar: v.union([v.array(v.lazy(() => vBar)), v.null()]) }); export const vFoo = v.strictObject({ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts index f0dfcc0167..090aa6a3a2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts @@ -3,18 +3,14 @@ import * as v from 'valibot'; export const vBar: v.GenericSchema = v.object({ - bar: v.optional(v.array(v.lazy(() => { - return vBar; - }))) + bar: v.optional(v.array(v.lazy(() => vBar))) }); export const vFoo = v.object({ foo: v.optional(vBar) }); -export const vBaz: v.GenericSchema = v.lazy(() => { - return vQux; -}); +export const vBaz: v.GenericSchema = v.lazy(() => vQux); /** * description caused circular reference error diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts index 0f25138dee..4761269523 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts @@ -2,7 +2,7 @@ import * as v from 'valibot'; -export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), 'baz'); +export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), "baz"); export const vQux = v.record(v.string(), v.object({ qux: v.optional(v.string()) @@ -11,41 +11,24 @@ export const vQux = v.record(v.string(), v.object({ /** * This is Foo schema. */ -export const vFoo: v.GenericSchema = v.optional(v.union([ - v.object({ - foo: v.optional(v.pipe(v.pipe(v.string(), v.regex(/^\d{3}-\d{2}-\d{4}$/)), v.metadata({ - description: 'This is foo property.' - }))), - bar: v.optional(v.lazy(() => { - return vBar; - })), - baz: v.optional(v.pipe(v.array(v.lazy(() => { - return vFoo; - })), v.metadata({ - description: 'This is baz property.' - }))), - qux: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.gtValue(0)), v.metadata({ - description: 'This is qux property.' - })), 0) - }), - v.null() -]), null); +export const vFoo: v.GenericSchema = v.optional(v.union([v.object({ + foo: v.optional(v.pipe(v.pipe(v.string(), v.regex(/^\d{3}-\d{2}-\d{4}$/)), v.metadata({ description: "This is foo property." }))), + bar: v.optional(v.lazy(() => vBar)), + baz: v.optional(v.pipe(v.array(v.lazy(() => vFoo)), v.metadata({ description: "This is baz property." }))), + qux: v.optional(v.pipe(v.pipe(v.number(), v.integer(), v.gtValue(0)), v.metadata({ description: "This is qux property." })), 0) + }), v.null()]), null); /** * This is Bar schema. */ export const vBar = v.pipe(v.object({ foo: v.optional(vFoo) -}), v.metadata({ - description: 'This is Bar schema.' -})); +}), v.metadata({ description: "This is Bar schema." })); /** * This is Foo parameter. */ -export const vFoo2 = v.pipe(v.string(), v.metadata({ - description: 'This is Foo parameter.' -})); +export const vFoo2 = v.pipe(v.string(), v.metadata({ description: "This is Foo parameter." })); export const vFoo3 = v.object({ foo: v.optional(vBar) @@ -57,9 +40,7 @@ export const vPatchFooData = v.object({ }), path: v.optional(v.never()), query: v.optional(v.object({ - foo: v.optional(v.pipe(v.string(), v.metadata({ - description: 'This is Foo parameter.' - }))), + foo: v.optional(v.pipe(v.string(), v.metadata({ description: "This is Foo parameter." }))), bar: v.optional(vBar), baz: v.optional(v.object({ baz: v.optional(v.string()) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts index 72e55fa049..4f8d0e50e8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts @@ -2,7 +2,7 @@ import * as v from 'valibot'; -export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), 'baz'); +export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), "baz"); export const vQux = v.record(v.string(), v.object({ qux: v.optional(v.string()) @@ -11,19 +11,12 @@ export const vQux = v.record(v.string(), v.object({ /** * This is Foo schema. */ -export const vFoo: v.GenericSchema = v.optional(v.union([ - v.object({ +export const vFoo: v.GenericSchema = v.optional(v.union([v.object({ foo: v.optional(v.pipe(v.string(), v.regex(/^\d{3}-\d{2}-\d{4}$/))), - bar: v.optional(v.lazy(() => { - return vBar; - })), - baz: v.optional(v.array(v.lazy(() => { - return vFoo; - }))), + bar: v.optional(v.lazy(() => vBar)), + baz: v.optional(v.array(v.lazy(() => vFoo))), qux: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0)), 0) - }), - v.null() -]), null); + }), v.null()]), null); /** * This is Bar schema. diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts index 3662ff4896..2cd85b7cc9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts @@ -2,21 +2,15 @@ import * as v from 'valibot'; -export const vContact = v.union([ - v.object({ +export const vContact = v.union([v.object({ email: v.string() - }), - v.object({ + }), v.object({ phone: v.string() - }) -]); + })]); -export const vUser = v.intersect([ - vContact, - v.object({ +export const vUser = v.intersect([vContact, v.object({ username: v.string() - }) -]); + })]); export const vDogDetails = v.object({ breed: v.string(), @@ -25,9 +19,9 @@ export const vDogDetails = v.object({ export const vCatDetails = v.object({ furLength: v.picklist([ - 'short', - 'medium', - 'long' + "short", + "medium", + "long" ]), purrs: v.boolean() }); @@ -35,13 +29,7 @@ export const vCatDetails = v.object({ export const vPetStore = v.object({ animals: v.array(v.object({ name: v.string(), - type: v.optional(v.picklist([ - 'dog', - 'cat' - ])), - details: v.union([ - vDogDetails, - vCatDetails - ]) + type: v.optional(v.picklist(["dog", "cat"])), + details: v.union([vDogDetails, vCatDetails]) })) }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts index 72e55fa049..4f8d0e50e8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts @@ -2,7 +2,7 @@ import * as v from 'valibot'; -export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), 'baz'); +export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), "baz"); export const vQux = v.record(v.string(), v.object({ qux: v.optional(v.string()) @@ -11,19 +11,12 @@ export const vQux = v.record(v.string(), v.object({ /** * This is Foo schema. */ -export const vFoo: v.GenericSchema = v.optional(v.union([ - v.object({ +export const vFoo: v.GenericSchema = v.optional(v.union([v.object({ foo: v.optional(v.pipe(v.string(), v.regex(/^\d{3}-\d{2}-\d{4}$/))), - bar: v.optional(v.lazy(() => { - return vBar; - })), - baz: v.optional(v.array(v.lazy(() => { - return vFoo; - }))), + bar: v.optional(v.lazy(() => vBar)), + baz: v.optional(v.array(v.lazy(() => vFoo))), qux: v.optional(v.pipe(v.number(), v.integer(), v.gtValue(0)), 0) - }), - v.null() -]), null); + }), v.null()]), null); /** * This is Bar schema. diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts index a043f19ae8..76d959c161 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts @@ -9,7 +9,7 @@ export const vSessionUserPhoneCalloutRingingWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -17,7 +17,7 @@ export const vSessionUserPhoneCalloutRingingWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -30,12 +30,12 @@ export const vSessionUserPhoneCalloutRingingWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), from_number: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")) }) }) }) @@ -51,7 +51,7 @@ export const vSessionUserRoomSystemCalloutRingingWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -59,7 +59,7 @@ export const vSessionUserRoomSystemCalloutRingingWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -79,14 +79,12 @@ export const vSessionUserRoomSystemCalloutRingingWebhookRequest = v.object({ export const vSessionRecordingStartedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_started' - ]), + event: v.picklist(["session.recording_started"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -108,14 +106,12 @@ export const vSessionRecordingStartedWebhookRequest = v.object({ export const vSessionRecordingResumedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_resumed' - ]), + event: v.picklist(["session.recording_resumed"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -137,14 +133,12 @@ export const vSessionRecordingResumedWebhookRequest = v.object({ export const vSessionLiveStreamingStoppedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.live_streaming_stopped' - ]), + event: v.picklist(["session.live_streaming_stopped"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -155,10 +149,10 @@ export const vSessionLiveStreamingStoppedWebhookRequest = v.object({ start_time: v.pipe(v.string(), v.isoTimestamp()), live_streaming: v.object({ service: v.picklist([ - 'Facebook', - 'Workplace_by_Facebook', - 'YouTube', - 'Custom_Live_Streaming_Service' + "Facebook", + "Workplace_by_Facebook", + "YouTube", + "Custom_Live_Streaming_Service" ]), custom_live_streaming_settings: v.object({ stream_url: v.string(), @@ -177,14 +171,12 @@ export const vSessionLiveStreamingStoppedWebhookRequest = v.object({ export const vSessionStreamIngestionStoppedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.stream_ingestion_stopped' - ]), + event: v.picklist(["session.stream_ingestion_stopped"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -213,7 +205,7 @@ export const vSessionUserRoomSystemCalloutRejectedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -221,7 +213,7 @@ export const vSessionUserRoomSystemCalloutRejectedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -241,14 +233,12 @@ export const vSessionUserRoomSystemCalloutRejectedWebhookRequest = v.object({ export const vSessionAlertWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.alert' - ]), + event: v.picklist(["session.alert"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -257,11 +247,11 @@ export const vSessionAlertWebhookRequest = v.object({ session_name: v.string(), session_key: v.optional(v.string()), issues: v.array(v.picklist([ - 'Unstable audio quality', - 'Unstable video quality', - 'Unstable screen share quality', - 'High CPU occupation', - 'Call Reconnection' + "Unstable audio quality", + "Unstable video quality", + "Unstable screen share quality", + "High CPU occupation", + "Call Reconnection" ])) }) }) @@ -272,14 +262,12 @@ export const vSessionAlertWebhookRequest = v.object({ export const vSessionSharingEndedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.sharing_ended' - ]), + event: v.picklist(["session.sharing_ended"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -293,10 +281,10 @@ export const vSessionSharingEndedWebhookRequest = v.object({ user_key: v.optional(v.string()), sharing_details: v.strictObject({ content: v.picklist([ - 'application', - 'whiteboard', - 'desktop', - 'unknown' + "application", + "whiteboard", + "desktop", + "unknown" ]), date_time: v.pipe(v.string(), v.isoTimestamp()) }) @@ -310,14 +298,12 @@ export const vSessionSharingEndedWebhookRequest = v.object({ export const vSessionRecordingPausedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_paused' - ]), + event: v.picklist(["session.recording_paused"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -339,14 +325,12 @@ export const vSessionRecordingPausedWebhookRequest = v.object({ export const vSessionEndedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.ended' - ]), + event: v.picklist(["session.ended"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -365,14 +349,12 @@ export const vSessionEndedWebhookRequest = v.object({ export const vSessionStartedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.started' - ]), + event: v.picklist(["session.started"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -390,14 +372,12 @@ export const vSessionStartedWebhookRequest = v.object({ export const vSessionStreamIngestionUnbindWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.stream_ingestion_unbind' - ]), + event: v.picklist(["session.stream_ingestion_unbind"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -421,14 +401,12 @@ export const vSessionStreamIngestionUnbindWebhookRequest = v.object({ export const vSessionLiveStreamingStartedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.live_streaming_started' - ]), + event: v.picklist(["session.live_streaming_started"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -439,10 +417,10 @@ export const vSessionLiveStreamingStartedWebhookRequest = v.object({ start_time: v.pipe(v.string(), v.isoTimestamp()), live_streaming: v.object({ service: v.picklist([ - 'Facebook', - 'Workplace_by_Facebook', - 'YouTube', - 'Custom_Live_Streaming_Service' + "Facebook", + "Workplace_by_Facebook", + "YouTube", + "Custom_Live_Streaming_Service" ]), custom_live_streaming_settings: v.object({ stream_url: v.string(), @@ -466,7 +444,7 @@ export const vSessionUserRoomSystemCalloutMissedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -474,7 +452,7 @@ export const vSessionUserRoomSystemCalloutMissedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -499,7 +477,7 @@ export const vSessionUserPhoneCalloutAcceptedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -507,7 +485,7 @@ export const vSessionUserPhoneCalloutAcceptedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -520,12 +498,12 @@ export const vSessionUserPhoneCalloutAcceptedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), from_number: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")) }) }) }) @@ -536,14 +514,12 @@ export const vSessionUserPhoneCalloutAcceptedWebhookRequest = v.object({ export const vSessionUserLeftWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.user_left' - ]), + event: v.picklist(["session.user_left"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -569,14 +545,12 @@ export const vSessionUserLeftWebhookRequest = v.object({ export const vSessionSharingStartedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.sharing_started' - ]), + event: v.picklist(["session.sharing_started"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -590,10 +564,10 @@ export const vSessionSharingStartedWebhookRequest = v.object({ user_key: v.optional(v.string()), sharing_details: v.strictObject({ content: v.picklist([ - 'application', - 'whiteboard', - 'desktop', - 'unknown' + "application", + "whiteboard", + "desktop", + "unknown" ]), date_time: v.pipe(v.string(), v.isoTimestamp()) }) @@ -612,7 +586,7 @@ export const vSessionUserPhoneCalloutCanceledWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -626,12 +600,12 @@ export const vSessionUserPhoneCalloutCanceledWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), from_number: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")) }) }) }) @@ -642,14 +616,12 @@ export const vSessionUserPhoneCalloutCanceledWebhookRequest = v.object({ export const vSessionRecordingTranscriptCompletedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_transcript_completed' - ]), + event: v.picklist(["session.recording_transcript_completed"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), download_token: v.string(), payload: v.strictObject({ account_id: v.string(), @@ -666,48 +638,46 @@ export const vSessionRecordingTranscriptCompletedWebhookRequest = v.object({ file_name: v.optional(v.string()), file_path: v.optional(v.string()), file_type: v.optional(v.picklist([ - 'MP4', - 'M4A', - 'CHAT', - 'TRANSCRIPT', - 'CSV', - 'CC', - 'TB', - 'CHAT_MESSAGE', - 'TIMELINE' + "MP4", + "M4A", + "CHAT", + "TRANSCRIPT", + "CSV", + "CC", + "TB", + "CHAT_MESSAGE", + "TIMELINE" ])), file_size: v.optional(v.number()), file_extension: v.optional(v.picklist([ - 'MP4', - 'M4A', - 'TXT', - 'VTT', - 'CSV', - 'JSON', - 'JPG' + "MP4", + "M4A", + "TXT", + "VTT", + "CSV", + "JSON", + "JPG" ])), download_url: v.optional(v.string()), - status: v.optional(v.picklist([ - 'completed' - ])), + status: v.optional(v.picklist(["completed"])), recording_type: v.optional(v.picklist([ - 'shared_screen_with_speaker_view(CC)', - 'shared_screen_with_speaker_view', - 'shared_screen_with_gallery_view', - 'gallery_view', - 'shared_screen', - 'audio_only', - 'audio_transcript', - 'chat_file', - 'active_speaker', - 'host_video', - 'audio_only_each_participant', - 'cc_transcript', - 'closed_caption', - 'poll', - 'timeline', - 'thumbnail', - 'chat_message' + "shared_screen_with_speaker_view(CC)", + "shared_screen_with_speaker_view", + "shared_screen_with_gallery_view", + "gallery_view", + "shared_screen", + "audio_only", + "audio_transcript", + "chat_file", + "active_speaker", + "host_video", + "audio_only_each_participant", + "cc_transcript", + "closed_caption", + "poll", + "timeline", + "thumbnail", + "chat_message" ])) })) }) @@ -719,14 +689,12 @@ export const vSessionRecordingTranscriptCompletedWebhookRequest = v.object({ export const vSessionRecordingDeletedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_deleted' - ]), + event: v.picklist(["session.recording_deleted"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), operator: v.pipe(v.string(), v.email()), @@ -751,7 +719,7 @@ export const vSessionUserRoomSystemCalloutFailedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -759,7 +727,7 @@ export const vSessionUserRoomSystemCalloutFailedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -780,14 +748,12 @@ export const vSessionUserRoomSystemCalloutFailedWebhookRequest = v.object({ export const vSessionRecordingCompletedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_completed' - ]), + event: v.picklist(["session.recording_completed"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), download_token: v.string(), payload: v.strictObject({ account_id: v.string(), @@ -804,47 +770,45 @@ export const vSessionRecordingCompletedWebhookRequest = v.object({ file_name: v.optional(v.string()), file_path: v.optional(v.string()), file_type: v.optional(v.picklist([ - 'MP4', - 'M4A', - 'CHAT', - 'TRANSCRIPT', - 'CSV', - 'CC', - 'TB', - 'CHAT_MESSAGE' + "MP4", + "M4A", + "CHAT", + "TRANSCRIPT", + "CSV", + "CC", + "TB", + "CHAT_MESSAGE" ])), file_size: v.optional(v.number()), file_extension: v.optional(v.picklist([ - 'MP4', - 'M4A', - 'TXT', - 'VTT', - 'CSV', - 'JSON', - 'JPG' + "MP4", + "M4A", + "TXT", + "VTT", + "CSV", + "JSON", + "JPG" ])), download_url: v.optional(v.string()), - status: v.optional(v.picklist([ - 'completed' - ])), + status: v.optional(v.picklist(["completed"])), recording_type: v.optional(v.picklist([ - 'shared_screen_with_speaker_view(CC)', - 'shared_screen_with_speaker_view', - 'shared_screen_with_gallery_view', - 'gallery_view', - 'shared_screen', - 'audio_only', - 'audio_transcript', - 'chat_file', - 'active_speaker', - 'host_video', - 'audio_only_each_participant', - 'cc_transcript', - 'closed_caption', - 'poll', - 'timeline', - 'thumbnail', - 'chat_message' + "shared_screen_with_speaker_view(CC)", + "shared_screen_with_speaker_view", + "shared_screen_with_gallery_view", + "gallery_view", + "shared_screen", + "audio_only", + "audio_transcript", + "chat_file", + "active_speaker", + "host_video", + "audio_only_each_participant", + "cc_transcript", + "closed_caption", + "poll", + "timeline", + "thumbnail", + "chat_message" ])) })), participant_audio_files: v.optional(v.array(v.object({ @@ -854,47 +818,45 @@ export const vSessionRecordingCompletedWebhookRequest = v.object({ file_name: v.optional(v.string()), file_path: v.optional(v.string()), file_type: v.optional(v.picklist([ - 'MP4', - 'M4A', - 'CHAT', - 'TRANSCRIPT', - 'CSV', - 'CC', - 'TB', - 'CHAT_MESSAGE' + "MP4", + "M4A", + "CHAT", + "TRANSCRIPT", + "CSV", + "CC", + "TB", + "CHAT_MESSAGE" ])), file_size: v.optional(v.number()), file_extension: v.optional(v.picklist([ - 'MP4', - 'M4A', - 'TXT', - 'VTT', - 'CSV', - 'JSON', - 'JPG' + "MP4", + "M4A", + "TXT", + "VTT", + "CSV", + "JSON", + "JPG" ])), download_url: v.optional(v.string()), - status: v.optional(v.picklist([ - 'completed' - ])), + status: v.optional(v.picklist(["completed"])), recording_type: v.optional(v.picklist([ - 'shared_screen_with_speaker_view(CC)', - 'shared_screen_with_speaker_view', - 'shared_screen_with_gallery_view', - 'gallery_view', - 'shared_screen', - 'audio_only', - 'audio_transcript', - 'chat_file', - 'active_speaker', - 'host_video', - 'audio_only_each_participant', - 'cc_transcript', - 'closed_caption', - 'poll', - 'timeline', - 'thumbnail', - 'chat_message' + "shared_screen_with_speaker_view(CC)", + "shared_screen_with_speaker_view", + "shared_screen_with_gallery_view", + "gallery_view", + "shared_screen", + "audio_only", + "audio_transcript", + "chat_file", + "active_speaker", + "host_video", + "audio_only_each_participant", + "cc_transcript", + "closed_caption", + "poll", + "timeline", + "thumbnail", + "chat_message" ])), user_id: v.optional(v.string()), user_key: v.optional(v.string()) @@ -905,21 +867,12 @@ export const vSessionRecordingCompletedWebhookRequest = v.object({ recording_end: v.optional(v.string()), file_name: v.optional(v.string()), file_path: v.optional(v.string()), - file_type: v.optional(v.picklist([ - 'MP4' - ])), + file_type: v.optional(v.picklist(["MP4"])), file_size: v.optional(v.number()), - file_extension: v.optional(v.picklist([ - 'MP4' - ])), + file_extension: v.optional(v.picklist(["MP4"])), download_url: v.optional(v.string()), - status: v.optional(v.picklist([ - 'completed' - ])), - recording_type: v.optional(v.picklist([ - 'individual_user', - 'individual_shared_screen' - ])), + status: v.optional(v.picklist(["completed"])), + recording_type: v.optional(v.picklist(["individual_user", "individual_shared_screen"])), user_id: v.optional(v.string()), user_key: v.optional(v.string()) }))) @@ -932,14 +885,12 @@ export const vSessionRecordingCompletedWebhookRequest = v.object({ export const vSessionRecordingTranscriptFailedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_transcript_failed' - ]), + event: v.picklist(["session.recording_transcript_failed"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -957,14 +908,12 @@ export const vSessionRecordingTranscriptFailedWebhookRequest = v.object({ export const vSessionRecordingTrashedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_trashed' - ]), + event: v.picklist(["session.recording_trashed"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), operator: v.pipe(v.string(), v.email()), @@ -984,14 +933,12 @@ export const vSessionRecordingTrashedWebhookRequest = v.object({ export const vSessionUserJoinedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.user_joined' - ]), + event: v.picklist(["session.user_joined"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1016,14 +963,12 @@ export const vSessionUserJoinedWebhookRequest = v.object({ export const vSessionStreamIngestionStartedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.stream_ingestion_started' - ]), + event: v.picklist(["session.stream_ingestion_started"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1047,14 +992,12 @@ export const vSessionStreamIngestionStartedWebhookRequest = v.object({ export const vSessionStreamIngestionConnectedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.stream_ingestion_connected' - ]), + event: v.picklist(["session.stream_ingestion_connected"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1078,14 +1021,12 @@ export const vSessionStreamIngestionConnectedWebhookRequest = v.object({ export const vSessionStreamIngestionDisconnectedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.stream_ingestion_disconnected' - ]), + event: v.picklist(["session.stream_ingestion_disconnected"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1109,14 +1050,12 @@ export const vSessionStreamIngestionDisconnectedWebhookRequest = v.object({ export const vSessionRecordingRecoveredWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_recovered' - ]), + event: v.picklist(["session.recording_recovered"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), operator: v.pipe(v.string(), v.email()), @@ -1141,7 +1080,7 @@ export const vSessionUserPhoneCalloutMissedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1149,7 +1088,7 @@ export const vSessionUserPhoneCalloutMissedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -1162,12 +1101,12 @@ export const vSessionUserPhoneCalloutMissedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), from_number: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")) }) }) }) @@ -1183,7 +1122,7 @@ export const vSessionUserPhoneCalloutRejectedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1191,7 +1130,7 @@ export const vSessionUserPhoneCalloutRejectedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -1204,12 +1143,12 @@ export const vSessionUserPhoneCalloutRejectedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), from_number: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')) + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")) }) }) }) @@ -1225,7 +1164,7 @@ export const vSessionUserRoomSystemCalloutAcceptedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ @@ -1233,7 +1172,7 @@ export const vSessionUserRoomSystemCalloutAcceptedWebhookRequest = v.object({ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'))), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1"))), uuid: v.optional(v.string()), session_id: v.string(), session_name: v.string(), @@ -1253,14 +1192,12 @@ export const vSessionUserRoomSystemCalloutAcceptedWebhookRequest = v.object({ export const vSessionRecordingStoppedWebhookRequest = v.object({ body: v.optional(v.strictObject({ - event: v.picklist([ - 'session.recording_stopped' - ]), + event: v.picklist(["session.recording_stopped"]), event_ts: v.pipe(v.union([ v.number(), v.string(), v.bigint() - ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1')), + ]), v.transform(x => BigInt(x)), v.minValue(BigInt("-9223372036854775808"), "Invalid value: Expected int64 to be >= -2^63"), v.maxValue(BigInt("9223372036854775807"), "Invalid value: Expected int64 to be <= 2^63-1")), payload: v.strictObject({ account_id: v.string(), object: v.strictObject({ diff --git a/packages/openapi-ts/src/plugins/valibot/shared/export.ts b/packages/openapi-ts/src/plugins/valibot/shared/export.ts index db0b6e1819..ad4d8aff64 100644 --- a/packages/openapi-ts/src/plugins/valibot/shared/export.ts +++ b/packages/openapi-ts/src/plugins/valibot/shared/export.ts @@ -32,7 +32,7 @@ export const exportAst = ({ .$if(state.hasLazyExpression.value, (c) => c.type( $.type(v.placeholder).attr( - ast.typeName || identifiers.types.GenericSchema.text, + ast.typeName || identifiers.types.GenericSchema, ), ), ) diff --git a/packages/openapi-ts/src/plugins/valibot/shared/numbers.ts b/packages/openapi-ts/src/plugins/valibot/shared/numbers.ts index 18105e9177..209ea94f6c 100644 --- a/packages/openapi-ts/src/plugins/valibot/shared/numbers.ts +++ b/packages/openapi-ts/src/plugins/valibot/shared/numbers.ts @@ -1,4 +1,4 @@ -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; export const INTEGER_FORMATS = { int16: { @@ -75,7 +75,7 @@ export const numberParameter = ({ isBigInt: boolean; value: unknown; }) => { - const expression = tsc.valueToExpression({ value }); + const expression = $.toExpr(value); if ( isBigInt && @@ -84,10 +84,7 @@ export const numberParameter = ({ typeof value === 'string' || typeof value === 'boolean') ) { - return tsc.callExpression({ - functionName: 'BigInt', - parameters: [expression], - }); + return $('BigInt').call(expression); } return expression; diff --git a/packages/openapi-ts/src/plugins/valibot/shared/pipesToAst.ts b/packages/openapi-ts/src/plugins/valibot/shared/pipesToAst.ts index 40adbff006..b9ea973797 100644 --- a/packages/openapi-ts/src/plugins/valibot/shared/pipesToAst.ts +++ b/packages/openapi-ts/src/plugins/valibot/shared/pipesToAst.ts @@ -1,6 +1,4 @@ -import type ts from 'typescript'; - -import { $, TsDsl } from '~/ts-dsl'; +import { $ } from '~/ts-dsl'; import type { ValibotPlugin } from '../types'; import { identifiers } from '../v1/constants'; @@ -9,11 +7,11 @@ export const pipesToAst = ({ pipes, plugin, }: { - pipes: ReadonlyArray>; + pipes: ReadonlyArray>; plugin: ValibotPlugin['Instance']; -}): ts.Expression => { +}): ReturnType => { if (pipes.length === 1) { - return pipes[0] instanceof TsDsl ? pipes[0].$render() : pipes[0]!; + return pipes[0]!; } const v = plugin.referenceSymbol({ @@ -22,6 +20,5 @@ export const pipesToAst = ({ }); return $(v.placeholder) .attr(identifiers.methods.pipe) - .call(...pipes) - .$render(); + .call(...pipes); }; diff --git a/packages/openapi-ts/src/plugins/valibot/shared/types.d.ts b/packages/openapi-ts/src/plugins/valibot/shared/types.d.ts index ef1a1ae7f1..1ef7efb024 100644 --- a/packages/openapi-ts/src/plugins/valibot/shared/types.d.ts +++ b/packages/openapi-ts/src/plugins/valibot/shared/types.d.ts @@ -3,12 +3,13 @@ import type ts from 'typescript'; import type { IR } from '~/ir/types'; import type { ToRefs } from '~/plugins'; +import type { $ } from '~/ts-dsl'; import type { ValibotPlugin } from '../types'; export type Ast = { hasLazyExpression?: boolean; - pipes: Array; + pipes: Array>; typeName?: string | ts.Identifier; }; diff --git a/packages/openapi-ts/src/plugins/valibot/types.d.ts b/packages/openapi-ts/src/plugins/valibot/types.d.ts index 98fab14d4d..49364fe0f1 100644 --- a/packages/openapi-ts/src/plugins/valibot/types.d.ts +++ b/packages/openapi-ts/src/plugins/valibot/types.d.ts @@ -342,7 +342,7 @@ export type FormatResolverArgs = SharedResolverArgs & { export type ObjectBaseResolverArgs = SharedResolverArgs & { /** Null = never */ - additional?: ts.Expression | null; + additional?: ReturnType | null; schema: IR.SchemaObject; shape: ReturnType; }; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/constants.ts b/packages/openapi-ts/src/plugins/valibot/v1/constants.ts index e49e120a44..6207204d8e 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/constants.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/constants.ts @@ -1,248 +1,246 @@ -import { tsc } from '~/tsc'; - export const identifiers = { /** * {@link https://valibot.dev/api/#actions Actions} */ actions: { - args: tsc.identifier({ text: 'args' }), - base64: tsc.identifier({ text: 'base64' }), - bic: tsc.identifier({ text: 'bic' }), - brand: tsc.identifier({ text: 'brand' }), - bytes: tsc.identifier({ text: 'bytes' }), - check: tsc.identifier({ text: 'check' }), - checkItems: tsc.identifier({ text: 'checkItems' }), - creditCard: tsc.identifier({ text: 'creditCard' }), - cuid2: tsc.identifier({ text: 'cuid2' }), - decimal: tsc.identifier({ text: 'decimal' }), - description: tsc.identifier({ text: 'description' }), - digits: tsc.identifier({ text: 'digits' }), - email: tsc.identifier({ text: 'email' }), - emoji: tsc.identifier({ text: 'emoji' }), - empty: tsc.identifier({ text: 'empty' }), - endsWith: tsc.identifier({ text: 'endsWith' }), - entries: tsc.identifier({ text: 'entries' }), - everyItem: tsc.identifier({ text: 'everyItem' }), - excludes: tsc.identifier({ text: 'excludes' }), - filterItems: tsc.identifier({ text: 'filterItems' }), - findItem: tsc.identifier({ text: 'findItem' }), - finite: tsc.identifier({ text: 'finite' }), - flavor: tsc.identifier({ text: 'flavor' }), - graphemes: tsc.identifier({ text: 'graphemes' }), - gtValue: tsc.identifier({ text: 'gtValue' }), - hash: tsc.identifier({ text: 'hash' }), - hexColor: tsc.identifier({ text: 'hexColor' }), - hexadecimal: tsc.identifier({ text: 'hexadecimal' }), - imei: tsc.identifier({ text: 'imei' }), - includes: tsc.identifier({ text: 'includes' }), - integer: tsc.identifier({ text: 'integer' }), - ip: tsc.identifier({ text: 'ip' }), - ipv4: tsc.identifier({ text: 'ipv4' }), - ipv6: tsc.identifier({ text: 'ipv6' }), - isoDate: tsc.identifier({ text: 'isoDate' }), - isoDateTime: tsc.identifier({ text: 'isoDateTime' }), - isoTime: tsc.identifier({ text: 'isoTime' }), - isoTimeSecond: tsc.identifier({ text: 'isoTimeSecond' }), - isoTimestamp: tsc.identifier({ text: 'isoTimestamp' }), - isoWeek: tsc.identifier({ text: 'isoWeek' }), - length: tsc.identifier({ text: 'length' }), - ltValue: tsc.identifier({ text: 'ltValue' }), - mac: tsc.identifier({ text: 'mac' }), - mac48: tsc.identifier({ text: 'mac48' }), - mac64: tsc.identifier({ text: 'mac64' }), - mapItems: tsc.identifier({ text: 'mapItems' }), - maxBytes: tsc.identifier({ text: 'maxBytes' }), - maxEntries: tsc.identifier({ text: 'maxEntries' }), - maxGraphemes: tsc.identifier({ text: 'maxGraphemes' }), - maxLength: tsc.identifier({ text: 'maxLength' }), - maxSize: tsc.identifier({ text: 'maxSize' }), - maxValue: tsc.identifier({ text: 'maxValue' }), - maxWords: tsc.identifier({ text: 'maxWords' }), - metadata: tsc.identifier({ text: 'metadata' }), - mimeType: tsc.identifier({ text: 'mimeType' }), - minBytes: tsc.identifier({ text: 'minBytes' }), - minEntries: tsc.identifier({ text: 'minEntries' }), - minGraphemes: tsc.identifier({ text: 'minGraphemes' }), - minLength: tsc.identifier({ text: 'minLength' }), - minSize: tsc.identifier({ text: 'minSize' }), - minValue: tsc.identifier({ text: 'minValue' }), - minWords: tsc.identifier({ text: 'minWords' }), - multipleOf: tsc.identifier({ text: 'multipleOf' }), - nanoid: tsc.identifier({ text: 'nanoid' }), - nonEmpty: tsc.identifier({ text: 'nonEmpty' }), - normalize: tsc.identifier({ text: 'normalize' }), - notBytes: tsc.identifier({ text: 'notBytes' }), - notEntries: tsc.identifier({ text: 'notEntries' }), - notGraphemes: tsc.identifier({ text: 'notGraphemes' }), - notLength: tsc.identifier({ text: 'notLength' }), - notSize: tsc.identifier({ text: 'notSize' }), - notValue: tsc.identifier({ text: 'notValue' }), - notValues: tsc.identifier({ text: 'notValues' }), - notWords: tsc.identifier({ text: 'notWords' }), - octal: tsc.identifier({ text: 'octal' }), - parseJson: tsc.identifier({ text: 'parseJson' }), - partialCheck: tsc.identifier({ text: 'partialCheck' }), - rawCheck: tsc.identifier({ text: 'rawCheck' }), - rawTransform: tsc.identifier({ text: 'rawTransform' }), - readonly: tsc.identifier({ text: 'readonly' }), - reduceItems: tsc.identifier({ text: 'reduceItems' }), - regex: tsc.identifier({ text: 'regex' }), - returns: tsc.identifier({ text: 'returns' }), - rfcEmail: tsc.identifier({ text: 'rfcEmail' }), - safeInteger: tsc.identifier({ text: 'safeInteger' }), - size: tsc.identifier({ text: 'size' }), - slug: tsc.identifier({ text: 'slug' }), - someItem: tsc.identifier({ text: 'someItem' }), - sortItems: tsc.identifier({ text: 'sortItems' }), - startsWith: tsc.identifier({ text: 'startsWith' }), - stringifyJson: tsc.identifier({ text: 'stringifyJson' }), - title: tsc.identifier({ text: 'title' }), - toLowerCase: tsc.identifier({ text: 'toLowerCase' }), - toMaxValue: tsc.identifier({ text: 'toMaxValue' }), - toMinValue: tsc.identifier({ text: 'toMinValue' }), - toUpperCase: tsc.identifier({ text: 'toUpperCase' }), - transform: tsc.identifier({ text: 'transform' }), - trim: tsc.identifier({ text: 'trim' }), - trimEnd: tsc.identifier({ text: 'trimEnd' }), - trimStart: tsc.identifier({ text: 'trimStart' }), - ulid: tsc.identifier({ text: 'ulid' }), - url: tsc.identifier({ text: 'url' }), - uuid: tsc.identifier({ text: 'uuid' }), - value: tsc.identifier({ text: 'value' }), - values: tsc.identifier({ text: 'values' }), - words: tsc.identifier({ text: 'words' }), + args: 'args', + base64: 'base64', + bic: 'bic', + brand: 'brand', + bytes: 'bytes', + check: 'check', + checkItems: 'checkItems', + creditCard: 'creditCard', + cuid2: 'cuid2', + decimal: 'decimal', + description: 'description', + digits: 'digits', + email: 'email', + emoji: 'emoji', + empty: 'empty', + endsWith: 'endsWith', + entries: 'entries', + everyItem: 'everyItem', + excludes: 'excludes', + filterItems: 'filterItems', + findItem: 'findItem', + finite: 'finite', + flavor: 'flavor', + graphemes: 'graphemes', + gtValue: 'gtValue', + hash: 'hash', + hexColor: 'hexColor', + hexadecimal: 'hexadecimal', + imei: 'imei', + includes: 'includes', + integer: 'integer', + ip: 'ip', + ipv4: 'ipv4', + ipv6: 'ipv6', + isoDate: 'isoDate', + isoDateTime: 'isoDateTime', + isoTime: 'isoTime', + isoTimeSecond: 'isoTimeSecond', + isoTimestamp: 'isoTimestamp', + isoWeek: 'isoWeek', + length: 'length', + ltValue: 'ltValue', + mac: 'mac', + mac48: 'mac48', + mac64: 'mac64', + mapItems: 'mapItems', + maxBytes: 'maxBytes', + maxEntries: 'maxEntries', + maxGraphemes: 'maxGraphemes', + maxLength: 'maxLength', + maxSize: 'maxSize', + maxValue: 'maxValue', + maxWords: 'maxWords', + metadata: 'metadata', + mimeType: 'mimeType', + minBytes: 'minBytes', + minEntries: 'minEntries', + minGraphemes: 'minGraphemes', + minLength: 'minLength', + minSize: 'minSize', + minValue: 'minValue', + minWords: 'minWords', + multipleOf: 'multipleOf', + nanoid: 'nanoid', + nonEmpty: 'nonEmpty', + normalize: 'normalize', + notBytes: 'notBytes', + notEntries: 'notEntries', + notGraphemes: 'notGraphemes', + notLength: 'notLength', + notSize: 'notSize', + notValue: 'notValue', + notValues: 'notValues', + notWords: 'notWords', + octal: 'octal', + parseJson: 'parseJson', + partialCheck: 'partialCheck', + rawCheck: 'rawCheck', + rawTransform: 'rawTransform', + readonly: 'readonly', + reduceItems: 'reduceItems', + regex: 'regex', + returns: 'returns', + rfcEmail: 'rfcEmail', + safeInteger: 'safeInteger', + size: 'size', + slug: 'slug', + someItem: 'someItem', + sortItems: 'sortItems', + startsWith: 'startsWith', + stringifyJson: 'stringifyJson', + title: 'title', + toLowerCase: 'toLowerCase', + toMaxValue: 'toMaxValue', + toMinValue: 'toMinValue', + toUpperCase: 'toUpperCase', + transform: 'transform', + trim: 'trim', + trimEnd: 'trimEnd', + trimStart: 'trimStart', + ulid: 'ulid', + url: 'url', + uuid: 'uuid', + value: 'value', + values: 'values', + words: 'words', }, /** * {@link https://valibot.dev/api/#async Async} */ async: { - argsAsync: tsc.identifier({ text: 'argsAsync' }), - arrayAsync: tsc.identifier({ text: 'arrayAsync' }), - awaitAsync: tsc.identifier({ text: 'awaitAsync' }), - checkAsync: tsc.identifier({ text: 'checkAsync' }), - checkItemsAsync: tsc.identifier({ text: 'checkItemsAsync' }), - customAsync: tsc.identifier({ text: 'customAsync' }), - exactOptionalAsync: tsc.identifier({ text: 'exactOptionalAsync' }), - fallbackAsync: tsc.identifier({ text: 'fallbackAsync' }), - forwardAsync: tsc.identifier({ text: 'forwardAsync' }), - getDefaultsAsync: tsc.identifier({ text: 'getDefaultsAsync' }), - getFallbacksAsync: tsc.identifier({ text: 'getFallbacksAsync' }), - intersectAsync: tsc.identifier({ text: 'intersectAsync' }), - lazyAsync: tsc.identifier({ text: 'lazyAsync' }), - looseObjectAsync: tsc.identifier({ text: 'looseObjectAsync' }), - looseTupleAsync: tsc.identifier({ text: 'looseTupleAsync' }), - mapAsync: tsc.identifier({ text: 'mapAsync' }), - nonNullableAsync: tsc.identifier({ text: 'nonNullableAsync' }), - nonNullishAsync: tsc.identifier({ text: 'nonNullishAsync' }), - nonOptionalAsync: tsc.identifier({ text: 'nonOptionalAsync' }), - nullableAsync: tsc.identifier({ text: 'nullableAsync' }), - nullishAsync: tsc.identifier({ text: 'nullishAsync' }), - objectAsync: tsc.identifier({ text: 'objectAsync' }), - objectWithRestAsync: tsc.identifier({ text: 'objectWithRestAsync' }), - optionalAsync: tsc.identifier({ text: 'optionalAsync' }), - parseAsync: tsc.identifier({ text: 'parseAsync' }), - parserAsync: tsc.identifier({ text: 'parserAsync' }), - partialAsync: tsc.identifier({ text: 'partialAsync' }), - partialCheckAsync: tsc.identifier({ text: 'partialCheckAsync' }), - pipeAsync: tsc.identifier({ text: 'pipeAsync' }), - rawCheckAsync: tsc.identifier({ text: 'rawCheckAsync' }), - rawTransformAsync: tsc.identifier({ text: 'rawTransformAsync' }), - recordAsync: tsc.identifier({ text: 'recordAsync' }), - requiredAsync: tsc.identifier({ text: 'requiredAsync' }), - returnsAsync: tsc.identifier({ text: 'returnsAsync' }), - safeParseAsync: tsc.identifier({ text: 'safeParseAsync' }), - safeParserAsync: tsc.identifier({ text: 'safeParserAsync' }), - setAsync: tsc.identifier({ text: 'setAsync' }), - strictObjectAsync: tsc.identifier({ text: 'strictObjectAsync' }), - strictTupleAsync: tsc.identifier({ text: 'strictTupleAsync' }), - transformAsync: tsc.identifier({ text: 'transformAsync' }), - tupleAsync: tsc.identifier({ text: 'tupleAsync' }), - tupleWithRestAsync: tsc.identifier({ text: 'tupleWithRestAsync' }), - undefinedableAsync: tsc.identifier({ text: 'undefinedableAsync' }), - unionAsync: tsc.identifier({ text: 'unionAsync' }), - variantAsync: tsc.identifier({ text: 'variantAsync' }), + argsAsync: 'argsAsync', + arrayAsync: 'arrayAsync', + awaitAsync: 'awaitAsync', + checkAsync: 'checkAsync', + checkItemsAsync: 'checkItemsAsync', + customAsync: 'customAsync', + exactOptionalAsync: 'exactOptionalAsync', + fallbackAsync: 'fallbackAsync', + forwardAsync: 'forwardAsync', + getDefaultsAsync: 'getDefaultsAsync', + getFallbacksAsync: 'getFallbacksAsync', + intersectAsync: 'intersectAsync', + lazyAsync: 'lazyAsync', + looseObjectAsync: 'looseObjectAsync', + looseTupleAsync: 'looseTupleAsync', + mapAsync: 'mapAsync', + nonNullableAsync: 'nonNullableAsync', + nonNullishAsync: 'nonNullishAsync', + nonOptionalAsync: 'nonOptionalAsync', + nullableAsync: 'nullableAsync', + nullishAsync: 'nullishAsync', + objectAsync: 'objectAsync', + objectWithRestAsync: 'objectWithRestAsync', + optionalAsync: 'optionalAsync', + parseAsync: 'parseAsync', + parserAsync: 'parserAsync', + partialAsync: 'partialAsync', + partialCheckAsync: 'partialCheckAsync', + pipeAsync: 'pipeAsync', + rawCheckAsync: 'rawCheckAsync', + rawTransformAsync: 'rawTransformAsync', + recordAsync: 'recordAsync', + requiredAsync: 'requiredAsync', + returnsAsync: 'returnsAsync', + safeParseAsync: 'safeParseAsync', + safeParserAsync: 'safeParserAsync', + setAsync: 'setAsync', + strictObjectAsync: 'strictObjectAsync', + strictTupleAsync: 'strictTupleAsync', + transformAsync: 'transformAsync', + tupleAsync: 'tupleAsync', + tupleWithRestAsync: 'tupleWithRestAsync', + undefinedableAsync: 'undefinedableAsync', + unionAsync: 'unionAsync', + variantAsync: 'variantAsync', }, /** * {@link https://valibot.dev/api/#methods Methods} */ methods: { - assert: tsc.identifier({ text: 'assert' }), - config: tsc.identifier({ text: 'config' }), - fallback: tsc.identifier({ text: 'fallback' }), - flatten: tsc.identifier({ text: 'flatten' }), - forward: tsc.identifier({ text: 'forward' }), - getDefault: tsc.identifier({ text: 'getDefault' }), - getDefaults: tsc.identifier({ text: 'getDefaults' }), - getDescription: tsc.identifier({ text: 'getDescription' }), - getFallback: tsc.identifier({ text: 'getFallback' }), - getFallbacks: tsc.identifier({ text: 'getFallbacks' }), - getMetadata: tsc.identifier({ text: 'getMetadata' }), - getTitle: tsc.identifier({ text: 'getTitle' }), - is: tsc.identifier({ text: 'is' }), - keyof: tsc.identifier({ text: 'keyof' }), - message: tsc.identifier({ text: 'message' }), - omit: tsc.identifier({ text: 'omit' }), - parse: tsc.identifier({ text: 'parse' }), - parser: tsc.identifier({ text: 'parser' }), - partial: tsc.identifier({ text: 'partial' }), - pick: tsc.identifier({ text: 'pick' }), - pipe: tsc.identifier({ text: 'pipe' }), - required: tsc.identifier({ text: 'required' }), - safeParse: tsc.identifier({ text: 'safeParse' }), - safeParser: tsc.identifier({ text: 'safeParser' }), - summarize: tsc.identifier({ text: 'summarize' }), - unwrap: tsc.identifier({ text: 'unwrap' }), + assert: 'assert', + config: 'config', + fallback: 'fallback', + flatten: 'flatten', + forward: 'forward', + getDefault: 'getDefault', + getDefaults: 'getDefaults', + getDescription: 'getDescription', + getFallback: 'getFallback', + getFallbacks: 'getFallbacks', + getMetadata: 'getMetadata', + getTitle: 'getTitle', + is: 'is', + keyof: 'keyof', + message: 'message', + omit: 'omit', + parse: 'parse', + parser: 'parser', + partial: 'partial', + pick: 'pick', + pipe: 'pipe', + required: 'required', + safeParse: 'safeParse', + safeParser: 'safeParser', + summarize: 'summarize', + unwrap: 'unwrap', }, /** * {@link https://valibot.dev/api/#schemas Schemas} */ schemas: { - any: tsc.identifier({ text: 'any' }), - array: tsc.identifier({ text: 'array' }), - bigInt: tsc.identifier({ text: 'bigint' }), - blob: tsc.identifier({ text: 'blob' }), - boolean: tsc.identifier({ text: 'boolean' }), - custom: tsc.identifier({ text: 'custom' }), - date: tsc.identifier({ text: 'date' }), - enum: tsc.identifier({ text: 'enum' }), - exactOptional: tsc.identifier({ text: 'exactOptional' }), - file: tsc.identifier({ text: 'file' }), - function: tsc.identifier({ text: 'function' }), - instance: tsc.identifier({ text: 'instance' }), - intersect: tsc.identifier({ text: 'intersect' }), - lazy: tsc.identifier({ text: 'lazy' }), - literal: tsc.identifier({ text: 'literal' }), - looseObject: tsc.identifier({ text: 'looseObject' }), - looseTuple: tsc.identifier({ text: 'looseTuple' }), - map: tsc.identifier({ text: 'map' }), - nan: tsc.identifier({ text: 'nan' }), - never: tsc.identifier({ text: 'never' }), - nonNullable: tsc.identifier({ text: 'nonNullable' }), - nonNullish: tsc.identifier({ text: 'nonNullish' }), - nonOptional: tsc.identifier({ text: 'nonOptional' }), - null: tsc.identifier({ text: 'null' }), - nullable: tsc.identifier({ text: 'nullable' }), - nullish: tsc.identifier({ text: 'nullish' }), - number: tsc.identifier({ text: 'number' }), - object: tsc.identifier({ text: 'object' }), - objectWithRest: tsc.identifier({ text: 'objectWithRest' }), - optional: tsc.identifier({ text: 'optional' }), - picklist: tsc.identifier({ text: 'picklist' }), - promise: tsc.identifier({ text: 'promise' }), - record: tsc.identifier({ text: 'record' }), - set: tsc.identifier({ text: 'set' }), - strictObject: tsc.identifier({ text: 'strictObject' }), - strictTuple: tsc.identifier({ text: 'strictTuple' }), - string: tsc.identifier({ text: 'string' }), - symbol: tsc.identifier({ text: 'symbol' }), - tuple: tsc.identifier({ text: 'tuple' }), - tupleWithRest: tsc.identifier({ text: 'tupleWithRest' }), - undefined: tsc.identifier({ text: 'undefined' }), - undefinedable: tsc.identifier({ text: 'undefinedable' }), - union: tsc.identifier({ text: 'union' }), - unknown: tsc.identifier({ text: 'unknown' }), - variant: tsc.identifier({ text: 'variant' }), - void: tsc.identifier({ text: 'void' }), + any: 'any', + array: 'array', + bigInt: 'bigint', + blob: 'blob', + boolean: 'boolean', + custom: 'custom', + date: 'date', + enum: 'enum', + exactOptional: 'exactOptional', + file: 'file', + function: 'function', + instance: 'instance', + intersect: 'intersect', + lazy: 'lazy', + literal: 'literal', + looseObject: 'looseObject', + looseTuple: 'looseTuple', + map: 'map', + nan: 'nan', + never: 'never', + nonNullable: 'nonNullable', + nonNullish: 'nonNullish', + nonOptional: 'nonOptional', + null: 'null', + nullable: 'nullable', + nullish: 'nullish', + number: 'number', + object: 'object', + objectWithRest: 'objectWithRest', + optional: 'optional', + picklist: 'picklist', + promise: 'promise', + record: 'record', + set: 'set', + strictObject: 'strictObject', + strictTuple: 'strictTuple', + string: 'string', + symbol: 'symbol', + tuple: 'tuple', + tupleWithRest: 'tupleWithRest', + undefined: 'undefined', + undefinedable: 'undefinedable', + union: 'union', + unknown: 'unknown', + variant: 'variant', + void: 'void', }, /** * {@link https://valibot.dev/api/#storages Storages} @@ -255,7 +253,7 @@ export const identifiers = { */ types: { // TODO: implement if necessary - GenericSchema: tsc.identifier({ text: 'GenericSchema' }), + GenericSchema: 'GenericSchema', }, /** * {@link https://valibot.dev/api/#utils Utils} diff --git a/packages/openapi-ts/src/plugins/valibot/v1/plugin.ts b/packages/openapi-ts/src/plugins/valibot/v1/plugin.ts index f6ef684fae..40cd70cee1 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/plugin.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/plugin.ts @@ -1,12 +1,11 @@ import type { SymbolMeta } from '@hey-api/codegen-core'; -import type ts from 'typescript'; import { deduplicateSchema } from '~/ir/schema'; import type { IR } from '~/ir/types'; import { buildName } from '~/openApi/shared/utils/name'; import type { SchemaWithType } from '~/plugins'; import { toRef, toRefs } from '~/plugins/shared/utils/refs'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import { pathToJsonPointer, refToName } from '~/utils/ref'; import { exportAst } from '../shared/export'; @@ -51,24 +50,12 @@ export const irSchemaToAst = ({ }; const refSymbol = plugin.referenceSymbol(query); if (plugin.isSymbolRegistered(query)) { - const ref = tsc.identifier({ text: refSymbol.placeholder }); + const ref = $(refSymbol.placeholder); ast.pipes.push(ref); } else { - const lazyExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.lazy, - }), - parameters: [ - tsc.arrowFunction({ - statements: [ - tsc.returnStatement({ - expression: tsc.identifier({ text: refSymbol.placeholder }), - }), - ], - }), - ], - }); + const lazyExpression = $(v.placeholder) + .attr(identifiers.schemas.lazy) + .call($.func().do($(refSymbol.placeholder).return())); ast.pipes.push(lazyExpression); state.hasLazyExpression.value = true; } @@ -82,22 +69,9 @@ export const irSchemaToAst = ({ ast.pipes.push(typeAst.expression); if (plugin.config.metadata && schema.description) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.metadata, - }), - parameters: [ - tsc.objectExpression({ - obj: [ - { - key: 'description', - value: tsc.stringLiteral({ text: schema.description }), - }, - ], - }), - ], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.metadata) + .call($.object().prop('description', $.literal(schema.description))); ast.pipes.push(expression); } } else if (schema.items) { @@ -117,30 +91,14 @@ export const irSchemaToAst = ({ }); if (schema.logicalOperator === 'and') { - const intersectExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.intersect, - }), - parameters: [ - tsc.arrayLiteralExpression({ - elements: itemsAst, - }), - ], - }); + const intersectExpression = $(v.placeholder) + .attr(identifiers.schemas.intersect) + .call($.array(...itemsAst)); ast.pipes.push(intersectExpression); } else { - const unionExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.union, - }), - parameters: [ - tsc.arrayLiteralExpression({ - elements: itemsAst, - }), - ], - }); + const unionExpression = $(v.placeholder) + .attr(identifiers.schemas.union) + .call($.array(...itemsAst)); ast.pipes.push(unionExpression); } } else { @@ -162,45 +120,31 @@ export const irSchemaToAst = ({ if (ast.pipes.length) { if (schema.accessScope === 'read') { - const readonlyExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.readonly, - }), - }); + const readonlyExpression = $(v.placeholder) + .attr(identifiers.actions.readonly) + .call(); ast.pipes.push(readonlyExpression); } - let callParameter: ts.Expression | undefined; + let callParameter: ReturnType | undefined; if (schema.default !== undefined) { const isBigInt = schema.type === 'integer' && schema.format === 'int64'; callParameter = numberParameter({ isBigInt, value: schema.default }); if (callParameter) { ast.pipes = [ - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.optional, - }), - parameters: [ - pipesToAst({ pipes: ast.pipes, plugin }), - callParameter, - ], - }), + $(v.placeholder) + .attr(identifiers.schemas.optional) + .call(pipesToAst({ pipes: ast.pipes, plugin }), callParameter), ]; } } if (optional && !callParameter) { ast.pipes = [ - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.optional, - }), - parameters: [pipesToAst({ pipes: ast.pipes, plugin })], - }), + $(v.placeholder) + .attr(identifiers.schemas.optional) + .call(pipesToAst({ pipes: ast.pipes, plugin })), ]; } } diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts index 4d94cf523f..cad968c9d7 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/array.ts @@ -1,7 +1,7 @@ import { deduplicateSchema } from '~/ir/schema'; import type { SchemaWithType } from '~/plugins'; import { toRef } from '~/plugins/shared/utils/refs'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import { pipesToAst } from '../../shared/pipesToAst'; import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; @@ -24,24 +24,18 @@ export const arrayToAst = ({ category: 'external', resource: 'valibot.v', }); - const functionName = tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.array, - }); + const functionName = $(v.placeholder).attr(identifiers.schemas.array); if (!schema.items) { - const expression = tsc.callExpression({ - functionName, - parameters: [ - unknownToAst({ - plugin, - schema: { - type: 'unknown', - }, - state, - }), - ], - }); + const expression = functionName.call( + unknownToAst({ + plugin, + schema: { + type: 'unknown', + }, + state, + }), + ); result.pipes.push(expression); } else { schema = deduplicateSchema({ schema }); @@ -63,10 +57,7 @@ export const arrayToAst = ({ }); if (itemExpressions.length === 1) { - const expression = tsc.callExpression({ - functionName, - parameters: itemExpressions, - }); + const expression = functionName.call(...itemExpressions); result.pipes.push(expression); } else { if (schema.logicalOperator === 'and') { @@ -79,51 +70,36 @@ export const arrayToAst = ({ // TODO: parser - handle union // return tsc.typeArrayNode(tsc.typeUnionNode({ types: itemExpressions })); - const expression = tsc.callExpression({ - functionName, - parameters: [ - unknownToAst({ - plugin, - schema: { - type: 'unknown', - }, - state, - }), - ], - }); + const expression = functionName.call( + unknownToAst({ + plugin, + schema: { + type: 'unknown', + }, + state, + }), + ); result.pipes.push(expression); } } if (schema.minItems === schema.maxItems && schema.minItems !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.length, - }), - parameters: [tsc.valueToExpression({ value: schema.minItems })], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.length) + .call($.toExpr(schema.minItems)); result.pipes.push(expression); } else { if (schema.minItems !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.minLength, - }), - parameters: [tsc.valueToExpression({ value: schema.minItems })], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.minLength) + .call($.toExpr(schema.minItems)); result.pipes.push(expression); } if (schema.maxItems !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.maxLength, - }), - parameters: [tsc.valueToExpression({ value: schema.maxItems })], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.maxLength) + .call($.toExpr(schema.maxItems)); result.pipes.push(expression); } } diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts index 5f015d5451..b1b1030690 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts @@ -1,5 +1,3 @@ -import type ts from 'typescript'; - import type { SchemaWithType } from '~/plugins'; import { $ } from '~/ts-dsl'; @@ -12,7 +10,7 @@ export const booleanToAst = ({ schema, }: IrSchemaToAstOptions & { schema: SchemaWithType<'boolean'>; -}): ts.Expression => { +}): ReturnType => { const pipes: Array> = []; const v = plugin.referenceSymbol({ diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/enum.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/enum.ts index 2f76275975..df36da719d 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/enum.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/enum.ts @@ -1,7 +1,5 @@ -import type ts from 'typescript'; - import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import type { IrSchemaToAstOptions } from '../../shared/types'; import { identifiers } from '../constants'; @@ -13,19 +11,15 @@ export const enumToAst = ({ state, }: IrSchemaToAstOptions & { schema: SchemaWithType<'enum'>; -}): ts.CallExpression => { - const enumMembers: Array = []; +}): ReturnType => { + const enumMembers: Array> = []; let isNullable = false; for (const item of schema.items ?? []) { // Zod supports only string enums if (item.type === 'string' && typeof item.const === 'string') { - enumMembers.push( - tsc.stringLiteral({ - text: item.const, - }), - ); + enumMembers.push($.literal(item.const)); } else if (item.type === 'null' || item.const === null) { isNullable = true; } @@ -46,27 +40,14 @@ export const enumToAst = ({ resource: 'valibot.v', }); - let resultExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.picklist, - }), - parameters: [ - tsc.arrayLiteralExpression({ - elements: enumMembers, - multiLine: false, - }), - ], - }); + let resultExpression = $(v.placeholder) + .attr(identifiers.schemas.picklist) + .call($.array(...enumMembers)); if (isNullable) { - resultExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.nullable, - }), - parameters: [resultExpression], - }); + resultExpression = $(v.placeholder) + .attr(identifiers.schemas.nullable) + .call(resultExpression); } return resultExpression; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/index.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/index.ts index 8d5948e253..e6800609ab 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/index.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/index.ts @@ -1,6 +1,5 @@ -import type ts from 'typescript'; - import type { SchemaWithType } from '~/plugins'; +import type { $ } from '~/ts-dsl'; import { pipesToAst } from '../../shared/pipesToAst'; import type { IrSchemaToAstOptions } from '../../shared/types'; @@ -24,7 +23,7 @@ export const irSchemaWithTypeToAst = ({ schema: SchemaWithType; }): { anyType?: string; - expression: ts.Expression; + expression: ReturnType; } => { switch (schema.type) { case 'array': diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/never.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/never.ts index 582234d16e..f2a79046fe 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/never.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/never.ts @@ -1,5 +1,5 @@ import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import type { IrSchemaToAstOptions } from '../../shared/types'; import { identifiers } from '../constants'; @@ -13,11 +13,6 @@ export const neverToAst = ({ category: 'external', resource: 'valibot.v', }); - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.never, - }), - }); + const expression = $(v.placeholder).attr(identifiers.schemas.never).call(); return expression; }; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/null.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/null.ts index 42d0566e05..25eb8de333 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/null.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/null.ts @@ -1,5 +1,5 @@ import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import type { IrSchemaToAstOptions } from '../../shared/types'; import { identifiers } from '../constants'; @@ -13,11 +13,6 @@ export const nullToAst = ({ category: 'external', resource: 'valibot.v', }); - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.null, - }), - }); + const expression = $(v.placeholder).attr(identifiers.schemas.null).call(); return expression; }; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts index 5b2817d073..25732f8637 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/number.ts @@ -1,7 +1,5 @@ -import type ts from 'typescript'; - import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import { INTEGER_FORMATS, @@ -32,23 +30,20 @@ export const numberToAst = ({ // Return early if const is defined since we can create a literal type directly without additional validation if (schema.const !== undefined && schema.const !== null) { const constValue = schema.const; - let literalValue; + let literalValue: ReturnType; // Case 1: Number with no format -> generate literal with the number if (typeof constValue === 'number' && !format) { - literalValue = tsc.ots.number(constValue); + literalValue = $.literal(constValue); } // Case 2: Number with format -> check if format needs BigInt, generate appropriate literal else if (typeof constValue === 'number' && format) { if (isBigInt) { // Format requires BigInt, convert number to BigInt - literalValue = tsc.callExpression({ - functionName: 'BigInt', - parameters: [tsc.ots.string(constValue.toString())], - }); + literalValue = $('BigInt').call($.literal(constValue)); } else { // Regular format, use number as-is - literalValue = tsc.ots.number(constValue); + literalValue = $.literal(constValue); } } // Case 3: Format that allows string -> generate BigInt literal (for int64/uint64 formats) @@ -57,10 +52,7 @@ export const numberToAst = ({ const cleanString = constValue.endsWith('n') ? constValue.slice(0, -1) : constValue; - literalValue = tsc.callExpression({ - functionName: 'BigInt', - parameters: [tsc.ots.string(cleanString)], - }); + literalValue = $('BigInt').call($.literal(cleanString)); } // Case 4: Const is typeof bigint (literal) -> transform from literal to BigInt() else if (typeof constValue === 'bigint') { @@ -69,98 +61,49 @@ export const numberToAst = ({ const cleanString = bigintString.endsWith('n') ? bigintString.slice(0, -1) : bigintString; - literalValue = tsc.callExpression({ - functionName: 'BigInt', - parameters: [tsc.ots.string(cleanString)], - }); + literalValue = $('BigInt').call($.literal(cleanString)); } // Default case: use value as-is for other types else { - literalValue = tsc.valueToExpression({ value: constValue }); + literalValue = $.toExpr(constValue); } - return tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.literal, - }), - parameters: [literalValue], - }); + return $(v.placeholder) + .attr(identifiers.schemas.literal) + .call(literalValue); } - const pipes: Array = []; + const pipes: Array> = []; // For bigint formats (int64, uint64), create union of number, string, and bigint with transform if (isBigInt) { - const unionExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.union, - }), - parameters: [ - tsc.arrayLiteralExpression({ - elements: [ - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.number, - }), - }), - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.string, - }), - }), - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.bigInt, - }), - }), - ], - multiLine: false, - }), - ], - }); + const unionExpression = $(v.placeholder) + .attr(identifiers.schemas.union) + .call( + $.array( + $(v.placeholder).attr(identifiers.schemas.number).call(), + $(v.placeholder).attr(identifiers.schemas.string).call(), + $(v.placeholder).attr(identifiers.schemas.bigInt).call(), + ), + ); pipes.push(unionExpression); // Add transform to convert to BigInt - const transformExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.transform, - }), - parameters: [ - tsc.arrowFunction({ - parameters: [{ name: 'x' }], - statements: tsc.callExpression({ - functionName: 'BigInt', - parameters: [tsc.identifier({ text: 'x' })], - }), - }), - ], - }); + const transformExpression = $(v.placeholder) + .attr(identifiers.actions.transform) + .call($.func().param('x').do($('BigInt').call('x').return())); pipes.push(transformExpression); } else { // For regular number formats, use number schema - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.number, - }), - }); + const expression = $(v.placeholder).attr(identifiers.schemas.number).call(); pipes.push(expression); } // Add integer validation for integer types (except when using bigint union) if (!isBigInt && isInteger) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.integer, - }), - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.integer) + .call(); pipes.push(expression); } @@ -172,83 +115,45 @@ export const numberToAst = ({ const maxErrorMessage = formatInfo.maxError; // Add minimum value validation - const minExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.minValue, - }), - parameters: [ - isBigInt - ? tsc.callExpression({ - functionName: 'BigInt', - parameters: [tsc.ots.string(minValue.toString())], - }) - : tsc.ots.number(minValue as number), - tsc.ots.string(minErrorMessage), - ], - }); + const minExpression = $(v.placeholder) + .attr(identifiers.actions.minValue) + .call( + isBigInt ? $('BigInt').call($.literal(minValue)) : $.literal(minValue), + $.literal(minErrorMessage), + ); pipes.push(minExpression); // Add maximum value validation - const maxExpression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.maxValue, - }), - parameters: [ - isBigInt - ? tsc.callExpression({ - functionName: 'BigInt', - parameters: [tsc.ots.string(maxValue.toString())], - }) - : tsc.ots.number(maxValue as number), - tsc.ots.string(maxErrorMessage), - ], - }); + const maxExpression = $(v.placeholder) + .attr(identifiers.actions.maxValue) + .call( + isBigInt ? $('BigInt').call($.literal(maxValue)) : $.literal(maxValue), + $.literal(maxErrorMessage), + ); pipes.push(maxExpression); } if (schema.exclusiveMinimum !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.gtValue, - }), - parameters: [ - numberParameter({ isBigInt, value: schema.exclusiveMinimum }), - ], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.gtValue) + .call(numberParameter({ isBigInt, value: schema.exclusiveMinimum })); pipes.push(expression); } else if (schema.minimum !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.minValue, - }), - parameters: [numberParameter({ isBigInt, value: schema.minimum })], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.minValue) + .call(numberParameter({ isBigInt, value: schema.minimum })); pipes.push(expression); } if (schema.exclusiveMaximum !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.ltValue, - }), - parameters: [ - numberParameter({ isBigInt, value: schema.exclusiveMaximum }), - ], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.ltValue) + .call(numberParameter({ isBigInt, value: schema.exclusiveMaximum })); pipes.push(expression); } else if (schema.maximum !== undefined) { - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.actions.maxValue, - }), - parameters: [numberParameter({ isBigInt, value: schema.maximum })], - }); + const expression = $(v.placeholder) + .attr(identifiers.actions.maxValue) + .call(numberParameter({ isBigInt, value: schema.maximum })); pipes.push(expression); } diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts index 47ed8bbf22..da80e6f042 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts @@ -1,5 +1,3 @@ -import type ts from 'typescript'; - import type { SchemaWithType } from '~/plugins'; import { toRef } from '~/plugins/shared/utils/refs'; import { $ } from '~/ts-dsl'; @@ -88,7 +86,7 @@ export const objectToAst = ({ shape.prop(name, pipesToAst({ pipes: propertyAst.pipes, plugin })); } - let additional: ts.Expression | null | undefined; + let additional: ReturnType | null | undefined; if (schema.additionalProperties && schema.additionalProperties.type) { if (schema.additionalProperties.type === 'never') { additional = null; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts index 3c2a06ffa5..1b41cf8db2 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts @@ -1,5 +1,3 @@ -import type ts from 'typescript'; - import type { SchemaWithType } from '~/plugins'; import { $ } from '~/ts-dsl'; @@ -52,7 +50,7 @@ export const stringToAst = ({ schema, }: IrSchemaToAstOptions & { schema: SchemaWithType<'string'>; -}): ts.Expression => { +}): ReturnType => { const pipes: Array> = []; const v = plugin.referenceSymbol({ diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts index 9a3e4f1a5e..3dd106d366 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/tuple.ts @@ -1,6 +1,6 @@ import type { SchemaWithType } from '~/plugins'; import { toRef } from '~/plugins/shared/utils/refs'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import { pipesToAst } from '../../shared/pipesToAst'; import type { Ast, IrSchemaToAstOptions } from '../../shared/types'; @@ -24,26 +24,12 @@ export const tupleToAst = ({ if (schema.const && Array.isArray(schema.const)) { const tupleElements = schema.const.map((value) => - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.literal, - }), - parameters: [tsc.valueToExpression({ value })], - }), + $(v.placeholder).attr(identifiers.schemas.literal).call($.toExpr(value)), ); result.pipes = [ - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.tuple, - }), - parameters: [ - tsc.arrayLiteralExpression({ - elements: tupleElements, - }), - ], - }), + $(v.placeholder) + .attr(identifiers.schemas.tuple) + .call($.array(...tupleElements)), ]; return result as Omit; } @@ -64,17 +50,9 @@ export const tupleToAst = ({ return pipesToAst({ pipes: schemaPipes.pipes, plugin }); }); result.pipes = [ - tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.tuple, - }), - parameters: [ - tsc.arrayLiteralExpression({ - elements: tupleElements, - }), - ], - }), + $(v.placeholder) + .attr(identifiers.schemas.tuple) + .call($.array(...tupleElements)), ]; return result as Omit; } diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/undefined.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/undefined.ts index 52ab435e55..bd729b699d 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/undefined.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/undefined.ts @@ -1,5 +1,5 @@ import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import type { IrSchemaToAstOptions } from '../../shared/types'; import { identifiers } from '../constants'; @@ -14,11 +14,8 @@ export const undefinedToAst = ({ resource: 'valibot.v', }); - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.undefined, - }), - }); + const expression = $(v.placeholder) + .attr(identifiers.schemas.undefined) + .call(); return expression; }; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/unknown.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/unknown.ts index 3df395f556..ae147c96d4 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/unknown.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/unknown.ts @@ -1,5 +1,5 @@ import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import type { IrSchemaToAstOptions } from '../../shared/types'; import { identifiers } from '../constants'; @@ -14,11 +14,6 @@ export const unknownToAst = ({ resource: 'valibot.v', }); - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.unknown, - }), - }); + const expression = $(v.placeholder).attr(identifiers.schemas.unknown).call(); return expression; }; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/void.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/void.ts index a331d62a31..539687ab9c 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/void.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/void.ts @@ -1,5 +1,5 @@ import type { SchemaWithType } from '~/plugins'; -import { tsc } from '~/tsc'; +import { $ } from '~/ts-dsl'; import type { IrSchemaToAstOptions } from '../../shared/types'; import { identifiers } from '../constants'; @@ -14,11 +14,6 @@ export const voidToAst = ({ resource: 'valibot.v', }); - const expression = tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: v.placeholder, - name: identifiers.schemas.void, - }), - }); + const expression = $(v.placeholder).attr(identifiers.schemas.void).call(); return expression; };