mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
* introduce analytics * add user survey backend * add user survey backend * set answers on survey submit Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> * change name to personalization * lint Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> * N8n 2495 add personalization modal (#2280) * update modals * add onboarding modal * implement questions * introduce analytics * simplify impl * implement survey handling * add personalized cateogry * update modal behavior * add thank you view * handle empty cases * rename modal * standarize modal names * update image, add tags to headings * remove unused file * remove unused interfaces * clean up footer spacing * introduce analytics * refactor to fix bug * update endpoint * set min height * update stories * update naming from questions to survey * remove spacing after core categories * fix bug in logic * sort nodes * rename types * merge with be * rename userSurvey * clean up rest api * use constants for keys * use survey keys * clean up types * move personalization to its own file Co-authored-by: ahsan-virani <ahsan.virani@gmail.com> * Survey new options (#2300) * split up options * fix quotes * remove unused import * add user created workflow event (#2301) * simplify env vars * fix versionCli on FE * update personalization env * fix event User opened Credentials panel * fix select modal spacing * fix nodes panel event * fix workflow id in workflow execute event * improve telemetry error logging * fix config and stop process events * add flush call on n8n stop * ready for release * improve telemetry process exit * fix merge * improve n8n stop events Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
194 lines
6.3 KiB
TypeScript
194 lines
6.3 KiB
TypeScript
import Vue from 'vue';
|
|
import { parse } from 'flatted';
|
|
|
|
import { Method } from 'axios';
|
|
import {
|
|
IActivationError,
|
|
IExecutionsCurrentSummaryExtended,
|
|
IExecutionDeleteFilter,
|
|
IExecutionPushResponse,
|
|
IExecutionResponse,
|
|
IExecutionFlattedResponse,
|
|
IExecutionsListResponse,
|
|
IExecutionsStopData,
|
|
IStartRunData,
|
|
IWorkflowDb,
|
|
IWorkflowShortResponse,
|
|
IRestApi,
|
|
IWorkflowDataUpdate,
|
|
} from '@/Interface';
|
|
import {
|
|
IDataObject,
|
|
INodeCredentials,
|
|
INodeParameters,
|
|
INodePropertyOptions,
|
|
INodeTypeDescription,
|
|
INodeTypeNameVersion,
|
|
} from 'n8n-workflow';
|
|
import { makeRestApiRequest } from '@/api/helpers';
|
|
|
|
/**
|
|
* Unflattens the Execution data.
|
|
*
|
|
* @export
|
|
* @param {IExecutionFlattedResponse} fullExecutionData The data to unflatten
|
|
* @returns {IExecutionResponse}
|
|
*/
|
|
function unflattenExecutionData (fullExecutionData: IExecutionFlattedResponse): IExecutionResponse {
|
|
// Unflatten the data
|
|
const returnData: IExecutionResponse = {
|
|
...fullExecutionData,
|
|
workflowData: fullExecutionData.workflowData as IWorkflowDb,
|
|
data: parse(fullExecutionData.data),
|
|
};
|
|
|
|
returnData.finished = returnData.finished ? returnData.finished : false;
|
|
|
|
if (fullExecutionData.id) {
|
|
returnData.id = fullExecutionData.id;
|
|
}
|
|
|
|
return returnData;
|
|
}
|
|
|
|
export const restApi = Vue.extend({
|
|
methods: {
|
|
restApi (): IRestApi {
|
|
const self = this;
|
|
return {
|
|
async makeRestApiRequest (method: Method, endpoint: string, data?: IDataObject): Promise<any> { // tslint:disable-line:no-any
|
|
return makeRestApiRequest(self.$store.getters.getRestApiContext, method, endpoint, data);
|
|
},
|
|
getActiveWorkflows: (): Promise<string[]> => {
|
|
return self.restApi().makeRestApiRequest('GET', `/active`);
|
|
},
|
|
getActivationError: (id: string): Promise<IActivationError | undefined> => {
|
|
return self.restApi().makeRestApiRequest('GET', `/active/error/${id}`);
|
|
},
|
|
getCurrentExecutions: (filter: object): Promise<IExecutionsCurrentSummaryExtended[]> => {
|
|
let sendData = {};
|
|
if (filter) {
|
|
sendData = {
|
|
filter,
|
|
};
|
|
}
|
|
return self.restApi().makeRestApiRequest('GET', `/executions-current`, sendData);
|
|
},
|
|
stopCurrentExecution: (executionId: string): Promise<IExecutionsStopData> => {
|
|
return self.restApi().makeRestApiRequest('POST', `/executions-current/${executionId}/stop`);
|
|
},
|
|
|
|
// Returns all node-types
|
|
getNodeTypes: (onlyLatest = false): Promise<INodeTypeDescription[]> => {
|
|
return self.restApi().makeRestApiRequest('GET', `/node-types`, {onlyLatest});
|
|
},
|
|
|
|
getNodesInformation: (nodeInfos: INodeTypeNameVersion[]): Promise<INodeTypeDescription[]> => {
|
|
return self.restApi().makeRestApiRequest('POST', `/node-types`, {nodeInfos});
|
|
},
|
|
|
|
// Returns all the parameter options from the server
|
|
getNodeParameterOptions: (nodeTypeAndVersion: INodeTypeNameVersion, path: string, methodName: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials): Promise<INodePropertyOptions[]> => {
|
|
const sendData = {
|
|
nodeTypeAndVersion,
|
|
path,
|
|
methodName,
|
|
credentials,
|
|
currentNodeParameters,
|
|
};
|
|
return self.restApi().makeRestApiRequest('GET', '/node-parameter-options', sendData);
|
|
},
|
|
|
|
// Removes a test webhook
|
|
removeTestWebhook: (workflowId: string): Promise<boolean> => {
|
|
return self.restApi().makeRestApiRequest('DELETE', `/test-webhook/${workflowId}`);
|
|
},
|
|
|
|
// Execute a workflow
|
|
runWorkflow: async (startRunData: IStartRunData): Promise<IExecutionPushResponse> => {
|
|
return self.restApi().makeRestApiRequest('POST', `/workflows/run`, startRunData);
|
|
},
|
|
|
|
// Creates new credentials
|
|
createNewWorkflow: (sendData: IWorkflowDataUpdate): Promise<IWorkflowDb> => {
|
|
return self.restApi().makeRestApiRequest('POST', `/workflows`, sendData);
|
|
},
|
|
|
|
// Updates an existing workflow
|
|
updateWorkflow: (id: string, data: IWorkflowDataUpdate): Promise<IWorkflowDb> => {
|
|
return self.restApi().makeRestApiRequest('PATCH', `/workflows/${id}`, data);
|
|
},
|
|
|
|
// Deletes a workflow
|
|
deleteWorkflow: (name: string): Promise<void> => {
|
|
return self.restApi().makeRestApiRequest('DELETE', `/workflows/${name}`);
|
|
},
|
|
|
|
// Returns the workflow with the given name
|
|
getWorkflow: (id: string): Promise<IWorkflowDb> => {
|
|
return self.restApi().makeRestApiRequest('GET', `/workflows/${id}`);
|
|
},
|
|
|
|
// Returns all saved workflows
|
|
getWorkflows: (filter?: object): Promise<IWorkflowShortResponse[]> => {
|
|
let sendData;
|
|
if (filter) {
|
|
sendData = {
|
|
filter,
|
|
};
|
|
}
|
|
return self.restApi().makeRestApiRequest('GET', `/workflows`, sendData);
|
|
},
|
|
|
|
// Returns a workflow from a given URL
|
|
getWorkflowFromUrl: (url: string): Promise<IWorkflowDb> => {
|
|
return self.restApi().makeRestApiRequest('GET', `/workflows/from-url`, { url });
|
|
},
|
|
|
|
// Returns the execution with the given name
|
|
getExecution: async (id: string): Promise<IExecutionResponse> => {
|
|
const response = await self.restApi().makeRestApiRequest('GET', `/executions/${id}`);
|
|
return unflattenExecutionData(response);
|
|
},
|
|
|
|
// Deletes executions
|
|
deleteExecutions: (sendData: IExecutionDeleteFilter): Promise<void> => {
|
|
return self.restApi().makeRestApiRequest('POST', `/executions/delete`, sendData);
|
|
},
|
|
|
|
// Returns the execution with the given name
|
|
retryExecution: (id: string, loadWorkflow?: boolean): Promise<boolean> => {
|
|
let sendData;
|
|
if (loadWorkflow === true) {
|
|
sendData = {
|
|
loadWorkflow: true,
|
|
};
|
|
}
|
|
return self.restApi().makeRestApiRequest('POST', `/executions/${id}/retry`, sendData);
|
|
},
|
|
|
|
// Returns all saved executions
|
|
// TODO: For sure needs some kind of default filter like last day, with max 10 results, ...
|
|
getPastExecutions: (filter: object, limit: number, lastId?: string | number, firstId?: string | number): Promise<IExecutionsListResponse> => {
|
|
let sendData = {};
|
|
if (filter) {
|
|
sendData = {
|
|
filter,
|
|
firstId,
|
|
lastId,
|
|
limit,
|
|
};
|
|
}
|
|
|
|
return self.restApi().makeRestApiRequest('GET', `/executions`, sendData);
|
|
},
|
|
|
|
// Returns all the available timezones
|
|
getTimezones: (): Promise<IDataObject> => {
|
|
return self.restApi().makeRestApiRequest('GET', `/options/timezones`);
|
|
},
|
|
};
|
|
},
|
|
},
|
|
});
|