gomtm 0.0.284 → 0.0.286

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.
@@ -36,15 +36,18 @@ var __async = (__this, __arguments, generator) => {
36
36
  };
37
37
  import { jsx } from "react/jsx-runtime";
38
38
  import { HydrationBoundary, QueryClient, dehydrate } from "@tanstack/react-query";
39
- import { goMtmQueryFn } from "../gomtmQuery";
40
- import { createInfiniteQueryKey } from "../mtmFetcher";
39
+ import { createInfiniteQueryKey, goMtmQueryFn } from "../mtmFetcher";
41
40
  function PrefetchConnectInfiniteQuery(props) {
42
41
  return __async(this, null, function* () {
43
42
  const { svc, method, input, children } = props;
44
43
  const queryClient = new QueryClient();
44
+ const queryKey = createInfiniteQueryKey(svc, method, input);
45
+ const data = yield goMtmQueryFn({ svc, method, input });
45
46
  yield queryClient.prefetchInfiniteQuery({
46
- queryKey: createInfiniteQueryKey(svc, method, input),
47
- queryFn: (k) => goMtmQueryFn({ svc, method, input }),
47
+ queryKey,
48
+ queryFn: (k) => __async(this, null, function* () {
49
+ return data;
50
+ }),
48
51
  initialPageParam: __spreadValues({}, input)
49
52
  });
50
53
  const dehydratedState = dehydrate(queryClient);
@@ -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 | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null | undefined;
5
+ } & PropsWithChildren) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | import("react").JSX.Element | null | undefined;
@@ -1,5 +1,7 @@
1
1
  "use client";
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -15,6 +17,7 @@ var __spreadValues = (a, b) => {
15
17
  }
16
18
  return a;
17
19
  };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
18
21
  var __async = (__this, __arguments, generator) => {
19
22
  return new Promise((resolve, reject) => {
20
23
  var fulfilled = (value) => {
@@ -35,7 +38,7 @@ var __async = (__this, __arguments, generator) => {
35
38
  step((generator = generator.apply(__this, __arguments)).next());
36
39
  });
37
40
  };
38
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
41
+ import { jsx, jsxs } from "react/jsx-runtime";
39
42
  import { debounce } from "lodash";
40
43
  import { Icons } from "mtxuilib/icons/icons";
41
44
  import { cn } from "mtxuilib/lib/utils";
@@ -56,13 +59,13 @@ import { ListLayout } from "../list-item/ListLayout";
56
59
  import { ListViewLayoutDefault } from "./listview-layouts/default";
57
60
  import ListViewLayoutDemo from "./listview-layouts/listviewlayout-demo";
58
61
  const ALL_Layouts = [
59
- "demo",
60
62
  "default",
61
- "none"
63
+ "demo"
62
64
  ];
63
65
  const commonListViewContext = createContext(void 0);
64
66
  function ListViewProvider(props) {
65
- const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet } = props;
67
+ var _a;
68
+ const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet, params } = props;
66
69
  const mtapp = useMtmApp();
67
70
  const [_svc, setSvc] = useState(svc);
68
71
  const [openRemove, setOpenRemove] = useState(false);
@@ -70,15 +73,17 @@ function ListViewProvider(props) {
70
73
  const [activateItem, setActivateItem] = useState(void 0);
71
74
  const [openEdit, setOpenEdit] = useState(false);
72
75
  const [openDebug, setOpenDebug] = useState(false);
73
- const [_params, _setParams] = useState(mtapp.globalSearchParams);
76
+ const [_params, _setParams] = useState(params);
74
77
  const [detailData, setDetailData] = useState(void 0);
75
78
  const [layout, setLayout] = useState("default");
76
- const params = useMemo(() => {
77
- var _a;
78
- return {
79
- q: (_a = mtapp.globalSearchParams) == null ? void 0 : _a.q
80
- };
81
- }, [mtapp.globalSearchParams]);
79
+ const __params = useMemo(() => {
80
+ var _a2, _b;
81
+ return __spreadProps(__spreadValues({}, params), {
82
+ params: __spreadValues(__spreadValues({}, params.params), ((_a2 = mtapp.globalSearchParams) == null ? void 0 : _a2.q) && {
83
+ q: (_b = mtapp.globalSearchParams) == null ? void 0 : _b.q
84
+ })
85
+ });
86
+ }, [(_a = mtapp.globalSearchParams) == null ? void 0 : _a.q, params]);
82
87
  const setParams = useCallback(debounce((values) => {
83
88
  _setParams(values);
84
89
  }, CONST_debounce_INPUT), [_setParams]);
@@ -99,14 +104,16 @@ function ListViewProvider(props) {
99
104
  setOpenEdit,
100
105
  openDebug,
101
106
  setOpenDebug,
102
- params,
107
+ params: __params,
103
108
  setParams,
104
109
  detailData,
105
110
  setDetailData,
106
111
  layout,
107
112
  setLayout
108
113
  }, children: /* @__PURE__ */ jsxs(ListViewLayout, { children: [
114
+ " ",
109
115
  children,
116
+ " ",
110
117
  /* @__PURE__ */ jsx(ListViewLayoutSwitch, {})
111
118
  ] }) });
112
119
  }
@@ -203,15 +210,15 @@ const ListViewActions = () => {
203
210
  const ListViewLayout = (props) => {
204
211
  const listView = useListView();
205
212
  const { children } = props;
206
- return /* @__PURE__ */ jsx(Fragment, { children: listView.layout == "default" ? /* @__PURE__ */ jsxs(ListViewLayoutDefault, { children: [
207
- " ",
208
- children,
209
- " "
210
- ] }) : listView.layout == "demo" ? /* @__PURE__ */ jsxs(ListViewLayoutDemo, { children: [
211
- " ",
212
- children,
213
- " "
214
- ] }) : listView.layout == "none" ? /* @__PURE__ */ jsx(Fragment, { children }) : children });
213
+ const Layout = useMemo(() => {
214
+ switch (listView.layout) {
215
+ case "demo":
216
+ return ListViewLayoutDemo;
217
+ default:
218
+ return ListViewLayoutDefault;
219
+ }
220
+ }, [listView.layout]);
221
+ return /* @__PURE__ */ jsx(Layout, { children });
215
222
  };
216
223
  const ListViewLayoutSwitch = () => {
217
224
  const listview = useListView();
@@ -1,14 +1,4 @@
1
- interface goMtmQueryFnProps {
2
- svc: string;
3
- method: string;
4
- input?: any;
5
- options?: {
6
- url: string;
7
- };
8
- }
9
- export declare const goMtmQueryFn: (props: goMtmQueryFnProps) => Promise<any>;
10
1
  export declare const useGomtmQuery: (svc: string, method: string, input?: any) => import("@tanstack/react-query").UseQueryResult<any, Error>;
11
2
  export declare const useGomtmSuspenseQuery: (svc: string, method: string, input?: any) => import("@tanstack/react-query").UseSuspenseQueryResult<any, Error>;
12
3
  export declare const useGomtmSuspenseInfiniteQuery: (svc: string, method: string, input?: any) => import("@tanstack/react-query").UseSuspenseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<any, unknown>, Error>;
13
4
  export declare const useGomtmMutation: (svc: string, method: string) => import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
14
- export {};
@@ -1,44 +1,8 @@
1
1
  "use client";
2
- var __async = (__this, __arguments, generator) => {
3
- return new Promise((resolve, reject) => {
4
- var fulfilled = (value) => {
5
- try {
6
- step(generator.next(value));
7
- } catch (e) {
8
- reject(e);
9
- }
10
- };
11
- var rejected = (value) => {
12
- try {
13
- step(generator.throw(value));
14
- } catch (e) {
15
- reject(e);
16
- }
17
- };
18
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
- step((generator = generator.apply(__this, __arguments)).next());
20
- });
21
- };
22
2
  import { useMutation, useQuery, useSuspenseInfiniteQuery, useSuspenseQuery } from "@tanstack/react-query";
23
- import { camelCase } from "lodash";
24
3
  import { MTM_API_PREFIX } from "./consts";
25
- import { createMtmServiceClientByName, createQueryKey } from "./mtmFetcher";
4
+ import { createInfiniteQueryKey, createQueryKey, goMtmQueryFn } from "./mtmFetcher";
26
5
  import { useMtmApp } from "./providers/GomtmProvider";
27
- const goMtmQueryFn = (props) => __async(void 0, null, function* () {
28
- var _a;
29
- const client = createMtmServiceClientByName(props.svc, (_a = props.options) == null ? void 0 : _a.url);
30
- if (!client) {
31
- throw new Error(`missing mtmclient:"${props.svc}"`);
32
- }
33
- const methodName = camelCase(props.method);
34
- const methodFn = client[methodName];
35
- if (!methodFn) {
36
- throw new Error(`missing mtmclient method:"${props.svc}.${methodName}"`);
37
- }
38
- const data = yield methodFn(props.input);
39
- console.log(`goMtmQueryFn ${props.svc}.${props.method}.${props.input}`, data);
40
- return data;
41
- });
42
6
  const useGomtmQuery = (svc, method, input) => {
43
7
  const query = useQuery({
44
8
  queryKey: createQueryKey(svc, method, input),
@@ -64,7 +28,7 @@ const useGomtmSuspenseQuery = (svc, method, input) => {
64
28
  const useGomtmSuspenseInfiniteQuery = (svc, method, input) => {
65
29
  const mtapp = useMtmApp();
66
30
  const query = useSuspenseInfiniteQuery({
67
- queryKey: createQueryKey(svc, method, input),
31
+ queryKey: createInfiniteQueryKey(svc, method, input),
68
32
  queryFn: (k) => goMtmQueryFn({
69
33
  svc,
70
34
  method,
@@ -94,7 +58,6 @@ const useGomtmMutation = (svc, method) => {
94
58
  });
95
59
  };
96
60
  export {
97
- goMtmQueryFn,
98
61
  useGomtmMutation,
99
62
  useGomtmQuery,
100
63
  useGomtmSuspenseInfiniteQuery,
@@ -477,7 +477,7 @@ export declare class ItemAction extends Message<ItemAction> {
477
477
  static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ItemAction;
478
478
  static equals(a: ItemAction | PlainMessage<ItemAction> | undefined, b: ItemAction | PlainMessage<ItemAction> | undefined): boolean;
479
479
  }
480
- export declare class ListParams extends Message<ListParams> {
480
+ export declare class CommontListReq extends Message<CommontListReq> {
481
481
  slugs?: string;
482
482
  params: {
483
483
  [key: string]: string;
@@ -487,18 +487,6 @@ export declare class ListParams extends Message<ListParams> {
487
487
  cursor?: string;
488
488
  rerefer?: string;
489
489
  siteHost?: string;
490
- constructor(data?: PartialMessage<ListParams>);
491
- static readonly runtime: typeof proto3;
492
- static readonly typeName = "sppb.ListParams";
493
- static readonly fields: FieldList;
494
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ListParams;
495
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ListParams;
496
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ListParams;
497
- static equals(a: ListParams | PlainMessage<ListParams> | undefined, b: ListParams | PlainMessage<ListParams> | undefined): boolean;
498
- }
499
- export declare class CommontListReq extends Message<CommontListReq> {
500
- params?: ListParams;
501
- pagination?: Paging;
502
490
  constructor(data?: PartialMessage<CommontListReq>);
503
491
  static readonly runtime: typeof proto3;
504
492
  static readonly typeName = "sppb.CommontListReq";
@@ -1912,10 +1912,13 @@ __publicField(_ItemAction, "fields", proto3.util.newFieldList(() => [
1912
1912
  { no: 2, name: "item_actions", kind: "message", T: ListItemAction, repeated: true }
1913
1913
  ]));
1914
1914
  let ItemAction = _ItemAction;
1915
- const _ListParams = class _ListParams extends Message {
1915
+ const _CommontListReq = class _CommontListReq extends Message {
1916
1916
  constructor(data) {
1917
1917
  super();
1918
1918
  /**
1919
+ * ListParams params = 1;
1920
+ * Paging pagination = 2;
1921
+ *
1919
1922
  * @generated from field: optional string slugs = 1;
1920
1923
  */
1921
1924
  __publicField(this, "slugs");
@@ -1957,21 +1960,21 @@ const _ListParams = class _ListParams extends Message {
1957
1960
  proto3.util.initPartial(data, this);
1958
1961
  }
1959
1962
  static fromBinary(bytes, options) {
1960
- return new _ListParams().fromBinary(bytes, options);
1963
+ return new _CommontListReq().fromBinary(bytes, options);
1961
1964
  }
1962
1965
  static fromJson(jsonValue, options) {
1963
- return new _ListParams().fromJson(jsonValue, options);
1966
+ return new _CommontListReq().fromJson(jsonValue, options);
1964
1967
  }
1965
1968
  static fromJsonString(jsonString, options) {
1966
- return new _ListParams().fromJsonString(jsonString, options);
1969
+ return new _CommontListReq().fromJsonString(jsonString, options);
1967
1970
  }
1968
1971
  static equals(a, b) {
1969
- return proto3.util.equals(_ListParams, a, b);
1972
+ return proto3.util.equals(_CommontListReq, a, b);
1970
1973
  }
1971
1974
  };
1972
- __publicField(_ListParams, "runtime", proto3);
1973
- __publicField(_ListParams, "typeName", "sppb.ListParams");
1974
- __publicField(_ListParams, "fields", proto3.util.newFieldList(() => [
1975
+ __publicField(_CommontListReq, "runtime", proto3);
1976
+ __publicField(_CommontListReq, "typeName", "sppb.CommontListReq");
1977
+ __publicField(_CommontListReq, "fields", proto3.util.newFieldList(() => [
1975
1978
  { no: 1, name: "slugs", kind: "scalar", T: 9, opt: true },
1976
1979
  { no: 2, name: "params", kind: "map", K: 9, V: {
1977
1980
  kind: "scalar",
@@ -1984,39 +1987,6 @@ __publicField(_ListParams, "fields", proto3.util.newFieldList(() => [
1984
1987
  { no: 9, name: "rerefer", kind: "scalar", T: 9, opt: true },
1985
1988
  { no: 10, name: "site_host", kind: "scalar", T: 9, opt: true }
1986
1989
  ]));
1987
- let ListParams = _ListParams;
1988
- const _CommontListReq = class _CommontListReq extends Message {
1989
- constructor(data) {
1990
- super();
1991
- /**
1992
- * @generated from field: sppb.ListParams params = 1;
1993
- */
1994
- __publicField(this, "params");
1995
- /**
1996
- * @generated from field: sppb.Paging pagination = 2;
1997
- */
1998
- __publicField(this, "pagination");
1999
- proto3.util.initPartial(data, this);
2000
- }
2001
- static fromBinary(bytes, options) {
2002
- return new _CommontListReq().fromBinary(bytes, options);
2003
- }
2004
- static fromJson(jsonValue, options) {
2005
- return new _CommontListReq().fromJson(jsonValue, options);
2006
- }
2007
- static fromJsonString(jsonString, options) {
2008
- return new _CommontListReq().fromJsonString(jsonString, options);
2009
- }
2010
- static equals(a, b) {
2011
- return proto3.util.equals(_CommontListReq, a, b);
2012
- }
2013
- };
2014
- __publicField(_CommontListReq, "runtime", proto3);
2015
- __publicField(_CommontListReq, "typeName", "sppb.CommontListReq");
2016
- __publicField(_CommontListReq, "fields", proto3.util.newFieldList(() => [
2017
- { no: 1, name: "params", kind: "message", T: ListParams },
2018
- { no: 2, name: "pagination", kind: "message", T: Paging }
2019
- ]));
2020
1990
  let CommontListReq = _CommontListReq;
2021
1991
  const _CommontListRes = class _CommontListRes extends Message {
2022
1992
  constructor(data) {
@@ -7142,7 +7112,6 @@ export {
7142
7112
  ItemAction,
7143
7113
  ListItem,
7144
7114
  ListItemAction,
7145
- ListParams,
7146
7115
  ListViewActionType,
7147
7116
  ListViewLayout,
7148
7117
  LogLine,
@@ -7,7 +7,7 @@ import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
7
7
  import { TooltipProvider } from "mtxuilib/ui/tooltip";
8
8
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
9
9
  import { AppProgressBar as ProgressBar } from "next-nprogress-bar";
10
- import { Suspense, lazy, useState } from "react";
10
+ import { Suspense, lazy, useMemo, useState } from "react";
11
11
  import { useHotkeys } from "react-hotkeys-hook";
12
12
  import { Toaster } from "sonner";
13
13
  import { HOTKEY_Switchlayout } from "../consts";
@@ -26,12 +26,20 @@ const LzFrontLayout = lazy(() => import("./front-layout"));
26
26
  const LayoutBase = (props) => {
27
27
  const { children } = props;
28
28
  const mtapp = useMtmApp();
29
+ const LayoutComponent = useMemo(() => {
30
+ switch (mtapp.layoutName) {
31
+ case "dash5":
32
+ return LzDash5;
33
+ case "debug":
34
+ return LzDebugLayout;
35
+ case "demo":
36
+ return LzDemoLayout;
37
+ default:
38
+ return LzFrontLayout;
39
+ }
40
+ }, [mtapp.layoutName]);
29
41
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 0, children: [
30
- mtapp.layoutName == "front" ? /* @__PURE__ */ jsxs(LzFrontLayout, { children: [
31
- " ",
32
- children,
33
- " "
34
- ] }) : mtapp.layoutName == "dash5" ? /* @__PURE__ */ jsx(LzDash5, { children }) : mtapp.layoutName == "debug" ? /* @__PURE__ */ jsx(LzDebugLayout, { children }) : mtapp.layoutName == "demo1" ? /* @__PURE__ */ jsx(LzDemoLayout, { children }) : mtapp.layoutName == "default" ? /* @__PURE__ */ jsx(Fragment, { children }) : children,
42
+ /* @__PURE__ */ jsx(LayoutComponent, { children }),
35
43
  /* @__PURE__ */ jsx(
36
44
  ProgressBar,
37
45
  {
@@ -1,6 +1,15 @@
1
1
  import { ServiceType } from "@bufbuild/protobuf";
2
2
  export declare const createQueryKey: (svc: string, method: string, input: any) => any[];
3
3
  export declare const createInfiniteQueryKey: (svc: string, method: string, input: any) => any[];
4
+ interface goMtmQueryFnProps {
5
+ svc: string;
6
+ method: string;
7
+ input?: any;
8
+ options?: {
9
+ url: string;
10
+ };
11
+ }
12
+ export declare const goMtmQueryFn: (props: goMtmQueryFnProps) => Promise<any>;
4
13
  export declare const ssrGetBackendUrl: () => string;
5
14
  export declare const gomtmApiUrl: () => string;
6
15
  export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
@@ -34,9 +34,10 @@ var __async = (__this, __arguments, generator) => {
34
34
  step((generator = generator.apply(__this, __arguments)).next());
35
35
  });
36
36
  };
37
+ import { toPlainMessage } from "@bufbuild/protobuf";
37
38
  import { createPromiseClient } from "@connectrpc/connect";
38
39
  import { createConnectTransport } from "@connectrpc/connect-web";
39
- import { merge } from "lodash";
40
+ import { camelCase, merge } from "lodash";
40
41
  import { fetchMiddleWithCache } from "mtxlib/http/fetchMiddleWithCache";
41
42
  import { MTM_API_PREFIX } from "./consts";
42
43
  import { MtmService } from "./gomtmpb/mtm/sppb/mtm_connect";
@@ -45,8 +46,23 @@ const createQueryKey = (svc, method, input) => {
45
46
  return [svc, method, input || {}];
46
47
  };
47
48
  const createInfiniteQueryKey = (svc, method, input) => {
48
- return [svc, method, input || {}, "infinite"];
49
+ return [...createQueryKey(svc, method, input), "infinite"];
49
50
  };
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);
54
+ if (!client) {
55
+ throw new Error(`missing mtmclient:"${props.svc}"`);
56
+ }
57
+ const methodName = camelCase(props.method);
58
+ const methodFn = client[methodName];
59
+ if (!methodFn) {
60
+ throw new Error(`missing mtmclient method:"${props.svc}.${methodName}"`);
61
+ }
62
+ const data = yield methodFn(props.input);
63
+ console.log(`goMtmQueryFn ${props.svc}.${props.method}.(${props.input})`, data);
64
+ return toPlainMessage(data);
65
+ });
50
66
  const ssrGetBackendUrl = () => {
51
67
  var _a;
52
68
  if (typeof window == "undefined") {
@@ -157,6 +173,7 @@ export {
157
173
  createMtmServiceClientByName,
158
174
  createQueryKey,
159
175
  createTransport,
176
+ goMtmQueryFn,
160
177
  gomtmApiUrl,
161
178
  gomtmFetcher,
162
179
  ssrGetBackendUrl