Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] TypeScript transformation - platform - workspace #3439

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,78 @@
* SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Eclipse Dirigible contributors
* SPDX-License-Identifier: EPL-2.0
*/
import { json } from "@dirigible/http/response";
import * as bytes from "@dirigible/io/bytes";
import { workspace } from ".";
const WorkspaceFacade = Java.type("org.eclipse.dirigible.components.api.platform.WorkspaceFacade");

export function createWorkspace(name) {
const native = WorkspaceFacade.createWorkspace(name);
return new Workspace(native);
};
export class Workspaces{
public static createWorkspace(name: string): Workspace {
return new Workspace(WorkspaceFacade.createWorkspace(name));
};

public static getWorkspace(name: string): Workspace {
return new Workspace(WorkspaceFacade.getWorkspace(name));
};

public static getWorkspacesNames(): JSON | any {
let workspacesNames = WorkspaceFacade.getWorkspacesNames();

export function getWorkspace(name) {
const native = WorkspaceFacade.getWorkspace(name);
return new Workspace(native);
};
if (workspacesNames) {
return JSON.parse(workspacesNames);
}

export function getWorkspacesNames() {
const workspacesNames = WorkspaceFacade.getWorkspacesNames();
if (workspacesNames) {
return JSON.parse(workspacesNames);
}
return workspacesNames;
};
return workspacesNames;
};

export function deleteWorkspace(name) {
WorkspaceFacade.deleteWorkspace(name);
};
public static deleteWorkspace(name: string): void {
WorkspaceFacade.deleteWorkspace(name);
};
}

/**
* Workspace object
*/
class Workspace {

constructor(private native) { }
constructor(private native: any) { }

getProjects() {
getProjects(): Projects {
const native = this.native.getProjects();
return new Projects(native);
};

createProject(name) {
createProject(name: string): Project {
const native = this.native.createProject(name);
return new Project(native);
};

getProject(name) {
getProject(name: string): Project {
const native = this.native.getProject(name);
return new Project(native);
};

deleteProject(name) {
deleteProject(name: string): void {
this.native.deleteProject(name);
};

exists() {
exists(): boolean {
return this.native.exists();
};

existsFolder(path) {
existsFolder(path: string): boolean {
return this.native.existsFolder(path);
};

existsFile(path) {
existsFile(path: string): boolean {
return this.native.existsFile(path);
};

copyProject(source, target) {
copyProject(source: string, target: string): void {
this.native.copyProject(source, target);
};

moveProject(source, target) {
moveProject(source: string, target: string): void {
this.native.moveProject(source, target);
};

Expand All @@ -87,13 +91,13 @@ class Workspace {
*/
class Projects {

constructor(private native) { }
constructor(private native: any) { }

size() {
size(): number {
return this.native.size();
};

get(index) {
get(index: string): Project {
const native = this.native.get(index);
return new Project(native);
};
Expand All @@ -105,65 +109,65 @@ class Projects {
*/
class Project {

constructor(private native) { }
constructor(private native: any) { }

getName() {
getName(): string {
const collection = this.native.getInternal();
return collection.getName();
};

getPath() {
getPath(): string {
const collection = this.native.getInternal();
return collection.getPath();
};

createFolder(path) {
createFolder(path: string): Folder {
const native = this.native.createFolder(path);
return new Folder(native);
};

exists() {
exists(): boolean {
return this.native.exists();
};

existsFolder(path) {
existsFolder(path: string): boolean {
return this.native.existsFolder(path);
};

getFolder(path) {
getFolder(path: string): Folder {
const native = this.native.getFolder(path);
return new Folder(native);
};

getFolders(path) {
getFolders(path: string): Folders {
const native = this.native.getFolders(path);
return new Folders(native);
};

deleteFolder(path) {
deleteFolder(path: string): void {
return this.native.deleteFolder(path);
};

createFile(path, input) {
createFile(path: string, input: any): File {
const native = this.native.createFile(path, input);
return new File(native);
};

existsFile(path) {
existsFile(path: string): boolean {
return this.native.existsFile(path);
};

getFile(path) {
getFile(path: string): File {
const native = this.native.getFile(path);
return new File(native);
};

getFiles(path) {
getFiles(path: string): Files {
const native = this.native.getFiles(path);
return new Files(native);
};

deleteFile(path) {
deleteFile(path: string): void {
return this.native.deleteFile(path);
};

Expand All @@ -174,14 +178,14 @@ class Project {
*/
class Folders {

constructor(private native) { }
constructor(private native: any) { }

size() {
size(): number {
const size = this.native.size();
return size;
};

get(index) {
get(index: number): Folder {
const native = this.native.get(index);
return new Folder(native);
};
Expand All @@ -193,14 +197,14 @@ class Folders {
*/
class Files {

constructor(private native) { }
constructor(private native: any) { }

size() {
size(): number {
const size = this.native.size();
return size;
};

get(index) {
get(index: number): File {
const native = this.native.get(index);
return new File(native);
};
Expand All @@ -212,66 +216,66 @@ class Files {
*/
class Folder {

constructor(private native) { }
constructor(private native: any) { }

getName() {
getName(): string {
const collection = this.native.getInternal();
const name = collection.getName();
return name;
};

getPath() {
getPath(): string {
const collection = this.native.getInternal();
return collection.getPath();
};

createFolder(path) {
createFolder(path: string): Folder {
const native = this.native.createFolder(path);
return new Folder(native);
};

exists() {
exists(): boolean {
return this.native.exists();
};

existsFolder(path) {
existsFolder(path: string): boolean {
return this.native.existsFolder(path);
};

getFolder(path) {
getFolder(path: string): Folder {
const native = this.native.getFolder(path);
return new Folder(native);
};

getFolders(path) {
getFolders(path: string): Folders {
const native = this.native.getFolders(path);
return new Folders(native);
};

deleteFolder(path) {
deleteFolder(path: string): void {
return this.native.deleteFolder(path);
};

createFile(path, input) {
createFile(path: string, input: any): File {
const native = this.native.createFile(path, input);
return new File(native);
};

existsFile(path) {
existsFile(path: string): boolean {
return this.native.existsFile(path);
};

getFile(path) {
getFile(path: string): File {
const native = this.native.getFile(path);
return new File(native);
};

getFiles(path) {
getFiles(path: string): Files {
const native = this.native.getFiles(path);
return new Files(native);
};

deleteFile(path) {
deleteFile(path: string): void {
return this.native.deleteFile(path);
};

Expand All @@ -282,50 +286,50 @@ class Folder {
*/
class File {

constructor(private native) { }
constructor(private native: any) { }

getName() {
getName(): string {
const collection = this.native.getInternal();
return collection.getName();
};

getPath() {
getPath(): string {
const collection = this.native.getInternal();
return collection.getPath();
};

getContentType() {
getContentType(): string {
return this.native.getContentType();
};

isBinary() {
isBinary(): boolean {
return this.native.isBinary();
};

getContent() {
getContent(): any {
const output = WorkspaceFacade.getContent(this.native);
if (output) {
output;
}
return output;
};

getText() {
getText(): string {
const bytesOutput = this.getContent();
return bytes.byteArrayToText(bytesOutput);
};

setContent(input) {
setContent(input: any): any {
const output = WorkspaceFacade.setContent(this.native, input);
return output;
};

setText(input) {
setText(input: any): any {
const bytesInput = bytes.textToByteArray(input);
return this.setContent(bytesInput);
};

exists() {
exists(): boolean {
return this.native.exists();
};
}