frappe-js-sdk
Version:
TypeScript/JavaScript client for Frappe Framework REST API
39 lines (38 loc) • 1.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrappeApp = void 0;
var __1 = require("..");
var call_1 = require("../call");
var db_1 = require("../db");
var file_1 = require("../file");
var axios_1 = require("../utils/axios");
var FrappeApp = /** @class */ (function () {
function FrappeApp(url, tokenParams, name, customHeaders) {
var _a, _b;
this.url = url;
this.name = name !== null && name !== void 0 ? name : 'FrappeApp';
this.useToken = (_a = tokenParams === null || tokenParams === void 0 ? void 0 : tokenParams.useToken) !== null && _a !== void 0 ? _a : false;
this.token = tokenParams === null || tokenParams === void 0 ? void 0 : tokenParams.token;
this.tokenType = (_b = tokenParams === null || tokenParams === void 0 ? void 0 : tokenParams.type) !== null && _b !== void 0 ? _b : 'Bearer';
this.customHeaders = customHeaders;
this.axios = (0, axios_1.getAxiosClient)(this.url, this.useToken, this.token, this.tokenType, this.customHeaders);
}
/** Returns a FrappeAuth object for the app */
FrappeApp.prototype.auth = function () {
return new __1.FrappeAuth(this.url, this.axios, this.useToken, this.token, this.tokenType);
};
/** Returns a FrappeDB object for the app */
FrappeApp.prototype.db = function () {
return new db_1.FrappeDB(this.url, this.axios, this.useToken, this.token, this.tokenType);
};
/** Returns a FrappeFileUpload object for the app */
FrappeApp.prototype.file = function () {
return new file_1.FrappeFileUpload(this.url, this.axios, this.useToken, this.token, this.tokenType, this.customHeaders);
};
/** Returns a FrappeCall object for the app */
FrappeApp.prototype.call = function () {
return new call_1.FrappeCall(this.url, this.axios, this.useToken, this.token, this.tokenType);
};
return FrappeApp;
}());
exports.FrappeApp = FrappeApp;