@backstage/core-compat-api 0.5.4-next.0 → 0.5.5-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,26 @@
1
1
  # @backstage/core-compat-api
2
2
 
3
+ ## 0.5.5-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/frontend-plugin-api@0.13.2-next.0
9
+ - @backstage/core-plugin-api@1.12.1-next.0
10
+ - @backstage/plugin-catalog-react@1.21.4-next.0
11
+ - @backstage/types@1.2.2
12
+ - @backstage/version-bridge@1.0.11
13
+
14
+ ## 0.5.4
15
+
16
+ ### Patch Changes
17
+
18
+ - 4d03f08: Internal refactor of route reference implementations with minor updates to the `toString` implementations.
19
+ - Updated dependencies
20
+ - @backstage/frontend-plugin-api@0.13.0
21
+ - @backstage/plugin-catalog-react@1.21.3
22
+ - @backstage/core-plugin-api@1.12.0
23
+
3
24
  ## 0.5.4-next.0
4
25
 
5
26
  ### Patch Changes
@@ -1,8 +1,8 @@
1
1
  import { routeRefType } from './core-plugin-api/src/routing/types.esm.js';
2
2
  import { createRouteRef, createSubRouteRef, createExternalRouteRef } from '@backstage/frontend-plugin-api';
3
- import { toInternalRouteRef } from './frontend-plugin-api/src/routing/RouteRef.esm.js';
4
- import { toInternalSubRouteRef } from './frontend-plugin-api/src/routing/SubRouteRef.esm.js';
5
- import { toInternalExternalRouteRef } from './frontend-plugin-api/src/routing/ExternalRouteRef.esm.js';
3
+ import { OpaqueRouteRef } from './frontend-internal/src/routing/OpaqueRouteRef.esm.js';
4
+ import { OpaqueSubRouteRef } from './frontend-internal/src/routing/OpaqueSubRouteRef.esm.js';
5
+ import { OpaqueExternalRouteRef } from './frontend-internal/src/routing/OpaqueExternalRouteRef.esm.js';
6
6
 
7
7
  function convertLegacyRouteRefs(refs) {
8
8
  return Object.fromEntries(
@@ -27,7 +27,7 @@ function convertLegacyRouteRef(ref) {
27
27
  }
28
28
  function convertNewToOld(ref) {
29
29
  if (ref.$$type === "@backstage/RouteRef") {
30
- const newRef = toInternalRouteRef(ref);
30
+ const newRef = OpaqueRouteRef.toInternal(ref);
31
31
  return Object.assign(ref, {
32
32
  [routeRefType]: "absolute",
33
33
  params: newRef.getParams(),
@@ -35,7 +35,7 @@ function convertNewToOld(ref) {
35
35
  });
36
36
  }
37
37
  if (ref.$$type === "@backstage/SubRouteRef") {
38
- const newRef = toInternalSubRouteRef(ref);
38
+ const newRef = OpaqueSubRouteRef.toInternal(ref);
39
39
  return Object.assign(ref, {
40
40
  [routeRefType]: "sub",
41
41
  parent: convertLegacyRouteRef(newRef.getParent()),
@@ -43,7 +43,7 @@ function convertNewToOld(ref) {
43
43
  });
44
44
  }
45
45
  if (ref.$$type === "@backstage/ExternalRouteRef") {
46
- const newRef = toInternalExternalRouteRef(ref);
46
+ const newRef = OpaqueExternalRouteRef.toInternal(ref);
47
47
  return Object.assign(ref, {
48
48
  [routeRefType]: "external",
49
49
  optional: true,
@@ -59,7 +59,7 @@ function convertOldToNew(ref, type) {
59
59
  if (type === "absolute") {
60
60
  const legacyRef = ref;
61
61
  const legacyRefStr = String(legacyRef);
62
- const newRef = toInternalRouteRef(
62
+ const newRef = OpaqueRouteRef.toInternal(
63
63
  createRouteRef({
64
64
  params: legacyRef.params
65
65
  })
@@ -85,7 +85,7 @@ function convertOldToNew(ref, type) {
85
85
  if (type === "sub") {
86
86
  const legacyRef = ref;
87
87
  const legacyRefStr = String(legacyRef);
88
- const newRef = toInternalSubRouteRef(
88
+ const newRef = OpaqueSubRouteRef.toInternal(
89
89
  createSubRouteRef({
90
90
  path: legacyRef.path,
91
91
  parent: convertLegacyRouteRef(legacyRef.parent)
@@ -112,7 +112,7 @@ function convertOldToNew(ref, type) {
112
112
  if (type === "external") {
113
113
  const legacyRef = ref;
114
114
  const legacyRefStr = String(legacyRef);
115
- const newRef = toInternalExternalRouteRef(
115
+ const newRef = OpaqueExternalRouteRef.toInternal(
116
116
  createExternalRouteRef({
117
117
  params: legacyRef.params,
118
118
  defaultTarget: "getDefaultTarget" in legacyRef ? legacyRef.getDefaultTarget() : void 0
@@ -1 +1 @@
1
- {"version":3,"file":"convertLegacyRouteRef.esm.js","sources":["../src/convertLegacyRouteRef.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 RouteRef as LegacyRouteRef,\n SubRouteRef as LegacySubRouteRef,\n ExternalRouteRef as LegacyExternalRouteRef,\n AnyRouteRefParams,\n} from '@backstage/core-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routeRefType } from '../../core-plugin-api/src/routing/types';\n\nimport {\n RouteRef,\n SubRouteRef,\n ExternalRouteRef,\n createRouteRef,\n createSubRouteRef,\n createExternalRouteRef,\n} from '@backstage/frontend-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalRouteRef } from '../../frontend-plugin-api/src/routing/RouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalSubRouteRef } from '../../frontend-plugin-api/src/routing/SubRouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExternalRouteRef } from '../../frontend-plugin-api/src/routing/ExternalRouteRef';\n\n/**\n * Converts a legacy route ref type to the new system.\n *\n * @public\n */\nexport type ToNewRouteRef<\n T extends LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef,\n> = T extends LegacyRouteRef<infer IParams>\n ? RouteRef<IParams>\n : T extends LegacySubRouteRef<infer IParams>\n ? SubRouteRef<IParams>\n : T extends LegacyExternalRouteRef<infer IParams>\n ? ExternalRouteRef<IParams>\n : never;\n\n/**\n * Converts a collection of legacy route refs to the new system.\n * This is particularly useful when defining plugin `routes` and `externalRoutes`.\n *\n * @public\n */\nexport function convertLegacyRouteRefs<\n TRefs extends {\n [name in string]:\n | LegacyRouteRef\n | LegacySubRouteRef\n | LegacyExternalRouteRef;\n },\n>(refs: TRefs): { [KName in keyof TRefs]: ToNewRouteRef<TRefs[KName]> } {\n return Object.fromEntries(\n Object.entries(refs).map(([name, ref]) => [\n name,\n convertLegacyRouteRef(ref as LegacyRouteRef),\n ]),\n ) as { [KName in keyof TRefs]: ToNewRouteRef<TRefs[KName]> };\n}\n\n/**\n * A temporary helper to convert a legacy route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacyRouteRef<TParams>,\n): RouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy sub route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createSubRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacySubRouteRef<TParams>,\n): SubRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy external route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacyExternalRouteRef<TParams>,\n): ExternalRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a new route ref to the legacy system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: RouteRef<TParams>,\n): LegacyRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a new sub route ref to the legacy system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createSubRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: SubRouteRef<TParams>,\n): LegacySubRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a new external route ref to the legacy system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: ExternalRouteRef<TParams>,\n): LegacyExternalRouteRef<TParams, true>;\nexport function convertLegacyRouteRef(\n ref:\n | LegacyRouteRef\n | LegacySubRouteRef\n | LegacyExternalRouteRef\n | RouteRef\n | SubRouteRef\n | ExternalRouteRef,\n):\n | RouteRef\n | SubRouteRef\n | ExternalRouteRef\n | LegacyRouteRef\n | LegacySubRouteRef\n | LegacyExternalRouteRef {\n const isNew = '$$type' in ref;\n const oldType = (ref as unknown as { [routeRefType]: unknown })[routeRefType];\n\n // Ref has already been converted\n if (isNew && oldType) {\n return ref as any;\n }\n\n if (isNew) {\n return convertNewToOld(\n ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef,\n );\n }\n\n return convertOldToNew(ref, oldType);\n}\n\nfunction convertNewToOld(\n ref: RouteRef | SubRouteRef | ExternalRouteRef,\n): LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef {\n if (ref.$$type === '@backstage/RouteRef') {\n const newRef = toInternalRouteRef(ref);\n return Object.assign(ref, {\n [routeRefType]: 'absolute',\n params: newRef.getParams(),\n title: newRef.getDescription(),\n } as Omit<LegacyRouteRef, '$$routeRefType'>) as unknown as LegacyRouteRef;\n }\n if (ref.$$type === '@backstage/SubRouteRef') {\n const newRef = toInternalSubRouteRef(ref);\n return Object.assign(ref, {\n [routeRefType]: 'sub',\n parent: convertLegacyRouteRef(newRef.getParent()),\n params: newRef.getParams(),\n } as Omit<LegacySubRouteRef, '$$routeRefType' | 'path'>) as unknown as LegacySubRouteRef;\n }\n if (ref.$$type === '@backstage/ExternalRouteRef') {\n const newRef = toInternalExternalRouteRef(ref);\n return Object.assign(ref, {\n [routeRefType]: 'external',\n optional: true,\n params: newRef.getParams(),\n defaultTarget: newRef.getDefaultTarget(),\n } as Omit<LegacyExternalRouteRef, '$$routeRefType' | 'optional'>) as unknown as LegacyExternalRouteRef;\n }\n\n throw new Error(\n `Failed to convert route ref, unknown type '${(ref as any).$$type}'`,\n );\n}\n\nfunction convertOldToNew(\n ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef,\n type: unknown,\n): RouteRef | SubRouteRef | ExternalRouteRef {\n if (type === 'absolute') {\n const legacyRef = ref as LegacyRouteRef;\n const legacyRefStr = String(legacyRef);\n const newRef = toInternalRouteRef(\n createRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/RouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return legacyRefStr;\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return legacyRefStr;\n },\n });\n }\n if (type === 'sub') {\n const legacyRef = ref as LegacySubRouteRef;\n const legacyRefStr = String(legacyRef);\n const newRef = toInternalSubRouteRef(\n createSubRouteRef({\n path: legacyRef.path,\n parent: convertLegacyRouteRef(legacyRef.parent),\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/SubRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getParent() {\n return newRef.getParent();\n },\n getDescription() {\n return legacyRefStr;\n },\n toString() {\n return legacyRefStr;\n },\n });\n }\n if (type === 'external') {\n const legacyRef = ref as LegacyExternalRouteRef;\n const legacyRefStr = String(legacyRef);\n const newRef = toInternalExternalRouteRef(\n createExternalRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n defaultTarget:\n 'getDefaultTarget' in legacyRef\n ? (legacyRef.getDefaultTarget as () => string | undefined)()\n : undefined,\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/ExternalRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return legacyRefStr;\n },\n // This might already be implemented in the legacy ref, but we override it just to be sure\n getDefaultTarget() {\n return newRef.getDefaultTarget();\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return legacyRefStr;\n },\n });\n }\n\n throw new Error(`Failed to convert legacy route ref, unknown type '${type}'`);\n}\n"],"names":[],"mappings":";;;;;;AA+DO,SAAS,uBAOd,IAAA,EAAsE;AACtE,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,IAAA,EAAM,GAAG,CAAA,KAAM;AAAA,MACxC,IAAA;AAAA,MACA,sBAAsB,GAAqB;AAAA,KAC5C;AAAA,GACH;AACF;AAyEO,SAAS,sBACd,GAAA,EAayB;AACzB,EAAA,MAAM,QAAQ,QAAA,IAAY,GAAA;AAC1B,EAAA,MAAM,OAAA,GAAW,IAA+C,YAAY,CAAA;AAG5E,EAAA,IAAI,SAAS,OAAA,EAAS;AACpB,IAAA,OAAO,GAAA;AAAA,EACT;AAEA,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAO,eAAA;AAAA,MACL;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO,eAAA,CAAgB,KAAK,OAAO,CAAA;AACrC;AAEA,SAAS,gBACP,GAAA,EAC6D;AAC7D,EAAA,IAAI,GAAA,CAAI,WAAW,qBAAA,EAAuB;AACxC,IAAA,MAAM,MAAA,GAAS,mBAAmB,GAAG,CAAA;AACrC,IAAA,OAAO,MAAA,CAAO,OAAO,GAAA,EAAK;AAAA,MACxB,CAAC,YAAY,GAAG,UAAA;AAAA,MAChB,MAAA,EAAQ,OAAO,SAAA,EAAU;AAAA,MACzB,KAAA,EAAO,OAAO,cAAA;AAAe,KACY,CAAA;A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A;AAAA,QAClB,aAAA,EACE,kBAAA,IAAsB,SAAA,GACjB,SAAA,CAAU,kBAA8C,GACzD;AAAA,OACP;AAAA,KACH;AACA,IAAA,OAAO,MAAA,CAAO,OAAO,SAAA,EAAW;AAAA,MAC9B,MAAA,EAAQ,6BAAA;AAAA,MACR,OAAA,EAAS,IAAA;AAAA,MACT,GAAG,MAAA,CAAO,CAAA;AAAA,MACV,SAAA,GAAY;AACV,QAAA,OAAO,OAAO,SAAA,EAAU;AAAA,MAC1B,CAAA;AAAA,MACA,cAAA,GAAiB;AACf,QAAA,OAAO,YAAA;AAAA,MACT,CAAA;AAAA;AAAA,MAEA,gBAAA,GAAmB;AACjB,QAAA,OAAO,OAAO,gBAAA,EAAiB;AAAA,MACjC,CAAA;AAAA,MACA,MAAM,EAAA,EAAY;AAChB,QAAA,MAAA,CAAO,MAAM,EAAE,CAAA;AAAA,MACjB,CAAA;AAAA,MACA,QAAA,GAAW;AACT,QAAA,OAAO,YAAA;AAAA,MACT;AAAA,KACD,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,IAAI,CAAA,CAAA,CAAG,CAAA;AAC9E;;;;"}
1
+ {"version":3,"file":"convertLegacyRouteRef.esm.js","sources":["../src/convertLegacyRouteRef.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 RouteRef as LegacyRouteRef,\n SubRouteRef as LegacySubRouteRef,\n ExternalRouteRef as LegacyExternalRouteRef,\n AnyRouteRefParams,\n} from '@backstage/core-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routeRefType } from '../../core-plugin-api/src/routing/types';\n\nimport {\n RouteRef,\n SubRouteRef,\n ExternalRouteRef,\n createRouteRef,\n createSubRouteRef,\n createExternalRouteRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n OpaqueRouteRef,\n OpaqueSubRouteRef,\n OpaqueExternalRouteRef,\n} from '@internal/frontend';\n\n/**\n * Converts a legacy route ref type to the new system.\n *\n * @public\n */\nexport type ToNewRouteRef<\n T extends LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef,\n> = T extends LegacyRouteRef<infer IParams>\n ? RouteRef<IParams>\n : T extends LegacySubRouteRef<infer IParams>\n ? SubRouteRef<IParams>\n : T extends LegacyExternalRouteRef<infer IParams>\n ? ExternalRouteRef<IParams>\n : never;\n\n/**\n * Converts a collection of legacy route refs to the new system.\n * This is particularly useful when defining plugin `routes` and `externalRoutes`.\n *\n * @public\n */\nexport function convertLegacyRouteRefs<\n TRefs extends {\n [name in string]:\n | LegacyRouteRef\n | LegacySubRouteRef\n | LegacyExternalRouteRef;\n },\n>(refs: TRefs): { [KName in keyof TRefs]: ToNewRouteRef<TRefs[KName]> } {\n return Object.fromEntries(\n Object.entries(refs).map(([name, ref]) => [\n name,\n convertLegacyRouteRef(ref as LegacyRouteRef),\n ]),\n ) as { [KName in keyof TRefs]: ToNewRouteRef<TRefs[KName]> };\n}\n\n/**\n * A temporary helper to convert a legacy route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacyRouteRef<TParams>,\n): RouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy sub route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createSubRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacySubRouteRef<TParams>,\n): SubRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy external route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacyExternalRouteRef<TParams>,\n): ExternalRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a new route ref to the legacy system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: RouteRef<TParams>,\n): LegacyRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a new sub route ref to the legacy system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createSubRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: SubRouteRef<TParams>,\n): LegacySubRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a new external route ref to the legacy system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: ExternalRouteRef<TParams>,\n): LegacyExternalRouteRef<TParams, true>;\nexport function convertLegacyRouteRef(\n ref:\n | LegacyRouteRef\n | LegacySubRouteRef\n | LegacyExternalRouteRef\n | RouteRef\n | SubRouteRef\n | ExternalRouteRef,\n):\n | RouteRef\n | SubRouteRef\n | ExternalRouteRef\n | LegacyRouteRef\n | LegacySubRouteRef\n | LegacyExternalRouteRef {\n const isNew = '$$type' in ref;\n const oldType = (ref as unknown as { [routeRefType]: unknown })[routeRefType];\n\n // Ref has already been converted\n if (isNew && oldType) {\n return ref as any;\n }\n\n if (isNew) {\n return convertNewToOld(\n ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef,\n );\n }\n\n return convertOldToNew(ref, oldType);\n}\n\nfunction convertNewToOld(\n ref: RouteRef | SubRouteRef | ExternalRouteRef,\n): LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef {\n if (ref.$$type === '@backstage/RouteRef') {\n const newRef = OpaqueRouteRef.toInternal(ref);\n return Object.assign(ref, {\n [routeRefType]: 'absolute',\n params: newRef.getParams(),\n title: newRef.getDescription(),\n } as Omit<LegacyRouteRef, '$$routeRefType' | keyof RouteRef>) as unknown as LegacyRouteRef;\n }\n if (ref.$$type === '@backstage/SubRouteRef') {\n const newRef = OpaqueSubRouteRef.toInternal(ref);\n return Object.assign(ref, {\n [routeRefType]: 'sub',\n parent: convertLegacyRouteRef(newRef.getParent()),\n params: newRef.getParams(),\n } as Omit<LegacySubRouteRef, '$$routeRefType' | keyof SubRouteRef>) as unknown as LegacySubRouteRef;\n }\n if (ref.$$type === '@backstage/ExternalRouteRef') {\n const newRef = OpaqueExternalRouteRef.toInternal(ref);\n return Object.assign(ref, {\n [routeRefType]: 'external',\n optional: true,\n params: newRef.getParams(),\n defaultTarget: newRef.getDefaultTarget(),\n } as Omit<LegacyExternalRouteRef, '$$routeRefType' | keyof ExternalRouteRef>) as unknown as LegacyExternalRouteRef;\n }\n\n throw new Error(\n `Failed to convert route ref, unknown type '${(ref as any).$$type}'`,\n );\n}\n\nfunction convertOldToNew(\n ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef,\n type: unknown,\n): RouteRef | SubRouteRef | ExternalRouteRef {\n if (type === 'absolute') {\n const legacyRef = ref as LegacyRouteRef;\n const legacyRefStr = String(legacyRef);\n const newRef = OpaqueRouteRef.toInternal(\n createRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/RouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return legacyRefStr;\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return legacyRefStr;\n },\n });\n }\n if (type === 'sub') {\n const legacyRef = ref as LegacySubRouteRef;\n const legacyRefStr = String(legacyRef);\n const newRef = OpaqueSubRouteRef.toInternal(\n createSubRouteRef({\n path: legacyRef.path,\n parent: convertLegacyRouteRef(legacyRef.parent),\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/SubRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getParent() {\n return newRef.getParent();\n },\n getDescription() {\n return legacyRefStr;\n },\n toString() {\n return legacyRefStr;\n },\n });\n }\n if (type === 'external') {\n const legacyRef = ref as LegacyExternalRouteRef;\n const legacyRefStr = String(legacyRef);\n const newRef = OpaqueExternalRouteRef.toInternal(\n createExternalRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n defaultTarget:\n 'getDefaultTarget' in legacyRef\n ? (legacyRef.getDefaultTarget as () => string | undefined)()\n : undefined,\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/ExternalRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return legacyRefStr;\n },\n // This might already be implemented in the legacy ref, but we override it just to be sure\n getDefaultTarget() {\n return newRef.getDefaultTarget();\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return legacyRefStr;\n },\n });\n }\n\n throw new Error(`Failed to convert legacy route ref, unknown type '${type}'`);\n}\n"],"names":[],"mappings":";;;;;;AA6DO,SAAS,uBAOd,IAAA,EAAsE;AACtE,EAAA,OAAO,MAAA,CAAO,WAAA;AAAA,IACZ,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,IAAI,CAAC,CAAC,IAAA,EAAM,GAAG,CAAA,KAAM;AAAA,MACxC,IAAA;AAAA,MACA,sBAAsB,GAAqB;AAAA,KAC5C;AAAA,GACH;AACF;AAyEO,SAAS,sBACd,GAAA,EAayB;AACzB,EAAA,MAAM,QAAQ,QAAA,IAAY,GAAA;AAC1B,EAAA,MAAM,OAAA,GAAW,IAA+C,YAAY,CAAA;AAG5E,EAAA,IAAI,SAAS,OA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A,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,IAAI,CAAA,CAAA,CAAG,CAAA;AAC9E;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.esm.js","sources":["../../../../../core-plugin-api/src/routing/types.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getOrCreateGlobalSingleton } from '@backstage/version-bridge';\n\n/**\n * Catch-all type for route params.\n *\n * @public\n */\nexport type AnyRouteRefParams = { [param in string]: string } | undefined;\n\n/**\n * @deprecated use {@link AnyRouteRefParams} instead\n * @public\n */\nexport type AnyParams = AnyRouteRefParams;\n\n/**\n * Type describing the key type of a route parameter mapping.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamKeys<Params extends AnyParams> = [AnyRouteRefParams] extends [\n Params,\n]\n ? string[]\n : keyof Params extends never\n ? []\n : Array<keyof Params>;\n\n/**\n * Optional route params.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type OptionalParams<Params extends { [param in string]: string }> =\n Params[keyof Params] extends never ? undefined : Params;\n\n/**\n * TS magic for handling route parameters.\n *\n * @remarks\n *\n * The extra TS magic here is to require a single params argument if the RouteRef\n * had at least one param defined, but require 0 arguments if there are no params defined.\n * Without this we'd have to pass in empty object to all parameter-less RouteRefs\n * just to make TypeScript happy, or we would have to make the argument optional in\n * which case you might forget to pass it in when it is actually required.\n *\n * @public\n */\nexport type RouteFunc<Params extends AnyParams> = (\n ...[params]: Params extends undefined ? readonly [] : readonly [Params]\n) => string;\n\n/**\n * This symbol is what we use at runtime to determine whether a given object\n * is a type of RouteRef or not. It doesn't work well in TypeScript though since\n * the `unique symbol` will refer to different values between package versions.\n * For that reason we use the marker $$routeRefType to represent the symbol at\n * compile-time instead of using the symbol directly.\n *\n * @internal\n */\nexport const routeRefType: unique symbol = getOrCreateGlobalSingleton<any>(\n 'route-ref-type',\n () => Symbol('route-ref-type'),\n);\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type RouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'absolute'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n};\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type SubRouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'sub'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n parent: RouteRef;\n\n path: string;\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n};\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type ExternalRouteRef<\n Params extends AnyParams = any,\n Optional extends boolean = any,\n> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'external'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n\n optional?: Optional;\n};\n\n/**\n * @internal\n */\nexport type AnyRouteRef =\n | RouteRef<any>\n | SubRouteRef<any>\n | ExternalRouteRef<any, any>;\n\n/**\n * A duplicate of the react-router RouteObject, but with routeRef added\n * @internal\n */\nexport interface BackstageRouteObject {\n caseSensitive: boolean;\n children?: BackstageRouteObject[];\n element: React.ReactNode;\n path: string;\n routeRefs: Set<RouteRef>;\n}\n"],"names":[],"mappings":";;AAgFO,MAAM,YAAA,GAA8B,0BAAA;AAAA,EACzC,gBAAA;AAAA,EACA,MAAM,OAAO,gBAAgB;AAC/B;;;;"}
1
+ {"version":3,"file":"types.esm.js","sources":["../../../../../core-plugin-api/src/routing/types.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getOrCreateGlobalSingleton } from '@backstage/version-bridge';\n\n/**\n * Catch-all type for route params.\n *\n * @public\n */\nexport type AnyRouteRefParams = { [param in string]: string } | undefined;\n\n/**\n * @deprecated use {@link AnyRouteRefParams} instead\n * @public\n */\nexport type AnyParams = AnyRouteRefParams;\n\n/**\n * Type describing the key type of a route parameter mapping.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamKeys<Params extends AnyParams> = [AnyRouteRefParams] extends [\n Params,\n]\n ? string[]\n : keyof Params extends never\n ? []\n : Array<keyof Params>;\n\n/**\n * Optional route params.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type OptionalParams<Params extends { [param in string]: string }> =\n Params[keyof Params] extends never ? undefined : Params;\n\n/**\n * TS magic for handling route parameters.\n *\n * @remarks\n *\n * The extra TS magic here is to require a single params argument if the RouteRef\n * had at least one param defined, but require 0 arguments if there are no params defined.\n * Without this we'd have to pass in empty object to all parameter-less RouteRefs\n * just to make TypeScript happy, or we would have to make the argument optional in\n * which case you might forget to pass it in when it is actually required.\n *\n * @public\n */\nexport type RouteFunc<Params extends AnyParams> = (\n ...[params]: Params extends undefined ? readonly [] : readonly [Params]\n) => string;\n\n/**\n * This symbol is what we use at runtime to determine whether a given object\n * is a type of RouteRef or not. It doesn't work well in TypeScript though since\n * the `unique symbol` will refer to different values between package versions.\n * For that reason we use the marker $$routeRefType to represent the symbol at\n * compile-time instead of using the symbol directly.\n *\n * @internal\n */\nexport const routeRefType: unique symbol = getOrCreateGlobalSingleton<any>(\n 'route-ref-type',\n () => Symbol('route-ref-type'),\n);\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type RouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'absolute'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n\n /** Compatibility field for new frontend system */\n readonly $$type: '@backstage/RouteRef';\n /** Compatibility field for new frontend system */\n readonly T: Params;\n};\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type SubRouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'sub'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n parent: RouteRef;\n\n path: string;\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n\n /** Compatibility field for new frontend system */\n readonly $$type: '@backstage/SubRouteRef';\n /** Compatibility field for new frontend system */\n readonly T: Params;\n};\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type ExternalRouteRef<\n Params extends AnyParams = any,\n Optional extends boolean = any,\n> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'external'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n\n optional?: Optional;\n\n /** Compatibility field for new frontend system */\n readonly $$type: '@backstage/ExternalRouteRef';\n /** Compatibility field for new frontend system */\n readonly T: Params;\n};\n\n/**\n * @internal\n */\nexport type AnyRouteRef =\n | RouteRef<any>\n | SubRouteRef<any>\n | ExternalRouteRef<any, any>;\n\n/**\n * A duplicate of the react-router RouteObject, but with routeRef added\n * @internal\n */\nexport interface BackstageRouteObject {\n caseSensitive: boolean;\n children?: BackstageRouteObject[];\n element: React.ReactNode;\n path: string;\n routeRefs: Set<RouteRef>;\n}\n"],"names":[],"mappings":";;AAgFO,MAAM,YAAA,GAA8B,0BAAA;AAAA,EACzC,gBAAA;AAAA,EACA,MAAM,OAAO,gBAAgB;AAC/B;;;;"}
@@ -0,0 +1,9 @@
1
+ import { OpaqueType } from '../../../opaque-internal/src/OpaqueType.esm.js';
2
+
3
+ const OpaqueExternalRouteRef = OpaqueType.create({
4
+ type: "@backstage/ExternalRouteRef",
5
+ versions: ["v1"]
6
+ });
7
+
8
+ export { OpaqueExternalRouteRef };
9
+ //# sourceMappingURL=OpaqueExternalRouteRef.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpaqueExternalRouteRef.esm.js","sources":["../../../../../frontend-internal/src/routing/OpaqueExternalRouteRef.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { ExternalRouteRef } from '@backstage/frontend-plugin-api';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueExternalRouteRef = OpaqueType.create<{\n public: ExternalRouteRef;\n versions: {\n readonly version: 'v1';\n\n getParams(): string[];\n getDescription(): string;\n getDefaultTarget(): string | undefined;\n\n setId(id: string): void;\n };\n}>({\n type: '@backstage/ExternalRouteRef',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;AAmBO,MAAM,sBAAA,GAAyB,WAAW,MAAA,CAW9C;AAAA,EACD,IAAA,EAAM,6BAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC;;;;"}
@@ -0,0 +1,9 @@
1
+ import { OpaqueType } from '../../../opaque-internal/src/OpaqueType.esm.js';
2
+
3
+ const OpaqueRouteRef = OpaqueType.create({
4
+ type: "@backstage/RouteRef",
5
+ versions: ["v1"]
6
+ });
7
+
8
+ export { OpaqueRouteRef };
9
+ //# sourceMappingURL=OpaqueRouteRef.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpaqueRouteRef.esm.js","sources":["../../../../../frontend-internal/src/routing/OpaqueRouteRef.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { RouteRef } from '@backstage/frontend-plugin-api';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueRouteRef = OpaqueType.create<{\n public: RouteRef;\n versions: {\n readonly version: 'v1';\n\n getParams(): string[];\n getDescription(): string;\n\n alias: string | undefined;\n\n setId(id: string): void;\n };\n}>({\n type: '@backstage/RouteRef',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;AAmBO,MAAM,cAAA,GAAiB,WAAW,MAAA,CAYtC;AAAA,EACD,IAAA,EAAM,qBAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC;;;;"}
@@ -0,0 +1,9 @@
1
+ import { OpaqueType } from '../../../opaque-internal/src/OpaqueType.esm.js';
2
+
3
+ const OpaqueSubRouteRef = OpaqueType.create({
4
+ type: "@backstage/SubRouteRef",
5
+ versions: ["v1"]
6
+ });
7
+
8
+ export { OpaqueSubRouteRef };
9
+ //# sourceMappingURL=OpaqueSubRouteRef.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpaqueSubRouteRef.esm.js","sources":["../../../../../frontend-internal/src/routing/OpaqueSubRouteRef.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { RouteRef, SubRouteRef } from '@backstage/frontend-plugin-api';\nimport { OpaqueType } from '@internal/opaque';\n\nexport const OpaqueSubRouteRef = OpaqueType.create<{\n public: SubRouteRef;\n versions: {\n readonly version: 'v1';\n\n getParams(): string[];\n getParent(): RouteRef;\n getDescription(): string;\n };\n}>({\n type: '@backstage/SubRouteRef',\n versions: ['v1'],\n});\n"],"names":[],"mappings":";;AAmBO,MAAM,iBAAA,GAAoB,WAAW,MAAA,CASzC;AAAA,EACD,IAAA,EAAM,wBAAA;AAAA,EACN,QAAA,EAAU,CAAC,IAAI;AACjB,CAAC;;;;"}
@@ -0,0 +1,103 @@
1
+ class OpaqueType {
2
+ /**
3
+ * Creates a new opaque type.
4
+ *
5
+ * @param options.type The type identifier of the opaque type
6
+ * @param options.versions The available versions of the opaque type
7
+ * @returns A new opaque type helper
8
+ */
9
+ static create(options) {
10
+ return new OpaqueType(options.type, new Set(options.versions));
11
+ }
12
+ #type;
13
+ #versions;
14
+ constructor(type, versions) {
15
+ this.#type = type;
16
+ this.#versions = versions;
17
+ }
18
+ /**
19
+ * The internal version of the opaque type, used like this: `typeof MyOpaqueType.TPublic`
20
+ *
21
+ * @remarks
22
+ *
23
+ * This property is only useful for type checking, its runtime value is `undefined`.
24
+ */
25
+ TPublic = void 0;
26
+ /**
27
+ * The internal version of the opaque type, used like this: `typeof MyOpaqueType.TInternal`
28
+ *
29
+ * @remarks
30
+ *
31
+ * This property is only useful for type checking, its runtime value is `undefined`.
32
+ */
33
+ TInternal = void 0;
34
+ /**
35
+ * @param value Input value expected to be an instance of this opaque type
36
+ * @returns True if the value matches this opaque type
37
+ */
38
+ isType = (value) => {
39
+ return this.#isThisInternalType(value);
40
+ };
41
+ /**
42
+ * @param value Input value expected to be an instance of this opaque type
43
+ * @throws If the value is not an instance of this opaque type or is of an unsupported version
44
+ * @returns The internal version of the opaque type
45
+ */
46
+ toInternal = (value) => {
47
+ if (!this.#isThisInternalType(value)) {
48
+ throw new TypeError(
49
+ `Invalid opaque type, expected '${this.#type}', but got '${this.#stringifyUnknown(value)}'`
50
+ );
51
+ }
52
+ if (!this.#versions.has(value.version)) {
53
+ const versions = Array.from(this.#versions).map(this.#stringifyVersion);
54
+ if (versions.length > 1) {
55
+ versions[versions.length - 1] = `or ${versions[versions.length - 1]}`;
56
+ }
57
+ const expected = versions.length > 2 ? versions.join(", ") : versions.join(" ");
58
+ throw new TypeError(
59
+ `Invalid opaque type instance, got version ${this.#stringifyVersion(
60
+ value.version
61
+ )}, expected ${expected}`
62
+ );
63
+ }
64
+ return value;
65
+ };
66
+ /**
67
+ * Creates an instance of the opaque type, returning the public type.
68
+ *
69
+ * @param version The version of the instance to create
70
+ * @param value The remaining public and internal properties of the instance
71
+ * @returns An instance of the opaque type
72
+ */
73
+ createInstance(version, props) {
74
+ return Object.assign(props, {
75
+ $$type: this.#type,
76
+ ...version && { version }
77
+ });
78
+ }
79
+ #isThisInternalType(value) {
80
+ if (value === null || typeof value !== "object") {
81
+ return false;
82
+ }
83
+ return value.$$type === this.#type;
84
+ }
85
+ #stringifyUnknown(value) {
86
+ if (typeof value !== "object") {
87
+ return `<${typeof value}>`;
88
+ }
89
+ if (value === null) {
90
+ return "<null>";
91
+ }
92
+ if ("$$type" in value) {
93
+ return String(value.$$type);
94
+ }
95
+ return String(value);
96
+ }
97
+ #stringifyVersion = (version) => {
98
+ return version ? `'${version}'` : "undefined";
99
+ };
100
+ }
101
+
102
+ export { OpaqueType };
103
+ //# sourceMappingURL=OpaqueType.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpaqueType.esm.js","sources":["../../../../opaque-internal/src/OpaqueType.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\n// TODO(Rugvip): This lives here temporarily, but should be moved to a more\n// central location. It's useful for backend packages too so we'll need to have\n// it in a common package, but it might also be that we want to make it\n// available publicly too in which case it would make sense to have this be part\n// of @backstage/version-bridge. The problem with exporting it from there is\n// that it would need to be very stable at that point, so it might be a bit\n// early to put it there already.\n\n/**\n * A helper for working with opaque types.\n */\nexport class OpaqueType<\n T extends {\n public: { $$type: string };\n versions: { version: string | undefined };\n },\n> {\n /**\n * Creates a new opaque type.\n *\n * @param options.type The type identifier of the opaque type\n * @param options.versions The available versions of the opaque type\n * @returns A new opaque type helper\n */\n static create<\n T extends {\n public: { $$type: string };\n versions: { version: string | undefined };\n },\n >(options: {\n type: T['public']['$$type'];\n versions: Array<T['versions']['version']>;\n }) {\n return new OpaqueType<T>(options.type, new Set(options.versions));\n }\n\n #type: string;\n #versions: Set<string | undefined>;\n\n private constructor(type: string, versions: Set<string | undefined>) {\n this.#type = type;\n this.#versions = versions;\n }\n\n /**\n * The internal version of the opaque type, used like this: `typeof MyOpaqueType.TPublic`\n *\n * @remarks\n *\n * This property is only useful for type checking, its runtime value is `undefined`.\n */\n TPublic: T['public'] = undefined as any;\n\n /**\n * The internal version of the opaque type, used like this: `typeof MyOpaqueType.TInternal`\n *\n * @remarks\n *\n * This property is only useful for type checking, its runtime value is `undefined`.\n */\n TInternal: T['public'] & T['versions'] = undefined as any;\n\n /**\n * @param value Input value expected to be an instance of this opaque type\n * @returns True if the value matches this opaque type\n */\n isType = (value: unknown): value is T['public'] => {\n return this.#isThisInternalType(value);\n };\n\n /**\n * @param value Input value expected to be an instance of this opaque type\n * @throws If the value is not an instance of this opaque type or is of an unsupported version\n * @returns The internal version of the opaque type\n */\n toInternal = (value: unknown): T['public'] & T['versions'] => {\n if (!this.#isThisInternalType(value)) {\n throw new TypeError(\n `Invalid opaque type, expected '${\n this.#type\n }', but got '${this.#stringifyUnknown(value)}'`,\n );\n }\n\n if (!this.#versions.has(value.version)) {\n const versions = Array.from(this.#versions).map(this.#stringifyVersion);\n if (versions.length > 1) {\n versions[versions.length - 1] = `or ${versions[versions.length - 1]}`;\n }\n const expected =\n versions.length > 2 ? versions.join(', ') : versions.join(' ');\n throw new TypeError(\n `Invalid opaque type instance, got version ${this.#stringifyVersion(\n value.version,\n )}, expected ${expected}`,\n );\n }\n\n return value;\n };\n\n /**\n * Creates an instance of the opaque type, returning the public type.\n *\n * @param version The version of the instance to create\n * @param value The remaining public and internal properties of the instance\n * @returns An instance of the opaque type\n */\n createInstance<\n TVersion extends T['versions']['version'],\n TPublic extends T['public'],\n >(\n version: TVersion,\n props: Omit<T['public'], '$$type'> &\n (T['versions'] extends infer UVersion\n ? UVersion extends { version: TVersion }\n ? Omit<UVersion, 'version'>\n : never\n : never) &\n Object, // & Object to allow for object properties too, e.g. toString()\n ): TPublic {\n return Object.assign(props as object, {\n $$type: this.#type,\n ...(version && { version }),\n }) as unknown as TPublic;\n }\n\n #isThisInternalType(value: unknown): value is T['public'] & T['versions'] {\n if (value === null || typeof value !== 'object') {\n return false;\n }\n return (value as T['public']).$$type === this.#type;\n }\n\n #stringifyUnknown(value: unknown) {\n if (typeof value !== 'object') {\n return `<${typeof value}>`;\n }\n if (value === null) {\n return '<null>';\n }\n if ('$$type' in value) {\n return String(value.$$type);\n }\n return String(value);\n }\n\n #stringifyVersion = (version: string | undefined) => {\n return version ? `'${version}'` : 'undefined';\n };\n}\n"],"names":[],"mappings":"AA2BO,MAAM,UAAA,CAKX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAKL,OAAA,EAGC;AACD,IAAA,OAAO,IAAI,WAAc,OAAA,CAAQ,IAAA,EAAM,IAAI,GAAA,CAAI,OAAA,CAAQ,QAAQ,CAAC,CAAA;AAAA,EAClE;AAAA,EAEA,KAAA;AAAA,EACA,SAAA;AAAA,EAEQ,WAAA,CAAY,MAAc,QAAA,EAAmC;AACnE,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAA;AACb,IAAA,IAAA,CAAK,SAAA,GAAY,QAAA;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAA,GAAuB,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASvB,SAAA,GAAyC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMzC,MAAA,GAAS,CAAC,KAAA,KAAyC;AACjD,IAAA,OAAO,IAAA,CAAK,oBAAoB,KAAK,CAAA;AAAA,EACvC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,UAAA,GAAa,CAAC,KAAA,KAAgD;AAC5D,IAAA,IAAI,CAAC,IAAA,CAAK,mBAAA,CAAoB,KAAK,CAAA,EAAG;AACpC,MAAA,MAAM,I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AAQ,KAAA,CAAsB,WAAW,IAAA,CAAK,KAAA;AAAA,EAChD;AAAA,EAEA,kBAAkB,KAAA,EAAgB;AAChC,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,MAAA,OAAO,CAAA,CAAA,EAAI,OAAO,KAAK,CAAA,CAAA,CAAA;AAAA,IACzB;AACA,IAAA,IAAI,UAAU,IAAA,EAAM;AAClB,MAAA,OAAO,QAAA;AAAA,IACT;AACA,IAAA,IAAI,YAAY,KAAA,EAAO;AACrB,MAAA,OAAO,MAAA,CAAO,MAAM,MAAM,CAAA;AAAA,IAC5B;AACA,IAAA,OAAO,OAAO,KAAK,CAAA;AAAA,EACrB;AAAA,EAEA,iBAAA,GAAoB,CAAC,OAAA,KAAgC;AACnD,IAAA,OAAO,OAAA,GAAU,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,CAAA,GAAM,WAAA;AAAA,EACpC,CAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/core-compat-api",
3
- "version": "0.5.4-next.0",
3
+ "version": "0.5.5-next.0",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -31,19 +31,21 @@
31
31
  "test": "backstage-cli package test"
32
32
  },
33
33
  "dependencies": {
34
- "@backstage/core-plugin-api": "1.11.2-next.0",
35
- "@backstage/frontend-plugin-api": "0.12.2-next.0",
36
- "@backstage/plugin-catalog-react": "1.21.3-next.0",
34
+ "@backstage/core-plugin-api": "1.12.1-next.0",
35
+ "@backstage/frontend-plugin-api": "0.13.2-next.0",
36
+ "@backstage/plugin-catalog-react": "1.21.4-next.0",
37
+ "@backstage/types": "1.2.2",
37
38
  "@backstage/version-bridge": "1.0.11",
38
- "lodash": "^4.17.21"
39
+ "lodash": "^4.17.21",
40
+ "zod": "^3.22.4"
39
41
  },
40
42
  "devDependencies": {
41
- "@backstage/cli": "0.34.5-next.0",
42
- "@backstage/core-app-api": "1.19.2-next.0",
43
- "@backstage/frontend-app-api": "0.13.2-next.0",
44
- "@backstage/frontend-test-utils": "0.4.1-next.0",
45
- "@backstage/plugin-catalog": "1.31.5-next.0",
46
- "@backstage/test-utils": "1.7.13-next.0",
43
+ "@backstage/cli": "0.34.6-next.0",
44
+ "@backstage/core-app-api": "1.19.3-next.0",
45
+ "@backstage/frontend-app-api": "0.13.3-next.0",
46
+ "@backstage/frontend-test-utils": "0.4.2-next.0",
47
+ "@backstage/plugin-catalog": "1.32.1-next.0",
48
+ "@backstage/test-utils": "1.7.14-next.0",
47
49
  "@backstage/types": "1.2.2",
48
50
  "@testing-library/jest-dom": "^6.0.0",
49
51
  "@testing-library/react": "^16.0.0",
@@ -1,10 +0,0 @@
1
- function toInternalExternalRouteRef(resource) {
2
- const r = resource;
3
- if (r.$$type !== "@backstage/ExternalRouteRef") {
4
- throw new Error(`Invalid ExternalRouteRef, bad type '${r.$$type}'`);
5
- }
6
- return r;
7
- }
8
-
9
- export { toInternalExternalRouteRef };
10
- //# sourceMappingURL=ExternalRouteRef.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExternalRouteRef.esm.js","sources":["../../../../../frontend-plugin-api/src/routing/ExternalRouteRef.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RouteRefImpl } from './RouteRef';\nimport { describeParentCallSite } from './describeParentCallSite';\nimport { AnyRouteRefParams } from './types';\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface ExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/ExternalRouteRef';\n readonly T: TParams;\n}\n\n/** @internal */\nexport interface InternalExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends ExternalRouteRef<TParams> {\n readonly version: 'v1';\n getParams(): string[];\n getDescription(): string;\n getDefaultTarget(): string | undefined;\n\n setId(id: string): void;\n}\n\n/** @internal */\nexport function toInternalExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: ExternalRouteRef<TParams>): InternalExternalRouteRef<TParams> {\n const r = resource as InternalExternalRouteRef<TParams>;\n if (r.$$type !== '@backstage/ExternalRouteRef') {\n throw new Error(`Invalid ExternalRouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isExternalRouteRef(opaque: {\n $$type: string;\n}): opaque is ExternalRouteRef {\n return opaque.$$type === '@backstage/ExternalRouteRef';\n}\n\n/** @internal */\nclass ExternalRouteRefImpl\n extends RouteRefImpl\n implements InternalExternalRouteRef\n{\n readonly $$type = '@backstage/ExternalRouteRef' as any;\n readonly params: string[];\n readonly defaultTarget: string | undefined;\n\n constructor(\n params: string[] = [],\n defaultTarget: string | undefined,\n creationSite: string,\n ) {\n super(params, creationSite);\n this.params = params;\n this.defaultTarget = defaultTarget;\n }\n\n getDefaultTarget() {\n return this.defaultTarget;\n }\n}\n\n/**\n * Creates a route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @param options - Description of the route reference to be created.\n * @public\n */\nexport function createExternalRouteRef<\n TParams extends { [param in TParamKeys]: string } | undefined = undefined,\n TParamKeys extends string = string,\n>(options?: {\n /**\n * The parameters that will be provided to the external route reference.\n */\n readonly params?: string extends TParamKeys\n ? (keyof TParams)[]\n : TParamKeys[];\n\n /**\n * The route (typically in another plugin) that this should map to by default.\n *\n * The string is expected to be on the standard `<plugin id>.<route id>` form,\n * for example `techdocs.docRoot`.\n */\n defaultTarget?: string;\n}): ExternalRouteRef<\n keyof TParams extends never\n ? undefined\n : string extends TParamKeys\n ? TParams\n : { [param in TParamKeys]: string }\n> {\n return new ExternalRouteRefImpl(\n options?.params as string[] | undefined,\n options?.defaultTarget,\n describeParentCallSite(),\n );\n}\n"],"names":[],"mappings":"AAiDO,SAAS,2BAEd,QAAA,EAAwE;AACxE,EAAA,MAAM,CAAA,GAAI,QAAA;AACV,EAAA,IAAI,CAAA,CAAE,WAAW,6BAAA,EAA+B;AAC9C,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,oCAAA,EAAuC,CAAA,CAAE,MAAM,CAAA,CAAA,CAAG,CAAA;AAAA,EACpE;AAEA,EAAA,OAAO,CAAA;AACT;;;;"}
@@ -1,10 +0,0 @@
1
- function toInternalRouteRef(resource) {
2
- const r = resource;
3
- if (r.$$type !== "@backstage/RouteRef") {
4
- throw new Error(`Invalid RouteRef, bad type '${r.$$type}'`);
5
- }
6
- return r;
7
- }
8
-
9
- export { toInternalRouteRef };
10
- //# sourceMappingURL=RouteRef.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouteRef.esm.js","sources":["../../../../../frontend-plugin-api/src/routing/RouteRef.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describeParentCallSite } from './describeParentCallSite';\nimport { AnyRouteRefParams } from './types';\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface RouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/RouteRef';\n readonly T: TParams;\n}\n\n/** @internal */\nexport interface InternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends RouteRef<TParams> {\n readonly version: 'v1';\n getParams(): string[];\n getDescription(): string;\n\n alias: string | undefined;\n\n setId(id: string): void;\n}\n\n/** @internal */\nexport function toInternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: RouteRef<TParams>): InternalRouteRef<TParams> {\n const r = resource as InternalRouteRef<TParams>;\n if (r.$$type !== '@backstage/RouteRef') {\n throw new Error(`Invalid RouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isRouteRef(opaque: { $$type: string }): opaque is RouteRef {\n return opaque.$$type === '@backstage/RouteRef';\n}\n\n/** @internal */\nexport class RouteRefImpl implements InternalRouteRef {\n readonly $$type = '@backstage/RouteRef';\n readonly version = 'v1';\n declare readonly T: never;\n\n #id?: string;\n readonly #params: string[];\n readonly #creationSite: string;\n readonly #alias?: string;\n\n constructor(\n readonly params: string[] = [],\n creationSite: string,\n alias?: string,\n ) {\n this.#params = params;\n this.#creationSite = creationSite;\n this.#alias = alias;\n }\n\n getParams(): string[] {\n return this.#params;\n }\n\n get alias(): string | undefined {\n return this.#alias;\n }\n\n getDescription(): string {\n if (this.#id) {\n return this.#id;\n }\n return `created at '${this.#creationSite}'`;\n }\n\n get #name() {\n return this.$$type.slice('@backstage/'.length);\n }\n\n setId(id: string): void {\n if (!id) {\n throw new Error(`${this.#name} id must be a non-empty string`);\n }\n if (this.#id && this.#id !== id) {\n throw new Error(\n `${this.#name} was referenced twice as both '${this.#id}' and '${id}'`,\n );\n }\n this.#id = id;\n }\n\n toString(): string {\n return `${this.#name}{${this.getDescription()}}`;\n }\n}\n\n/**\n * Create a {@link RouteRef} from a route descriptor.\n *\n * @param config - Description of the route reference to be created.\n * @public\n */\nexport function createRouteRef<\n // Params is the type that we care about and the one to be embedded in the route ref.\n // For example, given the params ['name', 'kind'], Params will be {name: string, kind: string}\n TParams extends { [param in TParamKeys]: string } | undefined = undefined,\n TParamKeys extends string = string,\n>(config?: {\n /** A list of parameter names that the path that this route ref is bound to must contain */\n readonly params?: string extends TParamKeys\n ? (keyof TParams)[]\n : TParamKeys[];\n\n aliasFor?: string;\n}): RouteRef<\n keyof TParams extends never\n ? undefined\n : string extends TParamKeys\n ? TParams\n : { [param in TParamKeys]: string }\n> {\n return new RouteRefImpl(\n config?.params as string[] | undefined,\n describeParentCallSite(),\n config?.aliasFor,\n ) as RouteRef<any>;\n}\n"],"names":[],"mappings":"AAiDO,SAAS,mBAEd,QAAA,EAAwD;AACxD,EAAA,MAAM,CAAA,GAAI,QAAA;AACV,EAAA,IAAI,CAAA,CAAE,WAAW,qBAAA,EAAuB;AACtC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,CAAA,CAAE,MAAM,CAAA,CAAA,CAAG,CAAA;AAAA,EAC5D;AAEA,EAAA,OAAO,CAAA;AACT;;;;"}
@@ -1,10 +0,0 @@
1
- function toInternalSubRouteRef(resource) {
2
- const r = resource;
3
- if (r.$$type !== "@backstage/SubRouteRef") {
4
- throw new Error(`Invalid SubRouteRef, bad type '${r.$$type}'`);
5
- }
6
- return r;
7
- }
8
-
9
- export { toInternalSubRouteRef };
10
- //# sourceMappingURL=SubRouteRef.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubRouteRef.esm.js","sources":["../../../../../frontend-plugin-api/src/routing/SubRouteRef.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RouteRef, toInternalRouteRef } from './RouteRef';\nimport { AnyRouteRefParams } from './types';\n\n// Should match the pattern in react-router\nconst PARAM_PATTERN = /^\\w+$/;\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface SubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/SubRouteRef';\n\n readonly T: TParams;\n\n readonly path: string;\n}\n\n/** @internal */\nexport interface InternalSubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends SubRouteRef<TParams> {\n readonly version: 'v1';\n\n getParams(): string[];\n getParent(): RouteRef;\n getDescription(): string;\n}\n\n/** @internal */\nexport function toInternalSubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: SubRouteRef<TParams>): InternalSubRouteRef<TParams> {\n const r = resource as InternalSubRouteRef<TParams>;\n if (r.$$type !== '@backstage/SubRouteRef') {\n throw new Error(`Invalid SubRouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isSubRouteRef(opaque: {\n $$type: string;\n}): opaque is SubRouteRef {\n return opaque.$$type === '@backstage/SubRouteRef';\n}\n\n/** @internal */\nexport class SubRouteRefImpl<TParams extends AnyRouteRefParams>\n implements SubRouteRef<TParams>\n{\n readonly $$type = '@backstage/SubRouteRef';\n readonly version = 'v1';\n declare readonly T: never;\n\n #params: string[];\n #parent: RouteRef;\n\n constructor(readonly path: string, params: string[], parent: RouteRef) {\n this.#params = params;\n this.#parent = parent;\n }\n\n getParams(): string[] {\n return this.#params;\n }\n\n getParent(): RouteRef {\n return this.#parent;\n }\n\n getDescription(): string {\n const parent = toInternalRouteRef(this.#parent);\n return `at ${this.path} with parent ${parent.getDescription()}`;\n }\n\n toString(): string {\n return `SubRouteRef{${this.getDescription()}}`;\n }\n}\n\n/**\n * Used in {@link PathParams} type declaration.\n * @ignore\n */\ntype ParamPart<S extends string> = S extends `:${infer Param}` ? Param : never;\n\n/**\n * Used in {@link PathParams} type declaration.\n * @ignore\n */\ntype ParamNames<S extends string> = S extends `${infer Part}/${infer Rest}`\n ? ParamPart<Part> | ParamNames<Rest>\n : ParamPart<S>;\n/**\n * This utility type helps us infer a Param object type from a string path\n * For example, `/foo/:bar/:baz` inferred to `{ bar: string, baz: string }`\n * @ignore\n */\ntype PathParams<S extends string> = { [name in ParamNames<S>]: string };\n\n/**\n * Merges a param object type with an optional params type into a params object.\n * @ignore\n */\ntype MergeParams<\n P1 extends { [param in string]: string },\n P2 extends AnyRouteRefParams,\n> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);\n\n/**\n * Convert empty params to undefined.\n * @ignore\n */\ntype TrimEmptyParams<Params extends { [param in string]: string }> =\n keyof Params extends never ? undefined : Params;\n\n/**\n * Creates a SubRouteRef type given the desired parameters and parent route parameters.\n * The parameters types are merged together while ensuring that there is no overlap between the two.\n *\n * @ignore\n */\ntype MakeSubRouteRef<\n Params extends { [param in string]: string },\n ParentParams extends AnyRouteRefParams,\n> = keyof Params & keyof ParentParams extends never\n ? SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>>\n : never;\n\n/**\n * Create a {@link SubRouteRef} from a route descriptor.\n *\n * @param config - Description of the route reference to be created.\n * @public\n */\nexport function createSubRouteRef<\n Path extends string,\n ParentParams extends AnyRouteRefParams = never,\n>(config: {\n path: Path;\n parent: RouteRef<ParentParams>;\n}): MakeSubRouteRef<PathParams<Path>, ParentParams> {\n const { path, parent } = config;\n type Params = PathParams<Path>;\n\n const internalParent = toInternalRouteRef(parent);\n const parentParams = internalParent.getParams();\n\n // Collect runtime parameters from the path, e.g. ['bar', 'baz'] from '/foo/:bar/:baz'\n const pathParams = path\n .split('/')\n .filter(p => p.startsWith(':'))\n .map(p => p.substring(1));\n const params = [...parentParams, ...pathParams];\n\n if (parentParams.some(p => pathParams.includes(p as string))) {\n throw new Error(\n 'SubRouteRef may not have params that overlap with its parent',\n );\n }\n if (!path.startsWith('/')) {\n throw new Error(`SubRouteRef path must start with '/', got '${path}'`);\n }\n if (path.endsWith('/')) {\n throw new Error(`SubRouteRef path must not end with '/', got '${path}'`);\n }\n for (const param of pathParams) {\n if (!PARAM_PATTERN.test(param)) {\n throw new Error(`SubRouteRef path has invalid param, got '${param}'`);\n }\n }\n\n // We ensure that the type of the return type is sane here\n const subRouteRef = new SubRouteRefImpl(\n path,\n params as string[],\n parent,\n ) as SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>>;\n\n // But skip type checking of the return value itself, because the conditional\n // type checking of the parent parameter overlap is tricky to express.\n return subRouteRef as any;\n}\n"],"names":[],"mappings":"AAqDO,SAAS,sBAEd,QAAA,EAA8D;AAC9D,EAAA,MAAM,CAAA,GAAI,QAAA;AACV,EAAA,IAAI,CAAA,CAAE,WAAW,wBAAA,EAA0B;AACzC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,+BAAA,EAAkC,CAAA,CAAE,MAAM,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AAEA,EAAA,OAAO,CAAA;AACT;;;;"}