mulink 1.0.3 → 1.0.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/{chunk-RGLCJDOY.cjs → chunk-GKRRC2YD.cjs} +132 -88
- package/dist/lib/chunk-GKRRC2YD.cjs.map +1 -0
- package/dist/lib/{chunk-IVMVPQUK.js → chunk-KCNMWAI2.js} +132 -88
- package/dist/lib/chunk-KCNMWAI2.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-IVMVPQUK.js.map +0 -1
- package/dist/lib/chunk-RGLCJDOY.cjs.map +0 -1
|
@@ -1038,8 +1038,8 @@ import { cache } from 'react'
|
|
|
1038
1038
|
* We use dynamic imports to avoid bundling them in the client
|
|
1039
1039
|
*/
|
|
1040
1040
|
let serverOnlyModules: {
|
|
1041
|
-
cookies?: () => import('next/headers').
|
|
1042
|
-
headers?: () => import('next/headers').
|
|
1041
|
+
cookies?: () => Awaited<ReturnType<typeof import('next/headers').cookies>>
|
|
1042
|
+
headers?: () => Awaited<ReturnType<typeof import('next/headers').headers>>
|
|
1043
1043
|
after?: (fn: () => void | Promise<void>) => void
|
|
1044
1044
|
updateTag?: (tag: string) => void
|
|
1045
1045
|
} | null = null
|
|
@@ -1342,12 +1342,14 @@ export class BaseApiClient {
|
|
|
1342
1342
|
|
|
1343
1343
|
// Try external auth service
|
|
1344
1344
|
${this.configuration.auth?.enabled ? `try {
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1345
|
+
const authModule = await import('${authPath}').catch(() => null)
|
|
1346
|
+
if (authModule && authModule.${tokenGetter}) {
|
|
1347
|
+
const session = await authModule.${tokenGetter}()
|
|
1348
|
+
|
|
1349
|
+
if (session?.accessToken) {
|
|
1350
|
+
getAuthHeaders.Authorization = \`Bearer \${session.accessToken}\`
|
|
1351
|
+
return getAuthHeaders
|
|
1352
|
+
}
|
|
1351
1353
|
}
|
|
1352
1354
|
} catch (error) {
|
|
1353
1355
|
// Auth not available or error accessing
|
|
@@ -1546,7 +1548,9 @@ export class BaseApiClient {
|
|
|
1546
1548
|
const requestPromise = this.executeRequestInternal<TData>(
|
|
1547
1549
|
method, url, body, headers, fetchOptions, timeout, retries,
|
|
1548
1550
|
retryDelay, retryCondition, validateResponse, skipAuth,
|
|
1549
|
-
responseSchema, requestId, [...this.middleware, ...middleware]
|
|
1551
|
+
responseSchema, requestId, [...this.middleware, ...middleware],
|
|
1552
|
+
cacheTags, revalidate, connection, updateTag
|
|
1553
|
+
cacheTags, revalidate, connection, updateTag
|
|
1550
1554
|
)
|
|
1551
1555
|
|
|
1552
1556
|
requestCache.set(dedupeKey, requestPromise)
|
|
@@ -1562,7 +1566,9 @@ export class BaseApiClient {
|
|
|
1562
1566
|
return this.executeRequestInternal<TData>(
|
|
1563
1567
|
method, url, body, headers, fetchOptions, timeout, retries,
|
|
1564
1568
|
retryDelay, retryCondition, validateResponse, skipAuth,
|
|
1565
|
-
responseSchema, requestId, [...this.middleware, ...middleware]
|
|
1569
|
+
responseSchema, requestId, [...this.middleware, ...middleware],
|
|
1570
|
+
cacheTags, revalidate, connection, updateTag
|
|
1571
|
+
cacheTags, revalidate, connection, updateTag
|
|
1566
1572
|
)
|
|
1567
1573
|
}
|
|
1568
1574
|
|
|
@@ -1581,7 +1587,11 @@ export class BaseApiClient {
|
|
|
1581
1587
|
skipAuth: boolean,
|
|
1582
1588
|
responseSchema?: z.ZodSchema<TData>,
|
|
1583
1589
|
requestId?: string,
|
|
1584
|
-
middleware: RequestMiddleware[] = []
|
|
1590
|
+
middleware: RequestMiddleware[] = [],
|
|
1591
|
+
cacheTags: string[] = [],
|
|
1592
|
+
revalidate?: number | false,
|
|
1593
|
+
connection?: 'keep-alive' | 'close',
|
|
1594
|
+
updateTag?: (tag: string) => void
|
|
1585
1595
|
): Promise<ClientResponse<TData>> {
|
|
1586
1596
|
const startTime = Date.now()
|
|
1587
1597
|
|
|
@@ -1668,7 +1678,7 @@ export class BaseApiClient {
|
|
|
1668
1678
|
|
|
1669
1679
|
if (tagUpdater && typeof window === 'undefined') {
|
|
1670
1680
|
// Update cache tags on server-side only
|
|
1671
|
-
cacheTags.forEach(tag => {
|
|
1681
|
+
cacheTags.forEach((tag: string) => {
|
|
1672
1682
|
try {
|
|
1673
1683
|
tagUpdater(tag)
|
|
1674
1684
|
} catch (error) {
|
|
@@ -2555,13 +2565,23 @@ var SchemaGenerator = class {
|
|
|
2555
2565
|
const result = [];
|
|
2556
2566
|
const schemaMap = /* @__PURE__ */ new Map();
|
|
2557
2567
|
const dependencyGraph = /* @__PURE__ */ new Map();
|
|
2568
|
+
const enumSchemas = [];
|
|
2569
|
+
const otherSchemas = [];
|
|
2558
2570
|
for (const schema of schemas) {
|
|
2571
|
+
const isEnum = this.isEnumSchema(schema);
|
|
2572
|
+
if (isEnum) {
|
|
2573
|
+
enumSchemas.push(schema);
|
|
2574
|
+
} else {
|
|
2575
|
+
otherSchemas.push(schema);
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
for (const schema of [...enumSchemas, ...otherSchemas]) {
|
|
2559
2579
|
if (!schemaMap.has(schema.name)) {
|
|
2560
2580
|
schemaMap.set(schema.name, schema);
|
|
2561
2581
|
dependencyGraph.set(schema.name, /* @__PURE__ */ new Set());
|
|
2562
2582
|
}
|
|
2563
2583
|
}
|
|
2564
|
-
for (const schema of
|
|
2584
|
+
for (const schema of [...enumSchemas, ...otherSchemas]) {
|
|
2565
2585
|
const dependencies = this.findSchemaDependencies(schema);
|
|
2566
2586
|
for (const dep of dependencies) {
|
|
2567
2587
|
if (schemaMap.has(dep)) {
|
|
@@ -2591,13 +2611,25 @@ var SchemaGenerator = class {
|
|
|
2591
2611
|
visiting.delete(schemaName);
|
|
2592
2612
|
visited.add(schemaName);
|
|
2593
2613
|
}, "visit");
|
|
2594
|
-
for (const schema of
|
|
2614
|
+
for (const schema of enumSchemas) {
|
|
2615
|
+
if (!visited.has(schema.name)) {
|
|
2616
|
+
visit(schema.name);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
for (const schema of otherSchemas) {
|
|
2595
2620
|
if (!visited.has(schema.name)) {
|
|
2596
2621
|
visit(schema.name);
|
|
2597
2622
|
}
|
|
2598
2623
|
}
|
|
2599
2624
|
return result;
|
|
2600
2625
|
}
|
|
2626
|
+
isEnumSchema(schema) {
|
|
2627
|
+
if (!schema.schema || !schema.schema._def) {
|
|
2628
|
+
return false;
|
|
2629
|
+
}
|
|
2630
|
+
const def = schema.schema._def;
|
|
2631
|
+
return def.typeName === "ZodEnum";
|
|
2632
|
+
}
|
|
2601
2633
|
findSchemaDependencies(schema) {
|
|
2602
2634
|
const dependencies = [];
|
|
2603
2635
|
const schemaObj = schema.schema;
|
|
@@ -2679,7 +2711,7 @@ var SchemaGenerator = class {
|
|
|
2679
2711
|
schemaExports.push(...endpointSchemas.exports);
|
|
2680
2712
|
}
|
|
2681
2713
|
const validationHelpers = this.generateValidationHelpers();
|
|
2682
|
-
const
|
|
2714
|
+
const contentWithImports = [
|
|
2683
2715
|
...imports,
|
|
2684
2716
|
"",
|
|
2685
2717
|
"// Generated schemas from OpenAPI specification",
|
|
@@ -2689,7 +2721,11 @@ var SchemaGenerator = class {
|
|
|
2689
2721
|
"",
|
|
2690
2722
|
validationHelpers,
|
|
2691
2723
|
""
|
|
2692
|
-
].join("\n")
|
|
2724
|
+
].join("\n");
|
|
2725
|
+
let content = this.removeUnusedCode(contentWithImports);
|
|
2726
|
+
if (!content.includes('import { z } from "zod"') && !content.includes("import { z } from 'zod'")) {
|
|
2727
|
+
content = 'import { z } from "zod"\n\n' + content;
|
|
2728
|
+
}
|
|
2693
2729
|
return {
|
|
2694
2730
|
path: "schemas/index.ts",
|
|
2695
2731
|
content,
|
|
@@ -3038,7 +3074,11 @@ export const errorMessages = {
|
|
|
3038
3074
|
const lines = content.split("\n");
|
|
3039
3075
|
const cleanedLines = [];
|
|
3040
3076
|
const usedIdentifiers = /* @__PURE__ */ new Set();
|
|
3077
|
+
usedIdentifiers.add("z");
|
|
3041
3078
|
for (const line of lines) {
|
|
3079
|
+
if (line.includes("z.")) {
|
|
3080
|
+
usedIdentifiers.add("z");
|
|
3081
|
+
}
|
|
3042
3082
|
const assignments = line.match(/(\w+)\s*[:=]/g);
|
|
3043
3083
|
if (assignments) {
|
|
3044
3084
|
assignments.forEach((match) => {
|
|
@@ -3053,6 +3093,9 @@ export const errorMessages = {
|
|
|
3053
3093
|
usedIdentifiers.add(identifier);
|
|
3054
3094
|
});
|
|
3055
3095
|
}
|
|
3096
|
+
if (line.includes("z.infer")) {
|
|
3097
|
+
usedIdentifiers.add("z");
|
|
3098
|
+
}
|
|
3056
3099
|
}
|
|
3057
3100
|
for (const line of lines) {
|
|
3058
3101
|
if (line.trim() === "" || line.trim().startsWith("//")) {
|
|
@@ -3060,6 +3103,10 @@ export const errorMessages = {
|
|
|
3060
3103
|
continue;
|
|
3061
3104
|
}
|
|
3062
3105
|
if (line.includes("import") && line.includes("from")) {
|
|
3106
|
+
if (line.includes('from "zod"') || line.includes("from 'zod'")) {
|
|
3107
|
+
cleanedLines.push(line);
|
|
3108
|
+
continue;
|
|
3109
|
+
}
|
|
3063
3110
|
const importMatch = line.match(/import\s*\{([^}]+)\}/);
|
|
3064
3111
|
if (importMatch) {
|
|
3065
3112
|
const imports = importMatch[1].split(",").map((imp) => imp.trim());
|
|
@@ -3140,7 +3187,7 @@ var ActionGenerator = class {
|
|
|
3140
3187
|
...hasStreaming ? ["import { after } from 'next/server'"] : [],
|
|
3141
3188
|
"import { headers } from 'next/headers'",
|
|
3142
3189
|
`import { apiClient } from '${clientImport}'`,
|
|
3143
|
-
`import { ${usesAuth || hasRateLimit ? "authActionClient" : "
|
|
3190
|
+
`import { actionClientWithMeta${usesAuth || hasRateLimit ? ", authActionClient" : ""}, ActionError } from '${safeActionImport}'`,
|
|
3144
3191
|
...schemaImportsString ? [`import {
|
|
3145
3192
|
${schemaImportsString}
|
|
3146
3193
|
} from '${schemasImport}'`] : [],
|
|
@@ -3287,7 +3334,7 @@ ${Object.keys(endpointsByTag).map((tag) => `export * from './${toValidIdentifier
|
|
|
3287
3334
|
// Validate and sanitize input
|
|
3288
3335
|
const { body, params } = await validateAndSanitizeInput(${schemaName}, parsedInput)
|
|
3289
3336
|
const validatedBody = body
|
|
3290
|
-
const validatedParams = params as
|
|
3337
|
+
const validatedParams = params as z.infer<typeof ${operationName}ParamsSchema>`;
|
|
3291
3338
|
requestOptionsParams = this.buildRequestOptions(pathParameters, queryParameters, true, true);
|
|
3292
3339
|
} else if (hasRequestBody) {
|
|
3293
3340
|
schemaName = `${operationName}RequestSchema`;
|
|
@@ -3299,7 +3346,7 @@ ${Object.keys(endpointsByTag).map((tag) => `export * from './${toValidIdentifier
|
|
|
3299
3346
|
schemaName = `${operationName}ParamsSchema`;
|
|
3300
3347
|
parameterProcessing = `
|
|
3301
3348
|
// Validate and sanitize parameters
|
|
3302
|
-
const validatedParams = await validateAndSanitizeInput(${schemaName}, parsedInput) as
|
|
3349
|
+
const validatedParams = await validateAndSanitizeInput(${schemaName}, parsedInput) as z.infer<typeof ${operationName}ParamsSchema>`;
|
|
3303
3350
|
requestOptionsParams = this.buildRequestOptions(pathParameters, queryParameters, false, true);
|
|
3304
3351
|
} else {
|
|
3305
3352
|
schemaName = "z.void()";
|
|
@@ -3338,7 +3385,7 @@ export const ${actionName} = cache(
|
|
|
3338
3385
|
rateLimit: { requests: ${endpoint.metadata.rateLimit?.requests || 10}, window: "${endpoint.metadata.rateLimit?.window || "1m"}" }` : ""}
|
|
3339
3386
|
})
|
|
3340
3387
|
.schema(${schemaName})
|
|
3341
|
-
.action(async ({ parsedInput, ctx }) => {
|
|
3388
|
+
.action(async ({ parsedInput, ctx }: { parsedInput: ${hasRequestBody || hasAnyParams ? `z.infer<typeof ${schemaName}>` : "void"}, ctx${requiresAuth || hasRateLimit ? ": { user?: any, ratelimit?: { remaining: number } }" : "?: any"}) => {
|
|
3342
3389
|
const startTime = Date.now()
|
|
3343
3390
|
|
|
3344
3391
|
try {${rateLimitCode}${parameterProcessing}
|
|
@@ -3429,7 +3476,7 @@ export const ${actionName} = ${clientName}
|
|
|
3429
3476
|
rateLimit: { requests: ${endpoint.metadata.rateLimit?.requests || 10}, window: "${endpoint.metadata.rateLimit?.window || "1m"}" }` : ""}
|
|
3430
3477
|
})
|
|
3431
3478
|
.schema(${schemaName})
|
|
3432
|
-
.action(async ({ parsedInput, ctx }) => {
|
|
3479
|
+
.action(async ({ parsedInput, ctx }: { parsedInput: ${hasRequestBody || hasAnyParams ? `z.infer<typeof ${schemaName}>` : "void"}, ctx${requiresAuth || hasRateLimit ? ": { user?: any, ratelimit?: { remaining: number } }" : "?: any"}) => {
|
|
3433
3480
|
const startTime = Date.now()
|
|
3434
3481
|
|
|
3435
3482
|
try {${rateLimitCode}${parameterProcessing}${fileUploadCode}
|
|
@@ -3763,14 +3810,14 @@ export function ${hookName}(${parameterTypes.length > 0 ? `${parameterTypes.join
|
|
|
3763
3810
|
refetchInterval: options?.refetchInterval, // Optional polling interval
|
|
3764
3811
|
initialDataUpdatedAt: initialData ? Date.now() : undefined,
|
|
3765
3812
|
// React Query v5: placeholderData replaces keepPreviousData
|
|
3766
|
-
placeholderData: (previousData) => previousData,
|
|
3767
|
-
retry: (failureCount, error) => {
|
|
3813
|
+
placeholderData: (previousData: ${returnType} | undefined) => previousData,
|
|
3814
|
+
retry: (failureCount: number, error: Error) => {
|
|
3768
3815
|
// Don't retry on 4xx errors (client errors)
|
|
3769
3816
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
3770
3817
|
// Retry up to 3 times for network/server errors
|
|
3771
3818
|
return failureCount < 3
|
|
3772
3819
|
},
|
|
3773
|
-
initialData: initialData as
|
|
3820
|
+
initialData: initialData as ${returnType} | undefined,
|
|
3774
3821
|
...restOptions
|
|
3775
3822
|
})
|
|
3776
3823
|
}
|
|
@@ -3793,7 +3840,7 @@ export function ${hookName.replace("use", "useInfinite")}(${parameterTypes.lengt
|
|
|
3793
3840
|
handleActionError(error)
|
|
3794
3841
|
}
|
|
3795
3842
|
}, [searchParams]),
|
|
3796
|
-
getNextPageParam: (lastPage:
|
|
3843
|
+
getNextPageParam: (lastPage: ${returnType}, allPages: ${returnType}[]) => {
|
|
3797
3844
|
if (lastPage?.hasMore || (Array.isArray(lastPage) && lastPage.length === searchParams.limit)) {
|
|
3798
3845
|
return allPages.length + 1
|
|
3799
3846
|
}
|
|
@@ -3806,9 +3853,9 @@ export function ${hookName.replace("use", "useInfinite")}(${parameterTypes.lengt
|
|
|
3806
3853
|
refetchOnReconnect: true,
|
|
3807
3854
|
refetchOnMount: 'always',
|
|
3808
3855
|
initialDataUpdatedAt: initialData ? Date.now() : undefined,
|
|
3809
|
-
placeholderData: (previousData) => previousData,
|
|
3856
|
+
placeholderData: (previousData: ${returnType} | undefined) => previousData,
|
|
3810
3857
|
retry: 3,
|
|
3811
|
-
initialData: initialData as
|
|
3858
|
+
initialData: initialData as ${returnType} | undefined,
|
|
3812
3859
|
...restOptions
|
|
3813
3860
|
})
|
|
3814
3861
|
}
|
|
@@ -3827,7 +3874,7 @@ export function ${hookName.replace("use", "useSuspense")}(${parameterTypes.lengt
|
|
|
3827
3874
|
return result
|
|
3828
3875
|
}, []),
|
|
3829
3876
|
staleTime: ${staleTime},
|
|
3830
|
-
initialData: initialData as
|
|
3877
|
+
initialData: initialData as ${returnType} | undefined,
|
|
3831
3878
|
...restOptions
|
|
3832
3879
|
})
|
|
3833
3880
|
}`;
|
|
@@ -3859,14 +3906,14 @@ export function ${hookName}(${parameterTypes.length > 0 ? `${parameterTypes.join
|
|
|
3859
3906
|
refetchInterval: options?.refetchInterval, // Optional polling interval
|
|
3860
3907
|
initialDataUpdatedAt: initialData ? Date.now() : undefined,
|
|
3861
3908
|
// React Query v5: placeholderData replaces keepPreviousData
|
|
3862
|
-
placeholderData: (previousData) => previousData,
|
|
3863
|
-
retry: (failureCount, error) => {
|
|
3909
|
+
placeholderData: (previousData: ${returnType} | undefined) => previousData,
|
|
3910
|
+
retry: (failureCount: number, error: Error) => {
|
|
3864
3911
|
// Don't retry on 4xx errors (client errors)
|
|
3865
3912
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
3866
3913
|
// Retry up to 3 times for network/server errors
|
|
3867
3914
|
return failureCount < 3
|
|
3868
3915
|
},
|
|
3869
|
-
initialData: initialData as
|
|
3916
|
+
initialData: initialData as ${returnType} | undefined,
|
|
3870
3917
|
...restOptions
|
|
3871
3918
|
})
|
|
3872
3919
|
}
|
|
@@ -3885,7 +3932,7 @@ export function ${hookName.replace("use", "useSuspense")}(${parameterTypes.lengt
|
|
|
3885
3932
|
return result
|
|
3886
3933
|
}, []),
|
|
3887
3934
|
staleTime: ${staleTime},
|
|
3888
|
-
initialData: initialData as
|
|
3935
|
+
initialData: initialData as ${returnType} | undefined,
|
|
3889
3936
|
...restOptions
|
|
3890
3937
|
})
|
|
3891
3938
|
}`;
|
|
@@ -3938,13 +3985,13 @@ export function ${hookName}(options?: {
|
|
|
3938
3985
|
mutationFn: async (variables: ${inputType}): Promise<${outputType}> => {
|
|
3939
3986
|
try {
|
|
3940
3987
|
const result = await ${actionName}(${variablesParam === "undefined" ? "" : "variables"})
|
|
3941
|
-
return result.data || ({} as
|
|
3988
|
+
return result.data || ({} as ${outputType})
|
|
3942
3989
|
} catch (error) {
|
|
3943
3990
|
handleActionError(error)
|
|
3944
3991
|
}
|
|
3945
3992
|
},
|
|
3946
3993
|
|
|
3947
|
-
onMutate: async (variables) => {
|
|
3994
|
+
onMutate: async (variables: ${inputType}) => {
|
|
3948
3995
|
${cancelQueriesCode}
|
|
3949
3996
|
|
|
3950
3997
|
${snapshotCode}
|
|
@@ -3955,7 +4002,7 @@ ${snapshotCode}
|
|
|
3955
4002
|
setOptimisticData(optimisticValue)
|
|
3956
4003
|
}
|
|
3957
4004
|
|
|
3958
|
-
return {
|
|
4005
|
+
return { /* Snapshot handled via query invalidation */ }
|
|
3959
4006
|
},
|
|
3960
4007
|
|
|
3961
4008
|
onSuccess: (data, variables) => {
|
|
@@ -3971,7 +4018,7 @@ ${invalidationCode}
|
|
|
3971
4018
|
options?.onSuccess?.(data, variables)
|
|
3972
4019
|
},
|
|
3973
4020
|
|
|
3974
|
-
onError: (error, variables, context) => {
|
|
4021
|
+
onError: (error: Error, variables: ${inputType}, context: any) => {
|
|
3975
4022
|
// Rollback optimistic update
|
|
3976
4023
|
${rollbackCode}
|
|
3977
4024
|
|
|
@@ -4055,29 +4102,26 @@ ${invalidationCode}
|
|
|
4055
4102
|
}
|
|
4056
4103
|
/**
|
|
4057
4104
|
* Build cancel queries code
|
|
4105
|
+
* Uses query key patterns to cancel all related queries regardless of parameters
|
|
4058
4106
|
*/
|
|
4059
4107
|
buildCancelQueriesCode(endpoint, relatedQueries) {
|
|
4060
4108
|
const cancels = [];
|
|
4061
4109
|
relatedQueries.forEach((queryEndpoint) => {
|
|
4062
|
-
const
|
|
4063
|
-
cancels.push(` await queryClient.cancelQueries({ queryKey: ${
|
|
4110
|
+
const queryKeyPrefix = `'${toActionName(queryEndpoint.operationId || queryEndpoint.id)}'`;
|
|
4111
|
+
cancels.push(` await queryClient.cancelQueries({ queryKey: [${queryKeyPrefix}] })`);
|
|
4064
4112
|
});
|
|
4065
4113
|
return cancels.length > 0 ? cancels.join("\n") : " // No queries to cancel";
|
|
4066
4114
|
}
|
|
4067
4115
|
/**
|
|
4068
4116
|
* Build snapshot code for rollback
|
|
4117
|
+
* Note: We can't snapshot specific queries with parameters in onMutate scope
|
|
4118
|
+
* Instead, we'll invalidate all related queries on error
|
|
4069
4119
|
*/
|
|
4070
4120
|
buildSnapshotCode(endpoint, relatedQueries) {
|
|
4071
4121
|
if (relatedQueries.length === 0) {
|
|
4072
4122
|
return " // No queries to snapshot";
|
|
4073
4123
|
}
|
|
4074
|
-
|
|
4075
|
-
relatedQueries.forEach((queryEndpoint, index) => {
|
|
4076
|
-
const queryKey = this.generateQueryKey(queryEndpoint);
|
|
4077
|
-
const varName = `previous${this.toPascalCase(toActionName(queryEndpoint.operationId || queryEndpoint.id))}`;
|
|
4078
|
-
snapshots.push(` const ${varName} = queryClient.getQueryData(${queryKey})`);
|
|
4079
|
-
});
|
|
4080
|
-
return snapshots.join("\n");
|
|
4124
|
+
return " // Snapshot handled via query invalidation";
|
|
4081
4125
|
}
|
|
4082
4126
|
/**
|
|
4083
4127
|
* Build rollback code
|
|
@@ -4264,8 +4308,8 @@ export function useBridgeQuery<TData = unknown, TError = Error>(
|
|
|
4264
4308
|
refetchOnWindowFocus: true,
|
|
4265
4309
|
refetchOnReconnect: true,
|
|
4266
4310
|
refetchOnMount: 'always',
|
|
4267
|
-
placeholderData: (previousData) => previousData,
|
|
4268
|
-
retry: (failureCount, error) => {
|
|
4311
|
+
placeholderData: (previousData: TData | undefined) => previousData,
|
|
4312
|
+
retry: (failureCount: number, error: Error) => {
|
|
4269
4313
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
4270
4314
|
return failureCount < 3
|
|
4271
4315
|
},
|
|
@@ -4290,13 +4334,13 @@ export function useBridgeInfiniteQuery<TData = unknown, TError = Error>(
|
|
|
4290
4334
|
refetchOnWindowFocus: true,
|
|
4291
4335
|
refetchOnReconnect: true,
|
|
4292
4336
|
refetchOnMount: 'always',
|
|
4293
|
-
placeholderData: (previousData) => previousData,
|
|
4294
|
-
retry: (failureCount, error) => {
|
|
4337
|
+
placeholderData: (previousData: TData | undefined) => previousData,
|
|
4338
|
+
retry: (failureCount: number, error: Error) => {
|
|
4295
4339
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
4296
4340
|
return failureCount < 3
|
|
4297
4341
|
},
|
|
4298
4342
|
...options,
|
|
4299
|
-
}
|
|
4343
|
+
})
|
|
4300
4344
|
}
|
|
4301
4345
|
|
|
4302
4346
|
/**
|
|
@@ -4313,7 +4357,7 @@ export function useBridgeSuspenseQuery<TData = unknown, TError = Error>(
|
|
|
4313
4357
|
queryFn: queryFn as QueryFunction<TData, QueryKey>,
|
|
4314
4358
|
staleTime: 5 * 60 * 1000,
|
|
4315
4359
|
gcTime: 10 * 60 * 1000,
|
|
4316
|
-
retry: (failureCount, error) => {
|
|
4360
|
+
retry: (failureCount: number, error: Error) => {
|
|
4317
4361
|
if (error instanceof Error && error.message.includes('4')) return false
|
|
4318
4362
|
return failureCount < 3
|
|
4319
4363
|
},
|
|
@@ -7528,9 +7572,6 @@ var UploadGenerator = class {
|
|
|
7528
7572
|
const compressionFormats = uploads?.compression?.formats || ["gzip", "webp"];
|
|
7529
7573
|
const content = `'use client'
|
|
7530
7574
|
|
|
7531
|
-
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
7532
|
-
import { toast } from 'sonner'
|
|
7533
|
-
|
|
7534
7575
|
/**
|
|
7535
7576
|
* Upload configuration
|
|
7536
7577
|
*/
|
|
@@ -7710,7 +7751,7 @@ export function createUploadFormData(
|
|
|
7710
7751
|
"FileValidationResult",
|
|
7711
7752
|
"UploadProgress"
|
|
7712
7753
|
],
|
|
7713
|
-
imports: [
|
|
7754
|
+
imports: [],
|
|
7714
7755
|
dependencies: []
|
|
7715
7756
|
}
|
|
7716
7757
|
};
|
|
@@ -7816,16 +7857,18 @@ async function uploadToS3(
|
|
|
7816
7857
|
xhr.send(formData)
|
|
7817
7858
|
})
|
|
7818
7859
|
}
|
|
7819
|
-
|
|
7860
|
+
` : "";
|
|
7861
|
+
const needsBackendHelper = progressEnabled && useXHR || presignedEnabled && fallbackEnabled;
|
|
7862
|
+
const backendUploadHelper = needsBackendHelper ? `
|
|
7820
7863
|
/**
|
|
7821
7864
|
* Upload via backend API with progress tracking
|
|
7822
|
-
* Uses
|
|
7865
|
+
* Uses XMLHttpRequest for progress tracking support
|
|
7823
7866
|
*/
|
|
7824
7867
|
async function uploadViaBackendApi(
|
|
7825
7868
|
formData: FormData,
|
|
7826
7869
|
onProgress?: (progress: { loaded: number; total: number; percentage: number }) => void
|
|
7827
7870
|
): Promise<z.infer<typeof ${operationName}ResponseSchema>> {
|
|
7828
|
-
|
|
7871
|
+
return new Promise((resolve, reject) => {
|
|
7829
7872
|
const xhr = new XMLHttpRequest()
|
|
7830
7873
|
|
|
7831
7874
|
if (onProgress) {
|
|
@@ -7874,13 +7917,9 @@ async function uploadViaBackendApi(
|
|
|
7874
7917
|
: '${this.configuration.api?.baseUrl || "http://localhost:8000"}'
|
|
7875
7918
|
xhr.open('POST', \`\${baseUrl}${endpoint.path}\`)
|
|
7876
7919
|
xhr.send(formData)
|
|
7877
|
-
})
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
const response = await ${actionName}(formData as any)
|
|
7881
|
-
return response
|
|
7882
|
-
`}
|
|
7883
|
-
}` : "";
|
|
7920
|
+
})
|
|
7921
|
+
}
|
|
7922
|
+
` : "";
|
|
7884
7923
|
const uploadLogic = presignedEnabled ? `
|
|
7885
7924
|
let fileKey: string | null = null
|
|
7886
7925
|
let directUploadAttempted = false
|
|
@@ -7995,6 +8034,7 @@ async function uploadViaBackendApi(
|
|
|
7995
8034
|
`;
|
|
7996
8035
|
const content = `${imports}
|
|
7997
8036
|
${presignedHelpers}
|
|
8037
|
+
${backendUploadHelper || ""}
|
|
7998
8038
|
|
|
7999
8039
|
/**
|
|
8000
8040
|
* Upload hook for ${endpoint.method} ${endpoint.path}
|
|
@@ -8031,7 +8071,7 @@ export function ${hookName}Upload(options?: {
|
|
|
8031
8071
|
${uploadLogic}
|
|
8032
8072
|
},
|
|
8033
8073
|
|
|
8034
|
-
onSuccess: (data) => {
|
|
8074
|
+
onSuccess: (data: z.infer<typeof ${operationName}ResponseSchema>) => {
|
|
8035
8075
|
// Don't show toast here, let the page handle it
|
|
8036
8076
|
options?.onSuccess?.(data)
|
|
8037
8077
|
|
|
@@ -8245,7 +8285,9 @@ let toast: {
|
|
|
8245
8285
|
} | null = null
|
|
8246
8286
|
|
|
8247
8287
|
// Lazy load toast to avoid bundling issues
|
|
8248
|
-
async function getToast() {
|
|
8288
|
+
async function getToast(): Promise<{
|
|
8289
|
+
error: (message: string, options?: { duration?: number; description?: string }) => void
|
|
8290
|
+
} | null> {
|
|
8249
8291
|
if (toast !== null) return toast
|
|
8250
8292
|
|
|
8251
8293
|
try {
|
|
@@ -8339,24 +8381,26 @@ export async function handleAuthError(error: unknown, redirectTo?: string): Prom
|
|
|
8339
8381
|
const toastInstance = await getToast()
|
|
8340
8382
|
|
|
8341
8383
|
// Show appropriate error message based on error type
|
|
8342
|
-
if (
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8384
|
+
if (toastInstance) {
|
|
8385
|
+
if (isInactive) {
|
|
8386
|
+
toastInstance.error('Your account has been deactivated. Please contact support for assistance.', {
|
|
8387
|
+
duration: 5000,
|
|
8388
|
+
description: 'You will be redirected to the login page.',
|
|
8389
|
+
})
|
|
8390
|
+
} else if (apiError.status === 401) {
|
|
8391
|
+
toastInstance.error('Your session has expired. Please sign in again.', {
|
|
8392
|
+
duration: 4000,
|
|
8393
|
+
})
|
|
8394
|
+
} else if (apiError.status === 403) {
|
|
8395
|
+
toastInstance.error('Access denied. Your account may have been suspended.', {
|
|
8396
|
+
duration: 5000,
|
|
8397
|
+
description: 'You will be redirected to the login page.',
|
|
8398
|
+
})
|
|
8399
|
+
} else {
|
|
8400
|
+
toastInstance.error('Authentication failed. Please sign in again.', {
|
|
8401
|
+
duration: 4000,
|
|
8402
|
+
})
|
|
8403
|
+
}
|
|
8360
8404
|
}
|
|
8361
8405
|
|
|
8362
8406
|
if (typeof window !== 'undefined') {
|
|
@@ -8367,7 +8411,7 @@ export async function handleAuthError(error: unknown, redirectTo?: string): Prom
|
|
|
8367
8411
|
const { signOut } = await import('${authPath}')
|
|
8368
8412
|
signOut({
|
|
8369
8413
|
redirect: false,
|
|
8370
|
-
}).catch((signOutError) => {
|
|
8414
|
+
}).catch((signOutError: unknown) => {
|
|
8371
8415
|
console.error('[Auth Error Handler] Error during sign out (non-blocking):', signOutError)
|
|
8372
8416
|
})
|
|
8373
8417
|
} catch (importError) {
|
|
@@ -9546,5 +9590,5 @@ exports.VersionChecker = VersionChecker;
|
|
|
9546
9590
|
exports.__name = __name;
|
|
9547
9591
|
exports.checkAndNotifyUpdates = checkAndNotifyUpdates;
|
|
9548
9592
|
exports.createBridgeVersionChecker = createBridgeVersionChecker;
|
|
9549
|
-
//# sourceMappingURL=chunk-
|
|
9550
|
-
//# sourceMappingURL=chunk-
|
|
9593
|
+
//# sourceMappingURL=chunk-GKRRC2YD.cjs.map
|
|
9594
|
+
//# sourceMappingURL=chunk-GKRRC2YD.cjs.map
|