gomtm 0.0.256 → 0.0.258

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.
@@ -1,6 +1,6 @@
1
1
  import { exec } from "mtxlib/exec";
2
2
  import { resolve } from "path";
3
- import { projectRoot } from "../utils";
3
+ import { projectRoot } from "./utils";
4
4
  function cmdDeployMtworker(program) {
5
5
  program.command("deploy_mtworker").action(() => {
6
6
  const vercelToken = process.env.VERCEL_TOKEN;
@@ -0,0 +1 @@
1
+ export declare const projectRoot: string;
@@ -0,0 +1,5 @@
1
+ import { resolve } from "path";
2
+ const projectRoot = resolve("../..");
3
+ export {
4
+ projectRoot
5
+ };
@@ -6,7 +6,7 @@ import { Avatar, AvatarFallback, AvatarImage } from "mtxuilib/ui/avatar";
6
6
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
7
7
  import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
8
8
  import { usePathname } from "next/navigation";
9
- import { useAuth } from "../store/auth";
9
+ import { useAuth } from "../providers/AuthProvider";
10
10
  function UserAvatorMenus() {
11
11
  const pathName = usePathname();
12
12
  const auth = useAuth();
@@ -0,0 +1,7 @@
1
+ export declare function isRoleMatch(currentRoles: string[], allowRoles?: string[]): boolean;
2
+ import { MyJWTPayload } from "../lib/auth/jwt";
3
+ export declare function useAuth(): {
4
+ auth: MyJWTPayload | null;
5
+ userId: string | undefined;
6
+ isAdmin: boolean;
7
+ };
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ function isRoleMatch(currentRoles, allowRoles) {
3
+ if (!currentRoles) {
4
+ return true;
5
+ }
6
+ if (!(allowRoles == null ? void 0 : allowRoles.length)) {
7
+ return true;
8
+ }
9
+ for (const roleName of allowRoles) {
10
+ const ok = currentRoles.find((x) => x == roleName);
11
+ if (ok) {
12
+ return true;
13
+ }
14
+ }
15
+ return false;
16
+ }
17
+ import React, { useMemo } from "react";
18
+ import { useSuspenseQuery } from "../connectquery";
19
+ import { userinfo } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
20
+ 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);
26
+ const userId = useMemo(() => {
27
+ var _a;
28
+ return (_a = userInfoQuery.data.userInfo) == null ? void 0 : _a.ID;
29
+ }, [userInfoQuery.data]);
30
+ return { auth, userId, isAdmin };
31
+ }
32
+ export {
33
+ isRoleMatch,
34
+ useAuth
35
+ };
@@ -0,0 +1,10 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare function LoggerProvider(props: {} & PropsWithChildren): import("react").JSX.Element;
3
+ export declare function useLogger(): {
4
+ info: {
5
+ (...data: any[]): void;
6
+ (...data: any[]): void;
7
+ (...data: any[]): void;
8
+ (message?: any, ...optionalParams: any[]): void;
9
+ };
10
+ };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { mtlogger } from "mtxlib/mt-logger";
4
+ import { createContext, useContext, useState } from "react";
5
+ const LoggerContext = createContext(void 0);
6
+ function LoggerProvider(props) {
7
+ const { children } = props;
8
+ const [_logger, setLogger] = useState(mtlogger);
9
+ return /* @__PURE__ */ jsx(LoggerContext.Provider, { value: {
10
+ logger: _logger
11
+ }, children });
12
+ }
13
+ function useLogger() {
14
+ const context = useContext(LoggerContext);
15
+ if (context === void 0) {
16
+ throw new Error("useLogger must be used within a LoggerProvider");
17
+ }
18
+ return { info: mtlogger.log };
19
+ }
20
+ export {
21
+ LoggerProvider,
22
+ useLogger
23
+ };
@@ -29,7 +29,7 @@ const MtReactQueryProvider = (props) => {
29
29
  }
30
30
  }
31
31
  }));
32
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(RqErrorBoundary, { children: /* @__PURE__ */ jsx(ReactQueryStreamedHydration, { children }) }) }) });
32
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(RqErrorBoundary, { children: /* @__PURE__ */ jsx(ReactQueryStreamedHydration, { children }) }) });
33
33
  };
34
34
  function RqErrorBoundary(props) {
35
35
  const { children } = props;
@@ -21,17 +21,17 @@ export declare const spContentModiCreateInput: z.ZodObject<{
21
21
  action: z.ZodString;
22
22
  value: z.ZodString;
23
23
  }, "strip", z.ZodTypeAny, {
24
- action: string;
25
24
  value: string;
26
- sel: string;
25
+ action: string;
27
26
  spRouteId: string;
27
+ sel: string;
28
28
  matchContentType: string;
29
29
  title?: string | undefined;
30
30
  }, {
31
- action: string;
32
31
  value: string;
33
- sel: string;
32
+ action: string;
34
33
  spRouteId: string;
34
+ sel: string;
35
35
  matchContentType: string;
36
36
  title?: string | undefined;
37
37
  }>;
@@ -45,18 +45,18 @@ export declare const spContentModiSaveInput: z.ZodObject<{
45
45
  value: z.ZodString;
46
46
  }, "strip", z.ZodTypeAny, {
47
47
  id: string;
48
- action: string;
49
48
  value: string;
50
- sel: string;
49
+ action: string;
51
50
  spRouteId: string;
51
+ sel: string;
52
52
  matchContentType: string;
53
53
  title?: string | undefined;
54
54
  }, {
55
55
  id: string;
56
- action: string;
57
56
  value: string;
58
- sel: string;
57
+ action: string;
59
58
  spRouteId: string;
59
+ sel: string;
60
60
  matchContentType: string;
61
61
  title?: string | undefined;
62
62
  }>;
@@ -21,16 +21,16 @@ export declare const spRouteCreateInput: z.ZodObject<{
21
21
  value: z.ZodString;
22
22
  }, "strip", z.ZodTypeAny, {
23
23
  title: string;
24
- spProjectId: string;
24
+ value: string;
25
25
  hostPattern: string;
26
26
  pathPattern: string;
27
- value: string;
27
+ spProjectId: string;
28
28
  }, {
29
29
  title: string;
30
- spProjectId: string;
30
+ value: string;
31
31
  hostPattern: string;
32
32
  pathPattern: string;
33
- value: string;
33
+ spProjectId: string;
34
34
  }>;
35
35
  export type SpRouteSaveInput = z.infer<typeof SpRouteSaveInput>;
36
36
  export declare const SpRouteSaveInput: z.ZodObject<{
@@ -41,17 +41,17 @@ export declare const SpRouteSaveInput: z.ZodObject<{
41
41
  pathPattern: z.ZodString;
42
42
  value: z.ZodString;
43
43
  }, "strip", z.ZodTypeAny, {
44
- id: string;
45
44
  title: string;
46
- spProjectId: string;
45
+ id: string;
46
+ value: string;
47
47
  hostPattern: string;
48
48
  pathPattern: string;
49
- value: string;
49
+ spProjectId: string;
50
50
  }, {
51
- id: string;
52
51
  title: string;
53
- spProjectId: string;
52
+ id: string;
53
+ value: string;
54
54
  hostPattern: string;
55
55
  pathPattern: string;
56
- value: string;
56
+ spProjectId: string;
57
57
  }>;
@@ -40,25 +40,25 @@ export declare const Oauth2LoginResponseSchema: z.ZodObject<{
40
40
  accessToken: z.ZodString;
41
41
  roles: z.ZodArray<z.ZodString, "many">;
42
42
  }, "strip", z.ZodTypeAny, {
43
- accessToken: string;
44
43
  id: string;
45
- userName: string;
44
+ accessToken: string;
46
45
  roles: string[];
46
+ userName: string;
47
47
  }, {
48
- accessToken: string;
49
48
  id: string;
50
- userName: string;
49
+ accessToken: string;
51
50
  roles: string[];
51
+ userName: string;
52
52
  }>;
53
53
  export type Oauth2LoginResponse = z.infer<typeof Oauth2LoginResponseSchema>;
54
54
  export declare const MeResponseSchema: z.ZodObject<{
55
55
  userName: z.ZodString;
56
56
  roles: z.ZodArray<z.ZodString, "many">;
57
57
  }, "strip", z.ZodTypeAny, {
58
- userName: string;
59
58
  roles: string[];
60
- }, {
61
59
  userName: string;
60
+ }, {
62
61
  roles: string[];
62
+ userName: string;
63
63
  }>;
64
64
  export type MeResponse = z.infer<typeof MeResponseSchema>;