gomtm 0.0.205 → 0.0.207
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/CommonListViewV2.d.ts +1 -0
- package/dist/esm/curd/CommonListViewV2.js +68 -5
- package/dist/esm/curd/CurdAtomsDebug.d.ts +2 -0
- package/dist/esm/curd/CurdAtomsDebug.js +13 -0
- package/dist/esm/curd/curd.atoms.d.ts +6 -1
- package/dist/esm/curd/curd.atoms.js +18 -2
- package/dist/esm/curd/dlg/DlgCurdDebugInfo.d.ts +6 -0
- package/dist/esm/curd/dlg/DlgCurdDebugInfo.js +34 -0
- package/dist/esm/curd/dlg/DlgDebugInfo.d.ts +4 -0
- package/dist/esm/curd/dlg/DlgDebugInfo.js +21 -0
- package/dist/esm/curd/list-item/PostCardListItem.js +17 -7
- package/dist/esm/lzBizComponents.d.ts +5 -0
- package/dist/esm/lzBizComponents.js +15 -0
- package/dist/esm/mtmFetcher.js +1 -1
- package/dist/esm/providers/logger.context.d.ts +0 -2
- package/dist/esm/store/auth.js +1 -33
- package/dist/esm/validations/env.d.ts +2 -2
- package/dist/esm/validations/spContentModi.d.ts +8 -8
- package/dist/esm/validations/spRoute.d.ts +8 -8
- package/dist/gomtm +0 -0
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/esm/components/blog/BlogPostActions.d.ts +0 -4
- package/dist/esm/components/blog/BlogPostActions.js +0 -39
- package/dist/esm/components/blog/PostCard.d.ts +0 -5
- package/dist/esm/components/blog/PostCard.js +0 -62
- package/dist/esm/curd/CurdListView.d.ts +0 -13
- package/dist/esm/curd/CurdListView.js +0 -97
- package/dist/esm/curd/CurdListViewAuto.d.ts +0 -3
- package/dist/esm/curd/CurdListViewAuto.js +0 -15
- package/dist/esm/curd/CurdListViewV2.d.ts +0 -5
- package/dist/esm/curd/CurdListViewV2.js +0 -43
- package/dist/esm/curd/toolbar-buttons.d.ts +0 -3
- package/dist/esm/curd/toolbar-buttons.js +0 -12
- package/dist/esm/gomtm-clients-ss.d.ts +0 -9
- package/dist/esm/gomtm-clients-ss.js +0 -137
- package/dist/esm/gomtmcurd/gomtmcurd-detailview.d.ts +0 -2
- package/dist/esm/gomtmcurd/gomtmcurd-detailview.js +0 -19
- package/dist/esm/gomtmcurd/gomtmcurd-listview.d.ts +0 -2
- package/dist/esm/gomtmcurd/gomtmcurd-listview.js +0 -24
- package/dist/esm/gomtmcurd/hooks.d.ts +0 -1
- package/dist/esm/gomtmcurd/hooks.js +0 -16
- package/dist/esm/hooks/useAuth.d.ts +0 -5
- package/dist/esm/hooks/useAuth.js +0 -43
- package/dist/esm/store/auth.atoms.d.ts +0 -5
- package/dist/esm/store/auth.atoms.js +0 -27
- /package/dist/esm/{sscore.d.ts → store/gomtm.atom.d.ts} +0 -0
- /package/dist/esm/{sscore.js → store/gomtm.atom.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gomtm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.207",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"lucide-react": "^0.344.0",
|
|
70
70
|
"mtxlib": "*",
|
|
71
71
|
"mtxuilib": "*",
|
|
72
|
-
"next": "^14.2.
|
|
72
|
+
"next": "^14.2.2",
|
|
73
73
|
"next-nprogress-bar": "^2.3.4",
|
|
74
74
|
"path-to-regexp": "6.2.1",
|
|
75
75
|
"react": "^18.2.0",
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useAtom } from "jotai";
|
|
4
|
-
import { Icons } from "mtxuilib/icons/icons";
|
|
5
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
6
|
-
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
7
|
-
import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
|
|
8
|
-
import { curdSlugPathAtom } from "../../curd/CommonListViewV2";
|
|
9
|
-
const BlogPostItemActions = (props) => {
|
|
10
|
-
const { postId } = props;
|
|
11
|
-
const [curdSlugPath] = useAtom(curdSlugPathAtom);
|
|
12
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
13
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
14
|
-
MtButton,
|
|
15
|
-
{
|
|
16
|
-
variant: "ghost",
|
|
17
|
-
className: "data-[state=open]:bg-muted flex size-8 p-0",
|
|
18
|
-
children: [
|
|
19
|
-
/* @__PURE__ */ jsx(Icons.chevronRight, { className: "size-4" }),
|
|
20
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Open menu" })
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
) }),
|
|
24
|
-
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
|
|
25
|
-
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/${postId}/create`, children: "create" }),
|
|
26
|
-
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/show`, children: "show" }),
|
|
27
|
-
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit`, children: "edit" }),
|
|
28
|
-
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/listdebug`, children: "list debug" }),
|
|
29
|
-
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
30
|
-
/* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
|
|
31
|
-
"Delete",
|
|
32
|
-
/* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u2318\u232B" })
|
|
33
|
-
] })
|
|
34
|
-
] })
|
|
35
|
-
] });
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
BlogPostItemActions
|
|
39
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useAtom } from "jotai";
|
|
4
|
-
import { MtLink } from "mtxuilib/common/mtlink";
|
|
5
|
-
import { flexRender } from "mtxuilib/lib/render";
|
|
6
|
-
import { cn } from "mtxuilib/lib/utils";
|
|
7
|
-
import { useDebug } from "mtxuilib/store/app.atoms";
|
|
8
|
-
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
|
|
9
|
-
import { exampleListItemComponent } from "../../curd/CommonListViewV2";
|
|
10
|
-
import { curdActivateIdAtom, curdDashPathPrefixAtom } from "../../curd/curd.atoms";
|
|
11
|
-
import { BlogPostItemActions } from "./BlogPostActions";
|
|
12
|
-
const PostCard = (props) => {
|
|
13
|
-
const { item } = props;
|
|
14
|
-
const debug = useDebug();
|
|
15
|
-
const [curdActivateId, setcurdActivateId] = useAtom(curdActivateIdAtom);
|
|
16
|
-
const [dashPrefix] = useAtom(curdDashPathPrefixAtom);
|
|
17
|
-
const [Comp] = useAtom(exampleListItemComponent);
|
|
18
|
-
return /* @__PURE__ */ jsxs(
|
|
19
|
-
Card,
|
|
20
|
-
{
|
|
21
|
-
className: cn(
|
|
22
|
-
"w-[350px]",
|
|
23
|
-
item.id == curdActivateId && "bg-red-300 p-2",
|
|
24
|
-
debug.isDebug && "bg-blue-300"
|
|
25
|
-
),
|
|
26
|
-
onClick: () => {
|
|
27
|
-
setcurdActivateId(item.id);
|
|
28
|
-
},
|
|
29
|
-
children: [
|
|
30
|
-
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
31
|
-
/* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `${dashPrefix}/post/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
|
|
32
|
-
/* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
|
|
33
|
-
] }),
|
|
34
|
-
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
|
|
35
|
-
/* @__PURE__ */ jsx(MtLink, {
|
|
36
|
-
href: `/post/${item.id}`,
|
|
37
|
-
className: "hover:opacity-75",
|
|
38
|
-
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
39
|
-
children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
|
|
40
|
-
}),
|
|
41
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
|
|
42
|
-
/* @__PURE__ */ jsx(MtLink, { href: `/post/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
|
|
43
|
-
/* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
|
|
44
|
-
"By ",
|
|
45
|
-
/* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
|
|
46
|
-
","
|
|
47
|
-
] }),
|
|
48
|
-
/* @__PURE__ */ jsx("div", { children: item.excerpt })
|
|
49
|
-
] })
|
|
50
|
-
] }) }),
|
|
51
|
-
/* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
|
|
52
|
-
/* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/post/${item.id}`, children: "Show" }),
|
|
53
|
-
/* @__PURE__ */ jsx(BlogPostItemActions, { postId: item.id }),
|
|
54
|
-
Comp ? flexRender(Comp, {}) : /* @__PURE__ */ jsx("div", { children: "no comp" })
|
|
55
|
-
] })
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
export {
|
|
61
|
-
PostCard
|
|
62
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AnyMessage, Message, PlainMessage } from "@bufbuild/protobuf";
|
|
2
|
-
import { PropsWithChildren } from "react";
|
|
3
|
-
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
-
export declare function Curd3ListProvider<I extends Message<I>, O extends Message<O>>(props: {
|
|
5
|
-
params: Partial<PlainMessage<I>>;
|
|
6
|
-
methodList: MethodUnaryDescriptor<I, O>;
|
|
7
|
-
} & PropsWithChildren): import("react").JSX.Element;
|
|
8
|
-
export declare const useCurd3List: () => {
|
|
9
|
-
params: PlainMessage<AnyMessage>;
|
|
10
|
-
curd3MethodList: MethodUnaryDescriptor<AnyMessage, AnyMessage> | null;
|
|
11
|
-
};
|
|
12
|
-
export declare const Curd2ListView: () => import("react").JSX.Element;
|
|
13
|
-
export declare const Curd3ListViewDebug: () => import("react").JSX.Element;
|
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
-
import { atom, useAtom } from "jotai";
|
|
24
|
-
import { ScopeProvider } from "mtxlib/jotai/ScopeProvider";
|
|
25
|
-
import { AtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
26
|
-
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
27
|
-
import { callUnaryMethod } from "../connectquery";
|
|
28
|
-
import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
29
|
-
import { gomtmBaseUrlAtom, transportAtom } from "../providers/GomtmProvider";
|
|
30
|
-
import { ListItemView } from "./list-item/ListItem";
|
|
31
|
-
const curd3ListParamsAtom = atom({});
|
|
32
|
-
const curd3MethodListAtom = atom(null);
|
|
33
|
-
const curd3ItemsAtom = atom((get) => __async(void 0, null, function* () {
|
|
34
|
-
const params = get(curd3ListParamsAtom);
|
|
35
|
-
const methodList = get(curd3MethodListAtom);
|
|
36
|
-
if (!methodList) {
|
|
37
|
-
throw new Error("curd3ItemsAtom, missing methodList");
|
|
38
|
-
}
|
|
39
|
-
const transport = get(transportAtom);
|
|
40
|
-
const data = yield callUnaryMethod(methodList, params, { transport });
|
|
41
|
-
return data;
|
|
42
|
-
}));
|
|
43
|
-
function Curd3ListProvider(props) {
|
|
44
|
-
const { params, methodList, children } = props;
|
|
45
|
-
return /* @__PURE__ */ jsx(ScopeProvider, { atoms: [curd3ListParamsAtom, curd3MethodListAtom], children: /* @__PURE__ */ jsx(AtomsHydrator, { atomValues: [
|
|
46
|
-
[curd3ListParamsAtom, params],
|
|
47
|
-
[curd3MethodListAtom, methodList]
|
|
48
|
-
], children }) });
|
|
49
|
-
}
|
|
50
|
-
const useCurd3List = () => {
|
|
51
|
-
const [curd3ListParams] = useAtom(curd3ListParamsAtom);
|
|
52
|
-
const [curd3MethodList] = useAtom(curd3MethodListAtom);
|
|
53
|
-
return {
|
|
54
|
-
params: curd3ListParams,
|
|
55
|
-
curd3MethodList
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const Curd2ListView = () => {
|
|
59
|
-
const [res] = useAtom(curd3ItemsAtom);
|
|
60
|
-
return /* @__PURE__ */ jsx("div", { className: "bg-blue-100 p-2", children: res.errCode ? /* @__PURE__ */ jsx(MtUnaryCallErrorView, { unaryError: res }) : /* @__PURE__ */ jsx(Fragment, { children: res.items.map((item, i) => {
|
|
61
|
-
return /* @__PURE__ */ jsx(ListItemView, { item }, i);
|
|
62
|
-
}) }) });
|
|
63
|
-
};
|
|
64
|
-
const ListLayout = (props) => {
|
|
65
|
-
const { children } = props;
|
|
66
|
-
switch (props.layout) {
|
|
67
|
-
case ListViewLayout.simple:
|
|
68
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1 rounded-md p-2 shadow-sm", children });
|
|
69
|
-
case ListViewLayout.grid:
|
|
70
|
-
return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
|
|
71
|
-
case ListViewLayout.card:
|
|
72
|
-
return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
|
|
73
|
-
default:
|
|
74
|
-
return children;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const Curd3ListViewDebug = () => {
|
|
78
|
-
const curd3 = useCurd3List();
|
|
79
|
-
const [gomtmBaseUrl] = useAtom(gomtmBaseUrlAtom);
|
|
80
|
-
return /* @__PURE__ */ jsxs("div", { className: "bg-slate-200 p-2", children: [
|
|
81
|
-
/* @__PURE__ */ jsx("h1", { children: "Curd3ListViewDebug" }),
|
|
82
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
83
|
-
"params: ",
|
|
84
|
-
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(curd3, null, 2) })
|
|
85
|
-
] }),
|
|
86
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
87
|
-
"gomtmBaseUrl:",
|
|
88
|
-
gomtmBaseUrl
|
|
89
|
-
] })
|
|
90
|
-
] });
|
|
91
|
-
};
|
|
92
|
-
export {
|
|
93
|
-
Curd2ListView,
|
|
94
|
-
Curd3ListProvider,
|
|
95
|
-
Curd3ListViewDebug,
|
|
96
|
-
useCurd3List
|
|
97
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { usePathname } from "next/navigation";
|
|
4
|
-
function CurdListViewByPathname(props) {
|
|
5
|
-
const { children } = props;
|
|
6
|
-
const pathname = usePathname();
|
|
7
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("h1", { children: [
|
|
8
|
-
"CurdListViewByPathname(",
|
|
9
|
-
pathname,
|
|
10
|
-
")"
|
|
11
|
-
] }) }) });
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
CurdListViewByPathname
|
|
15
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useAtom } from "jotai";
|
|
4
|
-
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
5
|
-
import { usePathname } from "next/navigation";
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { useSuspenseQuery } from "../connectquery";
|
|
8
|
-
import { curdList } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
|
|
9
|
-
import { curd3ListParamsAtom, curdPathAtom } from "./curd.atoms";
|
|
10
|
-
import { ListItemView } from "./list-item/ListItem";
|
|
11
|
-
function Curd3ListProviderV2(props) {
|
|
12
|
-
const { params, children } = props;
|
|
13
|
-
const pathName = usePathname();
|
|
14
|
-
return /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
|
|
15
|
-
[curd3ListParamsAtom, params],
|
|
16
|
-
[curdPathAtom, pathName]
|
|
17
|
-
], children });
|
|
18
|
-
}
|
|
19
|
-
const Curd2ListViewV2 = () => {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const [slugPath] = useAtom(curdPathAtom);
|
|
22
|
-
const slug = useMemo(() => {
|
|
23
|
-
const path2 = slugPath.split("/");
|
|
24
|
-
if (path2.length >= 2) {
|
|
25
|
-
return path2[2];
|
|
26
|
-
}
|
|
27
|
-
}, [slugPath]);
|
|
28
|
-
const query = useSuspenseQuery(curdList, {
|
|
29
|
-
params: {
|
|
30
|
-
slugs: slug
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return /* @__PURE__ */ jsx("div", { className: "bg-blue-100 p-2", children: ((_a = query.data.error) == null ? void 0 : _a.code) ? /* @__PURE__ */ jsxs("div", { children: [
|
|
34
|
-
"error: ",
|
|
35
|
-
query.data.error.code
|
|
36
|
-
] }) : /* @__PURE__ */ jsx(Fragment, { children: (_b = query.data.items) == null ? void 0 : _b.map((item, i) => {
|
|
37
|
-
return /* @__PURE__ */ jsx(ListItemView, { item }, i);
|
|
38
|
-
}) }) });
|
|
39
|
-
};
|
|
40
|
-
export {
|
|
41
|
-
Curd2ListViewV2,
|
|
42
|
-
Curd3ListProviderV2
|
|
43
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
const CurdEditButton = () => {
|
|
4
|
-
return /* @__PURE__ */ jsx(Fragment, {});
|
|
5
|
-
};
|
|
6
|
-
const CurdCreateButton = () => {
|
|
7
|
-
return /* @__PURE__ */ jsx(Fragment, {});
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
CurdCreateButton,
|
|
11
|
-
CurdEditButton
|
|
12
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ServiceType } from "@bufbuild/protobuf";
|
|
2
|
-
export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
|
|
3
|
-
export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string): import("@connectrpc/connect").PromiseClient<ServiceType>;
|
|
4
|
-
type CustomRequestInit = RequestInit & {
|
|
5
|
-
enableCache?: boolean;
|
|
6
|
-
enableLog?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare const gomtmFetcher: (initGlobal?: CustomRequestInit) => (input: string | URL | globalThis.Request, init?: CustomRequestInit) => Promise<Response>;
|
|
9
|
-
export {};
|
|
@@ -1,137 +0,0 @@
|
|
|
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));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import { createPromiseClient } from "@connectrpc/connect";
|
|
41
|
-
import { createConnectTransport } from "@connectrpc/connect-web";
|
|
42
|
-
import { merge } from "lodash";
|
|
43
|
-
import { fetchMiddleWithCache } from "mtxlib/http/fetchMiddleWithCache";
|
|
44
|
-
import { MtmService } from "./gomtmpb/mtm/sppb/mtm_connect";
|
|
45
|
-
function createMtmServiceClient(service, url) {
|
|
46
|
-
const baseUrl = url || process.env.MTM_BACKEND;
|
|
47
|
-
if (!baseUrl) {
|
|
48
|
-
throw new Error("missing mtm api url,\xB7MTM_BACKEND\xB7");
|
|
49
|
-
}
|
|
50
|
-
console.info("gomtm baseUrl:", baseUrl);
|
|
51
|
-
return createPromiseClient(
|
|
52
|
-
service,
|
|
53
|
-
createConnectTransport({
|
|
54
|
-
baseUrl,
|
|
55
|
-
fetch: gomtmFetcher()
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
function createMtmServiceClientByName(svcName, url) {
|
|
60
|
-
const baseUrl = url || process.env.MTM_BACKEND;
|
|
61
|
-
if (!baseUrl) {
|
|
62
|
-
throw new Error("missing mtm api url,\xB7MTM_BACKEND\xB7");
|
|
63
|
-
}
|
|
64
|
-
console.info("gomtm baseUrl:", baseUrl);
|
|
65
|
-
let svcType = void 0;
|
|
66
|
-
for (const a of allServices) {
|
|
67
|
-
if (a.typeName == svcName) {
|
|
68
|
-
svcType = a;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!svcType) {
|
|
72
|
-
throw new Error(`unknown svcType ${svcName}`);
|
|
73
|
-
}
|
|
74
|
-
return createPromiseClient(
|
|
75
|
-
svcType,
|
|
76
|
-
createConnectTransport({
|
|
77
|
-
baseUrl,
|
|
78
|
-
fetch: gomtmFetcher()
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
const allServices = [MtmService];
|
|
83
|
-
const gomtmFetcher = (initGlobal) => {
|
|
84
|
-
return (input, init) => __async(void 0, null, function* () {
|
|
85
|
-
if (init) {
|
|
86
|
-
delete init.mode;
|
|
87
|
-
delete init.credentials;
|
|
88
|
-
}
|
|
89
|
-
const req = merge(init, initGlobal, {
|
|
90
|
-
redirect: "follow"
|
|
91
|
-
}) || {};
|
|
92
|
-
let headerCookie = "";
|
|
93
|
-
if (typeof window == "undefined") {
|
|
94
|
-
const reqHeaders = require("next/headers").headers();
|
|
95
|
-
headerCookie = reqHeaders.get("Cookie");
|
|
96
|
-
}
|
|
97
|
-
if (!init) {
|
|
98
|
-
init = {};
|
|
99
|
-
}
|
|
100
|
-
init = __spreadValues(__spreadValues({}, init), {
|
|
101
|
-
headers: __spreadValues(__spreadProps(__spreadValues({}, init.headers), {
|
|
102
|
-
"Content-Type": "application/json"
|
|
103
|
-
}), headerCookie && { "Cookie": headerCookie })
|
|
104
|
-
});
|
|
105
|
-
let fetcher = fetch;
|
|
106
|
-
req.enableCache = false;
|
|
107
|
-
if (req.enableCache) {
|
|
108
|
-
fetcher = fetchMiddleWithCache(fetch);
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
const responseData = yield fetcher(input, init);
|
|
112
|
-
return responseData;
|
|
113
|
-
} catch (e) {
|
|
114
|
-
console.error("[mtmfetch error]", {
|
|
115
|
-
input,
|
|
116
|
-
error: e,
|
|
117
|
-
init
|
|
118
|
-
});
|
|
119
|
-
const errorRsp = {
|
|
120
|
-
errCode: "-1",
|
|
121
|
-
errMessage: (e == null ? void 0 : e.toString()) || "unknow error"
|
|
122
|
-
};
|
|
123
|
-
const errorResponse = new Response(JSON.stringify(errorRsp), {
|
|
124
|
-
status: 200,
|
|
125
|
-
headers: {
|
|
126
|
-
"Content-Type": "application/json"
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return errorResponse;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
export {
|
|
134
|
-
createMtmServiceClient,
|
|
135
|
-
createMtmServiceClientByName,
|
|
136
|
-
gomtmFetcher
|
|
137
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useSuspenseQuery } from "../connectquery";
|
|
4
|
-
import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
5
|
-
import { useCurdSlugName } from "./hooks";
|
|
6
|
-
const GomtmCurdDetailView = () => {
|
|
7
|
-
const nameSlug = useCurdSlugName();
|
|
8
|
-
const curdGetQuery = useSuspenseQuery(curdViewGet, {
|
|
9
|
-
name: nameSlug
|
|
10
|
-
});
|
|
11
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "bg-blue-200 p-2", children: [
|
|
12
|
-
"nameSlug:",
|
|
13
|
-
nameSlug,
|
|
14
|
-
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(curdGetQuery.data, null, 2) })
|
|
15
|
-
] }) });
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
GomtmCurdDetailView
|
|
19
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useSuspenseQuery } from "../connectquery";
|
|
4
|
-
import { ListItemView } from "../curd/list-item/ListItem";
|
|
5
|
-
import { curdList } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
|
|
6
|
-
import { useCurdSlugName } from "./hooks";
|
|
7
|
-
const GomtmCurdListView = () => {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
const slugName = useCurdSlugName();
|
|
10
|
-
const listQuery = useSuspenseQuery(curdList, {
|
|
11
|
-
params: {
|
|
12
|
-
slugs: slugName
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return /* @__PURE__ */ jsx("div", { className: " bg-cyan-500", children: ((_a = listQuery.data.error) == null ? void 0 : _a.code) ? /* @__PURE__ */ jsxs("div", { children: [
|
|
16
|
-
"error: ",
|
|
17
|
-
listQuery.data.error.code
|
|
18
|
-
] }) : /* @__PURE__ */ jsx(Fragment, { children: (_b = listQuery.data.items) == null ? void 0 : _b.map((item, i) => {
|
|
19
|
-
return /* @__PURE__ */ jsx(ListItemView, { item }, i);
|
|
20
|
-
}) }) });
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
GomtmCurdListView
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useCurdSlugName: () => string | undefined;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { usePathname } from "next/navigation";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
const useCurdSlugName = () => {
|
|
5
|
-
const pathname = usePathname();
|
|
6
|
-
const nameSlug = useMemo(() => {
|
|
7
|
-
const a = pathname.split("/");
|
|
8
|
-
if (a.length >= 2) {
|
|
9
|
-
return a[2];
|
|
10
|
-
}
|
|
11
|
-
}, [pathname]);
|
|
12
|
-
return nameSlug;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
useCurdSlugName
|
|
16
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import React, { useEffect, useMemo } from "react";
|
|
22
|
-
import Cookies from "universal-cookie";
|
|
23
|
-
import { verifyJwtToken } from "../lib/auth/jwt";
|
|
24
|
-
function useAuth() {
|
|
25
|
-
const [auth, setAuth] = React.useState(null);
|
|
26
|
-
const getVerifiedtoken = () => __async(this, null, function* () {
|
|
27
|
-
var _a;
|
|
28
|
-
const cookies = new Cookies();
|
|
29
|
-
const token = (_a = cookies.get("token")) != null ? _a : null;
|
|
30
|
-
const verifiedToken = yield verifyJwtToken(token);
|
|
31
|
-
setAuth(verifiedToken);
|
|
32
|
-
});
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
getVerifiedtoken();
|
|
35
|
-
}, []);
|
|
36
|
-
const isAdmin = useMemo(() => {
|
|
37
|
-
return (auth == null ? void 0 : auth.role) == "admin";
|
|
38
|
-
}, [auth]);
|
|
39
|
-
return { auth, isAdmin };
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
useAuth
|
|
43
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { atom, useAtom } from "jotai";
|
|
3
|
-
const isAdminAtom = atom(false);
|
|
4
|
-
const useIsAdmin = () => {
|
|
5
|
-
const [isAdmin, setisAdmin] = useAtom(isAdminAtom);
|
|
6
|
-
return isAdmin;
|
|
7
|
-
};
|
|
8
|
-
function isRoleMatch(currentRoles, allowRoles) {
|
|
9
|
-
if (!currentRoles) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
if (!(allowRoles == null ? void 0 : allowRoles.length)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
for (const roleName of allowRoles) {
|
|
16
|
-
const ok = currentRoles.find((x) => x == roleName);
|
|
17
|
-
if (ok) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
isAdminAtom,
|
|
25
|
-
isRoleMatch,
|
|
26
|
-
useIsAdmin
|
|
27
|
-
};
|
|
File without changes
|
|
File without changes
|