@backstage/backend-defaults 0.14.0-next.0 → 0.14.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 +95 -0
- package/config.d.ts +9 -20
- package/dist/alpha/entrypoints/rootSystemMetadata/lib/DefaultRootSystemMetadataService.cjs.js +33 -0
- package/dist/alpha/entrypoints/rootSystemMetadata/lib/DefaultRootSystemMetadataService.cjs.js.map +1 -0
- package/dist/alpha/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.cjs.js +24 -0
- package/dist/alpha/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.cjs.js.map +1 -0
- package/dist/alpha.cjs.js +2 -0
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/alpha.d.ts +8 -1
- package/dist/auditor.d.ts +2 -1
- package/dist/auth.d.ts +2 -1
- package/dist/cache.d.ts +6 -1
- package/dist/database.d.ts +2 -1
- package/dist/discovery.d.ts +2 -1
- package/dist/entrypoints/auth/plugin/keys/DatabasePluginKeySource.cjs.js.map +1 -1
- package/dist/entrypoints/cache/CacheManager.cjs.js +62 -23
- package/dist/entrypoints/cache/CacheManager.cjs.js.map +1 -1
- package/dist/entrypoints/cache/types.cjs.js.map +1 -1
- package/dist/entrypoints/discovery/HostDiscovery.cjs.js +2 -19
- package/dist/entrypoints/discovery/HostDiscovery.cjs.js.map +1 -1
- package/dist/entrypoints/discovery/parsing.cjs.js +26 -0
- package/dist/entrypoints/discovery/parsing.cjs.js.map +1 -0
- package/dist/entrypoints/httpAuth/httpAuthServiceFactory.cjs.js +2 -2
- package/dist/entrypoints/httpAuth/httpAuthServiceFactory.cjs.js.map +1 -1
- package/dist/entrypoints/rootHttpRouter/http/readHelmetOptions.cjs.js +14 -1
- package/dist/entrypoints/rootHttpRouter/http/readHelmetOptions.cjs.js.map +1 -1
- package/dist/entrypoints/rootLogger/WinstonLogger.cjs.js +8 -3
- package/dist/entrypoints/rootLogger/WinstonLogger.cjs.js.map +1 -1
- package/dist/entrypoints/scheduler/lib/TaskWorker.cjs.js +4 -2
- package/dist/entrypoints/scheduler/lib/TaskWorker.cjs.js.map +1 -1
- package/dist/entrypoints/urlReader/lib/BitbucketCloudUrlReader.cjs.js +9 -4
- package/dist/entrypoints/urlReader/lib/BitbucketCloudUrlReader.cjs.js.map +1 -1
- package/dist/httpAuth.d.ts +2 -1
- package/dist/httpRouter.d.ts +2 -1
- package/dist/package.json.cjs.js +1 -1
- package/dist/rootConfig.d.ts +2 -1
- package/dist/rootHttpRouter.d.ts +2 -1
- package/dist/rootLogger.d.ts +2 -1
- package/dist/urlReader.d.ts +2 -1
- package/package.json +21 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,100 @@
|
|
|
1
1
|
# @backstage/backend-defaults
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fa43826: Move `better-sqlite3` from dependencies to peer dependencies
|
|
8
|
+
- 2bc4e02: **BREAKING** The correct configuration options for Valkey are now being used.
|
|
9
|
+
|
|
10
|
+
These changes are **required** to `app-config.yaml`:
|
|
11
|
+
|
|
12
|
+
```diff
|
|
13
|
+
backend:
|
|
14
|
+
cache:
|
|
15
|
+
store: valkey
|
|
16
|
+
connection: ...
|
|
17
|
+
client:
|
|
18
|
+
- namespace: 'my-app'
|
|
19
|
+
- keyPrefixSeparator: ':'
|
|
20
|
+
+ keyPrefix: 'my-app:'
|
|
21
|
+
- clearBatchSize: 1000
|
|
22
|
+
- useUnlink: false
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
In comparison to Redis, Valkey requires the full `keyPrefix` including the separator to be specified instead of separate `namespace` and `keyPrefixSeparator` options. Also, Valkey does not support the `clearBatchSize` and `useUnlink` options.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 37fba1d: Added support for Bitbucket Cloud OAuth. This introduces an alternative authentication method using a workspace OAuth consumer, alongside App Passwords (deprecated) and API tokens. OAuth does not require a bot or service account and avoids token expiry issues.
|
|
30
|
+
|
|
31
|
+
**BREAKING CHANGES**
|
|
32
|
+
|
|
33
|
+
- **@backstage/integration** (`src/bitbucketCloud/core.ts`)
|
|
34
|
+
|
|
35
|
+
- `getBitbucketCloudRequestOptions` now returns a `Promise` and **must** be awaited.
|
|
36
|
+
|
|
37
|
+
- **@backstage/plugin-scaffolder-backend-module-bitbucket-cloud** (`src/actions/helpers.ts`)
|
|
38
|
+
- `getBitbucketClient` now returns a `Promise` and **must** be awaited.
|
|
39
|
+
- `getAuthorizationHeader` now returns a `Promise` and **must** be awaited.
|
|
40
|
+
|
|
41
|
+
**OAuth usage example**
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
integrations:
|
|
45
|
+
bitbucketCloud:
|
|
46
|
+
- clientId: client-id
|
|
47
|
+
clientSecret: client-secret
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- de96a60: chore(deps): bump `express` from 4.21.2 to 4.22.0
|
|
51
|
+
- aa79251: build(deps): bump `node-forge` from 1.3.1 to 1.3.2
|
|
52
|
+
- f96edff: Allow configuration of the `referrerPolicy`
|
|
53
|
+
- fb029b6: Updated luxon types
|
|
54
|
+
- d9759a1: **BREAKING ALPHA**: The old `instanceMetadataService` has been removed from alpha. Please switch over to using the stable `coreServices.rootInstanceMetadata` and related types instead, available from `@backstage/backend-plugin-api`.
|
|
55
|
+
- 847a330: Fix for `jose` types
|
|
56
|
+
- 25b560e: Internal change to support new versions of the `logform` library
|
|
57
|
+
- 2a0c4b0: Adds a new experimental `RootSystemMetadataService` for tracking the collection of Backstage instances that may be deployed at any one time. It currently offers a single API, `getInstalledPlugins` that returns a list of installed plugins based on config you have set up in `discovery.endpoints` as well as the plugins installed on the instance you're calling the API with. It does not handle wildcard values or fallback values. The intention is for this plugin to provide plugin authors with a simple interface to fetch a trustworthy list of all installed plugins.
|
|
58
|
+
- 3016a79: Updated dependency `@types/archiver` to `^7.0.0`.
|
|
59
|
+
- 42db6a6: Don't warn when parsing `storeOptions` for `memory` cache
|
|
60
|
+
- Updated dependencies
|
|
61
|
+
- @backstage/cli-node@0.2.16
|
|
62
|
+
- @backstage/integration@1.19.0
|
|
63
|
+
- @backstage/plugin-auth-node@0.6.10
|
|
64
|
+
- @backstage/plugin-events-node@0.4.18
|
|
65
|
+
- @backstage/plugin-permission-node@0.10.7
|
|
66
|
+
- @backstage/backend-app-api@1.4.0
|
|
67
|
+
- @backstage/backend-plugin-api@1.6.0
|
|
68
|
+
- @backstage/config-loader@1.10.7
|
|
69
|
+
- @backstage/backend-dev-utils@0.1.6
|
|
70
|
+
|
|
71
|
+
## 0.14.0-next.1
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- de96a60: chore(deps): bump `express` from 4.21.2 to 4.22.0
|
|
76
|
+
- aa79251: build(deps): bump `node-forge` from 1.3.1 to 1.3.2
|
|
77
|
+
- f96edff: Allow configuration of the `referrerPolicy`
|
|
78
|
+
- fb029b6: Updated luxon types
|
|
79
|
+
- 847a330: Fix for `jose` types
|
|
80
|
+
- 25b560e: Internal change to support new versions of the `logform` library
|
|
81
|
+
- 2a0c4b0: Adds a new experimental `RootSystemMetadataService` for tracking the collection of Backstage instances that may be deployed at any one time. It currently offers a single API, `getInstalledPlugins` that returns a list of installed plugins based on config you have set up in `discovery.endpoints` as well as the plugins installed on the instance you're calling the API with. It does not handle wildcard values or fallback values. The intention is for this plugin to provide plugin authors with a simple interface to fetch a trustworthy list of all installed plugins.
|
|
82
|
+
- 3016a79: Updated dependency `@types/archiver` to `^7.0.0`.
|
|
83
|
+
- Updated dependencies
|
|
84
|
+
- @backstage/plugin-auth-node@0.6.10-next.1
|
|
85
|
+
- @backstage/plugin-events-node@0.4.18-next.1
|
|
86
|
+
- @backstage/plugin-permission-node@0.10.7-next.1
|
|
87
|
+
- @backstage/integration@1.18.3-next.1
|
|
88
|
+
- @backstage/backend-plugin-api@1.6.0-next.1
|
|
89
|
+
- @backstage/config-loader@1.10.7-next.1
|
|
90
|
+
- @backstage/backend-dev-utils@0.1.6-next.0
|
|
91
|
+
- @backstage/backend-app-api@1.4.0-next.1
|
|
92
|
+
- @backstage/cli-node@0.2.16-next.1
|
|
93
|
+
- @backstage/config@1.3.6
|
|
94
|
+
- @backstage/errors@1.2.7
|
|
95
|
+
- @backstage/integration-aws-node@0.1.19
|
|
96
|
+
- @backstage/types@1.2.2
|
|
97
|
+
|
|
3
98
|
## 0.14.0-next.0
|
|
4
99
|
|
|
5
100
|
### Minor Changes
|
package/config.d.ts
CHANGED
|
@@ -710,27 +710,9 @@ export interface Config {
|
|
|
710
710
|
*/
|
|
711
711
|
client?: {
|
|
712
712
|
/**
|
|
713
|
-
* Namespace for
|
|
714
|
-
*/
|
|
715
|
-
namespace?: string;
|
|
716
|
-
/**
|
|
717
|
-
* Separator to use between namespace and key.
|
|
718
|
-
*/
|
|
719
|
-
keyPrefixSeparator?: string;
|
|
720
|
-
/**
|
|
721
|
-
* Number of keys to delete in a single batch.
|
|
722
|
-
*/
|
|
723
|
-
clearBatchSize?: number;
|
|
724
|
-
/**
|
|
725
|
-
* Enable Unlink instead of using Del for clearing keys. This is more performant but may not be supported by all Redis versions.
|
|
726
|
-
*/
|
|
727
|
-
useUnlink?: boolean;
|
|
728
|
-
/**
|
|
729
|
-
* Whether to allow clearing all keys when no namespace is set.
|
|
730
|
-
* If set to true and no namespace is set, iterate() will return all keys.
|
|
731
|
-
* Defaults to `false`.
|
|
713
|
+
* Namespace and separator used for prefixing keys.
|
|
732
714
|
*/
|
|
733
|
-
|
|
715
|
+
keyPrefix?: string;
|
|
734
716
|
};
|
|
735
717
|
/**
|
|
736
718
|
* An optional Valkey cluster (redis cluster under the hood) configuration.
|
|
@@ -993,6 +975,13 @@ export interface Config {
|
|
|
993
975
|
*/
|
|
994
976
|
csp?: { [policyId: string]: string[] | false };
|
|
995
977
|
|
|
978
|
+
/**
|
|
979
|
+
* Referrer Policy options
|
|
980
|
+
*/
|
|
981
|
+
referrer?: {
|
|
982
|
+
policy: string[];
|
|
983
|
+
};
|
|
984
|
+
|
|
996
985
|
/**
|
|
997
986
|
* Options for the health check service and endpoint.
|
|
998
987
|
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var parsing = require('../../../../entrypoints/discovery/parsing.cjs.js');
|
|
4
|
+
|
|
5
|
+
function getPlugins(config) {
|
|
6
|
+
const endpoints = parsing.getEndpoints(config);
|
|
7
|
+
return Array.from(new Set(endpoints.flatMap((endpoint) => endpoint.plugins)));
|
|
8
|
+
}
|
|
9
|
+
class DefaultRootSystemMetadataService {
|
|
10
|
+
#plugins;
|
|
11
|
+
#instanceMetadata;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
const { config } = options;
|
|
14
|
+
this.#plugins = getPlugins(config);
|
|
15
|
+
config.subscribe?.(() => {
|
|
16
|
+
this.#plugins = getPlugins(config);
|
|
17
|
+
});
|
|
18
|
+
this.#instanceMetadata = options.instanceMetadata;
|
|
19
|
+
}
|
|
20
|
+
static create(pluginEnv) {
|
|
21
|
+
return new DefaultRootSystemMetadataService(pluginEnv);
|
|
22
|
+
}
|
|
23
|
+
async getInstalledPlugins() {
|
|
24
|
+
const plugins = this.#plugins.map((pluginId) => ({ pluginId }));
|
|
25
|
+
for (const plugin of await this.#instanceMetadata.getInstalledPlugins()) {
|
|
26
|
+
plugins.push({ pluginId: plugin.pluginId });
|
|
27
|
+
}
|
|
28
|
+
return plugins;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.DefaultRootSystemMetadataService = DefaultRootSystemMetadataService;
|
|
33
|
+
//# sourceMappingURL=DefaultRootSystemMetadataService.cjs.js.map
|
package/dist/alpha/entrypoints/rootSystemMetadata/lib/DefaultRootSystemMetadataService.cjs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultRootSystemMetadataService.cjs.js","sources":["../../../../../src/alpha/entrypoints/rootSystemMetadata/lib/DefaultRootSystemMetadataService.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n LoggerService,\n RootConfigService,\n RootInstanceMetadataService,\n} from '@backstage/backend-plugin-api';\nimport {\n RootSystemMetadataService,\n RootSystemMetadataServicePluginInfo,\n} from '@backstage/backend-plugin-api/alpha';\nimport { getEndpoints } from '../../../../entrypoints/discovery/parsing';\nimport { Config } from '@backstage/config';\n\nfunction getPlugins(config: Config): string[] {\n const endpoints = getEndpoints(config);\n return Array.from(new Set(endpoints.flatMap(endpoint => endpoint.plugins)));\n}\n\n/**\n * @alpha\n */\nexport class DefaultRootSystemMetadataService\n implements RootSystemMetadataService\n{\n #plugins: string[];\n #instanceMetadata: RootInstanceMetadataService;\n constructor(options: {\n logger: LoggerService;\n config: RootConfigService;\n instanceMetadata: RootInstanceMetadataService;\n }) {\n const { config } = options;\n this.#plugins = getPlugins(config);\n config.subscribe?.(() => {\n this.#plugins = getPlugins(config);\n });\n this.#instanceMetadata = options.instanceMetadata;\n }\n\n public static create(pluginEnv: {\n logger: LoggerService;\n config: RootConfigService;\n instanceMetadata: RootInstanceMetadataService;\n }) {\n return new DefaultRootSystemMetadataService(pluginEnv);\n }\n\n public async getInstalledPlugins(): Promise<\n RootSystemMetadataServicePluginInfo[]\n > {\n const plugins = this.#plugins.map(pluginId => ({ pluginId }));\n\n for (const plugin of await this.#instanceMetadata.getInstalledPlugins()) {\n plugins.push({ pluginId: plugin.pluginId });\n }\n\n return plugins;\n }\n}\n"],"names":["getEndpoints"],"mappings":";;;;AA4BA,SAAS,WAAW,MAAA,EAA0B;AAC5C,EAAA,MAAM,SAAA,GAAYA,qBAAa,MAAM,CAAA;AACrC,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,IAAI,GAAA,CAAI,SAAA,CAAU,QAAQ,CAAA,QAAA,KAAY,QAAA,CAAS,OAAO,CAAC,CAAC,CAAA;AAC5E;AAKO,MAAM,gCAAA,CAEb;AAAA,EACE,QAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAY,OAAA,EAIT;AACD,IAAA,MAAM,EAAE,QAAO,GAAI,OAAA;AACnB,IAAA,IAAA,CAAK,QAAA,GAAW,WAAW,MAAM,CAAA;AACjC,IAAA,MAAA,CAAO,YAAY,MAAM;AACvB,MAAA,IAAA,CAAK,QAAA,GAAW,WAAW,MAAM,CAAA;AAAA,IACnC,CAAC,CAAA;AACD,IAAA,IAAA,CAAK,oBAAoB,OAAA,CAAQ,gBAAA;AAAA,EACnC;AAAA,EAEA,OAAc,OAAO,SAAA,EAIlB;AACD,IAAA,OAAO,IAAI,iCAAiC,SAAS,CAAA;AAAA,EACvD;AAAA,EAEA,MAAa,mBAAA,GAEX;AACA,IAAA,MAAM,UAAU,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,QAAA,MAAa,EAAE,UAAS,CAAE,CAAA;AAE5D,IAAA,KAAA,MAAW,MAAA,IAAU,MAAM,IAAA,CAAK,iBAAA,CAAkB,qBAAoB,EAAG;AACvE,MAAA,OAAA,CAAQ,IAAA,CAAK,EAAE,QAAA,EAAU,MAAA,CAAO,UAAU,CAAA;AAAA,IAC5C;AAEA,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var DefaultRootSystemMetadataService = require('./lib/DefaultRootSystemMetadataService.cjs.js');
|
|
5
|
+
var alpha = require('@backstage/backend-plugin-api/alpha');
|
|
6
|
+
|
|
7
|
+
const rootSystemMetadataServiceFactory = backendPluginApi.createServiceFactory({
|
|
8
|
+
service: alpha.rootSystemMetadataServiceRef,
|
|
9
|
+
deps: {
|
|
10
|
+
logger: backendPluginApi.coreServices.rootLogger,
|
|
11
|
+
config: backendPluginApi.coreServices.rootConfig,
|
|
12
|
+
instanceMetadata: backendPluginApi.coreServices.rootInstanceMetadata
|
|
13
|
+
},
|
|
14
|
+
async factory({ logger, config, instanceMetadata }) {
|
|
15
|
+
return DefaultRootSystemMetadataService.DefaultRootSystemMetadataService.create({
|
|
16
|
+
logger,
|
|
17
|
+
config,
|
|
18
|
+
instanceMetadata
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.rootSystemMetadataServiceFactory = rootSystemMetadataServiceFactory;
|
|
24
|
+
//# sourceMappingURL=rootSystemMetadataServiceFactory.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rootSystemMetadataServiceFactory.cjs.js","sources":["../../../../src/alpha/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { DefaultRootSystemMetadataService } from './lib/DefaultRootSystemMetadataService';\nimport { rootSystemMetadataServiceRef } from '@backstage/backend-plugin-api/alpha';\n\n/**\n * Metadata about an entire Backstage system, a collection of Backstage instances.\n *\n * @alpha\n */\nexport const rootSystemMetadataServiceFactory = createServiceFactory({\n service: rootSystemMetadataServiceRef,\n deps: {\n logger: coreServices.rootLogger,\n config: coreServices.rootConfig,\n instanceMetadata: coreServices.rootInstanceMetadata,\n },\n async factory({ logger, config, instanceMetadata }) {\n return DefaultRootSystemMetadataService.create({\n logger,\n config,\n instanceMetadata,\n });\n },\n});\n"],"names":["createServiceFactory","rootSystemMetadataServiceRef","coreServices","DefaultRootSystemMetadataService"],"mappings":";;;;;;AA4BO,MAAM,mCAAmCA,qCAAA,CAAqB;AAAA,EACnE,OAAA,EAASC,kCAAA;AAAA,EACT,IAAA,EAAM;AAAA,IACJ,QAAQC,6BAAA,CAAa,UAAA;AAAA,IACrB,QAAQA,6BAAA,CAAa,UAAA;AAAA,IACrB,kBAAkBA,6BAAA,CAAa;AAAA,GACjC;AAAA,EACA,MAAM,OAAA,CAAQ,EAAE,MAAA,EAAQ,MAAA,EAAQ,kBAAiB,EAAG;AAClD,IAAA,OAAOC,kEAAiC,MAAA,CAAO;AAAA,MAC7C,MAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
package/dist/alpha.cjs.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
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 rootSystemMetadataServiceFactory = require('./alpha/entrypoints/rootSystemMetadata/rootSystemMetadataServiceFactory.cjs.js');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
exports.actionsRegistryServiceFactory = actionsRegistryServiceFactory.actionsRegistryServiceFactory;
|
|
9
10
|
exports.actionsServiceFactory = actionsServiceFactory.actionsServiceFactory;
|
|
11
|
+
exports.rootSystemMetadataServiceFactory = rootSystemMetadataServiceFactory.rootSystemMetadataServiceFactory;
|
|
10
12
|
//# sourceMappingURL=alpha.cjs.js.map
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -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,4 +11,11 @@ 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
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Metadata about an entire Backstage system, a collection of Backstage instances.
|
|
16
|
+
*
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
declare const rootSystemMetadataServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api_alpha.RootSystemMetadataService, "root", "singleton">;
|
|
20
|
+
|
|
21
|
+
export { actionsRegistryServiceFactory, actionsServiceFactory, rootSystemMetadataServiceFactory };
|
package/dist/auditor.d.ts
CHANGED
|
@@ -165,4 +165,5 @@ declare class WinstonRootAuditorService {
|
|
|
165
165
|
}): AuditorService;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
export {
|
|
168
|
+
export { DefaultAuditorService, WinstonRootAuditorService, auditorServiceFactory };
|
|
169
|
+
export type { AuditorEvent, AuditorEventActorDetails, AuditorEventOptions, AuditorEventRequest, AuditorEventStatus, AuditorLogFunction, WinstonRootAuditorServiceOptions };
|
package/dist/auth.d.ts
CHANGED
|
@@ -89,4 +89,5 @@ declare function createExternalTokenHandler<TContext>(handler: ExternalTokenHand
|
|
|
89
89
|
*/
|
|
90
90
|
declare const externalTokenHandlersServiceRef: _backstage_backend_plugin_api.ServiceRef<ExternalTokenHandler<unknown>, "plugin", "multiton">;
|
|
91
91
|
|
|
92
|
-
export {
|
|
92
|
+
export { authServiceFactory, createExternalTokenHandler, externalTokenHandlersServiceRef, pluginTokenHandlerDecoratorServiceRef };
|
|
93
|
+
export type { ExternalTokenHandler, PluginTokenHandler };
|
package/dist/cache.d.ts
CHANGED
|
@@ -70,6 +70,10 @@ declare class CacheManager {
|
|
|
70
70
|
* Parse Redis-specific options from configuration.
|
|
71
71
|
*/
|
|
72
72
|
private static parseRedisOptions;
|
|
73
|
+
/**
|
|
74
|
+
* Parse Valkey-specific options from configuration.
|
|
75
|
+
*/
|
|
76
|
+
private static parseValkeyOptions;
|
|
73
77
|
/**
|
|
74
78
|
* Construct the full namespace based on the options and pluginId.
|
|
75
79
|
*
|
|
@@ -109,4 +113,5 @@ declare class CacheManager {
|
|
|
109
113
|
private createInfinispanClient;
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
export { CacheManager,
|
|
116
|
+
export { CacheManager, cacheServiceFactory };
|
|
117
|
+
export type { CacheManagerOptions };
|
package/dist/database.d.ts
CHANGED
package/dist/discovery.d.ts
CHANGED
|
@@ -127,4 +127,5 @@ declare class HostDiscovery implements DiscoveryService {
|
|
|
127
127
|
getExternalBaseUrl(pluginId: string): Promise<string>;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
export { HostDiscovery,
|
|
130
|
+
export { HostDiscovery, discoveryServiceFactory };
|
|
131
|
+
export type { HostDiscoveryEndpoint, HostDiscoveryOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabasePluginKeySource.cjs.js","sources":["../../../../../src/entrypoints/auth/plugin/keys/DatabasePluginKeySource.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseService, LoggerService } from '@backstage/backend-plugin-api';\nimport { HumanDuration, durationToMilliseconds } from '@backstage/types';\nimport { JWK, exportJWK, generateKeyPair } from 'jose';\nimport { v4 as uuid } from 'uuid';\nimport { DatabaseKeyStore } from './DatabaseKeyStore';\nimport { InternalKey, KeyPayload, KeyStore } from './types';\nimport { PluginKeySource } from './types';\n\nconst SECONDS_IN_MS = 1000;\n\n/**\n * The margin for how many times longer we make the public key available\n * compared to how long we use the private key to sign new tokens.\n */\nconst KEY_EXPIRATION_MARGIN_FACTOR = 3;\n\nexport class DatabasePluginKeySource implements PluginKeySource {\n private privateKeyPromise?: Promise<JWK>;\n private keyExpiry?: Date;\n private readonly keyStore: KeyStore;\n private readonly logger: LoggerService;\n private readonly keyDurationSeconds: number;\n private readonly algorithm: string;\n\n constructor(\n keyStore: KeyStore,\n logger: LoggerService,\n keyDurationSeconds: number,\n algorithm: string,\n ) {\n this.keyStore = keyStore;\n this.logger = logger;\n this.keyDurationSeconds = keyDurationSeconds;\n this.algorithm = algorithm;\n }\n\n public static async create(options: {\n logger: LoggerService;\n database: DatabaseService;\n keyDuration: HumanDuration;\n algorithm?: string;\n }): Promise<PluginKeySource> {\n const keyStore = await DatabaseKeyStore.create({\n database: options.database,\n logger: options.logger,\n });\n\n return new DatabasePluginKeySource(\n keyStore,\n options.logger,\n Math.round(durationToMilliseconds(options.keyDuration) / 1000),\n options.algorithm ?? 'ES256',\n );\n }\n\n async getPrivateSigningKey(): Promise<JWK> {\n // Make sure that we only generate one key at a time\n if (this.privateKeyPromise) {\n if (this.keyExpiry && this.keyExpiry.getTime() > Date.now()) {\n return this.privateKeyPromise;\n }\n this.logger.info(`Signing key has expired, generating new key`);\n delete this.privateKeyPromise;\n }\n\n this.keyExpiry = new Date(\n Date.now() + this.keyDurationSeconds * SECONDS_IN_MS,\n );\n\n const promise = (async () => {\n // This generates a new signing key to be used to sign tokens until the next key rotation\n const kid = uuid();\n const key = await generateKeyPair(this.algorithm);\n const publicKey = await exportJWK(key.publicKey);\n const privateKey = await exportJWK(key.privateKey);\n publicKey.kid = privateKey.kid = kid;\n publicKey.alg = privateKey.alg = this.algorithm;\n\n // We're not allowed to use the key until it has been successfully stored\n // TODO: some token verification implementations aggressively cache the list of keys, and\n // don't attempt to fetch new ones even if they encounter an unknown kid. Therefore we\n // may want to keep using the existing key for some period of time until we switch to\n // the new one. This also needs to be implemented cross-service though, meaning new services\n // that boot up need to be able to grab an existing key to use for signing.\n this.logger.info(`Created new signing key ${kid}`);\n\n await this.keyStore.addKey({\n id: kid,\n key: publicKey as InternalKey,\n expiresAt: new Date(\n Date.now() +\n this.keyDurationSeconds *\n SECONDS_IN_MS *\n KEY_EXPIRATION_MARGIN_FACTOR,\n ),\n });\n\n // At this point we are allowed to start using the new key\n return privateKey;\n })();\n\n this.privateKeyPromise = promise;\n\n try {\n // If we fail to generate a new key, we need to clear the state so that\n // the next caller will try to generate another key.\n await promise;\n } catch (error) {\n this.logger.error(`Failed to generate new signing key, ${error}`);\n delete this.keyExpiry;\n delete this.privateKeyPromise;\n }\n\n return promise;\n }\n\n listKeys(): Promise<{ keys: KeyPayload[] }> {\n return this.keyStore.listKeys();\n }\n}\n"],"names":["DatabaseKeyStore","durationToMilliseconds","uuid","generateKeyPair","exportJWK"],"mappings":";;;;;;;AAwBA,MAAM,aAAA,GAAgB,GAAA;AAMtB,MAAM,4BAAA,GAA+B,CAAA;AAE9B,MAAM,uBAAA,CAAmD;AAAA,EACtD,iBAAA;AAAA,EACA,SAAA;AAAA,EACS,QAAA;AAAA,EACA,MAAA;AAAA,EACA,kBAAA;AAAA,EACA,SAAA;AAAA,EAEjB,WAAA,CACE,QAAA,EACA,MAAA,EACA,kBAA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A,GAAY,MAAMC,cAAA,CAAU,GAAA,CAAI,SAAS,CAAA;AAC/C,MAAA,MAAM,UAAA,GAAa,MAAMA,cAAA,CAAU,GAAA,CAAI,UAAU,CAAA;AACjD,MAAA,SAAA,CAAU,GAAA,GAAM,WAAW,GAAA,GAAM,GAAA;AACjC,MAAA,SAAA,CAAU,GAAA,GAAM,UAAA,CAAW,GAAA,GAAM,IAAA,CAAK,SAAA;AAQtC,MAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,CAAA,wBAAA,EAA2B,GAAG,CAAA,CAAE,CAAA;AAEjD,MAAA,MAAM,IAAA,CAAK,SAAS,MAAA,CAAO;AAAA,QACzB,EAAA,EAAI,GAAA;AAAA,QACJ,GAAA,EAAK,SAAA;AAAA,QACL,WAAW,IAAI,IAAA;AAAA,UACb,IAAA,CAAK,GAAA,EAAI,GACP,IAAA,CAAK,qBACH,aAAA,GACA;AAAA;AACN,OACD,CAAA;AAGD,MAAA,OAAO,UAAA;AAAA,IACT,CAAA,GAAG;AAEH,IAAA,IAAA,CAAK,iBAAA,GAAoB,OAAA;AAEzB,IAAA,IAAI;AAGF,MAAA,MAAM,OAAA;AAAA,IACR,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA,CAAM,CAAA,oCAAA,EAAuC,KAAK,CAAA,CAAE,CAAA;AAChE,MAAA,OAAO,IAAA,CAAK,SAAA;AACZ,MAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,IACd;AAEA,IAAA,OAAO,OAAA;AAAA,EACT;AAAA,EAEA,QAAA,GAA4C;AAC1C,IAAA,OAAO,IAAA,CAAK,SAAS,QAAA,EAAS;AAAA,EAChC;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"DatabasePluginKeySource.cjs.js","sources":["../../../../../src/entrypoints/auth/plugin/keys/DatabasePluginKeySource.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseService, LoggerService } from '@backstage/backend-plugin-api';\nimport { HumanDuration, durationToMilliseconds } from '@backstage/types';\nimport { JWK, exportJWK, generateKeyPair } from 'jose';\nimport { v4 as uuid } from 'uuid';\nimport { DatabaseKeyStore } from './DatabaseKeyStore';\nimport { InternalKey, KeyPayload, KeyStore } from './types';\nimport { PluginKeySource } from './types';\n\nconst SECONDS_IN_MS = 1000;\n\n/**\n * The margin for how many times longer we make the public key available\n * compared to how long we use the private key to sign new tokens.\n */\nconst KEY_EXPIRATION_MARGIN_FACTOR = 3;\n\nexport class DatabasePluginKeySource implements PluginKeySource {\n private privateKeyPromise?: Promise<JWK>;\n private keyExpiry?: Date;\n private readonly keyStore: KeyStore;\n private readonly logger: LoggerService;\n private readonly keyDurationSeconds: number;\n private readonly algorithm: string;\n\n constructor(\n keyStore: KeyStore,\n logger: LoggerService,\n keyDurationSeconds: number,\n algorithm: string,\n ) {\n this.keyStore = keyStore;\n this.logger = logger;\n this.keyDurationSeconds = keyDurationSeconds;\n this.algorithm = algorithm;\n }\n\n public static async create(options: {\n logger: LoggerService;\n database: DatabaseService;\n keyDuration: HumanDuration;\n algorithm?: string;\n }): Promise<PluginKeySource> {\n const keyStore = await DatabaseKeyStore.create({\n database: options.database,\n logger: options.logger,\n });\n\n return new DatabasePluginKeySource(\n keyStore,\n options.logger,\n Math.round(durationToMilliseconds(options.keyDuration) / 1000),\n options.algorithm ?? 'ES256',\n );\n }\n\n async getPrivateSigningKey(): Promise<JWK> {\n // Make sure that we only generate one key at a time\n if (this.privateKeyPromise) {\n if (this.keyExpiry && this.keyExpiry.getTime() > Date.now()) {\n return this.privateKeyPromise;\n }\n this.logger.info(`Signing key has expired, generating new key`);\n delete this.privateKeyPromise;\n }\n\n this.keyExpiry = new Date(\n Date.now() + this.keyDurationSeconds * SECONDS_IN_MS,\n );\n\n const promise = (async () => {\n // This generates a new signing key to be used to sign tokens until the next key rotation\n const kid = uuid();\n const key = await generateKeyPair(this.algorithm);\n const publicKey = await exportJWK(key.publicKey);\n const privateKey = await exportJWK(key.privateKey);\n publicKey.kid = privateKey.kid = kid;\n publicKey.alg = privateKey.alg = this.algorithm;\n\n // We're not allowed to use the key until it has been successfully stored\n // TODO: some token verification implementations aggressively cache the list of keys, and\n // don't attempt to fetch new ones even if they encounter an unknown kid. Therefore we\n // may want to keep using the existing key for some period of time until we switch to\n // the new one. This also needs to be implemented cross-service though, meaning new services\n // that boot up need to be able to grab an existing key to use for signing.\n this.logger.info(`Created new signing key ${kid}`);\n\n await this.keyStore.addKey({\n id: kid,\n key: publicKey as unknown as InternalKey,\n expiresAt: new Date(\n Date.now() +\n this.keyDurationSeconds *\n SECONDS_IN_MS *\n KEY_EXPIRATION_MARGIN_FACTOR,\n ),\n });\n\n // At this point we are allowed to start using the new key\n return privateKey;\n })();\n\n this.privateKeyPromise = promise;\n\n try {\n // If we fail to generate a new key, we need to clear the state so that\n // the next caller will try to generate another key.\n await promise;\n } catch (error) {\n this.logger.error(`Failed to generate new signing key, ${error}`);\n delete this.keyExpiry;\n delete this.privateKeyPromise;\n }\n\n return promise;\n }\n\n listKeys(): Promise<{ keys: KeyPayload[] }> {\n return this.keyStore.listKeys();\n }\n}\n"],"names":["DatabaseKeyStore","durationToMilliseconds","uuid","generateKeyPair","exportJWK"],"mappings":";;;;;;;AAwBA,MAAM,aAAA,GAAgB,GAAA;AAMtB,MAAM,4BAAA,GAA+B,CAAA;AAE9B,MAAM,uBAAA,CAAmD;AAAA,EACtD,iBAAA;AAAA,EACA,SAAA;AAAA,EACS,QAAA;AAAA,EACA,MAAA;AAAA,EACA,kBAAA;AAAA,EACA,S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.${store}`;
|
|
83
|
-
if (!config.has(storeConfigPath)) {
|
|
83
|
+
if (store !== "memory" && !config.has(storeConfigPath)) {
|
|
84
84
|
logger?.warn(
|
|
85
85
|
`No configuration found for cache store '${store}' at '${storeConfigPath}'.`
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
config,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
88
|
+
switch (store) {
|
|
89
|
+
case "redis":
|
|
90
|
+
return CacheManager.parseRedisOptions(storeConfigPath, config, logger);
|
|
91
|
+
case "valkey":
|
|
92
|
+
return CacheManager.parseValkeyOptions(storeConfigPath, config, logger);
|
|
93
|
+
case "infinispan":
|
|
94
|
+
return InfinispanOptionsMapper.InfinispanOptionsMapper.parseInfinispanOptions(
|
|
95
|
+
storeConfigPath,
|
|
96
|
+
config,
|
|
97
|
+
logger
|
|
98
|
+
);
|
|
99
|
+
default:
|
|
100
|
+
return void 0;
|
|
102
101
|
}
|
|
103
|
-
return void 0;
|
|
104
102
|
}
|
|
105
103
|
/**
|
|
106
104
|
* Parse Redis-specific options from configuration.
|
|
107
105
|
*/
|
|
108
|
-
static parseRedisOptions(
|
|
106
|
+
static parseRedisOptions(storeConfigPath, config$1, logger) {
|
|
109
107
|
const redisOptions = {
|
|
110
|
-
type:
|
|
108
|
+
type: "redis"
|
|
111
109
|
};
|
|
112
110
|
const redisConfig = config$1.getOptionalConfig(storeConfigPath) ?? new config.ConfigReader({});
|
|
113
111
|
redisOptions.client = {
|
|
@@ -141,6 +139,39 @@ class CacheManager {
|
|
|
141
139
|
}
|
|
142
140
|
return redisOptions;
|
|
143
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Parse Valkey-specific options from configuration.
|
|
144
|
+
*/
|
|
145
|
+
static parseValkeyOptions(storeConfigPath, config$1, logger) {
|
|
146
|
+
const valkeyOptions = {
|
|
147
|
+
type: "valkey"
|
|
148
|
+
};
|
|
149
|
+
const valkeyConfig = config$1.getOptionalConfig(storeConfigPath) ?? new config.ConfigReader({});
|
|
150
|
+
valkeyOptions.client = {
|
|
151
|
+
keyPrefix: valkeyConfig.getOptionalString("client.keyPrefix")
|
|
152
|
+
};
|
|
153
|
+
if (valkeyConfig.has("cluster")) {
|
|
154
|
+
const clusterConfig = valkeyConfig.getConfig("cluster");
|
|
155
|
+
if (!clusterConfig.has("rootNodes")) {
|
|
156
|
+
logger?.warn(
|
|
157
|
+
`Valkey cluster config has no 'rootNodes' key, defaulting to non-clustered mode`
|
|
158
|
+
);
|
|
159
|
+
return valkeyOptions;
|
|
160
|
+
}
|
|
161
|
+
valkeyOptions.cluster = {
|
|
162
|
+
rootNodes: clusterConfig.get("rootNodes"),
|
|
163
|
+
defaults: clusterConfig.getOptional("defaults"),
|
|
164
|
+
minimizeConnections: clusterConfig.getOptionalBoolean(
|
|
165
|
+
"minimizeConnections"
|
|
166
|
+
),
|
|
167
|
+
useReplicas: clusterConfig.getOptionalBoolean("useReplicas"),
|
|
168
|
+
maxCommandRedirections: clusterConfig.getOptionalNumber(
|
|
169
|
+
"maxCommandRedirections"
|
|
170
|
+
)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return valkeyOptions;
|
|
174
|
+
}
|
|
144
175
|
/**
|
|
145
176
|
* Construct the full namespace based on the options and pluginId.
|
|
146
177
|
*
|
|
@@ -149,7 +180,17 @@ class CacheManager {
|
|
|
149
180
|
* @returns The constructed namespace string combining the configured namespace with pluginId
|
|
150
181
|
*/
|
|
151
182
|
static constructNamespace(pluginId, storeOptions) {
|
|
152
|
-
|
|
183
|
+
let prefix;
|
|
184
|
+
switch (storeOptions?.type) {
|
|
185
|
+
case "redis":
|
|
186
|
+
prefix = storeOptions?.client?.namespace ? `${storeOptions.client.namespace}${storeOptions.client.keyPrefixSeparator ?? ":"}` : "";
|
|
187
|
+
break;
|
|
188
|
+
case "valkey":
|
|
189
|
+
prefix = storeOptions.client?.keyPrefix ?? "";
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
prefix = "";
|
|
193
|
+
}
|
|
153
194
|
return `${prefix}${pluginId}`;
|
|
154
195
|
}
|
|
155
196
|
/** @internal */
|
|
@@ -219,7 +260,7 @@ class CacheManager {
|
|
|
219
260
|
}
|
|
220
261
|
createValkeyStoreFactory() {
|
|
221
262
|
const KeyvValkey = require("@keyv/valkey").default;
|
|
222
|
-
const { createCluster } = require("@keyv/
|
|
263
|
+
const { createCluster } = require("@keyv/redis");
|
|
223
264
|
const stores = {};
|
|
224
265
|
return (pluginId, defaultTtl) => {
|
|
225
266
|
if (this.storeOptions?.type !== "valkey") {
|
|
@@ -228,9 +269,7 @@ class CacheManager {
|
|
|
228
269
|
);
|
|
229
270
|
}
|
|
230
271
|
if (!stores[pluginId]) {
|
|
231
|
-
const valkeyOptions = this.storeOptions?.client
|
|
232
|
-
keyPrefixSeparator: ":"
|
|
233
|
-
};
|
|
272
|
+
const valkeyOptions = this.storeOptions?.client;
|
|
234
273
|
if (this.storeOptions?.cluster) {
|
|
235
274
|
const cluster = createCluster(this.storeOptions?.cluster);
|
|
236
275
|
stores[pluginId] = new KeyvValkey(cluster, valkeyOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheManager.cjs.js","sources":["../../../src/entrypoints/cache/CacheManager.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 {\n CacheService,\n CacheServiceOptions,\n LoggerService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport Keyv from 'keyv';\nimport { DefaultCacheClient } from './CacheClient';\nimport {\n CacheManagerOptions,\n ttlToMilliseconds,\n CacheStoreOptions,\n RedisCacheStoreOptions,\n InfinispanClientBehaviorOptions,\n InfinispanServerConfig,\n} from './types';\nimport { InfinispanOptionsMapper } from './providers/infinispan/InfinispanOptionsMapper';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { ConfigReader, readDurationFromConfig } from '@backstage/config';\nimport {\n InfinispanClientCacheInterface,\n InfinispanKeyvStore,\n} from './providers/infinispan/InfinispanKeyvStore';\n\ntype StoreFactory = (pluginId: string, defaultTtl: number | undefined) => Keyv;\n\n/**\n * Implements a Cache Manager which will automatically create new cache clients\n * for plugins when requested. All requested cache clients are created with the\n * connection details provided.\n *\n * @public\n */\nexport class CacheManager {\n /**\n * Keys represent supported `backend.cache.store` values, mapped to factories\n * that return Keyv instances appropriate to the store.\n */\n private readonly storeFactories = {\n redis: this.createRedisStoreFactory(),\n valkey: this.createValkeyStoreFactory(),\n memcache: this.createMemcacheStoreFactory(),\n memory: this.createMemoryStoreFactory(),\n infinispan: this.createInfinispanStoreFactory(),\n };\n\n private readonly logger?: LoggerService;\n private readonly store: keyof CacheManager['storeFactories'];\n private readonly connection: string;\n private readonly errorHandler: CacheManagerOptions['onError'];\n private readonly defaultTtl?: number;\n private readonly storeOptions?: CacheStoreOptions;\n\n /**\n * Creates a new {@link CacheManager} instance by reading from the `backend`\n * config section, specifically the `.cache` key.\n *\n * @param config - The loaded application configuration.\n * @param options - Optional configuration for the CacheManager.\n * @returns A new CacheManager instance.\n */\n static fromConfig(\n config: RootConfigService,\n options: CacheManagerOptions = {},\n ): CacheManager {\n // If no `backend.cache` config is provided, instantiate the CacheManager\n // with an in-memory cache client.\n const store = config.getOptionalString('backend.cache.store') || 'memory';\n const defaultTtlConfig = config.getOptional('backend.cache.defaultTtl');\n const connectionString =\n config.getOptionalString('backend.cache.connection') || '';\n const logger = options.logger?.child({\n type: 'cacheManager',\n });\n\n if (config.has('backend.cache.useRedisSets')) {\n logger?.warn(\n \"The 'backend.cache.useRedisSets' configuration key is deprecated and no longer has any effect. The underlying '@keyv/redis' and '@keyv/valkey' libraries no longer support redis sets.\",\n );\n }\n\n let defaultTtl: number | undefined;\n if (defaultTtlConfig !== undefined) {\n if (typeof defaultTtlConfig === 'number') {\n defaultTtl = defaultTtlConfig;\n } else {\n defaultTtl = durationToMilliseconds(\n readDurationFromConfig(config, { key: 'backend.cache.defaultTtl' }),\n );\n }\n }\n\n // Read store-specific options from config\n const storeOptions = CacheManager.parseStoreOptions(store, config, logger);\n\n return new CacheManager(\n store,\n connectionString,\n options.onError,\n logger,\n defaultTtl,\n storeOptions,\n );\n }\n\n /**\n * Parse store-specific options from configuration.\n *\n * @param store - The cache store type ('redis', 'valkey', 'memcache', 'infinispan', or 'memory')\n * @param config - The configuration service\n * @param logger - Optional logger for warnings\n * @returns The parsed store options\n */\n private static parseStoreOptions(\n store: string,\n config: RootConfigService,\n logger?: LoggerService,\n ): CacheStoreOptions | undefined {\n const storeConfigPath = `backend.cache.${store}`;\n\n if (!config.has(storeConfigPath)) {\n logger?.warn(\n `No configuration found for cache store '${store}' at '${storeConfigPath}'.`,\n );\n }\n\n if (store === 'redis' || store === 'valkey') {\n return CacheManager.parseRedisOptions(\n store,\n storeConfigPath,\n config,\n logger,\n );\n }\n\n if (store === 'infinispan') {\n return InfinispanOptionsMapper.parseInfinispanOptions(\n storeConfigPath,\n config,\n logger,\n );\n }\n\n return undefined;\n }\n\n /**\n * Parse Redis-specific options from configuration.\n */\n private static parseRedisOptions(\n store: string,\n storeConfigPath: string,\n config: RootConfigService,\n logger?: LoggerService,\n ): RedisCacheStoreOptions {\n const redisOptions: RedisCacheStoreOptions = {\n type: store as 'redis' | 'valkey',\n };\n\n const redisConfig =\n config.getOptionalConfig(storeConfigPath) ?? new ConfigReader({});\n\n redisOptions.client = {\n namespace: redisConfig.getOptionalString('client.namespace'),\n keyPrefixSeparator:\n redisConfig.getOptionalString('client.keyPrefixSeparator') || ':',\n clearBatchSize: redisConfig.getOptionalNumber('client.clearBatchSize'),\n useUnlink: redisConfig.getOptionalBoolean('client.useUnlink'),\n noNamespaceAffectsAll: redisConfig.getOptionalBoolean(\n 'client.noNamespaceAffectsAll',\n ),\n };\n\n if (redisConfig.has('cluster')) {\n const clusterConfig = redisConfig.getConfig('cluster');\n\n if (!clusterConfig.has('rootNodes')) {\n logger?.warn(\n `Redis cluster config has no 'rootNodes' key, defaulting to non-clustered mode`,\n );\n return redisOptions;\n }\n\n redisOptions.cluster = {\n rootNodes: clusterConfig.get('rootNodes'),\n defaults: clusterConfig.getOptional('defaults'),\n minimizeConnections: clusterConfig.getOptionalBoolean(\n 'minimizeConnections',\n ),\n useReplicas: clusterConfig.getOptionalBoolean('useReplicas'),\n maxCommandRedirections: clusterConfig.getOptionalNumber(\n 'maxCommandRedirections',\n ),\n };\n }\n\n return redisOptions;\n }\n\n /**\n * Construct the full namespace based on the options and pluginId.\n *\n * @param pluginId - The plugin ID to namespace\n * @param storeOptions - Optional cache store configuration options\n * @returns The constructed namespace string combining the configured namespace with pluginId\n */\n private static constructNamespace(\n pluginId: string,\n storeOptions: RedisCacheStoreOptions | undefined,\n ): string {\n const prefix = storeOptions?.client?.namespace\n ? `${storeOptions.client.namespace}${\n storeOptions.client.keyPrefixSeparator ?? ':'\n }`\n : '';\n\n return `${prefix}${pluginId}`;\n }\n\n /** @internal */\n constructor(\n store: string,\n connectionString: string,\n errorHandler: CacheManagerOptions['onError'],\n logger?: LoggerService,\n defaultTtl?: number,\n storeOptions?: CacheStoreOptions,\n ) {\n if (!this.storeFactories.hasOwnProperty(store)) {\n throw new Error(`Unknown cache store: ${store}`);\n }\n this.logger = logger;\n this.store = store as keyof CacheManager['storeFactories'];\n this.connection = connectionString;\n this.errorHandler = errorHandler;\n this.defaultTtl = defaultTtl;\n this.storeOptions = storeOptions;\n }\n\n /**\n * Generates a PluginCacheManager for consumption by plugins.\n *\n * @param pluginId - The plugin that the cache manager should be created for.\n * Plugin names should be unique.\n */\n forPlugin(pluginId: string): CacheService {\n const clientFactory = (options: CacheServiceOptions) => {\n const ttl = options.defaultTtl ?? this.defaultTtl;\n return this.getClientWithTtl(\n pluginId,\n ttl !== undefined ? ttlToMilliseconds(ttl) : undefined,\n );\n };\n\n return new DefaultCacheClient(clientFactory({}), clientFactory, {});\n }\n\n private getClientWithTtl(pluginId: string, ttl: number | undefined): Keyv {\n return this.storeFactories[this.store](pluginId, ttl);\n }\n\n private createRedisStoreFactory(): StoreFactory {\n const KeyvRedis = require('@keyv/redis').default;\n const { createCluster } = require('@keyv/redis');\n const stores: Record<string, typeof KeyvRedis> = {};\n\n return (pluginId, defaultTtl) => {\n if (this.storeOptions?.type !== 'redis') {\n throw new Error(\n `Internal error: Wrong config type passed to redis factory: ${this.storeOptions?.type}`,\n );\n }\n if (!stores[pluginId]) {\n const redisOptions = this.storeOptions?.client || {\n keyPrefixSeparator: ':',\n };\n if (this.storeOptions?.cluster) {\n // Create a Redis cluster\n const cluster = createCluster(this.storeOptions?.cluster);\n stores[pluginId] = new KeyvRedis(cluster, redisOptions);\n } else {\n // Create a regular Redis connection\n stores[pluginId] = new KeyvRedis(this.connection, redisOptions);\n }\n\n // Always provide an error handler to avoid stopping the process\n stores[pluginId].on('error', (err: Error) => {\n this.logger?.error('Failed to create redis cache client', err);\n this.errorHandler?.(err);\n });\n }\n return new Keyv({\n namespace: CacheManager.constructNamespace(pluginId, this.storeOptions),\n ttl: defaultTtl,\n store: stores[pluginId],\n emitErrors: false,\n useKeyPrefix: false,\n });\n };\n }\n\n private createValkeyStoreFactory(): StoreFactory {\n const KeyvValkey = require('@keyv/valkey').default;\n const { createCluster } = require('@keyv/valkey');\n const stores: Record<string, typeof KeyvValkey> = {};\n\n return (pluginId, defaultTtl) => {\n if (this.storeOptions?.type !== 'valkey') {\n throw new Error(\n `Internal error: Wrong config type passed to valkey factory: ${this.storeOptions?.type}`,\n );\n }\n if (!stores[pluginId]) {\n const valkeyOptions = this.storeOptions?.client || {\n keyPrefixSeparator: ':',\n };\n if (this.storeOptions?.cluster) {\n // Create a Valkey cluster (Redis cluster under the hood)\n const cluster = createCluster(this.storeOptions?.cluster);\n stores[pluginId] = new KeyvValkey(cluster, valkeyOptions);\n } else {\n // Create a regular Valkey connection\n stores[pluginId] = new KeyvValkey(this.connection, valkeyOptions);\n }\n\n // Always provide an error handler to avoid stopping the process\n stores[pluginId].on('error', (err: Error) => {\n this.logger?.error('Failed to create valkey cache client', err);\n this.errorHandler?.(err);\n });\n }\n return new Keyv({\n namespace: CacheManager.constructNamespace(pluginId, this.storeOptions),\n ttl: defaultTtl,\n store: stores[pluginId],\n emitErrors: false,\n useKeyPrefix: false,\n });\n };\n }\n\n private createMemcacheStoreFactory(): StoreFactory {\n const KeyvMemcache = require('@keyv/memcache').default;\n const stores: Record<string, typeof KeyvMemcache> = {};\n\n return (pluginId, defaultTtl) => {\n if (!stores[pluginId]) {\n stores[pluginId] = new KeyvMemcache(this.connection);\n // Always provide an error handler to avoid stopping the process\n stores[pluginId].on('error', (err: Error) => {\n this.logger?.error('Failed to create memcache cache client', err);\n this.errorHandler?.(err);\n });\n }\n return new Keyv({\n namespace: pluginId,\n ttl: defaultTtl,\n emitErrors: false,\n store: stores[pluginId],\n });\n };\n }\n\n private createMemoryStoreFactory(): StoreFactory {\n const store = new Map();\n return (pluginId, defaultTtl) =>\n new Keyv({\n namespace: pluginId,\n ttl: defaultTtl,\n emitErrors: false,\n store,\n });\n }\n\n private createInfinispanStoreFactory(): StoreFactory {\n const stores: Record<string, InfinispanKeyvStore> = {};\n\n return (pluginId, defaultTtl) => {\n if (this.storeOptions?.type !== 'infinispan') {\n throw new Error(\n `Internal error: Wrong config type passed to infinispan factory: ${this.storeOptions?.type}`,\n );\n }\n\n if (!stores[pluginId]) {\n // Use sync version for testing environments\n const isTest =\n process.env.NODE_ENV === 'test' || typeof jest !== 'undefined';\n\n // Create the client promise ONCE and reuse it\n const clientPromise: Promise<InfinispanClientCacheInterface> = isTest\n ? this.createInfinispanClientSync()\n : this.createInfinispanClientAsync();\n\n this.logger?.info(\n `Creating Infinispan cache client for plugin ${pluginId} isTest = ${isTest}`,\n );\n const storeInstance = new InfinispanKeyvStore({\n clientPromise,\n logger: this.logger!,\n });\n\n stores[pluginId] = storeInstance;\n\n // Always provide an error handler to avoid stopping the process\n storeInstance.on('error', (err: Error) => {\n this.logger?.error('Failed to create infinispan cache client', err);\n this.errorHandler?.(err);\n });\n }\n\n return new Keyv({\n namespace: pluginId,\n ttl: defaultTtl,\n store: stores[pluginId],\n emitErrors: false,\n });\n };\n }\n\n /**\n * Creates an Infinispan client using dynamic import (production use).\n * @returns Promise that resolves to an Infinispan client\n */\n private async createInfinispanClientAsync(): Promise<InfinispanClientCacheInterface> {\n return this.createInfinispanClient(false);\n }\n\n /**\n * Creates an Infinispan client using synchronous import (testing purposes).\n * @returns Promise that resolves to an Infinispan client\n */\n private createInfinispanClientSync(): Promise<InfinispanClientCacheInterface> {\n return this.createInfinispanClient(true);\n }\n\n /**\n * Creates an Infinispan client based on the provided configuration.\n * @param useSync - Whether to use synchronous import (for testing) or dynamic import\n * @returns Promise that resolves to an Infinispan client\n */\n private async createInfinispanClient(\n useSync: boolean = false,\n ): Promise<InfinispanClientCacheInterface> {\n try {\n this.logger?.info('Creating Infinispan client');\n\n if (this.storeOptions?.type === 'infinispan') {\n // Import infinispan based on the useSync parameter\n const infinispan = useSync\n ? require('infinispan')\n : await import('infinispan');\n\n const client = await infinispan.client(\n this.storeOptions.servers as InfinispanServerConfig[],\n this.storeOptions.options as InfinispanClientBehaviorOptions,\n );\n\n this.logger?.info('Infinispan client created successfully');\n return client;\n }\n throw new Error('Infinispan store options are not defined');\n } catch (error: any) {\n this.logger?.error('Failed to create Infinispan client', {\n error: error.message,\n });\n throw error;\n }\n }\n}\n"],"names":["config","durationToMilliseconds","readDurationFromConfig","Infin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AA;AAC1D,QAAA,OAAO,MAAA;AAAA,MACT;AACA,MAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA,IAC5D,SAAS,KAAA,EAAY;AACnB,MAAA,IAAA,CAAK,MAAA,EAAQ,MAAM,oCAAA,EAAsC;AAAA,QACvD,OAAO,KAAA,CAAM;AAAA,OACd,CAAA;AACD,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CacheManager.cjs.js","sources":["../../../src/entrypoints/cache/CacheManager.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 {\n CacheService,\n CacheServiceOptions,\n LoggerService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport Keyv from 'keyv';\nimport { DefaultCacheClient } from './CacheClient';\nimport {\n CacheManagerOptions,\n ttlToMilliseconds,\n CacheStoreOptions,\n RedisCacheStoreOptions,\n InfinispanClientBehaviorOptions,\n InfinispanServerConfig,\n ValkeyCacheStoreOptions,\n} from './types';\nimport { InfinispanOptionsMapper } from './providers/infinispan/InfinispanOptionsMapper';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { ConfigReader, readDurationFromConfig } from '@backstage/config';\nimport {\n InfinispanClientCacheInterface,\n InfinispanKeyvStore,\n} from './providers/infinispan/InfinispanKeyvStore';\n\ntype StoreFactory = (pluginId: string, defaultTtl: number | undefined) => Keyv;\n\n/**\n * Implements a Cache Manager which will automatically create new cache clients\n * for plugins when requested. All requested cache clients are created with the\n * connection details provided.\n *\n * @public\n */\nexport class CacheManager {\n /**\n * Keys represent supported `backend.cache.store` values, mapped to factories\n * that return Keyv instances appropriate to the store.\n */\n private readonly storeFactories = {\n redis: this.createRedisStoreFactory(),\n valkey: this.createValkeyStoreFactory(),\n memcache: this.createMemcacheStoreFactory(),\n memory: this.createMemoryStoreFactory(),\n infinispan: this.createInfinispanStoreFactory(),\n };\n\n private readonly logger?: LoggerService;\n private readonly store: keyof CacheManager['storeFactories'];\n private readonly connection: string;\n private readonly errorHandler: CacheManagerOptions['onError'];\n private readonly defaultTtl?: number;\n private readonly storeOptions?: CacheStoreOptions;\n\n /**\n * Creates a new {@link CacheManager} instance by reading from the `backend`\n * config section, specifically the `.cache` key.\n *\n * @param config - The loaded application configuration.\n * @param options - Optional configuration for the CacheManager.\n * @returns A new CacheManager instance.\n */\n static fromConfig(\n config: RootConfigService,\n options: CacheManagerOptions = {},\n ): CacheManager {\n // If no `backend.cache` config is provided, instantiate the CacheManager\n // with an in-memory cache client.\n const store = config.getOptionalString('backend.cache.store') || 'memory';\n const defaultTtlConfig = config.getOptional('backend.cache.defaultTtl');\n const connectionString =\n config.getOptionalString('backend.cache.connection') || '';\n const logger = options.logger?.child({\n type: 'cacheManager',\n });\n\n if (config.has('backend.cache.useRedisSets')) {\n logger?.warn(\n \"The 'backend.cache.useRedisSets' configuration key is deprecated and no longer has any effect. The underlying '@keyv/redis' and '@keyv/valkey' libraries no longer support redis sets.\",\n );\n }\n\n let defaultTtl: number | undefined;\n if (defaultTtlConfig !== undefined) {\n if (typeof defaultTtlConfig === 'number') {\n defaultTtl = defaultTtlConfig;\n } else {\n defaultTtl = durationToMilliseconds(\n readDurationFromConfig(config, { key: 'backend.cache.defaultTtl' }),\n );\n }\n }\n\n // Read store-specific options from config\n const storeOptions = CacheManager.parseStoreOptions(store, config, logger);\n\n return new CacheManager(\n store,\n connectionString,\n options.onError,\n logger,\n defaultTtl,\n storeOptions,\n );\n }\n\n /**\n * Parse store-specific options from configuration.\n *\n * @param store - The cache store type ('redis', 'valkey', 'memcache', 'infinispan', or 'memory')\n * @param config - The configuration service\n * @param logger - Optional logger for warnings\n * @returns The parsed store options\n */\n private static parseStoreOptions(\n store: string,\n config: RootConfigService,\n logger?: LoggerService,\n ): CacheStoreOptions | undefined {\n const storeConfigPath = `backend.cache.${store}`;\n\n if (store !== 'memory' && !config.has(storeConfigPath)) {\n logger?.warn(\n `No configuration found for cache store '${store}' at '${storeConfigPath}'.`,\n );\n }\n\n switch (store) {\n case 'redis':\n return CacheManager.parseRedisOptions(storeConfigPath, config, logger);\n case 'valkey':\n return CacheManager.parseValkeyOptions(storeConfigPath, config, logger);\n case 'infinispan':\n return InfinispanOptionsMapper.parseInfinispanOptions(\n storeConfigPath,\n config,\n logger,\n );\n default:\n return undefined;\n }\n }\n\n /**\n * Parse Redis-specific options from configuration.\n */\n private static parseRedisOptions(\n storeConfigPath: string,\n config: RootConfigService,\n logger?: LoggerService,\n ): RedisCacheStoreOptions {\n const redisOptions: RedisCacheStoreOptions = {\n type: 'redis',\n };\n\n const redisConfig =\n config.getOptionalConfig(storeConfigPath) ?? new ConfigReader({});\n\n redisOptions.client = {\n namespace: redisConfig.getOptionalString('client.namespace'),\n keyPrefixSeparator:\n redisConfig.getOptionalString('client.keyPrefixSeparator') || ':',\n clearBatchSize: redisConfig.getOptionalNumber('client.clearBatchSize'),\n useUnlink: redisConfig.getOptionalBoolean('client.useUnlink'),\n noNamespaceAffectsAll: redisConfig.getOptionalBoolean(\n 'client.noNamespaceAffectsAll',\n ),\n };\n\n if (redisConfig.has('cluster')) {\n const clusterConfig = redisConfig.getConfig('cluster');\n\n if (!clusterConfig.has('rootNodes')) {\n logger?.warn(\n `Redis cluster config has no 'rootNodes' key, defaulting to non-clustered mode`,\n );\n return redisOptions;\n }\n\n redisOptions.cluster = {\n rootNodes: clusterConfig.get('rootNodes'),\n defaults: clusterConfig.getOptional('defaults'),\n minimizeConnections: clusterConfig.getOptionalBoolean(\n 'minimizeConnections',\n ),\n useReplicas: clusterConfig.getOptionalBoolean('useReplicas'),\n maxCommandRedirections: clusterConfig.getOptionalNumber(\n 'maxCommandRedirections',\n ),\n };\n }\n\n return redisOptions;\n }\n\n /**\n * Parse Valkey-specific options from configuration.\n */\n private static parseValkeyOptions(\n storeConfigPath: string,\n config: RootConfigService,\n logger?: LoggerService,\n ): ValkeyCacheStoreOptions {\n const valkeyOptions: ValkeyCacheStoreOptions = {\n type: 'valkey',\n };\n\n const valkeyConfig =\n config.getOptionalConfig(storeConfigPath) ?? new ConfigReader({});\n\n valkeyOptions.client = {\n keyPrefix: valkeyConfig.getOptionalString('client.keyPrefix'),\n };\n\n if (valkeyConfig.has('cluster')) {\n const clusterConfig = valkeyConfig.getConfig('cluster');\n\n if (!clusterConfig.has('rootNodes')) {\n logger?.warn(\n `Valkey cluster config has no 'rootNodes' key, defaulting to non-clustered mode`,\n );\n return valkeyOptions;\n }\n\n valkeyOptions.cluster = {\n rootNodes: clusterConfig.get('rootNodes'),\n defaults: clusterConfig.getOptional('defaults'),\n minimizeConnections: clusterConfig.getOptionalBoolean(\n 'minimizeConnections',\n ),\n useReplicas: clusterConfig.getOptionalBoolean('useReplicas'),\n maxCommandRedirections: clusterConfig.getOptionalNumber(\n 'maxCommandRedirections',\n ),\n };\n }\n\n return valkeyOptions;\n }\n\n /**\n * Construct the full namespace based on the options and pluginId.\n *\n * @param pluginId - The plugin ID to namespace\n * @param storeOptions - Optional cache store configuration options\n * @returns The constructed namespace string combining the configured namespace with pluginId\n */\n private static constructNamespace(\n pluginId: string,\n storeOptions: RedisCacheStoreOptions | ValkeyCacheStoreOptions | undefined,\n ): string {\n let prefix: string;\n switch (storeOptions?.type) {\n case 'redis':\n prefix = storeOptions?.client?.namespace\n ? `${storeOptions.client.namespace}${\n storeOptions.client.keyPrefixSeparator ?? ':'\n }`\n : '';\n break;\n case 'valkey':\n prefix = storeOptions.client?.keyPrefix ?? '';\n break;\n default:\n prefix = '';\n }\n\n return `${prefix}${pluginId}`;\n }\n\n /** @internal */\n constructor(\n store: string,\n connectionString: string,\n errorHandler: CacheManagerOptions['onError'],\n logger?: LoggerService,\n defaultTtl?: number,\n storeOptions?: CacheStoreOptions,\n ) {\n if (!this.storeFactories.hasOwnProperty(store)) {\n throw new Error(`Unknown cache store: ${store}`);\n }\n this.logger = logger;\n this.store = store as keyof CacheManager['storeFactories'];\n this.connection = connectionString;\n this.errorHandler = errorHandler;\n this.defaultTtl = defaultTtl;\n this.storeOptions = storeOptions;\n }\n\n /**\n * Generates a PluginCacheManager for consumption by plugins.\n *\n * @param pluginId - The plugin that the cache manager should be created for.\n * Plugin names should be unique.\n */\n forPlugin(pluginId: string): CacheService {\n const clientFactory = (options: CacheServiceOptions) => {\n const ttl = options.defaultTtl ?? this.defaultTtl;\n return this.getClientWithTtl(\n pluginId,\n ttl !== undefined ? ttlToMilliseconds(ttl) : undefined,\n );\n };\n\n return new DefaultCacheClient(clientFactory({}), clientFactory, {});\n }\n\n private getClientWithTtl(pluginId: string, ttl: number | undefined): Keyv {\n return this.storeFactories[this.store](pluginId, ttl);\n }\n\n private createRedisStoreFactory(): StoreFactory {\n const KeyvRedis = require('@keyv/redis').default;\n const { createCluster } = require('@keyv/redis');\n const stores: Record<string, typeof KeyvRedis> = {};\n\n return (pluginId, defaultTtl) => {\n if (this.storeOptions?.type !== 'redis') {\n throw new Error(\n `Internal error: Wrong config type passed to redis factory: ${this.storeOptions?.type}`,\n );\n }\n if (!stores[pluginId]) {\n const redisOptions = this.storeOptions?.client || {\n keyPrefixSeparator: ':',\n };\n if (this.storeOptions?.cluster) {\n // Create a Redis cluster\n const cluster = createCluster(this.storeOptions?.cluster);\n stores[pluginId] = new KeyvRedis(cluster, redisOptions);\n } else {\n // Create a regular Redis connection\n stores[pluginId] = new KeyvRedis(this.connection, redisOptions);\n }\n\n // Always provide an error handler to avoid stopping the process\n stores[pluginId].on('error', (err: Error) => {\n this.logger?.error('Failed to create redis cache client', err);\n this.errorHandler?.(err);\n });\n }\n return new Keyv({\n namespace: CacheManager.constructNamespace(pluginId, this.storeOptions),\n ttl: defaultTtl,\n store: stores[pluginId],\n emitErrors: false,\n useKeyPrefix: false,\n });\n };\n }\n\n private createValkeyStoreFactory(): StoreFactory {\n const KeyvValkey = require('@keyv/valkey').default;\n // `@keyv/valkey` doesn't export a `createCluster` function, but is compatible with the one from `@keyv/redis`\n // See https://keyv.org/docs/storage-adapters/valkey\n const { createCluster } = require('@keyv/redis');\n const stores: Record<string, typeof KeyvValkey> = {};\n\n return (pluginId, defaultTtl) => {\n if (this.storeOptions?.type !== 'valkey') {\n throw new Error(\n `Internal error: Wrong config type passed to valkey factory: ${this.storeOptions?.type}`,\n );\n }\n if (!stores[pluginId]) {\n const valkeyOptions = this.storeOptions?.client;\n if (this.storeOptions?.cluster) {\n // Create a Valkey cluster (Redis cluster under the hood)\n const cluster = createCluster(this.storeOptions?.cluster);\n stores[pluginId] = new KeyvValkey(cluster, valkeyOptions);\n } else {\n // Create a regular Valkey connection\n stores[pluginId] = new KeyvValkey(this.connection, valkeyOptions);\n }\n\n // Always provide an error handler to avoid stopping the process\n stores[pluginId].on('error', (err: Error) => {\n this.logger?.error('Failed to create valkey cache client', err);\n this.errorHandler?.(err);\n });\n }\n return new Keyv({\n namespace: CacheManager.constructNamespace(pluginId, this.storeOptions),\n ttl: defaultTtl,\n store: stores[pluginId],\n emitErrors: false,\n useKeyPrefix: false,\n });\n };\n }\n\n private createMemcacheStoreFactory(): StoreFactory {\n const KeyvMemcache = require('@keyv/memcache').default;\n const stores: Record<string, typeof KeyvMemcache> = {};\n\n return (pluginId, defaultTtl) => {\n if (!stores[pluginId]) {\n stores[pluginId] = new KeyvMemcache(this.connection);\n // Always provide an error handler to avoid stopping the process\n stores[pluginId].on('error', (err: Error) => {\n this.logger?.error('Failed to create memcache cache client', err);\n this.errorHandler?.(err);\n });\n }\n return new Keyv({\n namespace: pluginId,\n ttl: defaultTtl,\n emitErrors: false,\n store: stores[pluginId],\n });\n };\n }\n\n private createMemoryStoreFactory(): StoreFactory {\n const store = new Map();\n return (pluginId, defaultTtl) =>\n new Keyv({\n namespace: pluginId,\n ttl: defaultTtl,\n emitErrors: false,\n store,\n });\n }\n\n private createInfinispanStoreFactory(): StoreFactory {\n const stores: Record<string, InfinispanKeyvStore> = {};\n\n return (pluginId, defaultTtl) => {\n if (this.storeOptions?.type !== 'infinispan') {\n throw new Error(\n `Internal error: Wrong config type passed to infinispan factory: ${this.storeOptions?.type}`,\n );\n }\n\n if (!stores[pluginId]) {\n // Use sync version for testing environments\n const isTest =\n process.env.NODE_ENV === 'test' || typeof jest !== 'undefined';\n\n // Create the client promise ONCE and reuse it\n const clientPromise: Promise<InfinispanClientCacheInterface> = isTest\n ? this.createInfinispanClientSync()\n : this.createInfinispanClientAsync();\n\n this.logger?.info(\n `Creating Infinispan cache client for plugin ${pluginId} isTest = ${isTest}`,\n );\n const storeInstance = new InfinispanKeyvStore({\n clientPromise,\n logger: this.logger!,\n });\n\n stores[pluginId] = storeInstance;\n\n // Always provide an error handler to avoid stopping the process\n storeInstance.on('error', (err: Error) => {\n this.logger?.error('Failed to create infinispan cache client', err);\n this.errorHandler?.(err);\n });\n }\n\n return new Keyv({\n namespace: pluginId,\n ttl: defaultTtl,\n store: stores[pluginId],\n emitErrors: false,\n });\n };\n }\n\n /**\n * Creates an Infinispan client using dynamic import (production use).\n * @returns Promise that resolves to an Infinispan client\n */\n private async createInfinispanClientAsync(): Promise<InfinispanClientCacheInterface> {\n return this.createInfinispanClient(false);\n }\n\n /**\n * Creates an Infinispan client using synchronous import (testing purposes).\n * @returns Promise that resolves to an Infinispan client\n */\n private createInfinispanClientSync(): Promise<InfinispanClientCacheInterface> {\n return this.createInfinispanClient(true);\n }\n\n /**\n * Creates an Infinispan client based on the provided configuration.\n * @param useSync - Whether to use synchronous import (for testing) or dynamic import\n * @returns Promise that resolves to an Infinispan client\n */\n private async createInfinispanClient(\n useSync: boolean = false,\n ): Promise<InfinispanClientCacheInterface> {\n try {\n this.logger?.info('Creating Infinispan client');\n\n if (this.storeOptions?.type === 'infinispan') {\n // Import infinispan based on the useSync parameter\n const infinispan = useSync\n ? require('infinispan')\n : await import('infinispan');\n\n const client = await infinispan.client(\n this.storeOptions.servers as InfinispanServerConfig[],\n this.storeOptions.options as InfinispanClientBehaviorOptions,\n );\n\n this.logger?.info('Infinispan client created successfully');\n return client;\n }\n throw new Error('Infinispan store options are not defined');\n } catch (error: any) {\n this.logger?.error('Failed to create Infinispan client', {\n error: error.message,\n });\n throw error;\n }\n }\n}\n"],"names":["config","durationToMilliseconds","readDurationFromConfig","InfinispanOptionsMapper","ConfigReader","ttlToMilliseconds","DefaultCacheClient","Keyv","InfinispanKeyvStore"],"mappings":";;;;;;;;;;;;;;AAkDO,MAAM,YAAA,CAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKP,cAAA,GAAiB;AAAA,IAChC,KAAA,EAAO,KAAK,uBAAA,EAAwB;AAAA,IACpC,MAAA,EAAQ,KAAK,wBAAA,EAAyB;AAAA,IACtC,QAAA,EAAU,KAAK,0BAAA,EAA2B;AAAA,IAC1C,MAAA,EAAQ,KAAK,wBAAA,EAAyB;AAAA,IACtC,UAAA,EAAY,KAAK,4BAAA;AAA6B,GAChD;AAAA,EAEiB,MAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUjB,OAAO,UAAA,CACLA,QAAA,EACA,OAAA,GAA+B,EAAC,EAClB;AAGd,IAAA,MAAM,KAAA,GAAQA,QAAA,CAAO,iBAAA,CAAkB,qBAAqB,CAAA,IAAK,QAAA;AACjE,IAAA,MAAM,gBAAA,GAAmBA,QAAA,CAAO,WAAA,CAAY,0BAA0B,CAAA;AACtE,IAAA,MAAM,gBAAA,GACJA,QAAA,CAAO,iBAAA,CAAkB,0BAA0B,CAAA,IAAK,EAAA;AAC1D,IAAA,MAAM,MAAA,GAA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