@backstage/backend-defaults 0.15.2 → 0.15.3-next.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,30 @@
1
1
  # @backstage/backend-defaults
2
2
 
3
+ ## 0.15.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 6738cf0: build(deps): bump `minimatch` from 9.0.5 to 10.2.1
8
+ - d933f62: Add configurable throttling and retry mechanism for GitLab integration.
9
+ - b99158a: Fixed `yarn backstage-cli config:check --strict --config app-config.yaml` config validation error by adding
10
+ an optional `default` type discriminator to PostgreSQL connection configuration,
11
+ allowing `config:check` to properly validate `default` connection configurations.
12
+ - 1ee5b28: Adds an alpha `MetricsService` to provide a unified interface for metrics instrumentation across Backstage plugins.
13
+ - Updated dependencies
14
+ - @backstage/cli-node@0.2.19-next.0
15
+ - @backstage/integration@1.21.0-next.0
16
+ - @backstage/config-loader@1.10.9-next.0
17
+ - @backstage/backend-plugin-api@1.7.1-next.0
18
+ - @backstage/backend-app-api@1.5.1-next.0
19
+ - @backstage/backend-dev-utils@0.1.7
20
+ - @backstage/config@1.3.6
21
+ - @backstage/errors@1.2.7
22
+ - @backstage/integration-aws-node@0.1.20
23
+ - @backstage/types@1.2.2
24
+ - @backstage/plugin-auth-node@0.6.14-next.0
25
+ - @backstage/plugin-events-node@0.4.20-next.0
26
+ - @backstage/plugin-permission-node@0.10.11-next.0
27
+
3
28
  ## 0.15.2
4
29
 
5
30
  ### Patch Changes
package/config.d.ts CHANGED
@@ -633,6 +633,10 @@ export interface Config {
633
633
  ipAddressType?: 'PUBLIC' | 'PRIVATE' | 'PSC';
634
634
  }
635
635
  | {
636
+ /**
637
+ * The rest config for default, regular connections
638
+ */
639
+ type?: 'default';
636
640
  /**
637
641
  * Password that belongs to the client User
638
642
  * @visibility secret
@@ -1123,6 +1127,36 @@ export interface Config {
1123
1127
  headers?: { [name: string]: string };
1124
1128
  };
1125
1129
 
1130
+ /**
1131
+ * Options for the metrics service.
1132
+ */
1133
+ metrics?: {
1134
+ /**
1135
+ * Plugin-specific metrics configuration. Each plugin can override meter metadata.
1136
+ */
1137
+ plugin?: {
1138
+ [pluginId: string]: {
1139
+ /**
1140
+ * Meter configuration for this plugin.
1141
+ */
1142
+ meter?: {
1143
+ /**
1144
+ * Custom meter name. If not set, defaults to backstage-plugin-{pluginId}.
1145
+ */
1146
+ name?: string;
1147
+ /**
1148
+ * Version for the meter.
1149
+ */
1150
+ version?: string;
1151
+ /**
1152
+ * Schema URL for the meter.
1153
+ */
1154
+ schemaUrl?: string;
1155
+ };
1156
+ };
1157
+ };
1158
+ };
1159
+
1126
1160
  /**
1127
1161
  * Options to configure the default RootLoggerService.
1128
1162
  */
@@ -48,6 +48,7 @@ const defaultServiceFactories = [
48
48
  // alpha services
49
49
  alpha.actionsRegistryServiceFactory,
50
50
  alpha.actionsServiceFactory,
51
+ alpha.metricsServiceFactory,
51
52
  // Unexported alpha services kept around for compatibility reasons
52
53
  instanceMetadataServiceFactory.instanceMetadataServiceFactory
53
54
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"CreateBackend.cjs.js","sources":["../src/CreateBackend.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Backend, createSpecializedBackend } from '@backstage/backend-app-api';\nimport { auditorServiceFactory } from '@backstage/backend-defaults/auditor';\nimport { authServiceFactory } from '@backstage/backend-defaults/auth';\nimport { cacheServiceFactory } from '@backstage/backend-defaults/cache';\nimport { databaseServiceFactory } from '@backstage/backend-defaults/database';\nimport { discoveryServiceFactory } from '@backstage/backend-defaults/discovery';\nimport { httpAuthServiceFactory } from '@backstage/backend-defaults/httpAuth';\nimport { httpRouterServiceFactory } from '@backstage/backend-defaults/httpRouter';\nimport { lifecycleServiceFactory } from '@backstage/backend-defaults/lifecycle';\nimport { loggerServiceFactory } from '@backstage/backend-defaults/logger';\nimport { permissionsServiceFactory } from '@backstage/backend-defaults/permissions';\nimport { permissionsRegistryServiceFactory } from '@backstage/backend-defaults/permissionsRegistry';\nimport { rootConfigServiceFactory } from '@backstage/backend-defaults/rootConfig';\nimport { rootHealthServiceFactory } from '@backstage/backend-defaults/rootHealth';\nimport { rootHttpRouterServiceFactory } from '@backstage/backend-defaults/rootHttpRouter';\nimport { rootLifecycleServiceFactory } from '@backstage/backend-defaults/rootLifecycle';\nimport { rootLoggerServiceFactory } from '@backstage/backend-defaults/rootLogger';\nimport { schedulerServiceFactory } from '@backstage/backend-defaults/scheduler';\nimport { urlReaderServiceFactory } from '@backstage/backend-defaults/urlReader';\nimport { userInfoServiceFactory } from '@backstage/backend-defaults/userInfo';\nimport { eventsServiceFactory } from '@backstage/plugin-events-node';\nimport {\n actionsRegistryServiceFactory,\n actionsServiceFactory,\n} from '@backstage/backend-defaults/alpha';\nimport { instanceMetadataServiceFactory } from './alpha/entrypoints/instanceMetadata/instanceMetadataServiceFactory';\n\nexport const defaultServiceFactories = [\n auditorServiceFactory,\n authServiceFactory,\n cacheServiceFactory,\n rootConfigServiceFactory,\n databaseServiceFactory,\n discoveryServiceFactory,\n httpAuthServiceFactory,\n httpRouterServiceFactory,\n lifecycleServiceFactory,\n loggerServiceFactory,\n permissionsServiceFactory,\n permissionsRegistryServiceFactory,\n rootHealthServiceFactory,\n rootHttpRouterServiceFactory,\n rootLifecycleServiceFactory,\n rootLoggerServiceFactory,\n schedulerServiceFactory,\n userInfoServiceFactory,\n urlReaderServiceFactory,\n eventsServiceFactory,\n\n // alpha services\n actionsRegistryServiceFactory,\n actionsServiceFactory,\n\n // Unexported alpha services kept around for compatibility reasons\n instanceMetadataServiceFactory,\n];\n\n/**\n * @public\n */\nexport function createBackend(): Backend {\n return createSpecializedBackend({ defaultServiceFactories });\n}\n"],"names":["auditorServiceFactory","authServiceFactory","cacheServiceFactory","rootConfigServiceFactory","databaseServiceFactory","discoveryServiceFactory","httpAuthServiceFactory","httpRouterServiceFactory","lifecycleServiceFactory","loggerServiceFactory","permissionsServiceFactory","permissionsRegistryServiceFactory","rootHealthServiceFactory","rootHttpRouterServiceFactory","rootLifecycleServiceFactory","rootLoggerServiceFactory","schedulerServiceFactory","userInfoServiceFactory","urlReaderServiceFactory","eventsServiceFactory","actionsRegistryServiceFactory","actionsServiceFactory","instanceMetadataServiceFactory","createSpecializedBackend"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAM,uBAAA,GAA0B;AAAA,EACrCA,6BAAA;AAAA,EACAC,uBAAA;AAAA,EACAC,yBAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,+BAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,+BAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,2BAAA;AAAA,EACAC,qCAAA;AAAA,EACAC,qDAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,2CAAA;AAAA,EACAC,yCAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,+BAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,qCAAA;AAAA;AAAA,EAGAC,mCAAA;AAAA,EACAC,2BAAA;AAAA;AAAA,EAGAC;AACF;AAKO,SAAS,aAAA,GAAyB;AACvC,EAAA,OAAOC,sCAAA,CAAyB,EAAE,uBAAA,EAAyB,CAAA;AAC7D;;;;;"}
1
+ {"version":3,"file":"CreateBackend.cjs.js","sources":["../src/CreateBackend.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Backend, createSpecializedBackend } from '@backstage/backend-app-api';\nimport { auditorServiceFactory } from '@backstage/backend-defaults/auditor';\nimport { authServiceFactory } from '@backstage/backend-defaults/auth';\nimport { cacheServiceFactory } from '@backstage/backend-defaults/cache';\nimport { databaseServiceFactory } from '@backstage/backend-defaults/database';\nimport { discoveryServiceFactory } from '@backstage/backend-defaults/discovery';\nimport { httpAuthServiceFactory } from '@backstage/backend-defaults/httpAuth';\nimport { httpRouterServiceFactory } from '@backstage/backend-defaults/httpRouter';\nimport { lifecycleServiceFactory } from '@backstage/backend-defaults/lifecycle';\nimport { loggerServiceFactory } from '@backstage/backend-defaults/logger';\nimport { permissionsServiceFactory } from '@backstage/backend-defaults/permissions';\nimport { permissionsRegistryServiceFactory } from '@backstage/backend-defaults/permissionsRegistry';\nimport { rootConfigServiceFactory } from '@backstage/backend-defaults/rootConfig';\nimport { rootHealthServiceFactory } from '@backstage/backend-defaults/rootHealth';\nimport { rootHttpRouterServiceFactory } from '@backstage/backend-defaults/rootHttpRouter';\nimport { rootLifecycleServiceFactory } from '@backstage/backend-defaults/rootLifecycle';\nimport { rootLoggerServiceFactory } from '@backstage/backend-defaults/rootLogger';\nimport { schedulerServiceFactory } from '@backstage/backend-defaults/scheduler';\nimport { urlReaderServiceFactory } from '@backstage/backend-defaults/urlReader';\nimport { userInfoServiceFactory } from '@backstage/backend-defaults/userInfo';\nimport { eventsServiceFactory } from '@backstage/plugin-events-node';\nimport {\n actionsRegistryServiceFactory,\n actionsServiceFactory,\n metricsServiceFactory,\n} from '@backstage/backend-defaults/alpha';\nimport { instanceMetadataServiceFactory } from './alpha/entrypoints/instanceMetadata/instanceMetadataServiceFactory';\n\nexport const defaultServiceFactories = [\n auditorServiceFactory,\n authServiceFactory,\n cacheServiceFactory,\n rootConfigServiceFactory,\n databaseServiceFactory,\n discoveryServiceFactory,\n httpAuthServiceFactory,\n httpRouterServiceFactory,\n lifecycleServiceFactory,\n loggerServiceFactory,\n permissionsServiceFactory,\n permissionsRegistryServiceFactory,\n rootHealthServiceFactory,\n rootHttpRouterServiceFactory,\n rootLifecycleServiceFactory,\n rootLoggerServiceFactory,\n schedulerServiceFactory,\n userInfoServiceFactory,\n urlReaderServiceFactory,\n eventsServiceFactory,\n\n // alpha services\n actionsRegistryServiceFactory,\n actionsServiceFactory,\n metricsServiceFactory,\n\n // Unexported alpha services kept around for compatibility reasons\n instanceMetadataServiceFactory,\n];\n\n/**\n * @public\n */\nexport function createBackend(): Backend {\n return createSpecializedBackend({ defaultServiceFactories });\n}\n"],"names":["auditorServiceFactory","authServiceFactory","cacheServiceFactory","rootConfigServiceFactory","databaseServiceFactory","discoveryServiceFactory","httpAuthServiceFactory","httpRouterServiceFactory","lifecycleServiceFactory","loggerServiceFactory","permissionsServiceFactory","permissionsRegistryServiceFactory","rootHealthServiceFactory","rootHttpRouterServiceFactory","rootLifecycleServiceFactory","rootLoggerServiceFactory","schedulerServiceFactory","userInfoServiceFactory","urlReaderServiceFactory","eventsServiceFactory","actionsRegistryServiceFactory","actionsServiceFactory","metricsServiceFactory","instanceMetadataServiceFactory","createSpecializedBackend"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4CO,MAAM,uBAAA,GAA0B;AAAA,EACrCA,6BAAA;AAAA,EACAC,uBAAA;AAAA,EACAC,yBAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,+BAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,+BAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,2BAAA;AAAA,EACAC,qCAAA;AAAA,EACAC,qDAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,2CAAA;AAAA,EACAC,yCAAA;AAAA,EACAC,mCAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,+BAAA;AAAA,EACAC,iCAAA;AAAA,EACAC,qCAAA;AAAA;AAAA,EAGAC,mCAAA;AAAA,EACAC,2BAAA;AAAA,EACAC,2BAAA;AAAA;AAAA,EAGAC;AACF;AAKO,SAAS,aAAA,GAAyB;AACvC,EAAA,OAAOC,sCAAA,CAAyB,EAAE,uBAAA,EAAyB,CAAA;AAC7D;;;;;"}
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var api = require('@opentelemetry/api');
4
+
5
+ class DefaultMetricsService {
6
+ meter;
7
+ constructor(opts) {
8
+ this.meter = api.metrics.getMeter(opts.name, opts.version, {
9
+ schemaUrl: opts.schemaUrl
10
+ });
11
+ }
12
+ /**
13
+ * Creates a new {@link MetricsService} instance.
14
+ *
15
+ * @param opts - Options for configuring the meter scope
16
+ * @returns A new MetricsService instance
17
+ */
18
+ static create(opts) {
19
+ return new DefaultMetricsService(opts);
20
+ }
21
+ createCounter(name, opts) {
22
+ return this.meter.createCounter(name, opts);
23
+ }
24
+ createUpDownCounter(name, opts) {
25
+ return this.meter.createUpDownCounter(name, opts);
26
+ }
27
+ createHistogram(name, opts) {
28
+ return this.meter.createHistogram(name, opts);
29
+ }
30
+ createGauge(name, opts) {
31
+ return this.meter.createGauge(name, opts);
32
+ }
33
+ createObservableCounter(name, opts) {
34
+ return this.meter.createObservableCounter(name, opts);
35
+ }
36
+ createObservableUpDownCounter(name, opts) {
37
+ return this.meter.createObservableUpDownCounter(name, opts);
38
+ }
39
+ createObservableGauge(name, opts) {
40
+ return this.meter.createObservableGauge(name, opts);
41
+ }
42
+ }
43
+
44
+ exports.DefaultMetricsService = DefaultMetricsService;
45
+ //# sourceMappingURL=DefaultMetricsService.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultMetricsService.cjs.js","sources":["../../../../src/alpha/entrypoints/metrics/DefaultMetricsService.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\nimport { Meter, metrics } from '@opentelemetry/api';\nimport {\n MetricsService,\n MetricAttributes,\n MetricOptions,\n MetricsServiceCounter,\n MetricsServiceUpDownCounter,\n MetricsServiceHistogram,\n MetricsServiceGauge,\n MetricsServiceObservableCounter,\n MetricsServiceObservableGauge,\n MetricsServiceObservableUpDownCounter,\n} from '@backstage/backend-plugin-api/alpha';\n\n/**\n * Options for creating a {@link DefaultMetricsService}.\n *\n * @alpha\n */\nexport interface DefaultMetricsServiceOptions {\n name: string;\n version?: string;\n schemaUrl?: string;\n}\n\n/**\n * Default implementation of the {@link MetricsService} interface.\n *\n * This implementation provides a thin wrapper around the OpenTelemetry Meter API.\n *\n * @alpha\n */\nexport class DefaultMetricsService implements MetricsService {\n private readonly meter: Meter;\n\n private constructor(opts: DefaultMetricsServiceOptions) {\n // The meter name sets the OpenTelemetry Instrumentation Scope which identifies the source of metrics in telemetry backends.\n this.meter = metrics.getMeter(opts.name, opts.version, {\n schemaUrl: opts.schemaUrl,\n });\n }\n\n /**\n * Creates a new {@link MetricsService} instance.\n *\n * @param opts - Options for configuring the meter scope\n * @returns A new MetricsService instance\n */\n static create(opts: DefaultMetricsServiceOptions): MetricsService {\n return new DefaultMetricsService(opts);\n }\n\n createCounter<TAttributes extends MetricAttributes = MetricAttributes>(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceCounter<TAttributes> {\n return this.meter.createCounter(name, opts);\n }\n\n createUpDownCounter<TAttributes extends MetricAttributes = MetricAttributes>(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceUpDownCounter<TAttributes> {\n return this.meter.createUpDownCounter(name, opts);\n }\n\n createHistogram<TAttributes extends MetricAttributes = MetricAttributes>(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceHistogram<TAttributes> {\n return this.meter.createHistogram(name, opts);\n }\n\n createGauge<TAttributes extends MetricAttributes = MetricAttributes>(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceGauge<TAttributes> {\n return this.meter.createGauge(name, opts);\n }\n\n createObservableCounter<\n TAttributes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceObservableCounter<TAttributes> {\n return this.meter.createObservableCounter(name, opts);\n }\n\n createObservableUpDownCounter<\n TAttributes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceObservableUpDownCounter<TAttributes> {\n return this.meter.createObservableUpDownCounter(name, opts);\n }\n\n createObservableGauge<\n TAttributes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n opts?: MetricOptions,\n ): MetricsServiceObservableGauge<TAttributes> {\n return this.meter.createObservableGauge(name, opts);\n }\n}\n"],"names":["metrics"],"mappings":";;;;AAgDO,MAAM,qBAAA,CAAgD;AAAA,EAC1C,KAAA;AAAA,EAET,YAAY,IAAA,EAAoC;AAEtD,IAAA,IAAA,CAAK,QAAQA,WAAA,CAAQ,QAAA,CAAS,IAAA,CAAK,IAAA,EAAM,KAAK,OAAA,EAAS;AAAA,MACrD,WAAW,IAAA,CAAK;AAAA,KACjB,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAAO,IAAA,EAAoD;AAChE,IAAA,OAAO,IAAI,sBAAsB,IAAI,CAAA;AAAA,EACvC;AAAA,EAEA,aAAA,CACE,MACA,IAAA,EACoC;AACpC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,EAAM,IAAI,CAAA;AAAA,EAC5C;AAAA,EAEA,mBAAA,CACE,MACA,IAAA,EAC0C;AAC1C,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,mBAAA,CAAoB,IAAA,EAAM,IAAI,CAAA;AAAA,EAClD;AAAA,EAEA,eAAA,CACE,MACA,IAAA,EACsC;AACtC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,eAAA,CAAgB,IAAA,EAAM,IAAI,CAAA;AAAA,EAC9C;AAAA,EAEA,WAAA,CACE,MACA,IAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,WAAA,CAAY,IAAA,EAAM,IAAI,CAAA;AAAA,EAC1C;AAAA,EAEA,uBAAA,CAGE,MACA,IAAA,EAC8C;AAC9C,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,uBAAA,CAAwB,IAAA,EAAM,IAAI,CAAA;AAAA,EACtD;AAAA,EAEA,6BAAA,CAGE,MACA,IAAA,EACoD;AACpD,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,6BAAA,CAA8B,IAAA,EAAM,IAAI,CAAA;AAAA,EAC5D;AAAA,EAEA,qBAAA,CAGE,MACA,IAAA,EAC4C;AAC5C,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,qBAAA,CAAsB,IAAA,EAAM,IAAI,CAAA;AAAA,EACpD;AACF;;;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var alpha = require('@backstage/backend-plugin-api/alpha');
4
+ var backendPluginApi = require('@backstage/backend-plugin-api');
5
+ var DefaultMetricsService = require('./DefaultMetricsService.cjs.js');
6
+
7
+ const metricsServiceFactory = backendPluginApi.createServiceFactory({
8
+ service: alpha.metricsServiceRef,
9
+ deps: {
10
+ config: backendPluginApi.coreServices.rootConfig,
11
+ pluginMetadata: backendPluginApi.coreServices.pluginMetadata
12
+ },
13
+ factory: ({ config, pluginMetadata }) => {
14
+ const pluginId = pluginMetadata.getId();
15
+ const meterConfig = config.getOptionalConfig(
16
+ `backend.metrics.plugin.${pluginId}.meter`
17
+ );
18
+ const scopeName = `backstage-plugin-${pluginId}`;
19
+ const name = meterConfig?.getOptionalString("name") ?? scopeName;
20
+ const version = meterConfig?.getOptionalString("version");
21
+ const schemaUrl = meterConfig?.getOptionalString("schemaUrl");
22
+ return DefaultMetricsService.DefaultMetricsService.create({ name, version, schemaUrl });
23
+ }
24
+ });
25
+
26
+ exports.metricsServiceFactory = metricsServiceFactory;
27
+ //# sourceMappingURL=metricsServiceFactory.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metricsServiceFactory.cjs.js","sources":["../../../../src/alpha/entrypoints/metrics/metricsServiceFactory.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { metricsServiceRef } from '@backstage/backend-plugin-api/alpha';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { DefaultMetricsService } from './DefaultMetricsService';\n\n/**\n * Service factory for collecting plugin-scoped metrics.\n *\n * @alpha\n */\nexport const metricsServiceFactory = createServiceFactory({\n service: metricsServiceRef,\n deps: {\n config: coreServices.rootConfig,\n pluginMetadata: coreServices.pluginMetadata,\n },\n factory: ({ config, pluginMetadata }) => {\n const pluginId = pluginMetadata.getId();\n\n const meterConfig = config.getOptionalConfig(\n `backend.metrics.plugin.${pluginId}.meter`,\n );\n const scopeName = `backstage-plugin-${pluginId}`;\n const name = meterConfig?.getOptionalString('name') ?? scopeName;\n const version = meterConfig?.getOptionalString('version');\n const schemaUrl = meterConfig?.getOptionalString('schemaUrl');\n\n return DefaultMetricsService.create({ name, version, schemaUrl });\n },\n});\n"],"names":["createServiceFactory","metricsServiceRef","coreServices","DefaultMetricsService"],"mappings":";;;;;;AA4BO,MAAM,wBAAwBA,qCAAA,CAAqB;AAAA,EACxD,OAAA,EAASC,uBAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,QAAQC,6BAAA,CAAa,UAAA;AAAA,IACrB,gBAAgBA,6BAAA,CAAa;AAAA,GAC/B;AAAA,EACA,OAAA,EAAS,CAAC,EAAE,MAAA,EAAQ,gBAAe,KAAM;AACvC,IAAA,MAAM,QAAA,GAAW,eAAe,KAAA,EAAM;AAEtC,IAAA,MAAM,cAAc,MAAA,CAAO,iBAAA;AAAA,MACzB,0BAA0B,QAAQ,CAAA,MAAA;AAAA,KACpC;AACA,IAAA,MAAM,SAAA,GAAY,oBAAoB,QAAQ,CAAA,CAAA;AAC9C,IAAA,MAAM,IAAA,GAAO,WAAA,EAAa,iBAAA,CAAkB,MAAM,CAAA,IAAK,SAAA;AACvD,IAAA,MAAM,OAAA,GAAU,WAAA,EAAa,iBAAA,CAAkB,SAAS,CAAA;AACxD,IAAA,MAAM,SAAA,GAAY,WAAA,EAAa,iBAAA,CAAkB,WAAW,CAAA;AAE5D,IAAA,OAAOC,4CAAsB,MAAA,CAAO,EAAE,IAAA,EAAM,OAAA,EAAS,WAAW,CAAA;AAAA,EAClE;AACF,CAAC;;;;"}
package/dist/alpha.cjs.js CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  var actionsRegistryServiceFactory = require('./alpha/entrypoints/actionsRegistry/actionsRegistryServiceFactory.cjs.js');
4
4
  var actionsServiceFactory = require('./alpha/entrypoints/actions/actionsServiceFactory.cjs.js');
5
+ var metricsServiceFactory = require('./alpha/entrypoints/metrics/metricsServiceFactory.cjs.js');
5
6
  var rootSystemMetadataServiceFactory = require('./alpha/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.cjs.js');
6
7
 
7
8
 
8
9
 
9
10
  exports.actionsRegistryServiceFactory = actionsRegistryServiceFactory.actionsRegistryServiceFactory;
10
11
  exports.actionsServiceFactory = actionsServiceFactory.actionsServiceFactory;
12
+ exports.metricsServiceFactory = metricsServiceFactory.metricsServiceFactory;
11
13
  exports.rootSystemMetadataServiceFactory = rootSystemMetadataServiceFactory.rootSystemMetadataServiceFactory;
12
14
  //# sourceMappingURL=alpha.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -11,6 +11,13 @@ declare const actionsRegistryServiceFactory: _backstage_backend_plugin_api.Servi
11
11
  */
12
12
  declare const actionsServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api_alpha.ActionsService, "plugin", "singleton">;
13
13
 
14
+ /**
15
+ * Service factory for collecting plugin-scoped metrics.
16
+ *
17
+ * @alpha
18
+ */
19
+ declare const metricsServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api_alpha.MetricsService, "plugin", "singleton">;
20
+
14
21
  /**
15
22
  * Metadata about an entire Backstage system, a collection of Backstage instances.
16
23
  *
@@ -18,4 +25,4 @@ declare const actionsServiceFactory: _backstage_backend_plugin_api.ServiceFactor
18
25
  */
19
26
  declare const rootSystemMetadataServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api_alpha.RootSystemMetadataService, "root", "singleton">;
20
27
 
21
- export { actionsRegistryServiceFactory, actionsServiceFactory, rootSystemMetadataServiceFactory };
28
+ export { actionsRegistryServiceFactory, actionsServiceFactory, metricsServiceFactory, rootSystemMetadataServiceFactory };
@@ -1,18 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var fetch = require('node-fetch');
4
3
  var errors = require('@backstage/errors');
5
4
  var integration = require('@backstage/integration');
6
5
  var parseGitUrl = require('git-url-parse');
7
6
  var lodash = require('lodash');
8
7
  var minimatch = require('minimatch');
9
- var node_stream = require('node:stream');
10
8
  var ReadUrlResponseFactory = require('./ReadUrlResponseFactory.cjs.js');
11
- var util = require('./util.cjs.js');
12
9
 
13
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
14
11
 
15
- var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
16
12
  var parseGitUrl__default = /*#__PURE__*/_interopDefaultCompat(parseGitUrl);
17
13
 
18
14
  class GitlabUrlReader {
@@ -42,7 +38,7 @@ class GitlabUrlReader {
42
38
  const builtUrl = await this.getGitlabFetchUrl(url, token);
43
39
  let response;
44
40
  try {
45
- response = await fetch__default.default(builtUrl, {
41
+ response = await this.integration.fetch(builtUrl, {
46
42
  headers: {
47
43
  ...integration.getGitLabRequestOptions(this.integration.config, token).headers,
48
44
  ...etag && !isArtifact && { "If-None-Match": etag },
@@ -65,12 +61,7 @@ class GitlabUrlReader {
65
61
  throw new errors.NotModifiedError();
66
62
  }
67
63
  if (response.ok) {
68
- return ReadUrlResponseFactory.ReadUrlResponseFactory.fromNodeJSReadable(response.body, {
69
- etag: response.headers.get("ETag") ?? void 0,
70
- lastModifiedAt: util.parseLastModified(
71
- response.headers.get("Last-Modified")
72
- )
73
- });
64
+ return ReadUrlResponseFactory.ReadUrlResponseFactory.fromResponse(response);
74
65
  }
75
66
  const message = `${url} could not be read as ${builtUrl}, ${response.status} ${response.statusText}`;
76
67
  if (response.status === 404) {
@@ -89,7 +80,7 @@ class GitlabUrlReader {
89
80
  const rectifiedRelativePath = `${lodash.trimStart(relativePath, "/")}/`;
90
81
  repoFullName = full_name.replace(rectifiedRelativePath, "");
91
82
  }
92
- const projectGitlabResponse = await fetch__default.default(
83
+ const projectGitlabResponse = await this.integration.fetch(
93
84
  new URL(
94
85
  `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(
95
86
  repoFullName
@@ -111,7 +102,7 @@ class GitlabUrlReader {
111
102
  if (!!filepath) {
112
103
  commitsReqParams.set("path", filepath);
113
104
  }
114
- const commitsGitlabResponse = await fetch__default.default(
105
+ const commitsGitlabResponse = await this.integration.fetch(
115
106
  new URL(
116
107
  `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(
117
108
  repoFullName
@@ -144,30 +135,28 @@ class GitlabUrlReader {
144
135
  if (!!filepath) {
145
136
  archiveReqParams.set("path", filepath);
146
137
  }
147
- const archiveGitLabResponse = await fetch__default.default(
148
- `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(
149
- repoFullName
150
- )}/repository/archive?${archiveReqParams.toString()}`,
151
- {
152
- ...integration.getGitLabRequestOptions(this.integration.config, token),
153
- // TODO(freben): The signal cast is there because pre-3.x versions of
154
- // node-fetch have a very slightly deviating AbortSignal type signature.
155
- // The difference does not affect us in practice however. The cast can
156
- // be removed after we support ESM for CLI dependencies and migrate to
157
- // version 3 of node-fetch.
158
- // https://github.com/backstage/backstage/issues/8242
159
- ...signal && { signal }
160
- }
161
- );
138
+ const reqUrl = `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(
139
+ repoFullName
140
+ )}/repository/archive?${archiveReqParams.toString()}`;
141
+ const archiveGitLabResponse = await this.integration.fetch(reqUrl, {
142
+ ...integration.getGitLabRequestOptions(this.integration.config, token),
143
+ // TODO(freben): The signal cast is there because pre-3.x versions of
144
+ // node-fetch have a very slightly deviating AbortSignal type signature.
145
+ // The difference does not affect us in practice however. The cast can
146
+ // be removed after we support ESM for CLI dependencies and migrate to
147
+ // version 3 of node-fetch.
148
+ // https://github.com/backstage/backstage/issues/8242
149
+ ...signal && { signal }
150
+ });
162
151
  if (!archiveGitLabResponse.ok) {
163
- const message = `Failed to read tree (archive) from ${url}, ${archiveGitLabResponse.status} ${archiveGitLabResponse.statusText}`;
152
+ const message = `Failed to read tree (archive) from ${url}, ${reqUrl}, ${archiveGitLabResponse.status} ${archiveGitLabResponse.statusText}`;
164
153
  if (archiveGitLabResponse.status === 404) {
165
154
  throw new errors.NotFoundError(message);
166
155
  }
167
156
  throw new Error(message);
168
157
  }
169
158
  return await this.deps.treeResponseFactory.fromTarArchive({
170
- stream: node_stream.Readable.from(archiveGitLabResponse.body),
159
+ response: archiveGitLabResponse,
171
160
  subpath: filepath,
172
161
  etag: commitSha,
173
162
  filter: options?.filter
@@ -244,7 +233,7 @@ class GitlabUrlReader {
244
233
  async getGitlabFetchUrl(target, token) {
245
234
  const targetUrl = new URL(target);
246
235
  if (targetUrl.pathname.includes("/-/jobs/artifacts/")) {
247
- return this.getGitlabArtifactFetchUrl(targetUrl, token).then(
236
+ return this.getGitlabArtifactFetchUrl(targetUrl).then(
248
237
  (value) => value.toString()
249
238
  );
250
239
  }
@@ -253,52 +242,32 @@ class GitlabUrlReader {
253
242
  // convert urls of the form:
254
243
  // https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path_to_file>?job=<job_name>
255
244
  // to urls of the form:
256
- // https://example.com/api/v4/projects/:id/jobs/artifacts/:ref_name/raw/*artifact_path?job=<job_name>
257
- async getGitlabArtifactFetchUrl(target, token) {
245
+ // https://example.com/api/v4/projects/namespace%2Fproject/jobs/artifacts/:ref_name/raw/*artifact_path?job=<job_name>
246
+ getGitlabArtifactFetchUrl(target) {
258
247
  if (!target.pathname.includes("/-/jobs/artifacts/")) {
259
248
  throw new Error("Unable to process url as an GitLab artifact");
260
249
  }
261
250
  try {
262
251
  const [namespaceAndProject, ref] = target.pathname.split("/-/jobs/artifacts/");
263
- const projectPath = new URL(target);
264
- projectPath.pathname = namespaceAndProject;
265
- const projectId = await this.resolveProjectToId(projectPath, token);
266
252
  const relativePath = integration.getGitLabIntegrationRelativePath(
267
253
  this.integration.config
268
254
  );
255
+ let projectPath = namespaceAndProject;
256
+ if (relativePath) {
257
+ projectPath = lodash.trimStart(projectPath, relativePath);
258
+ }
259
+ projectPath = projectPath.replace(/^\//, "");
269
260
  const newUrl = new URL(target);
270
- newUrl.pathname = `${relativePath}/api/v4/projects/${projectId}/jobs/artifacts/${ref}`;
271
- return newUrl;
261
+ newUrl.pathname = `${relativePath}/api/v4/projects/${encodeURIComponent(
262
+ projectPath
263
+ )}/jobs/artifacts/${ref}`;
264
+ return Promise.resolve(newUrl);
272
265
  } catch (e) {
273
266
  throw new Error(
274
267
  `Unable to translate GitLab artifact URL: ${target}, ${e}`
275
268
  );
276
269
  }
277
270
  }
278
- async resolveProjectToId(pathToProject, token) {
279
- let project = pathToProject.pathname;
280
- const relativePath = integration.getGitLabIntegrationRelativePath(
281
- this.integration.config
282
- );
283
- if (relativePath) {
284
- project = project.replace(relativePath, "");
285
- }
286
- project = project.replace(/^\//, "");
287
- const result = await fetch__default.default(
288
- `${pathToProject.origin}${relativePath}/api/v4/projects/${encodeURIComponent(project)}`,
289
- integration.getGitLabRequestOptions(this.integration.config, token)
290
- );
291
- const data = await result.json();
292
- if (!result.ok) {
293
- if (result.status === 401) {
294
- throw new Error(
295
- "GitLab Error: 401 - Unauthorized. The access token used is either expired, or does not have permission to read the project"
296
- );
297
- }
298
- throw new Error(`Gitlab error: ${data.error}, ${data.error_description}`);
299
- }
300
- return Number(data.id);
301
- }
302
271
  }
303
272
 
304
273
  exports.GitlabUrlReader = GitlabUrlReader;
@@ -1 +1 @@
1
- {"version":3,"file":"GitlabUrlReader.cjs.js","sources":["../../../../src/entrypoints/urlReader/lib/GitlabUrlReader.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// NOTE(freben): Intentionally uses node-fetch because of https://github.com/backstage/backstage/issues/28190\nimport fetch, { Response } from 'node-fetch';\n\nimport {\n UrlReaderService,\n UrlReaderServiceReadTreeOptions,\n UrlReaderServiceReadTreeResponse,\n UrlReaderServiceReadUrlOptions,\n UrlReaderServiceReadUrlResponse,\n UrlReaderServiceSearchOptions,\n UrlReaderServiceSearchResponse,\n} from '@backstage/backend-plugin-api';\nimport {\n assertError,\n NotFoundError,\n NotModifiedError,\n} from '@backstage/errors';\nimport {\n getGitLabFileFetchUrl,\n getGitLabIntegrationRelativePath,\n getGitLabRequestOptions,\n GitLabIntegration,\n ScmIntegrations,\n} from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\nimport { trimEnd, trimStart } from 'lodash';\nimport { Minimatch } from 'minimatch';\nimport { Readable } from 'node:stream';\nimport { ReadUrlResponseFactory } from './ReadUrlResponseFactory';\nimport { ReaderFactory, ReadTreeResponseFactory } from './types';\nimport { parseLastModified } from './util';\n\n/**\n * Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files on GitLab.\n *\n * @public\n */\nexport class GitlabUrlReader implements UrlReaderService {\n static factory: ReaderFactory = ({ config, treeResponseFactory }) => {\n const integrations = ScmIntegrations.fromConfig(config);\n return integrations.gitlab.list().map(integration => {\n const reader = new GitlabUrlReader(integration, {\n treeResponseFactory,\n });\n const predicate = (url: URL) => url.host === integration.config.host;\n return { reader, predicate };\n });\n };\n\n private readonly integration: GitLabIntegration;\n private readonly deps: { treeResponseFactory: ReadTreeResponseFactory };\n\n constructor(\n integration: GitLabIntegration,\n deps: { treeResponseFactory: ReadTreeResponseFactory },\n ) {\n this.integration = integration;\n this.deps = deps;\n }\n\n async read(url: string): Promise<Buffer> {\n const response = await this.readUrl(url);\n return response.buffer();\n }\n\n async readUrl(\n url: string,\n options?: UrlReaderServiceReadUrlOptions,\n ): Promise<UrlReaderServiceReadUrlResponse> {\n const { etag, lastModifiedAfter, signal, token } = options ?? {};\n const isArtifact = url.includes('/-/jobs/artifacts/');\n const builtUrl = await this.getGitlabFetchUrl(url, token);\n\n let response: Response;\n try {\n response = await fetch(builtUrl, {\n headers: {\n ...getGitLabRequestOptions(this.integration.config, token).headers,\n ...(etag && !isArtifact && { 'If-None-Match': etag }),\n ...(lastModifiedAfter &&\n !isArtifact && {\n 'If-Modified-Since': lastModifiedAfter.toUTCString(),\n }),\n },\n // TODO(freben): The signal cast is there because pre-3.x versions of\n // node-fetch have a very slightly deviating AbortSignal type signature.\n // The difference does not affect us in practice however. The cast can be\n // removed after we support ESM for CLI dependencies and migrate to\n // version 3 of node-fetch.\n // https://github.com/backstage/backstage/issues/8242\n ...(signal && { signal: signal as any }),\n });\n } catch (e) {\n throw new Error(`Unable to read ${url}, ${e}`);\n }\n\n if (response.status === 304) {\n throw new NotModifiedError();\n }\n\n if (response.ok) {\n return ReadUrlResponseFactory.fromNodeJSReadable(response.body, {\n etag: response.headers.get('ETag') ?? undefined,\n lastModifiedAt: parseLastModified(\n response.headers.get('Last-Modified'),\n ),\n });\n }\n\n const message = `${url} could not be read as ${builtUrl}, ${response.status} ${response.statusText}`;\n if (response.status === 404) {\n throw new NotFoundError(message);\n }\n throw new Error(message);\n }\n\n async readTree(\n url: string,\n options?: UrlReaderServiceReadTreeOptions,\n ): Promise<UrlReaderServiceReadTreeResponse> {\n const { etag, signal, token } = options ?? {};\n const { ref, full_name, filepath } = parseGitUrl(url);\n\n let repoFullName = full_name;\n\n const relativePath = getGitLabIntegrationRelativePath(\n this.integration.config,\n );\n\n // Considering self hosted gitlab with relative\n // assuming '/gitlab' is the relative path\n // from: /gitlab/repo/project\n // to: repo/project\n if (relativePath) {\n const rectifiedRelativePath = `${trimStart(relativePath, '/')}/`;\n repoFullName = full_name.replace(rectifiedRelativePath, '');\n }\n\n // Use GitLab API to get the default branch\n // encodeURIComponent is required for GitLab API\n // https://docs.gitlab.com/ee/api/README.html#namespaced-path-encoding\n const projectGitlabResponse = await fetch(\n new URL(\n `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(\n repoFullName,\n )}`,\n ).toString(),\n getGitLabRequestOptions(this.integration.config, token),\n );\n if (!projectGitlabResponse.ok) {\n const msg = `Failed to read tree from ${url}, ${projectGitlabResponse.status} ${projectGitlabResponse.statusText}`;\n if (projectGitlabResponse.status === 404) {\n throw new NotFoundError(msg);\n }\n throw new Error(msg);\n }\n const projectGitlabResponseJson = await projectGitlabResponse.json();\n\n // ref is an empty string if no branch is set in provided url to readTree.\n const branch = ref || projectGitlabResponseJson.default_branch;\n\n // Fetch the latest commit that modifies the filepath in the provided or default branch\n // to compare against the provided sha.\n const commitsReqParams = new URLSearchParams();\n commitsReqParams.set('ref_name', branch);\n if (!!filepath) {\n commitsReqParams.set('path', filepath);\n }\n const commitsGitlabResponse = await fetch(\n new URL(\n `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(\n repoFullName,\n )}/repository/commits?${commitsReqParams.toString()}`,\n ).toString(),\n {\n ...getGitLabRequestOptions(this.integration.config, token),\n // TODO(freben): The signal cast is there because pre-3.x versions of\n // node-fetch have a very slightly deviating AbortSignal type signature.\n // The difference does not affect us in practice however. The cast can\n // be removed after we support ESM for CLI dependencies and migrate to\n // version 3 of node-fetch.\n // https://github.com/backstage/backstage/issues/8242\n ...(signal && { signal: signal as any }),\n },\n );\n if (!commitsGitlabResponse.ok) {\n const message = `Failed to read tree (branch) from ${url}, ${commitsGitlabResponse.status} ${commitsGitlabResponse.statusText}`;\n if (commitsGitlabResponse.status === 404) {\n throw new NotFoundError(message);\n }\n throw new Error(message);\n }\n\n const commitSha = (await commitsGitlabResponse.json())[0]?.id ?? '';\n if (etag && etag === commitSha) {\n throw new NotModifiedError();\n }\n\n const archiveReqParams = new URLSearchParams();\n archiveReqParams.set('sha', branch);\n if (!!filepath) {\n archiveReqParams.set('path', filepath);\n }\n // https://docs.gitlab.com/ee/api/repositories.html#get-file-archive\n const archiveGitLabResponse = await fetch(\n `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(\n repoFullName,\n )}/repository/archive?${archiveReqParams.toString()}`,\n {\n ...getGitLabRequestOptions(this.integration.config, token),\n // TODO(freben): The signal cast is there because pre-3.x versions of\n // node-fetch have a very slightly deviating AbortSignal type signature.\n // The difference does not affect us in practice however. The cast can\n // be removed after we support ESM for CLI dependencies and migrate to\n // version 3 of node-fetch.\n // https://github.com/backstage/backstage/issues/8242\n ...(signal && { signal: signal as any }),\n },\n );\n if (!archiveGitLabResponse.ok) {\n const message = `Failed to read tree (archive) from ${url}, ${archiveGitLabResponse.status} ${archiveGitLabResponse.statusText}`;\n if (archiveGitLabResponse.status === 404) {\n throw new NotFoundError(message);\n }\n throw new Error(message);\n }\n\n return await this.deps.treeResponseFactory.fromTarArchive({\n stream: Readable.from(archiveGitLabResponse.body),\n subpath: filepath,\n etag: commitSha,\n filter: options?.filter,\n });\n }\n\n async search(\n url: string,\n options?: UrlReaderServiceSearchOptions,\n ): Promise<UrlReaderServiceSearchResponse> {\n const { filepath } = parseGitUrl(url);\n\n // If it's a direct URL we use readUrl instead\n if (!filepath?.match(/[*?]/)) {\n try {\n const data = await this.readUrl(url, options);\n\n return {\n files: [\n {\n url: url,\n content: data.buffer,\n lastModifiedAt: data.lastModifiedAt,\n },\n ],\n etag: data.etag ?? '',\n };\n } catch (error) {\n assertError(error);\n if (error.name === 'NotFoundError') {\n return {\n files: [],\n etag: '',\n };\n }\n throw error;\n }\n }\n\n const staticPart = this.getStaticPart(filepath);\n const matcher = new Minimatch(filepath);\n const treeUrl = trimEnd(url.replace(filepath, staticPart), `/`);\n const pathPrefix = staticPart ? `${staticPart}/` : '';\n const tree = await this.readTree(treeUrl, {\n etag: options?.etag,\n signal: options?.signal,\n filter: path => matcher.match(`${pathPrefix}${path}`),\n });\n\n const files = await tree.files();\n return {\n etag: tree.etag,\n files: files.map(file => ({\n url: this.integration.resolveUrl({\n url: `/${pathPrefix}${file.path}`,\n base: url,\n }),\n content: file.content,\n lastModifiedAt: file.lastModifiedAt,\n })),\n };\n }\n\n /**\n * This function splits the input globPattern string into segments using the path separator /. It then iterates over\n * the segments from the end of the array towards the beginning, checking if the concatenated string up to that\n * segment matches the original globPattern using the minimatch function. If a match is found, it continues iterating.\n * If no match is found, it returns the concatenated string up to the current segment, which is the static part of the\n * glob pattern.\n *\n * E.g. `catalog/foo/*.yaml` will return `catalog/foo`.\n *\n * @param globPattern - the glob pattern\n */\n private getStaticPart(globPattern: string) {\n const segments = globPattern.split('/');\n const globIndex = segments.findIndex(segment => segment.match(/[*?]/));\n return globIndex === -1\n ? globPattern\n : segments.slice(0, globIndex).join('/');\n }\n\n toString() {\n const { host, token } = this.integration.config;\n return `gitlab{host=${host},authed=${Boolean(token)}}`;\n }\n\n private async getGitlabFetchUrl(\n target: string,\n token?: string,\n ): Promise<string> {\n // If the target is for a job artifact then go down that path\n const targetUrl = new URL(target);\n if (targetUrl.pathname.includes('/-/jobs/artifacts/')) {\n return this.getGitlabArtifactFetchUrl(targetUrl, token).then(value =>\n value.toString(),\n );\n }\n // Default to the old behavior of assuming the url is for a file\n return getGitLabFileFetchUrl(target, this.integration.config, token);\n }\n\n // convert urls of the form:\n // https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path_to_file>?job=<job_name>\n // to urls of the form:\n // https://example.com/api/v4/projects/:id/jobs/artifacts/:ref_name/raw/*artifact_path?job=<job_name>\n private async getGitlabArtifactFetchUrl(\n target: URL,\n token?: string,\n ): Promise<URL> {\n if (!target.pathname.includes('/-/jobs/artifacts/')) {\n throw new Error('Unable to process url as an GitLab artifact');\n }\n try {\n const [namespaceAndProject, ref] =\n target.pathname.split('/-/jobs/artifacts/');\n const projectPath = new URL(target);\n projectPath.pathname = namespaceAndProject;\n const projectId = await this.resolveProjectToId(projectPath, token);\n const relativePath = getGitLabIntegrationRelativePath(\n this.integration.config,\n );\n const newUrl = new URL(target);\n newUrl.pathname = `${relativePath}/api/v4/projects/${projectId}/jobs/artifacts/${ref}`;\n return newUrl;\n } catch (e) {\n throw new Error(\n `Unable to translate GitLab artifact URL: ${target}, ${e}`,\n );\n }\n }\n\n private async resolveProjectToId(\n pathToProject: URL,\n token?: string,\n ): Promise<number> {\n let project = pathToProject.pathname;\n // Check relative path exist and remove it if so\n const relativePath = getGitLabIntegrationRelativePath(\n this.integration.config,\n );\n if (relativePath) {\n project = project.replace(relativePath, '');\n }\n // Trim an initial / if it exists\n project = project.replace(/^\\//, '');\n const result = await fetch(\n `${\n pathToProject.origin\n }${relativePath}/api/v4/projects/${encodeURIComponent(project)}`,\n getGitLabRequestOptions(this.integration.config, token),\n );\n const data = await result.json();\n if (!result.ok) {\n if (result.status === 401) {\n throw new Error(\n 'GitLab Error: 401 - Unauthorized. The access token used is either expired, or does not have permission to read the project',\n );\n }\n\n throw new Error(`Gitlab error: ${data.error}, ${data.error_description}`);\n }\n return Number(data.id);\n }\n}\n"],"names":["ScmIntegrations","fetch","getGitLabRequestOptions","NotModifiedError","ReadUrlResponseFactory","parseLastModified","NotFoundError","parseGitUrl","getGitLabIntegrationRelativePath","trimStart","Readable","assertError","Minimatch","trimEnd","getGitLabFileFetchUrl"],"mappings":";;;;;;;;;;;;;;;;;AAqDO,MAAM,eAAA,CAA4C;AAAA,EACvD,OAAO,OAAA,GAAyB,CAAC,EAAE,MAAA,EAAQ,qBAAoB,KAAM;AACnE,IAAA,MAAM,YAAA,GAAeA,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AACtD,IAAA,OAAO,YAAA,CAAa,MAAA,CAAO,IAAA,EAAK,CAAE,IAAI,CAAA,WAAA,KAAe;AACnD,MAAA,MAAM,MAAA,GAAS,IAAI,eAAA,CAAgB,WAAA,EAAa;AAAA,QAC9C;AAAA,OACD,CAAA;AACD,MAAA,MAAM,YAAY,CAAC,GAAA,KAAa,GAAA,CAAI,IAAA,KAAS,YAAY,MAAA,CAAO,IAAA;AAChE,MAAA,OAAO,EAAE,QAAQ,SAAA,EAAU;AAAA,IAC7B,CAAC,CAAA;AAAA,EACH,CAAA;AAAA,EAEiB,WAAA;AAAA,EACA,IAAA;AAAA,EAEjB,WAAA,CACE,aACA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YAAY,CAAA,iBAAA,EAAoB,kBAAA,CAAmB,OAAO,CAAC,CAAA,CAAA;AAAA,MAC9DC,mCAAA,CAAwB,IAAA,CAAK,WAAA,CAAY,MAAA,EAAQ,KAAK;AAAA,KACxD;AACA,IAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,IAAA,EAAK;AAC/B,IAAA,IAAI,CAAC,OAAO,EAAA,EAAI;AACd,MAAA,IAAI,MAAA,CAAO,WAAW,GAAA,EAAK;AACzB,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SACF;AAAA,MACF;AAEA,MAAA,MAAM,IAAI,MAAM,CAAA,cAAA,EAAiB,IAAA,CAAK,KAAK,CAAA,EAAA,EAAK,IAAA,CAAK,iBAAiB,CAAA,CAAE,CAAA;AAAA,IAC1E;AACA,IAAA,OAAO,MAAA,CAAO,KAAK,EAAE,CAAA;AAAA,EACvB;AACF;;;;"}
1
+ {"version":3,"file":"GitlabUrlReader.cjs.js","sources":["../../../../src/entrypoints/urlReader/lib/GitlabUrlReader.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n UrlReaderService,\n UrlReaderServiceReadTreeOptions,\n UrlReaderServiceReadTreeResponse,\n UrlReaderServiceReadUrlOptions,\n UrlReaderServiceReadUrlResponse,\n UrlReaderServiceSearchOptions,\n UrlReaderServiceSearchResponse,\n} from '@backstage/backend-plugin-api';\nimport {\n assertError,\n NotFoundError,\n NotModifiedError,\n} from '@backstage/errors';\nimport {\n getGitLabFileFetchUrl,\n getGitLabIntegrationRelativePath,\n getGitLabRequestOptions,\n GitLabIntegration,\n ScmIntegrations,\n} from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\nimport { trimEnd, trimStart } from 'lodash';\nimport { Minimatch } from 'minimatch';\nimport { ReadUrlResponseFactory } from './ReadUrlResponseFactory';\nimport { ReaderFactory, ReadTreeResponseFactory } from './types';\n\n/**\n * Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files on GitLab.\n *\n * @public\n */\nexport class GitlabUrlReader implements UrlReaderService {\n static factory: ReaderFactory = ({ config, treeResponseFactory }) => {\n const integrations = ScmIntegrations.fromConfig(config);\n return integrations.gitlab.list().map(integration => {\n const reader = new GitlabUrlReader(integration, {\n treeResponseFactory,\n });\n const predicate = (url: URL) => url.host === integration.config.host;\n return { reader, predicate };\n });\n };\n\n private readonly integration: GitLabIntegration;\n private readonly deps: { treeResponseFactory: ReadTreeResponseFactory };\n\n constructor(\n integration: GitLabIntegration,\n deps: { treeResponseFactory: ReadTreeResponseFactory },\n ) {\n this.integration = integration;\n this.deps = deps;\n }\n\n async read(url: string): Promise<Buffer> {\n const response = await this.readUrl(url);\n return response.buffer();\n }\n\n async readUrl(\n url: string,\n options?: UrlReaderServiceReadUrlOptions,\n ): Promise<UrlReaderServiceReadUrlResponse> {\n const { etag, lastModifiedAfter, signal, token } = options ?? {};\n const isArtifact = url.includes('/-/jobs/artifacts/');\n const builtUrl = await this.getGitlabFetchUrl(url, token);\n\n let response: Response;\n try {\n response = await this.integration.fetch(builtUrl, {\n headers: {\n ...getGitLabRequestOptions(this.integration.config, token).headers,\n ...(etag && !isArtifact && { 'If-None-Match': etag }),\n ...(lastModifiedAfter &&\n !isArtifact && {\n 'If-Modified-Since': lastModifiedAfter.toUTCString(),\n }),\n },\n // TODO(freben): The signal cast is there because pre-3.x versions of\n // node-fetch have a very slightly deviating AbortSignal type signature.\n // The difference does not affect us in practice however. The cast can be\n // removed after we support ESM for CLI dependencies and migrate to\n // version 3 of node-fetch.\n // https://github.com/backstage/backstage/issues/8242\n ...(signal && { signal: signal as any }),\n });\n } catch (e) {\n throw new Error(`Unable to read ${url}, ${e}`);\n }\n\n if (response.status === 304) {\n throw new NotModifiedError();\n }\n\n if (response.ok) {\n return ReadUrlResponseFactory.fromResponse(response);\n }\n\n const message = `${url} could not be read as ${builtUrl}, ${response.status} ${response.statusText}`;\n if (response.status === 404) {\n throw new NotFoundError(message);\n }\n throw new Error(message);\n }\n\n async readTree(\n url: string,\n options?: UrlReaderServiceReadTreeOptions,\n ): Promise<UrlReaderServiceReadTreeResponse> {\n const { etag, signal, token } = options ?? {};\n const { ref, full_name, filepath } = parseGitUrl(url);\n\n let repoFullName = full_name;\n\n const relativePath = getGitLabIntegrationRelativePath(\n this.integration.config,\n );\n\n // Considering self hosted gitlab with relative\n // assuming '/gitlab' is the relative path\n // from: /gitlab/repo/project\n // to: repo/project\n if (relativePath) {\n const rectifiedRelativePath = `${trimStart(relativePath, '/')}/`;\n repoFullName = full_name.replace(rectifiedRelativePath, '');\n }\n\n // Use GitLab API to get the default branch\n // encodeURIComponent is required for GitLab API\n // https://docs.gitlab.com/ee/api/README.html#namespaced-path-encoding\n const projectGitlabResponse = await this.integration.fetch(\n new URL(\n `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(\n repoFullName,\n )}`,\n ).toString(),\n getGitLabRequestOptions(this.integration.config, token),\n );\n if (!projectGitlabResponse.ok) {\n const msg = `Failed to read tree from ${url}, ${projectGitlabResponse.status} ${projectGitlabResponse.statusText}`;\n if (projectGitlabResponse.status === 404) {\n throw new NotFoundError(msg);\n }\n throw new Error(msg);\n }\n const projectGitlabResponseJson = await projectGitlabResponse.json();\n\n // ref is an empty string if no branch is set in provided url to readTree.\n const branch = ref || projectGitlabResponseJson.default_branch;\n\n // Fetch the latest commit that modifies the filepath in the provided or default branch\n // to compare against the provided sha.\n const commitsReqParams = new URLSearchParams();\n commitsReqParams.set('ref_name', branch);\n if (!!filepath) {\n commitsReqParams.set('path', filepath);\n }\n const commitsGitlabResponse = await this.integration.fetch(\n new URL(\n `${this.integration.config.apiBaseUrl}/projects/${encodeURIComponent(\n repoFullName,\n )}/repository/commits?${commitsReqParams.toString()}`,\n ).toString(),\n {\n ...getGitLabRequestOptions(this.integration.config, token),\n // TODO(freben): The signal cast is there because pre-3.x versions of\n // node-fetch have a very slightly deviating AbortSignal type signature.\n // The difference does not affect us in practice however. The cast can\n // be removed after we support ESM for CLI dependencies and migrate to\n // version 3 of node-fetch.\n // https://github.com/backstage/backstage/issues/8242\n ...(signal && { signal: signal as any }),\n },\n );\n if (!commitsGitlabResponse.ok) {\n const message = `Failed to read tree (branch) from ${url}, ${commitsGitlabResponse.status} ${commitsGitlabResponse.statusText}`;\n if (commitsGitlabResponse.status === 404) {\n throw new NotFoundError(message);\n }\n throw new Error(message);\n }\n\n const commitSha = (await commitsGitlabResponse.json())[0]?.id ?? '';\n if (etag && etag === commitSha) {\n throw new NotModifiedError();\n }\n\n const archiveReqParams = new URLSearchParams();\n archiveReqParams.set('sha', branch);\n if (!!filepath) {\n archiveReqParams.set('path', filepath);\n }\n // https://docs.gitlab.com/ee/api/repositories.html#get-file-archive\n const reqUrl = `${\n this.integration.config.apiBaseUrl\n }/projects/${encodeURIComponent(\n repoFullName,\n )}/repository/archive?${archiveReqParams.toString()}`;\n const archiveGitLabResponse = await this.integration.fetch(reqUrl, {\n ...getGitLabRequestOptions(this.integration.config, token),\n // TODO(freben): The signal cast is there because pre-3.x versions of\n // node-fetch have a very slightly deviating AbortSignal type signature.\n // The difference does not affect us in practice however. The cast can\n // be removed after we support ESM for CLI dependencies and migrate to\n // version 3 of node-fetch.\n // https://github.com/backstage/backstage/issues/8242\n ...(signal && { signal: signal as any }),\n });\n if (!archiveGitLabResponse.ok) {\n const message = `Failed to read tree (archive) from ${url}, ${reqUrl}, ${archiveGitLabResponse.status} ${archiveGitLabResponse.statusText}`;\n if (archiveGitLabResponse.status === 404) {\n throw new NotFoundError(message);\n }\n throw new Error(message);\n }\n\n return await this.deps.treeResponseFactory.fromTarArchive({\n response: archiveGitLabResponse,\n subpath: filepath,\n etag: commitSha,\n filter: options?.filter,\n });\n }\n\n async search(\n url: string,\n options?: UrlReaderServiceSearchOptions,\n ): Promise<UrlReaderServiceSearchResponse> {\n const { filepath } = parseGitUrl(url);\n\n // If it's a direct URL we use readUrl instead\n if (!filepath?.match(/[*?]/)) {\n try {\n const data = await this.readUrl(url, options);\n\n return {\n files: [\n {\n url: url,\n content: data.buffer,\n lastModifiedAt: data.lastModifiedAt,\n },\n ],\n etag: data.etag ?? '',\n };\n } catch (error) {\n assertError(error);\n if (error.name === 'NotFoundError') {\n return {\n files: [],\n etag: '',\n };\n }\n throw error;\n }\n }\n\n const staticPart = this.getStaticPart(filepath);\n const matcher = new Minimatch(filepath);\n const treeUrl = trimEnd(url.replace(filepath, staticPart), `/`);\n const pathPrefix = staticPart ? `${staticPart}/` : '';\n const tree = await this.readTree(treeUrl, {\n etag: options?.etag,\n signal: options?.signal,\n filter: path => matcher.match(`${pathPrefix}${path}`),\n });\n\n const files = await tree.files();\n return {\n etag: tree.etag,\n files: files.map(file => ({\n url: this.integration.resolveUrl({\n url: `/${pathPrefix}${file.path}`,\n base: url,\n }),\n content: file.content,\n lastModifiedAt: file.lastModifiedAt,\n })),\n };\n }\n\n /**\n * This function splits the input globPattern string into segments using the path separator /. It then iterates over\n * the segments from the end of the array towards the beginning, checking if the concatenated string up to that\n * segment matches the original globPattern using the minimatch function. If a match is found, it continues iterating.\n * If no match is found, it returns the concatenated string up to the current segment, which is the static part of the\n * glob pattern.\n *\n * E.g. `catalog/foo/*.yaml` will return `catalog/foo`.\n *\n * @param globPattern - the glob pattern\n */\n private getStaticPart(globPattern: string) {\n const segments = globPattern.split('/');\n const globIndex = segments.findIndex(segment => segment.match(/[*?]/));\n return globIndex === -1\n ? globPattern\n : segments.slice(0, globIndex).join('/');\n }\n\n toString() {\n const { host, token } = this.integration.config;\n return `gitlab{host=${host},authed=${Boolean(token)}}`;\n }\n\n private async getGitlabFetchUrl(\n target: string,\n token?: string,\n ): Promise<string> {\n // If the target is for a job artifact then go down that path\n const targetUrl = new URL(target);\n if (targetUrl.pathname.includes('/-/jobs/artifacts/')) {\n return this.getGitlabArtifactFetchUrl(targetUrl).then(value =>\n value.toString(),\n );\n }\n // Default to the optimized behavior - no API call needed for file URLs\n return getGitLabFileFetchUrl(target, this.integration.config, token);\n }\n\n // convert urls of the form:\n // https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path_to_file>?job=<job_name>\n // to urls of the form:\n // https://example.com/api/v4/projects/namespace%2Fproject/jobs/artifacts/:ref_name/raw/*artifact_path?job=<job_name>\n private getGitlabArtifactFetchUrl(target: URL): Promise<URL> {\n if (!target.pathname.includes('/-/jobs/artifacts/')) {\n throw new Error('Unable to process url as an GitLab artifact');\n }\n try {\n const [namespaceAndProject, ref] =\n target.pathname.split('/-/jobs/artifacts/');\n\n // Extract project path directly instead of making API call\n const relativePath = getGitLabIntegrationRelativePath(\n this.integration.config,\n );\n\n let projectPath = namespaceAndProject;\n // Check relative path exist and remove it\n if (relativePath) {\n projectPath = trimStart(projectPath, relativePath);\n }\n // Trim an initial / if it exists\n projectPath = projectPath.replace(/^\\//, '');\n\n const newUrl = new URL(target);\n newUrl.pathname = `${relativePath}/api/v4/projects/${encodeURIComponent(\n projectPath,\n )}/jobs/artifacts/${ref}`;\n return Promise.resolve(newUrl);\n } catch (e) {\n throw new Error(\n `Unable to translate GitLab artifact URL: ${target}, ${e}`,\n );\n }\n }\n}\n"],"names":["ScmIntegrations","getGitLabRequestOptions","NotModifiedError","ReadUrlResponseFactory","NotFoundError","parseGitUrl","getGitLabIntegrationRelativePath","trimStart","assertError","Minimatch","trimEnd","getGitLabFileFetchUrl"],"mappings":";;;;;;;;;;;;;AAgDO,MAAM,eAAA,CAA4C;AAAA,EACvD,OAAO,OAAA,GAAyB,CAAC,EAAE,MAAA,EAAQ,qBAAoB,KAAM;AACnE,IAAA,MAAM,YAAA,GAAeA,2BA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.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "0.15.2";
5
+ var version = "0.15.3-next.0";
6
6
  var packageinfo = {
7
7
  version: version};
8
8
 
@@ -276,7 +276,6 @@ declare class GitlabUrlReader implements UrlReaderService {
276
276
  toString(): string;
277
277
  private getGitlabFetchUrl;
278
278
  private getGitlabArtifactFetchUrl;
279
- private resolveProjectToId;
280
279
  }
281
280
 
282
281
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-defaults",
3
- "version": "0.15.2",
3
+ "version": "0.15.3-next.0",
4
4
  "description": "Backend defaults used by Backstage backend apps",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -217,19 +217,19 @@
217
217
  "@aws-sdk/types": "^3.347.0",
218
218
  "@azure/identity": "^4.0.0",
219
219
  "@azure/storage-blob": "^12.5.0",
220
- "@backstage/backend-app-api": "^1.5.0",
221
- "@backstage/backend-dev-utils": "^0.1.7",
222
- "@backstage/backend-plugin-api": "^1.7.0",
223
- "@backstage/cli-node": "^0.2.18",
224
- "@backstage/config": "^1.3.6",
225
- "@backstage/config-loader": "^1.10.8",
226
- "@backstage/errors": "^1.2.7",
227
- "@backstage/integration": "^1.20.0",
228
- "@backstage/integration-aws-node": "^0.1.20",
229
- "@backstage/plugin-auth-node": "^0.6.13",
230
- "@backstage/plugin-events-node": "^0.4.19",
231
- "@backstage/plugin-permission-node": "^0.10.10",
232
- "@backstage/types": "^1.2.2",
220
+ "@backstage/backend-app-api": "1.5.1-next.0",
221
+ "@backstage/backend-dev-utils": "0.1.7",
222
+ "@backstage/backend-plugin-api": "1.7.1-next.0",
223
+ "@backstage/cli-node": "0.2.19-next.0",
224
+ "@backstage/config": "1.3.6",
225
+ "@backstage/config-loader": "1.10.9-next.0",
226
+ "@backstage/errors": "1.2.7",
227
+ "@backstage/integration": "1.21.0-next.0",
228
+ "@backstage/integration-aws-node": "0.1.20",
229
+ "@backstage/plugin-auth-node": "0.6.14-next.0",
230
+ "@backstage/plugin-events-node": "0.4.20-next.0",
231
+ "@backstage/plugin-permission-node": "0.10.11-next.0",
232
+ "@backstage/types": "1.2.2",
233
233
  "@google-cloud/storage": "^7.0.0",
234
234
  "@keyv/memcache": "^2.0.1",
235
235
  "@keyv/redis": "^4.0.1",
@@ -260,7 +260,7 @@
260
260
  "lodash": "^4.17.21",
261
261
  "logform": "^2.3.2",
262
262
  "luxon": "^3.0.0",
263
- "minimatch": "^9.0.0",
263
+ "minimatch": "^10.2.1",
264
264
  "mysql2": "^3.0.0",
265
265
  "node-fetch": "^2.7.0",
266
266
  "node-forge": "^1.3.2",
@@ -284,9 +284,9 @@
284
284
  },
285
285
  "devDependencies": {
286
286
  "@aws-sdk/util-stream-node": "^3.350.0",
287
- "@backstage/backend-plugin-api": "^1.7.0",
288
- "@backstage/backend-test-utils": "^1.11.0",
289
- "@backstage/cli": "^0.35.4",
287
+ "@backstage/backend-plugin-api": "1.7.1-next.0",
288
+ "@backstage/backend-test-utils": "1.11.1-next.0",
289
+ "@backstage/cli": "0.35.5-next.0",
290
290
  "@google-cloud/cloud-sql-connector": "^1.4.0",
291
291
  "@types/archiver": "^7.0.0",
292
292
  "@types/base64-stream": "^1.0.2",