New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

knode-awx

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knode-awx - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

34

dist/Api/Api.js

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,11 +11,13 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { FetchApiError } from "./Error/FetchApiError.js";
import { params } from "./utils.js";
import { InstanceApiError } from "./Error/InstanceApiError.js";
import { ApiUrl } from "./ApiUrl.js";
export class AnsibleApi {
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnsibleApi = void 0;
const FetchApiError_1 = require("./Error/FetchApiError.js");
const utils_1 = require("./utils.js");
const InstanceApiError_1 = require("./Error/InstanceApiError.js");
const ApiUrl_1 = require("./ApiUrl.js");
class AnsibleApi {
testServer() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const url = ApiUrl.gURL(AnsibleApi.TEST);
const url = ApiUrl_1.ApiUrl.gURL(AnsibleApi.TEST);
const response = (yield this.fetchAPI(url));

@@ -25,8 +28,8 @@ if ((_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.startsWith("application/json")) {

if (status != 200)
throw new InstanceApiError(`The server return a status different of 200 : ${status}, url: ${url}`);
throw new InstanceApiError_1.InstanceApiError(`The server return a status different of 200 : ${status}, url: ${url}`);
if (jsonData.instances.length < 1)
throw new InstanceApiError(`The server have not active instance, url: ${url}`);
throw new InstanceApiError_1.InstanceApiError(`The server have not active instance, url: ${url}`);
return { status, jsonData };
}
throw new InstanceApiError(`The server is not reachable (verify URL, it must end with a '/'): ${url}`);
throw new InstanceApiError_1.InstanceApiError(`The server is not reachable (verify URL, it must end with a '/'): ${url}`);
});

@@ -42,3 +45,3 @@ }

if (this.INSTANCE === null)
throw new InstanceApiError("API Instance not found, init the class AnsibleApi() before used");
throw new InstanceApiError_1.InstanceApiError("API Instance not found, init the class AnsibleApi() before used");
return this.INSTANCE;

@@ -53,3 +56,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return yield fetch(url.toString(), params(this.token, url.method));
return yield fetch(url.toString(), (0, utils_1.params)(this.token, url.method));
});

@@ -68,12 +71,13 @@ }

if (statusCode.startsWith('404'))
throw new FetchApiError(`Resources not found : ${statusCode}`);
throw new FetchApiError_1.FetchApiError(`Resources not found : ${statusCode}`);
if (statusCode.startsWith('401'))
throw new FetchApiError(`Unauthorized (token is set?) : ${(_a = (yield response.json())) === null || _a === void 0 ? void 0 : _a.detail}`);
throw new FetchApiError_1.FetchApiError(`Unauthorized (token is set?) : ${(_a = (yield response.json())) === null || _a === void 0 ? void 0 : _a.detail}`);
if (statusCode.startsWith('403'))
throw new FetchApiError(`Forbidden, verify the token permission! ${(_b = (yield response.json())) === null || _b === void 0 ? void 0 : _b.detail}`);
throw new FetchApiError_1.FetchApiError(`Forbidden, verify the token permission! ${(_b = (yield response.json())) === null || _b === void 0 ? void 0 : _b.detail}`);
if (statusCode.startsWith('5'))
throw new FetchApiError(`Unknown error : ${response.status}`);
throw new FetchApiError_1.FetchApiError(`Unknown error : ${response.status}`);
});
}
}
exports.AnsibleApi = AnsibleApi;
AnsibleApi.TEST = { endpoint: "ping/" };

@@ -1,3 +0,6 @@

import { AnsibleApi } from "./Api.js";
export class ApiUrl {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiUrl = void 0;
const Api_1 = require("./Api.js");
class ApiUrl {
constructor(endpoint, method = "GET") {

@@ -17,3 +20,3 @@ this.endpoint = endpoint;

const ApiURL = new ApiUrl(url.endpoint, url.method);
ApiURL.url = new URL(url.endpoint, AnsibleApi.GETINSTANCE().url);
ApiURL.url = new URL(url.endpoint, Api_1.AnsibleApi.GETINSTANCE().url);
for (const query in url.queryParams) {

@@ -28,1 +31,2 @@ ApiURL.url.searchParams.append(query, url.queryParams[query].toString());

}
exports.ApiUrl = ApiUrl;

@@ -1,4 +0,8 @@

export class Generic {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Generic = void 0;
class Generic {
constructor() {
}
}
exports.Generic = Generic;

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,6 +11,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { AnsibleApi } from "../../Api.js";
import { Generic } from "../Generic.js";
import { ApiUrl } from "../../ApiUrl.js";
export class Inventory extends Generic {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Inventory = void 0;
const Api_1 = require("../../Api.js");
const Generic_1 = require("../Generic.js");
const ApiUrl_1 = require("../../ApiUrl.js");
class Inventory extends Generic_1.Generic {
constructor(inventory) {

@@ -21,3 +24,3 @@ super();

return __awaiter(this, void 0, void 0, function* () {
return yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(Inventory.LIST));
return yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(Inventory.LIST));
});

@@ -27,3 +30,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const inventoryDetail = yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(Inventory.DETAIL));
const inventoryDetail = yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(Inventory.DETAIL));
return new Inventory(inventoryDetail);

@@ -33,3 +36,4 @@ });

}
exports.Inventory = Inventory;
Inventory.LIST = { endpoint: "inventories/" };
Inventory.DETAIL = { endpoint: "inventories/{id}/" };

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,8 +11,10 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { Generic } from "../Generic.js";
import { AnsibleApi } from "../../Api.js";
import { StatusJob as StatusJobE } from "../../Enum/StatusJob.js";
import { sleep } from "../../utils.js";
import { ApiUrl } from "../../ApiUrl.js";
export class Job extends Generic {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Job = void 0;
const Generic_1 = require("../Generic.js");
const Api_1 = require("../../Api.js");
const StatusJob_1 = require("../../Enum/StatusJob.js");
const utils_1 = require("../../utils.js");
const ApiUrl_1 = require("../../ApiUrl.js");
class Job extends Generic_1.Generic {
constructor(job) {

@@ -23,3 +26,3 @@ super();

return __awaiter(this, void 0, void 0, function* () {
return yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(Job.LIST));
return yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(Job.LIST));
});

@@ -29,3 +32,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const jobDetail = yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(Job.DETAIL, { id: id }));
const jobDetail = yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(Job.DETAIL, { id: id }));
return new Job(jobDetail);

@@ -37,5 +40,5 @@ });

const { id } = this.job;
const { status } = yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(Job.DETAIL, { id: id }));
const { status } = yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(Job.DETAIL, { id: id }));
return {
finished: status !== StatusJobE.WAITING && status !== StatusJobE.PENDING && status !== StatusJobE.NEW && status != StatusJobE.RUNNING,
finished: status !== StatusJob_1.StatusJob.WAITING && status !== StatusJob_1.StatusJob.PENDING && status !== StatusJob_1.StatusJob.NEW && status != StatusJob_1.StatusJob.RUNNING,
status: status

@@ -55,3 +58,3 @@ };

}
yield sleep(checkInterval);
yield (0, utils_1.sleep)(checkInterval);
}

@@ -61,3 +64,4 @@ });

}
exports.Job = Job;
Job.LIST = { endpoint: "jobs/" };
Job.DETAIL = { endpoint: "jobs/{id}/" };

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,6 +11,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { Generic } from "../Generic.js";
import { AnsibleApi } from "../../Api.js";
import { ApiUrl } from "../../ApiUrl.js";
export class JobTemplate extends Generic {
Object.defineProperty(exports, "__esModule", { value: true });
exports.JobTemplate = void 0;
const Generic_1 = require("../Generic.js");
const Api_1 = require("../../Api.js");
const ApiUrl_1 = require("../../ApiUrl.js");
class JobTemplate extends Generic_1.Generic {
constructor(jobTemplate) {

@@ -21,3 +24,3 @@ super();

return __awaiter(this, void 0, void 0, function* () {
return yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(JobTemplate.LIST));
return yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(JobTemplate.LIST));
});

@@ -27,3 +30,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
return new JobTemplate(yield AnsibleApi.GETINSTANCE().fetchAD(ApiUrl.gURL(JobTemplate.DETAIL, { id: id })));
return new JobTemplate(yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(ApiUrl_1.ApiUrl.gURL(JobTemplate.DETAIL, { id: id })));
});

@@ -34,4 +37,4 @@ }

const { id } = this.jobTemplate;
const url = ApiUrl.gURL(JobTemplate.LAUNCH, { id: id });
const detail = yield AnsibleApi.GETINSTANCE().fetchAD(url);
const url = ApiUrl_1.ApiUrl.gURL(JobTemplate.LAUNCH, { id: id });
const detail = yield Api_1.AnsibleApi.GETINSTANCE().fetchAD(url);
//return new Job(detail)

@@ -41,4 +44,5 @@ });

}
exports.JobTemplate = JobTemplate;
JobTemplate.LIST = { endpoint: "job_templates/" };
JobTemplate.DETAIL = { endpoint: "job_templates/{id}/" };
JobTemplate.LAUNCH = { endpoint: "job_templates/{id}/launch/", method: "POST" };

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,2 +0,5 @@

export var StatusJob;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusJob = void 0;
var StatusJob;
(function (StatusJob) {

@@ -12,2 +15,2 @@ StatusJob["NEW"] = "new";

StatusJob["NEVER_UPDATED"] = "never updated";
})(StatusJob || (StatusJob = {}));
})(StatusJob || (exports.StatusJob = StatusJob = {}));

@@ -1,2 +0,5 @@

export class FetchApiError extends Error {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchApiError = void 0;
class FetchApiError extends Error {
constructor(message) {

@@ -6,1 +9,2 @@ super(message);

}
exports.FetchApiError = FetchApiError;

@@ -1,2 +0,5 @@

export class InstanceApiError extends Error {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InstanceApiError = void 0;
class InstanceApiError extends Error {
constructor(msg) {

@@ -6,1 +9,2 @@ super(msg);

}
exports.InstanceApiError = InstanceApiError;

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,2 +0,5 @@

export function params(token = undefined, method = "GET") {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sleep = exports.params = void 0;
function params(token = undefined, method = "GET") {
const paramAuthorization = token ? { Authorization: `Bearer ${token}` } : undefined;

@@ -8,4 +11,6 @@ return {

}
export function sleep(ms) {
exports.params = params;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
exports.sleep = sleep;

@@ -1,3 +0,7 @@

export function isAuthToken(object) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAuthToken = void 0;
function isAuthToken(object) {
return 'token' in object;
}
exports.isAuthToken = isAuthToken;

@@ -1,4 +0,11 @@

export { JobTemplate } from "./Api/Endpoint/Job/JobTemplate.js";
export { Job } from "./Api/Endpoint/Job/Job.js";
export { Inventory } from "./Api/Endpoint/Inventory/Inventory.js";
export { AnsibleApi } from "./Api/Api.js";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnsibleApi = exports.Inventory = exports.Job = exports.JobTemplate = void 0;
var JobTemplate_1 = require("./Api/Endpoint/Job/JobTemplate.js");
Object.defineProperty(exports, "JobTemplate", { enumerable: true, get: function () { return JobTemplate_1.JobTemplate; } });
var Job_1 = require("./Api/Endpoint/Job/Job.js");
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return Job_1.Job; } });
var Inventory_1 = require("./Api/Endpoint/Inventory/Inventory.js");
Object.defineProperty(exports, "Inventory", { enumerable: true, get: function () { return Inventory_1.Inventory; } });
var Api_1 = require("./Api/Api.js");
Object.defineProperty(exports, "AnsibleApi", { enumerable: true, get: function () { return Api_1.AnsibleApi; } });
{
"name": "knode-awx",
"description": "AWX (Ansible) interface with nodejs",
"main": "dist/src/index.js",
"main": "dist/index.js",
"license": "GPL-3.0",
"type": "module",
"version": "0.0.8",
"version": "0.1.0",
"devDependencies": {

@@ -9,0 +9,0 @@ "@babel/preset-env": "^7.24.7",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc