@backstage/core-plugin-api 1.7.0 → 1.8.0-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 +17 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +89 -2
- package/dist/alpha.esm.js +334 -25
- package/dist/alpha.esm.js.map +1 -1
- package/dist/esm/{StorageApi-2de4f480.esm.js → types-08c0ee05.esm.js} +8 -3
- package/dist/esm/types-08c0ee05.esm.js.map +1 -0
- package/dist/index.d.ts +23 -4
- package/dist/index.esm.js +2 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -9
- package/dist/esm/StorageApi-2de4f480.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @backstage/core-plugin-api
|
|
2
2
|
|
|
3
|
+
## 1.8.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1e5b7d993a: `IconComponent` can now have a `fontSize` of `inherit`, which is useful for in-line icons.
|
|
8
|
+
- cb6db75bc2: Introduced `AnyRouteRefParams` as a replacement for `AnyParams`, which is now deprecated.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 6c2b872153: Add official support for React 18.
|
|
13
|
+
- cb6db75bc2: Deprecated several types related to the routing system that are scheduled to be removed, as well as several fields on the route ref types themselves.
|
|
14
|
+
- 68fc9dc60e: Added a new `/alpha` export `convertLegacyRouteRef`, which is a temporary utility to allow existing route refs to be used with the new experimental packages.
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/version-bridge@1.0.7-next.0
|
|
17
|
+
- @backstage/config@1.1.1
|
|
18
|
+
- @backstage/types@1.1.1
|
|
19
|
+
|
|
3
20
|
## 1.7.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TranslationRef as TranslationRef$1, TranslationMessages as TranslationMessages$1 } from '@backstage/core-plugin-api/alpha';
|
|
2
|
-
import { ApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
import { ApiRef, AnyRouteRefParams as AnyRouteRefParams$1, RouteRef as RouteRef$1, SubRouteRef as SubRouteRef$1, ExternalRouteRef as ExternalRouteRef$1 } from '@backstage/core-plugin-api';
|
|
3
3
|
import { Observable } from '@backstage/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -391,4 +391,91 @@ declare const useTranslationRef: <TMessages extends {
|
|
|
391
391
|
t: TranslationFunction<TMessages>;
|
|
392
392
|
};
|
|
393
393
|
|
|
394
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Catch-all type for route params.
|
|
396
|
+
*
|
|
397
|
+
* @public
|
|
398
|
+
*/
|
|
399
|
+
type AnyRouteRefParams = {
|
|
400
|
+
[param in string]: string;
|
|
401
|
+
} | undefined;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Absolute route reference.
|
|
405
|
+
*
|
|
406
|
+
* @remarks
|
|
407
|
+
*
|
|
408
|
+
* See {@link https://backstage.io/docs/plugins/composability#routing-system}.
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
412
|
+
interface RouteRef<TParams extends AnyRouteRefParams = AnyRouteRefParams> {
|
|
413
|
+
readonly $$type: '@backstage/RouteRef';
|
|
414
|
+
readonly T: TParams;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Descriptor of a route relative to an absolute {@link RouteRef}.
|
|
419
|
+
*
|
|
420
|
+
* @remarks
|
|
421
|
+
*
|
|
422
|
+
* See {@link https://backstage.io/docs/plugins/composability#routing-system}.
|
|
423
|
+
*
|
|
424
|
+
* @public
|
|
425
|
+
*/
|
|
426
|
+
interface SubRouteRef<TParams extends AnyRouteRefParams = AnyRouteRefParams> {
|
|
427
|
+
readonly $$type: '@backstage/SubRouteRef';
|
|
428
|
+
readonly T: TParams;
|
|
429
|
+
readonly path: string;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.
|
|
434
|
+
*
|
|
435
|
+
* @remarks
|
|
436
|
+
*
|
|
437
|
+
* See {@link https://backstage.io/docs/plugins/composability#routing-system}.
|
|
438
|
+
*
|
|
439
|
+
* @public
|
|
440
|
+
*/
|
|
441
|
+
interface ExternalRouteRef<TParams extends AnyRouteRefParams = AnyRouteRefParams, TOptional extends boolean = boolean> {
|
|
442
|
+
readonly $$type: '@backstage/ExternalRouteRef';
|
|
443
|
+
readonly T: TParams;
|
|
444
|
+
readonly optional: TOptional;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** @ignore */
|
|
448
|
+
type NewRouteRef<TParams extends AnyRouteRefParams$1 = AnyRouteRefParams$1> = RouteRef<TParams>;
|
|
449
|
+
/** @ignore */
|
|
450
|
+
type NewSubRouteRef<TParams extends AnyRouteRefParams$1 = AnyRouteRefParams$1> = SubRouteRef<TParams>;
|
|
451
|
+
/** @ignore */
|
|
452
|
+
type NewExternalRouteRef<TParams extends AnyRouteRefParams$1 = AnyRouteRefParams$1, TOptional extends boolean = boolean> = ExternalRouteRef<TParams, TOptional>;
|
|
453
|
+
/**
|
|
454
|
+
* A temporary helper to convert a legacy route ref to the new system.
|
|
455
|
+
*
|
|
456
|
+
* @public
|
|
457
|
+
* @remarks
|
|
458
|
+
*
|
|
459
|
+
* In the future the legacy createRouteRef will instead create refs compatible with both systems.
|
|
460
|
+
*/
|
|
461
|
+
declare function convertLegacyRouteRef<TParams extends AnyRouteRefParams$1>(ref: RouteRef$1<TParams>): NewRouteRef<TParams>;
|
|
462
|
+
/**
|
|
463
|
+
* A temporary helper to convert a legacy sub route ref to the new system.
|
|
464
|
+
*
|
|
465
|
+
* @public
|
|
466
|
+
* @remarks
|
|
467
|
+
*
|
|
468
|
+
* In the future the legacy createSubRouteRef will instead create refs compatible with both systems.
|
|
469
|
+
*/
|
|
470
|
+
declare function convertLegacyRouteRef<TParams extends AnyRouteRefParams$1>(ref: SubRouteRef$1<TParams>): NewSubRouteRef<TParams>;
|
|
471
|
+
/**
|
|
472
|
+
* A temporary helper to convert a legacy external route ref to the new system.
|
|
473
|
+
*
|
|
474
|
+
* @public
|
|
475
|
+
* @remarks
|
|
476
|
+
*
|
|
477
|
+
* In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.
|
|
478
|
+
*/
|
|
479
|
+
declare function convertLegacyRouteRef<TParams extends AnyRouteRefParams$1, TOptional extends boolean>(ref: ExternalRouteRef$1<TParams, TOptional>): NewExternalRouteRef<TParams, TOptional>;
|
|
480
|
+
|
|
481
|
+
export { AppLanguageApi, TranslationApi, TranslationFunction, TranslationMessages, TranslationMessagesOptions, TranslationRef, TranslationRefOptions, TranslationResource, TranslationResourceOptions, TranslationSnapshot, appLanguageApiRef, convertLegacyRouteRef, createTranslationMessages, createTranslationRef, createTranslationResource, translationApiRef, useTranslationRef };
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
import { u as useApi,
|
|
2
|
+
import { u as useApi, s as errorApiRef, r as routeRefType } from './esm/types-08c0ee05.esm.js';
|
|
3
3
|
import { createApiRef } from '@backstage/core-plugin-api';
|
|
4
|
+
import 'react-router-dom';
|
|
4
5
|
import '@backstage/version-bridge';
|
|
5
6
|
|
|
6
7
|
function createTranslationMessages(options) {
|
|
@@ -31,61 +32,61 @@ function createTranslationResource(options) {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
var __defProp = Object.defineProperty;
|
|
35
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
36
|
-
var __publicField = (obj, key, value) => {
|
|
37
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
|
+
var __defProp$3 = Object.defineProperty;
|
|
36
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
37
|
+
var __publicField$3 = (obj, key, value) => {
|
|
38
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
38
39
|
return value;
|
|
39
40
|
};
|
|
40
|
-
var __accessCheck = (obj, member, msg) => {
|
|
41
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
41
42
|
if (!member.has(obj))
|
|
42
43
|
throw TypeError("Cannot " + msg);
|
|
43
44
|
};
|
|
44
|
-
var __privateGet = (obj, member, getter) => {
|
|
45
|
-
__accessCheck(obj, member, "read from private field");
|
|
45
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
46
|
+
__accessCheck$2(obj, member, "read from private field");
|
|
46
47
|
return getter ? getter.call(obj) : member.get(obj);
|
|
47
48
|
};
|
|
48
|
-
var __privateAdd = (obj, member, value) => {
|
|
49
|
+
var __privateAdd$2 = (obj, member, value) => {
|
|
49
50
|
if (member.has(obj))
|
|
50
51
|
throw TypeError("Cannot add the same private member more than once");
|
|
51
52
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
52
53
|
};
|
|
53
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
54
|
-
__accessCheck(obj, member, "write to private field");
|
|
54
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
55
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
55
56
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
56
57
|
return value;
|
|
57
58
|
};
|
|
58
|
-
var _id, _messages, _resources;
|
|
59
|
+
var _id$1, _messages, _resources;
|
|
59
60
|
class TranslationRefImpl {
|
|
60
61
|
constructor(options) {
|
|
61
|
-
__privateAdd(this, _id, void 0);
|
|
62
|
-
__privateAdd(this, _messages, void 0);
|
|
63
|
-
__privateAdd(this, _resources, void 0);
|
|
64
|
-
__publicField(this, "$$type", "@backstage/TranslationRef");
|
|
65
|
-
__publicField(this, "version", "v1");
|
|
66
|
-
__privateSet(this, _id, options.id);
|
|
67
|
-
__privateSet(this, _messages, options.messages);
|
|
62
|
+
__privateAdd$2(this, _id$1, void 0);
|
|
63
|
+
__privateAdd$2(this, _messages, void 0);
|
|
64
|
+
__privateAdd$2(this, _resources, void 0);
|
|
65
|
+
__publicField$3(this, "$$type", "@backstage/TranslationRef");
|
|
66
|
+
__publicField$3(this, "version", "v1");
|
|
67
|
+
__privateSet$2(this, _id$1, options.id);
|
|
68
|
+
__privateSet$2(this, _messages, options.messages);
|
|
68
69
|
}
|
|
69
70
|
get id() {
|
|
70
|
-
return __privateGet(this, _id);
|
|
71
|
+
return __privateGet$2(this, _id$1);
|
|
71
72
|
}
|
|
72
73
|
get T() {
|
|
73
74
|
throw new Error("Not implemented");
|
|
74
75
|
}
|
|
75
76
|
getDefaultMessages() {
|
|
76
|
-
return __privateGet(this, _messages);
|
|
77
|
+
return __privateGet$2(this, _messages);
|
|
77
78
|
}
|
|
78
79
|
setDefaultResource(resources) {
|
|
79
|
-
__privateSet(this, _resources, resources);
|
|
80
|
+
__privateSet$2(this, _resources, resources);
|
|
80
81
|
}
|
|
81
82
|
getDefaultResource() {
|
|
82
|
-
return __privateGet(this, _resources);
|
|
83
|
+
return __privateGet$2(this, _resources);
|
|
83
84
|
}
|
|
84
85
|
toString() {
|
|
85
86
|
return `TranslationRef{id=${this.id}}`;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
_id = new WeakMap();
|
|
89
|
+
_id$1 = new WeakMap();
|
|
89
90
|
_messages = new WeakMap();
|
|
90
91
|
_resources = new WeakMap();
|
|
91
92
|
function createTranslationRef(config) {
|
|
@@ -174,5 +175,313 @@ const useTranslationRef = (translationRef) => {
|
|
|
174
175
|
return { t: snapshot.t };
|
|
175
176
|
};
|
|
176
177
|
|
|
177
|
-
|
|
178
|
+
const MESSAGE_MARKER = "eHgtF5hmbrXyiEvo";
|
|
179
|
+
function describeParentCallSite(ErrorConstructor = Error) {
|
|
180
|
+
const { stack } = new ErrorConstructor(MESSAGE_MARKER);
|
|
181
|
+
if (!stack) {
|
|
182
|
+
return "<unknown>";
|
|
183
|
+
}
|
|
184
|
+
const startIndex = stack.includes(MESSAGE_MARKER) ? stack.indexOf("\n") + 1 : 0;
|
|
185
|
+
const secondEntryStart = stack.indexOf("\n", stack.indexOf("\n", startIndex) + 1) + 1;
|
|
186
|
+
const secondEntryEnd = stack.indexOf("\n", secondEntryStart);
|
|
187
|
+
const line = stack.substring(secondEntryStart, secondEntryEnd).trim();
|
|
188
|
+
if (!line) {
|
|
189
|
+
return "unknown";
|
|
190
|
+
}
|
|
191
|
+
if (line.includes("(")) {
|
|
192
|
+
return line.substring(line.indexOf("(") + 1, line.indexOf(")"));
|
|
193
|
+
}
|
|
194
|
+
if (line.includes("@")) {
|
|
195
|
+
return line.substring(line.indexOf("@") + 1);
|
|
196
|
+
}
|
|
197
|
+
return line;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
var __defProp$2 = Object.defineProperty;
|
|
201
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
202
|
+
var __publicField$2 = (obj, key, value) => {
|
|
203
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
204
|
+
return value;
|
|
205
|
+
};
|
|
206
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
207
|
+
if (!member.has(obj))
|
|
208
|
+
throw TypeError("Cannot " + msg);
|
|
209
|
+
};
|
|
210
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
211
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
212
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
213
|
+
};
|
|
214
|
+
var __privateAdd$1 = (obj, member, value) => {
|
|
215
|
+
if (member.has(obj))
|
|
216
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
217
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
218
|
+
};
|
|
219
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
220
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
221
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
222
|
+
return value;
|
|
223
|
+
};
|
|
224
|
+
var _id, _params$1, _creationSite, _name, name_get;
|
|
225
|
+
function toInternalRouteRef(resource) {
|
|
226
|
+
const r = resource;
|
|
227
|
+
if (r.$$type !== "@backstage/RouteRef") {
|
|
228
|
+
throw new Error(`Invalid RouteRef, bad type '${r.$$type}'`);
|
|
229
|
+
}
|
|
230
|
+
return r;
|
|
231
|
+
}
|
|
232
|
+
class RouteRefImpl {
|
|
233
|
+
constructor(params = [], creationSite) {
|
|
234
|
+
this.params = params;
|
|
235
|
+
__privateAdd$1(this, _name);
|
|
236
|
+
__publicField$2(this, "$$type", "@backstage/RouteRef");
|
|
237
|
+
__publicField$2(this, "version", "v1");
|
|
238
|
+
__privateAdd$1(this, _id, void 0);
|
|
239
|
+
__privateAdd$1(this, _params$1, void 0);
|
|
240
|
+
__privateAdd$1(this, _creationSite, void 0);
|
|
241
|
+
__privateSet$1(this, _params$1, params);
|
|
242
|
+
__privateSet$1(this, _creationSite, creationSite);
|
|
243
|
+
}
|
|
244
|
+
getParams() {
|
|
245
|
+
return __privateGet$1(this, _params$1);
|
|
246
|
+
}
|
|
247
|
+
getDescription() {
|
|
248
|
+
if (__privateGet$1(this, _id)) {
|
|
249
|
+
return __privateGet$1(this, _id);
|
|
250
|
+
}
|
|
251
|
+
return `created at '${__privateGet$1(this, _creationSite)}'`;
|
|
252
|
+
}
|
|
253
|
+
setId(id) {
|
|
254
|
+
if (!id) {
|
|
255
|
+
throw new Error(`${__privateGet$1(this, _name, name_get)} id must be a non-empty string`);
|
|
256
|
+
}
|
|
257
|
+
if (__privateGet$1(this, _id)) {
|
|
258
|
+
throw new Error(
|
|
259
|
+
`${__privateGet$1(this, _name, name_get)} was referenced twice as both '${__privateGet$1(this, _id)}' and '${id}'`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
__privateSet$1(this, _id, id);
|
|
263
|
+
}
|
|
264
|
+
toString() {
|
|
265
|
+
return `${__privateGet$1(this, _name, name_get)}{${this.getDescription()}}`;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
_id = new WeakMap();
|
|
269
|
+
_params$1 = new WeakMap();
|
|
270
|
+
_creationSite = new WeakMap();
|
|
271
|
+
_name = new WeakSet();
|
|
272
|
+
name_get = function() {
|
|
273
|
+
return this.$$type.slice("@backstage/".length);
|
|
274
|
+
};
|
|
275
|
+
function createRouteRef(config) {
|
|
276
|
+
return new RouteRefImpl(
|
|
277
|
+
config == null ? void 0 : config.params,
|
|
278
|
+
describeParentCallSite()
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
var __defProp$1 = Object.defineProperty;
|
|
283
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
284
|
+
var __publicField$1 = (obj, key, value) => {
|
|
285
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
286
|
+
return value;
|
|
287
|
+
};
|
|
288
|
+
var __accessCheck = (obj, member, msg) => {
|
|
289
|
+
if (!member.has(obj))
|
|
290
|
+
throw TypeError("Cannot " + msg);
|
|
291
|
+
};
|
|
292
|
+
var __privateGet = (obj, member, getter) => {
|
|
293
|
+
__accessCheck(obj, member, "read from private field");
|
|
294
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
295
|
+
};
|
|
296
|
+
var __privateAdd = (obj, member, value) => {
|
|
297
|
+
if (member.has(obj))
|
|
298
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
299
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
300
|
+
};
|
|
301
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
302
|
+
__accessCheck(obj, member, "write to private field");
|
|
303
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
304
|
+
return value;
|
|
305
|
+
};
|
|
306
|
+
var _params, _parent;
|
|
307
|
+
const PARAM_PATTERN = /^\w+$/;
|
|
308
|
+
function toInternalSubRouteRef(resource) {
|
|
309
|
+
const r = resource;
|
|
310
|
+
if (r.$$type !== "@backstage/SubRouteRef") {
|
|
311
|
+
throw new Error(`Invalid SubRouteRef, bad type '${r.$$type}'`);
|
|
312
|
+
}
|
|
313
|
+
return r;
|
|
314
|
+
}
|
|
315
|
+
class SubRouteRefImpl {
|
|
316
|
+
constructor(path, params, parent) {
|
|
317
|
+
this.path = path;
|
|
318
|
+
__publicField$1(this, "$$type", "@backstage/SubRouteRef");
|
|
319
|
+
__publicField$1(this, "version", "v1");
|
|
320
|
+
__privateAdd(this, _params, void 0);
|
|
321
|
+
__privateAdd(this, _parent, void 0);
|
|
322
|
+
__privateSet(this, _params, params);
|
|
323
|
+
__privateSet(this, _parent, parent);
|
|
324
|
+
}
|
|
325
|
+
getParams() {
|
|
326
|
+
return __privateGet(this, _params);
|
|
327
|
+
}
|
|
328
|
+
getParent() {
|
|
329
|
+
return __privateGet(this, _parent);
|
|
330
|
+
}
|
|
331
|
+
getDescription() {
|
|
332
|
+
const parent = toInternalRouteRef(__privateGet(this, _parent));
|
|
333
|
+
return `at ${this.path} with parent ${parent.getDescription()}`;
|
|
334
|
+
}
|
|
335
|
+
toString() {
|
|
336
|
+
return `SubRouteRef{${this.getDescription()}}`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
_params = new WeakMap();
|
|
340
|
+
_parent = new WeakMap();
|
|
341
|
+
function createSubRouteRef(config) {
|
|
342
|
+
const { path, parent } = config;
|
|
343
|
+
const internalParent = toInternalRouteRef(parent);
|
|
344
|
+
const parentParams = internalParent.getParams();
|
|
345
|
+
const pathParams = path.split("/").filter((p) => p.startsWith(":")).map((p) => p.substring(1));
|
|
346
|
+
const params = [...parentParams, ...pathParams];
|
|
347
|
+
if (parentParams.some((p) => pathParams.includes(p))) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
"SubRouteRef may not have params that overlap with its parent"
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
if (!path.startsWith("/")) {
|
|
353
|
+
throw new Error(`SubRouteRef path must start with '/', got '${path}'`);
|
|
354
|
+
}
|
|
355
|
+
if (path.endsWith("/")) {
|
|
356
|
+
throw new Error(`SubRouteRef path must not end with '/', got '${path}'`);
|
|
357
|
+
}
|
|
358
|
+
for (const param of pathParams) {
|
|
359
|
+
if (!PARAM_PATTERN.test(param)) {
|
|
360
|
+
throw new Error(`SubRouteRef path has invalid param, got '${param}'`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const subRouteRef = new SubRouteRefImpl(
|
|
364
|
+
path,
|
|
365
|
+
params,
|
|
366
|
+
parent
|
|
367
|
+
);
|
|
368
|
+
return subRouteRef;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
var __defProp = Object.defineProperty;
|
|
372
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
373
|
+
var __publicField = (obj, key, value) => {
|
|
374
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
375
|
+
return value;
|
|
376
|
+
};
|
|
377
|
+
function toInternalExternalRouteRef(resource) {
|
|
378
|
+
const r = resource;
|
|
379
|
+
if (r.$$type !== "@backstage/ExternalRouteRef") {
|
|
380
|
+
throw new Error(`Invalid ExternalRouteRef, bad type '${r.$$type}'`);
|
|
381
|
+
}
|
|
382
|
+
return r;
|
|
383
|
+
}
|
|
384
|
+
class ExternalRouteRefImpl extends RouteRefImpl {
|
|
385
|
+
constructor(optional, params = [], creationSite) {
|
|
386
|
+
super(params, creationSite);
|
|
387
|
+
this.optional = optional;
|
|
388
|
+
this.params = params;
|
|
389
|
+
__publicField(this, "$$type", "@backstage/ExternalRouteRef");
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function createExternalRouteRef(options) {
|
|
393
|
+
return new ExternalRouteRefImpl(
|
|
394
|
+
Boolean(options == null ? void 0 : options.optional),
|
|
395
|
+
options == null ? void 0 : options.params,
|
|
396
|
+
describeParentCallSite()
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function convertLegacyRouteRef(ref) {
|
|
401
|
+
if ("$$type" in ref) {
|
|
402
|
+
return ref;
|
|
403
|
+
}
|
|
404
|
+
const type = ref[routeRefType];
|
|
405
|
+
if (type === "absolute") {
|
|
406
|
+
const legacyRef = ref;
|
|
407
|
+
const newRef = toInternalRouteRef(
|
|
408
|
+
createRouteRef({
|
|
409
|
+
params: legacyRef.params
|
|
410
|
+
})
|
|
411
|
+
);
|
|
412
|
+
return Object.assign(legacyRef, {
|
|
413
|
+
$$type: "@backstage/RouteRef",
|
|
414
|
+
version: "v1",
|
|
415
|
+
T: newRef.T,
|
|
416
|
+
getParams() {
|
|
417
|
+
return newRef.getParams();
|
|
418
|
+
},
|
|
419
|
+
getDescription() {
|
|
420
|
+
return newRef.getDescription();
|
|
421
|
+
},
|
|
422
|
+
setId(id) {
|
|
423
|
+
newRef.setId(id);
|
|
424
|
+
},
|
|
425
|
+
toString() {
|
|
426
|
+
return newRef.toString();
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
if (type === "sub") {
|
|
431
|
+
const legacyRef = ref;
|
|
432
|
+
const newRef = toInternalSubRouteRef(
|
|
433
|
+
createSubRouteRef({
|
|
434
|
+
path: legacyRef.path,
|
|
435
|
+
parent: convertLegacyRouteRef(legacyRef.parent)
|
|
436
|
+
})
|
|
437
|
+
);
|
|
438
|
+
return Object.assign(legacyRef, {
|
|
439
|
+
$$type: "@backstage/SubRouteRef",
|
|
440
|
+
version: "v1",
|
|
441
|
+
T: newRef.T,
|
|
442
|
+
getParams() {
|
|
443
|
+
return newRef.getParams();
|
|
444
|
+
},
|
|
445
|
+
getParent() {
|
|
446
|
+
return newRef.getParent();
|
|
447
|
+
},
|
|
448
|
+
getDescription() {
|
|
449
|
+
return newRef.getDescription();
|
|
450
|
+
},
|
|
451
|
+
toString() {
|
|
452
|
+
return newRef.toString();
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (type === "external") {
|
|
457
|
+
const legacyRef = ref;
|
|
458
|
+
const newRef = toInternalExternalRouteRef(
|
|
459
|
+
createExternalRouteRef({
|
|
460
|
+
params: legacyRef.params,
|
|
461
|
+
optional: legacyRef.optional
|
|
462
|
+
})
|
|
463
|
+
);
|
|
464
|
+
return Object.assign(legacyRef, {
|
|
465
|
+
$$type: "@backstage/ExternalRouteRef",
|
|
466
|
+
version: "v1",
|
|
467
|
+
T: newRef.T,
|
|
468
|
+
optional: newRef.optional,
|
|
469
|
+
getParams() {
|
|
470
|
+
return newRef.getParams();
|
|
471
|
+
},
|
|
472
|
+
getDescription() {
|
|
473
|
+
return newRef.getDescription();
|
|
474
|
+
},
|
|
475
|
+
setId(id) {
|
|
476
|
+
newRef.setId(id);
|
|
477
|
+
},
|
|
478
|
+
toString() {
|
|
479
|
+
return newRef.toString();
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
throw new Error(`Failed to convert legacy route ref, unknown type '${type}'`);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export { appLanguageApiRef, convertLegacyRouteRef, createTranslationMessages, createTranslationRef, createTranslationResource, translationApiRef, useTranslationRef };
|
|
178
487
|
//# sourceMappingURL=alpha.esm.js.map
|