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