@backstage/plugin-catalog-backend 1.9.2-next.0 → 1.10.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 +52 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +2 -1
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/cjs/{CatalogBuilder-6a9091b7.cjs.js → CatalogBuilder-26406e82.cjs.js} +65 -22
- package/dist/cjs/CatalogBuilder-26406e82.cjs.js.map +1 -0
- package/dist/index.cjs.js +3 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/package.json +21 -19
- package/dist/cjs/CatalogBuilder-6a9091b7.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 1.10.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 44c7ad6b8e11: Adds an optional `EventBroker` that is used for sending an event when there are conflicts, with details of the conflict so that it can be handled elsewhere.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/backend-common@0.19.0-next.2
|
|
13
|
+
- @backstage/catalog-model@1.4.0-next.1
|
|
14
|
+
- @backstage/backend-plugin-api@0.5.3-next.2
|
|
15
|
+
- @backstage/backend-tasks@0.5.3-next.2
|
|
16
|
+
- @backstage/catalog-client@1.4.2-next.2
|
|
17
|
+
- @backstage/config@1.0.7
|
|
18
|
+
- @backstage/errors@1.2.0-next.0
|
|
19
|
+
- @backstage/integration@1.5.0-next.0
|
|
20
|
+
- @backstage/types@1.0.2
|
|
21
|
+
- @backstage/plugin-auth-node@0.2.15-next.2
|
|
22
|
+
- @backstage/plugin-catalog-common@1.0.14-next.1
|
|
23
|
+
- @backstage/plugin-catalog-node@1.3.7-next.2
|
|
24
|
+
- @backstage/plugin-events-node@0.2.7-next.2
|
|
25
|
+
- @backstage/plugin-permission-common@0.7.6-next.0
|
|
26
|
+
- @backstage/plugin-permission-node@0.7.9-next.2
|
|
27
|
+
- @backstage/plugin-scaffolder-common@1.3.1-next.1
|
|
28
|
+
- @backstage/plugin-search-backend-module-catalog@0.1.2-next.2
|
|
29
|
+
- @backstage/plugin-search-common@1.2.4-next.0
|
|
30
|
+
|
|
31
|
+
## 1.9.2-next.1
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 77e04a2d55be: Replace getBearerToken with library function of same
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
- @backstage/backend-common@0.19.0-next.1
|
|
38
|
+
- @backstage/integration@1.5.0-next.0
|
|
39
|
+
- @backstage/errors@1.2.0-next.0
|
|
40
|
+
- @backstage/backend-plugin-api@0.5.3-next.1
|
|
41
|
+
- @backstage/catalog-model@1.4.0-next.0
|
|
42
|
+
- @backstage/backend-tasks@0.5.3-next.1
|
|
43
|
+
- @backstage/plugin-auth-node@0.2.15-next.1
|
|
44
|
+
- @backstage/plugin-catalog-node@1.3.7-next.1
|
|
45
|
+
- @backstage/plugin-permission-node@0.7.9-next.1
|
|
46
|
+
- @backstage/plugin-search-backend-module-catalog@0.1.2-next.1
|
|
47
|
+
- @backstage/catalog-client@1.4.2-next.1
|
|
48
|
+
- @backstage/plugin-permission-common@0.7.6-next.0
|
|
49
|
+
- @backstage/plugin-catalog-common@1.0.14-next.0
|
|
50
|
+
- @backstage/plugin-scaffolder-common@1.3.1-next.0
|
|
51
|
+
- @backstage/config@1.0.7
|
|
52
|
+
- @backstage/types@1.0.2
|
|
53
|
+
- @backstage/plugin-search-common@1.2.4-next.0
|
|
54
|
+
|
|
3
55
|
## 1.9.2-next.0
|
|
4
56
|
|
|
5
57
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var alpha = require('@backstage/plugin-catalog-common/alpha');
|
|
6
6
|
var pluginPermissionNode = require('@backstage/plugin-permission-node');
|
|
7
|
-
var CatalogBuilder = require('./cjs/CatalogBuilder-
|
|
7
|
+
var CatalogBuilder = require('./cjs/CatalogBuilder-26406e82.cjs.js');
|
|
8
8
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
9
9
|
var alpha$1 = require('@backstage/plugin-catalog-node/alpha');
|
|
10
10
|
var backendCommon = require('@backstage/backend-common');
|
|
@@ -34,6 +34,7 @@ require('@backstage/catalog-client');
|
|
|
34
34
|
require('express');
|
|
35
35
|
require('express-promise-router');
|
|
36
36
|
require('yn');
|
|
37
|
+
require('@backstage/plugin-auth-node');
|
|
37
38
|
require('@backstage/plugin-permission-common');
|
|
38
39
|
require('minimatch');
|
|
39
40
|
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/permissions/conditionExports.ts","../src/service/CatalogPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { permissionRules } from './rules';\n\nconst { conditions, createConditionalDecision } = createConditionExports({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n rules: permissionRules,\n});\n\n/**\n * These conditions are used when creating conditional decisions for catalog\n * entities that are returned by authorization policies.\n *\n * @alpha\n */\nexport const catalogConditions = conditions;\n\n/**\n * `createCatalogConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';\n * import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {\n * return createCatalogConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n * ```\n *\n * @alpha\n */\nexport const createCatalogConditionalDecision = createConditionalDecision;\n","/*\n * Copyright 2022 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 {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogBuilder } from './CatalogBuilder';\nimport {\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n} from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogProcessor,\n EntityProvider,\n} from '@backstage/plugin-catalog-node';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\n\nclass CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint {\n #processors = new Array<CatalogProcessor>();\n #entityProviders = new Array<EntityProvider>();\n\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void {\n this.#entityProviders.push(...providers.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n\n get entityProviders() {\n return this.#entityProviders;\n }\n}\n\n/**\n * Catalog plugin\n * @alpha\n */\nexport const catalogPlugin = createBackendPlugin({\n pluginId: 'catalog',\n register(env) {\n const processingExtensions = new CatalogExtensionPointImpl();\n // plugins depending on this API will be initialized before this plugins init method is executed.\n env.registerExtensionPoint(\n catalogProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n lifecycle: coreServices.lifecycle,\n scheduler: coreServices.scheduler,\n },\n async init({\n logger,\n config,\n reader,\n database,\n permissions,\n httpRouter,\n lifecycle,\n scheduler,\n }) {\n const winstonLogger = loggerToWinstonLogger(logger);\n const builder = await CatalogBuilder.create({\n config,\n reader,\n permissions,\n database,\n scheduler,\n logger: winstonLogger,\n });\n builder.addProcessor(...processingExtensions.processors);\n builder.addEntityProvider(...processingExtensions.entityProviders);\n const { processingEngine, router } = await builder.build();\n\n await processingEngine.start();\n lifecycle.addShutdownHook(() => processingEngine.stop());\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_CATALOG_ENTITY","permissionRules","createBackendPlugin","catalogProcessingExtensionPoint","coreServices","loggerToWinstonLogger","CatalogBuilder"],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/permissions/conditionExports.ts","../src/service/CatalogPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { permissionRules } from './rules';\n\nconst { conditions, createConditionalDecision } = createConditionExports({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n rules: permissionRules,\n});\n\n/**\n * These conditions are used when creating conditional decisions for catalog\n * entities that are returned by authorization policies.\n *\n * @alpha\n */\nexport const catalogConditions = conditions;\n\n/**\n * `createCatalogConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';\n * import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {\n * return createCatalogConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n * ```\n *\n * @alpha\n */\nexport const createCatalogConditionalDecision = createConditionalDecision;\n","/*\n * Copyright 2022 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 {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogBuilder } from './CatalogBuilder';\nimport {\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n} from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogProcessor,\n EntityProvider,\n} from '@backstage/plugin-catalog-node';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\n\nclass CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint {\n #processors = new Array<CatalogProcessor>();\n #entityProviders = new Array<EntityProvider>();\n\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void {\n this.#entityProviders.push(...providers.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n\n get entityProviders() {\n return this.#entityProviders;\n }\n}\n\n/**\n * Catalog plugin\n * @alpha\n */\nexport const catalogPlugin = createBackendPlugin({\n pluginId: 'catalog',\n register(env) {\n const processingExtensions = new CatalogExtensionPointImpl();\n // plugins depending on this API will be initialized before this plugins init method is executed.\n env.registerExtensionPoint(\n catalogProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n lifecycle: coreServices.lifecycle,\n scheduler: coreServices.scheduler,\n },\n async init({\n logger,\n config,\n reader,\n database,\n permissions,\n httpRouter,\n lifecycle,\n scheduler,\n }) {\n const winstonLogger = loggerToWinstonLogger(logger);\n const builder = await CatalogBuilder.create({\n config,\n reader,\n permissions,\n database,\n scheduler,\n logger: winstonLogger,\n });\n builder.addProcessor(...processingExtensions.processors);\n builder.addEntityProvider(...processingExtensions.entityProviders);\n const { processingEngine, router } = await builder.build();\n\n await processingEngine.start();\n lifecycle.addShutdownHook(() => processingEngine.stop());\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_CATALOG_ENTITY","permissionRules","createBackendPlugin","catalogProcessingExtensionPoint","coreServices","loggerToWinstonLogger","CatalogBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,EAAE,UAAA,EAAY,yBAA0B,EAAA,GAAIA,2CAAuB,CAAA;AAAA,EACvE,QAAU,EAAA,SAAA;AAAA,EACV,YAAc,EAAAC,kCAAA;AAAA,EACd,KAAO,EAAAC,8BAAA;AACT,CAAC,CAAA,CAAA;AAQM,MAAM,iBAAoB,GAAA,WAAA;AAiC1B,MAAM,gCAAmC,GAAA;;;;;;;;;;;;;;;ACjEhD,IAAA,WAAA,EAAA,gBAAA,CAAA;AA8BA,MAAM,yBAAqE,CAAA;AAAA,EAA3E,WAAA,GAAA;AACE,IAAA,YAAA,CAAA,IAAA,EAAA,WAAA,EAAc,IAAI,KAAwB,EAAA,CAAA,CAAA;AAC1C,IAAA,YAAA,CAAA,IAAA,EAAA,gBAAA,EAAmB,IAAI,KAAsB,EAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAE7C,gBACK,UACG,EAAA;AACN,IAAA,YAAA,CAAA,IAAA,EAAK,WAAY,CAAA,CAAA,IAAA,CAAK,GAAG,UAAA,CAAW,MAAM,CAAA,CAAA;AAAA,GAC5C;AAAA,EAEA,qBACK,SACG,EAAA;AACN,IAAA,YAAA,CAAA,IAAA,EAAK,gBAAiB,CAAA,CAAA,IAAA,CAAK,GAAG,SAAA,CAAU,MAAM,CAAA,CAAA;AAAA,GAChD;AAAA,EAEA,IAAI,UAAa,GAAA;AACf,IAAA,OAAO,YAAK,CAAA,IAAA,EAAA,WAAA,CAAA,CAAA;AAAA,GACd;AAAA,EAEA,IAAI,eAAkB,GAAA;AACpB,IAAA,OAAO,YAAK,CAAA,IAAA,EAAA,gBAAA,CAAA,CAAA;AAAA,GACd;AACF,CAAA;AAtBE,WAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA,gBAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AA2BK,MAAM,gBAAgBC,oCAAoB,CAAA;AAAA,EAC/C,QAAU,EAAA,SAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAM,MAAA,oBAAA,GAAuB,IAAI,yBAA0B,EAAA,CAAA;AAE3D,IAAI,GAAA,CAAA,sBAAA;AAAA,MACFC,uCAAA;AAAA,MACA,oBAAA;AAAA,KACF,CAAA;AAEA,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,SAAA;AAAA,QACrB,aAAaA,6BAAa,CAAA,WAAA;AAAA,QAC1B,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,YAAYA,6BAAa,CAAA,UAAA;AAAA,QACzB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,WAAWA,6BAAa,CAAA,SAAA;AAAA,OAC1B;AAAA,MACA,MAAM,IAAK,CAAA;AAAA,QACT,MAAA;AAAA,QACA,MAAA;AAAA,QACA,MAAA;AAAA,QACA,QAAA;AAAA,QACA,WAAA;AAAA,QACA,UAAA;AAAA,QACA,SAAA;AAAA,QACA,SAAA;AAAA,OACC,EAAA;AACD,QAAM,MAAA,aAAA,GAAgBC,oCAAsB,MAAM,CAAA,CAAA;AAClD,QAAM,MAAA,OAAA,GAAU,MAAMC,6BAAA,CAAe,MAAO,CAAA;AAAA,UAC1C,MAAA;AAAA,UACA,MAAA;AAAA,UACA,WAAA;AAAA,UACA,QAAA;AAAA,UACA,SAAA;AAAA,UACA,MAAQ,EAAA,aAAA;AAAA,SACT,CAAA,CAAA;AACD,QAAQ,OAAA,CAAA,YAAA,CAAa,GAAG,oBAAA,CAAqB,UAAU,CAAA,CAAA;AACvD,QAAQ,OAAA,CAAA,iBAAA,CAAkB,GAAG,oBAAA,CAAqB,eAAe,CAAA,CAAA;AACjE,QAAA,MAAM,EAAE,gBAAkB,EAAA,MAAA,EAAW,GAAA,MAAM,QAAQ,KAAM,EAAA,CAAA;AAEzD,QAAA,MAAM,iBAAiB,KAAM,EAAA,CAAA;AAC7B,QAAA,SAAA,CAAU,eAAgB,CAAA,MAAM,gBAAiB,CAAA,IAAA,EAAM,CAAA,CAAA;AACvD,QAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;"}
|
|
@@ -27,6 +27,7 @@ var catalogClient = require('@backstage/catalog-client');
|
|
|
27
27
|
var express = require('express');
|
|
28
28
|
var Router = require('express-promise-router');
|
|
29
29
|
var yn = require('yn');
|
|
30
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
30
31
|
var alpha = require('@backstage/plugin-catalog-common/alpha');
|
|
31
32
|
var pluginPermissionCommon = require('@backstage/plugin-permission-common');
|
|
32
33
|
var minimatch = require('minimatch');
|
|
@@ -1219,6 +1220,8 @@ function generateStableHash$1(entity) {
|
|
|
1219
1220
|
return crypto.createHash("sha1").update(stableStringify__default["default"]({ ...entity })).digest("hex");
|
|
1220
1221
|
}
|
|
1221
1222
|
|
|
1223
|
+
const CATALOG_CONFLICTS_TOPIC = "experimental.catalog.conflict";
|
|
1224
|
+
|
|
1222
1225
|
const BATCH_SIZE$2 = 50;
|
|
1223
1226
|
class DefaultProcessingDatabase {
|
|
1224
1227
|
constructor(options) {
|
|
@@ -1388,6 +1391,7 @@ class DefaultProcessingDatabase {
|
|
|
1388
1391
|
* The entities will be added at the front of the processing queue.
|
|
1389
1392
|
*/
|
|
1390
1393
|
async addUnprocessedEntities(txOpaque, options) {
|
|
1394
|
+
var _a;
|
|
1391
1395
|
const tx = txOpaque;
|
|
1392
1396
|
const stateReferences = new Array();
|
|
1393
1397
|
for (const { entity, locationKey } of options.entities) {
|
|
@@ -1423,6 +1427,19 @@ class DefaultProcessingDatabase {
|
|
|
1423
1427
|
this.options.logger.warn(
|
|
1424
1428
|
`Detected conflicting entityRef ${entityRef} already referenced by ${conflictingKey} and now also ${locationKey}`
|
|
1425
1429
|
);
|
|
1430
|
+
if (this.options.eventBroker && locationKey) {
|
|
1431
|
+
const eventParams = {
|
|
1432
|
+
topic: CATALOG_CONFLICTS_TOPIC,
|
|
1433
|
+
eventPayload: {
|
|
1434
|
+
unprocessedEntity: entity,
|
|
1435
|
+
entityRef,
|
|
1436
|
+
newLocationKey: locationKey,
|
|
1437
|
+
existingLocationKey: conflictingKey,
|
|
1438
|
+
lastConflictAt: luxon.DateTime.now().toISO()
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
await ((_a = this.options.eventBroker) == null ? void 0 : _a.publish(eventParams));
|
|
1442
|
+
}
|
|
1426
1443
|
}
|
|
1427
1444
|
}
|
|
1428
1445
|
await tx("refresh_state_references").andWhere({ source_entity_ref: options.sourceEntityRef }).delete();
|
|
@@ -3402,7 +3419,7 @@ async function createRouter(options) {
|
|
|
3402
3419
|
if (refreshService) {
|
|
3403
3420
|
router.post("/refresh", async (req, res) => {
|
|
3404
3421
|
const refreshOptions = req.body;
|
|
3405
|
-
refreshOptions.authorizationToken =
|
|
3422
|
+
refreshOptions.authorizationToken = pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3406
3423
|
req.header("authorization")
|
|
3407
3424
|
);
|
|
3408
3425
|
await refreshService.refresh(refreshOptions);
|
|
@@ -3419,7 +3436,9 @@ async function createRouter(options) {
|
|
|
3419
3436
|
fields: parseEntityTransformParams(req.query),
|
|
3420
3437
|
order: parseEntityOrderParams(req.query),
|
|
3421
3438
|
pagination: parseEntityPaginationParams(req.query),
|
|
3422
|
-
authorizationToken:
|
|
3439
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3440
|
+
req.header("authorization")
|
|
3441
|
+
)
|
|
3423
3442
|
});
|
|
3424
3443
|
if (pageInfo.hasNextPage) {
|
|
3425
3444
|
const url = new URL(`http://ignored${req.url}`);
|
|
@@ -3431,7 +3450,9 @@ async function createRouter(options) {
|
|
|
3431
3450
|
}).get("/entities/by-query", async (req, res) => {
|
|
3432
3451
|
const { items, pageInfo, totalItems } = await entitiesCatalog.queryEntities({
|
|
3433
3452
|
...parseQueryEntitiesParams(req.query),
|
|
3434
|
-
authorizationToken:
|
|
3453
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3454
|
+
req.header("authorization")
|
|
3455
|
+
)
|
|
3435
3456
|
});
|
|
3436
3457
|
res.json({
|
|
3437
3458
|
items,
|
|
@@ -3449,7 +3470,9 @@ async function createRouter(options) {
|
|
|
3449
3470
|
const { uid } = req.params;
|
|
3450
3471
|
const { entities } = await entitiesCatalog.entities({
|
|
3451
3472
|
filter: basicEntityFilter({ "metadata.uid": uid }),
|
|
3452
|
-
authorizationToken:
|
|
3473
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3474
|
+
req.header("authorization")
|
|
3475
|
+
)
|
|
3453
3476
|
});
|
|
3454
3477
|
if (!entities.length) {
|
|
3455
3478
|
throw new errors.NotFoundError(`No entity with uid ${uid}`);
|
|
@@ -3458,7 +3481,9 @@ async function createRouter(options) {
|
|
|
3458
3481
|
}).delete("/entities/by-uid/:uid", async (req, res) => {
|
|
3459
3482
|
const { uid } = req.params;
|
|
3460
3483
|
await entitiesCatalog.removeEntityByUid(uid, {
|
|
3461
|
-
authorizationToken:
|
|
3484
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3485
|
+
req.header("authorization")
|
|
3486
|
+
)
|
|
3462
3487
|
});
|
|
3463
3488
|
res.status(204).end();
|
|
3464
3489
|
}).get("/entities/by-name/:kind/:namespace/:name", async (req, res) => {
|
|
@@ -3469,7 +3494,9 @@ async function createRouter(options) {
|
|
|
3469
3494
|
"metadata.namespace": namespace,
|
|
3470
3495
|
"metadata.name": name
|
|
3471
3496
|
}),
|
|
3472
|
-
authorizationToken:
|
|
3497
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3498
|
+
req.header("authorization")
|
|
3499
|
+
)
|
|
3473
3500
|
});
|
|
3474
3501
|
if (!entities.length) {
|
|
3475
3502
|
throw new errors.NotFoundError(
|
|
@@ -3483,13 +3510,17 @@ async function createRouter(options) {
|
|
|
3483
3510
|
const { kind, namespace, name } = req.params;
|
|
3484
3511
|
const entityRef = catalogModel.stringifyEntityRef({ kind, namespace, name });
|
|
3485
3512
|
const response = await entitiesCatalog.entityAncestry(entityRef, {
|
|
3486
|
-
authorizationToken:
|
|
3513
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3514
|
+
req.header("authorization")
|
|
3515
|
+
)
|
|
3487
3516
|
});
|
|
3488
3517
|
res.status(200).json(response);
|
|
3489
3518
|
}
|
|
3490
3519
|
).post("/entities/by-refs", async (req, res) => {
|
|
3491
3520
|
const request = entitiesBatchRequest(req);
|
|
3492
|
-
const token =
|
|
3521
|
+
const token = pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3522
|
+
req.header("authorization")
|
|
3523
|
+
);
|
|
3493
3524
|
const response = await entitiesCatalog.entitiesBatch({
|
|
3494
3525
|
entityRefs: request.entityRefs,
|
|
3495
3526
|
fields: parseEntityTransformParams(req.query, request.fields),
|
|
@@ -3500,7 +3531,9 @@ async function createRouter(options) {
|
|
|
3500
3531
|
const response = await entitiesCatalog.facets({
|
|
3501
3532
|
filter: parseEntityFilterParams(req.query),
|
|
3502
3533
|
facets: parseEntityFacetParams(req.query),
|
|
3503
|
-
authorizationToken:
|
|
3534
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3535
|
+
req.header("authorization")
|
|
3536
|
+
)
|
|
3504
3537
|
});
|
|
3505
3538
|
res.status(200).json(response);
|
|
3506
3539
|
});
|
|
@@ -3513,25 +3546,33 @@ async function createRouter(options) {
|
|
|
3513
3546
|
disallowReadonlyMode(readonlyEnabled);
|
|
3514
3547
|
}
|
|
3515
3548
|
const output = await locationService.createLocation(location, dryRun, {
|
|
3516
|
-
authorizationToken:
|
|
3549
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3550
|
+
req.header("authorization")
|
|
3551
|
+
)
|
|
3517
3552
|
});
|
|
3518
3553
|
res.status(201).json(output);
|
|
3519
3554
|
}).get("/locations", async (req, res) => {
|
|
3520
3555
|
const locations = await locationService.listLocations({
|
|
3521
|
-
authorizationToken:
|
|
3556
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3557
|
+
req.header("authorization")
|
|
3558
|
+
)
|
|
3522
3559
|
});
|
|
3523
3560
|
res.status(200).json(locations.map((l) => ({ data: l })));
|
|
3524
3561
|
}).get("/locations/:id", async (req, res) => {
|
|
3525
3562
|
const { id } = req.params;
|
|
3526
3563
|
const output = await locationService.getLocation(id, {
|
|
3527
|
-
authorizationToken:
|
|
3564
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3565
|
+
req.header("authorization")
|
|
3566
|
+
)
|
|
3528
3567
|
});
|
|
3529
3568
|
res.status(200).json(output);
|
|
3530
3569
|
}).delete("/locations/:id", async (req, res) => {
|
|
3531
3570
|
disallowReadonlyMode(readonlyEnabled);
|
|
3532
3571
|
const { id } = req.params;
|
|
3533
3572
|
await locationService.deleteLocation(id, {
|
|
3534
|
-
authorizationToken:
|
|
3573
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3574
|
+
req.header("authorization")
|
|
3575
|
+
)
|
|
3535
3576
|
});
|
|
3536
3577
|
res.status(204).end();
|
|
3537
3578
|
});
|
|
@@ -3598,13 +3639,6 @@ async function createRouter(options) {
|
|
|
3598
3639
|
router.use(backendCommon.errorHandler());
|
|
3599
3640
|
return router;
|
|
3600
3641
|
}
|
|
3601
|
-
function getBearerToken(authorizationHeader) {
|
|
3602
|
-
if (typeof authorizationHeader !== "string") {
|
|
3603
|
-
return void 0;
|
|
3604
|
-
}
|
|
3605
|
-
const matches = authorizationHeader.match(/Bearer\s+(\S+)/i);
|
|
3606
|
-
return matches == null ? void 0 : matches[1];
|
|
3607
|
-
}
|
|
3608
3642
|
|
|
3609
3643
|
class DefaultRefreshService {
|
|
3610
3644
|
constructor(options) {
|
|
@@ -4776,6 +4810,13 @@ class CatalogBuilder {
|
|
|
4776
4810
|
this.legacySingleProcessorValidation = true;
|
|
4777
4811
|
return this;
|
|
4778
4812
|
}
|
|
4813
|
+
/**
|
|
4814
|
+
* Enables the publishing of events for cloflicts in the DefaultProcessingDatabase
|
|
4815
|
+
*/
|
|
4816
|
+
setEventBroker(broker) {
|
|
4817
|
+
this.eventBroker = broker;
|
|
4818
|
+
return this;
|
|
4819
|
+
}
|
|
4779
4820
|
/**
|
|
4780
4821
|
* Wires up and returns all of the component parts of the catalog
|
|
4781
4822
|
*/
|
|
@@ -4793,7 +4834,8 @@ class CatalogBuilder {
|
|
|
4793
4834
|
const processingDatabase = new DefaultProcessingDatabase({
|
|
4794
4835
|
database: dbClient,
|
|
4795
4836
|
logger,
|
|
4796
|
-
refreshInterval: this.processingInterval
|
|
4837
|
+
refreshInterval: this.processingInterval,
|
|
4838
|
+
eventBroker: this.eventBroker
|
|
4797
4839
|
});
|
|
4798
4840
|
const providerDatabase = new DefaultProviderDatabase({
|
|
4799
4841
|
database: dbClient,
|
|
@@ -5050,6 +5092,7 @@ class CatalogBuilder {
|
|
|
5050
5092
|
|
|
5051
5093
|
exports.AnnotateLocationEntityProcessor = AnnotateLocationEntityProcessor;
|
|
5052
5094
|
exports.BuiltinKindsEntityProcessor = BuiltinKindsEntityProcessor;
|
|
5095
|
+
exports.CATALOG_CONFLICTS_TOPIC = CATALOG_CONFLICTS_TOPIC;
|
|
5053
5096
|
exports.CatalogBuilder = CatalogBuilder;
|
|
5054
5097
|
exports.CodeOwnersProcessor = CodeOwnersProcessor;
|
|
5055
5098
|
exports.FileReaderProcessor = FileReaderProcessor;
|
|
@@ -5059,4 +5102,4 @@ exports.createCatalogPermissionRule = createCatalogPermissionRule;
|
|
|
5059
5102
|
exports.createRandomProcessingInterval = createRandomProcessingInterval;
|
|
5060
5103
|
exports.parseEntityYaml = parseEntityYaml;
|
|
5061
5104
|
exports.permissionRules = permissionRules;
|
|
5062
|
-
//# sourceMappingURL=CatalogBuilder-
|
|
5105
|
+
//# sourceMappingURL=CatalogBuilder-26406e82.cjs.js.map
|