@backstage/plugin-scaffolder 1.0.0 → 1.0.1-next.2

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,498 @@
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
+ /**
152
+ * The Props for the Scaffolder Router
153
+ *
154
+ * @alpha
155
+ */
156
+ export declare type NextRouterProps = {
157
+ components?: {
158
+ TemplateCardComponent?: React_2.ComponentType<{
159
+ template: TemplateEntityV1beta3;
160
+ }>;
161
+ TaskPageComponent?: React_2.ComponentType<{}>;
162
+ };
163
+ groups?: TemplateGroupFilter[];
164
+ };
165
+
166
+ /**
167
+ * @alpha
168
+ * The Router and main entrypoint to the Alpha Scaffolder plugin.
169
+ */
170
+ export declare const NextScaffolderPage: (props: PropsWithChildren<NextRouterProps>) => JSX.Element;
171
+
172
+ /**
173
+ * A field extension to show all the Entities that are owned by the current logged-in User for use in templates.
174
+ *
175
+ * @public
176
+ */
177
+ export declare const OwnedEntityPickerFieldExtension: FieldExtensionComponent<string, OwnedEntityPickerUiOptions>;
178
+
179
+ /**
180
+ * The input props that can be specified under `ui:options` for the
181
+ * `OwnedEntityPicker` field extension.
182
+ *
183
+ * @public
184
+ */
185
+ export declare interface OwnedEntityPickerUiOptions {
186
+ allowedKinds?: string[];
187
+ defaultKind?: string;
188
+ }
189
+
190
+ /**
191
+ * A field extension for picking users and groups out of the Catalog.
192
+ *
193
+ * @public
194
+ */
195
+ export declare const OwnerPickerFieldExtension: FieldExtensionComponent<string, OwnerPickerUiOptions>;
196
+
197
+ /**
198
+ * The input props that can be specified under `ui:options` for the
199
+ * `OwnerPicker` field extension.
200
+ *
201
+ * @public
202
+ */
203
+ export declare interface OwnerPickerUiOptions {
204
+ allowedKinds?: string[];
205
+ }
206
+
207
+ /**
208
+ * The validation function for the `repoUrl` that is returned from the
209
+ * field extension. Ensures that you have all the required fields filled for
210
+ * the different providers that exist.
211
+ *
212
+ * @public
213
+ */
214
+ export declare const repoPickerValidation: (value: string, validation: FieldValidation, context: {
215
+ apiHolder: ApiHolder;
216
+ }) => void;
217
+
218
+ /**
219
+ * The field extension which provides the ability to select a RepositoryUrl.
220
+ * Currently this is an encoded URL that looks something like the following `github.com?repo=myRepoName&owner=backstage`.
221
+ *
222
+ * @public
223
+ */
224
+ export declare const RepoUrlPickerFieldExtension: FieldExtensionComponent<string, RepoUrlPickerUiOptions>;
225
+
226
+ /**
227
+ * The input props that can be specified under `ui:options` for the
228
+ * `RepoUrlPicker` field extension.
229
+ *
230
+ * @public
231
+ */
232
+ export declare interface RepoUrlPickerUiOptions {
233
+ allowedHosts?: string[];
234
+ allowedOwners?: string[];
235
+ requestUserCredentials?: {
236
+ secretsKey: string;
237
+ additionalScopes?: {
238
+ github?: string[];
239
+ gitlab?: string[];
240
+ bitbucket?: string[];
241
+ azure?: string[];
242
+ };
243
+ };
244
+ }
245
+
246
+ /**
247
+ * The props for the entrypoint `ScaffolderPage` component the plugin.
248
+ * @public
249
+ */
250
+ export declare type RouterProps = {
251
+ components?: {
252
+ TemplateCardComponent?: ComponentType<{
253
+ template: TemplateEntityV1beta3;
254
+ }> | undefined;
255
+ TaskPageComponent?: ComponentType<{}>;
256
+ };
257
+ groups?: Array<{
258
+ title?: React_2.ReactNode;
259
+ filter: (entity: Entity) => boolean;
260
+ }>;
261
+ defaultPreviewTemplate?: string;
262
+ };
263
+
264
+ /**
265
+ * An API to interact with the scaffolder backend.
266
+ *
267
+ * @public
268
+ */
269
+ export declare interface ScaffolderApi {
270
+ getTemplateParameterSchema(templateRef: string): Promise<TemplateParameterSchema>;
271
+ /**
272
+ * Executes the scaffolding of a component, given a template and its
273
+ * parameter values.
274
+ *
275
+ * @param options - The {@link ScaffolderScaffoldOptions} the scaffolding.
276
+ */
277
+ scaffold(options: ScaffolderScaffoldOptions): Promise<ScaffolderScaffoldResponse>;
278
+ getTask(taskId: string): Promise<ScaffolderTask>;
279
+ getIntegrationsList(options: ScaffolderGetIntegrationsListOptions): Promise<ScaffolderGetIntegrationsListResponse>;
280
+ /**
281
+ * Returns a list of all installed actions.
282
+ */
283
+ listActions(): Promise<ListActionsResponse>;
284
+ streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
285
+ }
286
+
287
+ /**
288
+ * Utility API reference for the {@link ScaffolderApi}.
289
+ *
290
+ * @public
291
+ */
292
+ export declare const scaffolderApiRef: ApiRef<ScaffolderApi>;
293
+
294
+ /**
295
+ * An API to interact with the scaffolder backend.
296
+ *
297
+ * @public
298
+ */
299
+ export declare class ScaffolderClient implements ScaffolderApi {
300
+ private readonly discoveryApi;
301
+ private readonly scmIntegrationsApi;
302
+ private readonly fetchApi;
303
+ private readonly useLongPollingLogs;
304
+ constructor(options: {
305
+ discoveryApi: DiscoveryApi;
306
+ fetchApi: FetchApi;
307
+ scmIntegrationsApi: ScmIntegrationRegistry;
308
+ useLongPollingLogs?: boolean;
309
+ });
310
+ getIntegrationsList(options: ScaffolderGetIntegrationsListOptions): Promise<ScaffolderGetIntegrationsListResponse>;
311
+ getTemplateParameterSchema(templateRef: string): Promise<TemplateParameterSchema>;
312
+ /**
313
+ * Executes the scaffolding of a component, given a template and its
314
+ * parameter values.
315
+ *
316
+ * @param options - The {@link ScaffolderScaffoldOptions} the scaffolding.
317
+ */
318
+ scaffold(options: ScaffolderScaffoldOptions): Promise<ScaffolderScaffoldResponse>;
319
+ getTask(taskId: string): Promise<ScaffolderTask>;
320
+ streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
321
+ private streamLogsEventStream;
322
+ private streamLogsPolling;
323
+ listActions(): Promise<ListActionsResponse>;
324
+ }
325
+
326
+ /**
327
+ * The Wrapping component for defining fields extensions inside
328
+ *
329
+ * @public
330
+ */
331
+ export declare const ScaffolderFieldExtensions: React_2.ComponentType;
332
+
333
+ /**
334
+ * The arguments for `getIntegrationsList`.
335
+ *
336
+ * @public
337
+ */
338
+ export declare interface ScaffolderGetIntegrationsListOptions {
339
+ allowedHosts: string[];
340
+ }
341
+
342
+ /**
343
+ * The response shape for `getIntegrationsList`.
344
+ *
345
+ * @public
346
+ */
347
+ export declare interface ScaffolderGetIntegrationsListResponse {
348
+ integrations: {
349
+ type: string;
350
+ title: string;
351
+ host: string;
352
+ }[];
353
+ }
354
+
355
+ /** @public */
356
+ export declare type ScaffolderOutputLink = {
357
+ title?: string;
358
+ icon?: string;
359
+ url?: string;
360
+ entityRef?: string;
361
+ };
362
+
363
+ /**
364
+ * The Router and main entrypoint to the Scaffolder plugin.
365
+ *
366
+ * @public
367
+ */
368
+ export declare const ScaffolderPage: (props: RouterProps) => JSX.Element;
369
+
370
+ /**
371
+ * The main plugin export for the scaffolder.
372
+ * @public
373
+ */
374
+ export declare const scaffolderPlugin: BackstagePlugin< {
375
+ root: RouteRef<undefined>;
376
+ }, {
377
+ registerComponent: ExternalRouteRef<undefined, true>;
378
+ }>;
379
+
380
+ /**
381
+ * The input options to the `scaffold` method of the `ScaffolderClient`.
382
+ *
383
+ * @public
384
+ */
385
+ export declare interface ScaffolderScaffoldOptions {
386
+ templateRef: string;
387
+ values: Record<string, JsonValue>;
388
+ secrets?: Record<string, string>;
389
+ }
390
+
391
+ /**
392
+ * The response shape of the `scaffold` method of the `ScaffolderClient`.
393
+ *
394
+ * @public
395
+ */
396
+ export declare interface ScaffolderScaffoldResponse {
397
+ taskId: string;
398
+ }
399
+
400
+ /**
401
+ * The input options to the `streamLogs` method of the `ScaffolderClient`.
402
+ *
403
+ * @public
404
+ */
405
+ export declare interface ScaffolderStreamLogsOptions {
406
+ taskId: string;
407
+ after?: number;
408
+ }
409
+
410
+ /**
411
+ * The shape of each task returned from the `scaffolder-backend`
412
+ *
413
+ * @public
414
+ */
415
+ export declare type ScaffolderTask = {
416
+ id: string;
417
+ spec: TaskSpec;
418
+ status: 'failed' | 'completed' | 'processing' | 'open' | 'cancelled';
419
+ lastHeartbeatAt: string;
420
+ createdAt: string;
421
+ };
422
+
423
+ /** @public */
424
+ export declare type ScaffolderTaskOutput = {
425
+ links?: ScaffolderOutputLink[];
426
+ } & {
427
+ [key: string]: unknown;
428
+ };
429
+
430
+ /**
431
+ * The status of each task in a Scaffolder Job
432
+ *
433
+ * @public
434
+ */
435
+ export declare type ScaffolderTaskStatus = 'open' | 'processing' | 'failed' | 'completed' | 'skipped';
436
+
437
+ /**
438
+ * The return type from the useTemplateSecrets hook.
439
+ * @public
440
+ */
441
+ export declare interface ScaffolderUseTemplateSecrets {
442
+ setSecrets: (input: Record<string, string>) => void;
443
+ }
444
+
445
+ /**
446
+ * TaskPage for showing the status of the taskId provided as a param
447
+ * @param loadingText - Optional loading text shown before a task begins executing.
448
+ *
449
+ * @public
450
+ */
451
+ export declare const TaskPage: ({ loadingText }: TaskPageProps) => JSX.Element;
452
+
453
+ /**
454
+ * TaskPageProps for constructing a TaskPage
455
+ * @param loadingText - Optional loading text shown before a task begins executing.
456
+ *
457
+ * @public
458
+ */
459
+ export declare type TaskPageProps = {
460
+ loadingText?: string;
461
+ };
462
+
463
+ /**
464
+ * @alpha
465
+ */
466
+ export declare type TemplateGroupFilter = {
467
+ title?: React_2.ReactNode;
468
+ filter: (entity: Entity) => boolean;
469
+ };
470
+
471
+ /**
472
+ * The shape of each entry of parameters which gets rendered
473
+ * as a separate step in the wizard input
474
+ *
475
+ * @public
476
+ */
477
+ export declare type TemplateParameterSchema = {
478
+ title: string;
479
+ steps: Array<{
480
+ title: string;
481
+ schema: JsonObject;
482
+ }>;
483
+ };
484
+
485
+ /**
486
+ * The component to select the `type` of `Template` that you will see in the table.
487
+ *
488
+ * @public
489
+ */
490
+ export declare const TemplateTypePicker: () => JSX.Element | null;
491
+
492
+ /**
493
+ * Hook to access the secrets context.
494
+ * @public
495
+ */
496
+ export declare const useTemplateSecrets: () => ScaffolderUseTemplateSecrets;
497
+
498
+ export { }