mulink 1.1.4 → 1.1.6
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/{chunk-FH22JEFH.cjs → chunk-GJQLMHP7.cjs} +53 -25
- package/dist/lib/chunk-GJQLMHP7.cjs.map +1 -0
- package/dist/lib/{chunk-ANAYISGK.js → chunk-OSS5TUD2.js} +53 -25
- package/dist/lib/chunk-OSS5TUD2.js.map +1 -0
- package/dist/lib/cli.cjs +16 -16
- package/dist/lib/cli.js +1 -1
- package/dist/lib/client.cjs +18 -18
- package/dist/lib/client.js +2 -2
- package/dist/lib/index.cjs +15 -15
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
- package/dist/lib/chunk-ANAYISGK.js.map +0 -1
- package/dist/lib/chunk-FH22JEFH.cjs.map +0 -1
|
@@ -3464,16 +3464,10 @@ ${actions}`;
|
|
|
3464
3464
|
parameterProcessing = "";
|
|
3465
3465
|
requestOptionsParams = "";
|
|
3466
3466
|
}
|
|
3467
|
-
const parsedInputType = hasRequestBody || hasAnyParams ? schemaName.includes("\n") ? `z.infer<typeof z.object({
|
|
3468
|
-
body: ${operationName}RequestSchema,
|
|
3469
|
-
params: ${operationName}ParamsSchema
|
|
3470
|
-
})>` : `z.infer<typeof ${schemaName}>` : "void";
|
|
3467
|
+
const parsedInputType = hasRequestBody || hasAnyParams ? schemaName.includes("\n") ? `z.infer<typeof z.object({ body: ${operationName}RequestSchema, params: ${operationName}ParamsSchema })>` : `z.infer<typeof ${schemaName}>` : "void";
|
|
3471
3468
|
const ctxType = requiresAuth || hasRateLimit ? "{ user?: any; ratelimit?: { remaining: number } }" : "any";
|
|
3472
3469
|
const ctxDeclaration = requiresAuth || hasRateLimit ? `ctx: ${ctxType}` : "ctx?: any";
|
|
3473
|
-
const actionArgsType = `{
|
|
3474
|
-
parsedInput: ${parsedInputType};
|
|
3475
|
-
${ctxDeclaration}
|
|
3476
|
-
}`;
|
|
3470
|
+
const actionArgsType = schemaName.includes("\n") ? `{ parsedInput: z.infer<typeof z.object({ body: ${operationName}RequestSchema, params: ${operationName}ParamsSchema })>; ${ctxDeclaration} }` : `{ parsedInput: ${parsedInputType}; ${ctxDeclaration} }`;
|
|
3477
3471
|
const clientName = requiresAuth || hasRateLimit ? "authActionClient" : "actionClientWithMeta";
|
|
3478
3472
|
const rateLimitCode = hasRateLimit ? `
|
|
3479
3473
|
${this.commentLine("Rate limiting", 6)} const { userAgent, ip } = await getClientInfo()
|
|
@@ -3943,7 +3937,7 @@ export function ${hookName.replace("use", "useInfinite")}(${parameterTypes.lengt
|
|
|
3943
3937
|
return `if ('${param.name}' in searchParams) queryParams.${param.name} = searchParams.${param.name}`;
|
|
3944
3938
|
}
|
|
3945
3939
|
}).join("\n ")}
|
|
3946
|
-
const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallParams.replace(queryParamObject, "
|
|
3940
|
+
const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallParams.replace(queryParamObject, "...queryParams")}))
|
|
3947
3941
|
return result
|
|
3948
3942
|
} catch (error) {
|
|
3949
3943
|
handleActionError(error)
|
|
@@ -4401,8 +4395,15 @@ export function useBridgeQuery<TData = unknown, TError = Error>(
|
|
|
4401
4395
|
refetchOnWindowFocus: true,
|
|
4402
4396
|
refetchOnReconnect: true,
|
|
4403
4397
|
refetchOnMount: 'always',
|
|
4404
|
-
|
|
4405
|
-
|
|
4398
|
+
// React Query v5: placeholderData cannot be a function type
|
|
4399
|
+
// Use keepPreviousData pattern: return previousData if it exists and is not a function
|
|
4400
|
+
placeholderData: (previousData) => {
|
|
4401
|
+
if (previousData === undefined) return undefined
|
|
4402
|
+
// Type guard: ensure we don't return a function (React Query v5 requirement)
|
|
4403
|
+
if (typeof previousData === 'function') return undefined
|
|
4404
|
+
return previousData
|
|
4405
|
+
} as any,
|
|
4406
|
+
retry: (failureCount: number, error: TError) => {
|
|
4406
4407
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
4407
4408
|
return failureCount < 3
|
|
4408
4409
|
},
|
|
@@ -4428,7 +4429,7 @@ export function useBridgeInfiniteQuery<TData = unknown, TError = Error>(
|
|
|
4428
4429
|
refetchOnWindowFocus: true,
|
|
4429
4430
|
refetchOnReconnect: true,
|
|
4430
4431
|
refetchOnMount: 'always',
|
|
4431
|
-
retry: (failureCount: number, error:
|
|
4432
|
+
retry: (failureCount: number, error: TError) => {
|
|
4432
4433
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
4433
4434
|
return failureCount < 3
|
|
4434
4435
|
},
|
|
@@ -4450,7 +4451,7 @@ export function useBridgeSuspenseQuery<TData = unknown, TError = Error>(
|
|
|
4450
4451
|
queryFn: queryFn as QueryFunction<TData, QueryKey>,
|
|
4451
4452
|
staleTime: 5 * 60 * 1000,
|
|
4452
4453
|
gcTime: 10 * 60 * 1000,
|
|
4453
|
-
retry: (failureCount: number, error:
|
|
4454
|
+
retry: (failureCount: number, error: TError) => {
|
|
4454
4455
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
4455
4456
|
return failureCount < 3
|
|
4456
4457
|
},
|
|
@@ -7632,7 +7633,7 @@ var UploadGenerator = class {
|
|
|
7632
7633
|
};
|
|
7633
7634
|
const presignedEndpoint = presignedEnabled ? this.findPresignedEndpoint(schema.endpoints) || (extractedUploadConfig.presignedEndpoint ? schema.endpoints.find((e) => e.path === extractedUploadConfig.presignedEndpoint) || null : null) : null;
|
|
7634
7635
|
generatedFiles.push(this.generateUploadUtilities(uploadProvider, uploadStrategy, presignedEndpoint));
|
|
7635
|
-
generatedFiles.push(this.generateUseUploadFileHook(uploadProvider, uploadStrategy));
|
|
7636
|
+
generatedFiles.push(this.generateUseUploadFileHook(uploadProvider, uploadStrategy, context));
|
|
7636
7637
|
for (const endpoint of uploadEndpoints) {
|
|
7637
7638
|
generatedFiles.push(this.generateUploadHook(
|
|
7638
7639
|
endpoint,
|
|
@@ -8281,8 +8282,19 @@ export function ${hookName}Upload(options?: {
|
|
|
8281
8282
|
const method = this.toPascalCase(endpoint.method.toLowerCase());
|
|
8282
8283
|
return [...pathParts, method].join("");
|
|
8283
8284
|
}
|
|
8284
|
-
generateUseUploadFileHook(uploadProvider, uploadStrategy) {
|
|
8285
|
+
generateUseUploadFileHook(uploadProvider, uploadStrategy, context) {
|
|
8285
8286
|
const uploadUtilsImport = this.buildImportPath("services/uploadUtils");
|
|
8287
|
+
const uploadEndpoints = context?.schema?.endpoints?.filter(
|
|
8288
|
+
(e) => e.metadata?.fileUpload || e.path.toLowerCase().includes("upload") || e.operationId && e.operationId.toLowerCase().includes("upload")
|
|
8289
|
+
) || [];
|
|
8290
|
+
const firstUploadEndpoint = uploadEndpoints[0];
|
|
8291
|
+
let uploadMethodName = "uploadFile";
|
|
8292
|
+
let uploadClientTag = "files";
|
|
8293
|
+
if (firstUploadEndpoint) {
|
|
8294
|
+
this.getOperationName(firstUploadEndpoint);
|
|
8295
|
+
uploadMethodName = toActionName(firstUploadEndpoint.operationId || firstUploadEndpoint.id);
|
|
8296
|
+
uploadClientTag = toValidIdentifier(firstUploadEndpoint.tags[0] || "files");
|
|
8297
|
+
}
|
|
8286
8298
|
const content = `'use client'
|
|
8287
8299
|
|
|
8288
8300
|
import { useMutation } from '@tanstack/react-query'
|
|
@@ -8328,13 +8340,21 @@ export function useUploadFile(options?: {
|
|
|
8328
8340
|
// Mulink will generate the upload endpoint from your OpenAPI schema
|
|
8329
8341
|
const { apiClient } = await import('${this.buildImportPath("client")}')
|
|
8330
8342
|
|
|
8331
|
-
// Try to find upload endpoint in
|
|
8343
|
+
// Try to find upload endpoint in generated client
|
|
8332
8344
|
try {
|
|
8333
|
-
|
|
8334
|
-
|
|
8345
|
+
${firstUploadEndpoint ? `
|
|
8346
|
+
// Use the detected upload endpoint
|
|
8347
|
+
const response = await apiClient.${uploadClientTag}?.${uploadMethodName}?.({
|
|
8348
|
+
body: formData as any,
|
|
8349
|
+
params: { query: {} }
|
|
8350
|
+
})` : `
|
|
8351
|
+
// Try common upload endpoint names
|
|
8352
|
+
const response = await apiClient.files?.uploadFileApiV1FilesUploadPost?.({
|
|
8353
|
+
body: formData as any,
|
|
8354
|
+
params: { query: {} }
|
|
8335
8355
|
}) || await apiClient.default?.uploadFile?.({
|
|
8336
8356
|
body: formData as any
|
|
8337
|
-
})
|
|
8357
|
+
})`}
|
|
8338
8358
|
return response?.data?.url || response?.data?.file_url || response?.data?.url || ''
|
|
8339
8359
|
} catch (error) {
|
|
8340
8360
|
console.warn('[Mulink] Upload endpoint not found in generated client, using fallback')
|
|
@@ -8347,13 +8367,21 @@ export function useUploadFile(options?: {
|
|
|
8347
8367
|
// Mulink will generate the upload endpoint from your OpenAPI schema
|
|
8348
8368
|
const { apiClient } = await import('${this.buildImportPath("client")}')
|
|
8349
8369
|
|
|
8350
|
-
// Try to find upload endpoint in
|
|
8370
|
+
// Try to find upload endpoint in generated client
|
|
8351
8371
|
try {
|
|
8352
|
-
|
|
8353
|
-
|
|
8372
|
+
${firstUploadEndpoint ? `
|
|
8373
|
+
// Use the detected upload endpoint
|
|
8374
|
+
const response = await apiClient.${uploadClientTag}?.${uploadMethodName}?.({
|
|
8375
|
+
body: formData as any,
|
|
8376
|
+
params: { query: {} }
|
|
8377
|
+
})` : `
|
|
8378
|
+
// Try common upload endpoint names
|
|
8379
|
+
const response = await apiClient.files?.uploadFileApiV1FilesUploadPost?.({
|
|
8380
|
+
body: formData as any,
|
|
8381
|
+
params: { query: {} }
|
|
8354
8382
|
}) || await apiClient.default?.uploadFile?.({
|
|
8355
8383
|
body: formData as any
|
|
8356
|
-
})
|
|
8384
|
+
})`}
|
|
8357
8385
|
return response?.data?.url || response?.data?.file_url || response?.data?.url || ''
|
|
8358
8386
|
} catch (error) {
|
|
8359
8387
|
console.warn('[Mulink] Upload endpoint not found in generated client, using fallback')
|
|
@@ -9754,5 +9782,5 @@ ${errorMessages}`,
|
|
|
9754
9782
|
};
|
|
9755
9783
|
|
|
9756
9784
|
export { BridgeCore, BridgeError, BridgeLogger, ConfigurationLoader, FileSystemManager, GenerationError, LogLevel, NextJsCodeGenerator, OpenApiSchemaParser, SchemaParseError, ValidationError, VersionChecker, __name, checkAndNotifyUpdates, createBridgeVersionChecker };
|
|
9757
|
-
//# sourceMappingURL=chunk-
|
|
9758
|
-
//# sourceMappingURL=chunk-
|
|
9785
|
+
//# sourceMappingURL=chunk-OSS5TUD2.js.map
|
|
9786
|
+
//# sourceMappingURL=chunk-OSS5TUD2.js.map
|