@next-feature/client 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/README.md +7 -0
- package/components/api-error-boundary.d.ts +18 -0
- package/hooks/use-api-error.d.ts +10 -0
- package/index.d.ts +30 -0
- package/index.js +4831 -0
- package/lib/client.d.ts +68 -0
- package/lib/error.d.ts +35 -0
- package/lib/types/client.d.ts +19 -0
- package/lib/types/index.d.ts +27 -0
- package/lib/utils/axios.d.ts +7 -0
- package/lib/utils/error.d.ts +19 -0
- package/lib/utils/zod.d.ts +10 -0
- package/package.json +17 -0
- package/server.d.ts +0 -0
- package/server.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React, Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import { ApiError } from '../lib/error';
|
|
3
|
+
interface Props {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
fallback?: (error: ApiError) => ReactNode;
|
|
6
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
7
|
+
}
|
|
8
|
+
interface State {
|
|
9
|
+
hasError: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
export declare class ApiErrorBoundary extends Component<Props, State> {
|
|
13
|
+
constructor(props: Props);
|
|
14
|
+
static getDerivedStateFromError(error: Error): State;
|
|
15
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
16
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>> | import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiError } from '../lib/error';
|
|
2
|
+
interface UseApiErrorResult {
|
|
3
|
+
error: ApiError | null;
|
|
4
|
+
setError: (error: ApiError | null) => void;
|
|
5
|
+
clearError: () => void;
|
|
6
|
+
handleError: (error: unknown) => void;
|
|
7
|
+
errorMessage: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function useApiError(): UseApiErrorResult;
|
|
10
|
+
export {};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client package exports
|
|
3
|
+
*
|
|
4
|
+
* This client package provides all necessary API client utilities.
|
|
5
|
+
* All implementations are self-contained and do not depend on external packages.
|
|
6
|
+
*
|
|
7
|
+
* CUSTOMIZATION:
|
|
8
|
+
* You can easily customize any part of the implementation:
|
|
9
|
+
*
|
|
10
|
+
* 1. For custom ApiClient/ApiError logic with interceptors:
|
|
11
|
+
* - Run: npx nx g next-feature:client-config --projectName=<your-project>
|
|
12
|
+
* - This creates lib/client/config.ts for centralized setup
|
|
13
|
+
*
|
|
14
|
+
* 2. For full custom implementations:
|
|
15
|
+
* - Edit src/lib/client.ts to customize ApiClient behavior
|
|
16
|
+
* - Edit src/lib/error.ts to customize error handling
|
|
17
|
+
* - The changes are immediately reflected in all imports
|
|
18
|
+
*
|
|
19
|
+
* 3. For project-specific hooks/components:
|
|
20
|
+
* - Import directly: import { useApiError } from './hooks/use-api-error'
|
|
21
|
+
* - Customize src/hooks/use-api-error.tsx
|
|
22
|
+
* - Customize src/components/api-error-boundary.tsx
|
|
23
|
+
*/
|
|
24
|
+
export { ApiClient } from './lib/client';
|
|
25
|
+
export { ApiError } from './lib/error';
|
|
26
|
+
export * from './lib/types/client';
|
|
27
|
+
export * from './lib/types/index';
|
|
28
|
+
export * from './lib/utils/axios';
|
|
29
|
+
export * from './lib/utils/error';
|
|
30
|
+
export * from './lib/utils/zod';
|