@lokalise/harmony 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/harmony.cjs +1 -1
- package/dist/harmony.mjs +923 -506
- package/dist/types/src/components/Sidebar/Sidebar.d.ts +5 -2
- package/dist/types/src/components/Sidebar/Widgets/Avatar/Avatar.d.ts +3 -0
- package/dist/types/src/components/Sidebar/Widgets/IconLink/IconLink.d.ts +3 -0
- package/dist/types/src/components/Sidebar/Widgets/Menu/Menu.d.ts +3 -0
- package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/ProfileMenu.d.ts +4 -0
- package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/ProfileSettingsMenuItem/ProfileSettingsMenuItem.d.ts +4 -0
- package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/TeamMenuItem/TeamMenuItem.d.ts +5 -0
- package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/TeamSwitch/TeamSwitch.d.ts +3 -0
- package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/UpgradeMenuItem/UpgradeMenuItem.d.ts +5 -0
- package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/types.d.ts +1 -0
- package/dist/types/src/features/auth/backend/services/getAuthenticatedSessionDetailFromRequest.d.ts +10 -0
- package/dist/types/src/features/auth/backend/services/getAuthenticatedSessionPayloadFromRequest.test.d.ts +1 -0
- package/dist/types/src/features/auth/core/jwtTokenPayload.d.ts +7 -0
- package/dist/types/src/features/auth/core/jwtTokenPayload.test.d.ts +1 -0
- package/dist/types/src/features/auth/core/lokaliseAuthAddon.d.ts +14 -0
- package/dist/types/src/features/auth/core/middleware/jwtAuthMiddleware.d.ts +13 -0
- package/dist/types/src/features/auth/core/middleware/jwtAuthMiddleware.test.d.ts +1 -0
- package/dist/types/src/features/auth/core/middleware/publicApiHeadersMiddleware.d.ts +5 -0
- package/dist/types/src/features/auth/core/types/jwtTokenPayload.d.ts +42 -0
- package/dist/types/src/features/auth/core/types/jwtTokenPayload.fixture.d.ts +27 -0
- package/dist/types/src/features/auth/core/utils/makeAuthHeader.d.ts +2 -0
- package/dist/types/src/features/auth/core/utils/makeAuthHeader.test.d.ts +1 -0
- package/dist/types/src/features/auth/frontend/addon/lokaliseAuthBrowserAddon.d.ts +35 -0
- package/dist/types/src/features/auth/frontend/events/NewJwtIssuedEvent.d.ts +20 -0
- package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedProjectContributor.d.ts +28 -0
- package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedSessionPayload.d.ts +18 -0
- package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedUser.d.ts +18 -0
- package/dist/types/src/features/auth/frontend/hooks/useGetPromotedClassicSessionJwtQuery.d.ts +12 -0
- package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.d.ts +14 -0
- package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.test.d.ts +1 -0
- package/dist/types/src/features/auth/frontend/utils/cookieTokenUtils.d.ts +4 -0
- package/dist/types/src/features/auth/frontend/utils/cookieTokenUtils.test.d.ts +1 -0
- package/dist/types/src/features/auth/node.d.ts +9 -0
- package/dist/types/src/features/node.d.ts +2 -0
- package/dist/types/src/features/publicApi/contributors.d.ts +111 -0
- package/dist/types/src/features/publicApi/hooks/useCreateProjectMutation.d.ts +76 -0
- package/dist/types/src/features/publicApi/hooks/useGetTeamUsersQuery.d.ts +26 -0
- package/dist/types/src/features/publicApi/hooks/useGetUserTokenQuery.d.ts +20 -0
- package/dist/types/src/features/publicApi/hooks/useListProjectsQuery.d.ts +81 -0
- package/dist/types/src/features/publicApi/hooks/useRetrieveContributorQuery.d.ts +34 -0
- package/dist/types/src/features/publicApi/hooks/useRetrieveProjectQuery.d.ts +72 -0
- package/dist/types/src/features/publicApi/node.d.ts +16 -0
- package/dist/types/src/features/publicApi/projects.d.ts +1132 -0
- package/dist/types/src/features/publicApi/teamUsers.d.ts +61 -0
- package/dist/types/src/features/publicApi/types/contributorTypes.d.ts +171 -0
- package/dist/types/src/features/publicApi/types/languageTypes.d.ts +29 -0
- package/dist/types/src/features/publicApi/types/projectTypes.d.ts +1061 -0
- package/dist/types/src/features/publicApi/types/teamRoleTypes.d.ts +3 -0
- package/dist/types/src/features/publicApi/types/teamUserTypes.d.ts +70 -0
- package/dist/types/src/features/publicApi/types/userTokenTypes.d.ts +26 -0
- package/dist/types/src/features/publicApi/userToken.d.ts +35 -0
- package/dist/types/src/node.d.ts +3 -1
- package/dist/types/src/utils/testing/createMockFactoryWithDefaults.d.ts +2 -0
- package/dist/types/src/utils/testing/createMockFactoryWithDefaults.test.d.ts +1 -0
- package/dist/types/src/utils/testing/deepOverride.d.ts +4 -0
- package/dist/types/src/utils/testing/deepOverride.test.d.ts +1 -0
- package/dist/types/src/utils/types/apiMutationOverrides.d.ts +2 -0
- package/dist/types/src/utils/types/apiQueryOverrides.d.ts +2 -0
- package/package.json +35 -19
@@ -2,10 +2,13 @@ import { HTMLProps, PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
type SidebarProps = HTMLProps<HTMLElement> & {
|
3
3
|
children: ReactNode;
|
4
4
|
};
|
5
|
+
/**
|
6
|
+
* Sidebar is a self-contained component using widgets.
|
7
|
+
*/
|
5
8
|
declare const Sidebar: {
|
6
9
|
({ children, ...navProps }: SidebarProps): import("react/jsx-runtime").JSX.Element;
|
7
|
-
Top({ children }: PropsWithChildren)
|
8
|
-
Bottom({ children }: PropsWithChildren)
|
10
|
+
Top: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
11
|
+
Bottom: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
9
12
|
Avatar: ({ src, href, ariaLabel, alt }: {
|
10
13
|
src: string;
|
11
14
|
href?: string;
|
@@ -5,5 +5,8 @@ type IconLinkProps = {
|
|
5
5
|
label: string;
|
6
6
|
icon: FC<SvgIconProps>;
|
7
7
|
};
|
8
|
+
/**
|
9
|
+
* Display link with an icon. Mainly used in the top section
|
10
|
+
*/
|
8
11
|
export declare const IconLink: ({ label, to, icon: Icon }: IconLinkProps) => import("react/jsx-runtime").JSX.Element;
|
9
12
|
export {};
|
@@ -3,5 +3,8 @@ import { FC, PropsWithChildren } from 'react';
|
|
3
3
|
type MenuProps = PropsWithChildren<{
|
4
4
|
icon: FC<SvgIconProps>;
|
5
5
|
}>;
|
6
|
+
/**
|
7
|
+
* Use this widget for simple side menu. Currently utilised for `Help` section
|
8
|
+
*/
|
6
9
|
export declare const Menu: ({ children, icon: Icon }: MenuProps) => import("react/jsx-runtime").JSX.Element;
|
7
10
|
export {};
|
@@ -4,5 +4,9 @@ type ProfileMenuProps = {
|
|
4
4
|
config: SidebarProfileMenuConfig;
|
5
5
|
children: ProfileMenuContentProps['children'];
|
6
6
|
};
|
7
|
+
/**
|
8
|
+
* Contextual component, requires initial configuration
|
9
|
+
* and works with internal widgets
|
10
|
+
*/
|
7
11
|
export declare const ProfileMenu: ({ config, children }: ProfileMenuProps) => import("react/jsx-runtime").JSX.Element;
|
8
12
|
export {};
|
@@ -4,5 +4,9 @@ type ProfileSettingsMenuItemProps = {
|
|
4
4
|
onClick?: () => void;
|
5
5
|
hideBottomDivider?: boolean;
|
6
6
|
};
|
7
|
+
/**
|
8
|
+
* Menu item that comes with a small user's email and renders conditionally,
|
9
|
+
* only if team is not suspended or is not at the end of a trial
|
10
|
+
*/
|
7
11
|
export declare const ProfileSettingsMenuItem: ({ href, onClick, userEmail, hideBottomDivider, }: ProfileSettingsMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
8
12
|
export {};
|
package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/TeamMenuItem/TeamMenuItem.d.ts
CHANGED
@@ -4,5 +4,10 @@ type TeamMenuItemProps = {
|
|
4
4
|
onClick?: (team: SidebarTeam) => void;
|
5
5
|
hidePlanLabel?: boolean;
|
6
6
|
};
|
7
|
+
/**
|
8
|
+
* Uses context of current team, and depending on ability to switch team or not,
|
9
|
+
* it renders as a div or clickable MenuItem. If used with TeamSwitch, it triggers `onSwitchTeams`
|
10
|
+
* callback, passing relevant team as an argument
|
11
|
+
*/
|
7
12
|
export declare const TeamMenuItem: ({ team, onClick, hidePlanLabel }: TeamMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
8
13
|
export {};
|
@@ -2,5 +2,8 @@ import { SidebarTeam } from '../../../types';
|
|
2
2
|
type TeamSwitchProps = {
|
3
3
|
onSwitchTeam: (team: SidebarTeam) => void;
|
4
4
|
};
|
5
|
+
/**
|
6
|
+
* Uses available teams (other than current) and allows user to switch between them
|
7
|
+
*/
|
5
8
|
export declare const TeamSwitch: ({ onSwitchTeam }: TeamSwitchProps) => import("react/jsx-runtime").JSX.Element | null;
|
6
9
|
export {};
|
package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/UpgradeMenuItem/UpgradeMenuItem.d.ts
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
type UpgradeMenuItemProps = {
|
2
2
|
upgradeOptionHref: string;
|
3
3
|
};
|
4
|
+
/**
|
5
|
+
* Menu item conditionally rendering only if `showUpgradeButton` is `true`.
|
6
|
+
* It renders correct upgrade note depending on the current team plan
|
7
|
+
* and red arrow up to indicate an update option.
|
8
|
+
*/
|
4
9
|
export declare const UpgradeMenuItem: ({ upgradeOptionHref }: UpgradeMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
5
10
|
export {};
|
package/dist/types/src/features/auth/backend/services/getAuthenticatedSessionDetailFromRequest.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import { JwtTokenPayload } from '../../core/types/jwtTokenPayload';
|
2
|
+
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
3
|
+
type AuthenticatedSessionDetail = JwtToken & {
|
4
|
+
payload: JwtTokenPayload;
|
5
|
+
};
|
6
|
+
/**
|
7
|
+
* Returns the JWT tokens and parses the attached payload.
|
8
|
+
*/
|
9
|
+
export declare function getAuthenticatedSessionDetailFromRequest(): AuthenticatedSessionDetail | undefined;
|
10
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Wretch, WretchAddon } from 'wretch/types';
|
2
|
+
import { JwtAuthProps } from './middleware/jwtAuthMiddleware';
|
3
|
+
export interface LokaliseAuthAddon {
|
4
|
+
/**
|
5
|
+
* Add authentication and automatic token refresh to Lokalise requests.
|
6
|
+
*/
|
7
|
+
lokaliseAuth<T extends LokaliseAuthAddon>(this: T & Wretch<T>, props: JwtAuthProps): this;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Addon for Lokalise authentication.
|
11
|
+
* This will expose a method that can be used to authenticate requests to Lokalise.
|
12
|
+
* It will also handle refreshing the token when it expires.
|
13
|
+
*/
|
14
|
+
export declare const LokaliseAuthAddon: WretchAddon<LokaliseAuthAddon>;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
2
|
+
import { ConfiguredMiddleware, Wretch } from 'wretch';
|
3
|
+
export type JwtAuthProps = {
|
4
|
+
/**
|
5
|
+
* This function should return the current JWT token if it exists.
|
6
|
+
*/
|
7
|
+
getCachedJwtToken: () => Promise<JwtToken | undefined>;
|
8
|
+
/**
|
9
|
+
* This function is called when a new JWT token is issued or if/when the token is refreshed.
|
10
|
+
*/
|
11
|
+
onNewJwtTokenIssued?: (jwtToken: JwtToken) => Promise<void>;
|
12
|
+
};
|
13
|
+
export declare function jwtAuthMiddleware<T>(client: Wretch<T>, props: JwtAuthProps): ConfiguredMiddleware;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
export declare const JWT_TOKEN_PAYLOAD_SCHEMA: z.ZodObject<{
|
3
|
+
userId: z.ZodNumber;
|
4
|
+
userUuid: z.ZodString;
|
5
|
+
teamId: z.ZodNumber;
|
6
|
+
userTeamRole: z.ZodUnion<[z.ZodLiteral<"owner">, z.ZodLiteral<"admin">, z.ZodLiteral<"biller">, z.ZodLiteral<"member">]>;
|
7
|
+
userEmail: z.ZodString;
|
8
|
+
userName: z.ZodString;
|
9
|
+
userCurrentTeamId: z.ZodNumber;
|
10
|
+
planId: z.ZodNumber;
|
11
|
+
planName: z.ZodString;
|
12
|
+
isProviderAlpha: z.ZodBoolean;
|
13
|
+
isFullyAuthenticated: z.ZodBoolean;
|
14
|
+
exp: z.ZodNumber;
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
16
|
+
isProviderAlpha: boolean;
|
17
|
+
isFullyAuthenticated: boolean;
|
18
|
+
planId: number;
|
19
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
20
|
+
userEmail: string;
|
21
|
+
teamId: number;
|
22
|
+
userId: number;
|
23
|
+
userUuid: string;
|
24
|
+
userName: string;
|
25
|
+
userCurrentTeamId: number;
|
26
|
+
planName: string;
|
27
|
+
exp: number;
|
28
|
+
}, {
|
29
|
+
isProviderAlpha: boolean;
|
30
|
+
isFullyAuthenticated: boolean;
|
31
|
+
planId: number;
|
32
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
33
|
+
userEmail: string;
|
34
|
+
teamId: number;
|
35
|
+
userId: number;
|
36
|
+
userUuid: string;
|
37
|
+
userName: string;
|
38
|
+
userCurrentTeamId: number;
|
39
|
+
planName: string;
|
40
|
+
exp: number;
|
41
|
+
}>;
|
42
|
+
export type JwtTokenPayload = z.infer<typeof JWT_TOKEN_PAYLOAD_SCHEMA>;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
export declare const createMockJwtTokenPayload: (overrides?: {
|
2
|
+
isProviderAlpha?: boolean | undefined;
|
3
|
+
isFullyAuthenticated?: boolean | undefined;
|
4
|
+
planId?: number | undefined;
|
5
|
+
userTeamRole?: "member" | "admin" | "biller" | "owner" | undefined;
|
6
|
+
userEmail?: string | undefined;
|
7
|
+
teamId?: number | undefined;
|
8
|
+
userId?: number | undefined;
|
9
|
+
userUuid?: string | undefined;
|
10
|
+
userName?: string | undefined;
|
11
|
+
userCurrentTeamId?: number | undefined;
|
12
|
+
planName?: string | undefined;
|
13
|
+
exp?: number | undefined;
|
14
|
+
} | undefined, removeProperties?: ("isProviderAlpha" | "isFullyAuthenticated" | "planId" | "userTeamRole" | "userEmail" | "teamId" | "userId" | "userUuid" | "userName" | "userCurrentTeamId" | "planName" | "exp")[]) => {
|
15
|
+
isProviderAlpha: boolean;
|
16
|
+
isFullyAuthenticated: boolean;
|
17
|
+
planId: number;
|
18
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
19
|
+
userEmail: string;
|
20
|
+
teamId: number;
|
21
|
+
userId: number;
|
22
|
+
userUuid: string;
|
23
|
+
userName: string;
|
24
|
+
userCurrentTeamId: number;
|
25
|
+
planName: string;
|
26
|
+
exp: number;
|
27
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { Wretch, WretchAddon } from 'wretch/types';
|
2
|
+
import { JwtAuthProps } from '../../core/middleware/jwtAuthMiddleware';
|
3
|
+
import { PromoteAuthProps } from '../middleware/promoteClassicSessionToJwtMiddleware';
|
4
|
+
type BrowserJwtAuthProps = Omit<JwtAuthProps, 'getCachedJwtToken'> & {
|
5
|
+
/**
|
6
|
+
* The browser implementation makes this optional, as it can be inferred from the cookie.
|
7
|
+
* You can still provide a custom implementation if you want to.
|
8
|
+
*/
|
9
|
+
getCachedJwtToken?: JwtAuthProps['getCachedJwtToken'];
|
10
|
+
};
|
11
|
+
type BrowserPromoteAuthProps = Omit<PromoteAuthProps, 'getCachedJwtToken' | 'getCsrfToken'> & {
|
12
|
+
/**
|
13
|
+
* The browser implementation makes this optional, as it can be inferred from the cookie.
|
14
|
+
* You can still provide a custom implementation if you want to.
|
15
|
+
*/
|
16
|
+
getCachedJwtToken?: PromoteAuthProps['getCachedJwtToken'];
|
17
|
+
/**
|
18
|
+
* The browser implementation makes this optional, as it can be inferred from the cookie.
|
19
|
+
* You can still provide a custom implementation if you want to.
|
20
|
+
*/
|
21
|
+
getCsrfToken?: PromoteAuthProps['getCsrfToken'];
|
22
|
+
};
|
23
|
+
export interface LokaliseAuthBrowserAddon {
|
24
|
+
lokaliseAuth<T extends LokaliseAuthBrowserAddon>(this: T & Wretch<T>, props?: BrowserJwtAuthProps): this;
|
25
|
+
promoteClassicSession<T extends LokaliseAuthBrowserAddon>(this: T & Wretch<T>, props: BrowserPromoteAuthProps): this;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* A browser implementation of the LokaliseAuthAddon.
|
29
|
+
* This implementation provides default providers that uses cookies to retrieve the JWT token.
|
30
|
+
*
|
31
|
+
* It exposes another utility method to automatically promote a classic session to a JWT session
|
32
|
+
* when a request is made from an environment using class CSRF PHP token authentication.
|
33
|
+
*/
|
34
|
+
export declare const LokaliseAuthBrowserAddon: WretchAddon<LokaliseAuthBrowserAddon>;
|
35
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { JwtTokenPayload } from '../../core/types/jwtTokenPayload';
|
2
|
+
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
3
|
+
type NewJwtIssuedEventDetail = {
|
4
|
+
token: JwtToken;
|
5
|
+
payload: JwtTokenPayload | undefined;
|
6
|
+
};
|
7
|
+
/**
|
8
|
+
* This event is emitted when a new JWT token is issued or refreshed.
|
9
|
+
*/
|
10
|
+
export declare class NewJwtIssuedEvent extends CustomEvent<NewJwtIssuedEventDetail> {
|
11
|
+
static readonly eventName: "new-jwt-issued";
|
12
|
+
constructor(token: JwtToken);
|
13
|
+
}
|
14
|
+
export declare const isNewJwtIssuedEvent: (event: Event) => event is NewJwtIssuedEvent;
|
15
|
+
declare global {
|
16
|
+
interface WindowEventMap {
|
17
|
+
[NewJwtIssuedEvent.eventName]: NewJwtIssuedEvent;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
export {};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
/**
|
3
|
+
* Uses the payload attached to the JWT to request the contributor information
|
4
|
+
* of the provided project for the authenticated user.
|
5
|
+
* This required an active JWT token to be present in the cookie.
|
6
|
+
*
|
7
|
+
* @param wretchClient - Wretch instance configured to a public API instance.
|
8
|
+
* @param projectId - The ID of the project to retrieve the contributor information.
|
9
|
+
*/
|
10
|
+
export declare function useAuthenticatedProjectContributor<T>(wretchClient: Wretch<T>, projectId: string): import('@tanstack/react-query').UseQueryResult<{
|
11
|
+
contributors: {
|
12
|
+
email: string;
|
13
|
+
user_id: number;
|
14
|
+
fullname: string;
|
15
|
+
created_at: string;
|
16
|
+
created_at_timestamp: number;
|
17
|
+
admin_rights: string[];
|
18
|
+
languages: {
|
19
|
+
lang_id: number;
|
20
|
+
lang_iso: string;
|
21
|
+
lang_name: string;
|
22
|
+
is_writable: 0 | 1;
|
23
|
+
}[];
|
24
|
+
is_admin: boolean;
|
25
|
+
is_reviewer: boolean;
|
26
|
+
}[];
|
27
|
+
project_id: string;
|
28
|
+
}, undefined>;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* A hook that will bring the cached JWT token into the React lifecycle.
|
3
|
+
* If the token is updated or removed, the hook will update the state.
|
4
|
+
*/
|
5
|
+
export declare function useAuthenticatedSessionPayload(): {
|
6
|
+
isProviderAlpha: boolean;
|
7
|
+
isFullyAuthenticated: boolean;
|
8
|
+
planId: number;
|
9
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
10
|
+
userEmail: string;
|
11
|
+
teamId: number;
|
12
|
+
userId: number;
|
13
|
+
userUuid: string;
|
14
|
+
userName: string;
|
15
|
+
userCurrentTeamId: number;
|
16
|
+
planName: string;
|
17
|
+
exp: number;
|
18
|
+
} | undefined;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
/**
|
3
|
+
* Uses the payload attached to the JWT to request the team-user information for the authenticated user.
|
4
|
+
* This required an active JWT token to be present in the cookie.
|
5
|
+
*
|
6
|
+
* @param wretchClient - Wretch instance configured to a public API instance.
|
7
|
+
*/
|
8
|
+
export declare function useAuthenticatedUser<T>(wretchClient: Wretch<T>): import('@tanstack/react-query').UseQueryResult<{
|
9
|
+
team_id: number;
|
10
|
+
team_user: {
|
11
|
+
role: "member" | "admin" | "biller" | "owner";
|
12
|
+
email: string;
|
13
|
+
user_id: number;
|
14
|
+
fullname: string;
|
15
|
+
created_at: string;
|
16
|
+
created_at_timestamp: number;
|
17
|
+
};
|
18
|
+
}, undefined>;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
/**
|
3
|
+
* For use in environments that are authenticated with a classic CSRF PHP session (e.g. Expert).
|
4
|
+
* This hook will send that token to the public API, upgrade to a JWT session.
|
5
|
+
*
|
6
|
+
* @param wretchClient - Wretch instance configured to a public API instance.
|
7
|
+
* @param teamId - The team ID to get the JWT for.
|
8
|
+
*/
|
9
|
+
export declare function useGetPromotedClassicSessionJwtQuery<T>(wretchClient: Wretch<T>, teamId: number): import('@tanstack/react-query').UseQueryResult<{
|
10
|
+
accessToken: string;
|
11
|
+
refreshToken: string;
|
12
|
+
}, undefined>;
|
package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.d.ts
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ConfiguredMiddleware, Wretch } from 'wretch';
|
2
|
+
import { JwtAuthProps } from '../../core/middleware/jwtAuthMiddleware';
|
3
|
+
export type PromoteAuthProps = JwtAuthProps & {
|
4
|
+
/**
|
5
|
+
* Team ID is required to issue a new JWT token.
|
6
|
+
*/
|
7
|
+
getTeamId: () => Promise<number>;
|
8
|
+
/**
|
9
|
+
* The current CSRF token is required to issue a new JWT token.
|
10
|
+
* So this function should return the CSRF token for the current session.
|
11
|
+
*/
|
12
|
+
getCsrfToken: () => Promise<string | undefined>;
|
13
|
+
};
|
14
|
+
export declare function promoteClassicSessionToJwtMiddleware<T>(client: Wretch<T>, props: PromoteAuthProps): ConfiguredMiddleware;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
2
|
+
export declare function getJwtTokenFromCookie(): JwtToken | undefined;
|
3
|
+
export declare function getCsrfTokenFromCookie(): string | undefined;
|
4
|
+
export declare function getCookie(cookies: string, name: string): string | undefined;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from './frontend/hooks/useGetPromotedClassicSessionJwtQuery';
|
2
|
+
export * from './frontend/hooks/useAuthenticatedSessionPayload';
|
3
|
+
export * from './frontend/hooks/useAuthenticatedUser';
|
4
|
+
export * from './frontend/hooks/useAuthenticatedProjectContributor';
|
5
|
+
export * from './backend/services/getAuthenticatedSessionDetailFromRequest';
|
6
|
+
export { parseJwtTokenPayload } from './core/jwtTokenPayload';
|
7
|
+
export { publicApiHeadersMiddleware } from './core/middleware/publicApiHeadersMiddleware';
|
8
|
+
export { LokaliseAuthAddon } from './core/lokaliseAuthAddon';
|
9
|
+
export { LokaliseAuthBrowserAddon } from './frontend/addon/lokaliseAuthBrowserAddon';
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
/**
|
3
|
+
* Public API router definition for retrieving a project contributor
|
4
|
+
*/
|
5
|
+
export declare const retrieveContributor: import('@lokalise/universal-ts-utils/node').GetRouteDefinition<{
|
6
|
+
projectId: string;
|
7
|
+
contributorId: number;
|
8
|
+
}, z.ZodObject<{
|
9
|
+
project_id: z.ZodString;
|
10
|
+
contributors: z.ZodArray<z.ZodObject<{
|
11
|
+
user_id: z.ZodNumber;
|
12
|
+
email: z.ZodString;
|
13
|
+
fullname: z.ZodString;
|
14
|
+
created_at: z.ZodString;
|
15
|
+
created_at_timestamp: z.ZodNumber;
|
16
|
+
admin_rights: z.ZodArray<z.ZodString, "many">;
|
17
|
+
languages: z.ZodArray<z.ZodObject<{
|
18
|
+
lang_id: z.ZodNumber;
|
19
|
+
lang_iso: z.ZodString;
|
20
|
+
lang_name: z.ZodString;
|
21
|
+
is_writable: z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>;
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
23
|
+
lang_id: number;
|
24
|
+
lang_iso: string;
|
25
|
+
lang_name: string;
|
26
|
+
is_writable: 0 | 1;
|
27
|
+
}, {
|
28
|
+
lang_id: number;
|
29
|
+
lang_iso: string;
|
30
|
+
lang_name: string;
|
31
|
+
is_writable: 0 | 1;
|
32
|
+
}>, "many">;
|
33
|
+
is_admin: z.ZodBoolean;
|
34
|
+
is_reviewer: z.ZodBoolean;
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
36
|
+
email: string;
|
37
|
+
user_id: number;
|
38
|
+
fullname: string;
|
39
|
+
created_at: string;
|
40
|
+
created_at_timestamp: number;
|
41
|
+
admin_rights: string[];
|
42
|
+
languages: {
|
43
|
+
lang_id: number;
|
44
|
+
lang_iso: string;
|
45
|
+
lang_name: string;
|
46
|
+
is_writable: 0 | 1;
|
47
|
+
}[];
|
48
|
+
is_admin: boolean;
|
49
|
+
is_reviewer: boolean;
|
50
|
+
}, {
|
51
|
+
email: string;
|
52
|
+
user_id: number;
|
53
|
+
fullname: string;
|
54
|
+
created_at: string;
|
55
|
+
created_at_timestamp: number;
|
56
|
+
admin_rights: string[];
|
57
|
+
languages: {
|
58
|
+
lang_id: number;
|
59
|
+
lang_iso: string;
|
60
|
+
lang_name: string;
|
61
|
+
is_writable: 0 | 1;
|
62
|
+
}[];
|
63
|
+
is_admin: boolean;
|
64
|
+
is_reviewer: boolean;
|
65
|
+
}>, "many">;
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
67
|
+
contributors: {
|
68
|
+
email: string;
|
69
|
+
user_id: number;
|
70
|
+
fullname: string;
|
71
|
+
created_at: string;
|
72
|
+
created_at_timestamp: number;
|
73
|
+
admin_rights: string[];
|
74
|
+
languages: {
|
75
|
+
lang_id: number;
|
76
|
+
lang_iso: string;
|
77
|
+
lang_name: string;
|
78
|
+
is_writable: 0 | 1;
|
79
|
+
}[];
|
80
|
+
is_admin: boolean;
|
81
|
+
is_reviewer: boolean;
|
82
|
+
}[];
|
83
|
+
project_id: string;
|
84
|
+
}, {
|
85
|
+
contributors: {
|
86
|
+
email: string;
|
87
|
+
user_id: number;
|
88
|
+
fullname: string;
|
89
|
+
created_at: string;
|
90
|
+
created_at_timestamp: number;
|
91
|
+
admin_rights: string[];
|
92
|
+
languages: {
|
93
|
+
lang_id: number;
|
94
|
+
lang_iso: string;
|
95
|
+
lang_name: string;
|
96
|
+
is_writable: 0 | 1;
|
97
|
+
}[];
|
98
|
+
is_admin: boolean;
|
99
|
+
is_reviewer: boolean;
|
100
|
+
}[];
|
101
|
+
project_id: string;
|
102
|
+
}>, z.ZodObject<{
|
103
|
+
projectId: z.ZodString;
|
104
|
+
contributorId: z.ZodNumber;
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
106
|
+
projectId: string;
|
107
|
+
contributorId: number;
|
108
|
+
}, {
|
109
|
+
projectId: string;
|
110
|
+
contributorId: number;
|
111
|
+
}>, undefined, undefined, false, false>;
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import { ApiMutationOverrides } from '../../../utils/types/apiMutationOverrides';
|
2
|
+
import { Wretch } from 'wretch';
|
3
|
+
import { CreateProjectRequestBody, Project } from '../types/projectTypes';
|
4
|
+
/**
|
5
|
+
* A react-router wrapper about the createProject public API endpoint
|
6
|
+
*
|
7
|
+
* @param wretchClient - Wretch instance configured to a public API instance.
|
8
|
+
* @param overrides - Additional options to pass to the query.
|
9
|
+
*/
|
10
|
+
export declare function useCreateProjectMutation<T>(wretchClient: Wretch<T>, overrides?: ApiMutationOverrides<Project, CreateProjectRequestBody>): import('@tanstack/react-query').UseMutationResult<{
|
11
|
+
name: string;
|
12
|
+
created_at: string;
|
13
|
+
created_at_timestamp: number;
|
14
|
+
team_id: number;
|
15
|
+
description: string;
|
16
|
+
project_id: string;
|
17
|
+
uuid: string;
|
18
|
+
project_type: "localization_files" | "paged_documents" | "marketing";
|
19
|
+
created_by: number;
|
20
|
+
created_by_email: string;
|
21
|
+
base_language_id: number;
|
22
|
+
base_language_iso: string;
|
23
|
+
settings: {
|
24
|
+
per_platform_key_names: boolean;
|
25
|
+
reviewing: boolean;
|
26
|
+
auto_toggle_unverified: boolean;
|
27
|
+
offline_translation: boolean;
|
28
|
+
key_editing: boolean;
|
29
|
+
inline_machine_translations: boolean;
|
30
|
+
custom_translation_statuses: boolean;
|
31
|
+
custom_translation_statuses_allow_multiple: boolean;
|
32
|
+
segmentation: boolean;
|
33
|
+
contributor_preview_download_enabled: boolean;
|
34
|
+
};
|
35
|
+
statistics: {
|
36
|
+
team: number;
|
37
|
+
languages: {
|
38
|
+
progress: number;
|
39
|
+
language_id: number;
|
40
|
+
language_iso: string;
|
41
|
+
words_to_do: number;
|
42
|
+
}[];
|
43
|
+
progress_total: number;
|
44
|
+
keys_total: number;
|
45
|
+
base_words: number;
|
46
|
+
qa_issues_total: number;
|
47
|
+
qa_issues: {
|
48
|
+
not_reviewed: number;
|
49
|
+
unverified: number;
|
50
|
+
spelling_grammar: number;
|
51
|
+
inconsistent_placeholders: number;
|
52
|
+
inconsistent_html: number;
|
53
|
+
different_number_of_urls: number;
|
54
|
+
different_urls: number;
|
55
|
+
leading_whitespace: number;
|
56
|
+
trailing_whitespace: number;
|
57
|
+
different_number_of_email_address: number;
|
58
|
+
different_email_address: number;
|
59
|
+
different_brackets: number;
|
60
|
+
different_numbers: number;
|
61
|
+
double_space: number;
|
62
|
+
special_placeholder: number;
|
63
|
+
unbalanced_brackets: number;
|
64
|
+
};
|
65
|
+
};
|
66
|
+
}, undefined, {
|
67
|
+
name: string;
|
68
|
+
team_id: string;
|
69
|
+
languages: {
|
70
|
+
lang_iso: string;
|
71
|
+
custom_iso?: string | undefined;
|
72
|
+
}[];
|
73
|
+
project_type: "localization_files" | "paged_documents" | "marketing";
|
74
|
+
base_lang_iso: string;
|
75
|
+
is_segmentation_enabled: boolean;
|
76
|
+
}, undefined>;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { TeamUserResponse } from '../types/teamUserTypes';
|
2
|
+
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
3
|
+
import { Wretch } from 'wretch/types';
|
4
|
+
/**
|
5
|
+
* Factory for generating the query key for the getTeamUser public API endpoint
|
6
|
+
*/
|
7
|
+
export declare const getTeamUsersQueryKey: {
|
8
|
+
teamUserKey: (teamId: number, userId: number) => readonly ["GetTeamUsers", number, number];
|
9
|
+
};
|
10
|
+
/**
|
11
|
+
* A react-router wrapper about the getTeamUser public API endpoint
|
12
|
+
*
|
13
|
+
* @param wretchClient - Wretch instance configured to a public API instance.
|
14
|
+
* @param overrides - Additional options to pass to the query.
|
15
|
+
*/
|
16
|
+
export declare const useGetTeamUsersQuery: <T>(wretchClient: Wretch<T>, overrides: ApiQueryOverrides<TeamUserResponse, typeof getTeamUsersQueryKey>) => import('@tanstack/react-query').UseQueryResult<{
|
17
|
+
team_id: number;
|
18
|
+
team_user: {
|
19
|
+
role: "member" | "admin" | "biller" | "owner";
|
20
|
+
email: string;
|
21
|
+
user_id: number;
|
22
|
+
fullname: string;
|
23
|
+
created_at: string;
|
24
|
+
created_at_timestamp: number;
|
25
|
+
};
|
26
|
+
}, undefined>;
|