gomtm 0.0.299 → 0.0.301
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/dist/esm/curd/listview/ListViewProvider.d.ts +0 -1
- package/dist/esm/curd/listview/ListViewProvider.js +1 -26
- package/dist/esm/curd/listview/list-store.js +2 -6
- package/dist/esm/gomtmQuery.js +26 -35
- package/dist/esm/mtmFetcher.d.ts +1 -0
- package/dist/esm/mtmFetcher.js +5 -4
- package/dist/esm/providers/AuthProvider.js +2 -2
- package/dist/esm/providers/GomtmAppSS.js +4 -2
- package/dist/esm/store/mtapp-store.d.ts +1 -0
- package/dist/esm/store/mtapp-store.js +10 -16
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -2,5 +2,4 @@
|
|
|
2
2
|
export declare const LzListViewLayoutDemo: import("react").LazyExoticComponent<typeof import("./listview-layouts/listviewlayout-demo").default>;
|
|
3
3
|
export declare const LzListViewLayoutDefault: import("react").LazyExoticComponent<typeof import("./listview-layouts/default").default>;
|
|
4
4
|
export declare function CommonListView(): import("react").JSX.Element | null;
|
|
5
|
-
export declare function CommonListViewV2(): import("react").JSX.Element;
|
|
6
5
|
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
@@ -26,7 +26,7 @@ import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
|
26
26
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
27
27
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
28
28
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
29
|
-
import { Suspense, lazy,
|
|
29
|
+
import { Suspense, lazy, useMemo, useState } from "react";
|
|
30
30
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
31
31
|
import { MtmErrorView } from "../../components/MtmErrorView";
|
|
32
32
|
import { HOTKEY_Listview_Switchlayout } from "../../consts";
|
|
@@ -80,28 +80,6 @@ function CommonListView() {
|
|
|
80
80
|
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) })
|
|
81
81
|
] });
|
|
82
82
|
}
|
|
83
|
-
function CommonListViewV2() {
|
|
84
|
-
const useListData = useListview((x) => x.loadListData);
|
|
85
|
-
const bbb = use(useListData());
|
|
86
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative w-full bg-slate-200 p-2", children: [
|
|
87
|
-
/* @__PURE__ */ jsxs(
|
|
88
|
-
"div",
|
|
89
|
-
{
|
|
90
|
-
className: cn(
|
|
91
|
-
"w-full"
|
|
92
|
-
// 滚动设置
|
|
93
|
-
// " max-h-[700px] overflow-y-auto"
|
|
94
|
-
),
|
|
95
|
-
children: [
|
|
96
|
-
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
97
|
-
}, children: "fetch next" }),
|
|
98
|
-
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(bbb, null, 2) })
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
),
|
|
102
|
-
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1" })
|
|
103
|
-
] });
|
|
104
|
-
}
|
|
105
83
|
const PanelRemove = () => {
|
|
106
84
|
const svc = useListview((x) => x.svc);
|
|
107
85
|
const openRemove = useListview((x) => x.openRemove);
|
|
@@ -124,8 +102,6 @@ const PanelCreate = () => {
|
|
|
124
102
|
const openCreate = useListview((x) => x.openCreate);
|
|
125
103
|
const setOpenCreate = useListview((x) => x.setOpenCreate);
|
|
126
104
|
const methodDelete = useListview((x) => x.methodDelete);
|
|
127
|
-
const mutation = useGomtmMutation(svc, methodDelete);
|
|
128
|
-
const activateItem = useListview((x) => x.activateItem);
|
|
129
105
|
return /* @__PURE__ */ jsx(Dialog, { open: openCreate, onOpenChange: setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
130
106
|
/* @__PURE__ */ jsx(DialogTitle, { children: "TODO create item Dlg" }),
|
|
131
107
|
/* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
|
|
@@ -188,7 +164,6 @@ const ListViewLayoutSwitch = () => {
|
|
|
188
164
|
};
|
|
189
165
|
export {
|
|
190
166
|
CommonListView,
|
|
191
|
-
CommonListViewV2,
|
|
192
167
|
ListViewActions,
|
|
193
168
|
LzListViewLayoutDefault,
|
|
194
169
|
LzListViewLayoutDemo
|
|
@@ -50,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
50
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
|
-
import { jsx
|
|
53
|
+
import { jsx } from "react/jsx-runtime";
|
|
54
54
|
import { setCookie } from "mtxlib/clientlib";
|
|
55
55
|
import { createContext, useContext, useRef } from "react";
|
|
56
56
|
import { useStore } from "zustand";
|
|
@@ -110,11 +110,7 @@ const ListViewStoreProvider = (props) => {
|
|
|
110
110
|
const ListView = (props) => {
|
|
111
111
|
const backendUrl = useGomtm((x) => x.backendUrl);
|
|
112
112
|
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
-
"backendUrl: ",
|
|
115
|
-
backendUrl,
|
|
116
|
-
children
|
|
117
|
-
] }));
|
|
113
|
+
return /* @__PURE__ */ jsx(ListViewStoreProvider, __spreadProps(__spreadValues({}, props), { backendUrl: backendUrl || "", children }));
|
|
118
114
|
};
|
|
119
115
|
function useListview(selector) {
|
|
120
116
|
const store = useContext(listViewContext);
|
package/dist/esm/gomtmQuery.js
CHANGED
|
@@ -3,27 +3,28 @@ import { useMutation, useQuery, useSuspenseInfiniteQuery, useSuspenseQuery } fro
|
|
|
3
3
|
import { MTM_API_PREFIX } from "./consts";
|
|
4
4
|
import { createInfiniteQueryKey, createQueryKey, goMtmQueryFn } from "./mtmFetcher";
|
|
5
5
|
import { useGomtm } from "./store/mtapp-store";
|
|
6
|
-
const
|
|
7
|
-
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
6
|
+
const useGmtmQjeryFn = () => {
|
|
8
7
|
const backendUrl = useGomtm((x) => x.backendUrl);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
9
|
+
const token = useGomtm((x) => x.token);
|
|
10
|
+
return (svc, method, input) => {
|
|
11
|
+
return goMtmQueryFn({
|
|
12
12
|
svc,
|
|
13
13
|
method,
|
|
14
14
|
input,
|
|
15
15
|
options: {
|
|
16
16
|
url: new URL(MTM_API_PREFIX, backendUrl).toString(),
|
|
17
|
-
token
|
|
17
|
+
token,
|
|
18
|
+
cookieStr
|
|
18
19
|
}
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
return query;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
|
-
const
|
|
23
|
+
const useGomtmQuery = (svc, method, input) => {
|
|
24
24
|
const backendUrl = useGomtm((x) => x.backendUrl);
|
|
25
25
|
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
26
|
-
const
|
|
26
|
+
const token = useGomtm((x) => x.token);
|
|
27
|
+
const query = useQuery({
|
|
27
28
|
queryKey: createQueryKey(svc, method, input),
|
|
28
29
|
queryFn: (k) => goMtmQueryFn({
|
|
29
30
|
svc,
|
|
@@ -31,27 +32,26 @@ const useGomtmSuspenseQuery = (svc, method, input) => {
|
|
|
31
32
|
input,
|
|
32
33
|
options: {
|
|
33
34
|
url: new URL(MTM_API_PREFIX, backendUrl).toString(),
|
|
34
|
-
token
|
|
35
|
+
token,
|
|
36
|
+
cookieStr
|
|
35
37
|
}
|
|
36
38
|
})
|
|
37
39
|
});
|
|
38
40
|
return query;
|
|
39
41
|
};
|
|
42
|
+
const useGomtmSuspenseQuery = (svc, method, input) => {
|
|
43
|
+
const fn = useGmtmQjeryFn();
|
|
44
|
+
const query = useSuspenseQuery({
|
|
45
|
+
queryKey: createQueryKey(svc, method, input),
|
|
46
|
+
queryFn: (k) => fn(svc, method, input)
|
|
47
|
+
});
|
|
48
|
+
return query;
|
|
49
|
+
};
|
|
40
50
|
const useGomtmSuspenseInfiniteQuery = (svc, method, input) => {
|
|
41
|
-
const
|
|
42
|
-
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
43
|
-
console.log("useGomtmSuspenseInfiniteQuery, backendUrl", backendUrl);
|
|
51
|
+
const fn = useGmtmQjeryFn();
|
|
44
52
|
const query = useSuspenseInfiniteQuery({
|
|
45
53
|
queryKey: createInfiniteQueryKey(svc, method, input),
|
|
46
|
-
queryFn: (k) =>
|
|
47
|
-
svc,
|
|
48
|
-
method,
|
|
49
|
-
input,
|
|
50
|
-
options: {
|
|
51
|
-
url: new URL(MTM_API_PREFIX, backendUrl).toString(),
|
|
52
|
-
token: cookieStr
|
|
53
|
-
}
|
|
54
|
-
}),
|
|
54
|
+
queryFn: (k) => fn(svc, method, input),
|
|
55
55
|
initialPageParam: input,
|
|
56
56
|
getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => {
|
|
57
57
|
return lastPage;
|
|
@@ -60,18 +60,9 @@ const useGomtmSuspenseInfiniteQuery = (svc, method, input) => {
|
|
|
60
60
|
return query;
|
|
61
61
|
};
|
|
62
62
|
const useGomtmMutation = (svc, method) => {
|
|
63
|
-
const
|
|
64
|
-
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
63
|
+
const fn = useGmtmQjeryFn();
|
|
65
64
|
return useMutation({
|
|
66
|
-
mutationFn: (input) =>
|
|
67
|
-
svc,
|
|
68
|
-
method,
|
|
69
|
-
input,
|
|
70
|
-
options: {
|
|
71
|
-
url: new URL(MTM_API_PREFIX, backendUrl).toString(),
|
|
72
|
-
token: cookieStr
|
|
73
|
-
}
|
|
74
|
-
})
|
|
65
|
+
mutationFn: (input) => fn(svc, method)
|
|
75
66
|
});
|
|
76
67
|
};
|
|
77
68
|
export {
|
package/dist/esm/mtmFetcher.d.ts
CHANGED
package/dist/esm/mtmFetcher.js
CHANGED
|
@@ -105,18 +105,19 @@ function createMtmServiceClientByName(svcName, url, token) {
|
|
|
105
105
|
throw new Error(`unknown svcType ${svcName}`);
|
|
106
106
|
}
|
|
107
107
|
const baseUrl = url || gomtmApiUrl();
|
|
108
|
-
console.log("createMtmServiceClientByName, baseUrl", baseUrl);
|
|
109
108
|
return createPromiseClient(
|
|
110
109
|
svcType,
|
|
111
110
|
createConnectTransport({
|
|
112
111
|
baseUrl,
|
|
113
112
|
fetch: gomtmFetcher({
|
|
114
|
-
cookieStr: token
|
|
113
|
+
cookieStr: token,
|
|
114
|
+
token
|
|
115
115
|
})
|
|
116
116
|
})
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
const gomtmFetcher = (initGlobal) => {
|
|
120
|
+
const token = initGlobal == null ? void 0 : initGlobal.token;
|
|
120
121
|
return (input, init) => __async(void 0, null, function* () {
|
|
121
122
|
if (init) {
|
|
122
123
|
delete init.mode;
|
|
@@ -137,10 +138,10 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
137
138
|
cookieStr1 = (yield import("next/headers")).headers().get("cookie") || "";
|
|
138
139
|
}
|
|
139
140
|
init = __spreadValues(__spreadValues({}, init), {
|
|
140
|
-
headers: __spreadValues({
|
|
141
|
+
headers: __spreadValues(__spreadValues({
|
|
141
142
|
// ...init.headers,
|
|
142
143
|
"Content-Type": "application/json"
|
|
143
|
-
}, cookieStr1 && { "Cookie": cookieStr1 })
|
|
144
|
+
}, cookieStr1 && { "Cookie": cookieStr1 }), token && { "Authorization": "Bearer " + token })
|
|
144
145
|
});
|
|
145
146
|
let fetcher = fetch;
|
|
146
147
|
req.enableCache = true;
|
|
@@ -20,9 +20,9 @@ function isRoleMatch(currentRoles, allowRoles) {
|
|
|
20
20
|
}
|
|
21
21
|
function useAuth() {
|
|
22
22
|
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
23
|
-
|
|
23
|
+
const token = useGomtm((x) => x.token);
|
|
24
|
+
console.log("\uFF08useAuth\uFF09cookieStr-----------", { token, cookieStr });
|
|
24
25
|
const userInfoQuery = useGomtmSuspenseQuery(userinfo.service.typeName, userinfo.name);
|
|
25
|
-
console.log("userInfoQuery.data", userInfoQuery.data);
|
|
26
26
|
const userId = useMemo(() => {
|
|
27
27
|
var _a;
|
|
28
28
|
return (_a = userInfoQuery.data.userInfo) == null ? void 0 : _a.ID;
|
|
@@ -39,21 +39,23 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
};
|
|
40
40
|
import { jsx } from "react/jsx-runtime";
|
|
41
41
|
import { cookies, headers } from "next/headers";
|
|
42
|
-
import { CookieConfigState } from "../consts";
|
|
42
|
+
import { CookieConfigState, MtM_TOKEN_NAME } from "../consts";
|
|
43
43
|
import { ssrGetBackendUrl } from "../mtmFetcher";
|
|
44
44
|
import { GoMtmAppProvider } from "../store/mtapp-store";
|
|
45
45
|
function GomtmAppSS(props) {
|
|
46
46
|
return __async(this, null, function* () {
|
|
47
|
-
var _a;
|
|
47
|
+
var _a, _b;
|
|
48
48
|
const { children } = props;
|
|
49
49
|
const backend = ssrGetBackendUrl();
|
|
50
50
|
const cookiesStr = headers().get("Cookie");
|
|
51
51
|
const configState = JSON.parse(((_a = cookies().get(CookieConfigState)) == null ? void 0 : _a.value) || "{}");
|
|
52
52
|
const cState = configState["state"];
|
|
53
|
+
const token = (_b = cookies().get(MtM_TOKEN_NAME)) == null ? void 0 : _b.value;
|
|
53
54
|
return /* @__PURE__ */ jsx(
|
|
54
55
|
GoMtmAppProvider,
|
|
55
56
|
__spreadProps(__spreadValues({}, cState), {
|
|
56
57
|
cookieStr: cookiesStr || "",
|
|
58
|
+
token,
|
|
57
59
|
backendUrl: (cState == null ? void 0 : cState.backendUrl) || backend,
|
|
58
60
|
children
|
|
59
61
|
})
|
|
@@ -48,7 +48,6 @@ import { customCookieStorage } from "./customStorage";
|
|
|
48
48
|
const createGomtmAppStore = (initProps) => {
|
|
49
49
|
const DEFAULT_PROPS = {
|
|
50
50
|
debug: false,
|
|
51
|
-
// configState: {},
|
|
52
51
|
params: {},
|
|
53
52
|
counter: 0
|
|
54
53
|
};
|
|
@@ -88,19 +87,13 @@ const GoMtmAppProvider = (props) => {
|
|
|
88
87
|
if (!storeRef.current) {
|
|
89
88
|
storeRef.current = createGomtmAppStore(props);
|
|
90
89
|
}
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
/* @__PURE__ */ jsxs(
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
return /* @__PURE__ */ jsx(BearContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsxs(MtConnectProvider, { children: [
|
|
91
|
+
/* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
92
|
+
/* @__PURE__ */ jsx(GoMtmDebug, {}),
|
|
93
|
+
children
|
|
95
94
|
] }),
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
|
|
98
|
-
/* @__PURE__ */ jsx(GoMtmDebug, {}),
|
|
99
|
-
children
|
|
100
|
-
] }),
|
|
101
|
-
/* @__PURE__ */ jsx(Setup, {})
|
|
102
|
-
] })
|
|
103
|
-
] });
|
|
95
|
+
/* @__PURE__ */ jsx(Setup, {})
|
|
96
|
+
] }) });
|
|
104
97
|
};
|
|
105
98
|
function useGomtm(selector) {
|
|
106
99
|
const store = useContext(BearContext);
|
|
@@ -121,13 +114,14 @@ const MtConnectProvider = (props) => {
|
|
|
121
114
|
const { children } = props;
|
|
122
115
|
const backendUrl = useGomtm((x) => x.backendUrl);
|
|
123
116
|
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
117
|
+
const token = useGomtm((x) => x.token);
|
|
124
118
|
const transport = useMemo(() => {
|
|
125
119
|
const baseApiUrl = new URL(MTM_API_PREFIX, backendUrl || "").toString();
|
|
126
|
-
console.log("MtConnectProvider, baseApiUrl:", baseApiUrl);
|
|
127
120
|
return createConnectTransport({
|
|
128
121
|
baseUrl: baseApiUrl,
|
|
129
122
|
fetch: gomtmFetcher({
|
|
130
|
-
cookieStr
|
|
123
|
+
cookieStr,
|
|
124
|
+
token
|
|
131
125
|
}),
|
|
132
126
|
jsonOptions: {
|
|
133
127
|
typeRegistry: anypbTypeReg
|
|
@@ -135,7 +129,7 @@ const MtConnectProvider = (props) => {
|
|
|
135
129
|
useHttpGet: true,
|
|
136
130
|
useBinaryFormat: false
|
|
137
131
|
});
|
|
138
|
-
}, [backendUrl, cookieStr]);
|
|
132
|
+
}, [backendUrl, cookieStr, token]);
|
|
139
133
|
return /* @__PURE__ */ jsx(TransportProvider, { transport, children });
|
|
140
134
|
};
|
|
141
135
|
const DebugCounter = () => {
|