@backstage/plugin-catalog-backend-module-openapi 0.2.5 → 0.2.6-next.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-openapi
|
|
2
2
|
|
|
3
|
+
## 0.2.6-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/types@1.2.1-next.0
|
|
9
|
+
- @backstage/backend-plugin-api@1.1.1-next.1
|
|
10
|
+
- @backstage/catalog-model@1.7.3-next.0
|
|
11
|
+
- @backstage/plugin-catalog-node@1.15.1-next.1
|
|
12
|
+
- @backstage/plugin-catalog-common@1.1.3-next.0
|
|
13
|
+
- @backstage/integration@1.16.1-next.0
|
|
14
|
+
|
|
15
|
+
## 0.2.6-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 57e794a: Refactor to no longer use backend-common
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/backend-plugin-api@1.1.1-next.0
|
|
22
|
+
- @backstage/catalog-model@1.7.2
|
|
23
|
+
- @backstage/integration@1.16.0
|
|
24
|
+
- @backstage/types@1.2.0
|
|
25
|
+
- @backstage/plugin-catalog-common@1.1.2
|
|
26
|
+
- @backstage/plugin-catalog-node@1.15.1-next.0
|
|
27
|
+
|
|
3
28
|
## 0.2.5
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiRefProcessor.cjs.js","sources":["../src/OpenApiRefProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {
|
|
1
|
+
{"version":3,"file":"OpenApiRefProcessor.cjs.js","sources":["../src/OpenApiRefProcessor.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n LoggerService,\n RootConfigService,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { CatalogProcessor } from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport { bundleFileWithRefs } from './lib';\n\n/**\n * @public\n * @deprecated replaced by the openApiPlaceholderResolver\n */\nexport class OpenApiRefProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrations;\n private readonly logger: LoggerService;\n private readonly reader: UrlReaderService;\n\n static fromConfig(\n config: RootConfigService,\n options: { logger: LoggerService; reader: UrlReaderService },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new OpenApiRefProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrations;\n logger: LoggerService;\n reader: UrlReaderService;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.reader = options.reader;\n }\n\n getProcessorName(): string {\n return 'OpenApiRefProcessor';\n }\n\n async preProcessEntity(\n entity: Entity,\n location: LocationSpec,\n ): Promise<Entity> {\n if (\n !entity ||\n entity.kind !== 'API' ||\n (entity.spec && entity.spec.type !== 'openapi')\n ) {\n return entity;\n }\n\n const scmIntegration = this.integrations.byUrl(location.target);\n const definition = entity.spec!.definition;\n\n if (!scmIntegration || !definition) {\n return entity;\n }\n\n const resolveUrl = (url: string, base: string): string => {\n return scmIntegration.resolveUrl({ url, base });\n };\n\n this.logger.debug(`Bundling OpenAPI specification from ${location.target}`);\n try {\n const read = async (url: string) => {\n const { buffer } = await this.reader.readUrl(url);\n return await buffer();\n };\n const bundledSpec = await bundleFileWithRefs(\n definition.toString(),\n location.target,\n read,\n resolveUrl,\n );\n\n return {\n ...entity,\n spec: { ...entity.spec, definition: bundledSpec },\n };\n } catch (error) {\n this.logger.error(`Unable to bundle OpenAPI specification`, error);\n return entity;\n }\n }\n}\n"],"names":["ScmIntegrations","bundleFileWithRefs"],"mappings":";;;;;AA+BO,MAAM,mBAAgD,CAAA;AAAA,EAC1C,YAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EAEjB,OAAO,UACL,CAAA,MAAA,EACA,OACA,EAAA;AACA,IAAM,MAAA,YAAA,GAAeA,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAEtD,IAAA,OAAO,IAAI,mBAAoB,CAAA;AAAA,MAC7B,GAAG,OAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA;AACH,EAEA,YAAY,OAIT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AACtB,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AAAA;AACxB,EAEA,gBAA2B,GAAA;AACzB,IAAO,OAAA,qBAAA;AAAA;AACT,EAEA,MAAM,gBACJ,CAAA,MAAA,EACA,QACiB,EAAA;AACjB,IACE,IAAA,CAAC,MACD,IAAA,MAAA,CAAO,IAAS,KAAA,KAAA,IACf,OAAO,IAAQ,IAAA,MAAA,CAAO,I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verParams } from '@backstage/plugin-catalog-backend';
|
|
2
1
|
import { JsonValue } from '@backstage/types';
|
|
2
|
+
import { PlaceholderResolverParams, CatalogProcessor } from '@backstage/plugin-catalog-node';
|
|
3
3
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
4
|
-
import { UrlReaderService } from '@backstage/backend-plugin-api';
|
|
4
|
+
import { RootConfigService, LoggerService, UrlReaderService } from '@backstage/backend-plugin-api';
|
|
5
5
|
import { Entity } from '@backstage/catalog-model';
|
|
6
|
-
import { Config } from '@backstage/config';
|
|
7
6
|
import { ScmIntegrations } from '@backstage/integration';
|
|
8
|
-
import { CatalogProcessor } from '@backstage/plugin-catalog-node';
|
|
9
7
|
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
|
10
|
-
import { Logger } from 'winston';
|
|
11
8
|
|
|
12
9
|
/** @public */
|
|
13
10
|
declare function jsonSchemaRefPlaceholderResolver(params: PlaceholderResolverParams): Promise<JsonValue>;
|
|
@@ -20,13 +17,13 @@ declare class OpenApiRefProcessor implements CatalogProcessor {
|
|
|
20
17
|
private readonly integrations;
|
|
21
18
|
private readonly logger;
|
|
22
19
|
private readonly reader;
|
|
23
|
-
static fromConfig(config:
|
|
24
|
-
logger:
|
|
20
|
+
static fromConfig(config: RootConfigService, options: {
|
|
21
|
+
logger: LoggerService;
|
|
25
22
|
reader: UrlReaderService;
|
|
26
23
|
}): OpenApiRefProcessor;
|
|
27
24
|
constructor(options: {
|
|
28
25
|
integrations: ScmIntegrations;
|
|
29
|
-
logger:
|
|
26
|
+
logger: LoggerService;
|
|
30
27
|
reader: UrlReaderService;
|
|
31
28
|
});
|
|
32
29
|
getProcessorName(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonSchemaRefPlaceholderResolver.cjs.js","sources":["../src/jsonSchemaRefPlaceholderResolver.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {
|
|
1
|
+
{"version":3,"file":"jsonSchemaRefPlaceholderResolver.cjs.js","sources":["../src/jsonSchemaRefPlaceholderResolver.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { JsonValue } from '@backstage/types';\nimport {\n PlaceholderResolverParams,\n processingResult,\n} from '@backstage/plugin-catalog-node';\nimport { bundleFileWithRefs } from './lib';\n\n/** @public */\nexport async function jsonSchemaRefPlaceholderResolver(\n params: PlaceholderResolverParams,\n): Promise<JsonValue> {\n const { content, url } = await readTextLocation(params);\n\n params.emit(processingResult.refresh(`url:${url}`));\n\n try {\n return await bundleFileWithRefs(\n content,\n url,\n params.read,\n params.resolveUrl,\n );\n } catch (error) {\n throw new Error(\n `Placeholder \\$${params.key} unable to bundle the file at ${params.value}, ${error}`,\n );\n }\n}\n\n/*\n * Helpers, copied from PlaceholderProcessor\n */\n\nasync function readTextLocation(\n params: PlaceholderResolverParams,\n): Promise<{ content: string; url: string }> {\n const newUrl = relativeUrl(params);\n\n try {\n const data = await params.read(newUrl);\n return { content: data.toString('utf-8'), url: newUrl };\n } catch (e) {\n throw new Error(\n `Placeholder \\$${params.key} could not read location ${params.value}, ${e}`,\n );\n }\n}\n\nfunction relativeUrl({\n key,\n value,\n baseUrl,\n resolveUrl,\n}: PlaceholderResolverParams): string {\n if (typeof value !== 'string') {\n throw new Error(\n `Placeholder \\$${key} expected a string value parameter, in the form of an absolute URL or a relative path`,\n );\n }\n\n try {\n return resolveUrl(value, baseUrl);\n } catch (e) {\n // The only remaining case that isn't support is a relative file path that should be\n // resolved using a relative file location. Accessing local file paths can lead to\n // path traversal attacks and access to any file on the host system. Implementing this\n // would require additional security measures.\n throw new Error(\n `Placeholder \\$${key} could not form a URL out of ${baseUrl} and ${value}, ${e}`,\n );\n }\n}\n"],"names":["processingResult","bundleFileWithRefs"],"mappings":";;;;;AAwBA,eAAsB,iCACpB,MACoB,EAAA;AACpB,EAAA,MAAM,EAAE,OAAS,EAAA,GAAA,EAAQ,GAAA,MAAM,iBAAiB,MAAM,CAAA;AAEtD,EAAA,MAAA,CAAO,KAAKA,kCAAiB,CAAA,OAAA,CAAQ,CAAO,IAAA,EAAA,GAAG,EAAE,CAAC,CAAA;AAElD,EAAI,IAAA;AACF,IAAA,OAAO,MAAMC,yBAAA;AAAA,MACX,OAAA;AAAA,MACA,GAAA;AAAA,MACA,MAAO,CAAA,IAAA;AAAA,MACP,MAAO,CAAA;AAAA,KACT;AAAA,WACO,KAAO,EAAA;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gBAAiB,MAAO,CAAA,GAAG,iCAAiC,MAAO,CAAA,KAAK,KAAK,KAAK,CAAA;AAAA,KACpF;AAAA;AAEJ;AAMA,eAAe,iBACb,MAC2C,EAAA;AAC3C,EAAM,MAAA,MAAA,GAAS,YAAY,MAAM,CAAA;AAEjC,EAAI,IAAA;AACF,IAAA,MAAM,IAAO,GAAA,MAAM,MAAO,CAAA,IAAA,CAAK,MAAM,CAAA;AACrC,IAAA,OAAO,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,OAAO,CAAA,EAAG,KAAK,MAAO,EAAA;AAAA,WAC/C,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gBAAiB,MAAO,CAAA,GAAG,4BAA4B,MAAO,CAAA,KAAK,KAAK,CAAC,CAAA;AAAA,KAC3E;AAAA;AAEJ;AAEA,SAAS,WAAY,CAAA;AAAA,EACnB,GAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAsC,EAAA;AACpC,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gBAAiB,GAAG,CAAA,qFAAA;AAAA,KACtB;AAAA;AAGF,EAAI,IAAA;AACF,IAAO,OAAA,UAAA,CAAW,OAAO,OAAO,CAAA;AAAA,WACzB,CAAG,EAAA;AAKV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gBAAiB,GAAG,CAAA,6BAAA,EAAgC,OAAO,CAAQ,KAAA,EAAA,KAAK,KAAK,CAAC,CAAA;AAAA,KAChF;AAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend-module-openapi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6-next.1",
|
|
4
4
|
"description": "A Backstage catalog backend module that helps with OpenAPI specifications",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -38,21 +38,17 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@apidevtools/json-schema-ref-parser": "^11.0.0",
|
|
41
|
-
"@backstage/backend-
|
|
42
|
-
"@backstage/
|
|
43
|
-
"@backstage/
|
|
44
|
-
"@backstage/
|
|
45
|
-
"@backstage/
|
|
46
|
-
"@backstage/
|
|
47
|
-
"@backstage/plugin-catalog-common": "^1.1.2",
|
|
48
|
-
"@backstage/plugin-catalog-node": "^1.15.0",
|
|
49
|
-
"@backstage/types": "^1.2.0",
|
|
50
|
-
"winston": "^3.2.1",
|
|
41
|
+
"@backstage/backend-plugin-api": "1.1.1-next.1",
|
|
42
|
+
"@backstage/catalog-model": "1.7.3-next.0",
|
|
43
|
+
"@backstage/integration": "1.16.1-next.0",
|
|
44
|
+
"@backstage/plugin-catalog-common": "1.1.3-next.0",
|
|
45
|
+
"@backstage/plugin-catalog-node": "1.15.1-next.1",
|
|
46
|
+
"@backstage/types": "1.2.1-next.0",
|
|
51
47
|
"yaml": "^2.1.1"
|
|
52
48
|
},
|
|
53
49
|
"devDependencies": {
|
|
54
|
-
"@backstage/backend-test-utils": "
|
|
55
|
-
"@backstage/cli": "
|
|
50
|
+
"@backstage/backend-test-utils": "1.2.1-next.1",
|
|
51
|
+
"@backstage/cli": "0.29.5-next.1",
|
|
56
52
|
"openapi-types": "^12.0.0"
|
|
57
53
|
},
|
|
58
54
|
"typesVersions": {
|