mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-10 20:37:29 -08:00
26a20ed47e
* feat(editor): roll out schema view * feat(editor): add posthog tracking * refactor: use composables * refactor: clean up console log * refactor: clean up impl * chore: clean up impl * fix: fix demo var * chore: add comment * refactor: clean up * chore: wrap error func * refactor: clean up import * refactor: make store * feat: enable rudderstack usebeacon, move event to unload * chore: clean up alert * refactor: move tracking from hooks * fix: reload flags on login * fix: add func to setup * fix: clear duplicate import * chore: add console to tesT * chore: add console to tesT * fix: try reload * chore: randomize instnace id for testing * chore: randomize instnace id for testing * chore: add console logs for testing * chore: move random id to fe * chore: use query param for testing * feat: update PostHog api endpoint * feat: update rs host * feat: update rs host * feat: update rs endpoints * refactor: use api host for BE events as well * refactor: refactor out posthog client * feat: add feature flags to login * feat: add feature flags to login * feat: get feature flags to work * feat: add created at to be events * chore: add todos * chore: clean up store * chore: add created at to identify * feat: add posthog config to settings * feat: add bootstrapping * chore: clean up * chore: fix build * fix: get dates to work * fix: get posthog to recognize dates * chore: refactor * fix: update back to number * fix: update key * fix: get experiment evals to work * feat: add posthog to signup router * feat: add feature flags on sign up * chore: clean up * fix: fix import * chore: clean up loading script * feat: add timeout, fix: script loader * fix: test timeout and get working on 8080 * refactor: move out posthog * feat: add experiment tracking * fix: clear tracked on reset * fix: fix signup bug * fix: handle errors when telmetry is disabled * refactor: remove redundant await * fix: add back posthog to telemetry * test: fix test * test: fix test * test: add tests for posthog client * lint: fix * fix: fix issue with slow decide endpoint * lint: fix * lint: fix * lint: fix * lint: fix * chore: address PR feedback * chore: address PR feedback * feat: add onboarding experiment
139 lines
4.1 KiB
TypeScript
139 lines
4.1 KiB
TypeScript
import {
|
|
CurrentUserResponse,
|
|
IInviteResponse,
|
|
IPersonalizationLatestVersion,
|
|
IRestApiContext,
|
|
IUserResponse,
|
|
} from '@/Interface';
|
|
import { IDataObject } from 'n8n-workflow';
|
|
import { makeRestApiRequest } from '@/utils/apiUtils';
|
|
|
|
export function loginCurrentUser(context: IRestApiContext): Promise<CurrentUserResponse | null> {
|
|
return makeRestApiRequest(context, 'GET', '/login');
|
|
}
|
|
|
|
export function login(
|
|
context: IRestApiContext,
|
|
params: { email: string; password: string },
|
|
): Promise<CurrentUserResponse> {
|
|
return makeRestApiRequest(context, 'POST', '/login', params);
|
|
}
|
|
|
|
export async function logout(context: IRestApiContext): Promise<void> {
|
|
await makeRestApiRequest(context, 'POST', '/logout');
|
|
}
|
|
|
|
export function preOwnerSetup(
|
|
context: IRestApiContext,
|
|
): Promise<{ credentials: number; workflows: number }> {
|
|
return makeRestApiRequest(context, 'GET', '/owner/pre-setup');
|
|
}
|
|
|
|
export function setupOwner(
|
|
context: IRestApiContext,
|
|
params: { firstName: string; lastName: string; email: string; password: string },
|
|
): Promise<IUserResponse> {
|
|
return makeRestApiRequest(context, 'POST', '/owner/setup', params as unknown as IDataObject);
|
|
}
|
|
|
|
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 } }> {
|
|
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<CurrentUserResponse> {
|
|
const { inviteeId, ...props } = params;
|
|
return makeRestApiRequest(
|
|
context,
|
|
'POST',
|
|
`/users/${params.inviteeId}`,
|
|
props as unknown as IDataObject,
|
|
);
|
|
}
|
|
|
|
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> {
|
|
await makeRestApiRequest(context, 'GET', '/resolve-password-token', params);
|
|
}
|
|
|
|
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> {
|
|
return makeRestApiRequest(context, 'PATCH', '/me', params as unknown as IDataObject);
|
|
}
|
|
|
|
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> {
|
|
await makeRestApiRequest(context, 'DELETE', `/users/${id}`, transferId ? { transferId } : {});
|
|
}
|
|
|
|
export function getUsers(context: IRestApiContext): Promise<IUserResponse[]> {
|
|
return makeRestApiRequest(context, 'GET', '/users');
|
|
}
|
|
|
|
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> {
|
|
await makeRestApiRequest(context, 'POST', `/users/${id}/reinvite`);
|
|
}
|
|
|
|
export async function getInviteLink(
|
|
context: IRestApiContext,
|
|
{ id }: { id: string },
|
|
): Promise<{ link: string }> {
|
|
return await makeRestApiRequest(context, 'GET', `/users/${id}/invite-link`);
|
|
}
|
|
|
|
export async function submitPersonalizationSurvey(
|
|
context: IRestApiContext,
|
|
params: IPersonalizationLatestVersion,
|
|
): Promise<void> {
|
|
await makeRestApiRequest(context, 'POST', '/me/survey', params as unknown as IDataObject);
|
|
}
|