refactor: deprecate cache implementation and types

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-06-13 09:53:39 +02:00
parent b68439587c
commit e171620164
20 changed files with 89 additions and 121 deletions
+10 -24
View File
@@ -17,9 +17,11 @@ import { BackendFeature } from '@backstage/backend-plugin-api';
import { BitbucketCloudIntegration } from '@backstage/integration';
import { BitbucketIntegration } from '@backstage/integration';
import { BitbucketServerIntegration } from '@backstage/integration';
import { CacheManager as CacheManager_2 } from '@backstage/backend-defaults/cache';
import { CacheManagerOptions as CacheManagerOptions_2 } from '@backstage/backend-defaults/cache';
import { CacheService } from '@backstage/backend-plugin-api';
import { CacheServiceOptions } from '@backstage/backend-plugin-api';
import type { CacheServiceSetOptions } from '@backstage/backend-plugin-api';
import { CacheServiceSetOptions } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import cors from 'cors';
import { DiscoveryService } from '@backstage/backend-plugin-api';
@@ -43,6 +45,7 @@ import { Logger } from 'winston';
import { LoggerService } from '@backstage/backend-plugin-api';
import { MergeResult } from 'isomorphic-git';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { PluginCacheManager as PluginCacheManager_2 } from '@backstage/backend-defaults/cache';
import { DatabaseService as PluginDatabaseManager } from '@backstage/backend-plugin-api';
import { PluginMetadataService } from '@backstage/backend-plugin-api';
import { PushResult } from 'isomorphic-git';
@@ -119,25 +122,11 @@ export type CacheClientOptions = CacheServiceOptions;
// @public @deprecated (undocumented)
export type CacheClientSetOptions = CacheServiceSetOptions;
// @public
export class CacheManager {
forPlugin(pluginId: string): {
getClient(options?: CacheServiceOptions): CacheService;
};
static fromConfig(
config: Config,
options?: {
logger?: LoggerService;
onError?: (err: Error) => void;
},
): CacheManager;
}
// @public @deprecated (undocumented)
export const CacheManager: typeof CacheManager_2;
// @public
export type CacheManagerOptions = {
logger?: LoggerService;
onError?: (err: Error) => void;
};
// @public @deprecated (undocumented)
export type CacheManagerOptions = CacheManagerOptions_2;
// @public
export function cacheToPluginCacheManager(cache: CacheService): {
@@ -471,11 +460,8 @@ export function makeLegacyPlugin<
// @public @deprecated
export function notFoundHandler(): RequestHandler;
// @public (undocumented)
export interface PluginCacheManager {
// (undocumented)
getClient(options?: CacheServiceOptions): CacheService;
}
// @public @deprecated (undocumented)
export type PluginCacheManager = PluginCacheManager_2;
export { PluginDatabaseManager };
+1
View File
@@ -59,6 +59,7 @@
"@aws-sdk/client-s3": "^3.350.0",
"@aws-sdk/credential-providers": "^3.350.0",
"@aws-sdk/types": "^3.347.0",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-dev-utils": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/cli-common": "workspace:^",
-2
View File
@@ -15,5 +15,3 @@
*/
export { cacheToPluginCacheManager } from './cacheToPluginCacheManager';
export * from './reexport';
export * from './types';
-29
View File
@@ -1,29 +0,0 @@
/*
* 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.
*/
/*
* NOTE(freben): This is a temporary hack. We use cross-package imports so that
* we do not have to maintain double implementations for the time being, until
* backend-common is properly removed.
*/
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
export { CacheManager } from '../../../backend-defaults/src/entrypoints/cache/CacheManager';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
export {
type PluginCacheManager,
type CacheManagerOptions,
} from '../../../backend-defaults/src/entrypoints/cache/types';
-39
View File
@@ -1,39 +0,0 @@
/*
* Copyright 2020 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.
*/
import type {
CacheService,
CacheServiceSetOptions,
CacheServiceOptions,
} from '@backstage/backend-plugin-api';
/**
* @public
* @deprecated Use `CacheService` from the `@backstage/backend-plugin-api` package instead
*/
export type CacheClient = CacheService;
/**
* @public
* @deprecated Use `CacheServiceSetOptions` from the `@backstage/backend-plugin-api` package instead
*/
export type CacheClientSetOptions = CacheServiceSetOptions;
/**
* @public
* @deprecated Use `CacheServiceOptions` from the `@backstage/backend-plugin-api` package instead
*/
export type CacheClientOptions = CacheServiceOptions;
@@ -17,12 +17,57 @@
export * from './scm';
import {
CacheManager as _CacheManager,
CacheManagerOptions as _CacheManagerOptions,
PluginCacheManager as _PluginCacheManager,
} from '@backstage/backend-defaults/cache';
import {
CacheService,
CacheServiceOptions,
CacheServiceSetOptions,
isDatabaseConflictError as _isDatabaseConflictError,
resolvePackagePath as _resolvePackagePath,
resolveSafeChildPath as _resolveSafeChildPath,
isChildPath as _isChildPath,
} from '@backstage/backend-plugin-api';
/**
* @public
* @deprecated Use `CacheManager` from the `@backstage/backend-defaults` package instead
*/
export const CacheManager = _CacheManager;
/**
* @public
* @deprecated Use `CacheManagerOptions` from the `@backstage/backend-defaults` package instead
*/
export type CacheManagerOptions = _CacheManagerOptions;
/**
* @public
* @deprecated Use `PluginCacheManager` from the `@backstage/backend-defaults` package instead
*/
export type PluginCacheManager = _PluginCacheManager;
/**
* @public
* @deprecated Use `CacheService` from the `@backstage/backend-plugin-api` package instead
*/
export type CacheClient = CacheService;
/**
* @public
* @deprecated Use `CacheServiceSetOptions` from the `@backstage/backend-plugin-api` package instead
*/
export type CacheClientSetOptions = CacheServiceSetOptions;
/**
* @public
* @deprecated Use `CacheServiceOptions` from the `@backstage/backend-plugin-api` package instead
*/
export type CacheClientOptions = CacheServiceOptions;
/**
* @public
* @deprecated This function is deprecated and will be removed in a future release, see https://github.com/backstage/backstage/issues/24493.