@shriyanss/js-recon 1.2.1-beta.2 → 1.2.2-alpha.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.
- package/.github/workflows/build-and-prettify.yaml +3 -0
- package/.github/workflows/pr_checker.yml +1 -0
- package/CHANGELOG.md +22 -0
- package/build/analyze/engine/astEngine.js +11 -0
- package/build/analyze/engine/astEngine.js.map +1 -1
- package/build/analyze/engine/index.js +13 -0
- package/build/analyze/engine/index.js.map +1 -1
- package/build/analyze/engine/requestEngine.js +11 -0
- package/build/analyze/engine/requestEngine.js.map +1 -1
- package/build/analyze/helpers/engineHelpers/findDirectAssignment.js +10 -0
- package/build/analyze/helpers/engineHelpers/findDirectAssignment.js.map +1 -1
- package/build/analyze/helpers/engineHelpers/findMemberExpressionAssignment.js +4 -1
- package/build/analyze/helpers/engineHelpers/findMemberExpressionAssignment.js.map +1 -1
- package/build/analyze/helpers/engineHelpers/resolveFunctionIdentifier.js +9 -4
- package/build/analyze/helpers/engineHelpers/resolveFunctionIdentifier.js.map +1 -1
- package/build/analyze/helpers/initRules.js +33 -8
- package/build/analyze/helpers/initRules.js.map +1 -1
- package/build/analyze/helpers/outputHelper.js +6 -0
- package/build/analyze/helpers/outputHelper.js.map +1 -1
- package/build/analyze/helpers/validate.js +9 -0
- package/build/analyze/helpers/validate.js.map +1 -1
- package/build/analyze/index.js +21 -0
- package/build/analyze/index.js.map +1 -1
- package/build/api_gateway/checkFeasibility.js +9 -0
- package/build/api_gateway/checkFeasibility.js.map +1 -1
- package/build/api_gateway/checkFireWallBlocking.js +9 -0
- package/build/api_gateway/checkFireWallBlocking.js.map +1 -1
- package/build/api_gateway/genReq.js +6 -0
- package/build/api_gateway/genReq.js.map +1 -1
- package/build/api_gateway/index.js +17 -0
- package/build/api_gateway/index.js.map +1 -1
- package/build/endpoints/gen_report/gen_json.js +8 -0
- package/build/endpoints/gen_report/gen_json.js.map +1 -1
- package/build/endpoints/gen_report/utility/iterate_n_store.js +18 -0
- package/build/endpoints/gen_report/utility/iterate_n_store.js.map +1 -1
- package/build/endpoints/index.js +18 -0
- package/build/endpoints/index.js.map +1 -1
- package/build/endpoints/next_js/client_jsFilesHref.js +10 -0
- package/build/endpoints/next_js/client_jsFilesHref.js.map +1 -1
- package/build/endpoints/next_js/client_jsonParse.js +10 -0
- package/build/endpoints/next_js/client_jsonParse.js.map +1 -1
- package/build/endpoints/next_js/client_mappedJsonFile.js +6 -0
- package/build/endpoints/next_js/client_mappedJsonFile.js.map +1 -1
- package/build/endpoints/next_js/client_subsequentRequests.js +7 -0
- package/build/endpoints/next_js/client_subsequentRequests.js.map +1 -1
- package/build/globalConfig.js +1 -1
- package/build/globalConfig.js.map +1 -1
- package/build/index.js +30 -1
- package/build/index.js.map +1 -1
- package/build/lazyLoad/downloadFilesUtil.js +9 -7
- package/build/lazyLoad/downloadFilesUtil.js.map +1 -1
- package/build/lazyLoad/downloadLoadedJsUtil.js +3 -10
- package/build/lazyLoad/downloadLoadedJsUtil.js.map +1 -1
- package/build/lazyLoad/globals.js +49 -1
- package/build/lazyLoad/globals.js.map +1 -1
- package/build/lazyLoad/index.js +25 -17
- package/build/lazyLoad/index.js.map +1 -1
- package/build/lazyLoad/next_js/next_GetJSScript.js +7 -4
- package/build/lazyLoad/next_js/next_GetJSScript.js.map +1 -1
- package/build/lazyLoad/next_js/next_GetLazyResourcesBuildManifestJs.js +11 -0
- package/build/lazyLoad/next_js/next_GetLazyResourcesBuildManifestJs.js.map +1 -1
- package/build/lazyLoad/next_js/next_GetLazyResourcesWebpackJs.js +15 -10
- package/build/lazyLoad/next_js/next_GetLazyResourcesWebpackJs.js.map +1 -1
- package/build/lazyLoad/next_js/next_SubsequentRequests.js +3 -7
- package/build/lazyLoad/next_js/next_SubsequentRequests.js.map +1 -1
- package/build/lazyLoad/next_js/next_buildId.js +47 -0
- package/build/lazyLoad/next_js/next_buildId.js.map +1 -0
- package/build/lazyLoad/next_js/next_globals.js +8 -0
- package/build/lazyLoad/next_js/next_globals.js.map +1 -0
- package/build/lazyLoad/nuxt_js/nuxt_astParse.js +12 -0
- package/build/lazyLoad/nuxt_js/nuxt_astParse.js.map +1 -1
- package/build/lazyLoad/nuxt_js/nuxt_getFromPageSource.js +8 -0
- package/build/lazyLoad/nuxt_js/nuxt_getFromPageSource.js.map +1 -1
- package/build/lazyLoad/nuxt_js/nuxt_stringAnalysisJSFiles.js +13 -0
- package/build/lazyLoad/nuxt_js/nuxt_stringAnalysisJSFiles.js.map +1 -1
- package/build/lazyLoad/svelte/svelte_getFromPageSource.js +8 -0
- package/build/lazyLoad/svelte/svelte_getFromPageSource.js.map +1 -1
- package/build/lazyLoad/svelte/svelte_stringAnalysisJSFiles.js +13 -0
- package/build/lazyLoad/svelte/svelte_stringAnalysisJSFiles.js.map +1 -1
- package/build/lazyLoad/techDetect/index.js +27 -12
- package/build/lazyLoad/techDetect/index.js.map +1 -1
- package/build/map/index.js +18 -0
- package/build/map/index.js.map +1 -1
- package/build/map/next_js/getAxiosInstances.js +12 -0
- package/build/map/next_js/getAxiosInstances.js.map +1 -1
- package/build/map/next_js/getExports.js +5 -0
- package/build/map/next_js/getExports.js.map +1 -1
- package/build/map/next_js/getFetchInstances.js +28 -0
- package/build/map/next_js/getFetchInstances.js.map +1 -1
- package/build/map/next_js/getWebpackConnections.js +7 -0
- package/build/map/next_js/getWebpackConnections.js.map +1 -1
- package/build/map/next_js/interactive.js +5 -0
- package/build/map/next_js/interactive.js.map +1 -1
- package/build/map/next_js/interactive_helpers/commandHandler.js +6 -0
- package/build/map/next_js/interactive_helpers/commandHandler.js.map +1 -1
- package/build/map/next_js/interactive_helpers/commandHelpers.js +34 -0
- package/build/map/next_js/interactive_helpers/commandHelpers.js.map +1 -1
- package/build/map/next_js/interactive_helpers/keybindings.js +7 -0
- package/build/map/next_js/interactive_helpers/keybindings.js.map +1 -1
- package/build/map/next_js/interactive_helpers/printer.js +7 -1
- package/build/map/next_js/interactive_helpers/printer.js.map +1 -1
- package/build/map/next_js/interactive_helpers/ui.js +9 -0
- package/build/map/next_js/interactive_helpers/ui.js.map +1 -1
- package/build/map/next_js/resolveAxios.js +10 -0
- package/build/map/next_js/resolveAxios.js.map +1 -1
- package/build/map/next_js/resolveAxiosHelpers/astNodeToJsonString.js +12 -0
- package/build/map/next_js/resolveAxiosHelpers/astNodeToJsonString.js.map +1 -1
- package/build/map/next_js/resolveAxiosHelpers/findAxiosClients.js +8 -0
- package/build/map/next_js/resolveAxiosHelpers/findAxiosClients.js.map +1 -1
- package/build/map/next_js/resolveAxiosHelpers/findAxiosInstance.js +8 -0
- package/build/map/next_js/resolveAxiosHelpers/findAxiosInstance.js.map +1 -1
- package/build/map/next_js/resolveAxiosHelpers/handleAxiosCreate.js +18 -0
- package/build/map/next_js/resolveAxiosHelpers/handleAxiosCreate.js.map +1 -1
- package/build/map/next_js/resolveAxiosHelpers/processAxiosCall.js +15 -0
- package/build/map/next_js/resolveAxiosHelpers/processAxiosCall.js.map +1 -1
- package/build/map/next_js/resolveFetch.js +5 -0
- package/build/map/next_js/resolveFetch.js.map +1 -1
- package/build/map/next_js/utils.js +29 -2
- package/build/map/next_js/utils.js.map +1 -1
- package/build/refactor/index.js +13 -0
- package/build/refactor/index.js.map +1 -1
- package/build/refactor/next/index.js +12 -0
- package/build/refactor/next/index.js.map +1 -1
- package/build/report/index.js +15 -0
- package/build/report/index.js.map +1 -1
- package/build/report/utility/dataTables/genDataTablesPage.js +48 -2
- package/build/report/utility/dataTables/genDataTablesPage.js.map +1 -1
- package/build/report/utility/genHtml.js +29 -2
- package/build/report/utility/genHtml.js.map +1 -1
- package/build/report/utility/initReportDb.js +25 -0
- package/build/report/utility/initReportDb.js.map +1 -1
- package/build/report/utility/markdownGen/addAnalyze.js +8 -0
- package/build/report/utility/markdownGen/addAnalyze.js.map +1 -1
- package/build/report/utility/markdownGen/addMappedJson.js +8 -0
- package/build/report/utility/markdownGen/addMappedJson.js.map +1 -1
- package/build/report/utility/populateDb/populateAnalysisFindings.js +8 -0
- package/build/report/utility/populateDb/populateAnalysisFindings.js.map +1 -1
- package/build/report/utility/populateDb/populateEndpoints.js +8 -0
- package/build/report/utility/populateDb/populateEndpoints.js.map +1 -1
- package/build/report/utility/populateDb/populateMappedJson.js +8 -0
- package/build/report/utility/populateDb/populateMappedJson.js.map +1 -1
- package/build/report/utility/populateDb/populateMappedOpenapi.js +8 -0
- package/build/report/utility/populateDb/populateMappedOpenapi.js.map +1 -1
- package/build/run/index.js +40 -2
- package/build/run/index.js.map +1 -1
- package/build/strings/index.js +5 -6
- package/build/strings/index.js.map +1 -1
- package/build/strings/openapi.js +8 -0
- package/build/strings/openapi.js.map +1 -1
- package/build/strings/permutate.js +7 -0
- package/build/strings/permutate.js.map +1 -1
- package/build/strings/secrets.js +13 -0
- package/build/strings/secrets.js.map +1 -1
- package/build/utility/ai.js +33 -5
- package/build/utility/ai.js.map +1 -1
- package/build/utility/configureSandbox.js +14 -0
- package/build/utility/configureSandbox.js.map +1 -0
- package/build/utility/globals.js +177 -7
- package/build/utility/globals.js.map +1 -1
- package/build/utility/makeReq.js +69 -21
- package/build/utility/makeReq.js.map +1 -1
- package/build/utility/openapiGenerator.js +15 -7
- package/build/utility/openapiGenerator.js.map +1 -1
- package/build/utility/replaceUrlPlaceholders.js +15 -0
- package/build/utility/replaceUrlPlaceholders.js.map +1 -1
- package/build/utility/resolvePath.js +15 -15
- package/build/utility/runSandboxed.js +20 -0
- package/build/utility/runSandboxed.js.map +1 -1
- package/build/utility/urlUtils.js +7 -6
- package/build/utility/urlUtils.js.map +1 -1
- package/package.json +4 -2
package/build/utility/ai.js
CHANGED
|
@@ -10,24 +10,51 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import OpenAI from "openai";
|
|
11
11
|
import { Ollama } from "ollama";
|
|
12
12
|
import * as globals from "./globals.js";
|
|
13
|
+
/**
|
|
14
|
+
* OpenAI client instance.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This client is used to communicate with the OpenAI API.
|
|
18
|
+
* The base URL and API key are configurable via the
|
|
19
|
+
* `setAiEndpoint` and `setOpenaiApiKey` functions.
|
|
20
|
+
*/
|
|
13
21
|
const openai_client = new OpenAI({
|
|
14
22
|
baseURL: globals.getAiEndpoint() || "https://api.openai.com/v1",
|
|
15
23
|
apiKey: globals.getOpenaiApiKey(),
|
|
16
24
|
});
|
|
25
|
+
/**
|
|
26
|
+
* Ollama client instance.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* This client is used to communicate with the Ollama API.
|
|
30
|
+
* The host is configurable via the `setAiEndpoint` function.
|
|
31
|
+
*/
|
|
17
32
|
const ollama_client = new Ollama({
|
|
18
33
|
host: globals.getAiEndpoint() || "http://127.0.0.1:11434",
|
|
19
34
|
});
|
|
35
|
+
/**
|
|
36
|
+
* Returns an AI client instance based on the configured provider.
|
|
37
|
+
*
|
|
38
|
+
* @returns {Object} An object containing the AI client and the configured model.
|
|
39
|
+
*/
|
|
20
40
|
const ai = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
|
|
41
|
+
const model = globals.getAiModel();
|
|
22
42
|
const provider = globals.getAiServiceProvider();
|
|
23
43
|
if (provider === "openai") {
|
|
24
|
-
|
|
44
|
+
return { client: openai_client, model };
|
|
25
45
|
}
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
if (provider === "ollama") {
|
|
47
|
+
return { client: ollama_client, model };
|
|
28
48
|
}
|
|
29
|
-
|
|
49
|
+
throw new Error(`AI service provider "${provider}" is not supported or configured.`);
|
|
30
50
|
});
|
|
51
|
+
/**
|
|
52
|
+
* Asks an AI service provider to generate text based on a prompt.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} prompt The input prompt describing the desired text output.
|
|
55
|
+
* @param {string} [systemPrompt="You are a helpful assistant."] The system prompt guiding the overall tone and behavior.
|
|
56
|
+
* @returns {Promise<string>} The generated text produced for the prompt.
|
|
57
|
+
*/
|
|
31
58
|
function getCompletion(prompt_1) {
|
|
32
59
|
return __awaiter(this, arguments, void 0, function* (prompt, systemPrompt = "You are a helpful assistant.") {
|
|
33
60
|
var _a, _b, _c, _d;
|
|
@@ -37,6 +64,7 @@ function getCompletion(prompt_1) {
|
|
|
37
64
|
throw new Error(`AI service provider "${provider}" is not supported or configured.`);
|
|
38
65
|
}
|
|
39
66
|
if (provider === "openai") {
|
|
67
|
+
// @ts-ignore
|
|
40
68
|
const completion = yield client.responses.create({
|
|
41
69
|
input: [
|
|
42
70
|
{ role: "system", content: systemPrompt },
|
package/build/utility/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/utility/ai.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,2BAA2B;IAC/D,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE;CACpC,CAAC,CAAC;AACH,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC;IAC7B,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,wBAAwB;CAC5D,CAAC,CAAC;AAEH,MAAM,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/utility/ai.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC;IAC7B,OAAO,EAAE,OAAO,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AY,EAAE;oBACzC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;iBACpC;gBACD,KAAK,EAAE,KAAK,IAAI,aAAa;gBAC7B,WAAW,EAAE,GAAG;aACnB,CAAC,CAAC;YACH,OAAO,CAAA,MAAA,MAAA,MAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAG,CAAC,CAAC,0CAAE,OAAO,0CAAG,CAAC,CAAC,0CAAE,IAAI,KAAI,MAAM,CAAC;QACjE,CAAC;QAED,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC;gBACtC,KAAK,EAAE,KAAK,IAAI,UAAU;gBAC1B,QAAQ,EAAE;oBACN,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;oBACzC;wBACI,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE,MAAM;qBAClB;iBACJ;gBACD,OAAO,EAAE;oBACL,WAAW,EAAE,GAAG;iBACnB;aACJ,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC;QAC9C,CAAC;IACL,CAAC;CAAA;AAED,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import * as globalsUtil from "./globals.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configures the browser sandbox based on command-line flags and environment variables.
|
|
5
|
+
* @param cmd - The commander command object.
|
|
6
|
+
*/
|
|
7
|
+
const configureSandbox = (cmd) => {
|
|
8
|
+
if (process.env.IS_DOCKER === "true" || cmd.sandbox === false) {
|
|
9
|
+
globalsUtil.setDisableSandbox(true);
|
|
10
|
+
console.log(chalk.yellow(`[!] Disabling browser sandbox`));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default configureSandbox;
|
|
14
|
+
//# sourceMappingURL=configureSandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureSandbox.js","sourceRoot":"","sources":["../../src/utility/configureSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,EAAE;IAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC5D,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC;IAC/D,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/build/utility/globals.js
CHANGED
|
@@ -1,113 +1,283 @@
|
|
|
1
|
-
//
|
|
1
|
+
// API Gateway Configuration
|
|
2
|
+
/** Path to the API Gateway configuration file */
|
|
2
3
|
export let apiGatewayConfigFile = "";
|
|
4
|
+
/** Whether to use API Gateway for requests */
|
|
3
5
|
export let useApiGateway = false;
|
|
6
|
+
/**
|
|
7
|
+
* Sets the API Gateway configuration file path.
|
|
8
|
+
* @param file - Path to the API Gateway configuration file
|
|
9
|
+
*/
|
|
4
10
|
export const setApiGatewayConfigFile = (file) => {
|
|
5
11
|
apiGatewayConfigFile = file;
|
|
6
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Enables or disables the use of API Gateway.
|
|
15
|
+
* @param value - Whether to use API Gateway
|
|
16
|
+
*/
|
|
7
17
|
export const setUseApiGateway = (value) => {
|
|
8
18
|
useApiGateway = value;
|
|
9
19
|
};
|
|
10
|
-
//
|
|
20
|
+
// Response Cache Configuration
|
|
21
|
+
/** Whether response caching is disabled */
|
|
11
22
|
export let disableCache = false;
|
|
23
|
+
/** Path to the response cache file */
|
|
12
24
|
export let respCacheFile = ".resp_cache.json";
|
|
25
|
+
/**
|
|
26
|
+
* Disables or enables response caching.
|
|
27
|
+
* @param value - Whether to disable caching
|
|
28
|
+
*/
|
|
13
29
|
export const setDisableCache = (value) => {
|
|
14
30
|
disableCache = value;
|
|
15
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Sets the response cache file path.
|
|
34
|
+
* @param file - Path to the response cache file
|
|
35
|
+
*/
|
|
16
36
|
export const setRespCacheFile = (file) => {
|
|
17
37
|
respCacheFile = file;
|
|
18
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Gets the current cache disable status.
|
|
41
|
+
* @returns Whether caching is disabled
|
|
42
|
+
*/
|
|
19
43
|
export const getDisableCache = () => {
|
|
20
44
|
return disableCache;
|
|
21
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Gets the current response cache file path.
|
|
48
|
+
* @returns Path to the response cache file
|
|
49
|
+
*/
|
|
22
50
|
export const getRespCacheFile = () => {
|
|
23
51
|
return respCacheFile;
|
|
24
52
|
};
|
|
25
|
-
//
|
|
53
|
+
// Sandbox Configuration
|
|
54
|
+
/** Whether to disable the browser sandbox */
|
|
55
|
+
export let disableSandbox = false;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the disable sandbox flag.
|
|
58
|
+
* @param value - Whether to disable the sandbox
|
|
59
|
+
*/
|
|
60
|
+
export const setDisableSandbox = (value) => {
|
|
61
|
+
disableSandbox = value;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current disable sandbox status.
|
|
65
|
+
* @returns Whether the sandbox is disabled
|
|
66
|
+
*/
|
|
67
|
+
export const getDisableSandbox = () => {
|
|
68
|
+
return disableSandbox;
|
|
69
|
+
};
|
|
70
|
+
// Auto-execution Configuration
|
|
71
|
+
/** Whether to auto-approve code execution */
|
|
26
72
|
export let yes = false;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the auto-approval flag for code execution.
|
|
75
|
+
* @param value - Whether to auto-approve code execution
|
|
76
|
+
*/
|
|
27
77
|
export const setYes = (value) => {
|
|
28
78
|
yes = value;
|
|
29
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Gets the current auto-approval status.
|
|
82
|
+
* @returns Whether auto-approval is enabled
|
|
83
|
+
*/
|
|
30
84
|
export const getYes = () => {
|
|
31
85
|
return yes;
|
|
32
86
|
};
|
|
33
|
-
//
|
|
87
|
+
// Request Timeout Configuration
|
|
88
|
+
/** Request timeout in milliseconds */
|
|
89
|
+
export let requestTimeout = 30000;
|
|
90
|
+
/**
|
|
91
|
+
* Sets the request timeout value.
|
|
92
|
+
* @param value - Timeout in milliseconds
|
|
93
|
+
*/
|
|
94
|
+
export const setRequestTimeout = (value) => {
|
|
95
|
+
requestTimeout = value;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Gets the current request timeout value.
|
|
99
|
+
* @returns Timeout in milliseconds
|
|
100
|
+
*/
|
|
101
|
+
export const getRequestTimeout = () => {
|
|
102
|
+
return requestTimeout;
|
|
103
|
+
};
|
|
104
|
+
// AI Configuration
|
|
105
|
+
/** Array of AI analysis options */
|
|
34
106
|
export let ai = [];
|
|
107
|
+
/** OpenAI API key */
|
|
35
108
|
export let openaiApiKey = "";
|
|
109
|
+
/** AI model to use for analysis */
|
|
36
110
|
export let aiModel = "gpt-4o-mini";
|
|
111
|
+
/** AI service provider (openai, ollama, etc.) */
|
|
37
112
|
export let aiServiceProvider = "openai";
|
|
113
|
+
/** Number of AI analysis threads */
|
|
38
114
|
export let aiThreads = 5;
|
|
115
|
+
/** Custom AI endpoint URL */
|
|
39
116
|
export let aiEndpoint = undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Sets the AI analysis options.
|
|
119
|
+
* @param value - Array of AI options (e.g., ['description'])
|
|
120
|
+
*/
|
|
40
121
|
export const setAi = (value) => {
|
|
41
122
|
ai = value;
|
|
42
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Sets the OpenAI API key.
|
|
126
|
+
* @param value - OpenAI API key
|
|
127
|
+
*/
|
|
43
128
|
export const setOpenaiApiKey = (value) => {
|
|
44
129
|
openaiApiKey = value;
|
|
45
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Gets the current AI analysis options.
|
|
133
|
+
* @returns Array of AI options
|
|
134
|
+
*/
|
|
46
135
|
export const getAi = () => {
|
|
47
136
|
return ai;
|
|
48
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Gets the OpenAI API key.
|
|
140
|
+
* @returns OpenAI API key
|
|
141
|
+
*/
|
|
49
142
|
export const getOpenaiApiKey = () => {
|
|
50
143
|
return openaiApiKey;
|
|
51
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Gets the current AI model.
|
|
147
|
+
* @returns AI model identifier
|
|
148
|
+
*/
|
|
52
149
|
export const getAiModel = () => {
|
|
53
150
|
return aiModel;
|
|
54
151
|
};
|
|
152
|
+
/**
|
|
153
|
+
* Sets the AI model to use.
|
|
154
|
+
* @param value - AI model identifier
|
|
155
|
+
*/
|
|
55
156
|
export const setAiModel = (value) => {
|
|
56
157
|
aiModel = value;
|
|
57
158
|
};
|
|
159
|
+
/**
|
|
160
|
+
* Sets the number of AI analysis threads.
|
|
161
|
+
* @param value - Number of threads
|
|
162
|
+
*/
|
|
58
163
|
export const setAiThreads = (value) => {
|
|
59
164
|
aiThreads = value;
|
|
60
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* Gets the number of AI analysis threads.
|
|
168
|
+
* @returns Number of threads
|
|
169
|
+
*/
|
|
61
170
|
export const getAiThreads = () => {
|
|
62
171
|
return aiThreads;
|
|
63
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Sets the AI service provider.
|
|
175
|
+
* @param value - Service provider identifier
|
|
176
|
+
*/
|
|
64
177
|
export const setAiServiceProvider = (value) => {
|
|
65
178
|
aiServiceProvider = value;
|
|
66
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Gets the AI service provider.
|
|
182
|
+
* @returns Service provider identifier
|
|
183
|
+
*/
|
|
67
184
|
export const getAiServiceProvider = () => {
|
|
68
185
|
return aiServiceProvider;
|
|
69
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* Sets a custom AI endpoint URL.
|
|
189
|
+
* @param value - Custom endpoint URL
|
|
190
|
+
*/
|
|
70
191
|
export const setAiEndpoint = (value) => {
|
|
71
192
|
aiEndpoint = value;
|
|
72
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Gets the custom AI endpoint URL.
|
|
196
|
+
* @returns Custom endpoint URL or undefined
|
|
197
|
+
*/
|
|
73
198
|
export const getAiEndpoint = () => {
|
|
74
199
|
return aiEndpoint;
|
|
75
200
|
};
|
|
76
|
-
//
|
|
201
|
+
// Technology Detection
|
|
202
|
+
/** Detected technology stack */
|
|
77
203
|
export let tech = "";
|
|
204
|
+
/**
|
|
205
|
+
* Sets the detected technology stack.
|
|
206
|
+
* @param value - Technology identifier (e.g., 'next', 'nuxt', 'svelte')
|
|
207
|
+
*/
|
|
78
208
|
export const setTech = (value) => {
|
|
79
209
|
tech = value;
|
|
80
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Gets the currently detected technology stack.
|
|
213
|
+
* @returns Technology identifier
|
|
214
|
+
*/
|
|
81
215
|
export const getTech = () => {
|
|
82
216
|
return tech;
|
|
83
217
|
};
|
|
84
|
-
//
|
|
218
|
+
// OpenAPI Configuration
|
|
219
|
+
/** Whether to generate OpenAPI specifications */
|
|
85
220
|
export let openapi = false;
|
|
221
|
+
/** Output file path for OpenAPI specifications */
|
|
86
222
|
export let openapiOutputFile = "mapped-openapi.json";
|
|
223
|
+
/**
|
|
224
|
+
* Enables or disables OpenAPI specification generation.
|
|
225
|
+
* @param value - Whether to generate OpenAPI specs
|
|
226
|
+
*/
|
|
87
227
|
export const setOpenapi = (value) => {
|
|
88
228
|
openapi = value;
|
|
89
229
|
};
|
|
230
|
+
/**
|
|
231
|
+
* Gets the OpenAPI generation status.
|
|
232
|
+
* @returns Whether OpenAPI generation is enabled
|
|
233
|
+
*/
|
|
90
234
|
export const getOpenapi = () => {
|
|
91
235
|
return openapi;
|
|
92
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* Sets the OpenAPI output file path.
|
|
239
|
+
* @param value - Path to the OpenAPI output file
|
|
240
|
+
*/
|
|
93
241
|
export const setOpenapiOutputFile = (value) => {
|
|
94
242
|
openapiOutputFile = value;
|
|
95
243
|
};
|
|
244
|
+
/**
|
|
245
|
+
* Gets the OpenAPI output file path.
|
|
246
|
+
* @returns Path to the OpenAPI output file
|
|
247
|
+
*/
|
|
96
248
|
export const getOpenapiOutputFile = () => {
|
|
97
249
|
return openapiOutputFile;
|
|
98
250
|
};
|
|
251
|
+
/** Array of OpenAPI output items */
|
|
99
252
|
export let openapiOutput = [];
|
|
253
|
+
/**
|
|
254
|
+
* Adds an item to the OpenAPI output collection.
|
|
255
|
+
* @param value - OpenAPI output item to add
|
|
256
|
+
*/
|
|
100
257
|
export const addOpenapiOutput = (value) => {
|
|
101
258
|
openapiOutput.push(value);
|
|
102
259
|
};
|
|
260
|
+
/**
|
|
261
|
+
* Gets the current OpenAPI output collection.
|
|
262
|
+
* @returns Array of OpenAPI output items
|
|
263
|
+
*/
|
|
103
264
|
export const getOpenapiOutput = () => {
|
|
104
265
|
return openapiOutput;
|
|
105
266
|
};
|
|
106
|
-
//
|
|
267
|
+
// OpenAPI Chunk Tag Configuration
|
|
268
|
+
/** Whether to add chunk ID tags to OpenAPI specifications */
|
|
107
269
|
export let openapiChunkTag = false;
|
|
270
|
+
/**
|
|
271
|
+
* Enables or disables chunk ID tags in OpenAPI specs.
|
|
272
|
+
* @param value - Whether to add chunk ID tags
|
|
273
|
+
*/
|
|
108
274
|
export const setOpenapiChunkTag = (value) => {
|
|
109
275
|
openapiChunkTag = value;
|
|
110
276
|
};
|
|
277
|
+
/**
|
|
278
|
+
* Gets the chunk tag configuration status.
|
|
279
|
+
* @returns Whether chunk ID tags are enabled
|
|
280
|
+
*/
|
|
111
281
|
export const getOpenapiChunkTag = () => {
|
|
112
282
|
return openapiChunkTag;
|
|
113
283
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/utility/globals.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/utility/globals.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,iDAAiD;AACjD,MAAM,CAAC,IAAI,oBAAoB,GAAG,EAAE,CAAC;AACrC,8CAA8C;AAC9C,MAAM,CAAC,IAAI,aAAa,GAAG,KAAK,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC1D,oBAAoB,GAAG,IAAI,CAAC;AAChC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAQ,EAAE;IACrD,aAAa,GAAG,KAAK,CAAC;AAC1B,CAAC,CAAC;AAEF,+BAA+B;AAC/B,2CAA2C;AAC3C,MAAM,CAAC,IAAI,YAAY,GAAG,KAAK,CAAC;AAChC,sCAAsC;AACtC,MAAM,CAAC,IAAI,aAAa,GAAG,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAAQ,EAAE;IACpD,YAAY,GAAG,KAAK,CAAC;AACzB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAQ,EAAE;IACnD,aAAa,GAAG,IAAI,CAAC;AACzB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE;IACzC,OAAO,YAAY,CAAC;AACxB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CA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;AAeF,oCAAoC;AACpC,MAAM,CAAC,IAAI,aAAa,GAAwB,EAAE,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAwB,EAAQ,EAAE;IAC/D,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAwB,EAAE;IACtD,OAAO,aAAa,CAAC;AACzB,CAAC,CAAC;AAEF,kCAAkC;AAClC,6DAA6D;AAC7D,MAAM,CAAC,IAAI,eAAe,GAAG,KAAK,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAQ,EAAE;IACvD,eAAe,GAAG,KAAK,CAAC;AAC5B,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAY,EAAE;IAC5C,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAC"}
|
package/build/utility/makeReq.js
CHANGED
|
@@ -7,6 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
10
21
|
import chalk from "chalk";
|
|
11
22
|
import puppeteer from "puppeteer";
|
|
12
23
|
import * as globals from "./globals.js";
|
|
@@ -70,6 +81,20 @@ const UAs = [
|
|
|
70
81
|
"Chrome/Android: Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36",
|
|
71
82
|
"Firefox/Android: Mozilla/5.0 (Android 11; Mobile; rv:68.0) Gecko/68.0 Firefox/84.0",
|
|
72
83
|
];
|
|
84
|
+
/**
|
|
85
|
+
* Reads response data from cache for future requests.
|
|
86
|
+
*
|
|
87
|
+
* If the cache file exists, and the given URL is present in the cache,
|
|
88
|
+
* it checks if the response contains the specific request headers. If it does,
|
|
89
|
+
* it builds a Response object with the cached data and returns it.
|
|
90
|
+
*
|
|
91
|
+
* If the response does not contain the request headers, or if the cache file
|
|
92
|
+
* does not exist, or if the URL is not present in the cache, it returns null.
|
|
93
|
+
*
|
|
94
|
+
* @param url - The URL to read the cache for
|
|
95
|
+
* @param headers - Request headers that were used
|
|
96
|
+
* @returns A Promise that resolves to a Response object if the cache is found, or null if not
|
|
97
|
+
*/
|
|
73
98
|
const readCache = (url, headers) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
99
|
// first, check if the file exists or not
|
|
75
100
|
if (!fs.existsSync(globals.getRespCacheFile())) {
|
|
@@ -102,6 +127,17 @@ const readCache = (url, headers) => __awaiter(void 0, void 0, void 0, function*
|
|
|
102
127
|
// console.log("cache not found for ", url);
|
|
103
128
|
return null;
|
|
104
129
|
});
|
|
130
|
+
/**
|
|
131
|
+
* Writes response data to cache for future requests.
|
|
132
|
+
*
|
|
133
|
+
* Stores response body, status, and headers in cache file, handling special
|
|
134
|
+
* cases like RSC (React Server Components) headers separately.
|
|
135
|
+
*
|
|
136
|
+
* @param url - The URL to cache the response for
|
|
137
|
+
* @param headers - Request headers that were used
|
|
138
|
+
* @param response - The Response object to cache
|
|
139
|
+
* @returns Promise that resolves when caching is complete
|
|
140
|
+
*/
|
|
105
141
|
const writeCache = (url, headers, response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
142
|
// clone the response
|
|
107
143
|
const clonedResponse = response.clone();
|
|
@@ -139,18 +175,35 @@ const writeCache = (url, headers, response) => __awaiter(void 0, void 0, void 0,
|
|
|
139
175
|
fs.writeFileSync(globals.getRespCacheFile(), JSON.stringify(cache));
|
|
140
176
|
// console.log("wrote cache for ", url);
|
|
141
177
|
});
|
|
178
|
+
/**
|
|
179
|
+
* Makes a GET request to the given URL and returns the response.
|
|
180
|
+
*
|
|
181
|
+
* If caching is enabled, it will first check if the response is cached.
|
|
182
|
+
* If it is, it will return the cached response. If not, it will make the request
|
|
183
|
+
* using the given options, and cache the response before returning it.
|
|
184
|
+
*
|
|
185
|
+
* If the request fails, it will retry up to 10 times with 0.5s of sleep in between.
|
|
186
|
+
* If all retries fail, it will return null.
|
|
187
|
+
*
|
|
188
|
+
* @param url - The URL to request
|
|
189
|
+
* @param args - Request options
|
|
190
|
+
* @returns A Promise that resolves to a Response, or null if all retries fail
|
|
191
|
+
*/
|
|
142
192
|
const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
193
|
+
const _a = args || {}, { timeout } = _a, restArgs = __rest(_a, ["timeout"]);
|
|
194
|
+
const requestOptions = restArgs;
|
|
195
|
+
const requestTimeout = timeout || globals.getRequestTimeout();
|
|
143
196
|
// if cache is enabled, read the cache and return if cache is present. else, continue
|
|
144
197
|
if (!globals.getDisableCache()) {
|
|
145
|
-
const cachedResponse = yield readCache(url,
|
|
198
|
+
const cachedResponse = yield readCache(url, requestOptions.headers || {});
|
|
146
199
|
if (cachedResponse !== null) {
|
|
147
200
|
return cachedResponse;
|
|
148
201
|
}
|
|
149
202
|
}
|
|
150
203
|
if (globals.useApiGateway) {
|
|
151
204
|
let get_headers;
|
|
152
|
-
if (
|
|
153
|
-
get_headers =
|
|
205
|
+
if (requestOptions && requestOptions.headers) {
|
|
206
|
+
get_headers = requestOptions.headers;
|
|
154
207
|
}
|
|
155
208
|
else {
|
|
156
209
|
get_headers = {
|
|
@@ -174,31 +227,22 @@ const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
174
227
|
return response;
|
|
175
228
|
}
|
|
176
229
|
else {
|
|
177
|
-
if (args === undefined || Object.keys(args).length === 0) {
|
|
178
|
-
args = {
|
|
179
|
-
headers: {
|
|
180
|
-
"User-Agent": UAs[Math.floor(Math.random() * UAs.length)],
|
|
181
|
-
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
182
|
-
"Accept-Language": "en-US,en;q=0.9",
|
|
183
|
-
"Sec-Fetch-Site": "same-origin",
|
|
184
|
-
"Sec-Fetch-Mode": "cors",
|
|
185
|
-
"Sec-Fetch-Dest": "empty",
|
|
186
|
-
Referer: url,
|
|
187
|
-
Origin: url,
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
230
|
let res;
|
|
192
231
|
let counter = 0;
|
|
193
232
|
while (true) {
|
|
233
|
+
const controller = new AbortController();
|
|
234
|
+
const timeoutId = setTimeout(() => controller.abort(), requestTimeout);
|
|
235
|
+
const currentRequestOptions = Object.assign(Object.assign({}, requestOptions), { signal: controller.signal });
|
|
194
236
|
try {
|
|
195
237
|
EventEmitter.defaultMaxListeners = 20;
|
|
196
|
-
res = yield fetch(url,
|
|
238
|
+
res = yield fetch(url, currentRequestOptions);
|
|
239
|
+
clearTimeout(timeoutId);
|
|
197
240
|
if (res) {
|
|
198
241
|
break;
|
|
199
242
|
}
|
|
200
243
|
}
|
|
201
244
|
catch (err) {
|
|
245
|
+
clearTimeout(timeoutId);
|
|
202
246
|
counter++;
|
|
203
247
|
// BUG: https://github.com/nodejs/node/issues/47246
|
|
204
248
|
// if the header content is too large, it will throw an error like
|
|
@@ -209,6 +253,10 @@ const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
209
253
|
console.log(chalk.yellow(`[!] The tool detected a header overflow. Please increase the limit by setting environment variable \`NODE_OPTIONS="--max-http-header-size=99999999"\`. If the error still persists, please try again with a higher limit.`));
|
|
210
254
|
process.exit(21);
|
|
211
255
|
}
|
|
256
|
+
if (err.name === "AbortError") {
|
|
257
|
+
console.log(chalk.red(`[!] Request to ${url} timed out after ${requestTimeout}ms`));
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
212
260
|
if (counter > 10) {
|
|
213
261
|
console.log(chalk.red(`[!] Failed to fetch ${url} : ${err}`));
|
|
214
262
|
return null;
|
|
@@ -228,7 +276,7 @@ const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
228
276
|
// if it is, load it in a headless browser
|
|
229
277
|
const browser = yield puppeteer.launch({
|
|
230
278
|
headless: true,
|
|
231
|
-
args:
|
|
279
|
+
args: globals.getDisableSandbox() ? ["--no-sandbox", "--disable-setuid-sandbox"] : [],
|
|
232
280
|
});
|
|
233
281
|
const page = yield browser.newPage();
|
|
234
282
|
yield page.goto(url);
|
|
@@ -246,7 +294,7 @@ const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
246
294
|
// if it is, load it in a headless browser
|
|
247
295
|
const browser = yield puppeteer.launch({
|
|
248
296
|
headless: true,
|
|
249
|
-
args:
|
|
297
|
+
args: globals.getDisableSandbox() ? ["--no-sandbox", "--disable-setuid-sandbox"] : [],
|
|
250
298
|
});
|
|
251
299
|
const page = yield browser.newPage();
|
|
252
300
|
yield page.goto(url);
|
|
@@ -262,7 +310,7 @@ const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
262
310
|
// if cache is enabled, write the response to the cache
|
|
263
311
|
if (!globals.getDisableCache()) {
|
|
264
312
|
const resToCache = preservedRes.clone();
|
|
265
|
-
yield writeCache(url,
|
|
313
|
+
yield writeCache(url, requestOptions.headers || {}, resToCache);
|
|
266
314
|
}
|
|
267
315
|
return preservedRes2;
|
|
268
316
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeReq.js","sourceRoot":"","sources":["../../src/utility/makeReq.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"makeReq.js","sourceRoot":"","sources":["../../src/utility/makeReq.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,qBAAqB;AACrB,MAAM,GAAG,GAAG;IACR,oIAAoI;IACpI,+HAA+H;IAC/H,wHAAwH;IACxH,qIAAqI;IACrI,wHAAwH;IACxH,8JAA8J;IAC9J,mKAAmK;IACnK,mJAAmJ;IACnJ,0JAA0J;IAC1J,kIAAkI;IAClI,4IAA4I;IAC5I,2IAA2I;IAC3I,iGAAiG;IACjG,kGAAkG;IAClG,mFAAmF;IACnF,0JAA0J;IAC1J,+IAA+I;IAC/I,oFAAoF;IACpF,oIAAoI;IACpI,wJAAwJ;IACxJ,0JAA0J;IAC1J,6IAA6I;IAC7I,8EAA8E;IAC9E,kJAAkJ;IAClJ,mJAAmJ;IACnJ,0JAA0J;IAC1J,sKAAsK;IACtK,qJAAqJ;IACrJ,sJAAsJ;IACtJ,yIAAyI;IACzI,8JAA8J;IAC9J,4IAA4I;IAC5I,kJAAkJ;IAClJ,qIAAqI;IACrI,4JAA4J;IAC5J,kKAAkK;IAClK,2KAA2K;IAC3K,2KAA2K;IAC3K,qIAAqI;IACrI,oIAAoI;IACpI,kGAAkG;IAClG,qIAAqI;IACrI,kJAAkJ;IAClJ,mJAAmJ;IACnJ,qJAAqJ;IACrJ,2JAA2J;IAC3J,uJAAuJ;IACvJ,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AC,CAAC,EAAE;aACxF,CAAC,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;YAC1D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YAEtB,uDAAuD;YACvD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;gBAC7B,MAAM,UAAU,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,uDAAuD;QACvD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;YACxC,MAAM,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC,OAAO,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as globalsUtil from "./globals.js";
|
|
2
2
|
import replacePlaceholders from "./replaceUrlPlaceholders.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* `OpenapiOutputItem` objects.
|
|
4
|
+
* Returns the OpenAPI type string corresponding to the given value.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* If the value is null, returns "string" as OpenAPI 3.0 doesn't have a 'null' type.
|
|
7
|
+
* If the value is an array, returns "array".
|
|
8
|
+
* If the value is a primitive type (string, number, boolean), returns the corresponding OpenAPI type.
|
|
9
|
+
* If the value is an object, returns "object".
|
|
10
|
+
* For other types, returns "string" as a fallback.
|
|
11
|
+
* @param value - The value to determine the OpenAPI type for
|
|
12
|
+
* @returns The OpenAPI type string corresponding to the given value
|
|
12
13
|
*/
|
|
13
14
|
export const getOpenApiType = (value) => {
|
|
14
15
|
if (value === null) {
|
|
@@ -23,6 +24,13 @@ export const getOpenApiType = (value) => {
|
|
|
23
24
|
}
|
|
24
25
|
return "string"; // Fallback for other types
|
|
25
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Generates an OpenAPI v3 spec based on the given OpenAPI output items.
|
|
29
|
+
*
|
|
30
|
+
* @param items - The OpenAPI output items to generate the spec from
|
|
31
|
+
* @param chunks - The chunks of API endpoints that the items belong to
|
|
32
|
+
* @returns The generated OpenAPI v3 spec
|
|
33
|
+
*/
|
|
26
34
|
export const generateOpenapiV3Spec = (items, chunks) => {
|
|
27
35
|
const spec = {
|
|
28
36
|
openapi: "3.0.0",
|