mulink 1.0.9 → 1.1.0
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-7WH2SJ23.cjs → chunk-MBBHRJ7J.cjs} +91 -10
- package/dist/lib/chunk-MBBHRJ7J.cjs.map +1 -0
- package/dist/lib/{chunk-EED6FUEW.js → chunk-ONA3ENYR.js} +91 -10
- package/dist/lib/chunk-ONA3ENYR.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-7WH2SJ23.cjs.map +0 -1
- package/dist/lib/chunk-EED6FUEW.js.map +0 -1
|
@@ -3499,7 +3499,7 @@ ${this.commentLine("Rate limiting", 6)} const { userAgent, ip } = await get
|
|
|
3499
3499
|
try {${rateLimitCode}${parameterProcessing}
|
|
3500
3500
|
|
|
3501
3501
|
// Execute API call with enhanced error handling
|
|
3502
|
-
const response = await apiClient.${tagName}.${actionName}({${requestOptionsParams}${requestOptionsParams ? "," : ""}
|
|
3502
|
+
const response = await apiClient.${tagName}.${actionName}({${requestOptionsParams}${requestOptionsParams && !requestOptionsParams.trim().endsWith(",") ? "," : ""}
|
|
3503
3503
|
config: {
|
|
3504
3504
|
timeout: ${endpoint.metadata.timeout || this.configuration.api.timeout},
|
|
3505
3505
|
retries: ${this.configuration.api.retries},
|
|
@@ -3565,7 +3565,7 @@ ${this.commentLine("Process file with compression and validation if enabled", 10
|
|
|
3565
3565
|
try {${rateLimitCode}${parameterProcessing}${fileUploadCode}
|
|
3566
3566
|
|
|
3567
3567
|
// Execute API call with enhanced configuration
|
|
3568
|
-
const response = await apiClient.${tagName}.${actionName}({${requestOptionsParams}${requestOptionsParams ? "," : ""}
|
|
3568
|
+
const response = await apiClient.${tagName}.${actionName}({${requestOptionsParams}${requestOptionsParams && !requestOptionsParams.trim().endsWith(",") ? "," : ""}
|
|
3569
3569
|
config: {
|
|
3570
3570
|
timeout: ${endpoint.metadata.timeout || this.configuration.api.timeout},
|
|
3571
3571
|
retries: ${this.configuration.api.retries},
|
|
@@ -3745,7 +3745,7 @@ var HookGenerator = class {
|
|
|
3745
3745
|
...reactQueryImports.length > 0 ? [`import { ${reactQueryImports.join(", ")} } from '@tanstack/react-query'`] : [],
|
|
3746
3746
|
...reactImports.length > 0 ? [`import { ${reactImports.join(", ")} } from 'react'`] : [],
|
|
3747
3747
|
...hasSearchParams ? ["import { parseAsInteger, parseAsString, useQueryStates } from 'nuqs'"] : [],
|
|
3748
|
-
...hasMutations ? ["import { toast } from 'sonner'"] : [],
|
|
3748
|
+
...hasQueries || hasMutations ? ["import { toast } from 'sonner'"] : [],
|
|
3749
3749
|
`import { ${[...queries, ...mutations].map((endpoint) => toActionName(endpoint.operationId || endpoint.id)).join(", ")} } from '${actionsImport}'`,
|
|
3750
3750
|
...schemaImportsString ? [`import {
|
|
3751
3751
|
${schemaImportsString}
|
|
@@ -4078,7 +4078,7 @@ ${cancelQueriesCode}
|
|
|
4078
4078
|
// Optimistic update (if provided)
|
|
4079
4079
|
if (options?.optimisticUpdate) {
|
|
4080
4080
|
const optimisticValue = options.optimisticUpdate(variables)
|
|
4081
|
-
setOptimisticData(optimisticValue)
|
|
4081
|
+
setOptimisticData(optimisticValue as ${inputType})
|
|
4082
4082
|
}
|
|
4083
4083
|
|
|
4084
4084
|
return {}
|
|
@@ -7824,6 +7824,7 @@ export function createUploadFormData(
|
|
|
7824
7824
|
const useXHR = progressConfig?.useXHR !== false;
|
|
7825
7825
|
const presignedActionName = presignedEndpoint ? toActionName(presignedEndpoint.operationId || presignedEndpoint.id) : null;
|
|
7826
7826
|
const presignedOperationName = presignedEndpoint ? this.getOperationName(presignedEndpoint) : null;
|
|
7827
|
+
const paramsSchemaName = endpoint.parameters.length > 0 ? `${operationName}ParamsSchema` : null;
|
|
7827
7828
|
const imports = [
|
|
7828
7829
|
`'use client'`,
|
|
7829
7830
|
``,
|
|
@@ -7833,7 +7834,7 @@ export function createUploadFormData(
|
|
|
7833
7834
|
presignedEnabled && presignedActionName ? `import { ${presignedActionName} } from '${actionsImport}'` : null,
|
|
7834
7835
|
`import { validateFile, compressFile, createUploadFormData, type UploadConfig } from '${uploadUtilsImport}'`,
|
|
7835
7836
|
`import type { z } from 'zod'`,
|
|
7836
|
-
`import type { ${operationName}RequestSchema, ${operationName}ResponseSchema } from '${schemasImport}'`,
|
|
7837
|
+
`import type { ${operationName}RequestSchema, ${operationName}ResponseSchema${paramsSchemaName ? `, ${paramsSchemaName}` : ""} } from '${schemasImport}'`,
|
|
7837
7838
|
presignedEnabled && presignedOperationName ? `import type { ${presignedOperationName}RequestSchema, ${presignedOperationName}ResponseSchema } from '${schemasImport}'` : null
|
|
7838
7839
|
].filter(Boolean).join("\n");
|
|
7839
7840
|
const presignedHelpers = presignedEnabled ? `
|
|
@@ -8090,6 +8091,30 @@ async function uploadViaBackendApi(
|
|
|
8090
8091
|
${presignedHelpers}
|
|
8091
8092
|
${backendUploadHelper || ""}
|
|
8092
8093
|
|
|
8094
|
+
type ActionResultLike<T> = {
|
|
8095
|
+
data?: T
|
|
8096
|
+
serverError?: unknown
|
|
8097
|
+
validationErrors?: unknown
|
|
8098
|
+
}
|
|
8099
|
+
|
|
8100
|
+
async function resolveActionResult<T>(actionPromise: Promise<any>): Promise<T> {
|
|
8101
|
+
const result = await actionPromise
|
|
8102
|
+
if (result && typeof result === 'object') {
|
|
8103
|
+
const actionResult = result as ActionResultLike<T>
|
|
8104
|
+
if (actionResult.serverError) {
|
|
8105
|
+
const message = typeof actionResult.serverError === 'string' ? actionResult.serverError : 'Server action failed'
|
|
8106
|
+
throw new Error(message)
|
|
8107
|
+
}
|
|
8108
|
+
if (actionResult.validationErrors) {
|
|
8109
|
+
throw new Error('Validation failed, please check your input')
|
|
8110
|
+
}
|
|
8111
|
+
if (typeof actionResult.data !== 'undefined') {
|
|
8112
|
+
return actionResult.data as T
|
|
8113
|
+
}
|
|
8114
|
+
}
|
|
8115
|
+
return result as T
|
|
8116
|
+
}
|
|
8117
|
+
|
|
8093
8118
|
/**
|
|
8094
8119
|
* Upload hook for ${endpoint.method} ${endpoint.path}
|
|
8095
8120
|
* Features: ${presignedEnabled ? "Presigned URL upload (direct to S3/MinIO), " : ""}File validation, compression, progress tracking
|
|
@@ -8097,8 +8122,9 @@ ${backendUploadHelper || ""}
|
|
|
8097
8122
|
* Best Practice: ${presignedEnabled ? "Uses presigned URLs for direct uploads to S3/MinIO, reducing backend load" : "Standard FormData upload with progress tracking"}
|
|
8098
8123
|
*/
|
|
8099
8124
|
export type ${operationName}UploadInput = {
|
|
8100
|
-
file: File
|
|
8125
|
+
${endpoint.path.includes("multiple") ? "files: File[]" : "file: File"}
|
|
8101
8126
|
additionalFields?: Record<string, string | number | boolean>
|
|
8127
|
+
${paramsSchemaName ? "folder?: string" : ""}
|
|
8102
8128
|
}
|
|
8103
8129
|
|
|
8104
8130
|
${presignedEnabled && !fallbackEnabled ? `const directUploadsEnabled = process.env.NEXT_PUBLIC_ENABLE_DIRECT_UPLOADS !== "false"` : ""}
|
|
@@ -8112,7 +8138,46 @@ export function ${hookName}Upload(options?: {
|
|
|
8112
8138
|
const queryClient = useQueryClient()
|
|
8113
8139
|
|
|
8114
8140
|
return useMutation<z.infer<typeof ${operationName}ResponseSchema>, Error, ${operationName}UploadInput>({
|
|
8115
|
-
mutationFn: async ({ file, additionalFields }: ${operationName}UploadInput) => {
|
|
8141
|
+
mutationFn: async ({ ${endpoint.path.includes("multiple") ? "files" : "file"}, additionalFields, ${paramsSchemaName ? "folder" : ""} }: ${operationName}UploadInput) => {
|
|
8142
|
+
${endpoint.path.includes("multiple") ? `
|
|
8143
|
+
// Validate all files
|
|
8144
|
+
for (const file of files) {
|
|
8145
|
+
const validation = validateFile(file, options?.uploadConfig)
|
|
8146
|
+
if (!validation.valid) {
|
|
8147
|
+
throw new Error(validation.error || \`File validation failed for \${file.name}\`)
|
|
8148
|
+
}
|
|
8149
|
+
}
|
|
8150
|
+
|
|
8151
|
+
// Compress files if enabled
|
|
8152
|
+
const processedFiles = await Promise.all(
|
|
8153
|
+
files.map(file => compressFile(file, options?.uploadConfig?.compression?.formats))
|
|
8154
|
+
)
|
|
8155
|
+
|
|
8156
|
+
// Create FormData with all files
|
|
8157
|
+
const formData = new FormData()
|
|
8158
|
+
processedFiles.forEach((file, index) => {
|
|
8159
|
+
formData.append(\`file_\${index}\`, file)
|
|
8160
|
+
})
|
|
8161
|
+
|
|
8162
|
+
if (additionalFields) {
|
|
8163
|
+
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
8164
|
+
formData.append(key, String(value))
|
|
8165
|
+
})
|
|
8166
|
+
}
|
|
8167
|
+
|
|
8168
|
+
// Convert FormData to the format expected by the action
|
|
8169
|
+
const actionInput = {
|
|
8170
|
+
body: formData as any,
|
|
8171
|
+
params: {
|
|
8172
|
+
query: ${paramsSchemaName ? "folder ? { folder } : undefined" : "undefined"}
|
|
8173
|
+
}
|
|
8174
|
+
}
|
|
8175
|
+
|
|
8176
|
+
// Use server action for upload and extract data from SafeActionResult
|
|
8177
|
+
const result = await resolveActionResult<z.infer<typeof ${operationName}ResponseSchema>>(
|
|
8178
|
+
${actionName}(actionInput)
|
|
8179
|
+
)
|
|
8180
|
+
return result` : presignedEnabled ? uploadLogic : `
|
|
8116
8181
|
// Validate file
|
|
8117
8182
|
const validation = validateFile(file, options?.uploadConfig)
|
|
8118
8183
|
if (!validation.valid) {
|
|
@@ -8122,7 +8187,23 @@ export function ${hookName}Upload(options?: {
|
|
|
8122
8187
|
// Compress if enabled
|
|
8123
8188
|
const processedFile = await compressFile(file, options?.uploadConfig?.compression?.formats)
|
|
8124
8189
|
|
|
8125
|
-
|
|
8190
|
+
// Create FormData for the file
|
|
8191
|
+
const formData = createUploadFormData(processedFile, additionalFields)
|
|
8192
|
+
|
|
8193
|
+
// Convert FormData to the format expected by the action
|
|
8194
|
+
const actionInput = {
|
|
8195
|
+
body: formData as any,
|
|
8196
|
+
params: {
|
|
8197
|
+
query: ${paramsSchemaName ? "folder ? { folder } : undefined" : "undefined"}
|
|
8198
|
+
}
|
|
8199
|
+
}
|
|
8200
|
+
|
|
8201
|
+
${progressEnabled && useXHR ? `return await uploadViaBackendApi(formData, options?.onProgress)` : `
|
|
8202
|
+
// Use server action for upload and extract data from SafeActionResult
|
|
8203
|
+
const result = await resolveActionResult<z.infer<typeof ${operationName}ResponseSchema>>(
|
|
8204
|
+
${actionName}(actionInput)
|
|
8205
|
+
)
|
|
8206
|
+
return result`}`}
|
|
8126
8207
|
},
|
|
8127
8208
|
|
|
8128
8209
|
onSuccess: (data: z.infer<typeof ${operationName}ResponseSchema>) => {
|
|
@@ -9634,5 +9715,5 @@ ${errorMessages}`,
|
|
|
9634
9715
|
};
|
|
9635
9716
|
|
|
9636
9717
|
export { BridgeCore, BridgeError, BridgeLogger, ConfigurationLoader, FileSystemManager, GenerationError, LogLevel, NextJsCodeGenerator, OpenApiSchemaParser, SchemaParseError, ValidationError, VersionChecker, __name, checkAndNotifyUpdates, createBridgeVersionChecker };
|
|
9637
|
-
//# sourceMappingURL=chunk-
|
|
9638
|
-
//# sourceMappingURL=chunk-
|
|
9718
|
+
//# sourceMappingURL=chunk-ONA3ENYR.js.map
|
|
9719
|
+
//# sourceMappingURL=chunk-ONA3ENYR.js.map
|