@lastbrain/ai-ui-core 1.0.45 → 1.0.46
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enhanced-gateway.d.ts","sourceRoot":"","sources":["../../../src/route-handlers/nextjs/enhanced-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"enhanced-gateway.d.ts","sourceRoot":"","sources":["../../../src/route-handlers/nextjs/enhanced-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqMxD,wBAAsB,GAAG,CACvB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,8BAGjD;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,8BAGjD;AAED,wBAAsB,GAAG,CACvB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,8BAGjD;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,8BAGjD"}
|
|
@@ -65,17 +65,21 @@ function mapAuthRouteToPublicRoute(path) {
|
|
|
65
65
|
};
|
|
66
66
|
// Try exact match first
|
|
67
67
|
if (routeMappings[cleanPath]) {
|
|
68
|
+
console.log(`[Enhanced Gateway] Exact match: "${cleanPath}" -> "${routeMappings[cleanPath]}"`);
|
|
68
69
|
return routeMappings[cleanPath];
|
|
69
70
|
}
|
|
70
71
|
// Try pattern matching with priority to longer/more specific patterns first
|
|
71
72
|
const sortedPatterns = Object.entries(routeMappings)
|
|
72
73
|
.sort(([a], [b]) => b.length - a.length); // Longer patterns first
|
|
74
|
+
console.log(`[Enhanced Gateway] No exact match for "${cleanPath}", trying patterns...`);
|
|
73
75
|
for (const [pattern, target] of sortedPatterns) {
|
|
74
76
|
if (cleanPath.startsWith(pattern + "/") || cleanPath === pattern) {
|
|
77
|
+
console.log(`[Enhanced Gateway] Pattern match: "${pattern}" -> "${target}"`);
|
|
75
78
|
return target + cleanPath.slice(pattern.length);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
// Fallback: return clean path as-is
|
|
82
|
+
console.log(`[Enhanced Gateway] No pattern match, using fallback: "${cleanPath}"`);
|
|
79
83
|
return cleanPath;
|
|
80
84
|
}
|
|
81
85
|
async function handleRequest(request, context) {
|
|
@@ -85,7 +89,8 @@ async function handleRequest(request, context) {
|
|
|
85
89
|
const params = await context.params;
|
|
86
90
|
const originalPath = params.path.join("/");
|
|
87
91
|
const mappedPath = mapAuthRouteToPublicRoute(originalPath);
|
|
88
|
-
|
|
92
|
+
// Ajouter automatiquement le préfixe /api/ai pour le monorepo
|
|
93
|
+
const url = `${LB_BASE_URL}/api/ai/${mappedPath}`;
|
|
89
94
|
// Preserve query params
|
|
90
95
|
const searchParams = request.nextUrl.searchParams.toString();
|
|
91
96
|
const finalUrl = searchParams ? `${url}?${searchParams}` : url;
|
package/package.json
CHANGED
|
@@ -83,6 +83,7 @@ function mapAuthRouteToPublicRoute(path: string): string {
|
|
|
83
83
|
|
|
84
84
|
// Try exact match first
|
|
85
85
|
if (routeMappings[cleanPath]) {
|
|
86
|
+
console.log(`[Enhanced Gateway] Exact match: "${cleanPath}" -> "${routeMappings[cleanPath]}"`);
|
|
86
87
|
return routeMappings[cleanPath];
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -90,13 +91,16 @@ function mapAuthRouteToPublicRoute(path: string): string {
|
|
|
90
91
|
const sortedPatterns = Object.entries(routeMappings)
|
|
91
92
|
.sort(([a], [b]) => b.length - a.length); // Longer patterns first
|
|
92
93
|
|
|
94
|
+
console.log(`[Enhanced Gateway] No exact match for "${cleanPath}", trying patterns...`);
|
|
93
95
|
for (const [pattern, target] of sortedPatterns) {
|
|
94
96
|
if (cleanPath.startsWith(pattern + "/") || cleanPath === pattern) {
|
|
97
|
+
console.log(`[Enhanced Gateway] Pattern match: "${pattern}" -> "${target}"`);
|
|
95
98
|
return target + cleanPath.slice(pattern.length);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
// Fallback: return clean path as-is
|
|
103
|
+
console.log(`[Enhanced Gateway] No pattern match, using fallback: "${cleanPath}"`);
|
|
100
104
|
return cleanPath;
|
|
101
105
|
}
|
|
102
106
|
|
|
@@ -115,7 +119,8 @@ async function handleRequest(
|
|
|
115
119
|
const originalPath = params.path.join("/");
|
|
116
120
|
const mappedPath = mapAuthRouteToPublicRoute(originalPath);
|
|
117
121
|
|
|
118
|
-
|
|
122
|
+
// Ajouter automatiquement le préfixe /api/ai pour le monorepo
|
|
123
|
+
const url = `${LB_BASE_URL}/api/ai/${mappedPath}`;
|
|
119
124
|
|
|
120
125
|
// Preserve query params
|
|
121
126
|
const searchParams = request.nextUrl.searchParams.toString();
|