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

Develop #17

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"typescript.tsc.autoDetect": "off",

"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.organizeImports": "explicit",
"source.fixAll": "always"
}
},
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
"javascript.experimental.updateImportsOnPaste": true
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [0.14.0] - 09/12/2024

### Added

- `Protocol` setting to system

### Changed

- `Port` is no longer required.

## [0.13.6] - 13/11/2023

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 TaBayramNTT
Copyright (c) 2023 TaBayram

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

This extension tries to be a replacement for the web side of the standart mii workbench.

**Made by NTT Data Business Solutions Turkiye MII Team**

## Usage

Expand Down
33 changes: 24 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"description": "Sync projects in MII server",
"publisher": "NTTDataTurkiyeMII",
"author": {
"name": "TaBayramNTT",
"url": "https://github.com/TaBayramNTT"
"name": "TaBayram",
"url": "https://github.com/TaBayram"
},
"repository": {
"url": "https://github.com/TaBayramNTT/vscode-miisync",
"url": "https://github.com/TaBayram/vscode-miisync",
"type": "github"
},
"homepage": "https://github.com/TaBayramNTT/vscode-miisync",
"homepage": "https://github.com/TaBayram/vscode-miisync",
"icon": "resources/icon.png",
"version": "0.13.6",
"version": "0.14.1",
"license": "MIT",
"engines": {
"vscode": "^1.83.1"
Expand Down Expand Up @@ -280,7 +280,7 @@
{
"command": "miisync.downloadtransactionproperties",
"group": "mii",
"when": "editorLangId == 'javascript'"
"when": "editorLangId == 'javascript' || editorLangId == 'typescript'"
}
],
"view/title": [
Expand Down Expand Up @@ -318,7 +318,7 @@
},
{
"command": "miisync.openscreen",
"when": "view == remotedirectory && viewItem == index.html",
"when": "view == remotedirectory && viewItem =~ /index.*html/ ",
"group": "inline@0"
},
{
Expand All @@ -336,7 +336,7 @@
{
"command": "miisync.openscreen",
"group": "aa@1",
"when": "miisync.enabled && resourceFilename == index.html"
"when": "miisync.enabled && resourceFilename =~ /index.*html/"
},
{
"command": "miisync.uploadbroad",
Expand Down Expand Up @@ -478,7 +478,12 @@
},
"severity": {
"type": "string",
"enum": ["0-low","1-medium","2-high","3-critical"],
"enum": [
"0-low",
"1-medium",
"2-high",
"3-critical"
],
"default": "1-medium",
"description": "Severity level of the system. The higher the more confirms asked for operations"
},
Expand All @@ -497,6 +502,15 @@
"default": 50000,
"description": "Port of the target MII system."
},
"protocol": {
"type": "string",
"enum": [
"http",
"https"
],
"default": "http",
"description": "Protocol of the target system."
},
"username": {
"type": "string",
"default": "x-name",
Expand All @@ -513,6 +527,7 @@
"isMain": false,
"host": "11.22.33.44",
"port": 50000,
"protocol": "http",
"username": "x-name",
"password": "1234"
}
Expand Down
6 changes: 6 additions & 0 deletions schema/miisyncschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
"default": 50000,
"description": "Port of the target system."
},
"protocol": {
"type": "string",
"enum": ["http","https"],
"default": "http",
"description": "Protocol of the target system."
},
"username": {
"type": "string",
"default": "x-name",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commanddownloadproject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export async function OnCommandDownloadProject(){
logger.error("Remote Path doesn't exist");
return;
}
exportProjectService.call({host: configManager.CurrentSystem.host, port: configManager.CurrentSystem.port}, parentPath);
exportProjectService.call(configManager.CurrentSystem, parentPath);
return;
}
6 changes: 3 additions & 3 deletions src/commands/commandopenscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export async function OnCommandOpenScreen(obj: Uri | TreeItem) {
if (obj) {
if ('fsPath' in obj) {
const remotePath = GetRemotePath(obj.fsPath, userConfig, false);
openScreenService.call({ host: configManager.CurrentSystem.host, port: configManager.CurrentSystem.port }, remotePath);
openScreenService.call(configManager.CurrentSystem, remotePath);
return;
}
if ('data' in obj) {
const remotePath = RemoveWeb(obj.data.filePath + '/' + obj.data.name);
openScreenService.call({ host: configManager.CurrentSystem.host, port: configManager.CurrentSystem.port }, remotePath);
openScreenService.call(configManager.CurrentSystem, remotePath);
return;
}
}
Expand All @@ -28,7 +28,7 @@ export async function OnCommandOpenScreen(obj: Uri | TreeItem) {
const name = await FindFileInDir(workspaceUri.fsPath, 'index.html');
if (!name) return;
const remotePath = GetRemotePath(name, userConfig, false);
openScreenService.call({ host: configManager.CurrentSystem.host, port: configManager.CurrentSystem.port }, remotePath);
openScreenService.call(configManager.CurrentSystem, remotePath);


}
2 changes: 1 addition & 1 deletion src/events/changeactivettexteditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function CheckFileDifference(document: vscode.TextDocument, fileProp: File
if (system.username != modifiedUser) {
if (saidNoToTheseDocuments.find((no) => no.fsPath === document.uri.fsPath && no.modifiedTime == fileProp.Modified && no.modifiedUser == fileProp.ModifiedBy)) return;

const file = await readFileService.call({ host: system.host, port: system.port }, sourcePath);
const file = await readFileService.call(system, sourcePath);
if (!file || IsFatalResponse(file)) return;
const payload = file?.Rowsets?.Rowset?.Row?.find((row) => row.Name == "Payload");
if (!payload) return;
Expand Down
11 changes: 8 additions & 3 deletions src/extension/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ export enum Severity{
critical = "3-critical"
}

export interface SystemConfig {
export interface MIIServer {
host: string,
port: number,
protocol?: 'http' | 'https',
}

export interface SystemConfig extends MIIServer {
name: string,
isMain: boolean,
severity: Severity
host: string,
port: number,
username: string,
password?: string,
}
Expand All @@ -34,6 +38,7 @@ export class System implements SystemConfig {
isMain: boolean;
host: string;
port: number;
protocol?: 'http' | 'https'
username: string;
password?: string;

Expand Down
17 changes: 8 additions & 9 deletions src/miiservice/abstract/miiservice.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { X2jOptions, XMLParser } from 'fast-xml-parser';
import fetch, { HeadersInit, RequestRedirect, Response } from "node-fetch";
import { MIIServer } from '../../extension/system.js';
import logger from '../../ui/logger.js';
import { GetSession } from '../../user/session.js';

export interface Request {
host: string,
port: number,
export interface Request extends MIIServer {
body?: string
}

Expand All @@ -22,21 +21,21 @@ export interface MIIParams {
"Session"?: boolean
}

export abstract class Service{
export abstract class Service {
readonly abstract name: string;
readonly abstract mode: string;

constructor() { }

abstract call(request: Request, ...args: any): Promise<any>;
abstract get(host: string, port: number, ...args: any): string;
abstract get(system: MIIServer, ...args: any): string;
protected abstract generateParams(...args: any): string;

protected generateURL(host: string, port: number, protocol: 'http' | 'https' = 'http') {
return `${this.generateIP(host, port, protocol)}/${this.mode}`;
protected generateURL(server: MIIServer) {
return `${this.generateIP(server)}/${this.mode}`;
}
protected generateIP(host: string, port: number, protocol: 'http' | 'https' = 'http') {
return `${protocol}://${host}:${port}`;
protected generateIP({ host, port, protocol = "http" }: MIIServer) {
return `${protocol}://${host}${port ? ':' + port : ''}`;
}

protected async fetch(url: URL, settings?: FetchSettings): Promise<{ value: any, error: Error, isError: boolean, data?: any }> {
Expand Down
9 changes: 5 additions & 4 deletions src/miiservice/blowoutservice.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { MIIServer } from '../extension/system.js';
import { Request, Service } from './abstract/miiservice.js';
import { MIISafe, RowsetsMessage } from './abstract/responsetypes.js';

class BlowoutService extends Service {
name: string = "Delete Batch";
mode: string = "XMII/Catalog?Mode=Blowout&Class=Content&Content-Type=text/xml";

async call({ host, port }: Request, folderPath: string) {
const url = this.get(host, port, folderPath);
async call(request: Request, folderPath: string) {
const url = this.get(request, folderPath);
const { value, error, isError } = await this.fetch(new URL(url));
let data: MIISafe<null, null, RowsetsMessage> = null;
if (!isError) {
data = this.parseXML(value);
}
return data;
}
get(host: string, port: number, sourcePath: string) {
return this.generateURL(host, port, "http") + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
get(server: MIIServer, sourcePath: string) {
return this.generateURL(server) + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
}
protected generateParams(folder: string) {
return "Folder=" + folder;
Expand Down
9 changes: 5 additions & 4 deletions src/miiservice/createfolderservice.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { MIIServer } from '../extension/system.js';
import { Request, Service } from './abstract/miiservice.js';
import { MIISafe, RowsetsMessage } from './abstract/responsetypes.js';

class CreateFolderService extends Service {
name: string = "Create Folder";
mode: string = "XMII/Catalog?Mode=CreateFolder&Notify=true";

async call({ host, port }: Request, foldePath: string) {
const url = this.get(host, port, foldePath);
async call(request: Request, foldePath: string) {
const url = this.get(request, foldePath);
const { value, error, isError } = await this.fetch(new URL(url), { auth: false });
let data: MIISafe<null, null, RowsetsMessage> = null;
if (!isError) {
data = this.parseXML(value);
}
return data;
}
get(host: string, port: number, sourcePath: string) {
return this.generateURL(host, port, "http") + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
get(server: MIIServer, sourcePath: string) {
return this.generateURL(server) + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
}
protected generateParams(folderPath: string) {
return "Folder=" + folderPath;
Expand Down
9 changes: 5 additions & 4 deletions src/miiservice/currentuserservice.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { MIIServer } from '../extension/system.js';
import { Request, Service } from './abstract/miiservice.js';
import { CurrentUser, GeneralColumn, MIISafe } from './abstract/responsetypes.js';

class CurrentUsersService extends Service {
name: string = "Current Users";;
mode: string = "XMII/Illuminator?service=admin&mode=SessionList&content-type=text/json";

async call({ host, port }: Request) {
const url = this.get(host, port);
async call(request: Request) {
const url = this.get(request);
const { value, error, isError } = await this.fetch(new URL(url));
let data: MIISafe<CurrentUser, GeneralColumn> = null;
if (!isError) {
Expand All @@ -17,8 +18,8 @@ class CurrentUsersService extends Service {
/**
* response is JSON
*/
get(host: string, port: number) {
return this.generateURL(host, port, "http");
get(server: MIIServer) {
return this.generateURL(server);
}
protected generateParams() { return '' }
}
Expand Down
9 changes: 5 additions & 4 deletions src/miiservice/deletebatchservice.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MIIServer } from '../extension/system.js';
import { Request, Service } from './abstract/miiservice.js';
import { MIISafe, RowsetsMessage } from './abstract/responsetypes.js';

Expand All @@ -6,17 +7,17 @@ class DeleteBatchService extends Service {
mode: string = "XMII/Catalog?Mode=BatchDelete&Class=Content&Content-Type=text/xml";
optionals: string = "&TemporaryFile=false&Notify=true"

async call({ host, port }: Request, sourcePath: string) {
const url = this.get(host, port, sourcePath);
async call(request: Request, sourcePath: string) {
const url = this.get(request, sourcePath);
const { value, error, isError } = await this.fetch(new URL(url));
let data: MIISafe<null, null, RowsetsMessage> = null;
if (!isError) {
data = this.parseXML(value);
}
return data;
}
get(host: string, port: number, sourcePath: string) {
return this.generateURL(host, port, "http") + this.optionals + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
get(server: MIIServer, sourcePath: string) {
return this.generateURL(server) + this.optionals + `&${this.generateParams(sourcePath)}&__=${new Date().getTime()}`;
}
protected generateParams(objectName: string) {
return "ObjectName=" + objectName;
Expand Down
9 changes: 5 additions & 4 deletions src/miiservice/existsservice.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MIIServer } from '../extension/system.js';
import { Request, Service } from './abstract/miiservice.js';
import { MIISafe, RowsetsMessage } from './abstract/responsetypes.js';

Expand All @@ -11,17 +12,17 @@ class ExistsService extends Service {
*
* @returns 0 doesn't exist, 1 file exists, 2 folder exists
*/
async call({ host, port }: Request, path: string) {
const url = this.get(host, port, path);
async call(request: Request, path: string) {
const url = this.get(request, path);
const { value, error, isError } = await this.fetch(new URL(url));
let data: MIISafe<null, null, RowsetsMessage> = null;
if (!isError) {
data = this.parseXML(value);
}
return data;
}
get(host: string, port: number, folderPath: string) {
return this.generateURL(host, port, "http") + `&${this.generateParams(folderPath)}&__=${new Date().getTime()}`;
get(server: MIIServer, folderPath: string) {
return this.generateURL(server) + `&${this.generateParams(folderPath)}&__=${new Date().getTime()}`;
}
protected generateParams(path: string) {
return "ObjectName=" + path;
Expand Down
Loading