@tiny-server/core 0.0.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.
Files changed (138) hide show
  1. package/dist/api/apiResults.d.ts +48 -0
  2. package/dist/api/entity.d.ts +27 -0
  3. package/dist/api/index.d.ts +8 -0
  4. package/dist/api/paginationOptions.d.ts +13 -0
  5. package/dist/api/permissions.d.ts +55 -0
  6. package/dist/api/problemDetails.d.ts +16 -0
  7. package/dist/api/session.d.ts +38 -0
  8. package/dist/api/sortOptions.d.ts +17 -0
  9. package/dist/api/status.d.ts +27 -0
  10. package/dist/app/App.d.ts +12 -0
  11. package/dist/app/context.d.ts +6 -0
  12. package/dist/app/create.d.ts +12 -0
  13. package/dist/app/features/extensions/Extension.d.ts +32 -0
  14. package/dist/app/features/extensions/index.d.ts +2 -0
  15. package/dist/app/features/extensions/types.d.ts +43 -0
  16. package/dist/app/features/index.d.ts +6 -0
  17. package/dist/app/features/layout/Error.d.ts +15 -0
  18. package/dist/app/features/layout/Layout.d.ts +4 -0
  19. package/dist/app/features/layout/Loading.d.ts +14 -0
  20. package/dist/app/features/layout/Page.d.ts +6 -0
  21. package/dist/app/features/layout/index.d.ts +6 -0
  22. package/dist/app/features/layout/initializer.d.ts +2 -0
  23. package/dist/app/features/layout/types.d.ts +13 -0
  24. package/dist/app/features/menu/Menu.d.ts +7 -0
  25. package/dist/app/features/menu/MenuContainer.d.ts +4 -0
  26. package/dist/app/features/menu/MenuItem.d.ts +11 -0
  27. package/dist/app/features/menu/index.d.ts +5 -0
  28. package/dist/app/features/menu/initializer.d.ts +2 -0
  29. package/dist/app/features/menu/types.d.ts +71 -0
  30. package/dist/app/features/modals/Modal.d.ts +5 -0
  31. package/dist/app/features/modals/ModalBody.d.ts +4 -0
  32. package/dist/app/features/modals/ModalContent.d.ts +7 -0
  33. package/dist/app/features/modals/ModalFooter.d.ts +5 -0
  34. package/dist/app/features/modals/ModalHeader.d.ts +5 -0
  35. package/dist/app/features/modals/Modals.d.ts +4 -0
  36. package/dist/app/features/modals/index.d.ts +8 -0
  37. package/dist/app/features/modals/initializer.d.ts +2 -0
  38. package/dist/app/features/modals/store.d.ts +14 -0
  39. package/dist/app/features/modals/types.d.ts +84 -0
  40. package/dist/app/features/query/AppQueryClientProvider.d.ts +2 -0
  41. package/dist/app/features/query/client.d.ts +2 -0
  42. package/dist/app/features/query/index.d.ts +3 -0
  43. package/dist/app/features/query/initializer.d.ts +2 -0
  44. package/dist/app/features/query/types.d.ts +9 -0
  45. package/dist/app/features/router/AppLayout.d.ts +1 -0
  46. package/dist/app/features/router/AppRouteLayout.d.ts +5 -0
  47. package/dist/app/features/router/AppRouter.d.ts +4 -0
  48. package/dist/app/features/router/RouterErrorBoundary.d.ts +1 -0
  49. package/dist/app/features/router/context.d.ts +5 -0
  50. package/dist/app/features/router/index.d.ts +3 -0
  51. package/dist/app/features/router/middlewares.d.ts +42 -0
  52. package/dist/app/index.d.ts +5 -0
  53. package/dist/app/types.d.ts +78 -0
  54. package/dist/components/ErrorBoundary.d.ts +19 -0
  55. package/dist/components/WithPermissions.d.ts +30 -0
  56. package/dist/components/index.d.ts +2 -0
  57. package/dist/fetch.d.ts +84 -0
  58. package/dist/i18n/InitI18n.d.ts +6 -0
  59. package/dist/i18n/defineLocales.d.ts +10 -0
  60. package/dist/i18n/index.d.ts +3 -0
  61. package/dist/i18n/useGlobalT.d.ts +7 -0
  62. package/dist/index.d.ts +7 -0
  63. package/dist/index.js +557 -0
  64. package/dist/module.d.ts +7 -0
  65. package/dist/utils/dates.d.ts +3 -0
  66. package/dist/utils/index.d.ts +4 -0
  67. package/dist/utils/usePagination.d.ts +31 -0
  68. package/dist/utils/useSearch.d.ts +19 -0
  69. package/dist/utils/useSession.d.ts +22 -0
  70. package/package.json +52 -0
  71. package/src/api/apiResults.ts +50 -0
  72. package/src/api/entity.ts +29 -0
  73. package/src/api/index.ts +8 -0
  74. package/src/api/paginationOptions.ts +13 -0
  75. package/src/api/permissions.ts +63 -0
  76. package/src/api/problemDetails.ts +19 -0
  77. package/src/api/session.ts +51 -0
  78. package/src/api/sortOptions.ts +18 -0
  79. package/src/api/status.ts +34 -0
  80. package/src/app/App.tsx +33 -0
  81. package/src/app/context.ts +17 -0
  82. package/src/app/create.ts +34 -0
  83. package/src/app/features/extensions/Extension.tsx +69 -0
  84. package/src/app/features/extensions/index.ts +2 -0
  85. package/src/app/features/extensions/types.tsx +52 -0
  86. package/src/app/features/index.ts +6 -0
  87. package/src/app/features/layout/Error.tsx +20 -0
  88. package/src/app/features/layout/Layout.tsx +7 -0
  89. package/src/app/features/layout/Loading.tsx +21 -0
  90. package/src/app/features/layout/Page.tsx +42 -0
  91. package/src/app/features/layout/index.ts +6 -0
  92. package/src/app/features/layout/initializer.ts +12 -0
  93. package/src/app/features/layout/types.ts +14 -0
  94. package/src/app/features/menu/Menu.tsx +66 -0
  95. package/src/app/features/menu/MenuContainer.tsx +9 -0
  96. package/src/app/features/menu/MenuItem.tsx +46 -0
  97. package/src/app/features/menu/index.ts +5 -0
  98. package/src/app/features/menu/initializer.ts +8 -0
  99. package/src/app/features/menu/types.ts +84 -0
  100. package/src/app/features/modals/Modal.tsx +20 -0
  101. package/src/app/features/modals/ModalBody.tsx +8 -0
  102. package/src/app/features/modals/ModalContent.tsx +35 -0
  103. package/src/app/features/modals/ModalFooter.tsx +19 -0
  104. package/src/app/features/modals/ModalHeader.tsx +15 -0
  105. package/src/app/features/modals/Modals.tsx +33 -0
  106. package/src/app/features/modals/index.ts +8 -0
  107. package/src/app/features/modals/initializer.ts +17 -0
  108. package/src/app/features/modals/store.ts +35 -0
  109. package/src/app/features/modals/types.ts +94 -0
  110. package/src/app/features/query/AppQueryClientProvider.tsx +7 -0
  111. package/src/app/features/query/client.ts +3 -0
  112. package/src/app/features/query/index.ts +3 -0
  113. package/src/app/features/query/initializer.ts +6 -0
  114. package/src/app/features/query/types.ts +10 -0
  115. package/src/app/features/router/AppLayout.tsx +18 -0
  116. package/src/app/features/router/AppRouteLayout.tsx +31 -0
  117. package/src/app/features/router/AppRouter.tsx +45 -0
  118. package/src/app/features/router/RouterErrorBoundary.tsx +20 -0
  119. package/src/app/features/router/context.ts +7 -0
  120. package/src/app/features/router/index.ts +3 -0
  121. package/src/app/features/router/middlewares.ts +76 -0
  122. package/src/app/index.ts +6 -0
  123. package/src/app/types.ts +82 -0
  124. package/src/components/ErrorBoundary.tsx +34 -0
  125. package/src/components/WithPermissions.tsx +59 -0
  126. package/src/components/index.ts +2 -0
  127. package/src/fetch.ts +185 -0
  128. package/src/i18n/InitI18n.tsx +24 -0
  129. package/src/i18n/defineLocales.ts +59 -0
  130. package/src/i18n/index.ts +3 -0
  131. package/src/i18n/useGlobalT.ts +13 -0
  132. package/src/index.ts +8 -0
  133. package/src/module.tsx +27 -0
  134. package/src/utils/dates.ts +34 -0
  135. package/src/utils/index.ts +4 -0
  136. package/src/utils/usePagination.ts +64 -0
  137. package/src/utils/useSearch.ts +40 -0
  138. package/src/utils/useSession.ts +42 -0
@@ -0,0 +1,84 @@
1
+ import { ComponentType } from 'react';
2
+ import { ModalProps } from './Modal';
3
+ import { ModalBodyProps } from './ModalBody';
4
+ import { ModalFooterProps } from './ModalFooter';
5
+ import { ModalHeaderProps } from './ModalHeader';
6
+ declare module '../../types' {
7
+ interface AppInstance {
8
+ /**
9
+ * Shows a registered modal window.
10
+ * @param name The name of the modal to be shown.
11
+ * @param params The parameters to be passed to the modal.
12
+ */
13
+ showModal<TModalName extends ModalName>(name: TModalName, params: ModalParams<TModalName>): void;
14
+ }
15
+ interface AppComponents {
16
+ Modal: ComponentType<ModalProps>;
17
+ ModalBody: ComponentType<ModalBodyProps>;
18
+ ModalFooter: ComponentType<ModalFooterProps>;
19
+ ModalHeader: ComponentType<ModalHeaderProps>;
20
+ }
21
+ }
22
+ /**
23
+ * A map of all known modals.
24
+ * This interface can be extended by modules via declaration merging.
25
+ *
26
+ * ```ts
27
+ * declare module '@tiny-server/core' {
28
+ * export interface ModalParamsMap {
29
+ * 'my-modal': MyModalParams;
30
+ * }
31
+ * }
32
+ * ```
33
+ */
34
+ export interface ModalParamsMap {
35
+ '': never;
36
+ }
37
+ /**
38
+ * Defines all known modal types.
39
+ */
40
+ export type ModalName = keyof ModalParamsMap;
41
+ /**
42
+ * The parameters of the modal with the given `TName`.
43
+ */
44
+ export type ModalParams<TName extends ModalName> = ModalParamsMap[TName];
45
+ export interface ModalComponentProps<TName extends ModalName> {
46
+ /**
47
+ * The modal name.
48
+ */
49
+ name: TName;
50
+ /**
51
+ * The parameters to be forwarded to the modal component.
52
+ */
53
+ params: ModalParams<TName>;
54
+ /**
55
+ * Closes/unmounts the modal.
56
+ */
57
+ onClose(): void;
58
+ }
59
+ /**
60
+ * Optional configuration values for the modal container.
61
+ */
62
+ export interface ModalOptions {
63
+ /**
64
+ * The modal's size.
65
+ */
66
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'auto' | (string & {});
67
+ }
68
+ export interface ModalRegistration<TName extends ModalName> {
69
+ /**
70
+ * The name of the modal to be registered.
71
+ */
72
+ name: TName;
73
+ /**
74
+ * Optional configuration values for the modal container.
75
+ */
76
+ options?: ModalOptions;
77
+ /**
78
+ * The component to be rendered for the modal.
79
+ */
80
+ component: ComponentType<ModalComponentProps<TName>>;
81
+ }
82
+ export type AnyModalRegistration = {
83
+ [Key in ModalName]: ModalRegistration<Key>;
84
+ }[ModalName];
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare function AppQueryClientProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ export declare const queryClient: QueryClient;
@@ -0,0 +1,3 @@
1
+ export * from './AppQueryClientProvider';
2
+ export * from './initializer';
3
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ import { AppInitializer } from '../../types';
2
+ export declare const queryInitializer: AppInitializer;
@@ -0,0 +1,9 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ declare module '../../types' {
3
+ interface AppInstance {
4
+ /**
5
+ * The application's central {@link QueryClient} instance.
6
+ */
7
+ queryClient: QueryClient;
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ export declare function AppLayout(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The app's top-level route layout.
3
+ * Acts as a suspense and error boundary for all routes.
4
+ */
5
+ export declare function AppRouteLayout(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Renders the app's router based on the app configuration.
3
+ */
4
+ export declare function AppRouter(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function RouterErrorBoundary(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { AppInstance } from '../../types';
2
+ /**
3
+ * A router context which grants access to current {@link AppInstance}.
4
+ */
5
+ export declare const appContext: import('react-router').RouterContext<AppInstance>;
@@ -0,0 +1,3 @@
1
+ export * from './AppRouter';
2
+ export * from './context';
3
+ export * from './middlewares';
@@ -0,0 +1,42 @@
1
+ import { MiddlewareFunction } from 'react-router';
2
+ import { Permission } from '../../../api';
3
+ export interface RequireSessionMiddlewareOptions {
4
+ /**
5
+ * The URL to which an anonymous user should be redirected to.
6
+ * @default '/'
7
+ */
8
+ redirectUrl?: string;
9
+ /**
10
+ * A set of permissions which are required to access the route.
11
+ */
12
+ permissions?: Array<Permission>;
13
+ /**
14
+ * A custom callback which allows custom handling of unauthorized access errors, i.e., situations
15
+ * where no active session exists.
16
+ * If not provided, the middleware will redirect to {@link redirectUrl}.
17
+ */
18
+ onUnauthorized?: () => void | Promise<void>;
19
+ /**
20
+ * A custom callback which allows custom handling of forbidden access errors, i.e., situations
21
+ * where the user session does not have the required permissions.
22
+ * If not provided, the middleware will throw a `403` data error.
23
+ */
24
+ onForbidden?: () => void | Promise<void>;
25
+ }
26
+ /**
27
+ * Creates a router middleware function which ensures that an active user session exists.
28
+ * If no session exists, the user is redirected to {@link RequireSessionMiddlewareOptions#redirectUrl}.
29
+ */
30
+ export declare function requireSession({ redirectUrl, permissions, onUnauthorized, onForbidden, }?: RequireSessionMiddlewareOptions): MiddlewareFunction;
31
+ export interface RequireAnonymousMiddlewareOptions {
32
+ /**
33
+ * The URL to which a logged in user should be redirected to.
34
+ * @default '/'
35
+ */
36
+ redirectUrl?: string;
37
+ }
38
+ /**
39
+ * Creates a router middleware function which ensures that no user session exists.
40
+ * If a session exists, the user is redirected to {@link RequireAnonymousMiddlewareOptions#redirectUrl}.
41
+ */
42
+ export declare function requireAnonymous({ redirectUrl }?: RequireAnonymousMiddlewareOptions): MiddlewareFunction;
@@ -0,0 +1,5 @@
1
+ export * from './features';
2
+ export * from './App';
3
+ export { useApp } from './context';
4
+ export * from './create';
5
+ export * from './types';
@@ -0,0 +1,78 @@
1
+ import { RouteObject } from 'react-router';
2
+ import { AnyExtensionRegistration } from './features/extensions';
3
+ import { AnyMenuItemRegistration } from './features/menu';
4
+ import { AnyModalRegistration } from './features/modals';
5
+ import { ComponentType, PropsWithChildren } from 'react';
6
+ /**
7
+ * Represents an instance of a configured application.
8
+ * {@link AppInstance} objects provide the app's central orchestration API.
9
+ */
10
+ export interface AppInstance {
11
+ /**
12
+ * The set of modules which make up this application instance.
13
+ */
14
+ modules: Array<Module>;
15
+ /**
16
+ * A set of application specific components.
17
+ */
18
+ components: AppComponents;
19
+ }
20
+ /**
21
+ * Represents a set of configurable components which can be declared by modules
22
+ * and used by any component that has access to the application instance.
23
+ *
24
+ * This interface can be extended by modules via declaration merging.
25
+ *
26
+ * ```ts
27
+ * declare module '@tiny-server/core' {
28
+ * export interface AppComponents {
29
+ * MyComponent: ComponentType<MyComponentProps>;
30
+ * }
31
+ * }
32
+ * ```
33
+ */
34
+ export interface AppComponents {
35
+ }
36
+ /**
37
+ * An initializer function which can be registered as part of a module configuration.
38
+ *
39
+ * App initializers are called during app creation, receiving an {@link AppInstance}.
40
+ * They can perform any necessary setup or (re-)configuration of the app instance.
41
+ *
42
+ * App initializers *may* mutate the given app instance.
43
+ */
44
+ export type AppInitializer = (app: AppInstance) => AppInstance | void;
45
+ /**
46
+ * Initialization values for {@link Module} objects.
47
+ */
48
+ export type ModuleInit = Partial<Module>;
49
+ /**
50
+ * Represents an application module.
51
+ */
52
+ export interface Module {
53
+ /**
54
+ * Module-provided {@link AppInitializer} functions.
55
+ */
56
+ appInitializers: Array<AppInitializer>;
57
+ /**
58
+ * Module-provided provider components.
59
+ * These are rendered at the very top of the app's component tree.
60
+ */
61
+ providers: Array<ComponentType<PropsWithChildren>>;
62
+ /**
63
+ * Module-provided routes.
64
+ */
65
+ routes: Array<RouteObject>;
66
+ /**
67
+ * Module-provided extensions.
68
+ */
69
+ extensions: Array<AnyExtensionRegistration>;
70
+ /**
71
+ * Module-provided menu items.
72
+ */
73
+ menuItems: Array<AnyMenuItemRegistration>;
74
+ /**
75
+ * Module-provided modals.
76
+ */
77
+ modals: Array<AnyModalRegistration>;
78
+ }
@@ -0,0 +1,19 @@
1
+ import { Component, PropsWithChildren, ReactNode } from 'react';
2
+ interface State {
3
+ hasError: boolean;
4
+ }
5
+ export interface ErrorBoundaryProps extends PropsWithChildren {
6
+ /**
7
+ * The fallback to render when an error is caught.
8
+ */
9
+ fallback?: ReactNode;
10
+ }
11
+ /**
12
+ * A generic error boundary component which renders a fallback when an error is caught.
13
+ */
14
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, State> {
15
+ constructor(props: ErrorBoundaryProps);
16
+ static getDerivedStateFromError(): State;
17
+ render(): ReactNode;
18
+ }
19
+ export {};
@@ -0,0 +1,30 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { Permission } from '../api';
3
+ export interface WithPermissionsProps {
4
+ /**
5
+ * The required permissions.
6
+ * @default []
7
+ */
8
+ permissions?: Array<Permission>;
9
+ /**
10
+ * The operator to use for checking permissions.
11
+ * @default 'and'
12
+ */
13
+ operator?: 'and' | 'or';
14
+ /**
15
+ * The content to render when the user has the required permissions.
16
+ */
17
+ children?: ReactNode;
18
+ /**
19
+ * The content to render when the user is lacking the required permissions.
20
+ */
21
+ fallback?: ReactNode;
22
+ }
23
+ /**
24
+ * Renders content depending on whether the users has one or more given permissions.
25
+ */
26
+ export declare function WithPermissions({ permissions, operator, children, fallback }: WithPermissionsProps): import("react/jsx-runtime").JSX.Element;
27
+ /**
28
+ * Wraps the given component in a {@link WithPermissions} component.
29
+ */
30
+ export declare function withPermissions<T extends object>(withPermissionProps: Omit<WithPermissionsProps, 'children'>, WrappedComponent: ComponentType<T>): ComponentType<T>;
@@ -0,0 +1,2 @@
1
+ export * from './ErrorBoundary';
2
+ export * from './WithPermissions';
@@ -0,0 +1,84 @@
1
+ import { ProblemDetails } from './api';
2
+ /**
3
+ * Arguments for making an HTTP request using {@link appFetch}.
4
+ */
5
+ export interface AppFetchArgs<TResult = void> extends Omit<RequestInit, 'body'> {
6
+ /**
7
+ * The base URL to be used for the request.
8
+ * @default window.location.origin
9
+ */
10
+ baseUrl?: string;
11
+ /**
12
+ * The request URL.
13
+ */
14
+ url: string;
15
+ /**
16
+ * The body of the request.
17
+ * This body is, by default, automatically serialized as JSON **unless** the `Content-Type` header
18
+ * is set to a value other than `application/json`.
19
+ */
20
+ body?: BodyInit | object;
21
+ /**
22
+ * Additional query parameters to be appended to the URL.
23
+ * If set, these overwrite existing query parameters in {@link url} with the same name.
24
+ */
25
+ params?: AppFetchQueryParams;
26
+ /**
27
+ * Defines the handler which should be used to parse the response.
28
+ * @default 'json'
29
+ */
30
+ responseHandler?: DefaultResponseHandler | AppFetchResponseHandler<TResult>;
31
+ /**
32
+ * Defines the validators which should be used to validate the response.
33
+ * @default ['statusOk']
34
+ */
35
+ responseValidators?: Array<DefaultResponseValidator | AppFetchResponseValidator<TResult>>;
36
+ }
37
+ /**
38
+ * Supported query param types.
39
+ */
40
+ export type AppFetchQueryParams = Record<string, any>;
41
+ /**
42
+ * Represents a function which handles/processes a {@link Response} object.
43
+ * These handlers are supposed
44
+ */
45
+ export type AppFetchResponseHandler<TResult = void> = (response: Response) => Promise<TResult>;
46
+ /**
47
+ * Represents a function which validates that a response produced by {@link appFetch} is valid.
48
+ */
49
+ export type AppFetchResponseValidator<TResult = void> = (response: Response, result: TResult) => Promise<void>;
50
+ declare const defaultResponseHandlers: {
51
+ json: (response: Response) => Promise<any>;
52
+ };
53
+ declare const defaultResponseValidators: {
54
+ statusOk: (response: Response, result: unknown) => Promise<void>;
55
+ };
56
+ export type DefaultResponseHandler = keyof typeof defaultResponseHandlers;
57
+ export type DefaultResponseValidator = keyof typeof defaultResponseValidators;
58
+ /**
59
+ * A function similar to {@link fetch}, but tailored for the application's conventional backend API.
60
+ * {@link appFetch} implements automatic response (de-serialization) and validation.
61
+ * By default, {@link appFetch} assumes that requests and responses are based on JSON and that
62
+ * any non-2xx status code represents an error.
63
+ * These defaults can be overwritten via {@link args}.
64
+ * @param args The arguments for the fetch request. This can be a string representing the URL if no additional options are required.
65
+ */
66
+ export declare function appFetch<TResult = void>(args: string | AppFetchArgs<TResult>): Promise<TResult>;
67
+ /**
68
+ * An error thrown by {@link appFetch} when a default validation fails.
69
+ */
70
+ export declare class AppFetchError extends Error {
71
+ /**
72
+ * The received fetch response.
73
+ */
74
+ readonly response: Response;
75
+ constructor(response: Response, message?: string | null);
76
+ }
77
+ /**
78
+ * An error thrown by {@link appFetch} when the response contains a problem details object.
79
+ */
80
+ export declare class ProblemDetailsError extends AppFetchError {
81
+ readonly problem: Readonly<ProblemDetails>;
82
+ constructor(response: Response, problem: ProblemDetails);
83
+ }
84
+ export {};
@@ -0,0 +1,6 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { InitOptions } from 'i18next';
3
+ export interface InitI18nProps extends PropsWithChildren {
4
+ options?: InitOptions<unknown>;
5
+ }
6
+ export declare function InitI18n({ options, children }: InitI18nProps): import('react').ReactNode;
@@ -0,0 +1,10 @@
1
+ type KeyPrefixOrFn = string | ((...args: Array<any>) => any);
2
+ /**
3
+ * Registers a translation resource bundle and creates a `useT` hook that returns a translation
4
+ * function which translates the registered keys.
5
+ * @param keyPrefixOrFn The key prefix or function that the translations are registered for.
6
+ * @param translations The set of translations to register, keyed by the language.
7
+ * @returns A `useT` hook that returns a {@link TFunction} that returns the registered translations.
8
+ */
9
+ export declare function defineLocales<T extends Record<string, Record<string, unknown>>>(keyPrefixOrFn: KeyPrefixOrFn | Array<KeyPrefixOrFn>, translations: T): () => import('i18next').TFunction<"translation", string>;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './defineLocales';
2
+ export * from './InitI18n';
3
+ export * from './useGlobalT';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns a non-scoped translation function.
3
+ * To be used for accessing global translations.
4
+ * If possible, use {@link defineLocales} instead.
5
+ * @param keyPrefix An optional key prefix.
6
+ */
7
+ export declare function useGlobalT(keyPrefix?: string): import('i18next').TFunction<"translation", string>;
@@ -0,0 +1,7 @@
1
+ export * from './api';
2
+ export * from './app';
3
+ export * from './components';
4
+ export * from './utils';
5
+ export * from './fetch';
6
+ export * from './i18n/defineLocales';
7
+ export * from './module';