Fix build issue with new interfaces

This commit is contained in:
Jan Oberhauser 2020-04-09 20:23:33 +02:00
parent 6f87895e00
commit be9474e84a
2 changed files with 20 additions and 21 deletions

View file

@ -24,7 +24,7 @@ export class Push {
this.channel.on('disconnect', (channel: string, res: express.Response) => { this.channel.on('disconnect', (channel: string, res: express.Response) => {
if (res.req !== undefined) { if (res.req !== undefined) {
delete this.connections[res.req.query.sessionId]; delete this.connections[res.req.query.sessionId as string];
} }
}); });
} }

View file

@ -62,6 +62,7 @@ import {
IDataObject, IDataObject,
INodeCredentials, INodeCredentials,
INodeTypeDescription, INodeTypeDescription,
INodeParameters,
INodePropertyOptions, INodePropertyOptions,
IRunData, IRunData,
Workflow, Workflow,
@ -226,7 +227,7 @@ class App {
return; return;
} }
this.push.add(req.query.sessionId, req, res); this.push.add(req.query.sessionId as string, req, res);
return; return;
} }
next(); next();
@ -363,10 +364,10 @@ class App {
if (req.query.url === undefined) { if (req.query.url === undefined) {
throw new ResponseHelper.ResponseError(`The parameter "url" is missing!`, undefined, 400); throw new ResponseHelper.ResponseError(`The parameter "url" is missing!`, undefined, 400);
} }
if (!req.query.url.match(/^http[s]?:\/\/.*\.json$/i)) { if (!(req.query.url as string).match(/^http[s]?:\/\/.*\.json$/i)) {
throw new ResponseHelper.ResponseError(`The parameter "url" is not valid! It does not seem to be a URL pointing to a n8n workflow JSON file.`, undefined, 400); throw new ResponseHelper.ResponseError(`The parameter "url" is not valid! It does not seem to be a URL pointing to a n8n workflow JSON file.`, undefined, 400);
} }
const data = await requestPromise.get(req.query.url); const data = await requestPromise.get(req.query.url as string);
let workflowData: IWorkflowResponse | undefined; let workflowData: IWorkflowResponse | undefined;
try { try {
@ -390,7 +391,7 @@ class App {
this.app.get('/rest/workflows', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IWorkflowShortResponse[]> => { this.app.get('/rest/workflows', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IWorkflowShortResponse[]> => {
const findQuery = {} as FindManyOptions; const findQuery = {} as FindManyOptions;
if (req.query.filter) { if (req.query.filter) {
findQuery.where = JSON.parse(req.query.filter); findQuery.where = JSON.parse(req.query.filter as string);
} }
// Return only the fields we need // Return only the fields we need
@ -555,13 +556,13 @@ class App {
// Returns parameter values which normally get loaded from an external API or // Returns parameter values which normally get loaded from an external API or
// get generated dynamically // get generated dynamically
this.app.get('/rest/node-parameter-options', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<INodePropertyOptions[]> => { this.app.get('/rest/node-parameter-options', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<INodePropertyOptions[]> => {
const nodeType = req.query.nodeType; const nodeType = req.query.nodeType as string;
let credentials: INodeCredentials | undefined = undefined; let credentials: INodeCredentials | undefined = undefined;
const currentNodeParameters = req.query.currentNodeParameters; const currentNodeParameters = req.query.currentNodeParameters as INodeParameters[];
if (req.query.credentials !== undefined) { if (req.query.credentials !== undefined) {
credentials = JSON.parse(req.query.credentials); credentials = JSON.parse(req.query.credentials as string);
} }
const methodName = req.query.methodName; const methodName = req.query.methodName as string;
const nodeTypes = NodeTypes(); const nodeTypes = NodeTypes();
@ -780,13 +781,9 @@ class App {
const findQuery = {} as FindManyOptions; const findQuery = {} as FindManyOptions;
// Make sure the variable has an expected value // Make sure the variable has an expected value
if (req.query.includeData === 'true') { const includeData = ['true', true].includes(req.query.includeData as string);
req.query.includeData = true;
} else {
req.query.includeData = false;
}
if (req.query.includeData !== true) { if (includeData !== true) {
// Return only the fields we need // Return only the fields we need
findQuery.select = ['id', 'name', 'type', 'nodesAccess', 'createdAt', 'updatedAt']; findQuery.select = ['id', 'name', 'type', 'nodesAccess', 'createdAt', 'updatedAt'];
} }
@ -798,7 +795,7 @@ class App {
} }
let encryptionKey = undefined; let encryptionKey = undefined;
if (req.query.includeData === true) { if (includeData === true) {
encryptionKey = await UserSettings.getEncryptionKey(); encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) { if (encryptionKey === undefined) {
throw new Error('No encryption key got found to decrypt the credentials!'); throw new Error('No encryption key got found to decrypt the credentials!');
@ -818,7 +815,7 @@ class App {
this.app.get('/rest/credentials', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<ICredentialsResponse[]> => { this.app.get('/rest/credentials', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<ICredentialsResponse[]> => {
const findQuery = {} as FindManyOptions; const findQuery = {} as FindManyOptions;
if (req.query.filter) { if (req.query.filter) {
findQuery.where = JSON.parse(req.query.filter); findQuery.where = JSON.parse(req.query.filter as string);
if ((findQuery.where! as IDataObject).id !== undefined) { if ((findQuery.where! as IDataObject).id !== undefined) {
// No idea if multiple where parameters make db search // No idea if multiple where parameters make db search
// slower but to be sure that that is not the case we // slower but to be sure that that is not the case we
@ -832,7 +829,9 @@ class App {
const results = await Db.collections.Credentials!.find(findQuery) as unknown as ICredentialsResponse[]; const results = await Db.collections.Credentials!.find(findQuery) as unknown as ICredentialsResponse[];
let encryptionKey = undefined; let encryptionKey = undefined;
if (req.query.includeData === true) {
const includeData = ['true', true].includes(req.query.includeData as string);
if (includeData === true) {
encryptionKey = await UserSettings.getEncryptionKey(); encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) { if (encryptionKey === undefined) {
throw new Error('No encryption key got found to decrypt the credentials!'); throw new Error('No encryption key got found to decrypt the credentials!');
@ -880,12 +879,12 @@ class App {
let filter: any = {}; // tslint:disable-line:no-any let filter: any = {}; // tslint:disable-line:no-any
if (req.query.filter) { if (req.query.filter) {
filter = JSON.parse(req.query.filter); filter = JSON.parse(req.query.filter as string);
} }
let limit = 20; let limit = 20;
if (req.query.limit) { if (req.query.limit) {
limit = parseInt(req.query.limit, 10); limit = parseInt(req.query.limit as string, 10);
} }
const countFilter = JSON.parse(JSON.stringify(filter)); const countFilter = JSON.parse(JSON.stringify(filter));
@ -1063,7 +1062,7 @@ class App {
let filter: any = {}; // tslint:disable-line:no-any let filter: any = {}; // tslint:disable-line:no-any
if (req.query.filter) { if (req.query.filter) {
filter = JSON.parse(req.query.filter); filter = JSON.parse(req.query.filter as string);
} }
for (const data of executingWorkflows) { for (const data of executingWorkflows) {