@backstage/plugin-user-settings-backend 0.2.31-next.0 → 0.3.0-next.2

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,37 @@
1
1
  # @backstage/plugin-user-settings-backend
2
2
 
3
+ ## 0.3.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-defaults@0.8.2-next.2
9
+ - @backstage/backend-plugin-api@1.2.1-next.1
10
+ - @backstage/errors@1.2.7
11
+ - @backstage/types@1.2.1
12
+ - @backstage/plugin-auth-node@0.6.1-next.1
13
+ - @backstage/plugin-signals-node@0.1.18-next.2
14
+ - @backstage/plugin-user-settings-common@0.0.1
15
+
16
+ ## 0.3.0-next.1
17
+
18
+ ### Minor Changes
19
+
20
+ - e202017: **BREAKING**: Removed support for the old backend system.
21
+
22
+ As part of this change the plugin export from `/alpha` as been removed. If you are currently importing `@backstage/plugin-user-settings-backend/alpha`, please update your import to `@backstage/plugin-user-settings-backend`.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies
27
+ - @backstage/plugin-auth-node@0.6.1-next.1
28
+ - @backstage/backend-defaults@0.8.2-next.1
29
+ - @backstage/backend-plugin-api@1.2.1-next.1
30
+ - @backstage/errors@1.2.7
31
+ - @backstage/types@1.2.1
32
+ - @backstage/plugin-signals-node@0.1.18-next.1
33
+ - @backstage/plugin-user-settings-common@0.0.1
34
+
3
35
  ## 0.2.31-next.0
4
36
 
5
37
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var plugin = require('./plugin.cjs.js');
6
- var deprecated = require('./deprecated.cjs.js');
7
6
 
8
7
 
9
8
 
10
9
  exports.default = plugin.default;
11
- exports.createRouter = deprecated.createRouter;
12
10
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { DatabaseService } from '@backstage/backend-plugin-api';
3
- import express from 'express';
4
- import { SignalsService } from '@backstage/plugin-signals-node';
5
- import { IdentityApi } from '@backstage/plugin-auth-node';
6
2
 
7
3
  /**
8
4
  * The user settings backend plugin.
@@ -11,24 +7,4 @@ import { IdentityApi } from '@backstage/plugin-auth-node';
11
7
  */
12
8
  declare const _default: _backstage_backend_plugin_api.BackendFeature;
13
9
 
14
- /**
15
- * Type for the options passed to the "createRouter" function.
16
- *
17
- * @public
18
- * @deprecated This type is only exported for legacy reasons and will be removed in the future.
19
- */
20
- type RouterOptions = {
21
- database: DatabaseService;
22
- identity: IdentityApi;
23
- signals?: SignalsService;
24
- };
25
- /**
26
- * Create the user settings backend routes.
27
- *
28
- * @public
29
- * @deprecated This function is only exported for legacy reasons and will be removed in the future.
30
- * Please {@link https://backstage.io/docs/backend-system/building-backends/migrating | migrate } to use the new backend system and follow these {@link https://github.com/backstage/backstage/tree/master/plugins/user-settings-backend#new-backend | instructions } to install the user settings backend plugin.
31
- */
32
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
33
-
34
- export { type RouterOptions, createRouter, _default as default };
10
+ export { _default as default };
@@ -7,7 +7,7 @@ var router = require('./service/router.cjs.js');
7
7
  var pluginSignalsNode = require('@backstage/plugin-signals-node');
8
8
  var DatabaseUserSettingsStore = require('./database/DatabaseUserSettingsStore.cjs.js');
9
9
 
10
- var feature = backendPluginApi.createBackendPlugin({
10
+ var plugin = backendPluginApi.createBackendPlugin({
11
11
  pluginId: "user-settings",
12
12
  register(env) {
13
13
  env.registerInit({
@@ -22,12 +22,12 @@ var feature = backendPluginApi.createBackendPlugin({
22
22
  database
23
23
  });
24
24
  httpRouter.use(
25
- await router.createRouterInternal({ userSettingsStore, httpAuth, signals })
25
+ await router.createRouter({ userSettingsStore, httpAuth, signals })
26
26
  );
27
27
  }
28
28
  });
29
29
  }
30
30
  });
31
31
 
32
- exports.default = feature;
32
+ exports.default = plugin;
33
33
  //# sourceMappingURL=plugin.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 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 createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouterInternal } from './service/router';\nimport { signalsServiceRef } from '@backstage/plugin-signals-node';\nimport { DatabaseUserSettingsStore } from './database/DatabaseUserSettingsStore';\n\n/**\n * The user settings backend plugin.\n *\n * @public\n */\nexport default createBackendPlugin({\n pluginId: 'user-settings',\n register(env) {\n env.registerInit({\n deps: {\n database: coreServices.database,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n signals: signalsServiceRef,\n },\n async init({ database, httpAuth, httpRouter, signals }) {\n const userSettingsStore = await DatabaseUserSettingsStore.create({\n database,\n });\n httpRouter.use(\n await createRouterInternal({ userSettingsStore, httpAuth, signals }),\n );\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","signalsServiceRef","DatabaseUserSettingsStore","createRouterInternal"],"mappings":";;;;;;;;;AA6BA,cAAeA,oCAAoB,CAAA;AAAA,EACjC,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,UAAUC,6BAAa,CAAA,QAAA;AAAA,QACvB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,YAAYA,6BAAa,CAAA,UAAA;AAAA,QACzB,OAAS,EAAAC;AAAA,OACX;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,UAAU,QAAU,EAAA,UAAA,EAAY,SAAW,EAAA;AACtD,QAAM,MAAA,iBAAA,GAAoB,MAAMC,mDAAA,CAA0B,MAAO,CAAA;AAAA,UAC/D;AAAA,SACD,CAAA;AACD,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAMC,2BAAqB,CAAA,EAAE,iBAAmB,EAAA,QAAA,EAAU,SAAS;AAAA,SACrE;AAAA;AACF,KACD,CAAA;AAAA;AAEL,CAAC,CAAA;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 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 createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\nimport { signalsServiceRef } from '@backstage/plugin-signals-node';\nimport { DatabaseUserSettingsStore } from './database/DatabaseUserSettingsStore';\n\n/**\n * The user settings backend plugin.\n *\n * @public\n */\nexport default createBackendPlugin({\n pluginId: 'user-settings',\n register(env) {\n env.registerInit({\n deps: {\n database: coreServices.database,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n signals: signalsServiceRef,\n },\n async init({ database, httpAuth, httpRouter, signals }) {\n const userSettingsStore = await DatabaseUserSettingsStore.create({\n database,\n });\n httpRouter.use(\n await createRouter({ userSettingsStore, httpAuth, signals }),\n );\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","signalsServiceRef","DatabaseUserSettingsStore","createRouter"],"mappings":";;;;;;;;;AA6BA,aAAeA,oCAAoB,CAAA;AAAA,EACjC,QAAU,EAAA,eAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,UAAUC,6BAAa,CAAA,QAAA;AAAA,QACvB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,YAAYA,6BAAa,CAAA,UAAA;AAAA,QACzB,OAAS,EAAAC;AAAA,OACX;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,UAAU,QAAU,EAAA,UAAA,EAAY,SAAW,EAAA;AACtD,QAAM,MAAA,iBAAA,GAAoB,MAAMC,mDAAA,CAA0B,MAAO,CAAA;AAAA,UAC/D;AAAA,SACD,CAAA;AACD,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAMC,mBAAa,CAAA,EAAE,iBAAmB,EAAA,QAAA,EAAU,SAAS;AAAA,SAC7D;AAAA;AACF,KACD,CAAA;AAAA;AAEL,CAAC,CAAA;;;;"}
@@ -3,7 +3,6 @@
3
3
  var errors = require('@backstage/errors');
4
4
  var express = require('express');
5
5
  var Router = require('express-promise-router');
6
- var DatabaseUserSettingsStore = require('../database/DatabaseUserSettingsStore.cjs.js');
7
6
 
8
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
9
8
 
@@ -11,30 +10,13 @@ var express__default = /*#__PURE__*/_interopDefaultCompat(express);
11
10
  var Router__default = /*#__PURE__*/_interopDefaultCompat(Router);
12
11
 
13
12
  async function createRouter(options) {
14
- const userSettingsStore = await DatabaseUserSettingsStore.DatabaseUserSettingsStore.create({
15
- database: options.database
16
- });
17
- return await createRouterInternal({
18
- userSettingsStore,
19
- identity: options.identity,
20
- signals: options.signals
21
- });
22
- }
23
- async function createRouterInternal(options) {
24
13
  const router = Router__default.default();
25
14
  router.use(express__default.default.json());
26
15
  const getUserEntityRef = async (req) => {
27
- if ("httpAuth" in options) {
28
- const credentials = await options.httpAuth.credentials(req, {
29
- allow: ["user"]
30
- });
31
- return credentials.principal.userEntityRef;
32
- }
33
- const identity = await options.identity.getIdentity({ request: req });
34
- if (!identity) {
35
- throw new errors.AuthenticationError(`Missing token in 'authorization' header`);
36
- }
37
- return identity.identity.userEntityRef;
16
+ const credentials = await options.httpAuth.credentials(req, {
17
+ allow: ["user"]
18
+ });
19
+ return credentials.principal.userEntityRef;
38
20
  };
39
21
  router.get("/buckets/:bucket/keys/:key", async (req, res) => {
40
22
  const userEntityRef = await getUserEntityRef(req);
@@ -90,5 +72,4 @@ async function createRouterInternal(options) {
90
72
  }
91
73
 
92
74
  exports.createRouter = createRouter;
93
- exports.createRouterInternal = createRouterInternal;
94
75
  //# sourceMappingURL=router.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport { IdentityApi } from '@backstage/plugin-auth-node';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport { DatabaseUserSettingsStore } from '../database/DatabaseUserSettingsStore';\nimport { UserSettingsStore } from '../database/UserSettingsStore';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport { UserSettingsSignal } from '@backstage/plugin-user-settings-common';\nimport {\n DatabaseService,\n HttpAuthService,\n} from '@backstage/backend-plugin-api';\n\n/**\n * @public\n */\nexport interface RouterOptions {\n database: DatabaseService;\n identity: IdentityApi;\n signals?: SignalsService;\n}\n\n/**\n * Create the user settings backend routes.\n *\n * @public\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const userSettingsStore = await DatabaseUserSettingsStore.create({\n database: options.database,\n });\n\n return await createRouterInternal({\n userSettingsStore,\n identity: options.identity,\n signals: options.signals,\n });\n}\n\nexport async function createRouterInternal(\n options:\n | {\n identity: IdentityApi;\n userSettingsStore: UserSettingsStore;\n signals?: SignalsService;\n }\n | {\n httpAuth: HttpAuthService;\n userSettingsStore: UserSettingsStore;\n signals?: SignalsService;\n },\n): Promise<express.Router> {\n const router = Router();\n router.use(express.json());\n\n /**\n * Helper method to extract the userEntityRef from the request.\n */\n const getUserEntityRef = async (req: Request): Promise<string> => {\n if ('httpAuth' in options) {\n const credentials = await options.httpAuth.credentials(req, {\n allow: ['user'],\n });\n return credentials.principal.userEntityRef;\n }\n\n // throws an AuthenticationError in case the token exists but is invalid\n const identity = await options.identity.getIdentity({ request: req });\n if (!identity) {\n throw new AuthenticationError(`Missing token in 'authorization' header`);\n }\n\n return identity.identity.userEntityRef;\n };\n\n // get a single value\n router.get('/buckets/:bucket/keys/:key', async (req, res) => {\n const userEntityRef = await getUserEntityRef(req);\n const { bucket, key } = req.params;\n\n const setting = await options.userSettingsStore.get({\n userEntityRef,\n bucket,\n key,\n });\n\n res.json(setting);\n });\n\n // set a single value\n router.put('/buckets/:bucket/keys/:key', async (req, res) => {\n const userEntityRef = await getUserEntityRef(req);\n const { bucket, key } = req.params;\n const { value } = req.body;\n\n if (value === undefined) {\n throw new InputError('Missing required field \"value\"');\n }\n\n await options.userSettingsStore.set({\n userEntityRef,\n bucket,\n key,\n value,\n });\n const setting = await options.userSettingsStore.get({\n userEntityRef,\n bucket,\n key,\n });\n\n if (options.signals) {\n await options.signals.publish<UserSettingsSignal>({\n recipients: { type: 'user', entityRef: userEntityRef },\n channel: `user-settings`,\n message: { type: 'key-changed', key },\n });\n }\n\n res.json(setting);\n });\n\n // get a single value\n router.delete('/buckets/:bucket/keys/:key', async (req, res) => {\n const userEntityRef = await getUserEntityRef(req);\n const { bucket, key } = req.params;\n\n await options.userSettingsStore.delete({ userEntityRef, bucket, key });\n if (options.signals) {\n await options.signals.publish<UserSettingsSignal>({\n recipients: { type: 'user', entityRef: userEntityRef },\n channel: 'user-settings',\n message: { type: 'key-deleted', key },\n });\n }\n\n res.status(204).end();\n });\n\n return router;\n}\n"],"names":["DatabaseUserSettingsStore","Router","express","AuthenticationError","InputError"],"mappings":";;;;;;;;;;;;AA2CA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA,iBAAA,GAAoB,MAAMA,mDAAA,CAA0B,MAAO,CAAA;AAAA,IAC/D,UAAU,OAAQ,CAAA;AAAA,GACnB,CAAA;AAED,EAAA,OAAO,MAAM,oBAAqB,CAAA;AAAA,IAChC,iBAAA;AAAA,IACA,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,SAAS,OAAQ,CAAA;AAAA,GAClB,CAAA;AACH;AAEA,eAAsB,qBACpB,OAWyB,EAAA;AACzB,EAAA,MAAM,SAASC,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAKzB,EAAM,MAAA,gBAAA,GAAmB,OAAO,GAAkC,KAAA;AAChE,IAAA,IAAI,cAAc,OAAS,EAAA;AACzB,MAAA,MAAM,WAAc,GAAA,MAAM,OAAQ,CAAA,QAAA,CAAS,YAAY,GAAK,EAAA;AAAA,QAC1D,KAAA,EAAO,CAAC,MAAM;AAAA,OACf,CAAA;AACD,MAAA,OAAO,YAAY,SAAU,CAAA,aAAA;AAAA;AAI/B,IAAM,MAAA,QAAA,GAAW,MAAM,OAAQ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AA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,MAAM,MAAA,OAAA,CAAQ,QAAQ,OAA4B,CAAA;AAAA,QAChD,UAAY,EAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,WAAW,aAAc,EAAA;AAAA,QACrD,OAAS,EAAA,CAAA,aAAA,CAAA;AAAA,QACT,OAAS,EAAA,EAAE,IAAM,EAAA,aAAA,EAAe,GAAI;AAAA,OACrC,CAAA;AAAA;AAGH,IAAA,GAAA,CAAI,KAAK,OAAO,CAAA;AAAA,GACjB,CAAA;AAGD,EAAA,MAAA,CAAO,MAAO,CAAA,4BAAA,EAA8B,OAAO,GAAA,EAAK,GAAQ,KAAA;AAC9D,IAAM,MAAA,aAAA,GAAgB,MAAM,gBAAA,CAAiB,GAAG,CAAA;AAChD,IAAA,MAAM,EAAE,MAAA,EAAQ,GAAI,EAAA,GAAI,GAAI,CAAA,MAAA;AAE5B,IAAA,MAAM,QAAQ,iBAAkB,CAAA,MAAA,CAAO,EAAE,aAAe,EAAA,MAAA,EAAQ,KAAK,CAAA;AACrE,IAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,MAAM,MAAA,OAAA,CAAQ,QAAQ,OAA4B,CAAA;AAAA,QAChD,UAAY,EAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,WAAW,aAAc,EAAA;AAAA,QACrD,OAAS,EAAA,eAAA;AAAA,QACT,OAAS,EAAA,EAAE,IAAM,EAAA,aAAA,EAAe,GAAI;AAAA,OACrC,CAAA;AAAA;AAGH,IAAI,GAAA,CAAA,MAAA,CAAO,GAAG,CAAA,CAAE,GAAI,EAAA;AAAA,GACrB,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;;"}
1
+ {"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport express, { Request } from 'express';\nimport Router from 'express-promise-router';\nimport { UserSettingsStore } from '../database/UserSettingsStore';\nimport { SignalsService } from '@backstage/plugin-signals-node';\nimport { UserSettingsSignal } from '@backstage/plugin-user-settings-common';\nimport { HttpAuthService } from '@backstage/backend-plugin-api';\n\nexport async function createRouter(options: {\n httpAuth: HttpAuthService;\n userSettingsStore: UserSettingsStore;\n signals: SignalsService;\n}): Promise<express.Router> {\n const router = Router();\n router.use(express.json());\n\n /**\n * Helper method to extract the userEntityRef from the request.\n */\n const getUserEntityRef = async (req: Request): Promise<string> => {\n const credentials = await options.httpAuth.credentials(req, {\n allow: ['user'],\n });\n return credentials.principal.userEntityRef;\n };\n\n // get a single value\n router.get('/buckets/:bucket/keys/:key', async (req, res) => {\n const userEntityRef = await getUserEntityRef(req);\n const { bucket, key } = req.params;\n\n const setting = await options.userSettingsStore.get({\n userEntityRef,\n bucket,\n key,\n });\n\n res.json(setting);\n });\n\n // set a single value\n router.put('/buckets/:bucket/keys/:key', async (req, res) => {\n const userEntityRef = await getUserEntityRef(req);\n const { bucket, key } = req.params;\n const { value } = req.body;\n\n if (value === undefined) {\n throw new InputError('Missing required field \"value\"');\n }\n\n await options.userSettingsStore.set({\n userEntityRef,\n bucket,\n key,\n value,\n });\n const setting = await options.userSettingsStore.get({\n userEntityRef,\n bucket,\n key,\n });\n\n if (options.signals) {\n await options.signals.publish<UserSettingsSignal>({\n recipients: { type: 'user', entityRef: userEntityRef },\n channel: `user-settings`,\n message: { type: 'key-changed', key },\n });\n }\n\n res.json(setting);\n });\n\n // get a single value\n router.delete('/buckets/:bucket/keys/:key', async (req, res) => {\n const userEntityRef = await getUserEntityRef(req);\n const { bucket, key } = req.params;\n\n await options.userSettingsStore.delete({ userEntityRef, bucket, key });\n if (options.signals) {\n await options.signals.publish<UserSettingsSignal>({\n recipients: { type: 'user', entityRef: userEntityRef },\n channel: 'user-settings',\n message: { type: 'key-deleted', key },\n });\n }\n\n res.status(204).end();\n });\n\n return router;\n}\n"],"names":["Router","express","InputError"],"mappings":";;;;;;;;;;;AAwBA,eAAsB,aAAa,OAIP,EAAA;AAC1B,EAAA,MAAM,SAASA,uBAAO,EAAA;AACtB,EAAO,MAAA,CAAA,GAAA,CAAIC,wBAAQ,CAAA,IAAA,EAAM,CAAA;AAKzB,EAAM,MAAA,gBAAA,GAAmB,OAAO,GAAkC,KAAA;AAChE,IAAA,MAAM,WAAc,GAAA,MAAM,OAAQ,CAAA,QAAA,CAAS,YAAY,GAAK,EAAA;AAAA,MAC1D,KAAA,EAAO,CAAC,MAAM;AAAA,KACf,CAAA;AACD,IAAA,OAAO,YAAY,SAAU,CAAA,aAAA;AAAA,GAC/B;AAGA,EAAA,MAAA,CAAO,GAAI,CAAA,4BAAA,EAA8B,OAAO,GAAA,EAAK,GAAQ,KAAA;AAC3D,IAAM,MAAA,aAAA,GAAgB,MAAM,gBAAA,CAAiB,GAAG,CAAA;AAChD,IAAA,MAAM,EAAE,MAAA,EAAQ,GAAI,EAAA,GAAI,GAAI,CAAA,MAAA;AAE5B,IAAA,MAAM,OAAU,GAAA,MAAM,OAAQ,CAAA,iBAAA,CAAkB,GAAI,CAAA;AAAA,MAClD,aAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,GAAA,CAAI,KAAK,OAAO,CAAA;AAAA,GACjB,CAAA;AAGD,EAAA,MAAA,CAAO,GAAI,CAAA,4BAAA,EAA8B,OAAO,GAAA,EAAK,GAAQ,KAAA;AAC3D,IAAM,MAAA,aAAA,GAAgB,MAAM,gBAAA,CAAiB,GAAG,CAAA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,QAAQ,OAA4B,CAAA;AAAA,QAChD,UAAY,EAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,WAAW,aAAc,EAAA;AAAA,QACrD,OAAS,EAAA,eAAA;AAAA,QACT,OAAS,EAAA,EAAE,IAAM,EAAA,aAAA,EAAe,GAAI;AAAA,OACrC,CAAA;AAAA;AAGH,IAAI,GAAA,CAAA,MAAA,CAAO,GAAG,CAAA,CAAE,GAAI,EAAA;AAAA,GACrB,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-user-settings-backend",
3
- "version": "0.2.31-next.0",
3
+ "version": "0.3.0-next.2",
4
4
  "description": "The Backstage backend plugin to manage user settings",
5
5
  "backstage": {
6
6
  "role": "backend-plugin",
@@ -11,8 +11,7 @@
11
11
  "@backstage/plugin-user-settings-common"
12
12
  ],
13
13
  "features": {
14
- ".": "@backstage/BackendFeature",
15
- "./alpha": "@backstage/BackendFeature"
14
+ ".": "@backstage/BackendFeature"
16
15
  }
17
16
  },
18
17
  "publishConfig": {
@@ -32,26 +31,10 @@
32
31
  "types": "./dist/index.d.ts",
33
32
  "default": "./dist/index.cjs.js"
34
33
  },
35
- "./alpha": {
36
- "backstage": "@backstage/BackendFeature",
37
- "require": "./dist/alpha.cjs.js",
38
- "types": "./dist/alpha.d.ts",
39
- "default": "./dist/alpha.cjs.js"
40
- },
41
34
  "./package.json": "./package.json"
42
35
  },
43
36
  "main": "./dist/index.cjs.js",
44
37
  "types": "./dist/index.d.ts",
45
- "typesVersions": {
46
- "*": {
47
- "index": [
48
- "dist/index.d.ts"
49
- ],
50
- "alpha": [
51
- "dist/alpha.d.ts"
52
- ]
53
- }
54
- },
55
38
  "files": [
56
39
  "dist",
57
40
  "migrations"
@@ -66,24 +49,22 @@
66
49
  "test": "backstage-cli package test"
67
50
  },
68
51
  "dependencies": {
69
- "@backstage/backend-defaults": "0.8.2-next.0",
70
- "@backstage/backend-plugin-api": "1.2.1-next.0",
71
- "@backstage/config": "1.3.2",
52
+ "@backstage/backend-defaults": "0.8.2-next.2",
53
+ "@backstage/backend-plugin-api": "1.2.1-next.1",
72
54
  "@backstage/errors": "1.2.7",
73
- "@backstage/plugin-auth-node": "0.6.1-next.0",
74
- "@backstage/plugin-signals-node": "0.1.18-next.0",
55
+ "@backstage/plugin-auth-node": "0.6.1-next.1",
56
+ "@backstage/plugin-signals-node": "0.1.18-next.2",
75
57
  "@backstage/plugin-user-settings-common": "0.0.1",
76
58
  "@backstage/types": "1.2.1",
77
- "@types/express": "^4.17.6",
78
59
  "express": "^4.17.1",
79
60
  "express-promise-router": "^4.1.0",
80
- "knex": "^3.0.0",
81
- "yn": "^4.0.0"
61
+ "knex": "^3.0.0"
82
62
  },
83
63
  "devDependencies": {
84
- "@backstage/backend-defaults": "0.8.2-next.0",
85
- "@backstage/backend-test-utils": "1.3.1-next.0",
86
- "@backstage/cli": "0.30.0",
64
+ "@backstage/backend-defaults": "0.8.2-next.2",
65
+ "@backstage/backend-test-utils": "1.3.1-next.2",
66
+ "@backstage/cli": "0.31.0-next.1",
67
+ "@types/express": "^4.17.6",
87
68
  "@types/supertest": "^2.0.8",
88
69
  "supertest": "^7.0.0"
89
70
  }
package/dist/alpha.cjs.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var plugin = require('./plugin.cjs.js');
6
-
7
- const _feature = plugin.default;
8
-
9
- exports.default = _feature;
10
- //# sourceMappingURL=alpha.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.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 { default as feature } from './plugin';\n\n/** @alpha */\nconst _feature = feature;\nexport default _feature;\n"],"names":["feature"],"mappings":";;;;;;AAmBA,MAAM,QAAW,GAAAA;;;;"}
package/dist/alpha.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
-
3
- /** @alpha */
4
- declare const _feature: _backstage_backend_plugin_api.BackendFeature;
5
-
6
- export { _feature as default };
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var router = require('./service/router.cjs.js');
4
-
5
- async function createRouter(options) {
6
- return await router.createRouter(options);
7
- }
8
-
9
- exports.createRouter = createRouter;
10
- //# sourceMappingURL=deprecated.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated.cjs.js","sources":["../src/deprecated.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 express from 'express';\nimport { DatabaseService } from '@backstage/backend-plugin-api';\nimport { SignalsService } from '@backstage/plugin-signals-node';\n\nimport { createRouter as internalCreateRouter } from './service';\nimport { IdentityApi } from '@backstage/plugin-auth-node';\n\n/**\n * Type for the options passed to the \"createRouter\" function.\n *\n * @public\n * @deprecated This type is only exported for legacy reasons and will be removed in the future.\n */\nexport type RouterOptions = {\n database: DatabaseService;\n identity: IdentityApi;\n signals?: SignalsService;\n};\n\n/**\n * Create the user settings backend routes.\n *\n * @public\n * @deprecated This function is only exported for legacy reasons and will be removed in the future.\n * Please {@link https://backstage.io/docs/backend-system/building-backends/migrating | migrate } to use the new backend system and follow these {@link https://github.com/backstage/backstage/tree/master/plugins/user-settings-backend#new-backend | instructions } to install the user settings backend plugin.\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n return await internalCreateRouter(options);\n}\n"],"names":["internalCreateRouter"],"mappings":";;;;AA0CA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAO,OAAA,MAAMA,oBAAqB,OAAO,CAAA;AAC3C;;;;"}