@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-orchestrator 0.3.7 → 0.3.9
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,21 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-orchestrator
|
|
2
2
|
|
|
3
|
+
## 0.3.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e590195]
|
|
8
|
+
- Updated dependencies [66b7b7c]
|
|
9
|
+
- Updated dependencies [d7d2490]
|
|
10
|
+
- @red-hat-developer-hub/backstage-plugin-orchestrator-common@2.0.0
|
|
11
|
+
|
|
12
|
+
## 0.3.8
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [ff0f69e]
|
|
17
|
+
- @red-hat-developer-hub/backstage-plugin-orchestrator-common@1.28.4
|
|
18
|
+
|
|
3
19
|
## 0.3.7
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWorkflowParams.cjs.js","sources":["../../src/actions/getWorkflowParams.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { AuthService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/plugin-permission-common/index';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { JsonObject } from '@backstage/types/index';\n\nimport { isAxiosError } from 'axios';\nimport { dump } from 'js-yaml';\n\nimport { getOrchestratorApi, getRequestConfigOption } from './utils';\n\ntype RunWorkflowTemplateActionInput = { workflow_id: string; indent?: number };\ntype RunWorkflowTemplateActionOutput = {\n title: string;\n description: string;\n parameters: string;\n};\n\nconst getError = (err: unknown): Error => {\n if (\n isAxiosError<{ error: { message: string; name: string } }>(err) &&\n err.response?.data?.error?.message\n ) {\n const error = new Error(err.response?.data?.error?.message);\n error.name = err.response?.data?.error?.name || 'Error';\n return error;\n }\n return err as Error;\n};\n\nconst indentString = (str: string, indent: number) =>\n indent ? str.replace(/^/gm, ' '.repeat(indent)) : str;\n\nexport const createGetWorkflowParamsAction = (\n discoveryService: DiscoveryApi,\n authService: AuthService,\n) =>\n createTemplateAction<\n RunWorkflowTemplateActionInput,\n RunWorkflowTemplateActionOutput\n >({\n id: 'orchestrator:workflow:get_params',\n description: 'Collect parameters of a SonataFlow workflow.',\n supportsDryRun: false,\n schema: {\n input: {\n required: ['workflow_id'],\n type: 'object',\n properties: {\n workflow_id: {\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const workflowId = ctx.input?.workflow_id;\n if (!workflowId) {\n throw new Error('Missing workflow_id required input parameter.');\n }\n\n const api = await getOrchestratorApi(discoveryService);\n const reqConfigOption = await getRequestConfigOption(authService, ctx);\n\n try {\n const { data: workflow } = await api.getWorkflowOverviewById(\n workflowId,\n reqConfigOption,\n );\n if (!workflow) {\n throw new Error(`Can not find workflow ${workflowId}`);\n }\n\n const { data: inputSchemaWrapper } =\n await api.getWorkflowInputSchemaById(\n workflowId,\n undefined,\n reqConfigOption,\n );\n const inputSchema: JsonObject | undefined =\n inputSchemaWrapper.inputSchema;\n\n ctx.output('title', workflow.name || workflowId);\n ctx.output('description', workflow.description || '');\n\n if (inputSchema?.properties) {\n let parametersYaml = dump(\n [\n // scaffolder expects an array on the top-level\n inputSchema,\n ],\n { indent: 2 },\n );\n parametersYaml = indentString(parametersYaml, ctx.input?.indent || 0);\n parametersYaml = `\\n${parametersYaml}`;\n\n ctx.output('parameters', parametersYaml);\n } else {\n ctx.output('parameters', '{}');\n }\n } catch (err) {\n throw getError(err);\n }\n },\n });\n"],"names":["isAxiosError","createTemplateAction","getOrchestratorApi","getRequestConfigOption","dump"],"mappings":";;;;;;;AAgCA,MAAM,QAAA,GAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"getWorkflowParams.cjs.js","sources":["../../src/actions/getWorkflowParams.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { AuthService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/plugin-permission-common/index';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { JsonObject } from '@backstage/types/index';\n\nimport { isAxiosError } from 'axios';\nimport { dump } from 'js-yaml';\n\nimport { getOrchestratorApi, getRequestConfigOption } from './utils';\n\ntype RunWorkflowTemplateActionInput = { workflow_id: string; indent?: number };\ntype RunWorkflowTemplateActionOutput = {\n title: string;\n description: string;\n parameters: string;\n};\n\nconst getError = (err: unknown): Error => {\n if (\n isAxiosError<{ error: { message: string; name: string } }>(err) &&\n err.response?.data?.error?.message\n ) {\n const error = new Error(err.response?.data?.error?.message);\n error.name = err.response?.data?.error?.name || 'Error';\n return error;\n }\n return err as Error;\n};\n\nconst indentString = (str: string, indent: number) =>\n indent ? str.replace(/^/gm, ' '.repeat(indent)) : str;\n\nexport const createGetWorkflowParamsAction = (\n discoveryService: DiscoveryApi,\n authService: AuthService,\n) =>\n createTemplateAction<\n RunWorkflowTemplateActionInput,\n RunWorkflowTemplateActionOutput\n >({\n id: 'orchestrator:workflow:get_params',\n description: 'Collect parameters of a SonataFlow workflow.',\n supportsDryRun: false,\n schema: {\n input: {\n required: ['workflow_id'],\n type: 'object',\n properties: {\n workflow_id: {\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const workflowId = ctx.input?.workflow_id;\n if (!workflowId) {\n throw new Error('Missing workflow_id required input parameter.');\n }\n\n const api = await getOrchestratorApi(discoveryService);\n const reqConfigOption = await getRequestConfigOption(authService, ctx);\n\n try {\n const { data: workflow } = await api.getWorkflowOverviewById(\n workflowId,\n reqConfigOption,\n );\n if (!workflow) {\n throw new Error(`Can not find workflow ${workflowId}`);\n }\n\n const { data: inputSchemaWrapper } =\n await api.getWorkflowInputSchemaById(\n workflowId,\n undefined,\n reqConfigOption,\n );\n const inputSchema: JsonObject | undefined =\n inputSchemaWrapper.inputSchema;\n\n ctx.output('title', workflow.name || workflowId);\n ctx.output('description', workflow.description || '');\n\n if (inputSchema?.properties) {\n let parametersYaml = dump(\n [\n // scaffolder expects an array on the top-level\n inputSchema,\n ],\n { indent: 2 },\n );\n parametersYaml = indentString(parametersYaml, ctx.input?.indent || 0);\n parametersYaml = `\\n${parametersYaml}`;\n\n ctx.output('parameters', parametersYaml);\n } else {\n ctx.output('parameters', '{}');\n }\n } catch (err) {\n throw getError(err);\n }\n },\n });\n"],"names":["isAxiosError","createTemplateAction","getOrchestratorApi","getRequestConfigOption","dump"],"mappings":";;;;;;;AAgCA,MAAM,QAAA,GAAW,CAAC,GAAA,KAAwB;AACxC,EAAA,IACEA,mBAA2D,GAAG,CAAA,IAC9D,IAAI,QAAA,EAAU,IAAA,EAAM,OAAO,OAAA,EAC3B;AACA,IAAA,MAAM,QAAQ,IAAI,KAAA,CAAM,IAAI,QAAA,EAAU,IAAA,EAAM,OAAO,OAAO,CAAA;AAC1D,IAAA,KAAA,CAAM,IAAA,GAAO,GAAA,CAAI,QAAA,EAAU,IAAA,EAAM,OAAO,IA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,IAAA,EAAM,kBAAA,EAAmB,GAC/B,MAAM,GAAA,CAAI,0BAAA;AAAA,QACR,UAAA;AAAA,QACA,KAAA,CAAA;AAAA,QACA;AAAA,OACF;AACF,MAAA,MAAM,cACJ,kBAAA,CAAmB,WAAA;AAErB,MAAA,GAAA,CAAI,MAAA,CAAO,OAAA,EAAS,QAAA,CAAS,IAAA,IAAQ,UAAU,CAAA;AAC/C,MAAA,GAAA,CAAI,MAAA,CAAO,aAAA,EAAe,QAAA,CAAS,WAAA,IAAe,EAAE,CAAA;AAEpD,MAAA,IAAI,aAAa,UAAA,EAAY;AAC3B,QAAA,IAAI,cAAA,GAAiBC,WAAA;AAAA,UACnB;AAAA;AAAA,YAEE;AAAA,WACF;AAAA,UACA,EAAE,QAAQ,CAAA;AAAE,SACd;AACA,QAAA,cAAA,GAAiB,YAAA,CAAa,cAAA,EAAgB,GAAA,CAAI,KAAA,EAAO,UAAU,CAAC,CAAA;AACpE,QAAA,cAAA,GAAiB;AAAA,EAAK,cAAc,CAAA,CAAA;AAEpC,QAAA,GAAA,CAAI,MAAA,CAAO,cAAc,cAAc,CAAA;AAAA,MACzC,CAAA,MAAO;AACL,QAAA,GAAA,CAAI,MAAA,CAAO,cAAc,IAAI,CAAA;AAAA,MAC/B;AAAA,IACF,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,SAAS,GAAG,CAAA;AAAA,IACpB;AAAA,EACF;AACF,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWorkflow.cjs.js","sources":["../../src/actions/runWorkflow.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { AuthService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/plugin-permission-common/index';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { JsonObject } from '@backstage/types';\n\nimport { isAxiosError } from 'axios';\n\nimport { getOrchestratorApi, getRequestConfigOption } from './utils';\n\ntype RunWorkflowTemplateActionInput = {\n parameters: JsonObject;\n workflow_id: string;\n};\ntype RunWorkflowTemplateActionOutput = { instanceUrl: string };\n\nconst getError = (err: unknown): Error => {\n if (\n isAxiosError<{ error: { message: string; name: string } }>(err) &&\n err.response?.data?.error?.message\n ) {\n const error = new Error(err.response?.data?.error?.message);\n error.name = err.response?.data?.error?.name || 'Error';\n return error;\n }\n return err as Error;\n};\n\nexport const createRunWorkflowAction = (\n discoveryService: DiscoveryApi,\n authService: AuthService,\n) =>\n createTemplateAction<\n RunWorkflowTemplateActionInput,\n RunWorkflowTemplateActionOutput\n >({\n id: 'orchestrator:workflow:run',\n description: 'Run a SonataFlow workflow.',\n supportsDryRun: true,\n schema: {\n input: {\n required: ['parameters'],\n type: 'object',\n properties: {\n parameters: {\n type: 'object',\n title: 'Parameters',\n description: 'The workflow parameters.',\n },\n },\n },\n },\n async handler(ctx) {\n const entity = ctx.templateInfo?.entityRef;\n if (!entity) {\n throw new Error('No template entity');\n }\n\n const api = await getOrchestratorApi(discoveryService);\n const reqConfigOption = await getRequestConfigOption(authService, ctx);\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n if (!ctx.input.workflow_id) {\n throw new Error(\n \"Missing required 'workflow_id' input. Ensure that the step invoking the 'orchestrator:workflow:run' action includes an explicit 'workflow_id' field in its input.\",\n );\n }\n\n try {\n const { data } = await api.executeWorkflow(\n ctx.input.workflow_id,\n { inputData: ctx.input.parameters },\n reqConfigOption,\n );\n ctx.output('instanceUrl', `/orchestrator/instances/${data.id}`);\n } catch (err) {\n throw getError(err);\n }\n },\n });\n"],"names":["isAxiosError","createTemplateAction","getOrchestratorApi","getRequestConfigOption"],"mappings":";;;;;;AA8BA,MAAM,QAAA,GAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"runWorkflow.cjs.js","sources":["../../src/actions/runWorkflow.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { AuthService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/plugin-permission-common/index';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { JsonObject } from '@backstage/types';\n\nimport { isAxiosError } from 'axios';\n\nimport { getOrchestratorApi, getRequestConfigOption } from './utils';\n\ntype RunWorkflowTemplateActionInput = {\n parameters: JsonObject;\n workflow_id: string;\n};\ntype RunWorkflowTemplateActionOutput = { instanceUrl: string };\n\nconst getError = (err: unknown): Error => {\n if (\n isAxiosError<{ error: { message: string; name: string } }>(err) &&\n err.response?.data?.error?.message\n ) {\n const error = new Error(err.response?.data?.error?.message);\n error.name = err.response?.data?.error?.name || 'Error';\n return error;\n }\n return err as Error;\n};\n\nexport const createRunWorkflowAction = (\n discoveryService: DiscoveryApi,\n authService: AuthService,\n) =>\n createTemplateAction<\n RunWorkflowTemplateActionInput,\n RunWorkflowTemplateActionOutput\n >({\n id: 'orchestrator:workflow:run',\n description: 'Run a SonataFlow workflow.',\n supportsDryRun: true,\n schema: {\n input: {\n required: ['parameters'],\n type: 'object',\n properties: {\n parameters: {\n type: 'object',\n title: 'Parameters',\n description: 'The workflow parameters.',\n },\n },\n },\n },\n async handler(ctx) {\n const entity = ctx.templateInfo?.entityRef;\n if (!entity) {\n throw new Error('No template entity');\n }\n\n const api = await getOrchestratorApi(discoveryService);\n const reqConfigOption = await getRequestConfigOption(authService, ctx);\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n if (!ctx.input.workflow_id) {\n throw new Error(\n \"Missing required 'workflow_id' input. Ensure that the step invoking the 'orchestrator:workflow:run' action includes an explicit 'workflow_id' field in its input.\",\n );\n }\n\n try {\n const { data } = await api.executeWorkflow(\n ctx.input.workflow_id,\n { inputData: ctx.input.parameters },\n reqConfigOption,\n );\n ctx.output('instanceUrl', `/orchestrator/instances/${data.id}`);\n } catch (err) {\n throw getError(err);\n }\n },\n });\n"],"names":["isAxiosError","createTemplateAction","getOrchestratorApi","getRequestConfigOption"],"mappings":";;;;;;AA8BA,MAAM,QAAA,GAAW,CAAC,GAAA,KAAwB;AACxC,EAAA,IACEA,mBAA2D,GAAG,CAAA,IAC9D,IAAI,QAAA,EAAU,IAAA,EAAM,OAAO,OAAA,EAC3B;AACA,IAAA,MAAM,QAAQ,IAAI,KAAA,CAAM,IAAI,QAAA,EAAU,IAAA,EAAM,OAAO,OAAO,CAAA;AAC1D,IAAA,KAAA,CAAM,IAAA,GAAO,GAAA,CAAI,QAAA,EAAU,IAAA,EAAM,OAAO,IAAA,IAAQ,OAAA;AAChD,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,GAAA;AACT,CAAA;AAEO,MAAM,uBAAA,GAA0B,CACrC,gBAAA,EACA,WAAA,KAEAC,yCAAA,CAGE;AAAA,EACA,EAAA,EAAI,2BAAA;AAAA,EACJ,WAAA,EAAa,4BAAA;AAAA,EACb,cAAA,EAAgB,IAAA;AAAA,EAChB,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO;AAAA,MACL,QAAA,EAAU,CAAC,YAAY,CAAA;AAAA,MACvB,IAAA,EAAM,QAAA;AAAA,MACN,UA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yright Red Hat, Inc.\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 { AuthService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/plugin-permission-common/index';\n\nimport axios, { AxiosRequestConfig, isAxiosError } from 'axios';\n\nimport {\n Configuration,\n DefaultApi,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\nexport const getError = (err: unknown): Error => {\n if (\n isAxiosError<{ error: { message: string; name: string } }>(err) &&\n err.response?.data?.error?.message\n ) {\n const error = new Error(err.response?.data?.error?.message);\n error.name = err.response?.data?.error?.name || 'Error';\n return error;\n }\n return err as Error;\n};\n\nexport const getOrchestratorApi = async (\n discoveryService: DiscoveryApi,\n): Promise<DefaultApi> => {\n const baseUrl = await discoveryService.getBaseUrl('orchestrator');\n const config = new Configuration({});\n\n const axiosInstance = axios.create({\n baseURL: baseUrl,\n });\n const api = new DefaultApi(config, baseUrl, axiosInstance);\n\n return api;\n};\nexport const getRequestConfigOption = async (\n authService: AuthService,\n ctx: any,\n) => {\n const { token } = (await authService.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: 'orchestrator',\n })) ?? { token: ctx.secrets?.backstageToken };\n\n const reqConfigOption: AxiosRequestConfig = {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n };\n\n return reqConfigOption;\n};\n"],"names":["Configuration","axios","DefaultApi"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"utils.cjs.js","sources":["../../src/actions/utils.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { AuthService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/plugin-permission-common/index';\n\nimport axios, { AxiosRequestConfig, isAxiosError } from 'axios';\n\nimport {\n Configuration,\n DefaultApi,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\nexport const getError = (err: unknown): Error => {\n if (\n isAxiosError<{ error: { message: string; name: string } }>(err) &&\n err.response?.data?.error?.message\n ) {\n const error = new Error(err.response?.data?.error?.message);\n error.name = err.response?.data?.error?.name || 'Error';\n return error;\n }\n return err as Error;\n};\n\nexport const getOrchestratorApi = async (\n discoveryService: DiscoveryApi,\n): Promise<DefaultApi> => {\n const baseUrl = await discoveryService.getBaseUrl('orchestrator');\n const config = new Configuration({});\n\n const axiosInstance = axios.create({\n baseURL: baseUrl,\n });\n const api = new DefaultApi(config, baseUrl, axiosInstance);\n\n return api;\n};\nexport const getRequestConfigOption = async (\n authService: AuthService,\n ctx: any,\n) => {\n const { token } = (await authService.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: 'orchestrator',\n })) ?? { token: ctx.secrets?.backstageToken };\n\n const reqConfigOption: AxiosRequestConfig = {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n };\n\n return reqConfigOption;\n};\n"],"names":["Configuration","axios","DefaultApi"],"mappings":";;;;;;;;;AAqCO,MAAM,kBAAA,GAAqB,OAChC,gBAAA,KACwB;AACxB,EAAA,MAAM,OAAA,GAAU,MAAM,gBAAA,CAAiB,UAAA,CAAW,cAAc,CAAA;AAChE,EAAA,MAAM,MAAA,GAAS,IAAIA,+CAAA,CAAc,EAAE,CAAA;AAEnC,EAAA,MAAM,aAAA,GAAgBC,uBAAM,MAAA,CAAO;AAAA,IACjC,OAAA,EAAS;AAAA,GACV,CAAA;AACD,EAAA,MAAM,GAAA,GAAM,IAAIC,4CAAA,CAAW,MAAA,EAAQ,SAAS,aAAa,CAAA;AAEzD,EAAA,OAAO,GAAA;AACT;AACO,MAAM,sBAAA,GAAyB,OACpC,WAAA,EACA,GAAA,KACG;AACH,EAAA,MAAM,EAAE,KAAA,EAAM,GAAK,MAAM,YAAY,qBAAA,CAAsB;AAAA,IACzD,UAAA,EAAY,MAAM,GAAA,CAAI,uBAAA,EAAwB;AAAA,IAC9C,cAAA,EAAgB;AAAA,GACjB,CAAA,IAAM,EAAE,KAAA,EAAO,GAAA,CAAI,SAAS,cAAA,EAAe;AAE5C,EAAA,MAAM,eAAA,GAAsC;AAAA,IAC1C,OAAA,EAAS;AAAA,MACP,aAAA,EAAe,UAAU,KAAK,CAAA;AAAA;AAChC,GACF;AAEA,EAAA,OAAO,eAAA;AACT;;;;;"}
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\n\nimport {\n createGetWorkflowParamsAction,\n createRunWorkflowAction,\n} from './actions';\n\n/**\n * A backend module that registers the action into the scaffolder\n */\nexport const scaffolderModule = createBackendModule({\n moduleId: 'orchestrator',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolderActions: scaffolderActionsExtensionPoint,\n discoveryService: coreServices.discovery,\n authService: coreServices.auth,\n },\n async init({ scaffolderActions, discoveryService, authService }) {\n scaffolderActions.addActions(\n createRunWorkflowAction(discoveryService, authService),\n );\n scaffolderActions.addActions(\n createGetWorkflowParamsAction(discoveryService, authService),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","createRunWorkflowAction","createGetWorkflowParamsAction"],"mappings":";;;;;;;AA6BO,MAAM,mBAAmBA,
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\n\nimport {\n createGetWorkflowParamsAction,\n createRunWorkflowAction,\n} from './actions';\n\n/**\n * A backend module that registers the action into the scaffolder\n */\nexport const scaffolderModule = createBackendModule({\n moduleId: 'orchestrator',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolderActions: scaffolderActionsExtensionPoint,\n discoveryService: coreServices.discovery,\n authService: coreServices.auth,\n },\n async init({ scaffolderActions, discoveryService, authService }) {\n scaffolderActions.addActions(\n createRunWorkflowAction(discoveryService, authService),\n );\n scaffolderActions.addActions(\n createGetWorkflowParamsAction(discoveryService, authService),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","createRunWorkflowAction","createGetWorkflowParamsAction"],"mappings":";;;;;;;AA6BO,MAAM,mBAAmBA,oCAAA,CAAoB;AAAA,EAClD,QAAA,EAAU,cAAA;AAAA,EACV,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,iBAAA,EAAmBC,qCAAA;AAAA,QACnB,kBAAkBC,6BAAA,CAAa,SAAA;AAAA,QAC/B,aAAaA,6BAAA,CAAa;AAAA,OAC5B;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,iBAAA,EAAmB,gBAAA,EAAkB,aAAY,EAAG;AAC/D,QAAA,iBAAA,CAAkB,UAAA;AAAA,UAChBC,mCAAA,CAAwB,kBAAkB,WAAW;AAAA,SACvD;AACA,QAAA,iBAAA,CAAkB,UAAA;AAAA,UAChBC,+CAAA,CAA8B,kBAAkB,WAAW;AAAA,SAC7D;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-orchestrator",
|
|
3
3
|
"description": "The orchestrator module for @backstage/plugin-scaffolder-backend",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.9",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@backstage/catalog-model": "^1.7.3",
|
|
64
64
|
"@backstage/plugin-scaffolder-node": "^0.8.0",
|
|
65
65
|
"@backstage/types": "^1.2.1",
|
|
66
|
-
"@red-hat-developer-hub/backstage-plugin-orchestrator-common": "^
|
|
66
|
+
"@red-hat-developer-hub/backstage-plugin-orchestrator-common": "^2.0.0",
|
|
67
67
|
"axios": "^1.7.9",
|
|
68
68
|
"js-yaml": "^4.1.0"
|
|
69
69
|
},
|