@backstage/plugin-scaffolder 1.0.1 → 1.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,484 @@
1
+ /**
2
+ * The Backstage plugin that helps you create new things
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ /// <reference types="react" />
8
+
9
+ import { ApiHolder } from '@backstage/core-plugin-api';
10
+ import { ApiRef } from '@backstage/core-plugin-api';
11
+ import { BackstagePlugin } from '@backstage/core-plugin-api';
12
+ import { ComponentType } from 'react';
13
+ import { DiscoveryApi } from '@backstage/core-plugin-api';
14
+ import { Entity } from '@backstage/catalog-model';
15
+ import { Extension } from '@backstage/core-plugin-api';
16
+ import { ExternalRouteRef } from '@backstage/core-plugin-api';
17
+ import { FetchApi } from '@backstage/core-plugin-api';
18
+ import { FieldProps } from '@rjsf/core';
19
+ import { FieldValidation } from '@rjsf/core';
20
+ import { JsonObject } from '@backstage/types';
21
+ import { JSONSchema7 } from 'json-schema';
22
+ import { JsonValue } from '@backstage/types';
23
+ import { Observable } from '@backstage/types';
24
+ import { PropsWithChildren } from 'react';
25
+ import { default as React_2 } from 'react';
26
+ import { RouteRef } from '@backstage/core-plugin-api';
27
+ import { ScmIntegrationRegistry } from '@backstage/integration';
28
+ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
29
+ import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
30
+
31
+ /**
32
+ * Method for creating field extensions that can be used in the scaffolder
33
+ * frontend form.
34
+ * @public
35
+ */
36
+ export declare function createScaffolderFieldExtension<TReturnValue = unknown, TInputProps = unknown>(options: FieldExtensionOptions<TReturnValue, TInputProps>): Extension<FieldExtensionComponent<TReturnValue, TInputProps>>;
37
+
38
+ /**
39
+ * Field validation type for Custom Field Extensions.
40
+ *
41
+ * @public
42
+ */
43
+ export declare type CustomFieldValidator<TFieldReturnValue> = (data: TFieldReturnValue, field: FieldValidation, context: {
44
+ apiHolder: ApiHolder;
45
+ }) => void;
46
+
47
+ /**
48
+ * The field extension for selecting a name for a new Entity in the Catalog.
49
+ *
50
+ * @public
51
+ */
52
+ export declare const EntityNamePickerFieldExtension: FieldExtensionComponent<string, {}>;
53
+
54
+ /**
55
+ * A field extension for selecting an Entity that exists in the Catalog.
56
+ *
57
+ * @public
58
+ */
59
+ export declare const EntityPickerFieldExtension: FieldExtensionComponent<string, EntityPickerUiOptions>;
60
+
61
+ /**
62
+ * The input props that can be specified under `ui:options` for the
63
+ * `EntityPicker` field extension.
64
+ *
65
+ * @public
66
+ */
67
+ export declare interface EntityPickerUiOptions {
68
+ allowedKinds?: string[];
69
+ defaultKind?: string;
70
+ allowArbitraryValues?: boolean;
71
+ }
72
+
73
+ /**
74
+ * EntityTagsPickerFieldExtension
75
+ * @public
76
+ */
77
+ export declare const EntityTagsPickerFieldExtension: FieldExtensionComponent<string[], EntityTagsPickerUiOptions>;
78
+
79
+ /**
80
+ * The input props that can be specified under `ui:options` for the
81
+ * `EntityTagsPicker` field extension.
82
+ *
83
+ * @public
84
+ */
85
+ export declare interface EntityTagsPickerUiOptions {
86
+ kinds?: string[];
87
+ }
88
+
89
+ /**
90
+ * A type used to wrap up the FieldExtension to embed the ReturnValue and the InputProps
91
+ *
92
+ * @public
93
+ */
94
+ export declare type FieldExtensionComponent<_TReturnValue, _TInputProps> = () => null;
95
+
96
+ /**
97
+ * Type for field extensions and being able to type
98
+ * incoming props easier.
99
+ *
100
+ * @public
101
+ */
102
+ export declare interface FieldExtensionComponentProps<TFieldReturnValue, TUiOptions extends {} = {}> extends FieldProps<TFieldReturnValue> {
103
+ uiSchema: FieldProps['uiSchema'] & {
104
+ 'ui:options'?: TUiOptions;
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Type for the Custom Field Extension with the
110
+ * name and components and validation function.
111
+ *
112
+ * @public
113
+ */
114
+ export declare type FieldExtensionOptions<TFieldReturnValue = unknown, TInputProps = unknown> = {
115
+ name: string;
116
+ component: (props: FieldExtensionComponentProps<TFieldReturnValue, TInputProps>) => JSX.Element | null;
117
+ validation?: CustomFieldValidator<TFieldReturnValue>;
118
+ };
119
+
120
+ /**
121
+ * The response shape for the `listActions` call to the `scaffolder-backend`
122
+ *
123
+ * @public
124
+ */
125
+ export declare type ListActionsResponse = Array<{
126
+ id: string;
127
+ description?: string;
128
+ schema?: {
129
+ input?: JSONSchema7;
130
+ output?: JSONSchema7;
131
+ };
132
+ }>;
133
+
134
+ /**
135
+ * The shape of a `LogEvent` message from the `scaffolder-backend`
136
+ *
137
+ * @public
138
+ */
139
+ export declare type LogEvent = {
140
+ type: 'log' | 'completion';
141
+ body: {
142
+ message: string;
143
+ stepId?: string;
144
+ status?: ScaffolderTaskStatus;
145
+ };
146
+ createdAt: string;
147
+ id: string;
148
+ taskId: string;
149
+ };
150
+
151
+ /* Excluded from this release type: NextRouterProps */
152
+
153
+ /* Excluded from this release type: NextScaffolderPage */
154
+
155
+ /**
156
+ * A field extension to show all the Entities that are owned by the current logged-in User for use in templates.
157
+ *
158
+ * @public
159
+ */
160
+ export declare const OwnedEntityPickerFieldExtension: FieldExtensionComponent<string, OwnedEntityPickerUiOptions>;
161
+
162
+ /**
163
+ * The input props that can be specified under `ui:options` for the
164
+ * `OwnedEntityPicker` field extension.
165
+ *
166
+ * @public
167
+ */
168
+ export declare interface OwnedEntityPickerUiOptions {
169
+ allowedKinds?: string[];
170
+ defaultKind?: string;
171
+ }
172
+
173
+ /**
174
+ * A field extension for picking users and groups out of the Catalog.
175
+ *
176
+ * @public
177
+ */
178
+ export declare const OwnerPickerFieldExtension: FieldExtensionComponent<string, OwnerPickerUiOptions>;
179
+
180
+ /**
181
+ * The input props that can be specified under `ui:options` for the
182
+ * `OwnerPicker` field extension.
183
+ *
184
+ * @public
185
+ */
186
+ export declare interface OwnerPickerUiOptions {
187
+ allowedKinds?: string[];
188
+ }
189
+
190
+ /**
191
+ * The validation function for the `repoUrl` that is returned from the
192
+ * field extension. Ensures that you have all the required fields filled for
193
+ * the different providers that exist.
194
+ *
195
+ * @public
196
+ */
197
+ export declare const repoPickerValidation: (value: string, validation: FieldValidation, context: {
198
+ apiHolder: ApiHolder;
199
+ }) => void;
200
+
201
+ /**
202
+ * The field extension which provides the ability to select a RepositoryUrl.
203
+ * Currently this is an encoded URL that looks something like the following `github.com?repo=myRepoName&owner=backstage`.
204
+ *
205
+ * @public
206
+ */
207
+ export declare const RepoUrlPickerFieldExtension: FieldExtensionComponent<string, RepoUrlPickerUiOptions>;
208
+
209
+ /**
210
+ * The input props that can be specified under `ui:options` for the
211
+ * `RepoUrlPicker` field extension.
212
+ *
213
+ * @public
214
+ */
215
+ export declare interface RepoUrlPickerUiOptions {
216
+ allowedHosts?: string[];
217
+ allowedOwners?: string[];
218
+ requestUserCredentials?: {
219
+ secretsKey: string;
220
+ additionalScopes?: {
221
+ github?: string[];
222
+ gitlab?: string[];
223
+ bitbucket?: string[];
224
+ azure?: string[];
225
+ };
226
+ };
227
+ }
228
+
229
+ /**
230
+ * The props for the entrypoint `ScaffolderPage` component the plugin.
231
+ * @public
232
+ */
233
+ export declare type RouterProps = {
234
+ components?: {
235
+ TemplateCardComponent?: ComponentType<{
236
+ template: TemplateEntityV1beta3;
237
+ }> | undefined;
238
+ TaskPageComponent?: ComponentType<{}>;
239
+ };
240
+ groups?: Array<{
241
+ title?: React_2.ReactNode;
242
+ filter: (entity: Entity) => boolean;
243
+ }>;
244
+ defaultPreviewTemplate?: string;
245
+ /**
246
+ * Options for the context menu on the scaffolder page.
247
+ */
248
+ contextMenu?: {
249
+ /** Whether to show a link to the template editor */
250
+ editor?: boolean;
251
+ /** Whether to show a link to the actions documentation */
252
+ actions?: boolean;
253
+ };
254
+ };
255
+
256
+ /**
257
+ * An API to interact with the scaffolder backend.
258
+ *
259
+ * @public
260
+ */
261
+ export declare interface ScaffolderApi {
262
+ getTemplateParameterSchema(templateRef: string): Promise<TemplateParameterSchema>;
263
+ /**
264
+ * Executes the scaffolding of a component, given a template and its
265
+ * parameter values.
266
+ *
267
+ * @param options - The {@link ScaffolderScaffoldOptions} the scaffolding.
268
+ */
269
+ scaffold(options: ScaffolderScaffoldOptions): Promise<ScaffolderScaffoldResponse>;
270
+ getTask(taskId: string): Promise<ScaffolderTask>;
271
+ getIntegrationsList(options: ScaffolderGetIntegrationsListOptions): Promise<ScaffolderGetIntegrationsListResponse>;
272
+ /**
273
+ * Returns a list of all installed actions.
274
+ */
275
+ listActions(): Promise<ListActionsResponse>;
276
+ streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
277
+ }
278
+
279
+ /**
280
+ * Utility API reference for the {@link ScaffolderApi}.
281
+ *
282
+ * @public
283
+ */
284
+ export declare const scaffolderApiRef: ApiRef<ScaffolderApi>;
285
+
286
+ /**
287
+ * An API to interact with the scaffolder backend.
288
+ *
289
+ * @public
290
+ */
291
+ export declare class ScaffolderClient implements ScaffolderApi {
292
+ private readonly discoveryApi;
293
+ private readonly scmIntegrationsApi;
294
+ private readonly fetchApi;
295
+ private readonly useLongPollingLogs;
296
+ constructor(options: {
297
+ discoveryApi: DiscoveryApi;
298
+ fetchApi: FetchApi;
299
+ scmIntegrationsApi: ScmIntegrationRegistry;
300
+ useLongPollingLogs?: boolean;
301
+ });
302
+ getIntegrationsList(options: ScaffolderGetIntegrationsListOptions): Promise<ScaffolderGetIntegrationsListResponse>;
303
+ getTemplateParameterSchema(templateRef: string): Promise<TemplateParameterSchema>;
304
+ /**
305
+ * Executes the scaffolding of a component, given a template and its
306
+ * parameter values.
307
+ *
308
+ * @param options - The {@link ScaffolderScaffoldOptions} the scaffolding.
309
+ */
310
+ scaffold(options: ScaffolderScaffoldOptions): Promise<ScaffolderScaffoldResponse>;
311
+ getTask(taskId: string): Promise<ScaffolderTask>;
312
+ streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
313
+ private streamLogsEventStream;
314
+ private streamLogsPolling;
315
+ listActions(): Promise<ListActionsResponse>;
316
+ }
317
+
318
+ /**
319
+ * The Wrapping component for defining fields extensions inside
320
+ *
321
+ * @public
322
+ */
323
+ export declare const ScaffolderFieldExtensions: React_2.ComponentType;
324
+
325
+ /**
326
+ * The arguments for `getIntegrationsList`.
327
+ *
328
+ * @public
329
+ */
330
+ export declare interface ScaffolderGetIntegrationsListOptions {
331
+ allowedHosts: string[];
332
+ }
333
+
334
+ /**
335
+ * The response shape for `getIntegrationsList`.
336
+ *
337
+ * @public
338
+ */
339
+ export declare interface ScaffolderGetIntegrationsListResponse {
340
+ integrations: {
341
+ type: string;
342
+ title: string;
343
+ host: string;
344
+ }[];
345
+ }
346
+
347
+ /** @public */
348
+ export declare type ScaffolderOutputLink = {
349
+ title?: string;
350
+ icon?: string;
351
+ url?: string;
352
+ entityRef?: string;
353
+ };
354
+
355
+ /**
356
+ * The Router and main entrypoint to the Scaffolder plugin.
357
+ *
358
+ * @public
359
+ */
360
+ export declare const ScaffolderPage: (props: RouterProps) => JSX.Element;
361
+
362
+ /**
363
+ * The main plugin export for the scaffolder.
364
+ * @public
365
+ */
366
+ export declare const scaffolderPlugin: BackstagePlugin< {
367
+ root: RouteRef<undefined>;
368
+ }, {
369
+ registerComponent: ExternalRouteRef<undefined, true>;
370
+ }>;
371
+
372
+ /**
373
+ * The input options to the `scaffold` method of the `ScaffolderClient`.
374
+ *
375
+ * @public
376
+ */
377
+ export declare interface ScaffolderScaffoldOptions {
378
+ templateRef: string;
379
+ values: Record<string, JsonValue>;
380
+ secrets?: Record<string, string>;
381
+ }
382
+
383
+ /**
384
+ * The response shape of the `scaffold` method of the `ScaffolderClient`.
385
+ *
386
+ * @public
387
+ */
388
+ export declare interface ScaffolderScaffoldResponse {
389
+ taskId: string;
390
+ }
391
+
392
+ /**
393
+ * The input options to the `streamLogs` method of the `ScaffolderClient`.
394
+ *
395
+ * @public
396
+ */
397
+ export declare interface ScaffolderStreamLogsOptions {
398
+ taskId: string;
399
+ after?: number;
400
+ }
401
+
402
+ /**
403
+ * The shape of each task returned from the `scaffolder-backend`
404
+ *
405
+ * @public
406
+ */
407
+ export declare type ScaffolderTask = {
408
+ id: string;
409
+ spec: TaskSpec;
410
+ status: 'failed' | 'completed' | 'processing' | 'open' | 'cancelled';
411
+ lastHeartbeatAt: string;
412
+ createdAt: string;
413
+ };
414
+
415
+ /** @public */
416
+ export declare type ScaffolderTaskOutput = {
417
+ links?: ScaffolderOutputLink[];
418
+ } & {
419
+ [key: string]: unknown;
420
+ };
421
+
422
+ /**
423
+ * The status of each task in a Scaffolder Job
424
+ *
425
+ * @public
426
+ */
427
+ export declare type ScaffolderTaskStatus = 'open' | 'processing' | 'failed' | 'completed' | 'skipped';
428
+
429
+ /**
430
+ * The return type from the useTemplateSecrets hook.
431
+ * @public
432
+ */
433
+ export declare interface ScaffolderUseTemplateSecrets {
434
+ setSecrets: (input: Record<string, string>) => void;
435
+ }
436
+
437
+ /**
438
+ * TaskPage for showing the status of the taskId provided as a param
439
+ * @param loadingText - Optional loading text shown before a task begins executing.
440
+ *
441
+ * @public
442
+ */
443
+ export declare const TaskPage: ({ loadingText }: TaskPageProps) => JSX.Element;
444
+
445
+ /**
446
+ * TaskPageProps for constructing a TaskPage
447
+ * @param loadingText - Optional loading text shown before a task begins executing.
448
+ *
449
+ * @public
450
+ */
451
+ export declare type TaskPageProps = {
452
+ loadingText?: string;
453
+ };
454
+
455
+ /* Excluded from this release type: TemplateGroupFilter */
456
+
457
+ /**
458
+ * The shape of each entry of parameters which gets rendered
459
+ * as a separate step in the wizard input
460
+ *
461
+ * @public
462
+ */
463
+ export declare type TemplateParameterSchema = {
464
+ title: string;
465
+ steps: Array<{
466
+ title: string;
467
+ schema: JsonObject;
468
+ }>;
469
+ };
470
+
471
+ /**
472
+ * The component to select the `type` of `Template` that you will see in the table.
473
+ *
474
+ * @public
475
+ */
476
+ export declare const TemplateTypePicker: () => JSX.Element | null;
477
+
478
+ /**
479
+ * Hook to access the secrets context.
480
+ * @public
481
+ */
482
+ export declare const useTemplateSecrets: () => ScaffolderUseTemplateSecrets;
483
+
484
+ export { }