@jskit-ai/users-core 0.1.147 → 0.1.149

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.147",
4
+ version: "0.1.149",
5
5
  kind: "runtime",
6
6
  description: "Users/account runtime plus HTTP routes for account features.",
7
7
  dependsOn: [
@@ -146,16 +146,16 @@ export default Object.freeze({
146
146
  mutations: {
147
147
  dependencies: {
148
148
  runtime: {
149
- "@jskit-ai/auth-core": "0.1.133",
150
- "@jskit-ai/crud-core": "0.1.144",
151
- "@jskit-ai/database-runtime": "0.1.134",
152
- "@jskit-ai/http-runtime": "0.1.133",
153
- "@jskit-ai/json-rest-api-core": "0.1.79",
154
- "@jskit-ai/kernel": "0.1.135",
155
- "@jskit-ai/resource-core": "0.1.78",
156
- "@jskit-ai/resource-crud-core": "0.1.78",
149
+ "@jskit-ai/auth-core": "0.1.134",
150
+ "@jskit-ai/crud-core": "0.1.146",
151
+ "@jskit-ai/database-runtime": "0.1.135",
152
+ "@jskit-ai/http-runtime": "0.1.134",
153
+ "@jskit-ai/json-rest-api-core": "0.1.80",
154
+ "@jskit-ai/kernel": "0.1.136",
155
+ "@jskit-ai/resource-core": "0.1.79",
156
+ "@jskit-ai/resource-crud-core": "0.1.79",
157
157
  "@local/users": "file:packages/users",
158
- "@jskit-ai/uploads-runtime": "0.1.111"
158
+ "@jskit-ai/uploads-runtime": "0.1.112"
159
159
  },
160
160
  dev: {}
161
161
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-core",
3
- "version": "0.1.147",
3
+ "version": "0.1.149",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -11,14 +11,14 @@
11
11
  "./shared/resources/userSettingsResource": "./src/shared/resources/userSettingsResource.js"
12
12
  },
13
13
  "dependencies": {
14
- "@jskit-ai/auth-core": "0.1.133",
15
- "@jskit-ai/database-runtime": "0.1.134",
16
- "@jskit-ai/http-runtime": "0.1.133",
17
- "@jskit-ai/json-rest-api-core": "0.1.79",
18
- "@jskit-ai/kernel": "0.1.135",
19
- "@jskit-ai/resource-crud-core": "0.1.78",
20
- "@jskit-ai/resource-core": "0.1.78",
21
- "@jskit-ai/uploads-runtime": "0.1.111",
14
+ "@jskit-ai/auth-core": "0.1.134",
15
+ "@jskit-ai/database-runtime": "0.1.135",
16
+ "@jskit-ai/http-runtime": "0.1.134",
17
+ "@jskit-ai/json-rest-api-core": "0.1.80",
18
+ "@jskit-ai/kernel": "0.1.136",
19
+ "@jskit-ai/resource-crud-core": "0.1.79",
20
+ "@jskit-ai/resource-core": "0.1.79",
21
+ "@jskit-ai/uploads-runtime": "0.1.112",
22
22
  "json-rest-schema": "1.x.x"
23
23
  }
24
24
  }
@@ -3,14 +3,11 @@ import {
3
3
  recordIdParamsValidator
4
4
  } from "@jskit-ai/kernel/shared/validators";
5
5
  import {
6
- createCrudCursorPaginationQueryValidator,
7
- listSearchQueryValidator
6
+ createStandardCrudListQueryValidators,
7
+ createStandardCrudViewQueryValidators
8
8
  } from "@jskit-ai/crud-core/server/listQueryValidators";
9
9
  import { resource } from "../shared/userResource.js";
10
10
 
11
- const listCursorPaginationQueryValidator = createCrudCursorPaginationQueryValidator({
12
- orderBy: resource.defaultSort
13
- });
14
11
  const authenticatedPermission = Object.freeze({
15
12
  require: "authenticated"
16
13
  });
@@ -25,8 +22,7 @@ function createActions({ surface } = {}) {
25
22
  surfaces: [surface],
26
23
  permission: authenticatedPermission,
27
24
  input: composeSchemaDefinitions([
28
- listCursorPaginationQueryValidator,
29
- listSearchQueryValidator
25
+ ...createStandardCrudListQueryValidators({ resource })
30
26
  ]),
31
27
  output: null,
32
28
  idempotency: "none",
@@ -49,7 +45,8 @@ function createActions({ surface } = {}) {
49
45
  surfaces: [surface],
50
46
  permission: authenticatedPermission,
51
47
  input: composeSchemaDefinitions([
52
- recordIdParamsValidator
48
+ recordIdParamsValidator,
49
+ ...createStandardCrudViewQueryValidators()
53
50
  ]),
54
51
  output: null,
55
52
  idempotency: "none",
@@ -58,7 +55,8 @@ function createActions({ surface } = {}) {
58
55
  },
59
56
  observability: {},
60
57
  async execute(input, context, deps) {
61
- return deps.usersService.getDocumentById(input.recordId, {
58
+ const { recordId, ...query } = input || {};
59
+ return deps.usersService.getDocumentById(recordId, query, {
62
60
  context,
63
61
  visibilityContext: context?.visibilityContext
64
62
  });
@@ -2,6 +2,7 @@ import { createWithTransaction } from "@jskit-ai/database-runtime/shared";
2
2
  import {
3
3
  buildJsonRestQueryParams,
4
4
  createJsonRestContext,
5
+ returnBadRequestWhenJsonRestFieldsetInvalid,
5
6
  returnNullWhenJsonRestResourceMissing
6
7
  } from "@jskit-ai/json-rest-api-core/server/jsonRestApiHost";
7
8
  import { resource } from "../shared/userResource.js";
@@ -12,24 +13,10 @@ function createRepository({ api, knex } = {}) {
12
13
  const withTransaction = createWithTransaction(knex);
13
14
 
14
15
  async function queryDocuments(query = {}, options = {}) {
15
- return api.resources.users.query(
16
- {
17
- queryParams: buildJsonRestQueryParams(RESOURCE_TYPE, query),
18
- transaction: options?.trx || null,
19
- simplified: false
20
- },
21
- createJsonRestContext(options?.context || null)
22
- );
23
- }
24
-
25
- async function getDocumentById(recordId, options = {}) {
26
- return returnNullWhenJsonRestResourceMissing(() =>
27
- api.resources.users.get(
16
+ return returnBadRequestWhenJsonRestFieldsetInvalid(() =>
17
+ api.resources.users.query(
28
18
  {
29
- id: recordId,
30
- queryParams: buildJsonRestQueryParams(RESOURCE_TYPE, {}, {
31
- include: options?.include
32
- }),
19
+ queryParams: buildJsonRestQueryParams(RESOURCE_TYPE, query),
33
20
  transaction: options?.trx || null,
34
21
  simplified: false
35
22
  },
@@ -38,6 +25,22 @@ function createRepository({ api, knex } = {}) {
38
25
  );
39
26
  }
40
27
 
28
+ async function getDocumentById(recordId, query = {}, options = {}) {
29
+ return returnBadRequestWhenJsonRestFieldsetInvalid(() =>
30
+ returnNullWhenJsonRestResourceMissing(() =>
31
+ api.resources.users.get(
32
+ {
33
+ id: recordId,
34
+ queryParams: buildJsonRestQueryParams(RESOURCE_TYPE, query),
35
+ transaction: options?.trx || null,
36
+ simplified: false
37
+ },
38
+ createJsonRestContext(options?.context || null)
39
+ )
40
+ )
41
+ );
42
+ }
43
+
41
44
  return Object.freeze({
42
45
  withTransaction,
43
46
  queryDocuments,
@@ -20,11 +20,10 @@ function createService({ usersRepository } = {}) {
20
20
  context: options?.context || null
21
21
  }));
22
22
  },
23
- async getDocumentById(recordId, options = {}) {
24
- return returnJsonApiDocument(return404IfNotFound(await usersRepository.getDocumentById(recordId, {
23
+ async getDocumentById(recordId, query = {}, options = {}) {
24
+ return returnJsonApiDocument(return404IfNotFound(await usersRepository.getDocumentById(recordId, query, {
25
25
  trx: options?.trx || null,
26
- context: options?.context || null,
27
- include: options?.include
26
+ context: options?.context || null
28
27
  })));
29
28
  }
30
29
  });
@@ -3,15 +3,12 @@ import {
3
3
  recordIdParamsValidator
4
4
  } from "@jskit-ai/kernel/shared/validators";
5
5
  import {
6
- createCrudCursorPaginationQueryValidator,
7
- listSearchQueryValidator
6
+ createStandardCrudListQueryValidators,
7
+ createStandardCrudViewQueryValidators
8
8
  } from "@jskit-ai/crud-core/server/listQueryValidators";
9
9
  import { workspaceSlugParamsValidator } from "@jskit-ai/workspaces-core/server/validators/routeParamsValidator";
10
10
  import { resource } from "../shared/userResource.js";
11
11
 
12
- const listCursorPaginationQueryValidator = createCrudCursorPaginationQueryValidator({
13
- orderBy: resource.defaultSort
14
- });
15
12
  const authenticatedPermission = Object.freeze({
16
13
  require: "authenticated"
17
14
  });
@@ -33,8 +30,7 @@ function createActions({ surface } = {}) {
33
30
  permission: authenticatedPermission,
34
31
  input: composeSchemaDefinitions([
35
32
  workspaceSlugParamsValidator,
36
- listCursorPaginationQueryValidator,
37
- listSearchQueryValidator
33
+ ...createStandardCrudListQueryValidators({ resource })
38
34
  ]),
39
35
  output: null,
40
36
  idempotency: "none",
@@ -58,7 +54,8 @@ function createActions({ surface } = {}) {
58
54
  permission: authenticatedPermission,
59
55
  input: composeSchemaDefinitions([
60
56
  workspaceSlugParamsValidator,
61
- recordIdParamsValidator
57
+ recordIdParamsValidator,
58
+ ...createStandardCrudViewQueryValidators()
62
59
  ]),
63
60
  output: null,
64
61
  idempotency: "none",
@@ -67,7 +64,8 @@ function createActions({ surface } = {}) {
67
64
  },
68
65
  observability: {},
69
66
  async execute(input, context, deps) {
70
- return deps.usersService.getDocumentById(input.recordId, {
67
+ const { workspaceSlug, recordId, ...query } = input || {};
68
+ return deps.usersService.getDocumentById(recordId, query, {
71
69
  context,
72
70
  visibilityContext: context?.visibilityContext
73
71
  });
@@ -125,12 +125,17 @@ test("users-core base users package templates stay aligned with non-workspace ap
125
125
  assert.match(repositorySource, /api\.resources\.users\.query\(/);
126
126
  assert.match(repositorySource, /api\.resources\.users\.get\(/);
127
127
  assert.match(repositorySource, /async function queryDocuments\(query = \{\}, options = \{\}\)/);
128
- assert.match(repositorySource, /async function getDocumentById\(recordId, options = \{\}\)/);
128
+ assert.match(repositorySource, /async function getDocumentById\(recordId, query = \{\}, options = \{\}\)/);
129
+ assert.match(repositorySource, /buildJsonRestQueryParams\(RESOURCE_TYPE, query\)/);
130
+ assert.match(repositorySource, /returnBadRequestWhenJsonRestFieldsetInvalid/);
129
131
  assert.match(repositorySource, /returnNullWhenJsonRestResourceMissing/);
130
132
  assert.doesNotMatch(actionsSource, /workspaceSlugParamsValidator/);
131
133
  assert.doesNotMatch(actionsSource, /delete query\.workspaceSlug/);
132
134
  assert.doesNotMatch(actionsSource, /requireActionSurface/);
133
- assert.match(actionsSource, /orderBy: resource\.defaultSort/);
135
+ assert.match(actionsSource, /createStandardCrudListQueryValidators\(\{ resource \}\)/);
136
+ assert.match(actionsSource, /createStandardCrudViewQueryValidators\(\)/);
137
+ assert.match(actionsSource, /const \{ recordId, \.\.\.query \} = input \|\| \{\};/);
138
+ assert.match(actionsSource, /usersService\.getDocumentById\(recordId, query,/);
134
139
  assert.match(actionsSource, /output: null/);
135
140
  assert.match(actionsSource, /usersService\.queryDocuments/);
136
141
  assert.match(actionsSource, /usersService\.getDocumentById/);
@@ -189,7 +194,10 @@ test("users-core workspace users package templates stay aligned with workspace a
189
194
  assert.match(actionsSource, /workspaceSlugParamsValidator/);
190
195
  assert.match(actionsSource, /delete query\.workspaceSlug/);
191
196
  assert.doesNotMatch(actionsSource, /requireActionSurface/);
192
- assert.match(actionsSource, /orderBy: resource\.defaultSort/);
197
+ assert.match(actionsSource, /createStandardCrudListQueryValidators\(\{ resource \}\)/);
198
+ assert.match(actionsSource, /createStandardCrudViewQueryValidators\(\)/);
199
+ assert.match(actionsSource, /const \{ workspaceSlug, recordId, \.\.\.query \} = input \|\| \{\};/);
200
+ assert.match(actionsSource, /usersService\.getDocumentById\(recordId, query,/);
193
201
  assert.match(actionsSource, /usersService\.queryDocuments/);
194
202
  assert.match(actionsSource, /usersService\.getDocumentById/);
195
203
  assert.doesNotMatch(actionsSource, /from "\.\/actionIds\.js"/);