@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.
Files changed (134) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +60 -0
  3. package/dist/components/Actions/Action.d.ts +3 -0
  4. package/dist/components/Actions/Actions.d.ts +3 -0
  5. package/dist/components/Actions/ActionsDropdown.d.ts +3 -0
  6. package/dist/components/Actions/index.d.ts +4 -0
  7. package/dist/components/Actions/types.d.ts +14 -0
  8. package/dist/components/Buttons/Button.d.ts +2 -0
  9. package/dist/components/Buttons/IconButton.d.ts +2 -0
  10. package/dist/components/Buttons/ToTop.d.ts +1 -0
  11. package/dist/components/Buttons/index.d.ts +3 -0
  12. package/dist/components/Buttons/types.d.ts +12 -0
  13. package/dist/components/Chip/Chip.d.ts +7 -0
  14. package/dist/components/Chip/DeletableChip.d.ts +2 -0
  15. package/dist/components/Chip/index.d.ts +3 -0
  16. package/dist/components/Chip/types.d.ts +12 -0
  17. package/dist/components/Dialog/ConfirmationDialog.d.ts +2 -0
  18. package/dist/components/Dialog/Dialog.d.ts +2 -0
  19. package/dist/components/Dialog/FormDialog.d.ts +3 -0
  20. package/dist/components/Dialog/index.d.ts +4 -0
  21. package/dist/components/Dialog/types.d.ts +18 -0
  22. package/dist/components/Drawer/Drawer.d.ts +2 -0
  23. package/dist/components/Drawer/index.d.ts +2 -0
  24. package/dist/components/Drawer/types.d.ts +6 -0
  25. package/dist/components/Dropdown/Dropdown.d.ts +2 -0
  26. package/dist/components/Dropdown/index.d.ts +2 -0
  27. package/dist/components/Dropdown/types.d.ts +6 -0
  28. package/dist/components/Empty/Empty.d.ts +3 -0
  29. package/dist/components/Empty/index.d.ts +2 -0
  30. package/dist/components/Empty/types.d.ts +9 -0
  31. package/dist/components/Error/Error.d.ts +2 -0
  32. package/dist/components/Error/index.d.ts +2 -0
  33. package/dist/components/Error/types.d.ts +4 -0
  34. package/dist/components/Form/FormContainer.d.ts +3 -0
  35. package/dist/components/Form/ParagraphInput.d.ts +7 -0
  36. package/dist/components/Form/PasswordInput.d.ts +2 -0
  37. package/dist/components/Form/index.d.ts +4 -0
  38. package/dist/components/Form/types.d.ts +20 -0
  39. package/dist/components/Loading/Loading.d.ts +2 -0
  40. package/dist/components/Loading/SplashScreen.d.ts +1 -0
  41. package/dist/components/Loading/index.d.ts +3 -0
  42. package/dist/components/Loading/types.d.ts +6 -0
  43. package/dist/components/Navbar/Clock.d.ts +1 -0
  44. package/dist/components/Navbar/Navbar.d.ts +2 -0
  45. package/dist/components/Navbar/index.d.ts +2 -0
  46. package/dist/components/Navbar/types.d.ts +3 -0
  47. package/dist/components/Notification/Notification.d.ts +1 -0
  48. package/dist/components/Notification/index.d.ts +1 -0
  49. package/dist/components/Onboarding/Onboarding.d.ts +2 -0
  50. package/dist/components/Onboarding/Step.d.ts +2 -0
  51. package/dist/components/Onboarding/index.d.ts +3 -0
  52. package/dist/components/Onboarding/types.d.ts +10 -0
  53. package/dist/components/Page/Page.d.ts +3 -0
  54. package/dist/components/Page/PageHeader.d.ts +3 -0
  55. package/dist/components/Page/index.d.ts +2 -0
  56. package/dist/components/Page/types.d.ts +19 -0
  57. package/dist/components/PrettyGrid/PrettyGrid.d.ts +3 -0
  58. package/dist/components/PrettyGrid/index.d.ts +2 -0
  59. package/dist/components/PrettyGrid/types.d.ts +9 -0
  60. package/dist/components/TabsLayout/Tab.d.ts +2 -0
  61. package/dist/components/TabsLayout/TabsLayout.d.ts +2 -0
  62. package/dist/components/TabsLayout/index.d.ts +3 -0
  63. package/dist/components/TabsLayout/types.d.ts +21 -0
  64. package/dist/components/index.d.ts +18 -0
  65. package/dist/components/types.d.ts +8 -0
  66. package/dist/dashboard-app.cjs +1 -0
  67. package/dist/dashboard-app.js +2858 -0
  68. package/dist/hooks/actions/index.d.ts +5 -0
  69. package/dist/hooks/actions/types.d.ts +24 -0
  70. package/dist/hooks/actions/useDeleteAction.d.ts +12 -0
  71. package/dist/hooks/actions/useEditAction.d.ts +6 -0
  72. package/dist/hooks/actions/useExportAction.d.ts +11 -0
  73. package/dist/hooks/actions/useRestoreAction.d.ts +12 -0
  74. package/dist/hooks/dialogs/index.d.ts +5 -0
  75. package/dist/hooks/dialogs/types.d.ts +27 -0
  76. package/dist/hooks/dialogs/useDeleteDialog.d.ts +17 -0
  77. package/dist/hooks/dialogs/useDialog.d.ts +6 -0
  78. package/dist/hooks/dialogs/useFormDialog.d.ts +4 -0
  79. package/dist/hooks/dialogs/useRestoreDialog.d.ts +17 -0
  80. package/dist/hooks/forms/index.d.ts +3 -0
  81. package/dist/hooks/forms/types.d.ts +20 -0
  82. package/dist/hooks/forms/useConfirmationForm.d.ts +8 -0
  83. package/dist/hooks/forms/usePostForm.d.ts +5 -0
  84. package/dist/hooks/index.d.ts +7 -0
  85. package/dist/hooks/mutate/index.d.ts +1 -0
  86. package/dist/hooks/mutate/types.d.ts +9 -0
  87. package/dist/hooks/mutate/useExportActionMutate.d.ts +11 -0
  88. package/dist/hooks/queries/index.d.ts +1 -0
  89. package/dist/hooks/queries/types.d.ts +12 -0
  90. package/dist/hooks/useScrollTrigger.d.ts +1 -0
  91. package/dist/hooks/useTimeAge.d.ts +3 -0
  92. package/dist/index.d.ts +2 -0
  93. package/dist/lib/Notification.d.ts +11 -0
  94. package/dist/lib/ServiceError.d.ts +4 -0
  95. package/dist/lib/ValidationError.d.ts +3 -0
  96. package/dist/lib/api/APIClient.d.ts +48 -0
  97. package/dist/lib/api/AuthClient.d.ts +10 -0
  98. package/dist/lib/api/BaseClient.d.ts +59 -0
  99. package/dist/lib/api/IManager.d.ts +9 -0
  100. package/dist/lib/api/index.d.ts +6 -0
  101. package/dist/lib/api/types.d.ts +24 -0
  102. package/dist/lib/api/utils/index.d.ts +2 -0
  103. package/dist/lib/api/utils/query.d.ts +9 -0
  104. package/dist/lib/api/utils/services.d.ts +24 -0
  105. package/dist/lib/entities/auth/AuthDto.d.ts +4 -0
  106. package/dist/lib/entities/auth/RegisterDto.d.ts +4 -0
  107. package/dist/lib/entities/auth/SessionDto.d.ts +6 -0
  108. package/dist/lib/entities/auth/index.d.ts +3 -0
  109. package/dist/lib/entities/base/BaseCommonEntityDto.d.ts +4 -0
  110. package/dist/lib/entities/base/BaseEntityDto.d.ts +6 -0
  111. package/dist/lib/entities/base/BaseFilterDto.d.ts +3 -0
  112. package/dist/lib/entities/base/DeleteDto.d.ts +3 -0
  113. package/dist/lib/entities/base/index.d.ts +5 -0
  114. package/dist/lib/entities/index.d.ts +3 -0
  115. package/dist/lib/entities/user/CommonUserDto.d.ts +2 -0
  116. package/dist/lib/entities/user/index.d.ts +1 -0
  117. package/dist/lib/index.d.ts +8 -0
  118. package/dist/lib/models/index.d.ts +0 -0
  119. package/dist/lib/utils/date.d.ts +11 -0
  120. package/dist/lib/utils/enums.d.ts +4 -0
  121. package/dist/lib/utils/index.d.ts +6 -0
  122. package/dist/lib/utils/local.d.ts +20 -0
  123. package/dist/lib/utils/navigation.d.ts +56 -0
  124. package/dist/lib/utils/os.d.ts +1 -0
  125. package/dist/lib/utils/queryKey.d.ts +7 -0
  126. package/dist/main.css +1 -0
  127. package/dist/main.d.ts +4 -0
  128. package/dist/providers/AuthProvider.d.ts +13 -0
  129. package/dist/providers/ConfigProvider.d.ts +13 -0
  130. package/dist/providers/ManagerProvider.d.ts +15 -0
  131. package/dist/providers/NotificationProvider.d.ts +7 -0
  132. package/dist/providers/index.d.ts +5 -0
  133. package/dist/providers/types.d.ts +57 -0
  134. package/package.json +80 -0
@@ -0,0 +1,5 @@
1
+ export * from './useDeleteAction';
2
+ export * from './useRestoreAction';
3
+ export * from './useEditAction';
4
+ export * from './types';
5
+ export * from './useExportAction';
@@ -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,5 @@
1
+ export * from './useDeleteDialog';
2
+ export * from './useDialog';
3
+ export * from './useFormDialog';
4
+ export * from './useRestoreDialog';
5
+ export type * from './types';
@@ -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,6 @@
1
+ export declare const useDialog: () => {
2
+ open: boolean;
3
+ setOpen: import('react').Dispatch<import('react').SetStateAction<boolean>>;
4
+ handleClose: () => void;
5
+ handleOpen: () => void;
6
+ };
@@ -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,3 @@
1
+ export * from './useConfirmationForm';
2
+ export * from './usePostForm';
3
+ export type * from './types';
@@ -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,7 @@
1
+ export * from './useTimeAge';
2
+ export * from './forms';
3
+ export * from './actions';
4
+ export * from './dialogs';
5
+ export * from './queries';
6
+ export * from './mutate';
7
+ export * from './useScrollTrigger';
@@ -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;
@@ -0,0 +1,3 @@
1
+ export declare function useTimeAge(): {
2
+ timeAge: (date: Date) => string;
3
+ };
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export {}
@@ -0,0 +1,11 @@
1
+ export declare enum NotificationEnumType {
2
+ success = 0,
3
+ error = 1,
4
+ warning = 2,
5
+ info = 3
6
+ }
7
+ export type NotificationType = {
8
+ message?: string;
9
+ type?: NotificationEnumType;
10
+ id?: number;
11
+ };
@@ -0,0 +1,4 @@
1
+ export type ServiceError = {
2
+ key: string;
3
+ message: string;
4
+ };
@@ -0,0 +1,3 @@
1
+ export interface ValidationError extends Error {
2
+ errors: string[];
3
+ }
@@ -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,9 @@
1
+ import { AuthClient } from './AuthClient';
2
+ export declare class IManager {
3
+ auth: AuthClient;
4
+ constructor(baseUrl: string, userKey?: string);
5
+ /**
6
+ * @returns auth
7
+ */
8
+ get Auth(): AuthClient;
9
+ }
@@ -0,0 +1,6 @@
1
+ export * from './IManager';
2
+ export * from './utils/';
3
+ export * from './types';
4
+ export * from './APIClient';
5
+ export * from './AuthClient';
6
+ export * from './BaseClient';
@@ -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,2 @@
1
+ export * from './services';
2
+ export * from './query';
@@ -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,4 @@
1
+ export type AuthDto = {
2
+ email: string;
3
+ password: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ import { AuthDto } from './AuthDto';
2
+ export interface RegisterDto extends AuthDto {
3
+ rPassword: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ export type SessionDto = {
2
+ id: number;
3
+ username: string;
4
+ email: string;
5
+ token: string;
6
+ };
@@ -0,0 +1,3 @@
1
+ export * from './AuthDto';
2
+ export * from './RegisterDto';
3
+ export * from './SessionDto';
@@ -0,0 +1,4 @@
1
+ import { DeleteDto } from '../..';
2
+ export interface BaseCommonEntityDto extends DeleteDto {
3
+ updatedAt: Date;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { DeleteDto } from '../..';
2
+ export interface BaseEntityDto extends DeleteDto {
3
+ deleted: boolean;
4
+ createdAt: Date;
5
+ updatedAt: Date;
6
+ }
@@ -0,0 +1,3 @@
1
+ export interface BaseFilterDto {
2
+ deleted?: boolean;
3
+ }
@@ -0,0 +1,3 @@
1
+ export interface DeleteDto {
2
+ id: number;
3
+ }
@@ -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,3 @@
1
+ export * from './base';
2
+ export * from './auth';
3
+ export * from './user';
@@ -0,0 +1,2 @@
1
+ import { BaseCommonEntityDto } from '../..';
2
+ export type CommonUserDto = BaseCommonEntityDto;
@@ -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,4 @@
1
+ export declare function enumToKeyValueArray<T extends Record<string, string | number>>(enumObj: T): {
2
+ key: string;
3
+ value: string | number;
4
+ }[];
@@ -0,0 +1,6 @@
1
+ export * from './enums';
2
+ export * from './queryKey';
3
+ export * from './local';
4
+ export * from './date';
5
+ export * from './os';
6
+ export * from './navigation';
@@ -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;