mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Allow custom types on getCredentials (no-changelog) (#10567)
This commit is contained in:
committed by
GitHub
parent
52c574d83f
commit
be52176585
@@ -94,11 +94,11 @@ export class EmbeddingsAzureOpenAi implements INodeType {
|
|||||||
|
|
||||||
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
||||||
this.logger.verbose('Supply data for embeddings');
|
this.logger.verbose('Supply data for embeddings');
|
||||||
const credentials = (await this.getCredentials('azureOpenAiApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
resourceName: string;
|
resourceName: string;
|
||||||
apiVersion: string;
|
apiVersion: string;
|
||||||
};
|
}>('azureOpenAiApi');
|
||||||
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
||||||
|
|
||||||
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export class EmbeddingsCohere implements INodeType {
|
|||||||
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
||||||
this.logger.verbose('Supply data for embeddings Cohere');
|
this.logger.verbose('Supply data for embeddings Cohere');
|
||||||
const modelName = this.getNodeParameter('modelName', itemIndex, 'embed-english-v2.0') as string;
|
const modelName = this.getNodeParameter('modelName', itemIndex, 'embed-english-v2.0') as string;
|
||||||
const credentials = (await this.getCredentials('cohereApi')) as { apiKey: string };
|
const credentials = await this.getCredentials<{ apiKey: string }>('cohereApi');
|
||||||
const embeddings = new CohereEmbeddings({
|
const embeddings = new CohereEmbeddings({
|
||||||
apiKey: credentials.apiKey,
|
apiKey: credentials.apiKey,
|
||||||
model: modelName,
|
model: modelName,
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ export class LmChatAzureOpenAi implements INodeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
||||||
const credentials = (await this.getCredentials('azureOpenAiApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
resourceName: string;
|
resourceName: string;
|
||||||
apiVersion: string;
|
apiVersion: string;
|
||||||
};
|
}>('azureOpenAiApi');
|
||||||
|
|
||||||
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
const modelName = this.getNodeParameter('model', itemIndex) as string;
|
||||||
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export class MemoryPostgresChat implements INodeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
const tableName = this.getNodeParameter('tableName', itemIndex, 'n8n_chat_histories') as string;
|
const tableName = this.getNodeParameter('tableName', itemIndex, 'n8n_chat_histories') as string;
|
||||||
const sessionId = getSessionId(this, itemIndex);
|
const sessionId = getSessionId(this, itemIndex);
|
||||||
|
|
||||||
|
|||||||
@@ -104,11 +104,11 @@ export class MemoryZep implements INodeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
async supplyData(this: IExecuteFunctions, itemIndex: number): Promise<SupplyData> {
|
||||||
const credentials = (await this.getCredentials('zepApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
apiUrl?: string;
|
apiUrl?: string;
|
||||||
cloud?: boolean;
|
cloud?: boolean;
|
||||||
};
|
}>('zepApi');
|
||||||
|
|
||||||
const nodeVersion = this.getNode().typeVersion;
|
const nodeVersion = this.getNode().typeVersion;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export async function validateAuth(context: IWebhookFunctions) {
|
|||||||
// Basic authorization is needed to call webhook
|
// Basic authorization is needed to call webhook
|
||||||
let expectedAuth: ICredentialDataDecryptedObject | undefined;
|
let expectedAuth: ICredentialDataDecryptedObject | undefined;
|
||||||
try {
|
try {
|
||||||
expectedAuth = await context.getCredentials('httpBasicAuth');
|
expectedAuth = await context.getCredentials<ICredentialDataDecryptedObject>('httpBasicAuth');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (expectedAuth === undefined || !expectedAuth.user || !expectedAuth.password) {
|
if (expectedAuth === undefined || !expectedAuth.user || !expectedAuth.password) {
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ export const VectorStoreZep = createVectorStoreNode({
|
|||||||
embeddingDimensions?: number;
|
embeddingDimensions?: number;
|
||||||
}) || {};
|
}) || {};
|
||||||
|
|
||||||
const credentials = (await context.getCredentials('zepApi')) as {
|
const credentials = await context.getCredentials<{
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
};
|
}>('zepApi');
|
||||||
|
|
||||||
const zepConfig: IZepConfig = {
|
const zepConfig: IZepConfig = {
|
||||||
apiUrl: credentials.apiUrl,
|
apiUrl: credentials.apiUrl,
|
||||||
@@ -102,10 +102,10 @@ export const VectorStoreZep = createVectorStoreNode({
|
|||||||
embeddingDimensions?: number;
|
embeddingDimensions?: number;
|
||||||
}) || {};
|
}) || {};
|
||||||
|
|
||||||
const credentials = (await context.getCredentials('zepApi')) as {
|
const credentials = await context.getCredentials<{
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
};
|
}>('zepApi');
|
||||||
|
|
||||||
const zepConfig = {
|
const zepConfig = {
|
||||||
apiUrl: credentials.apiUrl,
|
apiUrl: credentials.apiUrl,
|
||||||
|
|||||||
@@ -110,10 +110,10 @@ export class VectorStoreZepInsert implements INodeType {
|
|||||||
embeddingDimensions?: number;
|
embeddingDimensions?: number;
|
||||||
}) || {};
|
}) || {};
|
||||||
|
|
||||||
const credentials = (await this.getCredentials('zepApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
};
|
}>('zepApi');
|
||||||
|
|
||||||
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
const documentInput = (await this.getInputConnectionData(NodeConnectionType.AiDocument, 0)) as
|
||||||
| N8nJsonLoader
|
| N8nJsonLoader
|
||||||
|
|||||||
@@ -93,10 +93,10 @@ export class VectorStoreZepLoad implements INodeType {
|
|||||||
embeddingDimensions?: number;
|
embeddingDimensions?: number;
|
||||||
}) || {};
|
}) || {};
|
||||||
|
|
||||||
const credentials = (await this.getCredentials('zepApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
};
|
}>('zepApi');
|
||||||
const embeddings = (await this.getInputConnectionData(
|
const embeddings = (await this.getInputConnectionData(
|
||||||
NodeConnectionType.AiEmbedding,
|
NodeConnectionType.AiEmbedding,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -3,20 +3,22 @@ import type { ICredentialDataDecryptedObject, ICredentialsEncrypted } from 'n8n-
|
|||||||
import { ApplicationError, ICredentials, jsonParse } from 'n8n-workflow';
|
import { ApplicationError, ICredentials, jsonParse } from 'n8n-workflow';
|
||||||
import { Cipher } from './Cipher';
|
import { Cipher } from './Cipher';
|
||||||
|
|
||||||
export class Credentials extends ICredentials {
|
export class Credentials<
|
||||||
|
T extends object = ICredentialDataDecryptedObject,
|
||||||
|
> extends ICredentials<T> {
|
||||||
private readonly cipher = Container.get(Cipher);
|
private readonly cipher = Container.get(Cipher);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets new credential object
|
* Sets new credential object
|
||||||
*/
|
*/
|
||||||
setData(data: ICredentialDataDecryptedObject): void {
|
setData(data: T): void {
|
||||||
this.data = this.cipher.encrypt(data);
|
this.data = this.cipher.encrypt(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the decrypted credential object
|
* Returns the decrypted credential object
|
||||||
*/
|
*/
|
||||||
getData(): ICredentialDataDecryptedObject {
|
getData(): T {
|
||||||
if (this.data === undefined) {
|
if (this.data === undefined) {
|
||||||
throw new ApplicationError('No data is set so nothing can be returned.');
|
throw new ApplicationError('No data is set so nothing can be returned.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1656,7 +1656,8 @@ export async function httpRequestWithAuthentication(
|
|||||||
if (additionalCredentialOptions?.credentialsDecrypted) {
|
if (additionalCredentialOptions?.credentialsDecrypted) {
|
||||||
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
||||||
} else {
|
} else {
|
||||||
credentialsDecrypted = await this.getCredentials(credentialsType);
|
credentialsDecrypted =
|
||||||
|
await this.getCredentials<ICredentialDataDecryptedObject>(credentialsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (credentialsDecrypted === undefined) {
|
if (credentialsDecrypted === undefined) {
|
||||||
@@ -1853,7 +1854,10 @@ export async function requestWithAuthentication(
|
|||||||
if (additionalCredentialOptions?.credentialsDecrypted) {
|
if (additionalCredentialOptions?.credentialsDecrypted) {
|
||||||
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
||||||
} else {
|
} else {
|
||||||
credentialsDecrypted = await this.getCredentials(credentialsType, itemIndex);
|
credentialsDecrypted = await this.getCredentials<ICredentialDataDecryptedObject>(
|
||||||
|
credentialsType,
|
||||||
|
itemIndex,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (credentialsDecrypted === undefined) {
|
if (credentialsDecrypted === undefined) {
|
||||||
@@ -1988,7 +1992,7 @@ export function getAdditionalKeys(
|
|||||||
* @param {INode} node Node which request the data
|
* @param {INode} node Node which request the data
|
||||||
* @param {string} type The credential type to return
|
* @param {string} type The credential type to return
|
||||||
*/
|
*/
|
||||||
export async function getCredentials(
|
export async function getCredentials<T extends object = ICredentialDataDecryptedObject>(
|
||||||
workflow: Workflow,
|
workflow: Workflow,
|
||||||
node: INode,
|
node: INode,
|
||||||
type: string,
|
type: string,
|
||||||
@@ -1999,7 +2003,7 @@ export async function getCredentials(
|
|||||||
runIndex?: number,
|
runIndex?: number,
|
||||||
connectionInputData?: INodeExecutionData[],
|
connectionInputData?: INodeExecutionData[],
|
||||||
itemIndex?: number,
|
itemIndex?: number,
|
||||||
): Promise<ICredentialDataDecryptedObject> {
|
): Promise<T> {
|
||||||
// Get the NodeType as it has the information if the credentials are required
|
// Get the NodeType as it has the information if the credentials are required
|
||||||
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
||||||
if (nodeType === undefined) {
|
if (nodeType === undefined) {
|
||||||
@@ -2117,7 +2121,7 @@ export async function getCredentials(
|
|||||||
expressionResolveValues,
|
expressionResolveValues,
|
||||||
);
|
);
|
||||||
|
|
||||||
return decryptedDataObject;
|
return decryptedDataObject as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export async function automizyApiRequest(
|
|||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
option = {},
|
option = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('automizyApi')) as IDataObject;
|
const credentials = await this.getCredentials<{ apiToken: string }>('automizyApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -19,16 +19,14 @@ export async function autopilotApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
_option: IDataObject = {},
|
_option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('autopilotApi')) as IDataObject;
|
const credentials = await this.getCredentials<{ apiKey: string }>('autopilotApi');
|
||||||
|
|
||||||
const apiKey = `${credentials.apiKey}`;
|
|
||||||
|
|
||||||
const endpoint = 'https://api2.autopilothq.com/v1';
|
const endpoint = 'https://api2.autopilothq.com/v1';
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
autopilotapikey: apiKey,
|
autopilotapikey: credentials.apiKey,
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export class Baserow implements INodeType {
|
|||||||
methods = {
|
methods = {
|
||||||
loadOptions: {
|
loadOptions: {
|
||||||
async getDatabaseIds(this: ILoadOptionsFunctions) {
|
async getDatabaseIds(this: ILoadOptionsFunctions) {
|
||||||
const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials;
|
const credentials = await this.getCredentials<BaserowCredentials>('baserowApi');
|
||||||
const jwtToken = await getJwtToken.call(this, credentials);
|
const jwtToken = await getJwtToken.call(this, credentials);
|
||||||
const endpoint = '/api/applications/';
|
const endpoint = '/api/applications/';
|
||||||
const databases = (await baserowApiRequest.call(
|
const databases = (await baserowApiRequest.call(
|
||||||
@@ -124,7 +124,7 @@ export class Baserow implements INodeType {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getTableIds(this: ILoadOptionsFunctions) {
|
async getTableIds(this: ILoadOptionsFunctions) {
|
||||||
const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials;
|
const credentials = await this.getCredentials<BaserowCredentials>('baserowApi');
|
||||||
const jwtToken = await getJwtToken.call(this, credentials);
|
const jwtToken = await getJwtToken.call(this, credentials);
|
||||||
const databaseId = this.getNodeParameter('databaseId', 0) as string;
|
const databaseId = this.getNodeParameter('databaseId', 0) as string;
|
||||||
const endpoint = `/api/database/tables/database/${databaseId}/`;
|
const endpoint = `/api/database/tables/database/${databaseId}/`;
|
||||||
@@ -138,7 +138,7 @@ export class Baserow implements INodeType {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getTableFields(this: ILoadOptionsFunctions) {
|
async getTableFields(this: ILoadOptionsFunctions) {
|
||||||
const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials;
|
const credentials = await this.getCredentials<BaserowCredentials>('baserowApi');
|
||||||
const jwtToken = await getJwtToken.call(this, credentials);
|
const jwtToken = await getJwtToken.call(this, credentials);
|
||||||
const tableId = this.getNodeParameter('tableId', 0) as string;
|
const tableId = this.getNodeParameter('tableId', 0) as string;
|
||||||
const endpoint = `/api/database/fields/table/${tableId}/`;
|
const endpoint = `/api/database/fields/table/${tableId}/`;
|
||||||
@@ -160,7 +160,7 @@ export class Baserow implements INodeType {
|
|||||||
const operation = this.getNodeParameter('operation', 0) as Operation;
|
const operation = this.getNodeParameter('operation', 0) as Operation;
|
||||||
|
|
||||||
const tableId = this.getNodeParameter('tableId', 0) as string;
|
const tableId = this.getNodeParameter('tableId', 0) as string;
|
||||||
const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials;
|
const credentials = await this.getCredentials<BaserowCredentials>('baserowApi');
|
||||||
const jwtToken = await getJwtToken.call(this, credentials);
|
const jwtToken = await getJwtToken.call(this, credentials);
|
||||||
const fields = await mapper.getTableFields.call(this, tableId, jwtToken);
|
const fields = await mapper.getTableFields.call(this, tableId, jwtToken);
|
||||||
mapper.createMappings(fields);
|
mapper.createMappings(fields);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export async function baserowApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials;
|
const credentials = await this.getCredentials<BaserowCredentials>('baserowApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export async function getAuthenticationType(
|
|||||||
): Promise<'accessToken' | 'apiKey'> {
|
): Promise<'accessToken' | 'apiKey'> {
|
||||||
const authentication = this.getNodeParameter('authentication', 0) as string;
|
const authentication = this.getNodeParameter('authentication', 0) as string;
|
||||||
if (authentication === 'apiKey') {
|
if (authentication === 'apiKey') {
|
||||||
const { apiKey } = (await this.getCredentials('calendlyApi')) as { apiKey: string };
|
const { apiKey } = await this.getCredentials<{ apiKey: string }>('calendlyApi');
|
||||||
return getAuthenticationTypeFromApiKey(apiKey);
|
return getAuthenticationTypeFromApiKey(apiKey);
|
||||||
} else {
|
} else {
|
||||||
return 'accessToken';
|
return 'accessToken';
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export async function dhlApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('dhlApi')) as { apiKey: string };
|
const credentials = await this.getCredentials<{ apiKey: string }>('dhlApi');
|
||||||
|
|
||||||
let options: IRequestOptions = {
|
let options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export async function discourseApiRequest(
|
|||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
_option = {},
|
_option = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('discourseApi')) as { url: string };
|
const credentials = await this.getCredentials<{ url: string }>('discourseApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
method,
|
method,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export async function disqusApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('disqusApi')) as IDataObject;
|
const credentials = await this.getCredentials<{ accessToken: string }>('disqusApi');
|
||||||
qs.api_key = credentials.accessToken;
|
qs.api_key = credentials.accessToken;
|
||||||
|
|
||||||
// Convert to query string into a format the API can read
|
// Convert to query string into a format the API can read
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ export function simplify(data: IDataObject[]) {
|
|||||||
export async function getCredentials(this: IExecuteFunctions) {
|
export async function getCredentials(this: IExecuteFunctions) {
|
||||||
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
return (await this.getCredentials('dropboxApi')) as IDataObject;
|
return await this.getCredentials('dropboxApi');
|
||||||
} else {
|
} else {
|
||||||
return (await this.getCredentials('dropboxOAuth2Api')) as IDataObject;
|
return await this.getCredentials('dropboxOAuth2Api');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export async function erpNextApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials('erpNextApi')) as ERPNextApiCredentials;
|
const credentials = await this.getCredentials<ERPNextApiCredentials>('erpNextApi');
|
||||||
const baseUrl = getBaseUrl(credentials);
|
const baseUrl = getBaseUrl(credentials);
|
||||||
|
|
||||||
let options: IRequestOptions = {
|
let options: IRequestOptions = {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export async function emeliaApiRequest(
|
|||||||
body: object = {},
|
body: object = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { apiKey } = (await this.getCredentials('emeliaApi')) as { apiKey: string };
|
const { apiKey } = await this.getCredentials<{ apiKey: string }>('emeliaApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export async function formIoApiRequest(
|
|||||||
body = {},
|
body = {},
|
||||||
qs = {},
|
qs = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('formIoApi')) as unknown as IFormIoCredentials;
|
const credentials = await this.getCredentials<IFormIoCredentials>('formIoApi');
|
||||||
|
|
||||||
const token = await getToken.call(this, credentials);
|
const token = await getToken.call(this, credentials);
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export async function apiRequest(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = (await this.getCredentials('formstackApi')) as IDataObject;
|
const credentials = await this.getCredentials<{ accessToken: string }>('formstackApi');
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${credentials.accessToken}`;
|
options.headers!.Authorization = `Bearer ${credentials.accessToken}`;
|
||||||
return await this.helpers.request(options);
|
return await this.helpers.request(options);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export async function freshworksCrmApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { domain } = (await this.getCredentials('freshworksCrmApi')) as FreshworksCrmApiCredentials;
|
const { domain } = await this.getCredentials<FreshworksCrmApiCredentials>('freshworksCrmApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
method,
|
method,
|
||||||
|
|||||||
@@ -510,9 +510,9 @@ export class Ftp implements INodeType {
|
|||||||
const protocol = this.getNodeParameter('protocol', 0) as string;
|
const protocol = this.getNodeParameter('protocol', 0) as string;
|
||||||
|
|
||||||
if (protocol === 'sftp') {
|
if (protocol === 'sftp') {
|
||||||
credentials = await this.getCredentials('sftp');
|
credentials = await this.getCredentials<ICredentialDataDecryptedObject>('sftp');
|
||||||
} else {
|
} else {
|
||||||
credentials = await this.getCredentials('ftp');
|
credentials = await this.getCredentials<ICredentialDataDecryptedObject>('ftp');
|
||||||
}
|
}
|
||||||
let ftp: ftpClient;
|
let ftp: ftpClient;
|
||||||
let sftp: sftpClient;
|
let sftp: sftpClient;
|
||||||
|
|||||||
@@ -143,9 +143,9 @@ export async function handleGetAll(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadWebinars(this: ILoadOptionsFunctions) {
|
export async function loadWebinars(this: ILoadOptionsFunctions) {
|
||||||
const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as {
|
const { oauthTokenData } = await this.getCredentials<{
|
||||||
oauthTokenData: { account_key: string };
|
oauthTokenData: { account_key: string };
|
||||||
};
|
}>('goToWebinarOAuth2Api');
|
||||||
|
|
||||||
const endpoint = `accounts/${oauthTokenData.account_key}/webinars`;
|
const endpoint = `accounts/${oauthTokenData.account_key}/webinars`;
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ export async function loadWebinars(this: ILoadOptionsFunctions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadWebinarSessions(this: ILoadOptionsFunctions) {
|
export async function loadWebinarSessions(this: ILoadOptionsFunctions) {
|
||||||
const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as {
|
const { oauthTokenData } = await this.getCredentials<{
|
||||||
oauthTokenData: { organizer_key: string };
|
oauthTokenData: { organizer_key: string };
|
||||||
};
|
}>('goToWebinarOAuth2Api');
|
||||||
|
|
||||||
const webinarKey = this.getCurrentNodeParameter('webinarKey') as string;
|
const webinarKey = this.getCurrentNodeParameter('webinarKey') as string;
|
||||||
|
|
||||||
@@ -208,9 +208,9 @@ export async function loadWebinarSessions(this: ILoadOptionsFunctions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions) {
|
export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions) {
|
||||||
const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as {
|
const { oauthTokenData } = await this.getCredentials<{
|
||||||
oauthTokenData: { organizer_key: string };
|
oauthTokenData: { organizer_key: string };
|
||||||
};
|
}>('goToWebinarOAuth2Api');
|
||||||
|
|
||||||
const webinarkey = this.getNodeParameter('webinarKey') as string;
|
const webinarkey = this.getNodeParameter('webinarKey') as string;
|
||||||
|
|
||||||
@@ -233,9 +233,9 @@ export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadAnswers(this: ILoadOptionsFunctions) {
|
export async function loadAnswers(this: ILoadOptionsFunctions) {
|
||||||
const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as {
|
const { oauthTokenData } = await this.getCredentials<{
|
||||||
oauthTokenData: { organizer_key: string };
|
oauthTokenData: { organizer_key: string };
|
||||||
};
|
}>('goToWebinarOAuth2Api');
|
||||||
|
|
||||||
const webinarKey = this.getCurrentNodeParameter('webinarKey') as string;
|
const webinarKey = this.getCurrentNodeParameter('webinarKey') as string;
|
||||||
|
|
||||||
@@ -262,9 +262,9 @@ export async function loadAnswers(this: ILoadOptionsFunctions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadRegistranMultiChoiceQuestions(this: ILoadOptionsFunctions) {
|
export async function loadRegistranMultiChoiceQuestions(this: ILoadOptionsFunctions) {
|
||||||
const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as {
|
const { oauthTokenData } = await this.getCredentials<{
|
||||||
oauthTokenData: { organizer_key: string };
|
oauthTokenData: { organizer_key: string };
|
||||||
};
|
}>('goToWebinarOAuth2Api');
|
||||||
|
|
||||||
const webinarkey = this.getNodeParameter('webinarKey') as string;
|
const webinarkey = this.getNodeParameter('webinarKey') as string;
|
||||||
|
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ export class GoToWebinar implements INodeType {
|
|||||||
let responseData;
|
let responseData;
|
||||||
const returnData: INodeExecutionData[] = [];
|
const returnData: INodeExecutionData[] = [];
|
||||||
|
|
||||||
const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as {
|
const { oauthTokenData } = await this.getCredentials<{
|
||||||
oauthTokenData: { account_key: string; organizer_key: string };
|
oauthTokenData: { account_key: string; organizer_key: string };
|
||||||
};
|
}>('goToWebinarOAuth2Api');
|
||||||
|
|
||||||
const accountKey = oauthTokenData.account_key;
|
const accountKey = oauthTokenData.account_key;
|
||||||
const organizerKey = oauthTokenData.organizer_key;
|
const organizerKey = oauthTokenData.organizer_key;
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ export async function googleApiRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = (await this.getCredentials('googleApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
email: string;
|
email: string;
|
||||||
privateKey: string;
|
privateKey: string;
|
||||||
};
|
}>('googleApi');
|
||||||
|
|
||||||
const { access_token } = await getGoogleAccessToken.call(this, credentials, 'books');
|
const { access_token } = await getGoogleAccessToken.call(this, credentials, 'books');
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export async function grafanaApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { baseUrl: rawBaseUrl } = (await this.getCredentials('grafanaApi')) as GrafanaCredentials;
|
const { baseUrl: rawBaseUrl } = await this.getCredentials<GrafanaCredentials>('grafanaApi');
|
||||||
|
|
||||||
const baseUrl = tolerateTrailingSlash(rawBaseUrl);
|
const baseUrl = tolerateTrailingSlash(rawBaseUrl);
|
||||||
|
|
||||||
|
|||||||
@@ -534,7 +534,7 @@ export class JiraTrigger implements INodeType {
|
|||||||
let httpQueryAuth: ICredentialDataDecryptedObject | undefined;
|
let httpQueryAuth: ICredentialDataDecryptedObject | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httpQueryAuth = await this.getCredentials('httpQueryAuth');
|
httpQueryAuth = await this.getCredentials<ICredentialDataDecryptedObject>('httpQueryAuth');
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
if (httpQueryAuth === undefined || !httpQueryAuth.name || !httpQueryAuth.value) {
|
if (httpQueryAuth === undefined || !httpQueryAuth.name || !httpQueryAuth.value) {
|
||||||
|
|||||||
@@ -348,13 +348,13 @@ export class Jwt implements INodeType {
|
|||||||
|
|
||||||
const operation = this.getNodeParameter('operation', 0);
|
const operation = this.getNodeParameter('operation', 0);
|
||||||
|
|
||||||
const credentials = (await this.getCredentials('jwtAuth')) as {
|
const credentials = await this.getCredentials<{
|
||||||
keyType: 'passphrase' | 'pemKey';
|
keyType: 'passphrase' | 'pemKey';
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
privateKey: string;
|
privateKey: string;
|
||||||
secret: string;
|
secret: string;
|
||||||
algorithm: jwt.Algorithm;
|
algorithm: jwt.Algorithm;
|
||||||
};
|
}>('jwtAuth');
|
||||||
|
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ export async function kitemakerRequest(
|
|||||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { personalAccessToken } = (await this.getCredentials('kitemakerApi')) as {
|
const { personalAccessToken } = await this.getCredentials<{
|
||||||
personalAccessToken: string;
|
personalAccessToken: string;
|
||||||
};
|
}>('kitemakerApi');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ export class Mqtt implements INodeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const credentials = (await this.getCredentials('mqtt')) as unknown as MqttCredential;
|
const credentials = await this.getCredentials<MqttCredential>('mqtt');
|
||||||
const client = await createClient(credentials);
|
const client = await createClient(credentials);
|
||||||
|
|
||||||
const publishPromises = [];
|
const publishPromises = [];
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export class MqttTrigger implements INodeType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const options = this.getNodeParameter('options') as Options;
|
const options = this.getNodeParameter('options') as Options;
|
||||||
const credentials = (await this.getCredentials('mqtt')) as unknown as MqttCredential;
|
const credentials = await this.getCredentials<MqttCredential>('mqtt');
|
||||||
const client = await createClient(credentials);
|
const client = await createClient(credentials);
|
||||||
|
|
||||||
const parsePayload = (topic: string, payload: Buffer) => {
|
const parsePayload = (topic: string, payload: Buffer) => {
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ export async function mailjetApiRequest(
|
|||||||
|
|
||||||
if (resource === 'email' || this.getNode().type.includes('Trigger')) {
|
if (resource === 'email' || this.getNode().type.includes('Trigger')) {
|
||||||
credentialType = 'mailjetEmailApi';
|
credentialType = 'mailjetEmailApi';
|
||||||
const { sandboxMode } = (await this.getCredentials('mailjetEmailApi')) as {
|
const { sandboxMode } = await this.getCredentials<{
|
||||||
sandboxMode: boolean;
|
sandboxMode: boolean;
|
||||||
};
|
}>('mailjetEmailApi');
|
||||||
|
|
||||||
if (!this.getNode().type.includes('Trigger')) {
|
if (!this.getNode().type.includes('Trigger')) {
|
||||||
Object.assign(body, { SandboxMode: sandboxMode });
|
Object.assign(body, { SandboxMode: sandboxMode });
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ export async function microsoftApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('microsoftDynamicsOAuth2Api')) as {
|
const credentials = await this.getCredentials<{
|
||||||
subdomain: string;
|
subdomain: string;
|
||||||
region: string;
|
region: string;
|
||||||
};
|
}>('microsoftDynamicsOAuth2Api');
|
||||||
|
|
||||||
let options: IRequestOptions = {
|
let options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ export async function msGraphSecurityApiRequest(
|
|||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
oauthTokenData: { access_token },
|
oauthTokenData: { access_token },
|
||||||
} = (await this.getCredentials('microsoftGraphSecurityOAuth2Api')) as {
|
} = await this.getCredentials<{
|
||||||
oauthTokenData: {
|
oauthTokenData: {
|
||||||
access_token: string;
|
access_token: string;
|
||||||
};
|
};
|
||||||
};
|
}>('microsoftGraphSecurityOAuth2Api');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ export async function monicaCrmApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials('monicaCrmApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
apiToken: string;
|
apiToken: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
domain: string;
|
domain: string;
|
||||||
};
|
}>('monicaCrmApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
|
|||||||
|
|
||||||
nodeOptions.nodeVersion = this.getNode().typeVersion;
|
nodeOptions.nodeVersion = this.getNode().typeVersion;
|
||||||
|
|
||||||
const credentials = (await this.getCredentials('mySql')) as MysqlNodeCredentials;
|
const credentials = await this.getCredentials<MysqlNodeCredentials>('mySql');
|
||||||
|
|
||||||
const pool = await createPool.call(this, credentials, nodeOptions);
|
const pool = await createPool.call(this, credentials, nodeOptions);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { createPool } from '../transport';
|
|||||||
import type { MysqlNodeCredentials } from '../helpers/interfaces';
|
import type { MysqlNodeCredentials } from '../helpers/interfaces';
|
||||||
|
|
||||||
export async function searchTables(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
export async function searchTables(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||||
const credentials = (await this.getCredentials('mySql')) as MysqlNodeCredentials;
|
const credentials = await this.getCredentials<MysqlNodeCredentials>('mySql');
|
||||||
|
|
||||||
const nodeOptions = this.getNodeParameter('options', 0) as IDataObject;
|
const nodeOptions = this.getNodeParameter('options', 0) as IDataObject;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { escapeSqlIdentifier } from '../helpers/utils';
|
|||||||
import type { MysqlNodeCredentials } from '../helpers/interfaces';
|
import type { MysqlNodeCredentials } from '../helpers/interfaces';
|
||||||
|
|
||||||
export async function getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
export async function getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const credentials = (await this.getCredentials('mySql')) as MysqlNodeCredentials;
|
const credentials = await this.getCredentials<MysqlNodeCredentials>('mySql');
|
||||||
const nodeOptions = this.getNodeParameter('options', 0) as IDataObject;
|
const nodeOptions = this.getNodeParameter('options', 0) as IDataObject;
|
||||||
|
|
||||||
const pool = await createPool.call(this, credentials, nodeOptions);
|
const pool = await createPool.call(this, credentials, nodeOptions);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export async function apiRequest(
|
|||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const credentials = (await this.getCredentials('n8nApi')) as N8nApiCredentials;
|
const credentials = await this.getCredentials<N8nApiCredentials>('n8nApi');
|
||||||
const baseUrl = credentials.baseUrl;
|
const baseUrl = credentials.baseUrl;
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export async function netscalerADCApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const { url } = (await this.getCredentials('citrixAdcApi')) as { url: string };
|
const { url } = await this.getCredentials<{ url: string }>('citrixAdcApi');
|
||||||
|
|
||||||
let options: IRequestOptions = {
|
let options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ export async function nextCloudApiRequest(
|
|||||||
let credentials;
|
let credentials;
|
||||||
|
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
credentials = (await this.getCredentials('nextCloudApi')) as { webDavUrl: string };
|
credentials = await this.getCredentials<{ webDavUrl: string }>('nextCloudApi');
|
||||||
} else {
|
} else {
|
||||||
credentials = (await this.getCredentials('nextCloudOAuth2Api')) as { webDavUrl: string };
|
credentials = await this.getCredentials<{ webDavUrl: string }>('nextCloudOAuth2Api');
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export class PayPalTrigger implements INodeType {
|
|||||||
const headerData = this.getHeaderData() as IDataObject;
|
const headerData = this.getHeaderData() as IDataObject;
|
||||||
const endpoint = '/notifications/verify-webhook-signature';
|
const endpoint = '/notifications/verify-webhook-signature';
|
||||||
|
|
||||||
const { env } = (await this.getCredentials('payPalApi')) as { env: string };
|
const { env } = await this.getCredentials<{ env: string }>('payPalApi');
|
||||||
|
|
||||||
// if sanbox omit verification
|
// if sanbox omit verification
|
||||||
if (env === 'sanbox') {
|
if (env === 'sanbox') {
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ export class PipedriveTrigger implements INodeType {
|
|||||||
let httpBasicAuth: ICredentialDataDecryptedObject | undefined;
|
let httpBasicAuth: ICredentialDataDecryptedObject | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httpBasicAuth = await this.getCredentials('httpBasicAuth');
|
httpBasicAuth = await this.getCredentials<ICredentialDataDecryptedObject>('httpBasicAuth');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ export async function plivoApiRequest(
|
|||||||
body: IDataObject = {},
|
body: IDataObject = {},
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials('plivoApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
authId: string;
|
authId: string;
|
||||||
authToken: string;
|
authToken: string;
|
||||||
};
|
}>('plivoApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export async function pgTriggerFunction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function initDB(this: ITriggerFunctions | ILoadOptionsFunctions) {
|
export async function initDB(this: ITriggerFunctions | ILoadOptionsFunctions) {
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
const options = this.getNodeParameter('options', {}) as {
|
const options = this.getNodeParameter('options', {}) as {
|
||||||
connectionTimeout?: number;
|
connectionTimeout?: number;
|
||||||
delayClosingIdleConnection?: number;
|
delayClosingIdleConnection?: number;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
|
|||||||
const resource = this.getNodeParameter<PostgresType>('resource', 0);
|
const resource = this.getNodeParameter<PostgresType>('resource', 0);
|
||||||
const operation = this.getNodeParameter('operation', 0);
|
const operation = this.getNodeParameter('operation', 0);
|
||||||
|
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
const options = this.getNodeParameter('options', 0, {}) as PostgresNodeOptions;
|
const options = this.getNodeParameter('options', 0, {}) as PostgresNodeOptions;
|
||||||
const node = this.getNode();
|
const node = this.getNode();
|
||||||
options.nodeVersion = node.typeVersion;
|
options.nodeVersion = node.typeVersion;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { configurePostgres } from '../transport';
|
|||||||
import type { PostgresNodeCredentials } from '../helpers/interfaces';
|
import type { PostgresNodeCredentials } from '../helpers/interfaces';
|
||||||
|
|
||||||
export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
const options = { nodeVersion: this.getNode().typeVersion };
|
const options = { nodeVersion: this.getNode().typeVersion };
|
||||||
|
|
||||||
const { db } = await configurePostgres.call(this, credentials, options);
|
const { db } = await configurePostgres.call(this, credentials, options);
|
||||||
@@ -23,7 +23,7 @@ export async function schemaSearch(this: ILoadOptionsFunctions): Promise<INodeLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
export async function tableSearch(this: ILoadOptionsFunctions): Promise<INodeListSearchResult> {
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
const options = { nodeVersion: this.getNode().typeVersion };
|
const options = { nodeVersion: this.getNode().typeVersion };
|
||||||
|
|
||||||
const { db } = await configurePostgres.call(this, credentials, options);
|
const { db } = await configurePostgres.call(this, credentials, options);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { configurePostgres } from '../transport';
|
|||||||
import type { PostgresNodeCredentials } from '../helpers/interfaces';
|
import type { PostgresNodeCredentials } from '../helpers/interfaces';
|
||||||
|
|
||||||
export async function getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
export async function getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
const options = { nodeVersion: this.getNode().typeVersion };
|
const options = { nodeVersion: this.getNode().typeVersion };
|
||||||
|
|
||||||
const { db } = await configurePostgres.call(this, credentials, options);
|
const { db } = await configurePostgres.call(this, credentials, options);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ function mapPostgresType(postgresType: string): FieldType {
|
|||||||
export async function getMappingColumns(
|
export async function getMappingColumns(
|
||||||
this: ILoadOptionsFunctions,
|
this: ILoadOptionsFunctions,
|
||||||
): Promise<ResourceMapperFields> {
|
): Promise<ResourceMapperFields> {
|
||||||
const credentials = (await this.getCredentials('postgres')) as PostgresNodeCredentials;
|
const credentials = await this.getCredentials<PostgresNodeCredentials>('postgres');
|
||||||
|
|
||||||
const { db } = await configurePostgres.call(this, credentials);
|
const { db } = await configurePostgres.call(this, credentials);
|
||||||
|
|
||||||
|
|||||||
@@ -254,9 +254,9 @@ export async function loadResource(this: ILoadOptionsFunctions, resource: string
|
|||||||
oauthTokenData: {
|
oauthTokenData: {
|
||||||
callbackQueryString: { realmId },
|
callbackQueryString: { realmId },
|
||||||
},
|
},
|
||||||
} = (await this.getCredentials('quickBooksOAuth2Api')) as {
|
} = await this.getCredentials<{
|
||||||
oauthTokenData: { callbackQueryString: { realmId: string } };
|
oauthTokenData: { callbackQueryString: { realmId: string } };
|
||||||
};
|
}>('quickBooksOAuth2Api');
|
||||||
const endpoint = `/v3/company/${realmId}/query`;
|
const endpoint = `/v3/company/${realmId}/query`;
|
||||||
|
|
||||||
const resourceItems = await quickBooksApiRequestAllItems.call(
|
const resourceItems = await quickBooksApiRequestAllItems.call(
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ export async function supabaseApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
headers: IDataObject = {},
|
headers: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials('supabaseApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
host: string;
|
host: string;
|
||||||
serviceRole: string;
|
serviceRole: string;
|
||||||
};
|
}>('supabaseApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export class Totp implements INodeType {
|
|||||||
const returnData: INodeExecutionData[] = [];
|
const returnData: INodeExecutionData[] = [];
|
||||||
|
|
||||||
const operation = this.getNodeParameter('operation', 0);
|
const operation = this.getNodeParameter('operation', 0);
|
||||||
const credentials = (await this.getCredentials('totpApi')) as { label: string; secret: string };
|
const credentials = await this.getCredentials<{ label: string; secret: string }>('totpApi');
|
||||||
|
|
||||||
if (!credentials.label.includes(':')) {
|
if (!credentials.label.includes(':')) {
|
||||||
throw new NodeOperationError(this.getNode(), 'Malformed label - expected `issuer:username`');
|
throw new NodeOperationError(this.getNode(), 'Malformed label - expected `issuer:username`');
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ export async function twilioApiRequest(
|
|||||||
body: IDataObject,
|
body: IDataObject,
|
||||||
query?: IDataObject,
|
query?: IDataObject,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('twilioApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
accountSid: string;
|
accountSid: string;
|
||||||
authType: 'authToken' | 'apiKey';
|
authType: 'authToken' | 'apiKey';
|
||||||
authToken: string;
|
authToken: string;
|
||||||
apiKeySid: string;
|
apiKeySid: string;
|
||||||
apiKeySecret: string;
|
apiKeySecret: string;
|
||||||
};
|
}>('twilioApi');
|
||||||
|
|
||||||
if (query === undefined) {
|
if (query === undefined) {
|
||||||
query = {};
|
query = {};
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export async function venafiApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
headers: IDataObject = {},
|
headers: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('venafiTlsProtectDatacenterApi')) as IDataObject;
|
const credentials = await this.getCredentials('venafiTlsProtectDatacenterApi');
|
||||||
|
|
||||||
const options: IRequestOptions = {
|
const options: IRequestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export async function validateWebhookAuthentication(
|
|||||||
// Basic authorization is needed to call webhook
|
// Basic authorization is needed to call webhook
|
||||||
let expectedAuth: ICredentialDataDecryptedObject | undefined;
|
let expectedAuth: ICredentialDataDecryptedObject | undefined;
|
||||||
try {
|
try {
|
||||||
expectedAuth = await ctx.getCredentials('httpBasicAuth');
|
expectedAuth = await ctx.getCredentials<ICredentialDataDecryptedObject>('httpBasicAuth');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (expectedAuth === undefined || !expectedAuth.user || !expectedAuth.password) {
|
if (expectedAuth === undefined || !expectedAuth.user || !expectedAuth.password) {
|
||||||
@@ -211,7 +211,7 @@ export async function validateWebhookAuthentication(
|
|||||||
// Special header with value is needed to call webhook
|
// Special header with value is needed to call webhook
|
||||||
let expectedAuth: ICredentialDataDecryptedObject | undefined;
|
let expectedAuth: ICredentialDataDecryptedObject | undefined;
|
||||||
try {
|
try {
|
||||||
expectedAuth = await ctx.getCredentials('httpHeaderAuth');
|
expectedAuth = await ctx.getCredentials<ICredentialDataDecryptedObject>('httpHeaderAuth');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (expectedAuth === undefined || !expectedAuth.name || !expectedAuth.value) {
|
if (expectedAuth === undefined || !expectedAuth.name || !expectedAuth.value) {
|
||||||
@@ -232,12 +232,12 @@ export async function validateWebhookAuthentication(
|
|||||||
let expectedAuth;
|
let expectedAuth;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
expectedAuth = (await ctx.getCredentials('jwtAuth')) as {
|
expectedAuth = await ctx.getCredentials<{
|
||||||
keyType: 'passphrase' | 'pemKey';
|
keyType: 'passphrase' | 'pemKey';
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
secret: string;
|
secret: string;
|
||||||
algorithm: jwt.Algorithm;
|
algorithm: jwt.Algorithm;
|
||||||
};
|
}>('jwtAuth');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (expectedAuth === undefined) {
|
if (expectedAuth === undefined) {
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ export async function wiseApiRequest(
|
|||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const { apiToken, environment, privateKey } = (await this.getCredentials('wiseApi')) as {
|
const { apiToken, environment, privateKey } = await this.getCredentials<{
|
||||||
apiToken: string;
|
apiToken: string;
|
||||||
environment: 'live' | 'test';
|
environment: 'live' | 'test';
|
||||||
privateKey?: string;
|
privateKey?: string;
|
||||||
};
|
}>('wiseApi');
|
||||||
|
|
||||||
const rootUrl =
|
const rootUrl =
|
||||||
environment === 'live'
|
environment === 'live'
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ export async function workableApiRequest(
|
|||||||
uri?: string,
|
uri?: string,
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const credentials = (await this.getCredentials('workableApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
subdomain: string;
|
subdomain: string;
|
||||||
};
|
}>('workableApi');
|
||||||
|
|
||||||
let options: IRequestOptions = {
|
let options: IRequestOptions = {
|
||||||
headers: { Authorization: `Bearer ${credentials.accessToken}` },
|
headers: { Authorization: `Bearer ${credentials.accessToken}` },
|
||||||
|
|||||||
@@ -137,10 +137,10 @@ export class WorkableTrigger implements INodeType {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
async create(this: IHookFunctions): Promise<boolean> {
|
async create(this: IHookFunctions): Promise<boolean> {
|
||||||
const credentials = (await this.getCredentials('workableApi')) as {
|
const credentials = await this.getCredentials<{
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
subdomain: string;
|
subdomain: string;
|
||||||
};
|
}>('workableApi');
|
||||||
const webhookData = this.getWorkflowStaticData('node');
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||||
const triggerOn = this.getNodeParameter('triggerOn') as string;
|
const triggerOn = this.getNodeParameter('triggerOn') as string;
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ export async function zendeskApiRequest(
|
|||||||
let credentials;
|
let credentials;
|
||||||
|
|
||||||
if (authenticationMethod === 'apiToken') {
|
if (authenticationMethod === 'apiToken') {
|
||||||
credentials = (await this.getCredentials('zendeskApi')) as { subdomain: string };
|
credentials = await this.getCredentials<{ subdomain: string }>('zendeskApi');
|
||||||
} else {
|
} else {
|
||||||
credentials = (await this.getCredentials('zendeskOAuth2Api')) as { subdomain: string };
|
credentials = await this.getCredentials<{ subdomain: string }>('zendeskOAuth2Api');
|
||||||
}
|
}
|
||||||
|
|
||||||
let options: IRequestOptions = {
|
let options: IRequestOptions = {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export interface IGetCredentials {
|
|||||||
get(type: string, id: string | null): Promise<ICredentialsEncrypted>;
|
get(type: string, id: string | null): Promise<ICredentialsEncrypted>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class ICredentials {
|
export abstract class ICredentials<T extends object = ICredentialDataDecryptedObject> {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
@@ -106,11 +106,11 @@ export abstract class ICredentials {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getData(nodeType?: string): ICredentialDataDecryptedObject;
|
abstract getData(nodeType?: string): T;
|
||||||
|
|
||||||
abstract getDataToSave(): ICredentialsEncrypted;
|
abstract getDataToSave(): ICredentialsEncrypted;
|
||||||
|
|
||||||
abstract setData(data: ICredentialDataDecryptedObject): void;
|
abstract setData(data: T): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUser {
|
export interface IUser {
|
||||||
@@ -128,11 +128,11 @@ export type ProjectSharingData = {
|
|||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ICredentialsDecrypted {
|
export interface ICredentialsDecrypted<T extends object = ICredentialDataDecryptedObject> {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
data?: ICredentialDataDecryptedObject;
|
data?: T;
|
||||||
homeProject?: ProjectSharingData;
|
homeProject?: ProjectSharingData;
|
||||||
sharedWithProjects?: ProjectSharingData[];
|
sharedWithProjects?: ProjectSharingData[];
|
||||||
}
|
}
|
||||||
@@ -718,7 +718,7 @@ export interface IExecuteWorkflowInfo {
|
|||||||
|
|
||||||
export type ICredentialTestFunction = (
|
export type ICredentialTestFunction = (
|
||||||
this: ICredentialTestFunctions,
|
this: ICredentialTestFunctions,
|
||||||
credential: ICredentialsDecrypted,
|
credential: ICredentialsDecrypted<ICredentialDataDecryptedObject>,
|
||||||
) => Promise<INodeCredentialTestResult>;
|
) => Promise<INodeCredentialTestResult>;
|
||||||
|
|
||||||
export interface ICredentialTestFunctions {
|
export interface ICredentialTestFunctions {
|
||||||
@@ -860,7 +860,10 @@ export type NodeTypeAndVersion = {
|
|||||||
|
|
||||||
export interface FunctionsBase {
|
export interface FunctionsBase {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
getCredentials(type: string, itemIndex?: number): Promise<ICredentialDataDecryptedObject>;
|
getCredentials<T extends object = ICredentialDataDecryptedObject>(
|
||||||
|
type: string,
|
||||||
|
itemIndex?: number,
|
||||||
|
): Promise<T>;
|
||||||
getCredentialsProperties(type: string): INodeProperties[];
|
getCredentialsProperties(type: string): INodeProperties[];
|
||||||
getExecutionId(): string;
|
getExecutionId(): string;
|
||||||
getNode(): INode;
|
getNode(): INode;
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ export class RoutingNode {
|
|||||||
credentials = credentialsDecrypted.data;
|
credentials = credentialsDecrypted.data;
|
||||||
} else if (credentialType) {
|
} else if (credentialType) {
|
||||||
try {
|
try {
|
||||||
credentials = (await executeFunctions.getCredentials(credentialType)) || {};
|
credentials =
|
||||||
|
(await executeFunctions.getCredentials<ICredentialDataDecryptedObject>(credentialType)) ||
|
||||||
|
{};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (
|
||||||
nodeType.description.credentials?.length &&
|
nodeType.description.credentials?.length &&
|
||||||
|
|||||||
Reference in New Issue
Block a user