gomtm 0.0.164 → 0.0.165

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.
@@ -55,8 +55,6 @@ export declare const CurdViewView: (props: {
55
55
  export declare function useCurdView(): {
56
56
  curdView: CurdView;
57
57
  openShow: (id: string) => void;
58
- invalidateList: () => Promise<void>;
59
- invalidateGet: () => Promise<void>;
60
58
  activateId: string;
61
59
  setActivateId: (args_0: string | ((prev: string) => string)) => void;
62
60
  editLink: (id: string) => string;
@@ -1,24 +1,4 @@
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 { Fragment, jsx } from "react/jsx-runtime";
23
3
  import { useQueryClient } from "@tanstack/react-query";
24
4
  import { atom, createStore, useAtom } from "jotai";
@@ -28,7 +8,6 @@ import { compile, match } from "path-to-regexp";
28
8
  import { useCallback, useMemo } from "react";
29
9
  import { useSuspenseQuery } from "../connectquery";
30
10
  import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
31
- import { createInfiniteQueryKey, createQueryKey } from "../mtmquery";
32
11
  const activateIdAtom = atom("0");
33
12
  const curdViewAtom = atom(null);
34
13
  const curdViewIdAtom = atom("");
@@ -63,20 +42,6 @@ function useCurdView() {
63
42
  router.push(showLink(id));
64
43
  }
65
44
  }, [router, showLink]);
66
- const invalidateList = useCallback(() => __async(this, null, function* () {
67
- if (curdView) {
68
- yield queryClient.invalidateQueries({
69
- queryKey: createInfiniteQueryKey(curdView.svcName, curdView.methodList)
70
- });
71
- }
72
- }), [curdView, queryClient]);
73
- const invalidateGet = useCallback(() => __async(this, null, function* () {
74
- if (curdView) {
75
- yield queryClient.invalidateQueries({
76
- queryKey: createQueryKey(curdView.svcName, curdView.methodGet)
77
- });
78
- }
79
- }), [curdView, queryClient]);
80
45
  const editLink = useCallback((id) => {
81
46
  if (curdView == null ? void 0 : curdView.routeEdit) {
82
47
  const toPath = compile(curdView == null ? void 0 : curdView.routeEdit, { encode: encodeURIComponent });
@@ -106,8 +71,8 @@ function useCurdView() {
106
71
  return {
107
72
  curdView,
108
73
  openShow,
109
- invalidateList,
110
- invalidateGet,
74
+ // invalidateList,
75
+ // invalidateGet,
111
76
  activateId,
112
77
  setActivateId,
113
78
  editLink,
@@ -1,3 +0,0 @@
1
- export type * from '@tanstack/react-query';
2
- export declare function createQueryKey(svc: string, method: string, input?: any): any[];
3
- export declare function createInfiniteQueryKey(svc: string, method: string, input?: any): any[];
@@ -1,12 +1 @@
1
1
  "use client";
2
- import { camelCase, upperFirst } from "lodash";
3
- function createQueryKey(svc, method, input) {
4
- return [svc, upperFirst(camelCase(method)), input || {}];
5
- }
6
- function createInfiniteQueryKey(svc, method, input) {
7
- return [...createQueryKey(svc, method, input), "infinite"];
8
- }
9
- export {
10
- createInfiniteQueryKey,
11
- createQueryKey
12
- };
@@ -1,9 +1 @@
1
- import React, { PropsWithChildren } from 'react';
2
- import { ConnectError, PartialMessage } from '..';
3
- import { LoginReply, LoginReq } from '../gomtmpb/mtm/sppb/mtm_pb';
4
- import { UseMutationResult } from '../mtmquery';
5
- export declare function UserProvider(props: {} & PropsWithChildren): React.JSX.Element;
6
1
  export declare function isRoleMatch(currentRoles: string[], allowRoles?: string[]): boolean;
7
- export declare const useAuth: () => {
8
- login: UseMutationResult<LoginReply, ConnectError, PartialMessage<LoginReq>>;
9
- };
@@ -1,18 +1,4 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import React from "react";
4
- import { useMutation, useSuspenseQuery } from "../connectquery";
5
- import { MtM_TOKEN_NAME } from "../consts";
6
- import { login, userinfo } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
7
- import { useToken } from "./GomtmProvider";
8
- const UserContext = React.createContext(void 0);
9
- function UserProvider(props) {
10
- const { children } = props;
11
- const query = useSuspenseQuery(userinfo, {});
12
- return /* @__PURE__ */ jsx(UserContext.Provider, { value: {
13
- userInfo: query.data
14
- }, children });
15
- }
16
2
  function isRoleMatch(currentRoles, allowRoles) {
17
3
  if (!currentRoles) {
18
4
  return true;
@@ -28,20 +14,6 @@ function isRoleMatch(currentRoles, allowRoles) {
28
14
  }
29
15
  return false;
30
16
  }
31
- const useAuth = () => {
32
- const { token, setToken } = useToken();
33
- const loginMutation = useMutation(login, {
34
- onSuccess(data, variables, context) {
35
- setToken(data.accessToken);
36
- document.cookie = `${MtM_TOKEN_NAME}=${data.accessToken}`;
37
- }
38
- });
39
- return {
40
- login: loginMutation
41
- };
42
- };
43
17
  export {
44
- UserProvider,
45
- isRoleMatch,
46
- useAuth
18
+ isRoleMatch
47
19
  };