@tstdl/base 0.93.56 → 0.93.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,4 +7,4 @@ export type SchemaConversionOptions = {
|
|
|
7
7
|
mask?: boolean;
|
|
8
8
|
};
|
|
9
9
|
/** WARNING: *DOES NOT* cover all schemas and options. Meant for usage in schema generators like genkit, not for full schema testing in APIs etc. */
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function convertToZodV3Schema<O, I = unknown>(testable: SchemaTestable<O>, options?: SchemaConversionOptions): z.ZodType<O, ZodTypeDef, I>;
|
|
@@ -6,7 +6,7 @@ import { isArray, isNotNull, isNumber } from '../../utils/type-guards.js';
|
|
|
6
6
|
import { any, AnySchema, ArraySchema, BigIntSchema, BooleanSchema, DateSchema, DefaultSchema, DeferredSchema, EnumerationSchema, InstanceSchema, LiteralSchema, NeverSchema, NullableSchema, NumberSchema, ObjectSchema, OneOrManySchema, OptionalSchema, ReadableStreamSchema, StringSchema, SymbolSchema, TransformSchema, UnionSchema, UnknownSchema } from '../schemas/index.js';
|
|
7
7
|
import { schemaTestableToSchema } from '../testable.js';
|
|
8
8
|
/** WARNING: *DOES NOT* cover all schemas and options. Meant for usage in schema generators like genkit, not for full schema testing in APIs etc. */
|
|
9
|
-
export function
|
|
9
|
+
export function convertToZodV3Schema(testable, options) {
|
|
10
10
|
const schema = schemaTestableToSchema(testable);
|
|
11
11
|
return convertToZodSchemaBase(schema, options);
|
|
12
12
|
}
|
|
@@ -82,7 +82,7 @@ function convertToZodSchemaBase(schema, options) {
|
|
|
82
82
|
const propertyEntries = objectEntries(s.properties);
|
|
83
83
|
// Handle generic records (no specific properties, but has unknownProperties/Key)
|
|
84
84
|
if ((propertyEntries.length == 0) && (isNotNull(s.unknownPropertiesKey) || isNotNull(s.unknownProperties))) {
|
|
85
|
-
return z.record(
|
|
85
|
+
return z.record(convertToZodV3Schema(s.unknownPropertiesKey ?? any()), convertToZodV3Schema(s.unknownProperties ?? any()));
|
|
86
86
|
}
|
|
87
87
|
const shape = {};
|
|
88
88
|
for (const [key, propertySchema] of propertyEntries) {
|