vls-openapi-generator 1.13.0 → 1.15.0
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/.eslintcache +1 -0
- package/dist/generate-openapi.js +17 -84
- package/package.json +1 -2
- package/src/generate-openapi.ts +17 -109
- package/.github/workflows/release.yaml +0 -74
- package/.github/workflows/security_allinone.yml +0 -23
package/.eslintcache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/__w/vls-openapi-generator/vls-openapi-generator/.commitlintrc.js":"1","/__w/vls-openapi-generator/vls-openapi-generator/dist/generate-openapi.js":"2","/__w/vls-openapi-generator/vls-openapi-generator/dist/index.js":"3","/__w/vls-openapi-generator/vls-openapi-generator/dist/lambda-type.js":"4","/__w/vls-openapi-generator/vls-openapi-generator/dist/openapi-type.js":"5","/__w/vls-openapi-generator/vls-openapi-generator/dist/postman-service.js":"6","/__w/vls-openapi-generator/vls-openapi-generator/dist/upload-openapi.js":"7","/__w/vls-openapi-generator/vls-openapi-generator/eslint.config.mjs":"8","/__w/vls-openapi-generator/vls-openapi-generator/release.config.js":"9","/__w/vls-openapi-generator/vls-openapi-generator/src/generate-openapi.ts":"10","/__w/vls-openapi-generator/vls-openapi-generator/src/index.ts":"11","/__w/vls-openapi-generator/vls-openapi-generator/src/lambda-type.ts":"12","/__w/vls-openapi-generator/vls-openapi-generator/src/openapi-type.ts":"13","/__w/vls-openapi-generator/vls-openapi-generator/src/postman-service.ts":"14","/__w/vls-openapi-generator/vls-openapi-generator/src/upload-openapi.ts":"15"},{"size":103,"mtime":1764155630302,"results":"16","hashOfConfig":"17"},{"size":6644,"mtime":1764169300649,"results":"18","hashOfConfig":"17"},{"size":530,"mtime":1764169300693,"results":"19","hashOfConfig":"17"},{"size":77,"mtime":1764169300629,"results":"20","hashOfConfig":"17"},{"size":77,"mtime":1764169300637,"results":"21","hashOfConfig":"17"},{"size":3073,"mtime":1764169300665,"results":"22","hashOfConfig":"17"},{"size":5361,"mtime":1764169300693,"results":"23","hashOfConfig":"17"},{"size":1247,"mtime":1764155630302,"results":"24","hashOfConfig":"17"},{"size":401,"mtime":1764155630302,"results":"25","hashOfConfig":"17"},{"size":5552,"mtime":1764169293749,"results":"26","hashOfConfig":"27"},{"size":441,"mtime":1764155630302,"results":"28","hashOfConfig":"27"},{"size":243,"mtime":1764155630302,"results":"29","hashOfConfig":"27"},{"size":1634,"mtime":1764155630302,"results":"30","hashOfConfig":"27"},{"size":3666,"mtime":1764155630302,"results":"31","hashOfConfig":"27"},{"size":3960,"mtime":1764155630302,"results":"32","hashOfConfig":"27"},{"filePath":"33","messages":"34","suppressedMessages":"35","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"47mvrp",{"filePath":"36","messages":"37","suppressedMessages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"39","messages":"40","suppressedMessages":"41","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"42","messages":"43","suppressedMessages":"44","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"45","messages":"46","suppressedMessages":"47","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","suppressedMessages":"56","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"57","messages":"58","suppressedMessages":"59","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","suppressedMessages":"62","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1fhi8uz",{"filePath":"63","messages":"64","suppressedMessages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","suppressedMessages":"68","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","suppressedMessages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","suppressedMessages":"74","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"75","messages":"76","suppressedMessages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/__w/vls-openapi-generator/vls-openapi-generator/.commitlintrc.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/dist/generate-openapi.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/dist/index.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/dist/lambda-type.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/dist/openapi-type.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/dist/postman-service.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/dist/upload-openapi.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/eslint.config.mjs",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/release.config.js",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/src/generate-openapi.ts",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/src/index.ts",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/src/lambda-type.ts",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/src/openapi-type.ts",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/src/postman-service.ts",[],[],"/__w/vls-openapi-generator/vls-openapi-generator/src/upload-openapi.ts",[],[]]
|
package/dist/generate-openapi.js
CHANGED
|
@@ -35,51 +35,39 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.generateOpenAPI = void 0;
|
|
37
37
|
const zod_openapi_1 = require("@anatine/zod-openapi");
|
|
38
|
-
const
|
|
39
|
-
const
|
|
38
|
+
const node_child_process_1 = require("node:child_process");
|
|
39
|
+
const node_fs_1 = require("node:fs");
|
|
40
40
|
require("module-alias/register.js");
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
const
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const node_util_1 = require("node:util");
|
|
43
43
|
const zod_1 = require("zod");
|
|
44
|
-
const client_cloudformation_1 = require("@aws-sdk/client-cloudformation");
|
|
45
44
|
const OPENAPI_FILE = path.join(process.cwd(), 'openapi.json');
|
|
46
45
|
const HANDLERS_DIR = path.join(process.cwd(), 'dist', 'src', 'handlers');
|
|
47
46
|
const SCHEMAS_DIR = path.join(process.cwd(), 'dist', 'src', 'schemas');
|
|
48
47
|
const OUTPUT_FILE = path.join(process.cwd(), 'openapi.json');
|
|
49
48
|
const generateOpenAPI = async () => {
|
|
50
|
-
await (0,
|
|
51
|
-
await (0,
|
|
52
|
-
const handlerFiles = await
|
|
49
|
+
await (0, node_util_1.promisify)(node_child_process_1.exec)('rm -rf ./dist');
|
|
50
|
+
await (0, node_util_1.promisify)(node_child_process_1.exec)('npx tsc');
|
|
51
|
+
const handlerFiles = await node_fs_1.promises.readdir(HANDLERS_DIR).catch((error) => {
|
|
52
|
+
console.error(error);
|
|
53
|
+
return [];
|
|
54
|
+
});
|
|
53
55
|
if (handlerFiles.length === 0) {
|
|
54
56
|
console.log('No handler found in handlers folder.');
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
console.info('Generating Open API documentation...');
|
|
58
|
-
const
|
|
59
|
-
const params = {};
|
|
60
|
-
for (let i = 2; i < args.length;) {
|
|
61
|
-
const key = args[i].replace('--', '');
|
|
62
|
-
params[key] = args[i + 1];
|
|
63
|
-
if (!params[key]) {
|
|
64
|
-
i++;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (params[key].startsWith('--')) {
|
|
68
|
-
i++;
|
|
69
|
-
delete params[key];
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
i += 2;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const existingOpenAPIFile = JSON.parse(await fs_1.promises.readFile(OPENAPI_FILE, 'utf-8'));
|
|
60
|
+
const existingOpenAPIFile = JSON.parse(await node_fs_1.promises.readFile(OPENAPI_FILE, 'utf-8'));
|
|
76
61
|
existingOpenAPIFile.paths = {};
|
|
77
62
|
for (const handler of handlerFiles) {
|
|
78
63
|
const fileName = path.parse(handler).name;
|
|
79
64
|
if (fileName.match(/^([a-z]+-)+queue-(publisher|consumer)$/)) {
|
|
80
65
|
continue;
|
|
81
66
|
}
|
|
82
|
-
const { bodySchema, queryParametersSchema, eventResponseParametersSchema, eventResponseModulesSchema, OPENAPI_CONFIG: openAPIConfig } = (await Promise.resolve(`${path.join(SCHEMAS_DIR, fileName + '.js')}`).then(s => __importStar(require(s))).catch(() =>
|
|
67
|
+
const { bodySchema, queryParametersSchema, eventResponseParametersSchema, eventResponseModulesSchema, OPENAPI_CONFIG: openAPIConfig } = (await Promise.resolve(`${path.join(SCHEMAS_DIR, fileName + '.js')}`).then(s => __importStar(require(s))).catch((error) => {
|
|
68
|
+
console.error(error);
|
|
69
|
+
return {};
|
|
70
|
+
}));
|
|
83
71
|
if (!openAPIConfig) {
|
|
84
72
|
throw new Error(`${fileName} handler schema not found.`);
|
|
85
73
|
}
|
|
@@ -94,7 +82,7 @@ const generateOpenAPI = async () => {
|
|
|
94
82
|
if (queryParametersSchema) {
|
|
95
83
|
for (const key in queryParametersComponent.properties) {
|
|
96
84
|
const properties = queryParametersComponent?.properties;
|
|
97
|
-
if (!properties
|
|
85
|
+
if (!properties?.[key]) {
|
|
98
86
|
continue;
|
|
99
87
|
}
|
|
100
88
|
queryParameters.push({
|
|
@@ -131,65 +119,10 @@ const generateOpenAPI = async () => {
|
|
|
131
119
|
}
|
|
132
120
|
};
|
|
133
121
|
}
|
|
134
|
-
|
|
135
|
-
if (partnerName) {
|
|
136
|
-
const developmentURLIndex = existingOpenAPIFile.servers.findIndex((x) => x.url.includes('development'));
|
|
137
|
-
const fetchedDevelopmentURL = await getStackURL(partnerName, 'development');
|
|
138
|
-
if (fetchedDevelopmentURL) {
|
|
139
|
-
existingOpenAPIFile.servers[developmentURLIndex].url =
|
|
140
|
-
fetchedDevelopmentURL[fetchedDevelopmentURL.length - 1] === '/'
|
|
141
|
-
? fetchedDevelopmentURL.slice(0, -1)
|
|
142
|
-
: fetchedDevelopmentURL;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
existingOpenAPIFile.servers[developmentURLIndex].url = 'development url';
|
|
146
|
-
}
|
|
147
|
-
const productionURLIndex = existingOpenAPIFile.servers.findIndex((x) => x.url.includes('production'));
|
|
148
|
-
const fetchedProductionURL = await getStackURL(partnerName, 'production');
|
|
149
|
-
if (fetchedProductionURL) {
|
|
150
|
-
existingOpenAPIFile.servers[productionURLIndex].url =
|
|
151
|
-
fetchedProductionURL[fetchedProductionURL.length - 1] === '/'
|
|
152
|
-
? fetchedProductionURL.slice(0, -1)
|
|
153
|
-
: fetchedProductionURL;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
existingOpenAPIFile.servers[productionURLIndex].url = 'production url';
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
await fs_1.promises.writeFile(OUTPUT_FILE, JSON.stringify(existingOpenAPIFile, undefined, 4));
|
|
122
|
+
await node_fs_1.promises.writeFile(OUTPUT_FILE, JSON.stringify(existingOpenAPIFile, undefined, 4));
|
|
160
123
|
console.info('Open API documentation generated successfully');
|
|
161
124
|
};
|
|
162
125
|
exports.generateOpenAPI = generateOpenAPI;
|
|
163
|
-
async function getStackURL(partnerName, environment) {
|
|
164
|
-
const stackName = `${partnerName}-${environment}`;
|
|
165
|
-
const cloudFormationClient = new client_cloudformation_1.CloudFormationClient();
|
|
166
|
-
const describeStacksCommand = new client_cloudformation_1.DescribeStacksCommand({
|
|
167
|
-
StackName: stackName
|
|
168
|
-
});
|
|
169
|
-
const result = await cloudFormationClient.send(describeStacksCommand).catch((err) => {
|
|
170
|
-
if (err instanceof client_cloudformation_1.CloudFormationServiceException &&
|
|
171
|
-
err.message.includes(`Stack with id ${stackName} does not exist`)) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
throw err;
|
|
175
|
-
});
|
|
176
|
-
if (!result || !result.Stacks) {
|
|
177
|
-
console.warn(`Base URL was not found with the given environment. Environment will not be updated. Given environment: ${environment}`);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
for (const cloudFormationStack of result.Stacks) {
|
|
181
|
-
if (!cloudFormationStack.Outputs) {
|
|
182
|
-
console.warn(`Output was not found within the given stack. Environment will not be updated. Given environment: ${environment}`);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
for (const output of cloudFormationStack.Outputs) {
|
|
186
|
-
if (output.OutputKey !== 'WebEndpoint' || !output.OutputValue) {
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
return output.OutputValue;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
126
|
function generateEventResponseComponent(responseType = 'mindbehind-chat-bot-response', eventResponseParametersSchema, eventResponseModulesSchema) {
|
|
194
127
|
if (responseType === 'mindbehind-chat-bot-response') {
|
|
195
128
|
return (0, zod_openapi_1.generateSchema)(zod_1.z.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vls-openapi-generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"description": "VLS Open API Generator",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@anatine/zod-openapi": "^2.2.7",
|
|
19
|
-
"@aws-sdk/client-cloudformation": "^3.817.0",
|
|
20
19
|
"axios": "^1.12.0",
|
|
21
20
|
"module-alias": "^2.2.3",
|
|
22
21
|
"openapi-to-postmanv2": "^4.25.0"
|
package/src/generate-openapi.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { extendApi, generateSchema, OpenApiZodAny } from '@anatine/zod-openapi';
|
|
2
|
-
import { exec } from 'child_process';
|
|
3
|
-
import { promises as fs } from 'fs';
|
|
2
|
+
import { exec } from 'node:child_process';
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
4
|
import 'module-alias/register.js';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { promisify } from 'util';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { LambdaConfig, OpenAPIConfig } from './lambda-type';
|
|
9
9
|
import { OpenAPI } from './openapi-type';
|
|
10
|
-
import {
|
|
11
|
-
CloudFormationClient,
|
|
12
|
-
CloudFormationServiceException,
|
|
13
|
-
DescribeStacksCommand
|
|
14
|
-
} from '@aws-sdk/client-cloudformation';
|
|
15
10
|
|
|
16
11
|
const OPENAPI_FILE = path.join(process.cwd(), 'openapi.json');
|
|
17
12
|
const HANDLERS_DIR = path.join(process.cwd(), 'dist', 'src', 'handlers');
|
|
@@ -22,7 +17,11 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
22
17
|
await promisify(exec)('rm -rf ./dist');
|
|
23
18
|
await promisify(exec)('npx tsc');
|
|
24
19
|
|
|
25
|
-
const handlerFiles = await fs.readdir(HANDLERS_DIR).catch(() =>
|
|
20
|
+
const handlerFiles = await fs.readdir(HANDLERS_DIR).catch((error) => {
|
|
21
|
+
console.error(error);
|
|
22
|
+
|
|
23
|
+
return [];
|
|
24
|
+
});
|
|
26
25
|
|
|
27
26
|
if (handlerFiles.length === 0) {
|
|
28
27
|
console.log('No handler found in handlers folder.');
|
|
@@ -32,26 +31,6 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
32
31
|
|
|
33
32
|
console.info('Generating Open API documentation...');
|
|
34
33
|
|
|
35
|
-
const args = process.argv;
|
|
36
|
-
const params: Record<string, string> = {};
|
|
37
|
-
|
|
38
|
-
for (let i = 2; i < args.length; ) {
|
|
39
|
-
const key = args[i].replace('--', '');
|
|
40
|
-
params[key] = args[i + 1];
|
|
41
|
-
|
|
42
|
-
if (!params[key]) {
|
|
43
|
-
i++;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (params[key].startsWith('--')) {
|
|
48
|
-
i++;
|
|
49
|
-
delete params[key];
|
|
50
|
-
} else {
|
|
51
|
-
i += 2;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
34
|
const existingOpenAPIFile = JSON.parse(await fs.readFile(OPENAPI_FILE, 'utf-8')) as OpenAPI;
|
|
56
35
|
|
|
57
36
|
existingOpenAPIFile.paths = {};
|
|
@@ -69,7 +48,11 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
69
48
|
eventResponseParametersSchema,
|
|
70
49
|
eventResponseModulesSchema,
|
|
71
50
|
OPENAPI_CONFIG: openAPIConfig
|
|
72
|
-
} = (await import(path.join(SCHEMAS_DIR, fileName + '.js')).catch(() =>
|
|
51
|
+
} = (await import(path.join(SCHEMAS_DIR, fileName + '.js')).catch((error) => {
|
|
52
|
+
console.error(error);
|
|
53
|
+
|
|
54
|
+
return {};
|
|
55
|
+
})) as {
|
|
73
56
|
bodySchema?: OpenApiZodAny;
|
|
74
57
|
eventResponseParametersSchema?: OpenApiZodAny;
|
|
75
58
|
eventResponseModulesSchema?: OpenApiZodAny;
|
|
@@ -103,14 +86,14 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
103
86
|
for (const key in queryParametersComponent.properties) {
|
|
104
87
|
const properties = queryParametersComponent?.properties;
|
|
105
88
|
|
|
106
|
-
if (!properties
|
|
89
|
+
if (!properties?.[key]) {
|
|
107
90
|
continue;
|
|
108
91
|
}
|
|
109
92
|
|
|
110
93
|
queryParameters.push({
|
|
111
94
|
name: key,
|
|
112
95
|
in: 'query',
|
|
113
|
-
schema: properties[key]
|
|
96
|
+
schema: properties[key]
|
|
114
97
|
} as const);
|
|
115
98
|
}
|
|
116
99
|
}
|
|
@@ -143,86 +126,11 @@ export const generateOpenAPI = async (): Promise<void> => {
|
|
|
143
126
|
};
|
|
144
127
|
}
|
|
145
128
|
|
|
146
|
-
const partnerName = params['partner-name'];
|
|
147
|
-
|
|
148
|
-
if (partnerName) {
|
|
149
|
-
const developmentURLIndex = existingOpenAPIFile.servers.findIndex((x) => x.url.includes('development'));
|
|
150
|
-
|
|
151
|
-
const fetchedDevelopmentURL = await getStackURL(partnerName, 'development');
|
|
152
|
-
|
|
153
|
-
if (fetchedDevelopmentURL) {
|
|
154
|
-
existingOpenAPIFile.servers[developmentURLIndex].url =
|
|
155
|
-
fetchedDevelopmentURL[fetchedDevelopmentURL.length - 1] === '/'
|
|
156
|
-
? fetchedDevelopmentURL.slice(0, -1)
|
|
157
|
-
: fetchedDevelopmentURL;
|
|
158
|
-
} else {
|
|
159
|
-
existingOpenAPIFile.servers[developmentURLIndex].url = 'development url';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const productionURLIndex = existingOpenAPIFile.servers.findIndex((x) => x.url.includes('production'));
|
|
163
|
-
|
|
164
|
-
const fetchedProductionURL = await getStackURL(partnerName, 'production');
|
|
165
|
-
|
|
166
|
-
if (fetchedProductionURL) {
|
|
167
|
-
existingOpenAPIFile.servers[productionURLIndex].url =
|
|
168
|
-
fetchedProductionURL[fetchedProductionURL.length - 1] === '/'
|
|
169
|
-
? fetchedProductionURL.slice(0, -1)
|
|
170
|
-
: fetchedProductionURL;
|
|
171
|
-
} else {
|
|
172
|
-
existingOpenAPIFile.servers[productionURLIndex].url = 'production url';
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
129
|
await fs.writeFile(OUTPUT_FILE, JSON.stringify(existingOpenAPIFile, undefined, 4));
|
|
130
|
+
|
|
177
131
|
console.info('Open API documentation generated successfully');
|
|
178
132
|
};
|
|
179
133
|
|
|
180
|
-
async function getStackURL(partnerName: string, environment: 'development' | 'production') {
|
|
181
|
-
const stackName = `${partnerName}-${environment}`;
|
|
182
|
-
const cloudFormationClient = new CloudFormationClient();
|
|
183
|
-
|
|
184
|
-
const describeStacksCommand = new DescribeStacksCommand({
|
|
185
|
-
StackName: stackName
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
const result = await cloudFormationClient.send(describeStacksCommand).catch((err) => {
|
|
189
|
-
if (
|
|
190
|
-
err instanceof CloudFormationServiceException &&
|
|
191
|
-
err.message.includes(`Stack with id ${stackName} does not exist`)
|
|
192
|
-
) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
throw err;
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
if (!result || !result.Stacks) {
|
|
200
|
-
console.warn(
|
|
201
|
-
`Base URL was not found with the given environment. Environment will not be updated. Given environment: ${environment}`
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
for (const cloudFormationStack of result.Stacks) {
|
|
208
|
-
if (!cloudFormationStack.Outputs) {
|
|
209
|
-
console.warn(
|
|
210
|
-
`Output was not found within the given stack. Environment will not be updated. Given environment: ${environment}`
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
for (const output of cloudFormationStack.Outputs) {
|
|
217
|
-
if (output.OutputKey !== 'WebEndpoint' || !output.OutputValue) {
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return output.OutputValue;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
134
|
function generateEventResponseComponent(
|
|
227
135
|
responseType: OpenAPIConfig['responseType'] = 'mindbehind-chat-bot-response',
|
|
228
136
|
eventResponseParametersSchema?: OpenApiZodAny,
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
name: CI/CD Pipeline
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
push:
|
|
8
|
-
branches:
|
|
9
|
-
- main
|
|
10
|
-
|
|
11
|
-
permissions:
|
|
12
|
-
contents: write
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
release:
|
|
16
|
-
if: github.event_name == 'push'
|
|
17
|
-
runs-on: [mb-runner]
|
|
18
|
-
container:
|
|
19
|
-
image: ubuntu:latest
|
|
20
|
-
steps:
|
|
21
|
-
- name: Install Git
|
|
22
|
-
run: apt-get update && apt-get -y install git
|
|
23
|
-
|
|
24
|
-
- name: Checkout code
|
|
25
|
-
uses: actions/checkout@v4
|
|
26
|
-
with:
|
|
27
|
-
fetch-depth: 0
|
|
28
|
-
|
|
29
|
-
- name: Setup Node
|
|
30
|
-
uses: actions/setup-node@v4
|
|
31
|
-
with:
|
|
32
|
-
node-version: 20
|
|
33
|
-
cache: 'npm'
|
|
34
|
-
|
|
35
|
-
- name: Set ownership
|
|
36
|
-
run: chown -R $(whoami) .
|
|
37
|
-
|
|
38
|
-
- name: Install dependencies
|
|
39
|
-
run: npm install
|
|
40
|
-
|
|
41
|
-
- name: Build project
|
|
42
|
-
run: npm run build
|
|
43
|
-
|
|
44
|
-
- name: Release with Semantic
|
|
45
|
-
run: npx semantic-release
|
|
46
|
-
env:
|
|
47
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN_FOR_VLS }}
|
|
48
|
-
|
|
49
|
-
build:
|
|
50
|
-
if: github.event_name == 'pull_request'
|
|
51
|
-
runs-on: [mb-runner]
|
|
52
|
-
container:
|
|
53
|
-
image: ubuntu:latest
|
|
54
|
-
steps:
|
|
55
|
-
- name: Checkout code
|
|
56
|
-
uses: actions/checkout@v4
|
|
57
|
-
|
|
58
|
-
- name: Setup Node
|
|
59
|
-
uses: actions/setup-node@v4
|
|
60
|
-
with:
|
|
61
|
-
node-version: 20
|
|
62
|
-
cache: 'npm'
|
|
63
|
-
|
|
64
|
-
- name: Install dependencies
|
|
65
|
-
run: npm install
|
|
66
|
-
|
|
67
|
-
- name: Run Prettier check
|
|
68
|
-
run: npx prettier --check .
|
|
69
|
-
|
|
70
|
-
- name: Lint check
|
|
71
|
-
run: npx eslint .
|
|
72
|
-
|
|
73
|
-
- name: Build project
|
|
74
|
-
run: npm run build
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Security AllInOne
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- feature/*
|
|
6
|
-
pull_request:
|
|
7
|
-
types:
|
|
8
|
-
- opened
|
|
9
|
-
- closed
|
|
10
|
-
- ready_for_review
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
runs-on:
|
|
14
|
-
group: default
|
|
15
|
-
labels: self-hosted
|
|
16
|
-
steps:
|
|
17
|
-
- name: Trigger to Insider Security
|
|
18
|
-
run: |
|
|
19
|
-
curl -X POST -H "Content-Type: application/json" \
|
|
20
|
-
-d '{"type": "security-allinone", "version": "v1", "repository": "${{ github.event.repository.name }}", "ref": "${{ github.head_ref || github.ref_name }}", "event_name": "${{ github.event_name }}", "event_action": "${{ github.event.action }}", "default_branch": "${{ github.event.repository.default_branch }}"}' \
|
|
21
|
-
$INSECPROXY_HOOK
|
|
22
|
-
env:
|
|
23
|
-
INSECPROXY_HOOK: ${{ secrets.INSECPROXY_HOOK }}
|