akanjs 2.0.6 → 2.0.7
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/README.ko.md +1 -1
- package/README.md +1 -1
- package/cli/application/application.command.ts +4 -1
- package/cli/application/application.runner.ts +5 -7
- package/cli/build.ts +1 -0
- package/cli/index.js +114 -74
- package/constant/serialize.ts +1 -1
- package/devkit/capacitor.base.config.ts +18 -4
- package/devkit/capacitorApp.ts +118 -64
- package/devkit/mobile/mobileTarget.ts +2 -1
- package/devkit/scanInfo.ts +1 -0
- package/package.json +1 -1
- package/server/akanApp.ts +53 -12
- package/server/processMetricsCollector.ts +79 -1
- package/server/resolver/database.resolver.ts +82 -31
- package/server/resolver/signal.resolver.ts +67 -28
- package/service/ipcTypes.ts +5 -0
- package/service/predefinedAdaptor/database.adaptor.ts +95 -27
- package/service/predefinedAdaptor/solidSqlite.ts +7 -7
- package/service/predefinedAdaptor/storage.adaptor.ts +35 -9
- package/signal/index.ts +1 -0
- package/signal/middleware.ts +5 -1
- package/signal/signalContext.ts +85 -31
- package/signal/trace.ts +279 -0
- package/types/devkit/capacitorApp.d.ts +14 -5
- package/types/server/processMetricsCollector.d.ts +2 -0
- package/types/service/ipcTypes.d.ts +5 -0
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +26 -32
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +3 -3
- package/types/service/predefinedAdaptor/storage.adaptor.d.ts +8 -2
- package/types/signal/index.d.ts +1 -0
- package/types/signal/signalContext.d.ts +4 -1
- package/types/signal/trace.d.ts +97 -0
- package/types/ui/Signal/style.d.ts +15 -0
- package/ui/Signal/Arg.tsx +22 -15
- package/ui/Signal/Doc.tsx +28 -21
- package/ui/Signal/Listener.tsx +15 -39
- package/ui/Signal/Message.tsx +32 -50
- package/ui/Signal/Object.tsx +16 -13
- package/ui/Signal/PubSub.tsx +29 -47
- package/ui/Signal/Response.tsx +7 -17
- package/ui/Signal/RestApi.tsx +41 -57
- package/ui/Signal/WebSocket.tsx +1 -1
- package/ui/Signal/style.ts +36 -0
- package/webkit/useCsrValues.ts +147 -37
package/ui/Signal/Message.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import Listener from "./Listener";
|
|
|
14
14
|
import { makeRequestExample } from "./makeExample";
|
|
15
15
|
import UiObject from "./Object";
|
|
16
16
|
import Response from "./Response";
|
|
17
|
+
import { getEndpointBadgeClassName, getGuardBadgeClassName, signalUi } from "./style";
|
|
17
18
|
|
|
18
19
|
export default function Message() {
|
|
19
20
|
return <div></div>;
|
|
@@ -28,58 +29,39 @@ interface MessageEndpointProps {
|
|
|
28
29
|
const MessageEndpoint = ({ refName, endpointKey, endpoint, open }: MessageEndpointProps) => {
|
|
29
30
|
const { l } = usePage();
|
|
30
31
|
const [viewStatus, setViewStatus] = useState<"doc" | "test">("doc");
|
|
31
|
-
const args = endpoint.args.filter((arg) => arg.refName !== "Upload");
|
|
32
|
-
const uploadArgs = endpoint.args.filter((arg) => arg.refName === "Upload");
|
|
33
32
|
return (
|
|
34
|
-
<div className=
|
|
35
|
-
<input type="checkbox"
|
|
36
|
-
<div className="collapse-title
|
|
37
|
-
<div className="flex items-center gap-
|
|
38
|
-
<div className={
|
|
39
|
-
|
|
40
|
-
</div>
|
|
41
|
-
{endpointKey} <span className="text-sm">({l._(`${refName}.signal.${endpointKey}`)})</span>
|
|
33
|
+
<div className={signalUi.endpointCard}>
|
|
34
|
+
<input type="checkbox" defaultChecked={open} />
|
|
35
|
+
<div className="collapse-title">
|
|
36
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
37
|
+
<div className={getEndpointBadgeClassName(endpoint.type)}>{endpoint.type}</div>
|
|
38
|
+
<div className="font-bold text-lg">{endpointKey}</div>
|
|
39
|
+
<div className="text-base-content/70 text-sm">{l._(`${refName}.signal.${endpointKey}`)}</div>
|
|
42
40
|
</div>
|
|
43
41
|
</div>
|
|
44
|
-
<div className=
|
|
45
|
-
<div className="
|
|
46
|
-
Description
|
|
47
|
-
<hr className="my-2 border-[0.1px] border-gray-400" />
|
|
42
|
+
<div className={signalUi.endpointContent}>
|
|
43
|
+
<div className="rounded-xl bg-base-100 p-3">
|
|
44
|
+
<div className={signalUi.sectionTitle}>Description</div>
|
|
48
45
|
{endpoint.guards?.some((guard) => guard !== "None") ? (
|
|
49
|
-
<div className="flex items-center gap-2
|
|
50
|
-
-
|
|
46
|
+
<div className="mt-2 flex flex-wrap items-center gap-2 font-normal text-sm">
|
|
47
|
+
<span className="text-base-content/70">Guards</span>
|
|
51
48
|
{endpoint.guards.map((guard) => (
|
|
52
|
-
<span
|
|
53
|
-
className={`badge ${
|
|
54
|
-
guard === "Public"
|
|
55
|
-
? "badge-success"
|
|
56
|
-
: guard === "SuperAdmin"
|
|
57
|
-
? "badge-error"
|
|
58
|
-
: guard === "Admin"
|
|
59
|
-
? "badge-error"
|
|
60
|
-
: guard === "User"
|
|
61
|
-
? "badge-accent"
|
|
62
|
-
: guard === "Owner"
|
|
63
|
-
? "badge-accent"
|
|
64
|
-
: guard === "Every"
|
|
65
|
-
? "badge-warning"
|
|
66
|
-
: ""
|
|
67
|
-
}`}
|
|
68
|
-
key={guard}
|
|
69
|
-
>
|
|
49
|
+
<span className={getGuardBadgeClassName(guard)} key={guard}>
|
|
70
50
|
{guard}
|
|
71
51
|
</span>
|
|
72
52
|
))}
|
|
73
53
|
</div>
|
|
74
54
|
) : null}
|
|
75
|
-
<div className="
|
|
55
|
+
<div className="mt-2 font-normal text-base-content/70 text-sm">
|
|
56
|
+
{l._(`${refName}.signal.${endpointKey}.desc`)}
|
|
57
|
+
</div>
|
|
76
58
|
</div>
|
|
77
|
-
<div className="
|
|
59
|
+
<div className="join w-fit">
|
|
78
60
|
<button
|
|
79
61
|
onClick={() => {
|
|
80
62
|
setViewStatus("doc");
|
|
81
63
|
}}
|
|
82
|
-
className={`btn
|
|
64
|
+
className={`btn join-item btn-sm ${viewStatus === "doc" ? "btn-primary" : "btn-outline"}`}
|
|
83
65
|
>
|
|
84
66
|
<AiOutlineFileWord className="text-xl" /> View Doc
|
|
85
67
|
</button>
|
|
@@ -87,7 +69,7 @@ const MessageEndpoint = ({ refName, endpointKey, endpoint, open }: MessageEndpoi
|
|
|
87
69
|
onClick={() => {
|
|
88
70
|
setViewStatus("test");
|
|
89
71
|
}}
|
|
90
|
-
className={`btn
|
|
72
|
+
className={`btn join-item btn-sm ${viewStatus === "test" ? "btn-primary" : "btn-outline"}`}
|
|
91
73
|
>
|
|
92
74
|
<BiSolidNetworkChart className="text-xl" /> Message
|
|
93
75
|
</button>
|
|
@@ -117,16 +99,16 @@ const MessageInterface = ({ refName, endpointKey, endpoint }: MessageInterfacePr
|
|
|
117
99
|
<div className="flex flex-col gap-4">
|
|
118
100
|
{uploadArgs.length ? (
|
|
119
101
|
<div>
|
|
120
|
-
<div className=
|
|
121
|
-
<div className=
|
|
102
|
+
<div className={signalUi.sectionTitle}>Form data upload</div>
|
|
103
|
+
<div className={signalUi.tablePanel}>
|
|
122
104
|
<Arg.Table refName={refName} endpointKey={endpointKey} args={uploadArgs} />
|
|
123
105
|
</div>
|
|
124
106
|
</div>
|
|
125
107
|
) : null}
|
|
126
108
|
{args.length ? (
|
|
127
109
|
<div>
|
|
128
|
-
<div className=
|
|
129
|
-
<div className=
|
|
110
|
+
<div className={signalUi.sectionTitle}>Variables</div>
|
|
111
|
+
<div className={signalUi.tablePanel}>
|
|
130
112
|
<Arg.Table refName={refName} endpointKey={endpointKey} args={args} />
|
|
131
113
|
</div>
|
|
132
114
|
</div>
|
|
@@ -134,14 +116,14 @@ const MessageInterface = ({ refName, endpointKey, endpoint }: MessageInterfacePr
|
|
|
134
116
|
<div className="font-bold text-lg">
|
|
135
117
|
<div className="flex w-full flex-col gap-2 rounded-md font-normal md:flex-row">
|
|
136
118
|
<div className="w-full md:w-1/2">
|
|
137
|
-
Response Type
|
|
138
|
-
<div className="max-h-[500px] overflow-auto rounded-
|
|
119
|
+
<div className={signalUi.sectionTitle}>Response Type</div>
|
|
120
|
+
<div className="max-h-[500px] overflow-auto rounded-xl bg-base-100 p-4 md:h-[500px]">
|
|
139
121
|
Returns: <UiObject.Type objRef={returnRef} arrDepth={endpoint.returns.arrDepth ?? 0} />
|
|
140
122
|
{isReturnModelType ? <UiObject.Detail objRef={returnRef as ConstantCls} /> : null}
|
|
141
123
|
</div>
|
|
142
124
|
</div>
|
|
143
125
|
<div className="w-full md:w-1/2">
|
|
144
|
-
Response Example
|
|
126
|
+
<div className={signalUi.sectionTitle}>Response Example</div>
|
|
145
127
|
<Response.Example endpoint={endpoint} />
|
|
146
128
|
</div>
|
|
147
129
|
</div>
|
|
@@ -213,7 +195,7 @@ const MessageTry = ({ endpointKey, endpoint }: MessageTryProps) => {
|
|
|
213
195
|
<div>
|
|
214
196
|
<div className="grid gap-2 lg:grid-cols-2">
|
|
215
197
|
<div>
|
|
216
|
-
<div className=
|
|
198
|
+
<div className={signalUi.sectionTitle}>Variables</div>
|
|
217
199
|
<div className="w-full items-center justify-center">
|
|
218
200
|
<Arg.Json
|
|
219
201
|
value={gqlRequest}
|
|
@@ -234,19 +216,19 @@ const MessageTry = ({ endpointKey, endpoint }: MessageTryProps) => {
|
|
|
234
216
|
<div className="flex w-full flex-col gap-2">
|
|
235
217
|
<button
|
|
236
218
|
disabled={!!stopListen}
|
|
237
|
-
className="btn btn-
|
|
219
|
+
className="btn btn-primary w-full"
|
|
238
220
|
onClick={() => {
|
|
239
221
|
onListen();
|
|
240
222
|
}}
|
|
241
223
|
>
|
|
242
224
|
<AiOutlineSwap className="" /> Listen Message
|
|
243
225
|
</button>
|
|
244
|
-
<button disabled={!stopListen} className="btn btn-
|
|
226
|
+
<button disabled={!stopListen} className="btn btn-secondary w-full" onClick={() => void onSend()}>
|
|
245
227
|
<AiOutlineSend className="" /> Send Message
|
|
246
228
|
</button>
|
|
247
229
|
<button
|
|
248
230
|
disabled={!stopListen}
|
|
249
|
-
className="btn btn-
|
|
231
|
+
className="btn btn-outline w-full"
|
|
250
232
|
onClick={() => {
|
|
251
233
|
onStopListen();
|
|
252
234
|
}}
|
|
@@ -258,7 +240,7 @@ const MessageTry = ({ endpointKey, endpoint }: MessageTryProps) => {
|
|
|
258
240
|
</div>
|
|
259
241
|
|
|
260
242
|
<div>
|
|
261
|
-
<div className=
|
|
243
|
+
<div className={signalUi.sectionTitle}>Response</div>
|
|
262
244
|
<Listener.Result status={response.status} data={messages} />
|
|
263
245
|
</div>
|
|
264
246
|
</div>
|
package/ui/Signal/Object.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { capitalize } from "akanjs/common";
|
|
|
5
5
|
import { type ConstantCls, ConstantRegistry } from "akanjs/constant";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { Modal } from "../Modal";
|
|
8
|
+
import { signalUi } from "./style";
|
|
8
9
|
|
|
9
10
|
export default function Object() {
|
|
10
11
|
return <div></div>;
|
|
@@ -22,7 +23,7 @@ const ObjectType = ({ objRef, arrDepth, nullable }: ObjectTypeProps) => {
|
|
|
22
23
|
return (
|
|
23
24
|
<>
|
|
24
25
|
<div
|
|
25
|
-
className={isModelType ? "
|
|
26
|
+
className={isModelType ? "badge badge-primary cursor-pointer" : "badge badge-outline"}
|
|
26
27
|
onClick={() => {
|
|
27
28
|
if (isModelType) setOpenDetail(true);
|
|
28
29
|
}}
|
|
@@ -55,22 +56,24 @@ const ObjectDetail = ({ objRef }: ObjectDetailProps) => {
|
|
|
55
56
|
const modelRefName = ConstantRegistry.getRefName(objRef);
|
|
56
57
|
const { l } = usePage();
|
|
57
58
|
return (
|
|
58
|
-
<div>
|
|
59
|
+
<div className={signalUi.tablePanel}>
|
|
59
60
|
<table className="table">
|
|
60
61
|
<thead>
|
|
61
|
-
<tr
|
|
62
|
-
<th
|
|
63
|
-
<th className="text-center
|
|
64
|
-
<th className="text-center
|
|
65
|
-
<th className="text-center
|
|
66
|
-
<th className="text-center
|
|
62
|
+
<tr>
|
|
63
|
+
<th>Key</th>
|
|
64
|
+
<th className="text-center">Cls</th>
|
|
65
|
+
<th className="text-center">Field Name</th>
|
|
66
|
+
<th className="text-center">Description</th>
|
|
67
|
+
<th className="text-center">Enum</th>
|
|
67
68
|
</tr>
|
|
68
69
|
</thead>
|
|
69
70
|
{globalThis.Object.entries(objRef[FIELD_META]).map(
|
|
70
71
|
([key, { arrDepth, nullable, modelRef, isClass, enum: enumOpt, isMap, of }], idx) => (
|
|
71
72
|
<tbody className="font-normal" key={idx}>
|
|
72
73
|
<tr>
|
|
73
|
-
<td
|
|
74
|
+
<td>
|
|
75
|
+
<div className="font-bold">{key}</div>
|
|
76
|
+
</td>
|
|
74
77
|
<td className="text-center">
|
|
75
78
|
{isClass ? (
|
|
76
79
|
<ObjectType objRef={modelRef} arrDepth={arrDepth} />
|
|
@@ -90,13 +93,13 @@ const ObjectDetail = ({ objRef }: ObjectDetailProps) => {
|
|
|
90
93
|
</>
|
|
91
94
|
) : null}
|
|
92
95
|
</td>
|
|
93
|
-
<td className="text-center">{l._(`${modelRefName}.${key}`)}</td>
|
|
94
|
-
<td className="text-center">{l._(`${modelRefName}.${key}.desc`)}</td>
|
|
96
|
+
<td className="text-center text-base-content/70">{l._(`${modelRefName}.${key}`)}</td>
|
|
97
|
+
<td className="text-center text-base-content/70">{l._(`${modelRefName}.${key}.desc`)}</td>
|
|
95
98
|
<td className="flex flex-wrap items-center justify-center gap-2 text-center">
|
|
96
99
|
{enumOpt
|
|
97
100
|
? enumOpt.map((opt, idx: number) => (
|
|
98
101
|
<div key={idx} className="tooltip tooltip-primary" data-tip={l._(`${enumOpt.refName}.${opt}`)}>
|
|
99
|
-
<button className="btn btn-xs">{opt}</button>
|
|
102
|
+
<button className="btn btn-outline btn-xs">{opt}</button>
|
|
100
103
|
</div>
|
|
101
104
|
))
|
|
102
105
|
: "-"}
|
|
@@ -122,7 +125,7 @@ const ObjectSchema = ({ objRef }: ObjectSchemaProps) => {
|
|
|
122
125
|
<div className="flex break-after-page flex-col gap-4">
|
|
123
126
|
<div className="mt-24" />
|
|
124
127
|
<div className="font-bold text-3xl">{gqlName}</div>
|
|
125
|
-
<div className="
|
|
128
|
+
<div className="text-base-content/70">{l._(`${refName}.modelDesc`)}</div>
|
|
126
129
|
<div className="font-bold text-2xl">Schema</div>
|
|
127
130
|
<ObjectDetail objRef={objRef as ConstantCls} />
|
|
128
131
|
</div>
|
package/ui/Signal/PubSub.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import { PrimitiveRegistry } from "akanjs/base";
|
|
|
3
3
|
import { fetch, usePage } from "akanjs/client";
|
|
4
4
|
import { type ConstantCls, ConstantRegistry } from "akanjs/constant";
|
|
5
5
|
import type { SerializedEndpoint } from "akanjs/signal";
|
|
6
|
-
import { st } from "akanjs/store";
|
|
7
6
|
import { useEffect, useMemo, useState } from "react";
|
|
8
7
|
import { AiOutlineDisconnect, AiOutlineFileWord, AiOutlineSwap } from "react-icons/ai";
|
|
9
8
|
import { BiSolidNetworkChart } from "react-icons/bi";
|
|
@@ -12,6 +11,7 @@ import Listener from "./Listener";
|
|
|
12
11
|
import { makeRequestExample } from "./makeExample";
|
|
13
12
|
import UiObject from "./Object";
|
|
14
13
|
import Response from "./Response";
|
|
14
|
+
import { getEndpointBadgeClassName, getGuardBadgeClassName, signalUi } from "./style";
|
|
15
15
|
|
|
16
16
|
export default function PubSub() {
|
|
17
17
|
return <div></div>;
|
|
@@ -27,55 +27,38 @@ const PubSubEndpoint = ({ refName, endpointKey, endpoint, open }: PubSubEndpoint
|
|
|
27
27
|
const { l } = usePage();
|
|
28
28
|
const [viewStatus, setViewStatus] = useState<"doc" | "test">("doc");
|
|
29
29
|
return (
|
|
30
|
-
<div className=
|
|
31
|
-
<input type="checkbox"
|
|
32
|
-
<div className="collapse-title
|
|
33
|
-
<div className="flex items-center gap-
|
|
34
|
-
<div className={
|
|
35
|
-
|
|
36
|
-
</div>
|
|
37
|
-
{endpointKey} <span className="text-sm">({l._(`${refName}.signal.${endpointKey}`)})</span>
|
|
30
|
+
<div className={signalUi.endpointCard}>
|
|
31
|
+
<input type="checkbox" defaultChecked={open} />
|
|
32
|
+
<div className="collapse-title">
|
|
33
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
34
|
+
<div className={getEndpointBadgeClassName(endpoint.type)}>{endpoint.type}</div>
|
|
35
|
+
<div className="font-bold text-lg">{endpointKey}</div>
|
|
36
|
+
<div className="text-base-content/70 text-sm">{l._(`${refName}.signal.${endpointKey}`)}</div>
|
|
38
37
|
</div>
|
|
39
38
|
</div>
|
|
40
|
-
<div className=
|
|
41
|
-
<div className="
|
|
42
|
-
Description
|
|
43
|
-
<hr className="my-2 border-[0.1px] border-gray-400" />
|
|
39
|
+
<div className={signalUi.endpointContent}>
|
|
40
|
+
<div className="rounded-xl bg-base-100 p-3">
|
|
41
|
+
<div className={signalUi.sectionTitle}>Description</div>
|
|
44
42
|
{endpoint.guards?.some((guard) => guard !== "None") ? (
|
|
45
|
-
<div className="flex items-center gap-2
|
|
46
|
-
-
|
|
43
|
+
<div className="mt-2 flex flex-wrap items-center gap-2 font-normal text-sm">
|
|
44
|
+
<span className="text-base-content/70">Guards</span>
|
|
47
45
|
{endpoint.guards.map((guard) => (
|
|
48
|
-
<span
|
|
49
|
-
className={`badge ${
|
|
50
|
-
guard === "Public"
|
|
51
|
-
? "badge-success"
|
|
52
|
-
: guard === "SuperAdmin"
|
|
53
|
-
? "badge-error"
|
|
54
|
-
: guard === "Admin"
|
|
55
|
-
? "badge-error"
|
|
56
|
-
: guard === "User"
|
|
57
|
-
? "badge-accent"
|
|
58
|
-
: guard === "Owner"
|
|
59
|
-
? "badge-accent"
|
|
60
|
-
: guard === "Every"
|
|
61
|
-
? "badge-warning"
|
|
62
|
-
: ""
|
|
63
|
-
}`}
|
|
64
|
-
key={guard}
|
|
65
|
-
>
|
|
46
|
+
<span className={getGuardBadgeClassName(guard)} key={guard}>
|
|
66
47
|
{guard}
|
|
67
48
|
</span>
|
|
68
49
|
))}
|
|
69
50
|
</div>
|
|
70
51
|
) : null}
|
|
71
|
-
<div className="
|
|
52
|
+
<div className="mt-2 font-normal text-base-content/70 text-sm">
|
|
53
|
+
{l._(`${refName}.signal.${endpointKey}.desc`)}
|
|
54
|
+
</div>
|
|
72
55
|
</div>
|
|
73
|
-
<div className="
|
|
56
|
+
<div className="join w-fit">
|
|
74
57
|
<button
|
|
75
58
|
onClick={() => {
|
|
76
59
|
setViewStatus("doc");
|
|
77
60
|
}}
|
|
78
|
-
className={`btn
|
|
61
|
+
className={`btn join-item btn-sm ${viewStatus === "doc" ? "btn-primary" : "btn-outline"}`}
|
|
79
62
|
>
|
|
80
63
|
<AiOutlineFileWord className="text-xl" /> View Doc
|
|
81
64
|
</button>
|
|
@@ -83,7 +66,7 @@ const PubSubEndpoint = ({ refName, endpointKey, endpoint, open }: PubSubEndpoint
|
|
|
83
66
|
onClick={() => {
|
|
84
67
|
setViewStatus("test");
|
|
85
68
|
}}
|
|
86
|
-
className={`btn
|
|
69
|
+
className={`btn join-item btn-sm ${viewStatus === "test" ? "btn-primary" : "btn-outline"}`}
|
|
87
70
|
>
|
|
88
71
|
<BiSolidNetworkChart className="text-xl" /> PubSub
|
|
89
72
|
</button>
|
|
@@ -111,8 +94,8 @@ const PubSubInterface = ({ refName, endpointKey, endpoint }: PubSubInterfaceProp
|
|
|
111
94
|
<div className="flex flex-col gap-4">
|
|
112
95
|
{endpoint.args.length ? (
|
|
113
96
|
<div>
|
|
114
|
-
<div className=
|
|
115
|
-
<div className=
|
|
97
|
+
<div className={signalUi.sectionTitle}>Variables</div>
|
|
98
|
+
<div className={signalUi.tablePanel}>
|
|
116
99
|
<Arg.Table refName={refName} endpointKey={endpointKey} args={endpoint.args} />
|
|
117
100
|
</div>
|
|
118
101
|
</div>
|
|
@@ -120,14 +103,14 @@ const PubSubInterface = ({ refName, endpointKey, endpoint }: PubSubInterfaceProp
|
|
|
120
103
|
<div className="font-bold text-lg">
|
|
121
104
|
<div className="flex w-full flex-col gap-2 rounded-md font-normal md:flex-row">
|
|
122
105
|
<div className="w-full md:w-1/2">
|
|
123
|
-
Response Type
|
|
124
|
-
<div className="max-h-[500px] overflow-auto rounded-
|
|
106
|
+
<div className={signalUi.sectionTitle}>Response Type</div>
|
|
107
|
+
<div className="max-h-[500px] overflow-auto rounded-xl bg-base-100 p-4 md:h-[500px]">
|
|
125
108
|
Returns: <UiObject.Type objRef={returnRef} arrDepth={endpoint.returns.arrDepth ?? 0} />
|
|
126
109
|
{isReturnModelType ? <UiObject.Detail objRef={returnRef as ConstantCls} /> : null}
|
|
127
110
|
</div>
|
|
128
111
|
</div>
|
|
129
112
|
<div className="w-full md:w-1/2">
|
|
130
|
-
Response Example
|
|
113
|
+
<div className={signalUi.sectionTitle}>Response Example</div>
|
|
131
114
|
<Response.Example endpoint={endpoint} />
|
|
132
115
|
</div>
|
|
133
116
|
</div>
|
|
@@ -143,7 +126,6 @@ interface PubSubTryProps {
|
|
|
143
126
|
endpoint: SerializedEndpoint;
|
|
144
127
|
}
|
|
145
128
|
const PubSubTry = ({ refName, endpointKey, endpoint }: PubSubTryProps) => {
|
|
146
|
-
const tryJwt = st.use.tryJwt();
|
|
147
129
|
const requestExample = useMemo(() => JSON.stringify(makeRequestExample(endpoint), null, 2), []);
|
|
148
130
|
const [gqlRequest, setGqlRequest] = useState<string>(requestExample);
|
|
149
131
|
const [unsubscribe, setUnsubscribe] = useState<(() => void) | null>(null);
|
|
@@ -198,7 +180,7 @@ const PubSubTry = ({ refName, endpointKey, endpoint }: PubSubTryProps) => {
|
|
|
198
180
|
<div>
|
|
199
181
|
<div className="grid gap-2 lg:grid-cols-2">
|
|
200
182
|
<div>
|
|
201
|
-
<div className=
|
|
183
|
+
<div className={signalUi.sectionTitle}>Variables</div>
|
|
202
184
|
<div className="w-full items-center justify-center">
|
|
203
185
|
<Arg.Json
|
|
204
186
|
value={gqlRequest}
|
|
@@ -218,7 +200,7 @@ const PubSubTry = ({ refName, endpointKey, endpoint }: PubSubTryProps) => {
|
|
|
218
200
|
<div className="relative flex items-center justify-center gap-2">
|
|
219
201
|
<button
|
|
220
202
|
disabled={!!unsubscribe}
|
|
221
|
-
className="btn btn-
|
|
203
|
+
className="btn btn-primary w-1/2"
|
|
222
204
|
onClick={() => {
|
|
223
205
|
onSubscribe();
|
|
224
206
|
}}
|
|
@@ -227,7 +209,7 @@ const PubSubTry = ({ refName, endpointKey, endpoint }: PubSubTryProps) => {
|
|
|
227
209
|
</button>
|
|
228
210
|
<button
|
|
229
211
|
disabled={!unsubscribe}
|
|
230
|
-
className="btn btn-
|
|
212
|
+
className="btn btn-outline w-1/2"
|
|
231
213
|
onClick={() => {
|
|
232
214
|
onUnsubscribe();
|
|
233
215
|
}}
|
|
@@ -238,7 +220,7 @@ const PubSubTry = ({ refName, endpointKey, endpoint }: PubSubTryProps) => {
|
|
|
238
220
|
</div>
|
|
239
221
|
|
|
240
222
|
<div>
|
|
241
|
-
<div className=
|
|
223
|
+
<div className={signalUi.sectionTitle}>Response</div>
|
|
242
224
|
<Listener.Result status={response.status} data={messages} />
|
|
243
225
|
</div>
|
|
244
226
|
</div>
|
package/ui/Signal/Response.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { AiOutlineCopy } from "react-icons/ai";
|
|
6
6
|
import { Copy } from "../Copy";
|
|
7
7
|
import { makeResponseExample } from "./makeExample";
|
|
8
|
+
import { getStatusBadgeClassName, getStatusTextareaClassName, signalUi } from "./style";
|
|
8
9
|
|
|
9
10
|
export default function Response() {
|
|
10
11
|
return <div></div>;
|
|
@@ -17,14 +18,10 @@ const ResponseExample = ({ endpoint }: ResponseExampleProps) => {
|
|
|
17
18
|
const example = useMemo(() => JSON.stringify(makeResponseExample(endpoint), null, 2), []);
|
|
18
19
|
return (
|
|
19
20
|
<div className="relative">
|
|
20
|
-
<textarea
|
|
21
|
-
className="min-h-72 w-full rounded-md bg-base-100 p-4 text-base"
|
|
22
|
-
value={example}
|
|
23
|
-
onChange={() => true}
|
|
24
|
-
/>
|
|
21
|
+
<textarea className={`${signalUi.codePanel} min-h-72 text-base`} value={example} onChange={() => true} />
|
|
25
22
|
<div className="absolute top-4 right-4">
|
|
26
23
|
<Copy text={example}>
|
|
27
|
-
<button className="btn btn-sm">
|
|
24
|
+
<button className="btn btn-outline btn-sm">
|
|
28
25
|
<AiOutlineCopy /> Copy
|
|
29
26
|
</button>
|
|
30
27
|
</Copy>
|
|
@@ -43,15 +40,7 @@ const ResponseResult = ({ status, data }: ResponseResultProps) => {
|
|
|
43
40
|
return (
|
|
44
41
|
<div className="relative">
|
|
45
42
|
<textarea
|
|
46
|
-
className={
|
|
47
|
-
status === "loading"
|
|
48
|
-
? "textarea-disabled"
|
|
49
|
-
: status === "success"
|
|
50
|
-
? "textarea-success border-success"
|
|
51
|
-
: status === "error"
|
|
52
|
-
? "textarea-error border-error text-error"
|
|
53
|
-
: ""
|
|
54
|
-
} min-h-[300px] w-full rounded-md bg-base-100 p-4 font-normal text-sm`}
|
|
43
|
+
className={`${signalUi.codePanel} ${getStatusTextareaClassName(status)}`}
|
|
55
44
|
value={dataStr}
|
|
56
45
|
onChange={() => true}
|
|
57
46
|
/>
|
|
@@ -62,9 +51,10 @@ const ResponseResult = ({ status, data }: ResponseResultProps) => {
|
|
|
62
51
|
) : status === "idle" ? (
|
|
63
52
|
<></>
|
|
64
53
|
) : (
|
|
65
|
-
<div className="absolute top-4 right-4">
|
|
54
|
+
<div className="absolute top-4 right-4 flex items-center gap-2">
|
|
55
|
+
<span className={getStatusBadgeClassName(status)}>{status}</span>
|
|
66
56
|
<Copy text={dataStr}>
|
|
67
|
-
<button className="btn btn-sm">
|
|
57
|
+
<button className="btn btn-outline btn-sm">
|
|
68
58
|
<AiOutlineCopy /> Copy
|
|
69
59
|
</button>
|
|
70
60
|
</Copy>
|