@backstage/plugin-user-settings-backend 0.2.4-next.2 → 0.2.5
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 +22 -0
- package/alpha/package.json +3 -3
- package/dist/alpha.cjs.js +29 -0
- package/dist/alpha.cjs.js.map +1 -0
- package/dist/alpha.d.ts +10 -0
- package/dist/cjs/router-101d7e68.cjs.js +126 -0
- package/dist/cjs/router-101d7e68.cjs.js.map +1 -0
- package/dist/index.cjs.js +6 -138
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -14
- package/package.json +25 -15
- package/dist/index.alpha.d.ts +0 -29
- package/dist/index.beta.d.ts +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-user-settings-backend
|
|
2
2
|
|
|
3
|
+
## 0.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f6c651fe3c6c: Switched to using `"exports"` field for `/alpha` subpath export.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-common@0.19.9
|
|
10
|
+
- @backstage/plugin-auth-node@0.4.1
|
|
11
|
+
- @backstage/backend-plugin-api@0.6.7
|
|
12
|
+
|
|
13
|
+
## 0.2.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/backend-common@0.19.8
|
|
19
|
+
- @backstage/plugin-auth-node@0.4.0
|
|
20
|
+
- @backstage/catalog-model@1.4.3
|
|
21
|
+
- @backstage/errors@1.2.3
|
|
22
|
+
- @backstage/backend-plugin-api@0.6.6
|
|
23
|
+
- @backstage/types@1.1.1
|
|
24
|
+
|
|
3
25
|
## 0.2.4-next.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/alpha/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
|
+
var router = require('./cjs/router-101d7e68.cjs.js');
|
|
7
|
+
require('@backstage/backend-common');
|
|
8
|
+
require('@backstage/errors');
|
|
9
|
+
require('express');
|
|
10
|
+
require('express-promise-router');
|
|
11
|
+
|
|
12
|
+
var alpha = backendPluginApi.createBackendPlugin({
|
|
13
|
+
pluginId: "userSettings",
|
|
14
|
+
register(env) {
|
|
15
|
+
env.registerInit({
|
|
16
|
+
deps: {
|
|
17
|
+
database: backendPluginApi.coreServices.database,
|
|
18
|
+
identity: backendPluginApi.coreServices.identity,
|
|
19
|
+
httpRouter: backendPluginApi.coreServices.httpRouter
|
|
20
|
+
},
|
|
21
|
+
async init({ database, identity, httpRouter }) {
|
|
22
|
+
httpRouter.use(await router.createRouter({ database, identity }));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
exports["default"] = alpha;
|
|
29
|
+
//# sourceMappingURL=alpha.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.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 createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\n\n/**\n * The user settings backend plugin.\n *\n * @alpha\n */\nexport default createBackendPlugin({\n pluginId: 'userSettings',\n register(env) {\n env.registerInit({\n deps: {\n database: coreServices.database,\n identity: coreServices.identity,\n httpRouter: coreServices.httpRouter,\n },\n async init({ database, identity, httpRouter }) {\n httpRouter.use(await createRouter({ database, identity }));\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","createRouter"],"mappings":";;;;;;;;;;;AA2BA,YAAeA,oCAAoB,CAAA;AAAA,EACjC,QAAU,EAAA,cAAA;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,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,QAAU,EAAA,QAAA,EAAU,YAAc,EAAA;AAC7C,QAAA,UAAA,CAAW,IAAI,MAAMC,mBAAA,CAAa,EAAE,QAAU,EAAA,QAAA,EAAU,CAAC,CAAA,CAAA;AAAA,OAC3D;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC,CAAA;;;;"}
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendCommon = require('@backstage/backend-common');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
5
|
+
var express = require('express');
|
|
6
|
+
var Router = require('express-promise-router');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
11
|
+
var Router__default = /*#__PURE__*/_interopDefaultLegacy(Router);
|
|
12
|
+
|
|
13
|
+
const migrationsDir = backendCommon.resolvePackagePath(
|
|
14
|
+
"@backstage/plugin-user-settings-backend",
|
|
15
|
+
"migrations"
|
|
16
|
+
);
|
|
17
|
+
class DatabaseUserSettingsStore {
|
|
18
|
+
constructor(db) {
|
|
19
|
+
this.db = db;
|
|
20
|
+
}
|
|
21
|
+
static async create(options) {
|
|
22
|
+
var _a;
|
|
23
|
+
const { database } = options;
|
|
24
|
+
const client = await database.getClient();
|
|
25
|
+
if (!((_a = database.migrations) == null ? void 0 : _a.skip)) {
|
|
26
|
+
await client.migrate.latest({
|
|
27
|
+
directory: migrationsDir
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return new DatabaseUserSettingsStore(client);
|
|
31
|
+
}
|
|
32
|
+
async get(options) {
|
|
33
|
+
const rows = await this.db("user_settings").where({
|
|
34
|
+
user_entity_ref: options.userEntityRef,
|
|
35
|
+
bucket: options.bucket,
|
|
36
|
+
key: options.key
|
|
37
|
+
}).select(["bucket", "key", "value"]);
|
|
38
|
+
if (!rows.length) {
|
|
39
|
+
throw new errors.NotFoundError(
|
|
40
|
+
`Unable to find '${options.key}' in bucket '${options.bucket}'`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
bucket: rows[0].bucket,
|
|
45
|
+
key: rows[0].key,
|
|
46
|
+
value: JSON.parse(rows[0].value)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async set(options) {
|
|
50
|
+
await this.db("user_settings").insert({
|
|
51
|
+
user_entity_ref: options.userEntityRef,
|
|
52
|
+
bucket: options.bucket,
|
|
53
|
+
key: options.key,
|
|
54
|
+
value: JSON.stringify(options.value)
|
|
55
|
+
}).onConflict(["user_entity_ref", "bucket", "key"]).merge(["value"]);
|
|
56
|
+
}
|
|
57
|
+
async delete(options) {
|
|
58
|
+
await this.db("user_settings").where({
|
|
59
|
+
user_entity_ref: options.userEntityRef,
|
|
60
|
+
bucket: options.bucket,
|
|
61
|
+
key: options.key
|
|
62
|
+
}).delete();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function createRouter(options) {
|
|
67
|
+
const userSettingsStore = await DatabaseUserSettingsStore.create({
|
|
68
|
+
database: options.database
|
|
69
|
+
});
|
|
70
|
+
return await createRouterInternal({
|
|
71
|
+
userSettingsStore,
|
|
72
|
+
identity: options.identity
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async function createRouterInternal(options) {
|
|
76
|
+
const router = Router__default["default"]();
|
|
77
|
+
router.use(express__default["default"].json());
|
|
78
|
+
const getUserEntityRef = async (req) => {
|
|
79
|
+
const identity = await options.identity.getIdentity({ request: req });
|
|
80
|
+
if (!identity) {
|
|
81
|
+
throw new errors.AuthenticationError(`Missing token in 'authorization' header`);
|
|
82
|
+
}
|
|
83
|
+
return identity.identity.userEntityRef;
|
|
84
|
+
};
|
|
85
|
+
router.get("/buckets/:bucket/keys/:key", async (req, res) => {
|
|
86
|
+
const userEntityRef = await getUserEntityRef(req);
|
|
87
|
+
const { bucket, key } = req.params;
|
|
88
|
+
const setting = await options.userSettingsStore.get({
|
|
89
|
+
userEntityRef,
|
|
90
|
+
bucket,
|
|
91
|
+
key
|
|
92
|
+
});
|
|
93
|
+
res.json(setting);
|
|
94
|
+
});
|
|
95
|
+
router.put("/buckets/:bucket/keys/:key", async (req, res) => {
|
|
96
|
+
const userEntityRef = await getUserEntityRef(req);
|
|
97
|
+
const { bucket, key } = req.params;
|
|
98
|
+
const { value } = req.body;
|
|
99
|
+
if (value === void 0) {
|
|
100
|
+
throw new errors.InputError('Missing required field "value"');
|
|
101
|
+
}
|
|
102
|
+
await options.userSettingsStore.set({
|
|
103
|
+
userEntityRef,
|
|
104
|
+
bucket,
|
|
105
|
+
key,
|
|
106
|
+
value
|
|
107
|
+
});
|
|
108
|
+
const setting = await options.userSettingsStore.get({
|
|
109
|
+
userEntityRef,
|
|
110
|
+
bucket,
|
|
111
|
+
key
|
|
112
|
+
});
|
|
113
|
+
res.json(setting);
|
|
114
|
+
});
|
|
115
|
+
router.delete("/buckets/:bucket/keys/:key", async (req, res) => {
|
|
116
|
+
const userEntityRef = await getUserEntityRef(req);
|
|
117
|
+
const { bucket, key } = req.params;
|
|
118
|
+
await options.userSettingsStore.delete({ userEntityRef, bucket, key });
|
|
119
|
+
res.status(204).end();
|
|
120
|
+
});
|
|
121
|
+
router.use(backendCommon.errorHandler());
|
|
122
|
+
return router;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
exports.createRouter = createRouter;
|
|
126
|
+
//# sourceMappingURL=router-101d7e68.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-101d7e68.cjs.js","sources":["../../src/database/DatabaseUserSettingsStore.ts","../../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 {\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport { NotFoundError } from '@backstage/errors';\nimport { JsonValue } from '@backstage/types';\nimport { Knex } from 'knex';\nimport { UserSettingsStore, type UserSetting } from './UserSettingsStore';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-user-settings-backend',\n 'migrations',\n);\n\n/**\n * @public\n */\nexport type RawDbUserSettingsRow = {\n user_entity_ref: string;\n bucket: string;\n key: string;\n value: string;\n};\n\n/**\n * Store to manage the user settings.\n *\n * @public\n */\nexport class DatabaseUserSettingsStore implements UserSettingsStore {\n static async create(options: {\n database: PluginDatabaseManager;\n }): Promise<DatabaseUserSettingsStore> {\n const { database } = options;\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new DatabaseUserSettingsStore(client);\n }\n\n private constructor(private readonly db: Knex) {}\n\n async get(options: {\n userEntityRef: string;\n bucket: string;\n key: string;\n }): Promise<UserSetting> {\n const rows = await this.db<RawDbUserSettingsRow>('user_settings')\n .where({\n user_entity_ref: options.userEntityRef,\n bucket: options.bucket,\n key: options.key,\n })\n .select(['bucket', 'key', 'value']);\n\n if (!rows.length) {\n throw new NotFoundError(\n `Unable to find '${options.key}' in bucket '${options.bucket}'`,\n );\n }\n\n return {\n bucket: rows[0].bucket,\n key: rows[0].key,\n value: JSON.parse(rows[0].value),\n };\n }\n\n async set(options: {\n userEntityRef: string;\n bucket: string;\n key: string;\n value: JsonValue;\n }): Promise<void> {\n await this.db<RawDbUserSettingsRow>('user_settings')\n .insert({\n user_entity_ref: options.userEntityRef,\n bucket: options.bucket,\n key: options.key,\n value: JSON.stringify(options.value),\n })\n .onConflict(['user_entity_ref', 'bucket', 'key'])\n .merge(['value']);\n }\n\n async delete(options: {\n userEntityRef: string;\n bucket: string;\n key: string;\n }): Promise<void> {\n await this.db<RawDbUserSettingsRow>('user_settings')\n .where({\n user_entity_ref: options.userEntityRef,\n bucket: options.bucket,\n key: options.key,\n })\n .delete();\n }\n}\n","/*\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 { errorHandler, PluginDatabaseManager } from '@backstage/backend-common';\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';\n\n/**\n * @public\n */\nexport interface RouterOptions {\n database: PluginDatabaseManager;\n identity: IdentityApi;\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 });\n}\n\nexport async function createRouterInternal(options: {\n identity: IdentityApi;\n userSettingsStore: UserSettingsStore;\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 // 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 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\n res.status(204).end();\n });\n\n router.use(errorHandler());\n\n return router;\n}\n"],"names":["resolvePackagePath","NotFoundError","Router","express","AuthenticationError","InputError","errorHandler"],"mappings":";;;;;;;;;;;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s/router-101d7e68.cjs.js');
|
|
6
|
+
require('@backstage/backend-common');
|
|
7
|
+
require('@backstage/errors');
|
|
8
|
+
require('express');
|
|
9
|
+
require('express-promise-router');
|
|
10
10
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
11
|
|
|
13
|
-
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
14
|
-
var Router__default = /*#__PURE__*/_interopDefaultLegacy(Router);
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
"@backstage/plugin-user-settings-backend",
|
|
18
|
-
"migrations"
|
|
19
|
-
);
|
|
20
|
-
class DatabaseUserSettingsStore {
|
|
21
|
-
constructor(db) {
|
|
22
|
-
this.db = db;
|
|
23
|
-
}
|
|
24
|
-
static async create(options) {
|
|
25
|
-
var _a;
|
|
26
|
-
const { database } = options;
|
|
27
|
-
const client = await database.getClient();
|
|
28
|
-
if (!((_a = database.migrations) == null ? void 0 : _a.skip)) {
|
|
29
|
-
await client.migrate.latest({
|
|
30
|
-
directory: migrationsDir
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return new DatabaseUserSettingsStore(client);
|
|
34
|
-
}
|
|
35
|
-
async get(options) {
|
|
36
|
-
const rows = await this.db("user_settings").where({
|
|
37
|
-
user_entity_ref: options.userEntityRef,
|
|
38
|
-
bucket: options.bucket,
|
|
39
|
-
key: options.key
|
|
40
|
-
}).select(["bucket", "key", "value"]);
|
|
41
|
-
if (!rows.length) {
|
|
42
|
-
throw new errors.NotFoundError(
|
|
43
|
-
`Unable to find '${options.key}' in bucket '${options.bucket}'`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
bucket: rows[0].bucket,
|
|
48
|
-
key: rows[0].key,
|
|
49
|
-
value: JSON.parse(rows[0].value)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async set(options) {
|
|
53
|
-
await this.db("user_settings").insert({
|
|
54
|
-
user_entity_ref: options.userEntityRef,
|
|
55
|
-
bucket: options.bucket,
|
|
56
|
-
key: options.key,
|
|
57
|
-
value: JSON.stringify(options.value)
|
|
58
|
-
}).onConflict(["user_entity_ref", "bucket", "key"]).merge(["value"]);
|
|
59
|
-
}
|
|
60
|
-
async delete(options) {
|
|
61
|
-
await this.db("user_settings").where({
|
|
62
|
-
user_entity_ref: options.userEntityRef,
|
|
63
|
-
bucket: options.bucket,
|
|
64
|
-
key: options.key
|
|
65
|
-
}).delete();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function createRouter(options) {
|
|
70
|
-
const userSettingsStore = await DatabaseUserSettingsStore.create({
|
|
71
|
-
database: options.database
|
|
72
|
-
});
|
|
73
|
-
return await createRouterInternal({
|
|
74
|
-
userSettingsStore,
|
|
75
|
-
identity: options.identity
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
async function createRouterInternal(options) {
|
|
79
|
-
const router = Router__default["default"]();
|
|
80
|
-
router.use(express__default["default"].json());
|
|
81
|
-
const getUserEntityRef = async (req) => {
|
|
82
|
-
const identity = await options.identity.getIdentity({ request: req });
|
|
83
|
-
if (!identity) {
|
|
84
|
-
throw new errors.AuthenticationError(`Missing token in 'authorization' header`);
|
|
85
|
-
}
|
|
86
|
-
return identity.identity.userEntityRef;
|
|
87
|
-
};
|
|
88
|
-
router.get("/buckets/:bucket/keys/:key", async (req, res) => {
|
|
89
|
-
const userEntityRef = await getUserEntityRef(req);
|
|
90
|
-
const { bucket, key } = req.params;
|
|
91
|
-
const setting = await options.userSettingsStore.get({
|
|
92
|
-
userEntityRef,
|
|
93
|
-
bucket,
|
|
94
|
-
key
|
|
95
|
-
});
|
|
96
|
-
res.json(setting);
|
|
97
|
-
});
|
|
98
|
-
router.put("/buckets/:bucket/keys/:key", async (req, res) => {
|
|
99
|
-
const userEntityRef = await getUserEntityRef(req);
|
|
100
|
-
const { bucket, key } = req.params;
|
|
101
|
-
const { value } = req.body;
|
|
102
|
-
if (value === void 0) {
|
|
103
|
-
throw new errors.InputError('Missing required field "value"');
|
|
104
|
-
}
|
|
105
|
-
await options.userSettingsStore.set({
|
|
106
|
-
userEntityRef,
|
|
107
|
-
bucket,
|
|
108
|
-
key,
|
|
109
|
-
value
|
|
110
|
-
});
|
|
111
|
-
const setting = await options.userSettingsStore.get({
|
|
112
|
-
userEntityRef,
|
|
113
|
-
bucket,
|
|
114
|
-
key
|
|
115
|
-
});
|
|
116
|
-
res.json(setting);
|
|
117
|
-
});
|
|
118
|
-
router.delete("/buckets/:bucket/keys/:key", async (req, res) => {
|
|
119
|
-
const userEntityRef = await getUserEntityRef(req);
|
|
120
|
-
const { bucket, key } = req.params;
|
|
121
|
-
await options.userSettingsStore.delete({ userEntityRef, bucket, key });
|
|
122
|
-
res.status(204).end();
|
|
123
|
-
});
|
|
124
|
-
router.use(backendCommon.errorHandler());
|
|
125
|
-
return router;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const userSettingsPlugin = backendPluginApi.createBackendPlugin({
|
|
129
|
-
pluginId: "userSettings",
|
|
130
|
-
register(env) {
|
|
131
|
-
env.registerInit({
|
|
132
|
-
deps: {
|
|
133
|
-
database: backendPluginApi.coreServices.database,
|
|
134
|
-
identity: backendPluginApi.coreServices.identity,
|
|
135
|
-
httpRouter: backendPluginApi.coreServices.httpRouter
|
|
136
|
-
},
|
|
137
|
-
async init({ database, identity, httpRouter }) {
|
|
138
|
-
httpRouter.use(await createRouter({ database, identity }));
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
exports.createRouter = createRouter;
|
|
145
|
-
exports["default"] = userSettingsPlugin;
|
|
13
|
+
exports.createRouter = router.createRouter;
|
|
146
14
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/database/DatabaseUserSettingsStore.ts","../src/service/router.ts","../src/plugin.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 {\n PluginDatabaseManager,\n resolvePackagePath,\n} from '@backstage/backend-common';\nimport { NotFoundError } from '@backstage/errors';\nimport { JsonValue } from '@backstage/types';\nimport { Knex } from 'knex';\nimport { UserSettingsStore, type UserSetting } from './UserSettingsStore';\n\nconst migrationsDir = resolvePackagePath(\n '@backstage/plugin-user-settings-backend',\n 'migrations',\n);\n\n/**\n * @public\n */\nexport type RawDbUserSettingsRow = {\n user_entity_ref: string;\n bucket: string;\n key: string;\n value: string;\n};\n\n/**\n * Store to manage the user settings.\n *\n * @public\n */\nexport class DatabaseUserSettingsStore implements UserSettingsStore {\n static async create(options: {\n database: PluginDatabaseManager;\n }): Promise<DatabaseUserSettingsStore> {\n const { database } = options;\n const client = await database.getClient();\n\n if (!database.migrations?.skip) {\n await client.migrate.latest({\n directory: migrationsDir,\n });\n }\n\n return new DatabaseUserSettingsStore(client);\n }\n\n private constructor(private readonly db: Knex) {}\n\n async get(options: {\n userEntityRef: string;\n bucket: string;\n key: string;\n }): Promise<UserSetting> {\n const rows = await this.db<RawDbUserSettingsRow>('user_settings')\n .where({\n user_entity_ref: options.userEntityRef,\n bucket: options.bucket,\n key: options.key,\n })\n .select(['bucket', 'key', 'value']);\n\n if (!rows.length) {\n throw new NotFoundError(\n `Unable to find '${options.key}' in bucket '${options.bucket}'`,\n );\n }\n\n return {\n bucket: rows[0].bucket,\n key: rows[0].key,\n value: JSON.parse(rows[0].value),\n };\n }\n\n async set(options: {\n userEntityRef: string;\n bucket: string;\n key: string;\n value: JsonValue;\n }): Promise<void> {\n await this.db<RawDbUserSettingsRow>('user_settings')\n .insert({\n user_entity_ref: options.userEntityRef,\n bucket: options.bucket,\n key: options.key,\n value: JSON.stringify(options.value),\n })\n .onConflict(['user_entity_ref', 'bucket', 'key'])\n .merge(['value']);\n }\n\n async delete(options: {\n userEntityRef: string;\n bucket: string;\n key: string;\n }): Promise<void> {\n await this.db<RawDbUserSettingsRow>('user_settings')\n .where({\n user_entity_ref: options.userEntityRef,\n bucket: options.bucket,\n key: options.key,\n })\n .delete();\n }\n}\n","/*\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 { errorHandler, PluginDatabaseManager } from '@backstage/backend-common';\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';\n\n/**\n * @public\n */\nexport interface RouterOptions {\n database: PluginDatabaseManager;\n identity: IdentityApi;\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 });\n}\n\nexport async function createRouterInternal(options: {\n identity: IdentityApi;\n userSettingsStore: UserSettingsStore;\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 // 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 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\n res.status(204).end();\n });\n\n router.use(errorHandler());\n\n return router;\n}\n","/*\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 createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { createRouter } from './service/router';\n\n/**\n * The user settings backend plugin.\n *\n * @alpha\n */\nexport const userSettingsPlugin = createBackendPlugin({\n pluginId: 'userSettings',\n register(env) {\n env.registerInit({\n deps: {\n database: coreServices.database,\n identity: coreServices.identity,\n httpRouter: coreServices.httpRouter,\n },\n async init({ database, identity, httpRouter }) {\n httpRouter.use(await createRouter({ database, identity }));\n },\n });\n },\n});\n"],"names":["resolvePackagePath","NotFoundError","Router","express","AuthenticationError","InputError","errorHandler","createBackendPlugin","coreServices"],"mappings":";;;;;;;;;;;;;;;AAyBA,MAAM,aAAgB,GAAAA,gCAAA;AAAA,EACpB,yCAAA;AAAA,EACA,YAAA;AACF,CAAA,CAAA;AAiBO,MAAM,yBAAuD,CAAA;AAAA,EAgB1D,YAA6B,EAAU,EAAA;AAAV,IAAA,IAAA,CAAA,EAAA,GAAA,EAAA,CAAA;AAAA,GAAW;AAAA,EAfhD,aAAa,OAAO,OAEmB,EAAA;AAhDzC,IAAA,IAAA,EAAA,CAAA;AAiDI,IAAM,MAAA,EAAE,UAAa,GAAA,OAAA,CAAA;AACrB,IAAM,MAAA,MAAA,GAAS,MAAM,QAAA,CAAS,SAAU,EAAA,CAAA;AAExC,IAAA,IAAI,EAAC,CAAA,EAAA,GAAA,QAAA,CAAS,UAAT,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAqB,IAAM,CAAA,EAAA;AAC9B,MAAM,MAAA,MAAA,CAAO,QAAQ,MAAO,CAAA;AAAA,QAC1B,SAAW,EAAA,aAAA;AAAA,OACZ,CAAA,CAAA;AAAA,KACH;AAEA,IAAO,OAAA,IAAI,0BAA0B,MAAM,CAAA,CAAA;AAAA,GAC7C;AAAA,EAIA,MAAM,IAAI,OAIe,EAAA;AACvB,IAAA,MAAM,OAAO,MAAM,IAAA,CAAK,EAAyB,CAAA,eAAe,EAC7D,KAAM,CAAA;AAAA,MACL,iBAAiB,OAAQ,CAAA,aAAA;AAAA,MACzB,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAK,OAAQ,CAAA,GAAA;AAAA,KACd,CACA,CAAA,MAAA,CAAO,CAA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AAc,CAAA,CAAA;AAEzB,EAAO,OAAA,MAAA,CAAA;AACT;;AC/FO,MAAM,qBAAqBC,oCAAoB,CAAA;AAAA,EACpD,QAAU,EAAA,cAAA;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,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,QAAU,EAAA,QAAA,EAAU,YAAc,EAAA;AAC7C,QAAA,UAAA,CAAW,IAAI,MAAM,YAAA,CAAa,EAAE,QAAU,EAAA,QAAA,EAAU,CAAC,CAAA,CAAA;AAAA,OAC3D;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import { IdentityApi } from '@backstage/plugin-auth-node';
|
|
4
1
|
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Create the user settings backend routes.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
2
|
+
import { IdentityApi } from '@backstage/plugin-auth-node';
|
|
3
|
+
import express from 'express';
|
|
12
4
|
|
|
13
5
|
/**
|
|
14
6
|
* @public
|
|
15
7
|
*/
|
|
16
|
-
|
|
8
|
+
interface RouterOptions {
|
|
17
9
|
database: PluginDatabaseManager;
|
|
18
10
|
identity: IdentityApi;
|
|
19
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Create the user settings backend routes.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { }
|
|
19
|
+
export { RouterOptions, createRouter };
|
package/package.json
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-user-settings-backend",
|
|
3
3
|
"description": "The Backstage backend plugin to manage user settings",
|
|
4
|
-
"version": "0.2.
|
|
5
|
-
"main": "dist/index.cjs.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
4
|
+
"version": "0.2.5",
|
|
5
|
+
"main": "./dist/index.cjs.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"backstage": {
|
|
9
9
|
"role": "backend-plugin"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"require": "./dist/index.cjs.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.cjs.js"
|
|
19
|
+
},
|
|
20
|
+
"./alpha": {
|
|
21
|
+
"require": "./dist/alpha.cjs.js",
|
|
22
|
+
"types": "./dist/alpha.d.ts",
|
|
23
|
+
"default": "./dist/alpha.cjs.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
16
26
|
},
|
|
17
27
|
"homepage": "https://backstage.io",
|
|
18
28
|
"repository": {
|
|
@@ -22,7 +32,7 @@
|
|
|
22
32
|
},
|
|
23
33
|
"scripts": {
|
|
24
34
|
"start": "backstage-cli package start",
|
|
25
|
-
"build": "backstage-cli package build
|
|
35
|
+
"build": "backstage-cli package build",
|
|
26
36
|
"lint": "backstage-cli package lint",
|
|
27
37
|
"test": "backstage-cli package test",
|
|
28
38
|
"prepack": "backstage-cli package prepack",
|
|
@@ -30,11 +40,11 @@
|
|
|
30
40
|
"clean": "backstage-cli package clean"
|
|
31
41
|
},
|
|
32
42
|
"dependencies": {
|
|
33
|
-
"@backstage/backend-common": "^0.19.8
|
|
34
|
-
"@backstage/backend-plugin-api": "^0.6.6
|
|
35
|
-
"@backstage/catalog-model": "^1.4.3
|
|
36
|
-
"@backstage/errors": "^1.2.3
|
|
37
|
-
"@backstage/plugin-auth-node": "^0.4.0
|
|
43
|
+
"@backstage/backend-common": "^0.19.8",
|
|
44
|
+
"@backstage/backend-plugin-api": "^0.6.6",
|
|
45
|
+
"@backstage/catalog-model": "^1.4.3",
|
|
46
|
+
"@backstage/errors": "^1.2.3",
|
|
47
|
+
"@backstage/plugin-auth-node": "^0.4.0",
|
|
38
48
|
"@backstage/types": "^1.1.1",
|
|
39
49
|
"@types/express": "^4.17.6",
|
|
40
50
|
"express": "^4.17.1",
|
|
@@ -44,8 +54,8 @@
|
|
|
44
54
|
"yn": "^4.0.0"
|
|
45
55
|
},
|
|
46
56
|
"devDependencies": {
|
|
47
|
-
"@backstage/backend-test-utils": "^0.2.7
|
|
48
|
-
"@backstage/cli": "^0.23.0
|
|
57
|
+
"@backstage/backend-test-utils": "^0.2.7",
|
|
58
|
+
"@backstage/cli": "^0.23.0",
|
|
49
59
|
"@types/supertest": "^2.0.8",
|
|
50
60
|
"supertest": "^6.1.3"
|
|
51
61
|
},
|
package/dist/index.alpha.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import { IdentityApi } from '@backstage/plugin-auth-node';
|
|
4
|
-
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create the user settings backend routes.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export declare interface RouterOptions {
|
|
17
|
-
database: PluginDatabaseManager;
|
|
18
|
-
identity: IdentityApi;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The user settings backend plugin.
|
|
23
|
-
*
|
|
24
|
-
* @alpha
|
|
25
|
-
*/
|
|
26
|
-
declare const userSettingsPlugin: () => BackendFeature;
|
|
27
|
-
export default userSettingsPlugin;
|
|
28
|
-
|
|
29
|
-
export { }
|
package/dist/index.beta.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import { IdentityApi } from '@backstage/plugin-auth-node';
|
|
4
|
-
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create the user settings backend routes.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export declare interface RouterOptions {
|
|
17
|
-
database: PluginDatabaseManager;
|
|
18
|
-
identity: IdentityApi;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/* Excluded from this release type: userSettingsPlugin */
|
|
22
|
-
|
|
23
|
-
export { }
|