gomtm 0.0.163 → 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,14 +1 @@
1
- import { Message, PartialMessage, ServiceType } from "@bufbuild/protobuf";
2
- import { PlainMessage } from ".";
3
- import { MtmError } from "./gomtmpb/mtm/sppb/mtm_pb";
4
- import { ExtInfo } from "./mtmcore";
5
- type CustomRequestInit = RequestInit & {
6
- enableCache?: boolean;
7
- enableLog?: boolean;
8
- };
9
- export declare const newMtmFetch: (extInfo: ExtInfo, initGlobal?: CustomRequestInit) => (input: string | URL | globalThis.Request, init?: CustomRequestInit) => Promise<Response>;
10
1
  export declare function getMtmApiUrl(backendUrl: string): string;
11
- export declare function createMtConnectTransport(backendUrl: string, extInfo: ExtInfo): import("@connectrpc/connect").Transport;
12
- export declare function createClient<T extends ServiceType>(extInfo: ExtInfo, svc: T, options: CustomRequestInit): import("@connectrpc/connect").PromiseClient<T>;
13
- export declare function mtmCallUnaryMethod<I extends Message<I>, O extends Message<O>>(extInfo: ExtInfo, svc: string, method: string, input?: PartialMessage<I> | undefined): Promise<O | PlainMessage<MtmError>>;
14
- export {};
@@ -1,153 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __async = (__this, __arguments, generator) => {
18
- return new Promise((resolve, reject) => {
19
- var fulfilled = (value) => {
20
- try {
21
- step(generator.next(value));
22
- } catch (e) {
23
- reject(e);
24
- }
25
- };
26
- var rejected = (value) => {
27
- try {
28
- step(generator.throw(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
- step((generator = generator.apply(__this, __arguments)).next());
35
- });
36
- };
37
- import { createPromiseClient } from "@connectrpc/connect";
38
- import { createConnectTransport } from "@connectrpc/connect-web";
39
- import { camelCase, merge } from "lodash";
40
- import { fetchMiddleWithCache } from "mtxlib/http/fetchMiddleWithCache";
41
- import { HeaderMtmHost } from "./consts";
42
- import { MtmError } from "./gomtmpb/mtm/sppb/mtm_pb";
43
- import { GetMtmServiceByTypeName, anypbTypeReg } from "./messageTypeRegistry";
44
- import { extGetMemBackend, extGetSitehost, extGetToken } from "./mtmcore";
45
- const newMtmFetch = (extInfo, initGlobal) => {
46
- return (input, init) => __async(void 0, null, function* () {
47
- if (init) {
48
- delete init.mode;
49
- delete init.credentials;
50
- }
51
- const req = merge(init, initGlobal, {
52
- redirect: "follow"
53
- }) || {};
54
- const token = extGetToken(extInfo);
55
- if (token) {
56
- req.headers.set("Authorization", `Bearer ${token}`);
57
- }
58
- const siteHost = extGetSitehost(extInfo);
59
- if (siteHost) {
60
- req.headers.set(HeaderMtmHost, siteHost);
61
- }
62
- let fetcher = fetch;
63
- if (req.enableCache) {
64
- fetcher = fetchMiddleWithCache(fetch);
65
- }
66
- if (req.enableLog) {
67
- fetcher = fetchWithLoger(fetcher);
68
- }
69
- try {
70
- const responseData = yield fetcher(input, init);
71
- return responseData;
72
- } catch (e) {
73
- console.error("mtmfetch error", e);
74
- const errorRsp = {
75
- errCode: "-1",
76
- errMessage: (e == null ? void 0 : e.toString()) || "unknow error"
77
- };
78
- const errorResponse = new Response(JSON.stringify(errorRsp), {
79
- status: 200,
80
- headers: {
81
- "Content-Type": "application/json"
82
- }
83
- });
84
- return errorResponse;
85
- }
86
- });
87
- };
88
1
  function getMtmApiUrl(backendUrl) {
89
2
  return backendUrl + "/api";
90
3
  }
91
- function createMtConnectTransport(backendUrl, extInfo) {
92
- return createConnectTransport({
93
- baseUrl: getMtmApiUrl(backendUrl),
94
- fetch: newMtmFetch(extInfo),
95
- jsonOptions: {
96
- typeRegistry: anypbTypeReg
97
- }
98
- });
99
- }
100
- function createClient(extInfo, svc, options) {
101
- const backendUrl = extGetMemBackend(extInfo);
102
- return createPromiseClient(svc, createConnectTransport({
103
- baseUrl: getMtmApiUrl(backendUrl || ""),
104
- fetch: newMtmFetch(extInfo, __spreadValues({}, options))
105
- }));
106
- }
107
- function mtmCallUnaryMethod(extInfo, svc, method, input) {
108
- return __async(this, null, function* () {
109
- if (!method) {
110
- throw new Error(`missing method: "${method}"`);
111
- }
112
- const service = GetMtmServiceByTypeName(svc);
113
- if (!service) {
114
- throw new Error(`not service by name ${svc}`);
115
- }
116
- const methodName = camelCase(method);
117
- console.log(`[unary] ${svc}.${methodName}`, input);
118
- const client = createClient(extInfo, service, {
119
- enableCache: false
120
- });
121
- const fn = client[methodName];
122
- if (!fn) {
123
- return new MtmError({
124
- errCode: "-2",
125
- errMessage: `missing method ${svc}.${methodName}`
126
- });
127
- }
128
- try {
129
- const result = yield client[methodName](input);
130
- return result;
131
- } catch (e) {
132
- console.error("[mtmCallUnaryMethod error]", e.stack);
133
- const errorRsp = {
134
- errCode: "-2",
135
- errMessage: (e == null ? void 0 : e.toString()) || "unknow error"
136
- };
137
- return errorRsp;
138
- }
139
- });
140
- }
141
- function fetchWithLoger(fetcher) {
142
- return (input, init) => __async(this, null, function* () {
143
- const response = yield fetcher(input, init);
144
- return response;
145
- });
146
- }
147
4
  export {
148
- createClient,
149
- createMtConnectTransport,
150
- getMtmApiUrl,
151
- mtmCallUnaryMethod,
152
- newMtmFetch
5
+ getMtmApiUrl
153
6
  };
@@ -1,5 +0,0 @@
1
- export type ExtInfo = (key: string) => string | null | undefined;
2
- export declare const extGetToken: (extInfo: ExtInfo) => string | null | undefined;
3
- export declare const extGetMemBackend: (extInfo: ExtInfo) => string | null | undefined;
4
- export declare const extGetSitehost: (extInfo: ExtInfo) => string | null | undefined;
5
- export declare const headersGet: (name: string, headers: Record<string, any>) => any;
@@ -1,19 +0,0 @@
1
- import { ExtKey_Hostname, ExtKey_mtmaccessToken, ExtKey_mtmbackend } from "./consts";
2
- const extGetToken = (extInfo) => {
3
- return extInfo(ExtKey_mtmaccessToken);
4
- };
5
- const extGetMemBackend = (extInfo) => {
6
- return extInfo(ExtKey_mtmbackend);
7
- };
8
- const extGetSitehost = (extInfo) => {
9
- return extInfo(ExtKey_Hostname);
10
- };
11
- const headersGet = (name, headers) => {
12
- return headers[name];
13
- };
14
- export {
15
- extGetMemBackend,
16
- extGetSitehost,
17
- extGetToken,
18
- headersGet
19
- };
@@ -1,9 +0,0 @@
1
- import { InfiniteData, UseMutationResult, UseSuspenseInfiniteQueryResult, UseSuspenseQueryResult } from "@tanstack/react-query";
2
- import { Message, PlainMessage } from ".";
3
- import { MtmError } from "./gomtmpb/mtm/sppb/mtm_pb";
4
- export type * from '@tanstack/react-query';
5
- export declare function createQueryKey(svc: string, method: string, input?: any): any[];
6
- export declare function createInfiniteQueryKey(svc: string, method: string, input?: any): any[];
7
- export declare function useMtmSuspenseQuery<T extends Message<T>>(serviceName: string, methodName: string, input?: any): UseSuspenseQueryResult<T>;
8
- export declare function useMtmSuspenseInfiniteQuery<T extends Message<T>>(serviceName: string, methodName: string, input?: any): UseSuspenseInfiniteQueryResult<InfiniteData<T & PlainMessage<MtmError>>, PlainMessage<MtmError>>;
9
- export declare function useMtmMutation(serviceName: string, methodName: string): UseMutationResult<any>;
@@ -1,75 +1 @@
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
- import { toPlainMessage } from "@bufbuild/protobuf";
23
- import { useMutation, useSuspenseInfiniteQuery, useSuspenseQuery } from "@tanstack/react-query";
24
- import { camelCase, upperFirst } from "lodash";
25
- import { mtmCallUnaryMethod } from "./mtmFetcher";
26
- import { useExtInfo } from "./providers/GomtmProvider";
27
- function createQueryKey(svc, method, input) {
28
- return [svc, upperFirst(camelCase(method)), input || {}];
29
- }
30
- function createInfiniteQueryKey(svc, method, input) {
31
- return [...createQueryKey(svc, method, input), "infinite"];
32
- }
33
- function useMtmSuspenseQuery(serviceName, methodName, input) {
34
- const extInfo = useExtInfo();
35
- return useSuspenseQuery({
36
- queryKey: createQueryKey(serviceName, methodName, input),
37
- queryFn: (k) => __async(this, null, function* () {
38
- const result = yield mtmCallUnaryMethod(extInfo, serviceName, methodName, input || {});
39
- const a = result;
40
- return toPlainMessage(a);
41
- })
42
- });
43
- }
44
- function useMtmSuspenseInfiniteQuery(serviceName, methodName, input) {
45
- const extInfo = useExtInfo();
46
- return useSuspenseInfiniteQuery({
47
- queryKey: createInfiniteQueryKey(serviceName, methodName, input),
48
- queryFn: (k) => __async(this, null, function* () {
49
- const result = yield mtmCallUnaryMethod(extInfo, serviceName, methodName, input || {});
50
- const a = result;
51
- return toPlainMessage(a);
52
- }),
53
- initialPageParam: {
54
- page: ""
55
- },
56
- getNextPageParam: () => {
57
- return {};
58
- }
59
- });
60
- }
61
- function useMtmMutation(serviceName, methodName) {
62
- const extInfo = useExtInfo();
63
- return useMutation({
64
- mutationFn: (values) => __async(this, null, function* () {
65
- yield mtmCallUnaryMethod(extInfo, serviceName, methodName, values);
66
- })
67
- });
68
- }
69
- export {
70
- createInfiniteQueryKey,
71
- createQueryKey,
72
- useMtmMutation,
73
- useMtmSuspenseInfiniteQuery,
74
- useMtmSuspenseQuery
75
- };
@@ -1,2 +1,3 @@
1
1
  import { PropsWithChildren } from "react";
2
2
  export declare function GomtmAppSS(props: {} & PropsWithChildren): Promise<import("react").JSX.Element>;
3
+ export declare const ssrGetBackendUrl: () => any;
@@ -19,30 +19,42 @@ var __async = (__this, __arguments, generator) => {
19
19
  });
20
20
  };
21
21
  import { Fragment, jsx } from "react/jsx-runtime";
22
- import { ExtKey_Hostname, ExtKey_mtmbackend } from "../consts";
23
- import { ExtinfoSS } from "../sscore";
22
+ import { MTM_SERVER_COOKIE_ACTIVATE_URL } from "../consts";
23
+ import { GomtmBackendProvider } from "../store/GomtmBackendProvider";
24
24
  import { GomtmProvider } from "./GomtmProvider";
25
25
  function GomtmAppSS(props) {
26
26
  return __async(this, null, function* () {
27
27
  const { children } = props;
28
- const backend = ExtinfoSS(ExtKey_Hostname);
28
+ const backend = ssrGetBackendUrl();
29
29
  if (!backend) {
30
30
  return /* @__PURE__ */ jsx(Fragment, { children: "missing backend" });
31
31
  }
32
32
  return /* @__PURE__ */ jsx(
33
33
  GomtmProvider,
34
34
  {
35
- initExtKv: {
36
- // [ExtKey_Hostname]: ExtinfoSS(ExtKey_Hostname),
37
- // [ExtKey_mtmaccessToken]: ExtinfoSS(ExtKey_mtmaccessToken),
38
- [ExtKey_mtmbackend]: ExtinfoSS(ExtKey_mtmbackend)
39
- // [ExtKey_SelfBackend]: ExtinfoSS(ExtKey_SelfBackend)
40
- },
41
- children
35
+ children: /* @__PURE__ */ jsx(GomtmBackendProvider, { baseUrl: backend, children })
42
36
  }
43
37
  );
44
38
  });
45
39
  }
40
+ const ssrGetBackendUrl = () => {
41
+ var _a, _b;
42
+ if (typeof window == "undefined") {
43
+ const _cookies = require("next/headers").cookies();
44
+ const value = (_a = _cookies.get(MTM_SERVER_COOKIE_ACTIVATE_URL)) == null ? void 0 : _a.value;
45
+ if (value) {
46
+ return value;
47
+ }
48
+ if ((_b = process == null ? void 0 : process.env) == null ? void 0 : _b.MTM_BACKEND) {
49
+ return process.env.MTM_BACKEND;
50
+ }
51
+ if (process.env.VERCEL_URL) {
52
+ return `https://${process.env.VERCEL_URL}`;
53
+ }
54
+ }
55
+ return "https://localhost";
56
+ };
46
57
  export {
47
- GomtmAppSS
58
+ GomtmAppSS,
59
+ ssrGetBackendUrl
48
60
  };
@@ -55,9 +55,7 @@ interface IAppContext {
55
55
  isOpenDebugView?: boolean;
56
56
  setOpenDebugView: Dispatch<React.SetStateAction<boolean>>;
57
57
  }
58
- export declare function GomtmProvider(props: {
59
- initExtKv: Record<string, any | undefined>;
60
- } & PropsWithChildren): React.JSX.Element;
58
+ export declare function GomtmProvider(props: {} & PropsWithChildren): React.JSX.Element;
61
59
  export declare function useMtmApp(): IAppContext;
62
60
  export declare const useMtmBackendUrl: () => string | null | undefined;
63
61
  export declare const useHostname: () => string;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
- import { createContext, useCallback, useContext, useMemo, useState } from "react";
3
+ import { createContext, useCallback, useContext, useState } from "react";
4
4
  import { createStore } from "jotai";
5
5
  import { getCookie } from "mtxlib/clientlib";
6
6
  import { ExtKey_Hostname, ExtKey_SelfBackend, ExtKey_mtmaccessToken, ExtKey_mtmbackend, MtM_TOKEN_NAME } from "../consts";
@@ -9,34 +9,8 @@ import { MtReactQueryProvider } from "./ReactQueryProvider";
9
9
  const mtmAppStore = createStore();
10
10
  const AppContext = createContext(void 0);
11
11
  function GomtmProvider(props) {
12
- const { children, initExtKv } = props;
13
- const [isOpenDebugView, setOpenDebugView] = useState(false);
14
- const [debugData, setDebugData] = useState(null);
15
- const [isDebug, setIsDebug] = useState(false);
16
- const trpcBackendUrl = useMemo(() => {
17
- return initExtKv[ExtKey_SelfBackend];
18
- }, [initExtKv]);
19
- const backendUrl = useMemo(() => {
20
- return initExtKv[ExtKey_mtmbackend];
21
- }, [initExtKv]);
22
- const hostname = useMemo(() => {
23
- return initExtKv[ExtKey_Hostname];
24
- }, [initExtKv]);
25
- const token = useMemo(() => {
26
- return initExtKv[ExtKey_mtmaccessToken];
27
- }, [initExtKv]);
28
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(AppContext.Provider, { value: {
29
- extKv: initExtKv,
30
- token,
31
- hostname,
32
- backendUrl,
33
- isDebug,
34
- debugData,
35
- setDebugData,
36
- isOpenDebugView,
37
- setOpenDebugView,
38
- trpcBackendUrl
39
- }, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsx(MtReactQueryProvider, { children }) }) }) });
12
+ const { children } = props;
13
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsx(MtReactQueryProvider, { children }) }) });
40
14
  }
41
15
  function useMtmApp() {
42
16
  const mtappContext = useContext(AppContext);
@@ -1,16 +1,11 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { useMemo } from "react";
3
+ import { useAtom } from "jotai";
4
4
  import { TransportProvider } from "../connectquery";
5
- import { createMtConnectTransport } from "../mtmFetcher";
6
- import { useExtInfo, useMtmBackendUrl } from "./GomtmProvider";
5
+ import { transportAtom } from "../store/GomtmBackendProvider";
7
6
  const MtConnectProvider = (props) => {
8
7
  const { children } = props;
9
- const backendUrl = useMtmBackendUrl();
10
- const extInfo = useExtInfo();
11
- const transport = useMemo(() => {
12
- return createMtConnectTransport(backendUrl || "", extInfo);
13
- }, [backendUrl, extInfo]);
8
+ const [transport] = useAtom(transportAtom);
14
9
  return /* @__PURE__ */ jsx(TransportProvider, { transport, children });
15
10
  };
16
11
  export {
@@ -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
  };
@@ -1,4 +1 @@
1
- import { ExtInfo } from "./mtmcore";
2
1
  export declare const ssrGetBackendUrl: () => string;
3
- export declare const getSelfbackendUrl: () => string;
4
- export declare const ExtinfoSS: ExtInfo;
@@ -1,5 +1,5 @@
1
- import { cookies, headers } from "next/headers";
2
- import { ExtKey_Hostname, ExtKey_SelfBackend, ExtKey_mtmaccessToken, ExtKey_mtmbackend, MTM_SERVER_COOKIE_ACTIVATE_SELFBACKEND_URL, MTM_SERVER_COOKIE_ACTIVATE_URL, MtM_TOKEN_NAME } from "./consts";
1
+ import { cookies } from "next/headers";
2
+ import { MTM_SERVER_COOKIE_ACTIVATE_URL } from "./consts";
3
3
  const ssrGetBackendUrl = () => {
4
4
  var _a, _b;
5
5
  const activateServerUrl = (_a = cookies().get(MTM_SERVER_COOKIE_ACTIVATE_URL)) == null ? void 0 : _a.value;
@@ -14,38 +14,6 @@ const ssrGetBackendUrl = () => {
14
14
  }
15
15
  return "https://localhost";
16
16
  };
17
- const getSelfbackendUrl = () => {
18
- var _a, _b, _c;
19
- const activateServerUrl = (_a = cookies().get(MTM_SERVER_COOKIE_ACTIVATE_SELFBACKEND_URL)) == null ? void 0 : _a.value;
20
- if (activateServerUrl) {
21
- return activateServerUrl;
22
- }
23
- if ((_b = process == null ? void 0 : process.env) == null ? void 0 : _b.MTM_SELFBACKEND) {
24
- return process.env.MTM_SELFBACKEND;
25
- }
26
- if (process.env.VERCEL_URL) {
27
- return `https://${process.env.VERCEL_URL}`;
28
- }
29
- const port = ((_c = process.env) == null ? void 0 : _c.PORT) || 3e3;
30
- return `http://localhost:${port}`;
31
- };
32
- const ExtinfoSS = (key) => {
33
- var _a;
34
- switch (key) {
35
- case ExtKey_Hostname:
36
- return headers().get("host");
37
- case ExtKey_mtmaccessToken:
38
- return (_a = cookies().get(MtM_TOKEN_NAME)) == null ? void 0 : _a.value;
39
- case ExtKey_mtmbackend:
40
- return ssrGetBackendUrl();
41
- case ExtKey_SelfBackend:
42
- return getSelfbackendUrl();
43
- default:
44
- return "";
45
- }
46
- };
47
17
  export {
48
- ExtinfoSS,
49
- getSelfbackendUrl,
50
18
  ssrGetBackendUrl
51
19
  };
@@ -21,30 +21,10 @@ var __async = (__this, __arguments, generator) => {
21
21
  };
22
22
  import { jsx, jsxs } from "react/jsx-runtime";
23
23
  import { atom, useAtom } from "jotai";
24
- import { createConnectTransport } from "@connectrpc/connect-web";
25
24
  import { ScopeProvider } from "mtxlib/jotai/ScopeProvider";
26
25
  import { AtomsHydrator } from "mtxlib/jotai/jotai-helper";
27
26
  import { callUnaryMethod } from "../connectquery";
28
- import { gomtmFetcher } from "../gomtm-clients-ss";
29
- import { gomtmBaseUrlAtom } from "./GomtmBackendProvider";
30
- const curd3BackendUrlAtom = atom((get) => {
31
- const value1 = get(gomtmBaseUrlAtom);
32
- if (value1) {
33
- return value1;
34
- }
35
- if (typeof window == "undefined") {
36
- console.log("get gomtm backendurl(SSR)", process.env.MTM_BACKEND);
37
- return process.env.MTM_BACKEND || "";
38
- }
39
- return "";
40
- });
41
- const curd2TransportAtom = atom((get) => {
42
- const baseUrl = get(curd3BackendUrlAtom);
43
- return createConnectTransport({
44
- baseUrl,
45
- fetch: gomtmFetcher()
46
- });
47
- });
27
+ import { gomtmBaseUrlAtom, transportAtom } from "./GomtmBackendProvider";
48
28
  const curd3ListParamsAtom = atom({});
49
29
  const curd3MethodListAtom = atom(null);
50
30
  const curd3ItemsAtom = atom((get) => __async(void 0, null, function* () {
@@ -53,7 +33,7 @@ const curd3ItemsAtom = atom((get) => __async(void 0, null, function* () {
53
33
  if (!methodList) {
54
34
  throw new Error("curd3ItemsAtom, missing methodList");
55
35
  }
56
- const transport = get(curd2TransportAtom);
36
+ const transport = get(transportAtom);
57
37
  return yield callUnaryMethod(methodList, params, { transport });
58
38
  }));
59
39
  function Curd3ListProvider(props) {
@@ -1,8 +1,12 @@
1
+ import { Transport } from "@connectrpc/connect";
1
2
  import { PropsWithChildren } from "react";
2
3
  export declare const gomtmBaseUrlAtom: import("jotai").PrimitiveAtom<string> & {
3
4
  init: string;
4
5
  };
6
+ export declare const transportAtom: import("jotai").Atom<Transport>;
5
7
  export declare const GomtmBackendProvider: (props: {
6
8
  baseUrl?: string;
7
9
  } & PropsWithChildren) => import("react").JSX.Element;
8
- export declare const useGomtmBackend: () => void;
10
+ export declare const useGomtmBackend: () => {
11
+ gomtmBaseUrl: string;
12
+ };