From 6e3d583619930898694609919c1ee9dbd0ab4b97 Mon Sep 17 00:00:00 2001 From: Stefan Stoichev Date: Mon, 4 Sep 2023 10:05:56 +0100 Subject: [PATCH] config and id are private for all classes closes #219 --- CHANGELOG.md | 4 + package-lock.json | 18 ++--- package.json | 4 +- src/index.ts | 66 ++++++++-------- src/modules/APIKey.ts | 20 ++--- src/modules/APIKeys.ts | 18 ++--- src/modules/App.ts | 114 +++++++++++++-------------- src/modules/AppActions.ts | 22 +++--- src/modules/AppEvaluation.ts | 24 +++--- src/modules/AppEvaluations.ts | 12 +-- src/modules/AppMedia.ts | 14 ++-- src/modules/AppScript.ts | 24 +++--- src/modules/Apps.ts | 32 ++++---- src/modules/Assignment.ts | 16 ++-- src/modules/Audits.ts | 16 ++-- src/modules/Automation.ts | 46 +++++------ src/modules/Automations.ts | 20 ++--- src/modules/Brand.ts | 28 +++---- src/modules/BrandActions.ts | 16 ++-- src/modules/BrandFile.ts | 22 +++--- src/modules/Brands.ts | 14 ++-- src/modules/Collection.ts | 32 ++++---- src/modules/CollectionItem.ts | 16 ++-- src/modules/Collections.ts | 18 ++--- src/modules/Condition.ts | 16 ++-- src/modules/Conditions.ts | 14 ++-- src/modules/DataAlert.ts | 36 ++++----- src/modules/DataAlerts.interfaces.ts | 8 +- src/modules/DataAlerts.ts | 30 +++---- src/modules/DataConnection.ts | 20 ++--- src/modules/DataConnections.ts | 14 ++-- src/modules/DataCredential.ts | 20 ++--- src/modules/DataCredentials.ts | 10 +-- src/modules/Evaluation.ts | 16 ++-- src/modules/Evaluations.ts | 14 ++-- src/modules/Extension.ts | 28 +++---- src/modules/Extensions.ts | 14 ++-- src/modules/Group.ts | 20 ++--- src/modules/Groups.ts | 20 ++--- src/modules/IdentityProvider.ts | 16 ++-- src/modules/IdentityProviders.ts | 10 +-- src/modules/Item.ts | 24 +++--- src/modules/Items.ts | 12 +-- src/modules/LicenseAssignment.ts | 8 +- src/modules/Licenses.ts | 18 ++--- src/modules/NaturalLanguage.ts | 6 +- src/modules/Notification.ts | 4 +- src/modules/Notifications.ts | 8 +- src/modules/OAuthToken.ts | 12 +-- src/modules/OAuthTokens.ts | 8 +- src/modules/Origin.ts | 20 ++--- src/modules/Origins.ts | 16 ++-- src/modules/Quotas.ts | 8 +- src/modules/Reload.ts | 18 ++--- src/modules/ReloadTask.ts | 20 ++--- src/modules/ReloadTasks.ts | 14 ++-- src/modules/Reloads.ts | 14 ++-- src/modules/Roles.ts | 8 +- src/modules/Run.ts | 24 +++--- src/modules/Runs.ts | 12 +-- src/modules/Space.ts | 32 ++++---- src/modules/Spaces.ts | 18 ++--- src/modules/Tenant.ts | 24 +++--- src/modules/Tenants.ts | 10 +-- src/modules/Theme.ts | 28 +++---- src/modules/Themes.ts | 14 ++-- src/modules/Transports.ts | 12 +-- src/modules/TransportsActions.ts | 10 +-- src/modules/User.ts | 20 ++--- src/modules/Users.ts | 26 +++--- src/modules/UsersActions.ts | 8 +- src/modules/WebHook.ts | 36 ++++----- src/modules/WebHooks.ts | 16 ++-- src/modules/WebIntegration.ts | 20 ++--- src/modules/WebIntegrations.ts | 14 ++-- 75 files changed, 734 insertions(+), 730 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22aee30..179c100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 0.14.3 - 2023-09-04 + +- [#219](https://github.com/Informatiqal/qlik-saas-api/issues/219) `saasClient` and `id` are private and should not be available + ## 0.14.2 - 2023-08-29 - [#217](https://github.com/Informatiqal/qlik-saas-api/issues/217) import and update extension methods implemented diff --git a/package-lock.json b/package-lock.json index 665bccc..374fe90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "qlik-saas-api", - "version": "0.14.0", + "version": "0.14.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "qlik-saas-api", - "version": "0.14.0", + "version": "0.14.3", "license": "MIT", "dependencies": { "form-data": "^4.0.0", @@ -15,7 +15,7 @@ "devDependencies": { "@rollup/plugin-typescript": "^11.1.3", "@types/form-data": "^2.5.0", - "@types/node": "20.5.7", + "@types/node": "20.5.9", "dotenv": "16.3.1", "esm": "^3.2.25", "nyc": "15.1.0", @@ -1103,9 +1103,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", - "integrity": "sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "dev": true }, "node_modules/@vitest/expect": { @@ -4505,9 +4505,9 @@ "dev": true }, "@types/node": { - "version": "20.5.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", - "integrity": "sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "dev": true }, "@vitest/expect": { diff --git a/package.json b/package.json index 9342daa..70973a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qlik-saas-api", - "version": "0.14.2", + "version": "0.14.3", "description": "Interact with Qlik Sense SaaS REST API", "author": { "email": "info@informatiqal.com", @@ -61,7 +61,7 @@ "devDependencies": { "@rollup/plugin-typescript": "^11.1.3", "@types/form-data": "^2.5.0", - "@types/node": "20.5.7", + "@types/node": "20.5.9", "dotenv": "16.3.1", "esm": "^3.2.25", "nyc": "15.1.0", diff --git a/src/index.ts b/src/index.ts index 6695f2d..d64e0fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,7 +33,7 @@ import { Transports } from "./modules/Transports"; export namespace QlikSaaSApi { export class client { - public saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; public apps: Apps; public automations: Automations; public apiKeys: APIKeys; @@ -78,39 +78,39 @@ export namespace QlikSaaSApi { public notifications: Notifications; constructor(public saasConfig: any) { - this.saasClient = new QlikSaaSClient(saasConfig); + this.#saasClient = new QlikSaaSClient(saasConfig); - this.apps = new Apps(this.saasClient); - this.automations = new Automations(this.saasClient); - this.apiKeys = new APIKeys(this.saasClient); - this.audits = new Audits(this.saasClient); - this.brands = new Brands(this.saasClient); - this.dataAlerts = new DataAlerts(this.saasClient); - this.dataConnections = new DataConnections(this.saasClient); - this.dataCredentials = new DataCredentials(this.saasClient); - this.conditions = new Conditions(this.saasClient); - this.spaces = new Spaces(this.saasClient); - this.groups = new Groups(this.saasClient); - this.items = new Items(this.saasClient); - this.naturalLanguage = new NL(this.saasClient); - this.licenses = new Licenses(this.saasClient); - this.origins = new Origins(this.saasClient); - this.quotas = new Quotas(this.saasClient); - this.themes = new Themes(this.saasClient); - this.extensions = new Extensions(this.saasClient); - this.evaluations = new Evaluations(this.saasClient); - this.reloads = new Reloads(this.saasClient); - this.reloadTasks = new ReloadTasks(this.saasClient); - this.roles = new Roles(this.saasClient); - this.transports = new Transports(this.saasClient); - this.users = new Users(this.saasClient); - this.webHooks = new WebHooks(this.saasClient); - this.oauthTokens = new OAuthTokens(this.saasClient); - this.collections = new Collections(this.saasClient); - this.identityProviders = new IdentityProviders(this.saasClient); - this.tenants = new Tenants(this.saasClient); - this.webIntegrations = new WebIntegrations(this.saasClient); - this.notifications = new Notifications(this.saasClient); + this.apps = new Apps(this.#saasClient); + this.automations = new Automations(this.#saasClient); + this.apiKeys = new APIKeys(this.#saasClient); + this.audits = new Audits(this.#saasClient); + this.brands = new Brands(this.#saasClient); + this.dataAlerts = new DataAlerts(this.#saasClient); + this.dataConnections = new DataConnections(this.#saasClient); + this.dataCredentials = new DataCredentials(this.#saasClient); + this.conditions = new Conditions(this.#saasClient); + this.spaces = new Spaces(this.#saasClient); + this.groups = new Groups(this.#saasClient); + this.items = new Items(this.#saasClient); + this.naturalLanguage = new NL(this.#saasClient); + this.licenses = new Licenses(this.#saasClient); + this.origins = new Origins(this.#saasClient); + this.quotas = new Quotas(this.#saasClient); + this.themes = new Themes(this.#saasClient); + this.extensions = new Extensions(this.#saasClient); + this.evaluations = new Evaluations(this.#saasClient); + this.reloads = new Reloads(this.#saasClient); + this.reloadTasks = new ReloadTasks(this.#saasClient); + this.roles = new Roles(this.#saasClient); + this.transports = new Transports(this.#saasClient); + this.users = new Users(this.#saasClient); + this.webHooks = new WebHooks(this.#saasClient); + this.oauthTokens = new OAuthTokens(this.#saasClient); + this.collections = new Collections(this.#saasClient); + this.identityProviders = new IdentityProviders(this.#saasClient); + this.tenants = new Tenants(this.#saasClient); + this.webIntegrations = new WebIntegrations(this.#saasClient); + this.notifications = new Notifications(this.#saasClient); } } } diff --git a/src/modules/APIKey.ts b/src/modules/APIKey.ts index 3ff98f4..52d3fe3 100644 --- a/src/modules/APIKey.ts +++ b/src/modules/APIKey.ts @@ -14,28 +14,28 @@ export interface IAPIKey { } export class APIKey { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IAPIKey; constructor(saasClient: QlikSaaSClient, id: string, details?: IAPIKey) { if (!id) throw new Error(`apiKeys.get: "id" parameter is required`); this.details = details ?? ({} as IAPIKey); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: true }) { if (Object.keys(this.details).length == 0 || arg?.force == true) { - this.details = await this.saasClient - .Get(`api-keys/${this.id}`) + this.details = await this.#saasClient + .Get(`api-keys/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`api-keys/${this.id}`) + return await this.#saasClient + .Delete(`api-keys/${this.#id}`) .then((res) => res.status); } @@ -50,8 +50,8 @@ export class APIKey { }]; let updateStatus = 0; - return await this.saasClient - .Patch(`api-keys/${this.id}`, data) + return await this.#saasClient + .Patch(`api-keys/${this.#id}`, data) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/APIKeys.ts b/src/modules/APIKeys.ts index 67d96d0..ddadda7 100644 --- a/src/modules/APIKeys.ts +++ b/src/modules/APIKeys.ts @@ -25,24 +25,24 @@ export interface IAPIKeysConfigsUpdate { } export class APIKeys { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`apiKeys.get: "id" parameter is required`); - const apiKey: APIKey = new APIKey(this.saasClient, arg.id); + const apiKey: APIKey = new APIKey(this.#saasClient, arg.id); await apiKey.init(); return apiKey; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`api-keys?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new APIKey(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new APIKey(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -76,16 +76,16 @@ export class APIKeys { if (!arg.description) throw new Error(`apiKeys.create: "description" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`api-keys`, arg) - .then((res) => new APIKey(this.saasClient, res.data.id, res.data)); + .then((res) => new APIKey(this.#saasClient, res.data.id, res.data)); } async configs(arg: { tenantId: string }) { if (!arg.tenantId) throw new Error(`apiKeys.configs: "tenantId" parameter is required`); - return await this.saasClient + return await this.#saasClient .Get(`api-keys/configs/${arg.tenantId}`) .then((res) => res.data); } @@ -106,7 +106,7 @@ export class APIKeys { value: a.value, })); - return await this.saasClient + return await this.#saasClient .Patch(`api-keys/configs/${arg.tenantId}`, data) .then((res) => res.status); } diff --git a/src/modules/App.ts b/src/modules/App.ts index 1448d3d..14ad7f6 100644 --- a/src/modules/App.ts +++ b/src/modules/App.ts @@ -20,8 +20,8 @@ import { AppScript } from "./AppScript"; import { IItem } from "./Item"; export class App { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; private swapResourceIdAndId = false; evaluations: AppEvaluations; /** @@ -39,10 +39,10 @@ export class App { this.swapResourceIdAndId = true; this.details = details ?? ({} as IItem); - this.id = id; - this.saasClient = saasClient; - this.evaluations = new AppEvaluations(this.saasClient, this.id); - this._actions = new AppActions(this.saasClient, this.id); + this.#id = id; + this.#saasClient = saasClient; + this.evaluations = new AppEvaluations(this.#saasClient, this.#id); + this._actions = new AppActions(this.#saasClient, this.#id); // if we have to swap id and resourceId properties if ( @@ -61,11 +61,11 @@ export class App { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`items?resourceType=app&resourceId=${this.id}`) + this.details = await this.#saasClient + .Get(`items?resourceType=app&resourceId=${this.#id}`) .then((res) => { if (res.data.length == 0) - throw new Error(`apps.get: app with id ${this.id} was not found`); + throw new Error(`apps.get: app with id ${this.#id} was not found`); // if we have to swap id and resourceId properties if (this.swapResourceIdAndId == true) @@ -82,32 +82,32 @@ export class App { async copy(arg: IAppCopy) { if (!arg.name) throw new Error(`app.copy: "name" parameter is required`); - return await this.saasClient - .Post(`apps/${this.id}/copy`, arg) - .then((res) => new App(this.saasClient, res.data.resourceId, res.data)); + return await this.#saasClient + .Post(`apps/${this.#id}/copy`, arg) + .then((res) => new App(this.#saasClient, res.data.resourceId, res.data)); } async dataLineage() { - return await this.saasClient - .Get(`apps/${this.id}/data/lineage`) + return await this.#saasClient + .Get(`apps/${this.#id}/data/lineage`) .then((res) => res.data); } async metaData() { - return await this.saasClient - .Get(`apps/${this.id}/data/metadata`) + return await this.#saasClient + .Get(`apps/${this.#id}/data/metadata`) .then((res) => res.data); } async export(arg?: { noData: boolean }) { - const urlBuild = new URLBuild(`apps/${this.id}/export`); + const urlBuild = new URLBuild(`apps/${this.#id}/export`); urlBuild.addParam("NoData", arg?.noData); - const tempContentLocation = await this.saasClient.Post<{ + const tempContentLocation = await this.#saasClient.Post<{ location: string; }>(urlBuild.getUrl(), {}, "application/json", "json", false, true); - const appContent: Buffer = await this.saasClient + const appContent: Buffer = await this.#saasClient .Get( tempContentLocation.data.location.replace("/api/v1/", ""), "", @@ -143,16 +143,16 @@ export class App { `apps.publish: If app is moved, originAppId needs to be provided.` ); - return await this.saasClient - .Post(`apps/${this.id}/publish`, data) + return await this.#saasClient + .Post(`apps/${this.#id}/publish`, data) .then((res) => - this.saasClient.Get( + this.#saasClient.Get( `items?resourceType=app&resourceId=${res.data.attributes.id}` ) ) .then( (items) => - new App(this.saasClient, items.data[0].resourceId, items.data[0]) + new App(this.#saasClient, items.data[0].resourceId, items.data[0]) ); } @@ -175,16 +175,16 @@ export class App { if (arg.description) data.attributes["description"] = arg.description; if (arg.checkOriginAppId) data["checkOriginAppId"] = arg.checkOriginAppId; - return await this.saasClient - .Put(`apps/${this.id}/publish`, data) + return await this.#saasClient + .Put(`apps/${this.#id}/publish`, data) .then((res) => - this.saasClient.Get( + this.#saasClient.Get( `items?resourceType=app&resourceId=${res.data.attributes.id}` ) ) .then( (items) => - new App(this.saasClient, items.data[0].resourceId, items.data[0]) + new App(this.#saasClient, items.data[0].resourceId, items.data[0]) ); } @@ -193,10 +193,10 @@ export class App { if (!arg.spaceId) throw new Error(`app.addToSpace: "spaceId" parameter is required`); - return await this.saasClient - .Put(`apps/${this.id}/space`, { spaceId: arg.spaceId }) + return await this.#saasClient + .Put(`apps/${this.#id}/space`, { spaceId: arg.spaceId }) .then((res) => - this.saasClient.Get( + this.#saasClient.Get( `items?resourceType=app&resourceId=${res.data.attributes.id}` ) ) @@ -208,11 +208,11 @@ export class App { // REVIEW: the name? async removeFromSpace() { - return await this.saasClient - .Delete(`apps/${this.id}/space`) + return await this.#saasClient + .Delete(`apps/${this.#id}/space`) .then((res) => - this.saasClient.Get( - `items?resourceType=app&resourceId=${this.id}` + this.#saasClient.Get( + `items?resourceType=app&resourceId=${this.#id}` ) ) .then((res) => { @@ -222,8 +222,8 @@ export class App { } async remove() { - return await this.saasClient - .Delete(`apps/${this.id}`) + return await this.#saasClient + .Delete(`apps/${this.#id}`) .then((res) => res.status); } @@ -232,8 +232,8 @@ export class App { let updateStatus = 0; - return this.saasClient - .Put<{ attributes: IAppAttributes }>(`apps/${this.id}`, { + return this.#saasClient + .Put<{ attributes: IAppAttributes }>(`apps/${this.#id}`, { attributes: arg, }) .then((res) => { @@ -244,8 +244,8 @@ export class App { } async thumbnail() { - return this.saasClient - .Get(`apps/${this.id}/media/thumbnail`) + return this.#saasClient + .Get(`apps/${this.#id}/media/thumbnail`) .then((res) => res.data) .catch((e) => { if (e.message.indexOf("404") > -1) @@ -256,10 +256,10 @@ export class App { } async mediaFiles() { - return this.saasClient - .Get(`apps/${this.id}/media/list`) + return this.#saasClient + .Get(`apps/${this.#id}/media/list`) .then((res) => { - return res.data.map((m) => new Media(this.saasClient, m.id, m)); + return res.data.map((m) => new Media(this.#saasClient, m.id, m)); }); } @@ -269,13 +269,13 @@ export class App { if (!arg.fileName) throw new Error(`app.addMedia: "fileName" parameter is required`); - return await this.saasClient + return await this.#saasClient .Put( - `apps/${this.id}/media/files/${arg.fileName}`, + `apps/${this.#id}/media/files/${arg.fileName}`, arg.content, "application/octet-stream" ) - .then((res) => new Media(this.saasClient, res.data.id, res.data)); + .then((res) => new Media(this.#saasClient, res.data.id, res.data)); } /** @@ -287,13 +287,13 @@ export class App { // * Rate limit: Tier 1 (600 requests per minute) // */ async scriptVersions() { - return await this.saasClient - .Get<{ scripts: IScriptMeta[] }>(`apps/${this.id}/scripts`) + return await this.#saasClient + .Get<{ scripts: IScriptMeta[] }>(`apps/${this.#id}/scripts`) .then((res) => res.data) .then((data) => { return data.scripts.map( (t) => - new AppScript(this.saasClient, t.scriptId, this.id, { + new AppScript(this.#saasClient, t.scriptId, this.#id, { ...t, script: "", }) @@ -311,9 +311,9 @@ export class App { throw new Error(`app.scriptVersions: "versionId" parameter is required`); const scriptVersion = new AppScript( - this.saasClient, + this.#saasClient, arg.versionId, - this.id + this.#id ); await scriptVersion.init() await scriptVersion.getScriptContent(); @@ -327,8 +327,8 @@ export class App { * Rate limit: Tier 2 (60 requests per minute) */ async setScript(arg: IScriptVersion) { - return await this.saasClient - .Post(`apps/${this.id}/scripts`, arg) + return await this.#saasClient + .Post(`apps/${this.#id}/scripts`, arg) .then((res) => res.status); } @@ -336,8 +336,8 @@ export class App { // * List of reload logs (actual log is not included) // */ async reloadLogs() { - return this.saasClient - .Get(`apps/${this.id}/reloads/logs`) + return this.#saasClient + .Get(`apps/${this.#id}/reloads/logs`) .then((res) => res.data); } @@ -348,8 +348,8 @@ export class App { if (!arg.reloadId) throw new Error(`app.reloadLogContent: "reloadId" parameter is required`); - return this.saasClient - .Get(`apps/${this.id}/reloads/logs/${arg.reloadId}`) + return this.#saasClient + .Get(`apps/${this.#id}/reloads/logs/${arg.reloadId}`) .then((res) => res.data); } } diff --git a/src/modules/AppActions.ts b/src/modules/AppActions.ts index 0264cd6..46b4fbd 100644 --- a/src/modules/AppActions.ts +++ b/src/modules/AppActions.ts @@ -5,15 +5,15 @@ import { ReloadTasks } from "./ReloadTasks"; import { AppObject } from "./Apps.interfaces"; export class AppActions { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; private reloadTasks: ReloadTasks; private appReload: Reloads; constructor(saasClient: QlikSaaSClient, id: string) { - this.id = id; - this.saasClient = saasClient; - this.reloadTasks = new ReloadTasks(this.saasClient); - this.appReload = new Reloads(this.saasClient); + this.#id = id; + this.#saasClient = saasClient; + this.reloadTasks = new ReloadTasks(this.#saasClient); + this.appReload = new Reloads(this.#saasClient); } /** @@ -21,7 +21,7 @@ export class AppActions { */ async createReloadTask(arg: Omit) { await this.reloadTasks.create({ - appId: this.id, + appId: this.#id, ...arg, }); return true; @@ -33,7 +33,7 @@ export class AppActions { async getReloadTasks() { return await this.reloadTasks .getAll() - .then((allTasks) => allTasks.filter((r) => r.details.appId == this.id)); + .then((allTasks) => allTasks.filter((r) => r.details.appId == this.#id)); } /** @@ -46,7 +46,7 @@ export class AppActions { ); return await this.appReload.start({ - appId: this.id, + appId: this.#id, partial: arg?.partial || false, }); } @@ -60,8 +60,8 @@ export class AppActions { if (!arg.ownerId) throw new Error(`app.changeObjectOwner: "ownerId" parameter is required`); - return this.saasClient.Post( - `apps/${this.id}/objects/${arg.objectId}/actions/change-owner`, + return this.#saasClient.Post( + `apps/${this.#id}/objects/${arg.objectId}/actions/change-owner`, { ownerId: arg.ownerId } ); } diff --git a/src/modules/AppEvaluation.ts b/src/modules/AppEvaluation.ts index 2afdae3..88700ae 100644 --- a/src/modules/AppEvaluation.ts +++ b/src/modules/AppEvaluation.ts @@ -215,8 +215,8 @@ export interface IAppEvaluation { } export class AppEvaluation { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IAppEvaluation; constructor( saasClient: QlikSaaSClient, @@ -225,8 +225,8 @@ export class AppEvaluation { ) { if (!id) throw new Error(`evaluations.get: "id" parameter is required`); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; this.details = details ?? ({} as IAppEvaluation); if (details && details.ID && !details.id) this.details.id = this.details.ID ?? ""; @@ -234,8 +234,8 @@ export class AppEvaluation { async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`/app/evaluations/${this.id}`) + this.details = await this.#saasClient + .Get(`/app/evaluations/${this.#id}`) .then((res) => res.data); } } @@ -244,8 +244,8 @@ export class AppEvaluation { * Download a detailed XML log of a specific evaluation */ async download() { - return await this.saasClient - .Get(`apps/evaluations/${this.id}/actions/download`) + return await this.#saasClient + .Get(`apps/evaluations/${this.#id}/actions/download`) .then((res) => res.data); } @@ -261,14 +261,14 @@ export class AppEvaluation { ); const [result, log] = await Promise.all([ - this.saasClient + this.#saasClient .Get( - `apps/evaluations/${this.id}/actions/compare/${arg.comparisonId}?all=true&format=json` + `apps/evaluations/${this.#id}/actions/compare/${arg.comparisonId}?all=true&format=json` ) .then((res) => res.data), - this.saasClient + this.#saasClient .Get( - `apps/evaluations/${this.id}/actions/compare/${arg.comparisonId}/actions/download` + `apps/evaluations/${this.#id}/actions/compare/${arg.comparisonId}/actions/download` ) .then((res) => res.data), ]); diff --git a/src/modules/AppEvaluations.ts b/src/modules/AppEvaluations.ts index 68ff92d..2fee088 100644 --- a/src/modules/AppEvaluations.ts +++ b/src/modules/AppEvaluations.ts @@ -3,19 +3,19 @@ import { AppEvaluation, IAppEvaluation } from "./AppEvaluation"; import { parseFilter } from "../util/filter"; export class AppEvaluations { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; private appId: string; constructor(saasClient: QlikSaaSClient, appId: string) { - this.saasClient = saasClient; + this.#saasClient = saasClient; this.appId = appId; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`/apps/${this.appId}/evaluations?all=true&limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new AppEvaluation(this.saasClient, t.id ?? t.ID, t)) + data.map((t) => new AppEvaluation(this.#saasClient, t.id ?? t.ID, t)) ); } @@ -34,12 +34,12 @@ export class AppEvaluations { } async create() { - return await this.saasClient + return await this.#saasClient .Post(`/apps/${this.appId}/evaluations`, {}) .then( (res) => new AppEvaluation( - this.saasClient, + this.#saasClient, res.data.id ?? res.data.ID, res.data ) diff --git a/src/modules/AppMedia.ts b/src/modules/AppMedia.ts index 33930f2..cfbad95 100644 --- a/src/modules/AppMedia.ts +++ b/src/modules/AppMedia.ts @@ -8,27 +8,27 @@ export interface IAppMedia { } export class Media { - private id: string; + #id: string; private shortLink: string; - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: IAppMedia; constructor(saasClient: QlikSaaSClient, id: string, details?: IAppMedia) { if (!id) throw new Error(`app.get: "id" parameter is required`); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; this.details = details ?? ({} as IAppMedia); this.shortLink = this.details.link.replace("/api/v1/", "") ?? ""; } async content() { - return await this.saasClient + return await this.#saasClient .Get(this.shortLink, "", "arraybuffer") .then((res) => res.data); } async remove() { - return await this.saasClient + return await this.#saasClient .Delete(this.shortLink) .then((res) => res.status); } @@ -36,7 +36,7 @@ export class Media { async update(arg: { content: Buffer }) { if (!arg.content) throw new Error(`appMedia.update: "content" parameter is required`); - return await this.saasClient + return await this.#saasClient .Put(this.shortLink, arg.content, "application/octet-stream") .then((res) => res.status); } diff --git a/src/modules/AppScript.ts b/src/modules/AppScript.ts index b67915b..1b93f95 100644 --- a/src/modules/AppScript.ts +++ b/src/modules/AppScript.ts @@ -2,9 +2,9 @@ import { QlikSaaSClient } from "qlik-rest-api"; import { IScriptMeta, IScriptMetaWithScript } from "./Apps.interfaces"; export class AppScript { - private id: string; + #id: string; private appId: string; - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: IScriptMetaWithScript; constructor( saasClient: QlikSaaSClient, @@ -15,32 +15,32 @@ export class AppScript { if (!versionId) throw new Error(`"versionId" parameter is required`); this.details = details ?? ({} as IScriptMetaWithScript); - this.id = versionId; + this.#id = versionId; this.appId = appId; - this.saasClient = saasClient; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { if (!this.details || arg?.force == true) { - this.details = await this.saasClient + this.details = await this.#saasClient .Get( - `apps/${this.appId}/scripts?filter=ScriptId eq "${this.id}"` + `apps/${this.appId}/scripts?filter=ScriptId eq "${this.#id}"` ) .then((res) => ({ ...res.data, script: "" })); } } async getScriptContent() { - this.details.script = await this.saasClient - .Get(`apps/${this.appId}/scripts/${this.id}`) + this.details.script = await this.#saasClient + .Get(`apps/${this.appId}/scripts/${this.#id}`) .then((res) => res.data); return this.details.script; } async remove() { - return await this.saasClient - .Delete(`apps/${this.appId}/scripts/${this.id}`) + return await this.#saasClient + .Delete(`apps/${this.appId}/scripts/${this.#id}`) .then((res) => res.status); } @@ -51,8 +51,8 @@ export class AppScript { * And because of this, this method only updates the name as well */ async update(arg: { name: string }) { - const updateStatus = await this.saasClient - .Patch(`apps/${this.appId}/scripts/${this.id}`, [ + const updateStatus = await this.#saasClient + .Patch(`apps/${this.appId}/scripts/${this.#id}`, [ { op: "replace", path: "/versionMessage", diff --git a/src/modules/Apps.ts b/src/modules/Apps.ts index beae2a3..49d3360 100644 --- a/src/modules/Apps.ts +++ b/src/modules/Apps.ts @@ -7,36 +7,36 @@ import { parseFilter } from "../util/filter"; import { IItem } from "./Item"; export class Apps { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`apps.get: "id" parameter is required`); - const app: App = new App(this.saasClient, arg.id); + const app: App = new App(this.#saasClient, arg.id); await app.init(); return app; } async getEvaluation(arg: { id: string }) { - return await this.saasClient + return await this.#saasClient .Get(`apps/evaluations/${arg.id}`) .then((res) => res.data) .then( (data) => - new AppEvaluation(this.saasClient, (data.id || data.ID) ?? "", data) + new AppEvaluation(this.#saasClient, (data.id || data.ID) ?? "", data) ); } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`items?resourceType=app&limit=50`) .then((res) => res.data) .then((data) => { - return data.map((t) => new App(this.saasClient, t.resourceId, t)); + return data.map((t) => new App(this.#saasClient, t.resourceId, t)); }); } @@ -58,11 +58,11 @@ export class Apps { if (!arg.filter) throw new Error(`apps.getFilter: "filter" parameter is required`); - return await this.saasClient + return await this.#saasClient .Get(`items?resourceType=app,qvapp,qlikview&query=${arg.filter}`) .then((res) => res.data) .then((data) => { - return data.map((t) => new App(this.saasClient, t.id, t)); + return data.map((t) => new App(this.#saasClient, t.id, t)); }); } @@ -104,35 +104,35 @@ export class Apps { urlBuild.addParam("mode", arg.appId); urlBuild.addParam("fallbackName", arg.fallbackName); - return await this.saasClient + return await this.#saasClient .Post(urlBuild.getUrl(), arg.file, "application/octet-stream") .then((res) => - this.saasClient.Get( + this.#saasClient.Get( `/items?resourceType=app&resourceId=${res.data.attributes.id}` ) ) .then( - (res) => new App(this.saasClient, res.data[0].resourceId, res.data[0]) + (res) => new App(this.#saasClient, res.data[0].resourceId, res.data[0]) ); } async create(arg: IAppCreate) { if (!arg.name) throw new Error(`apps.create: "name" parameter is required`); - return this.saasClient + return this.#saasClient .Post("apps", { attributes: arg }) .then((res) => - this.saasClient.Get( + this.#saasClient.Get( `/items?resourceType=app&resourceId=${res.data.attributes.id}` ) ) .then( - (res) => new App(this.saasClient, res.data[0].resourceId, res.data[0]) + (res) => new App(this.#saasClient, res.data[0].resourceId, res.data[0]) ); } async privileges() { - return await this.saasClient + return await this.#saasClient .Get<{ [key: string]: string }>(`apps/privileges`) .then((p) => p.data); } diff --git a/src/modules/Assignment.ts b/src/modules/Assignment.ts index 743c2f0..0ecfa92 100644 --- a/src/modules/Assignment.ts +++ b/src/modules/Assignment.ts @@ -21,9 +21,9 @@ export interface IAssignment { } export class Assignment { - private id: string; + #id: string; private spaceId: string; - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: IAssignment; constructor( saasClient: QlikSaaSClient, @@ -35,20 +35,20 @@ export class Assignment { if (!spaceId) throw new Error(`assignment.get: "id" parameter is required`); this.details = details ?? ({} as IAssignment); - this.id = id; + this.#id = id; this.spaceId = spaceId; - this.saasClient = saasClient; + this.#saasClient = saasClient; } async remove() { - return await this.saasClient - .Delete(`spaces/${this.spaceId}/assignments/${this.id}`) + return await this.#saasClient + .Delete(`spaces/${this.spaceId}/assignments/${this.#id}`) .then((res) => res.status); } async update(arg: { roles: string[] }) { - return await this.saasClient - .Put(`spaces/${this.spaceId}/assignments/${this.id}`, { + return await this.#saasClient + .Put(`spaces/${this.spaceId}/assignments/${this.#id}`, { roles: arg.roles, }) .then((res) => { diff --git a/src/modules/Audits.ts b/src/modules/Audits.ts index 67dd99d..14c61d2 100644 --- a/src/modules/Audits.ts +++ b/src/modules/Audits.ts @@ -69,14 +69,14 @@ export interface IAuditsSettings { } export class Audits { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`audits.get: "id" parameter is required`); - return await this.saasClient + return await this.#saasClient .Get(`audits/${arg.id}`) .then((res) => res.data); } @@ -89,25 +89,25 @@ export class Audits { urlBuild.addParam("eventTime", arg.eventTime); urlBuild.addParam("userId", arg.userId); - return await this.saasClient + return await this.#saasClient .Get(urlBuild.getUrl()) .then((res) => res.data); } async settings() { - return await this.saasClient + return await this.#saasClient .Get(`audits/settings`) .then((res) => res.data); } async sources() { - return await this.saasClient + return await this.#saasClient .Get(`audits/sources`) .then((res) => res.data); } async types() { - return await this.saasClient + return await this.#saasClient .Get(`audits/types`) .then((res) => res.data); } @@ -117,7 +117,7 @@ export class Audits { if (!arg.date) throw new Error(`audits.archive: "date" parameter is required`); - return await this.saasClient + return await this.#saasClient .Get(`audits/archive?date=${arg.date}`) .then((res) => res.data); } diff --git a/src/modules/Automation.ts b/src/modules/Automation.ts index 7480beb..8e38e2b 100644 --- a/src/modules/Automation.ts +++ b/src/modules/Automation.ts @@ -3,15 +3,15 @@ import { IAutomation } from "./Automation.interfaces"; import { IRun, Run } from "./Run"; export class Automation { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IAutomation; constructor(saasClient: QlikSaaSClient, id: string, details?: IAutomation) { if (!id) throw new Error(`automation.get: "id" parameter is required`); this.details = details ?? ({} as IAutomation); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -20,15 +20,15 @@ export class Automation { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`automations/${this.id}`) + this.details = await this.#saasClient + .Get(`automations/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`automations/${this.id}`) + return await this.#saasClient + .Delete(`automations/${this.#id}`) .then((res) => res.status); } @@ -36,14 +36,14 @@ export class Automation { if (!arg.name) throw new Error(`automation.copy: "name" parameter is required`); - const copyResponse = await this.saasClient - .Post(`automations/${this.id}/actions/copy`, { + const copyResponse = await this.#saasClient + .Post(`automations/${this.#id}/actions/copy`, { name: arg.name, }) .then((res) => res.data); const newAutomation = new Automation( - this.saasClient, + this.#saasClient, (copyResponse as any).id ); await newAutomation.init(); @@ -54,8 +54,8 @@ export class Automation { async enable() { let updateStatus = 0; - return await this.saasClient - .Post(`automations/${this.id}/actions/enable`, {}) + return await this.#saasClient + .Post(`automations/${this.#id}/actions/enable`, {}) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -66,8 +66,8 @@ export class Automation { async disable() { let updateStatus = 0; - return await this.saasClient - .Post(`automations/${this.id}/actions/disable`, {}) + return await this.#saasClient + .Post(`automations/${this.#id}/actions/disable`, {}) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -78,8 +78,8 @@ export class Automation { async move() { let updateStatus = 0; - return await this.saasClient - .Post(`automations/${this.id}/actions/move`, {}) + return await this.#saasClient + .Post(`automations/${this.#id}/actions/move`, {}) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -88,10 +88,10 @@ export class Automation { } async getRuns() { - return await this.saasClient - .Get(`automations/automations/${this.id}/runs`) + return await this.#saasClient + .Get(`automations/automations/${this.#id}/runs`) .then((res) => { - return res.data.map((t) => new Run(this.saasClient, t.id, this.id, t)); + return res.data.map((t) => new Run(this.#saasClient, t.id, this.#id, t)); }); } @@ -99,8 +99,8 @@ export class Automation { if (!arg.runId) throw new Error(`automation.getRun: "runId" parameter is required`); - return await this.saasClient - .Get(`automations/automations/${this.id}/runs`) + return await this.#saasClient + .Get(`automations/automations/${this.#id}/runs`) .then((res) => { const runData = res.data.filter((r) => r.id == arg.runId); @@ -114,7 +114,7 @@ export class Automation { `automation.getRun: found more than one run with id "${arg.runId}"` ); - return new Run(this.saasClient, runData[0].id, this.id, runData[0]); + return new Run(this.#saasClient, runData[0].id, this.#id, runData[0]); }); } } diff --git a/src/modules/Automations.ts b/src/modules/Automations.ts index 4e8cd4e..402c6aa 100644 --- a/src/modules/Automations.ts +++ b/src/modules/Automations.ts @@ -10,25 +10,25 @@ import { import { parseFilter } from "../util/filter"; export class Automations { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`automations.get: "id" parameter is required`); - const a: Automation = new Automation(this.saasClient, arg.id); + const a: Automation = new Automation(this.#saasClient, arg.id); await a.init(); return a; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`automations?limit=50`) .then((res) => res.data) .then((data) => { - return data.map((t) => new Automation(this.saasClient, t.id, t)); + return data.map((t) => new Automation(this.#saasClient, t.id, t)); }); } @@ -62,9 +62,9 @@ export class Automations { } async create(arg: IAutomationCreate) { - return await this.saasClient + return await this.#saasClient .Post("automations", { ...arg }) - .then((res) => new Automation(this.saasClient, res.data.id, res.data)); + .then((res) => new Automation(this.#saasClient, res.data.id, res.data)); } async usage(arg: { filter: string; breakdown?: string }) { @@ -73,13 +73,13 @@ export class Automations { urlBuild.addParam("filter", arg.filter); urlBuild.addParam("breakdown", arg.breakdown); - return await this.saasClient + return await this.#saasClient .Get(urlBuild.getUrl()) .then((res) => res.data); } async getSettings() { - return await this.saasClient + return await this.#saasClient .Get(`automations/automations/settings`) .then((res) => res.data); } @@ -90,7 +90,7 @@ export class Automations { `automations.setSettings: "automationsEnabled" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Put(`automations/automations/settings`, { automationsEnabled: arg.automationsEnabled, }) diff --git a/src/modules/Brand.ts b/src/modules/Brand.ts index 714422d..681732f 100644 --- a/src/modules/Brand.ts +++ b/src/modules/Brand.ts @@ -33,26 +33,26 @@ export interface IBrandUpdate { } export class Brand { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IBrand; _actions: BrandActions; constructor(saasClient: QlikSaaSClient, id: string, details?: IBrand) { if (!id) throw new Error(`brands.get: "id" parameter is required`); this.details = details ?? ({} as IBrand); - this.id = id; - this.saasClient = saasClient; - this._actions = new BrandActions(this.saasClient, this.id); + this.#id = id; + this.#saasClient = saasClient; + this._actions = new BrandActions(this.#saasClient, this.#id); } async init(arg?: { force: true }) { if (Object.keys(this.details).length == 0 || arg?.force == true) { - this.details = await this.saasClient - .Get(`brands/${this.id}`) + this.details = await this.#saasClient + .Get(`brands/${this.#id}`) .then((res) => { const filesInstances = res.data.files.map( - (f) => new BrandFile(this.saasClient, this.id, f.id, f) + (f) => new BrandFile(this.#saasClient, this.#id, f.id, f) ); return { @@ -74,8 +74,8 @@ export class Brand { * Deletes the current brand */ async remove() { - return await this.saasClient - .Delete(`brands/${this.id}`) + return await this.#saasClient + .Delete(`brands/${this.#id}`) .then((res) => res.status); } @@ -92,8 +92,8 @@ export class Brand { })); let updateStatus = -1; - return await this.saasClient - .Patch(`brands/${this.id}`, data) + return await this.#saasClient + .Patch(`brands/${this.#id}`, data) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -128,8 +128,8 @@ export class Brand { let addFileStatus = 0; - return this.saasClient - .Post(`brands/${this.id}/files/${arg.id}`, fd.getData, fd.getHeaders) + return this.#saasClient + .Post(`brands/${this.#id}/files/${arg.id}`, fd.getData, fd.getHeaders) .then((res) => { addFileStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/BrandActions.ts b/src/modules/BrandActions.ts index 00eddc0..1887b4e 100644 --- a/src/modules/BrandActions.ts +++ b/src/modules/BrandActions.ts @@ -2,11 +2,11 @@ import { QlikSaaSClient } from "qlik-rest-api"; import { IBrand } from "./Brand"; export class BrandActions { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient, id: string) { - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } /** @@ -14,8 +14,8 @@ export class BrandActions { * If the brand is already active, no action is taken. */ async activate() { - return this.saasClient - .Post(`brands/${this.id}/actions/activate`, {}) + return this.#saasClient + .Post(`brands/${this.#id}/actions/activate`, {}) .then((res) => res.status); } @@ -24,8 +24,8 @@ export class BrandActions { * If the brand is already inactive, no action is taken. */ async deactivate() { - return this.saasClient - .Post(`brands/${this.id}/actions/deactivate`, {}) + return this.#saasClient + .Post(`brands/${this.#id}/actions/deactivate`, {}) .then((res) => res.status); } } diff --git a/src/modules/BrandFile.ts b/src/modules/BrandFile.ts index db4cc65..d3d47d5 100644 --- a/src/modules/BrandFile.ts +++ b/src/modules/BrandFile.ts @@ -14,9 +14,9 @@ export const contentTypeMime = { }; export class BrandFile { - private id: string; + #id: string; private brandId: string; - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: IBrandFile; constructor( saasClient: QlikSaaSClient, @@ -24,9 +24,9 @@ export class BrandFile { id: string, details: IBrandFile ) { - this.id = id; + this.#id = id; this.brandId = brandId; - this.saasClient = saasClient; + this.#saasClient = saasClient; this.details = details; } @@ -34,8 +34,8 @@ export class BrandFile { * Download the current brand file */ async download() { - return this.saasClient - .Get(`brands/${this.brandId}/files/${this.id}`) + return this.#saasClient + .Get(`brands/${this.brandId}/files/${this.#id}`) .then((res) => res.data); } @@ -43,8 +43,8 @@ export class BrandFile { * Remove the current brand file from the brand */ async remove() { - return this.saasClient - .Delete(`brands/${this.brandId}/files/${this.id}`) + return this.#saasClient + .Delete(`brands/${this.brandId}/files/${this.#id}`) .then((res) => res.status); } @@ -56,11 +56,11 @@ export class BrandFile { fd.append({ field: "file", data: arg.file, - contentType: contentTypeMime[this.id], + contentType: contentTypeMime[this.#id], }); - return this.saasClient - .Put(`brands/${this.brandId}/files/${this.id}`, fd.getData, fd.getHeaders) + return this.#saasClient + .Put(`brands/${this.brandId}/files/${this.#id}`, fd.getData, fd.getHeaders) .then((res) => res.status); } } diff --git a/src/modules/Brands.ts b/src/modules/Brands.ts index da89695..350a703 100644 --- a/src/modules/Brands.ts +++ b/src/modules/Brands.ts @@ -34,9 +34,9 @@ export interface IBrandCreate { } export class Brands { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } /** @@ -44,7 +44,7 @@ export class Brands { */ async get(arg: { id: string }) { if (!arg.id) throw new Error(`brands.get: "id" parameter is required`); - const brand: Brand = new Brand(this.saasClient, arg.id); + const brand: Brand = new Brand(this.#saasClient, arg.id); await brand.init(); return brand; @@ -54,10 +54,10 @@ export class Brands { * Get all existing brands */ async getAll() { - return await this.saasClient + return await this.#saasClient .Get<{ data: IBrand[] }>(`brands?limit=50`) .then((res) => res.data.data ?? res.data ?? []) - .then((data) => data.map((t) => new Brand(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Brand(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -121,8 +121,8 @@ export class Brands { // contentType: contentTypeMime.styles, }); - return await this.saasClient + return await this.#saasClient .Post(`brands`, fd.getData, fd.getHeaders) - .then((res) => new Brand(this.saasClient, res.data.id, res.data)); + .then((res) => new Brand(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Collection.ts b/src/modules/Collection.ts index 6b2b15c..98bbfe8 100644 --- a/src/modules/Collection.ts +++ b/src/modules/Collection.ts @@ -47,15 +47,15 @@ export interface ICollection { } export class Collection { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: ICollection; constructor(saasClient: QlikSaaSClient, id: string, details?: ICollection) { if (!id) throw new Error(`collection.get: "id" parameter is required`); this.details = details ?? ({} as ICollection); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -64,15 +64,15 @@ export class Collection { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`collections/${this.id}`) + this.details = await this.#saasClient + .Get(`collections/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`collections/${this.id}`) + return await this.#saasClient + .Delete(`collections/${this.#id}`) .then((res) => res.status); } @@ -82,8 +82,8 @@ export class Collection { let updateStatus = 0; - return this.saasClient - .Put(`collections/${this.id}`, arg) + return this.#saasClient + .Put(`collections/${this.#id}`, arg) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -92,11 +92,11 @@ export class Collection { } async items() { - return await this.saasClient - .Get(`collections/${this.id}/items`) + return await this.#saasClient + .Get(`collections/${this.#id}/items`) .then((res) => res.data) .then((data) => - data.map((t) => new CollectionItem(this.saasClient, t.id, this.id, t)) + data.map((t) => new CollectionItem(this.#saasClient, t.id, this.#id, t)) ); } @@ -104,11 +104,11 @@ export class Collection { if (!arg.id) throw new Error(`collection.addItem: "id" parameter is required`); - return await this.saasClient - .Post(`collections/${this.id}/items`, { id: arg.id }) + return await this.#saasClient + .Post(`collections/${this.#id}/items`, { id: arg.id }) .then( (res) => - new CollectionItem(this.saasClient, res.data.id, this.id, res.data) + new CollectionItem(this.#saasClient, res.data.id, this.#id, res.data) ); } } diff --git a/src/modules/CollectionItem.ts b/src/modules/CollectionItem.ts index f6f76d4..c0c1153 100644 --- a/src/modules/CollectionItem.ts +++ b/src/modules/CollectionItem.ts @@ -58,8 +58,8 @@ export interface ICollectionItem { } export class CollectionItem { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: ICollectionItem; collectionId: string; constructor( @@ -71,22 +71,22 @@ export class CollectionItem { if (!id) throw new Error(`collectionItems.get: "id" parameter is required`); this.details = details ?? ({} as ICollectionItem); - this.id = id; + this.#id = id; this.collectionId = collectionId; - this.saasClient = saasClient; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`collections/${this.id}/items/${this.id}`) + this.details = await this.#saasClient + .Get(`collections/${this.#id}/items/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`collections/${this.collectionId}/items/${this.id}`) + return await this.#saasClient + .Delete(`collections/${this.collectionId}/items/${this.#id}`) .then((res) => res.status); } } diff --git a/src/modules/Collections.ts b/src/modules/Collections.ts index f664fe4..41a1c37 100644 --- a/src/modules/Collections.ts +++ b/src/modules/Collections.ts @@ -9,26 +9,26 @@ export interface ICollectionCreate { } export class Collections { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`collections.get: "id" parameter is required`); - const collection: Collection = new Collection(this.saasClient, arg.id); + const collection: Collection = new Collection(this.#saasClient, arg.id); await collection.init(); return collection; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`collections?limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new Collection(this.saasClient, t.id, t)) + data.map((t) => new Collection(this.#saasClient, t.id, t)) ); } @@ -62,9 +62,9 @@ export class Collections { } async favorites() { - return await this.saasClient + return await this.#saasClient .Get(`collections/favorites`) - .then((res) => new Collection(this.saasClient, res.data.id, res.data)); + .then((res) => new Collection(this.#saasClient, res.data.id, res.data)); } async create(arg: ICollectionCreate) { @@ -73,8 +73,8 @@ export class Collections { if (!arg.type) throw new Error(`collections.create: "type" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`collections`, arg) - .then((res) => new Collection(this.saasClient, res.data.id, res.data)); + .then((res) => new Collection(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Condition.ts b/src/modules/Condition.ts index 7216fcc..09bdc1e 100644 --- a/src/modules/Condition.ts +++ b/src/modules/Condition.ts @@ -62,28 +62,28 @@ export interface IConditionComposite extends IConditionBase { export type ICondition = IConditionData | IConditionComposite; export class Condition { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: ICondition; constructor(saasClient: QlikSaaSClient, id: string, details?: ICondition) { if (!id) throw new Error(`conditions.get: "id" parameter is required`); this.details = details ?? ({} as ICondition); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`conditions/${this.id}`) + this.details = await this.#saasClient + .Get(`conditions/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`conditions/${this.id}`) + return await this.#saasClient + .Delete(`conditions/${this.#id}`) .then((res) => res.status); } } diff --git a/src/modules/Conditions.ts b/src/modules/Conditions.ts index 76668f7..3ee25d9 100644 --- a/src/modules/Conditions.ts +++ b/src/modules/Conditions.ts @@ -58,30 +58,30 @@ export interface IConditionCreateComposite extends IConditionCreateBase { export type IConditionCreate = IConditionCreateData | IConditionCreateComposite; export class Conditions { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`conditions.get: "id" parameter is required`); - const condition: Condition = new Condition(this.saasClient, arg.id); + const condition: Condition = new Condition(this.#saasClient, arg.id); await condition.init(); return condition; } // async getAll() { - // return await this.saasClient + // return await this.#saasClient // .Get(`conditions?limit=50`) // .then((res) => res.data) - // .then((data) => data.map((t) => new Condition(this.saasClient, t.id, t))); + // .then((data) => data.map((t) => new Condition(this.#saasClient, t.id, t))); // } async create(arg: IConditionCreate) { - return await this.saasClient + return await this.#saasClient .Post(`conditions`, arg) - .then((res) => new Condition(this.saasClient, "res.data.id", res.data)); + .then((res) => new Condition(this.#saasClient, "res.data.id", res.data)); } } diff --git a/src/modules/DataAlert.ts b/src/modules/DataAlert.ts index c311a51..1fcae53 100644 --- a/src/modules/DataAlert.ts +++ b/src/modules/DataAlert.ts @@ -8,35 +8,35 @@ import { } from "./DataAlerts.interfaces"; export class DataAlert { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IDataAlert; constructor(saasClient: QlikSaaSClient, id: string, details?: IDataAlert) { if (!id) throw new Error(`dataAlert.get: "id" parameter is required`); this.details = details ?? ({} as IDataAlert); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`data-alerts/${this.id}`) + this.details = await this.#saasClient + .Get(`data-alerts/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`data-alerts/${this.id}`) + return await this.#saasClient + .Delete(`data-alerts/${this.#id}`) .then((res) => res.status); } async update(arg: IDataAlertUpdate[]) { - return await this.saasClient + return await this.#saasClient .Patch( - `data-alerts/${this.id}`, + `data-alerts/${this.#id}`, arg.map((a) => ({ op: "replace", path: `/${a.path}`, @@ -47,15 +47,15 @@ export class DataAlert { } async getConditions() { - return await this.saasClient - .Get(`data-alerts/${this.id}/condition`) + return await this.#saasClient + .Get(`data-alerts/${this.#id}/condition`) .then((res) => res.data); } async getRecipientStats() { - return await this.saasClient + return await this.#saasClient .Get( - `data-alerts/${this.id}/recipient-stats` + `data-alerts/${this.#id}/recipient-stats` ) .then((res) => res.data); } @@ -66,9 +66,9 @@ export class DataAlert { `dataAlert.getExecution: "executionId" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Get( - `/data-alerts/${this.id}/executions/${arg.executionId}` + `/data-alerts/${this.#id}/executions/${arg.executionId}` ) .then((res) => res.data); } @@ -79,8 +79,8 @@ export class DataAlert { `dataAlert.removeExecution: "executionId" parameter is required` ); - return await this.saasClient - .Delete(`/data-alerts/${this.id}/executions/${arg.executionId}`) + return await this.#saasClient + .Delete(`/data-alerts/${this.#id}/executions/${arg.executionId}`) .then((res) => res.status); } } diff --git a/src/modules/DataAlerts.interfaces.ts b/src/modules/DataAlerts.interfaces.ts index 0a4ace2..2313ff9 100644 --- a/src/modules/DataAlerts.interfaces.ts +++ b/src/modules/DataAlerts.interfaces.ts @@ -33,7 +33,7 @@ export interface IAlertingTaskRecipientErrors { | "MAX_ALERTS_LIMIT_REACHED"; } -export interface IDataAlertalertingTaskError { +export interface IDataAlertingTaskError { added: string; value: | "OWNER_DISABLED" @@ -146,7 +146,7 @@ export interface IDataAlert { subscriptionIds: string[]; absoluteScan: string; conditionResponse: object; - alertingTaskError: IDataAlertalertingTaskError[]; + alertingTaskError: IDataAlertingTaskError[]; absoluteLastTrigger: string; hasHistoryCondition: boolean; lastExecutionStatus: "OK" | "FAILED"; @@ -163,7 +163,7 @@ export interface IDataAlertCreate { recipients: IDataAlertRecipients; throttling?: IDataAlertThrottlingResource; conditionId: string; - decription?: string; + description?: string; triggerType: "RELOAD" | "SCHEDULED"; scheduleOptions?: IDataAlertScheduleOptions; } @@ -177,7 +177,7 @@ export interface IDataAlertCreateWithNewCondition { recipients: IDataAlertRecipients; throttling?: IDataAlertThrottlingResource; condition: IConditionCreate; - decription?: string; + description?: string; triggerType: "RELOAD" | "SCHEDULED"; scheduleOptions?: IDataAlertScheduleOptions; } diff --git a/src/modules/DataAlerts.ts b/src/modules/DataAlerts.ts index 425d950..485c337 100644 --- a/src/modules/DataAlerts.ts +++ b/src/modules/DataAlerts.ts @@ -59,15 +59,15 @@ export interface IGetTaskExecutionsFilter { } export class DataAlerts { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`dataAlerts.get: "id" parameter is required`); - const da: DataAlert = new DataAlert(this.saasClient, arg.id); + const da: DataAlert = new DataAlert(this.#saasClient, arg.id); await da.init(); return da; @@ -76,11 +76,11 @@ export class DataAlerts { // TODO: why is Qlik returning the meaningful data under "tasks" property??? // https://community.qlik.com/t5/Integration-Extension-APIs/Inconsistencies-in-SaaS-REST-API/m-p/1958356#M17079 async getAll() { - return await this.saasClient + return await this.#saasClient .Get<{ tasks: IDataAlert[] }>(`data-alerts?limit=50`) .then((res) => res.data) .then((data) => { - return data.tasks.map((t) => new DataAlert(this.saasClient, t.id, t)); + return data.tasks.map((t) => new DataAlert(this.#saasClient, t.id, t)); }); } @@ -114,9 +114,9 @@ export class DataAlerts { } async create(arg: IDataAlertCreate) { - return await this.saasClient + return await this.#saasClient .Post("data-alerts", { ...arg }) - .then((res) => new DataAlert(this.saasClient, res.data.id, res.data)); + .then((res) => new DataAlert(this.#saasClient, res.data.id, res.data)); } async triggerAction(arg: { alertingTaskId: string }) { @@ -125,7 +125,7 @@ export class DataAlerts { `dataAlert.triggerAction: "alertingTaskId" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Post("data-alerts/actions/trigger", { alertingTaskID: arg.alertingTaskId, }) @@ -133,7 +133,7 @@ export class DataAlerts { } async getSettings() { - return await this.saasClient + return await this.#saasClient .Get("data-alerts/settings") .then((res) => res.data); } @@ -144,7 +144,7 @@ export class DataAlerts { `dataAlert.updateSettings: "enableDataAlerting" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Put("data-alerts/settings", { "enable-data-alerting": arg.enableDataAlerting, }) @@ -157,7 +157,7 @@ export class DataAlerts { `dataAlert.getTaskIdStats: "taskId" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Get( `data-alerts/${arg.taskId}/stats` ) @@ -196,7 +196,7 @@ export class DataAlerts { urlBuild.addParam("until", arg.filter.until); } - return await this.saasClient + return await this.#saasClient .Get(urlBuild.getUrl()) .then((res) => res.data); } @@ -212,7 +212,7 @@ export class DataAlerts { `dataAlert.getTaskIdExecutionsStats: "period" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Get( `data-alerts/${arg.taskId}/executions?period=${arg.period}` ) @@ -233,7 +233,7 @@ export class DataAlerts { `dataAlert.getTaskIdExecutionIdEvaluation: "executionId" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Get( `data-alerts/${arg.taskId}/executions/${arg.executionId}/evaluations` ) @@ -241,7 +241,7 @@ export class DataAlerts { } async validateActions(arg: IDataAlertCreate) { - return await this.saasClient + return await this.#saasClient .Post(`data-alerts/actions/validate`, { ...arg, }) diff --git a/src/modules/DataConnection.ts b/src/modules/DataConnection.ts index 5ed1c72..e133cf2 100644 --- a/src/modules/DataConnection.ts +++ b/src/modules/DataConnection.ts @@ -51,8 +51,8 @@ export interface IDataConnectionsUpdate { //TODO: whats the difference between the PUT and the PATCH methods export class DataConnection { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IDataConnection; constructor( saasClient: QlikSaaSClient, @@ -62,8 +62,8 @@ export class DataConnection { if (!id) throw new Error(`dataConnection.get: "id" parameter is required`); this.details = details ?? ({} as IDataConnection); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -72,15 +72,15 @@ export class DataConnection { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`data-connections/${this.id}`) + this.details = await this.#saasClient + .Get(`data-connections/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`data-connections/${this.id}`) + return await this.#saasClient + .Delete(`data-connections/${this.#id}`) .then((res) => res.status); } @@ -105,8 +105,8 @@ export class DataConnection { let updateStatus = 0; - return await this.saasClient - .Put(`data-connections/${this.id}`, this.details) + return await this.#saasClient + .Put(`data-connections/${this.#id}`, this.details) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/DataConnections.ts b/src/modules/DataConnections.ts index c9f6358..6938e07 100644 --- a/src/modules/DataConnections.ts +++ b/src/modules/DataConnections.ts @@ -22,16 +22,16 @@ export interface IDataConnectionsCreate { } export class DataConnections { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`dataConnections.get: "id" parameter is required`); const dataConnection: DataConnection = new DataConnection( - this.saasClient, + this.#saasClient, arg.id ); await dataConnection.init(); @@ -40,11 +40,11 @@ export class DataConnections { } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`data-connections?limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new DataConnection(this.saasClient, t.id, t)) + data.map((t) => new DataConnection(this.#saasClient, t.id, t)) ); } @@ -89,10 +89,10 @@ export class DataConnections { if (!arg.qType) throw new Error(`dataConnections.create: "qType" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`data-connections`, arg) .then( - (res) => new DataConnection(this.saasClient, res.data.id, res.data) + (res) => new DataConnection(this.#saasClient, res.data.id, res.data) ); } } diff --git a/src/modules/DataCredential.ts b/src/modules/DataCredential.ts index 2d78b1d..2320f48 100644 --- a/src/modules/DataCredential.ts +++ b/src/modules/DataCredential.ts @@ -25,8 +25,8 @@ export interface IDataCredentialUpdate { //TODO: whats the difference between the PUT and the PATCH methods export class DataCredential { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IDataCredential; constructor( saasClient: QlikSaaSClient, @@ -36,8 +36,8 @@ export class DataCredential { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as IDataCredential); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: true }) { @@ -46,15 +46,15 @@ export class DataCredential { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`data-credentials/${this.id}`) + this.details = await this.#saasClient + .Get(`data-credentials/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`data-credentials/${this.id}`) + return await this.#saasClient + .Delete(`data-credentials/${this.#id}`) .then((res) => res.status); } @@ -69,8 +69,8 @@ export class DataCredential { let updateStatus = 0; - return await this.saasClient - .Put(`data-credentials/${this.id}`, arg) + return await this.#saasClient + .Put(`data-credentials/${this.#id}`, arg) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/DataCredentials.ts b/src/modules/DataCredentials.ts index 8e651c3..04513fa 100644 --- a/src/modules/DataCredentials.ts +++ b/src/modules/DataCredentials.ts @@ -3,16 +3,16 @@ import { DataCredential, IDataCredential } from "./DataCredential"; import { parseFilter } from "../util/filter"; export class DataCredentials { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`dataCredentials.get: "id" parameter is required`); const dataCredential: DataCredential = new DataCredential( - this.saasClient, + this.#saasClient, arg.id ); await dataCredential.init(); @@ -21,11 +21,11 @@ export class DataCredentials { } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`data-credentials?limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new DataCredential(this.saasClient, t.qID, t)) + data.map((t) => new DataCredential(this.#saasClient, t.qID, t)) ); } diff --git a/src/modules/Evaluation.ts b/src/modules/Evaluation.ts index 6a6d435..f6ec8b0 100644 --- a/src/modules/Evaluation.ts +++ b/src/modules/Evaluation.ts @@ -137,28 +137,28 @@ export interface IEvaluation { } export class Evaluation { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IEvaluation; constructor(saasClient: QlikSaaSClient, id: string, details?: IEvaluation) { if (!id) throw new Error(`evaluations.get: "id" parameter is required`); this.details = details ?? ({} as IEvaluation); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`evaluations/${this.id}`) + this.details = await this.#saasClient + .Get(`evaluations/${this.#id}`) .then((res) => res.data); } } async download() { - return await this.saasClient - .Get(`evaluations/${this.id}/download`) + return await this.#saasClient + .Get(`evaluations/${this.#id}/download`) .then((res) => res.data); } } diff --git a/src/modules/Evaluations.ts b/src/modules/Evaluations.ts index 854d654..5c39fcf 100644 --- a/src/modules/Evaluations.ts +++ b/src/modules/Evaluations.ts @@ -8,14 +8,14 @@ export interface IEvaluationGetAll { } export class Evaluations { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`evaluations.get: "id" parameter is required`); - const evaluation: Evaluation = new Evaluation(this.saasClient, arg.id); + const evaluation: Evaluation = new Evaluation(this.#saasClient, arg.id); await evaluation.init(); return evaluation; @@ -27,11 +27,11 @@ export class Evaluations { `evaluations.getAll: "appid" or/and "itemid" parameters are required` ); - return await this.saasClient + return await this.#saasClient .Get(`evaluations`) .then((res) => res.data) .then((data) => - data.map((t) => new Evaluation(this.saasClient, t.id, t)) + data.map((t) => new Evaluation(this.#saasClient, t.id, t)) ); } @@ -41,11 +41,11 @@ export class Evaluations { if (!arg.itemid) throw new Error(`evaluations.getAll: "itemid" parameters is required`); - return await this.saasClient + return await this.#saasClient .Post(`evaluations`, { appid: arg.appid, itemid: arg.itemid, }) - .then((res) => new Evaluation(this.saasClient, res.data.id, res.data)); + .then((res) => new Evaluation(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Extension.ts b/src/modules/Extension.ts index 8b12301..f58ff3d 100644 --- a/src/modules/Extension.ts +++ b/src/modules/Extension.ts @@ -36,15 +36,15 @@ export interface IExtension { } export class Extension { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IExtension; constructor(saasClient: QlikSaaSClient, id: string, details?: IExtension) { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as IExtension); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -53,28 +53,28 @@ export class Extension { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`extensions/${this.id}`) + this.details = await this.#saasClient + .Get(`extensions/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`extensions/${this.id}`) + return await this.#saasClient + .Delete(`extensions/${this.#id}`) .then((res) => res.status); } async file(arg: { fileName: string }) { - return await this.saasClient - .Get(`extensions/${this.id}/file/${arg.fileName}`) + return await this.#saasClient + .Get(`extensions/${this.#id}/file/${arg.fileName}`) .then((res) => res.data); } async download() { - return await this.saasClient + return await this.#saasClient .Get( - `extensions/${this.id}/file`, + `extensions/${this.#id}/file`, "application/x-zip-compressed", "arraybuffer" ) @@ -133,8 +133,8 @@ export class Extension { }); let updateStatus = 0; - return await this.saasClient - .Patch(`extensions/${this.id}`, fd.getData, fd.getHeaders) + return await this.#saasClient + .Patch(`extensions/${this.#id}`, fd.getData, fd.getHeaders) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/Extensions.ts b/src/modules/Extensions.ts index a5ec748..2e3dcf0 100644 --- a/src/modules/Extensions.ts +++ b/src/modules/Extensions.ts @@ -111,24 +111,24 @@ export interface IExtensionImportData { //TODO: import extension method export class Extensions { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`extensions.get: "id" parameter is required`); - const extension: Extension = new Extension(this.saasClient, arg.id); + const extension: Extension = new Extension(this.#saasClient, arg.id); await extension.init(); return extension; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`extensions?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new Extension(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Extension(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -178,8 +178,8 @@ export class Extensions { data: JSON.stringify(arg.data), }); - return await this.saasClient + return await this.#saasClient .Post("extensions", fd.getData, fd.getHeaders) - .then((res) => new Extension(this.saasClient, res.data.id, res.data)); + .then((res) => new Extension(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Group.ts b/src/modules/Group.ts index e8372ab..9d1927f 100644 --- a/src/modules/Group.ts +++ b/src/modules/Group.ts @@ -27,28 +27,28 @@ export type IGroupUpdate = | { name: string }; export class Group { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IGroup; constructor(saasClient: QlikSaaSClient, id: string, details?: IGroup) { if (!id) throw new Error(`group.get: "id" parameter is required`); this.details = details ?? ({} as IGroup); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: true }) { if (Object.keys(this.details).length == 0 || arg?.force == true) { - this.details = await this.saasClient - .Get(`groups/${this.id}`) + this.details = await this.#saasClient + .Get(`groups/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`groups/${this.id}`) + return await this.#saasClient + .Delete(`groups/${this.#id}`) .then((res) => res.status); } @@ -63,8 +63,8 @@ export class Group { let updateStatus: number = -1; - return await this.saasClient - .Patch(`groups/${this.id}`, data) + return await this.#saasClient + .Patch(`groups/${this.#id}`, data) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/Groups.ts b/src/modules/Groups.ts index c9f3282..580fab5 100644 --- a/src/modules/Groups.ts +++ b/src/modules/Groups.ts @@ -31,15 +31,15 @@ export interface IGroupCreate { } export class Groups { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`groups.get: "id" parameter is required`); - const group: Group = new Group(this.saasClient, arg.id); + const group: Group = new Group(this.#saasClient, arg.id); await group.init(); return group; @@ -52,7 +52,7 @@ export class Groups { if (!arg.filter) throw new Error(`groups.getFilter: "filter" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(urlBuild.getUrl(), { filter: arg.filter }) .then((res) => res.data); } @@ -85,14 +85,14 @@ export class Groups { } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`groups?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new Group(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Group(this.#saasClient, t.id, t))); } async getSettings() { - return await this.saasClient + return await this.#saasClient .Get(`groups/settings`) .then((res) => res.data); } @@ -107,7 +107,7 @@ export class Groups { `groups.updateSettings: at least one update setting is required` ); - return await this.saasClient + return await this.#saasClient .Patch( `groups/settings`, arg.map((a) => ({ @@ -125,8 +125,8 @@ export class Groups { if (!arg.assignedRoles) throw new Error(`group.create: "assignedRoles" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`groups`, arg) - .then((res) => new Group(this.saasClient, res.data.id, res.data)); + .then((res) => new Group(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/IdentityProvider.ts b/src/modules/IdentityProvider.ts index b28e050..e2ba3d9 100644 --- a/src/modules/IdentityProvider.ts +++ b/src/modules/IdentityProvider.ts @@ -4,8 +4,8 @@ export interface IIdentityProvider { id: string; } export class IdentityProvider { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IIdentityProvider; constructor( saasClient: QlikSaaSClient, @@ -15,21 +15,21 @@ export class IdentityProvider { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as IIdentityProvider); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`identity-providers/${this.id}`) + this.details = await this.#saasClient + .Get(`identity-providers/${this.#id}`) .then((res) => res.data); } } // async remove() { - // return await this.saasClient - // .Delete(`identity-providers/${this.id}`) + // return await this.#saasClient + // .Delete(`identity-providers/${this.#id}`) // .then((res) => res.status); // } } diff --git a/src/modules/IdentityProviders.ts b/src/modules/IdentityProviders.ts index 4d94eda..468ea8d 100644 --- a/src/modules/IdentityProviders.ts +++ b/src/modules/IdentityProviders.ts @@ -4,16 +4,16 @@ import { parseFilter } from "../util/filter"; // TODO: documentation is incomplete! export class IdentityProviders { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`identityProviders.get: "id" parameter is required`); const identityProvider: IdentityProvider = new IdentityProvider( - this.saasClient, + this.#saasClient, arg.id ); await identityProvider.init(); @@ -22,11 +22,11 @@ export class IdentityProviders { } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`identity-providers?limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new IdentityProvider(this.saasClient, t.id, t)) + data.map((t) => new IdentityProvider(this.#saasClient, t.id, t)) ); } diff --git a/src/modules/Item.ts b/src/modules/Item.ts index 362c467..55f37aa 100644 --- a/src/modules/Item.ts +++ b/src/modules/Item.ts @@ -89,40 +89,40 @@ export interface IItem { } export class Item { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IItem; constructor(saasClient: QlikSaaSClient, id: string, details?: IItem) { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as IItem); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`items/${this.id}`) + this.details = await this.#saasClient + .Get(`items/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`items/${this.id}`) + return await this.#saasClient + .Delete(`items/${this.#id}`) .then((res) => res.status); } async collections() { - return await this.saasClient - .Get(`items/${this.id}/collections`) + return await this.#saasClient + .Get(`items/${this.#id}/collections`) .then((res) => res.data); } async publishedItems() { - return await this.saasClient - .Get(`items/${this.id}/publisheditems`) + return await this.#saasClient + .Get(`items/${this.#id}/publisheditems`) .then((res) => res.data); } } diff --git a/src/modules/Items.ts b/src/modules/Items.ts index 91078e5..c216de9 100644 --- a/src/modules/Items.ts +++ b/src/modules/Items.ts @@ -21,25 +21,25 @@ export interface IItemCreate { } export class Items { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`items.get: "id" parameter is required`); - const item: Item = new Item(this.saasClient, arg.id); + const item: Item = new Item(this.#saasClient, arg.id); await item.init(); return item; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`items?limit=50`) .then((res) => res.data) .then((data) => { - return data.map((t) => new Item(this.saasClient, t.id, t)); + return data.map((t) => new Item(this.#saasClient, t.id, t)); }); } @@ -81,6 +81,6 @@ export class Items { // arg.resourceCreatedAt = d.toISOString(); // } - // return await this.saasClient.Post(`items`, arg).then((res) => res.data); + // return await this.#saasClient.Post(`items`, arg).then((res) => res.data); // } } diff --git a/src/modules/LicenseAssignment.ts b/src/modules/LicenseAssignment.ts index 1bc0347..1fa77ec 100644 --- a/src/modules/LicenseAssignment.ts +++ b/src/modules/LicenseAssignment.ts @@ -10,15 +10,15 @@ export interface ILicenseAssignment { } export class LicenseAssignment { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: ILicenseAssignment; constructor(saasClient: QlikSaaSClient, details?: ILicenseAssignment) { - this.saasClient = saasClient; + this.#saasClient = saasClient; this.details = details ?? ({} as ILicenseAssignment); } async remove() { - return await this.saasClient + return await this.#saasClient .Post(`licenses/assignments/actions/delete`, { delete: [ { @@ -34,7 +34,7 @@ export class LicenseAssignment { if (!arg.sourceType) throw new Error(`assignments.update: "sourceType" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`licenses/assignments/actions/update`, { update: [ { diff --git a/src/modules/Licenses.ts b/src/modules/Licenses.ts index 4e98fa6..9f5a75a 100644 --- a/src/modules/Licenses.ts +++ b/src/modules/Licenses.ts @@ -49,45 +49,45 @@ export interface ILicenseOverview { } export class Licenses { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } // TODO: Cannot read property 'Href' of undefined async consumption() { - return await this.saasClient + return await this.#saasClient .Get(`licenses/consumption`) .then((res) => res.data); } // TODO: Cannot read property 'Href' of undefined async assignments() { - return await this.saasClient + return await this.#saasClient .Get(`licenses/assignments`) .then((res) => res.data) .then((assignments) => - assignments.map((a) => new LicenseAssignment(this.saasClient, a)) + assignments.map((a) => new LicenseAssignment(this.#saasClient, a)) ); } async assignmentsAdd(arg: { subject: string; type: string }[]) { - return await this.saasClient + return await this.#saasClient .Post(`licenses/assignments/actions/add`, arg) .then((res) => res.data) .then((assignments) => - assignments.map((a) => new LicenseAssignment(this.saasClient, a)) + assignments.map((a) => new LicenseAssignment(this.#saasClient, a)) ); } async status() { - return await this.saasClient + return await this.#saasClient .Get(`licenses/status`) .then((res) => res.data); } async overview() { - return await this.saasClient + return await this.#saasClient .Get(`licenses/overview`) .then((res) => res.data); } diff --git a/src/modules/NaturalLanguage.ts b/src/modules/NaturalLanguage.ts index 2f5b0cb..1d6f89f 100644 --- a/src/modules/NaturalLanguage.ts +++ b/src/modules/NaturalLanguage.ts @@ -59,13 +59,13 @@ export interface INL { } export class NL { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async ask(arg: INLAsk) { - return await this.saasClient + return await this.#saasClient .Post(`questions/actions/ask`, arg) .then((res) => res.data); } diff --git a/src/modules/Notification.ts b/src/modules/Notification.ts index c28f888..5d86787 100644 --- a/src/modules/Notification.ts +++ b/src/modules/Notification.ts @@ -19,10 +19,10 @@ export interface INotificationItem { } export class Notification { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: INotificationItem; constructor(saasClient: QlikSaaSClient, details?: INotificationItem) { - this.saasClient = saasClient; + this.#saasClient = saasClient; this.details = details ?? ({} as INotificationItem); } } diff --git a/src/modules/Notifications.ts b/src/modules/Notifications.ts index f6cf4ef..54ee1f8 100644 --- a/src/modules/Notifications.ts +++ b/src/modules/Notifications.ts @@ -4,9 +4,9 @@ import { URLBuild } from "../util/UrlBuild"; import { INotificationItem, Notification } from "./Notification"; export class Notifications { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async getAll(arg?: { locale?: string; subscribable?: "true" | "false" }) { @@ -14,9 +14,9 @@ export class Notifications { urlBuild.addParam("locale", arg?.locale); urlBuild.addParam("subscribable", arg?.subscribable); - return await this.saasClient + return await this.#saasClient .Get<{ notifications: INotificationItem[] }>(urlBuild.getUrl()) .then((res) => res.data.notifications as INotificationItem[]) - .then((data) => data.map((t) => new Notification(this.saasClient, t))); + .then((data) => data.map((t) => new Notification(this.#saasClient, t))); } } diff --git a/src/modules/OAuthToken.ts b/src/modules/OAuthToken.ts index e19de2b..9222f7e 100644 --- a/src/modules/OAuthToken.ts +++ b/src/modules/OAuthToken.ts @@ -10,20 +10,20 @@ export interface IOAuthToken { } export class OAuthToken { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IOAuthToken; constructor(saasClient: QlikSaaSClient, id: string, details?: IOAuthToken) { if (!id) throw new Error(`oauthToken.get: "id" parameter is required`); this.details = details ?? ({} as IOAuthToken); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async remove() { - return await this.saasClient - .Delete(`oauth-tokens/${this.id}`) + return await this.#saasClient + .Delete(`oauth-tokens/${this.#id}`) .then((res) => res.status); } } diff --git a/src/modules/OAuthTokens.ts b/src/modules/OAuthTokens.ts index b7f1b7e..64074cc 100644 --- a/src/modules/OAuthTokens.ts +++ b/src/modules/OAuthTokens.ts @@ -3,18 +3,18 @@ import { IOAuthToken, OAuthToken } from "./OAuthToken"; import { parseFilter } from "../util/filter"; export class OAuthTokens { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } // TODO: 400 when called? async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`oauth-tokens?limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new OAuthToken(this.saasClient, t.id, t)) + data.map((t) => new OAuthToken(this.#saasClient, t.id, t)) ); } diff --git a/src/modules/Origin.ts b/src/modules/Origin.ts index 4aa0b17..a8b3888 100644 --- a/src/modules/Origin.ts +++ b/src/modules/Origin.ts @@ -24,15 +24,15 @@ export interface IOrigin { } export class Origin { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IOrigin; constructor(saasClient: QlikSaaSClient, id: string, details?: IOrigin) { if (!id) throw new Error(`origins.get: "id" parameter is required`); this.details = details ?? ({} as IOrigin); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: true }) { @@ -41,15 +41,15 @@ export class Origin { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`csp-origins/${this.id}`) + this.details = await this.#saasClient + .Get(`csp-origins/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`csp-origins/${this.id}`) + return await this.#saasClient + .Delete(`csp-origins/${this.#id}`) .then((res) => res.status); } @@ -59,8 +59,8 @@ export class Origin { let updateStatus = 0; - return await this.saasClient - .Put(`csp-origins/${this.id}`, arg) + return await this.#saasClient + .Put(`csp-origins/${this.#id}`, arg) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/Origins.ts b/src/modules/Origins.ts index dcd2378..2b20aa5 100644 --- a/src/modules/Origins.ts +++ b/src/modules/Origins.ts @@ -24,14 +24,14 @@ export interface IOriginCreate { } export class Origins { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`origins.get: "id" parameter is required`); - const origin: Origin = new Origin(this.saasClient, arg.id); + const origin: Origin = new Origin(this.#saasClient, arg.id); await origin.init(); return origin; @@ -39,10 +39,10 @@ export class Origins { // TODO: 400 when called? async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`csp-origins?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new Origin(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Origin(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -73,7 +73,7 @@ export class Origins { } async generateHeader() { - return await this.saasClient + return await this.#saasClient .Get<{ [k: string]: any }>(`csp-origins/actions/generate-header`) .then((res) => res.data); } @@ -82,8 +82,8 @@ export class Origins { if (!arg.origin) throw new Error(`origins.create: "origin" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`csp-origins`, arg) - .then((res) => new Origin(this.saasClient, res.data.id, res.data)); + .then((res) => new Origin(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Quotas.ts b/src/modules/Quotas.ts index 8ad481f..8bbf8a5 100644 --- a/src/modules/Quotas.ts +++ b/src/modules/Quotas.ts @@ -21,15 +21,15 @@ type QuotaType = | string; export class Quotas { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: QuotaType }) { if (!arg.id) throw new Error(`quotas.get: "id" parameter is required`); - return await this.saasClient + return await this.#saasClient .Get(`quotas/${arg.id}`) .then((res) => res.data); } @@ -38,7 +38,7 @@ export class Quotas { const urlBuild = new URLBuild("quotas?limit=50"); urlBuild.addParam("reportUsage", "true"); - return await this.saasClient + return await this.#saasClient .Get(urlBuild.getUrl()) .then((res) => res.data); } diff --git a/src/modules/Reload.ts b/src/modules/Reload.ts index bd5f836..d321899 100644 --- a/src/modules/Reload.ts +++ b/src/modules/Reload.ts @@ -22,28 +22,28 @@ export interface IReload { } export class Reload { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IReload; constructor(saasClient: QlikSaaSClient, id: string, details?: IReload) { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as IReload); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`reloads/${this.id}`) + this.details = await this.#saasClient + .Get(`reloads/${this.#id}`) .then((res) => res.data); } } - async cancel() { - return await this.saasClient - .Post(`reloads/${this.id}/actions/cancel`, {}) + async cancel(arg?: { waitForCancel: boolean }) { + return await this.#saasClient + .Post(`reloads/${this.#id}/actions/cancel`, {}) .then((res) => res.status); } } diff --git a/src/modules/ReloadTask.ts b/src/modules/ReloadTask.ts index 79a1359..a09e71a 100644 --- a/src/modules/ReloadTask.ts +++ b/src/modules/ReloadTask.ts @@ -2,15 +2,15 @@ import { QlikSaaSClient } from "qlik-rest-api"; import { IReloadTask, IReloadTaskUpdate } from "./ReloadTask.interfaces"; export class ReloadTask { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IReloadTask; constructor(saasClient: QlikSaaSClient, id: string, details?: IReloadTask) { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as IReloadTask); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -19,15 +19,15 @@ export class ReloadTask { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`reload-tasks/${this.id}`) + this.details = await this.#saasClient + .Get(`reload-tasks/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`reload-tasks/${this.id}`) + return await this.#saasClient + .Delete(`reload-tasks/${this.#id}`) .then((res) => res.status); } @@ -46,8 +46,8 @@ export class ReloadTask { let updateStatus = 0; - return await this.saasClient - .Put(`reload-tasks/${this.id}`, arg) + return await this.#saasClient + .Put(`reload-tasks/${this.#id}`, arg) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/ReloadTasks.ts b/src/modules/ReloadTasks.ts index 1e72b0c..7f80cd1 100644 --- a/src/modules/ReloadTasks.ts +++ b/src/modules/ReloadTasks.ts @@ -4,25 +4,25 @@ import { IReloadTask, IReloadTaskCreate } from "./ReloadTask.interfaces"; import { parseFilter } from "../util/filter"; export class ReloadTasks { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`reloadTasks.get: "id" parameter is required`); - const rt: ReloadTask = new ReloadTask(this.saasClient, arg.id); + const rt: ReloadTask = new ReloadTask(this.#saasClient, arg.id); await rt.init(); return rt; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`reload-tasks?limit=50`) .then((res) => res.data) .then((data) => - data.map((t) => new ReloadTask(this.saasClient, t.id, t)) + data.map((t) => new ReloadTask(this.#saasClient, t.id, t)) ); } @@ -73,8 +73,8 @@ export class ReloadTasks { arg["state"] = "Enabled"; arg["type"] = "scheduled_reload"; - return await this.saasClient + return await this.#saasClient .Post(`reload-tasks`, arg) - .then((res) => new ReloadTask(this.saasClient, res.data.id, res.data)); + .then((res) => new ReloadTask(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Reloads.ts b/src/modules/Reloads.ts index b4200b7..6c9f251 100644 --- a/src/modules/Reloads.ts +++ b/src/modules/Reloads.ts @@ -3,24 +3,24 @@ import { IReload, Reload } from "./Reload"; import { parseFilter } from "../util/filter"; export class Reloads { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`reloads.get: "id" parameter is required`); - const reload: Reload = new Reload(this.saasClient, arg.id); + const reload: Reload = new Reload(this.#saasClient, arg.id); await reload.init(); return reload; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`reloads?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new Reload(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Reload(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -41,8 +41,8 @@ export class Reloads { if (!arg.appId) throw new Error(`reloads.start: "appId" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`reloads`, { appId: arg.appId, partial: arg.partial }) - .then((res) => new Reload(this.saasClient, res.data.id, res.data)); + .then((res) => new Reload(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Roles.ts b/src/modules/Roles.ts index 4769366..f270ec7 100644 --- a/src/modules/Roles.ts +++ b/src/modules/Roles.ts @@ -22,21 +22,21 @@ export interface IRole extends IRoleCondensed { } export class Roles { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`roles.get: "id" parameter is required`); - return await this.saasClient + return await this.#saasClient .Get(`roles/${arg.id}`) .then((res) => res.data); } async getAll() { - return await this.saasClient.Get(`roles?limit=50`).then((res) => res.data); + return await this.#saasClient.Get(`roles?limit=50`).then((res) => res.data); } async getFilter(arg: { filter: string }) { diff --git a/src/modules/Run.ts b/src/modules/Run.ts index 0b12656..88bbccd 100644 --- a/src/modules/Run.ts +++ b/src/modules/Run.ts @@ -35,9 +35,9 @@ export interface IRunExportResponse { } export class Run { - private id: string; + #id: string; private automationId: string; - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; details: IRun; constructor( saasClient: QlikSaaSClient, @@ -48,41 +48,41 @@ export class Run { if (!id) throw new Error(`run.get: "id" parameter is required`); this.details = details ?? ({} as IRun); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; this.automationId = automationId; } // async init() { // if (!this.details || Object.keys(this.details).length == 0) { - // this.details = await this.saasClient - // .Get(`automations/${this.id}`) + // this.details = await this.#saasClient + // .Get(`automations/${this.#id}`) // .then((res) => res.data); // } // } async export() { - return await this.saasClient + return await this.#saasClient .Post( - `automations/automations/${this.automationId}/runs/${this.id}/actions/export`, + `automations/automations/${this.automationId}/runs/${this.#id}/actions/export`, {} ) .then((res) => res.data); } async retry() { - return await this.saasClient + return await this.#saasClient .Post( - `automations/automations/${this.automationId}/runs/${this.id}/actions/retry`, + `automations/automations/${this.automationId}/runs/${this.#id}/actions/retry`, {} ) .then((res) => res.status); } async stop() { - return await this.saasClient + return await this.#saasClient .Post( - `automations/automations/${this.automationId}/runs/${this.id}/actions/stop`, + `automations/automations/${this.automationId}/runs/${this.#id}/actions/stop`, {} ) .then((res) => res.status); diff --git a/src/modules/Runs.ts b/src/modules/Runs.ts index 7461ee4..ab61530 100644 --- a/src/modules/Runs.ts +++ b/src/modules/Runs.ts @@ -4,31 +4,31 @@ // import { Run } from "./Run"; // export class Runs { -// private saasClient: QlikSaaSClient; +// #saasClient: QlikSaaSClient; // constructor(saasClient: QlikSaaSClient) { -// this.saasClient = saasClient; +// this.#saasClient = saasClient; // } // async get(arg: { id: string }) { // if (!arg.id) throw new Error(`runs.get: "id" parameter is required`); -// const a: Run = new Run(this.saasClient, arg.id); +// const a: Run = new Run(this.#saasClient, arg.id); // await a.init(); // return a; // } // async getAll() { -// return await this.saasClient +// return await this.#saasClient // .Get(`automations?limit=50`) // .then((res) => res.data) // .then((data: any) => { -// return data.map((t) => new Automation(this.saasClient, t.id, t)); +// return data.map((t) => new Automation(this.#saasClient, t.id, t)); // }); // } // async create(arg: IAutomationCreate) { -// return await this.saasClient +// return await this.#saasClient // .Post("automations", { ...arg }) // .then((res) => res.data); // } diff --git a/src/modules/Space.ts b/src/modules/Space.ts index fc2d6c3..01e2d92 100644 --- a/src/modules/Space.ts +++ b/src/modules/Space.ts @@ -40,15 +40,15 @@ export interface IAssignmentCreate { } export class Space { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: ISpace; constructor(saasClient: QlikSaaSClient, id: string, details?: ISpace) { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details ?? ({} as ISpace); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -57,15 +57,15 @@ export class Space { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`spaces/${this.id}`) + this.details = await this.#saasClient + .Get(`spaces/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`spaces/${this.id}`) + return await this.#saasClient + .Delete(`spaces/${this.#id}`) .then((res) => res.status); } @@ -77,8 +77,8 @@ export class Space { let updateStatus = 0; - return await this.saasClient - .Put(`spaces/${this.id}`, data) + return await this.#saasClient + .Put(`spaces/${this.#id}`, data) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -87,13 +87,13 @@ export class Space { } async assignments() { - return await this.saasClient - .Get(`spaces/${this.id}/assignments`) + return await this.#saasClient + .Get(`spaces/${this.#id}/assignments`) .then((res) => res.data) .then((assignments) => assignments.map( (assignment) => - new Assignment(this.saasClient, assignment.id, this.id, assignment) + new Assignment(this.#saasClient, assignment.id, this.#id, assignment) ) ); } @@ -104,12 +104,12 @@ export class Space { if (arg.assigneeId) data["assigneeId"] = arg.assigneeId; if (arg.roles) data["roles"] = arg.roles; - return await this.saasClient - .Post(`spaces/${this.id}/assignments`, data) + return await this.#saasClient + .Post(`spaces/${this.#id}/assignments`, data) .then((res) => res.data) .then( (assignment) => - new Assignment(this.saasClient, assignment.id, this.id, assignment) + new Assignment(this.#saasClient, assignment.id, this.#id, assignment) ); } } diff --git a/src/modules/Spaces.ts b/src/modules/Spaces.ts index 609f33f..3dcee69 100644 --- a/src/modules/Spaces.ts +++ b/src/modules/Spaces.ts @@ -32,25 +32,25 @@ export interface ISpaceCreate { } export class Spaces { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`spaces.get: "id" parameter is required`); - const space: Space = new Space(this.saasClient, arg.id); + const space: Space = new Space(this.#saasClient, arg.id); await space.init(); return space; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`spaces?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new Space(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Space(this.#saasClient, t.id, t))); } async getFilterNative(arg: ISpaceFilter) { @@ -63,10 +63,10 @@ export class Spaces { ids: arg.ids || [], names: arg.names || [], }; - return await this.saasClient + return await this.#saasClient .Post(`spaces/filter`, filter) .then((res) => res.data) - .then((data) => data.map((t) => new Space(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Space(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -111,8 +111,8 @@ export class Spaces { throw new Error(`spaces.create: "name" parameter is required`); if (!arg.type) throw new Error(`spaces.type: "type" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`spaces`, arg) - .then((res) => new Space(this.saasClient, res.data.id, res.data)); + .then((res) => new Space(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Tenant.ts b/src/modules/Tenant.ts index 89c64bc..ee30ca3 100644 --- a/src/modules/Tenant.ts +++ b/src/modules/Tenant.ts @@ -29,21 +29,21 @@ export type DeactivateStatus = { }; export class Tenant { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: ITenant; constructor(saasClient: QlikSaaSClient, id: string, details?: ITenant) { if (!id) throw new Error(`tenant.get: "id" parameter is required`); this.details = details ?? ({} as ITenant); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: true }) { if (Object.keys(this.details).length == 0 || arg?.force == true) { - this.details = await this.saasClient - .Get(`tenants/${this.id}`) + this.details = await this.#saasClient + .Get(`tenants/${this.#id}`) .then((res) => res.data); } } @@ -59,8 +59,8 @@ export class Tenant { let updateStatus: number = -1; - return await this.saasClient - .Patch(`tenants/${this.id}`, data) + return await this.#saasClient + .Patch(`tenants/${this.#id}`, data) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -71,8 +71,8 @@ export class Tenant { async reactivate() { let status = 200; - return await this.saasClient - .Post(`tenants/${this.id}/actions/reactivate`, {}) + return await this.#saasClient + .Post(`tenants/${this.#id}/actions/reactivate`, {}) .then((res) => { status = res.status; return this.init({ force: true }); @@ -92,9 +92,9 @@ export class Tenant { estimatedPurgeDate: "", }; - return await this.saasClient + return await this.#saasClient .Post( - `tenants/${this.id}/actions/deactivate`, + `tenants/${this.#id}/actions/deactivate`, arg?.purgeAfterDays ? { purgeAfterDays: arg.purgeAfterDays } : {} ) .then((res) => { diff --git a/src/modules/Tenants.ts b/src/modules/Tenants.ts index 02a1114..68acaf1 100644 --- a/src/modules/Tenants.ts +++ b/src/modules/Tenants.ts @@ -8,14 +8,14 @@ export interface ITenantCreationRequest { } export class Tenants { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`tenants.get: "id" parameter is required`); - const tenant: Tenant = new Tenant(this.saasClient, arg.id); + const tenant: Tenant = new Tenant(this.#saasClient, arg.id); await tenant.init(); return tenant; @@ -29,8 +29,8 @@ export class Tenants { if (!arg.licenseKey) throw new Error(`tenants.create: "licenseKey" parameter is required`); - return this.saasClient + return this.#saasClient .Post("tenants", arg) - .then((res) => new Tenant(this.saasClient, res.data.id, res.data)); + .then((res) => new Tenant(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/Theme.ts b/src/modules/Theme.ts index e0eaeb0..bd88815 100644 --- a/src/modules/Theme.ts +++ b/src/modules/Theme.ts @@ -28,41 +28,41 @@ export interface ITheme { } export class Theme { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: ITheme; constructor(saasClient: QlikSaaSClient, id: string, details?: ITheme) { if (!id) throw new Error(`app.get: "id" parameter is required`); this.details = details || ({} as ITheme); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init() { if (!this.details || Object.keys(this.details).length == 0) { - this.details = await this.saasClient - .Get(`themes/${this.id}`) + this.details = await this.#saasClient + .Get(`themes/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`themes/${this.id}`) + return await this.#saasClient + .Delete(`themes/${this.#id}`) .then((res) => res.status); } async file(arg: { fileName: string }) { - return await this.saasClient - .Get(`themes/${this.id}/file/${arg.fileName}`) + return await this.#saasClient + .Get(`themes/${this.#id}/file/${arg.fileName}`) .then((res) => res.data); } async download() { - return await this.saasClient + return await this.#saasClient .Get( - `themes/${this.id}/file`, + `themes/${this.#id}/file`, "application/x-zip-compressed", "arraybuffer" ) @@ -82,8 +82,8 @@ export class Theme { // // ts-ignore // formData.append("file", stream); // formData.append("data", { name: "test" }); - // return await this.saasClient - // .Patch(`themes/${this.id}/file`, formData, "multipart/form-data") + // return await this.#saasClient + // .Patch(`themes/${this.#id}/file`, formData, "multipart/form-data") // .then((res) => res.data); // } } diff --git a/src/modules/Themes.ts b/src/modules/Themes.ts index f682556..2e68ffa 100644 --- a/src/modules/Themes.ts +++ b/src/modules/Themes.ts @@ -8,25 +8,25 @@ import { parseFilter } from "../util/filter"; // } export class Themes { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`themes.get: "id" parameter is required`); - const theme: Theme = new Theme(this.saasClient, arg.id); + const theme: Theme = new Theme(this.#saasClient, arg.id); await theme.init(); return theme; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`themes?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new Theme(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new Theme(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -57,8 +57,8 @@ export class Themes { } // async create(arg: IThemeCreate) { - // return await this.saasClient + // return await this.#saasClient // .Post(`themes`, arg) - // .then((res) => new Theme(this.saasClient, res.data.id, res.data)); + // .then((res) => new Theme(this.#saasClient, res.data.id, res.data)); // } } diff --git a/src/modules/Transports.ts b/src/modules/Transports.ts index adf3ea9..2de1317 100644 --- a/src/modules/Transports.ts +++ b/src/modules/Transports.ts @@ -79,15 +79,15 @@ export interface IEmailConfigFieldPatch { } export class Transports { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; _actions: TransportsActions; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; - this._actions = new TransportsActions(this.saasClient); + this.#saasClient = saasClient; + this._actions = new TransportsActions(this.#saasClient); } async get() { - return await this.saasClient + return await this.#saasClient .Get(`transports/email-config`) .then((res) => res.data); } @@ -98,13 +98,13 @@ export class Transports { if (!Array.isArray(arg)) throw new Error(`transports.patch: provided argument is not an array`); - return await this.saasClient + return await this.#saasClient .Patch(`transports/email-config`, arg) .then((res) => res.status); } async delete() { - return await this.saasClient + return await this.#saasClient .Delete(`transports/email-config`) .then((res) => res.status); } diff --git a/src/modules/TransportsActions.ts b/src/modules/TransportsActions.ts index fbd6d22..0be720f 100644 --- a/src/modules/TransportsActions.ts +++ b/src/modules/TransportsActions.ts @@ -33,9 +33,9 @@ export interface ISmtpCheck { } export class TransportsActions { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } /** @@ -61,7 +61,7 @@ export class TransportsActions { `transports._actions.sendTestEmail: "subject" parameter is required` ); - return await this.saasClient + return await this.#saasClient .Post(`transports/email-config/actions/send-test-email`, arg) .then((res) => res.data); } @@ -72,7 +72,7 @@ export class TransportsActions { * Rate limit: Tier 2 (60 requests per minute) */ async validate(): Promise { - return await this.saasClient + return await this.#saasClient .Post(`transports/email-config/actions/validate`, {}) .then((res) => res.data); } @@ -83,7 +83,7 @@ export class TransportsActions { * Rate limit: Tier 2 (60 requests per minute) */ async verifyConnection(): Promise { - return await this.saasClient + return await this.#saasClient .Post( `transports/email-config/actions/verify-connection`, {} diff --git a/src/modules/User.ts b/src/modules/User.ts index 3262107..43bc864 100644 --- a/src/modules/User.ts +++ b/src/modules/User.ts @@ -55,15 +55,15 @@ export interface IUserUpdate { } export class User { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IUser; constructor(saasClient: QlikSaaSClient, id: string, details?: IUser) { if (!id) throw new Error(`user.get: "id" parameter is required`); this.details = details ?? ({} as IUser); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -72,15 +72,15 @@ export class User { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`users/${this.id}`) + this.details = await this.#saasClient + .Get(`users/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`users/${this.id}`) + return await this.#saasClient + .Delete(`users/${this.#id}`) .then((res) => res.status); } @@ -92,8 +92,8 @@ export class User { let updateStatus = 0; - return await this.saasClient - .Patch(`users/${this.id}`, data) + return await this.#saasClient + .Patch(`users/${this.#id}`, data) .then((res) => { updateStatus = res.status; return this.init({ force: true }); diff --git a/src/modules/Users.ts b/src/modules/Users.ts index 0abe3a5..cfecdde 100644 --- a/src/modules/Users.ts +++ b/src/modules/Users.ts @@ -15,24 +15,24 @@ export interface IUserCreate { } export class Users { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; _actions: UsersActions; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; - this._actions = new UsersActions(this.saasClient); + this.#saasClient = saasClient; + this._actions = new UsersActions(this.#saasClient); } /** * Info about the tenant accessing the endpoint */ async get(arg: { id: string }) { - return await this.saasClient + return await this.#saasClient .Post<{ data: IUser[] }>("users/actions/filter", { filter: `id eq "${arg.id}"`, }) .then((res) => res.data.data) .then((usersData) => - usersData.map((user) => new User(this.saasClient, user.id, user)) + usersData.map((user) => new User(this.#saasClient, user.id, user)) ); } @@ -49,7 +49,7 @@ export class Users { const urlBuild = new URLBuild(`users/actions/filter`); urlBuild.addParam("sort", arg.sort); - return await this.saasClient + return await this.#saasClient .Post(urlBuild.getUrl(), { filter: arg.filter }) .then((res) => res.data); } @@ -85,19 +85,19 @@ export class Users { * Returns a list of users. Each element of the list is an instance of the User class */ async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`users?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new User(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new User(this.#saasClient, t.id, t))); } /** * Redirects to retrieve the user resource associated with the JWT claims */ async me() { - return await this.saasClient + return await this.#saasClient .Get(`users/me`) - .then((res) => new User(this.saasClient, res.data.id, res.data)); + .then((res) => new User(this.#saasClient, res.data.id, res.data)); } /** @@ -111,7 +111,7 @@ export class Users { * The role names can now be retrieved from the list roles endpoint. */ async metadata() { - return await this.saasClient + return await this.#saasClient .Get<{ valid_roles: string[] }>(`users/metadata`) .then((res) => res.data); } @@ -127,8 +127,8 @@ export class Users { if (!arg.tenantId) throw new Error(`users.create: "tenantId" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`users`, arg) - .then((res) => new User(this.saasClient, res.data.id, res.data)); + .then((res) => new User(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/UsersActions.ts b/src/modules/UsersActions.ts index 16cc893..5b28684 100644 --- a/src/modules/UsersActions.ts +++ b/src/modules/UsersActions.ts @@ -22,9 +22,9 @@ export interface IUserActionsInvite { } export class UsersActions { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } /** @@ -34,7 +34,7 @@ export class UsersActions { * Rate limit: Tier 1 (1000 requests per minute) */ async count() { - return await this.saasClient + return await this.#saasClient .Get<{ total: number }>(`users/actions/count`) .then((res) => res.data); } @@ -48,7 +48,7 @@ export class UsersActions { if (!arg) throw new Error(`users._actions.invite: update arguments are missing`); - return await this.saasClient + return await this.#saasClient .Post<{ data: any[] }>(`users/actions/invite`, arg) .then((res) => res.data); } diff --git a/src/modules/WebHook.ts b/src/modules/WebHook.ts index 71842fd..f72e589 100644 --- a/src/modules/WebHook.ts +++ b/src/modules/WebHook.ts @@ -129,15 +129,15 @@ export interface IWebHookPatch { } export class WebHook { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IWebHook; constructor(saasClient: QlikSaaSClient, id: string, details?: IWebHook) { if (!id) throw new Error(`webHooks.get: "id" parameter is required`); this.details = details ?? ({} as IWebHook); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: boolean }) { @@ -146,15 +146,15 @@ export class WebHook { Object.keys(this.details).length == 0 || arg?.force == true ) { - this.details = await this.saasClient - .Get(`webhooks/${this.id}`) + this.details = await this.#saasClient + .Get(`webhooks/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`webhooks/${this.id}`) + return await this.#saasClient + .Delete(`webhooks/${this.#id}`) .then((res) => res.status); } @@ -166,8 +166,8 @@ export class WebHook { let updateStatus = 0; - return await this.saasClient - .Put(`webhooks/${this.id}`, this.details) + return await this.#saasClient + .Put(`webhooks/${this.#id}`, this.details) .then((res) => { updateStatus = res.status; return this.init({ force: true }); @@ -176,9 +176,9 @@ export class WebHook { } async patch(arg: IWebHookPatch[]) { - return await this.saasClient + return await this.#saasClient .Patch( - `/webhooks/${this.id}`, + `/webhooks/${this.#id}`, arg.map((a) => { const o: any = { op: a.op, @@ -194,8 +194,8 @@ export class WebHook { } async deliveries() { - return await this.saasClient - .Get(`webhooks/${this.id}/deliveries`) + return await this.#saasClient + .Get(`webhooks/${this.#id}/deliveries`) .then((res) => res.data); } @@ -203,8 +203,8 @@ export class WebHook { if (!arg.id) throw new Error(`webHook.delivery: "id" parameter is required`); - return await this.saasClient - .Get(`webhooks/${this.id}/deliveries/${arg.id}`) + return await this.#saasClient + .Get(`webhooks/${this.#id}/deliveries/${arg.id}`) .then((res) => res.data); } @@ -212,9 +212,9 @@ export class WebHook { if (!arg.id) throw new Error(`webHook.deliveryResend: "id" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post( - `webhooks/${this.id}/deliveries/${arg.id}/actions/resend`, + `webhooks/${this.#id}/deliveries/${arg.id}/actions/resend`, {} ) .then((res) => res.data); diff --git a/src/modules/WebHooks.ts b/src/modules/WebHooks.ts index 0fee8cf..5510523 100644 --- a/src/modules/WebHooks.ts +++ b/src/modules/WebHooks.ts @@ -25,25 +25,25 @@ export type IWebHookCreate = Partial< }; export class WebHooks { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`webhooks.get: "id" parameter is required`); - const webHook: WebHook = new WebHook(this.saasClient, arg.id); + const webHook: WebHook = new WebHook(this.#saasClient, arg.id); await webHook.init(); return webHook; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`webhooks?limit=50`) .then((res) => res.data) - .then((data) => data.map((t) => new WebHook(this.saasClient, t.id, t))); + .then((data) => data.map((t) => new WebHook(this.#saasClient, t.id, t))); } async getFilter(arg: { filter: string }) { @@ -74,7 +74,7 @@ export class WebHooks { } async eventTypes() { - return await this.saasClient + return await this.#saasClient .Get(`webhooks/event-types`) .then((res) => res.data); } @@ -85,8 +85,8 @@ export class WebHooks { if (!arg.url) throw new Error(`webHooks.create: "url" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post(`webhooks`, arg) - .then((res) => new WebHook(this.saasClient, res.data.id, res.data)); + .then((res) => new WebHook(this.#saasClient, res.data.id, res.data)); } } diff --git a/src/modules/WebIntegration.ts b/src/modules/WebIntegration.ts index c6ceacd..459773d 100644 --- a/src/modules/WebIntegration.ts +++ b/src/modules/WebIntegration.ts @@ -39,8 +39,8 @@ export interface IWebIntegration { } export class WebIntegration { - private id: string; - private saasClient: QlikSaaSClient; + #id: string; + #saasClient: QlikSaaSClient; details: IWebIntegration; constructor( saasClient: QlikSaaSClient, @@ -50,30 +50,30 @@ export class WebIntegration { if (!id) throw new Error(`webIntegration.get: "id" parameter is required`); this.details = details ?? ({} as IWebIntegration); - this.id = id; - this.saasClient = saasClient; + this.#id = id; + this.#saasClient = saasClient; } async init(arg?: { force: true }) { if (Object.keys(this.details).length == 0 || arg?.force == true) { - this.details = await this.saasClient - .Get(`web-integrations/${this.id}`) + this.details = await this.#saasClient + .Get(`web-integrations/${this.#id}`) .then((res) => res.data); } } async remove() { - return await this.saasClient - .Delete(`web-integrations/${this.id}`) + return await this.#saasClient + .Delete(`web-integrations/${this.#id}`) .then((res) => res.status); } async update(arg: IWebIntegrationUpdate[]) { let updateStatus = 0; - return await this.saasClient + return await this.#saasClient .Patch( - `web-integrations/${this.id}`, + `web-integrations/${this.#id}`, arg.map((a) => ({ op: "replace", path: `/${a.path}`, diff --git a/src/modules/WebIntegrations.ts b/src/modules/WebIntegrations.ts index 256142d..6591e24 100644 --- a/src/modules/WebIntegrations.ts +++ b/src/modules/WebIntegrations.ts @@ -13,27 +13,27 @@ export interface IWebIntegrationCreate { } export class WebIntegrations { - private saasClient: QlikSaaSClient; + #saasClient: QlikSaaSClient; constructor(saasClient: QlikSaaSClient) { - this.saasClient = saasClient; + this.#saasClient = saasClient; } async get(arg: { id: string }) { if (!arg.id) throw new Error(`webIntegrations.get: "id" parameter is required`); - const wi: WebIntegration = new WebIntegration(this.saasClient, arg.id); + const wi: WebIntegration = new WebIntegration(this.#saasClient, arg.id); await wi.init(); return wi; } async getAll() { - return await this.saasClient + return await this.#saasClient .Get(`web-integrations?limit=50`) .then((res) => res.data) .then((data) => { - return data.map((t) => new WebIntegration(this.saasClient, t.id, t)); + return data.map((t) => new WebIntegration(this.#saasClient, t.id, t)); }); } @@ -72,10 +72,10 @@ export class WebIntegrations { if (!arg.name) throw new Error(`webIntegrations.create: "name" parameter is required`); - return await this.saasClient + return await this.#saasClient .Post("web-integrations", { ...arg }) .then( - (res) => new WebIntegration(this.saasClient, res.data.id, res.data) + (res) => new WebIntegration(this.#saasClient, res.data.id, res.data) ); } }