diff --git a/.changeset/eighty-kings-dress.md b/.changeset/eighty-kings-dress.md new file mode 100644 index 0000000000..52aab627ab --- /dev/null +++ b/.changeset/eighty-kings-dress.md @@ -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`. diff --git a/.changeset/wet-crabs-guess.md b/.changeset/wet-crabs-guess.md new file mode 100644 index 0000000000..c8a9282a47 --- /dev/null +++ b/.changeset/wet-crabs-guess.md @@ -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. diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index e8b8c90061..df058266ed 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -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 { diff --git a/packages/backend-common/src/database/index.ts b/packages/backend-common/src/database/index.ts index a0a61ccdd0..77d75653b8 100644 --- a/packages/backend-common/src/database/index.ts +++ b/packages/backend-common/src/database/index.ts @@ -21,4 +21,3 @@ export type { } from './DatabaseManager'; export type { PluginDatabaseManager } from './types'; -export { isDatabaseConflictError } from './util'; diff --git a/packages/backend-common/src/deprecated/index.ts b/packages/backend-common/src/deprecated/index.ts index 708e358bfc..d9ca795c3a 100644 --- a/packages/backend-common/src/deprecated/index.ts +++ b/packages/backend-common/src/deprecated/index.ts @@ -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; diff --git a/packages/backend-plugin-api/api-report.md b/packages/backend-plugin-api/api-report.md index 85ae233dfe..c65fc5cf3e 100644 --- a/packages/backend-plugin-api/api-report.md +++ b/packages/backend-plugin-api/api-report.md @@ -357,6 +357,9 @@ export interface IdentityService extends IdentityApi {} export { isChildPath }; +// @public +export function isDatabaseConflictError(e: unknown): boolean; + // @public (undocumented) export interface LifecycleService { addShutdownHook( diff --git a/packages/backend-plugin-api/src/services/index.ts b/packages/backend-plugin-api/src/services/index.ts index dd24127b88..01d3da444b 100644 --- a/packages/backend-plugin-api/src/services/index.ts +++ b/packages/backend-plugin-api/src/services/index.ts @@ -16,3 +16,4 @@ export * from './definitions'; export * from './system'; +export * from './utilities'; diff --git a/packages/backend-common/src/database/util.ts b/packages/backend-plugin-api/src/services/utilities/database.ts similarity index 100% rename from packages/backend-common/src/database/util.ts rename to packages/backend-plugin-api/src/services/utilities/database.ts diff --git a/packages/backend-plugin-api/src/services/utilities/index.ts b/packages/backend-plugin-api/src/services/utilities/index.ts new file mode 100644 index 0000000000..0eec4f3e84 --- /dev/null +++ b/packages/backend-plugin-api/src/services/utilities/index.ts @@ -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'; diff --git a/plugins/catalog-backend/src/database/DefaultProviderDatabase.ts b/plugins/catalog-backend/src/database/DefaultProviderDatabase.ts index 5b016438e3..94026fbfa0 100644 --- a/plugins/catalog-backend/src/database/DefaultProviderDatabase.ts +++ b/plugins/catalog-backend/src/database/DefaultProviderDatabase.ts @@ -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 diff --git a/plugins/catalog-backend/src/database/conversion.ts b/plugins/catalog-backend/src/database/conversion.ts index 827ae9b367..32de149572 100644 --- a/plugins/catalog-backend/src/database/conversion.ts +++ b/plugins/catalog-backend/src/database/conversion.ts @@ -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'; diff --git a/plugins/catalog-backend/src/database/operations/refreshState/insertUnprocessedEntity.ts b/plugins/catalog-backend/src/database/operations/refreshState/insertUnprocessedEntity.ts index d6309c27fc..195dbe1f2c 100644 --- a/plugins/catalog-backend/src/database/operations/refreshState/insertUnprocessedEntity.ts +++ b/plugins/catalog-backend/src/database/operations/refreshState/insertUnprocessedEntity.ts @@ -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