import { EntityFilterQuery } from '@backstage/catalog-client'; import { Entity } from '@backstage/catalog-model'; import { CacheService, BackstageCredentials, LoggerService } from '@backstage/backend-plugin-api'; import { CatalogService } from '@backstage/plugin-catalog-node'; import * as express_serve_static_core from 'express-serve-static-core'; import { Config } from '@backstage/config'; import { LicenseProduct, LicenseValidationResponse } from '@spotify/backstage-plugin-core-common'; import { Request, Response, NextFunction } from 'express'; /** * Takes an entity and an EntityFilterQuery and returns whether the entity * matches the query. * * @public */ declare function matchesEntityFilterQuery(entity: Entity, entityFilterQuery: EntityFilterQuery): boolean; /** @public */ type ResolveRelatedEntitiesDeps = { cache: CacheService; catalog: CatalogService; credentials: BackstageCredentials; logger: LoggerService; }; /** @public */ type ResolveRelatedEntitiesProps = { entity: Partial; entityRef: string; entityFilterQuery?: EntityFilterQuery; relation: string; /** * @deprecated If you are using this option, you likely want to use * `initialRelation` instead. This attribute is no longer used and will be * removed in a future release. */ relationReverse?: string; /** * Useful if you're wanting to gather relationship hierarchies from one kind * of entity to another (e.g. finding groups for which a group is a "childOf" * other groups, but when starting from a user who is a "memberOf" one or * more of those groups). * * Defaults to the given relation. */ initialRelation?: string; }; /** * A function to take an entity and resolve all the ancestral relations * i.e the indirect ancestral groups that are parents of their direct groups. * * At the same time, we also filter out any groups that don't match * the provided filter. We do this at the same time to optimize * resolving parent groups. * * We heavily rely on the cache for this operation to avoid hitting * the catalog too much and to ensure use of this utility is performant * enough for end-user facing flows. We cache the following: * * - Entity refs which include the final resolved groups to help * resolve further events immediately. * * E.g... * * ``` * { * 'user:default/dave': [ * 'group:default/groupA', * 'group:default/groupB', * 'group:default/groupC' * ]; * } * ``` * * - Entity refs which include either * - a flag (false) to indicate that it is to be ignored because * it is excluded by the filter * - the final resolved parent groups to help resolve child group calls. * * E.g... * * ``` * { * // Has valid/unfiltered parent groups * 'group:default/groupA': ['group:default/groupB', 'group:default/groupC'], * * // Valid group, but has none or filtered parents * 'group:default/groupB': [], * * // Filtered group * 'group:default/groupC': null, * } * ``` * * @public */ declare function resolveRelatedEntities({ cache, catalog, credentials, logger }: ResolveRelatedEntitiesDeps, { entity, entityRef, entityFilterQuery, relation, initialRelation, }: ResolveRelatedEntitiesProps): Promise; /** * @public */ type CreateLicenseIntegrationRouterOptions = { config: Config; cache: CacheService; logger: LoggerService; product: LicenseProduct; }; /** * Adds a route to a backend plugin for license key validation from the frontend. This is only to * show the state of a license in the frontend UI; backend API protection should use * {@link validateLicenseMiddleware}. * * This is embedded in each backend so that an extra license-backend installation isn't needed; it * also allows us to check plugin licenses independently in the future, if we wish. * * @public */ declare function createLicenseIntegrationRouter({ config, cache, logger, product, }: CreateLicenseIntegrationRouterOptions): express_serve_static_core.Router; /** @public */ type CreateGetLicenseStateOptions = { logger: LoggerService; config: Config; cache: CacheService; product: LicenseProduct; publicKey?: string; }; /** * @public */ type GetLicenseStateOptions = { licenseKey?: string; }; /** * Creates a function that returns the current state of the license. * * @public */ declare function createGetLicenseState({ logger, config, cache, product, publicKey, }: CreateGetLicenseStateOptions): (options?: GetLicenseStateOptions) => Promise; /** @public */ type ValidateLicenseMiddlewareOptions = { config: Config; cache: CacheService; logger: LoggerService; product: LicenseProduct; publicKey?: string; shouldValidate?: (req: Request) => boolean; }; /** @public */ declare function validateLicenseMiddleware({ config, cache, logger, product, publicKey, shouldValidate, }: ValidateLicenseMiddlewareOptions): (req: Request, res: Response, next: NextFunction) => void; /** * Checks if the license key is cryptographically-encrypted for offline environments. * @public */ declare function hasOfflineSupport(key: string): boolean; export { type CreateGetLicenseStateOptions, type CreateLicenseIntegrationRouterOptions, type GetLicenseStateOptions, type ResolveRelatedEntitiesDeps, type ResolveRelatedEntitiesProps, type ValidateLicenseMiddlewareOptions, createGetLicenseState, createLicenseIntegrationRouter, hasOfflineSupport, matchesEntityFilterQuery, resolveRelatedEntities, validateLicenseMiddleware };