Merge pull request #24757 from backstage/camilaibs/nbs10-extract-service-types-and-helpers

[NBS 1.0] Extract service helpers and types to plugin api
This commit is contained in:
Camila Belo
2024-05-21 15:05:17 +02:00
committed by GitHub
12 changed files with 55 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-common': patch
---
In preparation to the new backend system stable release, the `isDatabaseConflictError` helper have been moved to the `@backstage/backend-plugin-api` package and deprecated from `@backstage/backend-common`.
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/backend-plugin-api': patch
'@backstage/plugin-catalog-backend': patch
---
Start using the `isDatabaseConflictError` helper from the `@backstage/backend-plugin-api` package in order to avoid dependency with the soon to deprecate `@backstage/backend-common` package.
+3 -2
View File
@@ -35,6 +35,7 @@ import { HostDiscovery as HostDiscovery_2 } from '@backstage/backend-app-api';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { IdentityService } from '@backstage/backend-plugin-api';
import { isChildPath as isChildPath_2 } from '@backstage/backend-plugin-api';
import { isDatabaseConflictError as isDatabaseConflictError_2 } from '@backstage/backend-plugin-api';
import { KubeConfig } from '@kubernetes/client-node';
import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
@@ -538,8 +539,8 @@ export const HostDiscovery: typeof HostDiscovery_2;
// @public @deprecated (undocumented)
export const isChildPath: typeof isChildPath_2;
// @public
export function isDatabaseConflictError(e: unknown): boolean;
// @public @deprecated (undocumented)
export const isDatabaseConflictError: typeof isDatabaseConflictError_2;
// @public
export class KubernetesContainerRunner implements ContainerRunner {
@@ -21,4 +21,3 @@ export type {
} from './DatabaseManager';
export type { PluginDatabaseManager } from './types';
export { isDatabaseConflictError } from './util';
@@ -17,6 +17,7 @@
export * from './scm';
import {
isDatabaseConflictError as _isDatabaseConflictError,
resolvePackagePath as _resolvePackagePath,
resolveSafeChildPath as _resolveSafeChildPath,
isChildPath as _isChildPath,
@@ -24,21 +25,28 @@ import {
/**
* @public
* @deprecated This type is deprecated and will be removed in a future release, see https://github.com/backstage/backstage/issues/24493.
* @deprecated This function is deprecated and will be removed in a future release, see https://github.com/backstage/backstage/issues/24493.
* Please use the `isDatabaseConflictError` function from the `@backstage/backend-plugin-api` package instead.
*/
export const isDatabaseConflictError = _isDatabaseConflictError;
/**
* @public
* @deprecated This function is deprecated and will be removed in a future release, see https://github.com/backstage/backstage/issues/24493.
* Please use the `resolvePackagePath` function from the `@backstage/backend-plugin-api` package instead.
*/
export const resolvePackagePath = _resolvePackagePath;
/**
* @public
* @deprecated This type is deprecated and will be removed in a future release, see
* @deprecated This function is deprecated and will be removed in a future release, see https://github.com/backstage/backstage/issues/24493.
* Please use the `resolveSafeChildPath` function from the `@backstage/backend-plugin-api` package instead.
*/
export const resolveSafeChildPath = _resolveSafeChildPath;
/**
* @public
* @deprecated This type is deprecated and will be removed in a future release, see
* @deprecated This function is deprecated and will be removed in a future release, see https://github.com/backstage/backstage/issues/24493.
* Please use the `isChildPath` function from the `@backstage/cli-common` package instead.
*/
export const isChildPath = _isChildPath;
@@ -357,6 +357,9 @@ export interface IdentityService extends IdentityApi {}
export { isChildPath };
// @public
export function isDatabaseConflictError(e: unknown): boolean;
// @public (undocumented)
export interface LifecycleService {
addShutdownHook(
@@ -16,3 +16,4 @@
export * from './definitions';
export * from './system';
export * from './utilities';
@@ -0,0 +1,17 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { isDatabaseConflictError } from './database';
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { isDatabaseConflictError } from '@backstage/backend-common';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { DeferredEntity } from '@backstage/plugin-catalog-node';
import { Knex } from 'knex';
@@ -34,7 +33,10 @@ import {
Transaction,
} from './types';
import { generateStableHash } from './util';
import { LoggerService } from '@backstage/backend-plugin-api';
import {
LoggerService,
isDatabaseConflictError,
} from '@backstage/backend-plugin-api';
// The number of items that are sent per batch to the database layer, when
// doing .batchInsert calls to knex. This needs to be low enough to not cause
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { isDatabaseConflictError } from '@backstage/backend-common';
import { isDatabaseConflictError } from '@backstage/backend-plugin-api';
import { ConflictError, InputError } from '@backstage/errors';
import { DateTime } from 'luxon';
@@ -18,8 +18,10 @@ import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
import { Knex } from 'knex';
import { DbRefreshStateRow } from '../../tables';
import { v4 as uuid } from 'uuid';
import { isDatabaseConflictError } from '@backstage/backend-common';
import { LoggerService } from '@backstage/backend-plugin-api';
import {
LoggerService,
isDatabaseConflictError,
} from '@backstage/backend-plugin-api';
/**
* Attempts to insert a new refresh state row for the given entity, returning