@nice2dev/ui-api 1.1.10 → 1.2.0
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/CHANGELOG.md +70 -0
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +181 -181
- package/dist/ui-api.css +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as n, jsx as e, Fragment as B } from "react/jsx-runtime";
|
|
2
|
-
import { NiceAppShell as
|
|
3
|
-
import { NiceTutorialButton as
|
|
4
|
-
import { useState as k, useCallback as I, useRef as
|
|
5
|
-
const
|
|
2
|
+
import { NiceAppShell as be, NiceButton as j, NiceTextInput as K, NiceTextArea as ae, NiceSelect as te, NiceCheckbox as ve, NiceIcon as Z } from "@nice2dev/ui";
|
|
3
|
+
import { NiceTutorialButton as se, resolveTutorial as re, NiceIcon as z, createId as ee } from "@nice2dev/ui-core";
|
|
4
|
+
import { useState as k, useCallback as I, useRef as ue, useEffect as we, forwardRef as Ce, useMemo as ke } from "react";
|
|
5
|
+
const Te = [
|
|
6
6
|
{
|
|
7
7
|
target: ".nice-api-designer",
|
|
8
8
|
titleKey: "tutorial.apiDesigner.intro.title",
|
|
@@ -11,7 +11,7 @@ const ke = [
|
|
|
11
11
|
content: "Define endpoints, parameters, request/response schemas and security for your OpenAPI document.",
|
|
12
12
|
placement: "auto"
|
|
13
13
|
}
|
|
14
|
-
],
|
|
14
|
+
], he = {
|
|
15
15
|
openapi: "3.0.3",
|
|
16
16
|
info: {
|
|
17
17
|
title: "Pet Store API",
|
|
@@ -113,19 +113,19 @@ const ke = [
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
tags: [{ name: "pets", description: "Pet operations" }]
|
|
116
|
-
},
|
|
116
|
+
}, ye = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Ee = [
|
|
117
117
|
"object",
|
|
118
118
|
"array",
|
|
119
119
|
"string",
|
|
120
120
|
"number",
|
|
121
121
|
"integer",
|
|
122
122
|
"boolean"
|
|
123
|
-
],
|
|
124
|
-
function
|
|
123
|
+
], Se = ["query", "path", "header", "cookie"], Pe = ["apiKey", "http", "oauth2", "openIdConnect"];
|
|
124
|
+
function le(t) {
|
|
125
125
|
var o, i;
|
|
126
126
|
const a = [];
|
|
127
127
|
return t.openapi || a.push({ path: "openapi", message: "OpenAPI version is required", severity: "error" }), (o = t.info) != null && o.title || a.push({ path: "info.title", message: "API title is required", severity: "error" }), (i = t.info) != null && i.version || a.push({ path: "info.version", message: "API version is required", severity: "error" }), Object.entries(t.paths || {}).forEach(([c, l]) => {
|
|
128
|
-
c.startsWith("/") || a.push({ path: `paths.${c}`, message: "Path must start with /", severity: "error" }),
|
|
128
|
+
c.startsWith("/") || a.push({ path: `paths.${c}`, message: "Path must start with /", severity: "error" }), ye.forEach((d) => {
|
|
129
129
|
const p = l[d.toLowerCase()];
|
|
130
130
|
p && !p.responses && a.push({
|
|
131
131
|
path: `paths.${c}.${d.toLowerCase()}.responses`,
|
|
@@ -135,8 +135,8 @@ function ce(t) {
|
|
|
135
135
|
});
|
|
136
136
|
}), a;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
function
|
|
138
|
+
const me = Ee.map((t) => ({ value: String(t), label: String(t) }));
|
|
139
|
+
function st({
|
|
140
140
|
schema: t,
|
|
141
141
|
onChange: a,
|
|
142
142
|
onSave: o,
|
|
@@ -144,14 +144,14 @@ function at({
|
|
|
144
144
|
className: c = "",
|
|
145
145
|
tutorial: l
|
|
146
146
|
}) {
|
|
147
|
-
var
|
|
148
|
-
const [d, p] = k(t ||
|
|
149
|
-
() =>
|
|
147
|
+
var H, M;
|
|
148
|
+
const [d, p] = k(t || he), [g, u] = k("/pets"), [f, _] = k("get"), [b, N] = k("paths"), [m, T] = k(
|
|
149
|
+
() => le(t || he)
|
|
150
150
|
), y = I(
|
|
151
151
|
(w) => {
|
|
152
152
|
p((v) => {
|
|
153
153
|
const x = w(v);
|
|
154
|
-
return a == null || a(x), T(
|
|
154
|
+
return a == null || a(x), T(le(x)), x;
|
|
155
155
|
});
|
|
156
156
|
},
|
|
157
157
|
[a]
|
|
@@ -167,20 +167,20 @@ function at({
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
})), u(w), _("get");
|
|
170
|
-
}, [y]),
|
|
170
|
+
}, [y]), U = I(
|
|
171
171
|
(w) => {
|
|
172
172
|
y((v) => {
|
|
173
|
-
const { [w]: x, ...
|
|
174
|
-
return { ...v, paths:
|
|
173
|
+
const { [w]: x, ...D } = v.paths;
|
|
174
|
+
return { ...v, paths: D };
|
|
175
175
|
}), u(null), _(null);
|
|
176
176
|
},
|
|
177
177
|
[y]
|
|
178
178
|
), F = I(() => {
|
|
179
179
|
let w = "NewSchema";
|
|
180
180
|
y((v) => {
|
|
181
|
-
var
|
|
181
|
+
var D, L, $;
|
|
182
182
|
let x = 1;
|
|
183
|
-
for (; (
|
|
183
|
+
for (; (L = (D = v.components) == null ? void 0 : D.schemas) != null && L[w]; )
|
|
184
184
|
w = `NewSchema${x++}`;
|
|
185
185
|
return {
|
|
186
186
|
...v,
|
|
@@ -190,29 +190,29 @@ function at({
|
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
});
|
|
193
|
-
}, [y]),
|
|
194
|
-
const w =
|
|
193
|
+
}, [y]), R = I(() => {
|
|
194
|
+
const w = le(d);
|
|
195
195
|
T(w), w.filter((v) => v.severity === "error").length === 0 && (o == null || o(d));
|
|
196
196
|
}, [d, o]), O = Object.entries(d.paths).flatMap(
|
|
197
|
-
([w, v]) =>
|
|
197
|
+
([w, v]) => ye.filter((x) => v[x.toLowerCase()]).map(
|
|
198
198
|
(x) => ({
|
|
199
199
|
path: w,
|
|
200
200
|
method: x,
|
|
201
201
|
operation: v[x.toLowerCase()]
|
|
202
202
|
})
|
|
203
203
|
)
|
|
204
|
-
),
|
|
204
|
+
), q = ["info", "paths", "schemas", "security", "preview"];
|
|
205
205
|
return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
|
|
206
|
-
l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(
|
|
206
|
+
l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(se, { steps: re(l, Te) }) }),
|
|
207
207
|
/* @__PURE__ */ e(
|
|
208
|
-
|
|
208
|
+
be,
|
|
209
209
|
{
|
|
210
210
|
flush: !0,
|
|
211
211
|
className: `nice-api-designer ${c}`,
|
|
212
212
|
height: "100%",
|
|
213
213
|
style: { minHeight: 600 },
|
|
214
214
|
toolbar: /* @__PURE__ */ n("div", { className: "nice-api-designer__toolbar", children: [
|
|
215
|
-
/* @__PURE__ */ e("div", { className: "nice-api-designer__tabs", children:
|
|
215
|
+
/* @__PURE__ */ e("div", { className: "nice-api-designer__tabs", children: q.map((w) => /* @__PURE__ */ e(
|
|
216
216
|
j,
|
|
217
217
|
{
|
|
218
218
|
size: "sm",
|
|
@@ -228,7 +228,7 @@ function at({
|
|
|
228
228
|
size: "sm",
|
|
229
229
|
variant: "primary",
|
|
230
230
|
leftIcon: /* @__PURE__ */ e(z, { name: "check", size: 14 }),
|
|
231
|
-
onClick:
|
|
231
|
+
onClick: R,
|
|
232
232
|
children: "Save"
|
|
233
233
|
}
|
|
234
234
|
)
|
|
@@ -249,9 +249,9 @@ function at({
|
|
|
249
249
|
v
|
|
250
250
|
)) }) : void 0,
|
|
251
251
|
children: /* @__PURE__ */ n("div", { className: "nice-api-designer__content", children: [
|
|
252
|
-
b === "info" && /* @__PURE__ */ e(
|
|
252
|
+
b === "info" && /* @__PURE__ */ e(Ae, { schema: d, onChange: y, readOnly: i }),
|
|
253
253
|
b === "paths" && /* @__PURE__ */ e(
|
|
254
|
-
|
|
254
|
+
xe,
|
|
255
255
|
{
|
|
256
256
|
endpoints: O,
|
|
257
257
|
schema: d,
|
|
@@ -261,15 +261,15 @@ function at({
|
|
|
261
261
|
u(w), _(v);
|
|
262
262
|
},
|
|
263
263
|
onAdd: A,
|
|
264
|
-
onDelete:
|
|
264
|
+
onDelete: U,
|
|
265
265
|
onChange: y,
|
|
266
266
|
readOnly: i
|
|
267
267
|
}
|
|
268
268
|
),
|
|
269
269
|
b === "schemas" && /* @__PURE__ */ e(
|
|
270
|
-
|
|
270
|
+
Ie,
|
|
271
271
|
{
|
|
272
|
-
schemas: ((
|
|
272
|
+
schemas: ((H = d.components) == null ? void 0 : H.schemas) || {},
|
|
273
273
|
onAdd: F,
|
|
274
274
|
onChange: (w) => y((v) => ({
|
|
275
275
|
...v,
|
|
@@ -279,7 +279,7 @@ function at({
|
|
|
279
279
|
}
|
|
280
280
|
),
|
|
281
281
|
b === "security" && /* @__PURE__ */ e(
|
|
282
|
-
|
|
282
|
+
$e,
|
|
283
283
|
{
|
|
284
284
|
schemes: ((M = d.components) == null ? void 0 : M.securitySchemes) || {},
|
|
285
285
|
onChange: (w) => y((v) => ({
|
|
@@ -289,13 +289,13 @@ function at({
|
|
|
289
289
|
readOnly: i
|
|
290
290
|
}
|
|
291
291
|
),
|
|
292
|
-
b === "preview" && /* @__PURE__ */ e(
|
|
292
|
+
b === "preview" && /* @__PURE__ */ e(Re, { schema: d })
|
|
293
293
|
] })
|
|
294
294
|
}
|
|
295
295
|
)
|
|
296
296
|
] });
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function Ae({ schema: t, onChange: a, readOnly: o }) {
|
|
299
299
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__info-editor", children: [
|
|
300
300
|
/* @__PURE__ */ e("h3", { children: "API information" }),
|
|
301
301
|
/* @__PURE__ */ e(
|
|
@@ -317,7 +317,7 @@ function Pe({ schema: t, onChange: a, readOnly: o }) {
|
|
|
317
317
|
}
|
|
318
318
|
),
|
|
319
319
|
/* @__PURE__ */ e(
|
|
320
|
-
|
|
320
|
+
ae,
|
|
321
321
|
{
|
|
322
322
|
label: "Description",
|
|
323
323
|
value: t.info.description || "",
|
|
@@ -390,7 +390,7 @@ function Pe({ schema: t, onChange: a, readOnly: o }) {
|
|
|
390
390
|
)
|
|
391
391
|
] });
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function xe({
|
|
394
394
|
endpoints: t,
|
|
395
395
|
schema: a,
|
|
396
396
|
selectedPath: o,
|
|
@@ -464,7 +464,7 @@ function Ae({
|
|
|
464
464
|
}
|
|
465
465
|
),
|
|
466
466
|
/* @__PURE__ */ e(
|
|
467
|
-
|
|
467
|
+
ae,
|
|
468
468
|
{
|
|
469
469
|
label: "Description",
|
|
470
470
|
value: u.description || "",
|
|
@@ -515,11 +515,11 @@ function Ae({
|
|
|
515
515
|
}
|
|
516
516
|
),
|
|
517
517
|
/* @__PURE__ */ e(
|
|
518
|
-
|
|
518
|
+
te,
|
|
519
519
|
{
|
|
520
520
|
size: "sm",
|
|
521
521
|
value: N.in,
|
|
522
|
-
options:
|
|
522
|
+
options: Se.map((T) => ({ value: String(T), label: String(T) })),
|
|
523
523
|
onChange: (T) => f({
|
|
524
524
|
parameters: _.map(
|
|
525
525
|
(y, A) => A === m ? { ...y, in: T } : y
|
|
@@ -528,7 +528,7 @@ function Ae({
|
|
|
528
528
|
}
|
|
529
529
|
),
|
|
530
530
|
/* @__PURE__ */ e(
|
|
531
|
-
|
|
531
|
+
ve,
|
|
532
532
|
{
|
|
533
533
|
checked: !!N.required,
|
|
534
534
|
onChange: (T) => f({
|
|
@@ -562,7 +562,7 @@ function Ae({
|
|
|
562
562
|
] })
|
|
563
563
|
] });
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function Ie({
|
|
566
566
|
schemas: t,
|
|
567
567
|
onAdd: a,
|
|
568
568
|
onChange: o,
|
|
@@ -595,16 +595,16 @@ function xe({
|
|
|
595
595
|
l && p && /* @__PURE__ */ n("div", { className: "nice-api-designer__schema-editor", children: [
|
|
596
596
|
/* @__PURE__ */ e("h3", { children: l }),
|
|
597
597
|
/* @__PURE__ */ e(
|
|
598
|
-
|
|
598
|
+
te,
|
|
599
599
|
{
|
|
600
600
|
label: "Type",
|
|
601
601
|
value: p.type || "object",
|
|
602
|
-
options:
|
|
602
|
+
options: me,
|
|
603
603
|
onChange: (_) => u({ type: _ })
|
|
604
604
|
}
|
|
605
605
|
),
|
|
606
606
|
/* @__PURE__ */ e(
|
|
607
|
-
|
|
607
|
+
ae,
|
|
608
608
|
{
|
|
609
609
|
label: "Description",
|
|
610
610
|
value: p.description || "",
|
|
@@ -657,16 +657,16 @@ function xe({
|
|
|
657
657
|
}
|
|
658
658
|
),
|
|
659
659
|
/* @__PURE__ */ e(
|
|
660
|
-
|
|
660
|
+
te,
|
|
661
661
|
{
|
|
662
662
|
size: "sm",
|
|
663
663
|
value: b.type || "string",
|
|
664
|
-
options:
|
|
664
|
+
options: me,
|
|
665
665
|
onChange: (m) => f(_, { ...b, type: m })
|
|
666
666
|
}
|
|
667
667
|
),
|
|
668
668
|
/* @__PURE__ */ e(
|
|
669
|
-
|
|
669
|
+
ve,
|
|
670
670
|
{
|
|
671
671
|
checked: N,
|
|
672
672
|
onChange: (m) => u({
|
|
@@ -696,7 +696,7 @@ function xe({
|
|
|
696
696
|
/* @__PURE__ */ n("details", { className: "nice-api-designer__raw", children: [
|
|
697
697
|
/* @__PURE__ */ e("summary", { children: "Raw JSON schema" }),
|
|
698
698
|
/* @__PURE__ */ e(
|
|
699
|
-
|
|
699
|
+
ae,
|
|
700
700
|
{
|
|
701
701
|
value: JSON.stringify(p, null, 2),
|
|
702
702
|
onChange: (_) => {
|
|
@@ -715,7 +715,7 @@ function xe({
|
|
|
715
715
|
] })
|
|
716
716
|
] });
|
|
717
717
|
}
|
|
718
|
-
function
|
|
718
|
+
function $e({ schemes: t, onChange: a, readOnly: o }) {
|
|
719
719
|
const i = (c, l) => a({ ...t, [c]: l });
|
|
720
720
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__security-editor", children: [
|
|
721
721
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
|
|
@@ -757,11 +757,11 @@ function Ie({ schemes: t, onChange: a, readOnly: o }) {
|
|
|
757
757
|
] }),
|
|
758
758
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
|
|
759
759
|
/* @__PURE__ */ e(
|
|
760
|
-
|
|
760
|
+
te,
|
|
761
761
|
{
|
|
762
762
|
size: "sm",
|
|
763
763
|
value: l.type,
|
|
764
|
-
options:
|
|
764
|
+
options: Pe.map((d) => ({ value: String(d), label: String(d) })),
|
|
765
765
|
onChange: (d) => i(c, { ...l, type: d })
|
|
766
766
|
}
|
|
767
767
|
),
|
|
@@ -777,7 +777,7 @@ function Ie({ schemes: t, onChange: a, readOnly: o }) {
|
|
|
777
777
|
}
|
|
778
778
|
),
|
|
779
779
|
/* @__PURE__ */ e(
|
|
780
|
-
|
|
780
|
+
te,
|
|
781
781
|
{
|
|
782
782
|
size: "sm",
|
|
783
783
|
value: l.in || "header",
|
|
@@ -822,13 +822,13 @@ function Ie({ schemes: t, onChange: a, readOnly: o }) {
|
|
|
822
822
|
] }, c))
|
|
823
823
|
] });
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function Re({ schema: t }) {
|
|
826
826
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__json-preview", children: [
|
|
827
827
|
/* @__PURE__ */ e("h3", { children: "OpenAPI specification" }),
|
|
828
828
|
/* @__PURE__ */ e("pre", { className: "nice-api-designer__code", children: JSON.stringify(t, null, 2) })
|
|
829
829
|
] });
|
|
830
830
|
}
|
|
831
|
-
const
|
|
831
|
+
const qe = [
|
|
832
832
|
{
|
|
833
833
|
target: ".nice-api-tester",
|
|
834
834
|
titleKey: "tutorial.apiTester.intro.title",
|
|
@@ -837,7 +837,7 @@ const De = [
|
|
|
837
837
|
content: "Build requests with collections and environment variables, send them and assert on the responses.",
|
|
838
838
|
placement: "auto"
|
|
839
839
|
}
|
|
840
|
-
],
|
|
840
|
+
], De = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], ze = {
|
|
841
841
|
id: "",
|
|
842
842
|
name: "New Request",
|
|
843
843
|
method: "GET",
|
|
@@ -845,14 +845,14 @@ const De = [
|
|
|
845
845
|
headers: {},
|
|
846
846
|
queryParams: {}
|
|
847
847
|
};
|
|
848
|
-
function
|
|
848
|
+
function de(t, a) {
|
|
849
849
|
return t.replace(/\{\{(\w+)\}\}/g, (o, i) => a[i] || `{{${i}}}`);
|
|
850
850
|
}
|
|
851
|
-
function
|
|
851
|
+
function je(t, a) {
|
|
852
852
|
const o = Object.entries(a).filter(([, i]) => i).map(([i, c]) => `${encodeURIComponent(i)}=${encodeURIComponent(c)}`).join("&");
|
|
853
853
|
return o ? `${t}?${o}` : t;
|
|
854
854
|
}
|
|
855
|
-
function
|
|
855
|
+
function rt({
|
|
856
856
|
collections: t = [],
|
|
857
857
|
environments: a = [],
|
|
858
858
|
onRequest: o,
|
|
@@ -863,27 +863,27 @@ function st({
|
|
|
863
863
|
const [d, p] = k(t), [g, u] = k(a), [f, _] = k(
|
|
864
864
|
a.find((s) => s.isActive) || null
|
|
865
865
|
), [b, N] = k({
|
|
866
|
-
...
|
|
867
|
-
id:
|
|
868
|
-
}), [m, T] = k(null), [y, A] = k(!1), [
|
|
866
|
+
...ze,
|
|
867
|
+
id: ee()
|
|
868
|
+
}), [m, T] = k(null), [y, A] = k(!1), [U, F] = k("none"), [R, O] = k(
|
|
869
869
|
"params"
|
|
870
|
-
), [
|
|
870
|
+
), [q, H] = k("body"), [M, w] = k(""), [v, x] = k(""), [D, L] = k([]), [$, J] = k([]), V = ue(null), Y = I(async () => {
|
|
871
871
|
var S;
|
|
872
872
|
if (!b.url)
|
|
873
873
|
return;
|
|
874
|
-
A(!0), T(null),
|
|
874
|
+
A(!0), T(null), L([]);
|
|
875
875
|
const s = Object.fromEntries(
|
|
876
876
|
Object.entries((f == null ? void 0 : f.variables) || {}).map(([E, P]) => [E, P.value])
|
|
877
877
|
), r = {
|
|
878
878
|
...b,
|
|
879
|
-
url:
|
|
879
|
+
url: de(b.url, s),
|
|
880
880
|
headers: Object.fromEntries(
|
|
881
|
-
Object.entries(b.headers).map(([E, P]) => [E,
|
|
881
|
+
Object.entries(b.headers).map(([E, P]) => [E, de(P, s)])
|
|
882
882
|
),
|
|
883
883
|
queryParams: Object.fromEntries(
|
|
884
884
|
Object.entries(b.queryParams).map(([E, P]) => [
|
|
885
885
|
E,
|
|
886
|
-
|
|
886
|
+
de(P, s)
|
|
887
887
|
])
|
|
888
888
|
)
|
|
889
889
|
}, C = performance.now();
|
|
@@ -894,36 +894,36 @@ function st({
|
|
|
894
894
|
else {
|
|
895
895
|
V.current = new AbortController();
|
|
896
896
|
const P = { ...r.headers };
|
|
897
|
-
b.auth &&
|
|
898
|
-
const
|
|
897
|
+
b.auth && Oe(P, b.auth);
|
|
898
|
+
const ie = je(r.url, r.queryParams), G = {
|
|
899
899
|
method: r.method,
|
|
900
900
|
headers: P,
|
|
901
901
|
signal: V.current.signal
|
|
902
902
|
};
|
|
903
903
|
["POST", "PUT", "PATCH"].includes(r.method) && ((S = b.body) != null && S.content) && (G.body = typeof b.body.content == "string" ? b.body.content : JSON.stringify(b.body.content), b.body.type === "json" && (P["Content-Type"] = "application/json"));
|
|
904
|
-
const
|
|
905
|
-
let
|
|
904
|
+
const ne = await fetch(ie, G), oe = await ne.text();
|
|
905
|
+
let ce;
|
|
906
906
|
try {
|
|
907
|
-
|
|
907
|
+
ce = JSON.parse(oe);
|
|
908
908
|
} catch {
|
|
909
|
-
|
|
909
|
+
ce = oe;
|
|
910
910
|
}
|
|
911
|
-
const
|
|
911
|
+
const Ne = performance.now();
|
|
912
912
|
E = {
|
|
913
|
-
status:
|
|
914
|
-
statusText:
|
|
915
|
-
headers: Object.fromEntries(
|
|
916
|
-
body:
|
|
917
|
-
time: Math.round(
|
|
918
|
-
size: new Blob([
|
|
913
|
+
status: ne.status,
|
|
914
|
+
statusText: ne.statusText,
|
|
915
|
+
headers: Object.fromEntries(ne.headers.entries()),
|
|
916
|
+
body: ce,
|
|
917
|
+
time: Math.round(Ne - C),
|
|
918
|
+
size: new Blob([oe]).size,
|
|
919
919
|
timestamp: /* @__PURE__ */ new Date()
|
|
920
920
|
};
|
|
921
921
|
}
|
|
922
922
|
if (T(E), J(
|
|
923
923
|
(P) => [...P, { request: b, response: E }].slice(-50)
|
|
924
924
|
), v) {
|
|
925
|
-
const P =
|
|
926
|
-
|
|
925
|
+
const P = He(v, E);
|
|
926
|
+
L(P);
|
|
927
927
|
}
|
|
928
928
|
} catch (E) {
|
|
929
929
|
E.name !== "AbortError" && T({
|
|
@@ -954,7 +954,7 @@ function st({
|
|
|
954
954
|
}, []), h = I(() => {
|
|
955
955
|
if (d.length === 0) {
|
|
956
956
|
const s = {
|
|
957
|
-
id:
|
|
957
|
+
id: ee(),
|
|
958
958
|
name: "My Collection",
|
|
959
959
|
requests: [b]
|
|
960
960
|
};
|
|
@@ -968,7 +968,7 @@ function st({
|
|
|
968
968
|
}
|
|
969
969
|
}, [d, b, i]);
|
|
970
970
|
return /* @__PURE__ */ n("div", { className: `nice-api-tester ${c}`, style: { position: "relative" }, children: [
|
|
971
|
-
l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(
|
|
971
|
+
l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(se, { steps: re(l, qe) }) }),
|
|
972
972
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__toolbar", children: /* @__PURE__ */ e("div", { className: "nice-api-tester__env-selector", children: /* @__PURE__ */ n(
|
|
973
973
|
"select",
|
|
974
974
|
{
|
|
@@ -990,7 +990,7 @@ function st({
|
|
|
990
990
|
method: s.target.value
|
|
991
991
|
})),
|
|
992
992
|
className: `nice-api-tester__method nice-api-tester__method--${b.method.toLowerCase()}`,
|
|
993
|
-
children:
|
|
993
|
+
children: De.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
|
|
994
994
|
}
|
|
995
995
|
),
|
|
996
996
|
/* @__PURE__ */ e(
|
|
@@ -1018,47 +1018,47 @@ function st({
|
|
|
1018
1018
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["params", "headers", "body", "auth", "tests"].map((s) => /* @__PURE__ */ e(
|
|
1019
1019
|
"button",
|
|
1020
1020
|
{
|
|
1021
|
-
className: `nice-api-tester__tab ${
|
|
1021
|
+
className: `nice-api-tester__tab ${R === s ? "nice-api-tester__tab--active" : ""}`,
|
|
1022
1022
|
onClick: () => O(s),
|
|
1023
1023
|
children: s.charAt(0).toUpperCase() + s.slice(1)
|
|
1024
1024
|
},
|
|
1025
1025
|
s
|
|
1026
1026
|
)) }),
|
|
1027
1027
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__tab-content", children: [
|
|
1028
|
-
|
|
1029
|
-
|
|
1028
|
+
R === "params" && /* @__PURE__ */ e(
|
|
1029
|
+
Le,
|
|
1030
1030
|
{
|
|
1031
1031
|
params: b.queryParams,
|
|
1032
1032
|
onChange: (s) => N((r) => ({ ...r, queryParams: s })),
|
|
1033
1033
|
onAdd: Q
|
|
1034
1034
|
}
|
|
1035
1035
|
),
|
|
1036
|
-
|
|
1037
|
-
|
|
1036
|
+
R === "headers" && /* @__PURE__ */ e(
|
|
1037
|
+
Ue,
|
|
1038
1038
|
{
|
|
1039
1039
|
headers: b.headers,
|
|
1040
1040
|
onChange: (s) => N((r) => ({ ...r, headers: s })),
|
|
1041
1041
|
onAdd: X
|
|
1042
1042
|
}
|
|
1043
1043
|
),
|
|
1044
|
-
|
|
1045
|
-
|
|
1044
|
+
R === "body" && /* @__PURE__ */ e(
|
|
1045
|
+
Me,
|
|
1046
1046
|
{
|
|
1047
1047
|
body: b.body,
|
|
1048
|
-
bodyTab:
|
|
1048
|
+
bodyTab: U,
|
|
1049
1049
|
onBodyTabChange: F,
|
|
1050
1050
|
onChange: (s) => N((r) => ({ ...r, body: s }))
|
|
1051
1051
|
}
|
|
1052
1052
|
),
|
|
1053
|
-
|
|
1054
|
-
|
|
1053
|
+
R === "auth" && /* @__PURE__ */ e(
|
|
1054
|
+
Be,
|
|
1055
1055
|
{
|
|
1056
1056
|
auth: b.auth,
|
|
1057
1057
|
onChange: (s) => N((r) => ({ ...r, auth: s }))
|
|
1058
1058
|
}
|
|
1059
1059
|
),
|
|
1060
|
-
|
|
1061
|
-
|
|
1060
|
+
R === "tests" && /* @__PURE__ */ e(
|
|
1061
|
+
Ve,
|
|
1062
1062
|
{
|
|
1063
1063
|
preRequestScript: M,
|
|
1064
1064
|
testScript: v,
|
|
@@ -1085,31 +1085,31 @@ function st({
|
|
|
1085
1085
|
m.time,
|
|
1086
1086
|
"ms"
|
|
1087
1087
|
] }),
|
|
1088
|
-
/* @__PURE__ */ e("span", { className: "nice-api-tester__size", children:
|
|
1088
|
+
/* @__PURE__ */ e("span", { className: "nice-api-tester__size", children: Ke(m.size) })
|
|
1089
1089
|
] }),
|
|
1090
1090
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["body", "headers", "tests"].map((s) => /* @__PURE__ */ n(
|
|
1091
1091
|
"button",
|
|
1092
1092
|
{
|
|
1093
|
-
className: `nice-api-tester__tab ${
|
|
1094
|
-
onClick: () =>
|
|
1093
|
+
className: `nice-api-tester__tab ${q === s ? "nice-api-tester__tab--active" : ""}`,
|
|
1094
|
+
onClick: () => H(s),
|
|
1095
1095
|
children: [
|
|
1096
1096
|
s.charAt(0).toUpperCase() + s.slice(1),
|
|
1097
|
-
s === "tests" &&
|
|
1098
|
-
|
|
1097
|
+
s === "tests" && D.length > 0 && /* @__PURE__ */ n("span", { className: "nice-api-tester__test-badge", children: [
|
|
1098
|
+
D.filter((r) => r.passed).length,
|
|
1099
1099
|
"/",
|
|
1100
|
-
|
|
1100
|
+
D.length
|
|
1101
1101
|
] })
|
|
1102
1102
|
]
|
|
1103
1103
|
},
|
|
1104
1104
|
s
|
|
1105
1105
|
)) }),
|
|
1106
1106
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__response-content", children: [
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
q === "body" && /* @__PURE__ */ e("pre", { className: "nice-api-tester__response-body", children: typeof m.body == "string" ? m.body : JSON.stringify(m.body, null, 2) }),
|
|
1108
|
+
q === "headers" && /* @__PURE__ */ e("div", { className: "nice-api-tester__response-headers", children: Object.entries(m.headers).map(([s, r]) => /* @__PURE__ */ n("div", { className: "nice-api-tester__header-row", children: [
|
|
1109
1109
|
/* @__PURE__ */ e("span", { className: "nice-api-tester__header-key", children: s }),
|
|
1110
1110
|
/* @__PURE__ */ e("span", { className: "nice-api-tester__header-value", children: r })
|
|
1111
1111
|
] }, s)) }),
|
|
1112
|
-
|
|
1112
|
+
q === "tests" && /* @__PURE__ */ e("div", { className: "nice-api-tester__test-results", children: D.map((s, r) => /* @__PURE__ */ n(
|
|
1113
1113
|
"div",
|
|
1114
1114
|
{
|
|
1115
1115
|
className: `nice-api-tester__test-result nice-api-tester__test-result--${s.passed ? "pass" : "fail"}`,
|
|
@@ -1156,7 +1156,7 @@ function st({
|
|
|
1156
1156
|
] })
|
|
1157
1157
|
] });
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1159
|
+
function Oe(t, a) {
|
|
1160
1160
|
var o, i, c, l, d;
|
|
1161
1161
|
switch (a.type) {
|
|
1162
1162
|
case "bearer":
|
|
@@ -1170,10 +1170,10 @@ function je(t, a) {
|
|
|
1170
1170
|
break;
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1173
|
+
function Ke(t) {
|
|
1174
1174
|
return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
|
|
1175
1175
|
}
|
|
1176
|
-
function
|
|
1176
|
+
function He(t, a) {
|
|
1177
1177
|
const o = [], i = {
|
|
1178
1178
|
response: {
|
|
1179
1179
|
code: a.status,
|
|
@@ -1229,7 +1229,7 @@ function Ke(t, a) {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
return o;
|
|
1231
1231
|
}
|
|
1232
|
-
function
|
|
1232
|
+
function fe({
|
|
1233
1233
|
items: t,
|
|
1234
1234
|
onChange: a,
|
|
1235
1235
|
onAdd: o,
|
|
@@ -1273,13 +1273,13 @@ function ye({
|
|
|
1273
1273
|
/* @__PURE__ */ e("button", { onClick: o, className: "nice-api-tester__add-btn", children: "+ Add" })
|
|
1274
1274
|
] });
|
|
1275
1275
|
}
|
|
1276
|
-
function
|
|
1276
|
+
function Le({
|
|
1277
1277
|
params: t,
|
|
1278
1278
|
onChange: a,
|
|
1279
1279
|
onAdd: o
|
|
1280
1280
|
}) {
|
|
1281
1281
|
return /* @__PURE__ */ e(
|
|
1282
|
-
|
|
1282
|
+
fe,
|
|
1283
1283
|
{
|
|
1284
1284
|
items: t,
|
|
1285
1285
|
onChange: a,
|
|
@@ -1289,13 +1289,13 @@ function Ue({
|
|
|
1289
1289
|
}
|
|
1290
1290
|
);
|
|
1291
1291
|
}
|
|
1292
|
-
function
|
|
1292
|
+
function Ue({
|
|
1293
1293
|
headers: t,
|
|
1294
1294
|
onChange: a,
|
|
1295
1295
|
onAdd: o
|
|
1296
1296
|
}) {
|
|
1297
1297
|
return /* @__PURE__ */ e(
|
|
1298
|
-
|
|
1298
|
+
fe,
|
|
1299
1299
|
{
|
|
1300
1300
|
items: t,
|
|
1301
1301
|
onChange: a,
|
|
@@ -1305,7 +1305,7 @@ function He({
|
|
|
1305
1305
|
}
|
|
1306
1306
|
);
|
|
1307
1307
|
}
|
|
1308
|
-
function
|
|
1308
|
+
function Me({
|
|
1309
1309
|
body: t,
|
|
1310
1310
|
bodyTab: a,
|
|
1311
1311
|
onBodyTabChange: o,
|
|
@@ -1337,7 +1337,7 @@ function Le({
|
|
|
1337
1337
|
)
|
|
1338
1338
|
] });
|
|
1339
1339
|
}
|
|
1340
|
-
function
|
|
1340
|
+
function Be({
|
|
1341
1341
|
auth: t,
|
|
1342
1342
|
onChange: a
|
|
1343
1343
|
}) {
|
|
@@ -1491,7 +1491,7 @@ function Me({
|
|
|
1491
1491
|
] })
|
|
1492
1492
|
] });
|
|
1493
1493
|
}
|
|
1494
|
-
function
|
|
1494
|
+
function Ve({
|
|
1495
1495
|
preRequestScript: t,
|
|
1496
1496
|
testScript: a,
|
|
1497
1497
|
onPreRequestChange: o,
|
|
@@ -1526,7 +1526,7 @@ function Be({
|
|
|
1526
1526
|
] })
|
|
1527
1527
|
] });
|
|
1528
1528
|
}
|
|
1529
|
-
const
|
|
1529
|
+
const Fe = [
|
|
1530
1530
|
{
|
|
1531
1531
|
target: ".nice-integration-builder",
|
|
1532
1532
|
titleKey: "tutorial.integrationBuilder.intro.title",
|
|
@@ -1535,7 +1535,7 @@ const Ve = [
|
|
|
1535
1535
|
content: "Wire a flow of nodes (triggers → actions → error handling) and connect them to build an integration.",
|
|
1536
1536
|
placement: "auto"
|
|
1537
1537
|
}
|
|
1538
|
-
],
|
|
1538
|
+
], pe = [
|
|
1539
1539
|
{ type: "trigger", label: "Trigger", icon: "zap", category: "Control" },
|
|
1540
1540
|
{ type: "http-request", label: "HTTP Request", icon: "globe", category: "Actions" },
|
|
1541
1541
|
{ type: "transform", label: "Transform", icon: "shuffle", category: "Data" },
|
|
@@ -1549,7 +1549,7 @@ const Ve = [
|
|
|
1549
1549
|
{ type: "webhook", label: "Webhook", icon: "link", category: "Actions" },
|
|
1550
1550
|
{ type: "function", label: "Function", icon: "code", category: "Actions" },
|
|
1551
1551
|
{ type: "error-handler", label: "Error Handler", icon: "warning", category: "Control" }
|
|
1552
|
-
],
|
|
1552
|
+
], Je = {
|
|
1553
1553
|
id: "",
|
|
1554
1554
|
name: "New Flow",
|
|
1555
1555
|
nodes: [],
|
|
@@ -1558,7 +1558,7 @@ const Ve = [
|
|
|
1558
1558
|
triggers: [],
|
|
1559
1559
|
errorHandling: { strategy: "stop" }
|
|
1560
1560
|
};
|
|
1561
|
-
function
|
|
1561
|
+
function ot({
|
|
1562
1562
|
flow: t,
|
|
1563
1563
|
connectors: a = [],
|
|
1564
1564
|
onChange: o,
|
|
@@ -1568,8 +1568,8 @@ function rt({
|
|
|
1568
1568
|
tutorial: d
|
|
1569
1569
|
}) {
|
|
1570
1570
|
const [p, g] = k(
|
|
1571
|
-
t || { ...
|
|
1572
|
-
), [u, f] = k(null), [_, b] = k(!0), [N, m] = k("canvas"), [T, y] = k(!1), [A,
|
|
1571
|
+
t || { ...Je, id: ee() }
|
|
1572
|
+
), [u, f] = k(null), [_, b] = k(!0), [N, m] = k("canvas"), [T, y] = k(!1), [A, U] = k(null), [F, R] = k(!1), [O, q] = k(null), [H, M] = k(!1), w = ue(null), v = I(
|
|
1573
1573
|
(h) => {
|
|
1574
1574
|
g((s) => {
|
|
1575
1575
|
const r = h(s);
|
|
@@ -1581,11 +1581,11 @@ function rt({
|
|
|
1581
1581
|
(h, s) => {
|
|
1582
1582
|
var C;
|
|
1583
1583
|
const r = {
|
|
1584
|
-
id:
|
|
1584
|
+
id: ee(),
|
|
1585
1585
|
type: h,
|
|
1586
|
-
name: ((C =
|
|
1586
|
+
name: ((C = pe.find((S) => S.type === h)) == null ? void 0 : C.label) || h,
|
|
1587
1587
|
position: s,
|
|
1588
|
-
config:
|
|
1588
|
+
config: We(h),
|
|
1589
1589
|
inputs: h !== "trigger" ? ["input"] : [],
|
|
1590
1590
|
outputs: ["output"]
|
|
1591
1591
|
};
|
|
@@ -1595,7 +1595,7 @@ function rt({
|
|
|
1595
1595
|
})), f(r);
|
|
1596
1596
|
},
|
|
1597
1597
|
[v]
|
|
1598
|
-
),
|
|
1598
|
+
), D = I(
|
|
1599
1599
|
(h) => {
|
|
1600
1600
|
v((s) => ({
|
|
1601
1601
|
...s,
|
|
@@ -1606,7 +1606,7 @@ function rt({
|
|
|
1606
1606
|
})), f(null);
|
|
1607
1607
|
},
|
|
1608
1608
|
[v]
|
|
1609
|
-
),
|
|
1609
|
+
), L = I(
|
|
1610
1610
|
(h, s) => {
|
|
1611
1611
|
v((r) => ({
|
|
1612
1612
|
...r,
|
|
@@ -1623,7 +1623,7 @@ function rt({
|
|
|
1623
1623
|
connections: [
|
|
1624
1624
|
...E.connections,
|
|
1625
1625
|
{
|
|
1626
|
-
id:
|
|
1626
|
+
id: ee(),
|
|
1627
1627
|
sourceNodeId: h,
|
|
1628
1628
|
sourceOutput: s,
|
|
1629
1629
|
targetNodeId: r,
|
|
@@ -1646,7 +1646,7 @@ function rt({
|
|
|
1646
1646
|
if (h.preventDefault(), !A || !w.current)
|
|
1647
1647
|
return;
|
|
1648
1648
|
const s = w.current.getBoundingClientRect(), r = h.clientX - s.left, C = h.clientY - s.top;
|
|
1649
|
-
x(A, { x: r, y: C }), y(!1),
|
|
1649
|
+
x(A, { x: r, y: C }), y(!1), U(null);
|
|
1650
1650
|
},
|
|
1651
1651
|
[A, x]
|
|
1652
1652
|
), Y = I(async () => {
|
|
@@ -1664,16 +1664,16 @@ function rt({
|
|
|
1664
1664
|
/* @__PURE__ */ e("h4", { children: "Nodes" }),
|
|
1665
1665
|
["Control", "Actions", "Data"].map((h) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__category", children: [
|
|
1666
1666
|
/* @__PURE__ */ e("h5", { children: h }),
|
|
1667
|
-
|
|
1667
|
+
pe.filter((s) => s.category === h).map((s) => /* @__PURE__ */ n(
|
|
1668
1668
|
"div",
|
|
1669
1669
|
{
|
|
1670
1670
|
className: "nice-integration-builder__palette-item",
|
|
1671
1671
|
draggable: !0,
|
|
1672
1672
|
onDragStart: () => {
|
|
1673
|
-
y(!0),
|
|
1673
|
+
y(!0), U(s.type);
|
|
1674
1674
|
},
|
|
1675
1675
|
onDragEnd: () => {
|
|
1676
|
-
y(!1),
|
|
1676
|
+
y(!1), U(null);
|
|
1677
1677
|
},
|
|
1678
1678
|
children: [
|
|
1679
1679
|
/* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(Z, { name: s.icon, size: 14 }) }),
|
|
@@ -1691,17 +1691,17 @@ function rt({
|
|
|
1691
1691
|
] }, h.id))
|
|
1692
1692
|
] })
|
|
1693
1693
|
] }) : void 0, Q = u && N === "canvas" ? /* @__PURE__ */ e(
|
|
1694
|
-
|
|
1694
|
+
Ye,
|
|
1695
1695
|
{
|
|
1696
1696
|
node: u,
|
|
1697
|
-
onChange: (h) =>
|
|
1697
|
+
onChange: (h) => L(u.id, h),
|
|
1698
1698
|
onClose: () => f(null)
|
|
1699
1699
|
}
|
|
1700
1700
|
) : void 0;
|
|
1701
1701
|
return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
|
|
1702
|
-
d && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(
|
|
1702
|
+
d && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(se, { steps: re(d, Fe) }) }),
|
|
1703
1703
|
/* @__PURE__ */ n(
|
|
1704
|
-
|
|
1704
|
+
be,
|
|
1705
1705
|
{
|
|
1706
1706
|
flush: !0,
|
|
1707
1707
|
className: `nice-integration-builder ${l}`,
|
|
@@ -1733,12 +1733,12 @@ function rt({
|
|
|
1733
1733
|
"button",
|
|
1734
1734
|
{
|
|
1735
1735
|
onClick: Y,
|
|
1736
|
-
disabled:
|
|
1736
|
+
disabled: H,
|
|
1737
1737
|
className: "nice-integration-builder__run-btn",
|
|
1738
1738
|
children: [
|
|
1739
|
-
/* @__PURE__ */ e(Z, { name:
|
|
1739
|
+
/* @__PURE__ */ e(Z, { name: H ? "clock" : "play", size: 14 }),
|
|
1740
1740
|
" ",
|
|
1741
|
-
|
|
1741
|
+
H ? "Running..." : "Run"
|
|
1742
1742
|
]
|
|
1743
1743
|
}
|
|
1744
1744
|
),
|
|
@@ -1762,28 +1762,28 @@ function rt({
|
|
|
1762
1762
|
const s = p.nodes.find((G) => G.id === h.sourceNodeId), r = p.nodes.find((G) => G.id === h.targetNodeId);
|
|
1763
1763
|
if (!s || !r)
|
|
1764
1764
|
return null;
|
|
1765
|
-
const C = s.position.x + 150, S = s.position.y + 30, E = r.position.x, P = r.position.y + 30,
|
|
1765
|
+
const C = s.position.x + 150, S = s.position.y + 30, E = r.position.x, P = r.position.y + 30, ie = (C + E) / 2;
|
|
1766
1766
|
return /* @__PURE__ */ e("g", { onClick: () => J(h.id), children: /* @__PURE__ */ e(
|
|
1767
1767
|
"path",
|
|
1768
1768
|
{
|
|
1769
|
-
d: `M ${C} ${S} C ${
|
|
1769
|
+
d: `M ${C} ${S} C ${ie} ${S}, ${ie} ${P}, ${E} ${P}`,
|
|
1770
1770
|
className: "nice-integration-builder__connection"
|
|
1771
1771
|
}
|
|
1772
1772
|
) }, h.id);
|
|
1773
1773
|
}) }),
|
|
1774
1774
|
p.nodes.map((h) => /* @__PURE__ */ e(
|
|
1775
|
-
|
|
1775
|
+
Ge,
|
|
1776
1776
|
{
|
|
1777
1777
|
node: h,
|
|
1778
1778
|
isSelected: (u == null ? void 0 : u.id) === h.id,
|
|
1779
1779
|
onSelect: () => f(h),
|
|
1780
|
-
onDelete: () =>
|
|
1781
|
-
onPositionChange: (s) =>
|
|
1780
|
+
onDelete: () => D(h.id),
|
|
1781
|
+
onPositionChange: (s) => L(h.id, { position: s }),
|
|
1782
1782
|
onStartConnection: (s) => {
|
|
1783
|
-
|
|
1783
|
+
R(!0), q({ nodeId: h.id, output: s });
|
|
1784
1784
|
},
|
|
1785
1785
|
onEndConnection: (s) => {
|
|
1786
|
-
O && $(O.nodeId, O.output, h.id, s),
|
|
1786
|
+
O && $(O.nodeId, O.output, h.id, s), R(!1), q(null);
|
|
1787
1787
|
}
|
|
1788
1788
|
},
|
|
1789
1789
|
h.id
|
|
@@ -1794,14 +1794,14 @@ function rt({
|
|
|
1794
1794
|
),
|
|
1795
1795
|
N === "code" && /* @__PURE__ */ e("div", { className: "nice-integration-builder__code-view", children: /* @__PURE__ */ e("pre", { children: JSON.stringify(p, null, 2) }) }),
|
|
1796
1796
|
N === "variables" && /* @__PURE__ */ e(
|
|
1797
|
-
|
|
1797
|
+
Xe,
|
|
1798
1798
|
{
|
|
1799
1799
|
variables: p.variables,
|
|
1800
1800
|
onChange: (h) => v((s) => ({ ...s, variables: h }))
|
|
1801
1801
|
}
|
|
1802
1802
|
),
|
|
1803
1803
|
N === "settings" && /* @__PURE__ */ e(
|
|
1804
|
-
|
|
1804
|
+
Qe,
|
|
1805
1805
|
{
|
|
1806
1806
|
errorHandling: p.errorHandling,
|
|
1807
1807
|
schedule: p.schedule,
|
|
@@ -1813,7 +1813,7 @@ function rt({
|
|
|
1813
1813
|
)
|
|
1814
1814
|
] });
|
|
1815
1815
|
}
|
|
1816
|
-
function
|
|
1816
|
+
function We(t) {
|
|
1817
1817
|
switch (t) {
|
|
1818
1818
|
case "http-request":
|
|
1819
1819
|
return { method: "GET", url: "", headers: {}, body: "" };
|
|
@@ -1844,7 +1844,7 @@ return input;` };
|
|
|
1844
1844
|
return {};
|
|
1845
1845
|
}
|
|
1846
1846
|
}
|
|
1847
|
-
function
|
|
1847
|
+
function Ge({
|
|
1848
1848
|
node: t,
|
|
1849
1849
|
isSelected: a,
|
|
1850
1850
|
onSelect: o,
|
|
@@ -1853,13 +1853,13 @@ function We({
|
|
|
1853
1853
|
onStartConnection: l,
|
|
1854
1854
|
onEndConnection: d
|
|
1855
1855
|
}) {
|
|
1856
|
-
const [p, g] = k(!1), [u, f] = k({ x: 0, y: 0 }), _ =
|
|
1856
|
+
const [p, g] = k(!1), [u, f] = k({ x: 0, y: 0 }), _ = ue(null), b = pe.find((m) => m.type === t.type), N = (m) => {
|
|
1857
1857
|
m.button === 0 && (m.stopPropagation(), g(!0), f({
|
|
1858
1858
|
x: m.clientX - t.position.x,
|
|
1859
1859
|
y: m.clientY - t.position.y
|
|
1860
1860
|
}), o());
|
|
1861
1861
|
};
|
|
1862
|
-
return
|
|
1862
|
+
return we(() => {
|
|
1863
1863
|
if (!p)
|
|
1864
1864
|
return;
|
|
1865
1865
|
const m = (y) => {
|
|
@@ -1928,7 +1928,7 @@ function We({
|
|
|
1928
1928
|
}
|
|
1929
1929
|
);
|
|
1930
1930
|
}
|
|
1931
|
-
function
|
|
1931
|
+
function Ye({
|
|
1932
1932
|
node: t,
|
|
1933
1933
|
onChange: a,
|
|
1934
1934
|
onClose: o
|
|
@@ -2060,7 +2060,7 @@ function Ge({
|
|
|
2060
2060
|
] })
|
|
2061
2061
|
] });
|
|
2062
2062
|
}
|
|
2063
|
-
function
|
|
2063
|
+
function Xe({ variables: t, onChange: a }) {
|
|
2064
2064
|
const o = () => {
|
|
2065
2065
|
a({ ...t, newVariable: "" });
|
|
2066
2066
|
};
|
|
@@ -2102,7 +2102,7 @@ function Ye({ variables: t, onChange: a }) {
|
|
|
2102
2102
|
/* @__PURE__ */ e("button", { onClick: o, children: "+ Add Variable" })
|
|
2103
2103
|
] });
|
|
2104
2104
|
}
|
|
2105
|
-
function
|
|
2105
|
+
function Qe({
|
|
2106
2106
|
errorHandling: t,
|
|
2107
2107
|
schedule: a,
|
|
2108
2108
|
onChange: o
|
|
@@ -2177,7 +2177,7 @@ function Xe({
|
|
|
2177
2177
|
] })
|
|
2178
2178
|
] });
|
|
2179
2179
|
}
|
|
2180
|
-
const
|
|
2180
|
+
const Ze = [
|
|
2181
2181
|
{
|
|
2182
2182
|
target: ".nice-webhook-tester",
|
|
2183
2183
|
titleKey: "tutorial.webhookTester.intro.title",
|
|
@@ -2187,16 +2187,16 @@ const Qe = [
|
|
|
2187
2187
|
placement: "auto"
|
|
2188
2188
|
}
|
|
2189
2189
|
];
|
|
2190
|
-
function
|
|
2190
|
+
function ge(t) {
|
|
2191
2191
|
return t ? Object.entries(t).map(([a, o]) => ({ key: a, value: o })) : [];
|
|
2192
2192
|
}
|
|
2193
|
-
function
|
|
2193
|
+
function _e(t) {
|
|
2194
2194
|
const a = {};
|
|
2195
2195
|
for (const o of t)
|
|
2196
2196
|
o.key.trim() !== "" && (a[o.key] = o.value);
|
|
2197
2197
|
return a;
|
|
2198
2198
|
}
|
|
2199
|
-
async function
|
|
2199
|
+
async function et(t, a) {
|
|
2200
2200
|
var d;
|
|
2201
2201
|
const o = (d = globalThis.crypto) == null ? void 0 : d.subtle;
|
|
2202
2202
|
if (!o)
|
|
@@ -2210,7 +2210,7 @@ async function Ze(t, a) {
|
|
|
2210
2210
|
), l = await o.sign("HMAC", c, i.encode(a));
|
|
2211
2211
|
return [...new Uint8Array(l)].map((p) => p.toString(16).padStart(2, "0")).join("");
|
|
2212
2212
|
}
|
|
2213
|
-
const
|
|
2213
|
+
const ct = Ce(
|
|
2214
2214
|
function(a, o) {
|
|
2215
2215
|
const {
|
|
2216
2216
|
url: i = "",
|
|
@@ -2226,7 +2226,7 @@ const ot = we(
|
|
|
2226
2226
|
style: N,
|
|
2227
2227
|
id: m,
|
|
2228
2228
|
"data-testid": T
|
|
2229
|
-
} = a, [y, A] = k(i), [
|
|
2229
|
+
} = a, [y, A] = k(i), [U, F] = k(c), [R, O] = k(() => ge(l)), [q, H] = k(d), [M, w] = k(""), [v, x] = k(!1), [D, L] = k(null), [$, J] = k(null), V = ke(() => {
|
|
2230
2230
|
const r = /* @__PURE__ */ new Map();
|
|
2231
2231
|
for (const C of p)
|
|
2232
2232
|
r.set(C.id, C);
|
|
@@ -2234,23 +2234,23 @@ const ot = we(
|
|
|
2234
2234
|
}, [p]), Y = (r) => {
|
|
2235
2235
|
w(r);
|
|
2236
2236
|
const C = V.get(r);
|
|
2237
|
-
C && (
|
|
2237
|
+
C && (H(C.payload), C.headers && O(ge(C.headers)));
|
|
2238
2238
|
}, W = (r, C) => {
|
|
2239
2239
|
O((S) => S.map((E, P) => P === r ? { ...E, ...C } : E));
|
|
2240
2240
|
}, X = async () => {
|
|
2241
|
-
x(!0),
|
|
2241
|
+
x(!0), L(null), J(null);
|
|
2242
2242
|
try {
|
|
2243
|
-
const r =
|
|
2243
|
+
const r = _e(R);
|
|
2244
2244
|
if (u && u.secret) {
|
|
2245
|
-
const P = await
|
|
2245
|
+
const P = await et(u.secret, q);
|
|
2246
2246
|
r[u.header] = `${u.prefix ?? ""}${P}`;
|
|
2247
2247
|
}
|
|
2248
|
-
const C = typeof performance < "u" ? performance.now() : Date.now(), S = await g({ url: y, method:
|
|
2248
|
+
const C = typeof performance < "u" ? performance.now() : Date.now(), S = await g({ url: y, method: U ?? "POST", headers: r, body: q }), E = Math.round(
|
|
2249
2249
|
(typeof performance < "u" ? performance.now() : Date.now()) - C
|
|
2250
2250
|
);
|
|
2251
2251
|
J({ ...S, durationMs: S.durationMs ?? E });
|
|
2252
2252
|
} catch (r) {
|
|
2253
|
-
|
|
2253
|
+
L(r instanceof Error ? r.message : String(r));
|
|
2254
2254
|
} finally {
|
|
2255
2255
|
x(!1);
|
|
2256
2256
|
}
|
|
@@ -2262,18 +2262,18 @@ const ot = we(
|
|
|
2262
2262
|
r && f({
|
|
2263
2263
|
id: `sample_${Date.now().toString(36)}`,
|
|
2264
2264
|
name: r,
|
|
2265
|
-
payload:
|
|
2266
|
-
headers:
|
|
2265
|
+
payload: q,
|
|
2266
|
+
headers: _e(R)
|
|
2267
2267
|
});
|
|
2268
2268
|
}, h = $ == null ? "" : $.status >= 200 && $.status < 300 ? " nice-webhook-tester__status--ok" : " nice-webhook-tester__status--error", s = "nice-webhook-tester" + (b ? ` ${b}` : "");
|
|
2269
2269
|
return /* @__PURE__ */ n("div", { ref: o, id: m, className: s, style: N, "data-testid": T, children: [
|
|
2270
|
-
_ && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(
|
|
2270
|
+
_ && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(se, { steps: re(_, Ze) }) }),
|
|
2271
2271
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__bar", children: [
|
|
2272
2272
|
/* @__PURE__ */ e(
|
|
2273
2273
|
"select",
|
|
2274
2274
|
{
|
|
2275
2275
|
className: "nice-webhook-tester__method",
|
|
2276
|
-
value:
|
|
2276
|
+
value: U,
|
|
2277
2277
|
onChange: (r) => F(r.target.value),
|
|
2278
2278
|
"aria-label": "Method",
|
|
2279
2279
|
children: ["POST", "PUT", "GET", "PATCH", "DELETE"].map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
|
|
@@ -2318,7 +2318,7 @@ const ot = we(
|
|
|
2318
2318
|
/* @__PURE__ */ e("code", { children: u.header })
|
|
2319
2319
|
] })
|
|
2320
2320
|
] }),
|
|
2321
|
-
|
|
2321
|
+
R.map((r, C) => /* @__PURE__ */ n("div", { className: "nice-webhook-tester__header-row", children: [
|
|
2322
2322
|
/* @__PURE__ */ e(
|
|
2323
2323
|
"input",
|
|
2324
2324
|
{
|
|
@@ -2368,16 +2368,16 @@ const ot = we(
|
|
|
2368
2368
|
"textarea",
|
|
2369
2369
|
{
|
|
2370
2370
|
className: "nice-webhook-tester__textarea",
|
|
2371
|
-
value:
|
|
2371
|
+
value: q,
|
|
2372
2372
|
spellCheck: !1,
|
|
2373
2373
|
rows: 8,
|
|
2374
2374
|
placeholder: '{ "type": "payment.succeeded", "data": { ... } }',
|
|
2375
|
-
onChange: (r) =>
|
|
2375
|
+
onChange: (r) => H(r.target.value),
|
|
2376
2376
|
"aria-label": "Payload"
|
|
2377
2377
|
}
|
|
2378
2378
|
)
|
|
2379
2379
|
] }),
|
|
2380
|
-
|
|
2380
|
+
D && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__error", children: D }),
|
|
2381
2381
|
$ && /* @__PURE__ */ n("div", { className: "nice-webhook-tester__response", children: [
|
|
2382
2382
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
|
|
2383
2383
|
"Response",
|
|
@@ -2395,8 +2395,8 @@ const ot = we(
|
|
|
2395
2395
|
}
|
|
2396
2396
|
);
|
|
2397
2397
|
export {
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2398
|
+
st as NiceAPIDesigner,
|
|
2399
|
+
rt as NiceAPITester,
|
|
2400
|
+
ot as NiceIntegrationBuilder,
|
|
2401
|
+
ct as NiceWebhookTester
|
|
2402
2402
|
};
|