@backstage/plugin-scaffolder-react 0.0.0-nightly-20230111022819

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