@scalar/openapi-parser 0.10.15 → 0.10.17
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 +12 -0
- package/README.md +0 -22
- package/dist/configuration/index.js +19 -22
- package/dist/configuration/index.js.map +7 -0
- package/dist/declarations.d.js +1 -0
- package/dist/declarations.d.js.map +7 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -29
- package/dist/index.js.map +7 -0
- package/dist/lib/Validator/Validator.d.ts +2 -2
- package/dist/lib/Validator/Validator.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.js +99 -119
- package/dist/lib/Validator/Validator.js.map +7 -0
- package/dist/lib/Validator/Validator.test.js +8 -0
- package/dist/lib/Validator/Validator.test.js.map +7 -0
- package/dist/lib/Validator/index.d.ts +2 -2
- package/dist/lib/Validator/index.d.ts.map +1 -1
- package/dist/lib/Validator/index.js +3 -0
- package/dist/lib/Validator/index.js.map +7 -0
- package/dist/plugins/fetch-urls/fetchUrls.d.ts +1 -2
- package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +1 -1
- package/dist/plugins/fetch-urls/fetchUrls.js +36 -111
- package/dist/plugins/fetch-urls/fetchUrls.js.map +7 -0
- package/dist/plugins/fetch-urls/fetchUrls.test.js +50 -0
- package/dist/plugins/fetch-urls/fetchUrls.test.js.map +7 -0
- package/dist/plugins/fetch-urls/index.d.ts +1 -1
- package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
- package/dist/plugins/fetch-urls/index.js +2 -1
- package/dist/plugins/fetch-urls/index.js.map +7 -0
- package/dist/plugins/read-files/index.d.ts +1 -1
- package/dist/plugins/read-files/index.d.ts.map +1 -1
- package/dist/plugins/read-files/index.js +2 -1
- package/dist/plugins/read-files/index.js.map +7 -0
- package/dist/plugins/read-files/readFiles.d.ts +1 -1
- package/dist/plugins/read-files/readFiles.d.ts.map +1 -1
- package/dist/plugins/read-files/readFiles.js +50 -70
- package/dist/plugins/read-files/readFiles.js.map +7 -0
- package/dist/plugins/read-files/readFiles.test.js +20 -0
- package/dist/plugins/read-files/readFiles.test.js.map +7 -0
- package/dist/polyfills/index.d.ts +1 -1
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +5 -0
- package/dist/polyfills/index.js.map +7 -0
- package/dist/polyfills/path.js +155 -98
- package/dist/polyfills/path.js.map +7 -0
- package/dist/schemas/v2.0/schema.d.ts +1405 -0
- package/dist/schemas/v2.0/schema.d.ts.map +1 -0
- package/dist/schemas/v2.0/schema.js +1463 -0
- package/dist/schemas/v2.0/schema.js.map +7 -0
- package/dist/schemas/v3.0/schema.d.ts +1264 -0
- package/dist/schemas/v3.0/schema.d.ts.map +1 -0
- package/dist/schemas/v3.0/schema.js +1493 -0
- package/dist/schemas/v3.0/schema.js.map +7 -0
- package/dist/schemas/v3.1/schema.d.ts +1225 -0
- package/dist/schemas/v3.1/schema.d.ts.map +1 -0
- package/dist/schemas/v3.1/schema.js +1296 -0
- package/dist/schemas/v3.1/schema.js.map +7 -0
- package/dist/types/index.d.ts +5 -24
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/helpers.js +88 -93
- package/dist/utils/betterAjvErrors/helpers.js.map +7 -0
- package/dist/utils/betterAjvErrors/index.js +14 -13
- package/dist/utils/betterAjvErrors/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts +2 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.js +27 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.js.map +7 -0
- package/dist/utils/betterAjvErrors/json/index.d.ts +2 -0
- package/dist/utils/betterAjvErrors/json/index.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/json/index.js +5 -0
- package/dist/utils/betterAjvErrors/json/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/json/utils.d.ts +2 -0
- package/dist/utils/betterAjvErrors/json/utils.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/json/utils.js +11 -0
- package/dist/utils/betterAjvErrors/json/utils.js.map +7 -0
- package/dist/utils/betterAjvErrors/utils.js +21 -14
- package/dist/utils/betterAjvErrors/utils.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.d.ts +23 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.js +6 -10
- package/dist/utils/betterAjvErrors/validation-errors/base.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/default.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts +11 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.js +19 -29
- package/dist/utils/betterAjvErrors/validation-errors/enum.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.d.ts +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.js +15 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/required.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js.map +7 -0
- package/dist/utils/dereference.d.ts +2 -2
- package/dist/utils/dereference.d.ts.map +1 -1
- package/dist/utils/dereference.js +17 -19
- package/dist/utils/dereference.js.map +7 -0
- package/dist/utils/dereference.test.js +300 -0
- package/dist/utils/dereference.test.js.map +7 -0
- package/dist/utils/details.d.ts +1 -1
- package/dist/utils/details.d.ts.map +1 -1
- package/dist/utils/details.js +26 -28
- package/dist/utils/details.js.map +7 -0
- package/dist/utils/errors.test.js +48 -0
- package/dist/utils/errors.test.js.map +7 -0
- package/dist/utils/escapeJsonPointer.js +5 -8
- package/dist/utils/escapeJsonPointer.js.map +7 -0
- package/dist/utils/escapeJsonPointer.test.js +11 -0
- package/dist/utils/escapeJsonPointer.test.js.map +7 -0
- package/dist/utils/filter.d.ts +1 -1
- package/dist/utils/filter.d.ts.map +1 -1
- package/dist/utils/filter.js +13 -15
- package/dist/utils/filter.js.map +7 -0
- package/dist/utils/getEntrypoint.d.ts +1 -1
- package/dist/utils/getEntrypoint.d.ts.map +1 -1
- package/dist/utils/getEntrypoint.js +5 -6
- package/dist/utils/getEntrypoint.js.map +7 -0
- package/dist/utils/getEntrypoint.test.js +18 -0
- package/dist/utils/getEntrypoint.test.js.map +7 -0
- package/dist/utils/getListOfReferences.d.ts +1 -1
- package/dist/utils/getListOfReferences.d.ts.map +1 -1
- package/dist/utils/getListOfReferences.js +15 -22
- package/dist/utils/getListOfReferences.js.map +7 -0
- package/dist/utils/getSegmentsFromPath.js +8 -15
- package/dist/utils/getSegmentsFromPath.js.map +7 -0
- package/dist/utils/getSegmentsFromPath.test.js +13 -0
- package/dist/utils/getSegmentsFromPath.test.js.map +7 -0
- package/dist/utils/index.d.ts +26 -26
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/isFilesystem.d.ts +1 -2
- package/dist/utils/isFilesystem.d.ts.map +1 -1
- package/dist/utils/isFilesystem.js +5 -9
- package/dist/utils/isFilesystem.js.map +7 -0
- package/dist/utils/isJson.js +10 -9
- package/dist/utils/isJson.js.map +7 -0
- package/dist/utils/isObject.js +5 -6
- package/dist/utils/isObject.js.map +7 -0
- package/dist/utils/isObject.test.js +23 -0
- package/dist/utils/isObject.test.js.map +7 -0
- package/dist/utils/isYaml.js +16 -17
- package/dist/utils/isYaml.js.map +7 -0
- package/dist/utils/load/index.d.ts +1 -1
- package/dist/utils/load/index.d.ts.map +1 -1
- package/dist/utils/load/index.js +2 -0
- package/dist/utils/load/index.js.map +7 -0
- package/dist/utils/load/load.d.ts +3 -12
- package/dist/utils/load/load.d.ts.map +1 -1
- package/dist/utils/load/load.js +89 -149
- package/dist/utils/load/load.js.map +7 -0
- package/dist/utils/load/load.test.js +361 -0
- package/dist/utils/load/load.test.js.map +7 -0
- package/dist/utils/makeFilesystem.d.ts +2 -19
- package/dist/utils/makeFilesystem.d.ts.map +1 -1
- package/dist/utils/makeFilesystem.js +20 -68
- package/dist/utils/makeFilesystem.js.map +7 -0
- package/dist/utils/makeFilesystem.test.js +15 -0
- package/dist/utils/makeFilesystem.test.js.map +7 -0
- package/dist/utils/normalize.d.ts +1 -1
- package/dist/utils/normalize.d.ts.map +1 -1
- package/dist/utils/normalize.js +22 -27
- package/dist/utils/normalize.js.map +7 -0
- package/dist/utils/normalize.test.js +88 -0
- package/dist/utils/normalize.test.js.map +7 -0
- package/dist/utils/openapi/actions/details.d.ts +2 -2
- package/dist/utils/openapi/actions/details.d.ts.map +1 -1
- package/dist/utils/openapi/actions/details.js +9 -11
- package/dist/utils/openapi/actions/details.js.map +7 -0
- package/dist/utils/openapi/actions/files.d.ts +1 -1
- package/dist/utils/openapi/actions/files.d.ts.map +1 -1
- package/dist/utils/openapi/actions/files.js +7 -9
- package/dist/utils/openapi/actions/files.js.map +7 -0
- package/dist/utils/openapi/actions/get.d.ts +1 -1
- package/dist/utils/openapi/actions/get.d.ts.map +1 -1
- package/dist/utils/openapi/actions/get.js +9 -11
- package/dist/utils/openapi/actions/get.js.map +7 -0
- package/dist/utils/openapi/actions/toJson.d.ts +1 -1
- package/dist/utils/openapi/actions/toJson.d.ts.map +1 -1
- package/dist/utils/openapi/actions/toJson.js +9 -11
- package/dist/utils/openapi/actions/toJson.js.map +7 -0
- package/dist/utils/openapi/actions/toYaml.d.ts +1 -1
- package/dist/utils/openapi/actions/toYaml.d.ts.map +1 -1
- package/dist/utils/openapi/actions/toYaml.js +9 -11
- package/dist/utils/openapi/actions/toYaml.js.map +7 -0
- package/dist/utils/openapi/commands/dereferenceCommand.d.ts +5 -5
- package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/dereferenceCommand.js +25 -27
- package/dist/utils/openapi/commands/dereferenceCommand.js.map +7 -0
- package/dist/utils/openapi/commands/filterCommand.d.ts +9 -9
- package/dist/utils/openapi/commands/filterCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/filterCommand.js +24 -26
- package/dist/utils/openapi/commands/filterCommand.js.map +7 -0
- package/dist/utils/openapi/commands/loadCommand.d.ts +1174 -1174
- package/dist/utils/openapi/commands/loadCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/loadCommand.js +40 -42
- package/dist/utils/openapi/commands/loadCommand.js.map +7 -0
- package/dist/utils/openapi/commands/upgradeCommand.d.ts +311 -311
- package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/upgradeCommand.js +27 -29
- package/dist/utils/openapi/commands/upgradeCommand.js.map +7 -0
- package/dist/utils/openapi/commands/validateCommand.d.ts +311 -311
- package/dist/utils/openapi/commands/validateCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/validateCommand.js +31 -33
- package/dist/utils/openapi/commands/validateCommand.js.map +7 -0
- package/dist/utils/openapi/index.d.ts +1 -1
- package/dist/utils/openapi/index.d.ts.map +1 -1
- package/dist/utils/openapi/index.js +2 -0
- package/dist/utils/openapi/index.js.map +7 -0
- package/dist/utils/openapi/openapi.d.ts +700 -700
- package/dist/utils/openapi/openapi.d.ts.map +1 -1
- package/dist/utils/openapi/openapi.js +13 -16
- package/dist/utils/openapi/openapi.js.map +7 -0
- package/dist/utils/openapi/openapi.test-d.js +14 -0
- package/dist/utils/openapi/openapi.test-d.js.map +7 -0
- package/dist/utils/openapi/openapi.test.js +309 -0
- package/dist/utils/openapi/openapi.test.js.map +7 -0
- package/dist/utils/openapi/utils/queueTask.d.ts +1 -1
- package/dist/utils/openapi/utils/queueTask.d.ts.map +1 -1
- package/dist/utils/openapi/utils/queueTask.js +8 -9
- package/dist/utils/openapi/utils/queueTask.js.map +7 -0
- package/dist/utils/openapi/utils/workThroughQueue.d.ts +1 -1
- package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +1 -1
- package/dist/utils/openapi/utils/workThroughQueue.js +49 -64
- package/dist/utils/openapi/utils/workThroughQueue.js.map +7 -0
- package/dist/utils/openapi/utils/workThroughQueue.test.js +244 -0
- package/dist/utils/openapi/utils/workThroughQueue.test.js.map +7 -0
- package/dist/utils/resolveReferences.d.ts +1 -7
- package/dist/utils/resolveReferences.d.ts.map +1 -1
- package/dist/utils/resolveReferences.js +91 -149
- package/dist/utils/resolveReferences.js.map +7 -0
- package/dist/utils/resolveReferences.test.js +567 -0
- package/dist/utils/resolveReferences.test.js.map +7 -0
- package/dist/utils/toJson.d.ts +1 -1
- package/dist/utils/toJson.d.ts.map +1 -1
- package/dist/utils/toJson.js +4 -2
- package/dist/utils/toJson.js.map +7 -0
- package/dist/utils/toYaml.d.ts +1 -1
- package/dist/utils/toYaml.d.ts.map +1 -1
- package/dist/utils/toYaml.js +5 -4
- package/dist/utils/toYaml.js.map +7 -0
- package/dist/utils/transform/index.d.ts +1 -1
- package/dist/utils/transform/index.d.ts.map +1 -1
- package/dist/utils/transform/index.js +2 -0
- package/dist/utils/transform/index.js.map +7 -0
- package/dist/utils/transform/sanitize.d.ts +3 -3
- package/dist/utils/transform/sanitize.d.ts.map +1 -1
- package/dist/utils/transform/sanitize.js +22 -21
- package/dist/utils/transform/sanitize.js.map +7 -0
- package/dist/utils/transform/sanitize.test.js +148 -0
- package/dist/utils/transform/sanitize.test.js.map +7 -0
- package/dist/utils/transform/utils/addInfoObject.d.ts +1 -1
- package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
- package/dist/utils/transform/utils/addInfoObject.js +14 -10
- package/dist/utils/transform/utils/addInfoObject.js.map +7 -0
- package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts +1 -1
- package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js +8 -5
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +7 -0
- package/dist/utils/transform/utils/addMissingTags.d.ts +1 -1
- package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
- package/dist/utils/transform/utils/addMissingTags.js +26 -27
- package/dist/utils/transform/utils/addMissingTags.js.map +7 -0
- package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts +1 -1
- package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js +36 -40
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +7 -0
- package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts +1 -1
- package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js +8 -6
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +7 -0
- package/dist/utils/transformErrors.d.ts +1 -1
- package/dist/utils/transformErrors.d.ts.map +1 -1
- package/dist/utils/transformErrors.js +18 -21
- package/dist/utils/transformErrors.js.map +7 -0
- package/dist/utils/transformErrors.test.js +17 -0
- package/dist/utils/transformErrors.test.js.map +7 -0
- package/dist/utils/traverse.d.ts +1 -1
- package/dist/utils/traverse.d.ts.map +1 -1
- package/dist/utils/traverse.js +19 -22
- package/dist/utils/traverse.js.map +7 -0
- package/dist/utils/traverse.test.js +68 -0
- package/dist/utils/traverse.test.js.map +7 -0
- package/dist/utils/unescapeJsonPointer.js +5 -9
- package/dist/utils/unescapeJsonPointer.js.map +7 -0
- package/dist/utils/unescapeJsonPointer.test.js +19 -0
- package/dist/utils/unescapeJsonPointer.test.js.map +7 -0
- package/dist/utils/upgrade.d.ts +1 -1
- package/dist/utils/upgrade.d.ts.map +1 -1
- package/dist/utils/upgrade.js +22 -22
- package/dist/utils/upgrade.js.map +7 -0
- package/dist/utils/upgrade.test-d.js +16 -0
- package/dist/utils/upgrade.test-d.js.map +7 -0
- package/dist/utils/upgrade.test.js +57 -0
- package/dist/utils/upgrade.test.js.map +7 -0
- package/dist/utils/upgradeFromThreeToThreeOne.js +114 -140
- package/dist/utils/upgradeFromThreeToThreeOne.js.map +7 -0
- package/dist/utils/upgradeFromThreeToThreeOne.test.js +462 -0
- package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +7 -0
- package/dist/utils/upgradeFromTwoToThree.js +212 -219
- package/dist/utils/upgradeFromTwoToThree.js.map +7 -0
- package/dist/utils/upgradeFromTwoToThree.test.js +589 -0
- package/dist/utils/upgradeFromTwoToThree.test.js.map +7 -0
- package/dist/utils/validate.d.ts +1 -1
- package/dist/utils/validate.d.ts.map +1 -1
- package/dist/utils/validate.js +14 -16
- package/dist/utils/validate.js.map +7 -0
- package/dist/utils/validate.test.js +64 -0
- package/dist/utils/validate.test.js.map +7 -0
- package/package.json +6 -8
- package/dist/schemas/v2.0/schema.json.js +0 -1623
- package/dist/schemas/v3.0/schema.json.js +0 -1673
- package/dist/schemas/v3.1/schema.json.js +0 -1451
|
@@ -1,115 +1,40 @@
|
|
|
1
1
|
const fetchUrlsDefaultConfiguration = {
|
|
2
|
-
|
|
2
|
+
limit: 20
|
|
3
3
|
};
|
|
4
4
|
const fetchUrls = (customConfiguration) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.warn(`[fetchUrls] Maximum number of requests reeached (${configuration?.limit}), skipping request`);
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
numberOfRequests++;
|
|
38
|
-
const response = await (configuration?.fetch ? configuration.fetch(url) : fetch(url));
|
|
39
|
-
return await response.text();
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('[fetchUrls]', error.message, `(${url})`);
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
getUri(value, source) {
|
|
47
|
-
return getAbsoluteUrl(value, source);
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
function getAbsoluteUrl(value, source) {
|
|
52
|
-
if (typeof source !== 'string') {
|
|
53
|
-
return value;
|
|
54
|
-
}
|
|
55
|
-
// Already an absolute URL
|
|
56
|
-
if (value.startsWith('http')) {
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
// Make it an absolute URL
|
|
60
|
-
if (source) {
|
|
61
|
-
// Skip if source or value is JSON/YAML content
|
|
62
|
-
if (source.startsWith('{') ||
|
|
63
|
-
source.startsWith('[') ||
|
|
64
|
-
source.includes('\n') ||
|
|
65
|
-
value.startsWith('{') ||
|
|
66
|
-
value.startsWith('[') ||
|
|
67
|
-
value.includes('\n')) {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
// If source is an HTTP URL, handle both absolute and relative paths
|
|
72
|
-
if (source.startsWith('http')) {
|
|
73
|
-
const sourceUrl = new URL(source);
|
|
74
|
-
// If value starts with /, treat it as relative to the host root
|
|
75
|
-
if (value.startsWith('/')) {
|
|
76
|
-
// Simply combine the origin with the absolute path
|
|
77
|
-
return `${sourceUrl.origin}${value}`;
|
|
78
|
-
}
|
|
79
|
-
// Otherwise treat it as relative to the source URL's directory
|
|
80
|
-
return new URL(value, sourceUrl.href).toString();
|
|
81
|
-
}
|
|
82
|
-
// Handle file system paths
|
|
83
|
-
if (source.startsWith('/') || !source.startsWith('http')) {
|
|
84
|
-
const sourceParts = source.split('/').filter(Boolean).slice(0, -1);
|
|
85
|
-
const valueParts = value.split('/').filter(Boolean);
|
|
86
|
-
const isAbsolute = source.startsWith('/');
|
|
87
|
-
// If value is absolute path, start fresh
|
|
88
|
-
if (value.startsWith('/')) {
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
// Process each part of the path
|
|
92
|
-
const resultParts = [...sourceParts];
|
|
93
|
-
for (const part of valueParts) {
|
|
94
|
-
if (part === '..') {
|
|
95
|
-
resultParts.pop();
|
|
96
|
-
}
|
|
97
|
-
else if (part !== '.') {
|
|
98
|
-
resultParts.push(part);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Preserve the leading slash for absolute paths, but avoid double slashes
|
|
102
|
-
return isAbsolute ? '/' + resultParts.join('/') : resultParts.join('/');
|
|
103
|
-
}
|
|
104
|
-
return new URL(value, source).toString();
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
console.warn('[fetchUrls] Failed to resolve URL:', error.message, `(${value})`);
|
|
108
|
-
return value;
|
|
109
|
-
}
|
|
5
|
+
let numberOfRequests = 0;
|
|
6
|
+
const configuration = {
|
|
7
|
+
...fetchUrlsDefaultConfiguration,
|
|
8
|
+
...customConfiguration
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
check(value) {
|
|
12
|
+
if (typeof value !== "string") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (!value.startsWith("http://") && !value.startsWith("https://")) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
},
|
|
20
|
+
async get(value) {
|
|
21
|
+
if (configuration?.limit !== false && numberOfRequests >= configuration?.limit) {
|
|
22
|
+
console.warn(`[fetchUrls] Maximum number of requests reeached (${configuration?.limit}), skipping request`);
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
numberOfRequests++;
|
|
27
|
+
const response = await (configuration?.fetch ? configuration.fetch(value) : fetch(value));
|
|
28
|
+
return await response.text();
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error("[fetchUrls]", error.message, `(${value})`);
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
110
33
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
fetchUrls,
|
|
38
|
+
fetchUrlsDefaultConfiguration
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=fetchUrls.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/fetch-urls/fetchUrls.ts"],
|
|
4
|
+
"sourcesContent": ["import type { LoadPlugin } from '../../utils/load/load'\n\nexport const fetchUrlsDefaultConfiguration = {\n limit: 20,\n}\n\nexport const fetchUrls: (customConfiguration?: {\n /**\n * Limit the number of requests. Set to `false` to disable the limit.\n */\n limit?: number | false\n /**\n * Fetch function to use instead of the global fetch. Use this to intercept requests.\n */\n fetch?: (url: string) => Promise<Response>\n}) => LoadPlugin = (customConfiguration) => {\n // State\n let numberOfRequests = 0\n\n // Configuration\n const configuration = {\n ...fetchUrlsDefaultConfiguration,\n ...customConfiguration,\n }\n\n return {\n check(value?: any) {\n // Not a string\n if (typeof value !== 'string') {\n return false\n }\n\n // Not http/https\n if (!value.startsWith('http://') && !value.startsWith('https://')) {\n return false\n }\n\n return true\n },\n async get(value?: any) {\n // Limit ht enumber of requests\n if (configuration?.limit !== false && numberOfRequests >= configuration?.limit) {\n console.warn(`[fetchUrls] Maximum number of requests reeached (${configuration?.limit}), skipping request`)\n return undefined\n }\n\n try {\n numberOfRequests++\n\n const response = await (configuration?.fetch ? configuration.fetch(value) : fetch(value))\n\n return await response.text()\n } catch (error) {\n console.error('[fetchUrls]', error.message, `(${value})`)\n return undefined\n }\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,gCAAgC;AAAA,EAC3C,OAAO;AACT;AAEO,MAAM,YASM,CAAC,wBAAwB;AAE1C,MAAI,mBAAmB;AAGvB,QAAM,gBAAgB;AAAA,IACpB,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,SAAO;AAAA,IACL,MAAM,OAAa;AAEjB,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAGA,UAAI,CAAC,MAAM,WAAW,SAAS,KAAK,CAAC,MAAM,WAAW,UAAU,GAAG;AACjE,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,IAAI,OAAa;AAErB,UAAI,eAAe,UAAU,SAAS,oBAAoB,eAAe,OAAO;AAC9E,gBAAQ,KAAK,oDAAoD,eAAe,KAAK,qBAAqB;AAC1G,eAAO;AAAA,MACT;AAEA,UAAI;AACF;AAEA,cAAM,WAAW,OAAO,eAAe,QAAQ,cAAc,MAAM,KAAK,IAAI,MAAM,KAAK;AAEvF,eAAO,MAAM,SAAS,KAAK;AAAA,MAC7B,SAAS,OAAO;AACd,gBAAQ,MAAM,eAAe,MAAM,SAAS,IAAI,KAAK,GAAG;AACxD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { fetchUrls } from "./fetchUrls.js";
|
|
3
|
+
global.fetch = vi.fn();
|
|
4
|
+
describe("fetchUrls", async () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
global.fetch.mockReset();
|
|
7
|
+
});
|
|
8
|
+
it("returns true for an url", async () => {
|
|
9
|
+
expect(fetchUrls().check("http://example.com/specification/openapi.yaml")).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
it("returns false for a filename", async () => {
|
|
12
|
+
expect(fetchUrls().check("openapi.yaml")).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
it("returns false for a path", async () => {
|
|
15
|
+
expect(fetchUrls().check("specification/openapi.yaml")).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
it("returns false for an object", async () => {
|
|
18
|
+
expect(fetchUrls().check({})).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
it("returns false for undefinded", async () => {
|
|
21
|
+
expect(fetchUrls().check()).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
it("fetches the URL", async () => {
|
|
24
|
+
fetch.mockImplementation(async (url) => ({
|
|
25
|
+
text: async () => {
|
|
26
|
+
if (url === "http://example.com/specification/openapi.yaml") {
|
|
27
|
+
return "OK";
|
|
28
|
+
}
|
|
29
|
+
throw new Error("Not found");
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
expect(await fetchUrls().get("http://example.com/specification/openapi.yaml")).toBe("OK");
|
|
33
|
+
});
|
|
34
|
+
it("rewrites the URL", async () => {
|
|
35
|
+
fetch.mockImplementation(async (url) => ({
|
|
36
|
+
text: async () => {
|
|
37
|
+
if (url === "http://foobar.com/specification/openapi.yaml") {
|
|
38
|
+
return "OK";
|
|
39
|
+
}
|
|
40
|
+
throw new Error("Not found");
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
expect(
|
|
44
|
+
await fetchUrls({
|
|
45
|
+
fetch: (url) => fetch(url.replace("example", "foobar"))
|
|
46
|
+
}).get("http://foobar.com/specification/openapi.yaml")
|
|
47
|
+
).toBe("OK");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=fetchUrls.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/fetch-urls/fetchUrls.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { beforeEach, describe, expect, it, vi } from 'vitest'\n\nimport { fetchUrls } from './fetchUrls'\n\nglobal.fetch = vi.fn()\n\ndescribe('fetchUrls', async () => {\n beforeEach(() => {\n // @ts-expect-error\n global.fetch.mockReset()\n })\n\n it('returns true for an url', async () => {\n expect(fetchUrls().check('http://example.com/specification/openapi.yaml')).toBe(true)\n })\n\n it('returns false for a filename', async () => {\n expect(fetchUrls().check('openapi.yaml')).toBe(false)\n })\n\n it('returns false for a path', async () => {\n expect(fetchUrls().check('specification/openapi.yaml')).toBe(false)\n })\n\n it('returns false for an object', async () => {\n expect(fetchUrls().check({})).toBe(false)\n })\n\n it('returns false for undefinded', async () => {\n expect(fetchUrls().check()).toBe(false)\n })\n\n it('fetches the URL', async () => {\n // @ts-expect-error\n fetch.mockImplementation(async (url: string) => ({\n text: async () => {\n if (url === 'http://example.com/specification/openapi.yaml') {\n return 'OK'\n }\n\n throw new Error('Not found')\n },\n }))\n\n expect(await fetchUrls().get('http://example.com/specification/openapi.yaml')).toBe('OK')\n })\n\n it('rewrites the URL', async () => {\n // @ts-expect-error\n fetch.mockImplementation(async (url: string) => ({\n text: async () => {\n if (url === 'http://foobar.com/specification/openapi.yaml') {\n return 'OK'\n }\n throw new Error('Not found')\n },\n }))\n\n expect(\n await fetchUrls({\n fetch: (url) => fetch(url.replace('example', 'foobar')),\n }).get('http://foobar.com/specification/openapi.yaml'),\n ).toBe('OK')\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,UAAU,QAAQ,IAAI,UAAU;AAErD,SAAS,iBAAiB;AAE1B,OAAO,QAAQ,GAAG,GAAG;AAErB,SAAS,aAAa,YAAY;AAChC,aAAW,MAAM;AAEf,WAAO,MAAM,UAAU;AAAA,EACzB,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,UAAU,EAAE,MAAM,+CAA+C,CAAC,EAAE,KAAK,IAAI;AAAA,EACtF,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,cAAc,CAAC,EAAE,KAAK,KAAK;AAAA,EACtD,CAAC;AAED,KAAG,4BAA4B,YAAY;AACzC,WAAO,UAAU,EAAE,MAAM,4BAA4B,CAAC,EAAE,KAAK,KAAK;AAAA,EACpE,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK;AAAA,EAC1C,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,EACxC,CAAC;AAED,KAAG,mBAAmB,YAAY;AAEhC,UAAM,mBAAmB,OAAO,SAAiB;AAAA,MAC/C,MAAM,YAAY;AAChB,YAAI,QAAQ,iDAAiD;AAC3D,iBAAO;AAAA,QACT;AAEA,cAAM,IAAI,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF,EAAE;AAEF,WAAO,MAAM,UAAU,EAAE,IAAI,+CAA+C,CAAC,EAAE,KAAK,IAAI;AAAA,EAC1F,CAAC;AAED,KAAG,oBAAoB,YAAY;AAEjC,UAAM,mBAAmB,OAAO,SAAiB;AAAA,MAC/C,MAAM,YAAY;AAChB,YAAI,QAAQ,gDAAgD;AAC1D,iBAAO;AAAA,QACT;AACA,cAAM,IAAI,MAAM,WAAW;AAAA,MAC7B;AAAA,IACF,EAAE;AAEF;AAAA,MACE,MAAM,UAAU;AAAA,QACd,OAAO,CAAC,QAAQ,MAAM,IAAI,QAAQ,WAAW,QAAQ,CAAC;AAAA,MACxD,CAAC,EAAE,IAAI,8CAA8C;AAAA,IACvD,EAAE,KAAK,IAAI;AAAA,EACb,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './fetchUrls.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch-urls/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch-urls/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./fetchUrls.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './readFiles.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./readFiles.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readFiles.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/readFiles.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"readFiles.d.ts","sourceRoot":"","sources":["../../../src/plugins/read-files/readFiles.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,SAAS,EAAE,MAAM,UAqD7B,CAAA"}
|
|
@@ -1,72 +1,52 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { ERRORS } from
|
|
3
|
-
import { dirname, join } from
|
|
4
|
-
import { isJson } from
|
|
5
|
-
import { isYaml } from
|
|
6
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { ERRORS } from "../../configuration/index.js";
|
|
3
|
+
import { dirname, join } from "../../polyfills/path.js";
|
|
4
|
+
import { isJson } from "../../utils/isJson.js";
|
|
5
|
+
import { isYaml } from "../../utils/isYaml.js";
|
|
7
6
|
const readFiles = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
getUri(value, source) {
|
|
50
|
-
if (typeof value !== 'string') {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
if (typeof source !== 'string') {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
// Already absolute
|
|
57
|
-
if (value.startsWith('/')) {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
const dir = dirname(source);
|
|
61
|
-
return join(dir, value);
|
|
62
|
-
},
|
|
63
|
-
getDir(value) {
|
|
64
|
-
return dirname(value);
|
|
65
|
-
},
|
|
66
|
-
getFilename(value) {
|
|
67
|
-
return value.split('/').pop();
|
|
68
|
-
},
|
|
69
|
-
};
|
|
7
|
+
return {
|
|
8
|
+
check(value) {
|
|
9
|
+
if (typeof value !== "string") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (value.startsWith("http://") || value.startsWith("https://")) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (value.includes("\n")) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (isJson(value)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (isYaml(value)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
async get(value) {
|
|
27
|
+
if (!fs.existsSync(value)) {
|
|
28
|
+
throw new Error(ERRORS.FILE_DOES_NOT_EXIST.replace("%s", value));
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return fs.readFileSync(value, "utf-8");
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("[readFiles]", error);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
resolvePath(value, reference) {
|
|
38
|
+
const dir = dirname(value);
|
|
39
|
+
return join(dir, reference);
|
|
40
|
+
},
|
|
41
|
+
getDir(value) {
|
|
42
|
+
return dirname(value);
|
|
43
|
+
},
|
|
44
|
+
getFilename(value) {
|
|
45
|
+
return value.split("/").pop();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
70
48
|
};
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
export {
|
|
50
|
+
readFiles
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=readFiles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/read-files/readFiles.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\n\nimport { ERRORS } from '../../configuration/index'\nimport { dirname, join } from '../../polyfills/path'\nimport { isJson } from '../../utils/isJson'\nimport { isYaml } from '../../utils/isYaml'\nimport type { LoadPlugin } from '../../utils/load/load'\n\nexport const readFiles: () => LoadPlugin = () => {\n return {\n check(value?: any) {\n // Not a string\n if (typeof value !== 'string') {\n return false\n }\n\n // URL\n if (value.startsWith('http://') || value.startsWith('https://')) {\n return false\n }\n\n // Line breaks\n if (value.includes('\\n')) {\n return false\n }\n\n // JSON\n if (isJson(value)) {\n return false\n }\n\n // YAML (run through YAML.parse)\n if (isYaml(value)) {\n return false\n }\n\n return true\n },\n async get(value?: any) {\n if (!fs.existsSync(value)) {\n throw new Error(ERRORS.FILE_DOES_NOT_EXIST.replace('%s', value))\n }\n\n try {\n return fs.readFileSync(value, 'utf-8')\n } catch (error) {\n console.error('[readFiles]', error)\n return false\n }\n },\n resolvePath(value: any, reference: string) {\n const dir = dirname(value)\n return join(dir, reference)\n },\n getDir(value: any) {\n return dirname(value)\n },\n getFilename(value: any) {\n return value.split('/').pop()\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AAEf,SAAS,cAAc;AACvB,SAAS,SAAS,YAAY;AAC9B,SAAS,cAAc;AACvB,SAAS,cAAc;AAGhB,MAAM,YAA8B,MAAM;AAC/C,SAAO;AAAA,IACL,MAAM,OAAa;AAEjB,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAGA,UAAI,MAAM,WAAW,SAAS,KAAK,MAAM,WAAW,UAAU,GAAG;AAC/D,eAAO;AAAA,MACT;AAGA,UAAI,MAAM,SAAS,IAAI,GAAG;AACxB,eAAO;AAAA,MACT;AAGA,UAAI,OAAO,KAAK,GAAG;AACjB,eAAO;AAAA,MACT;AAGA,UAAI,OAAO,KAAK,GAAG;AACjB,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,IAAI,OAAa;AACrB,UAAI,CAAC,GAAG,WAAW,KAAK,GAAG;AACzB,cAAM,IAAI,MAAM,OAAO,oBAAoB,QAAQ,MAAM,KAAK,CAAC;AAAA,MACjE;AAEA,UAAI;AACF,eAAO,GAAG,aAAa,OAAO,OAAO;AAAA,MACvC,SAAS,OAAO;AACd,gBAAQ,MAAM,eAAe,KAAK;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,YAAY,OAAY,WAAmB;AACzC,YAAM,MAAM,QAAQ,KAAK;AACzB,aAAO,KAAK,KAAK,SAAS;AAAA,IAC5B;AAAA,IACA,OAAO,OAAY;AACjB,aAAO,QAAQ,KAAK;AAAA,IACtB;AAAA,IACA,YAAY,OAAY;AACtB,aAAO,MAAM,MAAM,GAAG,EAAE,IAAI;AAAA,IAC9B;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readFiles } from "./readFiles.js";
|
|
3
|
+
describe("readFiles", async () => {
|
|
4
|
+
it("returns true for a filename", async () => {
|
|
5
|
+
expect(readFiles().check("openapi.yaml")).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
it("returns true for a path", async () => {
|
|
8
|
+
expect(readFiles().check("../specification/openapi.yaml")).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it("returns false for an object", async () => {
|
|
11
|
+
expect(readFiles().check({})).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
it("returns false for undefinded", async () => {
|
|
14
|
+
expect(readFiles().check()).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
it("returns false for an url", async () => {
|
|
17
|
+
expect(readFiles().check("http://example.com/specification/openapi.yaml")).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=readFiles.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/read-files/readFiles.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { readFiles } from './readFiles'\n\ndescribe('readFiles', async () => {\n it('returns true for a filename', async () => {\n expect(readFiles().check('openapi.yaml')).toBe(true)\n })\n\n it('returns true for a path', async () => {\n expect(readFiles().check('../specification/openapi.yaml')).toBe(true)\n })\n\n it('returns false for an object', async () => {\n expect(readFiles().check({})).toBe(false)\n })\n\n it('returns false for undefinded', async () => {\n expect(readFiles().check()).toBe(false)\n })\n\n it('returns false for an url', async () => {\n expect(readFiles().check('http://example.com/specification/openapi.yaml')).toBe(false)\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,iBAAiB;AAE1B,SAAS,aAAa,YAAY;AAChC,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,cAAc,CAAC,EAAE,KAAK,IAAI;AAAA,EACrD,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,UAAU,EAAE,MAAM,+BAA+B,CAAC,EAAE,KAAK,IAAI;AAAA,EACtE,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC5C,WAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK;AAAA,EAC1C,CAAC;AAED,KAAG,gCAAgC,YAAY;AAC7C,WAAO,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,EACxC,CAAC;AAED,KAAG,4BAA4B,YAAY;AACzC,WAAO,UAAU,EAAE,MAAM,+CAA+C,CAAC,EAAE,KAAK,KAAK;AAAA,EACvF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * as path from './path.
|
|
1
|
+
export * as path from './path.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/polyfills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/polyfills/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA"}
|