Skip to content

Commit 9e32935

Browse files
authored
Support importing/exporting XML files (intersystems-community#1171)
1 parent bb63edf commit 9e32935

File tree

11 files changed

+806
-135
lines changed

11 files changed

+806
-135
lines changed

docs/Studio.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ The [InterSystems ObjectScript extension](https://marketplace.visualstudio.com/i
4848

4949
The [InterSystems ObjectScript extension](https://marketplace.visualstudio.com/items?itemName=intersystems-community.vscode-objectscript) provides commands for creating new Interoperability classes. Commands are provided for Business Operation, Business Process, Business Rule, Business Service and Data Transformation classes. These commands are modeled after the wizards in Studio's [`File` → `New...` → `Production` menu](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GSTD_Commands#GSTD_Commands_File). The commands are shown in the `New File...` menu, which can be opened from the `File` menu (`File` → `New File...`) or the `Get Started` welcome page.
5050

51+
## XML Import/Export Commands
52+
53+
The [InterSystems ObjectScript extension](https://marketplace.visualstudio.com/items?itemName=intersystems-community.vscode-objectscript) provides commands for importing and exporting XML files. The commands can be invoked from [the command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) under the titles `Import XML Files...` and `Export Documents to XML File...`. These commands require an active server connection (the one from the currently opened document will be used if one is open), and the server's version must be 2023.2 or greater.
54+
5155
## Keyboard Shortcuts
5256

5357
In general, VS Code keyboard shortcuts are infinitely customizable <a href="https://code.visualstudio.com/docs/getstarted/keybindings">as described in the docs</a>. However, the IDE comes configured with a number of shortcuts that match Studio. <a href="https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference">Download a cheat sheet here</a>.

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
"onCommand:vscode-objectscript.openErrorLocation",
9292
"onCommand:vscode-objectscript.launchWebSocketTerminal",
9393
"onCommand:vscode-objectscript.intersystems-servermanager.webterminal",
94+
"onCommand:vscode-objectscript.importXMLFiles",
95+
"onCommand:vscode-objectscript.exportToXMLFile",
9496
"onTerminalProfile:vscode-objectscript.webSocketTerminal",
9597
"onLanguage:objectscript",
9698
"onLanguage:objectscript-int",
@@ -355,6 +357,14 @@
355357
{
356358
"command": "vscode-objectscript.intersystems-servermanager.webterminal",
357359
"when": "false"
360+
},
361+
{
362+
"command": "vscode-objectscript.importXMLFiles",
363+
"when": "vscode-objectscript.connectActive && workspaceFolderCount != 0"
364+
},
365+
{
366+
"command": "vscode-objectscript.exportToXMLFile",
367+
"when": "vscode-objectscript.connectActive && workspaceFolderCount != 0"
358368
}
359369
],
360370
"view/title": [
@@ -1146,6 +1156,16 @@
11461156
"command": "vscode-objectscript.intersystems-servermanager.webterminal",
11471157
"title": "Launch WebSocket Terminal",
11481158
"icon": "$(terminal)"
1159+
},
1160+
{
1161+
"category": "ObjectScript",
1162+
"command": "vscode-objectscript.importXMLFiles",
1163+
"title": "Import XML Files..."
1164+
},
1165+
{
1166+
"category": "ObjectScript",
1167+
"command": "vscode-objectscript.exportToXMLFile",
1168+
"title": "Export Documents to XML File..."
11491169
}
11501170
],
11511171
"keybindings": [

src/api/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ export class AtelierAPI {
240240
);
241241
}
242242

243+
/** Return the server's name in `intersystems.servers` if it exists, else its `host:port/pathPrefix` */
244+
public get serverId(): string {
245+
const { serverName, host, port, pathPrefix } = this.config;
246+
return serverName && serverName !== "" ? serverName : `${host}:${port}${pathPrefix}`;
247+
}
248+
243249
public async request(
244250
minVersion: number,
245251
method: string,
@@ -723,4 +729,25 @@ export class AtelierAPI {
723729
public async getCSPDebugId(): Promise<Atelier.Response<Atelier.Content<number>>> {
724730
return this.request(2, "GET", "%SYS/cspdebugid");
725731
}
732+
733+
// v7+
734+
public async actionXMLExport(body: string[]): Promise<Atelier.Response<Atelier.Content<string[]>>> {
735+
return this.request(7, "POST", `${this.ns}/action/xml/export`, body);
736+
}
737+
738+
// v7+
739+
public async actionXMLLoad(
740+
body: { file: string; content: string[]; selected?: string[] }[]
741+
): Promise<Atelier.Response<Atelier.Content<{ file: string; imported: string[]; status: string }[]>>> {
742+
return this.request(7, "POST", `${this.ns}/action/xml/load`, body);
743+
}
744+
745+
// v7+
746+
public async actionXMLList(
747+
body: { file: string; content: string[] }[]
748+
): Promise<
749+
Atelier.Response<Atelier.Content<{ file: string; documents: { name: string; ts: string }[]; status: string }[]>>
750+
> {
751+
return this.request(7, "POST", `${this.ns}/action/xml/list`, body);
752+
}
726753
}

0 commit comments

Comments
 (0)