@backstage/core-plugin-api 1.8.0 → 1.8.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +26 -99
- package/dist/alpha.esm.js +41 -334
- package/dist/alpha.esm.js.map +1 -1
- package/dist/esm/{types-08c0ee05.esm.js → StorageApi-2de4f480.esm.js} +3 -8
- package/dist/esm/StorageApi-2de4f480.esm.js.map +1 -0
- package/dist/index.esm.js +7 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
- package/dist/esm/types-08c0ee05.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @backstage/core-plugin-api
|
|
2
2
|
|
|
3
|
+
## 1.8.1-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c93dc37b2: The `createTranslationRef` function from the `/alpha` subpath can now also accept a nested object structure of default translation messages, which will be flatted using `.` separators.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/config@1.1.1
|
|
10
|
+
- @backstage/types@1.1.1
|
|
11
|
+
- @backstage/version-bridge@1.0.7
|
|
12
|
+
|
|
13
|
+
## 1.8.1-next.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 03d0b6dcdc: Removed the alpha `convertLegacyRouteRef` utility, which as been moved to `@backstage/core-compat-api`
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/config@1.1.1
|
|
20
|
+
- @backstage/types@1.1.1
|
|
21
|
+
- @backstage/version-bridge@1.0.7
|
|
22
|
+
|
|
3
23
|
## 1.8.0
|
|
4
24
|
|
|
5
25
|
### 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
|
|
2
|
+
import { ApiRef } from '@backstage/core-plugin-api';
|
|
3
3
|
import { Observable } from '@backstage/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -89,30 +89,44 @@ interface TranslationRef<TId extends string = string, TMessages extends {
|
|
|
89
89
|
id: TId;
|
|
90
90
|
T: TMessages;
|
|
91
91
|
}
|
|
92
|
+
/** @ignore */
|
|
93
|
+
type AnyNestedMessages = {
|
|
94
|
+
[key in string]: AnyNestedMessages | string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Flattens a nested message declaration into a flat object with dot-separated keys.
|
|
98
|
+
*
|
|
99
|
+
* @ignore
|
|
100
|
+
*/
|
|
101
|
+
type FlattenedMessages<TMessages extends AnyNestedMessages> = {
|
|
102
|
+
[TKey in keyof TMessages]: (_: TMessages[TKey] extends infer TValue ? TValue extends AnyNestedMessages ? FlattenedMessages<TValue> extends infer TNested ? {
|
|
103
|
+
[TNestedKey in keyof TNested as `${TKey & string}.${TNestedKey & string}`]: TNested[TNestedKey];
|
|
104
|
+
} : never : {
|
|
105
|
+
[_ in TKey]: TValue;
|
|
106
|
+
} : never) => void;
|
|
107
|
+
}[keyof TMessages] extends (_: infer TIntersection) => void ? {
|
|
108
|
+
readonly [TExpandKey in keyof TIntersection]: TIntersection[TExpandKey];
|
|
109
|
+
} : never;
|
|
92
110
|
/** @alpha */
|
|
93
|
-
interface TranslationRefOptions<TId extends string,
|
|
94
|
-
[key in string]: string;
|
|
95
|
-
}, TTranslations extends {
|
|
111
|
+
interface TranslationRefOptions<TId extends string, TNestedMessages extends AnyNestedMessages, TTranslations extends {
|
|
96
112
|
[language in string]: () => Promise<{
|
|
97
113
|
default: {
|
|
98
|
-
[key in keyof
|
|
114
|
+
[key in keyof FlattenedMessages<TNestedMessages>]: string | null;
|
|
99
115
|
};
|
|
100
116
|
}>;
|
|
101
117
|
}> {
|
|
102
118
|
id: TId;
|
|
103
|
-
messages:
|
|
119
|
+
messages: TNestedMessages;
|
|
104
120
|
translations?: TTranslations;
|
|
105
121
|
}
|
|
106
122
|
/** @alpha */
|
|
107
|
-
declare function createTranslationRef<TId extends string, const
|
|
108
|
-
[key in string]: string;
|
|
109
|
-
}, TTranslations extends {
|
|
123
|
+
declare function createTranslationRef<TId extends string, const TNestedMessages extends AnyNestedMessages, TTranslations extends {
|
|
110
124
|
[language in string]: () => Promise<{
|
|
111
125
|
default: {
|
|
112
|
-
[key in keyof
|
|
126
|
+
[key in keyof FlattenedMessages<TNestedMessages>]: string | null;
|
|
113
127
|
};
|
|
114
128
|
}>;
|
|
115
|
-
}>(config: TranslationRefOptions<TId,
|
|
129
|
+
}>(config: TranslationRefOptions<TId, TNestedMessages, TTranslations>): TranslationRef<TId, FlattenedMessages<TNestedMessages>>;
|
|
116
130
|
|
|
117
131
|
/**
|
|
118
132
|
* Base translation options.
|
|
@@ -391,91 +405,4 @@ declare const useTranslationRef: <TMessages extends {
|
|
|
391
405
|
t: TranslationFunction<TMessages>;
|
|
392
406
|
};
|
|
393
407
|
|
|
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 };
|
|
408
|
+
export { AppLanguageApi, TranslationApi, TranslationFunction, TranslationMessages, TranslationMessagesOptions, TranslationRef, TranslationRefOptions, TranslationResource, TranslationResourceOptions, TranslationSnapshot, appLanguageApiRef, createTranslationMessages, createTranslationRef, createTranslationResource, translationApiRef, useTranslationRef };
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|
2
|
-
import { u as useApi,
|
|
2
|
+
import { u as useApi, r as errorApiRef } from './esm/StorageApi-2de4f480.esm.js';
|
|
3
3
|
import { createApiRef } from '@backstage/core-plugin-api';
|
|
4
|
-
import 'react-router-dom';
|
|
5
4
|
import '@backstage/version-bridge';
|
|
6
5
|
|
|
7
6
|
function createTranslationMessages(options) {
|
|
@@ -32,61 +31,77 @@ function createTranslationResource(options) {
|
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
var __defProp
|
|
36
|
-
var __defNormalProp
|
|
37
|
-
var __publicField
|
|
38
|
-
__defNormalProp
|
|
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);
|
|
39
38
|
return value;
|
|
40
39
|
};
|
|
41
|
-
var __accessCheck
|
|
40
|
+
var __accessCheck = (obj, member, msg) => {
|
|
42
41
|
if (!member.has(obj))
|
|
43
42
|
throw TypeError("Cannot " + msg);
|
|
44
43
|
};
|
|
45
|
-
var __privateGet
|
|
46
|
-
__accessCheck
|
|
44
|
+
var __privateGet = (obj, member, getter) => {
|
|
45
|
+
__accessCheck(obj, member, "read from private field");
|
|
47
46
|
return getter ? getter.call(obj) : member.get(obj);
|
|
48
47
|
};
|
|
49
|
-
var __privateAdd
|
|
48
|
+
var __privateAdd = (obj, member, value) => {
|
|
50
49
|
if (member.has(obj))
|
|
51
50
|
throw TypeError("Cannot add the same private member more than once");
|
|
52
51
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
53
52
|
};
|
|
54
|
-
var __privateSet
|
|
55
|
-
__accessCheck
|
|
53
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
54
|
+
__accessCheck(obj, member, "write to private field");
|
|
56
55
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
57
56
|
return value;
|
|
58
57
|
};
|
|
59
|
-
var _id
|
|
58
|
+
var _id, _messages, _resources;
|
|
59
|
+
function flattenMessages(nested) {
|
|
60
|
+
const entries = new Array();
|
|
61
|
+
function visit(obj, prefix) {
|
|
62
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
63
|
+
if (typeof value === "string") {
|
|
64
|
+
entries.push([prefix + key, value]);
|
|
65
|
+
} else {
|
|
66
|
+
visit(value, `${prefix}${key}.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
visit(nested, "");
|
|
71
|
+
return Object.fromEntries(entries);
|
|
72
|
+
}
|
|
60
73
|
class TranslationRefImpl {
|
|
61
74
|
constructor(options) {
|
|
62
|
-
__privateAdd
|
|
63
|
-
__privateAdd
|
|
64
|
-
__privateAdd
|
|
65
|
-
__publicField
|
|
66
|
-
__publicField
|
|
67
|
-
__privateSet
|
|
68
|
-
__privateSet
|
|
75
|
+
__privateAdd(this, _id, void 0);
|
|
76
|
+
__privateAdd(this, _messages, void 0);
|
|
77
|
+
__privateAdd(this, _resources, void 0);
|
|
78
|
+
__publicField(this, "$$type", "@backstage/TranslationRef");
|
|
79
|
+
__publicField(this, "version", "v1");
|
|
80
|
+
__privateSet(this, _id, options.id);
|
|
81
|
+
__privateSet(this, _messages, flattenMessages(
|
|
82
|
+
options.messages
|
|
83
|
+
));
|
|
69
84
|
}
|
|
70
85
|
get id() {
|
|
71
|
-
return __privateGet
|
|
86
|
+
return __privateGet(this, _id);
|
|
72
87
|
}
|
|
73
88
|
get T() {
|
|
74
89
|
throw new Error("Not implemented");
|
|
75
90
|
}
|
|
76
91
|
getDefaultMessages() {
|
|
77
|
-
return __privateGet
|
|
92
|
+
return __privateGet(this, _messages);
|
|
78
93
|
}
|
|
79
94
|
setDefaultResource(resources) {
|
|
80
|
-
__privateSet
|
|
95
|
+
__privateSet(this, _resources, resources);
|
|
81
96
|
}
|
|
82
97
|
getDefaultResource() {
|
|
83
|
-
return __privateGet
|
|
98
|
+
return __privateGet(this, _resources);
|
|
84
99
|
}
|
|
85
100
|
toString() {
|
|
86
101
|
return `TranslationRef{id=${this.id}}`;
|
|
87
102
|
}
|
|
88
103
|
}
|
|
89
|
-
_id
|
|
104
|
+
_id = new WeakMap();
|
|
90
105
|
_messages = new WeakMap();
|
|
91
106
|
_resources = new WeakMap();
|
|
92
107
|
function createTranslationRef(config) {
|
|
@@ -175,313 +190,5 @@ const useTranslationRef = (translationRef) => {
|
|
|
175
190
|
return { t: snapshot.t };
|
|
176
191
|
};
|
|
177
192
|
|
|
178
|
-
|
|
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 };
|
|
193
|
+
export { appLanguageApiRef, createTranslationMessages, createTranslationRef, createTranslationResource, translationApiRef, useTranslationRef };
|
|
487
194
|
//# sourceMappingURL=alpha.esm.js.map
|