Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/batch/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
*
* @param schema - The schema to check
*/
const isZodSchema = (schema: StandardSchemaV1): schema is RuntimeZodType =>
const isZodSchema = (schema: StandardSchemaV1) =>
schema['~standard'].vendor === SchemaVendor.Zod;

/**
Expand All @@ -40,20 +40,23 @@ const createExtendedSchema = async (options: {
const { JSONStringified } = await import(
'@aws-lambda-powertools/parser/helpers'
);
// @ts-expect-error - we know it's a Zod schema due to the runtime check earlier
schema = JSONStringified(innerSchema);
break;
}
case 'base64': {
const { Base64Encoded } = await import(
'@aws-lambda-powertools/parser/helpers'
);
// @ts-expect-error - we know it's a Zod schema due to the runtime check earlier
schema = Base64Encoded(innerSchema);
break;
}
case 'unmarshall': {
const { DynamoDBMarshalled } = await import(
'@aws-lambda-powertools/parser/helpers/dynamodb'
);
// @ts-expect-error - we know it's a Zod schema due to the runtime check earlier
schema = DynamoDBMarshalled(innerSchema);
break;
}
Expand Down
6 changes: 2 additions & 4 deletions packages/batch/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,11 @@ type ParsedRecord<TRecord, TPayload, TOldPayload = TPayload> = TRecord extends {
* Parts of the parser integration within BatchProcessor rely on Zod for schema transformations,
* however some other parts also support other Standard Schema-compatible libraries.
*
* To avoid forcing a direct dependency on Zod, we use `any` here, which is not ideal but necessary.
* To avoid forcing a direct dependency on Zod, we use `unknown` here, which is not ideal but necessary.
*
* The vendor is checked at runtime to ensure Zod is being used when required using `StandardSchemaV1['~standard'].vendor`.
*
* biome-ignore lint/suspicious/noExplicitAny: using `any` to avoid direct dependency on 'zod'
*/
type RuntimeZodType = any;
type RuntimeZodType = unknown;

export type {
BatchProcessingOptions,
Expand Down
Loading