@backstage/plugin-scaffolder 1.27.1 → 1.27.2-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.
- package/CHANGELOG.md +37 -10
- package/dist/alpha/api/FormDecoratorsApi.esm.js +16 -0
- package/dist/alpha/api/FormDecoratorsApi.esm.js.map +1 -0
- package/dist/alpha/api/FormFieldsApi.esm.js +1 -0
- package/dist/alpha/api/FormFieldsApi.esm.js.map +1 -1
- package/dist/alpha/api/ref.esm.js +4 -1
- package/dist/alpha/api/ref.esm.js.map +1 -1
- package/dist/alpha/components/TemplateWizardPage/TemplateWizardPage.esm.js +18 -6
- package/dist/alpha/components/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -1
- package/dist/alpha/extensions.esm.js +24 -2
- package/dist/alpha/extensions.esm.js.map +1 -1
- package/dist/alpha/hooks/useFormDecorators.esm.js +75 -0
- package/dist/alpha/hooks/useFormDecorators.esm.js.map +1 -0
- package/dist/alpha/plugin.esm.js +1 -2
- package/dist/alpha/plugin.esm.js.map +1 -1
- package/dist/alpha.d.ts +38 -13
- package/dist/alpha.esm.js +2 -0
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api.esm.js +1 -1
- package/dist/api.esm.js.map +1 -1
- package/dist/components/Router/Router.esm.js.map +1 -1
- package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js +3 -3
- package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +13 -9
- package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +76 -11
- package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +15 -10
- package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +12 -7
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/utils.esm.js +6 -1
- package/dist/components/fields/RepoUrlPicker/utils.esm.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/packages/scaffolder-internal/src/wiring/InternalFormDecorator.esm.js +6 -0
- package/dist/packages/scaffolder-internal/src/wiring/InternalFormDecorator.esm.js.map +1 -0
- package/dist/plugin.esm.js +7 -0
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +26 -26
- package/dist/alpha/api.esm.js +0 -27
- package/dist/alpha/api.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder
|
|
2
2
|
|
|
3
|
-
## 1.27.1
|
|
3
|
+
## 1.27.2-next.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- Updated dependencies
|
|
8
|
-
- @backstage/
|
|
9
|
-
- @backstage/catalog-client@1.
|
|
8
|
+
- @backstage/plugin-catalog-react@1.14.3-next.1
|
|
9
|
+
- @backstage/catalog-client@1.9.0-next.1
|
|
10
|
+
- @backstage/plugin-scaffolder-react@1.14.2-next.1
|
|
11
|
+
- @backstage/core-components@0.16.2-next.1
|
|
10
12
|
- @backstage/catalog-model@1.7.1
|
|
11
|
-
- @backstage/core-compat-api@0.3.
|
|
12
|
-
- @backstage/core-components@0.16.1
|
|
13
|
+
- @backstage/core-compat-api@0.3.4-next.1
|
|
13
14
|
- @backstage/core-plugin-api@1.10.1
|
|
14
15
|
- @backstage/errors@1.2.5
|
|
15
|
-
- @backstage/
|
|
16
|
-
- @backstage/integration
|
|
16
|
+
- @backstage/frontend-plugin-api@0.9.3-next.1
|
|
17
|
+
- @backstage/integration@1.16.0-next.0
|
|
18
|
+
- @backstage/integration-react@1.2.2-next.0
|
|
19
|
+
- @backstage/types@1.2.0
|
|
20
|
+
- @backstage/plugin-catalog-common@1.1.1
|
|
21
|
+
- @backstage/plugin-permission-react@0.4.28
|
|
22
|
+
- @backstage/plugin-scaffolder-common@1.5.8-next.0
|
|
23
|
+
|
|
24
|
+
## 1.27.2-next.0
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 3c62a50: Experimental support for `formDecorators` to enable secret collection and mutations to the parameters for scaffolder tasks
|
|
29
|
+
- c4ffd13: Added the autocomplete feature to GitlabRepoUrlPicker
|
|
30
|
+
- 9951ba4: Updated dependency `@rjsf/utils` to `5.23.1`.
|
|
31
|
+
Updated dependency `@rjsf/core` to `5.23.1`.
|
|
32
|
+
Updated dependency `@rjsf/material-ui` to `5.23.1`.
|
|
33
|
+
Updated dependency `@rjsf/validator-ajv8` to `5.23.1`.
|
|
34
|
+
- Updated dependencies
|
|
35
|
+
- @backstage/integration@1.16.0-next.0
|
|
36
|
+
- @backstage/plugin-scaffolder-common@1.5.8-next.0
|
|
37
|
+
- @backstage/plugin-scaffolder-react@1.14.2-next.0
|
|
38
|
+
- @backstage/plugin-catalog-react@1.14.3-next.0
|
|
39
|
+
- @backstage/frontend-plugin-api@0.9.3-next.0
|
|
40
|
+
- @backstage/catalog-client@1.8.1-next.0
|
|
41
|
+
- @backstage/catalog-model@1.7.1
|
|
42
|
+
- @backstage/core-compat-api@0.3.4-next.0
|
|
43
|
+
- @backstage/core-components@0.16.2-next.0
|
|
44
|
+
- @backstage/core-plugin-api@1.10.1
|
|
45
|
+
- @backstage/errors@1.2.5
|
|
46
|
+
- @backstage/integration-react@1.2.2-next.0
|
|
17
47
|
- @backstage/types@1.2.0
|
|
18
48
|
- @backstage/plugin-catalog-common@1.1.1
|
|
19
|
-
- @backstage/plugin-catalog-react@1.14.2
|
|
20
49
|
- @backstage/plugin-permission-react@0.4.28
|
|
21
|
-
- @backstage/plugin-scaffolder-common@1.5.7
|
|
22
|
-
- @backstage/plugin-scaffolder-react@1.14.1
|
|
23
50
|
|
|
24
51
|
## 1.27.0
|
|
25
52
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class DefaultScaffolderFormDecoratorsApi {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
static create(options) {
|
|
6
|
+
return new DefaultScaffolderFormDecoratorsApi(
|
|
7
|
+
options ?? { decorators: [] }
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
async getFormDecorators() {
|
|
11
|
+
return this.options.decorators;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { DefaultScaffolderFormDecoratorsApi };
|
|
16
|
+
//# sourceMappingURL=FormDecoratorsApi.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDecoratorsApi.esm.js","sources":["../../../src/alpha/api/FormDecoratorsApi.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 { ScaffolderFormDecoratorsApi } from './types';\nimport { ScaffolderFormDecorator } from '@backstage/plugin-scaffolder-react/alpha';\n\n/** @alpha */\nexport class DefaultScaffolderFormDecoratorsApi\n implements ScaffolderFormDecoratorsApi\n{\n private constructor(\n private readonly options: {\n decorators: Array<ScaffolderFormDecorator>;\n },\n ) {}\n\n static create(options?: { decorators: ScaffolderFormDecorator[] }) {\n return new DefaultScaffolderFormDecoratorsApi(\n options ?? { decorators: [] },\n );\n }\n\n async getFormDecorators(): Promise<ScaffolderFormDecorator[]> {\n return this.options.decorators;\n }\n}\n"],"names":[],"mappings":"AAoBO,MAAM,kCAEb,CAAA;AAAA,EACU,YACW,OAGjB,EAAA;AAHiB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA;AAGhB,EAEH,OAAO,OAAO,OAAqD,EAAA;AACjE,IAAA,OAAO,IAAI,kCAAA;AAAA,MACT,OAAW,IAAA,EAAE,UAAY,EAAA,EAAG;AAAA,KAC9B;AAAA;AACF,EAEA,MAAM,iBAAwD,GAAA;AAC5D,IAAA,OAAO,KAAK,OAAQ,CAAA,UAAA;AAAA;AAExB;;;;"}
|
|
@@ -2,6 +2,7 @@ import { ApiBlueprint, createExtensionInput, createApiFactory } from '@backstage
|
|
|
2
2
|
import { formFieldsApiRef } from './ref.esm.js';
|
|
3
3
|
import { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';
|
|
4
4
|
import { OpaqueFormField } from '../../packages/scaffolder-internal/src/wiring/InternalFormField.esm.js';
|
|
5
|
+
import '../../packages/scaffolder-internal/src/wiring/InternalFormDecorator.esm.js';
|
|
5
6
|
|
|
6
7
|
class DefaultScaffolderFormFieldsApi {
|
|
7
8
|
constructor(formFieldLoaders = []) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldsApi.esm.js","sources":["../../../src/alpha/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 createApiFactory,\n createExtensionInput,\n} from '@backstage/frontend-plugin-api';\nimport { formFieldsApiRef } from './ref';\nimport { ScaffolderFormFieldsApi } from './types';\nimport { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';\nimport { FormField, OpaqueFormField } from '@internal/scaffolder';\n\nclass DefaultScaffolderFormFieldsApi implements ScaffolderFormFieldsApi {\n constructor(\n private readonly formFieldLoaders: Array<() => Promise<FormField>> = [],\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\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({\n factory: createApiFactory({\n api: formFieldsApiRef,\n deps: {},\n factory: () => new DefaultScaffolderFormFieldsApi(formFieldLoaders),\n }),\n });\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormFieldsApi.esm.js","sources":["../../../src/alpha/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 createApiFactory,\n createExtensionInput,\n} from '@backstage/frontend-plugin-api';\nimport { formFieldsApiRef } from './ref';\nimport { ScaffolderFormFieldsApi } from './types';\nimport { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';\nimport { FormField, OpaqueFormField } from '@internal/scaffolder';\n\nclass DefaultScaffolderFormFieldsApi implements ScaffolderFormFieldsApi {\n constructor(\n private readonly formFieldLoaders: Array<() => Promise<FormField>> = [],\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\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({\n factory: createApiFactory({\n api: formFieldsApiRef,\n deps: {},\n factory: () => new DefaultScaffolderFormFieldsApi(formFieldLoaders),\n }),\n });\n },\n});\n"],"names":[],"mappings":";;;;;;AA0BA,MAAM,8BAAkE,CAAA;AAAA,EACtE,WAAA,CACmB,gBAAoD,GAAA,EACrE,EAAA;AADiB,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AAAA;AAChB,EAEH,MAAM,aAAgB,GAAA;AACpB,IAAM,MAAA,UAAA,GAAa,MAAM,OAAQ,CAAA,GAAA;AAAA,MAC/B,IAAK,CAAA,gBAAA,CAAiB,GAAI,CAAA,CAAA,MAAA,KAAU,QAAQ;AAAA,KAC9C;AAEA,IAAA,MAAM,kBAAqB,GAAA,UAAA,CAAW,GAAI,CAAA,eAAA,CAAgB,UAAU,CAAA;AAEpE,IAAO,OAAA,kBAAA;AAAA;AAEX;AAEa,MAAA,aAAA,GAAgB,aAAa,iBAAkB,CAAA;AAAA,EAC1D,IAAM,EAAA,aAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,YAAY,oBAAqB,CAAA;AAAA,MAC/B,mBAAmB,QAAS,CAAA;AAAA,KAC7B;AAAA,GACH;AAAA,EACA,OAAQ,CAAA,eAAA,EAAiB,EAAE,MAAA,EAAU,EAAA;AACnC,IAAM,MAAA,gBAAA,GAAmB,OAAO,UAAW,CAAA,GAAA;AAAA,MAAI,CAC7C,CAAA,KAAA,CAAA,CAAE,GAAI,CAAA,kBAAA,CAAmB,SAAS,eAAe;AAAA,KACnD;AAEA,IAAA,OAAO,eAAgB,CAAA;AAAA,MACrB,SAAS,gBAAiB,CAAA;AAAA,QACxB,GAAK,EAAA,gBAAA;AAAA,QACL,MAAM,EAAC;AAAA,QACP,OAAS,EAAA,MAAM,IAAI,8BAAA,CAA+B,gBAAgB;AAAA,OACnE;AAAA,KACF,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -3,6 +3,9 @@ import { createApiRef } from '@backstage/frontend-plugin-api';
|
|
|
3
3
|
const formFieldsApiRef = createApiRef({
|
|
4
4
|
id: "plugin.scaffolder.form-fields"
|
|
5
5
|
});
|
|
6
|
+
const formDecoratorsApiRef = createApiRef({
|
|
7
|
+
id: "plugin.scaffolder.form-decorators"
|
|
8
|
+
});
|
|
6
9
|
|
|
7
|
-
export { formFieldsApiRef };
|
|
10
|
+
export { formDecoratorsApiRef, formFieldsApiRef };
|
|
8
11
|
//# sourceMappingURL=ref.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.esm.js","sources":["../../../src/alpha/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\nexport const formFieldsApiRef = createApiRef<ScaffolderFormFieldsApi>({\n id: 'plugin.scaffolder.form-fields',\n});\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ref.esm.js","sources":["../../../src/alpha/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, ScaffolderFormDecoratorsApi } from './types';\n\n/** @alpha */\nexport const formFieldsApiRef = createApiRef<ScaffolderFormFieldsApi>({\n id: 'plugin.scaffolder.form-fields',\n});\n\n/** @alpha */\nexport const formDecoratorsApiRef = createApiRef<ScaffolderFormDecoratorsApi>({\n id: 'plugin.scaffolder.form-decorators',\n});\n"],"names":[],"mappings":";;AAoBO,MAAM,mBAAmB,YAAsC,CAAA;AAAA,EACpE,EAAI,EAAA;AACN,CAAC;AAGM,MAAM,uBAAuB,YAA0C,CAAA;AAAA,EAC5E,EAAI,EAAA;AACN,CAAC;;;;"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { useNavigate, Navigate } from 'react-router-dom';
|
|
3
3
|
import useAsync from 'react-use/esm/useAsync';
|
|
4
4
|
import { stringifyEntityRef, ANNOTATION_EDIT_URL } from '@backstage/catalog-model';
|
|
5
5
|
import { useRouteRef, useApi, useRouteRefParams, AnalyticsContext } from '@backstage/core-plugin-api';
|
|
6
6
|
import { useTemplateSecrets, scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
|
|
7
7
|
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
8
|
-
import { Workflow } from '@backstage/plugin-scaffolder-react/alpha';
|
|
9
|
-
import { Page, Header } from '@backstage/core-components';
|
|
8
|
+
import { useTemplateParameterSchema, Workflow } from '@backstage/plugin-scaffolder-react/alpha';
|
|
9
|
+
import { Page, Header, Progress } from '@backstage/core-components';
|
|
10
10
|
import { rootRouteRef, scaffolderTaskRouteRef, selectedTemplateRouteRef } from '../../../routes.esm.js';
|
|
11
11
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
12
12
|
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
13
13
|
import { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu.esm.js';
|
|
14
|
+
import { useFormDecorators } from '../../hooks/useFormDecorators.esm.js';
|
|
14
15
|
|
|
15
16
|
const TemplateWizardPage = (props) => {
|
|
16
17
|
const rootRef = useRouteRef(rootRouteRef);
|
|
17
18
|
const taskRoute = useRouteRef(scaffolderTaskRouteRef);
|
|
18
|
-
const { secrets } = useTemplateSecrets();
|
|
19
|
+
const { secrets: contextSecrets } = useTemplateSecrets();
|
|
19
20
|
const scaffolderApi = useApi(scaffolderApiRef);
|
|
20
21
|
const catalogApi = useApi(catalogApiRef);
|
|
22
|
+
const [isCreating, setIsCreating] = useState(false);
|
|
21
23
|
const navigate = useNavigate();
|
|
22
24
|
const { templateName, namespace } = useRouteRefParams(
|
|
23
25
|
selectedTemplateRouteRef
|
|
@@ -28,11 +30,21 @@ const TemplateWizardPage = (props) => {
|
|
|
28
30
|
namespace,
|
|
29
31
|
name: templateName
|
|
30
32
|
});
|
|
33
|
+
const { manifest } = useTemplateParameterSchema(templateRef);
|
|
34
|
+
const decorators = useFormDecorators({ manifest });
|
|
31
35
|
const { value: editUrl } = useAsync(async () => {
|
|
32
36
|
const data = await catalogApi.getEntityByRef(templateRef);
|
|
33
37
|
return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];
|
|
34
38
|
}, [templateRef, catalogApi]);
|
|
35
|
-
const onCreate = async (
|
|
39
|
+
const onCreate = async (initialValues) => {
|
|
40
|
+
if (isCreating) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setIsCreating(true);
|
|
44
|
+
const { formState: values, secrets } = await decorators.run({
|
|
45
|
+
formState: initialValues,
|
|
46
|
+
secrets: contextSecrets
|
|
47
|
+
});
|
|
36
48
|
const { taskId } = await scaffolderApi.scaffold({
|
|
37
49
|
templateRef,
|
|
38
50
|
values,
|
|
@@ -50,7 +62,7 @@ const TemplateWizardPage = (props) => {
|
|
|
50
62
|
...props.headerOptions
|
|
51
63
|
},
|
|
52
64
|
/* @__PURE__ */ React.createElement(TemplateWizardPageContextMenu, { editUrl })
|
|
53
|
-
), /* @__PURE__ */ React.createElement(
|
|
65
|
+
), isCreating && /* @__PURE__ */ React.createElement(Progress, null), /* @__PURE__ */ React.createElement(
|
|
54
66
|
Workflow,
|
|
55
67
|
{
|
|
56
68
|
namespace,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateWizardPage.esm.js","sources":["../../../../src/alpha/components/TemplateWizardPage/TemplateWizardPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 React from 'react';\nimport { Navigate, useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n stringifyEntityRef,\n ANNOTATION_EDIT_URL,\n} from '@backstage/catalog-model';\nimport {\n AnalyticsContext,\n useApi,\n useRouteRef,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\nimport {\n scaffolderApiRef,\n useTemplateSecrets,\n type LayoutOptions,\n FormProps,\n FieldExtensionOptions,\n ReviewStepProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"TemplateWizardPage.esm.js","sources":["../../../../src/alpha/components/TemplateWizardPage/TemplateWizardPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 React, { useState } from 'react';\nimport { Navigate, useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n stringifyEntityRef,\n ANNOTATION_EDIT_URL,\n} from '@backstage/catalog-model';\nimport {\n AnalyticsContext,\n useApi,\n useRouteRef,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\nimport {\n scaffolderApiRef,\n useTemplateSecrets,\n type LayoutOptions,\n FormProps,\n FieldExtensionOptions,\n ReviewStepProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport {\n Workflow,\n useTemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react/alpha';\nimport { JsonValue } from '@backstage/types';\nimport { Header, Page, Progress } from '@backstage/core-components';\n\nimport {\n rootRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n} from '../../../routes';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nimport { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu';\nimport { useFormDecorators } from '../../hooks';\n\n/**\n * @alpha\n */\nexport type TemplateWizardPageProps = {\n customFieldExtensions: FieldExtensionOptions<any, any>[];\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nexport const TemplateWizardPage = (props: TemplateWizardPageProps) => {\n const rootRef = useRouteRef(rootRouteRef);\n const taskRoute = useRouteRef(scaffolderTaskRouteRef);\n const { secrets: contextSecrets } = useTemplateSecrets();\n const scaffolderApi = useApi(scaffolderApiRef);\n const catalogApi = useApi(catalogApiRef);\n const [isCreating, setIsCreating] = useState(false);\n const navigate = useNavigate();\n const { templateName, namespace } = useRouteRefParams(\n selectedTemplateRouteRef,\n );\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace,\n name: templateName,\n });\n\n const { manifest } = useTemplateParameterSchema(templateRef);\n const decorators = useFormDecorators({ manifest });\n\n const { value: editUrl } = useAsync(async () => {\n const data = await catalogApi.getEntityByRef(templateRef);\n return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];\n }, [templateRef, catalogApi]);\n\n const onCreate = async (initialValues: Record<string, JsonValue>) => {\n if (isCreating) {\n return;\n }\n\n setIsCreating(true);\n\n const { formState: values, secrets } = await decorators.run({\n formState: initialValues,\n secrets: contextSecrets,\n });\n\n const { taskId } = await scaffolderApi.scaffold({\n templateRef,\n values,\n secrets,\n });\n\n navigate(taskRoute({ taskId }));\n };\n\n const onError = () => <Navigate to={rootRef()} />;\n\n return (\n <AnalyticsContext attributes={{ entityRef: templateRef }}>\n <Page themeId=\"website\">\n <Header\n pageTitleOverride={t('templateWizardPage.pageTitle')}\n title={t('templateWizardPage.title')}\n subtitle={t('templateWizardPage.subtitle')}\n {...props.headerOptions}\n >\n <TemplateWizardPageContextMenu editUrl={editUrl} />\n </Header>\n {isCreating && <Progress />}\n <Workflow\n namespace={namespace}\n templateName={templateName}\n onCreate={onCreate}\n components={props.components}\n onError={onError}\n extensions={props.customFieldExtensions}\n formProps={props.formProps}\n layouts={props.layouts}\n />\n </Page>\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAyEa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA,OAAA,GAAU,YAAY,YAAY,CAAA;AACxC,EAAM,MAAA,SAAA,GAAY,YAAY,sBAAsB,CAAA;AACpD,EAAA,MAAM,EAAE,OAAA,EAAS,cAAe,EAAA,GAAI,kBAAmB,EAAA;AACvD,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA;AAC7C,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AACvC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,KAAK,CAAA;AAClD,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAM,MAAA,EAAE,YAAc,EAAA,SAAA,EAAc,GAAA,iBAAA;AAAA,IAClC;AAAA,GACF;AACA,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,cAAc,kBAAmB,CAAA;AAAA,IACrC,IAAM,EAAA,UAAA;AAAA,IACN,SAAA;AAAA,IACA,IAAM,EAAA;AAAA,GACP,CAAA;AAED,EAAA,MAAM,EAAE,QAAA,EAAa,GAAA,0BAAA,CAA2B,WAAW,CAAA;AAC3D,EAAA,MAAM,UAAa,GAAA,iBAAA,CAAkB,EAAE,QAAA,EAAU,CAAA;AAEjD,EAAA,MAAM,EAAE,KAAA,EAAO,OAAQ,EAAA,GAAI,SAAS,YAAY;AAC9C,IAAA,MAAM,IAAO,GAAA,MAAM,UAAW,CAAA,cAAA,CAAe,WAAW,CAAA;AACxD,IAAO,OAAA,IAAA,EAAM,QAAS,CAAA,WAAA,GAAc,mBAAmB,CAAA;AAAA,GACtD,EAAA,CAAC,WAA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AAAA,MACC,SAAA;AAAA,MACA,YAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAY,KAAM,CAAA,UAAA;AAAA,MAClB,OAAA;AAAA,MACA,YAAY,KAAM,CAAA,qBAAA;AAAA,MAClB,WAAW,KAAM,CAAA,SAAA;AAAA,MACjB,SAAS,KAAM,CAAA;AAAA;AAAA,GAEnB,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { convertLegacyRouteRef, compatWrapper } from '@backstage/core-compat-api';
|
|
2
|
-
import { PageBlueprint, NavItemBlueprint } from '@backstage/frontend-plugin-api';
|
|
2
|
+
import { PageBlueprint, NavItemBlueprint, ApiBlueprint, createApiFactory, discoveryApiRef, fetchApiRef, identityApiRef } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { rootRouteRef } from '../routes.esm.js';
|
|
5
5
|
import CreateComponentIcon from '@material-ui/icons/AddCircleOutline';
|
|
6
6
|
import { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';
|
|
7
|
+
import { scmIntegrationsApiRef } from '@backstage/integration-react';
|
|
8
|
+
import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
|
|
9
|
+
import { ScaffolderClient } from '../api.esm.js';
|
|
7
10
|
|
|
8
11
|
const scaffolderPage = PageBlueprint.make({
|
|
9
12
|
params: {
|
|
@@ -25,6 +28,25 @@ const repoUrlPickerFormField = FormFieldBlueprint.make({
|
|
|
25
28
|
field: () => import('./fields/RepoUrlPicker.esm.js').then((m) => m.RepoUrlPicker)
|
|
26
29
|
}
|
|
27
30
|
});
|
|
31
|
+
const scaffolderApi = ApiBlueprint.make({
|
|
32
|
+
params: {
|
|
33
|
+
factory: createApiFactory({
|
|
34
|
+
api: scaffolderApiRef,
|
|
35
|
+
deps: {
|
|
36
|
+
discoveryApi: discoveryApiRef,
|
|
37
|
+
scmIntegrationsApi: scmIntegrationsApiRef,
|
|
38
|
+
fetchApi: fetchApiRef,
|
|
39
|
+
identityApi: identityApiRef
|
|
40
|
+
},
|
|
41
|
+
factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) => new ScaffolderClient({
|
|
42
|
+
discoveryApi,
|
|
43
|
+
scmIntegrationsApi,
|
|
44
|
+
fetchApi,
|
|
45
|
+
identityApi
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
});
|
|
28
50
|
|
|
29
|
-
export { repoUrlPickerFormField, scaffolderNavItem, scaffolderPage };
|
|
51
|
+
export { repoUrlPickerFormField, scaffolderApi, scaffolderNavItem, scaffolderPage };
|
|
30
52
|
//# sourceMappingURL=extensions.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.esm.js","sources":["../../src/alpha/extensions.tsx"],"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 */\n\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n NavItemBlueprint,\n PageBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport React from 'react';\nimport { rootRouteRef } from '../routes';\nimport CreateComponentIcon from '@material-ui/icons/AddCircleOutline';\nimport { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';\n\nexport const scaffolderPage = PageBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n defaultPath: '/create',\n loader: () =>\n import('../components/Router').then(m => compatWrapper(<m.Router />)),\n },\n});\n\nexport const scaffolderNavItem = NavItemBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n title: 'Create...',\n icon: CreateComponentIcon,\n },\n});\n\nexport const repoUrlPickerFormField = FormFieldBlueprint.make({\n name: 'repo-url-picker',\n params: {\n field: () => import('./fields/RepoUrlPicker').then(m => m.RepoUrlPicker),\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extensions.esm.js","sources":["../../src/alpha/extensions.tsx"],"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 */\n\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n NavItemBlueprint,\n PageBlueprint,\n ApiBlueprint,\n createApiFactory,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n} from '@backstage/frontend-plugin-api';\nimport React from 'react';\nimport { rootRouteRef } from '../routes';\nimport CreateComponentIcon from '@material-ui/icons/AddCircleOutline';\nimport { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport { ScaffolderClient } from '../api';\n\nexport const scaffolderPage = PageBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n defaultPath: '/create',\n loader: () =>\n import('../components/Router').then(m => compatWrapper(<m.Router />)),\n },\n});\n\nexport const scaffolderNavItem = NavItemBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n title: 'Create...',\n icon: CreateComponentIcon,\n },\n});\n\nexport const repoUrlPickerFormField = FormFieldBlueprint.make({\n name: 'repo-url-picker',\n params: {\n field: () => import('./fields/RepoUrlPicker').then(m => m.RepoUrlPicker),\n },\n});\n\nexport const scaffolderApi = ApiBlueprint.make({\n params: {\n factory: createApiFactory({\n api: scaffolderApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n fetchApi: fetchApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) =>\n new ScaffolderClient({\n discoveryApi,\n scmIntegrationsApi,\n fetchApi,\n identityApi,\n }),\n }),\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;AAqCa,MAAA,cAAA,GAAiB,cAAc,IAAK,CAAA;AAAA,EAC/C,MAAQ,EAAA;AAAA,IACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,WAAa,EAAA,SAAA;AAAA,IACb,MAAQ,EAAA,MACN,OAAO,mCAAsB,CAAE,CAAA,IAAA,CAAK,CAAK,CAAA,KAAA,aAAA,iBAAe,KAAA,CAAA,aAAA,CAAA,CAAA,CAAE,MAAF,EAAA,IAAS,CAAE,CAAC;AAAA;AAE1E,CAAC;AAEY,MAAA,iBAAA,GAAoB,iBAAiB,IAAK,CAAA;AAAA,EACrD,MAAQ,EAAA;AAAA,IACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,KAAO,EAAA,WAAA;AAAA,IACP,IAAM,EAAA;AAAA;AAEV,CAAC;AAEY,MAAA,sBAAA,GAAyB,mBAAmB,IAAK,CAAA;AAAA,EAC5D,IAAM,EAAA,iBAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,MAAM,OAAO,+BAAwB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa;AAAA;AAE3E,CAAC;AAEY,MAAA,aAAA,GAAgB,aAAa,IAAK,CAAA;AAAA,EAC7C,MAAQ,EAAA;AAAA,IACN,SAAS,gBAAiB,CAAA;AAAA,MACxB,GAAK,EAAA,gBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,kBAAoB,EAAA,qBAAA;AAAA,QACpB,QAAU,EAAA,WAAA;AAAA,QACV,WAAa,EAAA;AAAA,OACf;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,oBAAoB,QAAU,EAAA,WAAA,EACtD,KAAA,IAAI,gBAAiB,CAAA;AAAA,QACnB,YAAA;AAAA,QACA,kBAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD;AAAA,KACJ;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useApi, errorApiRef, useApiHolder } from '@backstage/core-plugin-api';
|
|
2
|
+
import { formDecoratorsApiRef } from '../api/ref.esm.js';
|
|
3
|
+
import useAsync from 'react-use/esm/useAsync';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { OpaqueFormDecorator } from '../../packages/scaffolder-internal/src/wiring/InternalFormDecorator.esm.js';
|
|
6
|
+
import '../../packages/scaffolder-internal/src/wiring/InternalFormField.esm.js';
|
|
7
|
+
|
|
8
|
+
const useFormDecorators = ({
|
|
9
|
+
manifest
|
|
10
|
+
}) => {
|
|
11
|
+
const formDecoratorsApi = useApi(formDecoratorsApiRef);
|
|
12
|
+
const errorApi = useApi(errorApiRef);
|
|
13
|
+
const { value: decorators } = useAsync(
|
|
14
|
+
() => formDecoratorsApi.getFormDecorators(),
|
|
15
|
+
[]
|
|
16
|
+
);
|
|
17
|
+
const apiHolder = useApiHolder();
|
|
18
|
+
const boundDecorators = useMemo(() => {
|
|
19
|
+
const decoratorsMap = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const decorator of decorators ?? []) {
|
|
21
|
+
try {
|
|
22
|
+
const { decorator: decoratorFn, deps } = OpaqueFormDecorator.toInternal(decorator);
|
|
23
|
+
const resolvedDeps = Object.entries(deps ?? {}).map(([key, value]) => {
|
|
24
|
+
const api = apiHolder.get(value);
|
|
25
|
+
if (!api) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Failed to resolve apiRef ${value.id} for form decorator ${decorator.id} it will be disabled`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return [key, api];
|
|
31
|
+
});
|
|
32
|
+
decoratorsMap.set(decorator.id, {
|
|
33
|
+
decorator: (ctx) => decoratorFn(ctx, Object.fromEntries(resolvedDeps))
|
|
34
|
+
});
|
|
35
|
+
} catch (ex) {
|
|
36
|
+
errorApi.post(ex);
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return decoratorsMap;
|
|
41
|
+
}, [apiHolder, decorators, errorApi]);
|
|
42
|
+
return {
|
|
43
|
+
run: async (opts) => {
|
|
44
|
+
let formState = { ...opts.formState };
|
|
45
|
+
let secrets = {};
|
|
46
|
+
if (manifest?.EXPERIMENTAL_formDecorators) {
|
|
47
|
+
await Promise.all(
|
|
48
|
+
manifest.EXPERIMENTAL_formDecorators.map(async (decorator) => {
|
|
49
|
+
const formDecorator = boundDecorators?.get(decorator.id);
|
|
50
|
+
if (!formDecorator) {
|
|
51
|
+
errorApi.post(
|
|
52
|
+
new Error(`Failed to find form decorator ${decorator.id}`)
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
await formDecorator.decorator({
|
|
57
|
+
setSecrets: (handler) => {
|
|
58
|
+
secrets = { ...handler(secrets) };
|
|
59
|
+
},
|
|
60
|
+
setFormState: (handler) => {
|
|
61
|
+
formState = { ...handler(formState) };
|
|
62
|
+
},
|
|
63
|
+
formState,
|
|
64
|
+
input: decorator.input ?? {}
|
|
65
|
+
});
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return { formState, secrets };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { useFormDecorators };
|
|
75
|
+
//# sourceMappingURL=useFormDecorators.esm.js.map
|
|
@@ -0,0 +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 );\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,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A;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/dist/alpha/plugin.esm.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { convertLegacyRouteRefs } from '@backstage/core-compat-api';
|
|
2
2
|
import { createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { rootRouteRef, selectedTemplateRouteRef, scaffolderTaskRouteRef, actionsRouteRef, scaffolderListTaskRouteRef, editRouteRef, registerComponentRouteRef, viewTechDocRouteRef } from '../routes.esm.js';
|
|
4
|
-
import { scaffolderApi } from './
|
|
5
|
-
import { scaffolderPage, scaffolderNavItem, repoUrlPickerFormField } from './extensions.esm.js';
|
|
4
|
+
import { scaffolderApi, scaffolderPage, scaffolderNavItem, repoUrlPickerFormField } from './extensions.esm.js';
|
|
6
5
|
import { formFieldsApi } from './api/FormFieldsApi.esm.js';
|
|
7
6
|
|
|
8
7
|
var plugin = createFrontendPlugin({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../../src/alpha/plugin.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 */\n\nimport { convertLegacyRouteRefs } from '@backstage/core-compat-api';\nimport { createFrontendPlugin } from '@backstage/frontend-plugin-api';\nimport {\n rootRouteRef,\n actionsRouteRef,\n editRouteRef,\n registerComponentRouteRef,\n scaffolderListTaskRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n viewTechDocRouteRef,\n} from '../routes';\nimport {
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../../src/alpha/plugin.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 */\n\nimport { convertLegacyRouteRefs } from '@backstage/core-compat-api';\nimport { createFrontendPlugin } from '@backstage/frontend-plugin-api';\nimport {\n rootRouteRef,\n actionsRouteRef,\n editRouteRef,\n registerComponentRouteRef,\n scaffolderListTaskRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n viewTechDocRouteRef,\n} from '../routes';\nimport {\n repoUrlPickerFormField,\n scaffolderNavItem,\n scaffolderPage,\n scaffolderApi,\n} from './extensions';\nimport { formFieldsApi } from './api/FormFieldsApi';\n\n/** @alpha */\nexport default createFrontendPlugin({\n id: 'scaffolder',\n routes: convertLegacyRouteRefs({\n root: rootRouteRef,\n selectedTemplate: selectedTemplateRouteRef,\n ongoingTask: scaffolderTaskRouteRef,\n actions: actionsRouteRef,\n listTasks: scaffolderListTaskRouteRef,\n edit: editRouteRef,\n }),\n externalRoutes: convertLegacyRouteRefs({\n registerComponent: registerComponentRouteRef,\n viewTechDoc: viewTechDocRouteRef,\n }),\n extensions: [\n scaffolderApi,\n scaffolderPage,\n scaffolderNavItem,\n formFieldsApi,\n repoUrlPickerFormField,\n ],\n});\n"],"names":[],"mappings":";;;;;;AAqCA,aAAe,oBAAqB,CAAA;AAAA,EAClC,EAAI,EAAA,YAAA;AAAA,EACJ,QAAQ,sBAAuB,CAAA;AAAA,IAC7B,IAAM,EAAA,YAAA;AAAA,IACN,gBAAkB,EAAA,wBAAA;AAAA,IAClB,WAAa,EAAA,sBAAA;AAAA,IACb,OAAS,EAAA,eAAA;AAAA,IACT,SAAW,EAAA,0BAAA;AAAA,IACX,IAAM,EAAA;AAAA,GACP,CAAA;AAAA,EACD,gBAAgB,sBAAuB,CAAA;AAAA,IACrC,iBAAmB,EAAA,yBAAA;AAAA,IACnB,WAAa,EAAA;AAAA,GACd,CAAA;AAAA,EACD,UAAY,EAAA;AAAA,IACV,aAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA;AAEJ,CAAC,CAAA;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
|
|
|
5
5
|
import { TemplateGroupFilter, FieldExtensionOptions, ReviewStepProps, LayoutOptions, FormProps as FormProps$1 } from '@backstage/plugin-scaffolder-react';
|
|
6
6
|
import { FormProps as FormProps$2 } from '@rjsf/core';
|
|
7
7
|
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
|
|
8
|
-
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
9
8
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
9
|
+
import { FormFieldExtensionData, ScaffolderFormDecorator } from '@backstage/plugin-scaffolder-react/alpha';
|
|
10
|
+
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
10
11
|
|
|
11
12
|
/** @public */
|
|
12
13
|
type ScaffolderCustomFieldExplorerClassKey = 'root' | 'controls' | 'fieldForm' | 'preview';
|
|
@@ -224,6 +225,30 @@ declare const scaffolderTranslationRef: _backstage_core_plugin_api_alpha.Transla
|
|
|
224
225
|
readonly "templateEditorToolbarTemplatesMenu.button": "Templates";
|
|
225
226
|
}>;
|
|
226
227
|
|
|
228
|
+
/** @alpha */
|
|
229
|
+
interface ScaffolderFormFieldsApi {
|
|
230
|
+
getFormFields(): Promise<FormFieldExtensionData[]>;
|
|
231
|
+
}
|
|
232
|
+
/** @alpha */
|
|
233
|
+
interface ScaffolderFormDecoratorsApi {
|
|
234
|
+
getFormDecorators(): Promise<ScaffolderFormDecorator[]>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** @alpha */
|
|
238
|
+
declare const formFieldsApiRef: _backstage_frontend_plugin_api.ApiRef<ScaffolderFormFieldsApi>;
|
|
239
|
+
/** @alpha */
|
|
240
|
+
declare const formDecoratorsApiRef: _backstage_frontend_plugin_api.ApiRef<ScaffolderFormDecoratorsApi>;
|
|
241
|
+
|
|
242
|
+
/** @alpha */
|
|
243
|
+
declare class DefaultScaffolderFormDecoratorsApi implements ScaffolderFormDecoratorsApi {
|
|
244
|
+
private readonly options;
|
|
245
|
+
private constructor();
|
|
246
|
+
static create(options?: {
|
|
247
|
+
decorators: ScaffolderFormDecorator[];
|
|
248
|
+
}): DefaultScaffolderFormDecoratorsApi;
|
|
249
|
+
getFormDecorators(): Promise<ScaffolderFormDecorator[]>;
|
|
250
|
+
}
|
|
251
|
+
|
|
227
252
|
/*
|
|
228
253
|
* Copyright 2024 The Backstage Authors
|
|
229
254
|
*
|
|
@@ -263,17 +288,6 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
|
|
|
263
288
|
namespace: string;
|
|
264
289
|
}>;
|
|
265
290
|
}, {
|
|
266
|
-
"api:scaffolder": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
267
|
-
kind: "api";
|
|
268
|
-
name: undefined;
|
|
269
|
-
config: {};
|
|
270
|
-
configInput: {};
|
|
271
|
-
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_frontend_plugin_api.AnyApiFactory, "core.api.factory", {}>;
|
|
272
|
-
inputs: {};
|
|
273
|
-
params: {
|
|
274
|
-
factory: _backstage_frontend_plugin_api.AnyApiFactory;
|
|
275
|
-
};
|
|
276
|
-
}>;
|
|
277
291
|
"page:scaffolder": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
278
292
|
kind: "page";
|
|
279
293
|
name: undefined;
|
|
@@ -321,6 +335,17 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
|
|
|
321
335
|
field: () => Promise<FormField>;
|
|
322
336
|
};
|
|
323
337
|
}>;
|
|
338
|
+
"api:scaffolder": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
339
|
+
kind: "api";
|
|
340
|
+
name: undefined;
|
|
341
|
+
config: {};
|
|
342
|
+
configInput: {};
|
|
343
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_frontend_plugin_api.AnyApiFactory, "core.api.factory", {}>;
|
|
344
|
+
inputs: {};
|
|
345
|
+
params: {
|
|
346
|
+
factory: _backstage_frontend_plugin_api.AnyApiFactory;
|
|
347
|
+
};
|
|
348
|
+
}>;
|
|
324
349
|
"api:scaffolder/form-fields": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
325
350
|
config: {};
|
|
326
351
|
configInput: {};
|
|
@@ -339,4 +364,4 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
|
|
|
339
364
|
}>;
|
|
340
365
|
}>;
|
|
341
366
|
|
|
342
|
-
export { type FormProps, type ScaffolderCustomFieldExplorerClassKey, type ScaffolderTemplateEditorClassKey, type ScaffolderTemplateFormPreviewerClassKey, type TemplateListPageProps, type TemplateWizardPageProps, _default as default, scaffolderTranslationRef };
|
|
367
|
+
export { DefaultScaffolderFormDecoratorsApi, type FormProps, type ScaffolderCustomFieldExplorerClassKey, type ScaffolderFormDecoratorsApi, type ScaffolderFormFieldsApi, type ScaffolderTemplateEditorClassKey, type ScaffolderTemplateFormPreviewerClassKey, type TemplateListPageProps, type TemplateWizardPageProps, _default as default, formDecoratorsApiRef, formFieldsApiRef, scaffolderTranslationRef };
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { scaffolderTranslationRef } from './translation.esm.js';
|
|
2
|
+
export { formDecoratorsApiRef, formFieldsApiRef } from './alpha/api/ref.esm.js';
|
|
3
|
+
export { DefaultScaffolderFormDecoratorsApi } from './alpha/api/FormDecoratorsApi.esm.js';
|
|
2
4
|
export { default } from './alpha/plugin.esm.js';
|
|
3
5
|
//# sourceMappingURL=alpha.esm.js.map
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/api.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseEntityRef } from '@backstage/catalog-model';
|
|
2
2
|
import { ResponseError } from '@backstage/errors';
|
|
3
|
+
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
3
4
|
import qs from 'qs';
|
|
4
5
|
import ObservableImpl from 'zen-observable';
|
|
5
|
-
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
6
6
|
|
|
7
7
|
class ScaffolderClient {
|
|
8
8
|
discoveryApi;
|
package/dist/api.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { parseEntityRef } from '@backstage/catalog-model';\nimport {\n DiscoveryApi,\n FetchApi,\n IdentityApi,\n} from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Observable } from '@backstage/types';\nimport qs from 'qs';\nimport queryString from 'qs';\nimport ObservableImpl from 'zen-observable';\nimport {\n ListActionsResponse,\n LogEvent,\n ScaffolderApi,\n ScaffolderDryRunOptions,\n ScaffolderDryRunResponse,\n ScaffolderGetIntegrationsListOptions,\n ScaffolderGetIntegrationsListResponse,\n ScaffolderScaffoldOptions,\n ScaffolderScaffoldResponse,\n ScaffolderStreamLogsOptions,\n ScaffolderTask,\n TemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react';\nimport {\n EventSourceMessage,\n fetchEventSource,\n} from '@microsoft/fetch-event-source';\n\n/**\n * An API to interact with the scaffolder backend.\n *\n * @public\n */\nexport class ScaffolderClient implements ScaffolderApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly fetchApi: FetchApi;\n private readonly identityApi?: IdentityApi;\n private readonly useLongPollingLogs: boolean;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n identityApi?: IdentityApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n useLongPollingLogs?: boolean;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi ?? { fetch };\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.useLongPollingLogs = options.useLongPollingLogs ?? false;\n this.identityApi = options.identityApi;\n }\n\n async listTasks(options: {\n filterByOwnership: 'owned' | 'all';\n limit?: number;\n offset?: number;\n }): Promise<{ tasks: ScaffolderTask[]; totalTasks?: number }> {\n if (!this.identityApi) {\n throw new Error(\n 'IdentityApi is not available in the ScaffolderClient, please pass through the IdentityApi to the ScaffolderClient constructor in order to use the listTasks method',\n );\n }\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const { userEntityRef } = await this.identityApi.getBackstageIdentity();\n\n const query = queryString.stringify({\n createdBy:\n options.filterByOwnership === 'owned' ? userEntityRef : undefined,\n limit: options.limit,\n offset: options.offset,\n });\n\n const response = await this.fetchApi.fetch(`${baseUrl}/v2/tasks?${query}`);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async getIntegrationsList(\n options: ScaffolderGetIntegrationsListOptions,\n ): Promise<ScaffolderGetIntegrationsListResponse> {\n const integrations = [\n ...this.scmIntegrationsApi.azure.list(),\n ...this.scmIntegrationsApi.bitbucket\n .list()\n .filter(\n item =>\n !this.scmIntegrationsApi.bitbucketCloud.byHost(item.config.host) &&\n !this.scmIntegrationsApi.bitbucketServer.byHost(item.config.host),\n ),\n ...this.scmIntegrationsApi.bitbucketCloud.list(),\n ...this.scmIntegrationsApi.bitbucketServer.list(),\n ...this.scmIntegrationsApi.gerrit.list(),\n ...this.scmIntegrationsApi.gitea.list(),\n ...this.scmIntegrationsApi.github.list(),\n ...this.scmIntegrationsApi.gitlab.list(),\n ]\n .map(c => ({ type: c.type, title: c.title, host: c.config.host }))\n .filter(c => options.allowedHosts.includes(c.host));\n\n return {\n integrations,\n };\n }\n\n async getTemplateParameterSchema(\n templateRef: string,\n ): Promise<TemplateParameterSchema> {\n const { namespace, kind, name } = parseEntityRef(templateRef, {\n defaultKind: 'template',\n });\n\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const templatePath = [namespace, kind, name]\n .map(s => encodeURIComponent(s))\n .join('/');\n\n const url = `${baseUrl}/v2/templates/${templatePath}/parameter-schema`;\n\n const response = await this.fetchApi.fetch(url);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const schema: TemplateParameterSchema = await response.json();\n return schema;\n }\n\n async scaffold(\n options: ScaffolderScaffoldOptions,\n ): Promise<ScaffolderScaffoldResponse> {\n const { templateRef, values, secrets = {} } = options;\n const url = `${await this.discoveryApi.getBaseUrl('scaffolder')}/v2/tasks`;\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n templateRef,\n values: { ...values },\n secrets,\n }),\n });\n\n if (response.status !== 201) {\n const status = `${response.status} ${response.statusText}`;\n const body = await response.text();\n throw new Error(`Backend request failed, ${status} ${body.trim()}`);\n }\n\n const { id } = (await response.json()) as { id: string };\n return { taskId: id };\n }\n\n async getTask(taskId: string): Promise<ScaffolderTask> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}`;\n\n const response = await this.fetchApi.fetch(url);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent> {\n if (this.useLongPollingLogs) {\n return this.streamLogsPolling(options);\n }\n\n return this.streamLogsEventStream(options);\n }\n\n async dryRun(\n options: ScaffolderDryRunOptions,\n ): Promise<ScaffolderDryRunResponse> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const response = await this.fetchApi.fetch(`${baseUrl}/v2/dry-run`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n template: options.template,\n values: options.values,\n secrets: options.secrets,\n directoryContents: options.directoryContents,\n }),\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return response.json();\n }\n\n private streamLogsEventStream({\n isTaskRecoverable,\n taskId,\n after,\n }: ScaffolderStreamLogsOptions): Observable<LogEvent> {\n return new ObservableImpl(subscriber => {\n const params = new URLSearchParams();\n if (after !== undefined) {\n params.set('after', String(Number(after)));\n }\n\n this.discoveryApi.getBaseUrl('scaffolder').then(\n baseUrl => {\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(\n taskId,\n )}/eventstream`;\n\n const processEvent = (event: any) => {\n if (event.data) {\n try {\n subscriber.next(JSON.parse(event.data));\n } catch (ex) {\n subscriber.error(ex);\n }\n }\n };\n\n const ctrl = new AbortController();\n void fetchEventSource(url, {\n fetch: this.fetchApi.fetch,\n signal: ctrl.signal,\n onmessage(e: EventSourceMessage) {\n if (e.event === 'log') {\n processEvent(e);\n return;\n } else if (e.event === 'completion' && !isTaskRecoverable) {\n processEvent(e);\n subscriber.complete();\n ctrl.abort();\n return;\n }\n processEvent(e);\n },\n onerror(err) {\n subscriber.error(err);\n },\n });\n },\n error => {\n subscriber.error(error);\n },\n );\n });\n }\n\n private streamLogsPolling({\n taskId,\n after: inputAfter,\n }: {\n taskId: string;\n after?: number;\n }): Observable<LogEvent> {\n let after = inputAfter;\n\n return new ObservableImpl(subscriber => {\n this.discoveryApi.getBaseUrl('scaffolder').then(async baseUrl => {\n while (!subscriber.closed) {\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(\n taskId,\n )}/events?${qs.stringify({ after })}`;\n const response = await this.fetchApi.fetch(url);\n\n if (!response.ok) {\n // wait for one second to not run into an\n await new Promise(resolve => setTimeout(resolve, 1000));\n continue;\n }\n\n const logs = (await response.json()) as LogEvent[];\n\n for (const event of logs) {\n after = Number(event.id);\n\n subscriber.next(event);\n\n if (event.type === 'completion') {\n subscriber.complete();\n return;\n }\n }\n }\n });\n });\n }\n\n async listActions(): Promise<ListActionsResponse> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const response = await this.fetchApi.fetch(`${baseUrl}/v2/actions`);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async cancelTask(taskId: string): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}/cancel`;\n\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async retry?(taskId: string): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}/retry`;\n\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async autocomplete({\n token,\n resource,\n provider,\n context,\n }: {\n token: string;\n provider: string;\n resource: string;\n context?: Record<string, string>;\n }): Promise<{ results: { title: string }[] }> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n\n const url = `${baseUrl}/v2/autocomplete/${provider}/${resource}`;\n\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n token,\n context: context ?? {},\n }),\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const { results } = await response.json();\n return { results };\n }\n}\n"],"names":["queryString"],"mappings":";;;;;;AAoDO,MAAM,gBAA0C,CAAA;AAAA,EACpC,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EAEjB,YAAY,OAMT,EAAA;AACD,IAAA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A,QACnB,KAAA;AAAA,QACA,OAAA,EAAS,WAAW;AAAC,OACtB;AAAA,KACF,CAAA;AAED,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,MAAM,aAAc,CAAA,YAAA,CAAa,QAAQ,CAAA;AAAA;AAGjD,IAAA,MAAM,EAAE,OAAA,EAAY,GAAA,MAAM,SAAS,IAAK,EAAA;AACxC,IAAA,OAAO,EAAE,OAAQ,EAAA;AAAA;AAErB;;;;"}
|
|
1
|
+
{"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { parseEntityRef } from '@backstage/catalog-model';\nimport {\n DiscoveryApi,\n FetchApi,\n IdentityApi,\n} from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n ListActionsResponse,\n LogEvent,\n ScaffolderApi,\n ScaffolderDryRunOptions,\n ScaffolderDryRunResponse,\n ScaffolderGetIntegrationsListOptions,\n ScaffolderGetIntegrationsListResponse,\n ScaffolderScaffoldOptions,\n ScaffolderScaffoldResponse,\n ScaffolderStreamLogsOptions,\n ScaffolderTask,\n TemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react';\nimport { Observable } from '@backstage/types';\nimport {\n EventSourceMessage,\n fetchEventSource,\n} from '@microsoft/fetch-event-source';\nimport { default as qs, default as queryString } from 'qs';\nimport ObservableImpl from 'zen-observable';\n\n/**\n * An API to interact with the scaffolder backend.\n *\n * @public\n */\nexport class ScaffolderClient implements ScaffolderApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly fetchApi: FetchApi;\n private readonly identityApi?: IdentityApi;\n private readonly useLongPollingLogs: boolean;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n identityApi?: IdentityApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n useLongPollingLogs?: boolean;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi ?? { fetch };\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.useLongPollingLogs = options.useLongPollingLogs ?? false;\n this.identityApi = options.identityApi;\n }\n\n async listTasks(options: {\n filterByOwnership: 'owned' | 'all';\n limit?: number;\n offset?: number;\n }): Promise<{ tasks: ScaffolderTask[]; totalTasks?: number }> {\n if (!this.identityApi) {\n throw new Error(\n 'IdentityApi is not available in the ScaffolderClient, please pass through the IdentityApi to the ScaffolderClient constructor in order to use the listTasks method',\n );\n }\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const { userEntityRef } = await this.identityApi.getBackstageIdentity();\n\n const query = queryString.stringify({\n createdBy:\n options.filterByOwnership === 'owned' ? userEntityRef : undefined,\n limit: options.limit,\n offset: options.offset,\n });\n\n const response = await this.fetchApi.fetch(`${baseUrl}/v2/tasks?${query}`);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async getIntegrationsList(\n options: ScaffolderGetIntegrationsListOptions,\n ): Promise<ScaffolderGetIntegrationsListResponse> {\n const integrations = [\n ...this.scmIntegrationsApi.azure.list(),\n ...this.scmIntegrationsApi.bitbucket\n .list()\n .filter(\n item =>\n !this.scmIntegrationsApi.bitbucketCloud.byHost(item.config.host) &&\n !this.scmIntegrationsApi.bitbucketServer.byHost(item.config.host),\n ),\n ...this.scmIntegrationsApi.bitbucketCloud.list(),\n ...this.scmIntegrationsApi.bitbucketServer.list(),\n ...this.scmIntegrationsApi.gerrit.list(),\n ...this.scmIntegrationsApi.gitea.list(),\n ...this.scmIntegrationsApi.github.list(),\n ...this.scmIntegrationsApi.gitlab.list(),\n ]\n .map(c => ({ type: c.type, title: c.title, host: c.config.host }))\n .filter(c => options.allowedHosts.includes(c.host));\n\n return {\n integrations,\n };\n }\n\n async getTemplateParameterSchema(\n templateRef: string,\n ): Promise<TemplateParameterSchema> {\n const { namespace, kind, name } = parseEntityRef(templateRef, {\n defaultKind: 'template',\n });\n\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const templatePath = [namespace, kind, name]\n .map(s => encodeURIComponent(s))\n .join('/');\n\n const url = `${baseUrl}/v2/templates/${templatePath}/parameter-schema`;\n\n const response = await this.fetchApi.fetch(url);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const schema: TemplateParameterSchema = await response.json();\n return schema;\n }\n\n async scaffold(\n options: ScaffolderScaffoldOptions,\n ): Promise<ScaffolderScaffoldResponse> {\n const { templateRef, values, secrets = {} } = options;\n const url = `${await this.discoveryApi.getBaseUrl('scaffolder')}/v2/tasks`;\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n templateRef,\n values: { ...values },\n secrets,\n }),\n });\n\n if (response.status !== 201) {\n const status = `${response.status} ${response.statusText}`;\n const body = await response.text();\n throw new Error(`Backend request failed, ${status} ${body.trim()}`);\n }\n\n const { id } = (await response.json()) as { id: string };\n return { taskId: id };\n }\n\n async getTask(taskId: string): Promise<ScaffolderTask> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}`;\n\n const response = await this.fetchApi.fetch(url);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n streamLogs(options: ScaffolderStreamLogsOptions): Observable<LogEvent> {\n if (this.useLongPollingLogs) {\n return this.streamLogsPolling(options);\n }\n\n return this.streamLogsEventStream(options);\n }\n\n async dryRun(\n options: ScaffolderDryRunOptions,\n ): Promise<ScaffolderDryRunResponse> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const response = await this.fetchApi.fetch(`${baseUrl}/v2/dry-run`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n template: options.template,\n values: options.values,\n secrets: options.secrets,\n directoryContents: options.directoryContents,\n }),\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return response.json();\n }\n\n private streamLogsEventStream({\n isTaskRecoverable,\n taskId,\n after,\n }: ScaffolderStreamLogsOptions): Observable<LogEvent> {\n return new ObservableImpl(subscriber => {\n const params = new URLSearchParams();\n if (after !== undefined) {\n params.set('after', String(Number(after)));\n }\n\n this.discoveryApi.getBaseUrl('scaffolder').then(\n baseUrl => {\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(\n taskId,\n )}/eventstream`;\n\n const processEvent = (event: any) => {\n if (event.data) {\n try {\n subscriber.next(JSON.parse(event.data));\n } catch (ex) {\n subscriber.error(ex);\n }\n }\n };\n\n const ctrl = new AbortController();\n void fetchEventSource(url, {\n fetch: this.fetchApi.fetch,\n signal: ctrl.signal,\n onmessage(e: EventSourceMessage) {\n if (e.event === 'log') {\n processEvent(e);\n return;\n } else if (e.event === 'completion' && !isTaskRecoverable) {\n processEvent(e);\n subscriber.complete();\n ctrl.abort();\n return;\n }\n processEvent(e);\n },\n onerror(err) {\n subscriber.error(err);\n },\n });\n },\n error => {\n subscriber.error(error);\n },\n );\n });\n }\n\n private streamLogsPolling({\n taskId,\n after: inputAfter,\n }: {\n taskId: string;\n after?: number;\n }): Observable<LogEvent> {\n let after = inputAfter;\n\n return new ObservableImpl(subscriber => {\n this.discoveryApi.getBaseUrl('scaffolder').then(async baseUrl => {\n while (!subscriber.closed) {\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(\n taskId,\n )}/events?${qs.stringify({ after })}`;\n const response = await this.fetchApi.fetch(url);\n\n if (!response.ok) {\n // wait for one second to not run into an\n await new Promise(resolve => setTimeout(resolve, 1000));\n continue;\n }\n\n const logs = (await response.json()) as LogEvent[];\n\n for (const event of logs) {\n after = Number(event.id);\n\n subscriber.next(event);\n\n if (event.type === 'completion') {\n subscriber.complete();\n return;\n }\n }\n }\n });\n });\n }\n\n async listActions(): Promise<ListActionsResponse> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const response = await this.fetchApi.fetch(`${baseUrl}/v2/actions`);\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async cancelTask(taskId: string): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}/cancel`;\n\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async retry?(taskId: string): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}/retry`;\n\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n return await response.json();\n }\n\n async autocomplete({\n token,\n resource,\n provider,\n context,\n }: {\n token: string;\n provider: string;\n resource: string;\n context?: Record<string, string>;\n }): Promise<{ results: { title?: string; id: string }[] }> {\n const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder');\n\n const url = `${baseUrl}/v2/autocomplete/${provider}/${resource}`;\n\n const response = await this.fetchApi.fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n token,\n context: context ?? {},\n }),\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const { results } = await response.json();\n return { results };\n }\n}\n"],"names":["queryString"],"mappings":";;;;;;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