Merge pull request #25199 from backstage/camilaibs/nbs10-move-cache-manager-to-defaults

[NBS1.0] Move `cache` implementation and types to defaults
This commit is contained in:
Camila Belo
2024-06-13 14:44:40 +02:00
committed by GitHub
18 changed files with 90 additions and 121 deletions
+13 -24
View File
@@ -19,7 +19,7 @@ import { BitbucketIntegration } from '@backstage/integration';
import { BitbucketServerIntegration } from '@backstage/integration';
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';
@@ -119,25 +119,15 @@ 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;
}
// Warning: (ae-forgotten-export) The symbol "CacheManager_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export const CacheManager: typeof CacheManager_2;
// @public
export type CacheManagerOptions = {
logger?: LoggerService;
onError?: (err: Error) => void;
};
// Warning: (ae-forgotten-export) The symbol "CacheManagerOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type CacheManagerOptions = CacheManagerOptions_2;
// @public
export function cacheToPluginCacheManager(cache: CacheService): {
@@ -471,11 +461,10 @@ export function makeLegacyPlugin<
// @public @deprecated
export function notFoundHandler(): RequestHandler;
// @public (undocumented)
export interface PluginCacheManager {
// (undocumented)
getClient(options?: CacheServiceOptions): CacheService;
}
// Warning: (ae-forgotten-export) The symbol "PluginCacheManager_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type PluginCacheManager = PluginCacheManager_2;
export { PluginDatabaseManager };
-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;
@@ -16,13 +16,60 @@
export * from './scm';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import { CacheManager as _CacheManager } from '../../../backend-defaults/src/entrypoints/cache/CacheManager';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import {
type PluginCacheManager as _PluginCacheManager,
type CacheManagerOptions as _CacheManagerOptions,
} from '../../../backend-defaults/src/entrypoints/cache/types';
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.