@backstage/plugin-catalog-node 1.19.2-next.0 → 1.20.0-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 +14 -0
- package/dist/index.d.ts +10 -2
- package/dist/processing/parse.cjs.js +4 -2
- package/dist/processing/parse.cjs.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-node
|
|
2
2
|
|
|
3
|
+
## 1.20.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9d3ec06: Make YAML merge (<<:) support configurable in the Backstage Catalog instead of always being enabled
|
|
8
|
+
- 8c26af4: Enable YAML merge keys in yamlPlaceholderResolver
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/backend-plugin-api@1.5.0-next.1
|
|
14
|
+
- @backstage/plugin-permission-common@0.9.3-next.1
|
|
15
|
+
- @backstage/plugin-permission-node@0.10.6-next.1
|
|
16
|
+
|
|
3
17
|
## 1.19.2-next.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -383,6 +383,14 @@ declare function locationSpecToLocationEntity(opts: {
|
|
|
383
383
|
parentEntity?: Entity;
|
|
384
384
|
}): LocationEntityV1alpha1;
|
|
385
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Options for parsing entity YAML files.
|
|
388
|
+
*
|
|
389
|
+
* @public
|
|
390
|
+
*/
|
|
391
|
+
interface ParseEntityYamlOptions {
|
|
392
|
+
enableYamlMerge?: boolean;
|
|
393
|
+
}
|
|
386
394
|
/**
|
|
387
395
|
* A helper function that parses a YAML file, properly handling multiple
|
|
388
396
|
* documents in a single file.
|
|
@@ -399,7 +407,7 @@ declare function locationSpecToLocationEntity(opts: {
|
|
|
399
407
|
* assumptions whatsoever can be made on the emnitted entities except that they
|
|
400
408
|
* are valid JSON objects.
|
|
401
409
|
*/
|
|
402
|
-
declare function parseEntityYaml(data: string | Buffer, location: LocationSpec$1): Iterable<CatalogProcessorResult>;
|
|
410
|
+
declare function parseEntityYaml(data: string | Buffer, location: LocationSpec$1, options?: ParseEntityYamlOptions): Iterable<CatalogProcessorResult>;
|
|
403
411
|
|
|
404
412
|
/**
|
|
405
413
|
* @public
|
|
@@ -439,4 +447,4 @@ interface CatalogService {
|
|
|
439
447
|
*/
|
|
440
448
|
declare const catalogServiceRef: _backstage_backend_plugin_api.ServiceRef<CatalogService, "plugin", "singleton">;
|
|
441
449
|
|
|
442
|
-
export { type AnalyzeOptions, type CatalogProcessor, type CatalogProcessorCache, type CatalogProcessorEmit, type CatalogProcessorEntityResult, type CatalogProcessorErrorResult, type CatalogProcessorLocationResult, type CatalogProcessorParser, type CatalogProcessorRefreshKeysResult, type CatalogProcessorRelationResult, type CatalogProcessorResult, type CatalogService, type CatalogServiceRequestOptions, type DeferredEntity, type EntitiesSearchFilter, type EntityFilter, type EntityProvider, type EntityProviderConnection, type EntityProviderMutation, type EntityProviderRefreshOptions, type EntityRelationSpec, type LocationAnalyzer, type LocationSpec, type PlaceholderResolver, type PlaceholderResolverParams, type PlaceholderResolverRead, type PlaceholderResolverResolveUrl, type ScmLocationAnalyzer, catalogServiceRef, locationSpecToLocationEntity, locationSpecToMetadataName, parseEntityYaml, processingResult };
|
|
450
|
+
export { type AnalyzeOptions, type CatalogProcessor, type CatalogProcessorCache, type CatalogProcessorEmit, type CatalogProcessorEntityResult, type CatalogProcessorErrorResult, type CatalogProcessorLocationResult, type CatalogProcessorParser, type CatalogProcessorRefreshKeysResult, type CatalogProcessorRelationResult, type CatalogProcessorResult, type CatalogService, type CatalogServiceRequestOptions, type DeferredEntity, type EntitiesSearchFilter, type EntityFilter, type EntityProvider, type EntityProviderConnection, type EntityProviderMutation, type EntityProviderRefreshOptions, type EntityRelationSpec, type LocationAnalyzer, type LocationSpec, type ParseEntityYamlOptions, type PlaceholderResolver, type PlaceholderResolverParams, type PlaceholderResolverRead, type PlaceholderResolverResolveUrl, type ScmLocationAnalyzer, catalogServiceRef, locationSpecToLocationEntity, locationSpecToMetadataName, parseEntityYaml, processingResult };
|
|
@@ -10,11 +10,13 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var lodash__default = /*#__PURE__*/_interopDefaultCompat(lodash);
|
|
11
11
|
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
12
12
|
|
|
13
|
-
function* parseEntityYaml(data, location) {
|
|
13
|
+
function* parseEntityYaml(data, location, options) {
|
|
14
|
+
const parseOptions = { merge: options?.enableYamlMerge ?? false };
|
|
14
15
|
let documents;
|
|
15
16
|
try {
|
|
16
17
|
documents = yaml__default.default.parseAllDocuments(
|
|
17
|
-
typeof data === "string" ? data : data.toString("utf8")
|
|
18
|
+
typeof data === "string" ? data : data.toString("utf8"),
|
|
19
|
+
parseOptions
|
|
18
20
|
).filter((d) => d);
|
|
19
21
|
} catch (e) {
|
|
20
22
|
const loc = catalogModel.stringifyLocationRef(location);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.cjs.js","sources":["../../src/processing/parse.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 { Entity, stringifyLocationRef } from '@backstage/catalog-model';\nimport lodash from 'lodash';\nimport yaml from 'yaml';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport { CatalogProcessorResult } from '../api/processor';\nimport { processingResult } from '../api/processingResult';\n\n/**\n * A helper function that parses a YAML file, properly handling multiple\n * documents in a single file.\n *\n * @public\n * @remarks\n *\n * Each document is expected to be a valid Backstage entity. Each item in the\n * iterable is in the form of an entity result if the document seemed like a\n * valid object, or in the form of an error result if it seemed incorrect. This\n * way, you can choose to retain a partial result if you want.\n *\n * Note that this function does NOT perform any validation of the entities. No\n * assumptions whatsoever can be made on the emnitted entities except that they\n * are valid JSON objects.\n */\nexport function* parseEntityYaml(\n data: string | Buffer,\n location: LocationSpec,\n): Iterable<CatalogProcessorResult> {\n let documents: yaml.Document.Parsed[];\n try {\n documents = yaml\n .parseAllDocuments(\n typeof data === 'string' ? data : data.toString('utf8'),\n )\n .filter(d => d);\n } catch (e) {\n const loc = stringifyLocationRef(location);\n const message = `Failed to parse YAML at ${loc}, ${e}`;\n yield processingResult.generalError(location, message);\n return;\n }\n\n for (const document of documents) {\n if (document.errors?.length) {\n const loc = stringifyLocationRef(location);\n const message = `YAML error at ${loc}, ${document.errors[0]}`;\n yield processingResult.generalError(location, message);\n } else {\n const json = document.toJSON();\n if (lodash.isPlainObject(json)) {\n yield processingResult.entity(location, json as Entity);\n } else if (json === null) {\n // Ignore null values, these happen if there is an empty document in the\n // YAML file, for example if --- is added to the end of the file.\n } else {\n const message = `Expected object at root, got ${typeof json}`;\n yield processingResult.generalError(location, message);\n }\n }\n }\n}\n"],"names":["yaml","stringifyLocationRef","processingResult","lodash"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"parse.cjs.js","sources":["../../src/processing/parse.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 { Entity, stringifyLocationRef } from '@backstage/catalog-model';\nimport lodash from 'lodash';\nimport yaml from 'yaml';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport { CatalogProcessorResult } from '../api/processor';\nimport { processingResult } from '../api/processingResult';\n\n/**\n * Options for parsing entity YAML files.\n *\n * @public\n */\nexport interface ParseEntityYamlOptions {\n enableYamlMerge?: boolean;\n}\n\n/**\n * A helper function that parses a YAML file, properly handling multiple\n * documents in a single file.\n *\n * @public\n * @remarks\n *\n * Each document is expected to be a valid Backstage entity. Each item in the\n * iterable is in the form of an entity result if the document seemed like a\n * valid object, or in the form of an error result if it seemed incorrect. This\n * way, you can choose to retain a partial result if you want.\n *\n * Note that this function does NOT perform any validation of the entities. No\n * assumptions whatsoever can be made on the emnitted entities except that they\n * are valid JSON objects.\n */\nexport function* parseEntityYaml(\n data: string | Buffer,\n location: LocationSpec,\n options?: ParseEntityYamlOptions,\n): Iterable<CatalogProcessorResult> {\n const parseOptions = { merge: options?.enableYamlMerge ?? false };\n\n let documents: yaml.Document.Parsed[];\n try {\n documents = yaml\n .parseAllDocuments(\n typeof data === 'string' ? data : data.toString('utf8'),\n parseOptions,\n )\n .filter(d => d);\n } catch (e) {\n const loc = stringifyLocationRef(location);\n const message = `Failed to parse YAML at ${loc}, ${e}`;\n yield processingResult.generalError(location, message);\n return;\n }\n\n for (const document of documents) {\n if (document.errors?.length) {\n const loc = stringifyLocationRef(location);\n const message = `YAML error at ${loc}, ${document.errors[0]}`;\n yield processingResult.generalError(location, message);\n } else {\n const json = document.toJSON();\n if (lodash.isPlainObject(json)) {\n yield processingResult.entity(location, json as Entity);\n } else if (json === null) {\n // Ignore null values, these happen if there is an empty document in the\n // YAML file, for example if --- is added to the end of the file.\n } else {\n const message = `Expected object at root, got ${typeof json}`;\n yield processingResult.generalError(location, message);\n }\n }\n }\n}\n"],"names":["yaml","stringifyLocationRef","processingRes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AAS,IAAA,EAAM,CAG1B,MAAO;AACL,QAAA,MAAM,OAAA,GAAU,CAAA,6BAAA,EAAgC,OAAO,IAAI,CAAA,CAAA;AAC3D,QAAA,MAAMA,iCAAA,CAAiB,YAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0-next.1",
|
|
4
4
|
"description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -72,20 +72,20 @@
|
|
|
72
72
|
"test": "backstage-cli package test"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@backstage/backend-plugin-api": "1.
|
|
75
|
+
"@backstage/backend-plugin-api": "1.5.0-next.1",
|
|
76
76
|
"@backstage/catalog-client": "1.12.1-next.0",
|
|
77
77
|
"@backstage/catalog-model": "1.7.6-next.0",
|
|
78
78
|
"@backstage/errors": "1.2.7",
|
|
79
79
|
"@backstage/plugin-catalog-common": "1.1.7-next.0",
|
|
80
|
-
"@backstage/plugin-permission-common": "0.9.3-next.
|
|
81
|
-
"@backstage/plugin-permission-node": "0.10.6-next.
|
|
80
|
+
"@backstage/plugin-permission-common": "0.9.3-next.1",
|
|
81
|
+
"@backstage/plugin-permission-node": "0.10.6-next.1",
|
|
82
82
|
"@backstage/types": "1.2.2",
|
|
83
83
|
"lodash": "^4.17.21",
|
|
84
84
|
"yaml": "^2.0.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@backstage/backend-test-utils": "1.10.0-next.
|
|
88
|
-
"@backstage/cli": "0.34.5-next.
|
|
87
|
+
"@backstage/backend-test-utils": "1.10.0-next.1",
|
|
88
|
+
"@backstage/cli": "0.34.5-next.1",
|
|
89
89
|
"msw": "^1.0.0"
|
|
90
90
|
}
|
|
91
91
|
}
|