@backstage/plugin-scaffolder-react 1.19.5 → 1.19.6-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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @backstage/plugin-scaffolder-react
2
2
 
3
+ ## 1.19.6-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 2eeca03: Scaffolder form fields in the new frontend system now use a Utility API pattern instead of multiple attachment points. The `FormFieldBlueprint` now uses this new approach, and while form fields created with older versions still work, they will produce a deprecation warning and will stop working in a future release.
8
+
9
+ As part of this change, the following alpha exports were removed:
10
+
11
+ - `formFieldsApi`
12
+ - `formFieldsApiRef`
13
+ - `ScaffolderFormFieldsApi`
14
+
15
+ - 69d880e: Bump to latest zod to ensure it has the latest features
16
+ - Updated dependencies
17
+ - @backstage/plugin-catalog-react@1.21.6-next.0
18
+ - @backstage/core-components@0.18.6-next.0
19
+ - @backstage/frontend-plugin-api@0.14.0-next.0
20
+ - @backstage/core-plugin-api@1.12.2-next.0
21
+ - @backstage/catalog-client@1.12.1
22
+ - @backstage/catalog-model@1.7.6
23
+ - @backstage/theme@0.7.1
24
+ - @backstage/types@1.2.2
25
+ - @backstage/version-bridge@1.0.11
26
+ - @backstage/plugin-permission-react@0.4.40-next.0
27
+ - @backstage/plugin-scaffolder-common@1.7.6-next.0
28
+
3
29
  ## 1.19.5
4
30
 
5
31
  ### Patch Changes
package/dist/alpha.d.ts CHANGED
@@ -1,140 +1,21 @@
1
- import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
2
- import { z } from 'zod';
3
- import { FieldExtensionComponentProps, CustomFieldValidator, FieldSchema, TemplateParameterSchema, FieldExtensionOptions, FormProps, ReviewStepProps, LayoutOptions, TemplateGroupFilter, ScaffolderTaskOutput, ScaffolderRJSFFormProps, ScaffolderStep } from '@backstage/plugin-scaffolder-react';
4
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TemplateParameterSchema, FieldExtensionOptions, FormProps, ReviewStepProps, LayoutOptions, CustomFieldValidator, TemplateGroupFilter, ScaffolderTaskOutput, ScaffolderRJSFFormProps, ScaffolderStep, FieldExtensionComponentProps, FieldSchema } from '@backstage/plugin-scaffolder-react';
5
3
  import { JsonObject, JsonValue } from '@backstage/types';
6
4
  import * as react from 'react';
7
5
  import { ComponentType, ReactNode, PropsWithChildren, ReactElement } from 'react';
8
6
  import { TemplatePresentationV1beta3, TemplateEntityV1beta3, TaskStep } from '@backstage/plugin-scaffolder-common';
9
7
  import { UiSchema, FieldValidation, WidgetProps } from '@rjsf/utils';
10
- import { AnyApiRef, ApiHolder, IconComponent } from '@backstage/core-plugin-api';
8
+ import { ApiHolder, IconComponent, AnyApiRef } from '@backstage/core-plugin-api';
11
9
  import { Overrides } from '@material-ui/core/styles/overrides';
12
10
  import { StyleRules } from '@material-ui/core/styles/withStyles';
11
+ import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
12
+ import { z } from 'zod';
13
13
 
14
- /** @alpha */
15
- type ScaffolderFormDecoratorContext<TInput extends JsonObject = JsonObject> = {
16
- input: TInput;
17
- formState: Record<string, JsonValue>;
18
- setFormState: (fn: (currentState: Record<string, JsonValue>) => Record<string, JsonValue>) => void;
19
- setSecrets: (fn: (currentState: Record<string, string>) => Record<string, string>) => void;
20
- };
21
- /** @alpha */
22
- type ScaffolderFormDecorator<TInput extends JsonObject = JsonObject> = {
23
- readonly $$type: '@backstage/scaffolder/FormDecorator';
24
- readonly id: string;
25
- readonly TInput: TInput;
26
- };
27
- /**
28
- * Method for creating decorators which can be used to collect
29
- * secrets from the user before submitting to the backend.
30
- * @alpha
31
- */
32
- declare function createScaffolderFormDecorator<TInputSchema extends {
33
- [key in string]: (zImpl: typeof z) => z.ZodType;
34
- } = {
35
- [key in string]: (zImpl: typeof z) => z.ZodType;
36
- }, TDeps extends {
37
- [key in string]: AnyApiRef;
38
- } = {
39
- [key in string]: AnyApiRef;
40
- }, TInput extends JsonObject = {
41
- [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
42
- }>(options: {
43
- id: string;
44
- schema?: {
45
- input?: TInputSchema;
46
- };
47
- deps?: TDeps;
48
- decorator: (ctx: ScaffolderFormDecoratorContext<TInput>, deps: TDeps extends {
49
- [key in string]: AnyApiRef;
50
- } ? {
51
- [key in keyof TDeps]: TDeps[key]['T'];
52
- } : never) => Promise<void>;
53
- }): ScaffolderFormDecorator<TInput>;
54
-
55
- /**
56
- * @alpha
57
- * Creates extensions that are Field Extensions for the Scaffolder
58
- * */
59
- declare const FormDecoratorBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
60
- kind: "scaffolder-form-decorator";
61
- params: {
62
- decorator: ScaffolderFormDecorator;
63
- };
64
- output: _backstage_frontend_plugin_api.ExtensionDataRef<ScaffolderFormDecorator, "scaffolder.form-decorator-loader", {}>;
65
- inputs: {};
66
- config: {};
67
- configInput: {};
68
- dataRefs: {
69
- formDecoratorLoader: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<ScaffolderFormDecorator, "scaffolder.form-decorator-loader", {}>;
70
- };
71
- }>;
72
-
73
- /** @alpha */
74
- type FormFieldExtensionData<TReturnValue extends z.ZodType = z.ZodType, TUiOptions extends z.ZodType = z.ZodType> = {
75
- name: string;
76
- component: (props: FieldExtensionComponentProps<z.output<TReturnValue>, z.output<TUiOptions>>) => JSX.Element | null;
77
- validation?: CustomFieldValidator<z.output<TReturnValue>, z.output<TUiOptions>>;
78
- schema?: FieldSchema<z.output<TReturnValue>, z.output<TUiOptions>>;
79
- };
80
-
81
- /**
82
- * @alpha
83
- * Creates extensions that are Field Extensions for the Scaffolder
84
- * */
85
- declare const FormFieldBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
86
- kind: "scaffolder-form-field";
87
- params: {
88
- field: () => Promise<FormField>;
89
- };
90
- output: _backstage_frontend_plugin_api.ExtensionDataRef<() => Promise<FormField>, "scaffolder.form-field-loader", {}>;
91
- inputs: {};
92
- config: {};
93
- configInput: {};
94
- dataRefs: {
95
- formFieldLoader: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<() => Promise<FormField>, "scaffolder.form-field-loader", {}>;
96
- };
97
- }>;
98
- /**
99
- * @alpha
100
- * Used to create a form field binding with typechecking for compliance
101
- */
102
- declare function createFormField<TReturnValue extends z.ZodType, TUiOptions extends z.ZodType>(opts: FormFieldExtensionData<TReturnValue, TUiOptions>): FormField;
103
-
104
- /**
105
- * @alpha
106
- * @deprecated This API is no longer necessary and will be removed
107
- */
108
- interface ScaffolderFormFieldsApi {
109
- getFormFields(): Promise<FormFieldExtensionData[]>;
110
- }
111
14
  /** @alpha */
112
15
  interface FormField {
113
16
  readonly $$type: '@backstage/scaffolder/FormField';
114
17
  }
115
18
 
116
- /** @alpha */
117
- declare const formFieldsApi: _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
118
- config: {};
119
- configInput: {};
120
- output: _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.AnyApiFactory, "core.api.factory", {}>;
121
- inputs: {
122
- formFields: _backstage_frontend_plugin_api.ExtensionInput<_backstage_frontend_plugin_api.ConfigurableExtensionDataRef<() => Promise<FormField>, "scaffolder.form-field-loader", {}>, {
123
- singleton: false;
124
- optional: false;
125
- }>;
126
- };
127
- kind: "api";
128
- name: "form-fields";
129
- params: <TApi, TImpl extends TApi, TDeps extends { [name in string]: unknown; }>(params: _backstage_frontend_plugin_api.ApiFactory<TApi, TImpl, TDeps>) => _backstage_frontend_plugin_api.ExtensionBlueprintParams<_backstage_frontend_plugin_api.AnyApiFactory>;
130
- }>;
131
-
132
- /**
133
- * @alpha
134
- * @deprecated This API is no longer necessary and will be removed
135
- */
136
- declare const formFieldsApiRef: _backstage_frontend_plugin_api.ApiRef<ScaffolderFormFieldsApi>;
137
-
138
19
  /**
139
20
  * This is the parsed template schema that is returned from the {@link useTemplateSchema} hook.
140
21
  * @alpha
@@ -444,9 +325,104 @@ declare module '@backstage/theme' {
444
325
  }
445
326
  }
446
327
 
328
+ /** @alpha */
329
+ type ScaffolderFormDecoratorContext<TInput extends JsonObject = JsonObject> = {
330
+ input: TInput;
331
+ formState: Record<string, JsonValue>;
332
+ setFormState: (fn: (currentState: Record<string, JsonValue>) => Record<string, JsonValue>) => void;
333
+ setSecrets: (fn: (currentState: Record<string, string>) => Record<string, string>) => void;
334
+ };
335
+ /** @alpha */
336
+ type ScaffolderFormDecorator<TInput extends JsonObject = JsonObject> = {
337
+ readonly $$type: '@backstage/scaffolder/FormDecorator';
338
+ readonly id: string;
339
+ readonly TInput: TInput;
340
+ };
341
+ /**
342
+ * Method for creating decorators which can be used to collect
343
+ * secrets from the user before submitting to the backend.
344
+ * @alpha
345
+ */
346
+ declare function createScaffolderFormDecorator<TInputSchema extends {
347
+ [key in string]: (zImpl: typeof z) => z.ZodType;
348
+ } = {
349
+ [key in string]: (zImpl: typeof z) => z.ZodType;
350
+ }, TDeps extends {
351
+ [key in string]: AnyApiRef;
352
+ } = {
353
+ [key in string]: AnyApiRef;
354
+ }, TInput extends JsonObject = {
355
+ [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
356
+ }>(options: {
357
+ id: string;
358
+ schema?: {
359
+ input?: TInputSchema;
360
+ };
361
+ deps?: TDeps;
362
+ decorator: (ctx: ScaffolderFormDecoratorContext<TInput>, deps: TDeps extends {
363
+ [key in string]: AnyApiRef;
364
+ } ? {
365
+ [key in keyof TDeps]: TDeps[key]['T'];
366
+ } : never) => Promise<void>;
367
+ }): ScaffolderFormDecorator<TInput>;
368
+
369
+ /**
370
+ * @alpha
371
+ * Creates extensions that are Field Extensions for the Scaffolder
372
+ * */
373
+ declare const FormDecoratorBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
374
+ kind: "scaffolder-form-decorator";
375
+ params: {
376
+ decorator: ScaffolderFormDecorator;
377
+ };
378
+ output: _backstage_frontend_plugin_api.ExtensionDataRef<ScaffolderFormDecorator, "scaffolder.form-decorator-loader", {}>;
379
+ inputs: {};
380
+ config: {};
381
+ configInput: {};
382
+ dataRefs: {
383
+ formDecoratorLoader: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<ScaffolderFormDecorator, "scaffolder.form-decorator-loader", {}>;
384
+ };
385
+ }>;
386
+
387
+ /** @alpha */
388
+ type FormFieldExtensionData<TReturnValue extends z.ZodType = z.ZodType, TUiOptions extends z.ZodType = z.ZodType> = {
389
+ name: string;
390
+ component: (props: FieldExtensionComponentProps<z.output<TReturnValue>, z.output<TUiOptions>>) => JSX.Element | null;
391
+ validation?: CustomFieldValidator<z.output<TReturnValue>, z.output<TUiOptions>>;
392
+ schema?: FieldSchema<z.output<TReturnValue>, z.output<TUiOptions>>;
393
+ };
394
+
395
+ /**
396
+ * @alpha
397
+ * Creates extensions that are Field Extensions for the Scaffolder
398
+ * */
399
+ declare const FormFieldBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
400
+ kind: "scaffolder-form-field";
401
+ params: {
402
+ field: () => Promise<FormField>;
403
+ };
404
+ output: _backstage_frontend_plugin_api.ExtensionDataRef<() => Promise<FormField>, "scaffolder.form-field-loader", {}>;
405
+ inputs: {};
406
+ config: {};
407
+ configInput: {};
408
+ dataRefs: {
409
+ formFieldLoader: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<() => Promise<FormField>, "scaffolder.form-field-loader", {}>;
410
+ };
411
+ }>;
412
+ /**
413
+ * @alpha
414
+ * Used to create a form field binding with typechecking for compliance
415
+ */
416
+ declare function createFormField<TReturnValue extends z.ZodType, TUiOptions extends z.ZodType>(opts: FormFieldExtensionData<TReturnValue, TUiOptions>): FormField;
417
+
447
418
  /** @alpha */
448
419
  declare const scaffolderReactTranslationRef: _backstage_frontend_plugin_api.TranslationRef<"scaffolder-react", {
449
420
  readonly "workflow.noDescription": "No description";
421
+ readonly "stepper.backButtonText": "Back";
422
+ readonly "stepper.createButtonText": "Create";
423
+ readonly "stepper.reviewButtonText": "Review";
424
+ readonly "stepper.nextButtonText": "Next";
425
+ readonly "stepper.stepIndexLabel": "Step {{index, number}}";
450
426
  readonly "passwordWidget.content": "This widget is insecure. Please use [`ui:field: Secret`](https://backstage.io/docs/features/software-templates/writing-templates/#using-secrets) instead of `ui:widget: password`";
451
427
  readonly "scaffolderPageContextMenu.createLabel": "Create";
452
428
  readonly "scaffolderPageContextMenu.moreLabel": "more";
@@ -454,11 +430,6 @@ declare const scaffolderReactTranslationRef: _backstage_frontend_plugin_api.Tran
454
430
  readonly "scaffolderPageContextMenu.actionsLabel": "Installed Actions";
455
431
  readonly "scaffolderPageContextMenu.tasksLabel": "Task List";
456
432
  readonly "scaffolderPageContextMenu.templatingExtensionsLabel": "Templating Extensions";
457
- readonly "stepper.backButtonText": "Back";
458
- readonly "stepper.createButtonText": "Create";
459
- readonly "stepper.reviewButtonText": "Review";
460
- readonly "stepper.nextButtonText": "Next";
461
- readonly "stepper.stepIndexLabel": "Step {{index, number}}";
462
433
  readonly "templateCategoryPicker.title": "Categories";
463
434
  readonly "templateCard.noDescription": "No description";
464
435
  readonly "templateCard.chooseButtonText": "Choose";
@@ -466,5 +437,5 @@ declare const scaffolderReactTranslationRef: _backstage_frontend_plugin_api.Tran
466
437
  readonly "templateOutputs.title": "Text Output";
467
438
  }>;
468
439
 
469
- export { DefaultTemplateOutputs, EmbeddableWorkflow, Form, FormDecoratorBlueprint, FormFieldBlueprint, ReviewState, ScaffolderField, ScaffolderPageContextMenu, SecretWidget, Stepper, TaskLogStream, TaskSteps, TemplateCard, TemplateCategoryPicker, TemplateGroup, TemplateGroups, Workflow, createAsyncValidators, createFieldValidation, createFormField, createScaffolderFormDecorator, extractSchemaFromStep, formFieldsApi, formFieldsApiRef, scaffolderReactTranslationRef, useFilteredSchemaProperties, useFormDataFromQuery, useTemplateParameterSchema, useTemplateSchema };
470
- export type { BackstageOverrides, BackstageTemplateStepperClassKey, FormField, FormFieldExtensionData, FormValidation, ParsedTemplateSchema, ReviewStateProps, ScaffolderFieldProps, ScaffolderFormDecorator, ScaffolderFormDecoratorContext, ScaffolderFormFieldsApi, ScaffolderPageContextMenuProps, ScaffolderReactComponentsNameToClassKey, ScaffolderReactTemplateCategoryPickerClassKey, StepperProps, TaskStepsProps, TemplateCardProps, TemplateGroupProps, TemplateGroupsProps, WorkflowProps };
440
+ export { DefaultTemplateOutputs, EmbeddableWorkflow, Form, FormDecoratorBlueprint, FormFieldBlueprint, ReviewState, ScaffolderField, ScaffolderPageContextMenu, SecretWidget, Stepper, TaskLogStream, TaskSteps, TemplateCard, TemplateCategoryPicker, TemplateGroup, TemplateGroups, Workflow, createAsyncValidators, createFieldValidation, createFormField, createScaffolderFormDecorator, extractSchemaFromStep, scaffolderReactTranslationRef, useFilteredSchemaProperties, useFormDataFromQuery, useTemplateParameterSchema, useTemplateSchema };
441
+ export type { BackstageOverrides, BackstageTemplateStepperClassKey, FormField, FormFieldExtensionData, FormValidation, ParsedTemplateSchema, ReviewStateProps, ScaffolderFieldProps, ScaffolderFormDecorator, ScaffolderFormDecoratorContext, ScaffolderPageContextMenuProps, ScaffolderReactComponentsNameToClassKey, ScaffolderReactTemplateCategoryPickerClassKey, StepperProps, TaskStepsProps, TemplateCardProps, TemplateGroupProps, TemplateGroupsProps, WorkflowProps };
package/dist/alpha.esm.js CHANGED
@@ -1,5 +1,3 @@
1
- export { formFieldsApi } from './next/api/FormFieldsApi.esm.js';
2
- export { formFieldsApiRef } from './next/api/ref.esm.js';
3
1
  export { Stepper } from './next/components/Stepper/Stepper.esm.js';
4
2
  export { createAsyncValidators } from './next/components/Stepper/createAsyncValidators.esm.js';
5
3
  export { TemplateCard } from './next/components/TemplateCard/TemplateCard.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,59 +1,7 @@
1
- import { useAsync, useMountEffect } from '@react-hookz/web';
2
- import { useApi, useElementFilter } from '@backstage/core-plugin-api';
3
- import '../next/api/FormFieldsApi.esm.js';
4
- import { formFieldsApiRef } from '../next/api/ref.esm.js';
5
- import '../next/components/Stepper/Stepper.esm.js';
6
- import 'json-schema-library';
7
- import 'flatted';
8
- import '../next/components/TemplateCard/TemplateCard.esm.js';
9
- import 'react/jsx-runtime';
10
- import '@backstage/core-components';
11
- import 'lodash';
12
- import '@backstage/catalog-model';
13
- import '@backstage/plugin-catalog-react';
14
- import '@backstage/plugin-scaffolder-common';
15
- import '@material-ui/core/Typography';
16
- import 'react';
17
- import '../next/components/Workflow/Workflow.esm.js';
18
- import '@backstage/frontend-plugin-api';
19
- import '@material-ui/core/Box';
20
- import '@material-ui/core/Paper';
21
- import '../translation.esm.js';
22
- import '../next/components/TemplateOutputs/LinkOutputs.esm.js';
23
- import '@material-ui/core/Button';
24
- import '@material-ui/icons/Description';
25
- import '../next/components/Form/Form.esm.js';
26
- import '@material-ui/core/Stepper';
27
- import '@material-ui/core/Step';
28
- import '@material-ui/core/StepButton';
29
- import '@material-ui/core/StepLabel';
30
- import '../next/components/TaskSteps/StepIcon.esm.js';
31
- import 'react-use/esm/useInterval';
32
- import 'luxon';
33
- import 'humanize-duration';
34
- import '../next/components/TaskSteps/TaskBorder.esm.js';
35
- import '../next/components/TaskLogStream/TaskLogStream.esm.js';
36
- import '../next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js';
37
- import '../next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js';
38
- import '../next/components/ScaffolderField/ScaffolderField.esm.js';
39
- import '@backstage/plugin-scaffolder-react';
40
- import '@material-ui/core/TextField';
41
- import 'lodash/debounce';
42
- import 'qs';
43
- import 'react-use/esm/useAsync';
44
- import '../api/ref.esm.js';
45
- import 'lodash/cloneDeep';
46
- import '../next/blueprints/FormDecoratorBlueprint.esm.js';
47
- import '../next/blueprints/FormFieldBlueprint.esm.js';
1
+ import { useElementFilter } from '@backstage/core-plugin-api';
48
2
  import { FIELD_EXTENSION_WRAPPER_KEY, FIELD_EXTENSION_KEY } from '../extensions/keys.esm.js';
49
3
 
50
4
  const useCustomFieldExtensions = (outlet) => {
51
- const formFieldsApi = useApi(formFieldsApiRef);
52
- const [{ result: blueprintFields }, { execute }] = useAsync(
53
- () => formFieldsApi.getFormFields(),
54
- []
55
- );
56
- useMountEffect(execute);
57
5
  const outletFields = useElementFilter(
58
6
  outlet,
59
7
  (elements) => elements.selectByComponentData({
@@ -62,15 +10,7 @@ const useCustomFieldExtensions = (outlet) => {
62
10
  key: FIELD_EXTENSION_KEY
63
11
  })
64
12
  );
65
- const blueprintsToLegacy = blueprintFields?.map(
66
- (field) => ({
67
- component: field.component,
68
- name: field.name,
69
- validation: field.validation,
70
- schema: field.schema?.schema
71
- })
72
- );
73
- return [...blueprintsToLegacy, ...outletFields];
13
+ return outletFields;
74
14
  };
75
15
 
76
16
  export { useCustomFieldExtensions };
@@ -1 +1 @@
1
- {"version":3,"file":"useCustomFieldExtensions.esm.js","sources":["../../src/hooks/useCustomFieldExtensions.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAsync, useMountEffect } from '@react-hookz/web';\nimport { useApi, useElementFilter } from '@backstage/core-plugin-api';\nimport { formFieldsApiRef } from '../next';\nimport { FieldExtensionOptions } from '../extensions';\nimport {\n FIELD_EXTENSION_KEY,\n FIELD_EXTENSION_WRAPPER_KEY,\n} from '../extensions/keys';\n\n/**\n * Hook that returns all custom field extensions from the current outlet.\n * @public\n */\nexport const useCustomFieldExtensions = <\n // todo(blam): this shouldn't be here, should remove this, but this is a breaking change to remove the generic.\n TComponentDataType = FieldExtensionOptions,\n>(\n outlet: React.ReactNode,\n) => {\n // Get custom fields created with FormFieldBlueprint\n const formFieldsApi = useApi(formFieldsApiRef);\n const [{ result: blueprintFields }, { execute }] = useAsync(\n () => formFieldsApi.getFormFields(),\n [],\n );\n useMountEffect(execute);\n\n // Get custom fields created with ScaffolderFieldExtensions\n const outletFields = useElementFilter(outlet, elements =>\n elements\n .selectByComponentData({\n key: FIELD_EXTENSION_WRAPPER_KEY,\n })\n .findComponentData<TComponentDataType>({\n key: FIELD_EXTENSION_KEY,\n }),\n );\n\n // This should really be a different type moving forward, but we do this to keep type compatibility.\n // should probably also move the defaults into the API eventually too, but that will come with the move\n // to the new frontend system.\n const blueprintsToLegacy: FieldExtensionOptions[] = blueprintFields?.map(\n field => ({\n component: field.component,\n name: field.name,\n validation: field.validation,\n schema: field.schema?.schema,\n }),\n );\n\n return [...blueprintsToLegacy, ...outletFields] as TComponentDataType[];\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,wBAAA,GAA2B,CAItC,MAAA,KACG;AAEH,EAAA,MAAM,aAAA,GAAgB,OAAO,gBAAgB,CAAA;AAC7C,EAAA,MAAM,CAAC,EAAE,MAAA,EAAQ,eAAA,IAAmB,EAAE,OAAA,EAAS,CAAA,GAAI,QAAA;AAAA,IACjD,MAAM,cAAc,aAAA,EAAc;AAAA,IAClC;AAAC,GACH;AACA,EAAA,cAAA,CAAe,OAAO,CAAA;AAGtB,EAAA,MAAM,YAAA,GAAe,gBAAA;AAAA,IAAiB,MAAA;AAAA,IAAQ,CAAA,QAAA,KAC5C,SACG,qBAAA,CAAsB;AAAA,MACrB,GAAA,EAAK;AAAA,KACN,EACA,iBAAA,CAAsC;AAAA,MACrC,GAAA,EAAK;AAAA,KACN;AAAA,GACL;AAKA,EAAA,MAAM,qBAA8C,eAAA,EAAiB,GAAA;AAAA,IACnE,CAAA,KAAA,MAAU;AAAA,MACR,WAAW,KAAA,CAAM,SAAA;AAAA,MACjB,MAAM,KAAA,CAAM,IAAA;AAAA,MACZ,YAAY,KAAA,CAAM,UAAA;AAAA,MAClB,MAAA,EAAQ,MAAM,MAAA,EAAQ;AAAA,KACxB;AAAA,GACF;AAEA,EAAA,OAAO,CAAC,GAAG,kBAAA,EAAoB,GAAG,YAAY,CAAA;AAChD;;;;"}
1
+ {"version":3,"file":"useCustomFieldExtensions.esm.js","sources":["../../src/hooks/useCustomFieldExtensions.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useElementFilter } from '@backstage/core-plugin-api';\nimport { FieldExtensionOptions } from '../extensions';\nimport {\n FIELD_EXTENSION_KEY,\n FIELD_EXTENSION_WRAPPER_KEY,\n} from '../extensions/keys';\n\n/**\n * Hook that returns all custom field extensions from the current outlet.\n * @public\n */\nexport const useCustomFieldExtensions = <\n // todo(blam): this shouldn't be here, should remove this, but this is a breaking change to remove the generic.\n TComponentDataType = FieldExtensionOptions,\n>(\n outlet: React.ReactNode,\n) => {\n // Get custom fields created with ScaffolderFieldExtensions\n const outletFields = useElementFilter(outlet, elements =>\n elements\n .selectByComponentData({\n key: FIELD_EXTENSION_WRAPPER_KEY,\n })\n .findComponentData<TComponentDataType>({\n key: FIELD_EXTENSION_KEY,\n }),\n );\n\n return outletFields as TComponentDataType[];\n};\n"],"names":[],"mappings":";;;AA0BO,MAAM,wBAAA,GAA2B,CAItC,MAAA,KACG;AAEH,EAAA,MAAM,YAAA,GAAe,gBAAA;AAAA,IAAiB,MAAA;AAAA,IAAQ,CAAA,QAAA,KAC5C,SACG,qBAAA,CAAsB;AAAA,MACrB,GAAA,EAAK;AAAA,KACN,EACA,iBAAA,CAAsC;AAAA,MACrC,GAAA,EAAK;AAAA,KACN;AAAA,GACL;AAEA,EAAA,OAAO,YAAA;AACT;;;;"}
@@ -7,10 +7,7 @@ const formFieldExtensionDataRef = createExtensionDataRef().with({
7
7
  });
8
8
  const FormFieldBlueprint = createExtensionBlueprint({
9
9
  kind: "scaffolder-form-field",
10
- attachTo: [
11
- { id: "page:scaffolder", input: "formFields" },
12
- { id: "api:scaffolder/form-fields", input: "formFields" }
13
- ],
10
+ attachTo: { id: "api:scaffolder/form-fields", input: "formFields" },
14
11
  dataRefs: {
15
12
  formFieldLoader: formFieldExtensionDataRef
16
13
  },
@@ -1 +1 @@
1
- {"version":3,"file":"FormFieldBlueprint.esm.js","sources":["../../../src/next/blueprints/FormFieldBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\nimport { z } from 'zod';\n\nimport { OpaqueFormField } from '@internal/scaffolder';\nimport { FormFieldExtensionData } from './types';\nimport { FormField } from '../api';\n\nconst formFieldExtensionDataRef = createExtensionDataRef<\n () => Promise<FormField>\n>().with({\n id: 'scaffolder.form-field-loader',\n});\n\n/**\n * @alpha\n * Creates extensions that are Field Extensions for the Scaffolder\n * */\nexport const FormFieldBlueprint = createExtensionBlueprint({\n kind: 'scaffolder-form-field',\n attachTo: [\n { id: 'page:scaffolder', input: 'formFields' },\n { id: 'api:scaffolder/form-fields', input: 'formFields' },\n ],\n dataRefs: {\n formFieldLoader: formFieldExtensionDataRef,\n },\n output: [formFieldExtensionDataRef],\n *factory(params: { field: () => Promise<FormField> }) {\n yield formFieldExtensionDataRef(params.field);\n },\n});\n\n/**\n * @alpha\n * Used to create a form field binding with typechecking for compliance\n */\nexport function createFormField<\n TReturnValue extends z.ZodType,\n TUiOptions extends z.ZodType,\n>(opts: FormFieldExtensionData<TReturnValue, TUiOptions>): FormField {\n return OpaqueFormField.createInstance('v1', opts);\n}\n"],"names":[],"mappings":";;;;AAyBA,MAAM,yBAAA,GAA4B,sBAAA,EAEhC,CAAE,IAAA,CAAK;AAAA,EACP,EAAA,EAAI;AACN,CAAC,CAAA;AAMM,MAAM,qBAAqB,wBAAA,CAAyB;AAAA,EACzD,IAAA,EAAM,uBAAA;AAAA,EACN,QAAA,EAAU;AAAA,IACR,EAAE,EAAA,EAAI,iBAAA,EAAmB,KAAA,EAAO,YAAA,EAAa;AAAA,IAC7C,EAAE,EAAA,EAAI,4BAAA,EAA8B,KAAA,EAAO,YAAA;AAAa,GAC1D;AAAA,EACA,QAAA,EAAU;AAAA,IACR,eAAA,EAAiB;AAAA,GACnB;AAAA,EACA,MAAA,EAAQ,CAAC,yBAAyB,CAAA;AAAA,EAClC,CAAC,QAAQ,MAAA,EAA6C;AACpD,IAAA,MAAM,yBAAA,CAA0B,OAAO,KAAK,CAAA;AAAA,EAC9C;AACF,CAAC;AAMM,SAAS,gBAGd,IAAA,EAAmE;AACnE,EAAA,OAAO,eAAA,CAAgB,cAAA,CAAe,IAAA,EAAM,IAAI,CAAA;AAClD;;;;"}
1
+ {"version":3,"file":"FormFieldBlueprint.esm.js","sources":["../../../src/next/blueprints/FormFieldBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\nimport { z } from 'zod';\n\nimport { OpaqueFormField } from '@internal/scaffolder';\nimport { FormFieldExtensionData } from './types';\nimport { FormField } from '../api';\n\nconst formFieldExtensionDataRef = createExtensionDataRef<\n () => Promise<FormField>\n>().with({\n id: 'scaffolder.form-field-loader',\n});\n\n/**\n * @alpha\n * Creates extensions that are Field Extensions for the Scaffolder\n * */\nexport const FormFieldBlueprint = createExtensionBlueprint({\n kind: 'scaffolder-form-field',\n attachTo: { id: 'api:scaffolder/form-fields', input: 'formFields' },\n dataRefs: {\n formFieldLoader: formFieldExtensionDataRef,\n },\n output: [formFieldExtensionDataRef],\n *factory(params: { field: () => Promise<FormField> }) {\n yield formFieldExtensionDataRef(params.field);\n },\n});\n\n/**\n * @alpha\n * Used to create a form field binding with typechecking for compliance\n */\nexport function createFormField<\n TReturnValue extends z.ZodType,\n TUiOptions extends z.ZodType,\n>(opts: FormFieldExtensionData<TReturnValue, TUiOptions>): FormField {\n return OpaqueFormField.createInstance('v1', opts);\n}\n"],"names":[],"mappings":";;;;AAyBA,MAAM,yBAAA,GAA4B,sBAAA,EAEhC,CAAE,IAAA,CAAK;AAAA,EACP,EAAA,EAAI;AACN,CAAC,CAAA;AAMM,MAAM,qBAAqB,wBAAA,CAAyB;AAAA,EACzD,IAAA,EAAM,uBAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,4BAAA,EAA8B,OAAO,YAAA,EAAa;AAAA,EAClE,QAAA,EAAU;AAAA,IACR,eAAA,EAAiB;AAAA,GACnB;AAAA,EACA,MAAA,EAAQ,CAAC,yBAAyB,CAAA;AAAA,EAClC,CAAC,QAAQ,MAAA,EAA6C;AACpD,IAAA,MAAM,yBAAA,CAA0B,OAAO,KAAK,CAAA;AAAA,EAC9C;AACF,CAAC;AAMM,SAAS,gBAGd,IAAA,EAAmE;AACnE,EAAA,OAAO,eAAA,CAAgB,cAAA,CAAe,IAAA,EAAM,IAAI,CAAA;AAClD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-react",
3
- "version": "1.19.5",
3
+ "version": "1.19.6-next.0",
4
4
  "description": "A frontend library that helps other Backstage plugins interact with the Scaffolder",
5
5
  "backstage": {
6
6
  "role": "web-library",
@@ -66,17 +66,17 @@
66
66
  "test": "backstage-cli package test"
67
67
  },
68
68
  "dependencies": {
69
- "@backstage/catalog-client": "^1.12.1",
70
- "@backstage/catalog-model": "^1.7.6",
71
- "@backstage/core-components": "^0.18.5",
72
- "@backstage/core-plugin-api": "^1.12.1",
73
- "@backstage/frontend-plugin-api": "^0.13.3",
74
- "@backstage/plugin-catalog-react": "^1.21.5",
75
- "@backstage/plugin-permission-react": "^0.4.39",
76
- "@backstage/plugin-scaffolder-common": "^1.7.5",
77
- "@backstage/theme": "^0.7.1",
78
- "@backstage/types": "^1.2.2",
79
- "@backstage/version-bridge": "^1.0.11",
69
+ "@backstage/catalog-client": "1.12.1",
70
+ "@backstage/catalog-model": "1.7.6",
71
+ "@backstage/core-components": "0.18.6-next.0",
72
+ "@backstage/core-plugin-api": "1.12.2-next.0",
73
+ "@backstage/frontend-plugin-api": "0.14.0-next.0",
74
+ "@backstage/plugin-catalog-react": "1.21.6-next.0",
75
+ "@backstage/plugin-permission-react": "0.4.40-next.0",
76
+ "@backstage/plugin-scaffolder-common": "1.7.6-next.0",
77
+ "@backstage/theme": "0.7.1",
78
+ "@backstage/types": "1.2.2",
79
+ "@backstage/version-bridge": "1.0.11",
80
80
  "@material-ui/core": "^4.12.2",
81
81
  "@material-ui/icons": "^4.9.1",
82
82
  "@material-ui/lab": "4.0.0-alpha.61",
@@ -100,16 +100,16 @@
100
100
  "react-use": "^17.2.4",
101
101
  "use-immer": "^0.11.0",
102
102
  "zen-observable": "^0.10.0",
103
- "zod": "^3.22.4",
103
+ "zod": "^3.25.76",
104
104
  "zod-to-json-schema": "^3.25.1"
105
105
  },
106
106
  "devDependencies": {
107
- "@backstage/cli": "^0.35.2",
108
- "@backstage/core-app-api": "^1.19.3",
109
- "@backstage/plugin-catalog": "^1.32.2",
110
- "@backstage/plugin-catalog-common": "^1.1.7",
111
- "@backstage/plugin-permission-common": "^0.9.4",
112
- "@backstage/test-utils": "^1.7.14",
107
+ "@backstage/cli": "0.35.3-next.0",
108
+ "@backstage/core-app-api": "1.19.4-next.0",
109
+ "@backstage/plugin-catalog": "1.32.3-next.0",
110
+ "@backstage/plugin-catalog-common": "1.1.8-next.0",
111
+ "@backstage/plugin-permission-common": "0.9.5-next.0",
112
+ "@backstage/test-utils": "1.7.15-next.0",
113
113
  "@testing-library/dom": "^10.0.0",
114
114
  "@testing-library/jest-dom": "^6.0.0",
115
115
  "@testing-library/react": "^16.0.0",
@@ -1,42 +0,0 @@
1
- import { ApiBlueprint, createExtensionInput } from '@backstage/frontend-plugin-api';
2
- import { formFieldsApiRef } from './ref.esm.js';
3
- import '../blueprints/FormDecoratorBlueprint.esm.js';
4
- import { FormFieldBlueprint } from '../blueprints/FormFieldBlueprint.esm.js';
5
- import { OpaqueFormField } from '../../packages/scaffolder-internal/src/wiring/InternalFormField.esm.js';
6
-
7
- class DefaultScaffolderFormFieldsApi {
8
- formFieldLoaders;
9
- constructor(formFieldLoaders = []) {
10
- this.formFieldLoaders = formFieldLoaders;
11
- }
12
- async getFormFields() {
13
- const formFields = await Promise.all(
14
- this.formFieldLoaders.map((loader) => loader())
15
- );
16
- const internalFormFields = formFields.map(OpaqueFormField.toInternal);
17
- return internalFormFields;
18
- }
19
- }
20
- const formFieldsApi = ApiBlueprint.makeWithOverrides({
21
- name: "form-fields",
22
- inputs: {
23
- formFields: createExtensionInput([
24
- FormFieldBlueprint.dataRefs.formFieldLoader
25
- ])
26
- },
27
- factory(originalFactory, { inputs }) {
28
- const formFieldLoaders = inputs.formFields.map(
29
- (e) => e.get(FormFieldBlueprint.dataRefs.formFieldLoader)
30
- );
31
- return originalFactory(
32
- (defineParams) => defineParams({
33
- api: formFieldsApiRef,
34
- deps: {},
35
- factory: () => new DefaultScaffolderFormFieldsApi(formFieldLoaders)
36
- })
37
- );
38
- }
39
- });
40
-
41
- export { formFieldsApi };
42
- //# sourceMappingURL=FormFieldsApi.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormFieldsApi.esm.js","sources":["../../../src/next/api/FormFieldsApi.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiBlueprint,\n createExtensionInput,\n} from '@backstage/frontend-plugin-api';\nimport { formFieldsApiRef } from './ref';\nimport { FormField, ScaffolderFormFieldsApi } from './types';\nimport { FormFieldBlueprint } from '../blueprints';\nimport { OpaqueFormField } from '@internal/scaffolder';\n\nclass DefaultScaffolderFormFieldsApi implements ScaffolderFormFieldsApi {\n private readonly formFieldLoaders: Array<() => Promise<FormField>>;\n\n constructor(formFieldLoaders: Array<() => Promise<FormField>> = []) {\n this.formFieldLoaders = formFieldLoaders;\n }\n\n async getFormFields() {\n const formFields = await Promise.all(\n this.formFieldLoaders.map(loader => loader()),\n );\n\n const internalFormFields = formFields.map(OpaqueFormField.toInternal);\n\n return internalFormFields;\n }\n}\n\n/** @alpha */\nexport const formFieldsApi = ApiBlueprint.makeWithOverrides({\n name: 'form-fields',\n inputs: {\n formFields: createExtensionInput([\n FormFieldBlueprint.dataRefs.formFieldLoader,\n ]),\n },\n factory(originalFactory, { inputs }) {\n const formFieldLoaders = inputs.formFields.map(e =>\n e.get(FormFieldBlueprint.dataRefs.formFieldLoader),\n );\n\n return originalFactory(defineParams =>\n defineParams({\n api: formFieldsApiRef,\n deps: {},\n factory: () => new DefaultScaffolderFormFieldsApi(formFieldLoaders),\n }),\n );\n },\n});\n"],"names":[],"mappings":";;;;;;AAyBA,MAAM,8BAAA,CAAkE;AAAA,EACrD,gBAAA;AAAA,EAEjB,WAAA,CAAY,gBAAA,GAAoD,EAAC,EAAG;AAClE,IAAA,IAAA,CAAK,gBAAA,GAAmB,gBAAA;AAAA,EAC1B;AAAA,EAEA,MAAM,aAAA,GAAgB;AACpB,IAAA,MAAM,UAAA,GAAa,MAAM,OAAA,CAAQ,GAAA;AAAA,MAC/B,IAAA,CAAK,gBAAA,CAAiB,GAAA,CAAI,CAAA,MAAA,KAAU,QAAQ;AAAA,KAC9C;AAEA,IAAA,MAAM,kBAAA,GAAqB,UAAA,CAAW,GAAA,CAAI,eAAA,CAAgB,UAAU,CAAA;AAEpE,IAAA,OAAO,kBAAA;AAAA,EACT;AACF;AAGO,MAAM,aAAA,GAAgB,aAAa,iBAAA,CAAkB;AAAA,EAC1D,IAAA,EAAM,aAAA;AAAA,EACN,MAAA,EAAQ;AAAA,IACN,YAAY,oBAAA,CAAqB;AAAA,MAC/B,mBAAmB,QAAA,CAAS;AAAA,KAC7B;AAAA,GACH;AAAA,EACA,OAAA,CAAQ,eAAA,EAAiB,EAAE,MAAA,EAAO,EAAG;AACnC,IAAA,MAAM,gBAAA,GAAmB,OAAO,UAAA,CAAW,GAAA;AAAA,MAAI,CAAA,CAAA,KAC7C,CAAA,CAAE,GAAA,CAAI,kBAAA,CAAmB,SAAS,eAAe;AAAA,KACnD;AAEA,IAAA,OAAO,eAAA;AAAA,MAAgB,kBACrB,YAAA,CAAa;AAAA,QACX,GAAA,EAAK,gBAAA;AAAA,QACL,MAAM,EAAC;AAAA,QACP,OAAA,EAAS,MAAM,IAAI,8BAAA,CAA+B,gBAAgB;AAAA,OACnE;AAAA,KACH;AAAA,EACF;AACF,CAAC;;;;"}
@@ -1,8 +0,0 @@
1
- import { createApiRef } from '@backstage/frontend-plugin-api';
2
-
3
- const formFieldsApiRef = createApiRef({
4
- id: "plugin.scaffolder.form-fields"
5
- });
6
-
7
- export { formFieldsApiRef };
8
- //# sourceMappingURL=ref.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ref.esm.js","sources":["../../../src/next/api/ref.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createApiRef } from '@backstage/frontend-plugin-api';\nimport { ScaffolderFormFieldsApi } from './types';\n\n/**\n * @alpha\n * @deprecated This API is no longer necessary and will be removed\n */\nexport const formFieldsApiRef = createApiRef<ScaffolderFormFieldsApi>({\n id: 'plugin.scaffolder.form-fields',\n});\n"],"names":[],"mappings":";;AAuBO,MAAM,mBAAmB,YAAA,CAAsC;AAAA,EACpE,EAAA,EAAI;AACN,CAAC;;;;"}