@backstage/plugin-scaffolder-react 1.1.0 → 1.2.0-next.1

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.
@@ -1,591 +0,0 @@
1
- /// <reference types="react" />
2
-
3
- import { ApiHolder } from '@backstage/core-plugin-api';
4
- import { ApiRef } from '@backstage/core-plugin-api';
5
- import { ComponentType } from 'react';
6
- import { Dispatch } from 'react';
7
- import { Extension } from '@backstage/core-plugin-api';
8
- import { FieldProps } from '@rjsf/core';
9
- import { FieldProps as FieldProps_2 } from '@rjsf/utils';
10
- import { FieldValidation } from '@rjsf/core';
11
- import { FieldValidation as FieldValidation_2 } from '@rjsf/utils';
12
- import { FormProps as FormProps_2 } from '@rjsf/core-v5';
13
- import { IconComponent } from '@backstage/core-plugin-api';
14
- import { JsonObject } from '@backstage/types';
15
- import { JSONSchema7 } from 'json-schema';
16
- import { JsonValue } from '@backstage/types';
17
- import { Observable } from '@backstage/types';
18
- import { PropsWithChildren } from 'react';
19
- import { default as React_2 } from 'react';
20
- import { ReactNode } from 'react';
21
- import { RJSFSchema } from '@rjsf/utils';
22
- import { SetStateAction } from 'react';
23
- import { TaskSpec } from '@backstage/plugin-scaffolder-common';
24
- import { TaskStep } from '@backstage/plugin-scaffolder-common';
25
- import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
26
- import { UIOptionsType } from '@rjsf/utils';
27
- import { UiSchema } from '@rjsf/utils';
28
-
29
- /**
30
- * The response shape for a single action in the `listActions` call to the `scaffolder-backend`
31
- *
32
- * @public
33
- */
34
- export declare type Action = {
35
- id: string;
36
- description?: string;
37
- schema?: {
38
- input?: JSONSchema7;
39
- output?: JSONSchema7;
40
- };
41
- examples?: ActionExample[];
42
- };
43
-
44
- /**
45
- * A single action example
46
- *
47
- * @public
48
- */
49
- export declare type ActionExample = {
50
- description: string;
51
- example: string;
52
- };
53
-
54
- /**
55
- * Creates a field validation object for use in react jsonschema form
56
- * @alpha
57
- */
58
- export declare const createFieldValidation: () => FieldValidation_2;
59
-
60
- /**
61
- * Method for creating field extensions that can be used in the scaffolder
62
- * frontend form.
63
- * @alpha
64
- */
65
- export declare function createNextScaffolderFieldExtension<TReturnValue = unknown, TInputProps extends UIOptionsType = {}>(options: NextFieldExtensionOptions<TReturnValue, TInputProps>): Extension<FieldExtensionComponent<TReturnValue, TInputProps>>;
66
-
67
- /**
68
- * Method for creating field extensions that can be used in the scaffolder
69
- * frontend form.
70
- * @public
71
- */
72
- export declare function createScaffolderFieldExtension<TReturnValue = unknown, TInputProps = unknown>(options: FieldExtensionOptions<TReturnValue, TInputProps>): Extension<FieldExtensionComponent<TReturnValue, TInputProps>>;
73
-
74
- /**
75
- * Method for creating custom Layouts that can be used in the scaffolder frontend form
76
- *
77
- * @public
78
- */
79
- export declare function createScaffolderLayout<TInputProps = unknown>(options: LayoutOptions): Extension<LayoutComponent<TInputProps>>;
80
-
81
- /**
82
- * Type for the Custom Field Extension schema.
83
- *
84
- * @public
85
- */
86
- export declare type CustomFieldExtensionSchema = {
87
- returnValue: JSONSchema7;
88
- uiOptions?: JSONSchema7;
89
- };
90
-
91
- /**
92
- * Field validation type for Custom Field Extensions.
93
- *
94
- * @public
95
- */
96
- export declare type CustomFieldValidator<TFieldReturnValue> = (data: TFieldReturnValue, field: FieldValidation, context: {
97
- apiHolder: ApiHolder;
98
- }) => void | Promise<void>;
99
-
100
- /**
101
- * The DefaultOutputs renderer for the scaffolder task output
102
- *
103
- * @alpha
104
- */
105
- export declare const DefaultTemplateOutputs: (props: {
106
- output?: ScaffolderTaskOutput;
107
- }) => JSX.Element | null;
108
-
109
- /**
110
- * @alpha
111
- */
112
- export declare const EmbeddableWorkflow: (props: WorkflowProps) => JSX.Element;
113
-
114
- /**
115
- * Takes a step from a Backstage Template Manifest and converts it to a JSON Schema and UI Schema for rjsf
116
- * @alpha
117
- */
118
- export declare const extractSchemaFromStep: (inputStep: JsonObject) => {
119
- uiSchema: UiSchema;
120
- schema: JsonObject;
121
- };
122
-
123
- /**
124
- * The type used to wrap up the Layout and embed the input props
125
- *
126
- * @public
127
- */
128
- export declare type FieldExtensionComponent<_TReturnValue, _TInputProps> = () => null;
129
-
130
- /**
131
- * Type for field extensions and being able to type
132
- * incoming props easier.
133
- *
134
- * @public
135
- */
136
- export declare interface FieldExtensionComponentProps<TFieldReturnValue, TUiOptions extends {} = {}> extends FieldProps<TFieldReturnValue> {
137
- uiSchema: FieldProps['uiSchema'] & {
138
- 'ui:options'?: TUiOptions;
139
- };
140
- }
141
-
142
- /**
143
- * Type for the Custom Field Extension with the
144
- * name and components and validation function.
145
- *
146
- * @public
147
- */
148
- export declare type FieldExtensionOptions<TFieldReturnValue = unknown, TInputProps = unknown> = {
149
- name: string;
150
- component: (props: FieldExtensionComponentProps<TFieldReturnValue, TInputProps>) => JSX.Element | null;
151
- validation?: CustomFieldValidator<TFieldReturnValue>;
152
- schema?: CustomFieldExtensionSchema;
153
- };
154
-
155
- /** @alpha */
156
- export declare const Form: ComponentType<FormProps_2<any, RJSFSchema, any>>;
157
-
158
- /**
159
- * Any `@rjsf/core` form properties that are publicly exposed to the `NextScaffolderpage`
160
- *
161
- * @public
162
- */
163
- export declare type FormProps = Pick<FormProps_2, 'transformErrors' | 'noHtml5Validate'>;
164
-
165
- /**
166
- * A type used to wrap up the FieldExtension to embed the ReturnValue and the InputProps
167
- * @public
168
- */
169
- export declare type LayoutComponent<_TInputProps> = () => null;
170
-
171
- /**
172
- * The type of layouts that is passed to the TemplateForms
173
- *
174
- * @public
175
- */
176
- export declare interface LayoutOptions<P = any> {
177
- name: string;
178
- component: LayoutTemplate<P>;
179
- }
180
-
181
- /**
182
- * The field template from `@rjsf/core` which is a react component that gets passed `@rjsf/core` field related props.
183
- *
184
- * @public
185
- */
186
- export declare type LayoutTemplate<T = any> = NonNullable<FormProps_2<T>['uiSchema']>['ui:ObjectFieldTemplate'];
187
-
188
- /**
189
- * The response shape for the `listActions` call to the `scaffolder-backend`
190
- *
191
- * @public
192
- */
193
- export declare type ListActionsResponse = Array<Action>;
194
-
195
- /**
196
- * The shape of a `LogEvent` message from the `scaffolder-backend`
197
- *
198
- * @public
199
- */
200
- export declare type LogEvent = {
201
- type: 'log' | 'completion';
202
- body: {
203
- message: string;
204
- stepId?: string;
205
- status?: ScaffolderTaskStatus;
206
- };
207
- createdAt: string;
208
- id: string;
209
- taskId: string;
210
- };
211
-
212
- /**
213
- * Field validation type for Custom Field Extensions.
214
- *
215
- * @alpha
216
- */
217
- export declare type NextCustomFieldValidator<TFieldReturnValue> = (data: TFieldReturnValue, field: FieldValidation_2, context: {
218
- apiHolder: ApiHolder;
219
- formData: JsonObject;
220
- }) => void | Promise<void>;
221
-
222
- /**
223
- * Type for Field Extension Props for RJSF v5
224
- *
225
- * @alpha
226
- */
227
- export declare interface NextFieldExtensionComponentProps<TFieldReturnValue, TUiOptions = {}> extends PropsWithChildren<FieldProps_2<TFieldReturnValue>> {
228
- uiSchema?: UiSchema<TFieldReturnValue> & {
229
- 'ui:options'?: TUiOptions & UIOptionsType;
230
- };
231
- }
232
-
233
- /**
234
- * Type for the Custom Field Extension with the
235
- * name and components and validation function.
236
- *
237
- * @alpha
238
- */
239
- export declare type NextFieldExtensionOptions<TFieldReturnValue = unknown, TInputProps = unknown> = {
240
- name: string;
241
- component: (props: NextFieldExtensionComponentProps<TFieldReturnValue, TInputProps>) => JSX.Element | null;
242
- validation?: NextCustomFieldValidator<TFieldReturnValue>;
243
- schema?: CustomFieldExtensionSchema;
244
- };
245
-
246
- /**
247
- * This is the parsed template schema that is returned from the {@link useTemplateSchema} hook.
248
- * @alpha
249
- */
250
- export declare interface ParsedTemplateSchema {
251
- uiSchema: UiSchema;
252
- mergedSchema: JsonObject;
253
- schema: JsonObject;
254
- title: string;
255
- description?: string;
256
- }
257
-
258
- /**
259
- * The component used by the {@link Stepper} to render the review step.
260
- * @alpha
261
- */
262
- export declare const ReviewState: (props: ReviewStateProps) => JSX.Element;
263
-
264
- /**
265
- * The props for the {@link ReviewState} component.
266
- * @alpha
267
- */
268
- export declare type ReviewStateProps = {
269
- schemas: ParsedTemplateSchema[];
270
- formState: JsonObject;
271
- };
272
-
273
- /**
274
- * An API to interact with the scaffolder backend.
275
- *
276
- * @public
277
- */
278
- export declare interface ScaffolderApi {
279
- getTemplateParameterSchema(templateRef: string): Promise<TemplateParameterSchema>;
280
- /**
281
- * Executes the scaffolding of a component, given a template and its
282
- * parameter values.
283
- *
284
- * @param options - The {@link ScaffolderScaffoldOptions} the scaffolding.
285
- */
286
- scaffold(options: ScaffolderScaffoldOptions): Promise<ScaffolderScaffoldResponse>;
287
- getTask(taskId: string): Promise<ScaffolderTask>;
288
- listTasks?(options: {
289
- filterByOwnership: 'owned' | 'all';
290
- }): Promise<{
291
- tasks: ScaffolderTask[];
292
- }>;
293
- getIntegrationsList(options: ScaffolderGetIntegrationsListOptions): Promise<ScaffolderGetIntegrationsListResponse>;
294
- /**
295
- * Returns a list of all installed actions.
296
- */
297
- listActions(): Promise<ListActionsResponse>;
298
- streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent>;
299
- dryRun?(options: ScaffolderDryRunOptions): Promise<ScaffolderDryRunResponse>;
300
- }
301
-
302
- /** @public */
303
- export declare const scaffolderApiRef: ApiRef<ScaffolderApi>;
304
-
305
- /** @public */
306
- export declare interface ScaffolderDryRunOptions {
307
- template: JsonValue;
308
- values: JsonObject;
309
- secrets?: Record<string, string>;
310
- directoryContents: {
311
- path: string;
312
- base64Content: string;
313
- }[];
314
- }
315
-
316
- /** @public */
317
- export declare interface ScaffolderDryRunResponse {
318
- directoryContents: Array<{
319
- path: string;
320
- base64Content: string;
321
- executable: boolean;
322
- }>;
323
- log: Array<Pick<LogEvent, 'body'>>;
324
- steps: TaskStep[];
325
- output: ScaffolderTaskOutput;
326
- }
327
-
328
- /**
329
- * The Wrapping component for defining fields extensions inside
330
- *
331
- * @public
332
- */
333
- export declare const ScaffolderFieldExtensions: React_2.ComponentType<React_2.PropsWithChildren<{}>>;
334
-
335
- /**
336
- * The arguments for `getIntegrationsList`.
337
- *
338
- * @public
339
- */
340
- export declare interface ScaffolderGetIntegrationsListOptions {
341
- allowedHosts: string[];
342
- }
343
-
344
- /**
345
- * The response shape for `getIntegrationsList`.
346
- *
347
- * @public
348
- */
349
- export declare interface ScaffolderGetIntegrationsListResponse {
350
- integrations: {
351
- type: string;
352
- title: string;
353
- host: string;
354
- }[];
355
- }
356
-
357
- /**
358
- * The wrapping component for defining scaffolder layouts as children
359
- *
360
- * @public
361
- */
362
- export declare const ScaffolderLayouts: React.ComponentType;
363
-
364
- /** @public */
365
- export declare type ScaffolderOutputLink = {
366
- title?: string;
367
- icon?: string;
368
- url?: string;
369
- entityRef?: string;
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
- secrets: Record<string, string>;
436
- }
437
-
438
- /**
439
- * The Context Provider that holds the state for the secrets.
440
- * @public
441
- */
442
- export declare const SecretsContextProvider: ({ children }: PropsWithChildren<{}>) => JSX.Element;
443
-
444
- /**
445
- * The `Stepper` component is the Wizard that is rendered when a user selects a template
446
- * @alpha
447
- */
448
- export declare const Stepper: (stepperProps: StepperProps) => JSX.Element;
449
-
450
- /**
451
- * The Props for {@link Stepper} component
452
- * @alpha
453
- */
454
- export declare type StepperProps = {
455
- manifest: TemplateParameterSchema;
456
- extensions: NextFieldExtensionOptions<any, any>[];
457
- templateName?: string;
458
- FormProps?: FormProps;
459
- initialState?: Record<string, JsonValue>;
460
- onCreate: (values: Record<string, JsonValue>) => Promise<void>;
461
- components?: {
462
- ReviewStateComponent?: (props: ReviewStateProps) => JSX.Element;
463
- createButtonText?: ReactNode;
464
- reviewButtonText?: ReactNode;
465
- };
466
- layouts?: LayoutOptions[];
467
- };
468
-
469
- /**
470
- * The `TemplateCard` component that is rendered in a list for each template
471
- * @alpha
472
- */
473
- export declare const TemplateCard: (props: TemplateCardProps) => JSX.Element;
474
-
475
- /**
476
- * The Props for the {@link TemplateCard} component
477
- * @alpha
478
- */
479
- export declare interface TemplateCardProps {
480
- template: TemplateEntityV1beta3;
481
- additionalLinks?: {
482
- icon: IconComponent;
483
- text: string;
484
- url: string;
485
- }[];
486
- onSelected?: (template: TemplateEntityV1beta3) => void;
487
- }
488
-
489
- /**
490
- * The `TemplateGroup` component is used to display a group of templates with a title.
491
- * @alpha
492
- */
493
- export declare const TemplateGroup: (props: TemplateGroupProps) => JSX.Element;
494
-
495
- /**
496
- * The props for the {@link TemplateGroup} component.
497
- * @alpha
498
- */
499
- export declare interface TemplateGroupProps {
500
- templates: {
501
- template: TemplateEntityV1beta3;
502
- additionalLinks?: {
503
- icon: IconComponent;
504
- text: string;
505
- url: string;
506
- }[];
507
- }[];
508
- onSelected: (template: TemplateEntityV1beta3) => void;
509
- title: React_2.ReactNode;
510
- components?: {
511
- CardComponent?: React_2.ComponentType<TemplateCardProps>;
512
- };
513
- }
514
-
515
- /**
516
- * The shape of each entry of parameters which gets rendered
517
- * as a separate step in the wizard input
518
- *
519
- * @public
520
- */
521
- export declare type TemplateParameterSchema = {
522
- title: string;
523
- description?: string;
524
- steps: Array<{
525
- title: string;
526
- description?: string;
527
- schema: JsonObject;
528
- }>;
529
- };
530
-
531
- /**
532
- * Hook that returns all custom field extensions from the current outlet.
533
- * @public
534
- */
535
- export declare const useCustomFieldExtensions: <TComponentDataType = FieldExtensionOptions<unknown, unknown>>(outlet: React.ReactNode) => TComponentDataType[];
536
-
537
- /**
538
- * Hook that returns all custom field extensions from the current outlet.
539
- * @public
540
- */
541
- export declare const useCustomLayouts: <TComponentDataType = LayoutOptions<any>>(outlet: React.ReactNode) => TComponentDataType[];
542
-
543
- /**
544
- * This hook is used to get the formData from the query string.
545
- * @alpha
546
- */
547
- export declare const useFormDataFromQuery: (initialState?: Record<string, JsonValue>) => [Record<string, any>, Dispatch<SetStateAction<Record<string, any>>>];
548
-
549
- /**
550
- * @alpha
551
- */
552
- export declare const useTemplateParameterSchema: (templateRef: string) => {
553
- manifest: TemplateParameterSchema | undefined;
554
- loading: boolean;
555
- error: Error | undefined;
556
- };
557
-
558
- /**
559
- * This hook will parse the template schema and return the steps with the
560
- * parsed schema and uiSchema. Filtering out any steps or properties that
561
- * are not enabled with feature flags.
562
- * @alpha
563
- */
564
- export declare const useTemplateSchema: (manifest: TemplateParameterSchema) => {
565
- steps: ParsedTemplateSchema[];
566
- };
567
-
568
- /**
569
- * Hook to access the secrets context to be able to set secrets that are
570
- * passed to the Scaffolder backend.
571
- * @public
572
- */
573
- export declare const useTemplateSecrets: () => ScaffolderUseTemplateSecrets;
574
-
575
- /**
576
- * @alpha
577
- */
578
- export declare const Workflow: (workflowProps: WorkflowProps) => JSX.Element | null;
579
-
580
- /**
581
- * @alpha
582
- */
583
- export declare type WorkflowProps = {
584
- title?: string;
585
- description?: string;
586
- namespace: string;
587
- templateName: string;
588
- onError(error: Error | undefined): JSX.Element | null;
589
- } & Pick<StepperProps, 'extensions' | 'FormProps' | 'components' | 'onCreate' | 'initialState' | 'layouts'>;
590
-
591
- export { }