@backstage/backend-plugin-api 0.0.0-nightly-20230209023017 → 0.0.0-nightly-20230211022721

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,12 +1,13 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
- ## 0.0.0-nightly-20230209023017
3
+ ## 0.0.0-nightly-20230211022721
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - e716946103: **BREAKING**: Split out the hook for both lifecycle services so that the first parameter of `addShutdownHook` is the hook function, and the second is the options.
8
8
  - 0ff03319be: **BREAKING**: The plugin ID option passed to `createBackendPlugin` is now `pluginId`, rather than just `id`. This is to make it match `createBackendModule` more closely.
9
9
  - 71a5ec0f06: **BREAKING**: Switched out `LogMeta` type for `JsonObject`.
10
+ - 5febb216fe: **BREAKING**: The `CacheService` has been changed to remove the indirection of `getClient`, instead making the `CacheClient` methods directly available on the `CacheService`. In order to allow for the creation of clients with default options, there is now a new `.withOptions` method that must be implemented as part of the service interface.
10
11
  - b86efa2d04: Switch `ServiceFactory` to be an opaque type, keeping only the `service` field as public API, but also adding a type parameter for the service scope.
11
12
  - 610d65e143: Switched `BackendFeature` to be an opaque type.
12
13
 
@@ -21,10 +22,10 @@
21
22
  dependencies to plugins (should only ever be done for modules). This has no
22
23
  practical effect on code that was already well behaved.
23
24
  - Updated dependencies
24
- - @backstage/backend-tasks@0.0.0-nightly-20230209023017
25
+ - @backstage/backend-tasks@0.0.0-nightly-20230211022721
25
26
  - @backstage/config@1.0.6
26
27
  - @backstage/types@1.0.2
27
- - @backstage/plugin-auth-node@0.0.0-nightly-20230209023017
28
+ - @backstage/plugin-auth-node@0.0.0-nightly-20230211022721
28
29
  - @backstage/plugin-permission-common@0.7.3
29
30
 
30
31
  ## 0.4.0-next.2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "0.0.0-nightly-20230209023017",
3
+ "version": "0.0.0-nightly-20230211022721",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -93,35 +93,39 @@ export declare interface BackendPluginRegistrationPoints {
93
93
  }
94
94
 
95
95
  /**
96
- * A pre-configured, storage agnostic cache client suitable for use by
96
+ * A pre-configured, storage agnostic cache service suitable for use by
97
97
  * Backstage plugins.
98
98
  *
99
99
  * @public
100
100
  */
101
- export declare interface CacheClient {
101
+ export declare interface CacheService {
102
102
  /**
103
103
  * Reads data from a cache store for the given key. If no data was found,
104
104
  * returns undefined.
105
105
  */
106
- get(key: string): Promise<JsonValue | undefined>;
106
+ get<TValue extends JsonValue>(key: string): Promise<TValue | undefined>;
107
107
  /**
108
108
  * Writes the given data to a cache store, associated with the given key. An
109
109
  * optional TTL may also be provided, otherwise it defaults to the TTL that
110
110
  * was provided when the client was instantiated.
111
111
  */
112
- set(key: string, value: JsonValue, options?: CacheClientSetOptions): Promise<void>;
112
+ set(key: string, value: JsonValue, options?: CacheServiceSetOptions): Promise<void>;
113
113
  /**
114
114
  * Removes the given key from the cache store.
115
115
  */
116
116
  delete(key: string): Promise<void>;
117
+ /**
118
+ * Creates a new {@link CacheService} instance with the given options.
119
+ */
120
+ withOptions(options: CacheServiceOptions): CacheService;
117
121
  }
118
122
 
119
123
  /**
120
- * Options given when constructing a {@link CacheClient}.
124
+ * Options passed to {@link CacheService.withOptions}.
121
125
  *
122
126
  * @public
123
127
  */
124
- export declare type CacheClientOptions = {
128
+ export declare type CacheServiceOptions = {
125
129
  /**
126
130
  * An optional default TTL (in milliseconds) to be set when getting a client
127
131
  * instance. If not provided, data will persist indefinitely by default (or
@@ -131,11 +135,11 @@ export declare type CacheClientOptions = {
131
135
  };
132
136
 
133
137
  /**
134
- * Options passed to {@link CacheClient.set}.
138
+ * Options passed to {@link CacheService.set}.
135
139
  *
136
140
  * @public
137
141
  */
138
- export declare type CacheClientSetOptions = {
142
+ export declare type CacheServiceSetOptions = {
139
143
  /**
140
144
  * Optional TTL in milliseconds. Defaults to the TTL provided when the client
141
145
  * was set up (or no TTL if none are provided).
@@ -143,24 +147,6 @@ export declare type CacheClientSetOptions = {
143
147
  ttl?: number;
144
148
  };
145
149
 
146
- /**
147
- * Manages access to cache stores that plugins get.
148
- *
149
- * @public
150
- */
151
- export declare interface CacheService {
152
- /**
153
- * Provides backend plugins cache connections for themselves.
154
- *
155
- * @remarks
156
- *
157
- * The purpose of this method is to allow plugins to get isolated data stores
158
- * so that plugins are discouraged from cache-level integration and/or cache
159
- * key collisions.
160
- */
161
- getClient: (options?: CacheClientOptions) => CacheClient;
162
- }
163
-
164
150
  /**
165
151
  * @public
166
152
  */
@@ -93,35 +93,39 @@ export declare interface BackendPluginRegistrationPoints {
93
93
  }
94
94
 
95
95
  /**
96
- * A pre-configured, storage agnostic cache client suitable for use by
96
+ * A pre-configured, storage agnostic cache service suitable for use by
97
97
  * Backstage plugins.
98
98
  *
99
99
  * @public
100
100
  */
101
- export declare interface CacheClient {
101
+ export declare interface CacheService {
102
102
  /**
103
103
  * Reads data from a cache store for the given key. If no data was found,
104
104
  * returns undefined.
105
105
  */
106
- get(key: string): Promise<JsonValue | undefined>;
106
+ get<TValue extends JsonValue>(key: string): Promise<TValue | undefined>;
107
107
  /**
108
108
  * Writes the given data to a cache store, associated with the given key. An
109
109
  * optional TTL may also be provided, otherwise it defaults to the TTL that
110
110
  * was provided when the client was instantiated.
111
111
  */
112
- set(key: string, value: JsonValue, options?: CacheClientSetOptions): Promise<void>;
112
+ set(key: string, value: JsonValue, options?: CacheServiceSetOptions): Promise<void>;
113
113
  /**
114
114
  * Removes the given key from the cache store.
115
115
  */
116
116
  delete(key: string): Promise<void>;
117
+ /**
118
+ * Creates a new {@link CacheService} instance with the given options.
119
+ */
120
+ withOptions(options: CacheServiceOptions): CacheService;
117
121
  }
118
122
 
119
123
  /**
120
- * Options given when constructing a {@link CacheClient}.
124
+ * Options passed to {@link CacheService.withOptions}.
121
125
  *
122
126
  * @public
123
127
  */
124
- export declare type CacheClientOptions = {
128
+ export declare type CacheServiceOptions = {
125
129
  /**
126
130
  * An optional default TTL (in milliseconds) to be set when getting a client
127
131
  * instance. If not provided, data will persist indefinitely by default (or
@@ -131,11 +135,11 @@ export declare type CacheClientOptions = {
131
135
  };
132
136
 
133
137
  /**
134
- * Options passed to {@link CacheClient.set}.
138
+ * Options passed to {@link CacheService.set}.
135
139
  *
136
140
  * @public
137
141
  */
138
- export declare type CacheClientSetOptions = {
142
+ export declare type CacheServiceSetOptions = {
139
143
  /**
140
144
  * Optional TTL in milliseconds. Defaults to the TTL provided when the client
141
145
  * was set up (or no TTL if none are provided).
@@ -143,24 +147,6 @@ export declare type CacheClientSetOptions = {
143
147
  ttl?: number;
144
148
  };
145
149
 
146
- /**
147
- * Manages access to cache stores that plugins get.
148
- *
149
- * @public
150
- */
151
- export declare interface CacheService {
152
- /**
153
- * Provides backend plugins cache connections for themselves.
154
- *
155
- * @remarks
156
- *
157
- * The purpose of this method is to allow plugins to get isolated data stores
158
- * so that plugins are discouraged from cache-level integration and/or cache
159
- * key collisions.
160
- */
161
- getClient: (options?: CacheClientOptions) => CacheClient;
162
- }
163
-
164
150
  /**
165
151
  * @public
166
152
  */
package/dist/index.d.ts CHANGED
@@ -93,35 +93,39 @@ export declare interface BackendPluginRegistrationPoints {
93
93
  }
94
94
 
95
95
  /**
96
- * A pre-configured, storage agnostic cache client suitable for use by
96
+ * A pre-configured, storage agnostic cache service suitable for use by
97
97
  * Backstage plugins.
98
98
  *
99
99
  * @public
100
100
  */
101
- export declare interface CacheClient {
101
+ export declare interface CacheService {
102
102
  /**
103
103
  * Reads data from a cache store for the given key. If no data was found,
104
104
  * returns undefined.
105
105
  */
106
- get(key: string): Promise<JsonValue | undefined>;
106
+ get<TValue extends JsonValue>(key: string): Promise<TValue | undefined>;
107
107
  /**
108
108
  * Writes the given data to a cache store, associated with the given key. An
109
109
  * optional TTL may also be provided, otherwise it defaults to the TTL that
110
110
  * was provided when the client was instantiated.
111
111
  */
112
- set(key: string, value: JsonValue, options?: CacheClientSetOptions): Promise<void>;
112
+ set(key: string, value: JsonValue, options?: CacheServiceSetOptions): Promise<void>;
113
113
  /**
114
114
  * Removes the given key from the cache store.
115
115
  */
116
116
  delete(key: string): Promise<void>;
117
+ /**
118
+ * Creates a new {@link CacheService} instance with the given options.
119
+ */
120
+ withOptions(options: CacheServiceOptions): CacheService;
117
121
  }
118
122
 
119
123
  /**
120
- * Options given when constructing a {@link CacheClient}.
124
+ * Options passed to {@link CacheService.withOptions}.
121
125
  *
122
126
  * @public
123
127
  */
124
- export declare type CacheClientOptions = {
128
+ export declare type CacheServiceOptions = {
125
129
  /**
126
130
  * An optional default TTL (in milliseconds) to be set when getting a client
127
131
  * instance. If not provided, data will persist indefinitely by default (or
@@ -131,11 +135,11 @@ export declare type CacheClientOptions = {
131
135
  };
132
136
 
133
137
  /**
134
- * Options passed to {@link CacheClient.set}.
138
+ * Options passed to {@link CacheService.set}.
135
139
  *
136
140
  * @public
137
141
  */
138
- export declare type CacheClientSetOptions = {
142
+ export declare type CacheServiceSetOptions = {
139
143
  /**
140
144
  * Optional TTL in milliseconds. Defaults to the TTL provided when the client
141
145
  * was set up (or no TTL if none are provided).
@@ -143,24 +147,6 @@ export declare type CacheClientSetOptions = {
143
147
  ttl?: number;
144
148
  };
145
149
 
146
- /**
147
- * Manages access to cache stores that plugins get.
148
- *
149
- * @public
150
- */
151
- export declare interface CacheService {
152
- /**
153
- * Provides backend plugins cache connections for themselves.
154
- *
155
- * @remarks
156
- *
157
- * The purpose of this method is to allow plugins to get isolated data stores
158
- * so that plugins are discouraged from cache-level integration and/or cache
159
- * key collisions.
160
- */
161
- getClient: (options?: CacheClientOptions) => CacheClient;
162
- }
163
-
164
150
  /**
165
151
  * @public
166
152
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
3
  "description": "Core API used by Backstage backend plugins",
4
- "version": "0.0.0-nightly-20230209023017",
4
+ "version": "0.0.0-nightly-20230211022721",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "publishConfig": {
@@ -33,9 +33,9 @@
33
33
  "start": "backstage-cli package start"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/backend-tasks": "^0.0.0-nightly-20230209023017",
36
+ "@backstage/backend-tasks": "^0.0.0-nightly-20230211022721",
37
37
  "@backstage/config": "^1.0.6",
38
- "@backstage/plugin-auth-node": "^0.0.0-nightly-20230209023017",
38
+ "@backstage/plugin-auth-node": "^0.0.0-nightly-20230211022721",
39
39
  "@backstage/plugin-permission-common": "^0.7.3",
40
40
  "@backstage/types": "^1.0.2",
41
41
  "@types/express": "^4.17.6",
@@ -43,7 +43,7 @@
43
43
  "knex": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@backstage/cli": "^0.0.0-nightly-20230209023017"
46
+ "@backstage/cli": "^0.0.0-nightly-20230211022721"
47
47
  },
48
48
  "files": [
49
49
  "dist",