fix: address review feedback
This commit is contained in:
1 parent
ac7e3f2ef4
commit
5ac4a4cffc
3 files changed
+32
-5
No files matched your search
@@ -24,6 +24,17 @@ const isProcedure = (value: AnyProcedure | RouterRecord): value is AnyProcedure
|
||||
|
||||
const mergeInputs = (inputs: z.ZodObject[]) => inputs.reduce((merged, input) => merged.extend(input.shape), emptyInput);
|
||||
|
||||
const getObjectInput = (input: z.ZodType) => {
|
||||
if (input instanceof z.ZodObject) return input;
|
||||
|
||||
if (input instanceof z.ZodOptional) {
|
||||
const unwrappedInput = input.unwrap();
|
||||
if (unwrappedInput instanceof z.ZodObject) return unwrappedInput;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const getMcpMetadata = (meta: unknown): McpMeta["mcp"] => {
|
||||
if (!meta || typeof meta !== "object" || !("mcp" in meta)) return undefined;
|
||||
|
||||
@@ -41,8 +52,13 @@ const getMcpMetadata = (meta: unknown): McpMeta["mcp"] => {
|
||||
|
||||
const getProcedureInput = (inputs: z.ZodType[]) => {
|
||||
if (inputs.length === 0) return emptyInput;
|
||||
if (inputs.length === 1) return inputs[0] ?? emptyInput;
|
||||
if (inputs.every((input): input is z.ZodObject => input instanceof z.ZodObject)) return mergeInputs(inputs);
|
||||
if (inputs.length === 1) {
|
||||
const input = inputs[0] ?? emptyInput;
|
||||
return getObjectInput(input) ?? input;
|
||||
}
|
||||
|
||||
const objectInputs = inputs.map(getObjectInput);
|
||||
if (objectInputs.every((input): input is z.ZodObject => input !== null)) return mergeInputs(objectInputs);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
@@ -715,8 +715,15 @@ export const integrationRouter = createTRPCRouter({
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const integration = await createIntegrationAsync(ctx.integration);
|
||||
const result = await integration.requestMediaAsync(input.mediaType, input.mediaId, input.seasons);
|
||||
mediaRequestListRequestHandler.invalidateCache();
|
||||
await mediaRequestStatsRequestHandler.invalidateCacheAsync([ctx.integration.id]);
|
||||
try {
|
||||
mediaRequestListRequestHandler.invalidateCache();
|
||||
await mediaRequestStatsRequestHandler.invalidateCacheAsync([ctx.integration.id]);
|
||||
} catch (error) {
|
||||
logger.warn("Failed to invalidate media request caches after a successful request", {
|
||||
integrationId: ctx.integration.id,
|
||||
error: String(error),
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -140,7 +140,11 @@ export const createGetSetChannel = <TData>(name: string, options: RedisChannelOp
|
||||
await requireRedisConnection(client).set(name, superjson.stringify(data), "PX", options.ttlMs);
|
||||
return;
|
||||
}
|
||||
if (options?.ttlSeconds) {
|
||||
if (options?.ttlSeconds !== undefined) {
|
||||
if (options.ttlSeconds <= 0) {
|
||||
await requireRedisConnection(client).del(name);
|
||||
return;
|
||||
}
|
||||
await requireRedisConnection(client).set(name, superjson.stringify(data), "EX", options.ttlSeconds);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user