mulink 1.1.2 → 1.1.4

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.
@@ -3239,10 +3239,14 @@ ${this.commentsEnabled ? " // In production, send to your logging service\n //
3239
3239
  }
3240
3240
  return parts.join("\n\n");
3241
3241
  }
3242
- buildCombinedValidationSnippet(operationName, schemaName) {
3242
+ buildCombinedValidationSnippet(operationName, schemaName, isMultiLine = false) {
3243
3243
  if (this.validationEnabled) {
3244
+ const schemaCode = isMultiLine ? `z.object({
3245
+ body: ${operationName}RequestSchema,
3246
+ params: ${operationName}ParamsSchema
3247
+ })` : schemaName;
3244
3248
  return `
3245
- ${this.commentLine("Validate and sanitize input payload", 6)} const { body, params } = await validateAndSanitizeInput(${schemaName}, parsedInput)
3249
+ ${this.commentLine("Validate and sanitize input payload", 6)} const { body, params } = await validateAndSanitizeInput(${schemaCode}, parsedInput)
3246
3250
  const validatedBody = body
3247
3251
  const validatedParams = params as z.infer<typeof ${operationName}ParamsSchema>`;
3248
3252
  }
@@ -3450,7 +3454,8 @@ ${actions}`;
3450
3454
  body: ${operationName}RequestSchema,
3451
3455
  params: ${operationName}ParamsSchema
3452
3456
  })`;
3453
- parameterProcessing = this.buildCombinedValidationSnippet(operationName, schemaName);
3457
+ const isMultiLineSchema = schemaName.includes("\n");
3458
+ parameterProcessing = this.buildCombinedValidationSnippet(operationName, schemaName, isMultiLineSchema);
3454
3459
  requestOptionsParams = this.buildRequestOptions(pathParameters, queryParameters, true, true);
3455
3460
  } else if (hasRequestBody) {
3456
3461
  schemaName = `${operationName}RequestSchema`;
@@ -3465,10 +3470,16 @@ ${actions}`;
3465
3470
  parameterProcessing = "";
3466
3471
  requestOptionsParams = "";
3467
3472
  }
3468
- const parsedInputType = hasRequestBody || hasAnyParams ? schemaName.includes("\n") ? `z.infer<typeof z.object({ body: ${operationName}RequestSchema, params: ${operationName}ParamsSchema })>` : `z.infer<typeof ${schemaName}>` : "void";
3473
+ const parsedInputType = hasRequestBody || hasAnyParams ? schemaName.includes("\n") ? `z.infer<typeof z.object({
3474
+ body: ${operationName}RequestSchema,
3475
+ params: ${operationName}ParamsSchema
3476
+ })>` : `z.infer<typeof ${schemaName}>` : "void";
3469
3477
  const ctxType = requiresAuth || hasRateLimit ? "{ user?: any; ratelimit?: { remaining: number } }" : "any";
3470
3478
  const ctxDeclaration = requiresAuth || hasRateLimit ? `ctx: ${ctxType}` : "ctx?: any";
3471
- const actionArgsType = `{ parsedInput: ${parsedInputType}; ${ctxDeclaration} }`;
3479
+ const actionArgsType = `{
3480
+ parsedInput: ${parsedInputType};
3481
+ ${ctxDeclaration}
3482
+ }`;
3472
3483
  const clientName = requiresAuth || hasRateLimit ? "authActionClient" : "actionClientWithMeta";
3473
3484
  const rateLimitCode = hasRateLimit ? `
3474
3485
  ${this.commentLine("Rate limiting", 6)} const { userAgent, ip } = await getClientInfo()
@@ -3855,6 +3866,7 @@ ${Object.keys(endpointsByTag).map((tag) => `export * from './${toValidIdentifier
3855
3866
  const staleTime = this.getStaleTime(endpoint);
3856
3867
  const pathParameters = endpoint.parameters.filter((parameter) => parameter.in === "path");
3857
3868
  const queryParameters = endpoint.parameters.filter((parameter) => parameter.in === "query");
3869
+ const hasPageParam = queryParameters.some((param) => param.name === "page");
3858
3870
  const hasSearchParams = endpoint.path.includes("search") || endpoint.path.includes("list");
3859
3871
  endpoint.parameters.length > 0;
3860
3872
  const parameterTypes = [];
@@ -3926,7 +3938,18 @@ export function ${hookName.replace("use", "useInfinite")}(${parameterTypes.lengt
3926
3938
  initialPageParam: 1,
3927
3939
  queryFn: async ({ pageParam = 1, signal }: { pageParam?: number; signal?: AbortSignal }) => {
3928
3940
  try {
3929
- const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallParams.replace(queryParamObject, "{ ...searchParams, page: pageParam, limit: searchParams.limit }")}))
3941
+ // Build query params object with only the parameters the endpoint expects
3942
+ const queryParams: Record<string, any> = {}
3943
+ ${queryParameters.map((param) => {
3944
+ if (param.name === "page" && hasPageParam) {
3945
+ return `queryParams.${param.name} = pageParam`;
3946
+ } else if (param.name === "limit") {
3947
+ return `queryParams.${param.name} = searchParams.limit`;
3948
+ } else {
3949
+ return `if ('${param.name}' in searchParams) queryParams.${param.name} = searchParams.${param.name}`;
3950
+ }
3951
+ }).join("\n ")}
3952
+ const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallParams.replace(queryParamObject, "{ query: queryParams }")}))
3930
3953
  return result
3931
3954
  } catch (error) {
3932
3955
  handleActionError(error)
@@ -9751,5 +9774,5 @@ exports.VersionChecker = VersionChecker;
9751
9774
  exports.__name = __name;
9752
9775
  exports.checkAndNotifyUpdates = checkAndNotifyUpdates;
9753
9776
  exports.createBridgeVersionChecker = createBridgeVersionChecker;
9754
- //# sourceMappingURL=chunk-LTXRMKAN.cjs.map
9755
- //# sourceMappingURL=chunk-LTXRMKAN.cjs.map
9777
+ //# sourceMappingURL=chunk-FH22JEFH.cjs.map
9778
+ //# sourceMappingURL=chunk-FH22JEFH.cjs.map