@backstage/plugin-scaffolder-backend-module-sentry 0.2.16 → 0.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,24 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-sentry
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ab606b2: Add ability to configure the API Base URL
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @backstage/backend-plugin-api@1.6.1
13
+ - @backstage/plugin-scaffolder-node@0.12.3
14
+
15
+ ## 0.2.17-next.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @backstage/plugin-scaffolder-node@0.12.3-next.0
21
+
3
22
  ## 0.2.16
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -36,6 +36,14 @@ scaffolder:
36
36
  token: ${SENTRY_TOKEN}
37
37
  ```
38
38
 
39
+ You can optionally override the default Sentry API Base URL (`https://sentry.io/api/0`) in your `app-config.yaml`:
40
+
41
+ ```yaml
42
+ scaffolder:
43
+ sentry:
44
+ apiBaseUrl: API-BASE-URL
45
+ ```
46
+
39
47
  After that you can use the action in your template:
40
48
 
41
49
  ```yaml
package/config.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2026 The Backstage Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export interface Config {
18
+ scaffolder?: {
19
+ sentry?: {
20
+ apiBaseUrl?: string;
21
+ token?: string;
22
+ };
23
+ };
24
+ }
@@ -26,11 +26,22 @@ function createSentryCreateProjectAction(options) {
26
26
  }).optional(),
27
27
  authToken: (z) => z.string({
28
28
  description: "authenticate via bearer auth token. Requires scope: project:write"
29
+ }).optional(),
30
+ apiBaseUrl: (z) => z.string({
31
+ description: "Optional base URL for the Sentry API. e.g. https://sentry.io/api/0"
29
32
  }).optional()
30
33
  }
31
34
  },
32
35
  async handler(ctx) {
33
- const { organizationSlug, teamSlug, name, slug, platform, authToken } = ctx.input;
36
+ const {
37
+ organizationSlug,
38
+ teamSlug,
39
+ name,
40
+ slug,
41
+ platform,
42
+ authToken,
43
+ apiBaseUrl
44
+ } = ctx.input;
34
45
  const body = {
35
46
  name
36
47
  };
@@ -44,11 +55,12 @@ function createSentryCreateProjectAction(options) {
44
55
  if (!token) {
45
56
  throw new errors.InputError(`No valid sentry token given`);
46
57
  }
58
+ const baseUrl = apiBaseUrl || config.getOptionalString("scaffolder.sentry.apiBaseUrl") || "https://sentry.io/api/0";
47
59
  const { result } = await ctx.checkpoint({
48
60
  key: `create.project.${organizationSlug}.${teamSlug}`,
49
61
  fn: async () => {
50
62
  const response = await fetch(
51
- `https://sentry.io/api/0/teams/${organizationSlug}/${teamSlug}/projects/`,
63
+ `${baseUrl}/teams/${organizationSlug}/${teamSlug}/projects/`,
52
64
  {
53
65
  method: "POST",
54
66
  headers: {
@@ -1 +1 @@
1
- {"version":3,"file":"createProject.cjs.js","sources":["../../src/actions/createProject.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\n\n/**\n * Creates the `sentry:project:create` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n *\n * @param options - Configuration of the Sentry API.\n * @public\n */\nexport function createSentryCreateProjectAction(options: { config: Config }) {\n const { config } = options;\n\n return createTemplateAction({\n id: 'sentry:project:create',\n schema: {\n input: {\n organizationSlug: z =>\n z.string({\n description: 'The slug of the organization the team belongs to',\n }),\n teamSlug: z =>\n z.string({\n description: 'The slug of the team to create a new project for',\n }),\n name: z =>\n z.string({\n description: 'The name for the new project',\n }),\n slug: z =>\n z\n .string({\n description:\n 'Optional slug for the new project. If not provided a slug is generated from the name',\n })\n .optional(),\n platform: z =>\n z\n .string({\n description: 'Optional sentry platform for the new project. ',\n })\n .optional(),\n authToken: z =>\n z\n .string({\n description:\n 'authenticate via bearer auth token. Requires scope: project:write',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { organizationSlug, teamSlug, name, slug, platform, authToken } =\n ctx.input;\n\n const body: any = {\n name: name,\n };\n\n if (slug) {\n body.slug = slug;\n }\n\n if (platform) {\n body.platform = platform;\n }\n\n const token = authToken\n ? authToken\n : config.getOptionalString('scaffolder.sentry.token');\n\n if (!token) {\n throw new InputError(`No valid sentry token given`);\n }\n\n const { result } = await ctx.checkpoint({\n key: `create.project.${organizationSlug}.${teamSlug}`,\n fn: async () => {\n const response = await fetch(\n `https://sentry.io/api/0/teams/${organizationSlug}/${teamSlug}/projects/`,\n {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n },\n );\n\n const contentType = response.headers.get('content-type');\n\n if (contentType !== 'application/json') {\n throw new InputError(\n `Unexpected Sentry Response Type: ${await response.text()}`,\n );\n }\n\n const res = await response.json();\n\n if (response.status !== 201) {\n throw new InputError(`Sentry Response was: ${await res.detail}`);\n }\n\n return {\n code: response.status,\n result: res as { id: string },\n };\n },\n });\n\n ctx.output('id', result.id);\n ctx.output('result', result);\n },\n });\n}\n"],"names":["createTemplateAction","InputError"],"mappings":";;;;;AA8BO,SAAS,gCAAgC,OAAA,EAA6B;AAC3E,EAAA,MAAM,EAAE,QAAO,GAAI,OAAA;AAEnB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,uBAAA;AAAA,IACJ,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,gBAAA,EAAkB,CAAA,CAAA,KAChB,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,QAAA,EAAU,CAAA,CAAA,KACR,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,QAAA,EAAU,CAAA,CAAA,KACR,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,EAAE,kBAAkB,QAAA,EAAU,IAAA,EAAM,MAAM,QAAA,EAAU,SAAA,KACxD,GAAA,CAAI,KAAA;AAEN,MAAA,MAAM,IAAA,GAAY;AAAA,QAChB;AAAA,OACF;AAEA,MAAA,IAAI,IAAA,EAAM;AACR,QAAA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,CAAW,CAAA,qBAAA,EAAwB,MAAM,GAAA,CAAI,MAAM,CAAA,CAAE,CAAA;AAAA,UACjE;AAEA,UAAA,OAAO;AAAA,YACL,MAAM,QAAA,CAAS,MAAA;AAAA,YACf,MAAA,EAAQ;AAAA,WACV;AAAA,QACF;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,IAAA,EAAM,MAAA,CAAO,EAAE,CAAA;AAC1B,MAAA,GAAA,CAAI,MAAA,CAAO,UAAU,MAAM,CAAA;AAAA,IAC7B;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"createProject.cjs.js","sources":["../../src/actions/createProject.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\n\n/**\n * Creates the `sentry:project:create` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n *\n * @param options - Configuration of the Sentry API.\n * @public\n */\nexport function createSentryCreateProjectAction(options: { config: Config }) {\n const { config } = options;\n\n return createTemplateAction({\n id: 'sentry:project:create',\n schema: {\n input: {\n organizationSlug: z =>\n z.string({\n description: 'The slug of the organization the team belongs to',\n }),\n teamSlug: z =>\n z.string({\n description: 'The slug of the team to create a new project for',\n }),\n name: z =>\n z.string({\n description: 'The name for the new project',\n }),\n slug: z =>\n z\n .string({\n description:\n 'Optional slug for the new project. If not provided a slug is generated from the name',\n })\n .optional(),\n platform: z =>\n z\n .string({\n description: 'Optional sentry platform for the new project. ',\n })\n .optional(),\n authToken: z =>\n z\n .string({\n description:\n 'authenticate via bearer auth token. Requires scope: project:write',\n })\n .optional(),\n apiBaseUrl: z =>\n z\n .string({\n description:\n 'Optional base URL for the Sentry API. e.g. https://sentry.io/api/0',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n organizationSlug,\n teamSlug,\n name,\n slug,\n platform,\n authToken,\n apiBaseUrl,\n } = ctx.input;\n\n const body: any = {\n name: name,\n };\n\n if (slug) {\n body.slug = slug;\n }\n\n if (platform) {\n body.platform = platform;\n }\n\n const token = authToken\n ? authToken\n : config.getOptionalString('scaffolder.sentry.token');\n\n if (!token) {\n throw new InputError(`No valid sentry token given`);\n }\n\n const baseUrl =\n apiBaseUrl ||\n config.getOptionalString('scaffolder.sentry.apiBaseUrl') ||\n 'https://sentry.io/api/0';\n\n const { result } = await ctx.checkpoint({\n key: `create.project.${organizationSlug}.${teamSlug}`,\n fn: async () => {\n const response = await fetch(\n `${baseUrl}/teams/${organizationSlug}/${teamSlug}/projects/`,\n {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n },\n );\n\n const contentType = response.headers.get('content-type');\n\n if (contentType !== 'application/json') {\n throw new InputError(\n `Unexpected Sentry Response Type: ${await response.text()}`,\n );\n }\n\n const res = await response.json();\n\n if (response.status !== 201) {\n throw new InputError(`Sentry Response was: ${await res.detail}`);\n }\n\n return {\n code: response.status,\n result: res as { id: string },\n };\n },\n });\n\n ctx.output('id', result.id);\n ctx.output('result', result);\n },\n });\n}\n"],"names":["createTemplateAction","InputError"],"mappings":";;;;;AA8BO,SAAS,gCAAgC,OAAA,EAA6B;AAC3E,EAAA,MAAM,EAAE,QAAO,GAAI,OAAA;AAEnB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,uBAAA;AAAA,IACJ,MAAA,EAAQ;AAAA,MACN,KA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AE,CAAA;AAAA,UACjE;AAEA,UAAA,OAAO;AAAA,YACL,MAAM,QAAA,CAAS,MAAA;AAAA,YACf,MAAA,EAAQ;AAAA,WACV;AAAA,QACF;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,IAAA,EAAM,MAAA,CAAO,EAAE,CAAA;AAC1B,MAAA,GAAA,CAAI,MAAA,CAAO,UAAU,MAAM,CAAA;AAAA,IAC7B;AAAA,GACD,CAAA;AACH;;;;"}
@@ -18,6 +18,9 @@ function createSentryFetchDSNAction(options) {
18
18
  }),
19
19
  authToken: (z) => z.string({
20
20
  description: "authenticate via bearer auth token. Requires one of the following scopes: project:admin, project:read, project:write"
21
+ }).optional(),
22
+ apiBaseUrl: (z) => z.string({
23
+ description: "Optional base URL for the Sentry API. e.g. https://sentry.io/api/0"
21
24
  }).optional()
22
25
  },
23
26
  output: {
@@ -27,13 +30,14 @@ function createSentryFetchDSNAction(options) {
27
30
  }
28
31
  },
29
32
  async handler(ctx) {
30
- const { organizationSlug, projectSlug, authToken } = ctx.input;
33
+ const { organizationSlug, projectSlug, authToken, apiBaseUrl } = ctx.input;
31
34
  const token = authToken ? authToken : config.getOptionalString("scaffolder.sentry.token");
32
35
  if (!token) {
33
36
  throw new errors.InputError(`No valid sentry token given`);
34
37
  }
38
+ const baseUrl = apiBaseUrl || config.getOptionalString("scaffolder.sentry.apiBaseUrl") || "https://sentry.io/api/0";
35
39
  const response = await fetch(
36
- `https://sentry.io/api/0/projects/${organizationSlug}/${projectSlug}/keys/`,
40
+ `${baseUrl}/projects/${organizationSlug}/${projectSlug}/keys/`,
37
41
  {
38
42
  method: "GET",
39
43
  headers: {
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDSN.cjs.js","sources":["../../src/actions/fetchDSN.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\n\n/**\n * Creates the `sentry:fetch:dsn` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n *\n * @param options - Configuration of the Sentry API.\n * @public\n */\nexport function createSentryFetchDSNAction(options: { config: Config }) {\n const { config } = options;\n\n return createTemplateAction({\n id: 'sentry:fetch:dsn',\n supportsDryRun: true,\n schema: {\n input: {\n organizationSlug: z =>\n z.string({\n description: 'The slug of the organization the project belongs to',\n }),\n projectSlug: z =>\n z.string({\n description: 'The slug of the project to fetch the DSN for',\n }),\n authToken: z =>\n z\n .string({\n description:\n 'authenticate via bearer auth token. Requires one of the following scopes: project:admin, project:read, project:write',\n })\n .optional(),\n },\n output: {\n dsn: z =>\n z\n .string({\n description: 'The public DSN of the Sentry project',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { organizationSlug, projectSlug, authToken } = ctx.input;\n\n const token = authToken\n ? authToken\n : config.getOptionalString('scaffolder.sentry.token');\n\n if (!token) {\n throw new InputError(`No valid sentry token given`);\n }\n\n const response = await fetch(\n `https://sentry.io/api/0/projects/${organizationSlug}/${projectSlug}/keys/`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n },\n );\n\n if (!response.headers.get('content-type')?.includes('application/json')) {\n throw new InputError(\n `Unexpected Sentry Response Type: ${await response.text()}`,\n );\n }\n\n const keys = await response.json();\n\n if (response.status !== 200) {\n throw new InputError(\n `Sentry Response was: ${keys.detail || 'Unknown error'}`,\n );\n }\n\n if (!Array.isArray(keys) || keys.length === 0) {\n throw new InputError('No keys found for the specified project');\n }\n\n const publicDsn = keys[0]?.dsn?.public;\n if (!publicDsn) {\n throw new InputError('No public DSN found in project keys');\n }\n\n ctx.output('dsn', publicDsn);\n },\n });\n}\n"],"names":["createTemplateAction","InputError"],"mappings":";;;;;AA8BO,SAAS,2BAA2B,OAAA,EAA6B;AACtE,EAAA,MAAM,EAAE,QAAO,GAAI,OAAA;AAEnB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,IACJ,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,gBAAA,EAAkB,CAAA,CAAA,KAChB,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,WAAA,EAAa,CAAA,CAAA,KACX,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS,OAChB;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,MAAM,QAAQ,GAAA,EAAK;AACjB,MAAA,MAAM,EAAE,gBAAA,EAAkB,WAAA,EAAa,SAAA,KAAc,GAAA,CAAI,KAAA;AAEzD,MAAA,MAAM,KAAA,GAAQ,SAAA,GACV,SAAA,GACA,MAAA,CAAO,kBAAkB,yBAAyB,CAAA;AAEtD,MAAA,IAAI,CAAC,KAAA,EAAO;AACV,QAAA,MAAM,IAAIC,kBAAW,CAAA,2BAAA,CAA6B,CAAA;AAAA,MACpD;AAEA,MAAA,MAAM,WAAW,MAAM,KAAA;AAAA,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ensed 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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\n\n/**\n * Creates the `sentry:fetch:dsn` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n *\n * @param options - Configuration of the Sentry API.\n * @public\n */\nexport function createSentryFetchDSNAction(options: { config: Config }) {\n const { config } = options;\n\n return createTemplateAction({\n id: 'sentry:fetch:dsn',\n supportsDryRun: true,\n schema: {\n input: {\n organizationSlug: z =>\n z.string({\n description: 'The slug of the organization the project belongs to',\n }),\n projectSlug: z =>\n z.string({\n description: 'The slug of the project to fetch the DSN for',\n }),\n authToken: z =>\n z\n .string({\n description:\n 'authenticate via bearer auth token. Requires one of the following scopes: project:admin, project:read, project:write',\n })\n .optional(),\n apiBaseUrl: z =>\n z\n .string({\n description:\n 'Optional base URL for the Sentry API. e.g. https://sentry.io/api/0',\n })\n .optional(),\n },\n output: {\n dsn: z =>\n z\n .string({\n description: 'The public DSN of the Sentry project',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const { organizationSlug, projectSlug, authToken, apiBaseUrl } =\n ctx.input;\n\n const token = authToken\n ? authToken\n : config.getOptionalString('scaffolder.sentry.token');\n\n if (!token) {\n throw new InputError(`No valid sentry token given`);\n }\n\n const baseUrl =\n apiBaseUrl ||\n config.getOptionalString('scaffolder.sentry.apiBaseUrl') ||\n 'https://sentry.io/api/0';\n\n const response = await fetch(\n `${baseUrl}/projects/${organizationSlug}/${projectSlug}/keys/`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n },\n );\n\n if (!response.headers.get('content-type')?.includes('application/json')) {\n throw new InputError(\n `Unexpected Sentry Response Type: ${await response.text()}`,\n );\n }\n\n const keys = await response.json();\n\n if (response.status !== 200) {\n throw new InputError(\n `Sentry Response was: ${keys.detail || 'Unknown error'}`,\n );\n }\n\n if (!Array.isArray(keys) || keys.length === 0) {\n throw new InputError('No keys found for the specified project');\n }\n\n const publicDsn = keys[0]?.dsn?.public;\n if (!publicDsn) {\n throw new InputError('No public DSN found in project keys');\n }\n\n ctx.output('dsn', publicDsn);\n },\n });\n}\n"],"names":["createTemplateAction","InputError"],"mappings":";;;;;AA8BO,SAAS,2BAA2B,OAAA,EAA6B;AACtE,EAAA,MAAM,EAAE,QAAO,GAAI,OAAA;AAEnB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,IACJ,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,gBAAA,EAAkB,CAAA,CAAA,KAChB,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,WAAA,EAAa,CAAA,CAAA,KACX,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS,OAChB;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA;AAAS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CAAA,IAAK,IAAA,CAAK,WAAW,CAAA,EAAG;AAC7C,QAAA,MAAM,IAAIA,kBAAW,yCAAyC,CAAA;AAAA,MAChE;AAEA,MAAA,MAAM,SAAA,GAAY,IAAA,CAAK,CAAC,CAAA,EAAG,GAAA,EAAK,MAAA;AAChC,MAAA,IAAI,CAAC,SAAA,EAAW;AACd,QAAA,MAAM,IAAIA,kBAAW,qCAAqC,CAAA;AAAA,MAC5D;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,OAAO,SAAS,CAAA;AAAA,IAC7B;AAAA,GACD,CAAA;AACH;;;;"}
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ declare function createSentryCreateProjectAction(options: {
21
21
  slug?: string | undefined;
22
22
  platform?: string | undefined;
23
23
  authToken?: string | undefined;
24
+ apiBaseUrl?: string | undefined;
24
25
  }, {
25
26
  [x: string]: any;
26
27
  }, "v2">;
@@ -41,6 +42,7 @@ declare function createSentryFetchDSNAction(options: {
41
42
  organizationSlug: string;
42
43
  projectSlug: string;
43
44
  authToken?: string | undefined;
45
+ apiBaseUrl?: string | undefined;
44
46
  }, {
45
47
  dsn?: string | undefined;
46
48
  }, "v2">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-sentry",
3
- "version": "0.2.16",
3
+ "version": "0.3.0",
4
4
  "backstage": {
5
5
  "role": "backend-plugin-module",
6
6
  "pluginId": "scaffolder",
@@ -38,7 +38,8 @@
38
38
  }
39
39
  },
40
40
  "files": [
41
- "dist"
41
+ "dist",
42
+ "config.d.ts"
42
43
  ],
43
44
  "scripts": {
44
45
  "build": "backstage-cli package build",
@@ -50,17 +51,18 @@
50
51
  "test": "backstage-cli package test"
51
52
  },
52
53
  "dependencies": {
53
- "@backstage/backend-plugin-api": "^1.6.0",
54
+ "@backstage/backend-plugin-api": "^1.6.1",
54
55
  "@backstage/config": "^1.3.6",
55
56
  "@backstage/errors": "^1.2.7",
56
- "@backstage/plugin-scaffolder-node": "^0.12.2",
57
+ "@backstage/plugin-scaffolder-node": "^0.12.3",
57
58
  "yaml": "^2.3.3"
58
59
  },
59
60
  "devDependencies": {
60
- "@backstage/backend-test-utils": "^1.10.2",
61
- "@backstage/cli": "^0.35.0",
62
- "@backstage/plugin-scaffolder-node-test-utils": "^0.3.6",
61
+ "@backstage/backend-test-utils": "^1.10.3",
62
+ "@backstage/cli": "^0.35.2",
63
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.3.7",
63
64
  "@backstage/types": "^1.2.2",
64
65
  "msw": "^2.0.0"
65
- }
66
+ },
67
+ "configSchema": "config.d.ts"
66
68
  }