@sito/dashboard-app 0.0.1
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/LICENSE +21 -0
- package/README.md +60 -0
- package/dist/components/Actions/Action.d.ts +3 -0
- package/dist/components/Actions/Actions.d.ts +3 -0
- package/dist/components/Actions/ActionsDropdown.d.ts +3 -0
- package/dist/components/Actions/index.d.ts +4 -0
- package/dist/components/Actions/types.d.ts +14 -0
- package/dist/components/Buttons/Button.d.ts +2 -0
- package/dist/components/Buttons/IconButton.d.ts +2 -0
- package/dist/components/Buttons/ToTop.d.ts +1 -0
- package/dist/components/Buttons/index.d.ts +3 -0
- package/dist/components/Buttons/types.d.ts +12 -0
- package/dist/components/Chip/Chip.d.ts +7 -0
- package/dist/components/Chip/DeletableChip.d.ts +2 -0
- package/dist/components/Chip/index.d.ts +3 -0
- package/dist/components/Chip/types.d.ts +12 -0
- package/dist/components/Dialog/ConfirmationDialog.d.ts +2 -0
- package/dist/components/Dialog/Dialog.d.ts +2 -0
- package/dist/components/Dialog/FormDialog.d.ts +3 -0
- package/dist/components/Dialog/index.d.ts +4 -0
- package/dist/components/Dialog/types.d.ts +18 -0
- package/dist/components/Drawer/Drawer.d.ts +2 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Drawer/types.d.ts +6 -0
- package/dist/components/Dropdown/Dropdown.d.ts +2 -0
- package/dist/components/Dropdown/index.d.ts +2 -0
- package/dist/components/Dropdown/types.d.ts +6 -0
- package/dist/components/Empty/Empty.d.ts +3 -0
- package/dist/components/Empty/index.d.ts +2 -0
- package/dist/components/Empty/types.d.ts +9 -0
- package/dist/components/Error/Error.d.ts +2 -0
- package/dist/components/Error/index.d.ts +2 -0
- package/dist/components/Error/types.d.ts +4 -0
- package/dist/components/Form/FormContainer.d.ts +3 -0
- package/dist/components/Form/ParagraphInput.d.ts +7 -0
- package/dist/components/Form/PasswordInput.d.ts +2 -0
- package/dist/components/Form/index.d.ts +4 -0
- package/dist/components/Form/types.d.ts +20 -0
- package/dist/components/Loading/Loading.d.ts +2 -0
- package/dist/components/Loading/SplashScreen.d.ts +1 -0
- package/dist/components/Loading/index.d.ts +3 -0
- package/dist/components/Loading/types.d.ts +6 -0
- package/dist/components/Navbar/Clock.d.ts +1 -0
- package/dist/components/Navbar/Navbar.d.ts +2 -0
- package/dist/components/Navbar/index.d.ts +2 -0
- package/dist/components/Navbar/types.d.ts +3 -0
- package/dist/components/Notification/Notification.d.ts +1 -0
- package/dist/components/Notification/index.d.ts +1 -0
- package/dist/components/Onboarding/Onboarding.d.ts +2 -0
- package/dist/components/Onboarding/Step.d.ts +2 -0
- package/dist/components/Onboarding/index.d.ts +3 -0
- package/dist/components/Onboarding/types.d.ts +10 -0
- package/dist/components/Page/Page.d.ts +3 -0
- package/dist/components/Page/PageHeader.d.ts +3 -0
- package/dist/components/Page/index.d.ts +2 -0
- package/dist/components/Page/types.d.ts +19 -0
- package/dist/components/PrettyGrid/PrettyGrid.d.ts +3 -0
- package/dist/components/PrettyGrid/index.d.ts +2 -0
- package/dist/components/PrettyGrid/types.d.ts +9 -0
- package/dist/components/TabsLayout/Tab.d.ts +2 -0
- package/dist/components/TabsLayout/TabsLayout.d.ts +2 -0
- package/dist/components/TabsLayout/index.d.ts +3 -0
- package/dist/components/TabsLayout/types.d.ts +21 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/types.d.ts +8 -0
- package/dist/dashboard-app.cjs +1 -0
- package/dist/dashboard-app.js +2858 -0
- package/dist/hooks/actions/index.d.ts +5 -0
- package/dist/hooks/actions/types.d.ts +24 -0
- package/dist/hooks/actions/useDeleteAction.d.ts +12 -0
- package/dist/hooks/actions/useEditAction.d.ts +6 -0
- package/dist/hooks/actions/useExportAction.d.ts +11 -0
- package/dist/hooks/actions/useRestoreAction.d.ts +12 -0
- package/dist/hooks/dialogs/index.d.ts +5 -0
- package/dist/hooks/dialogs/types.d.ts +27 -0
- package/dist/hooks/dialogs/useDeleteDialog.d.ts +17 -0
- package/dist/hooks/dialogs/useDialog.d.ts +6 -0
- package/dist/hooks/dialogs/useFormDialog.d.ts +4 -0
- package/dist/hooks/dialogs/useRestoreDialog.d.ts +17 -0
- package/dist/hooks/forms/index.d.ts +3 -0
- package/dist/hooks/forms/types.d.ts +20 -0
- package/dist/hooks/forms/useConfirmationForm.d.ts +8 -0
- package/dist/hooks/forms/usePostForm.d.ts +5 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/mutate/index.d.ts +1 -0
- package/dist/hooks/mutate/types.d.ts +9 -0
- package/dist/hooks/mutate/useExportActionMutate.d.ts +11 -0
- package/dist/hooks/queries/index.d.ts +1 -0
- package/dist/hooks/queries/types.d.ts +12 -0
- package/dist/hooks/useScrollTrigger.d.ts +1 -0
- package/dist/hooks/useTimeAge.d.ts +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/lib/Notification.d.ts +11 -0
- package/dist/lib/ServiceError.d.ts +4 -0
- package/dist/lib/ValidationError.d.ts +3 -0
- package/dist/lib/api/APIClient.d.ts +48 -0
- package/dist/lib/api/AuthClient.d.ts +10 -0
- package/dist/lib/api/BaseClient.d.ts +59 -0
- package/dist/lib/api/IManager.d.ts +9 -0
- package/dist/lib/api/index.d.ts +6 -0
- package/dist/lib/api/types.d.ts +24 -0
- package/dist/lib/api/utils/index.d.ts +2 -0
- package/dist/lib/api/utils/query.d.ts +9 -0
- package/dist/lib/api/utils/services.d.ts +24 -0
- package/dist/lib/entities/auth/AuthDto.d.ts +4 -0
- package/dist/lib/entities/auth/RegisterDto.d.ts +4 -0
- package/dist/lib/entities/auth/SessionDto.d.ts +6 -0
- package/dist/lib/entities/auth/index.d.ts +3 -0
- package/dist/lib/entities/base/BaseCommonEntityDto.d.ts +4 -0
- package/dist/lib/entities/base/BaseEntityDto.d.ts +6 -0
- package/dist/lib/entities/base/BaseFilterDto.d.ts +3 -0
- package/dist/lib/entities/base/DeleteDto.d.ts +3 -0
- package/dist/lib/entities/base/index.d.ts +5 -0
- package/dist/lib/entities/index.d.ts +3 -0
- package/dist/lib/entities/user/CommonUserDto.d.ts +2 -0
- package/dist/lib/entities/user/index.d.ts +1 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/models/index.d.ts +0 -0
- package/dist/lib/utils/date.d.ts +11 -0
- package/dist/lib/utils/enums.d.ts +4 -0
- package/dist/lib/utils/index.d.ts +6 -0
- package/dist/lib/utils/local.d.ts +20 -0
- package/dist/lib/utils/navigation.d.ts +56 -0
- package/dist/lib/utils/os.d.ts +1 -0
- package/dist/lib/utils/queryKey.d.ts +7 -0
- package/dist/main.css +1 -0
- package/dist/main.d.ts +4 -0
- package/dist/providers/AuthProvider.d.ts +13 -0
- package/dist/providers/ConfigProvider.d.ts +13 -0
- package/dist/providers/ManagerProvider.d.ts +15 -0
- package/dist/providers/NotificationProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/types.d.ts +57 -0
- package/package.json +80 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface UseActionPropTypes {
|
|
2
|
+
hidden?: boolean;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface UseSingleActionPropTypes<TInDto> extends UseActionPropTypes {
|
|
7
|
+
onClick: (record: TInDto) => void;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface UseMultipleActionPropTypes<TInDto> extends UseActionPropTypes {
|
|
11
|
+
onClick: (record: TInDto[]) => void;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface UseExportAction extends UseActionPropTypes {
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare enum GlobalActions {
|
|
18
|
+
Add = "add",
|
|
19
|
+
Edit = "edit",
|
|
20
|
+
Delete = "delete",
|
|
21
|
+
Restore = "restore",
|
|
22
|
+
Refresh = "refresh",
|
|
23
|
+
Export = "export"
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GlobalActions, UseMultipleActionPropTypes } from '..';
|
|
2
|
+
import { BaseEntityDto } from '../../lib';
|
|
3
|
+
export declare const useDeleteAction: (props: UseMultipleActionPropTypes<number>) => {
|
|
4
|
+
action: (record: BaseEntityDto) => {
|
|
5
|
+
id: GlobalActions;
|
|
6
|
+
hidden: boolean;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
tooltip: string;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Action } from '@sito/dashboard';
|
|
2
|
+
import { UseSingleActionPropTypes } from '..';
|
|
3
|
+
import { BaseEntityDto } from '../../lib';
|
|
4
|
+
export declare const useEditAction: <TRow extends BaseEntityDto>(props: UseSingleActionPropTypes<number>) => {
|
|
5
|
+
action: (record: TRow) => Action<TRow>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GlobalActions, UseExportAction } from '..';
|
|
2
|
+
export declare const useExportAction: (props: UseExportAction) => {
|
|
3
|
+
action: () => {
|
|
4
|
+
id: GlobalActions;
|
|
5
|
+
hidden: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
tooltip: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GlobalActions, UseMultipleActionPropTypes } from '..';
|
|
2
|
+
import { BaseEntityDto } from '../../lib';
|
|
3
|
+
export declare const useRestoreAction: (props: UseMultipleActionPropTypes<number>) => {
|
|
4
|
+
action: (record: BaseEntityDto) => {
|
|
5
|
+
id: GlobalActions;
|
|
6
|
+
hidden: boolean;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
tooltip: string;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MutationFunction, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { DefaultValues, FieldValues } from 'react-hook-form';
|
|
3
|
+
import { Action } from '@sito/dashboard';
|
|
4
|
+
import { BaseEntityDto, ValidationError } from '../../lib';
|
|
5
|
+
import { UseConfirmationPropsType } from '../forms';
|
|
6
|
+
import { FormDialogPropsType } from '../../components';
|
|
7
|
+
export interface UseDeleteDialogPropsType extends UseConfirmationPropsType<number, ValidationError> {
|
|
8
|
+
queryKey: QueryKey;
|
|
9
|
+
}
|
|
10
|
+
export interface UseFormDialogPropsType<TDto, TMutationDto, TMutationOutputDto, TFormType extends FieldValues> {
|
|
11
|
+
defaultValues?: DefaultValues<TFormType>;
|
|
12
|
+
getFunction?: (id: number) => Promise<TDto>;
|
|
13
|
+
formToDto: (data: TFormType) => TMutationDto;
|
|
14
|
+
dtoToForm?: (data: TDto) => TFormType;
|
|
15
|
+
mutationFn: MutationFunction<TMutationOutputDto, TMutationDto>;
|
|
16
|
+
onError?: (errors: ValidationError) => void;
|
|
17
|
+
onSuccess?: (data: TMutationOutputDto) => void;
|
|
18
|
+
queryKey: QueryKey;
|
|
19
|
+
onSuccessMessage: string;
|
|
20
|
+
title: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TriggerFormDialogPropsType<TFormType extends FieldValues, TError extends Error = Error> extends FormDialogPropsType<TFormType, TError> {
|
|
23
|
+
openDialog: (id?: number) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface UseActionDialog<TRow extends BaseEntityDto, TFormType extends FieldValues> extends TriggerFormDialogPropsType<TFormType, ValidationError> {
|
|
26
|
+
action: (record: TRow) => Action<TRow>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UseDeleteDialogPropsType } from '..';
|
|
2
|
+
export declare const useDeleteDialog: (props: UseDeleteDialogPropsType) => {
|
|
3
|
+
onClick: (record: number | number[]) => Promise<void>;
|
|
4
|
+
title: string;
|
|
5
|
+
open: boolean;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
handleSubmit: () => void;
|
|
8
|
+
handleClose: () => void;
|
|
9
|
+
action: (record: import('../../lib').BaseEntityDto) => {
|
|
10
|
+
id: import('..').GlobalActions;
|
|
11
|
+
hidden: boolean;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
tooltip: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FieldValues } from 'react-hook-form';
|
|
2
|
+
import { ValidationError } from '../../lib';
|
|
3
|
+
import { UseFormDialogPropsType, TriggerFormDialogPropsType } from '..';
|
|
4
|
+
export declare const useFormDialog: <TDto, TMutationDto, TMutationOutputDto, TFormType extends FieldValues>(props: UseFormDialogPropsType<TDto, TMutationDto, TMutationOutputDto, TFormType>) => TriggerFormDialogPropsType<TFormType, ValidationError>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UseDeleteDialogPropsType } from '..';
|
|
2
|
+
export declare const useRestoreDialog: (props: UseDeleteDialogPropsType) => {
|
|
3
|
+
onClick: (record: number | number[]) => Promise<void>;
|
|
4
|
+
title: string;
|
|
5
|
+
open: boolean;
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
handleSubmit: () => void;
|
|
8
|
+
handleClose: () => void;
|
|
9
|
+
action: (record: import('../../lib').BaseEntityDto) => {
|
|
10
|
+
id: import('..').GlobalActions;
|
|
11
|
+
hidden: boolean;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
tooltip: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MutationFunction, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { ValidationError } from '../../lib';
|
|
3
|
+
import { FieldValues, DefaultValues } from 'react-hook-form';
|
|
4
|
+
export type UseConfirmationPropsType<TInDto, TError extends Error> = {
|
|
5
|
+
mutationFn: (data: TInDto[]) => Promise<TInDto>;
|
|
6
|
+
onError?: (error: TError) => void;
|
|
7
|
+
onSuccess?: (data: TInDto) => void | Promise<void>;
|
|
8
|
+
onSuccessMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface UseFormPropsType<TDto, TMutationDto, TMutationOutputDto, TFormType extends FieldValues> {
|
|
11
|
+
defaultValues?: DefaultValues<TFormType>;
|
|
12
|
+
getFunction?: (id: number) => Promise<TDto>;
|
|
13
|
+
formToDto: (data: TFormType) => TMutationDto;
|
|
14
|
+
dtoToForm?: (data: TDto) => TFormType;
|
|
15
|
+
mutationFn: MutationFunction<TMutationOutputDto, TMutationDto>;
|
|
16
|
+
onError?: (errors: ValidationError) => void;
|
|
17
|
+
onSuccess?: (data: TMutationOutputDto) => void;
|
|
18
|
+
queryKey?: QueryKey;
|
|
19
|
+
onSuccessMessage?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseConfirmationPropsType } from '..';
|
|
2
|
+
export declare const useConfirmationForm: <TInDto, TError extends Error>(props: UseConfirmationPropsType<TInDto, TError>) => {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClick: (record: TInDto | TInDto[]) => Promise<void>;
|
|
5
|
+
close: () => void;
|
|
6
|
+
dialogFn: import('@tanstack/react-query').UseMutationResult<TInDto, TError, void, unknown>;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FieldValues } from 'react-hook-form';
|
|
2
|
+
import { ValidationError } from '../../lib';
|
|
3
|
+
import { UseFormPropsType } from '..';
|
|
4
|
+
import { FormPropsType } from '../../components';
|
|
5
|
+
export declare const usePostForm: <TDto, TMutationDto, TMutationOutputDto, TFormType extends FieldValues>(props: UseFormPropsType<TDto, TMutationDto, TMutationOutputDto, TFormType>) => FormPropsType<TFormType, ValidationError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useExportActionMutate';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type UseBaseActionMutate<TInDto, TError extends Error> = {
|
|
2
|
+
mutationFn: () => Promise<TInDto>;
|
|
3
|
+
onError?: (error: TError) => void;
|
|
4
|
+
onSuccess?: (data: TInDto) => void | Promise<void>;
|
|
5
|
+
onSuccessMessage?: string;
|
|
6
|
+
};
|
|
7
|
+
export interface UseExportActionMutatePropsType<TInDto, Tables, TError extends Error> extends UseBaseActionMutate<TInDto, TError> {
|
|
8
|
+
entity: Tables;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseExportActionMutatePropsType } from './types';
|
|
2
|
+
export declare const useExportActionMutate: <TInOutDto, Tables, TError extends Error>(props: UseExportActionMutatePropsType<TInOutDto, Tables, TError>) => {
|
|
3
|
+
action: () => {
|
|
4
|
+
id: import('../actions').GlobalActions;
|
|
5
|
+
hidden: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
tooltip: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { BaseEntityDto, BaseFilterDto, QueryParam, QueryResult } from '../../lib';
|
|
3
|
+
export type UseFetchPropsType<TRow, TFilterDto = BaseFilterDto> = {
|
|
4
|
+
filters?: TFilterDto;
|
|
5
|
+
query?: QueryParam<TRow>;
|
|
6
|
+
};
|
|
7
|
+
export type UseFetchByIdPropsType = {
|
|
8
|
+
id: number;
|
|
9
|
+
};
|
|
10
|
+
export interface ApiQueryResult<TResponseDto extends BaseEntityDto> extends Omit<UseQueryResult<QueryResult<TResponseDto>>, "setTotal"> {
|
|
11
|
+
setTotal: (total: number) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useScrollTrigger(offset: number): boolean;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Methods } from './utils/services';
|
|
2
|
+
import { BaseEntityDto, BaseFilterDto, QueryParam, QueryResult } from '..';
|
|
3
|
+
/**
|
|
4
|
+
* @class APIClient
|
|
5
|
+
* @description it has all base methods
|
|
6
|
+
*/
|
|
7
|
+
export declare class APIClient {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
userKey: string;
|
|
10
|
+
secured: boolean;
|
|
11
|
+
tokenAcquirer: (useCookie?: boolean) => HeadersInit | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* @param baseUrl the base url of the server
|
|
14
|
+
* @param userKey the local storage user key
|
|
15
|
+
* @param secured if the api client requires token
|
|
16
|
+
* @param tokenAcquirer custom token acquirer
|
|
17
|
+
*/
|
|
18
|
+
constructor(baseUrl: string, userKey?: string, secured?: boolean, tokenAcquirer?: null);
|
|
19
|
+
defaultTokenAcquirer(useCookie?: boolean): HeadersInit | undefined;
|
|
20
|
+
doQuery<TResponse, TBody = unknown>(endpoint: string, method?: Methods, body?: TBody, header?: HeadersInit): Promise<TResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* @description Get all objects
|
|
23
|
+
* @param endpoint - backed endpoint
|
|
24
|
+
* @param query - query parameters
|
|
25
|
+
* @returns Result list
|
|
26
|
+
*/
|
|
27
|
+
get<TDto extends BaseEntityDto, TFilter extends BaseFilterDto>(endpoint: string, query?: QueryParam<TDto>, filters?: TFilter): Promise<QueryResult<TDto>>;
|
|
28
|
+
/**
|
|
29
|
+
* @description Get entity by id
|
|
30
|
+
* @param endpoint - backed endpoint
|
|
31
|
+
* @param data - data to update
|
|
32
|
+
* @returns updated entity
|
|
33
|
+
*/
|
|
34
|
+
patch<TDto, TUpdateDto>(endpoint: string, data: TUpdateDto): Promise<TDto>;
|
|
35
|
+
/**
|
|
36
|
+
* @param endpoint - backend endpoint
|
|
37
|
+
* @param data - value to insert
|
|
38
|
+
* @returns delete result
|
|
39
|
+
*/
|
|
40
|
+
delete(endpoint: string, data: number[]): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param endpoint - backend endpoint
|
|
44
|
+
* @param data - value to insert
|
|
45
|
+
* @returns inserted item
|
|
46
|
+
*/
|
|
47
|
+
post<TDto, TAddDto>(endpoint: string, data: TAddDto): Promise<TDto>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { APIClient } from './APIClient';
|
|
2
|
+
import { AuthDto, RegisterDto, SessionDto } from '../entities';
|
|
3
|
+
export declare class AuthClient {
|
|
4
|
+
api: APIClient;
|
|
5
|
+
constructor(baseUrl: string, userKey?: string);
|
|
6
|
+
login(data: AuthDto): Promise<SessionDto>;
|
|
7
|
+
logout(): Promise<void>;
|
|
8
|
+
register(userData: RegisterDto): Promise<SessionDto>;
|
|
9
|
+
getSession(): Promise<SessionDto>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { APIClient } from './APIClient';
|
|
2
|
+
import { QueryParam } from './types';
|
|
3
|
+
import { BaseCommonEntityDto, BaseEntityDto, BaseFilterDto, DeleteDto, QueryResult } from '..';
|
|
4
|
+
export declare class BaseClient<Tables, TDto extends BaseEntityDto, TCommonDto extends BaseCommonEntityDto, TAddDto, TUpdateDto extends DeleteDto, TFilter extends BaseFilterDto> {
|
|
5
|
+
table: Tables;
|
|
6
|
+
secured: boolean;
|
|
7
|
+
api: APIClient;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param table
|
|
11
|
+
* @param secured to see if the api client requires jwt protection
|
|
12
|
+
*/
|
|
13
|
+
constructor(table: Tables, baseUrl: string, userKey?: string, secured?: boolean);
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param value
|
|
17
|
+
* @returns inserted item
|
|
18
|
+
*/
|
|
19
|
+
insert(value: TAddDto): Promise<TDto>;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param data - values to insert
|
|
23
|
+
* @returns - Query result
|
|
24
|
+
*/
|
|
25
|
+
insertMany(data: TAddDto[]): Promise<TDto>;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param value
|
|
29
|
+
* @returns updated item
|
|
30
|
+
*/
|
|
31
|
+
update(value: TUpdateDto): Promise<TDto>;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param query - Where conditions (key-value)
|
|
35
|
+
* @param filters - Filters to apply
|
|
36
|
+
* @returns - Query result
|
|
37
|
+
*/
|
|
38
|
+
get(query?: QueryParam<TDto>, filters?: TFilter): Promise<QueryResult<TDto>>;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param filters - Filters to apply
|
|
42
|
+
* @returns - List of elements
|
|
43
|
+
*/
|
|
44
|
+
export(filters?: TFilter): Promise<TDto[]>;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param query - Where conditions (key-value)
|
|
48
|
+
* @returns - Query result
|
|
49
|
+
*/
|
|
50
|
+
commonGet(query: TFilter): Promise<TCommonDto[]>;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param id
|
|
54
|
+
* @returns - Query result
|
|
55
|
+
*/
|
|
56
|
+
getById(id: number): Promise<TDto>;
|
|
57
|
+
softDelete(ids: number[]): Promise<number>;
|
|
58
|
+
restore(ids: number[]): Promise<number>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SortOrder } from '@sito/dashboard';
|
|
2
|
+
export type APIError = {
|
|
3
|
+
kind: string;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export type QueryResult<TDto> = {
|
|
7
|
+
sort: keyof TDto;
|
|
8
|
+
order: "asc" | "desc";
|
|
9
|
+
currentPage: number;
|
|
10
|
+
pageSize: number;
|
|
11
|
+
totalElements: number;
|
|
12
|
+
totalPages: number;
|
|
13
|
+
items: TDto[];
|
|
14
|
+
};
|
|
15
|
+
export type QueryParam<TDto> = {
|
|
16
|
+
sortingBy?: keyof TDto;
|
|
17
|
+
sortingOrder?: SortOrder;
|
|
18
|
+
currentPage?: number;
|
|
19
|
+
pageSize?: number;
|
|
20
|
+
};
|
|
21
|
+
export type RangeValue<T> = {
|
|
22
|
+
start: T;
|
|
23
|
+
end: T;
|
|
24
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { QueryParam } from '../types';
|
|
2
|
+
import { BaseFilterDto } from '../../entities';
|
|
3
|
+
/**
|
|
4
|
+
* Builds a query string from pagination and filter params
|
|
5
|
+
* @param query - Pagination and sorting info
|
|
6
|
+
* @param filters - Filters to apply
|
|
7
|
+
* @returns - Encoded query string
|
|
8
|
+
*/
|
|
9
|
+
export declare const parseQueries: <TDto, TFilter extends BaseFilterDto>(endpoint: string, query?: QueryParam<TDto>, filters?: TFilter) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum Methods {
|
|
2
|
+
GET = "GET",
|
|
3
|
+
POST = "POST",
|
|
4
|
+
PUT = "PUT",
|
|
5
|
+
PATCH = "PATCH",
|
|
6
|
+
DELETE = "DELETE"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @description Make a request to the API
|
|
10
|
+
* @param url - URL to make the request
|
|
11
|
+
* @param method - Request method
|
|
12
|
+
* @param body - Request body
|
|
13
|
+
* @param h - Request headers
|
|
14
|
+
* @returns Request response
|
|
15
|
+
*/
|
|
16
|
+
export declare function makeRequest<TBody = undefined, TResponse = unknown>(url: string, method?: Methods, body?: TBody, customHeaders?: HeadersInit): Promise<{
|
|
17
|
+
data: TResponse | null;
|
|
18
|
+
status: number;
|
|
19
|
+
error: {
|
|
20
|
+
status: number;
|
|
21
|
+
message: string;
|
|
22
|
+
} | null;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function buildQueryUrl<TFilter>(endpoint: string, params?: TFilter): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseCommonEntityDto } from './BaseCommonEntityDto';
|
|
2
|
+
import { BaseEntityDto } from './BaseEntityDto';
|
|
3
|
+
import { DeleteDto } from './DeleteDto';
|
|
4
|
+
import { BaseFilterDto } from './BaseFilterDto';
|
|
5
|
+
export type { BaseCommonEntityDto, BaseEntityDto, DeleteDto, BaseFilterDto };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CommonUserDto';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ServiceError } from './ServiceError';
|
|
2
|
+
import { ValidationError } from './ValidationError';
|
|
3
|
+
import { NotificationType, NotificationEnumType } from './Notification';
|
|
4
|
+
export { NotificationEnumType };
|
|
5
|
+
export type { ServiceError, ValidationError, NotificationType };
|
|
6
|
+
export * from './entities';
|
|
7
|
+
export * from './api';
|
|
8
|
+
export * from './utils';
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @returns now date formatted
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFormattedDateTime(date?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param isoString iso string date
|
|
9
|
+
* @returns formated date for input
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatForDatetimeLocal(isoString?: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch data from local storage
|
|
3
|
+
* @param key - key to fetch
|
|
4
|
+
* @param as - transform parameter
|
|
5
|
+
* @returns value of key in local storage
|
|
6
|
+
*/
|
|
7
|
+
export declare const fromLocal: (key: string, as?: string) => any;
|
|
8
|
+
/**
|
|
9
|
+
* Save data to local storage
|
|
10
|
+
* @param key - key to save
|
|
11
|
+
* @param value - value to save
|
|
12
|
+
* @returns nothing
|
|
13
|
+
*/
|
|
14
|
+
export declare const toLocal: (key: string, value: any) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Remove data from local storage
|
|
17
|
+
* @param {string} key - key to remove
|
|
18
|
+
* @returns nothing
|
|
19
|
+
*/
|
|
20
|
+
export declare const removeFromLocal: (key: string) => void;
|