Skip to content

Commit

Permalink
Merge pull request #57 from neptunelabs/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
staybyte authored Jun 26, 2024
2 parents 208075b + 4729981 commit 9a22d24
Show file tree
Hide file tree
Showing 8 changed files with 1,768 additions and 1,403 deletions.
3,064 changes: 1,717 additions & 1,347 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neptunelabs/fsi-server-api-client",
"version": "1.0.89",
"version": "1.0.92",
"description": "API client for NeptuneLabs FSI Server",
"homepage": "https://github.com/neptunelabs/fsi-server-api-client-js#readme",
"scripts": {
Expand Down Expand Up @@ -31,35 +31,35 @@
"url": "https://github.com/neptunelabs/fsi-server-api-client-js/issues"
},
"engines": {
"node": ">=16.0.0",
"node": ">=18.0.0",
"npm": ">=6.0.0"
},
"license": "Apache-2.0",
"devDependencies": {
"@types/bytes": "^3.1.1",
"@types/chai": "^4.2.18",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"@types/ungap__url-search-params": "^0.1.0",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"chai": "^4.3.4",
"prettier": "^2.7.1",
"@types/bytes": "^3.1.4",
"@types/chai": "^4.3.16",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.8",
"@types/ungap__url-search-params": "^0.1.2",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"chai": "^4.4.1",
"json-schema": "^0.4.0",
"mocha": "^10.0.0",
"nock": "^13.2.2",
"mocha": "^10.5.1",
"nock": "^13.5.4",
"prettier": "^3.3.2",
"shelljs": "^0.8.5",
"ts-loader": "^9.1.2",
"ts-node": "^10.1.2",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.5.4",
"webpack": "^5.66.0",
"webpack-cli": "^5.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.5.2",
"webpack": "^5.92.1",
"webpack-cli": "^5.1.4",
"webpack-node-externals": "^3.0.0"
},
"dependencies": {
"@ungap/url-search-params": "^0.2.2",
"axios": "^1.2.2",
"axios": "^1.7.2",
"bytes": "^3.1.2"
}
}
6 changes: 3 additions & 3 deletions src/Download.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {AxiosRequestConfig} from "axios";
import { AxiosRequestConfig, AxiosResponseHeaders } from "axios";
import {default as fs} from "fs";
import urlSearchParams from "@ungap/url-search-params";
import {APIErrors, IAPIErrorDef} from "./resources/APIErrors";
import {APITasks, IAPITaskDef} from "./resources/APITasks";
import {APIAbortController} from "./APIAbortController";
import {FSIServerClientInterface, IProgressOptions, IPromptReply} from "./FSIServerClientInterface";
import {FSIServerClientUtils, IPathAndDir, IStringStringMap, IStringStringUndefinedMap} from "./FSIServerClientUtils";
import {FSIServerClientUtils, IPathAndDir, IStringStringMap} from "./FSIServerClientUtils";
import {IListData, IListEntry, IListEntryDownload, IListOptions} from "./ListServer";
import {TaskController} from "./TaskController";
import {TaskProgress} from "./TaskProgress";
Expand Down Expand Up @@ -193,7 +193,7 @@ export class Download {

targetPath = FSIServerClientUtils.NORMALIZE_PATH(targetPath);

const createStream = async (headers: IStringStringUndefinedMap): Promise<void> => {
const createStream = async (headers: AxiosResponseHeaders | any): Promise<void> => {


if (options.getICCProfile === true) {
Expand Down
5 changes: 0 additions & 5 deletions src/FSIServerClientUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ export interface IStringStringMap {
[key: string]: string;
}

export interface IStringStringUndefinedMap {
[key: string]: string | undefined;
}


export interface IStringAnyMap {
[key: string]: any;
}
Expand Down
1 change: 0 additions & 1 deletion src/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,6 @@ export class Queue {
}

private checkAborted(): void {

if (!this.aborted && this.abortController.getAborted()) {
const err: APIError = this.com.err.get(APIErrors.userAborted);
this.addError(err);
Expand Down
7 changes: 4 additions & 3 deletions src/TaskController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ export class TaskController {
}

public onPromiseError(msg: string, error: APIError): void {

if (error.message) msg += " -> " + error.message;
this.log(LogLevel.error, "ERROR: " + msg);
}

public onPromiseOk(): void {
if (this.currentTask) {

this.log(LogLevel.trace, "DONE: " + this.currentTask.getMessage());
}
}
Expand Down Expand Up @@ -200,10 +200,11 @@ export class TaskController {

const msg: string = (this.currentTask) ? this.currentTask.getMessage() : "unknown";

return p.then(arg => {
return p
.then(arg => {
this.onPromiseOk();
return arg;
})
})
.catch(error => {
this.onPromiseError(msg, error);
throw error;
Expand Down
44 changes: 22 additions & 22 deletions test/src/integration/queue.abort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {default as nock} from 'nock'
import {APIError, FSIServerClient, FSIServerClientUtils, LogLevel} from "library/index";
import {default as data} from "./reImportData.json"

const host = 'http://fsi.fake.tld';
const host:string = 'http://fsi.fake.tld';
const client = new FSIServerClient(host);
client.setLogLevel(LogLevel.none);

Expand All @@ -14,42 +14,42 @@ it('queue.abort()', () => {

// setup replies
// list
nock(host)
.get(/\/fsi\/server\?type=list&tpl=interface_thumbview_default.json&source=.*/)
.matchHeader('accept', 'application/json')
.matchHeader("user-agent", FSIServerClientUtils.USERAGENT)
.reply(200, data.listReply3);

// nock(host)
// .get(/\/fsi\/server\?type=list&tpl=interface_thumbview_default.json&source=.*/)
// .matchHeader('accept', 'application/json')
// .matchHeader("user-agent", FSIServerClientUtils.USERAGENT)
// .reply(200, data.listReply1);


const queue = client.createQueue({continueOnError: true});
queue.listServer("images/", {"recursive": true});

const res = queue.run()
.then(() => {
expect("result").equals("must catch");
},
(error) => {


expect(error.message).to.not.contain("must catch");
console.error("queue.abort() did not work!");
expect("foo").equals("must catch");
})
.catch( (error) => {

expect(queue.getAborted()).equals(true);
expect(error.message).to.not.contain("must catch");

const errors = queue.getErrors();
expect(errors).to.have.lengthOf(1);
const err: APIError = errors[0] as APIError;
expect(err).to.have.property("type");
if (err.type) expect(err.type).to.equal("aborted");
expect(queue.getAborted()).equals(true);

const errors = queue.getErrors();

})
expect(errors).to.have.lengthOf(1);
const err: APIError = errors[0] as APIError;
expect(err).to.have.property("type");
if (err.type) {
expect(err.type).to.equal("aborted");
}
})
.finally(() => {
nock.cleanAll();
});


queue.abort();

queue.abort();

return res;
});
Expand Down
4 changes: 2 additions & 2 deletions test/src/integration/queue.getRunning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ it('queue.changePassword(), queue.changeUser() and queue.getUserList()', () => {
queue.getUserList();


const res = queue.run()
const result = queue.run()
.then((res) => {
expect(res).equals(true);
expect(client.getCurrentUser()).equals("someUser", "client.getCurrentUser() !== \"someUser\"");
Expand All @@ -111,7 +111,7 @@ it('queue.changePassword(), queue.changeUser() and queue.getUserList()', () => {
});


return res;
return result;
});


0 comments on commit 9a22d24

Please sign in to comment.