@coherent.js/api 1.0.0-beta.2 → 1.0.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coherent.js/api",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "API framework for Coherent.js (REST/RPC/GraphQL).",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -10,6 +10,26 @@
10
10
  ".": {
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.cjs"
13
+ },
14
+ "./router": {
15
+ "import": "./dist/router.js",
16
+ "require": "./dist/router.cjs"
17
+ },
18
+ "./middleware": {
19
+ "import": "./dist/middleware.js",
20
+ "require": "./dist/middleware.cjs"
21
+ },
22
+ "./security": {
23
+ "import": "./dist/security.js",
24
+ "require": "./dist/security.cjs"
25
+ },
26
+ "./validation": {
27
+ "import": "./dist/validation.js",
28
+ "require": "./dist/validation.cjs"
29
+ },
30
+ "./serialization": {
31
+ "import": "./dist/serialization.js",
32
+ "require": "./dist/serialization.cjs"
13
33
  }
14
34
  },
15
35
  "files": [
@@ -27,12 +47,16 @@
27
47
  "url": "git+https://github.com/Tomdrouv1/coherent.js.git"
28
48
  },
29
49
  "peerDependencies": {
30
- "@coherent.js/core": "1.0.0-beta.2"
50
+ "@coherent.js/core": "1.0.0-beta.5"
51
+ },
52
+ "devDependencies": {
53
+ "@coherent.js/state": "1.0.0-beta.5"
31
54
  },
32
55
  "publishConfig": {
33
56
  "access": "public",
34
57
  "registry": "https://registry.npmjs.org/"
35
58
  },
59
+ "sideEffects": false,
36
60
  "scripts": {
37
61
  "build": "node build.mjs",
38
62
  "clean": "rm -rf dist/",
@@ -1,92 +0,0 @@
1
- /**
2
- * API Error Handling for Coherent.js
3
- * @fileoverview Standardized error classes and handling utilities
4
- */
5
- /**
6
- * Base API Error class
7
- * @extends Error
8
- */
9
- export class ApiError extends Error {
10
- /**
11
- * Create an API error
12
- * @param {string} message - Error message
13
- * @param {number} statusCode - HTTP status code
14
- * @param {Object} details - Additional error details
15
- */
16
- constructor(message: string, statusCode?: number, details?: Object);
17
- statusCode: number;
18
- details: Object;
19
- /**
20
- * Convert error to JSON-serializable object
21
- * @returns {Object} Error object
22
- */
23
- toJSON(): Object;
24
- }
25
- /**
26
- * Validation Error class
27
- * @extends ApiError
28
- */
29
- export class ValidationError extends ApiError {
30
- /**
31
- * Create a validation error
32
- * @param {Object} errors - Validation errors
33
- * @param {string} message - Error message
34
- */
35
- constructor(errors: Object, message?: string);
36
- }
37
- /**
38
- * Authentication Error class
39
- * @extends ApiError
40
- */
41
- export class AuthenticationError extends ApiError {
42
- /**
43
- * Create an authentication error
44
- * @param {string} message - Error message
45
- */
46
- constructor(message?: string);
47
- }
48
- /**
49
- * Authorization Error class
50
- * @extends ApiError
51
- */
52
- export class AuthorizationError extends ApiError {
53
- /**
54
- * Create an authorization error
55
- * @param {string} message - Error message
56
- */
57
- constructor(message?: string);
58
- }
59
- /**
60
- * Not Found Error class
61
- * @extends ApiError
62
- */
63
- export class NotFoundError extends ApiError {
64
- /**
65
- * Create a not found error
66
- * @param {string} message - Error message
67
- */
68
- constructor(message?: string);
69
- }
70
- /**
71
- * Conflict Error class
72
- * @extends ApiError
73
- */
74
- export class ConflictError extends ApiError {
75
- /**
76
- * Create a conflict error
77
- * @param {string} message - Error message
78
- */
79
- constructor(message?: string);
80
- }
81
- /**
82
- * Create error handling middleware
83
- * @param {Function} handler - Error handler function
84
- * @returns {Function} Middleware function
85
- */
86
- export function withErrorHandling(handler: Function): Function;
87
- /**
88
- * Global error handler middleware
89
- * @returns {Function} Express error handler middleware
90
- */
91
- export function createErrorHandler(): Function;
92
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/api/errors.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH;IACE;;;;;OAKG;IACH,qBAJW,MAAM,eACN,MAAM,YACN,MAAM,EAYhB;IAPC,mBAA4B;IAC5B,gBAAsB;IAQxB;;;OAGG;IACH,UAFa,MAAM,CASlB;CACF;AAED;;;GAGG;AACH;IACE;;;;OAIG;IACH,oBAHW,MAAM,YACN,MAAM,EAKhB;CACF;AAED;;;GAGG;AACH;IACE;;;OAGG;IACH,sBAFW,MAAM,EAKhB;CACF;AAED;;;GAGG;AACH;IACE;;;OAGG;IACH,sBAFW,MAAM,EAKhB;CACF;AAED;;;GAGG;AACH;IACE;;;OAGG;IACH,sBAFW,MAAM,EAKhB;CACF;AAED;;;GAGG;AACH;IACE;;;OAGG;IACH,sBAFW,MAAM,EAKhB;CACF;AAED;;;;GAIG;AACH,+DAcC;AAED;;;GAGG;AACH,+CA6BC"}
@@ -1,161 +0,0 @@
1
- /**
2
- * API Error Handling for Coherent.js
3
- * @fileoverview Standardized error classes and handling utilities
4
- */
5
- /**
6
- * Base API Error class
7
- * @extends Error
8
- */
9
- class ApiError extends Error {
10
- /**
11
- * Create an API error
12
- * @param {string} message - Error message
13
- * @param {number} statusCode - HTTP status code
14
- * @param {Object} details - Additional error details
15
- */
16
- constructor(message, statusCode = 500, details = {}) {
17
- super(message);
18
- this.name = 'ApiError';
19
- this.statusCode = statusCode;
20
- this.details = details;
21
- // Ensure proper stack trace
22
- if (Error.captureStackTrace) {
23
- Error.captureStackTrace(this, ApiError);
24
- }
25
- }
26
- /**
27
- * Convert error to JSON-serializable object
28
- * @returns {Object} Error object
29
- */
30
- toJSON() {
31
- return {
32
- error: this.name,
33
- message: this.message,
34
- statusCode: this.statusCode,
35
- details: this.details
36
- };
37
- }
38
- }
39
- /**
40
- * Validation Error class
41
- * @extends ApiError
42
- */
43
- class ValidationError extends ApiError {
44
- /**
45
- * Create a validation error
46
- * @param {Object} errors - Validation errors
47
- * @param {string} message - Error message
48
- */
49
- constructor(errors, message = 'Validation failed') {
50
- super(message, 400, { errors });
51
- this.name = 'ValidationError';
52
- }
53
- }
54
- /**
55
- * Authentication Error class
56
- * @extends ApiError
57
- */
58
- class AuthenticationError extends ApiError {
59
- /**
60
- * Create an authentication error
61
- * @param {string} message - Error message
62
- */
63
- constructor(message = 'Authentication required') {
64
- super(message, 401);
65
- this.name = 'AuthenticationError';
66
- }
67
- }
68
- /**
69
- * Authorization Error class
70
- * @extends ApiError
71
- */
72
- class AuthorizationError extends ApiError {
73
- /**
74
- * Create an authorization error
75
- * @param {string} message - Error message
76
- */
77
- constructor(message = 'Access denied') {
78
- super(message, 403);
79
- this.name = 'AuthorizationError';
80
- }
81
- }
82
- /**
83
- * Not Found Error class
84
- * @extends ApiError
85
- */
86
- class NotFoundError extends ApiError {
87
- /**
88
- * Create a not found error
89
- * @param {string} message - Error message
90
- */
91
- constructor(message = 'Resource not found') {
92
- super(message, 404);
93
- this.name = 'NotFoundError';
94
- }
95
- }
96
- /**
97
- * Conflict Error class
98
- * @extends ApiError
99
- */
100
- class ConflictError extends ApiError {
101
- /**
102
- * Create a conflict error
103
- * @param {string} message - Error message
104
- */
105
- constructor(message = 'Resource conflict') {
106
- super(message, 409);
107
- this.name = 'ConflictError';
108
- }
109
- }
110
- /**
111
- * Create error handling middleware
112
- * @param {Function} handler - Error handler function
113
- * @returns {Function} Middleware function
114
- */
115
- function withErrorHandling(handler) {
116
- return async (req, res, next) => {
117
- try {
118
- return await handler(req, res, next);
119
- }
120
- catch (error) {
121
- // If it's already an API error, use it as-is
122
- if (error instanceof ApiError) {
123
- throw error;
124
- }
125
- // Otherwise, wrap it as a generic server error
126
- throw new ApiError(error.message || 'Internal server error', 500);
127
- }
128
- };
129
- }
130
- /**
131
- * Global error handler middleware
132
- * @returns {Function} Express error handler middleware
133
- */
134
- function createErrorHandler() {
135
- return (error, req, res, next) => {
136
- // Log error for debugging
137
- console.error('API Error:', error);
138
- // If headers are already sent, delegate to default error handler
139
- if (res.headersSent) {
140
- return next(error);
141
- }
142
- // Format error response
143
- const response = {
144
- error: error.name || 'Error',
145
- message: error.message || 'An error occurred',
146
- statusCode: error.statusCode || 500
147
- };
148
- // Add details if available
149
- if (error.details) {
150
- response.details = error.details;
151
- }
152
- // Add stack trace in development
153
- if (process.env.NODE_ENV === 'development') {
154
- response.stack = error.stack;
155
- }
156
- res.status(response.statusCode).json(response);
157
- };
158
- }
159
- // Export all error classes and utilities
160
- export { ApiError, ValidationError, AuthenticationError, AuthorizationError, NotFoundError, ConflictError, withErrorHandling, createErrorHandler };
161
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/api/errors.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,QAAS,SAAQ,KAAK;IAC1B;;;;;OAKG;IACH,YAAY,OAAO,EAAE,UAAU,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,4BAA4B;QAC5B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,eAAgB,SAAQ,QAAQ;IACpC;;;;OAIG;IACH,YAAY,MAAM,EAAE,OAAO,GAAG,mBAAmB;QAC/C,KAAK,CAAC,OAAO,EAAE,GAAG,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export { ApiError };
4
- export { ValidationError };
5
- export { AuthenticationError };
6
- export { AuthorizationError };
7
- export { NotFoundError };
8
- export { ConflictError };
9
- export { withErrorHandling };
10
- export { createErrorHandler };
11
- export { validateAgainstSchema };
12
- export { validateField };
13
- export { withValidation };
14
- export { withQueryValidation };
15
- export { withParamsValidation };
16
- export { serializeDate };
17
- export { deserializeDate };
18
- export { serializeMap };
19
- export { deserializeMap };
20
- export { serializeSet };
21
- export { deserializeSet };
22
- export { withSerialization };
23
- export { serializeForJSON };
24
- export { withAuth };
25
- export { withRole };
26
- export { hashPassword };
27
- export { verifyPassword };
28
- export { generateToken };
29
- export { withInputValidation };
30
- }
31
- export default _default;
32
- import { createObjectRouter } from './router.js';
33
- import { ApiError } from './errors.js';
34
- import { ValidationError } from './errors.js';
35
- import { AuthenticationError } from './errors.js';
36
- import { AuthorizationError } from './errors.js';
37
- import { NotFoundError } from './errors.js';
38
- import { ConflictError } from './errors.js';
39
- import { withErrorHandling } from './errors.js';
40
- import { createErrorHandler } from './errors.js';
41
- import { validateAgainstSchema } from './validation.js';
42
- import { validateField } from './validation.js';
43
- import { withValidation } from './validation.js';
44
- import { withQueryValidation } from './validation.js';
45
- import { withParamsValidation } from './validation.js';
46
- import { serializeDate } from './serialization.js';
47
- import { deserializeDate } from './serialization.js';
48
- import { serializeMap } from './serialization.js';
49
- import { deserializeMap } from './serialization.js';
50
- import { serializeSet } from './serialization.js';
51
- import { deserializeSet } from './serialization.js';
52
- import { withSerialization } from './serialization.js';
53
- import { serializeForJSON } from './serialization.js';
54
- import { withAuth } from './security.js';
55
- import { withRole } from './security.js';
56
- import { hashPassword } from './security.js';
57
- import { verifyPassword } from './security.js';
58
- import { generateToken } from './security.js';
59
- import { withInputValidation } from './security.js';
60
- export { createObjectRouter, ApiError, ValidationError, AuthenticationError, AuthorizationError, NotFoundError, ConflictError, withErrorHandling, createErrorHandler, validateAgainstSchema, validateField, withValidation, withQueryValidation, withParamsValidation, serializeDate, deserializeDate, serializeMap, deserializeMap, serializeSet, deserializeSet, withSerialization, serializeForJSON, withAuth, withRole, hashPassword, verifyPassword, generateToken, withInputValidation };
61
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAKmC,aAAa;yBACwG,aAAa;gCAAb,aAAa;oCAAb,aAAa;mCAAb,aAAa;8BAAb,aAAa;8BAAb,aAAa;kCAAb,aAAa;mCAAb,aAAa;sCACrD,iBAAiB;8BAAjB,iBAAiB;+BAAjB,iBAAiB;oCAAjB,iBAAiB;qCAAjB,iBAAiB;8BACe,oBAAoB;gCAApB,oBAAoB;6BAApB,oBAAoB;+BAApB,oBAAoB;6BAApB,oBAAoB;+BAApB,oBAAoB;kCAApB,oBAAoB;iCAApB,oBAAoB;yBAC/D,eAAe;yBAAf,eAAe;6BAAf,eAAe;+BAAf,eAAe;8BAAf,eAAe;oCAAf,eAAe"}
package/dist/api/index.js DELETED
@@ -1,41 +0,0 @@
1
- /**
2
- * Coherent.js API Module
3
- * @fileoverview Core utilities for building APIs with Coherent.js
4
- */
5
- import { createObjectRouter } from './router.js';
6
- import { ApiError, ValidationError, AuthenticationError, AuthorizationError, NotFoundError, ConflictError, withErrorHandling, createErrorHandler } from './errors.js';
7
- import { validateAgainstSchema, validateField, withValidation, withQueryValidation, withParamsValidation } from './validation.js';
8
- import { serializeDate, deserializeDate, serializeMap, deserializeMap, serializeSet, deserializeSet, withSerialization, serializeForJSON } from './serialization.js';
9
- import { withAuth, withRole, hashPassword, verifyPassword, generateToken, withInputValidation } from './security.js';
10
- export { createObjectRouter, ApiError, ValidationError, AuthenticationError, AuthorizationError, NotFoundError, ConflictError, withErrorHandling, createErrorHandler, validateAgainstSchema, validateField, withValidation, withQueryValidation, withParamsValidation, serializeDate, deserializeDate, serializeMap, deserializeMap, serializeSet, deserializeSet, withSerialization, serializeForJSON, withAuth, withRole, hashPassword, verifyPassword, generateToken, withInputValidation };
11
- export default {
12
- createObjectRouter,
13
- ApiError,
14
- ValidationError,
15
- AuthenticationError,
16
- AuthorizationError,
17
- NotFoundError,
18
- ConflictError,
19
- withErrorHandling,
20
- createErrorHandler,
21
- validateAgainstSchema,
22
- validateField,
23
- withValidation,
24
- withQueryValidation,
25
- withParamsValidation,
26
- serializeDate,
27
- deserializeDate,
28
- serializeMap,
29
- deserializeMap,
30
- serializeSet,
31
- deserializeSet,
32
- withSerialization,
33
- serializeForJSON,
34
- withAuth,
35
- withRole,
36
- hashPassword,
37
- verifyPassword,
38
- generateToken,
39
- withInputValidation
40
- };
41
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/index.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtK,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAClI,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrK,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAErH,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,EACb,mBAAmB,EACpB,CAAC;AAEF,eAAe;IACb,kBAAkB;IAClB,QAAQ;IACR,eAAe;IACf,mBAAmB;IACnB,kBAAkB;IAClB,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,aAAa;IACb,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,aAAa;IACb,eAAe;IACf,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,gBAAgB;IAChB,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,cAAc;IACd,aAAa;IACb,mBAAmB;CACpB,CAAC"}
@@ -1,57 +0,0 @@
1
- /**
2
- * Middleware system for Coherent.js API framework
3
- * @fileoverview Common middleware utilities for API routes
4
- */
5
- /**
6
- * Creates a custom API middleware with error handling
7
- * @param {Function} handler - Middleware handler function
8
- * @returns {Function} Middleware function that catches errors
9
- */
10
- export function createApiMiddleware(handler: Function): Function;
11
- /**
12
- * Authentication middleware
13
- * @param {Function} verifyToken - Function to verify authentication token
14
- * @returns {Function} Middleware function
15
- */
16
- export function withAuth(verifyToken: Function): Function;
17
- /**
18
- * Authorization middleware
19
- * @param {Function} checkPermission - Function to check user permissions
20
- * @returns {Function} Middleware function
21
- */
22
- export function withPermission(checkPermission: Function): Function;
23
- /**
24
- * Logging middleware
25
- * @param {Object} options - Logging options
26
- * @returns {Function} Middleware function
27
- */
28
- export function withLogging(options?: Object): Function;
29
- /**
30
- * CORS middleware
31
- * @param {Object} options - CORS options
32
- * @returns {Function} Middleware function
33
- */
34
- export function withCors(options?: Object): Function;
35
- /**
36
- * Rate limiting middleware
37
- * @param {Object} options - Rate limiting options
38
- * @returns {Function} Middleware function
39
- */
40
- export function withRateLimit(options?: Object): Function;
41
- /**
42
- * Input sanitization middleware
43
- * @param {Object} options - Sanitization options
44
- * @returns {Function} Middleware function
45
- */
46
- export function withSanitization(options?: Object): Function;
47
- declare namespace _default {
48
- export { createApiMiddleware };
49
- export { withAuth };
50
- export { withPermission };
51
- export { withLogging };
52
- export { withCors };
53
- export { withRateLimit };
54
- export { withSanitization };
55
- }
56
- export default _default;
57
- //# sourceMappingURL=middleware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../../src/api/middleware.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,iEASC;AAED;;;;GAIG;AACH,0DAwBC;AAED;;;;GAIG;AACH,oEA2BC;AAED;;;;GAIG;AACH,sCAHW,MAAM,YAsBhB;AAED;;;;GAIG;AACH,mCAHW,MAAM,YAiChB;AAED;;;;GAIG;AACH,wCAHW,MAAM,YAgEhB;AAED;;;;GAIG;AACH,2CAHW,MAAM,YAyBhB"}