Merge branch 'add-codex-data' of github.com:n8n-io/n8n into PROD-819-nodes-panel-redesign

This commit is contained in:
Mutasem 2021-05-28 10:58:33 +03:00
commit 38b7d7ead1
3 changed files with 25 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import {
CodexSearchProperties,
INodeType,
INodeTypeData,
INodeTypes,
@ -25,7 +26,15 @@ class NodeTypesClass implements INodeTypes {
}
getAll(): INodeType[] {
return Object.values(this.nodeTypes).map((data) => data.type);
return Object.values(this.nodeTypes).map((data) => {
try {
data.type.description.codex = this.getCodexSearchProperties(data.sourcePath);
} catch (error) {
console.error(`No codex available for: ${data.sourcePath.split('/').pop()}`);
}
return data.type;
});
}
getByName(nodeType: string): INodeType | undefined {
@ -34,6 +43,15 @@ class NodeTypesClass implements INodeTypes {
}
return this.nodeTypes[nodeType].type;
}
getCodexSearchProperties(fullNodePath: string): CodexSearchProperties {
const codex = require(`${fullNodePath}on`); // .js to .json
return {
categories: codex.categories ?? [],
alias: codex.alias ?? [],
};
}
}

View file

@ -442,7 +442,6 @@ class App {
// Healthcheck
// ----------------------------------------
// Does very basic health check
this.app.get('/healthz', async (req: express.Request, res: express.Response) => {

View file

@ -566,6 +566,7 @@ export interface INodeTypeDescription {
deactivate?: INodeHookDescription[];
};
webhooks?: IWebhookDescription[];
codex?: CodexSearchProperties;
}
export interface INodeHookDescription {
@ -781,3 +782,8 @@ export interface IRawErrorObject {
export interface IStatusCodeMessages {
[key: string]: string;
}
export type CodexSearchProperties = {
categories: string[];
alias: string[];
};