@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,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"jsx": "preserve",
|
|
7
|
-
"jsxImportSource": "solid-js",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationDir": "./dist",
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"isolatedModules": true
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"src"
|
|
21
|
-
],
|
|
22
|
-
"exclude": [
|
|
23
|
-
"node_modules",
|
|
24
|
-
"dist"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: {
|
|
5
|
-
index: 'src/index.ts',
|
|
6
|
-
},
|
|
7
|
-
format: ['esm'],
|
|
8
|
-
dts: true,
|
|
9
|
-
clean: true,
|
|
10
|
-
outDir: 'dist',
|
|
11
|
-
sourcemap: true,
|
|
12
|
-
external: [
|
|
13
|
-
'solid-js',
|
|
14
|
-
'solid-js/web',
|
|
15
|
-
'solid-js/store',
|
|
16
|
-
'lucide-solid',
|
|
17
|
-
],
|
|
18
|
-
esbuildOptions(options) {
|
|
19
|
-
options.jsx = 'preserve'
|
|
20
|
-
},
|
|
21
|
-
})
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @geenius-tools/errors — Structured error handling
|
|
3
|
-
*
|
|
4
|
-
* Provides a hierarchy of typed errors for different error scenarios.
|
|
5
|
-
* Enables consistent error handling and formatting across the Geenius ecosystem.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Error codes for different error types
|
|
10
|
-
*/
|
|
11
|
-
export enum ErrorCode {
|
|
12
|
-
// Generic
|
|
13
|
-
UNKNOWN = 'UNKNOWN',
|
|
14
|
-
VALIDATION = 'VALIDATION',
|
|
15
|
-
NOT_FOUND = 'NOT_FOUND',
|
|
16
|
-
UNAUTHORIZED = 'UNAUTHORIZED',
|
|
17
|
-
FORBIDDEN = 'FORBIDDEN',
|
|
18
|
-
CONFLICT = 'CONFLICT',
|
|
19
|
-
INTERNAL = 'INTERNAL',
|
|
20
|
-
|
|
21
|
-
// Auth-specific
|
|
22
|
-
INVALID_CREDENTIALS = 'INVALID_CREDENTIALS',
|
|
23
|
-
SESSION_EXPIRED = 'SESSION_EXPIRED',
|
|
24
|
-
MFA_REQUIRED = 'MFA_REQUIRED',
|
|
25
|
-
INVALID_TOKEN = 'INVALID_TOKEN',
|
|
26
|
-
|
|
27
|
-
// Database
|
|
28
|
-
DATABASE_ERROR = 'DATABASE_ERROR',
|
|
29
|
-
CONSTRAINT_VIOLATION = 'CONSTRAINT_VIOLATION',
|
|
30
|
-
|
|
31
|
-
// Network
|
|
32
|
-
NETWORK_ERROR = 'NETWORK_ERROR',
|
|
33
|
-
TIMEOUT = 'TIMEOUT',
|
|
34
|
-
|
|
35
|
-
// Configuration
|
|
36
|
-
INVALID_CONFIG = 'INVALID_CONFIG',
|
|
37
|
-
MISSING_CONFIG = 'MISSING_CONFIG',
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Base Geenius error with structured information
|
|
42
|
-
*/
|
|
43
|
-
export interface GeeniusErrorOptions {
|
|
44
|
-
/** Error code for classification */
|
|
45
|
-
code?: ErrorCode
|
|
46
|
-
/** User-friendly message */
|
|
47
|
-
message: string
|
|
48
|
-
/** Technical details */
|
|
49
|
-
cause?: Error | unknown
|
|
50
|
-
/** HTTP status code equivalent */
|
|
51
|
-
statusCode?: number
|
|
52
|
-
/** Contextual data */
|
|
53
|
-
context?: Record<string, unknown>
|
|
54
|
-
/** Whether error should be logged */
|
|
55
|
-
log?: boolean
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Structured error class for Geenius packages
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* throw new GeeniusError({
|
|
64
|
-
* code: ErrorCode.VALIDATION,
|
|
65
|
-
* message: 'Invalid email format',
|
|
66
|
-
* statusCode: 400,
|
|
67
|
-
* context: { field: 'email' }
|
|
68
|
-
* })
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export class GeeniusError extends Error {
|
|
72
|
-
readonly code: ErrorCode
|
|
73
|
-
readonly statusCode: number
|
|
74
|
-
readonly context: Record<string, unknown>
|
|
75
|
-
readonly cause?: Error | unknown
|
|
76
|
-
readonly log: boolean
|
|
77
|
-
|
|
78
|
-
constructor(options: GeeniusErrorOptions) {
|
|
79
|
-
super(options.message)
|
|
80
|
-
this.name = 'GeeniusError'
|
|
81
|
-
this.code = options.code ?? ErrorCode.UNKNOWN
|
|
82
|
-
this.statusCode = options.statusCode ?? this.getDefaultStatusCode(this.code)
|
|
83
|
-
this.context = options.context ?? {}
|
|
84
|
-
this.cause = options.cause
|
|
85
|
-
this.log = options.log !== false
|
|
86
|
-
|
|
87
|
-
// Maintain proper prototype chain
|
|
88
|
-
Object.setPrototypeOf(this, GeeniusError.prototype)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Gets HTTP status code for error code
|
|
93
|
-
*/
|
|
94
|
-
private getDefaultStatusCode(code: ErrorCode): number {
|
|
95
|
-
const statusMap: Record<ErrorCode, number> = {
|
|
96
|
-
[ErrorCode.UNKNOWN]: 500,
|
|
97
|
-
[ErrorCode.VALIDATION]: 400,
|
|
98
|
-
[ErrorCode.NOT_FOUND]: 404,
|
|
99
|
-
[ErrorCode.UNAUTHORIZED]: 401,
|
|
100
|
-
[ErrorCode.FORBIDDEN]: 403,
|
|
101
|
-
[ErrorCode.CONFLICT]: 409,
|
|
102
|
-
[ErrorCode.INTERNAL]: 500,
|
|
103
|
-
[ErrorCode.INVALID_CREDENTIALS]: 401,
|
|
104
|
-
[ErrorCode.SESSION_EXPIRED]: 401,
|
|
105
|
-
[ErrorCode.MFA_REQUIRED]: 403,
|
|
106
|
-
[ErrorCode.INVALID_TOKEN]: 401,
|
|
107
|
-
[ErrorCode.DATABASE_ERROR]: 500,
|
|
108
|
-
[ErrorCode.CONSTRAINT_VIOLATION]: 409,
|
|
109
|
-
[ErrorCode.NETWORK_ERROR]: 502,
|
|
110
|
-
[ErrorCode.TIMEOUT]: 504,
|
|
111
|
-
[ErrorCode.INVALID_CONFIG]: 500,
|
|
112
|
-
[ErrorCode.MISSING_CONFIG]: 500,
|
|
113
|
-
}
|
|
114
|
-
return statusMap[code]
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Converts error to JSON for serialization
|
|
119
|
-
*/
|
|
120
|
-
toJSON() {
|
|
121
|
-
return {
|
|
122
|
-
name: this.name,
|
|
123
|
-
code: this.code,
|
|
124
|
-
message: this.message,
|
|
125
|
-
statusCode: this.statusCode,
|
|
126
|
-
context: this.context,
|
|
127
|
-
...(this.cause && { cause: formatError(this.cause) }),
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Converts error to string representation
|
|
133
|
-
*/
|
|
134
|
-
toString(): string {
|
|
135
|
-
return `${this.name} [${this.code}]: ${this.message}`
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Validation error for form/input validation failures
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* throw new ValidationError({
|
|
145
|
-
* message: 'Invalid input',
|
|
146
|
-
* context: { errors: { email: 'Invalid format' } }
|
|
147
|
-
* })
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
export class ValidationError extends GeeniusError {
|
|
151
|
-
constructor(options: Omit<GeeniusErrorOptions, 'code' | 'statusCode'>) {
|
|
152
|
-
super({
|
|
153
|
-
...options,
|
|
154
|
-
code: ErrorCode.VALIDATION,
|
|
155
|
-
statusCode: 400,
|
|
156
|
-
})
|
|
157
|
-
this.name = 'ValidationError'
|
|
158
|
-
Object.setPrototypeOf(this, ValidationError.prototype)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Authentication error
|
|
164
|
-
*/
|
|
165
|
-
export class AuthError extends GeeniusError {
|
|
166
|
-
constructor(options: Omit<GeeniusErrorOptions, 'code' | 'statusCode'>) {
|
|
167
|
-
super({
|
|
168
|
-
...options,
|
|
169
|
-
code: options.code ?? ErrorCode.INVALID_CREDENTIALS,
|
|
170
|
-
statusCode: 401,
|
|
171
|
-
})
|
|
172
|
-
this.name = 'AuthError'
|
|
173
|
-
Object.setPrototypeOf(this, AuthError.prototype)
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Not found error
|
|
179
|
-
*/
|
|
180
|
-
export class NotFoundError extends GeeniusError {
|
|
181
|
-
constructor(options: Omit<GeeniusErrorOptions, 'code' | 'statusCode'>) {
|
|
182
|
-
super({
|
|
183
|
-
...options,
|
|
184
|
-
code: ErrorCode.NOT_FOUND,
|
|
185
|
-
statusCode: 404,
|
|
186
|
-
})
|
|
187
|
-
this.name = 'NotFoundError'
|
|
188
|
-
Object.setPrototypeOf(this, NotFoundError.prototype)
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Conflict error (e.g., duplicate key)
|
|
194
|
-
*/
|
|
195
|
-
export class ConflictError extends GeeniusError {
|
|
196
|
-
constructor(options: Omit<GeeniusErrorOptions, 'code' | 'statusCode'>) {
|
|
197
|
-
super({
|
|
198
|
-
...options,
|
|
199
|
-
code: ErrorCode.CONFLICT,
|
|
200
|
-
statusCode: 409,
|
|
201
|
-
})
|
|
202
|
-
this.name = 'ConflictError'
|
|
203
|
-
Object.setPrototypeOf(this, ConflictError.prototype)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Formats any error into structured format
|
|
209
|
-
*
|
|
210
|
-
* @param error Error to format
|
|
211
|
-
* @returns Formatted error object
|
|
212
|
-
*/
|
|
213
|
-
export function formatError(error: unknown): Record<string, unknown> {
|
|
214
|
-
if (error instanceof GeeniusError) {
|
|
215
|
-
return error.toJSON()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (error instanceof Error) {
|
|
219
|
-
return {
|
|
220
|
-
name: error.name,
|
|
221
|
-
message: error.message,
|
|
222
|
-
stack: error.stack,
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (typeof error === 'string') {
|
|
227
|
-
return { message: error }
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (typeof error === 'object' && error !== null) {
|
|
231
|
-
return error as Record<string, unknown>
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return { message: String(error) }
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Type guard to check if error is GeeniusError
|
|
239
|
-
*
|
|
240
|
-
* @param error Error to check
|
|
241
|
-
* @returns True if error is GeeniusError
|
|
242
|
-
*/
|
|
243
|
-
export function isGeeniusError(error: unknown): error is GeeniusError {
|
|
244
|
-
return error instanceof GeeniusError
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Type guard to check if error is a specific error code
|
|
249
|
-
*
|
|
250
|
-
* @param error Error to check
|
|
251
|
-
* @param code Error code to match
|
|
252
|
-
* @returns True if error has specified code
|
|
253
|
-
*/
|
|
254
|
-
export function isErrorCode(error: unknown, code: ErrorCode): boolean {
|
|
255
|
-
return isGeeniusError(error) && error.code === code
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Wraps a promise to catch and transform errors
|
|
260
|
-
*
|
|
261
|
-
* @param promise Promise to wrap
|
|
262
|
-
* @param handler Error transformation function
|
|
263
|
-
* @returns Promise with transformed errors
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* ```ts
|
|
267
|
-
* const result = await catchError(
|
|
268
|
-
* fetchApi(),
|
|
269
|
-
* (err) => new GeeniusError({
|
|
270
|
-
* code: ErrorCode.NETWORK_ERROR,
|
|
271
|
-
* message: 'API request failed',
|
|
272
|
-
* cause: err
|
|
273
|
-
* })
|
|
274
|
-
* )
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
export async function catchError<T>(
|
|
278
|
-
promise: Promise<T>,
|
|
279
|
-
handler: (error: unknown) => Error
|
|
280
|
-
): Promise<T> {
|
|
281
|
-
try {
|
|
282
|
-
return await promise
|
|
283
|
-
} catch (error) {
|
|
284
|
-
throw handler(error)
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Creates a safe function that handles errors
|
|
290
|
-
*
|
|
291
|
-
* @param fn Function to wrap
|
|
292
|
-
* @param handler Error transformation
|
|
293
|
-
* @returns Safe version of function
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* ```ts
|
|
297
|
-
* const safeOp = makeSafe(
|
|
298
|
-
* (id: string) => db.user.find(id),
|
|
299
|
-
* (err) => new NotFoundError({ message: 'User not found', cause: err })
|
|
300
|
-
* )
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
export function makeSafe<T extends (...args: any[]) => any>(
|
|
304
|
-
fn: T,
|
|
305
|
-
handler: (error: unknown) => Error
|
|
306
|
-
): T {
|
|
307
|
-
return ((...args: any[]) => {
|
|
308
|
-
try {
|
|
309
|
-
const result = fn(...args)
|
|
310
|
-
if (result instanceof Promise) {
|
|
311
|
-
return result.catch((err: unknown) => {
|
|
312
|
-
throw handler(err)
|
|
313
|
-
})
|
|
314
|
-
}
|
|
315
|
-
return result
|
|
316
|
-
} catch (error) {
|
|
317
|
-
throw handler(error)
|
|
318
|
-
}
|
|
319
|
-
}) as T
|
|
320
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geenius-tools/logger",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Structured logging utilities for Geenius projects",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsup",
|
|
16
|
-
"type-check": "tsc --noEmit",
|
|
17
|
-
"clean": "rm -rf dist .turbo"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"typescript": "~6.0.2",
|
|
21
|
-
"tsup": "^8.0.1"
|
|
22
|
-
},
|
|
23
|
-
"publishConfig": {
|
|
24
|
-
"access": "public"
|
|
25
|
-
},
|
|
26
|
-
"license": "MIT"
|
|
27
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geenius-tools/logger-react",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": false,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"description": "React hooks for @geenius-tools/logger",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"publishConfig": {
|
|
9
|
-
"access": "public"
|
|
10
|
-
},
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"module": "./dist/index.js",
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"import": "./dist/index.js"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"src"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup",
|
|
26
|
-
"clean": "rm -rf dist",
|
|
27
|
-
"type-check": "tsc --noEmit",
|
|
28
|
-
"prepublishOnly": "pnpm clean && pnpm build"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@geenius-tools/logger": "workspace:*"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/react": "^19.0.0",
|
|
35
|
-
"react": "^19.2.4",
|
|
36
|
-
"tsup": "^8.5.1",
|
|
37
|
-
"typescript": "~5.9.3"
|
|
38
|
-
},
|
|
39
|
-
"peerDependencies": {
|
|
40
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
41
|
-
},
|
|
42
|
-
"author": "Antigravity HQ",
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=20.0.0"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/logger-react — src/useMetrics.ts
|
|
2
|
-
|
|
3
|
-
import { useState, useEffect, useCallback } from 'react'
|
|
4
|
-
import { metricsStore, type PerformanceMetric, type MetricsStore } from '@geenius-tools/logger'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* React hook to subscribe to the MetricsStore.
|
|
8
|
-
* Returns the latest metrics array (reactive).
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* import { useMetrics } from '@geenius-tools/logger-react'
|
|
13
|
-
*
|
|
14
|
-
* function DevPanel() {
|
|
15
|
-
* const metrics = useMetrics()
|
|
16
|
-
*
|
|
17
|
-
* return (
|
|
18
|
-
* <ul>
|
|
19
|
-
* {metrics.map(m => (
|
|
20
|
-
* <li key={m.id}>{m.name}: {m.duration?.toFixed(2)}ms</li>
|
|
21
|
-
* ))}
|
|
22
|
-
* </ul>
|
|
23
|
-
* )
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export function useMetrics(store: MetricsStore = metricsStore) {
|
|
28
|
-
const [metrics, setMetrics] = useState<PerformanceMetric[]>(() => store.getMetrics())
|
|
29
|
-
|
|
30
|
-
const handleNewMetrics = useCallback(() => {
|
|
31
|
-
setMetrics([...store.getMetrics()])
|
|
32
|
-
}, [store])
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const unsubscribe = store.subscribe(() => {
|
|
36
|
-
handleNewMetrics()
|
|
37
|
-
})
|
|
38
|
-
return unsubscribe
|
|
39
|
-
}, [store, handleNewMetrics])
|
|
40
|
-
|
|
41
|
-
return metrics
|
|
42
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/logger-react — src/usePerformanceLog.ts
|
|
2
|
-
|
|
3
|
-
import { useMemo } from 'react'
|
|
4
|
-
import {
|
|
5
|
-
perfLog,
|
|
6
|
-
type LogCategory,
|
|
7
|
-
type PerformanceLogger,
|
|
8
|
-
} from '@geenius-tools/logger'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* React hook for component-scoped performance logging.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* import { usePerformanceLog } from '@geenius-tools/logger-react'
|
|
16
|
-
*
|
|
17
|
-
* function MyComponent() {
|
|
18
|
-
* const perf = usePerformanceLog('MyComponent')
|
|
19
|
-
*
|
|
20
|
-
* useEffect(() => {
|
|
21
|
-
* perf.logMount()
|
|
22
|
-
* return () => perf.logUnmount()
|
|
23
|
-
* }, [])
|
|
24
|
-
*
|
|
25
|
-
* perf.logRender()
|
|
26
|
-
*
|
|
27
|
-
* const handleClick = async () => {
|
|
28
|
-
* const end = perf.start('fetch data', 'query')
|
|
29
|
-
* await fetchData()
|
|
30
|
-
* end()
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export function usePerformanceLog(
|
|
36
|
-
componentName: string,
|
|
37
|
-
logger: PerformanceLogger = perfLog,
|
|
38
|
-
) {
|
|
39
|
-
return useMemo(
|
|
40
|
-
() => ({
|
|
41
|
-
/** Log component mounted */
|
|
42
|
-
logMount: () =>
|
|
43
|
-
logger.log(componentName, 'Component mounted', undefined, 'component'),
|
|
44
|
-
/** Log component unmounted */
|
|
45
|
-
logUnmount: () =>
|
|
46
|
-
logger.log(componentName, 'Component unmounted', undefined, 'component'),
|
|
47
|
-
/** Track render count */
|
|
48
|
-
logRender: () => logger.renderCount(componentName),
|
|
49
|
-
/** Log a useEffect execution */
|
|
50
|
-
logEffect: (effectName: string) =>
|
|
51
|
-
logger.log(componentName, `Effect: ${effectName}`, undefined, 'effect'),
|
|
52
|
-
/** Start a timed operation, returns stop function */
|
|
53
|
-
start: (operation: string, category?: LogCategory) =>
|
|
54
|
-
logger.start(componentName, operation, category),
|
|
55
|
-
/** Generic log scoped to this component */
|
|
56
|
-
log: (message: string, data?: unknown, category?: LogCategory) =>
|
|
57
|
-
logger.log(componentName, message, data, category),
|
|
58
|
-
}),
|
|
59
|
-
[componentName, logger],
|
|
60
|
-
)
|
|
61
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"jsx": "react-jsx",
|
|
7
|
-
"lib": [
|
|
8
|
-
"ES2022",
|
|
9
|
-
"DOM",
|
|
10
|
-
"DOM.Iterable"
|
|
11
|
-
],
|
|
12
|
-
"strict": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"resolveJsonModule": true,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"declarationMap": true,
|
|
20
|
-
"sourceMap": true,
|
|
21
|
-
"outDir": "./dist",
|
|
22
|
-
"rootDir": "./src"
|
|
23
|
-
},
|
|
24
|
-
"include": [
|
|
25
|
-
"src"
|
|
26
|
-
],
|
|
27
|
-
"exclude": [
|
|
28
|
-
"node_modules",
|
|
29
|
-
"dist"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: { index: 'src/index.ts' },
|
|
5
|
-
outDir: 'dist',
|
|
6
|
-
format: ['esm'],
|
|
7
|
-
dts: true,
|
|
8
|
-
sourcemap: true,
|
|
9
|
-
clean: true,
|
|
10
|
-
treeshake: true,
|
|
11
|
-
external: ['react', '@geenius-tools/logger'],
|
|
12
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@geenius-tools/logger-solidjs",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": false,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"description": "SolidJS primitives for @geenius-tools/logger",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"publishConfig": {
|
|
9
|
-
"access": "public"
|
|
10
|
-
},
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"module": "./dist/index.js",
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"import": "./dist/index.js"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"src"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup",
|
|
26
|
-
"clean": "rm -rf dist",
|
|
27
|
-
"type-check": "tsc --noEmit",
|
|
28
|
-
"prepublishOnly": "pnpm clean && pnpm build"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@geenius-tools/logger": "workspace:*"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"solid-js": "^1.9.0",
|
|
35
|
-
"tsup": "^8.5.1",
|
|
36
|
-
"typescript": "~5.9.3"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"solid-js": "^1.9.0"
|
|
40
|
-
},
|
|
41
|
-
"author": "Antigravity HQ",
|
|
42
|
-
"engines": {
|
|
43
|
-
"node": ">=20.0.0"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// @geenius-tools/logger-solid — src/createMetrics.ts
|
|
2
|
-
|
|
3
|
-
import { createSignal, onCleanup } from 'solid-js'
|
|
4
|
-
import { metricsStore, type PerformanceMetric, type MetricsStore } from '@geenius-tools/logger'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* SolidJS reactive primitive for subscribing to the MetricsStore.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* import { createMetrics } from '@geenius-tools/logger-solidjs'
|
|
12
|
-
* import { For } from 'solid-js'
|
|
13
|
-
*
|
|
14
|
-
* function DevPanel() {
|
|
15
|
-
* const metrics = createMetrics()
|
|
16
|
-
*
|
|
17
|
-
* return (
|
|
18
|
-
* <ul>
|
|
19
|
-
* <For each={metrics()}>
|
|
20
|
-
* {(m) => <li>{m.name}: {m.duration?.toFixed(2)}ms</li>}
|
|
21
|
-
* </For>
|
|
22
|
-
* </ul>
|
|
23
|
-
* )
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export function createMetrics(store: MetricsStore = metricsStore) {
|
|
28
|
-
const [metrics, setMetrics] = createSignal<PerformanceMetric[]>(store.getMetrics())
|
|
29
|
-
|
|
30
|
-
const unsubscribe = store.subscribe(() => {
|
|
31
|
-
setMetrics([...store.getMetrics()])
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
onCleanup(unsubscribe)
|
|
35
|
-
|
|
36
|
-
return metrics
|
|
37
|
-
}
|