vls-openapi-generator 1.9.0 → 1.10.1

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.
@@ -8,19 +8,32 @@ on:
8
8
  branches:
9
9
  - main
10
10
 
11
+ permissions:
12
+ contents: write
13
+
11
14
  jobs:
12
15
  release:
13
16
  if: github.event_name == 'push'
14
- runs-on: ubuntu-latest
17
+ runs-on: [mb-runner]
18
+ container:
19
+ image: ubuntu:latest
15
20
  steps:
21
+ - name: Install Git
22
+ run: apt-get update && apt-get -y install git
23
+
16
24
  - name: Checkout code
17
- uses: actions/checkout@v3
25
+ uses: actions/checkout@v4
26
+ with:
27
+ fetch-depth: 0
18
28
 
19
- - name: Set up Node.js
20
- uses: actions/setup-node@v3
29
+ - name: Setup Node
30
+ uses: actions/setup-node@v4
21
31
  with:
22
- node-version: '20'
23
- registry-url: 'https://registry.npmjs.org/'
32
+ node-version: 20
33
+ cache: 'npm'
34
+
35
+ - name: Set ownership
36
+ run: chown -R $(whoami) .
24
37
 
25
38
  - name: Install dependencies
26
39
  run: npm install
@@ -31,19 +44,22 @@ jobs:
31
44
  - name: Release with Semantic
32
45
  run: npx semantic-release
33
46
  env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_FOR_VLS }}
47
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN_FOR_VLS }}
35
48
 
36
49
  build:
37
50
  if: github.event_name == 'pull_request'
38
- runs-on: ubuntu-latest
51
+ runs-on: [mb-runner]
52
+ container:
53
+ image: ubuntu:latest
39
54
  steps:
40
55
  - name: Checkout code
41
- uses: actions/checkout@v3
56
+ uses: actions/checkout@v4
42
57
 
43
- - name: Set up Node.js
44
- uses: actions/setup-node@v3
58
+ - name: Setup Node
59
+ uses: actions/setup-node@v4
45
60
  with:
46
- node-version: '20'
61
+ node-version: 20
62
+ cache: 'npm'
47
63
 
48
64
  - name: Install dependencies
49
65
  run: npm install
@@ -76,25 +76,13 @@ const generateOpenAPI = async () => {
76
76
  continue;
77
77
  }
78
78
  const { bodySchema, queryParametersSchema, eventResponseParametersSchema, eventResponseModulesSchema, OPENAPI_CONFIG: openAPIConfig } = (await Promise.resolve(`${path.join(SCHEMAS_DIR, fileName + '.js')}`).then(s => __importStar(require(s))).catch(() => ({})));
79
- const { LAMBDA_CONFIG } = (await Promise.resolve(`${path.join(HANDLERS_DIR, `${fileName}.js`)}`).then(s => __importStar(require(s))));
80
- if (openAPIConfig.isDocumentationNeeded !== undefined && !openAPIConfig.isDocumentationNeeded) {
79
+ if (openAPIConfig.isDocumentationNeeded === false) {
81
80
  continue;
82
81
  }
82
+ const { LAMBDA_CONFIG } = (await Promise.resolve(`${path.join(HANDLERS_DIR, `${fileName}.js`)}`).then(s => __importStar(require(s))));
83
83
  const bodyComponent = (0, zod_openapi_1.generateSchema)(bodySchema ?? zod_1.z.never(), undefined, '3.0');
84
84
  const queryParametersComponent = (0, zod_openapi_1.generateSchema)(queryParametersSchema ?? zod_1.z.never(), undefined, '3.0');
85
- const eventResponseComponent = (0, zod_openapi_1.generateSchema)(zod_1.z.object({
86
- ...(eventResponseParametersSchema
87
- ? { params: eventResponseParametersSchema }
88
- : { params: zod_1.z.object({}) }),
89
- ...(eventResponseModulesSchema
90
- ? { modules: eventResponseModulesSchema }
91
- : {
92
- modules: (0, zod_openapi_1.extendApi)(zod_1.z.array(zod_1.z.unknown()), {
93
- example: []
94
- })
95
- }),
96
- fallback: zod_1.z.boolean().default(false)
97
- }), undefined, '3.0');
85
+ const eventResponseComponent = generateEventResponseComponent(openAPIConfig.responseType, eventResponseParametersSchema, eventResponseModulesSchema);
98
86
  const queryParameters = [];
99
87
  if (queryParametersSchema) {
100
88
  for (const key in queryParametersComponent.properties) {
@@ -195,3 +183,21 @@ async function getStackURL(partnerName, environment) {
195
183
  }
196
184
  }
197
185
  }
186
+ function generateEventResponseComponent(responseType = 'mindbehind-chat-bot-response', eventResponseParametersSchema, eventResponseModulesSchema) {
187
+ if (responseType === 'mindbehind-chat-bot-response') {
188
+ return (0, zod_openapi_1.generateSchema)(zod_1.z.object({
189
+ ...(eventResponseParametersSchema
190
+ ? { params: eventResponseParametersSchema }
191
+ : { params: zod_1.z.object({}) }),
192
+ ...(eventResponseModulesSchema
193
+ ? { modules: eventResponseModulesSchema }
194
+ : {
195
+ modules: (0, zod_openapi_1.extendApi)(zod_1.z.array(zod_1.z.unknown()), {
196
+ example: []
197
+ })
198
+ }),
199
+ fallback: zod_1.z.boolean().default(false)
200
+ }), undefined, '3.0');
201
+ }
202
+ return (0, zod_openapi_1.generateSchema)(eventResponseParametersSchema ?? zod_1.z.object({}), undefined, '3.0');
203
+ }
@@ -1,6 +1,7 @@
1
1
  export type OpenAPIConfig = {
2
2
  tags: string[];
3
3
  isDocumentationNeeded?: boolean;
4
+ responseType?: 'mindbehind-chat-bot-response' | 'api-response';
4
5
  };
5
6
  export type LambdaConfig = {
6
7
  api?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vls-openapi-generator",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -70,32 +70,20 @@ export const generateOpenAPI = async (): Promise<void> => {
70
70
  OPENAPI_CONFIG: OpenAPIConfig;
71
71
  };
72
72
 
73
+ if (openAPIConfig.isDocumentationNeeded === false) {
74
+ continue;
75
+ }
76
+
73
77
  const { LAMBDA_CONFIG } = (await import(path.join(HANDLERS_DIR, `${fileName}.js`))) as {
74
78
  LAMBDA_CONFIG?: LambdaConfig;
75
79
  };
76
80
 
77
- if (openAPIConfig.isDocumentationNeeded !== undefined && !openAPIConfig.isDocumentationNeeded) {
78
- continue;
79
- }
80
-
81
81
  const bodyComponent = generateSchema(bodySchema ?? z.never(), undefined, '3.0');
82
82
  const queryParametersComponent = generateSchema(queryParametersSchema ?? z.never(), undefined, '3.0');
83
- const eventResponseComponent = generateSchema(
84
- z.object({
85
- ...(eventResponseParametersSchema
86
- ? { params: eventResponseParametersSchema }
87
- : { params: z.object({}) }),
88
- ...(eventResponseModulesSchema
89
- ? { modules: eventResponseModulesSchema }
90
- : {
91
- modules: extendApi(z.array(z.unknown()), {
92
- example: []
93
- })
94
- }),
95
- fallback: z.boolean().default(false)
96
- }),
97
- undefined,
98
- '3.0'
83
+ const eventResponseComponent = generateEventResponseComponent(
84
+ openAPIConfig.responseType,
85
+ eventResponseParametersSchema,
86
+ eventResponseModulesSchema
99
87
  );
100
88
 
101
89
  const queryParameters = [];
@@ -223,3 +211,31 @@ async function getStackURL(partnerName: string, environment: 'development' | 'pr
223
211
  }
224
212
  }
225
213
  }
214
+
215
+ function generateEventResponseComponent(
216
+ responseType: OpenAPIConfig['responseType'] = 'mindbehind-chat-bot-response',
217
+ eventResponseParametersSchema?: OpenApiZodAny,
218
+ eventResponseModulesSchema?: OpenApiZodAny
219
+ ) {
220
+ if (responseType === 'mindbehind-chat-bot-response') {
221
+ return generateSchema(
222
+ z.object({
223
+ ...(eventResponseParametersSchema
224
+ ? { params: eventResponseParametersSchema }
225
+ : { params: z.object({}) }),
226
+ ...(eventResponseModulesSchema
227
+ ? { modules: eventResponseModulesSchema }
228
+ : {
229
+ modules: extendApi(z.array(z.unknown()), {
230
+ example: []
231
+ })
232
+ }),
233
+ fallback: z.boolean().default(false)
234
+ }),
235
+ undefined,
236
+ '3.0'
237
+ );
238
+ }
239
+
240
+ return generateSchema(eventResponseParametersSchema ?? z.object({}), undefined, '3.0');
241
+ }
@@ -1,6 +1,7 @@
1
1
  export type OpenAPIConfig = {
2
2
  tags: string[];
3
3
  isDocumentationNeeded?: boolean;
4
+ responseType?: 'mindbehind-chat-bot-response' | 'api-response';
4
5
  };
5
6
 
6
7
  export type LambdaConfig = {