@backstage/plugin-catalog-node 1.17.0-next.0 → 1.17.0-next.2
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 +32 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/processing/parse.cjs.js +43 -0
- package/dist/processing/parse.cjs.js.map +1 -0
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-node
|
|
2
2
|
|
|
3
|
+
## 1.17.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.3.1-next.2
|
|
9
|
+
- @backstage/catalog-client@1.10.0-next.0
|
|
10
|
+
- @backstage/catalog-model@1.7.3
|
|
11
|
+
- @backstage/errors@1.2.7
|
|
12
|
+
- @backstage/types@1.2.1
|
|
13
|
+
- @backstage/plugin-catalog-common@1.1.4-next.0
|
|
14
|
+
- @backstage/plugin-permission-common@0.9.0-next.0
|
|
15
|
+
- @backstage/plugin-permission-node@0.10.0-next.2
|
|
16
|
+
|
|
17
|
+
## 1.17.0-next.1
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- a459f17: Added `parseEntityYaml` from `@backstage/plugin-catalog-backend`, to make it more easily usable by custom plugins and modules
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/backend-plugin-api@1.3.1-next.1
|
|
27
|
+
- @backstage/plugin-permission-common@0.9.0-next.0
|
|
28
|
+
- @backstage/plugin-permission-node@0.10.0-next.1
|
|
29
|
+
- @backstage/catalog-client@1.10.0-next.0
|
|
30
|
+
- @backstage/catalog-model@1.7.3
|
|
31
|
+
- @backstage/errors@1.2.7
|
|
32
|
+
- @backstage/types@1.2.1
|
|
33
|
+
- @backstage/plugin-catalog-common@1.1.4-next.0
|
|
34
|
+
|
|
3
35
|
## 1.17.0-next.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var processingResult = require('./api/processingResult.cjs.js');
|
|
4
4
|
var conversion = require('./conversion.cjs.js');
|
|
5
|
+
var parse = require('./processing/parse.cjs.js');
|
|
5
6
|
var catalogService = require('./catalogService.cjs.js');
|
|
6
7
|
|
|
7
8
|
|
|
@@ -9,5 +10,6 @@ var catalogService = require('./catalogService.cjs.js');
|
|
|
9
10
|
exports.processingResult = processingResult.processingResult;
|
|
10
11
|
exports.locationSpecToLocationEntity = conversion.locationSpecToLocationEntity;
|
|
11
12
|
exports.locationSpecToMetadataName = conversion.locationSpecToMetadataName;
|
|
13
|
+
exports.parseEntityYaml = parse.parseEntityYaml;
|
|
12
14
|
exports.catalogServiceRef = catalogService.catalogServiceRef;
|
|
13
15
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -298,6 +298,24 @@ type ScmLocationAnalyzer = {
|
|
|
298
298
|
}>;
|
|
299
299
|
};
|
|
300
300
|
|
|
301
|
+
/**
|
|
302
|
+
* A helper function that parses a YAML file, properly handling multiple
|
|
303
|
+
* documents in a single file.
|
|
304
|
+
*
|
|
305
|
+
* @public
|
|
306
|
+
* @remarks
|
|
307
|
+
*
|
|
308
|
+
* Each document is expected to be a valid Backstage entity. Each item in the
|
|
309
|
+
* iterable is in the form of an entity result if the document seemed like a
|
|
310
|
+
* valid object, or in the form of an error result if it seemed incorrect. This
|
|
311
|
+
* way, you can choose to retain a partial result if you want.
|
|
312
|
+
*
|
|
313
|
+
* Note that this function does NOT perform any validation of the entities. No
|
|
314
|
+
* assumptions whatsoever can be made on the emnitted entities except that they
|
|
315
|
+
* are valid JSON objects.
|
|
316
|
+
*/
|
|
317
|
+
declare function parseEntityYaml(data: string | Buffer, location: LocationSpec$1): Iterable<CatalogProcessorResult>;
|
|
318
|
+
|
|
301
319
|
/**
|
|
302
320
|
* A 'full' mutation replaces all existing entities created by this entity provider with new ones.
|
|
303
321
|
* A 'delta' mutation can both add and remove entities provided by this provider. Previously provided
|
|
@@ -412,4 +430,4 @@ interface CatalogService {
|
|
|
412
430
|
*/
|
|
413
431
|
declare const catalogServiceRef: _backstage_backend_plugin_api.ServiceRef<CatalogService, "plugin", "singleton">;
|
|
414
432
|
|
|
415
|
-
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, processingResult };
|
|
433
|
+
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 };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
4
|
+
var lodash = require('lodash');
|
|
5
|
+
var yaml = require('yaml');
|
|
6
|
+
var processingResult = require('../api/processingResult.cjs.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var lodash__default = /*#__PURE__*/_interopDefaultCompat(lodash);
|
|
11
|
+
var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
12
|
+
|
|
13
|
+
function* parseEntityYaml(data, location) {
|
|
14
|
+
let documents;
|
|
15
|
+
try {
|
|
16
|
+
documents = yaml__default.default.parseAllDocuments(
|
|
17
|
+
typeof data === "string" ? data : data.toString("utf8")
|
|
18
|
+
).filter((d) => d);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
const loc = catalogModel.stringifyLocationRef(location);
|
|
21
|
+
const message = `Failed to parse YAML at ${loc}, ${e}`;
|
|
22
|
+
yield processingResult.processingResult.generalError(location, message);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (const document of documents) {
|
|
26
|
+
if (document.errors?.length) {
|
|
27
|
+
const loc = catalogModel.stringifyLocationRef(location);
|
|
28
|
+
const message = `YAML error at ${loc}, ${document.errors[0]}`;
|
|
29
|
+
yield processingResult.processingResult.generalError(location, message);
|
|
30
|
+
} else {
|
|
31
|
+
const json = document.toJSON();
|
|
32
|
+
if (lodash__default.default.isPlainObject(json)) {
|
|
33
|
+
yield processingResult.processingResult.entity(location, json);
|
|
34
|
+
} else if (json === null) ; else {
|
|
35
|
+
const message = `Expected object at root, got ${typeof json}`;
|
|
36
|
+
yield processingResult.processingResult.generalError(location, message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.parseEntityYaml = parseEntityYaml;
|
|
43
|
+
//# sourceMappingURL=parse.cjs.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;AAuCiB,UAAA,eAAA,CACf,MACA,QACkC,EAAA;AAClC,EAAI,IAAA,SAAA;AACJ,EAAI,IAAA;AACF,IAAA,SAAA,GAAYA,qBACT,CAAA,iBAAA;AAAA,MACC,OAAO,IAAS,KAAA,QAAA,GAAW,IAAO,GAAA,IAAA,CAAK,SAAS,MAAM;AAAA,KACxD,CACC,MAAO,CAAA,CAAA,CAAA,KAAK,CAAC,CAAA;AAAA,WACT,CAAG,EAAA;AACV,IAAM,MAAA,GAAA,GAAMC,kCAAqB,QAAQ,CAAA;AACzC,IAAA,MAAM,OAAU,GAAA,CAAA,wBAAA,EAA2B,GAAG,CAAA,EAAA,EAAK,CAAC,CAAA,CAAA;AACpD,IAAM,MAAAC,iCAAA,CAAiB,YAAa,CAAA,QAAA,EAAU,OAAO,CAAA;AACrD,IAAA;AAAA;AAGF,EAAA,KAAA,MAAW,YAAY,SAAW,EAAA;AAChC,IAAI,IAAA,QAAA,CAAS,QAAQ,MAAQ,EAAA;AAC3B,MAAM,MAAA,GAAA,GAAMD,kCAAqB,QAAQ,CAAA;AACzC,MAAA,MAAM,UAAU,CAAiB,cAAA,EAAA,GAAG,KAAK,QAAS,CAAA,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAC3D,MAAM,MAAAC,iCAAA,CAAiB,YAAa,CAAA,QAAA,EAAU,OAAO,CAAA;AAAA,KAChD,MAAA;AACL,MAAM,MAAA,IAAA,GAAO,SAAS,MAAO,EAAA;AAC7B,MAAI,IAAAC,uBAAA,CAAO,aAAc,CAAA,IAAI,CAAG,EAAA;AAC9B,QAAM,MAAAD,iCAAA,CAAiB,MAAO,CAAA,QAAA,EAAU,IAAc,CAAA;AAAA,OACxD,MAAA,IAAW,SAAS,IAAM,EAAA,CAGnB,MAAA;AACL,QAAM,MAAA,OAAA,GAAU,CAAgC,6BAAA,EAAA,OAAO,IAAI,CAAA,CAAA;AAC3D,QAAM,MAAAA,iCAAA,CAAiB,YAAa,CAAA,QAAA,EAAU,OAAO,CAAA;AAAA;AACvD;AACF;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-node",
|
|
3
|
-
"version": "1.17.0-next.
|
|
3
|
+
"version": "1.17.0-next.2",
|
|
4
4
|
"description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -72,18 +72,20 @@
|
|
|
72
72
|
"test": "backstage-cli package test"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@backstage/backend-plugin-api": "1.3.1-next.
|
|
75
|
+
"@backstage/backend-plugin-api": "1.3.1-next.2",
|
|
76
76
|
"@backstage/catalog-client": "1.10.0-next.0",
|
|
77
77
|
"@backstage/catalog-model": "1.7.3",
|
|
78
78
|
"@backstage/errors": "1.2.7",
|
|
79
|
-
"@backstage/plugin-catalog-common": "1.1.
|
|
80
|
-
"@backstage/plugin-permission-common": "0.
|
|
81
|
-
"@backstage/plugin-permission-node": "0.
|
|
82
|
-
"@backstage/types": "1.2.1"
|
|
79
|
+
"@backstage/plugin-catalog-common": "1.1.4-next.0",
|
|
80
|
+
"@backstage/plugin-permission-common": "0.9.0-next.0",
|
|
81
|
+
"@backstage/plugin-permission-node": "0.10.0-next.2",
|
|
82
|
+
"@backstage/types": "1.2.1",
|
|
83
|
+
"lodash": "^4.17.21",
|
|
84
|
+
"yaml": "^2.0.0"
|
|
83
85
|
},
|
|
84
86
|
"devDependencies": {
|
|
85
|
-
"@backstage/backend-test-utils": "1.5.0-next.
|
|
86
|
-
"@backstage/cli": "0.32.1-next.
|
|
87
|
+
"@backstage/backend-test-utils": "1.5.0-next.3",
|
|
88
|
+
"@backstage/cli": "0.32.1-next.3",
|
|
87
89
|
"msw": "^1.0.0"
|
|
88
90
|
}
|
|
89
91
|
}
|