@chronark/zod-bird
Advanced tools
Comparing version 0.3.1-canary.0 to 0.3.1-canary.1
@@ -87,6 +87,6 @@ import { z } from 'zod'; | ||
}>; | ||
buildIngestEndpoint<TEvent extends Record<string, unknown>>(req: { | ||
buildIngestEndpoint<TOutput extends Record<string, unknown>, TInput = TOutput>(req: { | ||
datasource: string; | ||
event: z.ZodSchema<TEvent, any, any>; | ||
}): (events: TEvent | TEvent[]) => Promise<z.infer<typeof eventIngestReponseData>>; | ||
event: z.ZodSchema<TOutput, z.ZodTypeDef, TInput>; | ||
}): (events: TInput | TInput[]) => Promise<z.infer<typeof eventIngestReponseData>>; | ||
} | ||
@@ -113,8 +113,8 @@ | ||
}>; | ||
buildIngestEndpoint<TEvent extends Record<string, unknown>>(req: { | ||
buildIngestEndpoint<TOutput extends Record<string, unknown>, TInput = TOutput>(req: { | ||
datasource: string; | ||
event: z.ZodSchema<TEvent, any, any>; | ||
}): (events: TEvent | TEvent[]) => Promise<z.infer<typeof eventIngestReponseData>>; | ||
event: z.ZodSchema<TOutput, z.ZodTypeDef, TInput>; | ||
}): (events: TInput | TInput[]) => Promise<z.infer<typeof eventIngestReponseData>>; | ||
} | ||
export { NoopTinybird, Tinybird }; |
{ | ||
"name": "@chronark/zod-bird", | ||
"version": "0.3.1-canary.0", | ||
"version": "0.3.1-canary.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -83,8 +83,8 @@ import { type PipeErrorResponse, eventIngestReponseData, pipeResponseWithoutData } from "./util"; | ||
public buildIngestEndpoint<TEvent extends Record<string, unknown>,>(req: { | ||
public buildIngestEndpoint<TOutput extends Record<string, unknown>, TInput = TOutput>(req: { | ||
datasource: string; | ||
event: z.ZodSchema<TEvent, any, any>; | ||
}): (events: TEvent | TEvent[]) => Promise<z.infer<typeof eventIngestReponseData>> { | ||
return async (events: TEvent | TEvent[]) => { | ||
let validatedEvents: typeof events | undefined = undefined; | ||
event: z.ZodSchema<TOutput, z.ZodTypeDef, TInput>; | ||
}): (events: TInput | TInput[]) => Promise<z.infer<typeof eventIngestReponseData>> { | ||
return async (events: TInput | TInput[]) => { | ||
let validatedEvents: TOutput | TOutput[] | undefined = undefined; | ||
if (req.event) { | ||
@@ -91,0 +91,0 @@ const v = Array.isArray(events) |
@@ -86,2 +86,12 @@ /** | ||
export const publishTransformedEvents = tb.buildIngestEndpoint({ | ||
datasource: "events__v1", | ||
event: z.object({ | ||
actor: z | ||
.object({ id: z.string(), name: z.string() }) | ||
.transform((val) => JSON.stringify(val)), | ||
}), | ||
}); | ||
// await publishEvents([{ id: "1" }, { id: "2" }]) | ||
// await publishTransformedEvents({ actor: { id: "1", name: "John" } }); |
@@ -55,8 +55,8 @@ import { z } from "zod"; | ||
public buildIngestEndpoint<TEvent extends Record<string, unknown>,>(req: { | ||
public buildIngestEndpoint<TOutput extends Record<string, unknown>, TInput = TOutput>(req: { | ||
datasource: string; | ||
event: z.ZodSchema<TEvent, any, any>; | ||
}): (events: TEvent | TEvent[]) => Promise<z.infer<typeof eventIngestReponseData>> { | ||
return async (events: TEvent | TEvent[]) => { | ||
let validatedEvents: typeof events | undefined = undefined; | ||
event: z.ZodSchema<TOutput, z.ZodTypeDef, TInput>; | ||
}): (events: TInput | TInput[]) => Promise<z.infer<typeof eventIngestReponseData>> { | ||
return async (events: TInput | TInput[]) => { | ||
let validatedEvents: TOutput | TOutput[] | undefined = undefined; | ||
if (req.event) { | ||
@@ -63,0 +63,0 @@ const v = req.event.safeParse(events); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
68918
943