@next-feature/client 0.1.1 → 0.1.2-2

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.
@@ -1,136 +0,0 @@
1
- import { ApiError } from '../error';
2
-
3
- /**
4
- * Extract user-friendly error message from ApiError
5
- *
6
- * [get-error-message]
7
- * next-feature@0.0.11-beta
8
- * November 4th 2025, 11:47:45 am
9
- *
10
- */
11
- export function getErrorMessage(error: unknown): string {
12
- if (error instanceof ApiError) {
13
- // Use Spring Boot ProblemDetail information
14
- if (error.problemDetail?.detail) {
15
- return error.problemDetail.detail;
16
- }
17
- if (error.problemDetail?.title) {
18
- return error.problemDetail.title;
19
- }
20
- return error.message;
21
- }
22
-
23
- if (error instanceof Error) {
24
- return error.message;
25
- }
26
-
27
- return 'An unexpected error occurred';
28
- }
29
-
30
- /**
31
- * Format ProblemDetail for display
32
- */
33
- export function formatProblemDetail(error: ApiError): string {
34
- if (!error.problemDetail) {
35
- return error.message;
36
- }
37
-
38
- const parts: string[] = [];
39
-
40
- if (error.problemDetail.title) {
41
- parts.push(`Title: ${error.problemDetail.title}`);
42
- }
43
-
44
- if (error.problemDetail.detail) {
45
- parts.push(`Detail: ${error.problemDetail.detail}`);
46
- }
47
-
48
- if (error.problemDetail.instance) {
49
- parts.push(`Instance: ${error.problemDetail.instance}`);
50
- }
51
-
52
- return parts.join('\n');
53
- }
54
-
55
- /**
56
- * Check if error is a specific HTTP status
57
- */
58
- export function isHttpStatus(error: unknown, status: number): boolean {
59
- return error instanceof ApiError && error.status === status;
60
- }
61
-
62
- /**
63
- * Handle common API errors
64
- */
65
- export function handleApiError(error: unknown): void {
66
- if (!(error instanceof ApiError)) {
67
- console.error('Unexpected error:', error);
68
- return;
69
- }
70
-
71
- switch (error.status) {
72
- case 400:
73
- console.error('Bad Request:', error.problemDetail?.detail);
74
- break;
75
- case 401:
76
- console.error('Unauthorized - Please login');
77
- break;
78
- case 403:
79
- console.error('Forbidden - Access denied');
80
- break;
81
- case 404:
82
- console.error('Not Found:', error.problemDetail?.detail);
83
- break;
84
- case 409:
85
- console.error('Conflict:', error.problemDetail?.detail);
86
- break;
87
- case 422:
88
- console.error('Validation Error:', error.problemDetail);
89
- break;
90
- case 429:
91
- console.error('Too Many Requests - Please slow down');
92
- break;
93
- case 500:
94
- console.error('Server Error:', error.problemDetail?.detail);
95
- break;
96
- case 503:
97
- console.error('Service Unavailable - Please try again later');
98
- break;
99
- default:
100
- console.error(`Error ${error.status}:`, error.message);
101
- }
102
- }
103
-
104
- /**
105
- * Validation error extractor for Spring Boot validation errors
106
- */
107
- export function extractValidationErrors(
108
- error: ApiError
109
- ): Record<string, string[]> | null {
110
- if (!error.problemDetail || error.status !== 400) {
111
- return null;
112
- }
113
-
114
- // Spring Boot often includes validation errors in a 'errors' or 'fieldErrors' property
115
- const errors = error.problemDetail.errors || error.problemDetail.fieldErrors;
116
-
117
- if (!errors) {
118
- return null;
119
- }
120
-
121
- // Convert to a more usable format
122
- if (Array.isArray(errors)) {
123
- const result: Record<string, string[]> = {};
124
- errors.forEach((err: any) => {
125
- const field = err.field || err.property || 'general';
126
- const message = err.message || err.defaultMessage || 'Validation error';
127
- if (!result[field]) {
128
- result[field] = [];
129
- }
130
- result[field].push(message);
131
- });
132
- return result;
133
- }
134
-
135
- return errors as Record<string, string[]>;
136
- }
@@ -1,20 +0,0 @@
1
- import { ProblemDetail } from '../error';
2
-
3
- /**
4
- * [show-error-toast]
5
- * next-feature@0.0.11-beta
6
- * November 4th 2025, 11:58:52 am
7
- */
8
- export function showErrorToast(data: any) {
9
- return data;
10
- }
11
-
12
- export function getFieldError(
13
- error: ProblemDetail | undefined,
14
- fieldName: string
15
- ): string | undefined {
16
- if (!error) return undefined;
17
-
18
- const errors = error.errors as Record<string, string>;
19
- return errors?.[fieldName];
20
- }
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "allowJs": false,
5
- "esModuleInterop": false,
6
- "allowSyntheticDefaultImports": true,
7
- "types": ["vite/client", "node"]
8
- },
9
- "files": [],
10
- "include": [],
11
- "references": [
12
- {
13
- "path": "./tsconfig.lib.json"
14
- },
15
- {
16
- "path": "./tsconfig.spec.json"
17
- }
18
- ],
19
- "extends": "../../tsconfig.base.json"
20
- }
package/tsconfig.lib.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "types": [
6
- "node",
7
- "@nx/react/typings/cssmodule.d.ts",
8
- "@nx/react/typings/image.d.ts",
9
- "vite/client",
10
- "next",
11
- "@nx/next/typings/image.d.ts"
12
- ]
13
- },
14
- "exclude": [
15
- "**/*.spec.ts",
16
- "**/*.test.ts",
17
- "**/*.spec.tsx",
18
- "**/*.test.tsx",
19
- "**/*.spec.js",
20
- "**/*.test.js",
21
- "**/*.spec.jsx",
22
- "**/*.test.jsx",
23
- "jest.config.ts",
24
- "jest.config.cts",
25
- "src/**/*.spec.ts",
26
- "src/**/*.test.ts"
27
- ],
28
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
29
- }
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "moduleResolution": "node10",
7
- "jsx": "react-jsx",
8
- "types": ["jest", "node"]
9
- },
10
- "include": [
11
- "jest.config.ts",
12
- "jest.config.cts",
13
- "src/**/*.test.ts",
14
- "src/**/*.spec.ts",
15
- "src/**/*.test.tsx",
16
- "src/**/*.spec.tsx",
17
- "src/**/*.test.js",
18
- "src/**/*.spec.js",
19
- "src/**/*.test.jsx",
20
- "src/**/*.spec.jsx",
21
- "src/**/*.d.ts"
22
- ]
23
- }
package/vite.config.ts DELETED
@@ -1,51 +0,0 @@
1
- /// <reference types='vitest' />
2
- import { defineConfig } from 'vite';
3
- import react from '@vitejs/plugin-react';
4
- import dts from 'vite-plugin-dts';
5
- import * as path from 'path';
6
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
7
- import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
8
-
9
- export default defineConfig(() => ({
10
- root: __dirname,
11
- cacheDir: '../../node_modules/.vite/clients/client',
12
- plugins: [
13
- react(),
14
- nxViteTsPaths(),
15
- nxCopyAssetsPlugin(['*.md']),
16
- dts({
17
- entryRoot: 'src',
18
- tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
19
- pathsToAliases: false,
20
- }),
21
- ],
22
- // Uncomment this if you are using workers.
23
- // worker: {
24
- // plugins: [ nxViteTsPaths() ],
25
- // },
26
- // Configuration for building your library.
27
- // See: https://vitejs.dev/guide/build.html#library-mode
28
- build: {
29
- outDir: '../../dist/clients/client',
30
- emptyOutDir: true,
31
- reportCompressedSize: true,
32
- commonjsOptions: {
33
- transformMixedEsModules: true,
34
- },
35
- lib: {
36
- // Could also be a dictionary or array of multiple entry points.
37
- entry: {
38
- index: 'src/index.ts',
39
- },
40
- name: 'client',
41
- fileName: (format, entryName) => `${entryName}.js`,
42
- // Change this to the formats you want to support.
43
- // Don't forget to update your package.json as well.
44
- formats: ['es' as const],
45
- },
46
- rollupOptions: {
47
- // External packages that should not be bundled into your library.
48
- external: ['react', 'react-dom', 'react/jsx-runtime'],
49
- },
50
- },
51
- }));