@jskit-ai/users-core 0.1.20 → 0.1.21
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
CHANGED
|
@@ -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.
|
|
4
|
+
version: "0.1.21",
|
|
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",
|
|
@@ -206,7 +206,7 @@ export default Object.freeze({
|
|
|
206
206
|
"@jskit-ai/auth-core": "0.1.15",
|
|
207
207
|
"@jskit-ai/database-runtime": "0.1.16",
|
|
208
208
|
"@jskit-ai/http-runtime": "0.1.15",
|
|
209
|
-
"@jskit-ai/kernel": "0.1.
|
|
209
|
+
"@jskit-ai/kernel": "0.1.16",
|
|
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.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@jskit-ai/auth-core": "0.1.15",
|
|
28
28
|
"@jskit-ai/database-runtime": "0.1.16",
|
|
29
29
|
"@jskit-ai/http-runtime": "0.1.15",
|
|
30
|
-
"@jskit-ai/kernel": "0.1.
|
|
30
|
+
"@jskit-ai/kernel": "0.1.16",
|
|
31
31
|
"@fastify/multipart": "^9.4.0",
|
|
32
32
|
"@fastify/type-provider-typebox": "^6.1.0",
|
|
33
33
|
"typebox": "^1.0.81"
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { normalizePathname } from "@jskit-ai/kernel/shared/surface/paths";
|
|
2
|
+
import { splitPathQueryAndHash } from "@jskit-ai/kernel/shared/support";
|
|
2
3
|
|
|
3
4
|
const USERS_PUBLIC_API_BASE_PATH = "/api";
|
|
4
5
|
const USERS_WORKSPACE_API_BASE_PATH = "/api/w/:workspaceSlug/workspace";
|
|
5
6
|
|
|
6
7
|
function normalizeApiRelativePath(relativePath = "/") {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const { pathname, queryString, hash } = splitPathQueryAndHash(relativePath);
|
|
9
|
+
const normalizedPath = normalizePathname(pathname || "/") || "/";
|
|
10
|
+
const normalizedQueryString = String(queryString || "").trim().replace(/^\?+/, "");
|
|
11
|
+
const normalizedHash = String(hash || "").trim();
|
|
12
|
+
const querySuffix = normalizedQueryString ? `?${normalizedQueryString}` : "";
|
|
13
|
+
return `${normalizedPath}${querySuffix}${normalizedHash}`;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
function normalizeSurfaceWorkspaceRequirement(value = false) {
|
|
@@ -22,6 +27,10 @@ function resolveApiBasePath({ surfaceRequiresWorkspace = false, relativePath = "
|
|
|
22
27
|
return basePath;
|
|
23
28
|
}
|
|
24
29
|
|
|
30
|
+
if (normalizedRelativePath.startsWith("/?") || normalizedRelativePath.startsWith("/#")) {
|
|
31
|
+
return `${basePath}${normalizedRelativePath.slice(1)}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
return `${basePath}${normalizedRelativePath}`;
|
|
26
35
|
}
|
|
27
36
|
|
|
@@ -29,3 +29,21 @@ test("resolveApiBasePath resolves workspace and non-workspace API base paths", (
|
|
|
29
29
|
"/api/customers"
|
|
30
30
|
);
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
test("resolveApiBasePath preserves query strings and hash fragments", () => {
|
|
34
|
+
assert.equal(
|
|
35
|
+
resolveApiBasePath({
|
|
36
|
+
surfaceRequiresWorkspace: true,
|
|
37
|
+
relativePath: "/customers?search=buddy#top"
|
|
38
|
+
}),
|
|
39
|
+
"/api/w/:workspaceSlug/workspace/customers?search=buddy#top"
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
assert.equal(
|
|
43
|
+
resolveApiBasePath({
|
|
44
|
+
surfaceRequiresWorkspace: false,
|
|
45
|
+
relativePath: "/?cursor=2"
|
|
46
|
+
}),
|
|
47
|
+
"/api?cursor=2"
|
|
48
|
+
);
|
|
49
|
+
});
|