@jskit-ai/users-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/users-core",
4
- version: "0.1.9",
4
+ version: "0.1.10",
5
5
  description: "Users/workspace domain runtime plus HTTP routes for workspace, account, and console features.",
6
6
  dependsOn: [
7
7
  "@jskit-ai/auth-core",
@@ -203,10 +203,10 @@ export default Object.freeze({
203
203
  mutations: {
204
204
  dependencies: {
205
205
  runtime: {
206
- "@jskit-ai/auth-core": "0.1.9",
207
- "@jskit-ai/database-runtime": "0.1.9",
208
- "@jskit-ai/http-runtime": "0.1.9",
209
- "@jskit-ai/kernel": "0.1.9",
206
+ "@jskit-ai/auth-core": "0.1.8",
207
+ "@jskit-ai/database-runtime": "0.1.8",
208
+ "@jskit-ai/http-runtime": "0.1.8",
209
+ "@jskit-ai/kernel": "0.1.8",
210
210
  "@fastify/multipart": "^9.4.0",
211
211
  "@fastify/type-provider-typebox": "^6.1.0",
212
212
  "typebox": "^1.0.81"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-core",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -24,10 +24,10 @@
24
24
  "./shared/resources/consoleSettingsFields": "./src/shared/resources/consoleSettingsFields.js"
25
25
  },
26
26
  "dependencies": {
27
- "@jskit-ai/auth-core": "0.1.9",
28
- "@jskit-ai/database-runtime": "0.1.9",
29
- "@jskit-ai/http-runtime": "0.1.9",
30
- "@jskit-ai/kernel": "0.1.9",
27
+ "@jskit-ai/auth-core": "0.1.8",
28
+ "@jskit-ai/database-runtime": "0.1.8",
29
+ "@jskit-ai/http-runtime": "0.1.8",
30
+ "@jskit-ai/kernel": "0.1.8",
31
31
  "@fastify/multipart": "^9.4.0",
32
32
  "@fastify/type-provider-typebox": "^6.1.0",
33
33
  "typebox": "^1.0.81"
@@ -4,6 +4,7 @@ import {
4
4
  createCursorListValidator,
5
5
  normalizeObjectInput
6
6
  } from "@jskit-ai/kernel/shared/validators";
7
+ import { normalizeSettingsFieldInput } from "./normalizeSettingsFieldInput.js";
7
8
  import { consoleSettingsFields } from "./consoleSettingsFields.js";
8
9
 
9
10
  function buildCreateSchema() {
@@ -46,17 +47,7 @@ function buildConsoleSettingsPatchSchema() {
46
47
  }
47
48
 
48
49
  function normalizeConsoleSettingsInput(payload = {}) {
49
- const source = normalizeObjectInput(payload);
50
- const normalized = {};
51
- for (const field of consoleSettingsFields) {
52
- if (!Object.hasOwn(source, field.key)) {
53
- continue;
54
- }
55
- normalized[field.key] = field.normalizeInput(source[field.key], {
56
- payload: source
57
- });
58
- }
59
- return normalized;
50
+ return normalizeSettingsFieldInput(payload, consoleSettingsFields);
60
51
  }
61
52
 
62
53
  const consoleSettingsOutputValidator = Object.freeze({
@@ -0,0 +1,19 @@
1
+ import { normalizeObjectInput } from "@jskit-ai/kernel/shared/validators";
2
+
3
+ function normalizeSettingsFieldInput(payload = {}, fields = []) {
4
+ const source = normalizeObjectInput(payload);
5
+ const normalized = {};
6
+
7
+ for (const field of fields) {
8
+ if (!Object.hasOwn(source, field.key)) {
9
+ continue;
10
+ }
11
+ normalized[field.key] = field.normalizeInput(source[field.key], {
12
+ payload: source
13
+ });
14
+ }
15
+
16
+ return normalized;
17
+ }
18
+
19
+ export { normalizeSettingsFieldInput };
@@ -5,6 +5,7 @@ import {
5
5
  } from "@jskit-ai/kernel/shared/validators";
6
6
  import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
7
7
  import { createOperationMessages } from "../operationMessages.js";
8
+ import { normalizeSettingsFieldInput } from "./normalizeSettingsFieldInput.js";
8
9
  import { userProfileResource } from "./userProfileResource.js";
9
10
  import {
10
11
  USER_SETTINGS_SECTIONS,
@@ -49,20 +50,8 @@ function buildSectionOutputSchema(section) {
49
50
  return Type.Object(properties, { additionalProperties: false });
50
51
  }
51
52
 
52
- function normalizeUserSettingsInput(payload = {}) {
53
- const source = normalizeObjectInput(payload);
54
- const normalized = {};
55
-
56
- for (const field of userSettingsFields) {
57
- if (!Object.hasOwn(source, field.key)) {
58
- continue;
59
- }
60
- normalized[field.key] = field.normalizeInput(source[field.key], {
61
- payload: source
62
- });
63
- }
64
-
65
- return normalized;
53
+ function normalizeInput(payload = {}) {
54
+ return normalizeSettingsFieldInput(payload, userSettingsFields);
66
55
  }
67
56
 
68
57
  function normalizeSectionOutput(section, sectionSource = {}, settings = {}) {
@@ -147,14 +136,14 @@ const preferencesUpdateBodyValidator = Object.freeze({
147
136
  get schema() {
148
137
  return buildPreferencesUpdateBodySchema();
149
138
  },
150
- normalize: normalizeUserSettingsInput
139
+ normalize: normalizeInput
151
140
  });
152
141
 
153
142
  const notificationsUpdateBodyValidator = Object.freeze({
154
143
  get schema() {
155
144
  return buildNotificationsUpdateBodySchema();
156
145
  },
157
- normalize: normalizeUserSettingsInput
146
+ normalize: normalizeInput
158
147
  });
159
148
 
160
149
  function normalizeOAuthProviderParams(payload = {}) {
@@ -341,7 +330,7 @@ const userSettingsResource = Object.freeze({
341
330
  get schema() {
342
331
  return buildUserSettingsCreateBodySchema();
343
332
  },
344
- normalize: normalizeUserSettingsInput
333
+ normalize: normalizeInput
345
334
  }),
346
335
  outputValidator: userSettingsOutputValidator
347
336
  }),
@@ -352,7 +341,7 @@ const userSettingsResource = Object.freeze({
352
341
  get schema() {
353
342
  return buildUserSettingsCreateBodySchema();
354
343
  },
355
- normalize: normalizeUserSettingsInput
344
+ normalize: normalizeInput
356
345
  }),
357
346
  outputValidator: userSettingsOutputValidator
358
347
  }),
@@ -363,7 +352,7 @@ const userSettingsResource = Object.freeze({
363
352
  get schema() {
364
353
  return buildUserSettingsPatchBodySchema();
365
354
  },
366
- normalize: normalizeUserSettingsInput
355
+ normalize: normalizeInput
367
356
  }),
368
357
  outputValidator: userSettingsOutputValidator
369
358
  }),
@@ -4,6 +4,7 @@ import {
4
4
  normalizeObjectInput,
5
5
  createCursorListValidator
6
6
  } from "@jskit-ai/kernel/shared/validators";
7
+ import { normalizeSettingsFieldInput } from "./normalizeSettingsFieldInput.js";
7
8
  import { workspaceSettingsFields } from "./workspaceSettingsFields.js";
8
9
  import { createWorkspaceRoleCatalog } from "../roles.js";
9
10
 
@@ -60,19 +61,7 @@ function buildResponseRecordSchema() {
60
61
  }
61
62
 
62
63
  function normalizeInput(payload = {}) {
63
- const source = normalizeObjectInput(payload);
64
- const normalized = {};
65
-
66
- for (const field of workspaceSettingsFields) {
67
- if (!Object.hasOwn(source, field.key)) {
68
- continue;
69
- }
70
- normalized[field.key] = field.normalizeInput(source[field.key], {
71
- payload: source
72
- });
73
- }
74
-
75
- return normalized;
64
+ return normalizeSettingsFieldInput(payload, workspaceSettingsFields);
76
65
  }
77
66
 
78
67
  function normalizeOutput(payload = {}) {