refactor(editor): Apply Prettier (no-changelog) (#4920)
* ⚡ Adjust `format` script * 🔥 Remove exemption for `editor-ui` * 🎨 Prettify * 👕 Fix lint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {IRestApiContext} from "@/Interface";
|
||||
import {makeRestApiRequest} from "@/utils";
|
||||
import { IRestApiContext } from '@/Interface';
|
||||
import { makeRestApiRequest } from '@/utils';
|
||||
|
||||
export function getApiKey(context: IRestApiContext): Promise<{ apiKey: string | null }> {
|
||||
return makeRestApiRequest(context, 'GET', '/me/api-key');
|
||||
|
||||
@@ -2,12 +2,17 @@ import { IRestApiContext } from '@/Interface';
|
||||
import { PublicInstalledPackage } from 'n8n-workflow';
|
||||
import { get, post, makeRestApiRequest } from '@/utils';
|
||||
|
||||
export async function getInstalledCommunityNodes(context: IRestApiContext): Promise<PublicInstalledPackage[]> {
|
||||
export async function getInstalledCommunityNodes(
|
||||
context: IRestApiContext,
|
||||
): Promise<PublicInstalledPackage[]> {
|
||||
const response = await get(context.baseUrl, '/nodes');
|
||||
return response.data || [];
|
||||
}
|
||||
|
||||
export async function installNewPackage(context: IRestApiContext, name: string): Promise<PublicInstalledPackage> {
|
||||
export async function installNewPackage(
|
||||
context: IRestApiContext,
|
||||
name: string,
|
||||
): Promise<PublicInstalledPackage> {
|
||||
return await post(context.baseUrl, '/nodes', { name });
|
||||
}
|
||||
|
||||
@@ -15,6 +20,9 @@ export async function uninstallPackage(context: IRestApiContext, name: string):
|
||||
return await makeRestApiRequest(context, 'DELETE', '/nodes', { name });
|
||||
}
|
||||
|
||||
export async function updatePackage(context: IRestApiContext, name: string): Promise<PublicInstalledPackage> {
|
||||
export async function updatePackage(
|
||||
context: IRestApiContext,
|
||||
name: string,
|
||||
): Promise<PublicInstalledPackage> {
|
||||
return await makeRestApiRequest(context, 'PATCH', '/nodes', { name });
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import {
|
||||
ICredentialsResponse,
|
||||
IRestApiContext,
|
||||
IShareCredentialsPayload,
|
||||
} from '@/Interface';
|
||||
import { ICredentialsResponse, IRestApiContext, IShareCredentialsPayload } from '@/Interface';
|
||||
import { makeRestApiRequest } from '@/utils';
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
|
||||
export async function setCredentialSharedWith(context: IRestApiContext, id: string, data: IShareCredentialsPayload): Promise<ICredentialsResponse> {
|
||||
return makeRestApiRequest(context, 'PUT', `/credentials/${id}/share`, data as unknown as IDataObject);
|
||||
export async function setCredentialSharedWith(
|
||||
context: IRestApiContext,
|
||||
id: string,
|
||||
data: IShareCredentialsPayload,
|
||||
): Promise<ICredentialsResponse> {
|
||||
return makeRestApiRequest(
|
||||
context,
|
||||
'PUT',
|
||||
`/credentials/${id}/share`,
|
||||
data as unknown as IDataObject,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ export async function getCredentialTypes(baseUrl: string): Promise<ICredentialTy
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getCredentialsNewName(context: IRestApiContext, name?: string): Promise<{name: string}> {
|
||||
export async function getCredentialsNewName(
|
||||
context: IRestApiContext,
|
||||
name?: string,
|
||||
): Promise<{ name: string }> {
|
||||
return await makeRestApiRequest(context, 'GET', '/credentials/new', name ? { name } : {});
|
||||
}
|
||||
|
||||
@@ -22,7 +25,10 @@ export async function getAllCredentials(context: IRestApiContext): Promise<ICred
|
||||
return await makeRestApiRequest(context, 'GET', '/credentials');
|
||||
}
|
||||
|
||||
export async function createNewCredential(context: IRestApiContext, data: ICredentialsDecrypted): Promise<ICredentialsResponse> {
|
||||
export async function createNewCredential(
|
||||
context: IRestApiContext,
|
||||
data: ICredentialsDecrypted,
|
||||
): Promise<ICredentialsResponse> {
|
||||
return makeRestApiRequest(context, 'POST', `/credentials`, data as unknown as IDataObject);
|
||||
}
|
||||
|
||||
@@ -30,26 +36,52 @@ export async function deleteCredential(context: IRestApiContext, id: string): Pr
|
||||
return makeRestApiRequest(context, 'DELETE', `/credentials/${id}`);
|
||||
}
|
||||
|
||||
export async function updateCredential(context: IRestApiContext, id: string, data: ICredentialsDecrypted): Promise<ICredentialsResponse> {
|
||||
export async function updateCredential(
|
||||
context: IRestApiContext,
|
||||
id: string,
|
||||
data: ICredentialsDecrypted,
|
||||
): Promise<ICredentialsResponse> {
|
||||
return makeRestApiRequest(context, 'PATCH', `/credentials/${id}`, data as unknown as IDataObject);
|
||||
}
|
||||
|
||||
export async function getCredentialData(context: IRestApiContext, id: string): Promise<ICredentialsDecryptedResponse | ICredentialsResponse | undefined> {
|
||||
export async function getCredentialData(
|
||||
context: IRestApiContext,
|
||||
id: string,
|
||||
): Promise<ICredentialsDecryptedResponse | ICredentialsResponse | undefined> {
|
||||
return makeRestApiRequest(context, 'GET', `/credentials/${id}`, {
|
||||
includeData: true,
|
||||
});
|
||||
}
|
||||
|
||||
// Get OAuth1 Authorization URL using the stored credentials
|
||||
export async function oAuth1CredentialAuthorize(context: IRestApiContext, data: ICredentialsResponse): Promise<string> {
|
||||
return makeRestApiRequest(context, 'GET', `/oauth1-credential/auth`, data as unknown as IDataObject);
|
||||
export async function oAuth1CredentialAuthorize(
|
||||
context: IRestApiContext,
|
||||
data: ICredentialsResponse,
|
||||
): Promise<string> {
|
||||
return makeRestApiRequest(
|
||||
context,
|
||||
'GET',
|
||||
`/oauth1-credential/auth`,
|
||||
data as unknown as IDataObject,
|
||||
);
|
||||
}
|
||||
|
||||
// Get OAuth2 Authorization URL using the stored credentials
|
||||
export async function oAuth2CredentialAuthorize(context: IRestApiContext, data: ICredentialsResponse): Promise<string> {
|
||||
return makeRestApiRequest(context, 'GET', `/oauth2-credential/auth`, data as unknown as IDataObject);
|
||||
export async function oAuth2CredentialAuthorize(
|
||||
context: IRestApiContext,
|
||||
data: ICredentialsResponse,
|
||||
): Promise<string> {
|
||||
return makeRestApiRequest(
|
||||
context,
|
||||
'GET',
|
||||
`/oauth2-credential/auth`,
|
||||
data as unknown as IDataObject,
|
||||
);
|
||||
}
|
||||
|
||||
export async function testCredential(context: IRestApiContext, data: INodeCredentialTestRequest): Promise<INodeCredentialTestResult> {
|
||||
export async function testCredential(
|
||||
context: IRestApiContext,
|
||||
data: INodeCredentialTestRequest,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
return makeRestApiRequest(context, 'POST', '/credentials/test', data as unknown as IDataObject);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import {CurlToJSONResponse, IRestApiContext} from "@/Interface";
|
||||
import {makeRestApiRequest} from "@/utils";
|
||||
import { CurlToJSONResponse, IRestApiContext } from '@/Interface';
|
||||
import { makeRestApiRequest } from '@/utils';
|
||||
|
||||
export function getCurlToJson(context: IRestApiContext, curlCommand: string): Promise<CurlToJSONResponse> {
|
||||
export function getCurlToJson(
|
||||
context: IRestApiContext,
|
||||
curlCommand: string,
|
||||
): Promise<CurlToJSONResponse> {
|
||||
return makeRestApiRequest(context, 'POST', '/curl-to-json', { curlCommand });
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ export async function getNodesInformation(
|
||||
export async function getNodeParameterOptions(
|
||||
context: IRestApiContext,
|
||||
sendData: {
|
||||
nodeTypeAndVersion: INodeTypeNameVersion,
|
||||
path: string,
|
||||
methodName?: string,
|
||||
loadOptions?: ILoadOptions,
|
||||
currentNodeParameters: INodeParameters,
|
||||
credentials?: INodeCredentials,
|
||||
nodeTypeAndVersion: INodeTypeNameVersion;
|
||||
path: string;
|
||||
methodName?: string;
|
||||
loadOptions?: ILoadOptions;
|
||||
currentNodeParameters: INodeParameters;
|
||||
credentials?: INodeCredentials;
|
||||
},
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
return makeRestApiRequest(context, 'GET', '/node-parameter-options', sendData);
|
||||
@@ -52,5 +52,10 @@ export async function getResourceLocatorResults(
|
||||
context: IRestApiContext,
|
||||
sendData: IResourceLocatorReqParams,
|
||||
): Promise<INodeListSearchResult> {
|
||||
return makeRestApiRequest(context, 'GET', '/nodes-list-search', sendData as unknown as IDataObject);
|
||||
return makeRestApiRequest(
|
||||
context,
|
||||
'GET',
|
||||
'/nodes-list-search',
|
||||
sendData as unknown as IDataObject,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,55 @@
|
||||
import { IRestApiContext, IN8nPrompts, IN8nValueSurveyData, IN8nUISettings, IN8nPromptResponse } from '../Interface';
|
||||
import {
|
||||
IRestApiContext,
|
||||
IN8nPrompts,
|
||||
IN8nValueSurveyData,
|
||||
IN8nUISettings,
|
||||
IN8nPromptResponse,
|
||||
} from '../Interface';
|
||||
import { makeRestApiRequest, get, post } from '@/utils';
|
||||
import { N8N_IO_BASE_URL, NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@/constants';
|
||||
import { N8N_IO_BASE_URL, NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@/constants';
|
||||
|
||||
export function getSettings(context: IRestApiContext): Promise<IN8nUISettings> {
|
||||
return makeRestApiRequest(context, 'GET', '/settings');
|
||||
}
|
||||
|
||||
export async function getPromptsData(instanceId: string, userId: string): Promise<IN8nPrompts> {
|
||||
return await get(N8N_IO_BASE_URL, '/prompts', {}, {'n8n-instance-id': instanceId, 'n8n-user-id': userId});
|
||||
return await get(
|
||||
N8N_IO_BASE_URL,
|
||||
'/prompts',
|
||||
{},
|
||||
{ 'n8n-instance-id': instanceId, 'n8n-user-id': userId },
|
||||
);
|
||||
}
|
||||
|
||||
export async function submitContactInfo(instanceId: string, userId: string, email: string): Promise<IN8nPromptResponse> {
|
||||
return await post(N8N_IO_BASE_URL, '/prompt', { email }, {'n8n-instance-id': instanceId, 'n8n-user-id': userId});
|
||||
export async function submitContactInfo(
|
||||
instanceId: string,
|
||||
userId: string,
|
||||
email: string,
|
||||
): Promise<IN8nPromptResponse> {
|
||||
return await post(
|
||||
N8N_IO_BASE_URL,
|
||||
'/prompt',
|
||||
{ email },
|
||||
{ 'n8n-instance-id': instanceId, 'n8n-user-id': userId },
|
||||
);
|
||||
}
|
||||
|
||||
export async function submitValueSurvey(instanceId: string, userId: string, params: IN8nValueSurveyData): Promise<IN8nPromptResponse> {
|
||||
return await post(N8N_IO_BASE_URL, '/value-survey', params, {'n8n-instance-id': instanceId, 'n8n-user-id': userId});
|
||||
export async function submitValueSurvey(
|
||||
instanceId: string,
|
||||
userId: string,
|
||||
params: IN8nValueSurveyData,
|
||||
): Promise<IN8nPromptResponse> {
|
||||
return await post(N8N_IO_BASE_URL, '/value-survey', params, {
|
||||
'n8n-instance-id': instanceId,
|
||||
'n8n-user-id': userId,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAvailableCommunityPackageCount(): Promise<number> {
|
||||
const response = await get(NPM_COMMUNITY_NODE_SEARCH_API_URL, 'search?q=keywords:n8n-community-node-package');
|
||||
const response = await get(
|
||||
NPM_COMMUNITY_NODE_SEARCH_API_URL,
|
||||
'search?q=keywords:n8n-community-node-package',
|
||||
);
|
||||
|
||||
return response.total || 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,11 @@ export async function createTag(context: IRestApiContext, params: { name: string
|
||||
return await makeRestApiRequest(context, 'POST', '/tags', params);
|
||||
}
|
||||
|
||||
export async function updateTag(context: IRestApiContext, id: string, params: { name: string }): Promise<ITag> {
|
||||
export async function updateTag(
|
||||
context: IRestApiContext,
|
||||
id: string,
|
||||
params: { name: string },
|
||||
): Promise<ITag> {
|
||||
return await makeRestApiRequest(context, 'PATCH', `/tags/${id}`, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import { ITemplatesCategory, ITemplatesCollection, ITemplatesQuery, ITemplatesWorkflow, ITemplatesCollectionResponse, ITemplatesWorkflowResponse, IWorkflowTemplate } from '@/Interface';
|
||||
import {
|
||||
ITemplatesCategory,
|
||||
ITemplatesCollection,
|
||||
ITemplatesQuery,
|
||||
ITemplatesWorkflow,
|
||||
ITemplatesCollectionResponse,
|
||||
ITemplatesWorkflowResponse,
|
||||
IWorkflowTemplate,
|
||||
} from '@/Interface';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { get } from '@/utils';
|
||||
|
||||
@@ -10,30 +18,64 @@ export function testHealthEndpoint(apiEndpoint: string) {
|
||||
return get(apiEndpoint, '/health');
|
||||
}
|
||||
|
||||
export function getCategories(apiEndpoint: string, headers?: IDataObject): Promise<{categories: ITemplatesCategory[]}> {
|
||||
export function getCategories(
|
||||
apiEndpoint: string,
|
||||
headers?: IDataObject,
|
||||
): Promise<{ categories: ITemplatesCategory[] }> {
|
||||
return get(apiEndpoint, '/templates/categories', undefined, headers);
|
||||
}
|
||||
|
||||
export async function getCollections(apiEndpoint: string, query: ITemplatesQuery, headers?: IDataObject): Promise<{collections: ITemplatesCollection[]}> {
|
||||
return await get(apiEndpoint, '/templates/collections', {category: stringifyArray(query.categories || []), search: query.search}, headers);
|
||||
export async function getCollections(
|
||||
apiEndpoint: string,
|
||||
query: ITemplatesQuery,
|
||||
headers?: IDataObject,
|
||||
): Promise<{ collections: ITemplatesCollection[] }> {
|
||||
return await get(
|
||||
apiEndpoint,
|
||||
'/templates/collections',
|
||||
{ category: stringifyArray(query.categories || []), search: query.search },
|
||||
headers,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getWorkflows(
|
||||
apiEndpoint: string,
|
||||
query: {skip: number, limit: number, categories: number[], search: string},
|
||||
query: { skip: number; limit: number; categories: number[]; search: string },
|
||||
headers?: IDataObject,
|
||||
): Promise<{totalWorkflows: number, workflows: ITemplatesWorkflow[]}> {
|
||||
return get(apiEndpoint, '/templates/workflows', {skip: query.skip, rows: query.limit, category: stringifyArray(query.categories), search: query.search}, headers);
|
||||
): Promise<{ totalWorkflows: number; workflows: ITemplatesWorkflow[] }> {
|
||||
return get(
|
||||
apiEndpoint,
|
||||
'/templates/workflows',
|
||||
{
|
||||
skip: query.skip,
|
||||
rows: query.limit,
|
||||
category: stringifyArray(query.categories),
|
||||
search: query.search,
|
||||
},
|
||||
headers,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCollectionById(apiEndpoint: string, collectionId: string, headers?: IDataObject): Promise<{collection: ITemplatesCollectionResponse}> {
|
||||
export async function getCollectionById(
|
||||
apiEndpoint: string,
|
||||
collectionId: string,
|
||||
headers?: IDataObject,
|
||||
): Promise<{ collection: ITemplatesCollectionResponse }> {
|
||||
return await get(apiEndpoint, `/templates/collections/${collectionId}`, undefined, headers);
|
||||
}
|
||||
|
||||
export async function getTemplateById(apiEndpoint: string, templateId: string, headers?: IDataObject): Promise<{workflow: ITemplatesWorkflowResponse}> {
|
||||
export async function getTemplateById(
|
||||
apiEndpoint: string,
|
||||
templateId: string,
|
||||
headers?: IDataObject,
|
||||
): Promise<{ workflow: ITemplatesWorkflowResponse }> {
|
||||
return await get(apiEndpoint, `/templates/workflows/${templateId}`, undefined, headers);
|
||||
}
|
||||
|
||||
export async function getWorkflowTemplate(apiEndpoint: string, templateId: string, headers?: IDataObject): Promise<IWorkflowTemplate> {
|
||||
export async function getWorkflowTemplate(
|
||||
apiEndpoint: string,
|
||||
templateId: string,
|
||||
headers?: IDataObject,
|
||||
): Promise<IWorkflowTemplate> {
|
||||
return await get(apiEndpoint, `/workflows/templates/${templateId}`, undefined, headers);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { IInviteResponse, IPersonalizationLatestVersion, IRestApiContext, IUserResponse } from '@/Interface';
|
||||
import {
|
||||
IInviteResponse,
|
||||
IPersonalizationLatestVersion,
|
||||
IRestApiContext,
|
||||
IUserResponse,
|
||||
} from '@/Interface';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { makeRestApiRequest } from '@/utils';
|
||||
|
||||
@@ -10,7 +15,10 @@ export function getCurrentUser(context: IRestApiContext): Promise<IUserResponse
|
||||
return makeRestApiRequest(context, 'GET', '/me');
|
||||
}
|
||||
|
||||
export function login(context: IRestApiContext, params: {email: string, password: string}): Promise<IUserResponse> {
|
||||
export function login(
|
||||
context: IRestApiContext,
|
||||
params: { email: string; password: string },
|
||||
): Promise<IUserResponse> {
|
||||
return makeRestApiRequest(context, 'POST', '/login', params);
|
||||
}
|
||||
|
||||
@@ -18,7 +26,10 @@ export async function logout(context: IRestApiContext): Promise<void> {
|
||||
await makeRestApiRequest(context, 'POST', '/logout');
|
||||
}
|
||||
|
||||
export function setupOwner(context: IRestApiContext, params: { firstName: string; lastName: string; email: string; password: string;}): Promise<IUserResponse> {
|
||||
export function setupOwner(
|
||||
context: IRestApiContext,
|
||||
params: { firstName: string; lastName: string; email: string; password: string },
|
||||
): Promise<IUserResponse> {
|
||||
return makeRestApiRequest(context, 'POST', '/owner', params as unknown as IDataObject);
|
||||
}
|
||||
|
||||
@@ -26,36 +37,71 @@ export function skipOwnerSetup(context: IRestApiContext): Promise<void> {
|
||||
return makeRestApiRequest(context, 'POST', '/owner/skip-setup');
|
||||
}
|
||||
|
||||
export function validateSignupToken(context: IRestApiContext, params: {inviterId: string; inviteeId: string}): Promise<{inviter: {firstName: string, lastName: string}}> {
|
||||
export function validateSignupToken(
|
||||
context: IRestApiContext,
|
||||
params: { inviterId: string; inviteeId: string },
|
||||
): Promise<{ inviter: { firstName: string; lastName: string } }> {
|
||||
return makeRestApiRequest(context, 'GET', '/resolve-signup-token', params);
|
||||
}
|
||||
|
||||
export function signup(context: IRestApiContext, params: {inviterId: string; inviteeId: string; firstName: string; lastName: string; password: string}): Promise<IUserResponse> {
|
||||
export function signup(
|
||||
context: IRestApiContext,
|
||||
params: {
|
||||
inviterId: string;
|
||||
inviteeId: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
password: string;
|
||||
},
|
||||
): Promise<IUserResponse> {
|
||||
const { inviteeId, ...props } = params;
|
||||
return makeRestApiRequest(context, 'POST', `/users/${params.inviteeId}`, props as unknown as IDataObject);
|
||||
return makeRestApiRequest(
|
||||
context,
|
||||
'POST',
|
||||
`/users/${params.inviteeId}`,
|
||||
props as unknown as IDataObject,
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendForgotPasswordEmail(context: IRestApiContext, params: {email: string}): Promise<void> {
|
||||
export async function sendForgotPasswordEmail(
|
||||
context: IRestApiContext,
|
||||
params: { email: string },
|
||||
): Promise<void> {
|
||||
await makeRestApiRequest(context, 'POST', '/forgot-password', params);
|
||||
}
|
||||
|
||||
export async function validatePasswordToken(context: IRestApiContext, params: {token: string, userId: string}): Promise<void> {
|
||||
export async function validatePasswordToken(
|
||||
context: IRestApiContext,
|
||||
params: { token: string; userId: string },
|
||||
): Promise<void> {
|
||||
await makeRestApiRequest(context, 'GET', '/resolve-password-token', params);
|
||||
}
|
||||
|
||||
export async function changePassword(context: IRestApiContext, params: {token: string, password: string, userId: string}): Promise<void> {
|
||||
export async function changePassword(
|
||||
context: IRestApiContext,
|
||||
params: { token: string; password: string; userId: string },
|
||||
): Promise<void> {
|
||||
await makeRestApiRequest(context, 'POST', '/change-password', params);
|
||||
}
|
||||
|
||||
export function updateCurrentUser(context: IRestApiContext, params: {id: string, firstName: string, lastName: string, email: string}): Promise<IUserResponse> {
|
||||
export function updateCurrentUser(
|
||||
context: IRestApiContext,
|
||||
params: { id: string; firstName: string; lastName: string; email: string },
|
||||
): Promise<IUserResponse> {
|
||||
return makeRestApiRequest(context, 'PATCH', `/me`, params as unknown as IDataObject);
|
||||
}
|
||||
|
||||
export function updateCurrentUserPassword(context: IRestApiContext, params: {newPassword: string, currentPassword: string}): Promise<void> {
|
||||
export function updateCurrentUserPassword(
|
||||
context: IRestApiContext,
|
||||
params: { newPassword: string; currentPassword: string },
|
||||
): Promise<void> {
|
||||
return makeRestApiRequest(context, 'PATCH', `/me/password`, params);
|
||||
}
|
||||
|
||||
export async function deleteUser(context: IRestApiContext, {id, transferId}: {id: string, transferId?: string}): Promise<void> {
|
||||
export async function deleteUser(
|
||||
context: IRestApiContext,
|
||||
{ id, transferId }: { id: string; transferId?: string },
|
||||
): Promise<void> {
|
||||
await makeRestApiRequest(context, 'DELETE', `/users/${id}`, transferId ? { transferId } : {});
|
||||
}
|
||||
|
||||
@@ -63,14 +109,20 @@ export function getUsers(context: IRestApiContext): Promise<IUserResponse[]> {
|
||||
return makeRestApiRequest(context, 'GET', '/users');
|
||||
}
|
||||
|
||||
export function inviteUsers(context: IRestApiContext, params: Array<{email: string}>): Promise<IInviteResponse[]> {
|
||||
export function inviteUsers(
|
||||
context: IRestApiContext,
|
||||
params: Array<{ email: string }>,
|
||||
): Promise<IInviteResponse[]> {
|
||||
return makeRestApiRequest(context, 'POST', '/users', params as unknown as IDataObject);
|
||||
}
|
||||
|
||||
export async function reinvite(context: IRestApiContext, {id}: {id: string}): Promise<void> {
|
||||
export async function reinvite(context: IRestApiContext, { id }: { id: string }): Promise<void> {
|
||||
await makeRestApiRequest(context, 'POST', `/users/${id}/reinvite`);
|
||||
}
|
||||
|
||||
export async function submitPersonalizationSurvey(context: IRestApiContext, params: IPersonalizationLatestVersion): Promise<void> {
|
||||
export async function submitPersonalizationSurvey(
|
||||
context: IRestApiContext,
|
||||
params: IPersonalizationLatestVersion,
|
||||
): Promise<void> {
|
||||
await makeRestApiRequest(context, 'POST', '/me/survey', params as unknown as IDataObject);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ import { IVersion } from '@/Interface';
|
||||
import { INSTANCE_ID_HEADER } from '@/constants';
|
||||
import { get } from '@/utils';
|
||||
|
||||
export async function getNextVersions(endpoint: string, version: string, instanceId: string): Promise<IVersion[]> {
|
||||
const headers = {[INSTANCE_ID_HEADER as string] : instanceId};
|
||||
export async function getNextVersions(
|
||||
endpoint: string,
|
||||
version: string,
|
||||
instanceId: string,
|
||||
): Promise<IVersion[]> {
|
||||
const headers = { [INSTANCE_ID_HEADER as string]: instanceId };
|
||||
return await get(endpoint, version, {}, headers);
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
import { IOnboardingCallPrompt, IOnboardingCallPromptResponse, IUser } from "@/Interface";
|
||||
import { get, post } from "@/utils";
|
||||
import { IOnboardingCallPrompt, IOnboardingCallPromptResponse, IUser } from '@/Interface';
|
||||
import { get, post } from '@/utils';
|
||||
|
||||
const N8N_API_BASE_URL = 'https://api.n8n.io/api';
|
||||
const ONBOARDING_PROMPTS_ENDPOINT = '/prompts/onboarding';
|
||||
const CONTACT_EMAIL_SUBMISSION_ENDPOINT = '/accounts/onboarding';
|
||||
|
||||
export async function fetchNextOnboardingPrompt(instanceId: string, currentUer: IUser): Promise<IOnboardingCallPrompt> {
|
||||
return await get(
|
||||
N8N_API_BASE_URL,
|
||||
ONBOARDING_PROMPTS_ENDPOINT,
|
||||
{
|
||||
instance_id: instanceId,
|
||||
user_id: `${instanceId}#${currentUer.id}`,
|
||||
is_owner: currentUer.isOwner,
|
||||
survey_results: currentUer.personalizationAnswers,
|
||||
},
|
||||
);
|
||||
export async function fetchNextOnboardingPrompt(
|
||||
instanceId: string,
|
||||
currentUer: IUser,
|
||||
): Promise<IOnboardingCallPrompt> {
|
||||
return await get(N8N_API_BASE_URL, ONBOARDING_PROMPTS_ENDPOINT, {
|
||||
instance_id: instanceId,
|
||||
user_id: `${instanceId}#${currentUer.id}`,
|
||||
is_owner: currentUer.isOwner,
|
||||
survey_results: currentUer.personalizationAnswers,
|
||||
});
|
||||
}
|
||||
|
||||
export async function applyForOnboardingCall(instanceId: string, currentUer: IUser, email: string): Promise<string> {
|
||||
export async function applyForOnboardingCall(
|
||||
instanceId: string,
|
||||
currentUer: IUser,
|
||||
email: string,
|
||||
): Promise<string> {
|
||||
try {
|
||||
const response = await post(
|
||||
N8N_API_BASE_URL,
|
||||
ONBOARDING_PROMPTS_ENDPOINT,
|
||||
{
|
||||
instance_id: instanceId,
|
||||
user_id: `${instanceId}#${currentUer.id}`,
|
||||
email,
|
||||
},
|
||||
);
|
||||
const response = await post(N8N_API_BASE_URL, ONBOARDING_PROMPTS_ENDPOINT, {
|
||||
instance_id: instanceId,
|
||||
user_id: `${instanceId}#${currentUer.id}`,
|
||||
email,
|
||||
});
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
export async function submitEmailOnSignup(instanceId: string, currentUer: IUser, email: string | undefined, agree: boolean): Promise<string> {
|
||||
return await post(
|
||||
N8N_API_BASE_URL,
|
||||
CONTACT_EMAIL_SUBMISSION_ENDPOINT,
|
||||
{
|
||||
instance_id: instanceId,
|
||||
user_id: `${instanceId}#${currentUer.id}`,
|
||||
email,
|
||||
agree,
|
||||
},
|
||||
);
|
||||
export async function submitEmailOnSignup(
|
||||
instanceId: string,
|
||||
currentUer: IUser,
|
||||
email: string | undefined,
|
||||
agree: boolean,
|
||||
): Promise<string> {
|
||||
return await post(N8N_API_BASE_URL, CONTACT_EMAIL_SUBMISSION_ENDPOINT, {
|
||||
instance_id: instanceId,
|
||||
user_id: `${instanceId}#${currentUer.id}`,
|
||||
email,
|
||||
agree,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import {
|
||||
IRestApiContext,
|
||||
IShareWorkflowsPayload,
|
||||
IWorkflowsShareResponse,
|
||||
} from '@/Interface';
|
||||
import { IRestApiContext, IShareWorkflowsPayload, IWorkflowsShareResponse } from '@/Interface';
|
||||
import { makeRestApiRequest } from '@/utils';
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
|
||||
export async function setWorkflowSharedWith(context: IRestApiContext, id: string, data: IShareWorkflowsPayload): Promise<IWorkflowsShareResponse> {
|
||||
return makeRestApiRequest(context, 'PUT', `/workflows/${id}/share`, data as unknown as IDataObject);
|
||||
export async function setWorkflowSharedWith(
|
||||
context: IRestApiContext,
|
||||
id: string,
|
||||
data: IShareWorkflowsPayload,
|
||||
): Promise<IWorkflowsShareResponse> {
|
||||
return makeRestApiRequest(
|
||||
context,
|
||||
'PUT',
|
||||
`/workflows/${id}/share`,
|
||||
data as unknown as IDataObject,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user