@backstage/plugin-catalog-react 1.12.3 → 1.12.4-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 1.12.4-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ae9b6cb: Small internal fix to better work with recent `lodash` versions
8
+ - Updated dependencies
9
+ - @backstage/frontend-plugin-api@0.8.0-next.1
10
+ - @backstage/core-compat-api@0.3.0-next.1
11
+ - @backstage/catalog-client@1.6.7-next.0
12
+ - @backstage/core-components@0.14.11-next.0
13
+ - @backstage/catalog-model@1.6.0
14
+ - @backstage/core-plugin-api@1.9.3
15
+ - @backstage/errors@1.2.4
16
+ - @backstage/integration-react@1.1.30
17
+ - @backstage/types@1.1.1
18
+ - @backstage/version-bridge@1.0.8
19
+ - @backstage/plugin-catalog-common@1.0.26
20
+ - @backstage/plugin-permission-common@0.8.1
21
+ - @backstage/plugin-permission-react@0.4.25
22
+
23
+ ## 1.12.4-next.0
24
+
25
+ ### Patch Changes
26
+
27
+ - fec8b57: Updated exports to use the new type parameters for extensions and extension blueprints.
28
+ - 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).
29
+ - Updated dependencies
30
+ - @backstage/frontend-plugin-api@0.8.0-next.0
31
+ - @backstage/core-compat-api@0.2.9-next.0
32
+ - @backstage/catalog-client@1.6.6
33
+ - @backstage/catalog-model@1.6.0
34
+ - @backstage/core-components@0.14.10
35
+ - @backstage/core-plugin-api@1.9.3
36
+ - @backstage/errors@1.2.4
37
+ - @backstage/integration-react@1.1.30
38
+ - @backstage/types@1.1.1
39
+ - @backstage/version-bridge@1.0.8
40
+ - @backstage/plugin-catalog-common@1.0.26
41
+ - @backstage/plugin-permission-common@0.8.1
42
+ - @backstage/plugin-permission-react@0.4.25
43
+
3
44
  ## 1.12.3
4
45
 
5
46
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react__alpha",
3
- "version": "1.12.3",
3
+ "version": "1.12.4-next.1",
4
4
  "main": "../dist/alpha.esm.js",
5
5
  "module": "../dist/alpha.esm.js",
6
6
  "types": "../dist/alpha.d.ts"
@@ -1,17 +1,17 @@
1
1
  import { createExtensionBlueprint, coreExtensionData, ExtensionBoundary } from '@backstage/frontend-plugin-api';
2
- import { catalogExtensionData } from '../extensions.esm.js';
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
- catalogExtensionData.entityFilterFunction.optional(),
10
- catalogExtensionData.entityFilterExpression.optional()
9
+ entityFilterFunctionDataRef.optional(),
10
+ entityFilterExpressionDataRef.optional()
11
11
  ],
12
12
  dataRefs: {
13
- filterFunction: catalogExtensionData.entityFilterFunction,
14
- filterExpression: catalogExtensionData.entityFilterExpression
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 catalogExtensionData.entityFilterExpression(config.filter);
27
+ yield entityFilterExpressionDataRef(config.filter);
28
28
  } else if (typeof filter === "string") {
29
- yield catalogExtensionData.entityFilterExpression(filter);
29
+ yield entityFilterExpressionDataRef(filter);
30
30
  } else if (typeof filter === "function") {
31
- yield catalogExtensionData.entityFilterFunction(filter);
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 { catalogExtensionData } from '../extensions';\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 catalogExtensionData.entityFilterFunction.optional(),\n catalogExtensionData.entityFilterExpression.optional(),\n ],\n dataRefs: {\n filterFunction: catalogExtensionData.entityFilterFunction,\n filterExpression: catalogExtensionData.entityFilterExpression,\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 catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n },\n { node, config },\n ) {\n yield coreExtensionData.reactElement(ExtensionBoundary.lazy(node, loader));\n\n if (config.filter) {\n yield catalogExtensionData.entityFilterExpression(config.filter);\n } else if (typeof filter === 'string') {\n yield catalogExtensionData.entityFilterExpression(filter);\n } else if (typeof filter === 'function') {\n yield catalogExtensionData.entityFilterFunction(filter);\n }\n },\n});\n"],"names":[],"mappings":";;;AA2BO,MAAM,s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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 { catalogExtensionData } from '../extensions.esm.js';
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
- catalogExtensionData.entityContentTitle,
10
+ entityContentTitleDataRef,
11
11
  coreExtensionData.routeRef.optional(),
12
- catalogExtensionData.entityFilterFunction.optional(),
13
- catalogExtensionData.entityFilterExpression.optional()
12
+ entityFilterFunctionDataRef.optional(),
13
+ entityFilterExpressionDataRef.optional()
14
14
  ],
15
15
  dataRefs: {
16
- title: catalogExtensionData.entityContentTitle,
17
- filterFunction: catalogExtensionData.entityFilterFunction,
18
- filterExpression: catalogExtensionData.entityFilterExpression
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 catalogExtensionData.entityContentTitle(title);
38
+ yield entityContentTitleDataRef(title);
39
39
  if (routeRef) {
40
40
  yield coreExtensionData.routeRef(routeRef);
41
41
  }
42
42
  if (config.filter) {
43
- yield catalogExtensionData.entityFilterExpression(config.filter);
43
+ yield entityFilterExpressionDataRef(config.filter);
44
44
  } else if (typeof filter === "string") {
45
- yield catalogExtensionData.entityFilterExpression(filter);
45
+ yield entityFilterExpressionDataRef(filter);
46
46
  } else if (typeof filter === "function") {
47
- yield catalogExtensionData.entityFilterFunction(filter);
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 { catalogExtensionData } from '../extensions';\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 catalogExtensionData.entityContentTitle,\n coreExtensionData.routeRef.optional(),\n catalogExtensionData.entityFilterFunction.optional(),\n catalogExtensionData.entityFilterExpression.optional(),\n ],\n dataRefs: {\n title: catalogExtensionData.entityContentTitle,\n filterFunction: catalogExtensionData.entityFilterFunction,\n filterExpression: catalogExtensionData.entityFilterExpression,\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 catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.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 catalogExtensionData.entityContentTitle(title);\n\n if (routeRef) {\n yield coreExtensionData.routeRef(routeRef);\n }\n\n if (config.filter) {\n yield catalogExtensionData.entityFilterExpression(config.filter);\n } else if (typeof filter === 'string') {\n yield catalogExtensionData.entityFilterExpression(filter);\n } else if (typeof filter === 'function') {\n yield catalogExtens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AAM,kBAAkB,YAAa,CAAA,iBAAA,CAAkB,IAAK,CAAA,IAAA,EAAM,MAAM,CAAC,CAAA,CAAA;AAEzE,IAAM,MAAA,iBAAA,CAAkB,UAAU,IAAI,CAAA,CAAA;AAEtC,IAAM,MAAA,oBAAA,CAAqB,mBAAmB,KAAK,CAAA,CAAA;AAEnD,IAAA,IAAI,QAAU,EAAA;AACZ,MAAM,MAAA,iBAAA,CAAkB,SAAS,QAAQ,CAAA,CAAA;AAAA,KAC3C;AAEA,IAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,MAAM,MAAA,oBAAA,CAAqB,sBAAuB,CAAA,MAAA,CAAO,MAAM,CAAA,CAAA;AAAA,KACjE,MAAA,IAAW,OAAO,MAAA,KAAW,QAAU,EAAA;AACrC,MAAM,MAAA,oBAAA,CAAqB,uBAAuB,MAAM,CAAA,CAAA;AAAA,KAC1D,MAAA,IAAW,OAAO,MAAA,KAAW,UAAY,EAAA;AACvC,MAAM,MAAA,oBAAA,CAAqB,qBAAqB,MAAM,CAAA,CAAA;AAAA,KACxD;AAAA,GACF;AACF,CAAC;;;;"}
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,E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AAO,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<any> {\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,SAM0B,EAAA;AAC1B,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
+ {"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<any> {\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,SAQ0B,EAAA;AAC1B,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;;;;"}
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":[],"m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AAA,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, AnyExtensionInputMap, PortableSchema, ResolvedExtensionInputs, ExtensionDefinition } from '@backstage/frontend-plugin-api';
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
- loader: () => Promise<JSX.Element>;
32
- filter?: string | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
33
- }, _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", {
34
- optional: true;
35
- }> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
36
- optional: true;
37
- }>, {}, {
38
- filter: string | undefined;
39
- }, {
40
- filter?: string | undefined;
41
- }, {
42
- filterFunction: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {}>;
43
- filterExpression: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {}>;
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
- loader: () => Promise<JSX.Element>;
56
- defaultPath: string;
57
- defaultTitle: string;
58
- routeRef?: RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams> | undefined;
59
- filter?: string | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
60
- }, _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", {
61
- optional: true;
62
- }> | _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", {
63
- optional: true;
64
- }> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
65
- optional: true;
66
- }>, {}, {
67
- path: string | undefined;
68
- title: string | undefined;
69
- filter: string | undefined;
70
- }, {
71
- filter?: string | undefined;
72
- title?: string | undefined;
73
- path?: string | undefined;
74
- }, {
75
- title: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-content-title", {}>;
76
- filterFunction: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {}>;
77
- filterExpression: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {}>;
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
- * Utility type to expand type aliases into their equivalent type.
82
- * @ignore
83
- */
84
- type Expand<T> = T extends infer O ? {
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
- * A thin wrapper around the
90
- * {@link @backstage/plugin-permission-react#usePermission} hook which uses the
91
- * current entity in context to make an authorization request for the given
92
- * {@link @backstage/plugin-catalog-common#CatalogEntityPermission}.
93
- *
94
- * Note: this hook blocks the permission request until the entity has loaded in
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 const catalogExtensionData: {
165
- entityContentTitle: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-content-title", {}>;
166
- entityFilterFunction: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: Entity) => boolean, "catalog.entity-filter-function", {}>;
167
- entityFilterExpression: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {}>;
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, catalogExtensionData, catalogReactTranslationRef, convertLegacyEntityCardExtension, convertLegacyEntityContentExtension, createEntityCardExtension, createEntityContentExtension, isOwnerOf, useEntityPermission };
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
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -25,6 +25,7 @@ function defaultEntityPresentation(entityOrRef, context) {
25
25
  // leave it up to the presentation API to handle
26
26
  };
27
27
  }
28
+ const isString = (value) => Boolean(value) && typeof value === "string";
28
29
  function getParts(entityOrRef) {
29
30
  if (typeof entityOrRef === "string") {
30
31
  let colonI = entityOrRef.indexOf(":");
@@ -38,29 +39,23 @@ function getParts(entityOrRef) {
38
39
  return { kind, namespace, name };
39
40
  }
40
41
  if (typeof entityOrRef === "object" && entityOrRef !== null) {
41
- const kind = [get(entityOrRef, "kind")].find(
42
- (candidate) => candidate && typeof candidate === "string"
43
- );
42
+ const kind = [get(entityOrRef, "kind")].find(isString);
44
43
  const namespace = [
45
44
  get(entityOrRef, "metadata.namespace"),
46
45
  get(entityOrRef, "namespace")
47
- ].find((candidate) => candidate && typeof candidate === "string");
46
+ ].find(isString);
48
47
  const name = [
49
48
  get(entityOrRef, "metadata.name"),
50
49
  get(entityOrRef, "name")
51
- ].find((candidate) => candidate && typeof candidate === "string");
52
- const title = [get(entityOrRef, "metadata.title")].find(
53
- (candidate) => candidate && typeof candidate === "string"
54
- );
50
+ ].find(isString);
51
+ const title = [get(entityOrRef, "metadata.title")].find(isString);
55
52
  const description = [get(entityOrRef, "metadata.description")].find(
56
- (candidate) => candidate && typeof candidate === "string"
53
+ isString
57
54
  );
58
55
  const displayName = [get(entityOrRef, "spec.profile.displayName")].find(
59
- (candidate) => candidate && typeof candidate === "string"
60
- );
61
- const type = [get(entityOrRef, "spec.type")].find(
62
- (candidate) => candidate && typeof candidate === "string"
56
+ isString
63
57
  );
58
+ const type = [get(entityOrRef, "spec.type")].find(isString);
64
59
  return { kind, namespace, name, title, description, displayName, type };
65
60
  }
66
61
  return {};
@@ -1 +1 @@
1
- {"version":3,"file":"defaultEntityPresentation.esm.js","sources":["../../../src/apis/EntityPresentationApi/defaultEntityPresentation.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 */\n\nimport {\n CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport get from 'lodash/get';\nimport { EntityRefPresentationSnapshot } from './EntityPresentationApi';\n\n/**\n * This returns the default representation of an entity.\n *\n * @public\n * @param entityOrRef - Either an entity, or a ref to it.\n * @param context - Contextual information that may affect the presentation.\n */\nexport function defaultEntityPresentation(\n entityOrRef: Entity | CompoundEntityRef | string,\n context?: {\n defaultKind?: string;\n defaultNamespace?: string;\n },\n): EntityRefPresentationSnapshot {\n // NOTE(freben): This code may look convoluted, but it tries its very best to\n // be defensive and handling any type of malformed input and still producing\n // some form of result without crashing.\n const { kind, namespace, name, title, description, displayName, type } =\n getParts(entityOrRef);\n\n const entityRef: string = stringifyEntityRef({\n kind: kind || 'unknown',\n namespace: namespace || DEFAULT_NAMESPACE,\n name: name || 'unknown',\n });\n\n const shortRef = getShortRef({ kind, namespace, name, context });\n\n const primary = [displayName, title, shortRef].find(\n candidate => candidate && typeof candidate === 'string',\n )!;\n\n const secondary = [\n primary !== entityRef ? entityRef : undefined,\n type,\n description,\n ]\n .filter(candidate => candidate && typeof candidate === 'string')\n .join(' | ');\n\n return {\n entityRef,\n primaryTitle: primary,\n secondaryTitle: secondary || undefined,\n Icon: undefined, // leave it up to the presentation API to handle\n };\n}\n\n// Try to extract display-worthy parts of an entity or ref as best we can, without throwing\nfunction getParts(entityOrRef: Entity | CompoundEntityRef | string): {\n kind?: string;\n namespace?: string;\n name?: string;\n title?: string;\n description?: string;\n displayName?: string;\n type?: string;\n} {\n if (typeof entityOrRef === 'string') {\n let colonI = entityOrRef.indexOf(':');\n const slashI = entityOrRef.indexOf('/');\n\n // If the / is ahead of the :, treat the rest as the name\n if (slashI !== -1 && slashI < colonI) {\n colonI = -1;\n }\n\n const kind = colonI === -1 ? undefined : entityOrRef.slice(0, colonI);\n const namespace =\n slashI === -1 ? undefined : entityOrRef.slice(colonI + 1, slashI);\n const name = entityOrRef.slice(Math.max(colonI + 1, slashI + 1));\n\n return { kind, namespace, name };\n }\n\n if (typeof entityOrRef === 'object' && entityOrRef !== null) {\n const kind = [get(entityOrRef, 'kind')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const namespace = [\n get(entityOrRef, 'metadata.namespace'),\n get(entityOrRef, 'namespace'),\n ].find(candidate => candidate && typeof candidate === 'string');\n\n const name = [\n get(entityOrRef, 'metadata.name'),\n get(entityOrRef, 'name'),\n ].find(candidate => candidate && typeof candidate === 'string');\n\n const title = [get(entityOrRef, 'metadata.title')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const description = [get(entityOrRef, 'metadata.description')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const displayName = [get(entityOrRef, 'spec.profile.displayName')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const type = [get(entityOrRef, 'spec.type')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n return { kind, namespace, name, title, description, displayName, type };\n }\n\n return {};\n}\n\nfunction getShortRef(options: {\n kind?: string;\n namespace?: string;\n name?: string;\n context?: { defaultKind?: string; defaultNamespace?: string };\n}): string {\n const kind = options.kind?.toLocaleLowerCase('en-US') || 'unknown';\n const namespace = options.namespace || DEFAULT_NAMESPACE;\n const name = options.name || 'unknown';\n const defaultKindLower =\n options.context?.defaultKind?.toLocaleLowerCase('en-US');\n const defaultNamespaceLower =\n options.context?.defaultNamespace?.toLocaleLowerCase('en-US');\n\n let result = name;\n\n if (\n (defaultNamespaceLower &&\n namespace.toLocaleLowerCase('en-US') !== defaultNamespaceLower) ||\n namespace !== DEFAULT_NAMESPACE\n ) {\n result = `${namespace}/${result}`;\n }\n\n if (\n defaultKindLower &&\n kind.toLocaleLowerCase('en-US') !== defaultKindLower\n ) {\n result = `${kind}:${result}`;\n }\n\n return result;\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EAAA,MAAM,qBACJ,GAAA,OAAA,CAAQ,OAAS,EAAA,gBAAA,EAAkB,kBAAkB,OAAO,CAAA,CAAA;AAE9D,EAAA,IAAI,MAAS,GAAA,IAAA,CAAA;AAEb,EAAA,IACG,yBACC,SAAU,CAAA,iBAAA,CAAkB,OAAO,CAAM,KAAA,qBAAA,IAC3C,cAAc,iBACd,EAAA;AACA,IAAS,MAAA,GAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAA;AAAA,GACjC;AAEA,EAAA,IACE,gBACA,IAAA,IAAA,CAAK,iBAAkB,CAAA,OAAO,MAAM,gBACpC,EAAA;AACA,IAAS,MAAA,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAA;AAAA,GAC5B;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"defaultEntityPresentation.esm.js","sources":["../../../src/apis/EntityPresentationApi/defaultEntityPresentation.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 */\n\nimport {\n CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport get from 'lodash/get';\nimport { EntityRefPresentationSnapshot } from './EntityPresentationApi';\n\n/**\n * This returns the default representation of an entity.\n *\n * @public\n * @param entityOrRef - Either an entity, or a ref to it.\n * @param context - Contextual information that may affect the presentation.\n */\nexport function defaultEntityPresentation(\n entityOrRef: Entity | CompoundEntityRef | string,\n context?: {\n defaultKind?: string;\n defaultNamespace?: string;\n },\n): EntityRefPresentationSnapshot {\n // NOTE(freben): This code may look convoluted, but it tries its very best to\n // be defensive and handling any type of malformed input and still producing\n // some form of result without crashing.\n const { kind, namespace, name, title, description, displayName, type } =\n getParts(entityOrRef);\n\n const entityRef: string = stringifyEntityRef({\n kind: kind || 'unknown',\n namespace: namespace || DEFAULT_NAMESPACE,\n name: name || 'unknown',\n });\n\n const shortRef = getShortRef({ kind, namespace, name, context });\n\n const primary = [displayName, title, shortRef].find(\n candidate => candidate && typeof candidate === 'string',\n )!;\n\n const secondary = [\n primary !== entityRef ? entityRef : undefined,\n type,\n description,\n ]\n .filter(candidate => candidate && typeof candidate === 'string')\n .join(' | ');\n\n return {\n entityRef,\n primaryTitle: primary,\n secondaryTitle: secondary || undefined,\n Icon: undefined, // leave it up to the presentation API to handle\n };\n}\n\nconst isString = (value: unknown): value is string =>\n Boolean(value) && typeof value === 'string';\n\n// Try to extract display-worthy parts of an entity or ref as best we can, without throwing\nfunction getParts(entityOrRef: Entity | CompoundEntityRef | string): {\n kind?: string;\n namespace?: string;\n name?: string;\n title?: string;\n description?: string;\n displayName?: string;\n type?: string;\n} {\n if (typeof entityOrRef === 'string') {\n let colonI = entityOrRef.indexOf(':');\n const slashI = entityOrRef.indexOf('/');\n\n // If the / is ahead of the :, treat the rest as the name\n if (slashI !== -1 && slashI < colonI) {\n colonI = -1;\n }\n\n const kind = colonI === -1 ? undefined : entityOrRef.slice(0, colonI);\n const namespace =\n slashI === -1 ? undefined : entityOrRef.slice(colonI + 1, slashI);\n const name = entityOrRef.slice(Math.max(colonI + 1, slashI + 1));\n\n return { kind, namespace, name };\n }\n\n if (typeof entityOrRef === 'object' && entityOrRef !== null) {\n const kind = [get(entityOrRef, 'kind')].find(isString);\n\n const namespace = [\n get(entityOrRef, 'metadata.namespace'),\n get(entityOrRef, 'namespace'),\n ].find(isString);\n\n const name = [\n get(entityOrRef, 'metadata.name'),\n get(entityOrRef, 'name'),\n ].find(isString);\n\n const title = [get(entityOrRef, 'metadata.title')].find(isString);\n\n const description = [get(entityOrRef, 'metadata.description')].find(\n isString,\n );\n\n const displayName = [get(entityOrRef, 'spec.profile.displayName')].find(\n isString,\n );\n\n const type = [get(entityOrRef, 'spec.type')].find(isString);\n\n return { kind, namespace, name, title, description, displayName, type };\n }\n\n return {};\n}\n\nfunction getShortRef(options: {\n kind?: string;\n namespace?: string;\n name?: string;\n context?: { defaultKind?: string; defaultNamespace?: string };\n}): string {\n const kind = options.kind?.toLocaleLowerCase('en-US') || 'unknown';\n const namespace = options.namespace || DEFAULT_NAMESPACE;\n const name = options.name || 'unknown';\n const defaultKindLower =\n options.context?.defaultKind?.toLocaleLowerCase('en-US');\n const defaultNamespaceLower =\n options.context?.defaultNamespace?.toLocaleLowerCase('en-US');\n\n let result = name;\n\n if (\n (defaultNamespaceLower &&\n namespace.toLocaleLowerCase('en-US') !== defaultNamespaceLower) ||\n namespace !== DEFAULT_NAMESPACE\n ) {\n result = `${namespace}/${result}`;\n }\n\n if (\n defaultKindLower &&\n kind.toLocaleLowerCase('en-US') !== defaultKindLower\n ) {\n result = `${kind}:${result}`;\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAgCgB,SAAA,yBAAA,CACd,aACA,OAI+B,EAAA;AAI/B,EAAM,MAAA,EAAE,IAAM,EAAA,SAAA,EAAW,IAAM,EAAA,KAAA,EAAO,aAAa,WAAa,EAAA,IAAA,EAC9D,GAAA,QAAA,CAAS,WAAW,CAAA,CAAA;AAEtB,EAAA,MAAM,YAAoB,kBAAmB,CAAA;AAAA,IAC3C,MAAM,IAAQ,IAAA,SAAA;AAAA,IACd,WAAW,SAAa,IAAA,iBAAA;AAAA,IACxB,MAAM,IAAQ,IAAA,SAAA;AAAA,GACf,CAAA,CAAA;AAED,EAAA,MAAM,WAAW,WAAY,CAAA,EAAE,MAAM,SAAW,EAAA,IAAA,EAAM,SAAS,CAAA,CAAA;AAE/D,EAAA,MAAM,OAAU,GAAA,CAAC,WAAa,EAAA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AA,EAAa,aAAa,IAAK,EAAA,CAAA;AAAA,GACxE;AAEA,EAAA,OAAO,EAAC,CAAA;AACV,CAAA;AAEA,SAAS,YAAY,OAKV,EAAA;AACT,EAAA,MAAM,IAAO,GAAA,OAAA,CAAQ,IAAM,EAAA,iBAAA,CAAkB,OAAO,CAAK,IAAA,SAAA,CAAA;AACzD,EAAM,MAAA,SAAA,GAAY,QAAQ,SAAa,IAAA,iBAAA,CAAA;AACvC,EAAM,MAAA,IAAA,GAAO,QAAQ,IAAQ,IAAA,SAAA,CAAA;AAC7B,EAAA,MAAM,gBACJ,GAAA,OAAA,CAAQ,OAAS,EAAA,WAAA,EAAa,kBAAkB,OAAO,CAAA,CAAA;AACzD,EAAA,MAAM,qBACJ,GAAA,OAAA,CAAQ,OAAS,EAAA,gBAAA,EAAkB,kBAAkB,OAAO,CAAA,CAAA;AAE9D,EAAA,IAAI,MAAS,GAAA,IAAA,CAAA;AAEb,EAAA,IACG,yBACC,SAAU,CAAA,iBAAA,CAAkB,OAAO,CAAM,KAAA,qBAAA,IAC3C,cAAc,iBACd,EAAA;AACA,IAAS,MAAA,GAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAA;AAAA,GACjC;AAEA,EAAA,IACE,gBACA,IAAA,IAAA,CAAK,iBAAkB,CAAA,OAAO,MAAM,gBACpC,EAAA;AACA,IAAS,MAAA,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAA;AAAA,GAC5B;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -4,6 +4,7 @@ import { catalogApiRef } from '../../api.esm.js';
4
4
  import { useState } from 'react';
5
5
  import get from 'lodash/get';
6
6
 
7
+ const maybeString = (value) => typeof value === "string" ? value : void 0;
7
8
  function useFacetsEntities({ enabled }) {
8
9
  const catalogApi = useApi(catalogApiRef);
9
10
  const [facetsPromise] = useState(async () => {
@@ -14,14 +15,14 @@ function useFacetsEntities({ enabled }) {
14
15
  const facetsResponse = await catalogApi.getEntityFacets({
15
16
  facets: [facet]
16
17
  });
17
- const entityRefs = facetsResponse.facets[facet].map((e) => e.value);
18
+ const entityRefs = facetsResponse.facets[facet]?.map((e) => e.value) ?? [];
18
19
  return catalogApi.getEntitiesByRefs({ entityRefs }).then(
19
20
  (resp) => resp.items.filter((entity) => entity !== void 0).map((entity) => entity).sort(
20
21
  (a, b) => (a.metadata.namespace || "").localeCompare(
21
22
  b.metadata.namespace || "",
22
23
  "en-US"
23
- ) || (get(a, "spec.profile.displayName") || a.metadata.title || a.metadata.name).localeCompare(
24
- get(b, "spec.profile.displayName") || b.metadata.title || b.metadata.name,
24
+ ) || (maybeString(get(a, "spec.profile.displayName")) || a.metadata.title || a.metadata.name).localeCompare(
25
+ maybeString(get(b, "spec.profile.displayName")) || b.metadata.title || b.metadata.name,
25
26
  "en-US"
26
27
  ) || a.kind.localeCompare(b.kind, "en-US")
27
28
  )
@@ -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].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,eAAe,MAAO,CAAA,KAAK,EAAE,GAAI,CAAA,CAAA,CAAA,KAAK,EAAE,KAAK,CAAA,CAAA;AAEhE,IAAA,OAAO,UACJ,CAAA,iBAAA,CAAkB,EAAE,UAAA,EAAY,CAChC,CAAA,IAAA;AAAA,MAAK,CAAA,IAAA,KAC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B,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;;;;"}
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\nconst maybeString = (value: unknown): string | undefined =>\n typeof value === 'string' ? value : undefined;\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 maybeString(get(a, 'spec.profile.displayName')) ||\n a.metadata.title ||\n a.metadata.name\n ).localeCompare(\n maybeString(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":";;;;;;AAoCA,MAAM,cAAc,CAAC,KAAA,KACnB,OAAO,KAAA,KAAU,WAAW,KAAQ,GAAA,KAAA,CAAA,CAAA;AAStB,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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A,OAAO,EAAC,CAAA;AACV,CAAA;AAEA,SAAS,YAAA,CAAa,MAAc,MAAgB,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",
3
+ "version": "1.12.4-next.1",
4
4
  "description": "A frontend library that helps other Backstage plugins interact with the catalog",
5
5
  "backstage": {
6
6
  "role": "web-library",
@@ -56,13 +56,13 @@
56
56
  "test": "backstage-cli package test"
57
57
  },
58
58
  "dependencies": {
59
- "@backstage/catalog-client": "^1.6.6",
59
+ "@backstage/catalog-client": "^1.6.7-next.0",
60
60
  "@backstage/catalog-model": "^1.6.0",
61
- "@backstage/core-compat-api": "^0.2.8",
62
- "@backstage/core-components": "^0.14.10",
61
+ "@backstage/core-compat-api": "^0.3.0-next.1",
62
+ "@backstage/core-components": "^0.14.11-next.0",
63
63
  "@backstage/core-plugin-api": "^1.9.3",
64
64
  "@backstage/errors": "^1.2.4",
65
- "@backstage/frontend-plugin-api": "^0.7.0",
65
+ "@backstage/frontend-plugin-api": "^0.8.0-next.1",
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.1",
87
87
  "@backstage/core-app-api": "^1.14.2",
88
- "@backstage/frontend-test-utils": "^0.1.12",
88
+ "@backstage/frontend-test-utils": "^0.2.0-next.1",
89
89
  "@backstage/plugin-catalog-common": "^1.0.26",
90
90
  "@backstage/plugin-scaffolder-common": "^1.5.5",
91
- "@backstage/test-utils": "^1.5.10",
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,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