@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.
Files changed (177) hide show
  1. package/package.json +62 -3
  2. package/packages/convex/shared/README.md +1 -1
  3. package/packages/devtools/dist/index.d.ts +204 -0
  4. package/packages/devtools/dist/index.js +186 -0
  5. package/packages/devtools/dist/index.js.map +1 -0
  6. package/packages/devtools/react/README.md +1 -1
  7. package/packages/devtools/solidjs/README.md +1 -1
  8. package/packages/devtools/solidjs/dist/index.js +1830 -0
  9. package/packages/devtools/solidjs/dist/index.js.map +1 -0
  10. package/packages/env/dist/index.d.ts +151 -0
  11. package/packages/env/dist/index.js +93 -0
  12. package/packages/env/dist/index.js.map +1 -0
  13. package/packages/errors/dist/index.d.ts +177 -0
  14. package/packages/errors/dist/index.js +187 -0
  15. package/packages/errors/dist/index.js.map +1 -0
  16. package/packages/errors/react/README.md +1 -1
  17. package/packages/errors/solidjs/README.md +1 -1
  18. package/packages/logger/dist/index.d.ts +171 -0
  19. package/packages/logger/dist/index.js +216 -0
  20. package/packages/logger/dist/index.js.map +1 -0
  21. package/packages/logger/react/README.md +1 -1
  22. package/packages/logger/solidjs/README.md +1 -1
  23. package/packages/perf/dist/index.d.ts +168 -0
  24. package/packages/perf/dist/index.js +265 -0
  25. package/packages/perf/dist/index.js.map +1 -0
  26. package/packages/perf/react/README.md +1 -1
  27. package/packages/perf/solidjs/README.md +1 -1
  28. package/packages/shared/dist/index.d.ts +253 -0
  29. package/packages/shared/dist/index.js +278 -0
  30. package/packages/shared/dist/index.js.map +1 -0
  31. package/.changeset/config.json +0 -11
  32. package/.env.example +0 -2
  33. package/.github/CODEOWNERS +0 -1
  34. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -16
  35. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -11
  36. package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
  37. package/.github/dependabot.yml +0 -11
  38. package/.github/workflows/ci.yml +0 -23
  39. package/.github/workflows/release.yml +0 -29
  40. package/.node-version +0 -1
  41. package/.nvmrc +0 -1
  42. package/.prettierrc +0 -7
  43. package/.project/ACCOUNT.yaml +0 -4
  44. package/.project/IDEAS.yaml +0 -7
  45. package/.project/PROJECT.yaml +0 -11
  46. package/.project/ROADMAP.yaml +0 -15
  47. package/CODE_OF_CONDUCT.md +0 -26
  48. package/CONTRIBUTING.md +0 -69
  49. package/SECURITY.md +0 -18
  50. package/SUPPORT.md +0 -14
  51. package/packages/convex/shared/package.json +0 -42
  52. package/packages/convex/shared/src/audit/index.ts +0 -5
  53. package/packages/convex/shared/src/audit/presets.ts +0 -165
  54. package/packages/convex/shared/src/audit/schema.ts +0 -85
  55. package/packages/convex/shared/src/audit/write.ts +0 -102
  56. package/packages/convex/shared/src/extract.ts +0 -75
  57. package/packages/convex/shared/src/index.ts +0 -41
  58. package/packages/convex/shared/src/messages.ts +0 -45
  59. package/packages/convex/shared/src/security.ts +0 -112
  60. package/packages/convex/shared/src/throw.ts +0 -184
  61. package/packages/convex/shared/src/types.ts +0 -57
  62. package/packages/convex/shared/src/utils.ts +0 -58
  63. package/packages/convex/shared/tsconfig.json +0 -28
  64. package/packages/convex/shared/tsup.config.ts +0 -12
  65. package/packages/devtools/package.json +0 -27
  66. package/packages/devtools/react/package.json +0 -53
  67. package/packages/devtools/react/src/components/DesignPreview.tsx +0 -59
  68. package/packages/devtools/react/src/components/DesignSwitcherDropdown.tsx +0 -99
  69. package/packages/devtools/react/src/components/DevSidebar.tsx +0 -247
  70. package/packages/devtools/react/src/components/DevToolbar.tsx +0 -242
  71. package/packages/devtools/react/src/components/GitHubIssueDialog.tsx +0 -402
  72. package/packages/devtools/react/src/components/InspectorOverlay.tsx +0 -312
  73. package/packages/devtools/react/src/components/PageLoadWaterfall.tsx +0 -144
  74. package/packages/devtools/react/src/components/PerformancePanel.tsx +0 -330
  75. package/packages/devtools/react/src/context/DevModeContext.tsx +0 -226
  76. package/packages/devtools/react/src/context/PerformanceContext.tsx +0 -143
  77. package/packages/devtools/react/src/data/designs.ts +0 -13
  78. package/packages/devtools/react/src/hooks/useGitHubLabels.ts +0 -47
  79. package/packages/devtools/react/src/hooks/useVirtualList.ts +0 -124
  80. package/packages/devtools/react/src/index.ts +0 -77
  81. package/packages/devtools/react/src/panels/ConvexSpy.tsx +0 -130
  82. package/packages/devtools/react/src/panels/DatabaseSeeder.tsx +0 -116
  83. package/packages/devtools/react/src/panels/DevModePhase2.tsx +0 -191
  84. package/packages/devtools/react/src/panels/DevModePhase3.tsx +0 -234
  85. package/packages/devtools/react/src/panels/FeatureFlagsToggle.tsx +0 -104
  86. package/packages/devtools/react/src/panels/QuickRouteJump.tsx +0 -152
  87. package/packages/devtools/react/src/services/github-service.ts +0 -247
  88. package/packages/devtools/react/tsconfig.json +0 -31
  89. package/packages/devtools/react/tsup.config.ts +0 -18
  90. package/packages/devtools/solidjs/package.json +0 -49
  91. package/packages/devtools/solidjs/src/components/DesignPreview.tsx +0 -51
  92. package/packages/devtools/solidjs/src/components/DesignSwitcherDropdown.tsx +0 -95
  93. package/packages/devtools/solidjs/src/components/DevSidebar.tsx +0 -247
  94. package/packages/devtools/solidjs/src/components/DevToolbar.tsx +0 -242
  95. package/packages/devtools/solidjs/src/components/GitHubIssueDialog.tsx +0 -400
  96. package/packages/devtools/solidjs/src/components/InspectorOverlay.tsx +0 -311
  97. package/packages/devtools/solidjs/src/components/PageLoadWaterfall.tsx +0 -144
  98. package/packages/devtools/solidjs/src/components/PerformancePanel.tsx +0 -330
  99. package/packages/devtools/solidjs/src/context/DevModeContext.tsx +0 -216
  100. package/packages/devtools/solidjs/src/context/PerformanceContext.tsx +0 -135
  101. package/packages/devtools/solidjs/src/data/designs.ts +0 -13
  102. package/packages/devtools/solidjs/src/hooks/createGitHubLabels.ts +0 -47
  103. package/packages/devtools/solidjs/src/index.ts +0 -64
  104. package/packages/devtools/solidjs/src/services/github-service.ts +0 -247
  105. package/packages/devtools/solidjs/tsconfig.json +0 -21
  106. package/packages/devtools/src/index.ts +0 -377
  107. package/packages/devtools/tsup.config.ts +0 -12
  108. package/packages/env/package.json +0 -30
  109. package/packages/env/src/index.ts +0 -264
  110. package/packages/env/tsup.config.ts +0 -12
  111. package/packages/errors/package.json +0 -27
  112. package/packages/errors/react/package.json +0 -72
  113. package/packages/errors/react/src/analytics.ts +0 -16
  114. package/packages/errors/react/src/components/ErrorBoundary.tsx +0 -248
  115. package/packages/errors/react/src/components/ErrorDisplay.tsx +0 -328
  116. package/packages/errors/react/src/components/ValidationErrors.tsx +0 -102
  117. package/packages/errors/react/src/config.ts +0 -199
  118. package/packages/errors/react/src/constants.ts +0 -74
  119. package/packages/errors/react/src/hooks/useErrorBoundary.ts +0 -92
  120. package/packages/errors/react/src/hooks/useErrorHandler.ts +0 -87
  121. package/packages/errors/react/src/index.ts +0 -96
  122. package/packages/errors/react/src/types.ts +0 -102
  123. package/packages/errors/react/src/utils/errorMessages.ts +0 -35
  124. package/packages/errors/react/src/utils/errorPolicy.ts +0 -139
  125. package/packages/errors/react/src/utils/extractAppError.ts +0 -174
  126. package/packages/errors/react/src/utils/formatError.ts +0 -112
  127. package/packages/errors/react/tsconfig.json +0 -25
  128. package/packages/errors/react/tsup.config.ts +0 -24
  129. package/packages/errors/solidjs/package.json +0 -46
  130. package/packages/errors/solidjs/src/components/ErrorDisplay.tsx +0 -179
  131. package/packages/errors/solidjs/src/config.ts +0 -98
  132. package/packages/errors/solidjs/src/hooks/createErrorHandler.ts +0 -107
  133. package/packages/errors/solidjs/src/index.ts +0 -61
  134. package/packages/errors/solidjs/src/types.ts +0 -34
  135. package/packages/errors/solidjs/src/utils/errorPolicy.ts +0 -56
  136. package/packages/errors/solidjs/src/utils/extractAppError.ts +0 -94
  137. package/packages/errors/solidjs/src/utils/formatError.ts +0 -33
  138. package/packages/errors/solidjs/tsconfig.json +0 -26
  139. package/packages/errors/solidjs/tsup.config.ts +0 -21
  140. package/packages/errors/src/index.ts +0 -320
  141. package/packages/errors/tsup.config.ts +0 -12
  142. package/packages/logger/package.json +0 -27
  143. package/packages/logger/react/package.json +0 -46
  144. package/packages/logger/react/src/index.ts +0 -4
  145. package/packages/logger/react/src/useMetrics.ts +0 -42
  146. package/packages/logger/react/src/usePerformanceLog.ts +0 -61
  147. package/packages/logger/react/tsconfig.json +0 -31
  148. package/packages/logger/react/tsup.config.ts +0 -12
  149. package/packages/logger/solidjs/package.json +0 -45
  150. package/packages/logger/solidjs/src/createMetrics.ts +0 -37
  151. package/packages/logger/solidjs/src/createPerformanceLog.ts +0 -58
  152. package/packages/logger/solidjs/src/index.ts +0 -4
  153. package/packages/logger/solidjs/tsconfig.json +0 -32
  154. package/packages/logger/solidjs/tsup.config.ts +0 -12
  155. package/packages/logger/src/index.ts +0 -363
  156. package/packages/logger/tsup.config.ts +0 -12
  157. package/packages/perf/package.json +0 -27
  158. package/packages/perf/react/package.json +0 -59
  159. package/packages/perf/react/src/components/PerformanceDashboard.tsx +0 -257
  160. package/packages/perf/react/src/hooks/useMonitoredQuery.ts +0 -89
  161. package/packages/perf/react/src/hooks/usePerformanceMetrics.ts +0 -78
  162. package/packages/perf/react/src/index.ts +0 -33
  163. package/packages/perf/react/src/services/PerformanceMonitor.ts +0 -313
  164. package/packages/perf/react/src/types.ts +0 -77
  165. package/packages/perf/react/tsconfig.json +0 -25
  166. package/packages/perf/react/tsup.config.ts +0 -19
  167. package/packages/perf/solidjs/package.json +0 -41
  168. package/packages/perf/solidjs/src/components/PerformanceDashboard.tsx +0 -207
  169. package/packages/perf/solidjs/src/hooks/createPerformanceMetrics.ts +0 -73
  170. package/packages/perf/solidjs/src/index.ts +0 -31
  171. package/packages/perf/solidjs/src/services/PerformanceMonitor.ts +0 -134
  172. package/packages/perf/solidjs/src/types.ts +0 -78
  173. package/packages/perf/solidjs/tsconfig.json +0 -26
  174. package/packages/perf/solidjs/tsup.config.ts +0 -14
  175. package/packages/perf/src/index.ts +0 -410
  176. package/packages/perf/tsup.config.ts +0 -12
  177. package/pnpm-workspace.yaml +0 -2
@@ -1,179 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/components/ErrorDisplay.tsx
2
- // SolidJS error display component
3
-
4
- import { Component, Show, For } from 'solid-js'
5
- import { extractAppError, extractRequestId, normalizeErrorMessage } from '../utils/extractAppError'
6
- import { formatValidationErrors } from '../utils/formatError'
7
- import type { AppErrorPayload, ErrorDisplayVariant } from '../types'
8
- import { getErrorMessages } from '../config'
9
-
10
- export interface ErrorDisplayProps {
11
- error: unknown
12
- onRetry?: () => void
13
- variant?: ErrorDisplayVariant
14
- compact?: boolean
15
- showRequestId?: boolean
16
- }
17
-
18
- export const ErrorDisplay: Component<ErrorDisplayProps> = (props) => {
19
- const appError = () => extractAppError(props.error)
20
- const requestId = () => extractRequestId(props.error)
21
- const messages = () => getErrorMessages()
22
-
23
- return (
24
- <Show
25
- when={appError()}
26
- fallback={
27
- <div style={{
28
- "border-radius": "8px",
29
- border: "1px solid var(--border, #e5e7eb)",
30
- "background-color": "var(--panel, #fff)",
31
- padding: props.compact ? "16px" : "24px",
32
- }}>
33
- <div style={{ display: "flex", "align-items": "center", gap: "12px" }}>
34
- <div style={{ flex: "1" }}>
35
- <h3 style={{ "font-size": "14px", "font-weight": "600", margin: "0 0 4px" }}>Error</h3>
36
- <p style={{ "font-size": "14px", color: "var(--muted-foreground, #6b7280)", margin: "0" }}>
37
- {normalizeErrorMessage(props.error)}
38
- </p>
39
- </div>
40
- <Show when={props.onRetry}>
41
- <button
42
- onClick={props.onRetry}
43
- style={{
44
- padding: "6px 12px",
45
- "border-radius": "6px",
46
- border: "1px solid var(--border, #e5e7eb)",
47
- "background-color": "transparent",
48
- cursor: "pointer",
49
- "font-size": "13px",
50
- }}
51
- >
52
- Retry
53
- </button>
54
- </Show>
55
- </div>
56
- </div>
57
- }
58
- >
59
- {(err) => (
60
- <div style={{
61
- "border-radius": "8px",
62
- border: "1px solid var(--border, #e5e7eb)",
63
- "background-color": "var(--panel, #fff)",
64
- padding: props.compact ? "16px" : "24px",
65
- display: "flex",
66
- "flex-direction": "column",
67
- gap: "16px",
68
- }}>
69
- <div style={{ display: "flex", "align-items": "flex-start", gap: "16px" }}>
70
- <div style={{ flex: "1", "min-width": "0" }}>
71
- <h3 style={{
72
- "font-size": props.compact ? "14px" : "16px",
73
- "font-weight": "600",
74
- color: "var(--foreground, #111)",
75
- margin: "0 0 4px",
76
- }}>
77
- {messages().titles[err().code]}
78
- </h3>
79
- <p style={{
80
- "font-size": props.compact ? "13px" : "14px",
81
- color: "var(--muted-foreground, #6b7280)",
82
- margin: "0",
83
- }}>
84
- {err().message ?? messages().messages[err().code]}
85
- </p>
86
- </div>
87
- </div>
88
-
89
- <Show when={err().validationErrors && err().validationErrors!.length > 0}>
90
- <ValidationErrorList errors={err().validationErrors!} />
91
- </Show>
92
-
93
- <Show when={props.showRequestId && requestId()}>
94
- <p style={{
95
- "font-size": "12px",
96
- "font-family": "monospace",
97
- color: "var(--muted-foreground, #6b7280)",
98
- margin: "0",
99
- }}>
100
- Request ID: {requestId()}
101
- </p>
102
- </Show>
103
-
104
- <div style={{ display: "flex", gap: "8px" }}>
105
- <Show when={props.onRetry}>
106
- <button
107
- onClick={props.onRetry}
108
- style={{
109
- padding: "6px 12px",
110
- "border-radius": "6px",
111
- border: "1px solid var(--border, #e5e7eb)",
112
- "background-color": "transparent",
113
- cursor: "pointer",
114
- "font-size": "13px",
115
- "font-weight": "500",
116
- }}
117
- >
118
- Retry
119
- </button>
120
- </Show>
121
- <Show when={!props.onRetry}>
122
- <p style={{
123
- "font-size": "13px",
124
- color: "var(--muted-foreground, #6b7280)",
125
- margin: "0",
126
- }}>
127
- {messages().actions[err().code]}
128
- </p>
129
- </Show>
130
- </div>
131
- </div>
132
- )}
133
- </Show>
134
- )
135
- }
136
-
137
- // Internal component for validation error list
138
- import type { ValidationError } from '../types'
139
-
140
- const ValidationErrorList: Component<{ errors: ValidationError[] }> = (props) => {
141
- const grouped = () => formatValidationErrors(props.errors)
142
-
143
- return (
144
- <div style={{ display: "flex", "flex-direction": "column", gap: "8px" }}>
145
- <For each={Object.entries(grouped())}>
146
- {([field, messages]) => (
147
- <div style={{
148
- display: "flex",
149
- "align-items": "flex-start",
150
- gap: "8px",
151
- padding: "12px",
152
- "border-radius": "8px",
153
- "background-color": "rgba(234, 179, 8, 0.05)",
154
- border: "1px solid rgba(234, 179, 8, 0.2)",
155
- }}>
156
- <div style={{ flex: "1" }}>
157
- <p style={{
158
- "font-size": "14px",
159
- "font-weight": "500",
160
- "text-transform": "capitalize",
161
- color: "#854d0e",
162
- margin: "0",
163
- }}>
164
- {field}
165
- </p>
166
- <For each={messages}>
167
- {(msg) => (
168
- <p style={{ "font-size": "14px", color: "#a16207", margin: "0" }}>
169
- {msg}
170
- </p>
171
- )}
172
- </For>
173
- </div>
174
- </div>
175
- )}
176
- </For>
177
- </div>
178
- )
179
- }
@@ -1,98 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/config.ts
2
- // Pluggable configuration (same API as errors-react)
3
-
4
- import type { AppErrorCode } from './types'
5
-
6
- export interface ToastFn {
7
- (message: string): void
8
- error: (message: string, options?: { id?: string }) => void
9
- success: (message: string, options?: { id?: string }) => void
10
- loading: (message: string, options?: { id?: string }) => string | number
11
- }
12
-
13
- export interface ErrorHandlerConfig {
14
- toast?: ToastFn
15
- logInDev?: boolean
16
- }
17
-
18
- let _errorHandlerConfig: ErrorHandlerConfig = { logInDev: true }
19
-
20
- export function configureErrorHandler(config: ErrorHandlerConfig): void {
21
- _errorHandlerConfig = { ..._errorHandlerConfig, ...config }
22
- }
23
-
24
- export function getErrorHandlerConfig(): ErrorHandlerConfig {
25
- return _errorHandlerConfig
26
- }
27
-
28
- export interface ErrorMessageSet {
29
- messages: Record<AppErrorCode, string>
30
- titles: Record<AppErrorCode, string>
31
- descriptions: Record<AppErrorCode, string>
32
- actions: Record<AppErrorCode, string>
33
- validation: Record<string, string>
34
- }
35
-
36
- export const ERROR_MESSAGES_EN: ErrorMessageSet = {
37
- messages: {
38
- UNAUTHENTICATED: 'Authentication required. Please sign in.',
39
- FORBIDDEN: 'Access denied. You do not have permission for this action.',
40
- NOT_FOUND: 'The requested resource was not found.',
41
- BAD_REQUEST: 'Invalid request. Please check your input.',
42
- CONFLICT: 'A conflict occurred with existing data.',
43
- INTERNAL: 'An internal error occurred. Please try again later.',
44
- VALIDATION_ERROR: 'Some fields are invalid. Please check and try again.',
45
- RATE_LIMITED: 'Too many requests. Please try again later.',
46
- FEATURE_DISABLED: 'This feature is currently disabled.',
47
- },
48
- titles: {
49
- UNAUTHENTICATED: 'Not Authenticated',
50
- FORBIDDEN: 'Access Denied',
51
- NOT_FOUND: 'Not Found',
52
- BAD_REQUEST: 'Invalid Request',
53
- CONFLICT: 'Conflict',
54
- INTERNAL: 'Internal Error',
55
- VALIDATION_ERROR: 'Validation Error',
56
- RATE_LIMITED: 'Too Many Requests',
57
- FEATURE_DISABLED: 'Feature Disabled',
58
- },
59
- descriptions: {
60
- UNAUTHENTICATED: 'Please sign in to continue. Your session may have expired.',
61
- FORBIDDEN: 'You do not have permission for this action. Contact an administrator if you believe this is an error.',
62
- NOT_FOUND: 'The requested resource was not found. It may have been deleted or moved.',
63
- BAD_REQUEST: 'Invalid request. Please check your input and try again.',
64
- CONFLICT: 'This action could not be completed due to a conflict with existing data.',
65
- INTERNAL: 'An internal error occurred. Our team has been notified. Please try again later.',
66
- VALIDATION_ERROR: 'Some of your inputs are invalid. Please check the highlighted fields and try again.',
67
- RATE_LIMITED: 'You have sent too many requests in a short time. Please wait a moment and try again.',
68
- FEATURE_DISABLED: 'This feature is currently disabled. Please try again later or contact support.',
69
- },
70
- actions: {
71
- UNAUTHENTICATED: 'Please sign in again.',
72
- FORBIDDEN: 'Contact an administrator if you need access.',
73
- NOT_FOUND: 'Go back to the home page or use search.',
74
- BAD_REQUEST: 'Check your input and try again.',
75
- CONFLICT: 'Refresh the page and try again.',
76
- INTERNAL: 'Try again in a few minutes.',
77
- VALIDATION_ERROR: 'Fix the highlighted fields.',
78
- RATE_LIMITED: 'Wait a moment and try again.',
79
- FEATURE_DISABLED: 'Try again later or contact support.',
80
- },
81
- validation: {
82
- required: 'This field is required.',
83
- minLength: 'Must be at least {min} characters.',
84
- maxLength: 'Must be at most {max} characters.',
85
- email: 'Please enter a valid email address.',
86
- url: 'Please enter a valid URL.',
87
- },
88
- }
89
-
90
- let _currentMessages: ErrorMessageSet = ERROR_MESSAGES_EN
91
-
92
- export function configureErrorMessages(messages: ErrorMessageSet): void {
93
- _currentMessages = messages
94
- }
95
-
96
- export function getErrorMessages(): ErrorMessageSet {
97
- return _currentMessages
98
- }
@@ -1,107 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/hooks/createErrorHandler.ts
2
- // SolidJS signal-based error handling primitives
3
-
4
- import { createSignal } from 'solid-js'
5
- import { handleAppError, shouldRetryError, getRetryDelay } from '../utils/errorPolicy'
6
- import { extractAppError } from '../utils/extractAppError'
7
-
8
- /**
9
- * Create an error handler for SolidJS
10
- *
11
- * @example
12
- * const { handleError } = createErrorHandler()
13
- * try { await mutation(...) } catch (e) { handleError(e) }
14
- */
15
- export function createErrorHandler() {
16
- const handleError = (error: unknown) => {
17
- handleAppError(error)
18
- }
19
-
20
- return { handleError }
21
- }
22
-
23
- /**
24
- * Create async error handler with loading/error signals
25
- *
26
- * @example
27
- * const { execute, loading, error, hasError } = createAsyncError()
28
- *
29
- * const handleClick = async () => {
30
- * await execute(async () => {
31
- * await someAsyncOperation()
32
- * })
33
- * }
34
- */
35
- export function createAsyncError() {
36
- const [loading, setLoading] = createSignal(false)
37
- const [error, setError] = createSignal<Error | null>(null)
38
-
39
- const execute = async <T>(fn: () => Promise<T>): Promise<T | undefined> => {
40
- setLoading(true)
41
- setError(null)
42
-
43
- try {
44
- const result = await fn()
45
- setLoading(false)
46
- return result
47
- } catch (err) {
48
- setError(err instanceof Error ? err : new Error(String(err)))
49
- setLoading(false)
50
- return undefined
51
- }
52
- }
53
-
54
- const resetError = () => setError(null)
55
-
56
- return {
57
- execute,
58
- loading,
59
- error,
60
- hasError: () => error() !== null,
61
- resetError,
62
- }
63
- }
64
-
65
- /**
66
- * Create error boundary state management
67
- *
68
- * @example
69
- * const { error, hasError, setError, resetError } = createErrorBoundary()
70
- */
71
- export function createErrorBoundary() {
72
- const [error, setErrorState] = createSignal<Error | null>(null)
73
-
74
- const setError = (err: Error | null) => setErrorState(err)
75
- const resetError = () => setErrorState(null)
76
-
77
- return {
78
- error,
79
- hasError: () => error() !== null,
80
- setError,
81
- resetError,
82
- }
83
- }
84
-
85
- /**
86
- * Create error retry configuration
87
- */
88
- export function createErrorRetry(maxRetries = 3) {
89
- return {
90
- retry: (failureCount: number, error: unknown) => {
91
- if (failureCount >= maxRetries) return false
92
- return shouldRetryError(error)
93
- },
94
- retryDelay: (attemptIndex: number, error: unknown) => {
95
- return getRetryDelay(error, attemptIndex + 1)
96
- },
97
- }
98
- }
99
-
100
- /**
101
- * Create error info accessor
102
- */
103
- export function createErrorInfo() {
104
- return {
105
- getErrorInfo: (error: unknown) => extractAppError(error),
106
- }
107
- }
@@ -1,61 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/index.ts
2
-
3
- // ===== Types =====
4
- export type {
5
- AppErrorCode,
6
- AppErrorPayload,
7
- ValidationError,
8
- ErrorDisplayVariant,
9
- } from './types'
10
-
11
- // ===== Config =====
12
- export {
13
- configureErrorHandler,
14
- configureErrorMessages,
15
- getErrorHandlerConfig,
16
- getErrorMessages,
17
- ERROR_MESSAGES_EN,
18
- } from './config'
19
- export type {
20
- ToastFn,
21
- ErrorHandlerConfig,
22
- ErrorMessageSet,
23
- } from './config'
24
-
25
- // ===== Utils =====
26
- export {
27
- extractAppError,
28
- extractRequestId,
29
- extractFunctionName,
30
- getErrorDetails,
31
- normalizeErrorMessage,
32
- } from './utils/extractAppError'
33
-
34
- export {
35
- handleAppError,
36
- handleAppErrorSilent,
37
- shouldRetryError,
38
- getRetryDelay,
39
- } from './utils/errorPolicy'
40
-
41
- export {
42
- formatValidationErrors,
43
- formatValidationErrorsAsString,
44
- getFieldError,
45
- getFieldErrors,
46
- truncateMessage,
47
- formatErrorCode,
48
- } from './utils/formatError'
49
-
50
- // ===== Components =====
51
- export { ErrorDisplay } from './components/ErrorDisplay'
52
- export type { ErrorDisplayProps } from './components/ErrorDisplay'
53
-
54
- // ===== Hooks (SolidJS signals) =====
55
- export {
56
- createErrorHandler,
57
- createAsyncError,
58
- createErrorBoundary,
59
- createErrorRetry,
60
- createErrorInfo,
61
- } from './hooks/createErrorHandler'
@@ -1,34 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/types.ts
2
- // Self-contained error types (same as errors-react, no framework deps)
3
-
4
- export type AppErrorCode =
5
- | 'UNAUTHENTICATED'
6
- | 'FORBIDDEN'
7
- | 'NOT_FOUND'
8
- | 'BAD_REQUEST'
9
- | 'CONFLICT'
10
- | 'INTERNAL'
11
- | 'VALIDATION_ERROR'
12
- | 'RATE_LIMITED'
13
- | 'FEATURE_DISABLED'
14
-
15
- export interface ValidationError {
16
- field: string
17
- message: string
18
- }
19
-
20
- export interface AppErrorPayload {
21
- code: AppErrorCode
22
- message: string
23
- details?: Record<string, unknown>
24
- validationErrors?: ValidationError[]
25
- _metadata?: {
26
- requestId?: string
27
- functionName?: string
28
- timestamp?: string
29
- userId?: string
30
- [key: string]: unknown
31
- }
32
- }
33
-
34
- export type ErrorDisplayVariant = 'page' | 'card' | 'inline' | 'toast'
@@ -1,56 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/utils/errorPolicy.ts
2
-
3
- import { extractAppError, extractRequestId } from './extractAppError'
4
- import { getErrorHandlerConfig, getErrorMessages } from '../config'
5
-
6
- export function handleAppError(error: unknown): void {
7
- const appError = extractAppError(error)
8
- const requestId = extractRequestId(error)
9
- const config = getErrorHandlerConfig()
10
- const messages = getErrorMessages().messages
11
-
12
- const showError = (msg: string) => {
13
- if (config.toast) {
14
- config.toast.error(msg)
15
- } else {
16
- console.error('[errors-solidjs]', msg)
17
- }
18
- }
19
-
20
- if (!appError) {
21
- showError(requestId ? `An unexpected error occurred. Request ID: ${requestId}` : 'An unexpected error occurred.')
22
- return
23
- }
24
-
25
- const message = appError.message ?? messages[appError.code]
26
-
27
- switch (appError.code) {
28
- case 'UNAUTHENTICATED':
29
- case 'VALIDATION_ERROR':
30
- break
31
- case 'INTERNAL': {
32
- showError(requestId ? `${message} Request ID: ${requestId}` : message)
33
- break
34
- }
35
- default:
36
- showError(message)
37
- }
38
- }
39
-
40
- export function handleAppErrorSilent(error: unknown) {
41
- return extractAppError(error)
42
- }
43
-
44
- export function shouldRetryError(error: unknown): boolean {
45
- const appError = extractAppError(error)
46
- if (!appError) return true
47
- return appError.code === 'RATE_LIMITED' || appError.code === 'INTERNAL'
48
- }
49
-
50
- export function getRetryDelay(error: unknown, attemptNumber: number): number {
51
- const appError = extractAppError(error)
52
- if (!appError) return Math.min(1000 * Math.pow(2, attemptNumber - 1), 30000)
53
- if (appError.code === 'RATE_LIMITED') return Math.min(1000 * Math.pow(2, attemptNumber - 1), 60000)
54
- if (appError.code === 'INTERNAL') return 2000
55
- return 0
56
- }
@@ -1,94 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/utils/extractAppError.ts
2
- // Same pure logic as errors-react (no framework dependency)
3
-
4
- import type { AppErrorPayload, AppErrorCode } from '../types'
5
-
6
- const VALID_CODES: AppErrorCode[] = [
7
- 'UNAUTHENTICATED', 'FORBIDDEN', 'NOT_FOUND', 'BAD_REQUEST',
8
- 'CONFLICT', 'INTERNAL', 'VALIDATION_ERROR', 'RATE_LIMITED', 'FEATURE_DISABLED',
9
- ]
10
-
11
- function isAppErrorPayload(x: unknown): x is AppErrorPayload {
12
- if (!x || typeof x !== 'object') return false
13
- const obj = x as Record<string, unknown>
14
- if (typeof obj.code !== 'string') return false
15
- return VALID_CODES.includes(obj.code as AppErrorCode)
16
- }
17
-
18
- export function normalizeErrorMessage(error: unknown): string {
19
- if (typeof error === 'string') return error
20
- if (error instanceof Error) return error.message || error.toString()
21
- if (error && typeof error === 'object' && 'message' in error) {
22
- const msg = (error as { message?: unknown }).message
23
- if (typeof msg === 'string') return msg
24
- }
25
- return String(error)
26
- }
27
-
28
- export function extractAppError(error: unknown): AppErrorPayload | null {
29
- if (error && typeof error === 'object' && 'data' in error) {
30
- const data = (error as { data: unknown }).data
31
- if (isAppErrorPayload(data)) return data as AppErrorPayload
32
- }
33
- if (isAppErrorPayload(error)) return error as AppErrorPayload
34
- if (error && typeof error === 'object' && '_metadata' in error) {
35
- const meta = (error as { _metadata: unknown })._metadata
36
- if (meta && typeof meta === 'object' && 'code' in meta) {
37
- const code = (meta as { code: unknown }).code
38
- if (typeof code === 'string' && isAppErrorPayload({ code })) {
39
- return error as AppErrorPayload
40
- }
41
- }
42
- }
43
- return null
44
- }
45
-
46
- export function extractRequestId(error: unknown): string | undefined {
47
- if (error && typeof error === 'object') {
48
- const err = error as Record<string, unknown>
49
- if (err.data && typeof err.data === 'object') {
50
- const data = err.data as Record<string, unknown>
51
- if (data._metadata && typeof data._metadata === 'object') {
52
- const meta = data._metadata as Record<string, unknown>
53
- if (typeof meta.requestId === 'string') return meta.requestId
54
- }
55
- }
56
- if (err._metadata && typeof err._metadata === 'object') {
57
- const meta = err._metadata as Record<string, unknown>
58
- if (typeof meta.requestId === 'string') return meta.requestId
59
- }
60
- }
61
- const message = normalizeErrorMessage(error)
62
- const match = message.match(/Request ID:\s*([^\]\s]+)/i)
63
- return match?.[1]
64
- }
65
-
66
- export function extractFunctionName(error: unknown): string | undefined {
67
- if (error && typeof error === 'object') {
68
- const err = error as Record<string, unknown>
69
- if (err.data && typeof err.data === 'object') {
70
- const data = err.data as Record<string, unknown>
71
- if (data._metadata && typeof data._metadata === 'object') {
72
- const meta = data._metadata as Record<string, unknown>
73
- if (typeof meta.functionName === 'string') return meta.functionName
74
- }
75
- }
76
- if (err._metadata && typeof err._metadata === 'object') {
77
- const meta = err._metadata as Record<string, unknown>
78
- if (typeof meta.functionName === 'string') return meta.functionName
79
- }
80
- }
81
- const message = normalizeErrorMessage(error)
82
- const match = message.match(/\[CONVEX [QM]\(([^)]+)\)\]/i)
83
- return match?.[1]
84
- }
85
-
86
- export function getErrorDetails(error: unknown) {
87
- return {
88
- appError: extractAppError(error),
89
- requestId: extractRequestId(error),
90
- functionName: extractFunctionName(error),
91
- message: normalizeErrorMessage(error),
92
- raw: error,
93
- }
94
- }
@@ -1,33 +0,0 @@
1
- // @geenius-tools/errors-solidjs — src/utils/formatError.ts
2
-
3
- import type { ValidationError } from '../types'
4
-
5
- export function formatValidationErrors(errors: ValidationError[]): Record<string, string[]> {
6
- const grouped: Record<string, string[]> = {}
7
- for (const error of errors) {
8
- if (!grouped[error.field]) grouped[error.field] = []
9
- grouped[error.field].push(error.message)
10
- }
11
- return grouped
12
- }
13
-
14
- export function formatValidationErrorsAsString(errors: ValidationError[]): string {
15
- return errors.map((e) => `${e.field}: ${e.message}`).join('\n')
16
- }
17
-
18
- export function getFieldError(errors: ValidationError[], field: string): string | undefined {
19
- return errors.find((e) => e.field === field)?.message
20
- }
21
-
22
- export function getFieldErrors(errors: ValidationError[], field: string): string[] {
23
- return errors.filter((e) => e.field === field).map((e) => e.message)
24
- }
25
-
26
- export function truncateMessage(message: string, maxLength = 200): string {
27
- if (message.length <= maxLength) return message
28
- return message.slice(0, maxLength - 3) + '...'
29
- }
30
-
31
- export function formatErrorCode(code: string): string {
32
- return code.split('_').map((word) => word.charAt(0) + word.slice(1).toLowerCase()).join(' ')
33
- }