@jskit-ai/users-web 0.1.168 → 0.1.170
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 +14 -20
- package/src/client/composables/crud/crudJsonApiTransportSupport.js +1 -1
- package/src/client/composables/support/resourceLoadStateHelpers.js +8 -29
- package/src/client/composables/useScopeRuntime.js +2 -2
- package/test/crudJsonApiTransportSupport.test.js +1 -1
- package/test/exportsContract.test.js +0 -1
- package/src/client/composables/usePaths.js +0 -120
- package/src/client/composables/useSurfaceRouteContext.js +0 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/users-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.170",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -36,25 +36,23 @@
|
|
|
36
36
|
"./client/crudHttpClient": "./src/client/composables/crud/crudHttpClientSupport.js",
|
|
37
37
|
"./client/composables/useCrudListParentTitle": "./src/client/composables/useCrudListParentTitle.js",
|
|
38
38
|
"./client/composables/useRealtimeQueryInvalidation": "./src/client/composables/useRealtimeQueryInvalidation.js",
|
|
39
|
-
"./client/composables/useSurfaceRouteContext": "./src/client/composables/useSurfaceRouteContext.js",
|
|
40
39
|
"./client/composables/useView": "./src/client/composables/records/useView.js",
|
|
41
40
|
"./client/composables/useCrudView": "./src/client/composables/records/useCrudView.js",
|
|
42
41
|
"./client/composables/useCrudViewScreen": "./src/client/composables/useCrudViewScreen.js",
|
|
43
42
|
"./client/composables/usePagedCollection": "./src/client/composables/usePagedCollection.js",
|
|
44
|
-
"./client/composables/usePaths": "./src/client/composables/usePaths.js",
|
|
45
43
|
"./client/composables/runtime/useUiFeedback": "./src/client/composables/runtime/useUiFeedback.js",
|
|
46
44
|
"./client/lib/httpClient": "./src/client/lib/httpClient.js",
|
|
47
45
|
"./client/lib/permissions": "./src/client/lib/permissions.js",
|
|
48
46
|
"./client/support/contractGuards": "./src/client/support/contractGuards.js"
|
|
49
47
|
},
|
|
50
48
|
"dependencies": {
|
|
51
|
-
"@jskit-ai/auth-web": "0.1.
|
|
52
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
53
|
-
"@jskit-ai/kernel": "0.1.
|
|
54
|
-
"@jskit-ai/realtime": "0.1.
|
|
55
|
-
"@jskit-ai/shell-web": "0.1.
|
|
56
|
-
"@jskit-ai/uploads-image-web": "0.1.
|
|
57
|
-
"@jskit-ai/users-core": "0.1.
|
|
49
|
+
"@jskit-ai/auth-web": "0.1.152",
|
|
50
|
+
"@jskit-ai/http-runtime": "0.1.150",
|
|
51
|
+
"@jskit-ai/kernel": "0.1.152",
|
|
52
|
+
"@jskit-ai/realtime": "0.1.149",
|
|
53
|
+
"@jskit-ai/shell-web": "0.1.156",
|
|
54
|
+
"@jskit-ai/uploads-image-web": "0.1.127",
|
|
55
|
+
"@jskit-ai/users-core": "0.1.165",
|
|
58
56
|
"@mdi/js": "^7.4.47"
|
|
59
57
|
},
|
|
60
58
|
"peerDependencies": {
|
|
@@ -195,10 +193,6 @@
|
|
|
195
193
|
"subpath": "./client/composables/usePagedCollection",
|
|
196
194
|
"summary": "Exports paged collection query composable."
|
|
197
195
|
},
|
|
198
|
-
{
|
|
199
|
-
"subpath": "./client/composables/usePaths",
|
|
200
|
-
"summary": "Exports surface route path resolver composable."
|
|
201
|
-
},
|
|
202
196
|
{
|
|
203
197
|
"subpath": "./client/lib/httpClient",
|
|
204
198
|
"summary": "Exports the shared users-web HTTP client with credentials and CSRF behavior."
|
|
@@ -363,12 +357,12 @@
|
|
|
363
357
|
"dependencies": {
|
|
364
358
|
"runtime": {
|
|
365
359
|
"@mdi/js": "^7.4.47",
|
|
366
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
367
|
-
"@jskit-ai/realtime": "0.1.
|
|
368
|
-
"@jskit-ai/kernel": "0.1.
|
|
369
|
-
"@jskit-ai/shell-web": "0.1.
|
|
370
|
-
"@jskit-ai/uploads-image-web": "0.1.
|
|
371
|
-
"@jskit-ai/users-core": "0.1.
|
|
360
|
+
"@jskit-ai/http-runtime": "0.1.150",
|
|
361
|
+
"@jskit-ai/realtime": "0.1.149",
|
|
362
|
+
"@jskit-ai/kernel": "0.1.152",
|
|
363
|
+
"@jskit-ai/shell-web": "0.1.156",
|
|
364
|
+
"@jskit-ai/uploads-image-web": "0.1.127",
|
|
365
|
+
"@jskit-ai/users-core": "0.1.165"
|
|
372
366
|
},
|
|
373
367
|
"dev": {}
|
|
374
368
|
},
|
|
@@ -113,7 +113,7 @@ function inferCrudJsonApiTransport(resource = null, { mode = "", operationName =
|
|
|
113
113
|
function resolveCrudJsonApiTransport(transport = null, resource = null, options = {}) {
|
|
114
114
|
if (transport != null) {
|
|
115
115
|
throw new TypeError(
|
|
116
|
-
"CRUD hooks
|
|
116
|
+
"CRUD hooks do not accept explicit transport. Derive JSON:API transport from the shared resource."
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -77,12 +77,8 @@ function normalizeRequestRecoveryMethod(value = "") {
|
|
|
77
77
|
return normalizeText(value).toUpperCase();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function isRequestRecoveryMetaDisabled(sourceJskitMeta = {}
|
|
81
|
-
return
|
|
82
|
-
sourceJskitMeta.requestRecovery === false ||
|
|
83
|
-
sourceMeta.jskitRequestRecovery === false ||
|
|
84
|
-
sourceMeta.requestRecovery === false
|
|
85
|
-
);
|
|
80
|
+
function isRequestRecoveryMetaDisabled(sourceJskitMeta = {}) {
|
|
81
|
+
return sourceJskitMeta.requestRecovery === false;
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
function hasUsableMetaValue(source = {}, key = "") {
|
|
@@ -161,37 +157,20 @@ function buildRequestRecoveryMeta(requestRecovery = null, defaults = {}) {
|
|
|
161
157
|
return Object.keys(jskit).length > 0 ? { jskit } : {};
|
|
162
158
|
}
|
|
163
159
|
|
|
164
|
-
function hasRequestRecoveryMetaValue(sourceJskitMeta = {}, sourceMeta = {}, key = "") {
|
|
165
|
-
const suffix = String(key || "").trim();
|
|
166
|
-
if (!suffix) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const jskitKey = `requestRecovery${suffix}`;
|
|
171
|
-
const legacyJskitKey = `jskitRequestRecovery${suffix}`;
|
|
172
|
-
const legacyKey = `requestRecovery${suffix}`;
|
|
173
|
-
|
|
174
|
-
return Boolean(
|
|
175
|
-
hasUsableMetaValue(sourceJskitMeta, jskitKey) ||
|
|
176
|
-
hasUsableMetaValue(sourceMeta, legacyJskitKey) ||
|
|
177
|
-
hasUsableMetaValue(sourceMeta, legacyKey)
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
160
|
function resolveRequestRecoveryDefaults(queryOptions = null, defaults = {}) {
|
|
182
161
|
const sourceOptions = normalizePlainObject(queryOptions);
|
|
183
162
|
const sourceMeta = normalizePlainObject(sourceOptions.meta);
|
|
184
163
|
const sourceJskitMeta = normalizePlainObject(sourceMeta.jskit);
|
|
185
164
|
const fallback = normalizePlainObject(defaults);
|
|
186
|
-
if (isRequestRecoveryMetaDisabled(sourceJskitMeta
|
|
165
|
+
if (isRequestRecoveryMetaDisabled(sourceJskitMeta)) {
|
|
187
166
|
return {};
|
|
188
167
|
}
|
|
189
168
|
|
|
190
|
-
const hasExplicitLabel =
|
|
191
|
-
const hasExplicitSource =
|
|
192
|
-
const hasExplicitDedupeKey =
|
|
193
|
-
const hasExplicitDedupeWindowMs =
|
|
194
|
-
const hasExplicitMethod =
|
|
169
|
+
const hasExplicitLabel = hasUsableMetaValue(sourceJskitMeta, "requestRecoveryLabel");
|
|
170
|
+
const hasExplicitSource = hasUsableMetaValue(sourceJskitMeta, "requestRecoverySource");
|
|
171
|
+
const hasExplicitDedupeKey = hasUsableMetaValue(sourceJskitMeta, "requestRecoveryDedupeKey");
|
|
172
|
+
const hasExplicitDedupeWindowMs = hasUsableMetaValue(sourceJskitMeta, "requestRecoveryDedupeWindowMs");
|
|
173
|
+
const hasExplicitMethod = hasUsableMetaValue(sourceJskitMeta, "requestRecoveryMethod");
|
|
195
174
|
|
|
196
175
|
return {
|
|
197
176
|
...fallback,
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
ROUTE_VISIBILITY_WORKSPACE
|
|
5
5
|
} from "@jskit-ai/kernel/shared/support/visibility";
|
|
6
6
|
import { useAccess } from "./useAccess.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { usePaths } from "@jskit-ai/shell-web/client/navigation/usePaths";
|
|
8
|
+
import { useSurfaceRouteContext } from "@jskit-ai/shell-web/client/navigation/useSurfaceRouteContext";
|
|
9
9
|
import { resolveSurfaceDefinitionFromPlacementContext } from "@jskit-ai/shell-web/client/placement";
|
|
10
10
|
import {
|
|
11
11
|
asPlainObject,
|
|
@@ -30,7 +30,6 @@ test("users-web exports are explicit and aligned with production/template usage"
|
|
|
30
30
|
"./client/composables/useCommand",
|
|
31
31
|
"./client/composables/useEndpointResource",
|
|
32
32
|
"./client/composables/useList",
|
|
33
|
-
"./client/composables/usePaths",
|
|
34
33
|
"./client/composables/useView",
|
|
35
34
|
"./client/composables/useCrudAddEdit",
|
|
36
35
|
"./client/composables/useCrudAddEditScreen",
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { computed, unref } from "vue";
|
|
2
|
-
import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
3
|
-
import { resolveScopedApiBasePath } from "@jskit-ai/kernel/shared/surface";
|
|
4
|
-
import { resolveSurfaceDefinitionFromPlacementContext } from "@jskit-ai/shell-web/client/placement";
|
|
5
|
-
import { useShellLinkResolver } from "@jskit-ai/shell-web/client/navigation/linkResolver";
|
|
6
|
-
import { useSurfaceRouteContext } from "./useSurfaceRouteContext.js";
|
|
7
|
-
|
|
8
|
-
function normalizePathSuffix(value = "") {
|
|
9
|
-
const raw = normalizeText(unref(value));
|
|
10
|
-
if (!raw) {
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return raw.startsWith("/") ? raw : `/${raw}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function resolveSurfaceId(value, fallback = "") {
|
|
18
|
-
const normalized = normalizeText(unref(value)).toLowerCase();
|
|
19
|
-
if (normalized && normalized !== "*") {
|
|
20
|
-
return normalized;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const normalizedFallback = normalizeText(unref(fallback)).toLowerCase();
|
|
24
|
-
if (normalizedFallback && normalizedFallback !== "*") {
|
|
25
|
-
return normalizedFallback;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function resolveDefaultSurfaceIdFromPlacementContext(placementContext = null) {
|
|
32
|
-
return resolveSurfaceId(placementContext?.surfaceConfig?.defaultSurfaceId, "");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function normalizeRouteParams(params = null) {
|
|
36
|
-
if (!params || typeof params !== "object" || Array.isArray(params)) {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const output = {};
|
|
41
|
-
for (const [rawKey, rawValue] of Object.entries(params)) {
|
|
42
|
-
const key = normalizeText(rawKey);
|
|
43
|
-
if (!key) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const value = Array.isArray(rawValue) ? rawValue[0] : rawValue;
|
|
48
|
-
const normalizedValue = normalizeText(value);
|
|
49
|
-
if (!normalizedValue) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
output[key] = normalizedValue;
|
|
53
|
-
}
|
|
54
|
-
return output;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function resolveRouteParams(baseParams = {}, overrideParams = null) {
|
|
58
|
-
return {
|
|
59
|
-
...normalizeRouteParams(baseParams),
|
|
60
|
-
...normalizeRouteParams(overrideParams)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function usePaths({ routeContext: sourceRouteContext = null } = {}) {
|
|
65
|
-
const routeContext = sourceRouteContext || useSurfaceRouteContext();
|
|
66
|
-
const shellLinkResolver = useShellLinkResolver();
|
|
67
|
-
const routeParams = computed(() => normalizeRouteParams(routeContext.route?.params));
|
|
68
|
-
|
|
69
|
-
function page(relativePath = "/", options = {}) {
|
|
70
|
-
const source = options && typeof options === "object" && !Array.isArray(options) ? options : {};
|
|
71
|
-
const surface =
|
|
72
|
-
resolveSurfaceId(source.surface, routeContext.currentSurfaceId.value) ||
|
|
73
|
-
resolveDefaultSurfaceIdFromPlacementContext(routeContext.placementContext.value);
|
|
74
|
-
if (!surface) {
|
|
75
|
-
return "";
|
|
76
|
-
}
|
|
77
|
-
return shellLinkResolver.resolve(relativePath, {
|
|
78
|
-
surface,
|
|
79
|
-
explicitTo: source.explicitTo,
|
|
80
|
-
surfaceRelativePath: source.surfaceRelativePath,
|
|
81
|
-
params: resolveRouteParams(routeParams.value, source.params),
|
|
82
|
-
strictParams: source.strictParams !== false
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function api(relativePath = "", options = {}) {
|
|
87
|
-
const source = options && typeof options === "object" && !Array.isArray(options) ? options : {};
|
|
88
|
-
const surface =
|
|
89
|
-
resolveSurfaceId(source.surface, routeContext.currentSurfaceId.value) ||
|
|
90
|
-
resolveDefaultSurfaceIdFromPlacementContext(routeContext.placementContext.value);
|
|
91
|
-
const suffix = normalizePathSuffix(relativePath);
|
|
92
|
-
|
|
93
|
-
if (!suffix) {
|
|
94
|
-
throw new TypeError("usePaths().api(relativePath) requires a non-empty relativePath.");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const routeBase = resolveSurfaceDefinitionFromPlacementContext(
|
|
98
|
-
routeContext.placementContext.value,
|
|
99
|
-
surface
|
|
100
|
-
)?.routeBase || "/";
|
|
101
|
-
|
|
102
|
-
return resolveScopedApiBasePath({
|
|
103
|
-
routeBase,
|
|
104
|
-
relativePath: suffix,
|
|
105
|
-
params: resolveRouteParams(routeParams.value, source.params),
|
|
106
|
-
strictParams: source.strictParams !== false
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return Object.freeze({
|
|
111
|
-
route: routeContext.route,
|
|
112
|
-
placementContext: routeContext.placementContext,
|
|
113
|
-
currentSurfaceId: routeContext.currentSurfaceId,
|
|
114
|
-
routeParams,
|
|
115
|
-
page,
|
|
116
|
-
api
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export { usePaths };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import { useRoute } from "vue-router";
|
|
3
|
-
import {
|
|
4
|
-
resolveRuntimePathname,
|
|
5
|
-
resolveSurfaceIdFromPlacementPathname,
|
|
6
|
-
useWebPlacementContext
|
|
7
|
-
} from "@jskit-ai/shell-web/client/placement";
|
|
8
|
-
|
|
9
|
-
function useSurfaceRouteContext() {
|
|
10
|
-
const route = useRoute();
|
|
11
|
-
const { context: placementContext, mergeContext: mergePlacementContext } = useWebPlacementContext();
|
|
12
|
-
const routePath = computed(() => resolveRuntimePathname(route?.path));
|
|
13
|
-
|
|
14
|
-
const currentSurfaceId = computed(() => resolveSurfaceIdFromPlacementPathname(placementContext.value, routePath.value));
|
|
15
|
-
|
|
16
|
-
return Object.freeze({
|
|
17
|
-
route,
|
|
18
|
-
routePath,
|
|
19
|
-
placementContext,
|
|
20
|
-
mergePlacementContext,
|
|
21
|
-
currentSurfaceId
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { useSurfaceRouteContext };
|