@@ -12,7 +12,6 @@ import { ComponentProps } from 'react';
|
||||
import { ComponentType } from 'react';
|
||||
import { DiscoveryApi } from '@backstage/core-plugin-api';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityName } from '@backstage/catalog-model';
|
||||
import { Extension } from '@backstage/core-plugin-api';
|
||||
import { ExternalRouteRef } from '@backstage/core-plugin-api';
|
||||
import { FetchApi } from '@backstage/core-plugin-api';
|
||||
@@ -20,7 +19,7 @@ import { FieldProps } from '@rjsf/core';
|
||||
import { FieldValidation } from '@rjsf/core';
|
||||
import { IconButton } from '@material-ui/core';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { JSONSchema } from '@backstage/catalog-model';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { Observable } from '@backstage/types';
|
||||
import { default as React_2 } from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
@@ -122,6 +121,48 @@ export type FieldExtensionOptions<
|
||||
validation?: CustomFieldValidator<TFieldReturnValue>;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "JobStatus" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type JobStatus = 'PENDING' | 'STARTED' | 'COMPLETED' | 'FAILED';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ListActionsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type ListActionsResponse = Array<{
|
||||
id: string;
|
||||
description?: string;
|
||||
schema?: {
|
||||
input?: JSONSchema7;
|
||||
output?: JSONSchema7;
|
||||
};
|
||||
}>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "LogEvent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type LogEvent = {
|
||||
type: 'log' | 'completion';
|
||||
body: {
|
||||
message: string;
|
||||
stepId?: string;
|
||||
status?: LogEventStatus;
|
||||
};
|
||||
createdAt: string;
|
||||
id: string;
|
||||
taskId: string;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "LogEventStatus" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type LogEventStatus =
|
||||
| 'open'
|
||||
| 'processing'
|
||||
| 'failed'
|
||||
| 'completed'
|
||||
| 'skipped';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "OwnedEntityPicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
@@ -210,34 +251,24 @@ export interface RepoUrlPickerUiOptions {
|
||||
// @public
|
||||
export interface ScaffolderApi {
|
||||
// (undocumented)
|
||||
getIntegrationsList(options: { allowedHosts: string[] }): Promise<
|
||||
{
|
||||
type: string;
|
||||
title: string;
|
||||
host: string;
|
||||
}[]
|
||||
>;
|
||||
// Warning: (ae-forgotten-export) The symbol "ScaffolderTask" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
getIntegrationsList(
|
||||
options: ScaffolderGetIntegrationsListOptions,
|
||||
): Promise<ScaffolderGetIntegrationsListResponse>;
|
||||
// (undocumented)
|
||||
getTask(taskId: string): Promise<ScaffolderTask>;
|
||||
// Warning: (ae-forgotten-export) The symbol "TemplateParameterSchema" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
getTemplateParameterSchema(
|
||||
templateName: EntityName,
|
||||
templateRef: string,
|
||||
): Promise<TemplateParameterSchema>;
|
||||
// Warning: (ae-forgotten-export) The symbol "ListActionsResponse" needs to be exported by the entry point index.d.ts
|
||||
listActions(): Promise<ListActionsResponse>;
|
||||
// Warning: (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
|
||||
// Warning: (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
|
||||
// Warning: (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
|
||||
scaffold(
|
||||
templateName: string,
|
||||
values: Record<string, any>,
|
||||
secrets?: Record<string, string>,
|
||||
): Promise<string>;
|
||||
// Warning: (ae-forgotten-export) The symbol "LogEvent" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
options: ScaffolderScaffoldOptions,
|
||||
): Promise<ScaffolderScaffoldResponse>;
|
||||
// (undocumented)
|
||||
streamLogs(options: { taskId: string; after?: number }): Observable<LogEvent>;
|
||||
streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
|
||||
}
|
||||
|
||||
// @public
|
||||
@@ -252,28 +283,25 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
useLongPollingLogs?: boolean;
|
||||
});
|
||||
// (undocumented)
|
||||
getIntegrationsList(options: { allowedHosts: string[] }): Promise<
|
||||
{
|
||||
type: string;
|
||||
title: string;
|
||||
host: string;
|
||||
}[]
|
||||
>;
|
||||
getIntegrationsList(
|
||||
options: ScaffolderGetIntegrationsListOptions,
|
||||
): Promise<ScaffolderGetIntegrationsListResponse>;
|
||||
// (undocumented)
|
||||
getTask(taskId: string): Promise<any>;
|
||||
getTask(taskId: string): Promise<ScaffolderTask>;
|
||||
// (undocumented)
|
||||
getTemplateParameterSchema(
|
||||
templateName: EntityName,
|
||||
templateRef: string,
|
||||
): Promise<TemplateParameterSchema>;
|
||||
// (undocumented)
|
||||
listActions(): Promise<ListActionsResponse>;
|
||||
// Warning: (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
|
||||
// Warning: (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
|
||||
// Warning: (tsdoc-param-tag-with-invalid-name) The @param block should be followed by a valid parameter name: The identifier cannot non-word characters
|
||||
scaffold(
|
||||
templateName: string,
|
||||
values: Record<string, any>,
|
||||
secrets?: Record<string, string>,
|
||||
): Promise<string>;
|
||||
options: ScaffolderScaffoldOptions,
|
||||
): Promise<ScaffolderScaffoldResponse>;
|
||||
// (undocumented)
|
||||
streamLogs(options: { taskId: string; after?: number }): Observable<LogEvent>;
|
||||
streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderFieldExtensions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
@@ -281,6 +309,26 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
// @public (undocumented)
|
||||
export const ScaffolderFieldExtensions: React_2.ComponentType;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderGetIntegrationsListOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ScaffolderGetIntegrationsListOptions {
|
||||
// (undocumented)
|
||||
allowedHosts: string[];
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderGetIntegrationsListResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ScaffolderGetIntegrationsListResponse {
|
||||
// (undocumented)
|
||||
integrations: {
|
||||
type: string;
|
||||
title: string;
|
||||
host: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
@@ -316,6 +364,58 @@ export const scaffolderPlugin: BackstagePlugin<
|
||||
}
|
||||
>;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderScaffoldOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ScaffolderScaffoldOptions {
|
||||
// (undocumented)
|
||||
secrets?: Record<string, string>;
|
||||
// (undocumented)
|
||||
templateName: string;
|
||||
// (undocumented)
|
||||
values: Record<string, any>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderScaffoldResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ScaffolderScaffoldResponse {
|
||||
// (undocumented)
|
||||
taskId: string;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderStreamLogsOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ScaffolderStreamLogsOptions {
|
||||
// (undocumented)
|
||||
after?: number;
|
||||
// (undocumented)
|
||||
taskId: string;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderTask" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type ScaffolderTask = {
|
||||
id: string;
|
||||
spec: TaskSpec;
|
||||
status: 'failed' | 'completed' | 'processing' | 'open' | 'cancelled';
|
||||
lastHeartbeatAt: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ScaffolderTaskOutput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type ScaffolderTaskOutput = {
|
||||
entityRef?: string;
|
||||
remoteUrl?: string;
|
||||
links?: ScaffolderOutputLink[];
|
||||
} & {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
// @public
|
||||
export const TaskPage: ({ loadingText }: TaskPageProps) => JSX.Element;
|
||||
|
||||
@@ -348,6 +448,17 @@ export type TemplateListProps = {
|
||||
};
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "TemplateParameterSchema" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type TemplateParameterSchema = {
|
||||
title: string;
|
||||
steps: Array<{
|
||||
title: string;
|
||||
schema: JsonObject;
|
||||
}>;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "TemplateTypePicker" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
@@ -357,4 +468,8 @@ export const TemplateTypePicker: () => JSX.Element | null;
|
||||
export const useTemplateSecrets: () => {
|
||||
setSecret: (input: Record<string, string>) => void;
|
||||
};
|
||||
|
||||
// Warnings were encountered during analysis:
|
||||
//
|
||||
// src/types.d.ts:32:5 - (ae-forgotten-export) The symbol "ScaffolderOutputLink" needs to be exported by the entry point index.d.ts
|
||||
```
|
||||
|
||||
@@ -140,7 +140,7 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
}
|
||||
|
||||
const { id } = (await response.json()) as { id: string };
|
||||
return { jobId: id };
|
||||
return { taskId: id };
|
||||
}
|
||||
|
||||
async getTask(taskId: string): Promise<ScaffolderTask> {
|
||||
|
||||
@@ -49,7 +49,7 @@ import React, { memo, useEffect, useMemo, useState } from 'react';
|
||||
import { generatePath, useNavigate, useParams } from 'react-router';
|
||||
import useInterval from 'react-use/lib/useInterval';
|
||||
import { rootRouteRef } from '../../routes';
|
||||
import { Status, TaskOutput } from '../../types';
|
||||
import { LogEventStatus, ScaffolderTaskOutput } from '../../types';
|
||||
import { useTaskEventStream } from '../hooks/useEventStream';
|
||||
import { TaskPageLinks } from './TaskPageLinks';
|
||||
|
||||
@@ -86,7 +86,7 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||
type TaskStep = {
|
||||
id: string;
|
||||
name: string;
|
||||
status: Status;
|
||||
status: LogEventStatus;
|
||||
startedAt?: string;
|
||||
endedAt?: string;
|
||||
};
|
||||
@@ -217,7 +217,11 @@ export const TaskStatusStepper = memo(
|
||||
},
|
||||
);
|
||||
|
||||
const hasLinks = ({ entityRef, remoteUrl, links = [] }: TaskOutput): boolean =>
|
||||
const hasLinks = ({
|
||||
entityRef,
|
||||
remoteUrl,
|
||||
links = [],
|
||||
}: ScaffolderTaskOutput): boolean =>
|
||||
!!(entityRef || remoteUrl || links.length > 0);
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,12 +19,12 @@ import { entityRouteRef } from '@backstage/plugin-catalog-react';
|
||||
import { Box } from '@material-ui/core';
|
||||
import LanguageIcon from '@material-ui/icons/Language';
|
||||
import React from 'react';
|
||||
import { TaskOutput } from '../../types';
|
||||
import { ScaffolderTaskOutput } from '../../types';
|
||||
import { IconLink } from './IconLink';
|
||||
import { IconComponent, useApp, useRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
type TaskPageLinksProps = {
|
||||
output: TaskOutput;
|
||||
output: ScaffolderTaskOutput;
|
||||
};
|
||||
|
||||
export const TaskPageLinks = ({ output }: TaskPageLinksProps) => {
|
||||
|
||||
@@ -23,7 +23,8 @@ import { ThemeProvider } from '@material-ui/core';
|
||||
import { act, fireEvent, within } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { MemoryRouter, Route } from 'react-router';
|
||||
import { ScaffolderApi, scaffolderApiRef } from '../../api';
|
||||
import { scaffolderApiRef } from '../../api';
|
||||
import { ScaffolderApi } from '../../types';
|
||||
import { rootRouteRef } from '../../routes';
|
||||
import { TemplatePage } from './TemplatePage';
|
||||
import {
|
||||
|
||||
@@ -42,16 +42,11 @@ import {
|
||||
useRouteRef,
|
||||
} from '@backstage/core-plugin-api';
|
||||
|
||||
const useTemplateParameterSchema = (templateName: string) => {
|
||||
const useTemplateParameterSchema = (templateRef: string) => {
|
||||
const scaffolderApi = useApi(scaffolderApiRef);
|
||||
const { value, loading, error } = useAsync(
|
||||
() =>
|
||||
scaffolderApi.getTemplateParameterSchema({
|
||||
name: templateName,
|
||||
kind: 'template',
|
||||
namespace: 'default',
|
||||
}),
|
||||
[scaffolderApi, templateName],
|
||||
() => scaffolderApi.getTemplateParameterSchema(templateRef),
|
||||
[scaffolderApi, templateRef],
|
||||
);
|
||||
return { schema: value, loading, error };
|
||||
};
|
||||
@@ -141,11 +136,11 @@ export const TemplatePage = ({
|
||||
);
|
||||
|
||||
const handleCreate = async () => {
|
||||
const id = await scaffolderApi.scaffold(
|
||||
const { taskId } = await scaffolderApi.scaffold({
|
||||
templateName,
|
||||
formState,
|
||||
secretsContext?.secrets,
|
||||
);
|
||||
values: formState,
|
||||
secrets: secretsContext?.secrets,
|
||||
});
|
||||
|
||||
const formParams = qs.stringify(
|
||||
{ formData: formState },
|
||||
@@ -158,7 +153,7 @@ export const TemplatePage = ({
|
||||
// extra back/forward slots.
|
||||
window.history?.replaceState(null, document.title, newUrl);
|
||||
|
||||
navigate(generatePath(`${rootLink()}/tasks/:taskId`, { taskId: id }));
|
||||
navigate(generatePath(`${rootLink()}/tasks/:taskId`, { taskId }));
|
||||
};
|
||||
|
||||
if (error) {
|
||||
|
||||
@@ -15,14 +15,19 @@
|
||||
*/
|
||||
import { useImmerReducer } from 'use-immer';
|
||||
import { useEffect } from 'react';
|
||||
import { scaffolderApiRef, LogEvent } from '../../api';
|
||||
import { ScaffolderTask, Status, TaskOutput } from '../../types';
|
||||
import { scaffolderApiRef } from '../../api';
|
||||
import {
|
||||
ScaffolderTask,
|
||||
LogEventStatus,
|
||||
ScaffolderTaskOutput,
|
||||
LogEvent,
|
||||
} from '../../types';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { Subscription } from '@backstage/types';
|
||||
|
||||
type Step = {
|
||||
id: string;
|
||||
status: Status;
|
||||
status: LogEventStatus;
|
||||
endedAt?: string;
|
||||
startedAt?: string;
|
||||
};
|
||||
@@ -34,16 +39,16 @@ export type TaskStream = {
|
||||
completed: boolean;
|
||||
task?: ScaffolderTask;
|
||||
steps: { [stepId in string]: Step };
|
||||
output?: TaskOutput;
|
||||
output?: ScaffolderTaskOutput;
|
||||
};
|
||||
|
||||
type ReducerLogEntry = {
|
||||
createdAt: string;
|
||||
body: {
|
||||
stepId?: string;
|
||||
status?: Status;
|
||||
status?: LogEventStatus;
|
||||
message: string;
|
||||
output?: TaskOutput;
|
||||
output?: ScaffolderTaskOutput;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -17,28 +17,14 @@ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
|
||||
import { JsonObject, Observable } from '@backstage/types';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
|
||||
export type Status = 'open' | 'processing' | 'failed' | 'completed' | 'skipped';
|
||||
export type JobStatus = 'PENDING' | 'STARTED' | 'COMPLETED' | 'FAILED';
|
||||
export type Job = {
|
||||
id: string;
|
||||
metadata: {
|
||||
entity: any;
|
||||
values: any;
|
||||
remoteUrl?: string;
|
||||
catalogInfoUrl?: string;
|
||||
};
|
||||
status: JobStatus;
|
||||
stages: Stage[];
|
||||
error?: Error;
|
||||
};
|
||||
export type LogEventStatus =
|
||||
| 'open'
|
||||
| 'processing'
|
||||
| 'failed'
|
||||
| 'completed'
|
||||
| 'skipped';
|
||||
|
||||
export type Stage = {
|
||||
name: string;
|
||||
log: string[];
|
||||
status: JobStatus;
|
||||
startedAt: string;
|
||||
endedAt?: string;
|
||||
};
|
||||
export type JobStatus = 'PENDING' | 'STARTED' | 'COMPLETED' | 'FAILED';
|
||||
|
||||
export type ScaffolderTask = {
|
||||
id: string;
|
||||
@@ -57,19 +43,19 @@ export type ListActionsResponse = Array<{
|
||||
};
|
||||
}>;
|
||||
|
||||
type OutputLink = {
|
||||
type ScaffolderOutputLink = {
|
||||
title?: string;
|
||||
icon?: string;
|
||||
url?: string;
|
||||
entityRef?: string;
|
||||
};
|
||||
|
||||
export type TaskOutput = {
|
||||
export type ScaffolderTaskOutput = {
|
||||
/** @deprecated use the `links` property to link out to relevant resources */
|
||||
entityRef?: string;
|
||||
/** @deprecated use the `links` property to link out to relevant resources */
|
||||
remoteUrl?: string;
|
||||
links?: OutputLink[];
|
||||
links?: ScaffolderOutputLink[];
|
||||
} & {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
@@ -87,7 +73,7 @@ export type LogEvent = {
|
||||
body: {
|
||||
message: string;
|
||||
stepId?: string;
|
||||
status?: Status;
|
||||
status?: LogEventStatus;
|
||||
};
|
||||
createdAt: string;
|
||||
id: string;
|
||||
@@ -100,7 +86,7 @@ export interface ScaffolderScaffoldOptions {
|
||||
}
|
||||
|
||||
export interface ScaffolderScaffoldResponse {
|
||||
jobId: string;
|
||||
taskId: string;
|
||||
}
|
||||
|
||||
export interface ScaffolderGetIntegrationsListOptions {
|
||||
|
||||
Reference in New Issue
Block a user