api-ref: move opaque helper to frontend-internal

Share the internal ApiRef opaque helper through frontend-internal and fail fast when ApiRef-shaped values have an unsupported opaque version.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-17 11:05:00 +01:00
parent 90c3a9d1c0
commit cc0693ec40
6 changed files with 87 additions and 64 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { OpaqueType } from '@internal/opaque';
import { OpaqueApiRef } from '@internal/frontend';
import type { ApiRef } from './types';
/**
@@ -31,20 +31,6 @@ type ApiRefBuilderConfig<TId extends string> = {
pluginId?: string;
};
/** @internal */
export const OpaqueApiRef = OpaqueType.create<{
public: ApiRef<unknown> & {
readonly $$type: '@backstage/ApiRef';
};
versions: {
readonly version: 'v1';
readonly pluginId?: string;
};
}>({
type: '@backstage/ApiRef',
versions: ['v1'],
});
function validateId(id: string): void {
const valid = id
.split('.')