@backstage/core-plugin-api 1.11.2-next.1 → 1.12.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,18 @@
1
1
  # @backstage/core-plugin-api
2
2
 
3
+ ## 1.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 83439b1: All route references are now forwards compatible with the new frontend system, i.e. `@backstage/frontend-plugin-api`. This means they no longer need to be converted with `convertLegacyRouteRef` or `convertLegacyRouteRefs` from `@backstage/core-compat-api`.
8
+
9
+ ### Patch Changes
10
+
11
+ - b2bef92: Convert all enums to erasable-syntax compliant patterns
12
+ - 05f60e1: Refactored constructor parameter properties to explicit property declarations for compatibility with TypeScript's `erasableSyntaxOnly` setting. This internal refactoring maintains all existing functionality while ensuring TypeScript compilation compatibility.
13
+ - Updated dependencies
14
+ - @backstage/config@1.3.6
15
+
3
16
  ## 1.11.2-next.1
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1386,6 +1386,10 @@ type RouteRef<Params extends AnyParams = any> = {
1386
1386
  $$routeRefType: 'absolute';
1387
1387
  /** @deprecated access to this property will be removed in the future */
1388
1388
  params: ParamKeys<Params>;
1389
+ /** Compatibility field for new frontend system */
1390
+ readonly $$type: '@backstage/RouteRef';
1391
+ /** Compatibility field for new frontend system */
1392
+ readonly T: Params;
1389
1393
  };
1390
1394
  /**
1391
1395
  * Descriptor of a route relative to an absolute {@link RouteRef}.
@@ -1404,6 +1408,10 @@ type SubRouteRef<Params extends AnyParams = any> = {
1404
1408
  path: string;
1405
1409
  /** @deprecated access to this property will be removed in the future */
1406
1410
  params: ParamKeys<Params>;
1411
+ /** Compatibility field for new frontend system */
1412
+ readonly $$type: '@backstage/SubRouteRef';
1413
+ /** Compatibility field for new frontend system */
1414
+ readonly T: Params;
1407
1415
  };
1408
1416
  /**
1409
1417
  * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.
@@ -1420,6 +1428,10 @@ type ExternalRouteRef<Params extends AnyParams = any, Optional extends boolean =
1420
1428
  /** @deprecated access to this property will be removed in the future */
1421
1429
  params: ParamKeys<Params>;
1422
1430
  optional?: Optional;
1431
+ /** Compatibility field for new frontend system */
1432
+ readonly $$type: '@backstage/ExternalRouteRef';
1433
+ /** Compatibility field for new frontend system */
1434
+ readonly T: Params;
1423
1435
  };
1424
1436
 
1425
1437
  /**
@@ -13,11 +13,39 @@ class ExternalRouteRefImpl {
13
13
  this.defaultTarget = defaultTarget;
14
14
  }
15
15
  toString() {
16
+ if (this.#nfsId) {
17
+ return `externalRouteRef{id=${this.#nfsId},legacyId=${this.id}}`;
18
+ }
16
19
  return `routeRef{type=external,id=${this.id}}`;
17
20
  }
18
21
  getDefaultTarget() {
19
22
  return this.defaultTarget;
20
23
  }
24
+ // NFS implementation below
25
+ $$type = "@backstage/ExternalRouteRef";
26
+ version = "v1";
27
+ T = void 0;
28
+ #nfsId = void 0;
29
+ getParams() {
30
+ return this.params;
31
+ }
32
+ getDescription() {
33
+ if (this.#nfsId) {
34
+ return this.#nfsId;
35
+ }
36
+ return this.id;
37
+ }
38
+ setId(newId) {
39
+ if (!newId) {
40
+ throw new Error(`ExternalRouteRef id must be a non-empty string`);
41
+ }
42
+ if (this.#nfsId && this.#nfsId !== newId) {
43
+ throw new Error(
44
+ `ExternalRouteRef was referenced twice as both '${this.#nfsId}' and '${newId}'`
45
+ );
46
+ }
47
+ this.#nfsId = newId;
48
+ }
21
49
  }
22
50
  function createExternalRouteRef(options) {
23
51
  return new ExternalRouteRefImpl(
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalRouteRef.esm.js","sources":["../../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 {\n ExternalRouteRef,\n routeRefType,\n AnyParams,\n ParamKeys,\n OptionalParams,\n} from './types';\n\n/**\n * @internal\n */\nexport class ExternalRouteRefImpl<\n Params extends AnyParams,\n Optional extends boolean,\n> implements ExternalRouteRef<Params, Optional>\n{\n // The marker is used for type checking while the symbol is used at runtime.\n declare $$routeRefType: 'external';\n readonly [routeRefType] = 'external';\n\n private readonly id: string;\n readonly params: ParamKeys<Params>;\n readonly optional: Optional;\n readonly defaultTarget: string | undefined;\n\n constructor(\n id: string,\n params: ParamKeys<Params>,\n optional: Optional,\n defaultTarget: string | undefined,\n ) {\n this.id = id;\n this.params = params;\n this.optional = optional;\n this.defaultTarget = defaultTarget;\n }\n\n toString() {\n return `routeRef{type=external,id=${this.id}}`;\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 Params extends { [param in ParamKey]: string },\n Optional extends boolean = false,\n ParamKey extends string = never,\n>(options: {\n /**\n * An identifier for this route, used to identify it in error messages\n */\n id: string;\n\n /**\n * The parameters that will be provided to the external route reference.\n */\n params?: ParamKey[];\n\n /**\n * Whether or not this route is optional, defaults to false.\n *\n * Optional external routes are not required to be bound in the app, and\n * if they aren't, `useRouteRef` will return `undefined`.\n */\n optional?: Optional;\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<OptionalParams<Params>, Optional> {\n return new ExternalRouteRefImpl(\n options.id,\n (options.params ?? []) as ParamKeys<OptionalParams<Params>>,\n Boolean(options.optional) as Optional,\n options?.defaultTarget,\n );\n}\n"],"names":[],"mappings":";;AA2BO,MAAM,oBAAA,CAIb;AAAA,EAGE,CAAU,YAAY,IAAI,UAAA;AAAA,EAET,EAAA;AAAA,EACR,MAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EAET,WAAA,CACE,EAAA,EACA,MAAA,EACA,QAAA,EACA,aAAA,EACA;AACA,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IAAA,IAAA,CAAK,aAAA,GAAgB,aAAA;AAAA,EACvB;AAAA,EAEA,QAAA,GAAW;AACT,IAAA,OAAO,CAAA,0BAAA,EAA6B,KAAK,EAAE,CAAA,CAAA,CAAA;AAAA,EAC7C;AAAA,EAEA,gBAAA,GAAmB;AACjB,IAAA,OAAO,IAAA,CAAK,aAAA;AAAA,EACd;AACF;AAYO,SAAS,uBAId,OAAA,EA0BqD;AACrD,EAAA,OAAO,IAAI,oBAAA;AAAA,IACT,OAAA,CAAQ,EAAA;AAAA,IACP,OAAA,CAAQ,UAAU,EAAC;AAAA,IACpB,OAAA,CAAQ,QAAQ,QAAQ,CAAA;AAAA,IACxB,OAAA,EAAS;AAAA,GACX;AACF;;;;"}
1
+ {"version":3,"file":"ExternalRouteRef.esm.js","sources":["../../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 {\n ExternalRouteRef,\n routeRefType,\n AnyParams,\n ParamKeys,\n OptionalParams,\n} from './types';\n\n/**\n * @internal\n */\nexport class ExternalRouteRefImpl<\n Params extends AnyParams,\n Optional extends boolean,\n> implements ExternalRouteRef<Params, Optional>\n{\n // The marker is used for type checking while the symbol is used at runtime.\n declare $$routeRefType: 'external';\n readonly [routeRefType] = 'external';\n\n private readonly id: string;\n readonly params: ParamKeys<Params>;\n readonly optional: Optional;\n readonly defaultTarget: string | undefined;\n\n constructor(\n id: string,\n params: ParamKeys<Params>,\n optional: Optional,\n defaultTarget: string | undefined,\n ) {\n this.id = id;\n this.params = params;\n this.optional = optional;\n this.defaultTarget = defaultTarget;\n }\n\n toString() {\n if (this.#nfsId) {\n return `externalRouteRef{id=${this.#nfsId},legacyId=${this.id}}`;\n }\n return `routeRef{type=external,id=${this.id}}`;\n }\n\n getDefaultTarget() {\n return this.defaultTarget;\n }\n\n // NFS implementation below\n readonly $$type = '@backstage/ExternalRouteRef';\n readonly version = 'v1';\n readonly T = undefined as any;\n\n #nfsId: string | undefined = undefined;\n\n getParams(): string[] {\n return this.params as string[];\n }\n getDescription(): string {\n if (this.#nfsId) {\n return this.#nfsId;\n }\n return this.id;\n }\n setId(newId: string) {\n if (!newId) {\n throw new Error(`ExternalRouteRef id must be a non-empty string`);\n }\n if (this.#nfsId && this.#nfsId !== newId) {\n throw new Error(\n `ExternalRouteRef was referenced twice as both '${\n this.#nfsId\n }' and '${newId}'`,\n );\n }\n this.#nfsId = newId;\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 Params extends { [param in ParamKey]: string },\n Optional extends boolean = false,\n ParamKey extends string = never,\n>(options: {\n /**\n * An identifier for this route, used to identify it in error messages\n */\n id: string;\n\n /**\n * The parameters that will be provided to the external route reference.\n */\n params?: ParamKey[];\n\n /**\n * Whether or not this route is optional, defaults to false.\n *\n * Optional external routes are not required to be bound in the app, and\n * if they aren't, `useRouteRef` will return `undefined`.\n */\n optional?: Optional;\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<OptionalParams<Params>, Optional> {\n return new ExternalRouteRefImpl(\n options.id,\n (options.params ?? []) as ParamKeys<OptionalParams<Params>>,\n Boolean(options.optional) as Optional,\n options?.defaultTarget,\n ) as ExternalRouteRef<OptionalParams<Params>, Optional>;\n}\n"],"names":[],"mappings":";;AA2BO,MAAM,oBAAA,CAIb;AAAA,EAGE,CAAU,YAAY,IAAI,UAAA;AAAA,EAET,EAAA;AAAA,EACR,MAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EAET,WAAA,CACE,EAAA,EACA,MAAA,EACA,QAAA,EACA,aAAA,EACA;AACA,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IAAA,IAAA,CAAK,aAAA,GAAgB,aAAA;AAAA,EACvB;AAAA,EAEA,QAAA,GAAW;AACT,IAAA,IAAI,KAAK,MAAA,EAAQ;AACf,MAAA,OAAO,CAAA,oBAAA,EAAuB,IAAA,CAAK,MAAM,CAAA,UAAA,EAAa,KAAK,EAAE,CAAA,CAAA,CAAA;AAAA,IAC/D;AACA,IAAA,OAAO,CAAA,0BAAA,EAA6B,KAAK,EAAE,CAAA,CAAA,CAAA;AAAA,EAC7C;AAAA,EAEA,gBAAA,GAAmB;AACjB,IAAA,OAAO,IAAA,CAAK,aAAA;AAAA,EACd;AAAA;AAAA,EAGS,MAAA,GAAS,6BAAA;AAAA,EACT,OAAA,GAAU,IAAA;AAAA,EACV,CAAA,GAAI,MAAA;AAAA,EAEb,MAAA,GAA6B,MAAA;AAAA,EAE7B,SAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EACA,cAAA,GAAyB;AACvB,IAAA,IAAI,KAAK,MAAA,EAAQ;AACf,MAAA,OAAO,IAAA,CAAK,MAAA;AAAA,IACd;AACA,IAAA,OAAO,IAAA,CAAK,EAAA;AAAA,EACd;AAAA,EACA,MAAM,KAAA,EAAe;AACnB,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,MAAM,CAAA,8CAAA,CAAgD,CAAA;AAAA,IAClE;AACA,IAAA,IAAI,IAAA,CAAK,MAAA,IAAU,IAAA,CAAK,MAAA,KAAW,KAAA,EAAO;AACxC,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,+CAAA,EACE,IAAA,CAAK,MACP,CAAA,OAAA,EAAU,KAAK,CAAA,CAAA;AAAA,OACjB;AAAA,IACF;AACA,IAAA,IAAA,CAAK,MAAA,GAAS,KAAA;AAAA,EAChB;AACF;AAYO,SAAS,uBAId,OAAA,EA0BqD;AACrD,EAAA,OAAO,IAAI,oBAAA;AAAA,IACT,OAAA,CAAQ,EAAA;AAAA,IACP,OAAA,CAAQ,UAAU,EAAC;AAAA,IACpB,OAAA,CAAQ,QAAQ,QAAQ,CAAA;AAAA,IACxB,OAAA,EAAS;AAAA,GACX;AACF;;;;"}
@@ -12,8 +12,37 @@ class RouteRefImpl {
12
12
  return this.id;
13
13
  }
14
14
  toString() {
15
+ if (this.#nfsId) {
16
+ return `routeRef{id=${this.#nfsId},legacyId=${this.id}}`;
17
+ }
15
18
  return `routeRef{type=absolute,id=${this.id}}`;
16
19
  }
20
+ // NFS implementation below
21
+ $$type = "@backstage/RouteRef";
22
+ version = "v1";
23
+ T = void 0;
24
+ alias = void 0;
25
+ #nfsId = void 0;
26
+ getParams() {
27
+ return this.params;
28
+ }
29
+ getDescription() {
30
+ if (this.#nfsId) {
31
+ return this.#nfsId;
32
+ }
33
+ return this.id;
34
+ }
35
+ setId(newId) {
36
+ if (!newId) {
37
+ throw new Error(`RouteRef id must be a non-empty string`);
38
+ }
39
+ if (this.#nfsId && this.#nfsId !== newId) {
40
+ throw new Error(
41
+ `RouteRef was referenced twice as both '${this.#nfsId}' and '${newId}'`
42
+ );
43
+ }
44
+ this.#nfsId = newId;
45
+ }
17
46
  }
18
47
  function createRouteRef(config) {
19
48
  return new RouteRefImpl(
@@ -1 +1 @@
1
- {"version":3,"file":"RouteRef.esm.js","sources":["../../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 {\n RouteRef,\n routeRefType,\n AnyParams,\n ParamKeys,\n OptionalParams,\n} from './types';\n\n/**\n * @internal\n */\nexport class RouteRefImpl<Params extends AnyParams>\n implements RouteRef<Params>\n{\n // The marker is used for type checking while the symbol is used at runtime.\n declare $$routeRefType: 'absolute';\n readonly [routeRefType] = 'absolute';\n\n private readonly id: string;\n readonly params: ParamKeys<Params>;\n\n constructor(id: string, params: ParamKeys<Params>) {\n this.id = id;\n this.params = params;\n }\n\n get title() {\n return this.id;\n }\n\n toString() {\n return `routeRef{type=absolute,id=${this.id}}`;\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 Params extends { [param in ParamKey]: string },\n // ParamKey is here to make sure the Params type properly has its keys narrowed down\n // to only the elements of params. Defaulting to never makes sure we end up with\n // Param = {} if the params array is empty.\n ParamKey extends string = never,\n>(config: {\n /** The id of the route ref, used to identify it when printed */\n id: string;\n /** A list of parameter names that the path that this route ref is bound to must contain */\n params?: ParamKey[];\n}): RouteRef<OptionalParams<Params>> {\n return new RouteRefImpl(\n config.id,\n (config.params ?? []) as ParamKeys<OptionalParams<Params>>,\n );\n}\n"],"names":[],"mappings":";;AA2BO,MAAM,YAAA,CAEb;AAAA,EAGE,CAAU,YAAY,IAAI,UAAA;AAAA,EAET,EAAA;AAAA,EACR,MAAA;AAAA,EAET,WAAA,CAAY,IAAY,MAAA,EAA2B;AACjD,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,IAAI,KAAA,GAAQ;AACV,IAAA,OAAO,IAAA,CAAK,EAAA;AAAA,EACd;AAAA,EAEA,QAAA,GAAW;AACT,IAAA,OAAO,CAAA,0BAAA,EAA6B,KAAK,EAAE,CAAA,CAAA,CAAA;AAAA,EAC7C;AACF;AAQO,SAAS,eAQd,MAAA,EAKmC;AACnC,EAAA,OAAO,IAAI,YAAA;AAAA,IACT,MAAA,CAAO,EAAA;AAAA,IACN,MAAA,CAAO,UAAU;AAAC,GACrB;AACF;;;;"}
1
+ {"version":3,"file":"RouteRef.esm.js","sources":["../../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 {\n RouteRef,\n routeRefType,\n AnyParams,\n ParamKeys,\n OptionalParams,\n} from './types';\n\n/**\n * @internal\n */\nexport class RouteRefImpl<Params extends AnyParams>\n implements RouteRef<Params>\n{\n // The marker is used for type checking while the symbol is used at runtime.\n declare $$routeRefType: 'absolute';\n readonly [routeRefType] = 'absolute';\n\n private readonly id: string;\n readonly params: ParamKeys<Params>;\n\n constructor(id: string, params: ParamKeys<Params>) {\n this.id = id;\n this.params = params;\n }\n\n get title() {\n return this.id;\n }\n\n toString() {\n if (this.#nfsId) {\n return `routeRef{id=${this.#nfsId},legacyId=${this.id}}`;\n }\n return `routeRef{type=absolute,id=${this.id}}`;\n }\n\n // NFS implementation below\n readonly $$type = '@backstage/RouteRef';\n readonly version = 'v1';\n readonly T = undefined as any;\n readonly alias = undefined;\n\n #nfsId: string | undefined = undefined;\n\n getParams() {\n return this.params;\n }\n getDescription() {\n if (this.#nfsId) {\n return this.#nfsId;\n }\n return this.id;\n }\n setId(newId: string) {\n if (!newId) {\n throw new Error(`RouteRef id must be a non-empty string`);\n }\n if (this.#nfsId && this.#nfsId !== newId) {\n throw new Error(\n `RouteRef was referenced twice as both '${this.#nfsId}' and '${newId}'`,\n );\n }\n this.#nfsId = newId;\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 Params extends { [param in ParamKey]: string },\n // ParamKey is here to make sure the Params type properly has its keys narrowed down\n // to only the elements of params. Defaulting to never makes sure we end up with\n // Param = {} if the params array is empty.\n ParamKey extends string = never,\n>(config: {\n /** The id of the route ref, used to identify it when printed */\n id: string;\n /** A list of parameter names that the path that this route ref is bound to must contain */\n params?: ParamKey[];\n}): RouteRef<OptionalParams<Params>> {\n return new RouteRefImpl(\n config.id,\n (config.params ?? []) as ParamKeys<OptionalParams<Params>>,\n ) as RouteRef<OptionalParams<Params>>;\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AA0C,IAAA,CAAK,MAAM,CAAA,OAAA,EAAU,KAAK,CAAA,CAAA;AAAA,OACtE;AAAA,IACF;AACA,IAAA,IAAA,CAAK,MAAA,GAAS,KAAA;AAAA,EAChB;AACF;AAQO,SAAS,eAQd,MAAA,EAKmC;AACnC,EAAA,OAAO,IAAI,YAAA;AAAA,IACT,MAAA,CAAO,EAAA;AAAA,IACN,MAAA,CAAO,UAAU;AAAC,GACrB;AACF;;;;"}
@@ -16,6 +16,19 @@ class SubRouteRefImpl {
16
16
  toString() {
17
17
  return `routeRef{type=sub,id=${this.id}}`;
18
18
  }
19
+ // NFS implementation below
20
+ $$type = "@backstage/SubRouteRef";
21
+ version = "v1";
22
+ T = void 0;
23
+ getParams() {
24
+ return this.params;
25
+ }
26
+ getParent() {
27
+ return this.parent;
28
+ }
29
+ getDescription() {
30
+ return `at ${this.path} with parent ${this.parent}`;
31
+ }
19
32
  }
20
33
  function createSubRouteRef(config) {
21
34
  const { id, path, parent } = config;
@@ -1 +1 @@
1
- {"version":3,"file":"SubRouteRef.esm.js","sources":["../../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 {\n AnyParams,\n OptionalParams,\n ParamKeys,\n RouteRef,\n routeRefType,\n SubRouteRef,\n} from './types';\n\n// Should match the pattern in react-router\nconst PARAM_PATTERN = /^\\w+$/;\n\n/**\n * @internal\n */\nexport class SubRouteRefImpl<Params extends AnyParams>\n implements SubRouteRef<Params>\n{\n // The marker is used for type checking while the symbol is used at runtime.\n declare $$routeRefType: 'sub';\n readonly [routeRefType] = 'sub';\n\n private readonly id: string;\n readonly path: string;\n readonly parent: RouteRef;\n readonly params: ParamKeys<Params>;\n\n constructor(\n id: string,\n path: string,\n parent: RouteRef,\n params: ParamKeys<Params>,\n ) {\n this.id = id;\n this.path = path;\n this.parent = parent;\n this.params = params;\n }\n\n toString() {\n return `routeRef{type=sub,id=${this.id}}`;\n }\n}\n\n/**\n * Used in {@link PathParams} type declaration.\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamPart<S extends string> = S extends `:${infer Param}`\n ? Param\n : never;\n\n/**\n * Used in {@link PathParams} type declaration.\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamNames<S extends string> =\n 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 * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type 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 * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type MergeParams<\n P1 extends { [param in string]: string },\n P2 extends AnyParams,\n> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);\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 * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type MakeSubRouteRef<\n Params extends { [param in string]: string },\n ParentParams extends AnyParams,\n> = keyof Params & keyof ParentParams extends never\n ? SubRouteRef<OptionalParams<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 AnyParams = never,\n>(config: {\n id: string;\n path: Path;\n parent: RouteRef<ParentParams>;\n}): MakeSubRouteRef<PathParams<Path>, ParentParams> {\n const { id, path, parent } = config;\n type Params = PathParams<Path>;\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 = [...parent.params, ...pathParams];\n\n if (parent.params.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 id,\n path,\n parent,\n params as ParamKeys<MergeParams<Params, ParentParams>>,\n ) as SubRouteRef<OptionalParams<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":";;AA0BA,MAAM,aAAA,GAAgB,OAAA;AAKf,MAAM,eAAA,CAEb;AAAA,EAGE,CAAU,YAAY,IAAI,KAAA;AAAA,EAET,EAAA;AAAA,EACR,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EAET,WAAA,CACE,EAAA,EACA,IAAA,EACA,MAAA,EACA,MAAA,EACA;AACA,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,QAAA,GAAW;AACT,IAAA,OAAO,CAAA,qBAAA,EAAwB,KAAK,EAAE,CAAA,CAAA,CAAA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,EAAA,OAAO,WAAA;AACT;;;;"}
1
+ {"version":3,"file":"SubRouteRef.esm.js","sources":["../../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 {\n AnyParams,\n OptionalParams,\n ParamKeys,\n RouteRef,\n routeRefType,\n SubRouteRef,\n} from './types';\n\n// Should match the pattern in react-router\nconst PARAM_PATTERN = /^\\w+$/;\n\n/**\n * @internal\n */\nexport class SubRouteRefImpl<Params extends AnyParams>\n implements SubRouteRef<Params>\n{\n // The marker is used for type checking while the symbol is used at runtime.\n declare $$routeRefType: 'sub';\n readonly [routeRefType] = 'sub';\n\n private readonly id: string;\n readonly path: string;\n readonly parent: RouteRef;\n readonly params: ParamKeys<Params>;\n\n constructor(\n id: string,\n path: string,\n parent: RouteRef,\n params: ParamKeys<Params>,\n ) {\n this.id = id;\n this.path = path;\n this.parent = parent;\n this.params = params;\n }\n\n toString() {\n return `routeRef{type=sub,id=${this.id}}`;\n }\n\n // NFS implementation below\n readonly $$type = '@backstage/SubRouteRef';\n readonly version = 'v1';\n readonly T = undefined as any;\n\n getParams(): string[] {\n return this.params as string[];\n }\n getParent(): RouteRef {\n return this.parent;\n }\n getDescription(): string {\n return `at ${this.path} with parent ${this.parent}`;\n }\n}\n\n/**\n * Used in {@link PathParams} type declaration.\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamPart<S extends string> = S extends `:${infer Param}`\n ? Param\n : never;\n\n/**\n * Used in {@link PathParams} type declaration.\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamNames<S extends string> =\n 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 * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type 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 * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type MergeParams<\n P1 extends { [param in string]: string },\n P2 extends AnyParams,\n> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);\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 * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type MakeSubRouteRef<\n Params extends { [param in string]: string },\n ParentParams extends AnyParams,\n> = keyof Params & keyof ParentParams extends never\n ? SubRouteRef<OptionalParams<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 AnyParams = never,\n>(config: {\n id: string;\n path: Path;\n parent: RouteRef<ParentParams>;\n}): MakeSubRouteRef<PathParams<Path>, ParentParams> {\n const { id, path, parent } = config;\n type Params = PathParams<Path>;\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 = [...parent.params, ...pathParams];\n\n if (parent.params.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 id,\n path,\n parent,\n params as ParamKeys<MergeParams<Params, ParentParams>>,\n );\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":";;AA0BA,MAAM,aAAA,GAAgB,OAAA;AAKf,MAAM,eAAA,CAEb;AAAA,EAGE,CAAU,YAAY,IAAI,KAAA;AAAA,EAET,EAAA;AAAA,EACR,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EAET,WAAA,CACE,EAAA,EACA,IAAA,EACA,MAAA,EACA,MAAA,EACA;AACA,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,QAAA,GAAW;AACT,IAAA,OAAO,CAAA,qBAAA,EAAwB,KAAK,EAAE,CAAA,CAAA,CAAA;AAAA,EACxC;AAAA;AAAA,EAGS,MAAA,GAAS,wBAAA;AAAA,EACT,OAAA,GAAU,IAAA;AAAA,EACV,CAAA,GAAI,MAAA;AAAA,EAEb,SAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EACA,SAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EACA,cAAA,GAAyB;AACvB,IAAA,OAAO,CAAA,GAAA,EAAM,IAAA,CAAK,IAAI,CAAA,aAAA,EAAgB,KAAK,MAAM,CAAA,CAAA;AAAA,EACnD;AACF;AA0DO,SAAS,kBAGd,MAAA,EAIkD;AAClD,EAAA,MAAM,EAAE,EAAA,EAAI,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"],"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":["../../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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/core-plugin-api",
3
- "version": "1.11.2-next.1",
3
+ "version": "1.12.0",
4
4
  "description": "Core API used by Backstage plugins",
5
5
  "backstage": {
6
6
  "role": "web-library"
@@ -57,16 +57,18 @@
57
57
  "test": "backstage-cli package test"
58
58
  },
59
59
  "dependencies": {
60
- "@backstage/config": "1.3.6-next.0",
61
- "@backstage/errors": "1.2.7",
62
- "@backstage/types": "1.2.2",
63
- "@backstage/version-bridge": "1.0.11",
64
- "history": "^5.0.0"
60
+ "@backstage/config": "^1.3.6",
61
+ "@backstage/errors": "^1.2.7",
62
+ "@backstage/types": "^1.2.2",
63
+ "@backstage/version-bridge": "^1.0.11",
64
+ "history": "^5.0.0",
65
+ "zod": "^3.22.4"
65
66
  },
66
67
  "devDependencies": {
67
- "@backstage/cli": "0.34.5-next.1",
68
- "@backstage/core-app-api": "1.19.2-next.1",
69
- "@backstage/test-utils": "1.7.13-next.0",
68
+ "@backstage/cli": "^0.34.5",
69
+ "@backstage/core-app-api": "^1.19.2",
70
+ "@backstage/frontend-plugin-api": "^0.13.0",
71
+ "@backstage/test-utils": "^1.7.13",
70
72
  "@testing-library/dom": "^10.0.0",
71
73
  "@testing-library/jest-dom": "^6.0.0",
72
74
  "@testing-library/react": "^16.0.0",