@akanjs/ui 1.0.15 → 1.0.17
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/cjs/Signal/Message.js +2 -2
- package/cjs/Signal/PubSub.js +7 -1
- package/cjs/Signal/WebSocket.js +5 -11
- package/esm/Signal/Message.js +2 -2
- package/esm/Signal/PubSub.js +9 -3
- package/esm/Signal/WebSocket.js +5 -11
- package/package.json +1 -1
package/cjs/Signal/Message.js
CHANGED
|
@@ -157,12 +157,12 @@ const MessageTry = ({ gqlKey, gqlMeta }) => {
|
|
|
157
157
|
const onSend = async () => {
|
|
158
158
|
const request = JSON.parse(gqlRequest);
|
|
159
159
|
const argData = gqlMeta.args.map((argMeta) => request[argMeta.name]);
|
|
160
|
-
const fetchFn =
|
|
160
|
+
const fetchFn = import_client.fetch[gqlKey].bind(import_client.fetch);
|
|
161
161
|
await fetchFn(...argData);
|
|
162
162
|
};
|
|
163
163
|
const onListen = () => {
|
|
164
164
|
setResponse({ status: "loading", data: null });
|
|
165
|
-
const fetchFn =
|
|
165
|
+
const fetchFn = import_client.fetch[`listen${(0, import_common.capitalize)(gqlKey)}`].bind(import_client.fetch);
|
|
166
166
|
setResponse({ status: "loading", data: messages });
|
|
167
167
|
const stopListen2 = fetchFn((data) => {
|
|
168
168
|
setMessages(
|
package/cjs/Signal/PubSub.js
CHANGED
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(PubSub_exports);
|
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var import_base = require("@akanjs/base");
|
|
36
36
|
var import_client = require("@akanjs/client");
|
|
37
|
+
var import_common = require("@akanjs/common");
|
|
37
38
|
var import_constant = require("@akanjs/constant");
|
|
38
39
|
var import_signal = require("@akanjs/signal");
|
|
39
40
|
var import_store = require("@akanjs/store");
|
|
@@ -151,7 +152,12 @@ const PubSubTry = ({ refName, gqlKey, gqlMeta }) => {
|
|
|
151
152
|
setResponse({ status: "loading", data: "" });
|
|
152
153
|
const request = JSON.parse(gqlRequest);
|
|
153
154
|
const argData = gqlMeta.args.map((argMeta) => request[argMeta.name]);
|
|
154
|
-
const
|
|
155
|
+
const subscribeKey = `subscribe${(0, import_common.capitalize)(gqlKey)}`;
|
|
156
|
+
const fetchFn = import_client.fetch[subscribeKey]?.bind(import_client.fetch);
|
|
157
|
+
if (!fetchFn) {
|
|
158
|
+
setResponse({ status: "error", data: `Subscribe function not found: ${subscribeKey}` });
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
155
161
|
setResponse({ status: "loading", data: messages });
|
|
156
162
|
const unsubscribe2 = fetchFn(...argData, (data) => {
|
|
157
163
|
setMessages(
|
package/cjs/Signal/WebSocket.js
CHANGED
|
@@ -45,23 +45,17 @@ const WebSocketEndpoints = ({ refName, openAll }) => {
|
|
|
45
45
|
return null;
|
|
46
46
|
const tryRoles = import_store.st.use.tryRoles();
|
|
47
47
|
const gqlInfos = Object.entries(signal.endpoint).sort(([keyA], [keyB]) => keyA > keyB ? 1 : -1).filter(([key, gqlMeta]) => gqlMeta.signalOption?.onlyFor !== "restapi").filter(([key, gqlMeta]) => {
|
|
48
|
-
if (gqlMeta.type === "
|
|
48
|
+
if (gqlMeta.type === "query" || gqlMeta.type === "mutation")
|
|
49
49
|
return false;
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
if ((gqlMeta.signalOption?.guards?.includes("User") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("User"))
|
|
53
|
-
return true;
|
|
54
|
-
if ((gqlMeta.signalOption?.guards?.includes("Admin") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("Admin"))
|
|
55
|
-
return true;
|
|
56
|
-
if ((gqlMeta.signalOption?.guards?.includes("SuperAdmin") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("SuperAdmin"))
|
|
57
|
-
return true;
|
|
58
|
-
return false;
|
|
50
|
+
return true;
|
|
59
51
|
});
|
|
60
52
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: gqlInfos.map(([gqlKey, gqlMeta], idx) => {
|
|
61
53
|
if (gqlMeta.type === "pubsub") {
|
|
62
54
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PubSub.default.Endpoint, { refName, gqlKey, gqlMeta, open: openAll }, idx);
|
|
63
|
-
} else {
|
|
55
|
+
} else if (gqlMeta.type === "message") {
|
|
64
56
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Message.default.Endpoint, { refName, gqlKey, gqlMeta, open: openAll }, idx);
|
|
57
|
+
} else {
|
|
58
|
+
return null;
|
|
65
59
|
}
|
|
66
60
|
}) });
|
|
67
61
|
};
|
package/esm/Signal/Message.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { isGqlScalar } from "@akanjs/base";
|
|
4
|
-
import { usePage } from "@akanjs/client";
|
|
4
|
+
import { fetch, usePage } from "@akanjs/client";
|
|
5
5
|
import { capitalize } from "@akanjs/common";
|
|
6
6
|
import { constantInfo } from "@akanjs/constant";
|
|
7
|
-
import {
|
|
7
|
+
import { makeRequestExample } from "@akanjs/signal";
|
|
8
8
|
import { useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { AiOutlineDisconnect, AiOutlineFileWord, AiOutlineSend, AiOutlineSwap } from "react-icons/ai";
|
|
10
10
|
import { BiSolidNetworkChart } from "react-icons/bi";
|
package/esm/Signal/PubSub.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { isGqlScalar } from "@akanjs/base";
|
|
4
|
-
import { usePage } from "@akanjs/client";
|
|
4
|
+
import { fetch, usePage } from "@akanjs/client";
|
|
5
|
+
import { capitalize } from "@akanjs/common";
|
|
5
6
|
import { constantInfo } from "@akanjs/constant";
|
|
6
|
-
import {
|
|
7
|
+
import { makeRequestExample } from "@akanjs/signal";
|
|
7
8
|
import { st } from "@akanjs/store";
|
|
8
9
|
import { useEffect, useMemo, useState } from "react";
|
|
9
10
|
import { AiOutlineDisconnect, AiOutlineFileWord, AiOutlineSwap } from "react-icons/ai";
|
|
@@ -119,7 +120,12 @@ const PubSubTry = ({ refName, gqlKey, gqlMeta }) => {
|
|
|
119
120
|
setResponse({ status: "loading", data: "" });
|
|
120
121
|
const request = JSON.parse(gqlRequest);
|
|
121
122
|
const argData = gqlMeta.args.map((argMeta) => request[argMeta.name]);
|
|
122
|
-
const
|
|
123
|
+
const subscribeKey = `subscribe${capitalize(gqlKey)}`;
|
|
124
|
+
const fetchFn = fetch[subscribeKey]?.bind(fetch);
|
|
125
|
+
if (!fetchFn) {
|
|
126
|
+
setResponse({ status: "error", data: `Subscribe function not found: ${subscribeKey}` });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
123
129
|
setResponse({ status: "loading", data: messages });
|
|
124
130
|
const unsubscribe2 = fetchFn(...argData, (data) => {
|
|
125
131
|
setMessages(
|
package/esm/Signal/WebSocket.js
CHANGED
|
@@ -13,23 +13,17 @@ const WebSocketEndpoints = ({ refName, openAll }) => {
|
|
|
13
13
|
return null;
|
|
14
14
|
const tryRoles = st.use.tryRoles();
|
|
15
15
|
const gqlInfos = Object.entries(signal.endpoint).sort(([keyA], [keyB]) => keyA > keyB ? 1 : -1).filter(([key, gqlMeta]) => gqlMeta.signalOption?.onlyFor !== "restapi").filter(([key, gqlMeta]) => {
|
|
16
|
-
if (gqlMeta.type === "
|
|
16
|
+
if (gqlMeta.type === "query" || gqlMeta.type === "mutation")
|
|
17
17
|
return false;
|
|
18
|
-
|
|
19
|
-
return true;
|
|
20
|
-
if ((gqlMeta.signalOption?.guards?.includes("User") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("User"))
|
|
21
|
-
return true;
|
|
22
|
-
if ((gqlMeta.signalOption?.guards?.includes("Admin") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("Admin"))
|
|
23
|
-
return true;
|
|
24
|
-
if ((gqlMeta.signalOption?.guards?.includes("SuperAdmin") || gqlMeta.signalOption?.guards?.includes("Every")) && tryRoles.includes("SuperAdmin"))
|
|
25
|
-
return true;
|
|
26
|
-
return false;
|
|
18
|
+
return true;
|
|
27
19
|
});
|
|
28
20
|
return /* @__PURE__ */ jsx("div", { children: gqlInfos.map(([gqlKey, gqlMeta], idx) => {
|
|
29
21
|
if (gqlMeta.type === "pubsub") {
|
|
30
22
|
return /* @__PURE__ */ jsx(PubSub.Endpoint, { refName, gqlKey, gqlMeta, open: openAll }, idx);
|
|
31
|
-
} else {
|
|
23
|
+
} else if (gqlMeta.type === "message") {
|
|
32
24
|
return /* @__PURE__ */ jsx(Message.Endpoint, { refName, gqlKey, gqlMeta, open: openAll }, idx);
|
|
25
|
+
} else {
|
|
26
|
+
return null;
|
|
33
27
|
}
|
|
34
28
|
}) });
|
|
35
29
|
};
|