@red-hat-developer-hub/backstage-plugin-orchestrator-backend 8.1.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ### Dependencies
2
2
 
3
+ ## 8.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fceb33e: Removal of deprecated package @backstage/backend-tasks
8
+
9
+ ## 8.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - de5ced6: Backstage version bump to v1.42.5
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [de5ced6]
18
+ - @red-hat-developer-hub/backstage-plugin-orchestrator-common@3.1.0
19
+
3
20
  ## 8.1.0
4
21
 
5
22
  ### Minor Changes
@@ -1,12 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var fs = require('fs-extra');
4
- var os = require('os');
5
-
6
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
-
8
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
9
- var os__default = /*#__PURE__*/_interopDefaultCompat(os);
3
+ require('fs-extra');
4
+ require('os');
10
5
 
11
6
  async function retryAsyncFunction(args) {
12
7
  let result;
@@ -19,22 +14,6 @@ async function retryAsyncFunction(args) {
19
14
  }
20
15
  throw new Error("Exceeded maximum number of retries for async function");
21
16
  }
22
- async function getWorkingDirectory(config, logger) {
23
- if (!config.has("backend.workingDirectory")) {
24
- return os__default.default.tmpdir();
25
- }
26
- const workingDirectory = config.getString("backend.workingDirectory");
27
- try {
28
- await fs__default.default.access(workingDirectory, fs__default.default.constants.F_OK | fs__default.default.constants.W_OK);
29
- logger.info(`using working directory: ${workingDirectory}`);
30
- } catch (err) {
31
- logger.error(
32
- `working directory ${workingDirectory} ${err.code === "ENOENT" ? "does not exist" : "is not writable"}`
33
- );
34
- throw err;
35
- }
36
- return workingDirectory;
37
- }
38
17
  async function executeWithRetry(action, maxErrors = 15) {
39
18
  let response;
40
19
  let errorCount = 0;
@@ -61,6 +40,5 @@ function delay(time) {
61
40
 
62
41
  exports.delay = delay;
63
42
  exports.executeWithRetry = executeWithRetry;
64
- exports.getWorkingDirectory = getWorkingDirectory;
65
43
  exports.retryAsyncFunction = retryAsyncFunction;
66
44
  //# sourceMappingURL=Helper.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Helper.cjs.js","sources":["../../src/service/Helper.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 type { LoggerService } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport fs from 'fs-extra';\n\nimport os from 'os';\n\nexport async function retryAsyncFunction<T>(args: {\n asyncFn: () => Promise<T | undefined>;\n maxAttempts: number;\n delayMs: number;\n}): Promise<T> {\n let result: T | undefined;\n for (let i = 0; i < args.maxAttempts; i++) {\n result = await args.asyncFn();\n if (result !== undefined) {\n return result;\n }\n await new Promise(resolve => setTimeout(resolve, args.delayMs));\n }\n throw new Error('Exceeded maximum number of retries for async function');\n}\n\nexport async function getWorkingDirectory(\n config: Config,\n logger: LoggerService,\n): Promise<string> {\n if (!config.has('backend.workingDirectory')) {\n return os.tmpdir();\n }\n\n const workingDirectory = config.getString('backend.workingDirectory');\n try {\n // Check if working directory exists and is writable\n await fs.access(workingDirectory, fs.constants.F_OK | fs.constants.W_OK);\n logger.info(`using working directory: ${workingDirectory}`);\n } catch (err: any) {\n logger.error(\n `working directory ${workingDirectory} ${\n err.code === 'ENOENT' ? 'does not exist' : 'is not writable'\n }`,\n );\n throw err;\n }\n return workingDirectory;\n}\n\nexport async function executeWithRetry(\n action: () => Promise<Response>,\n maxErrors = 15,\n): Promise<Response> {\n let response: Response;\n let errorCount = 0;\n // execute with retry\n const backoff = 5000;\n while (errorCount < maxErrors) {\n try {\n response = await action();\n if (response.status >= 400) {\n errorCount++;\n // backoff\n await delay(backoff);\n } else {\n return response;\n }\n } catch (e) {\n errorCount++;\n await delay(backoff);\n }\n }\n throw new Error('Unable to execute query.');\n}\n\nexport function delay(time: number) {\n return new Promise(r => setTimeout(r, time));\n}\n"],"names":["os","fs"],"mappings":";;;;;;;;;;AAsBA,eAAsB,mBAAsB,IAAA,EAI7B;AACb,EAAA,IAAI,MAAA;AACJ,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,aAAa,CAAA,EAAA,EAAK;AACzC,IAAA,MAAA,GAAS,MAAM,KAAK,OAAA,EAAQ;AAC5B,IAAA,IAAI,WAAW,MAAA,EAAW;AACxB,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,WAAW,OAAA,EAAS,IAAA,CAAK,OAAO,CAAC,CAAA;AAAA,EAChE;AACA,EAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AACzE;AAEA,eAAsB,mBAAA,CACpB,QACA,MAAA,EACiB;AACjB,EAAA,IAAI,CAAC,MAAA,CAAO,GAAA,CAAI,0BAA0B,CAAA,EAAG;AAC3C,IAAA,OAAOA,oBAAG,MAAA,EAAO;AAAA,EACnB;AAEA,EAAA,MAAM,gBAAA,GAAmB,MAAA,CAAO,SAAA,CAAU,0BAA0B,CAAA;AACpE,EAAA,IAAI;AAEF,IAAA,MAAMC,mBAAA,CAAG,OAAO,gBAAA,EAAkBA,mBAAA,CAAG,UAAU,IAAA,GAAOA,mBAAA,CAAG,UAAU,IAAI,CAAA;AACvE,IAAA,MAAA,CAAO,IAAA,CAAK,CAAA,yBAAA,EAA4B,gBAAgB,CAAA,CAAE,CAAA;AAAA,EAC5D,SAAS,GAAA,EAAU;AACjB,IAAA,MAAA,CAAO,KAAA;AAAA,MACL,qBAAqB,gBAAgB,CAAA,CAAA,EACnC,IAAI,IAAA,KAAS,QAAA,GAAW,mBAAmB,iBAC7C,CAAA;AAAA,KACF;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACA,EAAA,OAAO,gBAAA;AACT;AAEA,eAAsB,gBAAA,CACpB,MAAA,EACA,SAAA,GAAY,EAAA,EACO;AACnB,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,UAAA,GAAa,CAAA;AAEjB,EAAA,MAAM,OAAA,GAAU,GAAA;AAChB,EAAA,OAAO,aAAa,SAAA,EAAW;AAC7B,IAAA,IAAI;AACF,MAAA,QAAA,GAAW,MAAM,MAAA,EAAO;AACxB,MAAA,IAAI,QAAA,CAAS,UAAU,GAAA,EAAK;AAC1B,QAAA,UAAA,EAAA;AAEA,QAAA,MAAM,MAAM,OAAO,CAAA;AAAA,MACrB,CAAA,MAAO;AACL,QAAA,OAAO,QAAA;AAAA,MACT;AAAA,IACF,SAAS,CAAA,EAAG;AACV,MAAA,UAAA,EAAA;AACA,MAAA,MAAM,MAAM,OAAO,CAAA;AAAA,IACrB;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAC5C;AAEO,SAAS,MAAM,IAAA,EAAc;AAClC,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAA,CAAA,KAAK,UAAA,CAAW,CAAA,EAAG,IAAI,CAAC,CAAA;AAC7C;;;;;;;"}
1
+ {"version":3,"file":"Helper.cjs.js","sources":["../../src/service/Helper.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 type { LoggerService } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport fs from 'fs-extra';\n\nimport os from 'os';\n\nexport async function retryAsyncFunction<T>(args: {\n asyncFn: () => Promise<T | undefined>;\n maxAttempts: number;\n delayMs: number;\n}): Promise<T> {\n let result: T | undefined;\n for (let i = 0; i < args.maxAttempts; i++) {\n result = await args.asyncFn();\n if (result !== undefined) {\n return result;\n }\n await new Promise(resolve => setTimeout(resolve, args.delayMs));\n }\n throw new Error('Exceeded maximum number of retries for async function');\n}\n\nexport async function getWorkingDirectory(\n config: Config,\n logger: LoggerService,\n): Promise<string> {\n if (!config.has('backend.workingDirectory')) {\n return os.tmpdir();\n }\n\n const workingDirectory = config.getString('backend.workingDirectory');\n try {\n // Check if working directory exists and is writable\n await fs.access(workingDirectory, fs.constants.F_OK | fs.constants.W_OK);\n logger.info(`using working directory: ${workingDirectory}`);\n } catch (err: any) {\n logger.error(\n `working directory ${workingDirectory} ${\n err.code === 'ENOENT' ? 'does not exist' : 'is not writable'\n }`,\n );\n throw err;\n }\n return workingDirectory;\n}\n\nexport async function executeWithRetry(\n action: () => Promise<Response>,\n maxErrors = 15,\n): Promise<Response> {\n let response: Response;\n let errorCount = 0;\n // execute with retry\n const backoff = 5000;\n while (errorCount < maxErrors) {\n try {\n response = await action();\n if (response.status >= 400) {\n errorCount++;\n // backoff\n await delay(backoff);\n } else {\n return response;\n }\n } catch (e) {\n errorCount++;\n await delay(backoff);\n }\n }\n throw new Error('Unable to execute query.');\n}\n\nexport function delay(time: number) {\n return new Promise(r => setTimeout(r, time));\n}\n"],"names":[],"mappings":";;;;;AAsBA,eAAsB,mBAAsB,IAAA,EAI7B;AACb,EAAA,IAAI,MAAA;AACJ,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,aAAa,CAAA,EAAA,EAAK;AACzC,IAAA,MAAA,GAAS,MAAM,KAAK,OAAA,EAAQ;AAC5B,IAAA,IAAI,WAAW,MAAA,EAAW;AACxB,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,WAAW,OAAA,EAAS,IAAA,CAAK,OAAO,CAAC,CAAA;AAAA,EAChE;AACA,EAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AACzE;AA0BA,eAAsB,gBAAA,CACpB,MAAA,EACA,SAAA,GAAY,EAAA,EACO;AACnB,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,UAAA,GAAa,CAAA;AAEjB,EAAA,MAAM,OAAA,GAAU,GAAA;AAChB,EAAA,OAAO,aAAa,SAAA,EAAW;AAC7B,IAAA,IAAI;AACF,MAAA,QAAA,GAAW,MAAM,MAAA,EAAO;AACxB,MAAA,IAAI,QAAA,CAAS,UAAU,GAAA,EAAK;AAC1B,QAAA,UAAA,EAAA;AAEA,QAAA,MAAM,MAAM,OAAO,CAAA;AAAA,MACrB,CAAA,MAAO;AACL,QAAA,OAAO,QAAA;AAAA,MACT;AAAA,IACF,SAAS,CAAA,EAAG;AACV,MAAA,UAAA,EAAA;AACA,MAAA,MAAM,MAAM,OAAO,CAAA;AAAA,IACrB;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAC5C;AAEO,SAAS,MAAM,IAAA,EAAc;AAClC,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAA,CAAA,KAAK,UAAA,CAAW,CAAA,EAAG,IAAI,CAAC,CAAA;AAC7C;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkflowCacheService.cjs.js","sources":["../../src/service/WorkflowCacheService.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 */\n\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { PluginTaskScheduler } from '@backstage/backend-tasks';\n\nimport { DataIndexService } from './DataIndexService';\nimport { SonataFlowService } from './SonataFlowService';\n\nexport type CacheHandler = 'skip' | 'throw';\n\nexport class WorkflowCacheService {\n private readonly TASK_ID = 'task__Orchestrator__WorkflowCacheService';\n private readonly DEFAULT_FREQUENCY_IN_SECONDS = 5;\n private readonly DEFAULT_TIMEOUT_IN_MINUTES = 10;\n private readonly definitionIdCache = new Set<string>();\n private readonly unavailableDefinitionIdCache = new Set<string>();\n\n constructor(\n private readonly logger: LoggerService,\n private readonly dataIndexService: DataIndexService,\n private readonly sonataFlowService: SonataFlowService,\n ) {}\n\n public get definitionIds(): string[] {\n return Array.from(this.definitionIdCache);\n }\n\n public get unavailableDefinitionIds(): string[] {\n return Array.from(this.unavailableDefinitionIdCache);\n }\n\n private isEmpty(): boolean {\n return (\n this.definitionIdCache.size === 0 &&\n this.unavailableDefinitionIdCache.size === 0\n );\n }\n\n public isAvailable(\n definitionId?: string,\n cacheHandler: CacheHandler = 'skip',\n ): boolean {\n if (!definitionId) {\n return false;\n }\n const isAvailable = this.definitionIdCache.has(definitionId);\n if (!isAvailable && cacheHandler === 'throw') {\n throw new Error(\n `Workflow service \"${definitionId}\" not available at the moment`,\n );\n }\n return isAvailable;\n }\n\n public schedule(args: {\n scheduler: PluginTaskScheduler;\n frequencyInSeconds?: number;\n timeoutInMinutes?: number;\n }): void {\n const {\n scheduler,\n frequencyInSeconds = this.DEFAULT_FREQUENCY_IN_SECONDS,\n timeoutInMinutes = this.DEFAULT_TIMEOUT_IN_MINUTES,\n } = args;\n\n scheduler.scheduleTask({\n id: this.TASK_ID,\n frequency: { seconds: frequencyInSeconds },\n timeout: { minutes: timeoutInMinutes },\n fn: async () => {\n await this.runTask();\n },\n });\n }\n\n private async runTask() {\n try {\n const idUrlMap = await this.dataIndexService.fetchWorkflowServiceUrls();\n this.definitionIdCache.forEach(definitionId => {\n if (!idUrlMap[definitionId]) {\n this.definitionIdCache.delete(definitionId);\n }\n });\n this.unavailableDefinitionIdCache.forEach(definitionId => {\n if (!idUrlMap[definitionId]) {\n this.unavailableDefinitionIdCache.delete(definitionId);\n }\n });\n await Promise.all(\n Object.entries(idUrlMap).map(async ([definitionId, serviceUrl]) => {\n let isServiceUp = false;\n try {\n isServiceUp = await this.sonataFlowService.pingWorkflowService({\n definitionId,\n serviceUrl,\n });\n } catch (err) {\n this.logger.error(\n `Ping workflow ${definitionId} service threw error: ${err}`,\n );\n }\n if (isServiceUp) {\n this.definitionIdCache.add(definitionId);\n this.unavailableDefinitionIdCache.delete(definitionId);\n } else {\n this.logger.error(\n `Failed to ping service for workflow ${definitionId} at ${serviceUrl}`,\n );\n if (this.definitionIdCache.has(definitionId)) {\n this.definitionIdCache.delete(definitionId);\n }\n this.unavailableDefinitionIdCache.add(definitionId);\n }\n }),\n );\n\n const workflowDefinitionIds = this.isEmpty()\n ? 'empty cache'\n : Array.from(this.definitionIdCache)\n .concat(Array.from(this.unavailableDefinitionIdCache))\n .join(', ');\n\n this.logger.debug(\n `${this.TASK_ID} updated the workflow definition ID cache to: ${workflowDefinitionIds}`,\n );\n } catch (error) {\n this.logger.error(`Error running ${this.TASK_ID}: ${error}`);\n return;\n }\n }\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,oBAAA,CAAqB;AAAA,EAOhC,WAAA,CACmB,MAAA,EACA,gBAAA,EACA,iBAAA,EACjB;AAHiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AACA,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAA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AA,CAAK,iBAAA,CAAkB,IAAI,YAAY,CAAA;AACvC,YAAA,IAAA,CAAK,4BAAA,CAA6B,OAAO,YAAY,CAAA;AAAA,UACvD,CAAA,MAAO;AACL,YAAA,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,cACV,CAAA,oCAAA,EAAuC,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA;AAAA,aACtE;AACA,YAAA,IAAI,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,YAAY,CAAA,EAAG;AAC5C,cAAA,IAAA,CAAK,iBAAA,CAAkB,OAAO,YAAY,CAAA;AAAA,YAC5C;AACA,YAAA,IAAA,CAAK,4BAAA,CAA6B,IAAI,YAAY,CAAA;AAAA,UACpD;AAAA,QACF,CAAC;AAAA,OACH;AAEA,MAAA,MAAM,wBAAwB,IAAA,CAAK,OAAA,KAC/B,aAAA,GACA,KAAA,CAAM,KAAK,IAAA,CAAK,iBAAiB,CAAA,CAC9B,MAAA,CAAO,MAAM,IAAA,CAAK,IAAA,CAAK,4BAA4B,CAAC,CAAA,CACpD,KAAK,IAAI,CAAA;AAEhB,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,QACV,CAAA,EAAG,IAAA,CAAK,OAAO,CAAA,8CAAA,EAAiD,qBAAqB,CAAA;AAAA,OACvF;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,OAAO,KAAA,CAAM,CAAA,cAAA,EAAiB,KAAK,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAA;AAC3D,MAAA;AAAA,IACF;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"WorkflowCacheService.cjs.js","sources":["../../src/service/WorkflowCacheService.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 */\n\nimport { LoggerService, SchedulerService } from '@backstage/backend-plugin-api';\n\nimport { DataIndexService } from './DataIndexService';\nimport { SonataFlowService } from './SonataFlowService';\n\nexport type CacheHandler = 'skip' | 'throw';\n\nexport class WorkflowCacheService {\n private readonly TASK_ID = 'task__Orchestrator__WorkflowCacheService';\n private readonly DEFAULT_FREQUENCY_IN_SECONDS = 5;\n private readonly DEFAULT_TIMEOUT_IN_MINUTES = 10;\n private readonly definitionIdCache = new Set<string>();\n private readonly unavailableDefinitionIdCache = new Set<string>();\n\n constructor(\n private readonly logger: LoggerService,\n private readonly dataIndexService: DataIndexService,\n private readonly sonataFlowService: SonataFlowService,\n ) {}\n\n public get definitionIds(): string[] {\n return Array.from(this.definitionIdCache);\n }\n\n public get unavailableDefinitionIds(): string[] {\n return Array.from(this.unavailableDefinitionIdCache);\n }\n\n private isEmpty(): boolean {\n return (\n this.definitionIdCache.size === 0 &&\n this.unavailableDefinitionIdCache.size === 0\n );\n }\n\n public isAvailable(\n definitionId?: string,\n cacheHandler: CacheHandler = 'skip',\n ): boolean {\n if (!definitionId) {\n return false;\n }\n const isAvailable = this.definitionIdCache.has(definitionId);\n if (!isAvailable && cacheHandler === 'throw') {\n throw new Error(\n `Workflow service \"${definitionId}\" not available at the moment`,\n );\n }\n return isAvailable;\n }\n\n public schedule(args: {\n scheduler: SchedulerService;\n frequencyInSeconds?: number;\n timeoutInMinutes?: number;\n }): void {\n const {\n scheduler,\n frequencyInSeconds = this.DEFAULT_FREQUENCY_IN_SECONDS,\n timeoutInMinutes = this.DEFAULT_TIMEOUT_IN_MINUTES,\n } = args;\n\n scheduler.scheduleTask({\n id: this.TASK_ID,\n frequency: { seconds: frequencyInSeconds },\n timeout: { minutes: timeoutInMinutes },\n fn: async () => {\n await this.runTask();\n },\n });\n }\n\n private async runTask() {\n try {\n const idUrlMap = await this.dataIndexService.fetchWorkflowServiceUrls();\n this.definitionIdCache.forEach(definitionId => {\n if (!idUrlMap[definitionId]) {\n this.definitionIdCache.delete(definitionId);\n }\n });\n this.unavailableDefinitionIdCache.forEach(definitionId => {\n if (!idUrlMap[definitionId]) {\n this.unavailableDefinitionIdCache.delete(definitionId);\n }\n });\n await Promise.all(\n Object.entries(idUrlMap).map(async ([definitionId, serviceUrl]) => {\n let isServiceUp = false;\n try {\n isServiceUp = await this.sonataFlowService.pingWorkflowService({\n definitionId,\n serviceUrl,\n });\n } catch (err) {\n this.logger.error(\n `Ping workflow ${definitionId} service threw error: ${err}`,\n );\n }\n if (isServiceUp) {\n this.definitionIdCache.add(definitionId);\n this.unavailableDefinitionIdCache.delete(definitionId);\n } else {\n this.logger.error(\n `Failed to ping service for workflow ${definitionId} at ${serviceUrl}`,\n );\n if (this.definitionIdCache.has(definitionId)) {\n this.definitionIdCache.delete(definitionId);\n }\n this.unavailableDefinitionIdCache.add(definitionId);\n }\n }),\n );\n\n const workflowDefinitionIds = this.isEmpty()\n ? 'empty cache'\n : Array.from(this.definitionIdCache)\n .concat(Array.from(this.unavailableDefinitionIdCache))\n .join(', ');\n\n this.logger.debug(\n `${this.TASK_ID} updated the workflow definition ID cache to: ${workflowDefinitionIds}`,\n );\n } catch (error) {\n this.logger.error(`Error running ${this.TASK_ID}: ${error}`);\n return;\n }\n }\n}\n"],"names":[],"mappings":";;AAuBO,MAAM,oBAAA,CAAqB;AAAA,EAOhC,WAAA,CACmB,MAAA,EACA,gBAAA,EACA,iBAAA,EACjB;AAHiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,gBAAA,GAAA,gBAAA;AACA,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA;AAAA,EAChB;AAAA,EAVc,OAAA,GAAU,0CAAA;AAAA,EACV,4BAAA,GAA+B,CAAA;AAAA,EAC/B,0BAAA,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;AAAA,UACvD,CAAA,MAAO;AACL,YAAA,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,cACV,CAAA,oCAAA,EAAuC,YAAY,CAAA,IAAA,EAAO,UAAU,CAAA;AAAA,aACtE;AACA,YAAA,IAAI,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,YAAY,CAAA,EAAG;AAC5C,cAAA,IAAA,CAAK,iBAAA,CAAkB,OAAO,YAAY,CAAA;AAAA,YAC5C;AACA,YAAA,IAAA,CAAK,4BAAA,CAA6B,IAAI,YAAY,CAAA;AAAA,UACpD;AAAA,QACF,CAAC;AAAA,OACH;AAEA,MAAA,MAAM,wBAAwB,IAAA,CAAK,OAAA,KAC/B,aAAA,GACA,KAAA,CAAM,KAAK,IAAA,CAAK,iBAAiB,CAAA,CAC9B,MAAA,CAAO,MAAM,IAAA,CAAK,IAAA,CAAK,4BAA4B,CAAC,CAAA,CACpD,KAAK,IAAI,CAAA;AAEhB,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,QACV,CAAA,EAAG,IAAA,CAAK,OAAO,CAAA,8CAAA,EAAiD,qBAAqB,CAAA;AAAA,OACvF;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,OAAO,KAAA,CAAM,CAAA,cAAA,EAAiB,KAAK,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAA;AAC3D,MAAA;AAAA,IACF;AAAA,EACF;AACF;;;;"}
@@ -13,7 +13,6 @@ var v2 = require('./api/v2.cjs.js');
13
13
  var DataIndexService = require('./DataIndexService.cjs.js');
14
14
  var DataInputSchemaService = require('./DataInputSchemaService.cjs.js');
15
15
  var OrchestratorService = require('./OrchestratorService.cjs.js');
16
- var ScaffolderService = require('./ScaffolderService.cjs.js');
17
16
  var SonataFlowService = require('./SonataFlowService.cjs.js');
18
17
  var WorkflowCacheService = require('./WorkflowCacheService.cjs.js');
19
18
 
@@ -90,9 +89,6 @@ async function createBackendRouter(options) {
90
89
  config,
91
90
  logger,
92
91
  auditor,
93
- discovery,
94
- catalogApi,
95
- urlReader,
96
92
  scheduler,
97
93
  permissions,
98
94
  httpAuth,
@@ -111,12 +107,6 @@ async function createBackendRouter(options) {
111
107
  logger.info("PONG!");
112
108
  response.json({ status: "ok" });
113
109
  });
114
- const scaffolderService = new ScaffolderService.ScaffolderService(
115
- logger,
116
- config,
117
- catalogApi,
118
- urlReader
119
- );
120
110
  setupInternalRoutes(
121
111
  publicServices,
122
112
  routerApi,
@@ -125,7 +115,6 @@ async function createBackendRouter(options) {
125
115
  auditor,
126
116
  userInfo
127
117
  );
128
- setupExternalRoutes(router, discovery, scaffolderService, auditor);
129
118
  router.use((req, res, next) => {
130
119
  if (!next) {
131
120
  throw new Error("next is undefined");
@@ -746,44 +735,6 @@ function setupInternalRoutes(services, routerApi, permissions, httpAuth, auditor
746
735
  }
747
736
  );
748
737
  }
749
- function setupExternalRoutes(router, discovery, scaffolderService, auditor) {
750
- router.get("/actions", async (req, res) => {
751
- const auditEvent = await auditor.createEvent({
752
- eventId: "actions",
753
- request: req
754
- });
755
- const scaffolderUrl = await discovery.getBaseUrl("scaffolder");
756
- const response = await fetch(`${scaffolderUrl}/v2/actions`);
757
- const json = await response.json();
758
- auditEvent.success();
759
- res.status(response.status).json(json);
760
- });
761
- router.post("/actions/:actionId", async (req, res) => {
762
- const { actionId } = req.params;
763
- const instanceId = req.header("kogitoprocinstanceid");
764
- const body = await req.body;
765
- const auditEvent = await auditor.createEvent({
766
- eventId: "actions",
767
- request: req,
768
- meta: {
769
- actionType: "by-id",
770
- instanceId
771
- }
772
- });
773
- const filteredBody = Object.fromEntries(
774
- Object.entries(body).filter(
775
- ([, value]) => value !== void 0 && value !== null
776
- )
777
- );
778
- const result = await scaffolderService.executeAction({
779
- actionId,
780
- instanceId,
781
- input: filteredBody
782
- });
783
- auditEvent.success();
784
- res.status(200).json(result);
785
- });
786
- }
787
738
  function getRequestFilters(req) {
788
739
  return req.body.filters ? req.body.filters : void 0;
789
740
  }
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 */\n\nimport { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\nimport {\n AuditorService,\n AuditorServiceEvent,\n HttpAuthService,\n LoggerService,\n PermissionsService,\n SchedulerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\nimport type { DiscoveryApi } from '@backstage/core-plugin-api';\nimport {\n AuthorizePermissionRequest,\n AuthorizePermissionResponse,\n AuthorizeResult,\n BasicPermission,\n} from '@backstage/plugin-permission-common';\nimport { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';\nimport type { JsonObject, JsonValue } from '@backstage/types';\n\nimport { UnauthorizedError } from '@backstage-community/plugin-rbac-common';\nimport { fullFormats } from 'ajv-formats/dist/formats';\nimport express, { Router } from 'express';\nimport { Request as HttpRequest } from 'express-serve-static-core';\nimport { OpenAPIBackend, Request } from 'openapi-backend';\n\nimport {\n FieldFilter,\n Filter,\n NestedFilter,\n openApiDocument,\n orchestratorInstanceAdminViewPermission,\n orchestratorPermissions,\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission,\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission,\n WorkflowOverviewListResultDTO,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\nimport { RouterOptions } from '../routerWrapper';\nimport { buildPagination } from '../types/pagination';\nimport { V2 } from './api/v2';\nimport { DataIndexService } from './DataIndexService';\nimport { DataInputSchemaService } from './DataInputSchemaService';\nimport { OrchestratorService } from './OrchestratorService';\nimport { ScaffolderService } from './ScaffolderService';\nimport { SonataFlowService } from './SonataFlowService';\nimport { WorkflowCacheService } from './WorkflowCacheService';\n\ninterface PublicServices {\n dataInputSchemaService: DataInputSchemaService;\n orchestratorService: OrchestratorService;\n}\n\ninterface RouterApi {\n openApiBackend: OpenAPIBackend;\n v2: V2;\n}\n\nconst authorize = async (\n request: HttpRequest,\n anyOfPermissions: BasicPermission[],\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n): Promise<AuthorizePermissionResponse> => {\n const credentials = await httpAuth.credentials(request);\n const decisionResponses: AuthorizePermissionResponse[][] = await Promise.all(\n anyOfPermissions.map(permission =>\n permissionsSvc.authorize([{ permission }], {\n credentials,\n }),\n ),\n );\n const decisions: AuthorizePermissionResponse[] = decisionResponses.map(\n d => d[0],\n );\n\n const allow = decisions.find(d => d.result === AuthorizeResult.ALLOW);\n return (\n allow || {\n result: AuthorizeResult.DENY,\n }\n );\n};\n\nconst isUserAuthorizedForInstanceAdminViewPermission = async (\n request: HttpRequest,\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n): Promise<boolean> => {\n const credentials = await httpAuth.credentials(request);\n const [decision] = await permissionsSvc.authorize(\n [{ permission: orchestratorInstanceAdminViewPermission }],\n { credentials },\n );\n\n return decision.result === AuthorizeResult.ALLOW;\n};\n\nconst filterAuthorizedWorkflowIds = async (\n request: HttpRequest,\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n workflowIds: string[],\n): Promise<string[]> => {\n const credentials = await httpAuth.credentials(request);\n const genericWorkflowPermissionDecision = await permissionsSvc.authorize(\n [{ permission: orchestratorWorkflowPermission }],\n {\n credentials,\n },\n );\n\n if (genericWorkflowPermissionDecision[0].result === AuthorizeResult.ALLOW) {\n // The user can see all workflows\n return workflowIds;\n }\n\n const specificWorkflowRequests: AuthorizePermissionRequest[] =\n workflowIds.map(workflowId => ({\n permission: orchestratorWorkflowSpecificPermission(workflowId),\n }));\n\n const decisions = await permissionsSvc.authorize(specificWorkflowRequests, {\n credentials,\n });\n\n return workflowIds.filter(\n (_, idx) => decisions[idx].result === AuthorizeResult.ALLOW,\n );\n};\n\nconst filterAuthorizedWorkflows = async (\n request: HttpRequest,\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n workflows: WorkflowOverviewListResultDTO,\n): Promise<WorkflowOverviewListResultDTO> => {\n if (!workflows.overviews) {\n return workflows;\n }\n\n const authorizedWorkflowIds = await filterAuthorizedWorkflowIds(\n request,\n permissionsSvc,\n httpAuth,\n workflows.overviews.map(w => w.workflowId),\n );\n\n const filtered = {\n ...workflows,\n overviews: workflows.overviews.filter(w =>\n authorizedWorkflowIds.includes(w.workflowId),\n ),\n };\n\n return filtered;\n};\n\nexport async function createBackendRouter(\n options: RouterOptions,\n): Promise<Router> {\n const {\n config,\n logger,\n auditor,\n discovery,\n catalogApi,\n urlReader,\n scheduler,\n permissions,\n httpAuth,\n userInfo,\n } = options;\n const publicServices = initPublicServices(logger, config, scheduler);\n\n const routerApi = await initRouterApi(publicServices.orchestratorService);\n\n const router = Router();\n const permissionsIntegrationRouter = createPermissionIntegrationRouter({\n permissions: orchestratorPermissions,\n });\n router.use(express.json());\n router.use(permissionsIntegrationRouter);\n router.use('/workflows', express.text());\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n const scaffolderService: ScaffolderService = new ScaffolderService(\n logger,\n config,\n catalogApi,\n urlReader,\n );\n\n setupInternalRoutes(\n publicServices,\n routerApi,\n permissions,\n httpAuth,\n auditor,\n userInfo,\n );\n setupExternalRoutes(router, discovery, scaffolderService, auditor);\n\n router.use((req, res, next) => {\n if (!next) {\n throw new Error('next is undefined');\n }\n\n return routerApi.openApiBackend\n .handleRequest(req as Request, req, res, next)\n .catch(error => {\n auditor\n .createEvent({\n eventId: 'generic-error-handler',\n request: req,\n // Keep at high since this is a fallback - any error should be caught in handlers\n severityLevel: 'high',\n meta: {},\n })\n .then(event => {\n event.fail({\n meta: {},\n error,\n });\n });\n\n next(error);\n });\n });\n\n const middleware = MiddlewareFactory.create({ logger, config });\n\n router.use(middleware.error({ logAllErrors: true })); // log also openapi errors\n\n return router;\n}\n\nfunction initPublicServices(\n logger: LoggerService,\n config: Config,\n scheduler: SchedulerService,\n): PublicServices {\n const dataIndexUrl = config.getString('orchestrator.dataIndexService.url');\n const dataIndexService = new DataIndexService(dataIndexUrl, logger);\n const sonataFlowService = new SonataFlowService(dataIndexService, logger);\n\n const workflowCacheService = new WorkflowCacheService(\n logger,\n dataIndexService,\n sonataFlowService,\n );\n workflowCacheService.schedule({ scheduler: scheduler });\n\n const orchestratorService = new OrchestratorService(\n sonataFlowService,\n dataIndexService,\n workflowCacheService,\n );\n\n const dataInputSchemaService = new DataInputSchemaService();\n\n return {\n orchestratorService,\n dataInputSchemaService,\n };\n}\n\nasync function initRouterApi(\n orchestratorService: OrchestratorService,\n): Promise<RouterApi> {\n const openApiBackend = new OpenAPIBackend({\n definition: openApiDocument,\n strict: false,\n ajvOpts: {\n strict: false,\n strictSchema: false,\n verbose: true,\n addUsedSchema: false,\n formats: fullFormats, // open issue: https://github.com/openapistack/openapi-backend/issues/280\n },\n handlers: {\n validationFail: async (\n c,\n _req: express.Request,\n res: express.Response,\n ) => {\n console.log('OPENAPI validationFail', c.operation);\n res.status(400).json({ err: c.validation.errors });\n },\n notFound: async (_c, req: express.Request, res: express.Response) => {\n res.status(404).json({ err: `${req.path} path not found` });\n },\n notImplemented: async (_c, req: express.Request, res: express.Response) =>\n res.status(500).json({ err: `${req.path} not implemented` }),\n },\n });\n await openApiBackend.init();\n const v2 = new V2(orchestratorService);\n return { v2, openApiBackend };\n}\n\n// ======================================================\n// Internal Backstage API calls to delegate to SonataFlow\n// ======================================================\nfunction setupInternalRoutes(\n services: PublicServices,\n routerApi: RouterApi,\n permissions: PermissionsService,\n httpAuth: HttpAuthService,\n auditor: AuditorService,\n userInfo: UserInfoService,\n) {\n function manageDenyAuthorization(auditEvent: AuditorServiceEvent) {\n const error = new UnauthorizedError();\n auditEvent.fail({\n meta: {\n message: 'Not authorized to request the endpoint',\n },\n error: new UnauthorizedError(),\n });\n\n throw error;\n }\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowsOverviewForEntity',\n async (_c, req, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-overview-entity',\n request: req,\n });\n const targetEntity = req.body.targetEntity as string;\n const annotationWorkflowIds = req.body.annotationWorkflowIds as string[];\n try {\n const result = await routerApi.v2.getWorkflowsOverviewForEntity(\n targetEntity,\n annotationWorkflowIds,\n );\n\n const workflows = await filterAuthorizedWorkflows(\n req,\n permissions,\n httpAuth,\n result,\n );\n auditEvent.success({\n meta: {\n workflowsCount: workflows.overviews?.length,\n },\n });\n res.json(workflows);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowsOverview',\n async (_c, req, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-overview',\n request: req,\n });\n\n try {\n const result = await routerApi.v2.getWorkflowsOverview(\n buildPagination(req),\n getRequestFilters(req),\n );\n\n const workflows = await filterAuthorizedWorkflows(\n req,\n permissions,\n httpAuth,\n result,\n );\n auditEvent.success({\n meta: {\n workflowsCount: workflows.overviews?.length,\n },\n });\n res.json(workflows);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowSourceById',\n async (c, req, res, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-source',\n request: req,\n meta: {\n actionType: 'by-id',\n workflowId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n try {\n const result = await routerApi.v2.getWorkflowSourceById(workflowId);\n auditEvent.success();\n res.status(200).contentType('text/plain').send(result);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'executeWorkflow',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n const credentials = await httpAuth.credentials(req);\n const token = req.headers.authorization?.split(' ')[1];\n const initiatorEntity = await (\n await userInfo.getUserInfo(credentials)\n ).userEntityRef;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'execute-workflow',\n request: req,\n meta: {\n workflowId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const executeWorkflowRequestDTO = req.body;\n\n return routerApi.v2\n .executeWorkflow(\n executeWorkflowRequestDTO,\n workflowId,\n initiatorEntity,\n token,\n )\n .then(result => {\n auditEvent.success({ meta: { id: result.id } });\n return res.status(200).json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'retriggerInstance',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n const instanceId = c.request.params.instanceId as string;\n const token = req.headers.authorization?.split(' ')[1];\n const retriggerInstanceRequestDTO = req.body;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'retrigger-instance',\n request: req,\n meta: {\n workflowId,\n instanceId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n await routerApi.v2\n .retriggerInstance(\n workflowId,\n instanceId,\n retriggerInstanceRequestDTO,\n token,\n )\n .then(result => {\n auditEvent.success();\n return res.status(200).json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowOverviewById',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-overview',\n request: req,\n meta: {\n actionType: 'by-id',\n workflowId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n return routerApi.v2\n .getWorkflowOverviewById(workflowId)\n .then(result => {\n auditEvent.success({\n meta: {\n workflowId: result.workflowId,\n },\n });\n return res.json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowStatuses',\n async (_c, request: express.Request, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-statuses',\n request,\n });\n\n // Anyone is authorized to call this endpoint\n\n return routerApi.v2\n .getWorkflowStatuses()\n .then(result => {\n auditEvent.success();\n res.status(200).json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowInputSchemaById',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n const instanceId = c.request.query.instanceId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-input-schema',\n request: req,\n meta: {\n actionType: 'by-id',\n workflowId,\n instanceId,\n },\n });\n\n try {\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const workflowDefinition =\n await services.orchestratorService.fetchWorkflowInfo({\n definitionId: workflowId,\n });\n\n if (!workflowDefinition) {\n throw new Error(\n `Failed to fetch workflow info for workflow ${workflowId}`,\n );\n }\n const serviceUrl = workflowDefinition.serviceUrl;\n if (!serviceUrl) {\n throw new Error(\n `Service URL is not defined for workflow ${workflowId}`,\n );\n }\n\n const definition =\n await services.orchestratorService.fetchWorkflowDefinition({\n definitionId: workflowId,\n });\n\n if (!definition) {\n throw new Error(\n 'Failed to fetch workflow definition for workflow ${workflowId}',\n );\n }\n\n if (!definition.dataInputSchema) {\n res.status(200).json({});\n return;\n }\n\n const instanceVariables = instanceId\n ? await services.orchestratorService.fetchInstanceVariables({\n instanceId,\n })\n : undefined;\n\n const workflowData = instanceVariables\n ? services.dataInputSchemaService.extractWorkflowData(\n instanceVariables,\n )\n : undefined;\n\n const workflowInfo = await routerApi.v2.getWorkflowInputSchemaById(\n workflowId,\n serviceUrl,\n );\n\n if (!workflowInfo?.inputSchema?.properties) {\n auditEvent.success({\n meta: {\n message: 'Successfully found nothing.',\n },\n });\n res.status(200).json({});\n return;\n }\n\n const inputSchemaProps = workflowInfo.inputSchema.properties;\n let inputData;\n\n if (workflowData) {\n inputData = Object.keys(inputSchemaProps)\n .filter(k => k in workflowData)\n .reduce((result, k) => {\n if (workflowData[k] === undefined) {\n return result;\n }\n result[k] = workflowData[k];\n return result;\n }, {} as JsonObject);\n }\n\n auditEvent.success({\n meta: {\n workflowId: workflowInfo.id,\n },\n });\n res.status(200).json({\n inputSchema: workflowInfo.inputSchema,\n data: inputData,\n });\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowInstances',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-instances',\n request: req,\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n return routerApi.v2\n .getInstances(buildPagination(req), getRequestFilters(req), [\n workflowId,\n ])\n .then(result => {\n auditEvent.success();\n res.json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'pingWorkflowServiceById',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'ping-workflow-service',\n request: req,\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n return routerApi.v2\n .pingWorkflowService(workflowId)\n .then(result => {\n auditEvent.success();\n res.json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getInstances',\n async (_c, req: express.Request, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-instances',\n request: req,\n });\n\n try {\n // Once we assign user to the instance in the future, we can rework this filtering\n const allWorkflowIds = routerApi.v2.getWorkflowIds();\n const authorizedWorkflowIds: string[] =\n await filterAuthorizedWorkflowIds(\n req,\n permissions,\n httpAuth,\n allWorkflowIds,\n );\n\n if (!authorizedWorkflowIds || authorizedWorkflowIds.length === 0)\n res.json([]);\n\n const credentials = await httpAuth.credentials(req);\n const initiatorEntity = (await userInfo.getUserInfo(credentials))\n .userEntityRef;\n const isUserAuthorizedForInstanceAdminView: boolean = // This permission will let user see ALL instances (including ones others created)\n await isUserAuthorizedForInstanceAdminViewPermission(\n req,\n permissions,\n httpAuth,\n );\n\n const requestFilters = getRequestFilters(req);\n\n let filters = requestFilters;\n\n if (!isUserAuthorizedForInstanceAdminView) {\n const initiatorEntityFilter: FieldFilter = {\n operator: 'EQ',\n value: initiatorEntity,\n field: 'initiatorEntity',\n };\n\n const nestedVariablesFilter: NestedFilter = {\n field: 'variables',\n nested: initiatorEntityFilter,\n };\n\n if (requestFilters === undefined) {\n filters = nestedVariablesFilter;\n } else {\n // combine filters\n filters = {\n operator: 'AND',\n filters: [nestedVariablesFilter, requestFilters],\n };\n }\n }\n\n const result = await routerApi.v2.getInstances(\n buildPagination(req),\n filters,\n authorizedWorkflowIds,\n );\n\n auditEvent.success({ meta: { authorizedWorkflowIds } });\n res.json(result);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getInstanceById',\n async (c, request: express.Request, res: express.Response, next) => {\n const instanceId = c.request.params.instanceId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-instance',\n request,\n meta: {\n actionType: 'by-id',\n instanceId,\n },\n });\n\n try {\n const instance = await routerApi.v2.getInstanceById(instanceId);\n\n const workflowId = instance.processId;\n\n const decision = await authorize(\n request,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const credentials = await httpAuth.credentials(request);\n const initiatorEntity = (await userInfo.getUserInfo(credentials))\n .userEntityRef;\n // Check if user is authorized to view all instances\n const isUserAuthorizedForInstanceAdminView =\n await isUserAuthorizedForInstanceAdminViewPermission(\n request,\n permissions,\n httpAuth,\n );\n\n // If not an admin, enforce initiatorEntity check\n if (!isUserAuthorizedForInstanceAdminView) {\n const instanceInitiatorEntity = instance.initiatorEntity;\n if (instanceInitiatorEntity !== initiatorEntity) {\n throw new Error(\n `Unauthorized to access instance ${instanceId} not initiated by user.`,\n );\n }\n }\n\n auditEvent.success();\n res.status(200).json(instance);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'abortWorkflow',\n async (c, request, res, next) => {\n const instanceId = c.request.params.instanceId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'abort-workflow',\n request,\n meta: {\n actionType: 'by-id',\n instanceId,\n },\n });\n\n try {\n const instance = await routerApi.v2.getInstanceById(instanceId);\n const workflowId = instance.processId;\n\n const decision = await authorize(\n request,\n [\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const result = await routerApi.v2.abortWorkflow(workflowId, instanceId);\n auditEvent.success({ meta: { result } });\n res.status(200).json(result);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n}\n\n// ======================================================\n// External SonataFlow API calls to delegate to Backstage\n// ======================================================\nfunction setupExternalRoutes(\n router: express.Router,\n discovery: DiscoveryApi,\n scaffolderService: ScaffolderService,\n auditor: AuditorService,\n) {\n router.get('/actions', async (req, res) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'actions',\n request: req,\n });\n const scaffolderUrl = await discovery.getBaseUrl('scaffolder');\n const response = await fetch(`${scaffolderUrl}/v2/actions`);\n const json = await response.json();\n auditEvent.success();\n res.status(response.status).json(json);\n });\n\n router.post('/actions/:actionId', async (req, res) => {\n const { actionId } = req.params;\n const instanceId: string | undefined = req.header('kogitoprocinstanceid');\n const body: JsonObject = (await req.body) as JsonObject;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'actions',\n request: req,\n meta: {\n actionType: 'by-id',\n instanceId,\n },\n });\n\n const filteredBody = Object.fromEntries(\n Object.entries(body).filter(\n ([, value]) => value !== undefined && value !== null,\n ),\n );\n\n const result: JsonValue = await scaffolderService.executeAction({\n actionId,\n instanceId,\n input: filteredBody,\n });\n auditEvent.success();\n res.status(200).json(result);\n });\n}\n\nfunction getRequestFilters(req: HttpRequest): Filter | undefined {\n return req.body.filters ? (req.body.filters as Filter) : undefined;\n}\n"],"names":["AuthorizeResult","orchestratorInstanceAdminViewPermission","orchestratorWorkflowPermission","orchestratorWorkflowSpecificPermission","Router","createPermissionIntegrationRouter","orchestratorPermissions","express","ScaffolderService","MiddlewareFactory","DataIndexService","SonataFlowService","WorkflowCacheService","OrchestratorService","DataInputSchemaService","OpenAPIBackend","openApiDocument","fullFormats","v2","V2","UnauthorizedError","buildPagination","orchestratorWorkflowUsePermission","orchestratorWorkflowUseSpecificPermission"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAM,SAAA,GAAY,OAChB,OAAA,EACA,gBAAA,EACA,gBACA,QAAA,KACyC;AACzC,EAAA,MAAM,WAAA,GAAc,MAAM,QAAA,CAAS,WAAA,CAAY,OAAO,CAAA;AACtD,EAAA,MAAM,iBAAA,GAAqD,MAAM,OAAA,CAAQ,GAAA;AAAA,IACvE,gBAAA,CAAiB,GAAA;AAAA,MAAI,gBACnB,cAAA,CAAe,SAAA,CAAU,CAAC,EAAE,UAAA,EAAY,CAAA,EAAG;AAAA,QACzC;AAAA,OACD;AAAA;AACH,GACF;AACA,EAAA,MAAM,YAA2C,iBAAA,CAAkB,GAAA;AAAA,IACjE,CAAA,CAAA,KAAK,EAAE,CAAC;AAAA,GACV;AAEA,EAAA,MAAM,QAAQ,SAAA,CAAU,IAAA,CAAK,OAAK,CAAA,CAAE,MAAA,KAAWA,uCAAgB,KAAK,CAAA;AACpE,EAAA,OACE,KAAA,IAAS;AAAA,IACP,QAAQA,sCAAA,CAAgB;AAAA,GAC1B;AAEJ,CAAA;AAEA,MAAM,8CAAA,GAAiD,OACrD,OAAA,EACA,cAAA,EACA,QAAA,KACqB;AACrB,EAAA,MAAM,WAAA,GAAc,MAAM,QAAA,CAAS,WAAA,CAAY,OAAO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A,KAAU;AAAA;AAClD,KACF;AAEA,IAAA,MAAM,MAAA,GAAoB,MAAM,iBAAA,CAAkB,aAAA,CAAc;AAAA,MAC9D,QAAA;AAAA,MACA,UAAA;AAAA,MACA,KAAA,EAAO;AAAA,KACR,CAAA;AACD,IAAA,UAAA,CAAW,OAAA,EAAQ;AACnB,IAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAAA,EAC7B,CAAC,CAAA;AACH;AAEA,SAAS,kBAAkB,GAAA,EAAsC;AAC/D,EAAA,OAAO,GAAA,CAAI,IAAA,CAAK,OAAA,GAAW,GAAA,CAAI,KAAK,OAAA,GAAqB,MAAA;AAC3D;;;;"}
1
+ {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.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 */\n\nimport { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';\nimport {\n AuditorService,\n AuditorServiceEvent,\n HttpAuthService,\n LoggerService,\n PermissionsService,\n SchedulerService,\n UserInfoService,\n} from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\nimport {\n AuthorizePermissionRequest,\n AuthorizePermissionResponse,\n AuthorizeResult,\n BasicPermission,\n} from '@backstage/plugin-permission-common';\nimport { createPermissionIntegrationRouter } from '@backstage/plugin-permission-node';\nimport type { JsonObject } from '@backstage/types';\n\nimport { UnauthorizedError } from '@backstage-community/plugin-rbac-common';\nimport { fullFormats } from 'ajv-formats/dist/formats';\nimport express, { Router } from 'express';\nimport { Request as HttpRequest } from 'express-serve-static-core';\nimport { OpenAPIBackend, Request } from 'openapi-backend';\n\nimport {\n FieldFilter,\n Filter,\n NestedFilter,\n openApiDocument,\n orchestratorInstanceAdminViewPermission,\n orchestratorPermissions,\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission,\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission,\n WorkflowOverviewListResultDTO,\n} from '@red-hat-developer-hub/backstage-plugin-orchestrator-common';\n\nimport { RouterOptions } from '../routerWrapper';\nimport { buildPagination } from '../types/pagination';\nimport { V2 } from './api/v2';\nimport { DataIndexService } from './DataIndexService';\nimport { DataInputSchemaService } from './DataInputSchemaService';\nimport { OrchestratorService } from './OrchestratorService';\nimport { SonataFlowService } from './SonataFlowService';\nimport { WorkflowCacheService } from './WorkflowCacheService';\n\ninterface PublicServices {\n dataInputSchemaService: DataInputSchemaService;\n orchestratorService: OrchestratorService;\n}\n\ninterface RouterApi {\n openApiBackend: OpenAPIBackend;\n v2: V2;\n}\n\nconst authorize = async (\n request: HttpRequest,\n anyOfPermissions: BasicPermission[],\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n): Promise<AuthorizePermissionResponse> => {\n const credentials = await httpAuth.credentials(request);\n const decisionResponses: AuthorizePermissionResponse[][] = await Promise.all(\n anyOfPermissions.map(permission =>\n permissionsSvc.authorize([{ permission }], {\n credentials,\n }),\n ),\n );\n const decisions: AuthorizePermissionResponse[] = decisionResponses.map(\n d => d[0],\n );\n\n const allow = decisions.find(d => d.result === AuthorizeResult.ALLOW);\n return (\n allow || {\n result: AuthorizeResult.DENY,\n }\n );\n};\n\nconst isUserAuthorizedForInstanceAdminViewPermission = async (\n request: HttpRequest,\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n): Promise<boolean> => {\n const credentials = await httpAuth.credentials(request);\n const [decision] = await permissionsSvc.authorize(\n [{ permission: orchestratorInstanceAdminViewPermission }],\n { credentials },\n );\n\n return decision.result === AuthorizeResult.ALLOW;\n};\n\nconst filterAuthorizedWorkflowIds = async (\n request: HttpRequest,\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n workflowIds: string[],\n): Promise<string[]> => {\n const credentials = await httpAuth.credentials(request);\n const genericWorkflowPermissionDecision = await permissionsSvc.authorize(\n [{ permission: orchestratorWorkflowPermission }],\n {\n credentials,\n },\n );\n\n if (genericWorkflowPermissionDecision[0].result === AuthorizeResult.ALLOW) {\n // The user can see all workflows\n return workflowIds;\n }\n\n const specificWorkflowRequests: AuthorizePermissionRequest[] =\n workflowIds.map(workflowId => ({\n permission: orchestratorWorkflowSpecificPermission(workflowId),\n }));\n\n const decisions = await permissionsSvc.authorize(specificWorkflowRequests, {\n credentials,\n });\n\n return workflowIds.filter(\n (_, idx) => decisions[idx].result === AuthorizeResult.ALLOW,\n );\n};\n\nconst filterAuthorizedWorkflows = async (\n request: HttpRequest,\n permissionsSvc: PermissionsService,\n httpAuth: HttpAuthService,\n workflows: WorkflowOverviewListResultDTO,\n): Promise<WorkflowOverviewListResultDTO> => {\n if (!workflows.overviews) {\n return workflows;\n }\n\n const authorizedWorkflowIds = await filterAuthorizedWorkflowIds(\n request,\n permissionsSvc,\n httpAuth,\n workflows.overviews.map(w => w.workflowId),\n );\n\n const filtered = {\n ...workflows,\n overviews: workflows.overviews.filter(w =>\n authorizedWorkflowIds.includes(w.workflowId),\n ),\n };\n\n return filtered;\n};\n\nexport async function createBackendRouter(\n options: RouterOptions,\n): Promise<Router> {\n const {\n config,\n logger,\n auditor,\n scheduler,\n permissions,\n httpAuth,\n userInfo,\n } = options;\n const publicServices = initPublicServices(logger, config, scheduler);\n\n const routerApi = await initRouterApi(publicServices.orchestratorService);\n\n const router = Router();\n const permissionsIntegrationRouter = createPermissionIntegrationRouter({\n permissions: orchestratorPermissions,\n });\n router.use(express.json());\n router.use(permissionsIntegrationRouter);\n router.use('/workflows', express.text());\n router.get('/health', (_, response) => {\n logger.info('PONG!');\n response.json({ status: 'ok' });\n });\n\n setupInternalRoutes(\n publicServices,\n routerApi,\n permissions,\n httpAuth,\n auditor,\n userInfo,\n );\n\n router.use((req, res, next) => {\n if (!next) {\n throw new Error('next is undefined');\n }\n\n return routerApi.openApiBackend\n .handleRequest(req as Request, req, res, next)\n .catch(error => {\n auditor\n .createEvent({\n eventId: 'generic-error-handler',\n request: req,\n // Keep at high since this is a fallback - any error should be caught in handlers\n severityLevel: 'high',\n meta: {},\n })\n .then(event => {\n event.fail({\n meta: {},\n error,\n });\n });\n\n next(error);\n });\n });\n\n const middleware = MiddlewareFactory.create({ logger, config });\n\n router.use(middleware.error({ logAllErrors: true })); // log also openapi errors\n\n return router;\n}\n\nfunction initPublicServices(\n logger: LoggerService,\n config: Config,\n scheduler: SchedulerService,\n): PublicServices {\n const dataIndexUrl = config.getString('orchestrator.dataIndexService.url');\n const dataIndexService = new DataIndexService(dataIndexUrl, logger);\n const sonataFlowService = new SonataFlowService(dataIndexService, logger);\n\n const workflowCacheService = new WorkflowCacheService(\n logger,\n dataIndexService,\n sonataFlowService,\n );\n workflowCacheService.schedule({ scheduler: scheduler });\n\n const orchestratorService = new OrchestratorService(\n sonataFlowService,\n dataIndexService,\n workflowCacheService,\n );\n\n const dataInputSchemaService = new DataInputSchemaService();\n\n return {\n orchestratorService,\n dataInputSchemaService,\n };\n}\n\nasync function initRouterApi(\n orchestratorService: OrchestratorService,\n): Promise<RouterApi> {\n const openApiBackend = new OpenAPIBackend({\n definition: openApiDocument,\n strict: false,\n ajvOpts: {\n strict: false,\n strictSchema: false,\n verbose: true,\n addUsedSchema: false,\n formats: fullFormats, // open issue: https://github.com/openapistack/openapi-backend/issues/280\n },\n handlers: {\n validationFail: async (\n c,\n _req: express.Request,\n res: express.Response,\n ) => {\n console.log('OPENAPI validationFail', c.operation);\n res.status(400).json({ err: c.validation.errors });\n },\n notFound: async (_c, req: express.Request, res: express.Response) => {\n res.status(404).json({ err: `${req.path} path not found` });\n },\n notImplemented: async (_c, req: express.Request, res: express.Response) =>\n res.status(500).json({ err: `${req.path} not implemented` }),\n },\n });\n await openApiBackend.init();\n const v2 = new V2(orchestratorService);\n return { v2, openApiBackend };\n}\n\n// ======================================================\n// Internal Backstage API calls to delegate to SonataFlow\n// ======================================================\nfunction setupInternalRoutes(\n services: PublicServices,\n routerApi: RouterApi,\n permissions: PermissionsService,\n httpAuth: HttpAuthService,\n auditor: AuditorService,\n userInfo: UserInfoService,\n) {\n function manageDenyAuthorization(auditEvent: AuditorServiceEvent) {\n const error = new UnauthorizedError();\n auditEvent.fail({\n meta: {\n message: 'Not authorized to request the endpoint',\n },\n error: new UnauthorizedError(),\n });\n\n throw error;\n }\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowsOverviewForEntity',\n async (_c, req, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-overview-entity',\n request: req,\n });\n const targetEntity = req.body.targetEntity as string;\n const annotationWorkflowIds = req.body.annotationWorkflowIds as string[];\n try {\n const result = await routerApi.v2.getWorkflowsOverviewForEntity(\n targetEntity,\n annotationWorkflowIds,\n );\n\n const workflows = await filterAuthorizedWorkflows(\n req,\n permissions,\n httpAuth,\n result,\n );\n auditEvent.success({\n meta: {\n workflowsCount: workflows.overviews?.length,\n },\n });\n res.json(workflows);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowsOverview',\n async (_c, req, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-overview',\n request: req,\n });\n\n try {\n const result = await routerApi.v2.getWorkflowsOverview(\n buildPagination(req),\n getRequestFilters(req),\n );\n\n const workflows = await filterAuthorizedWorkflows(\n req,\n permissions,\n httpAuth,\n result,\n );\n auditEvent.success({\n meta: {\n workflowsCount: workflows.overviews?.length,\n },\n });\n res.json(workflows);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowSourceById',\n async (c, req, res, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-source',\n request: req,\n meta: {\n actionType: 'by-id',\n workflowId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n try {\n const result = await routerApi.v2.getWorkflowSourceById(workflowId);\n auditEvent.success();\n res.status(200).contentType('text/plain').send(result);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'executeWorkflow',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n const credentials = await httpAuth.credentials(req);\n const token = req.headers.authorization?.split(' ')[1];\n const initiatorEntity = await (\n await userInfo.getUserInfo(credentials)\n ).userEntityRef;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'execute-workflow',\n request: req,\n meta: {\n workflowId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const executeWorkflowRequestDTO = req.body;\n\n return routerApi.v2\n .executeWorkflow(\n executeWorkflowRequestDTO,\n workflowId,\n initiatorEntity,\n token,\n )\n .then(result => {\n auditEvent.success({ meta: { id: result.id } });\n return res.status(200).json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'retriggerInstance',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n const instanceId = c.request.params.instanceId as string;\n const token = req.headers.authorization?.split(' ')[1];\n const retriggerInstanceRequestDTO = req.body;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'retrigger-instance',\n request: req,\n meta: {\n workflowId,\n instanceId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n await routerApi.v2\n .retriggerInstance(\n workflowId,\n instanceId,\n retriggerInstanceRequestDTO,\n token,\n )\n .then(result => {\n auditEvent.success();\n return res.status(200).json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowOverviewById',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-overview',\n request: req,\n meta: {\n actionType: 'by-id',\n workflowId,\n },\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n return routerApi.v2\n .getWorkflowOverviewById(workflowId)\n .then(result => {\n auditEvent.success({\n meta: {\n workflowId: result.workflowId,\n },\n });\n return res.json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowStatuses',\n async (_c, request: express.Request, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-statuses',\n request,\n });\n\n // Anyone is authorized to call this endpoint\n\n return routerApi.v2\n .getWorkflowStatuses()\n .then(result => {\n auditEvent.success();\n res.status(200).json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowInputSchemaById',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n const instanceId = c.request.query.instanceId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-input-schema',\n request: req,\n meta: {\n actionType: 'by-id',\n workflowId,\n instanceId,\n },\n });\n\n try {\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const workflowDefinition =\n await services.orchestratorService.fetchWorkflowInfo({\n definitionId: workflowId,\n });\n\n if (!workflowDefinition) {\n throw new Error(\n `Failed to fetch workflow info for workflow ${workflowId}`,\n );\n }\n const serviceUrl = workflowDefinition.serviceUrl;\n if (!serviceUrl) {\n throw new Error(\n `Service URL is not defined for workflow ${workflowId}`,\n );\n }\n\n const definition =\n await services.orchestratorService.fetchWorkflowDefinition({\n definitionId: workflowId,\n });\n\n if (!definition) {\n throw new Error(\n 'Failed to fetch workflow definition for workflow ${workflowId}',\n );\n }\n\n if (!definition.dataInputSchema) {\n res.status(200).json({});\n return;\n }\n\n const instanceVariables = instanceId\n ? await services.orchestratorService.fetchInstanceVariables({\n instanceId,\n })\n : undefined;\n\n const workflowData = instanceVariables\n ? services.dataInputSchemaService.extractWorkflowData(\n instanceVariables,\n )\n : undefined;\n\n const workflowInfo = await routerApi.v2.getWorkflowInputSchemaById(\n workflowId,\n serviceUrl,\n );\n\n if (!workflowInfo?.inputSchema?.properties) {\n auditEvent.success({\n meta: {\n message: 'Successfully found nothing.',\n },\n });\n res.status(200).json({});\n return;\n }\n\n const inputSchemaProps = workflowInfo.inputSchema.properties;\n let inputData;\n\n if (workflowData) {\n inputData = Object.keys(inputSchemaProps)\n .filter(k => k in workflowData)\n .reduce((result, k) => {\n if (workflowData[k] === undefined) {\n return result;\n }\n result[k] = workflowData[k];\n return result;\n }, {} as JsonObject);\n }\n\n auditEvent.success({\n meta: {\n workflowId: workflowInfo.id,\n },\n });\n res.status(200).json({\n inputSchema: workflowInfo.inputSchema,\n data: inputData,\n });\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getWorkflowInstances',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-workflow-instances',\n request: req,\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n return routerApi.v2\n .getInstances(buildPagination(req), getRequestFilters(req), [\n workflowId,\n ])\n .then(result => {\n auditEvent.success();\n res.json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'pingWorkflowServiceById',\n async (c, req: express.Request, res: express.Response, next) => {\n const workflowId = c.request.params.workflowId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'ping-workflow-service',\n request: req,\n });\n\n const decision = await authorize(\n req,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n return routerApi.v2\n .pingWorkflowService(workflowId)\n .then(result => {\n auditEvent.success();\n res.json(result);\n })\n .catch(error => {\n auditEvent.fail({ error });\n next(error);\n });\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getInstances',\n async (_c, req: express.Request, res: express.Response, next) => {\n const auditEvent = await auditor.createEvent({\n eventId: 'get-instances',\n request: req,\n });\n\n try {\n // Once we assign user to the instance in the future, we can rework this filtering\n const allWorkflowIds = routerApi.v2.getWorkflowIds();\n const authorizedWorkflowIds: string[] =\n await filterAuthorizedWorkflowIds(\n req,\n permissions,\n httpAuth,\n allWorkflowIds,\n );\n\n if (!authorizedWorkflowIds || authorizedWorkflowIds.length === 0)\n res.json([]);\n\n const credentials = await httpAuth.credentials(req);\n const initiatorEntity = (await userInfo.getUserInfo(credentials))\n .userEntityRef;\n const isUserAuthorizedForInstanceAdminView: boolean = // This permission will let user see ALL instances (including ones others created)\n await isUserAuthorizedForInstanceAdminViewPermission(\n req,\n permissions,\n httpAuth,\n );\n\n const requestFilters = getRequestFilters(req);\n\n let filters = requestFilters;\n\n if (!isUserAuthorizedForInstanceAdminView) {\n const initiatorEntityFilter: FieldFilter = {\n operator: 'EQ',\n value: initiatorEntity,\n field: 'initiatorEntity',\n };\n\n const nestedVariablesFilter: NestedFilter = {\n field: 'variables',\n nested: initiatorEntityFilter,\n };\n\n if (requestFilters === undefined) {\n filters = nestedVariablesFilter;\n } else {\n // combine filters\n filters = {\n operator: 'AND',\n filters: [nestedVariablesFilter, requestFilters],\n };\n }\n }\n\n const result = await routerApi.v2.getInstances(\n buildPagination(req),\n filters,\n authorizedWorkflowIds,\n );\n\n auditEvent.success({ meta: { authorizedWorkflowIds } });\n res.json(result);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'getInstanceById',\n async (c, request: express.Request, res: express.Response, next) => {\n const instanceId = c.request.params.instanceId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'get-instance',\n request,\n meta: {\n actionType: 'by-id',\n instanceId,\n },\n });\n\n try {\n const instance = await routerApi.v2.getInstanceById(instanceId);\n\n const workflowId = instance.processId;\n\n const decision = await authorize(\n request,\n [\n orchestratorWorkflowPermission,\n orchestratorWorkflowSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const credentials = await httpAuth.credentials(request);\n const initiatorEntity = (await userInfo.getUserInfo(credentials))\n .userEntityRef;\n // Check if user is authorized to view all instances\n const isUserAuthorizedForInstanceAdminView =\n await isUserAuthorizedForInstanceAdminViewPermission(\n request,\n permissions,\n httpAuth,\n );\n\n // If not an admin, enforce initiatorEntity check\n if (!isUserAuthorizedForInstanceAdminView) {\n const instanceInitiatorEntity = instance.initiatorEntity;\n if (instanceInitiatorEntity !== initiatorEntity) {\n throw new Error(\n `Unauthorized to access instance ${instanceId} not initiated by user.`,\n );\n }\n }\n\n auditEvent.success();\n res.status(200).json(instance);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n\n // v2\n routerApi.openApiBackend.register(\n 'abortWorkflow',\n async (c, request, res, next) => {\n const instanceId = c.request.params.instanceId as string;\n\n const auditEvent = await auditor.createEvent({\n eventId: 'abort-workflow',\n request,\n meta: {\n actionType: 'by-id',\n instanceId,\n },\n });\n\n try {\n const instance = await routerApi.v2.getInstanceById(instanceId);\n const workflowId = instance.processId;\n\n const decision = await authorize(\n request,\n [\n orchestratorWorkflowUsePermission,\n orchestratorWorkflowUseSpecificPermission(workflowId),\n ],\n permissions,\n httpAuth,\n );\n if (decision.result === AuthorizeResult.DENY) {\n manageDenyAuthorization(auditEvent);\n }\n\n const result = await routerApi.v2.abortWorkflow(workflowId, instanceId);\n auditEvent.success({ meta: { result } });\n res.status(200).json(result);\n } catch (error) {\n auditEvent.fail({ error });\n next(error);\n }\n },\n );\n}\n\nfunction getRequestFilters(req: HttpRequest): Filter | undefined {\n return req.body.filters ? (req.body.filters as Filter) : undefined;\n}\n"],"names":["AuthorizeResult","orchestratorInstanceAdminViewPermission","orchestratorWorkflowPermission","orchestratorWorkflowSpecificPermission","Router","createPermissionIntegrationRouter","orchestratorPermissions","express","MiddlewareFactory","DataIndexService","SonataFlowService","WorkflowCacheService","OrchestratorService","DataInputSchemaService","OpenAPIBackend","openApiDocument","fullFormats","v2","V2","UnauthorizedError","buildPagination","orchestratorWorkflowUsePermission","orchestratorWorkflowUseSpecificPermission"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2EA,MA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AAC5C,UAAA,uBAAA,CAAwB,UAAU,CAAA;AAAA,QACpC;AAEA,QAAA,MAAM,SAAS,MAAM,SAAA,CAAU,EAAA,CAAG,aAAA,CAAc,YAAY,UAAU,CAAA;AACtE,QAAA,UAAA,CAAW,QAAQ,EAAE,IAAA,EAAM,EAAE,MAAA,IAAU,CAAA;AACvC,QAAA,GAAA,CAAI,MAAA,CAAO,GAAG,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAAA,MAC7B,SAAS,KAAA,EAAO;AACd,QAAA,UAAA,CAAW,IAAA,CAAK,EAAE,KAAA,EAAO,CAAA;AACzB,QAAA,IAAA,CAAK,KAAK,CAAA;AAAA,MACZ;AAAA,IACF;AAAA,GACF;AACF;AAEA,SAAS,kBAAkB,GAAA,EAAsC;AAC/D,EAAA,OAAO,GAAA,CAAI,IAAA,CAAK,OAAA,GAAW,GAAA,CAAI,KAAK,OAAA,GAAqB,MAAA;AAC3D;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@red-hat-developer-hub/backstage-plugin-orchestrator-backend",
3
- "version": "8.1.0",
3
+ "version": "8.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
@@ -73,19 +73,18 @@
73
73
  "export-dynamic": "janus-cli package export-dynamic-plugin"
74
74
  },
75
75
  "dependencies": {
76
- "@backstage/backend-defaults": "^0.10.0",
77
- "@backstage/backend-plugin-api": "^1.3.1",
78
- "@backstage/backend-tasks": "^0.6.1",
79
- "@backstage/catalog-client": "^1.10.0",
80
- "@backstage/core-plugin-api": "^1.10.7",
76
+ "@backstage/backend-defaults": "^0.12.0",
77
+ "@backstage/backend-plugin-api": "^1.4.2",
78
+ "@backstage/catalog-client": "^1.11.0",
79
+ "@backstage/core-plugin-api": "^1.10.9",
81
80
  "@backstage/errors": "^1.2.7",
82
- "@backstage/integration": "^1.17.0",
83
- "@backstage/plugin-catalog-node": "^1.17.0",
84
- "@backstage/plugin-permission-common": "^0.9.0",
85
- "@backstage/plugin-permission-node": "^0.10.0",
86
- "@backstage/plugin-scaffolder-backend": "^1.33.0",
87
- "@backstage/plugin-scaffolder-node": "^0.9.0",
88
- "@red-hat-developer-hub/backstage-plugin-orchestrator-common": "^3.0.6",
81
+ "@backstage/integration": "^1.17.1",
82
+ "@backstage/plugin-catalog-node": "^1.18.0",
83
+ "@backstage/plugin-permission-common": "^0.9.1",
84
+ "@backstage/plugin-permission-node": "^0.10.3",
85
+ "@backstage/plugin-scaffolder-backend": "^2.2.0",
86
+ "@backstage/plugin-scaffolder-node": "^0.11.0",
87
+ "@red-hat-developer-hub/backstage-plugin-orchestrator-common": "^3.1.0",
89
88
  "@urql/core": "^4.1.4",
90
89
  "ajv-formats": "^2.1.1",
91
90
  "cloudevents": "^8.0.0",
@@ -100,8 +99,8 @@
100
99
  },
101
100
  "devDependencies": {
102
101
  "@backstage-community/plugin-rbac-common": "^1.12.1",
103
- "@backstage/backend-test-utils": "^1.5.0",
104
- "@backstage/cli": "^0.32.1",
102
+ "@backstage/backend-test-utils": "^1.8.0",
103
+ "@backstage/cli": "^0.34.1",
105
104
  "@janus-idp/backstage-plugin-audit-log-node": "^1.7.1",
106
105
  "@janus-idp/cli": "3.6.1",
107
106
  "@types/express": "4.17.23",
@@ -1,91 +0,0 @@
1
- 'use strict';
2
-
3
- var integration = require('@backstage/integration');
4
- var pluginScaffolderBackend = require('@backstage/plugin-scaffolder-backend');
5
- var fs = require('fs-extra');
6
- var crypto = require('crypto');
7
- var path = require('path');
8
- var Helper = require('./Helper.cjs.js');
9
-
10
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
-
12
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
13
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
14
-
15
- class ScaffolderService {
16
- constructor(logger, config, catalogApi, urlReader) {
17
- this.logger = logger;
18
- this.config = config;
19
- this.catalogApi = catalogApi;
20
- this.urlReader = urlReader;
21
- this.actionRegistry = new pluginScaffolderBackend.TemplateActionRegistry();
22
- }
23
- actionRegistry;
24
- loadActions() {
25
- const actions = [
26
- ...pluginScaffolderBackend.createBuiltinActions({
27
- integrations: integration.ScmIntegrations.fromConfig(this.config),
28
- catalogClient: this.catalogApi,
29
- reader: this.urlReader,
30
- config: this.config
31
- })
32
- ];
33
- actions.forEach((a) => this.actionRegistry.register(a));
34
- }
35
- getAction(id) {
36
- return this.actionRegistry.get(id);
37
- }
38
- async executeAction(actionExecutionContext) {
39
- if (this.actionRegistry.list().length === 0) {
40
- this.loadActions();
41
- }
42
- const action = this.getAction(
43
- actionExecutionContext.actionId
44
- );
45
- const stepOutput = {};
46
- let workspacePath;
47
- try {
48
- const workingDirectory = await Helper.getWorkingDirectory(
49
- this.config,
50
- this.logger
51
- );
52
- workspacePath = path__default.default.join(
53
- workingDirectory,
54
- actionExecutionContext.instanceId ?? crypto.randomUUID()
55
- );
56
- } catch (err) {
57
- this.logger.error(
58
- `Error getting working directory to execute action ${actionExecutionContext.actionId}`,
59
- err
60
- );
61
- throw err;
62
- }
63
- const actionContext = {
64
- input: actionExecutionContext.input,
65
- workspacePath,
66
- logger: this.logger,
67
- createTemporaryDirectory: async () => await fs__default.default.mkdtemp(`${workspacePath}_step-${0}-`),
68
- output(name, value) {
69
- stepOutput[name] = value;
70
- },
71
- getInitiatorCredentials: async () => {
72
- return {
73
- $$type: "@backstage/BackstageCredentials",
74
- principal: "mock-principal"
75
- };
76
- },
77
- checkpoint: async ({ key, fn }) => {
78
- this.logger.info(`Orchestrator ScaffolderService checkpoint ${key}`);
79
- return fn();
80
- },
81
- task: {
82
- id: "task-orchestrator"
83
- }
84
- };
85
- await action.handler(actionContext);
86
- return stepOutput;
87
- }
88
- }
89
-
90
- exports.ScaffolderService = ScaffolderService;
91
- //# sourceMappingURL=ScaffolderService.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScaffolderService.cjs.js","sources":["../../src/service/ScaffolderService.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 */\n\nimport type {\n LoggerService,\n UrlReaderService,\n} from '@backstage/backend-plugin-api';\nimport type { CatalogApi } from '@backstage/catalog-client';\nimport type { Config } from '@backstage/config';\nimport { ScmIntegrations } from '@backstage/integration';\nimport {\n createBuiltinActions,\n TemplateActionRegistry,\n} from '@backstage/plugin-scaffolder-backend';\nimport {\n ActionContext,\n TemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport type { JsonObject, JsonValue } from '@backstage/types';\n\nimport fs from 'fs-extra';\n\nimport { randomUUID } from 'crypto';\nimport path from 'path';\n\nimport { getWorkingDirectory } from './Helper';\n\nexport interface ActionExecutionContext {\n actionId: string;\n instanceId: string | undefined;\n input: JsonObject;\n}\n\nexport class ScaffolderService {\n private actionRegistry: TemplateActionRegistry;\n\n constructor(\n private readonly logger: LoggerService,\n private readonly config: Config,\n private readonly catalogApi: CatalogApi,\n private readonly urlReader: UrlReaderService,\n ) {\n this.actionRegistry = new TemplateActionRegistry();\n }\n\n public loadActions(): void {\n const actions = [\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(this.config),\n catalogClient: this.catalogApi,\n reader: this.urlReader,\n config: this.config,\n }),\n ];\n actions.forEach(a => this.actionRegistry.register(a));\n }\n\n public getAction(id: string): TemplateAction {\n return this.actionRegistry.get(id);\n }\n\n public async executeAction(\n actionExecutionContext: ActionExecutionContext,\n ): Promise<JsonValue> {\n if (this.actionRegistry.list().length === 0) {\n this.loadActions();\n }\n\n const action: TemplateAction = this.getAction(\n actionExecutionContext.actionId,\n );\n const stepOutput: { [outputName: string]: JsonValue } = {};\n\n let workspacePath: string;\n try {\n const workingDirectory = await getWorkingDirectory(\n this.config,\n this.logger,\n );\n workspacePath = path.join(\n workingDirectory,\n actionExecutionContext.instanceId ?? randomUUID(),\n );\n } catch (err: unknown) {\n this.logger.error(\n `Error getting working directory to execute action ${actionExecutionContext.actionId}`,\n err as Error,\n );\n throw err;\n }\n const actionContext: ActionContext<JsonObject> = {\n input: actionExecutionContext.input,\n workspacePath: workspacePath,\n logger: this.logger,\n createTemporaryDirectory: async () =>\n await fs.mkdtemp(`${workspacePath}_step-${0}-`),\n output(name: string, value: JsonValue) {\n stepOutput[name] = value;\n },\n getInitiatorCredentials: async () => {\n return {\n $$type: '@backstage/BackstageCredentials',\n principal: 'mock-principal',\n };\n },\n checkpoint: async ({ key, fn }) => {\n this.logger.info(`Orchestrator ScaffolderService checkpoint ${key}`);\n return fn();\n },\n task: {\n id: 'task-orchestrator',\n },\n };\n await action.handler(actionContext);\n\n return stepOutput;\n }\n}\n"],"names":["TemplateActionRegistry","createBuiltinActions","ScmIntegrations","getWorkingDirectory","path","randomUUID","fs"],"mappings":";;;;;;;;;;;;;;AA8CO,MAAM,iBAAA,CAAkB;AAAA,EAG7B,WAAA,CACmB,MAAA,EACA,MAAA,EACA,UAAA,EACA,SAAA,EACjB;AAJiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAEjB,IAAA,IAAA,CAAK,cAAA,GAAiB,IAAIA,8CAAA,EAAuB;AAAA,EACnD;AAAA,EATQ,cAAA;AAAA,EAWD,WAAA,GAAoB;AACzB,IAAA,MAAM,OAAA,GAAU;AAAA,MACd,GAAGC,4CAAA,CAAqB;AAAA,QACtB,YAAA,EAAcC,2BAAA,CA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