@backstage-community/plugin-scaffolder-backend-module-http-request 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ # @backstage-community/plugin-scaffolder-backend-module-http-request
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 6e1f38f: Publish the HTTP request scaffolder action in the community namespace. Install this package in place of `@roadiehq/scaffolder-backend-module-http-request` and import the backend module from the package root instead of `/new-backend`. The `http:backstage:request` action and existing templates remain unchanged.
package/README.md CHANGED
@@ -1,3 +1,206 @@
1
- # Temporary Holding Version
1
+ # @backstage-community/plugin-scaffolder-backend-module-http-request
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Originally developed by [Roadie](https://github.com/RoadieHQ/roadie-backstage-plugins/tree/main/plugins/scaffolder-actions/scaffolder-backend-module-http-request), this module provides the `http:backstage:request` scaffolder action.
4
+
5
+ ## Migrating from the Roadie package
6
+
7
+ Replace `@roadiehq/scaffolder-backend-module-http-request` with `@backstage-community/plugin-scaffolder-backend-module-http-request` in your backend dependencies and change the backend module import to the new package name. Remove the Roadie package after the switch. The action ID, template inputs and outputs remain the same; existing templates do not need changes. Import the backend module from the package root; the deprecated Roadie `/new-backend` entry point is not available in the community package.
8
+
9
+ This contains one action: `http:backstage:request`.
10
+
11
+ The `http:backstage:request` action allows the task to call any of the backstage APIs available to the user that triggers it. The action takes care of passing the authentication token of the user to the task execution so that the action can perform actions on behalf of the user that triggers it.
12
+
13
+ ## Getting started
14
+
15
+ Create your Backstage application using the Backstage CLI as described here:
16
+ https://backstage.io/docs/getting-started/create-an-app
17
+
18
+ > Note: If you are using this plugin in a Backstage monorepo that contains the code for `@backstage/plugin-scaffolder-backend`, you need to modify your internal build processes to transpile files from the `node_modules` folder as well.
19
+
20
+ You need to configure the action in your backend:
21
+
22
+ ## From your Backstage root directory
23
+
24
+ ```
25
+ cd packages/backend
26
+ yarn add @backstage-community/plugin-scaffolder-backend-module-http-request
27
+ ```
28
+
29
+ Configure the action:
30
+ (you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):
31
+
32
+ ```typescript
33
+ // Legacy backend registration (the new backend system below is recommended)
34
+ // packages/backend/src/plugins/scaffolder.ts
35
+ const actions = [
36
+ createHttpBackstageAction({ discovery }),
37
+ ...createBuiltinActions({
38
+ containerRunner,
39
+ integrations,
40
+ config,
41
+ catalogClient,
42
+ reader,
43
+ }),
44
+ ];
45
+
46
+ return await createRouter({
47
+ containerRunner,
48
+ logger,
49
+ config,
50
+ database,
51
+ catalogClient,
52
+ reader,
53
+ actions,
54
+ });
55
+ ```
56
+
57
+ ### New backend system
58
+
59
+ ## From your Backstage root directory
60
+
61
+ ```
62
+ cd packages/backend
63
+ yarn add @backstage-community/plugin-scaffolder-backend-module-http-request
64
+ ```
65
+
66
+ ```typescript
67
+ // packages/backend/src/index.ts
68
+ import { createBackend } from '@backstage/backend-defaults';
69
+ import { createBackendModule } from '@backstage/backend-plugin-api';
70
+
71
+ const backend = createBackend();
72
+ backend.add(import('@backstage/plugin-proxy-backend/alpha'));
73
+ backend.add(import('@backstage/plugin-scaffolder-backend/alpha'));
74
+ backend.add(
75
+ import('@backstage-community/plugin-scaffolder-backend-module-http-request'),
76
+ );
77
+ backend.start();
78
+ ```
79
+
80
+ ### Supported methods
81
+
82
+ Action supports following HTTP methods: `GET`, `HEAD`, `OPTIONS`, `POST`, `UPDATE`, `DELETE`, `PUT`, `PATCH`
83
+
84
+ The path should always point to a proxy entry with the following format: `proxy/<proxy-path>/<external-api-path>`
85
+
86
+ You can also point to the internal catalog apis like so: `/catalog/entities` See [https://backstage.io/docs/features/software-catalog/software-catalog-api/#get-entities](https://backstage.io/docs/features/software-catalog/software-catalog-api/#get-entities)
87
+
88
+ i.e.: `/proxy/snyk/org/<some-org>/projects` or `/proxy/circleci/api/projects` (NB: the CircleCI proxy path is `circleci/api/` but Snyk is just `snyk/`)
89
+
90
+ ### Example of using GET method
91
+
92
+ ```yaml
93
+ ---
94
+ apiVersion: scaffolder.backstage.io/v1beta3
95
+ kind: Template
96
+ metadata:
97
+ name: HTTP-testing
98
+ title: Http testing for post/get
99
+ description: Testing get functionality with get
100
+ spec:
101
+ owner: roadie
102
+ type: service
103
+
104
+ parameters:
105
+ - title: Fill in some params
106
+ properties:
107
+ httpGetPath:
108
+ title: Get Path
109
+ type: string
110
+ description: The path you want to get on your backstage instance
111
+ ui:autofocus: true
112
+ ui:options:
113
+ rows: 5
114
+
115
+ steps:
116
+ - id: backstage_request
117
+ name: backstage request
118
+ action: http:backstage:request
119
+ input:
120
+ method: 'GET'
121
+ path: '/proxy/snyk/org/<some-org>/project/<some-project-id>/aggregated-issues'
122
+ headers:
123
+ test: 'hello'
124
+ foo: 'bar'
125
+
126
+ output:
127
+ getResponse: '{{ steps.backstage_request.output.body }}'
128
+ getCode: '{{ steps.backstage_request.output.code }}'
129
+ getHeaders: '{{ steps.backstage_request.output.headers }}'
130
+ ```
131
+
132
+ ### Example of using POST method
133
+
134
+ If the request requires a body, it can be specified using the body parameter. There are two options here
135
+
136
+ 1. `content-type: application/json` header is specified. Everything under `body` hash will be converted into JSON string
137
+ 2. `content-type: application/json` header is not specified. `body` treated as a plain string
138
+
139
+ > [!IMPORTANT]
140
+ > For `application/json`, the header must be set in the template as shown. Setting the header in the proxy configuration will result in the body not being transformed to a JSON string.
141
+
142
+ ```yaml
143
+ steps:
144
+ - id: backstage_request
145
+ name: backstage request
146
+ action: http:backstage:request
147
+ input:
148
+ method: 'POST'
149
+ path: '/proxy/snyk/org/<some-org>/project/<some-project-id>/aggregated-issues'
150
+ headers:
151
+ content-type: 'application/json'
152
+ body:
153
+ name: 'test'
154
+ bar: 'foo'
155
+
156
+ output:
157
+ getResponse: '{{ steps.backstage_request.output.body }}'
158
+ getCode: '{{ steps.backstage_request.output.code }}'
159
+ getHeaders: '{{ steps.backstage_request.output.headers }}'
160
+ ```
161
+
162
+ Snippet above will send the following HTTP request:
163
+
164
+ ```sh
165
+ -------- 127.0.0.1:53321 | POST /
166
+ Headers
167
+ "Accept" : ["*/*"]
168
+ "Content-Type" : ["application/json"]
169
+ "Connection" : ["close"]
170
+ "User-Agent" : ["node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"]
171
+ "Content-Length" : ["27"]
172
+ 00000000 7b 22 6e 61 6d 65 22 3a 22 74 65 73 74 22 2c 22 |{"name":"test","|
173
+ 00000010 62 61 72 22 3a 22 66 6f 6f 22 7d |bar":"foo"}|
174
+ ```
175
+
176
+ ### Idempotency and task recovery (experimental)
177
+
178
+ When a template enables [experimental task recovery](https://backstage.io/docs/features/software-templates/experimental/#retries-and-recovery) (`spec.EXPERIMENTAL_recovery.EXPERIMENTAL_strategy: startOver`), a task that is interrupted (e.g. by a `scaffolder-backend` redeploy) is restarted from the beginning. By default that would re-send every `http:backstage:request` — duplicating non-idempotent side effects such as creating Jira tickets or other resources.
179
+
180
+ To make a request safe under recovery, set an `idempotencyKey`. The request is then wrapped in a [checkpoint](https://backstage.io/docs/features/software-templates/writing-custom-actions/#using-checkpoints-in-custom-actions-experimental): it is executed at most once per task, and on a restart the cached response is returned instead of sending the request again. The key must be stable and unique within the template.
181
+
182
+ ```yaml
183
+ steps:
184
+ - id: create_jira_ticket
185
+ name: Create Jira ticket
186
+ action: http:backstage:request
187
+ input:
188
+ method: 'POST'
189
+ path: '/proxy/jira/api/rest/api/latest/issue'
190
+ idempotencyKey: 'jira.create.parent'
191
+ headers:
192
+ content-type: 'application/json'
193
+ body:
194
+ fields:
195
+ project: { key: 'PROJ' }
196
+ summary: 'Created from Backstage'
197
+ issuetype: { name: 'Task' }
198
+ ```
199
+
200
+ When `idempotencyKey` is omitted, or when the scaffolder does not provide a checkpoint API, behaviour is unchanged and the request is sent on every run.
201
+
202
+ You can also visit the `/create/actions` route in your Backstage application to find out more about the parameters this action accepts when it's installed to configure how you like.
203
+
204
+ ---
205
+
206
+ This module was originally developed by Roadie. See the [original project](https://github.com/RoadieHQ/roadie-backstage-plugins) for its history.
@@ -0,0 +1,146 @@
1
+ 'use strict';
2
+
3
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
4
+ var helpers = require('./helpers.cjs.js');
5
+
6
+ function createHttpBackstageAction(options) {
7
+ const { discovery, auth } = options;
8
+ const actionId = "http:backstage:request";
9
+ return pluginScaffolderNode.createTemplateAction({
10
+ id: actionId,
11
+ description: "Sends a HTTP request to the Backstage API. It uses the token of the user who triggers the task to authenticate requests.",
12
+ supportsDryRun: true,
13
+ schema: {
14
+ input: (z) => z.object({
15
+ path: z.string().describe("The url path you want to query"),
16
+ method: z.enum([
17
+ "GET",
18
+ "HEAD",
19
+ "OPTIONS",
20
+ "POST",
21
+ "UPDATE",
22
+ "DELETE",
23
+ "PUT",
24
+ "PATCH"
25
+ ]).describe("The method type of the request"),
26
+ headers: z.record(z.any()).optional().describe("The headers you would like to pass to your request"),
27
+ params: z.record(z.any()).optional().describe(
28
+ "The query parameters you would like to pass to your request"
29
+ ),
30
+ body: z.any().optional().describe("The body you would like to pass to your request"),
31
+ logRequestPath: z.boolean().optional().describe("Option to turn request path logging off. On by default"),
32
+ continueOnBadResponse: z.boolean().optional().describe(
33
+ "Return response code and body and continue to next scaffolder step if the response status is 4xx or 5xx. By default the step will fail if any status code is returned 400 and above."
34
+ ),
35
+ timeout: z.number().optional().describe("Timeout for the request (milliseconds)").default(6e4),
36
+ useBackstageToken: z.boolean().optional().describe(
37
+ "When true, use the backstageToken from task secrets as the Authorization header instead of exchanging initiator credentials for a plugin token. Useful when the request needs to carry the caller's token directly."
38
+ ),
39
+ idempotencyKey: z.string().optional().describe(
40
+ "When set and the scaffolder supports checkpoints (experimental task recovery), the request is wrapped in a checkpoint with this key. The HTTP request is then executed at most once per task: on a task restart/recovery the cached response is returned instead of sending the request again. Use a key that is stable and unique within the template (e.g. 'jira.create.parent'). This makes non-idempotent requests (creating tickets, issues, etc.) safe to use with recoverable templates. When omitted, behaviour is unchanged and the request is sent on every run."
41
+ )
42
+ }),
43
+ output: (z) => z.object({
44
+ code: z.string().describe("The response code of the request").optional(),
45
+ headers: z.record(z.any()).describe("The headers of the response").optional(),
46
+ body: z.any().describe("The body of the response").optional()
47
+ })
48
+ },
49
+ async handler(ctx) {
50
+ const { input } = ctx;
51
+ const pluginId = helpers.getPluginId(input.path);
52
+ const { token } = input.useBackstageToken && ctx.secrets?.backstageToken ? { token: ctx.secrets.backstageToken } : await auth?.getPluginRequestToken({
53
+ onBehalfOf: await ctx.getInitiatorCredentials(),
54
+ targetPluginId: pluginId
55
+ }) ?? { token: ctx.secrets?.backstageToken };
56
+ const { method, params } = input;
57
+ const logRequestPath = input.logRequestPath ?? true;
58
+ if (options.config) {
59
+ const allowedMethods = options.config.getOptionalStringArray(
60
+ "scaffolder.http.allowedMethods"
61
+ ) ?? [];
62
+ if (allowedMethods.length > 0 && !allowedMethods.includes(method)) {
63
+ throw new Error(
64
+ `SSRF Blocked: HTTP method '${method}' is not permitted by 'scaffolder.http.allowedMethods'.`
65
+ );
66
+ }
67
+ const allowedHosts = options.config.getOptionalStringArray(
68
+ "scaffolder.http.allowedHosts"
69
+ ) ?? [];
70
+ if (allowedHosts.length > 0) {
71
+ let hostToMatch;
72
+ try {
73
+ const parsedUrl = new URL(input.path);
74
+ hostToMatch = parsedUrl.hostname;
75
+ } catch (e) {
76
+ throw new Error(
77
+ `SSRF Blocked: Invalid URL format in path '${input.path}'.`
78
+ );
79
+ }
80
+ const isHostAllowed = allowedHosts.some(
81
+ (host) => hostToMatch === host || hostToMatch.endsWith(`.${host}`)
82
+ );
83
+ if (!isHostAllowed) {
84
+ throw new Error(
85
+ `SSRF Blocked: The target host '${hostToMatch}' does not match any 'scaffolder.http.allowedHosts'.`
86
+ );
87
+ }
88
+ }
89
+ }
90
+ const continueOnBadResponse = input.continueOnBadResponse || false;
91
+ const url = await helpers.generateBackstageUrl(discovery, input.path);
92
+ if (logRequestPath) {
93
+ ctx.logger.info(
94
+ `Creating ${method} request with ${actionId} scaffolder action against ${input.path}`
95
+ );
96
+ } else {
97
+ ctx.logger.info(
98
+ `Creating ${method} request with ${actionId} scaffolder action`
99
+ );
100
+ }
101
+ const queryParams = params ? new URLSearchParams(params).toString() : "";
102
+ let inputBody = void 0;
103
+ const inputHeaders = input.headers && Object.entries(input.headers);
104
+ if (input.body && typeof input.body !== "string" && inputHeaders && inputHeaders.find(
105
+ (kv) => kv[0].toLowerCase() === "content-type" && kv[1].toLowerCase().includes("json")
106
+ )) {
107
+ inputBody = JSON.stringify(input.body);
108
+ } else {
109
+ inputBody = input.body;
110
+ }
111
+ const httpOptions = {
112
+ method: input.method,
113
+ timeout: input.timeout,
114
+ url: queryParams !== "" ? `${url}?${queryParams}` : url,
115
+ headers: input.headers ? { ...input.headers } : {},
116
+ body: inputBody
117
+ };
118
+ const authToken = helpers.getObjFieldCaseInsensitively(
119
+ input.headers,
120
+ "authorization"
121
+ );
122
+ if (token && !authToken) {
123
+ ctx.logger.info(`Token is defined. Setting authorization header.`);
124
+ httpOptions.headers.authorization = `Bearer ${token}`;
125
+ }
126
+ const dryRunSafeMethods = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
127
+ if (ctx.isDryRun === true && !dryRunSafeMethods.has(method)) {
128
+ ctx.logger.info(
129
+ `Dry run mode. Skipping non dry-run safe method '${method}' request to ${queryParams !== "" ? `${input.path}?${queryParams}` : input.path}`
130
+ );
131
+ return;
132
+ }
133
+ const sendRequest = () => helpers.http(httpOptions, ctx.logger, continueOnBadResponse);
134
+ const { code, headers, body } = input.idempotencyKey && ctx.checkpoint ? await ctx.checkpoint({
135
+ key: input.idempotencyKey,
136
+ fn: sendRequest
137
+ }) : await sendRequest();
138
+ ctx.output("code", code);
139
+ ctx.output("headers", headers);
140
+ ctx.output("body", body);
141
+ }
142
+ });
143
+ }
144
+
145
+ exports.createHttpBackstageAction = createHttpBackstageAction;
146
+ //# sourceMappingURL=backstageRequest.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backstageRequest.cjs.js","sources":["../../../src/actions/run/backstageRequest.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Copyright 2021 Larder Software Limited\n// Migrated from https://github.com/RoadieHQ/roadie-backstage-plugins in 2026.\n\nimport { AuthService } from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\nimport { DiscoveryApi } from '@backstage/core-plugin-api';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport {\n generateBackstageUrl,\n getObjFieldCaseInsensitively,\n getPluginId,\n http,\n} from './helpers';\nimport { Body, HttpOptions } from './types';\n\n/**\n * Creates a new action that sends an HTTP request to the Backstage API.\n *\n * @param options - Configuration options for the action, including the Discovery API,\n * optional Auth Service and optional Config API for the Zero-Leak Policy.\n * @returns A Scaffolder Template Action.\n * @public\n */\nexport function createHttpBackstageAction(options: {\n discovery: DiscoveryApi;\n auth?: AuthService;\n config?: Config;\n}) {\n const { discovery, auth } = options;\n const actionId = 'http:backstage:request';\n\n return createTemplateAction({\n id: actionId,\n description:\n 'Sends a HTTP request to the Backstage API. It uses the token of the user who triggers the task to authenticate requests.',\n supportsDryRun: true,\n schema: {\n input: z =>\n z.object({\n path: z.string().describe('The url path you want to query'),\n method: z\n .enum([\n 'GET',\n 'HEAD',\n 'OPTIONS',\n 'POST',\n 'UPDATE',\n 'DELETE',\n 'PUT',\n 'PATCH',\n ])\n .describe('The method type of the request'),\n headers: z\n .record(z.any())\n .optional()\n .describe('The headers you would like to pass to your request'),\n params: z\n .record(z.any())\n .optional()\n .describe(\n 'The query parameters you would like to pass to your request',\n ),\n body: z\n .any()\n .optional()\n .describe('The body you would like to pass to your request'),\n logRequestPath: z\n .boolean()\n .optional()\n .describe('Option to turn request path logging off. On by default'),\n continueOnBadResponse: z\n .boolean()\n .optional()\n .describe(\n 'Return response code and body and continue to next scaffolder step if the response status is 4xx or 5xx. By default the step will fail if any status code is returned 400 and above.',\n ),\n timeout: z\n .number()\n .optional()\n .describe('Timeout for the request (milliseconds)')\n .default(60000),\n useBackstageToken: z\n .boolean()\n .optional()\n .describe(\n \"When true, use the backstageToken from task secrets as the Authorization header instead of exchanging initiator credentials for a plugin token. Useful when the request needs to carry the caller's token directly.\",\n ),\n idempotencyKey: z\n .string()\n .optional()\n .describe(\n \"When set and the scaffolder supports checkpoints (experimental task recovery), the request is wrapped in a checkpoint with this key. The HTTP request is then executed at most once per task: on a task restart/recovery the cached response is returned instead of sending the request again. Use a key that is stable and unique within the template (e.g. 'jira.create.parent'). This makes non-idempotent requests (creating tickets, issues, etc.) safe to use with recoverable templates. When omitted, behaviour is unchanged and the request is sent on every run.\",\n ),\n }),\n output: z =>\n z.object({\n code: z\n .string()\n .describe('The response code of the request')\n .optional(),\n headers: z\n .record(z.any())\n .describe('The headers of the response')\n .optional(),\n body: z.any().describe('The body of the response').optional(),\n }),\n },\n\n async handler(ctx) {\n const { input } = ctx;\n const pluginId = getPluginId(input.path);\n const { token } =\n input.useBackstageToken && ctx.secrets?.backstageToken\n ? { token: ctx.secrets.backstageToken }\n : (await auth?.getPluginRequestToken({\n onBehalfOf: await ctx.getInitiatorCredentials(),\n targetPluginId: pluginId,\n })) ?? { token: ctx.secrets?.backstageToken };\n const { method, params } = input;\n const logRequestPath = input.logRequestPath ?? true;\n\n if (options.config) {\n const allowedMethods =\n options.config.getOptionalStringArray(\n 'scaffolder.http.allowedMethods',\n ) ?? [];\n if (allowedMethods.length > 0 && !allowedMethods.includes(method)) {\n throw new Error(\n `SSRF Blocked: HTTP method '${method}' is not permitted by 'scaffolder.http.allowedMethods'.`,\n );\n }\n\n const allowedHosts =\n options.config.getOptionalStringArray(\n 'scaffolder.http.allowedHosts',\n ) ?? [];\n if (allowedHosts.length > 0) {\n let hostToMatch: string;\n try {\n const parsedUrl = new URL(input.path);\n hostToMatch = parsedUrl.hostname;\n } catch (e) {\n throw new Error(\n `SSRF Blocked: Invalid URL format in path '${input.path}'.`,\n );\n }\n\n const isHostAllowed = allowedHosts.some(\n (host: string) =>\n hostToMatch === host || hostToMatch.endsWith(`.${host}`),\n );\n if (!isHostAllowed) {\n throw new Error(\n `SSRF Blocked: The target host '${hostToMatch}' does not match any 'scaffolder.http.allowedHosts'.`,\n );\n }\n }\n }\n const continueOnBadResponse = input.continueOnBadResponse || false;\n const url = await generateBackstageUrl(discovery, input.path);\n if (logRequestPath) {\n ctx.logger.info(\n `Creating ${method} request with ${actionId} scaffolder action against ${input.path}`,\n );\n } else {\n ctx.logger.info(\n `Creating ${method} request with ${actionId} scaffolder action`,\n );\n }\n\n const queryParams: string = params\n ? new URLSearchParams(params).toString()\n : '';\n\n let inputBody: Body = undefined;\n\n const inputHeaders: [string, any][] | undefined =\n input.headers && Object.entries(input.headers);\n if (\n input.body &&\n typeof input.body !== 'string' &&\n inputHeaders &&\n inputHeaders.find(\n kv =>\n kv[0].toLowerCase() === 'content-type' &&\n kv[1].toLowerCase().includes('json'),\n )\n ) {\n inputBody = JSON.stringify(input.body);\n } else {\n inputBody = input.body;\n }\n\n const httpOptions: HttpOptions = {\n method: input.method,\n timeout: input.timeout,\n url: queryParams !== '' ? `${url}?${queryParams}` : url,\n headers: input.headers ? { ...input.headers } : {},\n body: inputBody,\n };\n\n const authToken = getObjFieldCaseInsensitively(\n input.headers,\n 'authorization',\n );\n\n if (token && !authToken) {\n ctx.logger.info(`Token is defined. Setting authorization header.`);\n httpOptions.headers.authorization = `Bearer ${token}`;\n }\n\n const dryRunSafeMethods = new Set(['GET', 'HEAD', 'OPTIONS']);\n if (ctx.isDryRun === true && !dryRunSafeMethods.has(method)) {\n ctx.logger.info(\n `Dry run mode. Skipping non dry-run safe method '${method}' request to ${\n queryParams !== '' ? `${input.path}?${queryParams}` : input.path\n }`,\n );\n return;\n }\n\n const sendRequest = () =>\n http(httpOptions, ctx.logger, continueOnBadResponse);\n\n // When an idempotencyKey is provided and the scaffolder supports\n // checkpoints (experimental task recovery), wrap the request so it is\n // executed at most once per task: on recovery the stored response is\n // returned instead of re-sending the request. Otherwise behave exactly\n // as before and send the request on every run.\n const { code, headers, body } =\n input.idempotencyKey && ctx.checkpoint\n ? await ctx.checkpoint({\n key: input.idempotencyKey,\n fn: sendRequest,\n })\n : await sendRequest();\n\n ctx.output('code', code);\n ctx.output('headers', headers);\n ctx.output('body', body);\n },\n });\n}\n"],"names":["createTemplateAction","getPluginId","generateBackstageUrl","getObjFieldCaseInsensitively","http"],"mappings":";;;;;AAsCO,SAAS,0BAA0B,OAAA,EAIvC;AACD,EAAA,MAAM,EAAE,SAAA,EAAW,IAAA,EAAK,GAAI,OAAA;AAC5B,EAAA,MAAM,QAAA,GAAW,wBAAA;AAEjB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,QAAA;AAAA,IACJ,WAAA,EACE,0HAAA;AAAA,IACF,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,MAAA,CAAO;AAAA,QACP,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,gCAAgC,CAAA;AAAA,QAC1D,MAAA,EAAQ,EACL,IAAA,CAAK;AAAA,UACJ,KAAA;AAAA,UACA,MAAA;AAAA,UACA,SAAA;AAAA,UACA,MAAA;AAAA,UACA,QAAA;AAAA,UACA,QAAA;AAAA,UACA,KAAA;AAAA,UACA;AAAA,SACD,CAAA,CACA,QAAA,CAAS,gC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,EAAI,WAAW,CAAA,CAAA,GAAK,KAAA,CAAM,IAC9D,CAAA;AAAA,SACF;AACA,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,cAAc,MAClBC,YAAA,CAAK,WAAA,EAAa,GAAA,CAAI,QAAQ,qBAAqB,CAAA;AAOrD,MAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAK,GAC1B,KAAA,CAAM,cAAA,IAAkB,GAAA,CAAI,UAAA,GACxB,MAAM,GAAA,CAAI,UAAA,CAAW;AAAA,QACnB,KAAK,KAAA,CAAM,cAAA;AAAA,QACX,EAAA,EAAI;AAAA,OACL,CAAA,GACD,MAAM,WAAA,EAAY;AAExB,MAAA,GAAA,CAAI,MAAA,CAAO,QAAQ,IAAI,CAAA;AACvB,MAAA,GAAA,CAAI,MAAA,CAAO,WAAW,OAAO,CAAA;AAC7B,MAAA,GAAA,CAAI,MAAA,CAAO,QAAQ,IAAI,CAAA;AAAA,IACzB;AAAA,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var crossFetch = require('cross-fetch');
4
+
5
+ class HttpError extends Error {
6
+ }
7
+ const DEFAULT_TIMEOUT = 6e4;
8
+ const getPluginId = (path) => {
9
+ const pluginId = (path.startsWith("/") ? path.substring(1) : path).split(
10
+ "/"
11
+ )[0];
12
+ return pluginId;
13
+ };
14
+ const generateBackstageUrl = async (discovery, path) => {
15
+ const [pluginId, ...rest] = (path.startsWith("/") ? path.substring(1) : path).split("/");
16
+ return `${await discovery.getBaseUrl(pluginId)}/${rest.join("/")}`;
17
+ };
18
+ const http = async ({ url, timeout = DEFAULT_TIMEOUT, ...options }, logger, continueOnBadResponse = false) => {
19
+ let res;
20
+ try {
21
+ res = await crossFetch.fetch(url, {
22
+ ...options,
23
+ signal: AbortSignal.timeout(timeout)
24
+ });
25
+ } catch (e) {
26
+ if (e instanceof Error && e.name === "TimeoutError") {
27
+ throw new HttpError(
28
+ `Request was aborted as it took longer than ${timeout / 1e3} seconds`
29
+ );
30
+ }
31
+ throw new HttpError(`There was an issue with the request: ${e}`);
32
+ }
33
+ const headers = {};
34
+ for (const [name, value] of res.headers) {
35
+ headers[name] = value;
36
+ }
37
+ const isJSON = () => headers["content-type"] && headers["content-type"].includes("application/json");
38
+ let body;
39
+ try {
40
+ body = isJSON() ? await res.json() : { message: await res.text() };
41
+ } catch (e) {
42
+ throw new HttpError(`Could not parse response body: ${e}`);
43
+ }
44
+ if (res.status >= 400) {
45
+ logger.error(
46
+ `There was an issue with your request. Status code: ${res.status} Response body: ${JSON.stringify(body)}`
47
+ );
48
+ if (continueOnBadResponse) {
49
+ return { code: res.status, headers: {}, body };
50
+ }
51
+ throw new HttpError("Unable to complete request");
52
+ }
53
+ return { code: res.status, headers, body };
54
+ };
55
+ const getObjFieldCaseInsensitively = (obj = {}, fieldName) => {
56
+ const [, value = ""] = Object.entries(obj).find(
57
+ ([key]) => key.toLowerCase() === fieldName.toLowerCase()
58
+ ) || [];
59
+ return value;
60
+ };
61
+
62
+ exports.generateBackstageUrl = generateBackstageUrl;
63
+ exports.getObjFieldCaseInsensitively = getObjFieldCaseInsensitively;
64
+ exports.getPluginId = getPluginId;
65
+ exports.http = http;
66
+ //# sourceMappingURL=helpers.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../../src/actions/run/helpers.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Copyright 2021 Larder Software Limited\n// Migrated from https://github.com/RoadieHQ/roadie-backstage-plugins in 2026.\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { DiscoveryApi } from '@backstage/core-plugin-api';\nimport { fetch } from 'cross-fetch';\nimport type { Logger } from 'winston';\nimport { HttpOptions } from './types';\n\nclass HttpError extends Error {}\nconst DEFAULT_TIMEOUT = 60_000;\n\nexport const getPluginId = (path: string): string => {\n const pluginId = (path.startsWith('/') ? path.substring(1) : path).split(\n '/',\n )[0];\n return pluginId;\n};\n\nexport const generateBackstageUrl = async (\n discovery: DiscoveryApi,\n path: string,\n): Promise<string> => {\n const [pluginId, ...rest] = (\n path.startsWith('/') ? path.substring(1) : path\n ).split('/');\n return `${await discovery.getBaseUrl(pluginId)}/${rest.join('/')}`;\n};\n\nexport const http = async (\n { url, timeout = DEFAULT_TIMEOUT, ...options }: HttpOptions,\n logger: Logger | LoggerService,\n continueOnBadResponse: boolean = false,\n): Promise<any> => {\n let res: Response;\n\n try {\n res = await fetch(url, {\n ...options,\n signal: AbortSignal.timeout(timeout),\n });\n } catch (e) {\n // thrown by AbortSignal.timeout\n // https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static\n if (e instanceof Error && e.name === 'TimeoutError') {\n throw new HttpError(\n `Request was aborted as it took longer than ${timeout / 1000} seconds`,\n );\n }\n\n throw new HttpError(`There was an issue with the request: ${e}`);\n }\n\n const headers: any = {};\n for (const [name, value] of res.headers) {\n headers[name] = value;\n }\n\n const isJSON = () =>\n headers['content-type'] &&\n headers['content-type'].includes('application/json');\n\n let body;\n try {\n body = isJSON() ? await res.json() : { message: await res.text() };\n } catch (e) {\n throw new HttpError(`Could not parse response body: ${e}`);\n }\n\n if (res.status >= 400) {\n logger.error(\n `There was an issue with your request. Status code: ${\n res.status\n } Response body: ${JSON.stringify(body)}`,\n );\n if (continueOnBadResponse) {\n return { code: res.status, headers: {}, body };\n }\n throw new HttpError('Unable to complete request');\n }\n return { code: res.status, headers, body };\n};\n\nexport const getObjFieldCaseInsensitively = (obj = {}, fieldName: string) => {\n const [, value = ''] =\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CAAC,GAAA,GAAM,IAAI,SAAA,KAAsB;AAC3E,EAAA,MAAM,GAAG,KAAA,GAAQ,EAAE,IACjB,MAAA,CAAO,OAAA,CAAgB,GAAG,CAAA,CAAE,IAAA;AAAA,IAC1B,CAAC,CAAC,GAAG,CAAA,KAAM,IAAI,WAAA,EAAY,KAAM,UAAU,WAAA;AAAY,OACpD,EAAC;AAER,EAAA,OAAO,KAAA;AACT;;;;;;;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var backstageRequest = require('./actions/run/backstageRequest.cjs.js');
6
+ var module$1 = require('./module.cjs.js');
7
+
8
+
9
+
10
+ exports.createHttpBackstageAction = backstageRequest.createHttpBackstageAction;
11
+ exports.default = module$1.scaffolderBackendModuleHttpRequest;
12
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,42 @@
1
+ import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
3
+ import { AuthService } from '@backstage/backend-plugin-api';
4
+ import { Config } from '@backstage/config';
5
+ import { DiscoveryApi } from '@backstage/core-plugin-api';
6
+
7
+ /**
8
+ * Creates a new action that sends an HTTP request to the Backstage API.
9
+ *
10
+ * @param options - Configuration options for the action, including the Discovery API,
11
+ * optional Auth Service and optional Config API for the Zero-Leak Policy.
12
+ * @returns A Scaffolder Template Action.
13
+ * @public
14
+ */
15
+ declare function createHttpBackstageAction(options: {
16
+ discovery: DiscoveryApi;
17
+ auth?: AuthService;
18
+ config?: Config;
19
+ }): _backstage_plugin_scaffolder_node.TemplateAction<{
20
+ path: string;
21
+ timeout: number;
22
+ method: "GET" | "HEAD" | "OPTIONS" | "POST" | "UPDATE" | "DELETE" | "PUT" | "PATCH";
23
+ params?: Record<string, any> | undefined;
24
+ headers?: Record<string, any> | undefined;
25
+ body?: any;
26
+ logRequestPath?: boolean | undefined;
27
+ continueOnBadResponse?: boolean | undefined;
28
+ useBackstageToken?: boolean | undefined;
29
+ idempotencyKey?: string | undefined;
30
+ }, {
31
+ code?: string | undefined;
32
+ headers?: Record<string, any> | undefined;
33
+ body?: any;
34
+ }, "v2">;
35
+
36
+ /**
37
+ * @public
38
+ * The Scaffolder Backend HTTP Request module
39
+ */
40
+ declare const scaffolderBackendModuleHttpRequest: _backstage_backend_plugin_api.BackendFeature;
41
+
42
+ export { createHttpBackstageAction, scaffolderBackendModuleHttpRequest as default };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
5
+ var backstageRequest = require('./actions/run/backstageRequest.cjs.js');
6
+
7
+ const scaffolderBackendModuleHttpRequest = backendPluginApi.createBackendModule({
8
+ pluginId: "scaffolder",
9
+ moduleId: "scaffolder-backend-module-http-request",
10
+ register({ registerInit }) {
11
+ registerInit({
12
+ deps: {
13
+ scaffolder: pluginScaffolderNode.scaffolderActionsExtensionPoint,
14
+ discovery: backendPluginApi.coreServices.discovery,
15
+ auth: backendPluginApi.coreServices.auth,
16
+ config: backendPluginApi.coreServices.rootConfig
17
+ },
18
+ async init({ scaffolder, discovery, auth, config }) {
19
+ scaffolder.addActions(
20
+ backstageRequest.createHttpBackstageAction({
21
+ discovery,
22
+ auth,
23
+ config
24
+ })
25
+ );
26
+ }
27
+ });
28
+ }
29
+ });
30
+
31
+ exports.scaffolderBackendModuleHttpRequest = scaffolderBackendModuleHttpRequest;
32
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Copyright 2024 Larder Software Limited\n// Migrated from https://github.com/RoadieHQ/roadie-backstage-plugins in 2026.\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\nimport * as backendModuleHttp from './actions';\n\n/**\n * @public\n * The Scaffolder Backend HTTP Request module\n */\nexport const scaffolderBackendModuleHttpRequest = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'scaffolder-backend-module-http-request',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n discovery: coreServices.discovery,\n auth: coreServices.auth,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, discovery, auth, config }) {\n scaffolder.addActions(\n backendModuleHttp.createHttpBackstageAction({\n discovery,\n auth,\n config,\n }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","backendModuleHttp.createHttpBackstageAction"],"mappings":";;;;;;AA4BO,MAAM,qCAAqCA,oCAAA,CAAoB;AAAA,EACpE,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,wCAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,UAAA,EAAYC,oDAAA;AAAA,QACZ,WAAWC,6BAAA,CAAa,SAAA;AAAA,QACxB,MAAMA,6BAAA,CAAa,IAAA;AAAA,QACnB,QAAQA,6BAAA,CAAa;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,YAAY,SAAA,EAAW,IAAA,EAAM,QAAO,EAAG;AAClD,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,0CAAkB,CAA0B;AAAA,YAC1C,SAAA;AAAA,YACA,IAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-scaffolder-backend-module-http-request",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Scaffolder action for calling Backstage APIs and proxy endpoints",
4
+ "version": "1.0.0",
5
+ "main": "./dist/index.cjs.js",
6
+ "types": "./dist/index.d.ts",
7
+ "license": "Apache-2.0",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "backstage": {
12
+ "role": "backend-plugin-module",
13
+ "pluginId": "scaffolder",
14
+ "pluginPackage": "@backstage/plugin-scaffolder-backend",
15
+ "features": {
16
+ ".": "@backstage/BackendFeature"
17
+ }
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "backstage": "@backstage/BackendFeature",
22
+ "require": "./dist/index.cjs.js",
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.cjs.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "typesVersions": {
29
+ "*": {
30
+ "package.json": [
31
+ "package.json"
32
+ ]
33
+ }
34
+ },
35
+ "scripts": {
36
+ "start": "backstage-cli package start",
37
+ "build": "backstage-cli package build",
38
+ "lint:check": "backstage-cli package lint",
39
+ "lint:fix": "backstage-cli package lint --fix",
40
+ "tsc": "tsc",
41
+ "prettier:check": "prettier --ignore-unknown --check .",
42
+ "prettier:fix": "prettier --ignore-unknown --write .",
43
+ "test": "backstage-cli package test",
44
+ "prepack": "backstage-cli package prepack",
45
+ "postpack": "backstage-cli package postpack",
46
+ "clean": "backstage-cli package clean"
47
+ },
48
+ "dependencies": {
49
+ "@backstage/backend-plugin-api": "^1.10.0",
50
+ "@backstage/config": "^1.3.6",
51
+ "@backstage/core-plugin-api": "^1.10.1",
52
+ "@backstage/plugin-scaffolder-node": "^0.13.6",
53
+ "cross-fetch": "^4.0.0"
54
+ },
55
+ "devDependencies": {
56
+ "@backstage/backend-test-utils": "^1.11.6",
57
+ "@backstage/cli": "^0.36.5",
58
+ "@backstage/core-app-api": "^1.20.0",
59
+ "react": "^18.0.0",
60
+ "react-dom": "^18.0.0",
61
+ "react-router-dom": "^6.0.0",
62
+ "winston": "^3.2.1"
63
+ },
64
+ "files": [
65
+ "dist"
66
+ ],
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "https://github.com/backstage/community-plugins",
70
+ "directory": "workspaces/scaffolder/plugins/scaffolder-backend-module-http-request"
71
+ },
72
+ "bugs": "https://github.com/backstage/community-plugins/issues",
73
+ "keywords": [
74
+ "backstage",
75
+ "backend-plugin-module"
76
+ ]
6
77
  }