@adaptivestone/framework 3.4.1 → 3.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 3.4.2
2
+
3
+ [UPDATE] updated deps
4
+ [FIX] fix documentation generation
5
+
1
6
  ### 3.4.1
2
7
 
3
8
  [FIX] fix documentation generation
@@ -81,6 +81,7 @@ class GetOpenApiJson extends AbstractCommand {
81
81
 
82
82
  openApi.paths = {};
83
83
 
84
+ const permissionWithRoutes = {};
84
85
  for (const controller of baseDocumentation) {
85
86
  for (const route of controller.routesInfo) {
86
87
  const routeInfo = route[Object.keys(route)?.[0]];
@@ -90,7 +91,9 @@ class GetOpenApiJson extends AbstractCommand {
90
91
  ];
91
92
 
92
93
  const securitySchemaNames = [];
93
- let permissionString = '';
94
+
95
+ permissionWithRoutes[Object.keys(route)?.[0]] = [];
96
+
94
97
  if (middlewares?.length) {
95
98
  for (const middleware of middlewares) {
96
99
  if (middleware?.authParams?.length) {
@@ -98,7 +101,9 @@ class GetOpenApiJson extends AbstractCommand {
98
101
  const { permissions, ...mainFields } = authParam;
99
102
  const fullName = authParam.name;
100
103
  if (permissions) {
101
- permissionString = permissions;
104
+ permissionWithRoutes[Object.keys(route)?.[0]].push(
105
+ permissions,
106
+ );
102
107
  }
103
108
 
104
109
  if (!openApi.components.securitySchemes[fullName]) {
@@ -114,7 +119,6 @@ class GetOpenApiJson extends AbstractCommand {
114
119
  }
115
120
 
116
121
  let routeName = Object.keys(route)[0];
117
-
118
122
  if (routeName === '/') {
119
123
  // eslint-disable-next-line no-continue
120
124
  continue;
@@ -150,7 +154,13 @@ class GetOpenApiJson extends AbstractCommand {
150
154
 
151
155
  const routeDescription =
152
156
  route[Object.keys(route)[0]]?.description || 'empty description';
153
- const routeDescriptionWithPermissions = `${permissionString} ${routeDescription}`;
157
+ const permissions =
158
+ permissionWithRoutes[Object.keys(route)[0]][
159
+ permissionWithRoutes[Object.keys(route)[0]].length - 1
160
+ ];
161
+ const routeDescriptionWithPermissions = `${
162
+ permissions || ''
163
+ } ${routeDescription}`;
154
164
  const methodName = route[Object.keys(route)[0]].method.toLowerCase();
155
165
  const routeTitle = route[Object.keys(route)[0]].name;
156
166
 
@@ -232,6 +242,19 @@ class GetOpenApiJson extends AbstractCommand {
232
242
  type: field.innerType,
233
243
  };
234
244
  }
245
+
246
+ if (field.type === 'lazy') {
247
+ groupBodyFields[field.name] = {
248
+ oneOf: [
249
+ {
250
+ type: 'object',
251
+ },
252
+ {
253
+ type: 'string',
254
+ },
255
+ ],
256
+ };
257
+ }
235
258
  }
236
259
  }
237
260
 
@@ -364,13 +364,11 @@ class AbstractController extends Base {
364
364
  .map((middleware) => {
365
365
  const routeFullPath = route.fullPath.toUpperCase();
366
366
  const middlewareFullPath = middleware.fullPath.toUpperCase();
367
- const middlewareFullPathWithSliced = middleware.fullPath
368
- .toUpperCase()
369
- .slice(0, -1);
370
367
  if (
371
- middlewareFullPath === routeFullPath ||
372
- middlewareFullPath === `${routeFullPath}*` ||
373
- routeFullPath?.indexOf(middlewareFullPathWithSliced) !== -1
368
+ route.method.toLowerCase() ===
369
+ middleware.method.toLowerCase() &&
370
+ (middlewareFullPath === routeFullPath ||
371
+ middlewareFullPath === `${routeFullPath}*`)
374
372
  ) {
375
373
  return {
376
374
  name: middleware.name,
@@ -390,6 +388,7 @@ class AbstractController extends Base {
390
388
  const middlewareFullPathWithSliced = middleware.fullPath
391
389
  .toUpperCase()
392
390
  .slice(0, -1);
391
+
393
392
  return (
394
393
  middlewareFullPath === routeFullPath ||
395
394
  middlewareFullPath === `${routeFullPath}*` ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptivestone/framework",
3
- "version": "3.4.1",
3
+ "version": "3.4.3",
4
4
  "description": "Adaptive stone node js framework",
5
5
  "main": "src/index.js",
6
6
  "engines": {
package/tests/setup.js CHANGED
@@ -1,13 +1,14 @@
1
+ const path = require('node:path');
1
2
  /* eslint-disable jest/require-top-level-describe */
2
3
  const { MongoMemoryReplSet } = require('mongodb-memory-server');
3
4
  const mongoose = require('mongoose');
4
5
 
5
6
  let mongoMemoryServerInstance;
6
- const path = require('path');
7
+
7
8
  const redis = require('redis');
8
9
  const Server = require('../server');
9
10
 
10
- const clearRadisNamespace = require('../helpers/redis/clearNamespace');
11
+ const clearRedisNamespace = require('../helpers/redis/clearNamespace');
11
12
 
12
13
  jest.setTimeout(1000000);
13
14
  beforeAll(async () => {
@@ -29,6 +30,7 @@ beforeAll(async () => {
29
30
  models: process.env.TEST_FOLDER_MODELS || path.resolve('./models'),
30
31
  emails:
31
32
  process.env.TEST_FOLDER_EMAIL ||
33
+ process.env.TEST_FOLDER_EMAILS ||
32
34
  path.resolve('./services/messaging/email/templates'),
33
35
  locales: process.env.TEST_FOLDER_LOCALES || path.resolve('./locales'),
34
36
  commands: process.env.TEST_FOLDER_COMMANDS || path.resolve('./commands'),
@@ -81,9 +83,13 @@ afterEach(async () => {
81
83
  const { url, namespace } = global.server.getConfig('redis');
82
84
  const redisClient = redis.createClient({ url });
83
85
 
84
- await redisClient.connect();
85
- await clearRadisNamespace(redisClient, namespace);
86
- await redisClient.disconnect();
86
+ try {
87
+ await redisClient.connect();
88
+ await clearRedisNamespace(redisClient, namespace);
89
+ await redisClient.disconnect();
90
+ } catch (err) {
91
+ // that ok. No redis connection
92
+ }
87
93
  }
88
94
  });
89
95