Skip to content

Commit c6058a5

Browse files
committed
Merge remote-tracking branch 'upstream/bi-1.5.x' into bi-multi-project-auto-reveal
2 parents 728627f + 95637e1 commit c6058a5

File tree

82 files changed

+3626
-2008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3626
-2008
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 2516 additions & 1523 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/api-designer/api-designer-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
},
114114
"dependencies": {
115115
"copyfiles": "^2.4.1",
116-
"@vscode/vsce": "~2.21.0",
116+
"@vscode/vsce": "^3.7.0",
117117
"vscode-messenger": "^0.4.5",
118118
"vscode-messenger-common": "^0.4.5",
119119
"@wso2/api-designer-core": "workspace:*",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lib/
2+
storybook-static/
3+
.storybook/fonts/

workspaces/apk/apk-extension/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565
"@typescript-eslint/parser": "~5.48.2",
6666
"@vscode/test-electron": "^2.3.2",
6767
"eslint": "^8.32.0",
68-
"glob": "^8.1.0",
68+
"glob": "^11.1.0",
6969
"mocha": "^10.2.0",
7070
"typescript": "5.8.3",
71-
"vsce": "^2.15.0",
72-
"copyfiles": "^2.4.1"
71+
"copyfiles": "^2.4.1",
72+
"@vscode/vsce": "^3.7.0"
7373
}
7474
}
7575

workspaces/apk/apk-extension/src/test/suite/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import * as path from 'path';
2020
import * as Mocha from 'mocha';
21-
import * as glob from 'glob';
21+
import { glob } from 'glob';
2222

2323
export function run(): Promise<void> {
2424
// Create the mocha test
@@ -29,11 +29,9 @@ export function run(): Promise<void> {
2929

3030
const testsRoot = path.resolve(__dirname, '..');
3131

32-
return new Promise((c, e) => {
33-
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
34-
if (err) {
35-
return e(err);
36-
}
32+
return new Promise(async (c, e) => {
33+
try {
34+
const files = await glob('**/**.test.js', { cwd: testsRoot });
3735

3836
// Add files to the test suite
3937
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
@@ -51,6 +49,8 @@ export function run(): Promise<void> {
5149
console.error(err);
5250
e(err);
5351
}
54-
});
52+
} catch (err) {
53+
e(err);
54+
}
5555
});
5656
}

workspaces/ballerina/ballerina-core/src/rpc-types/visualizer/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import { HistoryEntry } from "../../history";
2020
import { ProjectStructureArtifactResponse, UpdatedArtifactsResponse } from "../../interfaces/bi";
2121
import { ColorThemeKind } from "../../state-machine-types";
22-
import { AddToUndoStackRequest, OpenViewRequest, UndoRedoStateResponse } from "./interfaces";
22+
import { AddToUndoStackRequest, JoinProjectPathRequest, JoinProjectPathResponse, OpenViewRequest, UndoRedoStateResponse } from "./interfaces";
2323

2424
export interface VisualizerAPI {
2525
openView: (params: OpenViewRequest) => void;
@@ -32,7 +32,7 @@ export interface VisualizerAPI {
3232
redo: (count: number) => Promise<string>;
3333
addToUndoStack: (params: AddToUndoStackRequest) => void;
3434
undoRedoState: () => Promise<UndoRedoStateResponse>;
35-
joinProjectPath: (segments: string | string[]) => Promise<string>;
35+
joinProjectPath: (params: JoinProjectPathRequest) => Promise<JoinProjectPathResponse>;
3636
getThemeKind: () => Promise<ColorThemeKind>;
3737
updateCurrentArtifactLocation: (params: UpdatedArtifactsResponse) => Promise<ProjectStructureArtifactResponse>;
3838
}

workspaces/ballerina/ballerina-core/src/rpc-types/visualizer/interfaces.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* under the License.
1717
*/
1818

19+
import { CodeData } from "../../interfaces/bi";
1920
import { EVENT_TYPE, PopupVisualizerLocation, VisualizerLocation } from "../../state-machine-types";
2021

2122
export interface UpdateUndoRedoMangerRequest {
@@ -48,3 +49,13 @@ export interface AddToUndoStackRequest {
4849
source: string;
4950
description?: string;
5051
}
52+
53+
export interface JoinProjectPathRequest {
54+
segments: string | string[];
55+
codeData?: CodeData;
56+
}
57+
58+
export interface JoinProjectPathResponse {
59+
filePath: string;
60+
projectPath: string;
61+
}

workspaces/ballerina/ballerina-core/src/rpc-types/visualizer/rpc-type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { HistoryEntry } from "../../history";
2121
import { ProjectStructureArtifactResponse, UpdatedArtifactsResponse } from "../../interfaces/bi";
2222
import { ColorThemeKind } from "../../state-machine-types";
23-
import { AddToUndoStackRequest, OpenViewRequest, UndoRedoStateResponse } from "./interfaces";
23+
import { AddToUndoStackRequest, JoinProjectPathRequest, JoinProjectPathResponse, OpenViewRequest, UndoRedoStateResponse } from "./interfaces";
2424
import { NotificationType, RequestType } from "vscode-messenger-common";
2525

2626
const _preFix = "visualizer";
@@ -34,6 +34,6 @@ export const undo: RequestType<number, string> = { method: `${_preFix}/undo` };
3434
export const redo: RequestType<number, string> = { method: `${_preFix}/redo` };
3535
export const addToUndoStack: NotificationType<AddToUndoStackRequest> = { method: `${_preFix}/addToUndoStack` };
3636
export const undoRedoState: RequestType<void, UndoRedoStateResponse> = { method: `${_preFix}/undoRedoState` };
37-
export const joinProjectPath: RequestType<string | string[], string> = { method: `${_preFix}/joinProjectPath` };
37+
export const joinProjectPath: RequestType<JoinProjectPathRequest, JoinProjectPathResponse> = { method: `${_preFix}/joinProjectPath` };
3838
export const getThemeKind: RequestType<void, ColorThemeKind> = { method: `${_preFix}/getThemeKind` };
3939
export const updateCurrentArtifactLocation: RequestType<UpdatedArtifactsResponse, ProjectStructureArtifactResponse> = { method: `${_preFix}/updateCurrentArtifactLocation` };

workspaces/ballerina/ballerina-extension/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,21 +1021,21 @@
10211021
"description": "design-view",
10221022
"default": {
10231023
"fontPath": "./resources/font-wso2-vscode/dist/wso2-vscode.woff",
1024-
"fontCharacter": "\\f19a"
1024+
"fontCharacter": "\\f16e"
10251025
}
10261026
},
10271027
"distro-start": {
10281028
"description": "start",
10291029
"default": {
10301030
"fontPath": "./resources/font-wso2-vscode/dist/wso2-vscode.woff",
1031-
"fontCharacter": "\\f210"
1031+
"fontCharacter": "\\f11a"
10321032
}
10331033
},
10341034
"distro-debug": {
10351035
"description": "debug",
10361036
"default": {
10371037
"fontPath": "./resources/font-wso2-vscode/dist/wso2-vscode.woff",
1038-
"fontCharacter": "\\f195"
1038+
"fontCharacter": "\\f171"
10391039
}
10401040
},
10411041
"distro-source-view": {
@@ -1049,7 +1049,7 @@
10491049
"description": "persist-diagram",
10501050
"default": {
10511051
"fontPath": "./resources/font-wso2-vscode/dist/wso2-vscode.woff",
1052-
"fontCharacter": "\\f1eb"
1052+
"fontCharacter": "\\f133"
10531053
}
10541054
},
10551055
"distro-cached-rounded": {
@@ -1196,7 +1196,7 @@
11961196
"@ai-sdk/anthropic": "^2.0.20",
11971197
"@types/lodash": "^4.14.200",
11981198
"@vscode/test-electron": "^2.5.2",
1199-
"@vscode/vsce": "^2.22.0",
1199+
"@vscode/vsce": "^3.7.0",
12001200
"@wso2/ballerina-core": "workspace:*",
12011201
"@wso2/ballerina-visualizer": "workspace:*",
12021202
"@wso2/trace-visualizer": "workspace:*",
@@ -1208,7 +1208,7 @@
12081208
"del-cli": "^5.1.0",
12091209
"dotenv": "~16.5.0",
12101210
"file-uri-to-path": "^2.0.0",
1211-
"glob": "^7.2.3",
1211+
"glob": "^11.1.0",
12121212
"handlebars": "~4.7.8",
12131213
"jwt-decode": "^4.0.0",
12141214
"lodash": "^4.17.21",
@@ -1268,7 +1268,6 @@
12681268
"vscode-messenger": "^0.4.4",
12691269
"webpack": "^5.89.0",
12701270
"webpack-cli": "^6.0.1",
1271-
"webpack-merge-and-include-globally": "^2.3.4",
12721271
"yarn": "^1.22.19"
12731272
},
12741273
"extensionPack": [

workspaces/ballerina/ballerina-extension/src/features/ai/service/datamapper/datamapper.ts

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,19 @@ export async function generateMappingCodeCore(mappingRequest: ProcessMappingPara
346346

347347
let customFunctionsTargetPath: string;
348348
let customFunctionsFileName: string;
349-
349+
350350
if (allMappingsRequest.customFunctionsFilePath) {
351-
customFunctionsTargetPath = determineCustomFunctionsPath(projectRoot, currentActiveFile);
352-
customFunctionsFileName = path.basename(customFunctionsTargetPath);
351+
const absoluteCustomFunctionsPath = determineCustomFunctionsPath(projectRoot, currentActiveFile);
352+
customFunctionsFileName = path.basename(absoluteCustomFunctionsPath);
353+
354+
// For workspace projects, make path relative to workspace root
355+
const workspacePath = context.workspacePath;
356+
if (workspacePath) {
357+
customFunctionsTargetPath = path.relative(workspacePath, absoluteCustomFunctionsPath);
358+
} else {
359+
// Normal project: use relative path from project root
360+
customFunctionsTargetPath = path.relative(projectRoot, absoluteCustomFunctionsPath);
361+
}
353362
}
354363

355364
// Check if mappings file and custom functions file are the same
@@ -395,7 +404,15 @@ export async function generateMappingCodeCore(mappingRequest: ProcessMappingPara
395404
);
396405
await new Promise((resolve) => setTimeout(resolve, 200));
397406

398-
let targetFilePath = path.join(projectRoot, mappingContext.filePath);
407+
// For workspace projects, compute relative file path from workspace root
408+
const workspacePath = context.workspacePath;
409+
let targetFilePath = mappingContext.filePath;
410+
411+
if (workspacePath) {
412+
// Workspace project: need to include package path prefix (e.g., "foo/mappings.bal")
413+
const absoluteFilePath = path.join(projectRoot, mappingContext.filePath);
414+
targetFilePath = path.relative(workspacePath, absoluteFilePath);
415+
}
399416

400417
const generatedSourceFiles = buildMappingFileArray(
401418
targetFilePath,
@@ -416,12 +433,12 @@ export async function generateMappingCodeCore(mappingRequest: ProcessMappingPara
416433

417434
if (isSameFile) {
418435
const mergedContent = `${generatedFunctionDefinition.source}\n${customContent}`;
419-
assistantResponse += `<code filename="${mappingContext.filePath}" type="ai_map">\n\`\`\`ballerina\n${mergedContent}\n\`\`\`\n</code>`;
436+
assistantResponse += `<code filename="${targetFilePath}" type="ai_map">\n\`\`\`ballerina\n${mergedContent}\n\`\`\`\n</code>`;
420437
} else {
421-
assistantResponse += `<code filename="${mappingContext.filePath}" type="ai_map">\n\`\`\`ballerina\n${generatedFunctionDefinition.source}\n\`\`\`\n</code>`;
438+
assistantResponse += `<code filename="${targetFilePath}" type="ai_map">\n\`\`\`ballerina\n${generatedFunctionDefinition.source}\n\`\`\`\n</code>`;
422439

423440
if (codeRepairResult.customFunctionsContent) {
424-
assistantResponse += `<code filename="${customFunctionsFileName}" type="ai_map">\n\`\`\`ballerina\n${codeRepairResult.customFunctionsContent}\n\`\`\`\n</code>`;
441+
assistantResponse += `<code filename="${customFunctionsTargetPath || customFunctionsFileName}" type="ai_map">\n\`\`\`ballerina\n${codeRepairResult.customFunctionsContent}\n\`\`\`\n</code>`;
425442
}
426443
}
427444

@@ -650,10 +667,19 @@ export async function generateInlineMappingCodeCore(inlineMappingRequest: Metada
650667

651668
let customFunctionsTargetPath: string | undefined;
652669
let customFunctionsFileName: string | undefined;
653-
670+
654671
if (inlineMappingsResult.allMappingsRequest.customFunctionsFilePath) {
655-
customFunctionsTargetPath = determineCustomFunctionsPath(projectRoot, targetFileName);
656-
customFunctionsFileName = path.basename(customFunctionsTargetPath);
672+
const absoluteCustomFunctionsPath = determineCustomFunctionsPath(projectRoot, targetFileName);
673+
customFunctionsFileName = path.basename(absoluteCustomFunctionsPath);
674+
675+
// For workspace projects, make path relative to workspace root
676+
const workspacePath = context.workspacePath;
677+
if (workspacePath) {
678+
customFunctionsTargetPath = path.relative(workspacePath, absoluteCustomFunctionsPath);
679+
} else {
680+
// Normal project: use relative path from project root
681+
customFunctionsTargetPath = path.relative(projectRoot, absoluteCustomFunctionsPath);
682+
}
657683
}
658684

659685
// Check if mappings file and custom functions file are the same
@@ -691,8 +717,17 @@ export async function generateInlineMappingCodeCore(inlineMappingRequest: Metada
691717
}, langClient, projectRoot);
692718
}
693719

720+
// For workspace projects, compute relative file path from workspace root
721+
let targetFilePath = path.relative(projectRoot, context.documentUri);
722+
const workspacePath = context.workspacePath;
723+
724+
if (workspacePath) {
725+
// Workspace project: make path relative to workspace root (e.g., "foo/mappings.bal")
726+
targetFilePath = path.relative(workspacePath, context.documentUri);
727+
}
728+
694729
const generatedSourceFiles = buildMappingFileArray(
695-
context.documentUri,
730+
targetFilePath,
696731
codeRepairResult.finalContent,
697732
customFunctionsTargetPath,
698733
codeRepairResult.customFunctionsContent,
@@ -718,12 +753,12 @@ export async function generateInlineMappingCodeCore(inlineMappingRequest: Metada
718753

719754
if (isSameFile) {
720755
const mergedCodeDisplay = customContent ? `${codeToDisplay}\n${customContent}` : codeToDisplay;
721-
assistantResponse += `<code filename="${targetFileName}" type="ai_map">\n\`\`\`ballerina\n${mergedCodeDisplay}\n\`\`\`\n</code>`;
756+
assistantResponse += `<code filename="${targetFilePath}" type="ai_map">\n\`\`\`ballerina\n${mergedCodeDisplay}\n\`\`\`\n</code>`;
722757
} else {
723-
assistantResponse += `<code filename="${targetFileName}" type="ai_map">\n\`\`\`ballerina\n${codeToDisplay}\n\`\`\`\n</code>`;
758+
assistantResponse += `<code filename="${targetFilePath}" type="ai_map">\n\`\`\`ballerina\n${codeToDisplay}\n\`\`\`\n</code>`;
724759

725760
if (codeRepairResult.customFunctionsContent) {
726-
assistantResponse += `<code filename="${customFunctionsFileName}" type="ai_map">\n\`\`\`ballerina\n${codeRepairResult.customFunctionsContent}\n\`\`\`\n</code>`;
761+
assistantResponse += `<code filename="${customFunctionsTargetPath || customFunctionsFileName}" type="ai_map">\n\`\`\`ballerina\n${codeRepairResult.customFunctionsContent}\n\`\`\`\n</code>`;
727762
}
728763
}
729764

@@ -765,6 +800,7 @@ export async function generateContextTypesCore(typeCreationRequest: ProcessConte
765800
try {
766801
const biDiagramRpcManager = new BiDiagramRpcManager();
767802
const langClient = StateMachine.langClient();
803+
const context = StateMachine.context();
768804
const projectComponents = await biDiagramRpcManager.getProjectComponents();
769805

770806
// Generate types from context with validation
@@ -774,11 +810,22 @@ export async function generateContextTypesCore(typeCreationRequest: ProcessConte
774810
langClient
775811
);
776812

813+
// For workspace projects, compute relative file path from workspace root
814+
const workspacePath = context.workspacePath;
815+
const projectRoot = context.projectPath;
816+
let targetFilePath = filePath;
817+
818+
if (workspacePath && projectRoot) {
819+
// Workspace project: need to include package path prefix (e.g., "foo/types.bal")
820+
const absoluteFilePath = path.isAbsolute(filePath) ? filePath : path.join(projectRoot, filePath);
821+
targetFilePath = path.relative(workspacePath, absoluteFilePath);
822+
}
823+
777824
// Build assistant response
778825
const sourceAttachmentNames = typeCreationRequest.attachments?.map(a => a.name).join(", ") || "attachment";
779826
const fileText = typeCreationRequest.attachments?.length === 1 ? "file" : "files";
780827
assistantResponse = `Record types generated from the ${sourceAttachmentNames} ${fileText} shown below.\n`;
781-
assistantResponse += `<code filename="${filePath}" type="type_creator">\n\`\`\`ballerina\n${typesCode}\n\`\`\`\n</code>`;
828+
assistantResponse += `<code filename="${targetFilePath}" type="type_creator">\n\`\`\`ballerina\n${typesCode}\n\`\`\`\n</code>`;
782829

783830
// Send assistant response through event handler
784831
eventHandler({ type: "content_block", content: assistantResponse });

0 commit comments

Comments
 (0)