@geenius/tools 0.1.0 → 0.3.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.
- package/package.json +62 -3
- package/packages/convex/shared/README.md +1 -1
- package/packages/devtools/dist/index.d.ts +204 -0
- package/packages/devtools/dist/index.js +186 -0
- package/packages/devtools/dist/index.js.map +1 -0
- package/packages/devtools/react/README.md +1 -1
- package/packages/devtools/solidjs/README.md +1 -1
- package/packages/devtools/solidjs/dist/index.js +1830 -0
- package/packages/devtools/solidjs/dist/index.js.map +1 -0
- package/packages/env/dist/index.d.ts +151 -0
- package/packages/env/dist/index.js +93 -0
- package/packages/env/dist/index.js.map +1 -0
- package/packages/errors/dist/index.d.ts +177 -0
- package/packages/errors/dist/index.js +187 -0
- package/packages/errors/dist/index.js.map +1 -0
- package/packages/errors/react/README.md +1 -1
- package/packages/errors/solidjs/README.md +1 -1
- package/packages/logger/dist/index.d.ts +171 -0
- package/packages/logger/dist/index.js +216 -0
- package/packages/logger/dist/index.js.map +1 -0
- package/packages/logger/react/README.md +1 -1
- package/packages/logger/solidjs/README.md +1 -1
- package/packages/perf/dist/index.d.ts +168 -0
- package/packages/perf/dist/index.js +265 -0
- package/packages/perf/dist/index.js.map +1 -0
- package/packages/perf/react/README.md +1 -1
- package/packages/perf/solidjs/README.md +1 -1
- package/packages/shared/dist/index.d.ts +253 -0
- package/packages/shared/dist/index.js +278 -0
- package/packages/shared/dist/index.js.map +1 -0
- package/.changeset/config.json +0 -11
- package/.env.example +0 -2
- package/.github/CODEOWNERS +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -16
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -11
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/ci.yml +0 -23
- package/.github/workflows/release.yml +0 -29
- package/.node-version +0 -1
- package/.nvmrc +0 -1
- package/.prettierrc +0 -7
- package/.project/ACCOUNT.yaml +0 -4
- package/.project/IDEAS.yaml +0 -7
- package/.project/PROJECT.yaml +0 -11
- package/.project/ROADMAP.yaml +0 -15
- package/CODE_OF_CONDUCT.md +0 -26
- package/CONTRIBUTING.md +0 -69
- package/SECURITY.md +0 -18
- package/SUPPORT.md +0 -14
- package/packages/convex/shared/package.json +0 -42
- package/packages/convex/shared/src/audit/index.ts +0 -5
- package/packages/convex/shared/src/audit/presets.ts +0 -165
- package/packages/convex/shared/src/audit/schema.ts +0 -85
- package/packages/convex/shared/src/audit/write.ts +0 -102
- package/packages/convex/shared/src/extract.ts +0 -75
- package/packages/convex/shared/src/index.ts +0 -41
- package/packages/convex/shared/src/messages.ts +0 -45
- package/packages/convex/shared/src/security.ts +0 -112
- package/packages/convex/shared/src/throw.ts +0 -184
- package/packages/convex/shared/src/types.ts +0 -57
- package/packages/convex/shared/src/utils.ts +0 -58
- package/packages/convex/shared/tsconfig.json +0 -28
- package/packages/convex/shared/tsup.config.ts +0 -12
- package/packages/devtools/package.json +0 -27
- package/packages/devtools/react/package.json +0 -53
- package/packages/devtools/react/src/components/DesignPreview.tsx +0 -59
- package/packages/devtools/react/src/components/DesignSwitcherDropdown.tsx +0 -99
- package/packages/devtools/react/src/components/DevSidebar.tsx +0 -247
- package/packages/devtools/react/src/components/DevToolbar.tsx +0 -242
- package/packages/devtools/react/src/components/GitHubIssueDialog.tsx +0 -402
- package/packages/devtools/react/src/components/InspectorOverlay.tsx +0 -312
- package/packages/devtools/react/src/components/PageLoadWaterfall.tsx +0 -144
- package/packages/devtools/react/src/components/PerformancePanel.tsx +0 -330
- package/packages/devtools/react/src/context/DevModeContext.tsx +0 -226
- package/packages/devtools/react/src/context/PerformanceContext.tsx +0 -143
- package/packages/devtools/react/src/data/designs.ts +0 -13
- package/packages/devtools/react/src/hooks/useGitHubLabels.ts +0 -47
- package/packages/devtools/react/src/hooks/useVirtualList.ts +0 -124
- package/packages/devtools/react/src/index.ts +0 -77
- package/packages/devtools/react/src/panels/ConvexSpy.tsx +0 -130
- package/packages/devtools/react/src/panels/DatabaseSeeder.tsx +0 -116
- package/packages/devtools/react/src/panels/DevModePhase2.tsx +0 -191
- package/packages/devtools/react/src/panels/DevModePhase3.tsx +0 -234
- package/packages/devtools/react/src/panels/FeatureFlagsToggle.tsx +0 -104
- package/packages/devtools/react/src/panels/QuickRouteJump.tsx +0 -152
- package/packages/devtools/react/src/services/github-service.ts +0 -247
- package/packages/devtools/react/tsconfig.json +0 -31
- package/packages/devtools/react/tsup.config.ts +0 -18
- package/packages/devtools/solidjs/package.json +0 -49
- package/packages/devtools/solidjs/src/components/DesignPreview.tsx +0 -51
- package/packages/devtools/solidjs/src/components/DesignSwitcherDropdown.tsx +0 -95
- package/packages/devtools/solidjs/src/components/DevSidebar.tsx +0 -247
- package/packages/devtools/solidjs/src/components/DevToolbar.tsx +0 -242
- package/packages/devtools/solidjs/src/components/GitHubIssueDialog.tsx +0 -400
- package/packages/devtools/solidjs/src/components/InspectorOverlay.tsx +0 -311
- package/packages/devtools/solidjs/src/components/PageLoadWaterfall.tsx +0 -144
- package/packages/devtools/solidjs/src/components/PerformancePanel.tsx +0 -330
- package/packages/devtools/solidjs/src/context/DevModeContext.tsx +0 -216
- package/packages/devtools/solidjs/src/context/PerformanceContext.tsx +0 -135
- package/packages/devtools/solidjs/src/data/designs.ts +0 -13
- package/packages/devtools/solidjs/src/hooks/createGitHubLabels.ts +0 -47
- package/packages/devtools/solidjs/src/index.ts +0 -64
- package/packages/devtools/solidjs/src/services/github-service.ts +0 -247
- package/packages/devtools/solidjs/tsconfig.json +0 -21
- package/packages/devtools/src/index.ts +0 -377
- package/packages/devtools/tsup.config.ts +0 -12
- package/packages/env/package.json +0 -30
- package/packages/env/src/index.ts +0 -264
- package/packages/env/tsup.config.ts +0 -12
- package/packages/errors/package.json +0 -27
- package/packages/errors/react/package.json +0 -72
- package/packages/errors/react/src/analytics.ts +0 -16
- package/packages/errors/react/src/components/ErrorBoundary.tsx +0 -248
- package/packages/errors/react/src/components/ErrorDisplay.tsx +0 -328
- package/packages/errors/react/src/components/ValidationErrors.tsx +0 -102
- package/packages/errors/react/src/config.ts +0 -199
- package/packages/errors/react/src/constants.ts +0 -74
- package/packages/errors/react/src/hooks/useErrorBoundary.ts +0 -92
- package/packages/errors/react/src/hooks/useErrorHandler.ts +0 -87
- package/packages/errors/react/src/index.ts +0 -96
- package/packages/errors/react/src/types.ts +0 -102
- package/packages/errors/react/src/utils/errorMessages.ts +0 -35
- package/packages/errors/react/src/utils/errorPolicy.ts +0 -139
- package/packages/errors/react/src/utils/extractAppError.ts +0 -174
- package/packages/errors/react/src/utils/formatError.ts +0 -112
- package/packages/errors/react/tsconfig.json +0 -25
- package/packages/errors/react/tsup.config.ts +0 -24
- package/packages/errors/solidjs/package.json +0 -46
- package/packages/errors/solidjs/src/components/ErrorDisplay.tsx +0 -179
- package/packages/errors/solidjs/src/config.ts +0 -98
- package/packages/errors/solidjs/src/hooks/createErrorHandler.ts +0 -107
- package/packages/errors/solidjs/src/index.ts +0 -61
- package/packages/errors/solidjs/src/types.ts +0 -34
- package/packages/errors/solidjs/src/utils/errorPolicy.ts +0 -56
- package/packages/errors/solidjs/src/utils/extractAppError.ts +0 -94
- package/packages/errors/solidjs/src/utils/formatError.ts +0 -33
- package/packages/errors/solidjs/tsconfig.json +0 -26
- package/packages/errors/solidjs/tsup.config.ts +0 -21
- package/packages/errors/src/index.ts +0 -320
- package/packages/errors/tsup.config.ts +0 -12
- package/packages/logger/package.json +0 -27
- package/packages/logger/react/package.json +0 -46
- package/packages/logger/react/src/index.ts +0 -4
- package/packages/logger/react/src/useMetrics.ts +0 -42
- package/packages/logger/react/src/usePerformanceLog.ts +0 -61
- package/packages/logger/react/tsconfig.json +0 -31
- package/packages/logger/react/tsup.config.ts +0 -12
- package/packages/logger/solidjs/package.json +0 -45
- package/packages/logger/solidjs/src/createMetrics.ts +0 -37
- package/packages/logger/solidjs/src/createPerformanceLog.ts +0 -58
- package/packages/logger/solidjs/src/index.ts +0 -4
- package/packages/logger/solidjs/tsconfig.json +0 -32
- package/packages/logger/solidjs/tsup.config.ts +0 -12
- package/packages/logger/src/index.ts +0 -363
- package/packages/logger/tsup.config.ts +0 -12
- package/packages/perf/package.json +0 -27
- package/packages/perf/react/package.json +0 -59
- package/packages/perf/react/src/components/PerformanceDashboard.tsx +0 -257
- package/packages/perf/react/src/hooks/useMonitoredQuery.ts +0 -89
- package/packages/perf/react/src/hooks/usePerformanceMetrics.ts +0 -78
- package/packages/perf/react/src/index.ts +0 -33
- package/packages/perf/react/src/services/PerformanceMonitor.ts +0 -313
- package/packages/perf/react/src/types.ts +0 -77
- package/packages/perf/react/tsconfig.json +0 -25
- package/packages/perf/react/tsup.config.ts +0 -19
- package/packages/perf/solidjs/package.json +0 -41
- package/packages/perf/solidjs/src/components/PerformanceDashboard.tsx +0 -207
- package/packages/perf/solidjs/src/hooks/createPerformanceMetrics.ts +0 -73
- package/packages/perf/solidjs/src/index.ts +0 -31
- package/packages/perf/solidjs/src/services/PerformanceMonitor.ts +0 -134
- package/packages/perf/solidjs/src/types.ts +0 -78
- package/packages/perf/solidjs/tsconfig.json +0 -26
- package/packages/perf/solidjs/tsup.config.ts +0 -14
- package/packages/perf/src/index.ts +0 -410
- package/packages/perf/tsup.config.ts +0 -12
- package/pnpm-workspace.yaml +0 -2
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/errors-react — src/types.ts
|
|
2
|
-
// Self-contained error types (no Convex path imports)
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Application error codes
|
|
6
|
-
*/
|
|
7
|
-
export type AppErrorCode =
|
|
8
|
-
| 'UNAUTHENTICATED'
|
|
9
|
-
| 'FORBIDDEN'
|
|
10
|
-
| 'NOT_FOUND'
|
|
11
|
-
| 'BAD_REQUEST'
|
|
12
|
-
| 'CONFLICT'
|
|
13
|
-
| 'INTERNAL'
|
|
14
|
-
| 'VALIDATION_ERROR'
|
|
15
|
-
| 'RATE_LIMITED'
|
|
16
|
-
| 'FEATURE_DISABLED'
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Validation error for a single field
|
|
20
|
-
*/
|
|
21
|
-
export interface ValidationError {
|
|
22
|
-
field: string
|
|
23
|
-
message: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Full error payload structure (matches ConvexError.data shape)
|
|
28
|
-
*/
|
|
29
|
-
export interface AppErrorPayload {
|
|
30
|
-
code: AppErrorCode
|
|
31
|
-
message: string
|
|
32
|
-
details?: Record<string, unknown>
|
|
33
|
-
validationErrors?: ValidationError[]
|
|
34
|
-
_metadata?: {
|
|
35
|
-
requestId?: string
|
|
36
|
-
functionName?: string
|
|
37
|
-
timestamp?: string
|
|
38
|
-
userId?: string
|
|
39
|
-
[key: string]: unknown
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Display variants for error components
|
|
45
|
-
*/
|
|
46
|
-
export type ErrorDisplayVariant = 'page' | 'card' | 'inline' | 'toast'
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Error analytics filter options
|
|
50
|
-
*/
|
|
51
|
-
export type ErrorAnalyticsFilters = {
|
|
52
|
-
errorCode?: string
|
|
53
|
-
functionName?: string
|
|
54
|
-
timeRange?: { start: Date; end: Date }
|
|
55
|
-
bucketType?: 'hourly' | 'daily'
|
|
56
|
-
showMuted?: boolean
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Error trend data point
|
|
61
|
-
*/
|
|
62
|
-
export type ErrorTrend = {
|
|
63
|
-
timeBucket: string
|
|
64
|
-
errorCode: string
|
|
65
|
-
functionName: string
|
|
66
|
-
count: number
|
|
67
|
-
uniqueUsers: number
|
|
68
|
-
firstOccurrence: string
|
|
69
|
-
lastOccurrence: string
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Error analytics entry (from Convex)
|
|
74
|
-
*/
|
|
75
|
-
export type ErrorAnalyticsEntry = {
|
|
76
|
-
_id: string
|
|
77
|
-
_creationTime: number
|
|
78
|
-
timeBucket: string
|
|
79
|
-
bucketType: 'hourly' | 'daily'
|
|
80
|
-
errorCode: AppErrorCode
|
|
81
|
-
functionName: string
|
|
82
|
-
count: number
|
|
83
|
-
uniqueUsers: string[]
|
|
84
|
-
firstOccurrence: string
|
|
85
|
-
lastOccurrence: string
|
|
86
|
-
muted?: boolean
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Muted error entry
|
|
91
|
-
*/
|
|
92
|
-
export type ErrorMute = {
|
|
93
|
-
_id: string
|
|
94
|
-
_creationTime: number
|
|
95
|
-
errorCode: string
|
|
96
|
-
functionName: string // "*" = all functions
|
|
97
|
-
muted: boolean
|
|
98
|
-
mutedAt?: string
|
|
99
|
-
mutedBy?: string
|
|
100
|
-
muteReason?: string
|
|
101
|
-
createdAt: string
|
|
102
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/errors-react — src/utils/errorMessages.ts
|
|
2
|
-
|
|
3
|
-
import type { AppErrorCode } from '../types'
|
|
4
|
-
import { getErrorMessages } from '../config'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get localized error title by error code
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const title = getErrorTitle('FORBIDDEN') // "Access Denied"
|
|
11
|
-
*/
|
|
12
|
-
export function getErrorTitle(code: AppErrorCode): string {
|
|
13
|
-
return getErrorMessages().titles[code] || 'Error'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get fallback error message by error code
|
|
18
|
-
*/
|
|
19
|
-
export function getFallbackMessage(code: AppErrorCode): string {
|
|
20
|
-
return getErrorMessages().messages[code]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get detailed user-friendly error description
|
|
25
|
-
*/
|
|
26
|
-
export function getErrorDescription(code: AppErrorCode): string {
|
|
27
|
-
return getErrorMessages().descriptions[code] || 'An unexpected error occurred.'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get suggested action for error code
|
|
32
|
-
*/
|
|
33
|
-
export function getErrorAction(code: AppErrorCode): string {
|
|
34
|
-
return getErrorMessages().actions[code] || 'Try again or contact support.'
|
|
35
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/errors-react — src/utils/errorPolicy.ts
|
|
2
|
-
|
|
3
|
-
import { extractAppError, extractRequestId } from './extractAppError'
|
|
4
|
-
import { getErrorHandlerConfig } from '../config'
|
|
5
|
-
import { getErrorMessages } from '../config'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Global error handling policy
|
|
9
|
-
*
|
|
10
|
-
* Uses the configured toast function (set via configureErrorHandler).
|
|
11
|
-
* If no toast is configured, errors are logged to console.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // In your app setup:
|
|
15
|
-
* import toast from 'react-hot-toast'
|
|
16
|
-
* configureErrorHandler({ toast })
|
|
17
|
-
*
|
|
18
|
-
* // Then in router/query client:
|
|
19
|
-
* queryClient: new QueryClient({
|
|
20
|
-
* defaultOptions: { mutations: { onError: handleAppError } },
|
|
21
|
-
* })
|
|
22
|
-
*/
|
|
23
|
-
export function handleAppError(error: unknown): void {
|
|
24
|
-
const appError = extractAppError(error)
|
|
25
|
-
const requestId = extractRequestId(error)
|
|
26
|
-
const config = getErrorHandlerConfig()
|
|
27
|
-
const messages = getErrorMessages().messages
|
|
28
|
-
|
|
29
|
-
const showError = (msg: string) => {
|
|
30
|
-
if (config.toast) {
|
|
31
|
-
config.toast.error(msg)
|
|
32
|
-
} else {
|
|
33
|
-
console.error('[errors-react]', msg)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// If not an app error, show generic error
|
|
38
|
-
if (!appError) {
|
|
39
|
-
const msg = requestId
|
|
40
|
-
? `An unexpected error occurred. Request ID: ${requestId}`
|
|
41
|
-
: 'An unexpected error occurred.'
|
|
42
|
-
showError(msg)
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const message = appError.message ?? messages[appError.code]
|
|
47
|
-
|
|
48
|
-
switch (appError.code) {
|
|
49
|
-
case 'UNAUTHENTICATED':
|
|
50
|
-
// Don't show toast — auth provider handles redirect
|
|
51
|
-
break
|
|
52
|
-
|
|
53
|
-
case 'FORBIDDEN':
|
|
54
|
-
case 'NOT_FOUND':
|
|
55
|
-
case 'BAD_REQUEST':
|
|
56
|
-
case 'CONFLICT':
|
|
57
|
-
showError(message)
|
|
58
|
-
break
|
|
59
|
-
|
|
60
|
-
case 'INTERNAL': {
|
|
61
|
-
const internalMsg = requestId
|
|
62
|
-
? `${message} Request ID: ${requestId}`
|
|
63
|
-
: message
|
|
64
|
-
showError(internalMsg)
|
|
65
|
-
break
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
case 'VALIDATION_ERROR':
|
|
69
|
-
// Don't show toast — handled by ValidationErrors component
|
|
70
|
-
break
|
|
71
|
-
|
|
72
|
-
case 'RATE_LIMITED':
|
|
73
|
-
case 'FEATURE_DISABLED':
|
|
74
|
-
showError(message)
|
|
75
|
-
break
|
|
76
|
-
|
|
77
|
-
default: {
|
|
78
|
-
const defaultMsg = requestId
|
|
79
|
-
? `${message} Request ID: ${requestId}`
|
|
80
|
-
: message
|
|
81
|
-
showError(defaultMsg)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Silent error handler (no toast)
|
|
88
|
-
*/
|
|
89
|
-
export function handleAppErrorSilent(error: unknown) {
|
|
90
|
-
return extractAppError(error)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Check if error should be retried
|
|
95
|
-
*/
|
|
96
|
-
export function shouldRetryError(error: unknown): boolean {
|
|
97
|
-
const appError = extractAppError(error)
|
|
98
|
-
|
|
99
|
-
if (!appError) {
|
|
100
|
-
// Unknown errors can be retried (might be network)
|
|
101
|
-
return true
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
switch (appError.code) {
|
|
105
|
-
case 'RATE_LIMITED':
|
|
106
|
-
case 'INTERNAL':
|
|
107
|
-
return true
|
|
108
|
-
case 'UNAUTHENTICATED':
|
|
109
|
-
case 'FORBIDDEN':
|
|
110
|
-
case 'NOT_FOUND':
|
|
111
|
-
case 'BAD_REQUEST':
|
|
112
|
-
case 'VALIDATION_ERROR':
|
|
113
|
-
case 'CONFLICT':
|
|
114
|
-
case 'FEATURE_DISABLED':
|
|
115
|
-
return false
|
|
116
|
-
default:
|
|
117
|
-
return false
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Get retry delay for error (in milliseconds)
|
|
123
|
-
*/
|
|
124
|
-
export function getRetryDelay(error: unknown, attemptNumber: number): number {
|
|
125
|
-
const appError = extractAppError(error)
|
|
126
|
-
|
|
127
|
-
if (!appError) {
|
|
128
|
-
return Math.min(1000 * Math.pow(2, attemptNumber - 1), 30000)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
switch (appError.code) {
|
|
132
|
-
case 'RATE_LIMITED':
|
|
133
|
-
return Math.min(1000 * Math.pow(2, attemptNumber - 1), 60000)
|
|
134
|
-
case 'INTERNAL':
|
|
135
|
-
return 2000
|
|
136
|
-
default:
|
|
137
|
-
return 0
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/errors-react — src/utils/extractAppError.ts
|
|
2
|
-
|
|
3
|
-
import type { AppErrorPayload, AppErrorCode } from '../types'
|
|
4
|
-
|
|
5
|
-
const VALID_CODES: AppErrorCode[] = [
|
|
6
|
-
'UNAUTHENTICATED',
|
|
7
|
-
'FORBIDDEN',
|
|
8
|
-
'NOT_FOUND',
|
|
9
|
-
'BAD_REQUEST',
|
|
10
|
-
'CONFLICT',
|
|
11
|
-
'INTERNAL',
|
|
12
|
-
'VALIDATION_ERROR',
|
|
13
|
-
'RATE_LIMITED',
|
|
14
|
-
'FEATURE_DISABLED',
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Type guard to check if an object is an AppErrorPayload
|
|
19
|
-
*/
|
|
20
|
-
function isAppErrorPayload(x: unknown): x is AppErrorPayload {
|
|
21
|
-
if (!x || typeof x !== 'object') return false
|
|
22
|
-
const obj = x as Record<string, unknown>
|
|
23
|
-
if (typeof obj.code !== 'string') return false
|
|
24
|
-
return VALID_CODES.includes(obj.code as AppErrorCode)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Normalize error message from various error formats
|
|
29
|
-
*/
|
|
30
|
-
export function normalizeErrorMessage(error: unknown): string {
|
|
31
|
-
if (typeof error === 'string') return error
|
|
32
|
-
if (error instanceof Error) return error.message || error.toString()
|
|
33
|
-
if (error && typeof error === 'object' && 'message' in error) {
|
|
34
|
-
const msg = (error as { message?: unknown }).message
|
|
35
|
-
if (typeof msg === 'string') return msg
|
|
36
|
-
}
|
|
37
|
-
return String(error)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Extract AppErrorPayload from ConvexError or other error types
|
|
42
|
-
*
|
|
43
|
-
* @param error - The error to extract from (ConvexError, Error, or unknown)
|
|
44
|
-
* @returns AppErrorPayload if found, null otherwise
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* try {
|
|
48
|
-
* await mutation(...)
|
|
49
|
-
* } catch (error) {
|
|
50
|
-
* const appError = extractAppError(error)
|
|
51
|
-
* if (appError) {
|
|
52
|
-
* console.log(appError.code, appError.message)
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
*/
|
|
56
|
-
export function extractAppError(error: unknown): AppErrorPayload | null {
|
|
57
|
-
// Strategy 1: Check ConvexError.data (new backend format)
|
|
58
|
-
if (error && typeof error === 'object' && 'data' in error) {
|
|
59
|
-
const data = (error as { data: unknown }).data
|
|
60
|
-
if (isAppErrorPayload(data)) {
|
|
61
|
-
return data as AppErrorPayload
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Strategy 2: Check if error itself is AppErrorPayload
|
|
66
|
-
if (isAppErrorPayload(error)) {
|
|
67
|
-
return error as AppErrorPayload
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Strategy 3: Check error._metadata for backend format
|
|
71
|
-
if (error && typeof error === 'object' && '_metadata' in error) {
|
|
72
|
-
const meta = (error as { _metadata: unknown })._metadata
|
|
73
|
-
if (meta && typeof meta === 'object' && 'code' in meta) {
|
|
74
|
-
const code = (meta as { code: unknown }).code
|
|
75
|
-
if (typeof code === 'string' && isAppErrorPayload({ code })) {
|
|
76
|
-
return error as AppErrorPayload
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return null
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Extract request ID from error (from metadata or Convex debug message)
|
|
86
|
-
*/
|
|
87
|
-
export function extractRequestId(error: unknown): string | undefined {
|
|
88
|
-
if (error && typeof error === 'object') {
|
|
89
|
-
const err = error as Record<string, unknown>
|
|
90
|
-
|
|
91
|
-
// ConvexError.data._metadata.requestId
|
|
92
|
-
if (err.data && typeof err.data === 'object') {
|
|
93
|
-
const data = err.data as Record<string, unknown>
|
|
94
|
-
if (data._metadata && typeof data._metadata === 'object') {
|
|
95
|
-
const meta = data._metadata as Record<string, unknown>
|
|
96
|
-
if (typeof meta.requestId === 'string') {
|
|
97
|
-
return meta.requestId
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Direct _metadata.requestId
|
|
103
|
-
if (err._metadata && typeof err._metadata === 'object') {
|
|
104
|
-
const meta = err._metadata as Record<string, unknown>
|
|
105
|
-
if (typeof meta.requestId === 'string') {
|
|
106
|
-
return meta.requestId
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Parse from Convex debug message format
|
|
112
|
-
const message = normalizeErrorMessage(error)
|
|
113
|
-
const requestIdMatch = message.match(/Request ID:\s*([^\]\s]+)/i)
|
|
114
|
-
if (requestIdMatch?.[1]) {
|
|
115
|
-
return requestIdMatch[1]
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return undefined
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Extract function name from error (from metadata or Convex debug message)
|
|
123
|
-
*/
|
|
124
|
-
export function extractFunctionName(error: unknown): string | undefined {
|
|
125
|
-
if (error && typeof error === 'object') {
|
|
126
|
-
const err = error as Record<string, unknown>
|
|
127
|
-
|
|
128
|
-
// ConvexError.data._metadata.functionName
|
|
129
|
-
if (err.data && typeof err.data === 'object') {
|
|
130
|
-
const data = err.data as Record<string, unknown>
|
|
131
|
-
if (data._metadata && typeof data._metadata === 'object') {
|
|
132
|
-
const meta = data._metadata as Record<string, unknown>
|
|
133
|
-
if (typeof meta.functionName === 'string') {
|
|
134
|
-
return meta.functionName
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Direct _metadata.functionName
|
|
140
|
-
if (err._metadata && typeof err._metadata === 'object') {
|
|
141
|
-
const meta = err._metadata as Record<string, unknown>
|
|
142
|
-
if (typeof meta.functionName === 'string') {
|
|
143
|
-
return meta.functionName
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Parse from Convex debug message format
|
|
149
|
-
const message = normalizeErrorMessage(error)
|
|
150
|
-
const operationMatch = message.match(/\[CONVEX [QM]\(([^)]+)\)\]/i)
|
|
151
|
-
if (operationMatch?.[1]) {
|
|
152
|
-
return operationMatch[1]
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return undefined
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Get detailed error information for debugging
|
|
160
|
-
*/
|
|
161
|
-
export function getErrorDetails(error: unknown) {
|
|
162
|
-
const appError = extractAppError(error)
|
|
163
|
-
const requestId = extractRequestId(error)
|
|
164
|
-
const functionName = extractFunctionName(error)
|
|
165
|
-
const message = normalizeErrorMessage(error)
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
appError,
|
|
169
|
-
requestId,
|
|
170
|
-
functionName,
|
|
171
|
-
message,
|
|
172
|
-
raw: error,
|
|
173
|
-
}
|
|
174
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/errors-react — src/utils/formatError.ts
|
|
2
|
-
|
|
3
|
-
import type { ValidationError } from '../types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Format validation errors for display
|
|
7
|
-
*
|
|
8
|
-
* @param errors - Array of validation errors
|
|
9
|
-
* @returns Formatted error messages grouped by field
|
|
10
|
-
*/
|
|
11
|
-
export function formatValidationErrors(
|
|
12
|
-
errors: ValidationError[],
|
|
13
|
-
): Record<string, string[]> {
|
|
14
|
-
const grouped: Record<string, string[]> = {}
|
|
15
|
-
for (const error of errors) {
|
|
16
|
-
if (!grouped[error.field]) {
|
|
17
|
-
grouped[error.field] = []
|
|
18
|
-
}
|
|
19
|
-
grouped[error.field].push(error.message)
|
|
20
|
-
}
|
|
21
|
-
return grouped
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Format validation errors as a single string
|
|
26
|
-
*/
|
|
27
|
-
export function formatValidationErrorsAsString(
|
|
28
|
-
errors: ValidationError[],
|
|
29
|
-
): string {
|
|
30
|
-
return errors.map((e) => `${e.field}: ${e.message}`).join('\n')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get first validation error for a specific field
|
|
35
|
-
*/
|
|
36
|
-
export function getFieldError(
|
|
37
|
-
errors: ValidationError[],
|
|
38
|
-
field: string,
|
|
39
|
-
): string | undefined {
|
|
40
|
-
const fieldError = errors.find((e) => e.field === field)
|
|
41
|
-
return fieldError?.message
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get all validation errors for a specific field
|
|
46
|
-
*/
|
|
47
|
-
export function getFieldErrors(
|
|
48
|
-
errors: ValidationError[],
|
|
49
|
-
field: string,
|
|
50
|
-
): string[] {
|
|
51
|
-
return errors.filter((e) => e.field === field).map((e) => e.message)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Format timestamp to readable format
|
|
56
|
-
*/
|
|
57
|
-
export function formatTimestamp(timestamp: string, locale = 'en-US'): string {
|
|
58
|
-
try {
|
|
59
|
-
const date = new Date(timestamp)
|
|
60
|
-
return date.toLocaleString(locale, {
|
|
61
|
-
year: 'numeric',
|
|
62
|
-
month: '2-digit',
|
|
63
|
-
day: '2-digit',
|
|
64
|
-
hour: '2-digit',
|
|
65
|
-
minute: '2-digit',
|
|
66
|
-
})
|
|
67
|
-
} catch {
|
|
68
|
-
return timestamp
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Format relative time
|
|
74
|
-
*/
|
|
75
|
-
export function formatRelativeTime(timestamp: string): string {
|
|
76
|
-
try {
|
|
77
|
-
const date = new Date(timestamp)
|
|
78
|
-
const now = new Date()
|
|
79
|
-
const diffMs = now.getTime() - date.getTime()
|
|
80
|
-
const diffSec = Math.floor(diffMs / 1000)
|
|
81
|
-
const diffMin = Math.floor(diffSec / 60)
|
|
82
|
-
const diffHour = Math.floor(diffMin / 60)
|
|
83
|
-
const diffDay = Math.floor(diffHour / 24)
|
|
84
|
-
|
|
85
|
-
if (diffSec < 60) return 'just now'
|
|
86
|
-
if (diffMin < 60) return `${diffMin} minute${diffMin !== 1 ? 's' : ''} ago`
|
|
87
|
-
if (diffHour < 24) return `${diffHour} hour${diffHour !== 1 ? 's' : ''} ago`
|
|
88
|
-
if (diffDay < 7) return `${diffDay} day${diffDay !== 1 ? 's' : ''} ago`
|
|
89
|
-
|
|
90
|
-
return formatTimestamp(timestamp)
|
|
91
|
-
} catch {
|
|
92
|
-
return timestamp
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Truncate long error messages
|
|
98
|
-
*/
|
|
99
|
-
export function truncateMessage(message: string, maxLength = 200): string {
|
|
100
|
-
if (message.length <= maxLength) return message
|
|
101
|
-
return message.slice(0, maxLength - 3) + '...'
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Format error code for display (convert to title case)
|
|
106
|
-
*/
|
|
107
|
-
export function formatErrorCode(code: string): string {
|
|
108
|
-
return code
|
|
109
|
-
.split('_')
|
|
110
|
-
.map((word) => word.charAt(0) + word.slice(1).toLowerCase())
|
|
111
|
-
.join(' ')
|
|
112
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"jsx": "react-jsx",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"declarationDir": "./dist",
|
|
13
|
-
"outDir": "./dist",
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"isolatedModules": true
|
|
17
|
-
},
|
|
18
|
-
"include": [
|
|
19
|
-
"src"
|
|
20
|
-
],
|
|
21
|
-
"exclude": [
|
|
22
|
-
"node_modules",
|
|
23
|
-
"dist"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: {
|
|
5
|
-
index: 'src/index.ts',
|
|
6
|
-
analytics: 'src/analytics.ts',
|
|
7
|
-
},
|
|
8
|
-
format: ['esm'],
|
|
9
|
-
dts: true,
|
|
10
|
-
clean: true,
|
|
11
|
-
outDir: 'dist',
|
|
12
|
-
sourcemap: true,
|
|
13
|
-
external: [
|
|
14
|
-
'react',
|
|
15
|
-
'react-dom',
|
|
16
|
-
'lucide-react',
|
|
17
|
-
'@geenius-ui/react',
|
|
18
|
-
'@tanstack/react-router',
|
|
19
|
-
'@tanstack/react-query',
|
|
20
|
-
'convex',
|
|
21
|
-
'convex/react',
|
|
22
|
-
'convex/server',
|
|
23
|
-
],
|
|
24
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geenius-tools/errors-solidjs",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "SolidJS error handling UI \u2014 boundaries, displays, hooks & utilities",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"module": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist",
|
|
18
|
-
"README.md"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsup",
|
|
22
|
-
"dev": "tsup --watch",
|
|
23
|
-
"typecheck": "tsc --noEmit"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"solid-js": "^1.9.0",
|
|
27
|
-
"tsup": "^8.5.1",
|
|
28
|
-
"typescript": "~5.9.3"
|
|
29
|
-
},
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"solid-js": "^1.8.0 || ^1.9.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependenciesMeta": {
|
|
34
|
-
"lucide-solid": {
|
|
35
|
-
"optional": true
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"author": "Antigravity HQ",
|
|
39
|
-
"license": "MIT",
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=20.0.0"
|
|
42
|
-
},
|
|
43
|
-
"publishConfig": {
|
|
44
|
-
"access": "public"
|
|
45
|
-
}
|
|
46
|
-
}
|