oip-common 0.3.2 → 0.3.3

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": "oip-common",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -82,8 +82,28 @@ let config = {
82
82
  onCreateRequestParams: (rawType) => {},
83
83
  onCreateRoute: (routeData) => {},
84
84
  onCreateRouteName: (routeNameInfo, rawRouteInfo) => {
85
- if (routeNameInfo.usage.startsWith(rawRouteInfo.moduleName)) {
86
- const str = routeNameInfo.usage.substring(rawRouteInfo.moduleName.length);
85
+ const route = rawRouteInfo.route || rawRouteInfo.path || "<unknown route>";
86
+ const method = rawRouteInfo.method || rawRouteInfo.requestMethod || "<unknown method>";
87
+ const tags = Array.isArray(rawRouteInfo.tags) ? rawRouteInfo.tags.join(", ") : (rawRouteInfo.tags || "<none>");
88
+ const moduleName = rawRouteInfo.moduleName;
89
+
90
+ if (!moduleName) {
91
+ throw new Error(
92
+ `Invalid API route name for ${method.toUpperCase()} ${route}. Missing moduleName. Tags: ${tags}. ` +
93
+ "Add a controller tag/module name or provide explicit operationId.",
94
+ );
95
+ }
96
+
97
+ if (routeNameInfo.usage === moduleName) {
98
+ throw new Error(
99
+ `Invalid API route name for ${method.toUpperCase()} ${route}. Generated usage "${routeNameInfo.usage}" ` +
100
+ `equals moduleName "${moduleName}". Add an action segment in controller route, ` +
101
+ `e.g. [HttpGet("get-${moduleName}")], or provide explicit operationId.`,
102
+ );
103
+ }
104
+
105
+ if (routeNameInfo.usage.startsWith(moduleName)) {
106
+ const str = routeNameInfo.usage.substring(moduleName.length);
87
107
  routeNameInfo.usage = str[0].toLowerCase() + str.slice(1);
88
108
  routeNameInfo.original = routeNameInfo.usage;
89
109
  }