@jskit-ai/console-core 0.1.9 → 0.1.11
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/package.descriptor.mjs +5 -5
- package/package.json +5 -5
- package/src/server/consoleSettings/consoleSettingsRepository.js +4 -3
- package/src/shared/resources/consoleSettingsFields.js +6 -4
- package/src/shared/resources/consoleSettingsResource.js +1 -1
- package/test/bootstrapPayloadIntegration.test.js +2 -2
- package/test/consoleRouteResources.test.js +1 -1
package/package.descriptor.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
packageVersion: 1,
|
|
3
3
|
packageId: "@jskit-ai/console-core",
|
|
4
|
-
version: "0.1.
|
|
4
|
+
version: "0.1.11",
|
|
5
5
|
kind: "runtime",
|
|
6
6
|
description: "Console runtime: console settings schema, bootstrap flags, actions, and HTTP routes.",
|
|
7
7
|
dependsOn: [
|
|
@@ -72,10 +72,10 @@ export default Object.freeze({
|
|
|
72
72
|
mutations: {
|
|
73
73
|
dependencies: {
|
|
74
74
|
runtime: {
|
|
75
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
76
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
77
|
-
"@jskit-ai/kernel": "0.1.
|
|
78
|
-
"@jskit-ai/users-core": "0.1.
|
|
75
|
+
"@jskit-ai/database-runtime": "0.1.48",
|
|
76
|
+
"@jskit-ai/http-runtime": "0.1.47",
|
|
77
|
+
"@jskit-ai/kernel": "0.1.48",
|
|
78
|
+
"@jskit-ai/users-core": "0.1.58",
|
|
79
79
|
"typebox": "^1.0.81"
|
|
80
80
|
},
|
|
81
81
|
dev: {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/console-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"./shared/resources/consoleSettingsFields": "./src/shared/resources/consoleSettingsFields.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
13
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
14
|
-
"@jskit-ai/kernel": "0.1.
|
|
15
|
-
"@jskit-ai/users-core": "0.1.
|
|
12
|
+
"@jskit-ai/database-runtime": "0.1.48",
|
|
13
|
+
"@jskit-ai/http-runtime": "0.1.47",
|
|
14
|
+
"@jskit-ai/kernel": "0.1.48",
|
|
15
|
+
"@jskit-ai/users-core": "0.1.58",
|
|
16
16
|
"typebox": "^1.0.81"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -15,8 +15,9 @@ function nowDb() {
|
|
|
15
15
|
function mapSettings(row = {}) {
|
|
16
16
|
const settings = {};
|
|
17
17
|
for (const field of consoleSettingsFields) {
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const repositoryColumn = field?.repository?.column;
|
|
19
|
+
const rawValue = Object.hasOwn(row, repositoryColumn)
|
|
20
|
+
? row[repositoryColumn]
|
|
20
21
|
: field.resolveDefault({
|
|
21
22
|
settings: row
|
|
22
23
|
});
|
|
@@ -96,7 +97,7 @@ function createRepository(knex) {
|
|
|
96
97
|
if (!Object.hasOwn(source, field.key)) {
|
|
97
98
|
continue;
|
|
98
99
|
}
|
|
99
|
-
dbPatch[field.
|
|
100
|
+
dbPatch[field.repository.column] = field.normalizeInput(source[field.key], {
|
|
100
101
|
payload: source
|
|
101
102
|
});
|
|
102
103
|
}
|
|
@@ -17,9 +17,9 @@ function defineField(field = {}) {
|
|
|
17
17
|
if (!field.outputSchema || typeof field.outputSchema !== "object") {
|
|
18
18
|
throw new TypeError(`consoleSettingsFields.defineField("${key}") requires outputSchema.`);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
22
|
-
throw new TypeError(`consoleSettingsFields.defineField("${key}") requires
|
|
20
|
+
const repositoryColumn = normalizeText(field?.repository?.column);
|
|
21
|
+
if (!repositoryColumn) {
|
|
22
|
+
throw new TypeError(`consoleSettingsFields.defineField("${key}") requires repository.column.`);
|
|
23
23
|
}
|
|
24
24
|
if (typeof field.normalizeInput !== "function") {
|
|
25
25
|
throw new TypeError(`consoleSettingsFields.defineField("${key}") requires normalizeInput.`);
|
|
@@ -33,7 +33,9 @@ function defineField(field = {}) {
|
|
|
33
33
|
|
|
34
34
|
consoleSettingsFields.push({
|
|
35
35
|
key,
|
|
36
|
-
|
|
36
|
+
repository: Object.freeze({
|
|
37
|
+
column: repositoryColumn
|
|
38
|
+
}),
|
|
37
39
|
required: field.required !== false,
|
|
38
40
|
inputSchema: field.inputSchema,
|
|
39
41
|
outputSchema: field.outputSchema,
|
|
@@ -68,7 +68,7 @@ const consoleSettingsOutputValidator = Object.freeze({
|
|
|
68
68
|
const CONSOLE_SETTINGS_OPERATION_MESSAGES = createOperationMessages();
|
|
69
69
|
|
|
70
70
|
const consoleSettingsResource = Object.freeze({
|
|
71
|
-
|
|
71
|
+
namespace: "consoleSettings",
|
|
72
72
|
operations: Object.freeze({
|
|
73
73
|
view: Object.freeze({
|
|
74
74
|
method: "GET",
|
|
@@ -22,12 +22,12 @@ test("bootstrap payload preserves consoleowner for authenticated users after use
|
|
|
22
22
|
const ownerSeeds = [];
|
|
23
23
|
const app = createContainer();
|
|
24
24
|
|
|
25
|
-
app.instance("
|
|
25
|
+
app.instance("internal.repository.user-profiles", {
|
|
26
26
|
async findById(userId) {
|
|
27
27
|
return String(userId || "") === profile.id ? profile : null;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
app.instance("
|
|
30
|
+
app.instance("internal.repository.user-settings", {
|
|
31
31
|
async ensureForUserId() {
|
|
32
32
|
return {};
|
|
33
33
|
}
|
|
@@ -10,7 +10,7 @@ import { consoleSettingsResource } from "../src/shared/resources/consoleSettings
|
|
|
10
10
|
function assertResourceShape(resource, label) {
|
|
11
11
|
assert.ok(resource, `${label} resource must exist.`);
|
|
12
12
|
assert.equal(typeof resource, "object", `${label} resource must be an object.`);
|
|
13
|
-
assert.equal(typeof resource.
|
|
13
|
+
assert.equal(typeof resource.namespace, "string", `.namespace must be a string.`);
|
|
14
14
|
|
|
15
15
|
for (const operationName of ["view", "list", "create", "replace", "patch"]) {
|
|
16
16
|
const operation = resource.operations?.[operationName];
|