@backstage/core-components 0.18.2 → 0.18.3-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @backstage/core-components
2
2
 
3
+ ## 0.18.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+ - Updated dependencies
9
+ - @backstage/core-plugin-api@1.11.2-next.0
10
+ - @backstage/config@1.3.6-next.0
11
+ - @backstage/errors@1.2.7
12
+ - @backstage/theme@0.7.0
13
+ - @backstage/version-bridge@1.0.11
14
+
3
15
  ## 0.18.2
4
16
 
5
17
  ### Patch Changes
@@ -34,12 +34,14 @@ const codeModifiers = Object.fromEntries(
34
34
  )
35
35
  );
36
36
  class AnsiLine {
37
+ text;
38
+ lineNumber;
39
+ chunks;
37
40
  constructor(lineNumber = 1, chunks = []) {
38
41
  this.lineNumber = lineNumber;
39
42
  this.chunks = chunks;
40
43
  this.text = chunks.map((c) => c.text).join("").toLocaleLowerCase("en-US");
41
44
  }
42
- text;
43
45
  lastChunk() {
44
46
  return this.chunks[this.chunks.length - 1];
45
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AnsiProcessor.esm.js","sources":["../../../src/components/LogViewer/AnsiProcessor.ts"],"sourcesContent":["/*\n * Copyright 2021 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 ansiRegexMaker from 'ansi-regex';\n\nconst ansiRegex = ansiRegexMaker();\nconst newlineRegex = /\\n\\r?/g;\n\n// A mapping of how each escape code changes the modifiers\nconst codeModifiers = Object.fromEntries(\n Object.entries({\n 1: m => ({ ...m, bold: true }),\n 3: m => ({ ...m, italic: true }),\n 4: m => ({ ...m, underline: true }),\n 22: ({ bold: _, ...m }) => m,\n 23: ({ italic: _, ...m }) => m,\n 24: ({ underline: _, ...m }) => m,\n 30: m => ({ ...m, foreground: 'black' }),\n 31: m => ({ ...m, foreground: 'red' }),\n 32: m => ({ ...m, foreground: 'green' }),\n 33: m => ({ ...m, foreground: 'yellow' }),\n 34: m => ({ ...m, foreground: 'blue' }),\n 35: m => ({ ...m, foreground: 'magenta' }),\n 36: m => ({ ...m, foreground: 'cyan' }),\n 37: m => ({ ...m, foreground: 'white' }),\n 39: ({ foreground: _, ...m }) => m,\n 90: m => ({ ...m, foreground: 'grey' }),\n 40: m => ({ ...m, background: 'black' }),\n 41: m => ({ ...m, background: 'red' }),\n 42: m => ({ ...m, background: 'green' }),\n 43: m => ({ ...m, background: 'yellow' }),\n 44: m => ({ ...m, background: 'blue' }),\n 45: m => ({ ...m, background: 'magenta' }),\n 46: m => ({ ...m, background: 'cyan' }),\n 47: m => ({ ...m, background: 'white' }),\n 49: ({ background: _, ...m }) => m,\n } as Record<string, (m: ChunkModifiers) => ChunkModifiers>).map(\n ([code, modifier]) => [`\\x1b[${code}m`, modifier],\n ),\n);\n\nexport type AnsiColor =\n | 'black'\n | 'red'\n | 'green'\n | 'yellow'\n | 'blue'\n | 'magenta'\n | 'cyan'\n | 'white'\n | 'grey';\n\nexport interface ChunkModifiers {\n foreground?: AnsiColor;\n background?: AnsiColor;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface AnsiChunk {\n text: string;\n modifiers: ChunkModifiers;\n}\n\nexport class AnsiLine {\n text: string;\n\n constructor(\n readonly lineNumber: number = 1,\n readonly chunks: AnsiChunk[] = [],\n ) {\n this.text = chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n\n lastChunk(): AnsiChunk | undefined {\n return this.chunks[this.chunks.length - 1];\n }\n\n replaceLastChunk(newChunks?: AnsiChunk[]) {\n if (newChunks) {\n this.chunks.splice(this.chunks.length - 1, 1, ...newChunks);\n this.text = this.chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n }\n}\n\nexport class AnsiProcessor {\n private text: string = '';\n private lines: AnsiLine[] = [];\n\n /**\n * Processes a chunk of text while keeping internal state that optimizes\n * subsequent processing that appends to the text.\n */\n process(text: string): AnsiLine[] {\n if (this.text === text) {\n return this.lines;\n }\n\n if (this.text && text.startsWith(this.text)) {\n const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;\n const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();\n const lastChunk = lastLine.lastChunk();\n\n const newLines = this.processLines(\n (lastChunk?.text ?? '') + text.slice(this.text.length),\n lastChunk?.modifiers,\n lastLine?.lineNumber,\n );\n lastLine.replaceLastChunk(newLines[0]?.chunks);\n\n this.lines[lastLineIndex] = lastLine;\n this.lines = this.lines.concat(newLines.slice(1));\n } else {\n this.lines = this.processLines(text);\n }\n this.text = text;\n\n return this.lines;\n }\n\n // Split a chunk of text up into lines and process each line individually\n private processLines = (\n text: string,\n modifiers: ChunkModifiers = {},\n startingLineNumber: number = 1,\n ): AnsiLine[] => {\n const lines: AnsiLine[] = [];\n\n let currentModifiers = modifiers;\n let currentLineNumber = startingLineNumber;\n\n let prevIndex = 0;\n newlineRegex.lastIndex = 0;\n for (;;) {\n const match = newlineRegex.exec(text);\n if (!match) {\n const chunks = this.processText(\n text.slice(prevIndex),\n currentModifiers,\n );\n lines.push(new AnsiLine(currentLineNumber, chunks));\n return lines;\n }\n\n const line = text.slice(prevIndex, match.index);\n prevIndex = match.index + match[0].length;\n\n const chunks = this.processText(line, currentModifiers);\n lines.push(new AnsiLine(currentLineNumber, chunks));\n\n // Modifiers that are active in the last chunk are carried over to the next line\n currentModifiers =\n chunks[chunks.length - 1].modifiers ?? currentModifiers;\n currentLineNumber += 1;\n }\n };\n\n // Processing of a one individual text chunk\n private processText = (\n fullText: string,\n modifiers: ChunkModifiers,\n ): AnsiChunk[] => {\n const chunks: AnsiChunk[] = [];\n\n let currentModifiers = modifiers;\n\n let prevIndex = 0;\n ansiRegex.lastIndex = 0;\n for (;;) {\n const match = ansiRegex.exec(fullText);\n if (!match) {\n chunks.push({\n text: fullText.slice(prevIndex),\n modifiers: currentModifiers,\n });\n return chunks;\n }\n\n const text = fullText.slice(prevIndex, match.index);\n chunks.push({ text, modifiers: currentModifiers });\n\n // For every escape code that we encounter we keep track of where the\n // next chunk of text starts, and what modifiers it has\n prevIndex = match.index + match[0].length;\n currentModifiers = this.processCode(match[0], currentModifiers);\n }\n };\n\n private processCode = (\n code: string,\n modifiers: ChunkModifiers,\n ): ChunkModifiers => {\n return codeModifiers[code]?.(modifiers) ?? modifiers;\n };\n}\n"],"names":["chunks"],"mappings":";;AAkBA,MAAM,YAAY,cAAA,EAAe;AACjC,MAAM,YAAA,GAAe,QAAA;AAGrB,MAAM,gBAAgB,MAAA,CAAO,WAAA;AAAA,EAC3B,OAAO,OAAA,CAAQ;AAAA,IACb,GAAG,CAAA,CAAA,MAAM,EAAE,GAAG,CAAA,EAAG,MAAM,IAAA,EAAK,CAAA;AAAA,IAC5B,GAAG,CAAA,CAAA,MAAM,EAAE,GAAG,CAAA,EAAG,QAAQ,IAAA,EAAK,CAAA;AAAA,IAC9B,GAAG,CAAA,CAAA,MAAM,EAAE,GAAG,CAAA,EAAG,WAAW,IAAA,EAAK,CAAA;AAAA,IACjC,IAAI,CAAC,EAAE,MAAM,CAAA,EAAG,GAAG,GAAE,KAAM,CAAA;AAAA,IAC3B,IAAI,CAAC,EAAE,QAAQ,CAAA,EAAG,GAAG,GAAE,KAAM,CAAA;AAAA,IAC7B,IAAI,CAAC,EAAE,WAAW,CAAA,EAAG,GAAG,GA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,CAAA;AAAA,IACvB;AAAA,EACF,CAAA;AAAA;AAAA,EAGQ,WAAA,GAAc,CACpB,QAAA,EACA,SAAA,KACgB;AAChB,IAAA,MAAM,SAAsB,EAAC;AAE7B,IAAA,IAAI,gBAAA,GAAmB,SAAA;AAEvB,IAAA,IAAI,SAAA,GAAY,CAAA;AAChB,IAAA,SAAA,CAAU,SAAA,GAAY,CAAA;AACtB,IAAA,WAAS;AACP,MAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,IAAA,CAAK,QAAQ,CAAA;AACrC,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,MAAA,CAAO,IAAA,CAAK;AAAA,UACV,IAAA,EAAM,QAAA,CAAS,KAAA,CAAM,SAAS,CAAA;AAAA,UAC9B,SAAA,EAAW;AAAA,SACZ,CAAA;AACD,QAAA,OAAO,MAAA;AAAA,MACT;AAEA,MAAA,MAAM,IAAA,GAAO,QAAA,CAAS,KAAA,CAAM,SAAA,EAAW,MAAM,KAAK,CAAA;AAClD,MAAA,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,SAAA,EAAW,kBAAkB,CAAA;AAIjD,MAAA,SAAA,GAAY,KAAA,CAAM,KAAA,GAAQ,KAAA,CAAM,CAAC,CAAA,CAAE,MAAA;AACnC,MAAA,gBAAA,GAAmB,IAAA,CAAK,WAAA,CAAY,KAAA,CAAM,CAAC,GAAG,gBAAgB,CAAA;AAAA,IAChE;AAAA,EACF,CAAA;AAAA,EAEQ,WAAA,GAAc,CACpB,IAAA,EACA,SAAA,KACmB;AACnB,IAAA,OAAO,aAAA,CAAc,IAAI,CAAA,GAAI,SAAS,CAAA,IAAK,SAAA;AAAA,EAC7C,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"AnsiProcessor.esm.js","sources":["../../../src/components/LogViewer/AnsiProcessor.ts"],"sourcesContent":["/*\n * Copyright 2021 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 ansiRegexMaker from 'ansi-regex';\n\nconst ansiRegex = ansiRegexMaker();\nconst newlineRegex = /\\n\\r?/g;\n\n// A mapping of how each escape code changes the modifiers\nconst codeModifiers = Object.fromEntries(\n Object.entries({\n 1: m => ({ ...m, bold: true }),\n 3: m => ({ ...m, italic: true }),\n 4: m => ({ ...m, underline: true }),\n 22: ({ bold: _, ...m }) => m,\n 23: ({ italic: _, ...m }) => m,\n 24: ({ underline: _, ...m }) => m,\n 30: m => ({ ...m, foreground: 'black' }),\n 31: m => ({ ...m, foreground: 'red' }),\n 32: m => ({ ...m, foreground: 'green' }),\n 33: m => ({ ...m, foreground: 'yellow' }),\n 34: m => ({ ...m, foreground: 'blue' }),\n 35: m => ({ ...m, foreground: 'magenta' }),\n 36: m => ({ ...m, foreground: 'cyan' }),\n 37: m => ({ ...m, foreground: 'white' }),\n 39: ({ foreground: _, ...m }) => m,\n 90: m => ({ ...m, foreground: 'grey' }),\n 40: m => ({ ...m, background: 'black' }),\n 41: m => ({ ...m, background: 'red' }),\n 42: m => ({ ...m, background: 'green' }),\n 43: m => ({ ...m, background: 'yellow' }),\n 44: m => ({ ...m, background: 'blue' }),\n 45: m => ({ ...m, background: 'magenta' }),\n 46: m => ({ ...m, background: 'cyan' }),\n 47: m => ({ ...m, background: 'white' }),\n 49: ({ background: _, ...m }) => m,\n } as Record<string, (m: ChunkModifiers) => ChunkModifiers>).map(\n ([code, modifier]) => [`\\x1b[${code}m`, modifier],\n ),\n);\n\nexport type AnsiColor =\n | 'black'\n | 'red'\n | 'green'\n | 'yellow'\n | 'blue'\n | 'magenta'\n | 'cyan'\n | 'white'\n | 'grey';\n\nexport interface ChunkModifiers {\n foreground?: AnsiColor;\n background?: AnsiColor;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface AnsiChunk {\n text: string;\n modifiers: ChunkModifiers;\n}\n\nexport class AnsiLine {\n text: string;\n readonly lineNumber: number;\n readonly chunks: AnsiChunk[];\n\n constructor(lineNumber: number = 1, chunks: AnsiChunk[] = []) {\n this.lineNumber = lineNumber;\n this.chunks = chunks;\n this.text = chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n\n lastChunk(): AnsiChunk | undefined {\n return this.chunks[this.chunks.length - 1];\n }\n\n replaceLastChunk(newChunks?: AnsiChunk[]) {\n if (newChunks) {\n this.chunks.splice(this.chunks.length - 1, 1, ...newChunks);\n this.text = this.chunks\n .map(c => c.text)\n .join('')\n .toLocaleLowerCase('en-US');\n }\n }\n}\n\nexport class AnsiProcessor {\n private text: string = '';\n private lines: AnsiLine[] = [];\n\n /**\n * Processes a chunk of text while keeping internal state that optimizes\n * subsequent processing that appends to the text.\n */\n process(text: string): AnsiLine[] {\n if (this.text === text) {\n return this.lines;\n }\n\n if (this.text && text.startsWith(this.text)) {\n const lastLineIndex = this.lines.length > 0 ? this.lines.length - 1 : 0;\n const lastLine = this.lines[lastLineIndex] ?? new AnsiLine();\n const lastChunk = lastLine.lastChunk();\n\n const newLines = this.processLines(\n (lastChunk?.text ?? '') + text.slice(this.text.length),\n lastChunk?.modifiers,\n lastLine?.lineNumber,\n );\n lastLine.replaceLastChunk(newLines[0]?.chunks);\n\n this.lines[lastLineIndex] = lastLine;\n this.lines = this.lines.concat(newLines.slice(1));\n } else {\n this.lines = this.processLines(text);\n }\n this.text = text;\n\n return this.lines;\n }\n\n // Split a chunk of text up into lines and process each line individually\n private processLines = (\n text: string,\n modifiers: ChunkModifiers = {},\n startingLineNumber: number = 1,\n ): AnsiLine[] => {\n const lines: AnsiLine[] = [];\n\n let currentModifiers = modifiers;\n let currentLineNumber = startingLineNumber;\n\n let prevIndex = 0;\n newlineRegex.lastIndex = 0;\n for (;;) {\n const match = newlineRegex.exec(text);\n if (!match) {\n const chunks = this.processText(\n text.slice(prevIndex),\n currentModifiers,\n );\n lines.push(new AnsiLine(currentLineNumber, chunks));\n return lines;\n }\n\n const line = text.slice(prevIndex, match.index);\n prevIndex = match.index + match[0].length;\n\n const chunks = this.processText(line, currentModifiers);\n lines.push(new AnsiLine(currentLineNumber, chunks));\n\n // Modifiers that are active in the last chunk are carried over to the next line\n currentModifiers =\n chunks[chunks.length - 1].modifiers ?? currentModifiers;\n currentLineNumber += 1;\n }\n };\n\n // Processing of a one individual text chunk\n private processText = (\n fullText: string,\n modifiers: ChunkModifiers,\n ): AnsiChunk[] => {\n const chunks: AnsiChunk[] = [];\n\n let currentModifiers = modifiers;\n\n let prevIndex = 0;\n ansiRegex.lastIndex = 0;\n for (;;) {\n const match = ansiRegex.exec(fullText);\n if (!match) {\n chunks.push({\n text: fullText.slice(prevIndex),\n modifiers: currentModifiers,\n });\n return chunks;\n }\n\n const text = fullText.slice(prevIndex, match.index);\n chunks.push({ text, modifiers: currentModifiers });\n\n // For every escape code that we encounter we keep track of where the\n // next chunk of text starts, and what modifiers it has\n prevIndex = match.index + match[0].length;\n currentModifiers = this.processCode(match[0], currentModifiers);\n }\n };\n\n private processCode = (\n code: string,\n modifiers: ChunkModifiers,\n ): ChunkModifiers => {\n return codeModifiers[code]?.(modifiers) ?? modifiers;\n };\n}\n"],"names":["chunks"],"mappings":";;AAkBA,MAAM,YAAY,cAAA,EAAe;AACjC,MAAM,YAAA,GAAe,QAAA;AAGrB,MAAM,gBAAgB,MAAA,CAAO,WAAA;AAAA,EAC3B,OAAO,OAAA,CAAQ;AAAA,IACb,GAAG,CAAA,CAAA,MAAM,EAAE,GAAG,CAAA,EAAG,MAAM,IAAA,EAAK,CAAA;AAAA,IAC5B,GAAG,CAAA,CAAA,MAAM,EAAE,GAAG,CAAA,EAAG,QAAQ,IAAA,EAAK,CAAA;AAAA,IAC9B,GAA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AA,GAAc,CACpB,IAAA,EACA,SAAA,KACmB;AACnB,IAAA,OAAO,aAAA,CAAc,IAAI,CAAA,GAAI,SAAS,CAAA,IAAK,SAAA;AAAA,EAC7C,CAAA;AACF;;;;"}
package/dist/index.d.ts CHANGED
@@ -2095,9 +2095,6 @@ type CustomProviderClassKey = 'form' | 'button';
2095
2095
  * @public
2096
2096
  */
2097
2097
  declare class UserIdentity implements IdentityApi {
2098
- private readonly identity;
2099
- private readonly authApi;
2100
- private readonly profile?;
2101
2098
  private profilePromise?;
2102
2099
  /**
2103
2100
  * Creates a new IdentityApi that acts as a Guest User.
@@ -2143,6 +2140,9 @@ declare class UserIdentity implements IdentityApi {
2143
2140
  */
2144
2141
  profile?: ProfileInfo;
2145
2142
  }): IdentityApi;
2143
+ private readonly identity;
2144
+ private readonly authApi;
2145
+ private readonly profile?;
2146
2146
  private constructor();
2147
2147
  /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getUserId} */
2148
2148
  getUserId(): string;
@@ -2,11 +2,6 @@ import { GuestUserIdentity } from './GuestUserIdentity.esm.js';
2
2
  import { LegacyUserIdentity } from './LegacyUserIdentity.esm.js';
3
3
 
4
4
  class UserIdentity {
5
- constructor(identity, authApi, profile) {
6
- this.identity = identity;
7
- this.authApi = authApi;
8
- this.profile = profile;
9
- }
10
5
  profilePromise;
11
6
  /**
12
7
  * Creates a new IdentityApi that acts as a Guest User.
@@ -33,6 +28,14 @@ class UserIdentity {
33
28
  static create(options) {
34
29
  return new UserIdentity(options.identity, options.authApi, options.profile);
35
30
  }
31
+ identity;
32
+ authApi;
33
+ profile;
34
+ constructor(identity, authApi, profile) {
35
+ this.identity = identity;
36
+ this.authApi = authApi;
37
+ this.profile = profile;
38
+ }
36
39
  /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getUserId} */
37
40
  getUserId() {
38
41
  const ref = this.identity.userEntityRef;
@@ -1 +1 @@
1
- {"version":3,"file":"UserIdentity.esm.js","sources":["../../../src/layout/SignInPage/UserIdentity.ts"],"sourcesContent":["/*\n * Copyright 2021 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 IdentityApi,\n ProfileInfo,\n ProfileInfoApi,\n BackstageUserIdentity,\n BackstageIdentityApi,\n SessionApi,\n} from '@backstage/core-plugin-api';\n\nimport { GuestUserIdentity } from './GuestUserIdentity';\nimport { LegacyUserIdentity } from './LegacyUserIdentity';\n\n// TODO(Rugvip): This and the other IdentityApi implementations still implement\n// the old removed methods. This is to allow for backwards compatibility\n// with old plugins that still consume this API. We will leave these in\n// place as a hidden compatibility for a couple of months.\n// The AppIdentityProxy warns in case any of these methods are called.\n\n/**\n * An implementation of the IdentityApi that is constructed using\n * various backstage user identity representations.\n *\n * @public\n */\nexport class UserIdentity implements IdentityApi {\n private profilePromise?: Promise<ProfileInfo>;\n /**\n * Creates a new IdentityApi that acts as a Guest User.\n *\n * @public\n */\n static createGuest(): IdentityApi {\n return new GuestUserIdentity();\n }\n\n /**\n * Creates a new IdentityApi using a legacy SignInResult object.\n *\n * @public\n */\n static fromLegacy(result: {\n /**\n * User ID that will be returned by the IdentityApi\n */\n userId: string;\n\n profile: ProfileInfo;\n\n /**\n * Function used to retrieve an ID token for the signed in user.\n */\n getIdToken?: () => Promise<string>;\n\n /**\n * Sign out handler that will be called if the user requests to sign out.\n */\n signOut?: () => Promise<void>;\n }): IdentityApi {\n return LegacyUserIdentity.fromResult(result);\n }\n\n /**\n * Creates a new IdentityApi implementation using a user identity\n * and an auth API that will be used to request backstage tokens.\n *\n * @public\n */\n static create(options: {\n identity: BackstageUserIdentity;\n authApi: ProfileInfoApi & BackstageIdentityApi & SessionApi;\n /**\n * Passing a profile synchronously allows the deprecated `getProfile` method to be\n * called by consumers of the {@link @backstage/core-plugin-api#IdentityApi}. If you\n * do not have any consumers of that method then this is safe to leave out.\n *\n * @deprecated Only provide this if you have plugins that call the synchronous `getProfile` method, which is also deprecated.\n */\n profile?: ProfileInfo;\n }): IdentityApi {\n return new UserIdentity(options.identity, options.authApi, options.profile);\n }\n\n private constructor(\n private readonly identity: BackstageUserIdentity,\n private readonly authApi: ProfileInfoApi &\n BackstageIdentityApi &\n SessionApi,\n private readonly profile?: ProfileInfo,\n ) {}\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getUserId} */\n getUserId(): string {\n const ref = this.identity.userEntityRef;\n const match = /^([^:/]+:)?([^:/]+\\/)?([^:/]+)$/.exec(ref);\n if (!match) {\n throw new TypeError(`Invalid user entity reference \"${ref}\"`);\n }\n\n return match[3];\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getIdToken} */\n async getIdToken(): Promise<string | undefined> {\n const identity = await this.authApi.getBackstageIdentity();\n return identity!.token;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfile} */\n getProfile(): ProfileInfo {\n if (!this.profile) {\n throw new Error(\n 'The identity API does not implement synchronous profile fetching, use getProfileInfo() instead',\n );\n }\n return this.profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfileInfo} */\n async getProfileInfo(): Promise<ProfileInfo> {\n if (this.profilePromise) {\n return await this.profilePromise;\n }\n\n try {\n this.profilePromise = this.authApi.getProfile() as Promise<ProfileInfo>;\n return await this.profilePromise;\n } catch (ex) {\n this.profilePromise = undefined;\n throw ex;\n }\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getBackstageIdentity} */\n async getBackstageIdentity(): Promise<BackstageUserIdentity> {\n return this.identity;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getCredentials} */\n async getCredentials(): Promise<{ token?: string | undefined }> {\n const identity = await this.authApi.getBackstageIdentity();\n return { token: identity!.token };\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.signOut} */\n async signOut(): Promise<void> {\n return this.authApi.signOut();\n }\n}\n"],"names":[],"mappings":";;;AAwCO,MAAM,YAAA,CAAoC;AAAA,EA0DvC,WAAA,CACW,QAAA,EACA,OAAA,EAGA,OAAA,EACjB;AALiB,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA,EAChB;AAAA,EA/DK,cAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,OAAO,WAAA,GAA2B;AAChC,IAAA,OAAO,IAAI,iBAAA,EAAkB;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,MAAA,EAiBF;AACd,IAAA,OAAO,kBAAA,CAAmB,WAAW,MAAM,CAAA;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAAO,OAAA,EAWE;AACd,IAAA,OAAO,IAAI,YAAA,CAAa,OAAA,CAAQ,UAAU,OAAA,CAAQ,OAAA,EAAS,QAAQ,OAAO,CAAA;AAAA,EAC5E;AAAA;AAAA,EAWA,SAAA,GAAoB;AAClB,IAAA,MAAM,GAAA,GAAM,KAAK,QAAA,CAAS,aAAA;AAC1B,IAAA,MAAM,KAAA,GAAQ,iCAAA,CAAkC,IAAA,CAAK,GAAG,CAAA;AACxD,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,SAAA,CAAU,CAAA,+BAAA,EAAkC,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IAC9D;AAEA,IAAA,OAAO,MAAM,CAAC,CAAA;AAAA,EAChB;AAAA;AAAA,EAGA,MAAM,UAAA,GAA0C;AAC9C,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,OAAA,CAAQ,oBAAA,EAAqB;AACzD,IAAA,OAAO,QAAA,CAAU,KAAA;AAAA,EACnB;AAAA;AAAA,EAGA,UAAA,GAA0B;AACxB,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACjB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA;AAAA,EAGA,MAAM,cAAA,GAAuC;AAC3C,IAAA,IAAI,KAAK,cAAA,EAAgB;AACvB,MAAA,OAAO,MAAM,IAAA,CAAK,cAAA;AAAA,IACpB;AAEA,IAAA,IAAI;AACF,MAAA,IAAA,CAAK,cAAA,GAAiB,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAW;AAC9C,MAAA,OAAO,MAAM,IAAA,CAAK,cAAA;AAAA,IACpB,SAAS,EAAA,EAAI;AACX,MAAA,IAAA,CAAK,cAAA,GAAiB,MAAA;AACtB,MAAA,MAAM,EAAA;AAAA,IACR;AAAA,EACF;AAAA;AAAA,EAGA,MAAM,oBAAA,GAAuD;AAC3D,IAAA,OAAO,IAAA,CAAK,QAAA;AAAA,EACd;AAAA;AAAA,EAGA,MAAM,cAAA,GAA0D;AAC9D,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,OAAA,CAAQ,oBAAA,EAAqB;AACzD,IAAA,OAAO,EAAE,KAAA,EAAO,QAAA,CAAU,KAAA,EAAM;AAAA,EAClC;AAAA;AAAA,EAGA,MAAM,OAAA,GAAyB;AAC7B,IAAA,OAAO,IAAA,CAAK,QAAQ,OAAA,EAAQ;AAAA,EAC9B;AACF;;;;"}
1
+ {"version":3,"file":"UserIdentity.esm.js","sources":["../../../src/layout/SignInPage/UserIdentity.ts"],"sourcesContent":["/*\n * Copyright 2021 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 IdentityApi,\n ProfileInfo,\n ProfileInfoApi,\n BackstageUserIdentity,\n BackstageIdentityApi,\n SessionApi,\n} from '@backstage/core-plugin-api';\n\nimport { GuestUserIdentity } from './GuestUserIdentity';\nimport { LegacyUserIdentity } from './LegacyUserIdentity';\n\n// TODO(Rugvip): This and the other IdentityApi implementations still implement\n// the old removed methods. This is to allow for backwards compatibility\n// with old plugins that still consume this API. We will leave these in\n// place as a hidden compatibility for a couple of months.\n// The AppIdentityProxy warns in case any of these methods are called.\n\n/**\n * An implementation of the IdentityApi that is constructed using\n * various backstage user identity representations.\n *\n * @public\n */\nexport class UserIdentity implements IdentityApi {\n private profilePromise?: Promise<ProfileInfo>;\n /**\n * Creates a new IdentityApi that acts as a Guest User.\n *\n * @public\n */\n static createGuest(): IdentityApi {\n return new GuestUserIdentity();\n }\n\n /**\n * Creates a new IdentityApi using a legacy SignInResult object.\n *\n * @public\n */\n static fromLegacy(result: {\n /**\n * User ID that will be returned by the IdentityApi\n */\n userId: string;\n\n profile: ProfileInfo;\n\n /**\n * Function used to retrieve an ID token for the signed in user.\n */\n getIdToken?: () => Promise<string>;\n\n /**\n * Sign out handler that will be called if the user requests to sign out.\n */\n signOut?: () => Promise<void>;\n }): IdentityApi {\n return LegacyUserIdentity.fromResult(result);\n }\n\n /**\n * Creates a new IdentityApi implementation using a user identity\n * and an auth API that will be used to request backstage tokens.\n *\n * @public\n */\n static create(options: {\n identity: BackstageUserIdentity;\n authApi: ProfileInfoApi & BackstageIdentityApi & SessionApi;\n /**\n * Passing a profile synchronously allows the deprecated `getProfile` method to be\n * called by consumers of the {@link @backstage/core-plugin-api#IdentityApi}. If you\n * do not have any consumers of that method then this is safe to leave out.\n *\n * @deprecated Only provide this if you have plugins that call the synchronous `getProfile` method, which is also deprecated.\n */\n profile?: ProfileInfo;\n }): IdentityApi {\n return new UserIdentity(options.identity, options.authApi, options.profile);\n }\n\n private readonly identity: BackstageUserIdentity;\n private readonly authApi: ProfileInfoApi & BackstageIdentityApi & SessionApi;\n private readonly profile?: ProfileInfo;\n\n private constructor(\n identity: BackstageUserIdentity,\n authApi: ProfileInfoApi & BackstageIdentityApi & SessionApi,\n profile?: ProfileInfo,\n ) {\n this.identity = identity;\n this.authApi = authApi;\n this.profile = profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getUserId} */\n getUserId(): string {\n const ref = this.identity.userEntityRef;\n const match = /^([^:/]+:)?([^:/]+\\/)?([^:/]+)$/.exec(ref);\n if (!match) {\n throw new TypeError(`Invalid user entity reference \"${ref}\"`);\n }\n\n return match[3];\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getIdToken} */\n async getIdToken(): Promise<string | undefined> {\n const identity = await this.authApi.getBackstageIdentity();\n return identity!.token;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfile} */\n getProfile(): ProfileInfo {\n if (!this.profile) {\n throw new Error(\n 'The identity API does not implement synchronous profile fetching, use getProfileInfo() instead',\n );\n }\n return this.profile;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getProfileInfo} */\n async getProfileInfo(): Promise<ProfileInfo> {\n if (this.profilePromise) {\n return await this.profilePromise;\n }\n\n try {\n this.profilePromise = this.authApi.getProfile() as Promise<ProfileInfo>;\n return await this.profilePromise;\n } catch (ex) {\n this.profilePromise = undefined;\n throw ex;\n }\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getBackstageIdentity} */\n async getBackstageIdentity(): Promise<BackstageUserIdentity> {\n return this.identity;\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.getCredentials} */\n async getCredentials(): Promise<{ token?: string | undefined }> {\n const identity = await this.authApi.getBackstageIdentity();\n return { token: identity!.token };\n }\n\n /** {@inheritdoc @backstage/core-plugin-api#IdentityApi.signOut} */\n async signOut(): Promise<void> {\n return this.authApi.signOut();\n }\n}\n"],"names":[],"mappings":";;;AAwCO,MAAM,YAAA,CAAoC;AAAA,EACvC,cAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,OAAO,WAAA,GAA2B;AAChC,IAAA,OAAO,IAAI,iBAAA,EAAkB;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,MAAA,EAiBF;AACd,IAAA,OAAO,kBAAA,CAAmB,WAAW,MAAM,CAAA;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAAO,OAAA,EAWE;AACd,IAAA,OAAO,IAAI,YAAA,CAAa,OAAA,CAAQ,UAAU,OAAA,CAAQ,OAAA,EAAS,QAAQ,OAAO,CAAA;AAAA,EAC5E;AAAA,EAEiB,QAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CACN,QAAA,EACA,OAAA,EACA,OAAA,EACA;AACA,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AAAA;AAAA,EAGA,SAAA,GAAoB;AAClB,IAAA,MAAM,GAAA,GAAM,KAAK,QAAA,CAAS,aAAA;AAC1B,IAAA,MAAM,KAAA,GAAQ,iCAAA,CAAkC,IAAA,CAAK,GAAG,CAAA;AACxD,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,SAAA,CAAU,CAAA,+BAAA,EAAkC,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IAC9D;AAEA,IAAA,OAAO,MAAM,CAAC,CAAA;AAAA,EAChB;AAAA;AAAA,EAGA,MAAM,UAAA,GAA0C;AAC9C,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,OAAA,CAAQ,oBAAA,EAAqB;AACzD,IAAA,OAAO,QAAA,CAAU,KAAA;AAAA,EACnB;AAAA;AAAA,EAGA,UAAA,GAA0B;AACxB,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACjB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EACd;AAAA;AAAA,EAGA,MAAM,cAAA,GAAuC;AAC3C,IAAA,IAAI,KAAK,cAAA,EAAgB;AACvB,MAAA,OAAO,MAAM,IAAA,CAAK,cAAA;AAAA,IACpB;AAEA,IAAA,IAAI;AACF,MAAA,IAAA,CAAK,cAAA,GAAiB,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAW;AAC9C,MAAA,OAAO,MAAM,IAAA,CAAK,cAAA;AAAA,IACpB,SAAS,EAAA,EAAI;AACX,MAAA,IAAA,CAAK,cAAA,GAAiB,MAAA;AACtB,MAAA,MAAM,EAAA;AAAA,IACR;AAAA,EACF;AAAA;AAAA,EAGA,MAAM,oBAAA,GAAuD;AAC3D,IAAA,OAAO,IAAA,CAAK,QAAA;AAAA,EACd;AAAA;AAAA,EAGA,MAAM,cAAA,GAA0D;AAC9D,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,OAAA,CAAQ,oBAAA,EAAqB;AACzD,IAAA,OAAO,EAAE,KAAA,EAAO,QAAA,CAAU,KAAA,EAAM;AAAA,EAClC;AAAA;AAAA,EAGA,MAAM,OAAA,GAAyB;AAC7B,IAAA,OAAO,IAAA,CAAK,QAAQ,OAAA,EAAQ;AAAA,EAC9B;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/core-components",
3
- "version": "0.18.2",
3
+ "version": "0.18.3-next.0",
4
4
  "description": "Core components used by Backstage plugins and apps",
5
5
  "backstage": {
6
6
  "role": "web-library"
@@ -66,11 +66,11 @@
66
66
  "test": "backstage-cli package test"
67
67
  },
68
68
  "dependencies": {
69
- "@backstage/config": "^1.3.5",
70
- "@backstage/core-plugin-api": "^1.11.1",
71
- "@backstage/errors": "^1.2.7",
72
- "@backstage/theme": "^0.7.0",
73
- "@backstage/version-bridge": "^1.0.11",
69
+ "@backstage/config": "1.3.6-next.0",
70
+ "@backstage/core-plugin-api": "1.11.2-next.0",
71
+ "@backstage/errors": "1.2.7",
72
+ "@backstage/theme": "0.7.0",
73
+ "@backstage/version-bridge": "1.0.11",
74
74
  "@dagrejs/dagre": "^1.1.4",
75
75
  "@date-io/core": "^1.3.13",
76
76
  "@material-table/core": "^3.1.0",
@@ -107,10 +107,10 @@
107
107
  "zod": "^3.22.4"
108
108
  },
109
109
  "devDependencies": {
110
- "@backstage/app-defaults": "^1.7.1",
111
- "@backstage/cli": "^0.34.4",
112
- "@backstage/core-app-api": "^1.19.1",
113
- "@backstage/test-utils": "^1.7.12",
110
+ "@backstage/app-defaults": "1.7.2-next.0",
111
+ "@backstage/cli": "0.34.5-next.0",
112
+ "@backstage/core-app-api": "1.19.2-next.0",
113
+ "@backstage/test-utils": "1.7.13-next.0",
114
114
  "@testing-library/dom": "^10.0.0",
115
115
  "@testing-library/jest-dom": "^6.0.0",
116
116
  "@testing-library/user-event": "^14.0.0",