Skip to content

Commit

Permalink
automation connections methods
Browse files Browse the repository at this point in the history
  • Loading branch information
countnazgul committed Dec 9, 2023
1 parent 7162cb4 commit 506aed6
Show file tree
Hide file tree
Showing 9 changed files with 1,408 additions and 794 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## 0.15.0 - 2023-12-09

- - `AutomationConnections` - new API endpoints implementation [post](https://qlik.dev/changelog/68-api-updates-automation-connections/)
- dependency updates

## 0.14.6 - 2023-09-20

- space assignments
Expand Down
2,063 changes: 1,283 additions & 780 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qlik-saas-api",
"version": "0.14.6",
"version": "0.15.0",
"description": "Interact with Qlik Sense SaaS REST API",
"author": {
"email": "info@informatiqal.com",
Expand All @@ -19,8 +19,7 @@
"build": "rollup -c",
"watch": "rollup -cw",
"docs": "npx typedoc src/index.doc.ts --name \"Qlik SaaS API\" --excludePrivate --hideGenerator",
"test": "set TS_NODE_PROJECT=tsconfig.test.json&mocha --require ts-node/register test/**/*.spec.ts --loader=ts-node/esm --no-warnings=ExperimentalWarning --experimental-specifier-resolution=node --ignore test/playground.spec.ts",
"test-badge": "set TS_NODE_PROJECT=tsconfig.test.json&mocha --reporter .\\node_modules\\mocha-badge-generator\\src --reporter-options=badge_format=svg,badge_output=badge.svg --require ts-node/register test/**/*.spec.ts"
"test": "vitest run test/app.spec.ts"
},
"engines": {
"node": ">=14.19.1"
Expand Down Expand Up @@ -59,22 +58,22 @@
},
"homepage": "https://informatiqal.com/qlik-saas-api/",
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.3",
"@rollup/plugin-typescript": "^11.1.5",
"@types/form-data": "^2.5.0",
"@types/node": "20.6.3",
"@types/node": "20.10.4",
"dotenv": "16.3.1",
"esm": "^3.2.25",
"nyc": "15.1.0",
"rollup": "^3.29.2",
"rollup": "^4.7.0",
"rollup-plugin-delete": "2.0.0",
"ts-node": "10.9.1",
"ts-node": "10.9.2",
"tslib": "^2.6.2",
"typedoc": "0.25.1",
"typedoc": "0.25.4",
"typescript": "5.0.4",
"vitest": "^0.34.4"
"vitest": "^1.0.3"
},
"dependencies": {
"form-data": "^4.0.0",
"qlik-rest-api": "^1.8.2"
"qlik-rest-api": "^1.8.3"
}
}
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Apps } from "./modules/Apps";
import { Brands } from "./modules/Brands";
import { DataAlerts } from "./modules/DataAlerts";
import { Automations } from "./modules/Automations";
import { AutomationConnections } from "./modules/AutomationConnections";
import { APIKeys } from "./modules/APIKeys";
import { Audits } from "./modules/Audits";
import { DataConnections } from "./modules/DataConnections";
Expand Down Expand Up @@ -36,6 +37,7 @@ export namespace QlikSaaSApi {
#saasClient: QlikSaaSClient;
public apps: Apps;
public automations: Automations;
public automationConnections: AutomationConnections;
public apiKeys: APIKeys;
public audits: Audits;
public brands: Brands;
Expand Down Expand Up @@ -82,6 +84,7 @@ export namespace QlikSaaSApi {

this.apps = new Apps(this.#saasClient);
this.automations = new Automations(this.#saasClient);
this.automationConnections = new AutomationConnections(this.#saasClient);
this.apiKeys = new APIKeys(this.#saasClient);
this.audits = new Audits(this.#saasClient);
this.brands = new Brands(this.#saasClient);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AppScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AppScript {
async getScriptContent() {
this.details.script = await this.#saasClient
.Get<string>(`apps/${this.appId}/scripts/${this.#id}`)
.then((res) => res.data);
.then((res) => res.data["script"]);

return this.details.script;
}
Expand Down
50 changes: 50 additions & 0 deletions src/modules/AutomationConnection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { QlikSaaSClient } from "qlik-rest-api";

export interface IAutomationConnection {
/**
* The unique identifier of an automation connection.
*/
id: string;
/**
* The name of an automation connection.
*/
name: string;
/**
* The unique identifier of the owner of the automation connection.
*/
ownerId: string;
/**
* The timestamp when the automation connection is created.
*/
createdAt: string;
/**
* The timestamp when the automation connection is updated.
*/
updatedAt: string;
/**
* The unique identifier of the connector the automation connection is created from.
*/
connectorId: string;
/**
* Returns true if the automation connection is connected.
*/
isConnected: boolean;
}

export class AutomationConnection {
#id: string;
#saasClient: QlikSaaSClient;
details: IAutomationConnection;
constructor(
saasClient: QlikSaaSClient,
id: string,
details?: IAutomationConnection
) {
if (!id)
throw new Error(`automationConnection.get: "id" parameter is required`);

this.details = details ?? ({} as IAutomationConnection);
this.#id = id;
this.#saasClient = saasClient;
}
}
56 changes: 56 additions & 0 deletions src/modules/AutomationConnections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { QlikSaaSClient } from "qlik-rest-api";
import {
AutomationConnection,
IAutomationConnection,
} from "./AutomationConnection";

export class AutomationConnections {
#saasClient: QlikSaaSClient;
constructor(saasClient: QlikSaaSClient) {
this.#saasClient = saasClient;
}

async getAll(
/**
* One of (default is "id"):
*
* id
*
* name
*
* createdAt
*
* updatedAt
*
* +id
*
* +name
*
* +createdAt
*
* +updatedAt
*
* -id
*
* -name
*
* -createdAt
*
* -updatedAt
*/
sortBy?: string
) {
const sortByUrlParam = sortBy ? `&sort=${sortBy}` : "";

return await this.#saasClient
.Get<IAutomationConnection[]>(
`automation-connections?limit=50${sortByUrlParam}`
)
.then((res) => res.data)
.then((data) => {
return data.map(
(t) => new AutomationConnection(this.#saasClient, t.id, t)
);
});
}
}
2 changes: 0 additions & 2 deletions test/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const saasApi = config.saasApi;
const helpers = new Helpers();

describe("Apps", function () {
this.timeout(30000);

it("Script operations", async function () {
const tempAppName = "Temp API Test app";
const script1 = "let a = 1;";
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
testTimeout: 300000,
exclude: [
...configDefaults.exclude,
//"test/playground.spec.ts"
"test/playground.spec.ts"
],
},
});

0 comments on commit 506aed6

Please sign in to comment.