@jskit-ai/console-core 0.1.9 → 0.1.10

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.
@@ -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.9",
4
+ version: "0.1.10",
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.46",
76
- "@jskit-ai/http-runtime": "0.1.45",
77
- "@jskit-ai/kernel": "0.1.46",
78
- "@jskit-ai/users-core": "0.1.56",
75
+ "@jskit-ai/database-runtime": "0.1.47",
76
+ "@jskit-ai/http-runtime": "0.1.46",
77
+ "@jskit-ai/kernel": "0.1.47",
78
+ "@jskit-ai/users-core": "0.1.57",
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.9",
3
+ "version": "0.1.10",
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.46",
13
- "@jskit-ai/http-runtime": "0.1.45",
14
- "@jskit-ai/kernel": "0.1.46",
15
- "@jskit-ai/users-core": "0.1.56",
12
+ "@jskit-ai/database-runtime": "0.1.47",
13
+ "@jskit-ai/http-runtime": "0.1.46",
14
+ "@jskit-ai/kernel": "0.1.47",
15
+ "@jskit-ai/users-core": "0.1.57",
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 rawValue = Object.hasOwn(row, field.dbColumn)
19
- ? row[field.dbColumn]
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.dbColumn] = field.normalizeInput(source[field.key], {
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 dbColumn = normalizeText(field.dbColumn);
21
- if (!dbColumn) {
22
- throw new TypeError(`consoleSettingsFields.defineField("${key}") requires dbColumn.`);
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
- dbColumn,
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
- resource: "consoleSettings",
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("usersRepository", {
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("userSettingsRepository", {
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.resource, "string", `${label}.resource must be a string.`);
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];