gomtm 0.0.222 → 0.0.224
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 +25 -12
- package/dist/esm/curd/dlg/DlgCurdDebugInfo.js +2 -2
- package/dist/esm/mtmFetcher.d.ts +1 -0
- package/dist/esm/mtmFetcher.js +22 -18
- package/dist/esm/providers/GomtmAppSS.d.ts +0 -1
- package/dist/esm/providers/GomtmAppSS.js +9 -16
- package/dist/esm/providers/GomtmProvider.d.ts +4 -3
- package/dist/esm/providers/GomtmProvider.js +12 -5
- package/dist/esm/store/auth.d.ts +0 -4
- package/dist/esm/store/auth.js +1 -9
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -13,3 +13,4 @@ export declare function CommonListViewProvider<I extends Message<I>, O extends M
|
|
|
13
13
|
slugPath?: string;
|
|
14
14
|
} & PropsWithChildren): import("react").JSX.Element;
|
|
15
15
|
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
16
|
+
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
@@ -23,8 +23,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
23
23
|
import { atom, useAtom } from "jotai";
|
|
24
24
|
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
25
25
|
import { DebugAtomValue } from "mtxuilib/common/devtools/DebugAtomValue";
|
|
26
|
+
import { Icons } from "mtxuilib/icons/icons";
|
|
26
27
|
import { cn } from "mtxuilib/lib/utils";
|
|
27
28
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
29
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
28
30
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
29
31
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
30
32
|
import { Suspense } from "react";
|
|
@@ -113,18 +115,7 @@ function CommonListView() {
|
|
|
113
115
|
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
|
|
114
116
|
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { href: "#" }) })
|
|
115
117
|
] }) }),
|
|
116
|
-
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1" })
|
|
117
|
-
/* @__PURE__ */ jsxs(Suspense, { children: [
|
|
118
|
-
/* @__PURE__ */ jsx(PanelRemove, {}),
|
|
119
|
-
/* @__PURE__ */ jsx(PanelCreate, {}),
|
|
120
|
-
/* @__PURE__ */ jsx(DlgCurdDebugInfo, {}),
|
|
121
|
-
/* @__PURE__ */ jsx(CurdCreatePanel, {}),
|
|
122
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-yellow-100 p-2", children: [
|
|
123
|
-
/* @__PURE__ */ jsx(DlgCurdDebugInfoTriggerButton, {}),
|
|
124
|
-
/* @__PURE__ */ jsx(CurdEditPanelTriggerButton, {}),
|
|
125
|
-
/* @__PURE__ */ jsx(CurdCreatePanelTriggerButton, {})
|
|
126
|
-
] })
|
|
127
|
-
] })
|
|
118
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) })
|
|
128
119
|
] });
|
|
129
120
|
}
|
|
130
121
|
const PanelRemove = () => {
|
|
@@ -156,9 +147,31 @@ const PanelCreate = () => {
|
|
|
156
147
|
}), children: "ok" })
|
|
157
148
|
] }) });
|
|
158
149
|
};
|
|
150
|
+
const ListViewActions = () => {
|
|
151
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
152
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { variant: "ghost", className: "m-0 flex h-10 w-10 items-center justify-center border p-0 shadow-sm backdrop-blur", children: /* @__PURE__ */ jsx(Icons.ellipsis, {}) }) }),
|
|
153
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56", children: [
|
|
154
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Edit" }),
|
|
155
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
156
|
+
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
157
|
+
/* @__PURE__ */ jsx(PanelRemove, {}),
|
|
158
|
+
/* @__PURE__ */ jsx(PanelCreate, {}),
|
|
159
|
+
/* @__PURE__ */ jsx(DlgCurdDebugInfo, {}),
|
|
160
|
+
/* @__PURE__ */ jsx(CurdCreatePanel, {}),
|
|
161
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-yellow-100 p-2", children: [
|
|
162
|
+
/* @__PURE__ */ jsx(DlgCurdDebugInfoTriggerButton, {}),
|
|
163
|
+
/* @__PURE__ */ jsx(CurdEditPanelTriggerButton, {}),
|
|
164
|
+
/* @__PURE__ */ jsx(CurdCreatePanelTriggerButton, {})
|
|
165
|
+
] })
|
|
166
|
+
] }) }) }),
|
|
167
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {})
|
|
168
|
+
] })
|
|
169
|
+
] });
|
|
170
|
+
};
|
|
159
171
|
export {
|
|
160
172
|
CommonListView,
|
|
161
173
|
CommonListViewProvider,
|
|
174
|
+
ListViewActions,
|
|
162
175
|
curdSlugPathAtom,
|
|
163
176
|
exampleListItemComponent,
|
|
164
177
|
exampleListItemValueComponent
|
|
@@ -5,7 +5,7 @@ import { DebugAtomValue } from "mtxuilib/common/devtools/DebugAtomValue";
|
|
|
5
5
|
import { flexRender } from "mtxuilib/lib/render";
|
|
6
6
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
7
7
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
8
|
-
import { isDebugAtom } from "../../
|
|
8
|
+
import { isDebugAtom } from "../../providers/GomtmProvider";
|
|
9
9
|
import { exampleListItemComponent } from "../CommonListViewV2";
|
|
10
10
|
import { createMethodSigAtom, curdActivateIdAtom, removeMethodSigAtom } from "../curd.atoms";
|
|
11
11
|
const openDlgCurdDebugInfoAtom = atom(false);
|
|
@@ -30,7 +30,7 @@ const DlgCurdDebugInfoTriggerButton = () => {
|
|
|
30
30
|
}
|
|
31
31
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
32
32
|
setOpenDlgCurdDebugInfo(true);
|
|
33
|
-
}, children: "
|
|
33
|
+
}, children: "DlgCurdDebug" }) });
|
|
34
34
|
};
|
|
35
35
|
export {
|
|
36
36
|
DlgCurdDebugInfo,
|
package/dist/esm/mtmFetcher.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServiceType } from "@bufbuild/protobuf";
|
|
2
|
+
export declare const ssrGetBackendUrl: () => string;
|
|
2
3
|
export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
|
|
3
4
|
export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string): import("@connectrpc/connect").PromiseClient<ServiceType>;
|
|
4
5
|
type CustomRequestInit = RequestInit & {
|
package/dist/esm/mtmFetcher.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
var __async = (__this, __arguments, generator) => {
|
|
21
18
|
return new Promise((resolve, reject) => {
|
|
22
19
|
var fulfilled = (value) => {
|
|
@@ -40,18 +37,27 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
37
|
import { createPromiseClient } from "@connectrpc/connect";
|
|
41
38
|
import { createConnectTransport } from "@connectrpc/connect-web";
|
|
42
39
|
import { merge } from "lodash";
|
|
43
|
-
import { fetchMiddleWithCache } from "mtxlib/http/fetchMiddleWithCache";
|
|
44
40
|
import { MtmService } from "./gomtmpb/mtm/sppb/mtm_connect";
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
41
|
+
const ssrGetBackendUrl = () => {
|
|
42
|
+
var _a;
|
|
43
|
+
if (typeof window == "undefined") {
|
|
44
|
+
if ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.MTM_BACKEND) {
|
|
45
|
+
return process.env.MTM_BACKEND;
|
|
46
|
+
}
|
|
47
|
+
if (process.env.VERCEL_URL) {
|
|
48
|
+
return `https://${process.env.VERCEL_URL}`;
|
|
49
|
+
}
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
+
return "https://localhost";
|
|
52
|
+
};
|
|
53
|
+
function createMtmServiceClient(service, url) {
|
|
54
|
+
const baseUrl = ssrGetBackendUrl();
|
|
55
|
+
const apiUrl = new URL("/api", baseUrl).toString();
|
|
56
|
+
console.info("gomtm apiUrl:", baseUrl);
|
|
51
57
|
return createPromiseClient(
|
|
52
58
|
service,
|
|
53
59
|
createConnectTransport({
|
|
54
|
-
baseUrl,
|
|
60
|
+
baseUrl: apiUrl,
|
|
55
61
|
fetch: gomtmFetcher()
|
|
56
62
|
})
|
|
57
63
|
);
|
|
@@ -93,15 +99,12 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
93
99
|
init = {};
|
|
94
100
|
}
|
|
95
101
|
init = __spreadValues(__spreadValues({}, init), {
|
|
96
|
-
headers: __spreadValues(
|
|
102
|
+
headers: __spreadValues({
|
|
103
|
+
// ...init.headers,
|
|
97
104
|
"Content-Type": "application/json"
|
|
98
|
-
}
|
|
105
|
+
}, (initGlobal == null ? void 0 : initGlobal.cookieStr) && { "Cookie": initGlobal == null ? void 0 : initGlobal.cookieStr })
|
|
99
106
|
});
|
|
100
|
-
|
|
101
|
-
req.enableCache = false;
|
|
102
|
-
if (req.enableCache) {
|
|
103
|
-
fetcher = fetchMiddleWithCache(fetch);
|
|
104
|
-
}
|
|
107
|
+
const fetcher = fetch;
|
|
105
108
|
try {
|
|
106
109
|
console.info("[mtmfetch]", {
|
|
107
110
|
input,
|
|
@@ -132,5 +135,6 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
132
135
|
export {
|
|
133
136
|
createMtmServiceClient,
|
|
134
137
|
createMtmServiceClientByName,
|
|
135
|
-
gomtmFetcher
|
|
138
|
+
gomtmFetcher,
|
|
139
|
+
ssrGetBackendUrl
|
|
136
140
|
};
|
|
@@ -19,7 +19,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
22
|
-
import {
|
|
22
|
+
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
23
|
+
import { headers } from "next/headers";
|
|
24
|
+
import { GomtmProvider, cookiesAtom } from "./GomtmProvider";
|
|
25
|
+
import { ssrGetBackendUrl } from "../mtmFetcher";
|
|
23
26
|
function GomtmAppSS(props) {
|
|
24
27
|
return __async(this, null, function* () {
|
|
25
28
|
const { children } = props;
|
|
@@ -27,22 +30,12 @@ function GomtmAppSS(props) {
|
|
|
27
30
|
if (!backend) {
|
|
28
31
|
return /* @__PURE__ */ jsx(Fragment, { children: "missing backend" });
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
const cookiesStr = headers().get("Cookie");
|
|
34
|
+
return /* @__PURE__ */ jsx(GomtmProvider, { backendUrl: backend, children: /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
|
|
35
|
+
[cookiesAtom, cookiesStr]
|
|
36
|
+
], children }) });
|
|
31
37
|
});
|
|
32
38
|
}
|
|
33
|
-
const ssrGetBackendUrl = () => {
|
|
34
|
-
var _a;
|
|
35
|
-
if (typeof window == "undefined") {
|
|
36
|
-
if ((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.MTM_BACKEND) {
|
|
37
|
-
return process.env.MTM_BACKEND;
|
|
38
|
-
}
|
|
39
|
-
if (process.env.VERCEL_URL) {
|
|
40
|
-
return `https://${process.env.VERCEL_URL}`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return "https://localhost";
|
|
44
|
-
};
|
|
45
39
|
export {
|
|
46
|
-
GomtmAppSS
|
|
47
|
-
ssrGetBackendUrl
|
|
40
|
+
GomtmAppSS
|
|
48
41
|
};
|
|
@@ -46,10 +46,11 @@ export type ActionHandler = (props: {
|
|
|
46
46
|
export declare const gomtmBaseUrlAtom: import("jotai").PrimitiveAtom<string> & {
|
|
47
47
|
init: string;
|
|
48
48
|
};
|
|
49
|
-
export declare const
|
|
50
|
-
|
|
49
|
+
export declare const cookiesAtom: import("jotai").WritableAtom<string | undefined, [value: string], void>;
|
|
50
|
+
export declare const isDebugValueAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
51
|
+
init: boolean;
|
|
51
52
|
};
|
|
52
|
-
export declare const
|
|
53
|
+
export declare const isDebugAtom: import("jotai").WritableAtom<boolean, [value: boolean], void>;
|
|
53
54
|
export declare const transportAtom: import("jotai").Atom<Transport>;
|
|
54
55
|
export declare const useGomtmBackend: () => {
|
|
55
56
|
gomtmBaseUrl: string;
|
|
@@ -7,7 +7,6 @@ import { AtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
|
7
7
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
8
8
|
import { TransportProvider } from "../connectquery";
|
|
9
9
|
import { gomtmFetcher } from "../mtmFetcher";
|
|
10
|
-
import { isDebugAtom } from "../store/gomtm.atom";
|
|
11
10
|
import { MtReactQueryProvider } from "./ReactQueryProvider";
|
|
12
11
|
const mtmAppStore = createStore();
|
|
13
12
|
const gomtmBaseUrlAtom = atom("");
|
|
@@ -26,17 +25,24 @@ const cookiesValueAtom = atom(void 0);
|
|
|
26
25
|
const cookiesAtom = atom((get) => {
|
|
27
26
|
const v = get(cookiesValueAtom);
|
|
28
27
|
return v;
|
|
28
|
+
}, (_, set, value) => {
|
|
29
|
+
set(cookiesValueAtom, value);
|
|
30
|
+
});
|
|
31
|
+
const isDebugValueAtom = atom(false);
|
|
32
|
+
const isDebugAtom = atom((get) => {
|
|
33
|
+
return get(isDebugValueAtom);
|
|
34
|
+
}, (_, set, value) => {
|
|
35
|
+
set(isDebugValueAtom, value);
|
|
29
36
|
});
|
|
30
37
|
const transportAtom = atom((get) => {
|
|
31
38
|
const baseUrl = get(curd3BackendUrlAtom);
|
|
32
|
-
const baseUrl2 = new URL("/api", baseUrl).toString();
|
|
33
39
|
const cookiesStr = get(cookiesAtom);
|
|
34
40
|
console.log("transportAtom :", {
|
|
35
|
-
|
|
41
|
+
baseUrl,
|
|
36
42
|
cookiesStr
|
|
37
43
|
});
|
|
38
44
|
return createConnectTransport({
|
|
39
|
-
baseUrl
|
|
45
|
+
baseUrl,
|
|
40
46
|
fetch: gomtmFetcher({
|
|
41
47
|
cookieStr: cookiesStr
|
|
42
48
|
})
|
|
@@ -88,8 +94,9 @@ export {
|
|
|
88
94
|
GomtmProvider,
|
|
89
95
|
MtConnectProvider,
|
|
90
96
|
cookiesAtom,
|
|
91
|
-
cookiesValueAtom,
|
|
92
97
|
gomtmBaseUrlAtom,
|
|
98
|
+
isDebugAtom,
|
|
99
|
+
isDebugValueAtom,
|
|
93
100
|
mtmAppStore,
|
|
94
101
|
transportAtom,
|
|
95
102
|
useGomtmBackend,
|
package/dist/esm/store/auth.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export declare const isAdminAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
2
|
-
init: boolean;
|
|
3
|
-
};
|
|
4
|
-
export declare const useIsAdmin: () => boolean;
|
|
5
1
|
export declare function isRoleMatch(currentRoles: string[], allowRoles?: string[]): boolean;
|
|
6
2
|
import { MyJWTPayload } from "../lib/auth/jwt";
|
|
7
3
|
export declare function useAuth(): {
|
package/dist/esm/store/auth.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
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
2
|
function isRoleMatch(currentRoles, allowRoles) {
|
|
9
3
|
if (!currentRoles) {
|
|
10
4
|
return true;
|
|
@@ -36,8 +30,6 @@ function useAuth() {
|
|
|
36
30
|
return { auth, userId, isAdmin };
|
|
37
31
|
}
|
|
38
32
|
export {
|
|
39
|
-
isAdminAtom,
|
|
40
33
|
isRoleMatch,
|
|
41
|
-
useAuth
|
|
42
|
-
useIsAdmin
|
|
34
|
+
useAuth
|
|
43
35
|
};
|