@backstage/backend-defaults 0.8.2 → 0.9.0-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,28 @@
1
1
  # @backstage/backend-defaults
2
2
 
3
+ ## 0.9.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 01edf6e: Allow pass through of redis client and cluster options to Cache core service
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @backstage/backend-app-api@1.2.1
13
+ - @backstage/plugin-auth-node@0.6.1
14
+ - @backstage/plugin-permission-node@0.9.0
15
+ - @backstage/backend-dev-utils@0.1.5
16
+ - @backstage/backend-plugin-api@1.2.1
17
+ - @backstage/cli-node@0.2.13
18
+ - @backstage/config@1.3.2
19
+ - @backstage/config-loader@1.10.0
20
+ - @backstage/errors@1.2.7
21
+ - @backstage/integration@1.16.2
22
+ - @backstage/integration-aws-node@0.1.15
23
+ - @backstage/types@1.2.1
24
+ - @backstage/plugin-events-node@0.4.9
25
+
3
26
  ## 0.8.2
4
27
 
5
28
  ### Patch Changes
package/config.d.ts CHANGED
@@ -559,6 +559,67 @@ export interface Config {
559
559
  connection: string;
560
560
  /** An optional default TTL (in milliseconds, if given as a number). */
561
561
  defaultTtl?: number | HumanDuration | string;
562
+ redis?: {
563
+ /**
564
+ * An optional Redis client configuration. These options are passed to the `@keyv/redis` client.
565
+ */
566
+ client?: {
567
+ /**
568
+ * Namespace for the current instance.
569
+ */
570
+ namespace?: string;
571
+ /**
572
+ * Separator to use between namespace and key.
573
+ */
574
+ keyPrefixSeparator?: string;
575
+ /**
576
+ * Number of keys to delete in a single batch.
577
+ */
578
+ clearBatchSize?: number;
579
+ /**
580
+ * Enable Unlink instead of using Del for clearing keys. This is more performant but may not be supported by all Redis versions.
581
+ */
582
+ useUnlink?: boolean;
583
+ /**
584
+ * Whether to allow clearing all keys when no namespace is set.
585
+ * If set to true and no namespace is set, iterate() will return all keys.
586
+ * Defaults to `false`.
587
+ */
588
+ noNamespaceAffectsAll?: boolean;
589
+ };
590
+ /**
591
+ * An optional Redis cluster configuration.
592
+ */
593
+ cluster?: {
594
+ /**
595
+ * Cluster configuration options to be passed to the `@keyv/redis` client (and node-redis under the hood)
596
+ * https://github.com/redis/node-redis/blob/master/docs/clustering.md
597
+ *
598
+ * @visibility secret
599
+ */
600
+ rootNodes: Array<object>;
601
+ /**
602
+ * Cluster node default configuration options to be passed to the `@keyv/redis` client (and node-redis under the hood)
603
+ * https://github.com/redis/node-redis/blob/master/docs/clustering.md
604
+ *
605
+ * @visibility secret
606
+ */
607
+ defaults?: Partial<object>;
608
+ /**
609
+ * When `true`, `.connect()` will only discover the cluster topology, without actually connecting to all the nodes.
610
+ * Useful for short-term or PubSub-only connections.
611
+ */
612
+ minimizeConnections?: boolean;
613
+ /**
614
+ * When `true`, distribute load by executing readonly commands (such as `GET`, `GEOSEARCH`, etc.) across all cluster nodes. When `false`, only use master nodes.
615
+ */
616
+ useReplicas?: boolean;
617
+ /**
618
+ * The maximum number of times a command will be redirected due to `MOVED` or `ASK` errors.
619
+ */
620
+ maxCommandRedirections?: number;
621
+ };
622
+ };
562
623
  }
563
624
  | {
564
625
  store: 'memcache';
package/dist/cache.d.ts CHANGED
@@ -47,6 +47,7 @@ declare class CacheManager {
47
47
  private readonly connection;
48
48
  private readonly errorHandler;
49
49
  private readonly defaultTtl?;
50
+ private readonly storeOptions?;
50
51
  /**
51
52
  * Creates a new {@link CacheManager} instance by reading from the `backend`
52
53
  * config section, specifically the `.cache` key.
@@ -54,6 +55,19 @@ declare class CacheManager {
54
55
  * @param config - The loaded application configuration.
55
56
  */
56
57
  static fromConfig(config: RootConfigService, options?: CacheManagerOptions): CacheManager;
58
+ /**
59
+ * Parse store-specific options from configuration.
60
+ *
61
+ * @param store - The cache store type ('redis', 'memcache', or 'memory')
62
+ * @param config - The configuration service
63
+ * @param logger - Optional logger for warnings
64
+ * @returns The parsed store options
65
+ */
66
+ private static parseStoreOptions;
67
+ /**
68
+ * Parse Redis-specific options from configuration.
69
+ */
70
+ private static parseRedisOptions;
57
71
  /**
58
72
  * Generates a PluginCacheManager for consumption by plugins.
59
73
  *
@@ -25,6 +25,7 @@ class CacheManager {
25
25
  connection;
26
26
  errorHandler;
27
27
  defaultTtl;
28
+ storeOptions;
28
29
  /**
29
30
  * Creates a new {@link CacheManager} instance by reading from the `backend`
30
31
  * config section, specifically the `.cache` key.
@@ -53,16 +54,70 @@ class CacheManager {
53
54
  );
54
55
  }
55
56
  }
57
+ const storeOptions = CacheManager.parseStoreOptions(store, config$1, logger);
56
58
  return new CacheManager(
57
59
  store,
58
60
  connectionString,
59
61
  options.onError,
60
62
  logger,
61
- defaultTtl
63
+ defaultTtl,
64
+ storeOptions
62
65
  );
63
66
  }
67
+ /**
68
+ * Parse store-specific options from configuration.
69
+ *
70
+ * @param store - The cache store type ('redis', 'memcache', or 'memory')
71
+ * @param config - The configuration service
72
+ * @param logger - Optional logger for warnings
73
+ * @returns The parsed store options
74
+ */
75
+ static parseStoreOptions(store, config, logger) {
76
+ const storeConfigPath = `backend.cache.${store}`;
77
+ if (store === "redis" && config.has(storeConfigPath)) {
78
+ return CacheManager.parseRedisOptions(storeConfigPath, config, logger);
79
+ }
80
+ return void 0;
81
+ }
82
+ /**
83
+ * Parse Redis-specific options from configuration.
84
+ */
85
+ static parseRedisOptions(storeConfigPath, config, logger) {
86
+ const redisOptions = {};
87
+ const redisConfig = config.getConfig(storeConfigPath);
88
+ redisOptions.client = {
89
+ namespace: redisConfig.getOptionalString("client.namespace"),
90
+ keyPrefixSeparator: redisConfig.getOptionalString("client.keyPrefixSeparator") || ":",
91
+ clearBatchSize: redisConfig.getOptionalNumber("client.clearBatchSize"),
92
+ useUnlink: redisConfig.getOptionalBoolean("client.useUnlink"),
93
+ noNamespaceAffectsAll: redisConfig.getOptionalBoolean(
94
+ "client.noNamespaceAffectsAll"
95
+ )
96
+ };
97
+ if (redisConfig.has("cluster")) {
98
+ const clusterConfig = redisConfig.getConfig("cluster");
99
+ if (!clusterConfig.has("rootNodes")) {
100
+ logger?.warn(
101
+ `Redis cluster config has no 'rootNodes' key, defaulting to non-clustered mode`
102
+ );
103
+ return redisOptions;
104
+ }
105
+ redisOptions.cluster = {
106
+ rootNodes: clusterConfig.get("rootNodes"),
107
+ defaults: clusterConfig.getOptional("defaults"),
108
+ minimizeConnections: clusterConfig.getOptionalBoolean(
109
+ "minimizeConnections"
110
+ ),
111
+ useReplicas: clusterConfig.getOptionalBoolean("useReplicas"),
112
+ maxCommandRedirections: clusterConfig.getOptionalNumber(
113
+ "maxCommandRedirections"
114
+ )
115
+ };
116
+ }
117
+ return redisOptions;
118
+ }
64
119
  /** @internal */
65
- constructor(store, connectionString, errorHandler, logger, defaultTtl) {
120
+ constructor(store, connectionString, errorHandler, logger, defaultTtl, storeOptions) {
66
121
  if (!this.storeFactories.hasOwnProperty(store)) {
67
122
  throw new Error(`Unknown cache store: ${store}`);
68
123
  }
@@ -71,6 +126,7 @@ class CacheManager {
71
126
  this.connection = connectionString;
72
127
  this.errorHandler = errorHandler;
73
128
  this.defaultTtl = defaultTtl;
129
+ this.storeOptions = storeOptions;
74
130
  }
75
131
  /**
76
132
  * Generates a PluginCacheManager for consumption by plugins.
@@ -93,12 +149,19 @@ class CacheManager {
93
149
  }
94
150
  createRedisStoreFactory() {
95
151
  const KeyvRedis = require("@keyv/redis").default;
152
+ const { createCluster } = require("@keyv/redis");
96
153
  const stores = {};
97
154
  return (pluginId, defaultTtl) => {
98
155
  if (!stores[pluginId]) {
99
- stores[pluginId] = new KeyvRedis(this.connection, {
156
+ const redisOptions = this.storeOptions?.client || {
100
157
  keyPrefixSeparator: ":"
101
- });
158
+ };
159
+ if (this.storeOptions?.cluster) {
160
+ const cluster = createCluster(this.storeOptions?.cluster);
161
+ stores[pluginId] = new KeyvRedis(cluster, redisOptions);
162
+ } else {
163
+ stores[pluginId] = new KeyvRedis(this.connection, redisOptions);
164
+ }
102
165
  stores[pluginId].on("error", (err) => {
103
166
  this.logger?.error("Failed to create redis cache client", err);
104
167
  this.errorHandler?.(err);
@@ -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 { CacheManagerOptions, ttlToMilliseconds } from './types';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { readDurationFromConfig } from '@backstage/config';\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 memcache: this.createMemcacheStoreFactory(),\n memory: this.createMemoryStoreFactory(),\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\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 */\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' library no longer supports 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 return new CacheManager(\n store,\n connectionString,\n options.onError,\n logger,\n defaultTtl,\n );\n }\n\n /** @internal */\n constructor(\n store: string,\n connectionString: string,\n errorHandler: CacheManagerOptions['onError'],\n logger?: LoggerService,\n defaultTtl?: number,\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 }\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 stores: Record<string, typeof KeyvRedis> = {};\n\n return (pluginId, defaultTtl) => {\n if (!stores[pluginId]) {\n stores[pluginId] = new KeyvRedis(this.connection, {\n keyPrefixSeparator: ':',\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: pluginId,\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"],"names":["config","durationToMilliseconds","readDurationFromConfig","ttlToMilliseconds","DefaultCacheClient","Keyv"],"mappings":";;;;;;;;;;;;AAqCO,MAAM,YAAa,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKP,cAAiB,GAAA;AAAA,IAChC,KAAA,EAAO,KAAK,uBAAwB,EAAA;AAAA,IACpC,QAAA,EAAU,KAAK,0BAA2B,EAAA;AAAA,IAC1C,MAAA,EAAQ,KAAK,wBAAyB;AAAA,GACxC;AAAA,EAEiB,MAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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MACP,SAAW,EAAA,QAAA;AAAA,MACX,GAAK,EAAA,UAAA;AAAA,MACL,UAAY,EAAA,KAAA;AAAA,MACZ;AAAA,KACD,CAAA;AAAA;AAEP;;;;"}
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} from './types';\nimport { durationToMilliseconds } from '@backstage/types';\nimport { readDurationFromConfig } from '@backstage/config';\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 memcache: this.createMemcacheStoreFactory(),\n memory: this.createMemoryStoreFactory(),\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 */\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' library no longer supports 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', 'memcache', 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 === 'redis' && config.has(storeConfigPath)) {\n return CacheManager.parseRedisOptions(storeConfigPath, config, logger);\n }\n\n return undefined;\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 const redisConfig = config.getConfig(storeConfigPath);\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 /** @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 (!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: pluginId,\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"],"names":["config","durationToMilliseconds","readDurationFromConfig","ttlToMilliseconds","DefaultCacheClient","Keyv"],"mappings":";;;;;;;;;;;;AA0CO,MAAM,YAAa,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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AA;AAAA,MACX,GAAK,EAAA,UAAA;AAAA,MACL,UAAY,EAAA,KAAA;AAAA,MACZ;AAAA,KACD,CAAA;AAAA;AAEP;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs.js","sources":["../../../src/entrypoints/cache/types.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport { HumanDuration, durationToMilliseconds } from '@backstage/types';\n\n/**\n * Options given when constructing a {@link CacheManager}.\n *\n * @public\n */\nexport type CacheManagerOptions = {\n /**\n * An optional logger for use by the PluginCacheManager.\n */\n logger?: LoggerService;\n\n /**\n * An optional handler for connection errors emitted from the underlying data\n * store.\n */\n onError?: (err: Error) => void;\n};\n\nexport function ttlToMilliseconds(ttl: number | HumanDuration): number {\n return typeof ttl === 'number' ? ttl : durationToMilliseconds(ttl);\n}\n"],"names":["durationToMilliseconds"],"mappings":";;;;AAqCO,SAAS,kBAAkB,GAAqC,EAAA;AACrE,EAAA,OAAO,OAAO,GAAA,KAAQ,QAAW,GAAA,GAAA,GAAMA,6BAAuB,GAAG,CAAA;AACnE;;;;"}
1
+ {"version":3,"file":"types.cjs.js","sources":["../../../src/entrypoints/cache/types.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport { HumanDuration, durationToMilliseconds } from '@backstage/types';\nimport { RedisClusterOptions, KeyvRedisOptions } from '@keyv/redis';\n\n/**\n * Options for Redis cache store.\n *\n * @public\n */\nexport type RedisCacheStoreOptions = {\n client?: KeyvRedisOptions;\n cluster?: RedisClusterOptions;\n};\n\n/**\n * Union type of all cache store options.\n *\n * @public\n */\nexport type CacheStoreOptions = RedisCacheStoreOptions;\n\n/**\n * Options given when constructing a {@link CacheManager}.\n *\n * @public\n */\nexport type CacheManagerOptions = {\n /**\n * An optional logger for use by the PluginCacheManager.\n */\n logger?: LoggerService;\n\n /**\n * An optional handler for connection errors emitted from the underlying data\n * store.\n */\n onError?: (err: Error) => void;\n};\n\nexport function ttlToMilliseconds(ttl: number | HumanDuration): number {\n return typeof ttl === 'number' ? ttl : durationToMilliseconds(ttl);\n}\n"],"names":["durationToMilliseconds"],"mappings":";;;;AAuDO,SAAS,kBAAkB,GAAqC,EAAA;AACrE,EAAA,OAAO,OAAO,GAAA,KAAQ,QAAW,GAAA,GAAA,GAAMA,6BAAuB,GAAG,CAAA;AACnE;;;;"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@backstage/backend-defaults";
6
- var version = "0.8.2";
6
+ var version = "0.9.0-next.0";
7
7
  var description = "Backend defaults used by Backstage backend apps";
8
8
  var backstage = {
9
9
  role: "node-library"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-defaults",
3
- "version": "0.8.2",
3
+ "version": "0.9.0-next.0",
4
4
  "description": "Backend defaults used by Backstage backend apps",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -208,19 +208,19 @@
208
208
  "@aws-sdk/credential-providers": "^3.350.0",
209
209
  "@aws-sdk/types": "^3.347.0",
210
210
  "@azure/storage-blob": "^12.5.0",
211
- "@backstage/backend-app-api": "^1.2.1",
212
- "@backstage/backend-dev-utils": "^0.1.5",
213
- "@backstage/backend-plugin-api": "^1.2.1",
214
- "@backstage/cli-node": "^0.2.13",
215
- "@backstage/config": "^1.3.2",
216
- "@backstage/config-loader": "^1.10.0",
217
- "@backstage/errors": "^1.2.7",
218
- "@backstage/integration": "^1.16.2",
219
- "@backstage/integration-aws-node": "^0.1.15",
220
- "@backstage/plugin-auth-node": "^0.6.1",
221
- "@backstage/plugin-events-node": "^0.4.9",
222
- "@backstage/plugin-permission-node": "^0.9.0",
223
- "@backstage/types": "^1.2.1",
211
+ "@backstage/backend-app-api": "1.2.1",
212
+ "@backstage/backend-dev-utils": "0.1.5",
213
+ "@backstage/backend-plugin-api": "1.2.1",
214
+ "@backstage/cli-node": "0.2.13",
215
+ "@backstage/config": "1.3.2",
216
+ "@backstage/config-loader": "1.10.0",
217
+ "@backstage/errors": "1.2.7",
218
+ "@backstage/integration": "1.16.2",
219
+ "@backstage/integration-aws-node": "0.1.15",
220
+ "@backstage/plugin-auth-node": "0.6.1",
221
+ "@backstage/plugin-events-node": "0.4.9",
222
+ "@backstage/plugin-permission-node": "0.9.0",
223
+ "@backstage/types": "1.2.1",
224
224
  "@google-cloud/storage": "^7.0.0",
225
225
  "@keyv/memcache": "^2.0.1",
226
226
  "@keyv/redis": "^4.0.1",
@@ -271,9 +271,9 @@
271
271
  },
272
272
  "devDependencies": {
273
273
  "@aws-sdk/util-stream-node": "^3.350.0",
274
- "@backstage/backend-plugin-api": "^1.2.1",
275
- "@backstage/backend-test-utils": "^1.3.1",
276
- "@backstage/cli": "^0.31.0",
274
+ "@backstage/backend-plugin-api": "1.2.1",
275
+ "@backstage/backend-test-utils": "1.3.2-next.0",
276
+ "@backstage/cli": "0.32.0-next.0",
277
277
  "@google-cloud/cloud-sql-connector": "^1.4.0",
278
278
  "@types/archiver": "^6.0.0",
279
279
  "@types/base64-stream": "^1.0.2",