unstable_concat return type is not been propagate to the input
I have a plugin that fetches all my services.
I am not sure this is the best way it works for me. The problem is that the input type is not updated after the transformation.
Thanks
I am not sure this is the best way it works for me. The problem is that the input type is not updated after the transformation.
Thanks
export function getAllServicesPlugin() {
const t = initTRPC.context<typeof createTRPCContext>().create();
return {
pluginProc: t.procedure
.input(serviceWithDateRangeSchema)
.use(async (opts) => {
const { input, ctx } = opts;
if (input.selectedServices.selectedCategory === "specific") {
return opts.next({
input: {
dateRange: input.dateRange,
services: input.selectedServices.services,
},
});
}
const categorizedRepositories = await getCategorizedRepositories(
ctx.connection,
);
return opts.next({
input: {
dateRange: input.dateRange,
services:
input.selectedServices.selectedCategory === "all-engineering"
? Object.values(categorizedRepositories).flat()
: (categorizedRepositories[
input.selectedServices.selectedCategory
] ?? []),
},
});
}),
};
}export function getAllServicesPlugin() {
const t = initTRPC.context<typeof createTRPCContext>().create();
return {
pluginProc: t.procedure
.input(serviceWithDateRangeSchema)
.use(async (opts) => {
const { input, ctx } = opts;
if (input.selectedServices.selectedCategory === "specific") {
return opts.next({
input: {
dateRange: input.dateRange,
services: input.selectedServices.services,
},
});
}
const categorizedRepositories = await getCategorizedRepositories(
ctx.connection,
);
return opts.next({
input: {
dateRange: input.dateRange,
services:
input.selectedServices.selectedCategory === "all-engineering"
? Object.values(categorizedRepositories).flat()
: (categorizedRepositories[
input.selectedServices.selectedCategory
] ?? []),
},
});
}),
};
}const metricsRouter = createTRPCRouter({
getBranchBuildDuration: publicProcedure
.input(serviceWithDateRangeSchema)
.output(
z.object({
overTime: z.array(branchBuildDuration),
aggregativeMetric: aggregativeMetricSchema,
}),
)
.unstable_concat(allServicePlugin.pluginProc)
.query(
async ({
ctx: { connection },
input: {
dateRange: { from, to },
services,
},
}) => {
...
},
)});const metricsRouter = createTRPCRouter({
getBranchBuildDuration: publicProcedure
.input(serviceWithDateRangeSchema)
.output(
z.object({
overTime: z.array(branchBuildDuration),
aggregativeMetric: aggregativeMetricSchema,
}),
)
.unstable_concat(allServicePlugin.pluginProc)
.query(
async ({
ctx: { connection },
input: {
dateRange: { from, to },
services,
},
}) => {
...
},
)});