@jskit-ai/kernel 0.1.83 → 0.1.85

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.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/kernel",
3
- "version": "0.1.83",
3
+ "version": "0.1.85",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "json-rest-schema": "1.x.x"
@@ -1,4 +1,5 @@
1
1
  import { normalizeText } from "./normalize.js";
2
+ import { toCamelCase } from "./stringCase.js";
2
3
  import { normalizePathname } from "../surface/paths.js";
3
4
  import {
4
5
  buildCrudFieldContractMap,
@@ -34,6 +35,15 @@ function resolveCrudLookupApiPathFromNamespace(value = "") {
34
35
  return `/${normalizedNamespace}`;
35
36
  }
36
37
 
38
+ function resolveCrudResourceScopeName(value = "") {
39
+ const normalizedNamespace = normalizeCrudLookupNamespace(value);
40
+ if (!normalizedNamespace) {
41
+ return "";
42
+ }
43
+
44
+ return toCamelCase(normalizedNamespace.replace(/\//g, "-"));
45
+ }
46
+
37
47
  function normalizeCrudLookupContainerKey(
38
48
  value,
39
49
  {
@@ -170,6 +180,7 @@ export {
170
180
  normalizeCrudLookupApiPath,
171
181
  normalizeCrudLookupNamespace,
172
182
  resolveCrudLookupApiPathFromNamespace,
183
+ resolveCrudResourceScopeName,
173
184
  normalizeCrudLookupContainerKey,
174
185
  resolveCrudLookupContainerKey,
175
186
  resolveCrudLookupFieldKeys,
@@ -6,6 +6,7 @@ import {
6
6
  normalizeCrudLookupApiPath,
7
7
  normalizeCrudLookupNamespace,
8
8
  resolveCrudLookupApiPathFromNamespace,
9
+ resolveCrudResourceScopeName,
9
10
  normalizeCrudLookupContainerKey,
10
11
  resolveCrudLookupContainerKey,
11
12
  resolveCrudParentFilterKeys,
@@ -60,6 +61,13 @@ test("resolveCrudLookupApiPathFromNamespace maps namespace to api path", () => {
60
61
  assert.equal(resolveCrudLookupApiPathFromNamespace(""), "");
61
62
  });
62
63
 
64
+ test("resolveCrudResourceScopeName maps namespace and api path values to json-rest-api scope names", () => {
65
+ assert.equal(resolveCrudResourceScopeName("pets"), "pets");
66
+ assert.equal(resolveCrudResourceScopeName("/customer-categories"), "customerCategories");
67
+ assert.equal(resolveCrudResourceScopeName("/workspace/pets"), "workspacePets");
68
+ assert.equal(resolveCrudResourceScopeName(""), "");
69
+ });
70
+
63
71
  test("normalizeCrudLookupContainerKey defaults to canonical value", () => {
64
72
  assert.equal(normalizeCrudLookupContainerKey(undefined), DEFAULT_CRUD_LOOKUP_CONTAINER_KEY);
65
73
  assert.equal(normalizeCrudLookupContainerKey(""), DEFAULT_CRUD_LOOKUP_CONTAINER_KEY);