@workerbase/sdk
Advanced tools
Comparing version 0.1.15-beta.11 to 0.1.15-beta.13
@@ -41,16 +41,3 @@ "use strict"; | ||
Object.keys(resources_1.default).forEach(function (name) { | ||
console.log('------------------------------'); | ||
console.log('name:', name); | ||
console.log('resources[name]:', resources_1.default[name]); | ||
if (name === 'buttons') { | ||
_this[name] = resources_1.default[name]; | ||
} | ||
else if (name === 'steps') { | ||
_this[name] = resources_1.default[name]; | ||
} | ||
else { | ||
_this[name] = new resources_1.default[name](_this); | ||
console.log('new resources[name](this):', new resources_1.default[name](_this)); | ||
} | ||
console.log('this[name]:', _this[name]); | ||
_this[name] = new resources_1.default[name](_this); | ||
}); | ||
@@ -57,0 +44,0 @@ }; |
@@ -10,4 +10,2 @@ import { DatabasesSDK } from './resources/Databases'; | ||
import { WorkinstructionSDK } from './resources/Workinstructions'; | ||
import { ButtonsSDK } from './resources/Buttons'; | ||
import { StepsSDK } from './resources/Steps'; | ||
export interface Resources { | ||
@@ -23,4 +21,2 @@ databases: DatabasesSDK; | ||
workinstructions: WorkinstructionSDK; | ||
buttons: ButtonsSDK; | ||
steps: StepsSDK; | ||
} | ||
@@ -37,9 +33,3 @@ declare const _default: { | ||
workinstructions: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
buttons: { | ||
CloseButton: (text: string, styles: any) => Partial<import("./types/buttons").WorkerbaseButton>; | ||
}; | ||
steps: { | ||
InfoText: (title: string, description: string, buttons: [import("./types/buttons").WorkerbaseButton]) => Partial<import("./types/steps").WorkerbaseStep>; | ||
}; | ||
}; | ||
export default _default; |
@@ -15,4 +15,2 @@ "use strict"; | ||
var Workinstructions_1 = __importDefault(require("./resources/Workinstructions")); | ||
var Buttons_1 = __importDefault(require("./resources/Buttons")); | ||
var Steps_1 = __importDefault(require("./resources/Steps")); | ||
exports.default = { | ||
@@ -28,5 +26,3 @@ databases: Databases_1.default, | ||
workinstructions: Workinstructions_1.default, | ||
buttons: Buttons_1.default, | ||
steps: Steps_1.default, | ||
}; | ||
//# sourceMappingURL=resources.js.map |
import { WorkerbaseButton } from '../types/buttons'; | ||
export interface ButtonsSDK { | ||
CloseButton: (text: string, styles: any) => Partial<WorkerbaseButton>; | ||
CloseButton: (data: Partial<WorkerbaseButton>) => Partial<WorkerbaseButton>; | ||
} | ||
declare const _default: { | ||
CloseButton: (text: string, styles: any) => Partial<WorkerbaseButton>; | ||
CloseButton: (data: Partial<WorkerbaseButton>) => Partial<WorkerbaseButton>; | ||
}; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
CloseButton: function (text, styles) { | ||
CloseButton: function (data) { | ||
return { | ||
text: text, | ||
styles: styles, | ||
text: data === null || data === void 0 ? void 0 : data.text, | ||
styles: data === null || data === void 0 ? void 0 : data.styles, | ||
action: { | ||
@@ -9,0 +9,0 @@ type: 'close', |
@@ -1,9 +0,8 @@ | ||
import { WorkerbaseButton } from '../types/buttons'; | ||
import { WorkerbaseStep } from '../types/steps'; | ||
export interface StepsSDK { | ||
InfoText: (title: string, description: string, buttons: [WorkerbaseButton]) => Partial<WorkerbaseStep>; | ||
InfoText: (data: Partial<WorkerbaseStep>) => Partial<WorkerbaseStep>; | ||
} | ||
declare const _default: { | ||
InfoText: (title: string, description: string, buttons: [WorkerbaseButton]) => Partial<WorkerbaseStep>; | ||
InfoText: (data: Partial<WorkerbaseStep>) => Partial<WorkerbaseStep>; | ||
}; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
InfoText: function (title, description, buttons) { | ||
InfoText: function (data) { | ||
var stepId = Buffer.from(Math.random() | ||
@@ -13,5 +13,5 @@ .toString() | ||
id: stepId, | ||
title: title, | ||
description: description, | ||
buttons: buttons, | ||
title: data === null || data === void 0 ? void 0 : data.title, | ||
description: data === null || data === void 0 ? void 0 : data.description, | ||
buttons: data === null || data === void 0 ? void 0 : data.buttons, | ||
}; | ||
@@ -18,0 +18,0 @@ }, |
import { WorkerbaseWorkinstruction, WorkerbaseWorkinstructionPOST, WorkerbaseWorkinstructionPUT } from '../types/workinstructions'; | ||
import { BasicMethodTypes } from '../utils/WorkerbaseRessource'; | ||
export declare type WorkinstructionSDK = BasicMethodTypes<{ | ||
import { ButtonsSDK } from './Buttons'; | ||
import { StepsSDK } from './Steps'; | ||
export interface WorkinstructionSDK extends BasicMethodTypes<{ | ||
GET: WorkerbaseWorkinstruction; | ||
POST: WorkerbaseWorkinstructionPOST; | ||
PUT: WorkerbaseWorkinstructionPUT; | ||
}>; | ||
}> { | ||
steps: StepsSDK; | ||
buttons: ButtonsSDK; | ||
} | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -21,4 +21,46 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var doRequest_1 = __importDefault(require("../utils/doRequest")); | ||
var WorkerbaseRessource_1 = __importStar(require("../utils/WorkerbaseRessource")); | ||
var Buttons_1 = __importDefault(require("./Buttons")); | ||
var Steps_1 = __importDefault(require("./Steps")); | ||
exports.default = WorkerbaseRessource_1.default({ | ||
@@ -32,3 +74,34 @@ path: 'workinstructions', | ||
], | ||
children: { | ||
steps: Steps_1.default, | ||
buttons: Buttons_1.default, | ||
}, | ||
methods: { | ||
create: function (spec) { return function (name, description, project, steps) { return __awaiter(void 0, void 0, void 0, function () { | ||
var initialStepId, payload, data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
initialStepId = steps === null || steps === void 0 ? void 0 : steps[0].id; | ||
payload = { | ||
name: name, | ||
description: description, | ||
project: project, | ||
steps: steps, | ||
initialStepId: initialStepId, | ||
isEvent: false, | ||
isApp: false, | ||
}; | ||
return [4 /*yield*/, doRequest_1.default(spec._api, spec.basePath + "/", { | ||
method: 'POST', | ||
data: payload, | ||
}, process.env.PROJECTS_SERVICE_HOST)]; | ||
case 1: | ||
data = (_a.sent()).data; | ||
return [2 /*return*/, data.data]; | ||
} | ||
}); | ||
}); }; }, | ||
}, | ||
}); | ||
//# sourceMappingURL=Workinstructions.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -49,20 +38,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.doRequest = void 0; | ||
var axios_1 = __importDefault(require("axios")); | ||
var parseurl_1 = __importDefault(require("parseurl")); | ||
var apiVersion = 'v1'; | ||
@@ -73,75 +46,22 @@ exports.doRequest = function (api, endpoint, options, internalHostname) { | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var baseUrl, url, response, err_1, errorMessage, errorToThrow, _a, tmpVar1, tmpVar2, otherErrorData; | ||
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8; | ||
return __generator(this, function (_9) { | ||
switch (_9.label) { | ||
case 0: | ||
if (!api.url) { | ||
throw new Error('No WB_API_URL in environment or option found'); | ||
} | ||
if (!api.accesstoken) { | ||
throw new Error('No WB_ACCESS_TOKEN in environment or option found'); | ||
} | ||
if (process.env.DEBUG) { | ||
console.log({ | ||
WB_ENABLE_INTERNAL_ROUTING: process.env.WB_ENABLE_INTERNAL_ROUTING, | ||
internalHostname: internalHostname, | ||
}); | ||
} | ||
if (process.env.WB_ENABLE_INTERNAL_ROUTING && internalHostname) { | ||
// eslint-disable-next-line no-param-reassign | ||
api.url = "http://" + internalHostname + ":3000/"; | ||
} | ||
baseUrl = parseurl_1.default({ url: api.url }).href; | ||
url = endpoint === 'graphql' | ||
? baseUrl + "graphql" | ||
: baseUrl + "api/" + apiVersion + "/" + endpoint; | ||
_9.label = 1; | ||
case 1: | ||
_9.trys.push([1, 3, , 4]); | ||
if (process.env.DEBUG) { | ||
console.log(__assign({ url: url, headers: __assign({ accesstoken: api.accesstoken, 'User-Agent': "workerbase-sdk (" + api.version + ")", 'Content-Type': 'application/json' }, options.headers), method: 'GET' }, options)); | ||
} | ||
return [4 /*yield*/, axios_1.default(__assign({ url: url, headers: __assign({ accesstoken: api.accesstoken, 'User-Agent': "workerbase-sdk (" + api.version + ")", 'Content-Type': 'application/json' }, options.headers), method: 'GET' }, options))]; | ||
case 2: | ||
response = _9.sent(); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
err_1 = _9.sent(); | ||
errorMessage = err_1.message; | ||
if (((_c = (_b = err_1.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.errorMessage) === 'HTTP Trigger failed' && ((_g = (_f = (_e = (_d = err_1.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.additionalData) === null || _g === void 0 ? void 0 : _g.errors)) { | ||
errorMessage = (_l = (_k = (_j = (_h = err_1.response) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.error) === null || _k === void 0 ? void 0 : _k.additionalData) === null || _l === void 0 ? void 0 : _l.errors.map(function (ruleError) { | ||
var _a, _b; | ||
var ruleErrorReason = ((_a = ruleError === null || ruleError === void 0 ? void 0 : ruleError.err) === null || _a === void 0 ? void 0 : _a.message) ? ": " + ((_b = ruleError === null || ruleError === void 0 ? void 0 : ruleError.err) === null || _b === void 0 ? void 0 : _b.message) : ""; | ||
var message = "Connector triggering RuleId " + ruleError.ruleId + " failed " + ruleErrorReason; | ||
return message.trim(); | ||
}).join(", "); | ||
} | ||
else if (((_o = (_m = err_1.response) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.errorMessage) && | ||
typeof ((_q = (_p = err_1.response) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.errorMessage) === 'string') { | ||
errorMessage = (_s = (_r = err_1.response) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.errorMessage; | ||
} | ||
else if (((_u = (_t = err_1.response) === null || _t === void 0 ? void 0 : _t.data) === null || _u === void 0 ? void 0 : _u.errorMessage) && | ||
typeof ((_w = (_v = err_1.response) === null || _v === void 0 ? void 0 : _v.data) === null || _w === void 0 ? void 0 : _w.errorMessage) === 'object') { | ||
errorMessage = JSON.stringify((_y = (_x = err_1.response) === null || _x === void 0 ? void 0 : _x.data) === null || _y === void 0 ? void 0 : _y.errorMessage); | ||
} | ||
else if ((_z = err_1.response) === null || _z === void 0 ? void 0 : _z.data) { | ||
errorMessage = JSON.stringify((_0 = err_1.response) === null || _0 === void 0 ? void 0 : _0.data); | ||
} | ||
errorToThrow = new Error(errorMessage); | ||
Object.assign(errorToThrow, { | ||
requestUrl: ((_2 = (_1 = err_1 === null || err_1 === void 0 ? void 0 : err_1.request) === null || _1 === void 0 ? void 0 : _1.res) === null || _2 === void 0 ? void 0 : _2.responseUrl) || url, | ||
requestMethod: (_3 = err_1 === null || err_1 === void 0 ? void 0 : err_1.request) === null || _3 === void 0 ? void 0 : _3.method, | ||
requestData: (_4 = err_1 === null || err_1 === void 0 ? void 0 : err_1.config) === null || _4 === void 0 ? void 0 : _4.data, | ||
requestParams: (_5 = err_1 === null || err_1 === void 0 ? void 0 : err_1.config) === null || _5 === void 0 ? void 0 : _5.params, | ||
responseStatusCode: (_6 = err_1 === null || err_1 === void 0 ? void 0 : err_1.response) === null || _6 === void 0 ? void 0 : _6.status, | ||
responseData: (_7 = err_1 === null || err_1 === void 0 ? void 0 : err_1.response) === null || _7 === void 0 ? void 0 : _7.data, | ||
}); | ||
if ((_8 = err_1.response) === null || _8 === void 0 ? void 0 : _8.data) { | ||
_a = err_1.response.data, tmpVar1 = _a.errorMessage, tmpVar2 = _a.success, otherErrorData = __rest(_a, ["errorMessage", "success"]); | ||
Object.assign(errorToThrow, otherErrorData); | ||
} | ||
throw errorToThrow; | ||
case 4: return [2 /*return*/]; | ||
} | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, { | ||
data: {}, | ||
// `status` is the HTTP status code from the server response | ||
status: 200, | ||
// `statusText` is the HTTP status message from the server response | ||
// As of HTTP/2 status text is blank or unsupported. | ||
// (HTTP/2 RFC: https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2.4) | ||
statusText: 'OK', | ||
// `headers` the HTTP headers that the server responded with | ||
// All header names are lower cased and can be accessed using the bracket notation. | ||
// Example: `response.headers['content-type']` | ||
headers: {}, | ||
// `config` is the config that was provided to `axios` for the request | ||
config: {}, | ||
// `request` is the request that generated this response | ||
// It is the last ClientRequest instance in node.js (in redirects) | ||
// and an XMLHttpRequest instance in the browser | ||
request: {}, | ||
}]; | ||
}); | ||
@@ -148,0 +68,0 @@ }); |
@@ -43,2 +43,3 @@ import { WorkerbaseSdk, API } from '..'; | ||
transformData?: (data: Item['GET']) => TransformedItem; | ||
children?: Record<string, any>; | ||
}): (workerbase: WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; |
@@ -145,3 +145,3 @@ "use strict"; | ||
if (parent === void 0) { parent = {}; } | ||
var childApis = params.childApis, includeBasics = params.includeBasics, path = params.path, methods = params.methods, internalHostname = params.internalHostname; | ||
var childApis = params.childApis, includeBasics = params.includeBasics, path = params.path, methods = params.methods, internalHostname = params.internalHostname, children = params.children; | ||
var fullPath = parentAPIPath + path; | ||
@@ -173,2 +173,7 @@ var initialTransformData = params.transformData || (function (data) { return data; }); | ||
} | ||
if (children) { | ||
Object.keys(children).forEach(function (key) { | ||
_this[key] = children[key]; | ||
}); | ||
} | ||
}; | ||
@@ -175,0 +180,0 @@ } |
{ | ||
"name": "@workerbase/sdk", | ||
"version": "0.1.15-beta.11", | ||
"version": "0.1.15-beta.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
23
122493
1840