@backstage/plugin-techdocs-react 1.3.3-next.0 → 1.3.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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # @backstage/plugin-techdocs-react
2
2
 
3
+ ## 1.3.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/core-components@0.18.2-next.0
9
+ - @backstage/frontend-plugin-api@0.12.1-next.0
10
+ - @backstage/catalog-model@1.7.5
11
+ - @backstage/config@1.3.3
12
+ - @backstage/core-plugin-api@1.11.0
13
+ - @backstage/version-bridge@1.0.11
14
+ - @backstage/plugin-techdocs-common@0.1.1
15
+
16
+ ## 1.3.3
17
+
18
+ ### Patch Changes
19
+
20
+ - a0b604c: Update to documentation regarding TechDocs redirects.
21
+ - Updated dependencies
22
+ - @backstage/frontend-plugin-api@0.12.0
23
+ - @backstage/core-plugin-api@1.11.0
24
+ - @backstage/core-components@0.18.0
25
+
3
26
  ## 1.3.3-next.0
4
27
 
5
28
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.esm.js","sources":["../src/helpers.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n CompoundEntityRef,\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport {\n TECHDOCS_EXTERNAL_ANNOTATION,\n TECHDOCS_EXTERNAL_PATH_ANNOTATION,\n} from '@backstage/plugin-techdocs-common';\nimport { RouteFunc } from '@backstage/core-plugin-api';\n\n/**\n * Lower-case entity triplets by default, but allow override.\n *\n * @public\n */\nexport function toLowercaseEntityRefMaybe(\n entityRef: CompoundEntityRef,\n config: Config,\n): CompoundEntityRef {\n if (config.getOptionalBoolean('techdocs.legacyUseCaseSensitiveTripletPaths'))\n return entityRef;\n\n entityRef.kind = entityRef.kind.toLocaleLowerCase();\n entityRef.name = entityRef.name.toLocaleLowerCase();\n entityRef.namespace = entityRef.namespace.toLocaleLowerCase();\n\n return entityRef;\n}\n\n/**\n * Get the entity path annotation from the given entity and ensure it starts with a slash.\n *\n * @public\n */\nexport function getEntityRootTechDocsPath(entity: Entity): string {\n let path = entity.metadata.annotations?.[TECHDOCS_EXTERNAL_PATH_ANNOTATION];\n if (!path) {\n return '';\n }\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n return path;\n}\n\n/**\n * Build the TechDocs URL for the given entity. This helper should be used anywhere there\n * is a link to an entities TechDocs.\n *\n * @public\n */\nexport const buildTechDocsURL = (\n entity: Entity,\n routeFunc:\n | RouteFunc<{\n namespace: string;\n kind: string;\n name: string;\n }>\n | undefined,\n) => {\n if (!routeFunc) {\n return undefined;\n }\n\n let { namespace, kind, name } = getCompoundEntityRef(entity);\n\n if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {\n try {\n const techdocsRef = parseEntityRef(\n entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],\n );\n namespace = techdocsRef.namespace;\n kind = techdocsRef.kind;\n name = techdocsRef.name;\n } catch {\n // not a fan of this but we don't care if the parseEntityRef fails\n }\n }\n\n const url = routeFunc({\n namespace,\n kind,\n name,\n });\n\n // Add on the external entity path to the url if one exists. This allows deep linking into another\n // entities TechDocs.\n const path = getEntityRootTechDocsPath(entity);\n\n return `${url}${path}`;\n};\n"],"names":[],"mappings":";;;AAkCO,SAAS,yBAAA,CACd,WACA,MAAA,EACmB;AACnB,EAAA,IAA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AAA,EACF;AAEA,EAAA,MAAM,MAAM,SAAA,CAAU;AAAA,IACpB,SAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACD,CAAA;AAID,EAAA,MAAM,IAAA,GAAO,0BAA0B,MAAM,CAAA;AAE7C,EAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AACtB;;;;"}
1
+ {"version":3,"file":"helpers.esm.js","sources":["../src/helpers.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n CompoundEntityRef,\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport {\n TECHDOCS_EXTERNAL_ANNOTATION,\n TECHDOCS_EXTERNAL_PATH_ANNOTATION,\n} from '@backstage/plugin-techdocs-common';\nimport { RouteFunc } from '@backstage/core-plugin-api';\n\n/**\n * Lower-case entity triplets by default, but allow override.\n *\n * @public\n */\nexport function toLowercaseEntityRefMaybe(\n entityRef: CompoundEntityRef,\n config: Config,\n): CompoundEntityRef {\n if (config.getOptionalBoolean('techdocs.legacyUseCaseSensitiveTripletPaths'))\n return entityRef;\n\n entityRef.kind = entityRef.kind.toLocaleLowerCase();\n entityRef.name = entityRef.name.toLocaleLowerCase();\n entityRef.namespace = entityRef.namespace.toLocaleLowerCase();\n\n return entityRef;\n}\n\n/**\n * Get the entity path annotation from the given entity and ensure it starts with a slash.\n *\n * @public\n */\nexport function getEntityRootTechDocsPath(entity: Entity): string {\n let path = entity.metadata.annotations?.[TECHDOCS_EXTERNAL_PATH_ANNOTATION];\n if (!path) {\n return '';\n }\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n return path;\n}\n\n/**\n * Build the TechDocs URL for the given entity. This helper should be used anywhere there\n * is a link to an entity's TechDocs.\n *\n * @public\n */\nexport const buildTechDocsURL = (\n entity: Entity,\n routeFunc:\n | RouteFunc<{\n namespace: string;\n kind: string;\n name: string;\n }>\n | undefined,\n) => {\n if (!routeFunc) {\n return undefined;\n }\n\n let { namespace, kind, name } = getCompoundEntityRef(entity);\n\n if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {\n try {\n const techdocsRef = parseEntityRef(\n entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],\n );\n namespace = techdocsRef.namespace;\n kind = techdocsRef.kind;\n name = techdocsRef.name;\n } catch {\n // not a fan of this but we don't care if the parseEntityRef fails\n }\n }\n\n const url = routeFunc({\n namespace,\n kind,\n name,\n });\n\n // Add on the external entity path to the url if one exists. This allows deep linking into another\n // entity's TechDocs.\n const path = getEntityRootTechDocsPath(entity);\n\n return `${url}${path}`;\n};\n"],"names":[],"mappings":";;;AAkCO,SAAS,yBAAA,CACd,WACA,MAAA,EACmB;AACnB,EAAA,IAAI,MAAA,CAAO,mBAAmB,6CAA6C,CAAA;AACzE,IAAA,OAAO,SAAA;AAET,EAAA,SAAA,CAAU,IAAA,GAAO,SAAA,CAAU,IAAA,CAAK,iBAAA,EAAkB;AAClD,EAAA,SAAA,CAAU,IAAA,GAAO,SAAA,CAAU,IAAA,CAAK,iBAAA,EAAkB;AAClD,EAAA,SAAA,CAAU,SAAA,GAAY,SAAA,CAAU,SAAA,CAAU,iBAAA,EAAkB;AAE5D,EAAA,OAAO,SAAA;AACT;AAOO,SAAS,0BAA0B,MAAA,EAAwB;AAChE,EAAA,IAAI,IAAA,GAAO,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,iCAAiC,CAAA;AAC1E,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,EAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AACzB,IAAA,IAAA,GAAO,IAAI,IAAI,CAAA,CAAA;AAAA,EACjB;AACA,EAAA,OAAO,IAAA;AACT;AAQO,MAAM,gBAAA,GAAmB,CAC9B,MAAA,EACA,SAAA,KAOG;AACH,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,EAAE,SAAA,EAAW,IAAA,EAAM,IAAA,EAAK,GAAI,qBAAqB,MAAM,CAAA;AAE3D,EAAA,IAAI,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,4BAA4B,CAAA,EAAG;AAC/D,IAAA,IAAI;AACF,MAAA,MAAM,WAAA,GAAc,cAAA;AAAA,QAClB,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,4BAA4B;AAAA,OAC5D;AACA,MAAA,SAAA,GAAY,WAAA,CAAY,SAAA;AACxB,MAAA,IAAA,GAAO,WAAA,CAAY,IAAA;AACnB,MAAA,IAAA,GAAO,WAAA,CAAY,IAAA;AAAA,IACrB,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAEA,EAAA,MAAM,MAAM,SAAA,CAAU;AAAA,IACpB,SAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACD,CAAA;AAID,EAAA,MAAM,IAAA,GAAO,0BAA0B,MAAM,CAAA;AAE7C,EAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AACtB;;;;"}
package/dist/index.d.ts CHANGED
@@ -276,7 +276,7 @@ declare function toLowercaseEntityRefMaybe(entityRef: CompoundEntityRef, config:
276
276
  declare function getEntityRootTechDocsPath(entity: Entity): string;
277
277
  /**
278
278
  * Build the TechDocs URL for the given entity. This helper should be used anywhere there
279
- * is a link to an entities TechDocs.
279
+ * is a link to an entity's TechDocs.
280
280
  *
281
281
  * @public
282
282
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-techdocs-react",
3
- "version": "1.3.3-next.0",
3
+ "version": "1.3.4-next.0",
4
4
  "description": "Shared frontend utilities for TechDocs and Addons",
5
5
  "backstage": {
6
6
  "role": "web-library",
@@ -68,9 +68,9 @@
68
68
  "dependencies": {
69
69
  "@backstage/catalog-model": "1.7.5",
70
70
  "@backstage/config": "1.3.3",
71
- "@backstage/core-components": "0.17.6-next.0",
72
- "@backstage/core-plugin-api": "1.10.9",
73
- "@backstage/frontend-plugin-api": "0.11.1-next.0",
71
+ "@backstage/core-components": "0.18.2-next.0",
72
+ "@backstage/core-plugin-api": "1.11.0",
73
+ "@backstage/frontend-plugin-api": "0.12.1-next.0",
74
74
  "@backstage/plugin-techdocs-common": "0.1.1",
75
75
  "@backstage/version-bridge": "1.0.11",
76
76
  "@material-ui/core": "^4.12.2",
@@ -81,7 +81,7 @@
81
81
  "react-use": "^17.2.4"
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/cli": "0.34.2-next.1",
84
+ "@backstage/cli": "0.34.4-next.0",
85
85
  "@backstage/test-utils": "1.7.11",
86
86
  "@backstage/theme": "0.6.8",
87
87
  "@testing-library/jest-dom": "^6.0.0",