gomtm 0.0.290 → 0.0.292

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.
Files changed (42) hide show
  1. package/dist/esm/components/devtools/GoMtmDebug.d.ts +1 -1
  2. package/dist/esm/components/devtools/GoMtmDebug.js +12 -3
  3. package/dist/esm/consts.d.ts +3 -10
  4. package/dist/esm/consts.js +7 -12
  5. package/dist/esm/curd/list-item/ListLayout.d.ts +1 -1
  6. package/dist/esm/curd/listview/ListViewProvider.d.ts +2 -2
  7. package/dist/esm/curd/listview/ListViewProvider.js +25 -3
  8. package/dist/esm/curd/listview/list-store.d.ts +7 -10
  9. package/dist/esm/curd/listview/list-store.js +45 -2
  10. package/dist/esm/gomtmQuery.js +23 -7
  11. package/dist/esm/ly/LayoutBase.js +2 -2
  12. package/dist/esm/ly/UserAvatorMenus.js +1 -0
  13. package/dist/esm/ly/front-layout/PageSearchCmd.js +17 -20
  14. package/dist/esm/mtmFetcher.d.ts +3 -1
  15. package/dist/esm/mtmFetcher.js +12 -6
  16. package/dist/esm/providers/AuthProvider.d.ts +1 -4
  17. package/dist/esm/providers/AuthProvider.js +12 -8
  18. package/dist/esm/providers/GomtmAppSS.js +28 -21
  19. package/dist/esm/store/GomtmAppSetting.d.ts +2 -0
  20. package/dist/esm/store/GomtmAppSetting.js +18 -0
  21. package/dist/esm/store/customStorage.d.ts +2 -0
  22. package/dist/esm/store/customStorage.js +35 -0
  23. package/dist/esm/store/mtapp-store.d.ts +24 -9
  24. package/dist/esm/store/mtapp-store.js +50 -14
  25. package/dist/esm/store/useStore.d.ts +2 -0
  26. package/dist/esm/store/useStore.js +13 -0
  27. package/dist/tsconfig.type.tsbuildinfo +1 -1
  28. package/package.json +3 -3
  29. package/dist/esm/curd/CurdDetailProvider.d.ts +0 -0
  30. package/dist/esm/curd/CurdDetailProvider.js +0 -0
  31. package/dist/esm/providers/ConfigStateProvider.d.ts +0 -0
  32. package/dist/esm/providers/ConfigStateProvider.js +0 -0
  33. package/dist/esm/providers/ListViewProvider.d.ts +0 -12
  34. package/dist/esm/providers/ListViewProvider.js +0 -47
  35. package/dist/esm/providers/counter-store-provider.d.ts +0 -9
  36. package/dist/esm/providers/counter-store-provider.js +0 -32
  37. package/dist/esm/store/config-store.d.ts +0 -0
  38. package/dist/esm/store/config-store.js +0 -0
  39. package/dist/esm/store/counter-store.d.ts +0 -11
  40. package/dist/esm/store/counter-store.js +0 -37
  41. package/dist/esm/store/list-store.d.ts +0 -25
  42. package/dist/esm/store/list-store.js +0 -97
@@ -1,2 +1,2 @@
1
1
  /// <reference types="react" />
2
- export declare const GoMtmDebug: () => import("react").JSX.Element;
2
+ export declare const GoMtmDebug: () => import("react").JSX.Element | null;
@@ -5,10 +5,15 @@ import { CommandDialog, CommandEmpty, CommandInput, CommandList, CommandSeparato
5
5
  import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
6
6
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
7
7
  import { useState } from "react";
8
- import { useGomtm } from "../../store/mtapp-store";
8
+ import { GomtmAppSetting } from "../../store/GomtmAppSetting";
9
+ import { DebugCounter, useGomtm } from "../../store/mtapp-store";
9
10
  const GoMtmDebug = () => {
10
11
  const [open, setOpen] = useState(false);
11
- return /* @__PURE__ */ jsxs("div", { className: "fixed bottom-12 right-2 bg-red-300", children: [
12
+ const debug = useGomtm((x) => x.debug);
13
+ if (!debug) {
14
+ return null;
15
+ }
16
+ return /* @__PURE__ */ jsxs("div", { className: "fixed bottom-24 right-8 z-20 bg-red-300", children: [
12
17
  /* @__PURE__ */ jsx(MtButton, { onClick: () => {
13
18
  setOpen(true);
14
19
  }, children: /* @__PURE__ */ jsx(Icons.bug, {}) }),
@@ -18,7 +23,11 @@ const GoMtmDebug = () => {
18
23
  } }),
19
24
  /* @__PURE__ */ jsxs(CommandList, { children: [
20
25
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." }),
21
- /* @__PURE__ */ jsx("div", { className: "flex gap-2 bg-slate-100 p-2", children: /* @__PURE__ */ jsx(DebugAppMainStateDlg, {}) }),
26
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2 bg-slate-100 p-2", children: [
27
+ /* @__PURE__ */ jsx(DebugAppMainStateDlg, {}),
28
+ /* @__PURE__ */ jsx(GomtmAppSetting, {}),
29
+ /* @__PURE__ */ jsx(DebugCounter, {})
30
+ ] }),
22
31
  /* @__PURE__ */ jsx(CommandSeparator, {})
23
32
  ] })
24
33
  ] })
@@ -30,13 +30,6 @@ export declare const HOTKEY_Listview_Switchlayout = "alt+m";
30
30
  export declare const HOTKEY_ListViewCMDK = "alt+c";
31
31
  export declare const CONST_cookieListViewLayout = "listViewLayout";
32
32
  export declare const CONST_debounce_INPUT = 300;
33
- export declare const gomtmAppConfig: {
34
- cookieBackendUrl: string;
35
- CookieLayout: string;
36
- CookieConfigState: string;
37
- };
38
- export declare const getGomtmConfig: () => {
39
- cookieBackendUrl: string;
40
- CookieLayout: string;
41
- CookieConfigState: string;
42
- };
33
+ export declare const CookieConfigState = "_config";
34
+ export declare const CookieLayout = "layout";
35
+ export declare const cookieBackendUrl = "backendUrl";
@@ -30,15 +30,9 @@ const HOTKEY_Listview_Switchlayout = "alt+m";
30
30
  const HOTKEY_ListViewCMDK = "alt+c";
31
31
  const CONST_cookieListViewLayout = "listViewLayout";
32
32
  const CONST_debounce_INPUT = 300;
33
- const gomtmAppConfig = {
34
- cookieBackendUrl: "backendUrl",
35
- // cookieListViewLayout: "listViewLayout",
36
- CookieLayout: "layout",
37
- CookieConfigState: "_config"
38
- };
39
- const getGomtmConfig = () => {
40
- return gomtmAppConfig;
41
- };
33
+ const CookieConfigState = "_config";
34
+ const CookieLayout = "layout";
35
+ const cookieBackendUrl = "backendUrl";
42
36
  export {
43
37
  ADMIN_ROLE,
44
38
  ActionCreate,
@@ -49,6 +43,8 @@ export {
49
43
  CONST_cookieListViewLayout,
50
44
  CONST_debounce_INPUT,
51
45
  COOKIE_MTM_SITE_ID,
46
+ CookieConfigState,
47
+ CookieLayout,
52
48
  Cookie_Site_Host,
53
49
  DEFAULT_revalidate_SECONDS,
54
50
  ExtKey_Hostname,
@@ -71,7 +67,6 @@ export {
71
67
  MTM_SITE_HOSTNAME,
72
68
  MtM_TOKEN_NAME,
73
69
  TRPC_API_PREFIX,
74
- fetchMaxRetry,
75
- getGomtmConfig,
76
- gomtmAppConfig
70
+ cookieBackendUrl,
71
+ fetchMaxRetry
77
72
  };
@@ -2,4 +2,4 @@ import { PropsWithChildren } from "react";
2
2
  import { ListViewLayout } from "../../gomtmpb/mtm/sppb/mtm_pb";
3
3
  export declare const ListLayout: (props: {
4
4
  layout: ListViewLayout;
5
- } & PropsWithChildren) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | import("react").JSX.Element | null | undefined;
5
+ } & PropsWithChildren) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null | undefined;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { Message } from "@bufbuild/protobuf";
3
2
  export declare const LzListViewLayoutDemo: import("react").LazyExoticComponent<typeof import("./listview-layouts/listviewlayout-demo").default>;
4
3
  export declare const LzListViewLayoutDefault: import("react").LazyExoticComponent<typeof import("./listview-layouts/default").default>;
5
- export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
4
+ export declare function CommonListView(): import("react").JSX.Element | null;
5
+ export declare function CommonListViewV2(): import("react").JSX.Element;
6
6
  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, useMemo, useState } from "react";
29
+ import { Suspense, lazy, use, 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";
@@ -46,7 +46,6 @@ function CommonListView() {
46
46
  const svc = useListview((x) => x.svc);
47
47
  const methodList = useListview((x) => x.methodList);
48
48
  const paramList = useListview((x) => x.paramsList);
49
- const backendUrl = useListview((x) => x.backendUrl);
50
49
  const listQuery = useGomtmSuspenseInfiniteQuery(svc, methodList, paramList);
51
50
  if (!(listQuery == null ? void 0 : listQuery.data)) {
52
51
  return null;
@@ -70,7 +69,7 @@ function CommonListView() {
70
69
  })
71
70
  }
72
71
  ),
73
- /* @__PURE__ */ jsx(Pagination, { children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
72
+ listQuery.data.pages && !!listQuery.data.pages.length && /* @__PURE__ */ jsx(Pagination, { children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
74
73
  /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationPrevious, { href: "#" }) }),
75
74
  /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "1" }) }),
76
75
  /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", isActive: true, children: "2" }) }),
@@ -81,6 +80,28 @@ function CommonListView() {
81
80
  /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) })
82
81
  ] });
83
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
+ }
84
105
  const PanelRemove = () => {
85
106
  const svc = useListview((x) => x.svc);
86
107
  const openRemove = useListview((x) => x.openRemove);
@@ -167,6 +188,7 @@ const ListViewLayoutSwitch = () => {
167
188
  };
168
189
  export {
169
190
  CommonListView,
191
+ CommonListViewV2,
170
192
  ListViewActions,
171
193
  LzListViewLayoutDefault,
172
194
  LzListViewLayoutDemo
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import { ComponentProps, PropsWithChildren } from 'react';
2
2
  interface ListViewStateProps {
3
- backendUrl?: string;
3
+ backendUrl: string;
4
4
  svc: string;
5
5
  methodList: string;
6
6
  methodGet: string;
@@ -12,6 +12,8 @@ interface ListViewStateProps {
12
12
  activateItem?: any;
13
13
  detailData?: any;
14
14
  layout?: string;
15
+ data?: any;
16
+ error?: any;
15
17
  }
16
18
  export interface ListViewState extends ListViewStateProps {
17
19
  openRemove: boolean;
@@ -22,17 +24,12 @@ export interface ListViewState extends ListViewStateProps {
22
24
  setOpenEdit: (openEdit: boolean) => void;
23
25
  setLayout: (layout: string) => void;
24
26
  setActivateItem: (activateItem: any) => void;
25
- loading?: boolean;
26
- success?: boolean;
27
- error?: boolean;
28
- data?: any;
29
- errorData?: any;
30
- demoListData?: any;
31
- items?: any[];
32
- value1?: any;
27
+ loadListData: () => Promise<any>;
28
+ nextPage: () => void;
33
29
  }
34
30
  export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
35
31
  type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
36
32
  export declare const ListViewStoreProvider: (props: BearProviderProps) => import("react").JSX.Element;
33
+ export declare const ListView: (props: Omit<ComponentProps<typeof ListViewStoreProvider>, 'backendUrl'> & PropsWithChildren) => import("react").JSX.Element;
37
34
  export declare function useListview<T>(selector: (state: ListViewState) => T): T;
38
35
  export {};
@@ -30,21 +30,44 @@ var __objRest = (source, exclude) => {
30
30
  }
31
31
  return target;
32
32
  };
33
+ var __async = (__this, __arguments, generator) => {
34
+ return new Promise((resolve, reject) => {
35
+ var fulfilled = (value) => {
36
+ try {
37
+ step(generator.next(value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ };
42
+ var rejected = (value) => {
43
+ try {
44
+ step(generator.throw(value));
45
+ } catch (e) {
46
+ reject(e);
47
+ }
48
+ };
49
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
50
+ step((generator = generator.apply(__this, __arguments)).next());
51
+ });
52
+ };
33
53
  import { jsx } from "react/jsx-runtime";
34
54
  import { setCookie } from "mtxlib/clientlib";
35
55
  import { createContext, useContext, useRef } from "react";
36
56
  import { useStore } from "zustand";
37
57
  import { createStore } from "zustand/vanilla";
38
58
  import { CONST_cookieListViewLayout } from "../../consts";
59
+ import { goMtmQueryFn } from "../../mtmFetcher";
60
+ import { useGomtm } from "../../store/mtapp-store";
39
61
  const createListviewStore = (initProps) => {
40
62
  const DEFAULT_PROPS = {
41
63
  svc: initProps.svc || "",
42
64
  methodList: initProps.methodList || "",
43
65
  methodGet: "",
44
66
  methodDelete: "",
45
- methodCreate: ""
67
+ methodCreate: "",
68
+ backendUrl: ""
46
69
  };
47
- return createStore()((set) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
70
+ return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
48
71
  openRemove: false,
49
72
  setOpenRemove: (openRemove) => set({ openRemove }),
50
73
  openCreate: false,
@@ -55,6 +78,20 @@ const createListviewStore = (initProps) => {
55
78
  setLayout: (layout) => {
56
79
  setCookie(CONST_cookieListViewLayout, layout);
57
80
  return set((state) => ({ layout }));
81
+ },
82
+ loadListData: () => __async(void 0, null, function* () {
83
+ const data = yield goMtmQueryFn({
84
+ svc: get().svc,
85
+ method: get().methodList,
86
+ input: get().paramsList,
87
+ options: {
88
+ url: get().backendUrl
89
+ }
90
+ });
91
+ set({ data });
92
+ return data;
93
+ }),
94
+ nextPage: () => {
58
95
  }
59
96
  }));
60
97
  };
@@ -67,6 +104,11 @@ const ListViewStoreProvider = (props) => {
67
104
  }
68
105
  return /* @__PURE__ */ jsx(listViewContext.Provider, { value: storeRef.current, children });
69
106
  };
107
+ const ListView = (props) => {
108
+ const backendUrl = useGomtm((x) => x.backendUrl);
109
+ const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
110
+ return /* @__PURE__ */ jsx(ListViewStoreProvider, __spreadProps(__spreadValues({}, props), { backendUrl: backendUrl || "", children }));
111
+ };
70
112
  function useListview(selector) {
71
113
  const store = useContext(listViewContext);
72
114
  if (!store)
@@ -74,6 +116,7 @@ function useListview(selector) {
74
116
  return useStore(store, selector);
75
117
  }
76
118
  export {
119
+ ListView,
77
120
  ListViewStoreProvider,
78
121
  listViewContext,
79
122
  useListview
@@ -4,14 +4,25 @@ import { MTM_API_PREFIX } from "./consts";
4
4
  import { createInfiniteQueryKey, createQueryKey, goMtmQueryFn } from "./mtmFetcher";
5
5
  import { useGomtm } from "./store/mtapp-store";
6
6
  const useGomtmQuery = (svc, method, input) => {
7
+ const cookieStr = useGomtm((x) => x.cookieStr);
8
+ const backendUrl = useGomtm((x) => x.backendUrl);
7
9
  const query = useQuery({
8
10
  queryKey: createQueryKey(svc, method, input),
9
- queryFn: (k) => goMtmQueryFn({ svc, method, input })
11
+ queryFn: (k) => goMtmQueryFn({
12
+ svc,
13
+ method,
14
+ input,
15
+ options: {
16
+ url: new URL(MTM_API_PREFIX, backendUrl).toString(),
17
+ token: cookieStr
18
+ }
19
+ })
10
20
  });
11
21
  return query;
12
22
  };
13
23
  const useGomtmSuspenseQuery = (svc, method, input) => {
14
- const backendUrl = useGomtm((x) => x.configState.backendUrl);
24
+ const backendUrl = useGomtm((x) => x.backendUrl);
25
+ const cookieStr = useGomtm((x) => x.cookieStr);
15
26
  const query = useSuspenseQuery({
16
27
  queryKey: createQueryKey(svc, method, input),
17
28
  queryFn: (k) => goMtmQueryFn({
@@ -19,14 +30,16 @@ const useGomtmSuspenseQuery = (svc, method, input) => {
19
30
  method,
20
31
  input,
21
32
  options: {
22
- url: new URL(MTM_API_PREFIX, backendUrl).toString()
33
+ url: new URL(MTM_API_PREFIX, backendUrl).toString(),
34
+ token: cookieStr
23
35
  }
24
36
  })
25
37
  });
26
38
  return query;
27
39
  };
28
40
  const useGomtmSuspenseInfiniteQuery = (svc, method, input) => {
29
- const backendUrl = useGomtm((x) => x.configState.backendUrl);
41
+ const backendUrl = useGomtm((x) => x.backendUrl);
42
+ const cookieStr = useGomtm((x) => x.cookieStr);
30
43
  const query = useSuspenseInfiniteQuery({
31
44
  queryKey: createInfiniteQueryKey(svc, method, input),
32
45
  queryFn: (k) => goMtmQueryFn({
@@ -34,7 +47,8 @@ const useGomtmSuspenseInfiniteQuery = (svc, method, input) => {
34
47
  method,
35
48
  input,
36
49
  options: {
37
- url: new URL(MTM_API_PREFIX, backendUrl).toString()
50
+ url: new URL(MTM_API_PREFIX, backendUrl).toString(),
51
+ token: cookieStr
38
52
  }
39
53
  }),
40
54
  initialPageParam: input,
@@ -45,14 +59,16 @@ const useGomtmSuspenseInfiniteQuery = (svc, method, input) => {
45
59
  return query;
46
60
  };
47
61
  const useGomtmMutation = (svc, method) => {
48
- const backendUrl = useGomtm((x) => x.configState.backendUrl);
62
+ const backendUrl = useGomtm((x) => x.backendUrl);
63
+ const cookieStr = useGomtm((x) => x.cookieStr);
49
64
  return useMutation({
50
65
  mutationFn: (input) => goMtmQueryFn({
51
66
  svc,
52
67
  method,
53
68
  input,
54
69
  options: {
55
- url: new URL(MTM_API_PREFIX, backendUrl).toString()
70
+ url: new URL(MTM_API_PREFIX, backendUrl).toString(),
71
+ token: cookieStr
56
72
  }
57
73
  })
58
74
  });
@@ -25,7 +25,7 @@ const LzDebugLayout = lazy(() => import("./debug-layout"));
25
25
  const LzFrontLayout = lazy(() => import("./front-layout"));
26
26
  const LayoutBase = (props) => {
27
27
  const { children } = props;
28
- const layout = useGomtm((x) => x.configState.layout);
28
+ const layout = useGomtm((x) => x.layout);
29
29
  const LayoutComponent = useMemo(() => {
30
30
  switch (layout) {
31
31
  case "dash5":
@@ -57,7 +57,7 @@ const LayoutBase = (props) => {
57
57
  ] }) });
58
58
  };
59
59
  const LayoutSwitchDlg = () => {
60
- const layout = useGomtm((x) => x.configState.layout);
60
+ const layout = useGomtm((x) => x.layout);
61
61
  const setLayout = useGomtm((x) => x.setLayout);
62
62
  const [open, setOpen] = useState(false);
63
63
  useHotkeys(HOTKEY_Switchlayout, () => {
@@ -10,6 +10,7 @@ import { useAuth } from "../providers/AuthProvider";
10
10
  function UserAvatorMenus() {
11
11
  const pathName = usePathname();
12
12
  const auth = useAuth();
13
+ console.log("auth.userId", auth.userId);
13
14
  return /* @__PURE__ */ jsx(Fragment, { children: !auth.userId ? /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/login?next=${pathName}`, children: " login" }) : /* @__PURE__ */ jsxs(DropdownMenu, { children: [
14
15
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Avatar, { children: [
15
16
  /* @__PURE__ */ jsx(AvatarImage, { src: "/mtm_images/placeholder-user.jpg", alt: "@siteCook" }),
@@ -36,27 +36,24 @@ const PageSearchCmd = () => {
36
36
  const setSearchParams = useGomtm((x) => x.setGlobalSearchParams);
37
37
  const form = useForm();
38
38
  return /* @__PURE__ */ jsxs(MtForm, __spreadProps(__spreadValues({}, form), { children: [
39
- /* @__PURE__ */ jsxs("form", { onSubmit: form.handleSubmit(() => {
40
- }), children: [
41
- /* @__PURE__ */ jsx("pre", { children: JSON.stringify(globalSearchParams, null, 2) }),
42
- /* @__PURE__ */ jsxs("div", { className: "relative ml-auto flex-1 md:grow-0", children: [
43
- /* @__PURE__ */ jsx(Search, { className: "text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4" }),
44
- /* @__PURE__ */ jsx(
45
- Input,
46
- {
47
- type: "search",
48
- placeholder: "Search...",
49
- className: "bg-background w-full rounded-lg pl-8 md:w-[200px] lg:w-[336px]",
50
- defaultValue: globalSearchParams == null ? void 0 : globalSearchParams.q,
51
- onChange: (e) => {
52
- setSearchParams({
53
- q: e.target.value
54
- });
55
- }
39
+ /* @__PURE__ */ jsx("form", { onSubmit: form.handleSubmit(() => {
40
+ }), children: /* @__PURE__ */ jsxs("div", { className: "relative ml-auto flex-1 md:grow-0", children: [
41
+ /* @__PURE__ */ jsx(Search, { className: "text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4" }),
42
+ /* @__PURE__ */ jsx(
43
+ Input,
44
+ {
45
+ type: "search",
46
+ placeholder: "Search...",
47
+ className: "bg-background w-full rounded-lg pl-8 md:w-[200px] lg:w-[336px]",
48
+ defaultValue: globalSearchParams == null ? void 0 : globalSearchParams.q,
49
+ onChange: (e) => {
50
+ setSearchParams({
51
+ q: e.target.value
52
+ });
56
53
  }
57
- )
58
- ] })
59
- ] }),
54
+ }
55
+ )
56
+ ] }) }),
60
57
  /* @__PURE__ */ jsxs(CommandDialog, { open, onOpenChange: setOpen, children: [
61
58
  /* @__PURE__ */ jsx(CommandInput, { placeholder: "Type a command or search...", onValueChange: (s) => {
62
59
  setOpen(false);
@@ -7,6 +7,7 @@ interface goMtmQueryFnProps {
7
7
  input?: any;
8
8
  options?: {
9
9
  url: string;
10
+ token?: string;
10
11
  };
11
12
  }
12
13
  export declare const goMtmQueryFn: (props: goMtmQueryFnProps) => Promise<any>;
@@ -14,9 +15,10 @@ export declare const ssrGetBackendUrl: () => string;
14
15
  export declare const gomtmApiUrl: () => string;
15
16
  export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
16
17
  export declare function createTransport(): import("@connectrpc/connect").Transport;
17
- export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string): import("@connectrpc/connect").PromiseClient<ServiceType>;
18
+ export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string, token?: string): import("@connectrpc/connect").PromiseClient<ServiceType>;
18
19
  type CustomRequestInit = RequestInit & {
19
20
  cookieStr?: string;
21
+ token?: string;
20
22
  enableCache?: boolean;
21
23
  enableLog?: boolean;
22
24
  };
@@ -49,8 +49,8 @@ const createInfiniteQueryKey = (svc, method, input) => {
49
49
  return [...createQueryKey(svc, method, input), "infinite"];
50
50
  };
51
51
  const goMtmQueryFn = (props) => __async(void 0, null, function* () {
52
- var _a;
53
- const client = createMtmServiceClientByName(props.svc, (_a = props.options) == null ? void 0 : _a.url);
52
+ var _a, _b, _c;
53
+ const client = createMtmServiceClientByName(props.svc, (_a = props.options) == null ? void 0 : _a.url, (_b = props.options) == null ? void 0 : _b.token);
54
54
  if (!client) {
55
55
  throw new Error(`missing mtmclient:"${props.svc}"`);
56
56
  }
@@ -60,7 +60,7 @@ const goMtmQueryFn = (props) => __async(void 0, null, function* () {
60
60
  throw new Error(`missing mtmclient method:"${props.svc}.${methodName}"`);
61
61
  }
62
62
  const data = yield methodFn(props.input);
63
- console.log(`goMtmQueryFn ${props.svc}.${props.method}.(${props.input})`, data);
63
+ console.log(`goMtmQueryFn ${props.svc}.${props.method}.(${props.input})`, { token: (_c = props.options) == null ? void 0 : _c.token, data });
64
64
  return toPlainMessage(data);
65
65
  });
66
66
  const ssrGetBackendUrl = () => {
@@ -94,7 +94,7 @@ function createTransport() {
94
94
  useHttpGet: true
95
95
  });
96
96
  }
97
- function createMtmServiceClientByName(svcName, url) {
97
+ function createMtmServiceClientByName(svcName, url, token) {
98
98
  let svcType = void 0;
99
99
  for (const a of allServices) {
100
100
  if (a.typeName == svcName) {
@@ -109,7 +109,9 @@ function createMtmServiceClientByName(svcName, url) {
109
109
  svcType,
110
110
  createConnectTransport({
111
111
  baseUrl,
112
- fetch: gomtmFetcher()
112
+ fetch: gomtmFetcher({
113
+ cookieStr: token
114
+ })
113
115
  })
114
116
  );
115
117
  }
@@ -129,11 +131,15 @@ const gomtmFetcher = (initGlobal) => {
129
131
  const decoder = new TextDecoder();
130
132
  init.body = decoder.decode(init.body);
131
133
  }
134
+ let cookieStr1 = initGlobal == null ? void 0 : initGlobal.cookieStr;
135
+ if (typeof window == "undefined") {
136
+ cookieStr1 = (yield import("next/headers")).headers().get("cookie") || "";
137
+ }
132
138
  init = __spreadValues(__spreadValues({}, init), {
133
139
  headers: __spreadValues({
134
140
  // ...init.headers,
135
141
  "Content-Type": "application/json"
136
- }, (initGlobal == null ? void 0 : initGlobal.cookieStr) && { "Cookie": initGlobal == null ? void 0 : initGlobal.cookieStr })
142
+ }, cookieStr1 && { "Cookie": cookieStr1 })
137
143
  });
138
144
  let fetcher = fetch;
139
145
  req.enableCache = true;
@@ -1,7 +1,4 @@
1
- import { MyJWTPayload } from "../lib/auth/jwt";
2
1
  export declare function isRoleMatch(currentRoles: string[], allowRoles?: string[]): boolean;
3
2
  export declare function useAuth(): {
4
- auth: MyJWTPayload | null;
5
- userId: string | undefined;
6
- isAdmin: boolean;
3
+ userId: any;
7
4
  };
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import React, { useMemo } from "react";
3
- import { useSuspenseQuery } from "../connectquery";
2
+ import { useMemo } from "react";
3
+ import { useGomtmSuspenseQuery } from "../gomtmQuery";
4
4
  import { userinfo } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
5
+ import { useGomtm } from "../store/mtapp-store";
5
6
  function isRoleMatch(currentRoles, allowRoles) {
6
7
  if (!currentRoles) {
7
8
  return true;
@@ -18,16 +19,19 @@ function isRoleMatch(currentRoles, allowRoles) {
18
19
  return false;
19
20
  }
20
21
  function useAuth() {
21
- const [auth, setAuth] = React.useState(null);
22
- const isAdmin = useMemo(() => {
23
- return (auth == null ? void 0 : auth.role) == "admin";
24
- }, [auth]);
25
- const userInfoQuery = useSuspenseQuery(userinfo);
22
+ const cookieStr = useGomtm((x) => x.cookieStr);
23
+ console.log("cookieStr-----------", cookieStr);
24
+ 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;
29
29
  }, [userInfoQuery.data]);
30
- return { auth, userId, isAdmin };
30
+ return {
31
+ // auth,
32
+ userId
33
+ // isAdmin
34
+ };
31
35
  }
32
36
  export {
33
37
  isRoleMatch,
@@ -1,3 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
20
  var __async = (__this, __arguments, generator) => {
2
21
  return new Promise((resolve, reject) => {
3
22
  var fulfilled = (value) => {
@@ -18,38 +37,26 @@ var __async = (__this, __arguments, generator) => {
18
37
  step((generator = generator.apply(__this, __arguments)).next());
19
38
  });
20
39
  };
21
- import { Fragment, jsx } from "react/jsx-runtime";
40
+ import { jsx } from "react/jsx-runtime";
22
41
  import { cookies, headers } from "next/headers";
23
- import { getGomtmConfig } from "../consts";
42
+ import { CookieConfigState } from "../consts";
24
43
  import { ssrGetBackendUrl } from "../mtmFetcher";
25
44
  import { GoMtmAppProvider } from "../store/mtapp-store";
26
45
  function GomtmAppSS(props) {
27
46
  return __async(this, null, function* () {
28
- var _a, _b;
47
+ var _a;
29
48
  const { children } = props;
30
- const gomtmAppConfig = getGomtmConfig();
31
- let backend = ssrGetBackendUrl();
32
- const backendFromCookie = (_a = cookies().get(gomtmAppConfig.cookieBackendUrl)) == null ? void 0 : _a.value;
33
- if (backendFromCookie) {
34
- backend = backendFromCookie;
35
- }
36
- if (!backend) {
37
- return /* @__PURE__ */ jsx(Fragment, { children: "missing backend" });
38
- }
49
+ const backend = ssrGetBackendUrl();
39
50
  const cookiesStr = headers().get("Cookie");
40
- const configStateJson = ((_b = cookies().get(gomtmAppConfig.CookieConfigState)) == null ? void 0 : _b.value) || "{}";
41
- const configState = JSON.parse(configStateJson);
42
- if (!configState.backendUrl) {
43
- configState.backendUrl = backend;
44
- }
51
+ const configState = JSON.parse(((_a = cookies().get(CookieConfigState)) == null ? void 0 : _a.value) || "{}");
52
+ const cState = configState["state"];
45
53
  return /* @__PURE__ */ jsx(
46
54
  GoMtmAppProvider,
47
- {
48
- configState,
49
- params: {},
55
+ __spreadProps(__spreadValues({}, cState), {
50
56
  cookieStr: cookiesStr || "",
57
+ backendUrl: (cState == null ? void 0 : cState.backendUrl) || backend,
51
58
  children
52
- }
59
+ })
53
60
  );
54
61
  });
55
62
  }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const GomtmAppSetting: () => import("react").JSX.Element;