@backstage/plugin-scaffolder 1.27.2 → 1.27.3

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,11 @@
1
1
  # @backstage/plugin-scaffolder
2
2
 
3
+ ## 1.27.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 9cadaf1: Fix issue with `secrets` not being forwarded properly to the backend when creating a task
8
+
3
9
  ## 1.27.2
4
10
 
5
11
  ### Patch Changes
@@ -42,7 +42,7 @@ const useFormDecorators = ({
42
42
  return {
43
43
  run: async (opts) => {
44
44
  let formState = { ...opts.formState };
45
- let secrets = {};
45
+ let secrets = { ...opts.secrets };
46
46
  if (manifest?.EXPERIMENTAL_formDecorators) {
47
47
  await Promise.all(
48
48
  manifest.EXPERIMENTAL_formDecorators.map(async (decorator) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useFormDecorators.esm.js","sources":["../../../src/alpha/hooks/useFormDecorators.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 */\nimport { errorApiRef, useApi, useApiHolder } from '@backstage/core-plugin-api';\nimport { formDecoratorsApiRef } from '../api/ref';\nimport useAsync from 'react-use/esm/useAsync';\nimport { useMemo } from 'react';\nimport { ScaffolderFormDecoratorContext } from '@backstage/plugin-scaffolder-react/alpha';\nimport { OpaqueFormDecorator } from '@internal/scaffolder';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\nimport { JsonValue } from '@backstage/types';\n\n/** @internal */\ntype BoundFieldDecorator = {\n decorator: (ctx: ScaffolderFormDecoratorContext) => Promise<void>;\n};\n\nexport const useFormDecorators = ({\n manifest,\n}: {\n manifest?: TemplateParameterSchema;\n}) => {\n const formDecoratorsApi = useApi(formDecoratorsApiRef);\n const errorApi = useApi(errorApiRef);\n const { value: decorators } = useAsync(\n () => formDecoratorsApi.getFormDecorators(),\n [],\n );\n const apiHolder = useApiHolder();\n\n const boundDecorators = useMemo(() => {\n const decoratorsMap = new Map<string, BoundFieldDecorator>();\n\n for (const decorator of decorators ?? []) {\n try {\n const { decorator: decoratorFn, deps } =\n OpaqueFormDecorator.toInternal(decorator);\n\n const resolvedDeps = Object.entries(deps ?? {}).map(([key, value]) => {\n const api = apiHolder.get(value);\n if (!api) {\n throw new Error(\n `Failed to resolve apiRef ${value.id} for form decorator ${decorator.id} it will be disabled`,\n );\n }\n return [key, api];\n });\n\n decoratorsMap.set(decorator.id, {\n decorator: ctx => decoratorFn(ctx, Object.fromEntries(resolvedDeps)),\n });\n } catch (ex) {\n errorApi.post(ex);\n return undefined;\n }\n }\n return decoratorsMap;\n }, [apiHolder, decorators, errorApi]);\n\n return {\n run: async (opts: {\n formState: Record<string, JsonValue>;\n secrets: Record<string, string>;\n }) => {\n let formState: Record<string, JsonValue> = { ...opts.formState };\n let secrets: Record<string, string> = {};\n\n if (manifest?.EXPERIMENTAL_formDecorators) {\n // for each of the form decorators, go and call the decorator with the context\n await Promise.all(\n manifest.EXPERIMENTAL_formDecorators.map(async decorator => {\n const formDecorator = boundDecorators?.get(decorator.id);\n if (!formDecorator) {\n errorApi.post(\n new Error(`Failed to find form decorator ${decorator.id}`),\n );\n return;\n }\n\n await formDecorator.decorator({\n setSecrets: (\n handler: (\n oldState: Record<string, string>,\n ) => Record<string, string>,\n ) => {\n secrets = { ...handler(secrets) };\n },\n setFormState: (\n handler: (\n oldState: Record<string, JsonValue>,\n ) => Record<string, JsonValue>,\n ) => {\n formState = { ...handler(formState) };\n },\n formState,\n input: decorator.input ?? {},\n });\n }),\n );\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;"}
1
+ {"version":3,"file":"useFormDecorators.esm.js","sources":["../../../src/alpha/hooks/useFormDecorators.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 */\nimport { errorApiRef, useApi, useApiHolder } from '@backstage/core-plugin-api';\nimport { formDecoratorsApiRef } from '../api/ref';\nimport useAsync from 'react-use/esm/useAsync';\nimport { useMemo } from 'react';\nimport { ScaffolderFormDecoratorContext } from '@backstage/plugin-scaffolder-react/alpha';\nimport { OpaqueFormDecorator } from '@internal/scaffolder';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\nimport { JsonValue } from '@backstage/types';\n\n/** @internal */\ntype BoundFieldDecorator = {\n decorator: (ctx: ScaffolderFormDecoratorContext) => Promise<void>;\n};\n\nexport const useFormDecorators = ({\n manifest,\n}: {\n manifest?: TemplateParameterSchema;\n}) => {\n const formDecoratorsApi = useApi(formDecoratorsApiRef);\n const errorApi = useApi(errorApiRef);\n const { value: decorators } = useAsync(\n () => formDecoratorsApi.getFormDecorators(),\n [],\n );\n const apiHolder = useApiHolder();\n\n const boundDecorators = useMemo(() => {\n const decoratorsMap = new Map<string, BoundFieldDecorator>();\n\n for (const decorator of decorators ?? []) {\n try {\n const { decorator: decoratorFn, deps } =\n OpaqueFormDecorator.toInternal(decorator);\n\n const resolvedDeps = Object.entries(deps ?? {}).map(([key, value]) => {\n const api = apiHolder.get(value);\n if (!api) {\n throw new Error(\n `Failed to resolve apiRef ${value.id} for form decorator ${decorator.id} it will be disabled`,\n );\n }\n return [key, api];\n });\n\n decoratorsMap.set(decorator.id, {\n decorator: ctx => decoratorFn(ctx, Object.fromEntries(resolvedDeps)),\n });\n } catch (ex) {\n errorApi.post(ex);\n return undefined;\n }\n }\n return decoratorsMap;\n }, [apiHolder, decorators, errorApi]);\n\n return {\n run: async (opts: {\n formState: Record<string, JsonValue>;\n secrets: Record<string, string>;\n }) => {\n let formState: Record<string, JsonValue> = { ...opts.formState };\n let secrets: Record<string, string> = { ...opts.secrets };\n\n if (manifest?.EXPERIMENTAL_formDecorators) {\n // for each of the form decorators, go and call the decorator with the context\n await Promise.all(\n manifest.EXPERIMENTAL_formDecorators.map(async decorator => {\n const formDecorator = boundDecorators?.get(decorator.id);\n if (!formDecorator) {\n errorApi.post(\n new Error(`Failed to find form decorator ${decorator.id}`),\n );\n return;\n }\n\n await formDecorator.decorator({\n setSecrets: (\n handler: (\n oldState: Record<string, string>,\n ) => Record<string, string>,\n ) => {\n secrets = { ...handler(secrets) };\n },\n setFormState: (\n handler: (\n oldState: Record<string, JsonValue>,\n ) => Record<string, JsonValue>,\n ) => {\n formState = { ...handler(formState) };\n },\n formState,\n input: decorator.input ?? {},\n });\n }),\n );\n }\n\n return { formState, secrets };\n },\n };\n};\n"],"names":[],"mappings":";;;;;;;AA6BO,MAAM,oBAAoB,CAAC;AAAA,EAChC;AACF,CAEM,KAAA;AACJ,EAAM,MAAA,iBAAA,GAAoB,OAAO,oBAAoB,CAAA;AACrD,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAM,MAAA,EAAE,KAAO,EAAA,UAAA,EAAe,GAAA,QAAA;AAAA,IAC5B,MAAM,kBAAkB,iBAAkB,EAAA;AAAA,IAC1C;AAAC,GACH;AACA,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAM,MAAA,eAAA,GAAkB,QAAQ,MAAM;AACpC,IAAM,MAAA,aAAA,uBAAoB,GAAiC,EAAA;AAE3D,IAAW,KAAA,MAAA,SAAA,IAAa,UAAc,IAAA,EAAI,EAAA;AACxC,MAAI,IAAA;A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,KAAA;AAC1D,YAAA,MAAM,aAAgB,GAAA,eAAA,EAAiB,GAAI,CAAA,SAAA,CAAU,EAAE,CAAA;AACvD,YAAA,IAAI,CAAC,aAAe,EAAA;AAClB,cAAS,QAAA,CAAA,IAAA;AAAA,gBACP,IAAI,KAAA,CAAM,CAAiC,8BAAA,EAAA,SAAA,CAAU,EAAE,CAAE,CAAA;AAAA,eAC3D;AACA,cAAA;AAAA;AAGF,YAAA,MAAM,cAAc,SAAU,CAAA;AAAA,cAC5B,UAAA,EAAY,CACV,OAGG,KAAA;AACH,gBAAA,OAAA,GAAU,EAAE,GAAG,OAAQ,CAAA,OAAO,CAAE,EAAA;AAAA,eAClC;AAAA,cACA,YAAA,EAAc,CACZ,OAGG,KAAA;AACH,gBAAA,SAAA,GAAY,EAAE,GAAG,OAAQ,CAAA,SAAS,CAAE,EAAA;AAAA,eACtC;AAAA,cACA,SAAA;AAAA,cACA,KAAA,EAAO,SAAU,CAAA,KAAA,IAAS;AAAC,aAC5B,CAAA;AAAA,WACF;AAAA,SACH;AAAA;AAGF,MAAO,OAAA,EAAE,WAAW,OAAQ,EAAA;AAAA;AAC9B,GACF;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder",
3
- "version": "1.27.2",
3
+ "version": "1.27.3",
4
4
  "description": "The Backstage plugin that helps you create new things",
5
5
  "backstage": {
6
6
  "role": "frontend-plugin",