@backstage/plugin-catalog-react 1.12.3 → 1.12.4-next.0
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 +21 -0
- package/alpha/package.json +1 -1
- package/dist/alpha/blueprints/EntityCardBlueprint.esm.js +8 -8
- package/dist/alpha/blueprints/EntityCardBlueprint.esm.js.map +1 -1
- package/dist/alpha/blueprints/EntityContentBlueprint.esm.js +11 -11
- package/dist/alpha/blueprints/EntityContentBlueprint.esm.js.map +1 -1
- package/dist/alpha/blueprints/extensionData.esm.js +12 -0
- package/dist/alpha/blueprints/extensionData.esm.js.map +1 -0
- package/dist/alpha/converters/convertLegacyEntityCardExtension.esm.js.map +1 -1
- package/dist/alpha/converters/convertLegacyEntityContentExtension.esm.js.map +1 -1
- package/dist/alpha.d.ts +77 -142
- package/dist/alpha.esm.js +2 -3
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/EntityOwnerPicker/useFacetsEntities.esm.js +1 -1
- package/dist/components/EntityOwnerPicker/useFacetsEntities.esm.js.map +1 -1
- package/package.json +6 -6
- package/dist/alpha/extensions.esm.js +0 -103
- package/dist/alpha/extensions.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 1.12.4-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fec8b57: Updated exports to use the new type parameters for extensions and extension blueprints.
|
|
8
|
+
- 5446061: The `/alpha` export no longer export extension creators for the new frontend system, existing usage should be switched to use the equivalent extension blueprint instead. For more information see the [new frontend system 1.30 migration documentation](https://backstage.io/docs/frontend-system/architecture/migrations#130).
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/frontend-plugin-api@0.8.0-next.0
|
|
11
|
+
- @backstage/core-compat-api@0.2.9-next.0
|
|
12
|
+
- @backstage/catalog-client@1.6.6
|
|
13
|
+
- @backstage/catalog-model@1.6.0
|
|
14
|
+
- @backstage/core-components@0.14.10
|
|
15
|
+
- @backstage/core-plugin-api@1.9.3
|
|
16
|
+
- @backstage/errors@1.2.4
|
|
17
|
+
- @backstage/integration-react@1.1.30
|
|
18
|
+
- @backstage/types@1.1.1
|
|
19
|
+
- @backstage/version-bridge@1.0.8
|
|
20
|
+
- @backstage/plugin-catalog-common@1.0.26
|
|
21
|
+
- @backstage/plugin-permission-common@0.8.1
|
|
22
|
+
- @backstage/plugin-permission-react@0.4.25
|
|
23
|
+
|
|
3
24
|
## 1.12.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/alpha/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createExtensionBlueprint, coreExtensionData, ExtensionBoundary } from '@backstage/frontend-plugin-api';
|
|
2
|
-
import {
|
|
2
|
+
import { entityFilterFunctionDataRef, entityFilterExpressionDataRef } from './extensionData.esm.js';
|
|
3
3
|
|
|
4
4
|
const EntityCardBlueprint = createExtensionBlueprint({
|
|
5
5
|
kind: "entity-card",
|
|
6
6
|
attachTo: { id: "entity-content:catalog/overview", input: "cards" },
|
|
7
7
|
output: [
|
|
8
8
|
coreExtensionData.reactElement,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
entityFilterFunctionDataRef.optional(),
|
|
10
|
+
entityFilterExpressionDataRef.optional()
|
|
11
11
|
],
|
|
12
12
|
dataRefs: {
|
|
13
|
-
filterFunction:
|
|
14
|
-
filterExpression:
|
|
13
|
+
filterFunction: entityFilterFunctionDataRef,
|
|
14
|
+
filterExpression: entityFilterExpressionDataRef
|
|
15
15
|
},
|
|
16
16
|
config: {
|
|
17
17
|
schema: {
|
|
@@ -24,11 +24,11 @@ const EntityCardBlueprint = createExtensionBlueprint({
|
|
|
24
24
|
}, { node, config }) {
|
|
25
25
|
yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader));
|
|
26
26
|
if (config.filter) {
|
|
27
|
-
yield
|
|
27
|
+
yield entityFilterExpressionDataRef(config.filter);
|
|
28
28
|
} else if (typeof filter === "string") {
|
|
29
|
-
yield
|
|
29
|
+
yield entityFilterExpressionDataRef(filter);
|
|
30
30
|
} else if (typeof filter === "function") {
|
|
31
|
-
yield
|
|
31
|
+
yield entityFilterFunctionDataRef(filter);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCardBlueprint.esm.js","sources":["../../../src/alpha/blueprints/EntityCardBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 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 ExtensionBoundary,\n coreExtensionData,\n createExtensionBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {
|
|
1
|
+
{"version":3,"file":"EntityCardBlueprint.esm.js","sources":["../../../src/alpha/blueprints/EntityCardBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 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 ExtensionBoundary,\n coreExtensionData,\n createExtensionBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n entityFilterFunctionDataRef,\n entityFilterExpressionDataRef,\n} from './extensionData';\n\n/**\n * @alpha\n * A blueprint for creating cards for the entity pages in the catalog.\n */\nexport const EntityCardBlueprint = createExtensionBlueprint({\n kind: 'entity-card',\n attachTo: { id: 'entity-content:catalog/overview', input: 'cards' },\n output: [\n coreExtensionData.reactElement,\n entityFilterFunctionDataRef.optional(),\n entityFilterExpressionDataRef.optional(),\n ],\n dataRefs: {\n filterFunction: entityFilterFunctionDataRef,\n filterExpression: entityFilterExpressionDataRef,\n },\n config: {\n schema: {\n filter: z => z.string().optional(),\n },\n },\n *factory(\n {\n loader,\n filter,\n }: {\n loader: () => Promise<JSX.Element>;\n filter?:\n | typeof entityFilterFunctionDataRef.T\n | typeof entityFilterExpressionDataRef.T;\n },\n { node, config },\n ) {\n yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader));\n\n if (config.filter) {\n yield entityFilterExpressionDataRef(config.filter);\n } else if (typeof filter === 'string') {\n yield entityFilterExpressionDataRef(filter);\n } else if (typeof filter === 'function') {\n yield entityFilterFunctionDataRef(filter);\n }\n },\n});\n"],"names":[],"mappings":";;;AA8BO,MAAM,sBAAsB,wBAAyB,CAAA;AAAA,EAC1D,IAAM,EAAA,aAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,iCAAA,EAAmC,OAAO,OAAQ,EAAA;AAAA,EAClE,MAAQ,EAAA;AAAA,IACN,iBAAkB,CAAA,YAAA;AAAA,IAClB,4BAA4B,QAAS,EAAA;AAAA,IACrC,8BAA8B,QAAS,EAAA;AAAA,GACzC;AAAA,EACA,QAAU,EAAA;AAAA,IACR,cAAgB,EAAA,2BAAA;AAAA,IAChB,gBAAkB,EAAA,6BAAA;AAAA,GACpB;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA;AAAA,MACN,MAAQ,EAAA,CAAA,CAAA,KAAK,CAAE,CAAA,MAAA,GAAS,QAAS,EAAA;AAAA,KACnC;AAAA,GACF;AAAA,EACA,CAAC,OACC,CAAA;AAAA,IACE,MAAA;AAAA,IACA,MAAA;AAAA,GAOF,EAAA,EAAE,IAAM,EAAA,MAAA,EACR,EAAA;AACA,IAAA,MAAM,kBAAkB,YAAa,CAAA,iBAAA,CAAkB,IAAK,CAAA,IAAA,EAAM,MAAM,CAAC,CAAA,CAAA;AAEzE,IAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,MAAM,MAAA,6BAAA,CAA8B,OAAO,MAAM,CAAA,CAAA;AAAA,KACnD,MAAA,IAAW,OAAO,MAAA,KAAW,QAAU,EAAA;AACrC,MAAA,MAAM,8BAA8B,MAAM,CAAA,CAAA;AAAA,KAC5C,MAAA,IAAW,OAAO,MAAA,KAAW,UAAY,EAAA;AACvC,MAAA,MAAM,4BAA4B,MAAM,CAAA,CAAA;AAAA,KAC1C;AAAA,GACF;AACF,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createExtensionBlueprint, coreExtensionData, ExtensionBoundary } from '@backstage/frontend-plugin-api';
|
|
2
|
-
import {
|
|
2
|
+
import { entityContentTitleDataRef, entityFilterFunctionDataRef, entityFilterExpressionDataRef } from './extensionData.esm.js';
|
|
3
3
|
|
|
4
4
|
const EntityContentBlueprint = createExtensionBlueprint({
|
|
5
5
|
kind: "entity-content",
|
|
@@ -7,15 +7,15 @@ const EntityContentBlueprint = createExtensionBlueprint({
|
|
|
7
7
|
output: [
|
|
8
8
|
coreExtensionData.reactElement,
|
|
9
9
|
coreExtensionData.routePath,
|
|
10
|
-
|
|
10
|
+
entityContentTitleDataRef,
|
|
11
11
|
coreExtensionData.routeRef.optional(),
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
entityFilterFunctionDataRef.optional(),
|
|
13
|
+
entityFilterExpressionDataRef.optional()
|
|
14
14
|
],
|
|
15
15
|
dataRefs: {
|
|
16
|
-
title:
|
|
17
|
-
filterFunction:
|
|
18
|
-
filterExpression:
|
|
16
|
+
title: entityContentTitleDataRef,
|
|
17
|
+
filterFunction: entityFilterFunctionDataRef,
|
|
18
|
+
filterExpression: entityFilterExpressionDataRef
|
|
19
19
|
},
|
|
20
20
|
config: {
|
|
21
21
|
schema: {
|
|
@@ -35,16 +35,16 @@ const EntityContentBlueprint = createExtensionBlueprint({
|
|
|
35
35
|
const title = config.title ?? defaultTitle;
|
|
36
36
|
yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader));
|
|
37
37
|
yield coreExtensionData.routePath(path);
|
|
38
|
-
yield
|
|
38
|
+
yield entityContentTitleDataRef(title);
|
|
39
39
|
if (routeRef) {
|
|
40
40
|
yield coreExtensionData.routeRef(routeRef);
|
|
41
41
|
}
|
|
42
42
|
if (config.filter) {
|
|
43
|
-
yield
|
|
43
|
+
yield entityFilterExpressionDataRef(config.filter);
|
|
44
44
|
} else if (typeof filter === "string") {
|
|
45
|
-
yield
|
|
45
|
+
yield entityFilterExpressionDataRef(filter);
|
|
46
46
|
} else if (typeof filter === "function") {
|
|
47
|
-
yield
|
|
47
|
+
yield entityFilterFunctionDataRef(filter);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityContentBlueprint.esm.js","sources":["../../../src/alpha/blueprints/EntityContentBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 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 coreExtensionData,\n createExtensionBlueprint,\n ExtensionBoundary,\n RouteRef,\n} from '@backstage/frontend-plugin-api';\nimport {
|
|
1
|
+
{"version":3,"file":"EntityContentBlueprint.esm.js","sources":["../../../src/alpha/blueprints/EntityContentBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2024 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 coreExtensionData,\n createExtensionBlueprint,\n ExtensionBoundary,\n RouteRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n entityContentTitleDataRef,\n entityFilterFunctionDataRef,\n entityFilterExpressionDataRef,\n} from './extensionData';\n\n/**\n * @alpha\n * Creates an EntityContent extension.\n */\nexport const EntityContentBlueprint = createExtensionBlueprint({\n kind: 'entity-content',\n attachTo: { id: 'page:catalog/entity', input: 'contents' },\n output: [\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n entityContentTitleDataRef,\n coreExtensionData.routeRef.optional(),\n entityFilterFunctionDataRef.optional(),\n entityFilterExpressionDataRef.optional(),\n ],\n dataRefs: {\n title: entityContentTitleDataRef,\n filterFunction: entityFilterFunctionDataRef,\n filterExpression: entityFilterExpressionDataRef,\n },\n config: {\n schema: {\n path: z => z.string().optional(),\n title: z => z.string().optional(),\n filter: z => z.string().optional(),\n },\n },\n *factory(\n {\n loader,\n defaultPath,\n defaultTitle,\n filter,\n routeRef,\n }: {\n loader: () => Promise<JSX.Element>;\n defaultPath: string;\n defaultTitle: string;\n routeRef?: RouteRef;\n filter?:\n | typeof entityFilterFunctionDataRef.T\n | typeof entityFilterExpressionDataRef.T;\n },\n { node, config },\n ) {\n const path = config.path ?? defaultPath;\n const title = config.title ?? defaultTitle;\n\n yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader));\n\n yield coreExtensionData.routePath(path);\n\n yield entityContentTitleDataRef(title);\n\n if (routeRef) {\n yield coreExtensionData.routeRef(routeRef);\n }\n\n if (config.filter) {\n yield entityFilterExpressionDataRef(config.filter);\n } else if (typeof filter === 'string') {\n yield entityFilterExpressionDataRef(filter);\n } else if (typeof filter === 'function') {\n yield entityFilterFunctionDataRef(filter);\n }\n },\n});\n"],"names":[],"mappings":";;;AAgCO,MAAM,yBAAyB,wBAAyB,CAAA;AAAA,EAC7D,IAAM,EAAA,gBAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,qBAAA,EAAuB,OAAO,UAAW,EAAA;AAAA,EACzD,MAAQ,EAAA;AAAA,IACN,iBAAkB,CAAA,YAAA;AAAA,IAClB,iBAAkB,CAAA,SAAA;AAAA,IAClB,yBAAA;AAAA,IACA,iBAAA,CAAkB,SAAS,QAAS,EAAA;AAAA,IACpC,4BAA4B,QAAS,EAAA;AAAA,IACrC,8BAA8B,QAAS,EAAA;AAAA,GACzC;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,yBAAA;AAAA,IACP,cAAgB,EAAA,2BAAA;AAAA,IAChB,gBAAkB,EAAA,6BAAA;AAAA,GACpB;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA;AAAA,MACN,IAAM,EAAA,CAAA,CAAA,KAAK,CAAE,CAAA,MAAA,GAAS,QAAS,EAAA;AAAA,MAC/B,KAAO,EAAA,CAAA,CAAA,KAAK,CAAE,CAAA,MAAA,GAAS,QAAS,EAAA;AAAA,MAChC,MAAQ,EAAA,CAAA,CAAA,KAAK,CAAE,CAAA,MAAA,GAAS,QAAS,EAAA;AAAA,KACnC;AAAA,GACF;AAAA,EACA,CAAC,OACC,CAAA;AAAA,IACE,MAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,GAUF,EAAA,EAAE,IAAM,EAAA,MAAA,EACR,EAAA;AACA,IAAM,MAAA,IAAA,GAAO,OAAO,IAAQ,IAAA,WAAA,CAAA;AAC5B,IAAM,MAAA,KAAA,GAAQ,OAAO,KAAS,IAAA,YAAA,CAAA;AAE9B,IAAA,MAAM,kBAAkB,YAAa,CAAA,iBAAA,CAAkB,IAAK,CAAA,IAAA,EAAM,MAAM,CAAC,CAAA,CAAA;AAEzE,IAAM,MAAA,iBAAA,CAAkB,UAAU,IAAI,CAAA,CAAA;AAEtC,IAAA,MAAM,0BAA0B,KAAK,CAAA,CAAA;AAErC,IAAA,IAAI,QAAU,EAAA;AACZ,MAAM,MAAA,iBAAA,CAAkB,SAAS,QAAQ,CAAA,CAAA;AAAA,KAC3C;AAEA,IAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,MAAM,MAAA,6BAAA,CAA8B,OAAO,MAAM,CAAA,CAAA;AAAA,KACnD,MAAA,IAAW,OAAO,MAAA,KAAW,QAAU,EAAA;AACrC,MAAA,MAAM,8BAA8B,MAAM,CAAA,CAAA;AAAA,KAC5C,MAAA,IAAW,OAAO,MAAA,KAAW,UAAY,EAAA;AACvC,MAAA,MAAM,4BAA4B,MAAM,CAAA,CAAA;AAAA,KAC1C;AAAA,GACF;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createExtensionDataRef } from '@backstage/frontend-plugin-api';
|
|
2
|
+
|
|
3
|
+
const entityContentTitleDataRef = createExtensionDataRef().with({
|
|
4
|
+
id: "catalog.entity-content-title"
|
|
5
|
+
});
|
|
6
|
+
const entityFilterFunctionDataRef = createExtensionDataRef().with({ id: "catalog.entity-filter-function" });
|
|
7
|
+
const entityFilterExpressionDataRef = createExtensionDataRef().with({
|
|
8
|
+
id: "catalog.entity-filter-expression"
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { entityContentTitleDataRef, entityFilterExpressionDataRef, entityFilterFunctionDataRef };
|
|
12
|
+
//# sourceMappingURL=extensionData.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionData.esm.js","sources":["../../../src/alpha/blueprints/extensionData.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 } from '@backstage/catalog-model';\nimport { createExtensionDataRef } from '@backstage/frontend-plugin-api';\n\n/** @internal */\nexport const entityContentTitleDataRef = createExtensionDataRef<string>().with({\n id: 'catalog.entity-content-title',\n});\n\n/** @internal */\nexport const entityFilterFunctionDataRef = createExtensionDataRef<\n (entity: Entity) => boolean\n>().with({ id: 'catalog.entity-filter-function' });\n\n/** @internal */\nexport const entityFilterExpressionDataRef =\n createExtensionDataRef<string>().with({\n id: 'catalog.entity-filter-expression',\n });\n"],"names":[],"mappings":";;AAoBa,MAAA,yBAAA,GAA4B,sBAA+B,EAAA,CAAE,IAAK,CAAA;AAAA,EAC7E,EAAI,EAAA,8BAAA;AACN,CAAC,EAAA;AAGM,MAAM,8BAA8B,sBAEzC,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,kCAAkC,EAAA;AAGpC,MAAA,6BAAA,GACX,sBAA+B,EAAA,CAAE,IAAK,CAAA;AAAA,EACpC,EAAI,EAAA,kCAAA;AACN,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertLegacyEntityCardExtension.esm.js","sources":["../../../src/alpha/converters/convertLegacyEntityCardExtension.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { compatWrapper } from '@backstage/core-compat-api';\nimport { BackstagePlugin, getComponentData } from '@backstage/core-plugin-api';\nimport { ExtensionDefinition } from '@backstage/frontend-plugin-api';\nimport React, { ComponentType } from 'react';\nimport { EntityCardBlueprint } from '../blueprints';\nimport kebabCase from 'lodash/kebabCase';\n\n/** @alpha */\nexport function convertLegacyEntityCardExtension(\n LegacyExtension: ComponentType<{}>,\n overrides?: {\n name?: string;\n filter?:\n | typeof EntityCardBlueprint.dataRefs.filterFunction.T\n | typeof EntityCardBlueprint.dataRefs.filterExpression.T;\n },\n): ExtensionDefinition
|
|
1
|
+
{"version":3,"file":"convertLegacyEntityCardExtension.esm.js","sources":["../../../src/alpha/converters/convertLegacyEntityCardExtension.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { compatWrapper } from '@backstage/core-compat-api';\nimport { BackstagePlugin, getComponentData } from '@backstage/core-plugin-api';\nimport { ExtensionDefinition } from '@backstage/frontend-plugin-api';\nimport React, { ComponentType } from 'react';\nimport { EntityCardBlueprint } from '../blueprints';\nimport kebabCase from 'lodash/kebabCase';\n\n/** @alpha */\nexport function convertLegacyEntityCardExtension(\n LegacyExtension: ComponentType<{}>,\n overrides?: {\n name?: string;\n filter?:\n | typeof EntityCardBlueprint.dataRefs.filterFunction.T\n | typeof EntityCardBlueprint.dataRefs.filterExpression.T;\n },\n): ExtensionDefinition {\n const element = <LegacyExtension />;\n\n const extName = getComponentData<string>(element, 'core.extensionName');\n if (!extName) {\n throw new Error('Extension has no name');\n }\n\n const plugin = getComponentData<BackstagePlugin>(element, 'core.plugin');\n const pluginId = plugin?.getId();\n\n const match = extName.match(/^Entity(.*)Card$/);\n const infix = match?.[1] ?? extName;\n\n let name: string | undefined = infix;\n if (\n pluginId &&\n name\n .toLocaleLowerCase('en-US')\n .startsWith(pluginId.toLocaleLowerCase('en-US'))\n ) {\n name = name.slice(pluginId.length);\n if (!name) {\n name = undefined;\n }\n }\n name = name && kebabCase(name);\n\n return EntityCardBlueprint.make({\n name: overrides?.name ?? name,\n params: {\n filter: overrides?.filter,\n loader: async () => compatWrapper(element),\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;AAwBgB,SAAA,gCAAA,CACd,iBACA,SAMqB,EAAA;AACrB,EAAM,MAAA,OAAA,uCAAW,eAAgB,EAAA,IAAA,CAAA,CAAA;AAEjC,EAAM,MAAA,OAAA,GAAU,gBAAyB,CAAA,OAAA,EAAS,oBAAoB,CAAA,CAAA;AACtE,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,uBAAuB,CAAA,CAAA;AAAA,GACzC;AAEA,EAAM,MAAA,MAAA,GAAS,gBAAkC,CAAA,OAAA,EAAS,aAAa,CAAA,CAAA;AACvE,EAAM,MAAA,QAAA,GAAW,QAAQ,KAAM,EAAA,CAAA;AAE/B,EAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,KAAA,CAAM,kBAAkB,CAAA,CAAA;AAC9C,EAAM,MAAA,KAAA,GAAQ,KAAQ,GAAA,CAAC,CAAK,IAAA,OAAA,CAAA;AAE5B,EAAA,IAAI,IAA2B,GAAA,KAAA,CAAA;AAC/B,EACE,IAAA,QAAA,IACA,IACG,CAAA,iBAAA,CAAkB,OAAO,CAAA,CACzB,WAAW,QAAS,CAAA,iBAAA,CAAkB,OAAO,CAAC,CACjD,EAAA;AACA,IAAO,IAAA,GAAA,IAAA,CAAK,KAAM,CAAA,QAAA,CAAS,MAAM,CAAA,CAAA;AACjC,IAAA,IAAI,CAAC,IAAM,EAAA;AACT,MAAO,IAAA,GAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAAA,GACF;AACA,EAAO,IAAA,GAAA,IAAA,IAAQ,UAAU,IAAI,CAAA,CAAA;AAE7B,EAAA,OAAO,oBAAoB,IAAK,CAAA;AAAA,IAC9B,IAAA,EAAM,WAAW,IAAQ,IAAA,IAAA;AAAA,IACzB,MAAQ,EAAA;AAAA,MACN,QAAQ,SAAW,EAAA,MAAA;AAAA,MACnB,MAAA,EAAQ,YAAY,aAAA,CAAc,OAAO,CAAA;AAAA,KAC3C;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertLegacyEntityContentExtension.esm.js","sources":["../../../src/alpha/converters/convertLegacyEntityContentExtension.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n BackstagePlugin,\n getComponentData,\n RouteRef as LegacyRouteRef,\n} from '@backstage/core-plugin-api';\nimport { ExtensionDefinition } from '@backstage/frontend-plugin-api';\nimport kebabCase from 'lodash/kebabCase';\nimport startCase from 'lodash/startCase';\nimport React, { ComponentType } from 'react';\nimport { EntityContentBlueprint } from '../blueprints';\n\n/** @alpha */\nexport function convertLegacyEntityContentExtension(\n LegacyExtension: ComponentType<{}>,\n overrides?: {\n name?: string;\n filter?:\n | typeof EntityContentBlueprint.dataRefs.filterFunction.T\n | typeof EntityContentBlueprint.dataRefs.filterExpression.T;\n defaultPath?: string;\n defaultTitle?: string;\n },\n): ExtensionDefinition
|
|
1
|
+
{"version":3,"file":"convertLegacyEntityContentExtension.esm.js","sources":["../../../src/alpha/converters/convertLegacyEntityContentExtension.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n BackstagePlugin,\n getComponentData,\n RouteRef as LegacyRouteRef,\n} from '@backstage/core-plugin-api';\nimport { ExtensionDefinition } from '@backstage/frontend-plugin-api';\nimport kebabCase from 'lodash/kebabCase';\nimport startCase from 'lodash/startCase';\nimport React, { ComponentType } from 'react';\nimport { EntityContentBlueprint } from '../blueprints';\n\n/** @alpha */\nexport function convertLegacyEntityContentExtension(\n LegacyExtension: ComponentType<{}>,\n overrides?: {\n name?: string;\n filter?:\n | typeof EntityContentBlueprint.dataRefs.filterFunction.T\n | typeof EntityContentBlueprint.dataRefs.filterExpression.T;\n defaultPath?: string;\n defaultTitle?: string;\n },\n): ExtensionDefinition {\n const element = <LegacyExtension />;\n\n const extName = getComponentData<string>(element, 'core.extensionName');\n if (!extName) {\n throw new Error('Extension has no name');\n }\n\n const mountPoint = getComponentData<LegacyRouteRef>(\n element,\n 'core.mountPoint',\n );\n\n const plugin = getComponentData<BackstagePlugin>(element, 'core.plugin');\n const pluginId = plugin?.getId();\n\n const match = extName.match(/^Entity(.*)Content$/);\n const infix = match?.[1] ?? extName;\n\n let name: string | undefined = infix;\n if (\n pluginId &&\n name\n .toLocaleLowerCase('en-US')\n .startsWith(pluginId.toLocaleLowerCase('en-US'))\n ) {\n name = name.slice(pluginId.length);\n if (!name) {\n name = undefined;\n }\n }\n name = name && kebabCase(name);\n\n return EntityContentBlueprint.make({\n name: overrides?.name ?? name,\n params: {\n filter: overrides?.filter,\n defaultPath: overrides?.defaultPath ?? `/${kebabCase(infix)}`,\n defaultTitle: overrides?.defaultTitle ?? startCase(infix),\n routeRef: mountPoint && convertLegacyRouteRef(mountPoint),\n loader: async () => compatWrapper(element),\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;AAgCgB,SAAA,mCAAA,CACd,iBACA,SAQqB,EAAA;AACrB,EAAM,MAAA,OAAA,uCAAW,eAAgB,EAAA,IAAA,CAAA,CAAA;AAEjC,EAAM,MAAA,OAAA,GAAU,gBAAyB,CAAA,OAAA,EAAS,oBAAoB,CAAA,CAAA;AACtE,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,uBAAuB,CAAA,CAAA;AAAA,GACzC;AAEA,EAAA,MAAM,UAAa,GAAA,gBAAA;AAAA,IACjB,OAAA;AAAA,IACA,iBAAA;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,MAAA,GAAS,gBAAkC,CAAA,OAAA,EAAS,aAAa,CAAA,CAAA;AACvE,EAAM,MAAA,QAAA,GAAW,QAAQ,KAAM,EAAA,CAAA;AAE/B,EAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,KAAA,CAAM,qBAAqB,CAAA,CAAA;AACjD,EAAM,MAAA,KAAA,GAAQ,KAAQ,GAAA,CAAC,CAAK,IAAA,OAAA,CAAA;AAE5B,EAAA,IAAI,IAA2B,GAAA,KAAA,CAAA;AAC/B,EACE,IAAA,QAAA,IACA,IACG,CAAA,iBAAA,CAAkB,OAAO,CAAA,CACzB,WAAW,QAAS,CAAA,iBAAA,CAAkB,OAAO,CAAC,CACjD,EAAA;AACA,IAAO,IAAA,GAAA,IAAA,CAAK,KAAM,CAAA,QAAA,CAAS,MAAM,CAAA,CAAA;AACjC,IAAA,IAAI,CAAC,IAAM,EAAA;AACT,MAAO,IAAA,GAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAAA,GACF;AACA,EAAO,IAAA,GAAA,IAAA,IAAQ,UAAU,IAAI,CAAA,CAAA;AAE7B,EAAA,OAAO,uBAAuB,IAAK,CAAA;AAAA,IACjC,IAAA,EAAM,WAAW,IAAQ,IAAA,IAAA;AAAA,IACzB,MAAQ,EAAA;AAAA,MACN,QAAQ,SAAW,EAAA,MAAA;AAAA,MACnB,aAAa,SAAW,EAAA,WAAA,IAAe,CAAI,CAAA,EAAA,SAAA,CAAU,KAAK,CAAC,CAAA,CAAA;AAAA,MAC3D,YAAc,EAAA,SAAA,EAAW,YAAgB,IAAA,SAAA,CAAU,KAAK,CAAA;AAAA,MACxD,QAAA,EAAU,UAAc,IAAA,qBAAA,CAAsB,UAAU,CAAA;AAAA,MACxD,MAAA,EAAQ,YAAY,aAAA,CAAc,OAAO,CAAA;AAAA,KAC3C;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
3
|
-
import { RouteRef,
|
|
3
|
+
import { RouteRef, ExtensionDefinition } from '@backstage/frontend-plugin-api';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { ComponentType } from 'react';
|
|
6
6
|
import * as _backstage_catalog_model from '@backstage/catalog-model';
|
|
7
7
|
import { Entity } from '@backstage/catalog-model';
|
|
8
|
-
import { ResourcePermission } from '@backstage/plugin-permission-common';
|
|
9
8
|
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
|
|
9
|
+
import { ResourcePermission } from '@backstage/plugin-permission-common';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Returns true if the `owner` argument is a direct owner on the `entity` argument.
|
|
@@ -27,20 +27,26 @@ declare const EntityCardBlueprint: _backstage_frontend_plugin_api.ExtensionBluep
|
|
|
27
27
|
kind: "entity-card";
|
|
28
28
|
namespace: undefined;
|
|
29
29
|
name: undefined;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
params: {
|
|
31
|
+
loader: () => Promise<JSX.Element>;
|
|
32
|
+
filter?: string | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
|
|
33
|
+
};
|
|
34
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<React.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
35
|
+
optional: true;
|
|
36
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
|
|
37
|
+
optional: true;
|
|
38
|
+
}>;
|
|
39
|
+
inputs: {};
|
|
40
|
+
config: {
|
|
41
|
+
filter: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
configInput: {
|
|
44
|
+
filter?: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
dataRefs: {
|
|
47
|
+
filterFunction: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {}>;
|
|
48
|
+
filterExpression: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {}>;
|
|
49
|
+
};
|
|
44
50
|
}>;
|
|
45
51
|
|
|
46
52
|
/**
|
|
@@ -51,56 +57,51 @@ declare const EntityContentBlueprint: _backstage_frontend_plugin_api.ExtensionBl
|
|
|
51
57
|
kind: "entity-content";
|
|
52
58
|
namespace: undefined;
|
|
53
59
|
name: undefined;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
params: {
|
|
61
|
+
loader: () => Promise<JSX.Element>;
|
|
62
|
+
defaultPath: string;
|
|
63
|
+
defaultTitle: string;
|
|
64
|
+
routeRef?: RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams> | undefined;
|
|
65
|
+
filter?: string | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
|
|
66
|
+
};
|
|
67
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<React.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
|
|
68
|
+
optional: true;
|
|
69
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-content-title", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
70
|
+
optional: true;
|
|
71
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
|
|
72
|
+
optional: true;
|
|
73
|
+
}>;
|
|
74
|
+
inputs: {};
|
|
75
|
+
config: {
|
|
76
|
+
path: string | undefined;
|
|
77
|
+
title: string | undefined;
|
|
78
|
+
filter: string | undefined;
|
|
79
|
+
};
|
|
80
|
+
configInput: {
|
|
81
|
+
filter?: string | undefined;
|
|
82
|
+
title?: string | undefined;
|
|
83
|
+
path?: string | undefined;
|
|
84
|
+
};
|
|
85
|
+
dataRefs: {
|
|
86
|
+
title: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-content-title", {}>;
|
|
87
|
+
filterFunction: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {}>;
|
|
88
|
+
filterExpression: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {}>;
|
|
89
|
+
};
|
|
78
90
|
}>;
|
|
79
91
|
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[K in keyof O]: O[K];
|
|
86
|
-
} : never;
|
|
92
|
+
/** @alpha */
|
|
93
|
+
declare function convertLegacyEntityCardExtension(LegacyExtension: ComponentType<{}>, overrides?: {
|
|
94
|
+
name?: string;
|
|
95
|
+
filter?: typeof EntityCardBlueprint.dataRefs.filterFunction.T | typeof EntityCardBlueprint.dataRefs.filterExpression.T;
|
|
96
|
+
}): ExtensionDefinition;
|
|
87
97
|
|
|
88
|
-
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* context. If you have the entityRef and need concurrent requests, use the
|
|
96
|
-
* `usePermission` hook directly.
|
|
97
|
-
* @alpha
|
|
98
|
-
*/
|
|
99
|
-
declare function useEntityPermission(permission: ResourcePermission<'catalog-entity'>): {
|
|
100
|
-
loading: boolean;
|
|
101
|
-
allowed: boolean;
|
|
102
|
-
error?: Error;
|
|
103
|
-
};
|
|
98
|
+
/** @alpha */
|
|
99
|
+
declare function convertLegacyEntityContentExtension(LegacyExtension: ComponentType<{}>, overrides?: {
|
|
100
|
+
name?: string;
|
|
101
|
+
filter?: typeof EntityContentBlueprint.dataRefs.filterFunction.T | typeof EntityContentBlueprint.dataRefs.filterExpression.T;
|
|
102
|
+
defaultPath?: string;
|
|
103
|
+
defaultTitle?: string;
|
|
104
|
+
}): ExtensionDefinition;
|
|
104
105
|
|
|
105
106
|
/** @alpha */
|
|
106
107
|
declare const catalogReactTranslationRef: _backstage_core_plugin_api_alpha.TranslationRef<"catalog-react", {
|
|
@@ -158,86 +159,20 @@ declare const catalogReactTranslationRef: _backstage_core_plugin_api_alpha.Trans
|
|
|
158
159
|
}>;
|
|
159
160
|
|
|
160
161
|
/**
|
|
162
|
+
* A thin wrapper around the
|
|
163
|
+
* {@link @backstage/plugin-permission-react#usePermission} hook which uses the
|
|
164
|
+
* current entity in context to make an authorization request for the given
|
|
165
|
+
* {@link @backstage/plugin-catalog-common#CatalogEntityPermission}.
|
|
166
|
+
*
|
|
167
|
+
* Note: this hook blocks the permission request until the entity has loaded in
|
|
168
|
+
* context. If you have the entityRef and need concurrent requests, use the
|
|
169
|
+
* `usePermission` hook directly.
|
|
161
170
|
* @alpha
|
|
162
|
-
* @deprecated use `dataRefs` property on either {@link EntityCardBlueprint} or {@link EntityContentBlueprint} instead
|
|
163
171
|
*/
|
|
164
|
-
declare
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
172
|
+
declare function useEntityPermission(permission: ResourcePermission<'catalog-entity'>): {
|
|
173
|
+
loading: boolean;
|
|
174
|
+
allowed: boolean;
|
|
175
|
+
error?: Error;
|
|
168
176
|
};
|
|
169
|
-
/**
|
|
170
|
-
* @alpha
|
|
171
|
-
* @deprecated use {@link EntityCardBlueprint} instead
|
|
172
|
-
*/
|
|
173
|
-
declare function createEntityCardExtension<TConfig extends {
|
|
174
|
-
filter?: string;
|
|
175
|
-
}, TInputs extends AnyExtensionInputMap>(options: {
|
|
176
|
-
namespace?: string;
|
|
177
|
-
name?: string;
|
|
178
|
-
attachTo?: {
|
|
179
|
-
id: string;
|
|
180
|
-
input: string;
|
|
181
|
-
};
|
|
182
|
-
disabled?: boolean;
|
|
183
|
-
inputs?: TInputs;
|
|
184
|
-
configSchema?: PortableSchema<TConfig>;
|
|
185
|
-
filter?: typeof catalogExtensionData.entityFilterFunction.T | typeof catalogExtensionData.entityFilterExpression.T;
|
|
186
|
-
loader: (options: {
|
|
187
|
-
config: TConfig;
|
|
188
|
-
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
|
189
|
-
}) => Promise<JSX.Element>;
|
|
190
|
-
}): _backstage_frontend_plugin_api.ExtensionDefinition<TConfig, TConfig, never, never, {
|
|
191
|
-
kind?: string | undefined;
|
|
192
|
-
namespace?: string | undefined;
|
|
193
|
-
name?: string | undefined;
|
|
194
|
-
}>;
|
|
195
|
-
/**
|
|
196
|
-
* @alpha
|
|
197
|
-
* @deprecated use {@link EntityContentBlueprint} instead
|
|
198
|
-
*/
|
|
199
|
-
declare function createEntityContentExtension<TInputs extends AnyExtensionInputMap>(options: {
|
|
200
|
-
namespace?: string;
|
|
201
|
-
name?: string;
|
|
202
|
-
attachTo?: {
|
|
203
|
-
id: string;
|
|
204
|
-
input: string;
|
|
205
|
-
};
|
|
206
|
-
disabled?: boolean;
|
|
207
|
-
inputs?: TInputs;
|
|
208
|
-
routeRef?: RouteRef;
|
|
209
|
-
defaultPath: string;
|
|
210
|
-
defaultTitle: string;
|
|
211
|
-
filter?: typeof catalogExtensionData.entityFilterFunction.T | typeof catalogExtensionData.entityFilterExpression.T;
|
|
212
|
-
loader: (options: {
|
|
213
|
-
inputs: Expand<ResolvedExtensionInputs<TInputs>>;
|
|
214
|
-
}) => Promise<JSX.Element>;
|
|
215
|
-
}): _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
216
|
-
title: string;
|
|
217
|
-
path: string;
|
|
218
|
-
filter?: string | undefined;
|
|
219
|
-
}, {
|
|
220
|
-
filter?: string | undefined;
|
|
221
|
-
title?: string | undefined;
|
|
222
|
-
path?: string | undefined;
|
|
223
|
-
}, never, never, {
|
|
224
|
-
kind?: string | undefined;
|
|
225
|
-
namespace?: string | undefined;
|
|
226
|
-
name?: string | undefined;
|
|
227
|
-
}>;
|
|
228
|
-
|
|
229
|
-
/** @alpha */
|
|
230
|
-
declare function convertLegacyEntityCardExtension(LegacyExtension: ComponentType<{}>, overrides?: {
|
|
231
|
-
name?: string;
|
|
232
|
-
filter?: typeof EntityCardBlueprint.dataRefs.filterFunction.T | typeof EntityCardBlueprint.dataRefs.filterExpression.T;
|
|
233
|
-
}): ExtensionDefinition<any>;
|
|
234
|
-
|
|
235
|
-
/** @alpha */
|
|
236
|
-
declare function convertLegacyEntityContentExtension(LegacyExtension: ComponentType<{}>, overrides?: {
|
|
237
|
-
name?: string;
|
|
238
|
-
filter?: typeof EntityContentBlueprint.dataRefs.filterFunction.T | typeof EntityContentBlueprint.dataRefs.filterExpression.T;
|
|
239
|
-
defaultPath?: string;
|
|
240
|
-
defaultTitle?: string;
|
|
241
|
-
}): ExtensionDefinition<any>;
|
|
242
177
|
|
|
243
|
-
export { EntityCardBlueprint, EntityContentBlueprint,
|
|
178
|
+
export { EntityCardBlueprint, EntityContentBlueprint, catalogReactTranslationRef, convertLegacyEntityCardExtension, convertLegacyEntityContentExtension, isOwnerOf, useEntityPermission };
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { EntityCardBlueprint } from './alpha/blueprints/EntityCardBlueprint.esm.js';
|
|
2
2
|
export { EntityContentBlueprint } from './alpha/blueprints/EntityContentBlueprint.esm.js';
|
|
3
|
-
export { catalogExtensionData, createEntityCardExtension, createEntityContentExtension } from './alpha/extensions.esm.js';
|
|
4
3
|
export { convertLegacyEntityCardExtension } from './alpha/converters/convertLegacyEntityCardExtension.esm.js';
|
|
5
4
|
export { convertLegacyEntityContentExtension } from './alpha/converters/convertLegacyEntityContentExtension.esm.js';
|
|
6
|
-
export { useEntityPermission } from './hooks/useEntityPermission.esm.js';
|
|
7
|
-
export { isOwnerOf } from './utils/isOwnerOf.esm.js';
|
|
8
5
|
export { catalogReactTranslationRef } from './translation.esm.js';
|
|
6
|
+
export { isOwnerOf } from './utils/isOwnerOf.esm.js';
|
|
7
|
+
export { useEntityPermission } from './hooks/useEntityPermission.esm.js';
|
|
9
8
|
//# sourceMappingURL=alpha.esm.js.map
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -14,7 +14,7 @@ function useFacetsEntities({ enabled }) {
|
|
|
14
14
|
const facetsResponse = await catalogApi.getEntityFacets({
|
|
15
15
|
facets: [facet]
|
|
16
16
|
});
|
|
17
|
-
const entityRefs = facetsResponse.facets[facet]
|
|
17
|
+
const entityRefs = facetsResponse.facets[facet]?.map((e) => e.value) ?? [];
|
|
18
18
|
return catalogApi.getEntitiesByRefs({ entityRefs }).then(
|
|
19
19
|
(resp) => resp.items.filter((entity) => entity !== void 0).map((entity) => entity).sort(
|
|
20
20
|
(a, b) => (a.metadata.namespace || "").localeCompare(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFacetsEntities.esm.js","sources":["../../../src/components/EntityOwnerPicker/useFacetsEntities.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { useApi } from '@backstage/core-plugin-api';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { catalogApiRef } from '../../api';\nimport { useState } from 'react';\nimport { Entity } from '@backstage/catalog-model';\nimport get from 'lodash/get';\n\ntype FacetsCursor = {\n start: number;\n text: string;\n};\n\ntype FacetsEntitiesResponse = {\n items: Entity[];\n cursor?: string;\n};\n\ntype FacetsInitialRequest = {\n text: string;\n};\n\n/**\n * This hook asynchronously loads the entity owners using the facets endpoint.\n * EntityOwnerPicker uses this hook when mode=\"owners-only\" is passed as prop.\n * All the owners are kept internally in memory and rendered in batches once requested\n * by the frontend. The values returned by this hook are compatible with `useQueryEntities`\n * hook, which is also used by EntityOwnerPicker.\n */\nexport function useFacetsEntities({ enabled }: { enabled: boolean }) {\n const catalogApi = useApi(catalogApiRef);\n\n const [facetsPromise] = useState(async () => {\n if (!enabled) {\n return [];\n }\n const facet = 'relations.ownedBy';\n const facetsResponse = await catalogApi.getEntityFacets({\n facets: [facet],\n });\n const entityRefs = facetsResponse.facets[facet]
|
|
1
|
+
{"version":3,"file":"useFacetsEntities.esm.js","sources":["../../../src/components/EntityOwnerPicker/useFacetsEntities.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { useApi } from '@backstage/core-plugin-api';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { catalogApiRef } from '../../api';\nimport { useState } from 'react';\nimport { Entity } from '@backstage/catalog-model';\nimport get from 'lodash/get';\n\ntype FacetsCursor = {\n start: number;\n text: string;\n};\n\ntype FacetsEntitiesResponse = {\n items: Entity[];\n cursor?: string;\n};\n\ntype FacetsInitialRequest = {\n text: string;\n};\n\n/**\n * This hook asynchronously loads the entity owners using the facets endpoint.\n * EntityOwnerPicker uses this hook when mode=\"owners-only\" is passed as prop.\n * All the owners are kept internally in memory and rendered in batches once requested\n * by the frontend. The values returned by this hook are compatible with `useQueryEntities`\n * hook, which is also used by EntityOwnerPicker.\n */\nexport function useFacetsEntities({ enabled }: { enabled: boolean }) {\n const catalogApi = useApi(catalogApiRef);\n\n const [facetsPromise] = useState(async () => {\n if (!enabled) {\n return [];\n }\n const facet = 'relations.ownedBy';\n const facetsResponse = await catalogApi.getEntityFacets({\n facets: [facet],\n });\n const entityRefs = facetsResponse.facets[facet]?.map(e => e.value) ?? [];\n\n return catalogApi\n .getEntitiesByRefs({ entityRefs })\n .then(resp =>\n resp.items\n .filter(entity => entity !== undefined)\n .map(entity => entity as Entity)\n .sort(\n (a, b) =>\n (a.metadata.namespace || '').localeCompare(\n b.metadata.namespace || '',\n 'en-US',\n ) ||\n (\n get(a, 'spec.profile.displayName') ||\n a.metadata.title ||\n a.metadata.name\n ).localeCompare(\n get(b, 'spec.profile.displayName') ||\n b.metadata.title ||\n b.metadata.name,\n 'en-US',\n ) ||\n a.kind.localeCompare(b.kind, 'en-US'),\n ),\n )\n .then(entities => entities)\n .catch(() => []);\n });\n\n return useAsyncFn<\n (\n request: FacetsInitialRequest | FacetsEntitiesResponse,\n options?: { limit?: number },\n ) => Promise<FacetsEntitiesResponse>\n >(\n async (request, options) => {\n const facets = await facetsPromise;\n\n if (!facets) {\n return {\n items: [],\n };\n }\n\n const limit = options?.limit ?? 20;\n\n const { text, start } = decodeCursor(request);\n const filteredRefs = facets.filter(e => filterEntity(text, e));\n const end = start + limit;\n return {\n items: filteredRefs.slice(0, end),\n ...encodeCursor({\n entities: filteredRefs,\n limit: end,\n payload: {\n text,\n start: end,\n },\n }),\n };\n },\n [facetsPromise],\n { loading: true, value: { items: [] } },\n );\n}\n\nfunction decodeCursor(\n request: FacetsInitialRequest | FacetsEntitiesResponse,\n): FacetsCursor {\n if (isFacetsResponse(request) && request.cursor) {\n return JSON.parse(atob(request.cursor));\n }\n return {\n text: (request as FacetsInitialRequest).text || '',\n start: 0,\n };\n}\n\nfunction isFacetsResponse(\n request: FacetsInitialRequest | FacetsEntitiesResponse,\n): request is FacetsEntitiesResponse {\n return !!(request as FacetsEntitiesResponse).cursor;\n}\n\nfunction encodeCursor({\n entities,\n limit,\n payload,\n}: {\n entities: Entity[];\n limit: number;\n payload: { text: string; start: number };\n}) {\n if (entities.length > limit) {\n return { cursor: btoa(JSON.stringify(payload)) };\n }\n return {};\n}\n\nfunction filterEntity(text: string, entity: Entity) {\n const normalizedText = text.trim();\n return (\n entity.kind.includes(normalizedText) ||\n entity.metadata.namespace?.includes(normalizedText) ||\n entity.metadata.name.includes(normalizedText) ||\n entity.metadata.title?.includes(normalizedText) ||\n (get(entity, 'spec.profile.displayName') as unknown as string)?.includes(\n normalizedText,\n )\n );\n}\n"],"names":[],"mappings":";;;;;;AA2CgB,SAAA,iBAAA,CAAkB,EAAE,OAAA,EAAiC,EAAA;AACnE,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AAEvC,EAAA,MAAM,CAAC,aAAa,CAAI,GAAA,QAAA,CAAS,YAAY;AAC3C,IAAA,IAAI,CAAC,OAAS,EAAA;AACZ,MAAA,OAAO,EAAC,CAAA;AAAA,KACV;AACA,IAAA,MAAM,KAAQ,GAAA,mBAAA,CAAA;AACd,IAAM,MAAA,cAAA,GAAiB,MAAM,UAAA,CAAW,eAAgB,CAAA;AAAA,MACtD,MAAA,EAAQ,CAAC,KAAK,CAAA;AAAA,KACf,CAAA,CAAA;AACD,IAAM,MAAA,UAAA,GAAa,cAAe,CAAA,MAAA,CAAO,KAAK,CAAA,EAAG,IAAI,CAAK,CAAA,KAAA,CAAA,CAAE,KAAK,CAAA,IAAK,EAAC,CAAA;AAEvE,IAAA,OAAO,UACJ,CAAA,iBAAA,CAAkB,EAAE,UAAA,EAAY,CAChC,CAAA,IAAA;AAAA,MAAK,CAAA,IAAA,KACJ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EAAA;AAClD,EAAM,MAAA,cAAA,GAAiB,KAAK,IAAK,EAAA,CAAA;AACjC,EACE,OAAA,MAAA,CAAO,IAAK,CAAA,QAAA,CAAS,cAAc,CAAA,IACnC,MAAO,CAAA,QAAA,CAAS,SAAW,EAAA,QAAA,CAAS,cAAc,CAAA,IAClD,MAAO,CAAA,QAAA,CAAS,KAAK,QAAS,CAAA,cAAc,CAC5C,IAAA,MAAA,CAAO,QAAS,CAAA,KAAA,EAAO,QAAS,CAAA,cAAc,CAC7C,IAAA,GAAA,CAAI,MAAQ,EAAA,0BAA0B,CAAyB,EAAA,QAAA;AAAA,IAC9D,cAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-react",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.4-next.0",
|
|
4
4
|
"description": "A frontend library that helps other Backstage plugins interact with the catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@backstage/catalog-client": "^1.6.6",
|
|
60
60
|
"@backstage/catalog-model": "^1.6.0",
|
|
61
|
-
"@backstage/core-compat-api": "^0.2.
|
|
61
|
+
"@backstage/core-compat-api": "^0.2.9-next.0",
|
|
62
62
|
"@backstage/core-components": "^0.14.10",
|
|
63
63
|
"@backstage/core-plugin-api": "^1.9.3",
|
|
64
64
|
"@backstage/errors": "^1.2.4",
|
|
65
|
-
"@backstage/frontend-plugin-api": "^0.
|
|
65
|
+
"@backstage/frontend-plugin-api": "^0.8.0-next.0",
|
|
66
66
|
"@backstage/integration-react": "^1.1.30",
|
|
67
67
|
"@backstage/plugin-catalog-common": "^1.0.26",
|
|
68
68
|
"@backstage/plugin-permission-common": "^0.8.1",
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
"zen-observable": "^0.10.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@backstage/cli": "^0.27.0",
|
|
86
|
+
"@backstage/cli": "^0.27.1-next.0",
|
|
87
87
|
"@backstage/core-app-api": "^1.14.2",
|
|
88
|
-
"@backstage/frontend-test-utils": "^0.
|
|
88
|
+
"@backstage/frontend-test-utils": "^0.2.0-next.0",
|
|
89
89
|
"@backstage/plugin-catalog-common": "^1.0.26",
|
|
90
90
|
"@backstage/plugin-scaffolder-common": "^1.5.5",
|
|
91
|
-
"@backstage/test-utils": "^1.
|
|
91
|
+
"@backstage/test-utils": "^1.6.0-next.0",
|
|
92
92
|
"@testing-library/dom": "^10.0.0",
|
|
93
93
|
"@testing-library/jest-dom": "^6.0.0",
|
|
94
94
|
"@testing-library/react": "^15.0.0",
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { createExtensionDataRef, createSchemaFromZod, createExtension, coreExtensionData, ExtensionBoundary } from '@backstage/frontend-plugin-api';
|
|
2
|
-
import React, { lazy } from 'react';
|
|
3
|
-
import '@backstage/catalog-model';
|
|
4
|
-
import '@backstage/plugin-permission-react';
|
|
5
|
-
import '../hooks/useEntity.esm.js';
|
|
6
|
-
export { catalogReactTranslationRef } from '../translation.esm.js';
|
|
7
|
-
|
|
8
|
-
const catalogExtensionData = {
|
|
9
|
-
entityContentTitle: createExtensionDataRef().with({
|
|
10
|
-
id: "catalog.entity-content-title"
|
|
11
|
-
}),
|
|
12
|
-
entityFilterFunction: createExtensionDataRef().with({ id: "catalog.entity-filter-function" }),
|
|
13
|
-
entityFilterExpression: createExtensionDataRef().with({
|
|
14
|
-
id: "catalog.entity-filter-expression"
|
|
15
|
-
})
|
|
16
|
-
};
|
|
17
|
-
function createEntityCardExtension(options) {
|
|
18
|
-
const configSchema = "configSchema" in options ? options.configSchema : createSchemaFromZod(
|
|
19
|
-
(z) => z.object({
|
|
20
|
-
filter: z.string().optional()
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
return createExtension({
|
|
24
|
-
kind: "entity-card",
|
|
25
|
-
namespace: options.namespace,
|
|
26
|
-
name: options.name,
|
|
27
|
-
attachTo: options.attachTo ?? {
|
|
28
|
-
id: "entity-content:catalog/overview",
|
|
29
|
-
input: "cards"
|
|
30
|
-
},
|
|
31
|
-
disabled: options.disabled,
|
|
32
|
-
output: {
|
|
33
|
-
element: coreExtensionData.reactElement,
|
|
34
|
-
filterFunction: catalogExtensionData.entityFilterFunction.optional(),
|
|
35
|
-
filterExpression: catalogExtensionData.entityFilterExpression.optional()
|
|
36
|
-
},
|
|
37
|
-
inputs: options.inputs,
|
|
38
|
-
configSchema,
|
|
39
|
-
factory({ config, inputs, node }) {
|
|
40
|
-
const ExtensionComponent = lazy(
|
|
41
|
-
() => options.loader({ inputs, config }).then((element) => ({ default: () => element }))
|
|
42
|
-
);
|
|
43
|
-
return {
|
|
44
|
-
element: /* @__PURE__ */ React.createElement(ExtensionBoundary, { node }, /* @__PURE__ */ React.createElement(ExtensionComponent, null)),
|
|
45
|
-
...mergeFilters({ config, options })
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function createEntityContentExtension(options) {
|
|
51
|
-
return createExtension({
|
|
52
|
-
kind: "entity-content",
|
|
53
|
-
namespace: options.namespace,
|
|
54
|
-
name: options.name,
|
|
55
|
-
attachTo: options.attachTo ?? {
|
|
56
|
-
id: "page:catalog/entity",
|
|
57
|
-
input: "contents"
|
|
58
|
-
},
|
|
59
|
-
disabled: options.disabled,
|
|
60
|
-
output: {
|
|
61
|
-
element: coreExtensionData.reactElement,
|
|
62
|
-
path: coreExtensionData.routePath,
|
|
63
|
-
routeRef: coreExtensionData.routeRef.optional(),
|
|
64
|
-
title: catalogExtensionData.entityContentTitle,
|
|
65
|
-
filterFunction: catalogExtensionData.entityFilterFunction.optional(),
|
|
66
|
-
filterExpression: catalogExtensionData.entityFilterExpression.optional()
|
|
67
|
-
},
|
|
68
|
-
inputs: options.inputs,
|
|
69
|
-
configSchema: createSchemaFromZod(
|
|
70
|
-
(z) => z.object({
|
|
71
|
-
path: z.string().default(options.defaultPath),
|
|
72
|
-
title: z.string().default(options.defaultTitle),
|
|
73
|
-
filter: z.string().optional()
|
|
74
|
-
})
|
|
75
|
-
),
|
|
76
|
-
factory({ config, inputs, node }) {
|
|
77
|
-
const ExtensionComponent = lazy(
|
|
78
|
-
() => options.loader({ inputs }).then((element) => ({ default: () => element }))
|
|
79
|
-
);
|
|
80
|
-
return {
|
|
81
|
-
path: config.path,
|
|
82
|
-
title: config.title,
|
|
83
|
-
routeRef: options.routeRef,
|
|
84
|
-
element: /* @__PURE__ */ React.createElement(ExtensionBoundary, { node }, /* @__PURE__ */ React.createElement(ExtensionComponent, null)),
|
|
85
|
-
...mergeFilters({ config, options })
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function mergeFilters(inputs) {
|
|
91
|
-
const { options, config } = inputs;
|
|
92
|
-
if (config.filter) {
|
|
93
|
-
return { filterExpression: config.filter };
|
|
94
|
-
} else if (typeof options.filter === "string") {
|
|
95
|
-
return { filterExpression: options.filter };
|
|
96
|
-
} else if (typeof options.filter === "function") {
|
|
97
|
-
return { filterFunction: options.filter };
|
|
98
|
-
}
|
|
99
|
-
return {};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { catalogExtensionData, createEntityCardExtension, createEntityContentExtension };
|
|
103
|
-
//# sourceMappingURL=extensions.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.esm.js","sources":["../../src/alpha/extensions.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 AnyExtensionInputMap,\n ExtensionBoundary,\n PortableSchema,\n ResolvedExtensionInputs,\n RouteRef,\n coreExtensionData,\n createExtension,\n createExtensionDataRef,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\nimport React, { lazy } from 'react';\nimport { Entity } from '@backstage/catalog-model';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { Expand } from '../../../../packages/frontend-plugin-api/src/types';\n\nexport { useEntityPermission } from '../hooks/useEntityPermission';\nexport { isOwnerOf } from '../utils';\nexport * from '../translation';\n\n/**\n * @alpha\n * @deprecated use `dataRefs` property on either {@link EntityCardBlueprint} or {@link EntityContentBlueprint} instead\n */\nexport const catalogExtensionData = {\n entityContentTitle: createExtensionDataRef<string>().with({\n id: 'catalog.entity-content-title',\n }),\n entityFilterFunction: createExtensionDataRef<\n (entity: Entity) => boolean\n >().with({ id: 'catalog.entity-filter-function' }),\n entityFilterExpression: createExtensionDataRef<string>().with({\n id: 'catalog.entity-filter-expression',\n }),\n};\n\n// TODO: Figure out how to merge with provided config schema\n/**\n * @alpha\n * @deprecated use {@link EntityCardBlueprint} instead\n */\nexport function createEntityCardExtension<\n TConfig extends { filter?: string },\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n configSchema?: PortableSchema<TConfig>;\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n}) {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({\n filter: z.string().optional(),\n }),\n ) as PortableSchema<TConfig>);\n return createExtension({\n kind: 'entity-card',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'entity-content:catalog/overview',\n input: 'cards',\n },\n disabled: options.disabled,\n output: {\n element: coreExtensionData.reactElement,\n filterFunction: catalogExtensionData.entityFilterFunction.optional(),\n filterExpression: catalogExtensionData.entityFilterExpression.optional(),\n },\n inputs: options.inputs,\n configSchema,\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ inputs, config })\n .then(element => ({ default: () => element })),\n );\n\n return {\n element: (\n <ExtensionBoundary node={node}>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n ...mergeFilters({ config, options }),\n };\n },\n });\n}\n\n/**\n * @alpha\n * @deprecated use {@link EntityContentBlueprint} instead\n */\nexport function createEntityContentExtension<\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n routeRef?: RouteRef;\n defaultPath: string;\n defaultTitle: string;\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n loader: (options: {\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n}) {\n return createExtension({\n kind: 'entity-content',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'page:catalog/entity',\n input: 'contents',\n },\n disabled: options.disabled,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n title: catalogExtensionData.entityContentTitle,\n filterFunction: catalogExtensionData.entityFilterFunction.optional(),\n filterExpression: catalogExtensionData.entityFilterExpression.optional(),\n },\n inputs: options.inputs,\n configSchema: createSchemaFromZod(z =>\n z.object({\n path: z.string().default(options.defaultPath),\n title: z.string().default(options.defaultTitle),\n filter: z.string().optional(),\n }),\n ),\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ inputs })\n .then(element => ({ default: () => element })),\n );\n\n return {\n path: config.path,\n title: config.title,\n routeRef: options.routeRef,\n element: (\n <ExtensionBoundary node={node}>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n ...mergeFilters({ config, options }),\n };\n },\n });\n}\n\n/**\n * Decides what filter outputs to produce, given some options and config\n */\nfunction mergeFilters(inputs: {\n options: {\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n };\n config: {\n filter?: string;\n };\n}): {\n filterFunction?: typeof catalogExtensionData.entityFilterFunction.T;\n filterExpression?: typeof catalogExtensionData.entityFilterExpression.T;\n} {\n const { options, config } = inputs;\n if (config.filter) {\n return { filterExpression: config.filter };\n } else if (typeof options.filter === 'string') {\n return { filterExpression: options.filter };\n } else if (typeof options.filter === 'function') {\n return { filterFunction: options.filter };\n }\n return {};\n}\n"],"names":[],"mappings":";;;;;;;AAwCO,MAAM,oBAAuB,GAAA;AAAA,EAClC,kBAAA,EAAoB,sBAA+B,EAAA,CAAE,IAAK,CAAA;AAAA,IACxD,EAAI,EAAA,8BAAA;AAAA,GACL,CAAA;AAAA,EACD,sBAAsB,sBAEpB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,kCAAkC,CAAA;AAAA,EACjD,sBAAA,EAAwB,sBAA+B,EAAA,CAAE,IAAK,CAAA;AAAA,IAC5D,EAAI,EAAA,kCAAA;AAAA,GACL,CAAA;AACH,EAAA;AAOO,SAAS,0BAGd,OAcC,EAAA;AACD,EAAA,MAAM,YACJ,GAAA,cAAA,IAAkB,OACd,GAAA,OAAA,CAAQ,YACP,GAAA,mBAAA;AAAA,IAAoB,CAAA,CAAA,KACnB,EAAE,MAAO,CAAA;AAAA,MACP,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,KAC7B,CAAA;AAAA,GACH,CAAA;AACN,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,aAAA;A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