@veloxts/core 0.3.4 → 0.3.5

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 (44) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js.map +1 -1
  3. package/dist/context.d.ts +26 -1
  4. package/dist/context.d.ts.map +1 -1
  5. package/dist/context.js +29 -0
  6. package/dist/context.js.map +1 -1
  7. package/dist/di/container.d.ts.map +1 -1
  8. package/dist/di/container.js +14 -8
  9. package/dist/di/container.js.map +1 -1
  10. package/dist/di/decorators.d.ts +22 -8
  11. package/dist/di/decorators.d.ts.map +1 -1
  12. package/dist/di/decorators.js.map +1 -1
  13. package/dist/di/index.d.ts +2 -2
  14. package/dist/di/index.d.ts.map +1 -1
  15. package/dist/di/index.js +7 -7
  16. package/dist/di/index.js.map +1 -1
  17. package/dist/di/providers.d.ts +48 -8
  18. package/dist/di/providers.d.ts.map +1 -1
  19. package/dist/di/providers.js.map +1 -1
  20. package/dist/di/scope.d.ts +21 -0
  21. package/dist/di/scope.d.ts.map +1 -1
  22. package/dist/di/scope.js +32 -0
  23. package/dist/di/scope.js.map +1 -1
  24. package/dist/errors/catalog.d.ts +79 -0
  25. package/dist/errors/catalog.d.ts.map +1 -0
  26. package/dist/errors/catalog.js +492 -0
  27. package/dist/errors/catalog.js.map +1 -0
  28. package/dist/errors/formatter.d.ts +101 -0
  29. package/dist/errors/formatter.d.ts.map +1 -0
  30. package/dist/errors/formatter.js +330 -0
  31. package/dist/errors/formatter.js.map +1 -0
  32. package/dist/errors/index.d.ts +14 -0
  33. package/dist/errors/index.d.ts.map +1 -0
  34. package/dist/errors/index.js +16 -0
  35. package/dist/errors/index.js.map +1 -0
  36. package/dist/errors.d.ts +35 -5
  37. package/dist/errors.d.ts.map +1 -1
  38. package/dist/errors.js +57 -4
  39. package/dist/errors.js.map +1 -1
  40. package/dist/index.d.ts +4 -4
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +18 -18
  43. package/dist/index.js.map +1 -1
  44. package/package.json +12 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/di/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAQ/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,oBAAY,KAAK;IACf;;;;;;;;;;;;OAYG;IACH,SAAS,cAAc;IAEvB;;;;;;;;;;OAUG;IACH,SAAS,cAAc;IAEvB;;;;;;;;;;;;;;OAcG;IACH,OAAO,YAAY;CACpB;AAMD;;;GAGG;AACH,QAAA,MAAM,iBAAiB,eAAmC,CAAC;AAE3D;;GAEG;AACH,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,cAAc;QACtB;;;WAGG;QACH,CAAC,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAC7C;CACF;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAE9D;;OAEG;IACH,OAAO,CAAC,uBAAuB,CAAS;IAExC;;;;;;;OAOG;IACH,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAsB9C;;;;;OAKG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,GAAG,SAAS;IAI9C;;;;;OAKG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI;IAIlD;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIrC;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,CAAC,GAAG,SAAS;IAQ3E;;;;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165
  hasSingleton(token) {
166
166
  return this.singletonCache.has(token);
167
167
  }
168
+ /**
169
+ * Gets a singleton instance from cache, throwing if not found
170
+ *
171
+ * Use this when you've already verified with hasSingleton()
172
+ *
173
+ * @param token - The service token
174
+ * @returns The cached instance
175
+ * @throws {VeloxError} If no singleton is cached for this token
176
+ */
177
+ getSingletonOrThrow(token) {
178
+ if (!this.singletonCache.has(token)) {
179
+ throw new VeloxError('Singleton not found for token', 500, 'SINGLETON_NOT_FOUND');
180
+ }
181
+ return this.singletonCache.get(token);
182
+ }
168
183
  /**
169
184
  * Gets a request-scoped instance from the current request's cache
170
185
  *
@@ -204,6 +219,23 @@ export class ScopeManager {
204
219
  const cache = request[REQUEST_SCOPE_KEY];
205
220
  return cache?.has(token) ?? false;
206
221
  }
222
+ /**
223
+ * Gets a request-scoped instance from cache, throwing if not found
224
+ *
225
+ * Use this when you've already verified with hasRequestScoped()
226
+ *
227
+ * @param token - The service token
228
+ * @param request - The current Fastify request
229
+ * @returns The cached instance
230
+ * @throws {VeloxError} If no request-scoped instance is cached for this token
231
+ */
232
+ getRequestScopedOrThrow(token, request) {
233
+ const cache = request[REQUEST_SCOPE_KEY];
234
+ if (!cache || !cache.has(token)) {
235
+ throw new VeloxError('Request-scoped instance not found for token', 500, 'REQUEST_SCOPED_NOT_FOUND');
236
+ }
237
+ return cache.get(token);
238
+ }
207
239
  /**
208
240
  * Validates that request scope is available and returns the request
209
241
  *
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/di/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAN,IAAY,KA6CX;AA7CD,WAAY,KAAK;IACf;;;;;;;;;;;;OAYG;IACH,gCAAuB,CAAA;IAEvB;;;;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AG,CAAC,KAAK,CAAM,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,kBAAkB,CAAC,OAAmC;QACpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,UAAU,CAClB,oEAAoE;gBAClE,kEAAkE,EACpE,GAAG,EACH,2BAA2B,CAC5B,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,UAAU,CAClB,kFAAkF,EAClF,GAAG,EACH,2BAA2B,CAC5B,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,eAAe;QACb,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,uBAAuB,GAAG,KAAK,CAAC;IACvC,CAAC;CACF;AAED,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,KAAK,KAAK,CAAC,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,CAAC,SAAS,CAAC;AACzB,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Error Catalog - Centralized error definitions with fix suggestions
3
+ *
4
+ * Error codes follow the pattern: VELOX-XYYY
5
+ * - X: Domain (1=Core, 2=Router, 3=Auth, 4=ORM, 5=Validation, 6=Client)
6
+ * - YYY: Sequential number within domain
7
+ *
8
+ * @module errors/catalog
9
+ */
10
+ /**
11
+ * Error code domain prefixes
12
+ */
13
+ export declare const ERROR_DOMAINS: {
14
+ readonly CORE: 1;
15
+ readonly ROUTER: 2;
16
+ readonly AUTH: 3;
17
+ readonly ORM: 4;
18
+ readonly VALIDATION: 5;
19
+ readonly CLIENT: 6;
20
+ };
21
+ export type ErrorDomain = keyof typeof ERROR_DOMAINS;
22
+ /**
23
+ * A single error catalog entry with all metadata for developer assistance
24
+ */
25
+ export interface ErrorCatalogEntry {
26
+ /** Unique error code (e.g., 'VELOX-1001') */
27
+ code: string;
28
+ /** Short title for the error */
29
+ title: string;
30
+ /** Detailed explanation of why this error occurs */
31
+ description: string;
32
+ /** HTTP status code to use */
33
+ statusCode: number;
34
+ /** Suggested fix with code example */
35
+ fix?: {
36
+ /** What the developer should do */
37
+ suggestion: string;
38
+ /** Code example showing the fix (optional) */
39
+ example?: string;
40
+ };
41
+ /** Link to documentation page */
42
+ docsUrl?: string;
43
+ /** Related error codes */
44
+ seeAlso?: string[];
45
+ }
46
+ /**
47
+ * The complete error catalog
48
+ * Organized by domain for easy navigation
49
+ */
50
+ export declare const ERROR_CATALOG: Record<string, ErrorCatalogEntry>;
51
+ /**
52
+ * Get an error catalog entry by code
53
+ *
54
+ * @param code - The error code (e.g., 'VELOX-1001')
55
+ * @returns The catalog entry or undefined if not found
56
+ */
57
+ export declare function getErrorEntry(code: string): ErrorCatalogEntry | undefined;
58
+ /**
59
+ * Get all error codes for a specific domain
60
+ *
61
+ * @param domain - The error domain (e.g., 'CORE', 'AUTH')
62
+ * @returns Array of error codes in that domain
63
+ */
64
+ export declare function getErrorsByDomain(domain: ErrorDomain): string[];
65
+ /**
66
+ * Check if an error code exists in the catalog
67
+ *
68
+ * @param code - The error code to check
69
+ * @returns true if the code exists
70
+ */
71
+ export declare function isKnownErrorCode(code: string): boolean;
72
+ /**
73
+ * Get the documentation URL for an error code
74
+ *
75
+ * @param code - The error code
76
+ * @returns The documentation URL or undefined
77
+ */
78
+ export declare function getDocsUrl(code: string): string | undefined;
79
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/errors/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,aAAa,CAAC;AAMrD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IAEb,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IAEd,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IAEpB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IAEnB,sCAAsC;IACtC,GAAG,CAAC,EAAE;QACJ,mCAAmC;QACnC,UAAU,EAAE,MAAM,CAAC;QACnB,8CAA8C;QAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAMD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAqc3D,CAAC;AAMF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAG/D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3D"}
@@ -0,0 +1,492 @@
1
+ /**
2
+ * Error Catalog - Centralized error definitions with fix suggestions
3
+ *
4
+ * Error codes follow the pattern: VELOX-XYYY
5
+ * - X: Domain (1=Core, 2=Router, 3=Auth, 4=ORM, 5=Validation, 6=Client)
6
+ * - YYY: Sequential number within domain
7
+ *
8
+ * @module errors/catalog
9
+ */
10
+ // ============================================================================
11
+ // Error Code Domains
12
+ // ============================================================================
13
+ /**
14
+ * Error code domain prefixes
15
+ */
16
+ export const ERROR_DOMAINS = {
17
+ CORE: 1,
18
+ ROUTER: 2,
19
+ AUTH: 3,
20
+ ORM: 4,
21
+ VALIDATION: 5,
22
+ CLIENT: 6,
23
+ };
24
+ // ============================================================================
25
+ // Error Catalog Registry
26
+ // ============================================================================
27
+ /**
28
+ * The complete error catalog
29
+ * Organized by domain for easy navigation
30
+ */
31
+ export const ERROR_CATALOG = {
32
+ // ==========================================================================
33
+ // CORE ERRORS (1XXX)
34
+ // ==========================================================================
35
+ 'VELOX-1001': {
36
+ code: 'VELOX-1001',
37
+ title: 'Server Already Running',
38
+ description: 'Attempted to start a VeloxTS server that is already running.',
39
+ statusCode: 500,
40
+ fix: {
41
+ suggestion: 'Stop the existing server before starting a new one, or check if another process is using the port.',
42
+ example: `// Stop the server before restarting
43
+ await app.stop();
44
+ await app.start();
45
+
46
+ // Or check if you're calling start() multiple times
47
+ const app = await veloxApp({ port: 3000 });
48
+ await app.start(); // Call only once`,
49
+ },
50
+ docsUrl: 'https://veloxts.dev/errors/VELOX-1001',
51
+ },
52
+ 'VELOX-1002': {
53
+ code: 'VELOX-1002',
54
+ title: 'Server Not Running',
55
+ description: 'Attempted to stop a VeloxTS server that is not running.',
56
+ statusCode: 500,
57
+ fix: {
58
+ suggestion: 'Ensure the server is started before attempting to stop it.',
59
+ example: `const app = await veloxApp({ port: 3000 });
60
+ await app.start(); // Must call start() first
61
+ // ... handle requests
62
+ await app.stop(); // Now safe to stop`,
63
+ },
64
+ docsUrl: 'https://veloxts.dev/errors/VELOX-1002',
65
+ },
66
+ 'VELOX-1003': {
67
+ code: 'VELOX-1003',
68
+ title: 'Plugin Registration Failed',
69
+ description: 'A plugin failed to register with the VeloxTS application.',
70
+ statusCode: 500,
71
+ fix: {
72
+ suggestion: 'Check that the plugin is correctly configured and all required dependencies are available.',
73
+ example: `// Ensure plugin is awaited and properly configured
74
+ await app.register(databasePlugin({
75
+ client: prisma // Required: pass Prisma client
76
+ }));
77
+
78
+ // Check plugin order - some plugins depend on others
79
+ await app.register(databasePlugin({ client: prisma }));
80
+ await app.register(authPlugin(authConfig)); // Auth needs database`,
81
+ },
82
+ docsUrl: 'https://veloxts.dev/errors/VELOX-1003',
83
+ },
84
+ 'VELOX-1004': {
85
+ code: 'VELOX-1004',
86
+ title: 'Configuration Error',
87
+ description: 'The VeloxTS application configuration is invalid or incomplete.',
88
+ statusCode: 500,
89
+ fix: {
90
+ suggestion: 'Review your configuration options and ensure all required fields are provided.',
91
+ example: `// Correct configuration
92
+ const app = await veloxApp({
93
+ port: parseInt(process.env.PORT || '3000'),
94
+ host: process.env.HOST || '0.0.0.0',
95
+ logger: process.env.NODE_ENV !== 'test',
96
+ });`,
97
+ },
98
+ docsUrl: 'https://veloxts.dev/errors/VELOX-1004',
99
+ },
100
+ 'VELOX-1005': {
101
+ code: 'VELOX-1005',
102
+ title: 'Invalid Plugin Metadata',
103
+ description: 'A plugin was registered without required metadata (name, version).',
104
+ statusCode: 500,
105
+ fix: {
106
+ suggestion: 'Ensure your plugin exports proper metadata.',
107
+ example: `// Plugin must have name property
108
+ const myPlugin: VeloxPlugin = {
109
+ name: 'my-plugin',
110
+ version: '1.0.0', // Optional but recommended
111
+ register: async (app) => {
112
+ // Plugin logic
113
+ }
114
+ };`,
115
+ },
116
+ docsUrl: 'https://veloxts.dev/errors/VELOX-1005',
117
+ },
118
+ // ==========================================================================
119
+ // ROUTER ERRORS (2XXX)
120
+ // ==========================================================================
121
+ 'VELOX-2001': {
122
+ code: 'VELOX-2001',
123
+ title: 'Procedure Missing Input Schema',
124
+ description: 'A procedure was defined without an input schema, but receives input data.',
125
+ statusCode: 500,
126
+ fix: {
127
+ suggestion: 'Add .input() to your procedure definition with a Zod schema.',
128
+ example: `export const getUser = procedure()
129
+ .input(z.object({ id: z.string().uuid() })) // Add input schema
130
+ .query(async ({ input, ctx }) => {
131
+ return ctx.db.user.findUnique({ where: { id: input.id } });
132
+ });`,
133
+ },
134
+ docsUrl: 'https://veloxts.dev/errors/VELOX-2001',
135
+ seeAlso: ['VELOX-2002'],
136
+ },
137
+ 'VELOX-2002': {
138
+ code: 'VELOX-2002',
139
+ title: 'Procedure Missing Output Schema',
140
+ description: 'A procedure was defined without an output schema. Output schemas ensure type safety.',
141
+ statusCode: 500,
142
+ fix: {
143
+ suggestion: 'Add .output() to your procedure definition for type-safe responses.',
144
+ example: `export const getUser = procedure()
145
+ .input(z.object({ id: z.string().uuid() }))
146
+ .output(UserSchema) // Add output schema
147
+ .query(async ({ input, ctx }) => {
148
+ return ctx.db.user.findUnique({ where: { id: input.id } });
149
+ });`,
150
+ },
151
+ docsUrl: 'https://veloxts.dev/errors/VELOX-2002',
152
+ seeAlso: ['VELOX-2001'],
153
+ },
154
+ 'VELOX-2003': {
155
+ code: 'VELOX-2003',
156
+ title: 'Guard Authorization Failed',
157
+ description: 'A guard prevented access to a procedure. The user lacks required permissions.',
158
+ statusCode: 403,
159
+ fix: {
160
+ suggestion: 'Ensure the user is authenticated and has the required roles/permissions.',
161
+ example: `// Using built-in guards
162
+ const protectedProcedure = procedure()
163
+ .guard(authenticated) // Requires valid auth
164
+ .query(({ ctx }) => ctx.user);
165
+
166
+ // Check user has required role
167
+ const adminProcedure = procedure()
168
+ .guard(hasRole('admin'))
169
+ .mutation(({ input }) => { /* ... */ });`,
170
+ },
171
+ docsUrl: 'https://veloxts.dev/errors/VELOX-2003',
172
+ },
173
+ 'VELOX-2004': {
174
+ code: 'VELOX-2004',
175
+ title: 'Duplicate Procedure Name',
176
+ description: 'Two procedures in the same collection have the same name.',
177
+ statusCode: 500,
178
+ fix: {
179
+ suggestion: 'Ensure all procedure names within a collection are unique.',
180
+ example: `// Wrong: duplicate names
181
+ const userProcedures = defineProcedures('users', {
182
+ getUser: procedure()...,
183
+ getUser: procedure()..., // Error: duplicate!
184
+ });
185
+
186
+ // Correct: unique names
187
+ const userProcedures = defineProcedures('users', {
188
+ getUser: procedure()...,
189
+ getUserProfile: procedure()..., // Different name
190
+ });`,
191
+ },
192
+ docsUrl: 'https://veloxts.dev/errors/VELOX-2004',
193
+ },
194
+ 'VELOX-2005': {
195
+ code: 'VELOX-2005',
196
+ title: 'Invalid REST Method Override',
197
+ description: 'The .rest() configuration contains an invalid HTTP method.',
198
+ statusCode: 500,
199
+ fix: {
200
+ suggestion: 'Use a valid HTTP method: GET, POST, PUT, PATCH, or DELETE.',
201
+ example: `// Correct usage
202
+ const updateUser = procedure()
203
+ .rest({ method: 'PUT', path: '/users/:id' })
204
+ .input(UpdateUserSchema)
205
+ .mutation(({ input }) => { /* ... */ });`,
206
+ },
207
+ docsUrl: 'https://veloxts.dev/errors/VELOX-2005',
208
+ },
209
+ // ==========================================================================
210
+ // AUTH ERRORS (3XXX)
211
+ // ==========================================================================
212
+ 'VELOX-3001': {
213
+ code: 'VELOX-3001',
214
+ title: 'Invalid JWT Secret',
215
+ description: 'The JWT secret is missing, too short, or lacks sufficient entropy.',
216
+ statusCode: 500,
217
+ fix: {
218
+ suggestion: 'Provide a strong secret with at least 64 characters and 16 unique characters.',
219
+ example: `# Generate a secure secret
220
+ openssl rand -base64 64
221
+
222
+ # Set in environment
223
+ JWT_SECRET=<your-64-char-secret>
224
+ JWT_REFRESH_SECRET=<another-64-char-secret>`,
225
+ },
226
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3001',
227
+ },
228
+ 'VELOX-3002': {
229
+ code: 'VELOX-3002',
230
+ title: 'Token Expired',
231
+ description: 'The JWT access token has expired and cannot be used for authentication.',
232
+ statusCode: 401,
233
+ fix: {
234
+ suggestion: 'Refresh the access token using your refresh token, or re-authenticate.',
235
+ example: `// Client-side token refresh
236
+ const response = await fetch('/api/auth/refresh', {
237
+ method: 'POST',
238
+ headers: { 'Content-Type': 'application/json' },
239
+ body: JSON.stringify({ refreshToken: storedRefreshToken }),
240
+ });
241
+ const { accessToken } = await response.json();`,
242
+ },
243
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3002',
244
+ },
245
+ 'VELOX-3003': {
246
+ code: 'VELOX-3003',
247
+ title: 'Invalid Credentials',
248
+ description: 'The provided email or password is incorrect.',
249
+ statusCode: 401,
250
+ fix: {
251
+ suggestion: 'Verify the email and password are correct. Passwords are case-sensitive.',
252
+ },
253
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3003',
254
+ },
255
+ 'VELOX-3004': {
256
+ code: 'VELOX-3004',
257
+ title: 'Rate Limit Exceeded',
258
+ description: 'Too many authentication attempts. Please wait before trying again.',
259
+ statusCode: 429,
260
+ fix: {
261
+ suggestion: 'Wait for the rate limit window to reset before retrying.',
262
+ example: `// The response includes retry timing
263
+ // Retry-After: 900 (seconds until reset)
264
+
265
+ // Client should wait before retrying
266
+ if (response.status === 429) {
267
+ const retryAfter = response.headers.get('Retry-After');
268
+ await delay(parseInt(retryAfter) * 1000);
269
+ }`,
270
+ },
271
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3004',
272
+ },
273
+ 'VELOX-3005': {
274
+ code: 'VELOX-3005',
275
+ title: 'Session Secret Invalid',
276
+ description: 'The session secret is missing or has insufficient entropy.',
277
+ statusCode: 500,
278
+ fix: {
279
+ suggestion: 'Provide a session secret with at least 32 characters and 16 unique characters.',
280
+ example: `# Generate a secure session secret
281
+ openssl rand -base64 32
282
+
283
+ # Set in environment
284
+ SESSION_SECRET=<your-32-char-secret>`,
285
+ },
286
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3005',
287
+ },
288
+ 'VELOX-3006': {
289
+ code: 'VELOX-3006',
290
+ title: 'CSRF Token Invalid',
291
+ description: 'The CSRF token is missing, expired, or does not match.',
292
+ statusCode: 403,
293
+ fix: {
294
+ suggestion: 'Include a valid CSRF token in your request.',
295
+ example: `// Get CSRF token from cookie or meta tag
296
+ const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content;
297
+
298
+ // Include in request headers
299
+ fetch('/api/users', {
300
+ method: 'POST',
301
+ headers: {
302
+ 'Content-Type': 'application/json',
303
+ 'X-CSRF-Token': csrfToken,
304
+ },
305
+ body: JSON.stringify(data),
306
+ });`,
307
+ },
308
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3006',
309
+ },
310
+ 'VELOX-3007': {
311
+ code: 'VELOX-3007',
312
+ title: 'Token Revoked',
313
+ description: 'This token has been revoked and can no longer be used.',
314
+ statusCode: 401,
315
+ fix: {
316
+ suggestion: 'Re-authenticate to obtain new tokens.',
317
+ },
318
+ docsUrl: 'https://veloxts.dev/errors/VELOX-3007',
319
+ },
320
+ // ==========================================================================
321
+ // ORM ERRORS (4XXX)
322
+ // ==========================================================================
323
+ 'VELOX-4001': {
324
+ code: 'VELOX-4001',
325
+ title: 'Database Connection Failed',
326
+ description: 'Could not establish a connection to the database.',
327
+ statusCode: 503,
328
+ fix: {
329
+ suggestion: 'Verify DATABASE_URL is correct and the database server is running.',
330
+ example: `# Check your .env file
331
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
332
+
333
+ # For SQLite
334
+ DATABASE_URL="file:./dev.db"
335
+
336
+ # Ensure database server is running
337
+ docker ps # Check if database container is up`,
338
+ },
339
+ docsUrl: 'https://veloxts.dev/errors/VELOX-4001',
340
+ },
341
+ 'VELOX-4002': {
342
+ code: 'VELOX-4002',
343
+ title: 'Database Already Connected',
344
+ description: 'Attempted to connect to a database that is already connected.',
345
+ statusCode: 500,
346
+ fix: {
347
+ suggestion: 'The database client is already connected. Avoid calling connect() multiple times.',
348
+ example: `// Connection is typically managed automatically
349
+ // Only call connect manually if needed
350
+ if (!isConnected) {
351
+ await prisma.$connect();
352
+ }`,
353
+ },
354
+ docsUrl: 'https://veloxts.dev/errors/VELOX-4002',
355
+ },
356
+ 'VELOX-4003': {
357
+ code: 'VELOX-4003',
358
+ title: 'Missing Database Plugin',
359
+ description: 'Attempted to access ctx.db without registering the database plugin.',
360
+ statusCode: 500,
361
+ fix: {
362
+ suggestion: 'Register the database plugin before accessing ctx.db.',
363
+ example: `import { databasePlugin } from '@veloxts/velox';
364
+ import { prisma } from './database/index.js';
365
+
366
+ const app = await veloxApp({ port: 3000 });
367
+ await app.register(databasePlugin({ client: prisma }));
368
+
369
+ // Now ctx.db is available in procedures`,
370
+ },
371
+ docsUrl: 'https://veloxts.dev/errors/VELOX-4003',
372
+ },
373
+ // ==========================================================================
374
+ // VALIDATION ERRORS (5XXX)
375
+ // ==========================================================================
376
+ 'VELOX-5001': {
377
+ code: 'VELOX-5001',
378
+ title: 'Validation Failed',
379
+ description: 'The request data failed schema validation.',
380
+ statusCode: 400,
381
+ fix: {
382
+ suggestion: 'Check the fields property for specific validation errors.',
383
+ example: `// Response includes field-specific errors
384
+ {
385
+ "error": "ValidationError",
386
+ "message": "Validation failed",
387
+ "statusCode": 400,
388
+ "code": "VELOX-5001",
389
+ "fields": {
390
+ "email": "Invalid email format",
391
+ "age": "Must be at least 18"
392
+ }
393
+ }`,
394
+ },
395
+ docsUrl: 'https://veloxts.dev/errors/VELOX-5001',
396
+ },
397
+ 'VELOX-5002': {
398
+ code: 'VELOX-5002',
399
+ title: 'Invalid Schema Definition',
400
+ description: 'The Zod schema definition is invalid.',
401
+ statusCode: 500,
402
+ fix: {
403
+ suggestion: 'Check your Zod schema for syntax errors or invalid chaining.',
404
+ example: `// Correct schema definition
405
+ const UserSchema = z.object({
406
+ id: z.string().uuid(),
407
+ email: z.string().email(),
408
+ age: z.number().min(0).max(150),
409
+ });`,
410
+ },
411
+ docsUrl: 'https://veloxts.dev/errors/VELOX-5002',
412
+ },
413
+ // ==========================================================================
414
+ // CLIENT ERRORS (6XXX)
415
+ // ==========================================================================
416
+ 'VELOX-6001': {
417
+ code: 'VELOX-6001',
418
+ title: 'Network Request Failed',
419
+ description: 'The HTTP request could not be completed due to a network error.',
420
+ statusCode: 0,
421
+ fix: {
422
+ suggestion: 'Check your internet connection and ensure the API server is reachable.',
423
+ example: `// Handle network errors gracefully
424
+ try {
425
+ const data = await api.users.list();
426
+ } catch (error) {
427
+ if (isNetworkError(error)) {
428
+ console.log('Network unavailable, using cached data');
429
+ return getCachedData();
430
+ }
431
+ throw error;
432
+ }`,
433
+ },
434
+ docsUrl: 'https://veloxts.dev/errors/VELOX-6001',
435
+ },
436
+ 'VELOX-6002': {
437
+ code: 'VELOX-6002',
438
+ title: 'API Base URL Not Configured',
439
+ description: 'The VeloxTS client was created without a base URL.',
440
+ statusCode: 500,
441
+ fix: {
442
+ suggestion: 'Provide a baseUrl when creating the client.',
443
+ example: `import { createClient } from '@veloxts/client';
444
+
445
+ const api = createClient({
446
+ baseUrl: process.env.API_URL || 'http://localhost:3000/api',
447
+ });`,
448
+ },
449
+ docsUrl: 'https://veloxts.dev/errors/VELOX-6002',
450
+ },
451
+ };
452
+ // ============================================================================
453
+ // Catalog Access Functions
454
+ // ============================================================================
455
+ /**
456
+ * Get an error catalog entry by code
457
+ *
458
+ * @param code - The error code (e.g., 'VELOX-1001')
459
+ * @returns The catalog entry or undefined if not found
460
+ */
461
+ export function getErrorEntry(code) {
462
+ return ERROR_CATALOG[code];
463
+ }
464
+ /**
465
+ * Get all error codes for a specific domain
466
+ *
467
+ * @param domain - The error domain (e.g., 'CORE', 'AUTH')
468
+ * @returns Array of error codes in that domain
469
+ */
470
+ export function getErrorsByDomain(domain) {
471
+ const prefix = `VELOX-${ERROR_DOMAINS[domain]}`;
472
+ return Object.keys(ERROR_CATALOG).filter((code) => code.startsWith(prefix));
473
+ }
474
+ /**
475
+ * Check if an error code exists in the catalog
476
+ *
477
+ * @param code - The error code to check
478
+ * @returns true if the code exists
479
+ */
480
+ export function isKnownErrorCode(code) {
481
+ return code in ERROR_CATALOG;
482
+ }
483
+ /**
484
+ * Get the documentation URL for an error code
485
+ *
486
+ * @param code - The error code
487
+ * @returns The documentation URL or undefined
488
+ */
489
+ export function getDocsUrl(code) {
490
+ return ERROR_CATALOG[code]?.docsUrl;
491
+ }
492
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/errors/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,UAAU,EAAE,CAAC;IACb,MAAM,EAAE,CAAC;CACD,CAAC;AAuCX,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAsC;IAC9D,6EAA6E;IAC7E,qBAAqB;IACrB,6EAA6E;IAE7E,YAAY,EAAE;QACZ,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EAAE,8DAA8D;QAC3E,UAAU,EAAE,GAAG;QACf,GAAG,EAAE;YACH,UAAU,EACR,oGAAoG;YACtG,OAAO,EAAE;;;;;;qCAMsB;SAChC;QACD,OAAO,EAAE,uCAAuC;KACjD;IAED,YAAY,EAAE;QACZ,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,yDAAyD;QACtE,UAAU,EAAE,GAAG;QACf,GAAG,EAAE;YACH,UAAU,EAAE,4DAA4D;YACxE,OAAO,EAAE;;;uCAGwB;SAClC;QACD,OAAO,EAAE,uCAAuC;KACjD;IAED,YAAY,EAAE;QACZ,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,4BAA4B;QACnC,WAAW,EAAE,2DAA2D;QACxE,UAAU,EAAE,GAAG;QACf,GAAG,EAAE;YACH,UAAU,EACR,4FAA4F;YAC9F,OAAO,EAAE;;;;;;;mEAOoD;SAC9D;QACD,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