Merge pull request #8405 from backstage/freben/nounpack
Do not unpack arguments directly on exported items 🧹
This commit is contained in:
@@ -17,13 +17,7 @@ export const analyticsModuleGA: BackstagePlugin<{}, {}>;
|
||||
//
|
||||
// @public
|
||||
export class GoogleAnalytics implements AnalyticsApi {
|
||||
captureEvent({
|
||||
context,
|
||||
action,
|
||||
subject,
|
||||
value,
|
||||
attributes,
|
||||
}: AnalyticsEvent): void;
|
||||
captureEvent(event: AnalyticsEvent): void;
|
||||
static fromConfig(config: Config): GoogleAnalytics;
|
||||
}
|
||||
|
||||
|
||||
+5
-14
@@ -39,19 +39,15 @@ export class GoogleAnalytics implements AnalyticsApi {
|
||||
/**
|
||||
* Instantiate the implementation and initialize ReactGA.
|
||||
*/
|
||||
private constructor({
|
||||
cdmConfig,
|
||||
trackingId,
|
||||
scriptSrc,
|
||||
testMode,
|
||||
debug,
|
||||
}: {
|
||||
private constructor(options: {
|
||||
cdmConfig: CustomDimensionOrMetricConfig[];
|
||||
trackingId: string;
|
||||
scriptSrc?: string;
|
||||
testMode: boolean;
|
||||
debug: boolean;
|
||||
}) {
|
||||
const { cdmConfig, trackingId, scriptSrc, testMode, debug } = options;
|
||||
|
||||
this.cdmConfig = cdmConfig;
|
||||
|
||||
// Initialize Google Analytics.
|
||||
@@ -102,13 +98,8 @@ export class GoogleAnalytics implements AnalyticsApi {
|
||||
* pageview and the rest as custom events. All custom dimensions/metrics are
|
||||
* applied as they should be (set on pageview, merged object on events).
|
||||
*/
|
||||
captureEvent({
|
||||
context,
|
||||
action,
|
||||
subject,
|
||||
value,
|
||||
attributes,
|
||||
}: AnalyticsEvent) {
|
||||
captureEvent(event: AnalyticsEvent) {
|
||||
const { context, action, subject, value, attributes } = event;
|
||||
const customMetadata = this.getCustomDimensionMetrics(context, attributes);
|
||||
|
||||
if (action === 'navigate' && context.extension === 'App') {
|
||||
|
||||
@@ -185,10 +185,7 @@ export class CatalogIdentityClient {
|
||||
// Warning: (ae-forgotten-export) The symbol "UserQuery" needs to be exported by the entry point index.d.ts
|
||||
findUser(query: UserQuery): Promise<UserEntity>;
|
||||
// Warning: (ae-forgotten-export) The symbol "MemberClaimQuery" needs to be exported by the entry point index.d.ts
|
||||
resolveCatalogMembership({
|
||||
entityRefs,
|
||||
logger,
|
||||
}: MemberClaimQuery): Promise<string[]>;
|
||||
resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "createAtlassianProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
@@ -270,13 +267,7 @@ export function createOriginFilter(config: Config): (origin: string) => boolean;
|
||||
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export function createRouter({
|
||||
logger,
|
||||
config,
|
||||
discovery,
|
||||
database,
|
||||
providerFactories,
|
||||
}: RouterOptions): Promise<express.Router>;
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const createSamlProvider: (
|
||||
|
||||
@@ -84,10 +84,8 @@ export class CatalogIdentityClient {
|
||||
*
|
||||
* Returns a superset of the entity names that can be passed directly to `issueToken` as `ent`.
|
||||
*/
|
||||
async resolveCatalogMembership({
|
||||
entityRefs,
|
||||
logger,
|
||||
}: MemberClaimQuery): Promise<string[]> {
|
||||
async resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]> {
|
||||
const { entityRefs, logger } = query;
|
||||
const resolvedEntityRefs = entityRefs
|
||||
.map((ref: string) => {
|
||||
try {
|
||||
|
||||
@@ -44,13 +44,10 @@ export interface RouterOptions {
|
||||
providerFactories?: ProviderFactories;
|
||||
}
|
||||
|
||||
export async function createRouter({
|
||||
logger,
|
||||
config,
|
||||
discovery,
|
||||
database,
|
||||
providerFactories,
|
||||
}: RouterOptions): Promise<express.Router> {
|
||||
export async function createRouter(
|
||||
options: RouterOptions,
|
||||
): Promise<express.Router> {
|
||||
const { logger, config, discovery, database, providerFactories } = options;
|
||||
const router = Router();
|
||||
|
||||
const appUrl = config.getString('app.baseUrl');
|
||||
|
||||
@@ -752,13 +752,7 @@ export type DbPageInfo =
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class DefaultCatalogCollator implements DocumentCollator {
|
||||
constructor({
|
||||
discovery,
|
||||
locationTemplate,
|
||||
filter,
|
||||
catalogClient,
|
||||
tokenManager,
|
||||
}: {
|
||||
constructor(options: {
|
||||
discovery: PluginEndpointDiscovery;
|
||||
tokenManager: TokenManager;
|
||||
locationTemplate?: string;
|
||||
|
||||
@@ -56,19 +56,16 @@ export class DefaultCatalogCollator implements DocumentCollator {
|
||||
});
|
||||
}
|
||||
|
||||
constructor({
|
||||
discovery,
|
||||
locationTemplate,
|
||||
filter,
|
||||
catalogClient,
|
||||
tokenManager,
|
||||
}: {
|
||||
constructor(options: {
|
||||
discovery: PluginEndpointDiscovery;
|
||||
tokenManager: TokenManager;
|
||||
locationTemplate?: string;
|
||||
filter?: CatalogEntitiesRequest['filter'];
|
||||
catalogClient?: CatalogApi;
|
||||
}) {
|
||||
const { discovery, locationTemplate, filter, catalogClient, tokenManager } =
|
||||
options;
|
||||
|
||||
this.discovery = discovery;
|
||||
this.locationTemplate =
|
||||
locationTemplate || '/catalog/:namespace/:kind/:name';
|
||||
|
||||
@@ -41,11 +41,9 @@ export const configSchemaPlugin: BackstagePlugin<
|
||||
{}
|
||||
>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "StaticSchemaLoader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
export class StaticSchemaLoader implements ConfigSchemaApi {
|
||||
constructor({ url }?: { url?: string });
|
||||
constructor(options?: { url?: string });
|
||||
// (undocumented)
|
||||
schema$(): Observable<ConfigSchemaResult>;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ const DEFAULT_URL = 'config-schema.json';
|
||||
|
||||
/**
|
||||
* A ConfigSchemaApi implementation that loads the configuration from a URL.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class StaticSchemaLoader implements ConfigSchemaApi {
|
||||
private readonly url: string;
|
||||
|
||||
constructor({ url = DEFAULT_URL }: { url?: string } = {}) {
|
||||
this.url = url;
|
||||
constructor(options: { url?: string } = {}) {
|
||||
this.url = options?.url ?? DEFAULT_URL;
|
||||
}
|
||||
|
||||
schema$(): Observable<ConfigSchemaResult> {
|
||||
|
||||
@@ -38,11 +38,7 @@ function createStatusColumn(): TableColumn<GithubDeployment>;
|
||||
// Warning: (ae-missing-release-tag) "EntityGithubDeploymentsCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export const EntityGithubDeploymentsCard: ({
|
||||
last,
|
||||
lastStatuses,
|
||||
columns,
|
||||
}: {
|
||||
export const EntityGithubDeploymentsCard: (props: {
|
||||
last?: number | undefined;
|
||||
lastStatuses?: number | undefined;
|
||||
columns?: TableColumn<GithubDeployment>[] | undefined;
|
||||
@@ -58,12 +54,9 @@ export const githubDeploymentsPlugin: BackstagePlugin<{}, {}>;
|
||||
// Warning: (ae-missing-release-tag) "GithubDeploymentsTable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export function GithubDeploymentsTable({
|
||||
deployments,
|
||||
isLoading,
|
||||
reload,
|
||||
columns,
|
||||
}: GithubDeploymentsTableProps): JSX.Element;
|
||||
export function GithubDeploymentsTable(
|
||||
props: GithubDeploymentsTableProps,
|
||||
): JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace GithubDeploymentsTable {
|
||||
@@ -78,7 +71,7 @@ export namespace GithubDeploymentsTable {
|
||||
// Warning: (ae-missing-release-tag) "GithubStateIndicator" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
const GithubStateIndicator: ({ state }: { state: string }) => JSX.Element;
|
||||
const GithubStateIndicator: (props: { state: string }) => JSX.Element;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "isGithubDeploymentsAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
|
||||
@@ -80,15 +80,12 @@ const GithubDeploymentsComponent = ({
|
||||
);
|
||||
};
|
||||
|
||||
export const GithubDeploymentsCard = ({
|
||||
last,
|
||||
lastStatuses,
|
||||
columns,
|
||||
}: {
|
||||
export const GithubDeploymentsCard = (props: {
|
||||
last?: number;
|
||||
lastStatuses?: number;
|
||||
columns?: TableColumn<GithubDeployment>[];
|
||||
}) => {
|
||||
const { last, lastStatuses, columns } = props;
|
||||
const { entity } = useEntity();
|
||||
const [host] = [
|
||||
entity?.metadata.annotations?.[SOURCE_LOCATION_ANNOTATION],
|
||||
|
||||
+2
-6
@@ -36,12 +36,8 @@ type GithubDeploymentsTableProps = {
|
||||
columns: TableColumn<GithubDeployment>[];
|
||||
};
|
||||
|
||||
export function GithubDeploymentsTable({
|
||||
deployments,
|
||||
isLoading,
|
||||
reload,
|
||||
columns,
|
||||
}: GithubDeploymentsTableProps) {
|
||||
export function GithubDeploymentsTable(props: GithubDeploymentsTableProps) {
|
||||
const { deployments, isLoading, reload, columns } = props;
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
|
||||
@@ -27,8 +27,8 @@ import {
|
||||
Link,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
export const GithubStateIndicator = ({ state }: { state: string }) => {
|
||||
switch (state) {
|
||||
export const GithubStateIndicator = (props: { state: string }) => {
|
||||
switch (props.state) {
|
||||
case 'PENDING':
|
||||
return <StatusPending />;
|
||||
case 'IN_PROGRESS':
|
||||
|
||||
@@ -10,7 +10,7 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
|
||||
import { ConfigApi } from '@backstage/core-plugin-api';
|
||||
import { DiscoveryApi } from '@backstage/core-plugin-api';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { PropsWithChildren } from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "EntityPagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
@@ -65,12 +65,7 @@ export class PagerDutyClient implements PagerDutyApi {
|
||||
// Warning: (ae-forgotten-export) The symbol "TriggerAlarmRequest" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
triggerAlarm({
|
||||
integrationKey,
|
||||
source,
|
||||
description,
|
||||
userName,
|
||||
}: TriggerAlarmRequest): Promise<Response>;
|
||||
triggerAlarm(request: TriggerAlarmRequest): Promise<Response>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "pagerDutyPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
@@ -84,9 +79,7 @@ export { pagerDutyPlugin as plugin };
|
||||
// Warning: (ae-missing-release-tag) "TriggerButton" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export function TriggerButton({
|
||||
children,
|
||||
}: PropsWithChildren<TriggerButtonProps>): JSX.Element;
|
||||
export function TriggerButton(props: TriggerButtonProps): JSX.Element;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "UnauthorizedError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
|
||||
@@ -91,12 +91,9 @@ export class PagerDutyClient implements PagerDutyApi {
|
||||
return oncalls;
|
||||
}
|
||||
|
||||
triggerAlarm({
|
||||
integrationKey,
|
||||
source,
|
||||
description,
|
||||
userName,
|
||||
}: TriggerAlarmRequest): Promise<Response> {
|
||||
triggerAlarm(request: TriggerAlarmRequest): Promise<Response> {
|
||||
const { integrationKey, source, description, userName } = request;
|
||||
|
||||
const body = JSON.stringify({
|
||||
event_action: 'trigger',
|
||||
routing_key: integrationKey,
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React, { useCallback, PropsWithChildren, useState } from 'react';
|
||||
import React, { useCallback, ReactNode, useState } from 'react';
|
||||
import { makeStyles, Button } from '@material-ui/core';
|
||||
import { BackstageTheme } from '@backstage/theme';
|
||||
|
||||
import { usePagerdutyEntity } from '../../hooks';
|
||||
import { TriggerDialog } from '../TriggerDialog';
|
||||
|
||||
export type TriggerButtonProps = {};
|
||||
export type TriggerButtonProps = {
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
const useStyles = makeStyles<BackstageTheme>(theme => ({
|
||||
buttonStyle: {
|
||||
@@ -32,9 +34,7 @@ const useStyles = makeStyles<BackstageTheme>(theme => ({
|
||||
},
|
||||
}));
|
||||
|
||||
export function TriggerButton({
|
||||
children,
|
||||
}: PropsWithChildren<TriggerButtonProps>) {
|
||||
export function TriggerButton(props: TriggerButtonProps) {
|
||||
const { buttonStyle } = useStyles();
|
||||
const { integrationKey } = usePagerdutyEntity();
|
||||
const [dialogShown, setDialogShown] = useState<boolean>(false);
|
||||
@@ -56,7 +56,7 @@ export function TriggerButton({
|
||||
disabled={disabled}
|
||||
>
|
||||
{integrationKey
|
||||
? children ?? 'Create Incident'
|
||||
? props.children ?? 'Create Incident'
|
||||
: 'Missing integration key'}
|
||||
</Button>
|
||||
{integrationKey && (
|
||||
|
||||
@@ -83,11 +83,7 @@ export const createConditionTransformer: <
|
||||
) => ConditionTransformer<TQuery>;
|
||||
|
||||
// @public
|
||||
export const createPermissionIntegrationRouter: <TResource>({
|
||||
resourceType,
|
||||
rules,
|
||||
getResource,
|
||||
}: {
|
||||
export const createPermissionIntegrationRouter: <TResource>(options: {
|
||||
resourceType: string;
|
||||
rules: PermissionRule<TResource, any, unknown[]>[];
|
||||
getResource: (resourceRef: string) => Promise<TResource | undefined>;
|
||||
|
||||
@@ -116,17 +116,15 @@ const applyConditions = <TResource>(
|
||||
* This is used to construct the `createPermissionIntegrationRouter`, a function to add an
|
||||
* authorization route to your backend plugin. This route will be called by the `permission-backend`
|
||||
* when authorization conditions relating to this plugin need to be evaluated.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const createPermissionIntegrationRouter = <TResource>({
|
||||
resourceType,
|
||||
rules,
|
||||
getResource,
|
||||
}: {
|
||||
export const createPermissionIntegrationRouter = <TResource>(options: {
|
||||
resourceType: string;
|
||||
rules: PermissionRule<TResource, any>[];
|
||||
getResource: (resourceRef: string) => Promise<TResource | undefined>;
|
||||
}): Router => {
|
||||
const { resourceType, rules, getResource } = options;
|
||||
const router = Router();
|
||||
|
||||
const getRule = createGetRule(rules);
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
import { ApiRef } from '@backstage/core-plugin-api';
|
||||
import { AuthorizeRequest } from '@backstage/plugin-permission-common';
|
||||
import { AuthorizeResponse } from '@backstage/plugin-permission-common';
|
||||
import { ComponentProps } from 'react';
|
||||
import { Config } from '@backstage/config';
|
||||
import { DiscoveryApi } from '@backstage/core-plugin-api';
|
||||
import { IdentityApi } from '@backstage/core-plugin-api';
|
||||
import { Permission } from '@backstage/plugin-permission-common';
|
||||
import { default as React_2 } from 'react';
|
||||
import { RouteProps } from 'react-router';
|
||||
import { ReactElement } from 'react';
|
||||
import { Route } from 'react-router';
|
||||
|
||||
// @public (undocumented)
|
||||
export type AsyncPermissionResult = {
|
||||
@@ -25,11 +26,7 @@ export class IdentityPermissionApi implements PermissionApi {
|
||||
// (undocumented)
|
||||
authorize(request: AuthorizeRequest): Promise<AuthorizeResponse>;
|
||||
// (undocumented)
|
||||
static create({
|
||||
configApi,
|
||||
discoveryApi,
|
||||
identityApi,
|
||||
}: {
|
||||
static create(options: {
|
||||
configApi: Config;
|
||||
discoveryApi: DiscoveryApi;
|
||||
identityApi: IdentityApi;
|
||||
@@ -45,19 +42,13 @@ export type PermissionApi = {
|
||||
export const permissionApiRef: ApiRef<PermissionApi>;
|
||||
|
||||
// @public
|
||||
export const PermissionedRoute: ({
|
||||
permission,
|
||||
resourceRef,
|
||||
errorComponent,
|
||||
...props
|
||||
}: RouteProps & {
|
||||
permission: Permission;
|
||||
resourceRef?: string | undefined;
|
||||
errorComponent?:
|
||||
| React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>>
|
||||
| null
|
||||
| undefined;
|
||||
}) => JSX.Element;
|
||||
export const PermissionedRoute: (
|
||||
props: ComponentProps<typeof Route> & {
|
||||
permission: Permission;
|
||||
resourceRef?: string;
|
||||
errorComponent?: ReactElement | null;
|
||||
},
|
||||
) => JSX.Element;
|
||||
|
||||
// @public
|
||||
export const usePermission: (
|
||||
|
||||
@@ -34,15 +34,12 @@ export class IdentityPermissionApi implements PermissionApi {
|
||||
private readonly identityApi: IdentityApi,
|
||||
) {}
|
||||
|
||||
static create({
|
||||
configApi,
|
||||
discoveryApi,
|
||||
identityApi,
|
||||
}: {
|
||||
static create(options: {
|
||||
configApi: Config;
|
||||
discoveryApi: DiscoveryApi;
|
||||
identityApi: IdentityApi;
|
||||
}) {
|
||||
const { configApi, discoveryApi, identityApi } = options;
|
||||
const permissionClient = new PermissionClient({ discoveryApi, configApi });
|
||||
return new IdentityPermissionApi(permissionClient, identityApi);
|
||||
}
|
||||
|
||||
@@ -21,20 +21,19 @@ import { usePermission } from '../hooks';
|
||||
import { Permission } from '@backstage/plugin-permission-common';
|
||||
|
||||
/**
|
||||
* Returns a React Router Route which only renders the element when authorized. If unathorized, the Route will render a
|
||||
* Returns a React Router Route which only renders the element when authorized. If unauthorized, the Route will render a
|
||||
* NotFoundErrorPage (see {@link @backstage/core-app-api#AppComponents}).
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const PermissionedRoute = ({
|
||||
permission,
|
||||
resourceRef,
|
||||
errorComponent,
|
||||
...props
|
||||
}: ComponentProps<typeof Route> & {
|
||||
permission: Permission;
|
||||
resourceRef?: string;
|
||||
errorComponent?: ReactElement | null;
|
||||
}) => {
|
||||
export const PermissionedRoute = (
|
||||
props: ComponentProps<typeof Route> & {
|
||||
permission: Permission;
|
||||
resourceRef?: string;
|
||||
errorComponent?: ReactElement | null;
|
||||
},
|
||||
) => {
|
||||
const { permission, resourceRef, errorComponent, ...otherProps } = props;
|
||||
const permissionResult = usePermission(permission, resourceRef);
|
||||
const app = useApp();
|
||||
const { NotFoundErrorPage } = app.getComponents();
|
||||
@@ -48,5 +47,5 @@ export const PermissionedRoute = ({
|
||||
shownElement = props.element;
|
||||
}
|
||||
|
||||
return <Route {...props} element={shownElement} />;
|
||||
return <Route {...otherProps} element={shownElement} />;
|
||||
};
|
||||
|
||||
@@ -11,8 +11,6 @@ import { SearchEngine } from '@backstage/search-common';
|
||||
import { SearchQuery } from '@backstage/search-common';
|
||||
import { SearchResultSet } from '@backstage/search-common';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ElasticSearchSearchEngine" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
constructor(
|
||||
@@ -24,12 +22,9 @@ export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
// Warning: (ae-forgotten-export) The symbol "ElasticSearchOptions" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
static fromConfig({
|
||||
logger,
|
||||
config,
|
||||
aliasPostfix,
|
||||
indexPrefix,
|
||||
}: ElasticSearchOptions): Promise<ElasticSearchSearchEngine>;
|
||||
static fromConfig(
|
||||
options: ElasticSearchOptions,
|
||||
): Promise<ElasticSearchSearchEngine>;
|
||||
// (undocumented)
|
||||
index(type: string, documents: IndexableDocument[]): Promise<void>;
|
||||
// (undocumented)
|
||||
@@ -41,11 +36,6 @@ export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
// Warning: (ae-forgotten-export) The symbol "ConcreteElasticSearchQuery" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
protected translator({
|
||||
term,
|
||||
filters,
|
||||
types,
|
||||
pageCursor,
|
||||
}: SearchQuery): ConcreteElasticSearchQuery;
|
||||
protected translator(query: SearchQuery): ConcreteElasticSearchQuery;
|
||||
}
|
||||
```
|
||||
|
||||
+16
-14
@@ -64,6 +64,9 @@ function isBlank(str: string) {
|
||||
return (isEmpty(str) && !isNumber(str)) || nan(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
constructor(
|
||||
private readonly elasticSearchClient: Client,
|
||||
@@ -72,12 +75,14 @@ export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
static async fromConfig({
|
||||
logger,
|
||||
config,
|
||||
aliasPostfix = `search`,
|
||||
indexPrefix = ``,
|
||||
}: ElasticSearchOptions) {
|
||||
static async fromConfig(options: ElasticSearchOptions) {
|
||||
const {
|
||||
logger,
|
||||
config,
|
||||
aliasPostfix = `search`,
|
||||
indexPrefix = ``,
|
||||
} = options;
|
||||
|
||||
return new ElasticSearchSearchEngine(
|
||||
await ElasticSearchSearchEngine.constructElasticSearchClient(
|
||||
logger,
|
||||
@@ -164,12 +169,9 @@ export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
});
|
||||
}
|
||||
|
||||
protected translator({
|
||||
term,
|
||||
filters = {},
|
||||
types,
|
||||
pageCursor,
|
||||
}: SearchQuery): ConcreteElasticSearchQuery {
|
||||
protected translator(query: SearchQuery): ConcreteElasticSearchQuery {
|
||||
const { term, filters = {}, types, pageCursor } = query;
|
||||
|
||||
const filter = Object.entries(filters)
|
||||
.filter(([_, value]) => Boolean(value))
|
||||
.map(([key, value]: [key: string, value: any]) => {
|
||||
@@ -190,7 +192,7 @@ export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
'Failed to add filters to query. Unrecognized filter type',
|
||||
);
|
||||
});
|
||||
const query = isBlank(term)
|
||||
const esbQuery = isBlank(term)
|
||||
? esb.matchAllQuery()
|
||||
: esb
|
||||
.multiMatchQuery(['*'], term)
|
||||
@@ -202,7 +204,7 @@ export class ElasticSearchSearchEngine implements SearchEngine {
|
||||
return {
|
||||
elasticSearchQuery: esb
|
||||
.requestBodySearch()
|
||||
.query(esb.boolQuery().filter(filter).must([query]))
|
||||
.query(esb.boolQuery().filter(filter).must([esbQuery]))
|
||||
.from(page * pageSize)
|
||||
.size(pageSize)
|
||||
.toJSON(),
|
||||
|
||||
@@ -77,9 +77,7 @@ export interface DatabaseStore {
|
||||
export class PgSearchEngine implements SearchEngine {
|
||||
constructor(databaseStore: DatabaseStore);
|
||||
// (undocumented)
|
||||
static from({
|
||||
database,
|
||||
}: {
|
||||
static from(options: {
|
||||
database: PluginDatabaseManager;
|
||||
}): Promise<PgSearchEngine>;
|
||||
// (undocumented)
|
||||
|
||||
@@ -35,13 +35,11 @@ export type ConcretePgSearchQuery = {
|
||||
export class PgSearchEngine implements SearchEngine {
|
||||
constructor(private readonly databaseStore: DatabaseStore) {}
|
||||
|
||||
static async from({
|
||||
database,
|
||||
}: {
|
||||
static async from(options: {
|
||||
database: PluginDatabaseManager;
|
||||
}): Promise<PgSearchEngine> {
|
||||
return new PgSearchEngine(
|
||||
await DatabaseDocumentStore.create(await database.getClient()),
|
||||
await DatabaseDocumentStore.create(await options.database.getClient()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,16 @@ import express from 'express';
|
||||
import { Logger as Logger_2 } from 'winston';
|
||||
import { SearchEngine } from '@backstage/plugin-search-backend-node';
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "RouterOptions" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export function createRouter({
|
||||
engine,
|
||||
logger,
|
||||
}: RouterOptions): Promise<express.Router>;
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "RouterOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type RouterOptions = {
|
||||
engine: SearchEngine;
|
||||
logger: Logger_2;
|
||||
};
|
||||
```
|
||||
|
||||
@@ -20,15 +20,15 @@ import { Logger } from 'winston';
|
||||
import { SearchQuery, SearchResultSet } from '@backstage/search-common';
|
||||
import { SearchEngine } from '@backstage/plugin-search-backend-node';
|
||||
|
||||
type RouterOptions = {
|
||||
export type RouterOptions = {
|
||||
engine: SearchEngine;
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
export async function createRouter({
|
||||
engine,
|
||||
logger,
|
||||
}: RouterOptions): Promise<express.Router> {
|
||||
export async function createRouter(
|
||||
options: RouterOptions,
|
||||
): Promise<express.Router> {
|
||||
const { engine, logger } = options;
|
||||
const router = Router();
|
||||
router.get(
|
||||
'/query',
|
||||
|
||||
@@ -28,15 +28,7 @@ export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
// @public (undocumented)
|
||||
export class DefaultTechDocsCollator implements DocumentCollator {
|
||||
// @deprecated
|
||||
constructor({
|
||||
discovery,
|
||||
locationTemplate,
|
||||
logger,
|
||||
catalogClient,
|
||||
tokenManager,
|
||||
parallelismLimit,
|
||||
legacyPathCasing,
|
||||
}: TechDocsCollatorOptions);
|
||||
constructor(options: TechDocsCollatorOptions);
|
||||
// (undocumented)
|
||||
protected applyArgsToFormat(
|
||||
format: string,
|
||||
|
||||
@@ -63,24 +63,17 @@ export class DefaultTechDocsCollator implements DocumentCollator {
|
||||
/**
|
||||
* @deprecated use static fromConfig method instead.
|
||||
*/
|
||||
constructor({
|
||||
discovery,
|
||||
locationTemplate,
|
||||
logger,
|
||||
catalogClient,
|
||||
tokenManager,
|
||||
parallelismLimit = 10,
|
||||
legacyPathCasing = false,
|
||||
}: TechDocsCollatorOptions) {
|
||||
this.discovery = discovery;
|
||||
constructor(options: TechDocsCollatorOptions) {
|
||||
this.discovery = options.discovery;
|
||||
this.locationTemplate =
|
||||
locationTemplate || '/docs/:namespace/:kind/:name/:path';
|
||||
this.logger = logger;
|
||||
options.locationTemplate || '/docs/:namespace/:kind/:name/:path';
|
||||
this.logger = options.logger;
|
||||
this.catalogClient =
|
||||
catalogClient || new CatalogClient({ discoveryApi: discovery });
|
||||
this.parallelismLimit = parallelismLimit;
|
||||
this.legacyPathCasing = legacyPathCasing;
|
||||
this.tokenManager = tokenManager;
|
||||
options.catalogClient ||
|
||||
new CatalogClient({ discoveryApi: options.discovery });
|
||||
this.parallelismLimit = options.parallelismLimit ?? 10;
|
||||
this.legacyPathCasing = options.legacyPathCasing ?? false;
|
||||
this.tokenManager = options.tokenManager;
|
||||
}
|
||||
|
||||
static fromConfig(config: Config, options: TechDocsCollatorOptions) {
|
||||
|
||||
@@ -112,7 +112,7 @@ export class TodoScmReader implements TodoReader {
|
||||
options: Omit<Options, 'integrations'>,
|
||||
): TodoScmReader;
|
||||
// (undocumented)
|
||||
readTodos({ url }: ReadTodosOptions): Promise<ReadTodosResult>;
|
||||
readTodos(options: ReadTodosOptions): Promise<ReadTodosResult>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "TodoService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
||||
@@ -76,7 +76,8 @@ export class TodoScmReader implements TodoReader {
|
||||
this.integrations = options.integrations;
|
||||
}
|
||||
|
||||
async readTodos({ url }: ReadTodosOptions): Promise<ReadTodosResult> {
|
||||
async readTodos(options: ReadTodosOptions): Promise<ReadTodosResult> {
|
||||
const { url } = options;
|
||||
const inFlightRead = this.inFlightReads.get(url);
|
||||
if (inFlightRead) {
|
||||
return inFlightRead.then(read => read.result);
|
||||
@@ -101,9 +102,10 @@ export class TodoScmReader implements TodoReader {
|
||||
}
|
||||
|
||||
private async doReadTodos(
|
||||
{ url }: ReadTodosOptions,
|
||||
options: ReadTodosOptions,
|
||||
etag?: string,
|
||||
): Promise<CacheItem> {
|
||||
const { url } = options;
|
||||
const tree = await this.reader.readTree(url, {
|
||||
etag,
|
||||
filter(filePath, info) {
|
||||
|
||||
@@ -26,13 +26,7 @@ export const todoApiRef: ApiRef<TodoApi>;
|
||||
export class TodoClient implements TodoApi {
|
||||
constructor(options: TodoClientOptions);
|
||||
// (undocumented)
|
||||
listTodos({
|
||||
entity,
|
||||
offset,
|
||||
limit,
|
||||
orderBy,
|
||||
filters,
|
||||
}: TodoListOptions): Promise<TodoListResult>;
|
||||
listTodos(options: TodoListOptions): Promise<TodoListResult>;
|
||||
}
|
||||
|
||||
// @public
|
||||
|
||||
@@ -43,13 +43,8 @@ export class TodoClient implements TodoApi {
|
||||
this.identityApi = options.identityApi;
|
||||
}
|
||||
|
||||
async listTodos({
|
||||
entity,
|
||||
offset,
|
||||
limit,
|
||||
orderBy,
|
||||
filters,
|
||||
}: TodoListOptions): Promise<TodoListResult> {
|
||||
async listTodos(options: TodoListOptions): Promise<TodoListResult> {
|
||||
const { entity, offset, limit, orderBy, filters } = options;
|
||||
const baseUrl = await this.discoveryApi.getBaseUrl('todo');
|
||||
const token = await this.identityApi.getIdToken();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user