@webpieces/core-meta 0.2.12 → 0.2.14
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 +1 -1
- package/src/WebAppMeta.d.ts +22 -44
- package/src/WebAppMeta.js +19 -39
- package/src/WebAppMeta.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -3
- package/src/index.js.map +1 -1
package/package.json
CHANGED
package/src/WebAppMeta.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContainerModule
|
|
1
|
+
import { ContainerModule } from 'inversify';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a route configuration that can be registered with the router.
|
|
4
4
|
* Similar to Java WebPieces Routes interface.
|
|
@@ -17,6 +17,13 @@ export interface RouteBuilder {
|
|
|
17
17
|
addRoute<TResult = unknown>(route: RouteDefinition<TResult>): void;
|
|
18
18
|
addFilter(filter: FilterDefinition): void;
|
|
19
19
|
}
|
|
20
|
+
export declare class RouteMetadata2 {
|
|
21
|
+
httpMethod: string;
|
|
22
|
+
path: string;
|
|
23
|
+
methodName: string;
|
|
24
|
+
parameterTypes?: any[];
|
|
25
|
+
constructor(httpMethod: string, path: string, methodName: string, parameterTypes?: any[]);
|
|
26
|
+
}
|
|
20
27
|
/**
|
|
21
28
|
* Definition of a single route.
|
|
22
29
|
*
|
|
@@ -24,11 +31,10 @@ export interface RouteBuilder {
|
|
|
24
31
|
* This provides type safety for the entire request/response cycle.
|
|
25
32
|
*/
|
|
26
33
|
export declare class RouteDefinition<TResult = unknown> {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
controllerFilepath?: string;
|
|
31
|
-
constructor(method: string, path: string, handler: RouteHandler<TResult>, controllerFilepath?: string);
|
|
34
|
+
routeMeta: RouteMetadata2;
|
|
35
|
+
controllerClass: any;
|
|
36
|
+
controllerFilepath?: string | undefined;
|
|
37
|
+
constructor(routeMeta: RouteMetadata2, controllerClass: any, controllerFilepath?: string | undefined);
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* Definition of a filter with priority.
|
|
@@ -43,6 +49,7 @@ export declare class RouteDefinition<TResult = unknown> {
|
|
|
43
49
|
export declare class FilterDefinition {
|
|
44
50
|
priority: number;
|
|
45
51
|
filterClass: any;
|
|
52
|
+
filter?: any;
|
|
46
53
|
/**
|
|
47
54
|
* Glob pattern to match controller file paths.
|
|
48
55
|
* If not specified, defaults to matching all controllers.
|
|
@@ -51,48 +58,19 @@ export declare class FilterDefinition {
|
|
|
51
58
|
constructor(priority: number, filterClass: any, filepathPattern: string);
|
|
52
59
|
}
|
|
53
60
|
/**
|
|
54
|
-
*
|
|
61
|
+
* Holds Express Request and Response objects.
|
|
62
|
+
* JsonFilter uses these to read request body and write response.
|
|
55
63
|
*/
|
|
56
64
|
export declare class RouteRequest {
|
|
57
|
-
body?: any;
|
|
58
|
-
query?: Record<string, any>;
|
|
59
|
-
params?: Record<string, any>;
|
|
60
|
-
headers?: Record<string, any>;
|
|
61
|
-
constructor(body?: any, query?: Record<string, any>, params?: Record<string, any>, headers?: Record<string, any>);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Context passed to route handlers.
|
|
65
|
-
* Contains DI container, request data, and extracted parameters.
|
|
66
|
-
*/
|
|
67
|
-
export declare class RouteContext {
|
|
68
|
-
/** DI container for resolving dependencies */
|
|
69
|
-
container: Container;
|
|
70
|
-
/** Extracted parameters (e.g., from request body, path params) */
|
|
71
|
-
params: any[];
|
|
72
|
-
/** Original request data */
|
|
73
|
-
request?: RouteRequest;
|
|
74
|
-
constructor(container: Container, params: any[], request?: RouteRequest);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Handler class for routes.
|
|
78
|
-
* Takes a RouteContext and returns the controller method result.
|
|
79
|
-
*
|
|
80
|
-
* Generic type parameter TResult represents the return type of the controller method.
|
|
81
|
-
* Example: RouteHandler<SaveResponse> for a method that returns Promise<SaveResponse>
|
|
82
|
-
*
|
|
83
|
-
* Using unknown as default instead of any forces type safety - consumers must
|
|
84
|
-
* handle the result appropriately rather than assuming any type.
|
|
85
|
-
*
|
|
86
|
-
* This is a class instead of a function type to make it easier to trace
|
|
87
|
-
* who is calling what in the debugger/IDE.
|
|
88
|
-
*/
|
|
89
|
-
export declare abstract class RouteHandler<TResult = unknown> {
|
|
90
65
|
/**
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
66
|
+
* Express Request object
|
|
67
|
+
*/
|
|
68
|
+
request: unknown;
|
|
69
|
+
/**
|
|
70
|
+
* Express Response object
|
|
94
71
|
*/
|
|
95
|
-
|
|
72
|
+
response: unknown;
|
|
73
|
+
constructor(request: unknown, response: unknown);
|
|
96
74
|
}
|
|
97
75
|
/**
|
|
98
76
|
* Main application metadata interface.
|
package/src/WebAppMeta.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RouteRequest = exports.FilterDefinition = exports.RouteDefinition = exports.RouteMetadata2 = void 0;
|
|
4
|
+
class RouteMetadata2 {
|
|
5
|
+
constructor(httpMethod, path, methodName, parameterTypes) {
|
|
6
|
+
this.httpMethod = httpMethod;
|
|
7
|
+
this.path = path;
|
|
8
|
+
this.methodName = methodName;
|
|
9
|
+
this.parameterTypes = parameterTypes;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.RouteMetadata2 = RouteMetadata2;
|
|
4
13
|
/**
|
|
5
14
|
* Definition of a single route.
|
|
6
15
|
*
|
|
@@ -8,10 +17,9 @@ exports.RouteHandler = exports.RouteContext = exports.RouteRequest = exports.Fil
|
|
|
8
17
|
* This provides type safety for the entire request/response cycle.
|
|
9
18
|
*/
|
|
10
19
|
class RouteDefinition {
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.handler = handler;
|
|
20
|
+
constructor(routeMeta, controllerClass, controllerFilepath) {
|
|
21
|
+
this.routeMeta = routeMeta;
|
|
22
|
+
this.controllerClass = controllerClass;
|
|
15
23
|
this.controllerFilepath = controllerFilepath;
|
|
16
24
|
}
|
|
17
25
|
}
|
|
@@ -31,47 +39,19 @@ class FilterDefinition {
|
|
|
31
39
|
this.priority = priority;
|
|
32
40
|
this.filterClass = filterClass;
|
|
33
41
|
this.filepathPattern = filepathPattern;
|
|
42
|
+
this.filter = undefined; // Set later by RouteBuilder
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
45
|
exports.FilterDefinition = FilterDefinition;
|
|
37
46
|
/**
|
|
38
|
-
*
|
|
47
|
+
* Holds Express Request and Response objects.
|
|
48
|
+
* JsonFilter uses these to read request body and write response.
|
|
39
49
|
*/
|
|
40
50
|
class RouteRequest {
|
|
41
|
-
constructor(
|
|
42
|
-
this.body = body;
|
|
43
|
-
this.query = query;
|
|
44
|
-
this.params = params;
|
|
45
|
-
this.headers = headers;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.RouteRequest = RouteRequest;
|
|
49
|
-
/**
|
|
50
|
-
* Context passed to route handlers.
|
|
51
|
-
* Contains DI container, request data, and extracted parameters.
|
|
52
|
-
*/
|
|
53
|
-
class RouteContext {
|
|
54
|
-
constructor(container, params, request) {
|
|
55
|
-
this.container = container;
|
|
56
|
-
this.params = params;
|
|
51
|
+
constructor(request, response) {
|
|
57
52
|
this.request = request;
|
|
53
|
+
this.response = response;
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
|
-
exports.
|
|
61
|
-
/**
|
|
62
|
-
* Handler class for routes.
|
|
63
|
-
* Takes a RouteContext and returns the controller method result.
|
|
64
|
-
*
|
|
65
|
-
* Generic type parameter TResult represents the return type of the controller method.
|
|
66
|
-
* Example: RouteHandler<SaveResponse> for a method that returns Promise<SaveResponse>
|
|
67
|
-
*
|
|
68
|
-
* Using unknown as default instead of any forces type safety - consumers must
|
|
69
|
-
* handle the result appropriately rather than assuming any type.
|
|
70
|
-
*
|
|
71
|
-
* This is a class instead of a function type to make it easier to trace
|
|
72
|
-
* who is calling what in the debugger/IDE.
|
|
73
|
-
*/
|
|
74
|
-
class RouteHandler {
|
|
75
|
-
}
|
|
76
|
-
exports.RouteHandler = RouteHandler;
|
|
56
|
+
exports.RouteRequest = RouteRequest;
|
|
77
57
|
//# sourceMappingURL=WebAppMeta.js.map
|
package/src/WebAppMeta.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebAppMeta.js","sourceRoot":"","sources":["../../../../../packages/core/core-meta/src/WebAppMeta.ts"],"names":[],"mappings":";;;AAsBA
|
|
1
|
+
{"version":3,"file":"WebAppMeta.js","sourceRoot":"","sources":["../../../../../packages/core/core-meta/src/WebAppMeta.ts"],"names":[],"mappings":";;;AAsBA,MAAa,cAAc;IAMvB,YACI,UAAkB,EAClB,IAAY,EACZ,UAAkB,EAClB,cAAsB;QAEtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;CACJ;AAjBD,wCAiBC;AACD;;;;;GAKG;AACH,MAAa,eAAe;IAE1B,YACW,SAAyB,EAC3B,eAAoB,EACpB,kBAA2B;QAFzB,cAAS,GAAT,SAAS,CAAgB;QAC3B,oBAAe,GAAf,eAAe,CAAK;QACpB,uBAAkB,GAAlB,kBAAkB,CAAS;IAEpC,CAAC;CACF;AARD,0CAQC;AAED;;;;;;;;;GASG;AACH,MAAa,gBAAgB;IAW3B,YACE,QAAgB,EAChB,WAAgB,EAChB,eAAuB;QAEvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,4BAA4B;IACvD,CAAC;CACF;AArBD,4CAqBC;AAED;;;GAGG;AACH,MAAa,YAAY;IAWvB,YAAY,OAAgB,EAAE,QAAiB;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAfD,oCAeC","sourcesContent":["import { ContainerModule, Container } from 'inversify';\n\n/**\n * Represents a route configuration that can be registered with the router.\n * Similar to Java WebPieces Routes interface.\n */\nexport interface Routes {\n /**\n * Configure routes using the provided RouteBuilder.\n */\n configure(routeBuilder: RouteBuilder): void;\n}\n\n/**\n * Builder for registering routes.\n * Will be implemented in http-routing package.\n */\nexport interface RouteBuilder {\n addRoute<TResult = unknown>(route: RouteDefinition<TResult>): void;\n addFilter(filter: FilterDefinition): void;\n}\n\nexport class RouteMetadata2 {\n httpMethod: string;\n path: string;\n methodName: string;\n parameterTypes?: any[];\n\n constructor(\n httpMethod: string,\n path: string,\n methodName: string,\n parameterTypes?: any[]\n ) {\n this.httpMethod = httpMethod;\n this.path = path;\n this.methodName = methodName;\n this.parameterTypes = parameterTypes;\n }\n}\n/**\n * Definition of a single route.\n *\n * Generic type parameter TResult represents the return type of the route handler.\n * This provides type safety for the entire request/response cycle.\n */\nexport class RouteDefinition<TResult = unknown> {\n\n constructor(\n public routeMeta: RouteMetadata2,\n public controllerClass: any,\n public controllerFilepath?: string\n ) {\n }\n}\n\n/**\n * Definition of a filter with priority.\n *\n * Use filepathPattern to scope filters to specific controllers:\n * - 'src/controllers/admin/**' + '/*.ts' - All admin controllers\n * - '**' + '/admin/**' - Any file in admin directories\n * - '**' + '/UserController.ts' - Specific controller file\n *\n * If filepathPattern is not specified, the filter matches all controllers.\n */\nexport class FilterDefinition {\n priority: number;\n filterClass: any;\n filter?: any; // Filter instance (set by RouteBuilder when resolving from DI)\n\n /**\n * Glob pattern to match controller file paths.\n * If not specified, defaults to matching all controllers.\n */\n filepathPattern: string;\n\n constructor(\n priority: number,\n filterClass: any,\n filepathPattern: string,\n ) {\n this.priority = priority;\n this.filterClass = filterClass;\n this.filepathPattern = filepathPattern;\n this.filter = undefined; // Set later by RouteBuilder\n }\n}\n\n/**\n * Holds Express Request and Response objects.\n * JsonFilter uses these to read request body and write response.\n */\nexport class RouteRequest {\n /**\n * Express Request object\n */\n request: unknown;\n\n /**\n * Express Response object\n */\n response: unknown;\n\n constructor(request: unknown, response: unknown) {\n this.request = request;\n this.response = response;\n }\n}\n\n\n/**\n * Main application metadata interface.\n * Similar to Java WebPieces WebAppMeta.\n *\n * This is the entry point that WebpiecesServer calls to configure your application.\n */\nexport interface WebAppMeta {\n /**\n * Returns the list of Inversify container modules for dependency injection.\n * Similar to getGuiceModules() in Java.\n */\n getDIModules(): ContainerModule[];\n\n /**\n * Returns the list of route configurations.\n * Similar to getRouteModules() in Java.\n */\n getRoutes(): Routes[];\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { WebAppMeta, Routes, RouteBuilder, RouteDefinition,
|
|
1
|
+
export { WebAppMeta, Routes, RouteBuilder, RouteDefinition, RouteMetadata2, FilterDefinition, RouteRequest, } from './WebAppMeta';
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouteRequest = exports.
|
|
3
|
+
exports.RouteRequest = exports.FilterDefinition = exports.RouteMetadata2 = exports.RouteDefinition = void 0;
|
|
4
4
|
var WebAppMeta_1 = require("./WebAppMeta");
|
|
5
5
|
Object.defineProperty(exports, "RouteDefinition", { enumerable: true, get: function () { return WebAppMeta_1.RouteDefinition; } });
|
|
6
|
+
Object.defineProperty(exports, "RouteMetadata2", { enumerable: true, get: function () { return WebAppMeta_1.RouteMetadata2; } });
|
|
6
7
|
Object.defineProperty(exports, "FilterDefinition", { enumerable: true, get: function () { return WebAppMeta_1.FilterDefinition; } });
|
|
7
|
-
Object.defineProperty(exports, "RouteHandler", { enumerable: true, get: function () { return WebAppMeta_1.RouteHandler; } });
|
|
8
|
-
Object.defineProperty(exports, "RouteContext", { enumerable: true, get: function () { return WebAppMeta_1.RouteContext; } });
|
|
9
8
|
Object.defineProperty(exports, "RouteRequest", { enumerable: true, get: function () { return WebAppMeta_1.RouteRequest; } });
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-meta/src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-meta/src/index.ts"],"names":[],"mappings":";;;AAAA,2CAQsB;AAJpB,6GAAA,eAAe,OAAA;AACf,4GAAA,cAAc,OAAA;AACd,8GAAA,gBAAgB,OAAA;AAChB,0GAAA,YAAY,OAAA","sourcesContent":["export {\n WebAppMeta,\n Routes,\n RouteBuilder,\n RouteDefinition,\n RouteMetadata2,\n FilterDefinition,\n RouteRequest,\n} from './WebAppMeta';\n"]}
|