n8n
Version:
n8n Workflow Automation Tool
64 lines • 3.17 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CredentialTypes = void 0;
const typedi_1 = require("typedi");
const n8n_core_1 = require("n8n-core");
const n8n_workflow_1 = require("n8n-workflow");
const constants_1 = require("./constants");
const LoadNodesAndCredentials_1 = require("./LoadNodesAndCredentials");
let CredentialTypes = class CredentialTypes {
constructor(loadNodesAndCredentials) {
this.loadNodesAndCredentials = loadNodesAndCredentials;
}
recognizes(type) {
const { loadedCredentials, knownCredentials } = this.loadNodesAndCredentials;
return type in knownCredentials || type in loadedCredentials;
}
getByName(credentialType) {
return this.getCredential(credentialType).type;
}
getSupportedNodes(type) {
var _a, _b;
return (_b = (_a = this.loadNodesAndCredentials.knownCredentials[type]) === null || _a === void 0 ? void 0 : _a.supportedNodes) !== null && _b !== void 0 ? _b : [];
}
getParentTypes(typeName) {
var _a, _b;
const extendsArr = (_b = (_a = this.loadNodesAndCredentials.knownCredentials[typeName]) === null || _a === void 0 ? void 0 : _a.extends) !== null && _b !== void 0 ? _b : [];
if (extendsArr.length) {
extendsArr.forEach((type) => {
extendsArr.push(...this.getParentTypes(type));
});
}
return extendsArr;
}
getCredential(type) {
const { loadedCredentials, knownCredentials } = this.loadNodesAndCredentials;
if (type in loadedCredentials) {
return loadedCredentials[type];
}
if (type in knownCredentials) {
const { className, sourcePath } = knownCredentials[type];
const loaded = (0, n8n_core_1.loadClassInIsolation)(sourcePath, className);
loadedCredentials[type] = { sourcePath, type: loaded };
return loadedCredentials[type];
}
throw new n8n_workflow_1.ApplicationError(constants_1.RESPONSE_ERROR_MESSAGES.NO_CREDENTIAL, {
tags: { credentialType: type },
});
}
};
exports.CredentialTypes = CredentialTypes;
exports.CredentialTypes = CredentialTypes = __decorate([
(0, typedi_1.Service)(),
__metadata("design:paramtypes", [LoadNodesAndCredentials_1.LoadNodesAndCredentials])
], CredentialTypes);
//# sourceMappingURL=CredentialTypes.js.map
;