@nice2dev/ui-api 1.2.0 → 1.2.2
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 +142 -0
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +863 -790
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as n, jsx as e, Fragment as
|
|
2
|
-
import { NiceAppShell as
|
|
3
|
-
import { NiceTutorialButton as
|
|
4
|
-
import { useState as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { NiceAppShell as ye, NiceButton as U, NiceTextInput as L, NiceTextArea as oe, NiceSelect as se, NiceCheckbox as fe, NiceIcon as ee } from "@nice2dev/ui";
|
|
3
|
+
import { useNiceTranslation as $, NiceTutorialButton as ce, resolveTutorial as le, NiceIcon as B, createId as re } from "@nice2dev/ui-core";
|
|
4
|
+
import { useState as C, useCallback as I, useRef as de, useEffect as Ne, forwardRef as Ce, useMemo as Se } from "react";
|
|
5
|
+
const Ee = [
|
|
6
6
|
{
|
|
7
7
|
target: ".nice-api-designer",
|
|
8
8
|
titleKey: "tutorial.apiDesigner.intro.title",
|
|
@@ -11,7 +11,7 @@ const Te = [
|
|
|
11
11
|
content: "Define endpoints, parameters, request/response schemas and security for your OpenAPI document.",
|
|
12
12
|
placement: "auto"
|
|
13
13
|
}
|
|
14
|
-
],
|
|
14
|
+
], ge = {
|
|
15
15
|
openapi: "3.0.3",
|
|
16
16
|
info: {
|
|
17
17
|
title: "Pet Store API",
|
|
@@ -113,253 +113,257 @@ const Te = [
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
tags: [{ name: "pets", description: "Pet operations" }]
|
|
116
|
-
},
|
|
116
|
+
}, we = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Pe = [
|
|
117
117
|
"object",
|
|
118
118
|
"array",
|
|
119
119
|
"string",
|
|
120
120
|
"number",
|
|
121
121
|
"integer",
|
|
122
122
|
"boolean"
|
|
123
|
-
],
|
|
124
|
-
function
|
|
123
|
+
], De = ["query", "path", "header", "cookie"], Ae = ["apiKey", "http", "oauth2", "openIdConnect"];
|
|
124
|
+
function ue(t) {
|
|
125
125
|
var o, i;
|
|
126
126
|
const a = [];
|
|
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(([
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
path: `paths.${
|
|
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(([r, c]) => {
|
|
128
|
+
r.startsWith("/") || a.push({ path: `paths.${r}`, message: "Path must start with /", severity: "error" }), we.forEach((l) => {
|
|
129
|
+
const d = c[l.toLowerCase()];
|
|
130
|
+
d && !d.responses && a.push({
|
|
131
|
+
path: `paths.${r}.${l.toLowerCase()}.responses`,
|
|
132
132
|
message: "Responses are required",
|
|
133
133
|
severity: "error"
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
}), a;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
|
|
138
|
+
const _e = /* @__PURE__ */ Pe.map((t) => ({
|
|
139
|
+
value: String(t),
|
|
140
|
+
label: String(t)
|
|
141
|
+
}));
|
|
142
|
+
function ot({
|
|
140
143
|
schema: t,
|
|
141
144
|
onChange: a,
|
|
142
145
|
onSave: o,
|
|
143
146
|
readOnly: i = !1,
|
|
144
|
-
className:
|
|
145
|
-
tutorial:
|
|
147
|
+
className: r = "",
|
|
148
|
+
tutorial: c
|
|
146
149
|
}) {
|
|
147
|
-
var
|
|
148
|
-
const [d, p] =
|
|
149
|
-
() =>
|
|
150
|
-
),
|
|
151
|
-
(
|
|
152
|
-
p((
|
|
153
|
-
const x =
|
|
154
|
-
return a == null || a(x),
|
|
150
|
+
var V, G;
|
|
151
|
+
const { t: l } = $(), [d, p] = C(t || ge), [v, u] = C("/pets"), [N, b] = C("get"), [y, T] = C("paths"), [m, S] = C(
|
|
152
|
+
() => ue(t || ge)
|
|
153
|
+
), w = I(
|
|
154
|
+
(k) => {
|
|
155
|
+
p((f) => {
|
|
156
|
+
const x = k(f);
|
|
157
|
+
return a == null || a(x), S(ue(x)), x;
|
|
155
158
|
});
|
|
156
159
|
},
|
|
157
160
|
[a]
|
|
158
161
|
), A = I(() => {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
...
|
|
162
|
+
const k = "/new-endpoint";
|
|
163
|
+
w((f) => ({
|
|
164
|
+
...f,
|
|
162
165
|
paths: {
|
|
163
|
-
...
|
|
164
|
-
[
|
|
165
|
-
...
|
|
166
|
+
...f.paths,
|
|
167
|
+
[k]: {
|
|
168
|
+
...f.paths[k],
|
|
166
169
|
get: { summary: "New endpoint", responses: { 200: { description: "Success" } } }
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
|
-
})), u(
|
|
170
|
-
}, [
|
|
171
|
-
(
|
|
172
|
-
|
|
173
|
-
const { [
|
|
174
|
-
return { ...
|
|
175
|
-
}), u(null),
|
|
172
|
+
})), u(k), b("get");
|
|
173
|
+
}, [w]), J = I(
|
|
174
|
+
(k) => {
|
|
175
|
+
w((f) => {
|
|
176
|
+
const { [k]: x, ...j } = f.paths;
|
|
177
|
+
return { ...f, paths: j };
|
|
178
|
+
}), u(null), b(null);
|
|
176
179
|
},
|
|
177
|
-
[
|
|
178
|
-
),
|
|
179
|
-
let
|
|
180
|
-
|
|
181
|
-
var
|
|
180
|
+
[w]
|
|
181
|
+
), te = I(() => {
|
|
182
|
+
let k = "NewSchema";
|
|
183
|
+
w((f) => {
|
|
184
|
+
var j, F, R;
|
|
182
185
|
let x = 1;
|
|
183
|
-
for (; (
|
|
184
|
-
|
|
186
|
+
for (; (F = (j = f.components) == null ? void 0 : j.schemas) != null && F[k]; )
|
|
187
|
+
k = `NewSchema${x++}`;
|
|
185
188
|
return {
|
|
186
|
-
...
|
|
189
|
+
...f,
|
|
187
190
|
components: {
|
|
188
|
-
...
|
|
189
|
-
schemas: { ...(
|
|
191
|
+
...f.components,
|
|
192
|
+
schemas: { ...(R = f.components) == null ? void 0 : R.schemas, [k]: { type: "object", properties: {} } }
|
|
190
193
|
}
|
|
191
194
|
};
|
|
192
195
|
});
|
|
193
|
-
}, [
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
}, [d, o]),
|
|
197
|
-
([
|
|
196
|
+
}, [w]), z = I(() => {
|
|
197
|
+
const k = ue(d);
|
|
198
|
+
S(k), k.filter((f) => f.severity === "error").length === 0 && (o == null || o(d));
|
|
199
|
+
}, [d, o]), M = Object.entries(d.paths).flatMap(
|
|
200
|
+
([k, f]) => we.filter((x) => f[x.toLowerCase()]).map(
|
|
198
201
|
(x) => ({
|
|
199
|
-
path:
|
|
202
|
+
path: k,
|
|
200
203
|
method: x,
|
|
201
|
-
operation:
|
|
204
|
+
operation: f[x.toLowerCase()]
|
|
202
205
|
})
|
|
203
206
|
)
|
|
204
|
-
),
|
|
207
|
+
), O = ["info", "paths", "schemas", "security", "preview"];
|
|
205
208
|
return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
|
|
206
|
-
|
|
209
|
+
c && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(c, Ee) }) }),
|
|
207
210
|
/* @__PURE__ */ e(
|
|
208
|
-
|
|
211
|
+
ye,
|
|
209
212
|
{
|
|
210
213
|
flush: !0,
|
|
211
|
-
className: `nice-api-designer ${
|
|
214
|
+
className: `nice-api-designer ${r}`,
|
|
212
215
|
height: "100%",
|
|
213
216
|
style: { minHeight: 600 },
|
|
214
217
|
toolbar: /* @__PURE__ */ n("div", { className: "nice-api-designer__toolbar", children: [
|
|
215
|
-
/* @__PURE__ */ e("div", { className: "nice-api-designer__tabs", children:
|
|
216
|
-
|
|
218
|
+
/* @__PURE__ */ e("div", { className: "nice-api-designer__tabs", children: O.map((k) => /* @__PURE__ */ e(
|
|
219
|
+
U,
|
|
217
220
|
{
|
|
218
221
|
size: "sm",
|
|
219
|
-
variant:
|
|
220
|
-
onClick: () =>
|
|
221
|
-
children:
|
|
222
|
+
variant: y === k ? "primary" : "ghost",
|
|
223
|
+
onClick: () => T(k),
|
|
224
|
+
children: k.charAt(0).toUpperCase() + k.slice(1)
|
|
222
225
|
},
|
|
223
|
-
|
|
226
|
+
k
|
|
224
227
|
)) }),
|
|
225
228
|
!i && /* @__PURE__ */ e(
|
|
226
|
-
|
|
229
|
+
U,
|
|
227
230
|
{
|
|
228
231
|
size: "sm",
|
|
229
232
|
variant: "primary",
|
|
230
|
-
leftIcon: /* @__PURE__ */ e(
|
|
231
|
-
onClick:
|
|
232
|
-
children: "Save"
|
|
233
|
+
leftIcon: /* @__PURE__ */ e(B, { name: "check", size: 14 }),
|
|
234
|
+
onClick: z,
|
|
235
|
+
children: l("apiDesigner.save", "Save")
|
|
233
236
|
}
|
|
234
237
|
)
|
|
235
238
|
] }),
|
|
236
|
-
bottomPanel: m.length > 0 ? /* @__PURE__ */ e("div", { className: "nice-api-designer__errors", children: m.map((
|
|
239
|
+
bottomPanel: m.length > 0 ? /* @__PURE__ */ e("div", { className: "nice-api-designer__errors", children: m.map((k, f) => /* @__PURE__ */ n(
|
|
237
240
|
"div",
|
|
238
241
|
{
|
|
239
|
-
className: `nice-api-designer__error nice-api-designer__error--${
|
|
242
|
+
className: `nice-api-designer__error nice-api-designer__error--${k.severity}`,
|
|
240
243
|
children: [
|
|
241
244
|
/* @__PURE__ */ n("strong", { children: [
|
|
242
|
-
|
|
245
|
+
k.path,
|
|
243
246
|
":"
|
|
244
247
|
] }),
|
|
245
248
|
" ",
|
|
246
|
-
|
|
249
|
+
k.message
|
|
247
250
|
]
|
|
248
251
|
},
|
|
249
|
-
|
|
252
|
+
f
|
|
250
253
|
)) }) : void 0,
|
|
251
254
|
children: /* @__PURE__ */ n("div", { className: "nice-api-designer__content", children: [
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
y === "info" && /* @__PURE__ */ e(xe, { schema: d, onChange: w, readOnly: i }),
|
|
256
|
+
y === "paths" && /* @__PURE__ */ e(
|
|
257
|
+
Ie,
|
|
255
258
|
{
|
|
256
|
-
endpoints:
|
|
259
|
+
endpoints: M,
|
|
257
260
|
schema: d,
|
|
258
|
-
selectedPath:
|
|
259
|
-
selectedMethod:
|
|
260
|
-
onSelectEndpoint: (
|
|
261
|
-
u(
|
|
261
|
+
selectedPath: v,
|
|
262
|
+
selectedMethod: N,
|
|
263
|
+
onSelectEndpoint: (k, f) => {
|
|
264
|
+
u(k), b(f);
|
|
262
265
|
},
|
|
263
266
|
onAdd: A,
|
|
264
|
-
onDelete:
|
|
265
|
-
onChange:
|
|
267
|
+
onDelete: J,
|
|
268
|
+
onChange: w,
|
|
266
269
|
readOnly: i
|
|
267
270
|
}
|
|
268
271
|
),
|
|
269
|
-
|
|
270
|
-
|
|
272
|
+
y === "schemas" && /* @__PURE__ */ e(
|
|
273
|
+
Re,
|
|
271
274
|
{
|
|
272
|
-
schemas: ((
|
|
273
|
-
onAdd:
|
|
274
|
-
onChange: (
|
|
275
|
-
...
|
|
276
|
-
components: { ...
|
|
275
|
+
schemas: ((V = d.components) == null ? void 0 : V.schemas) || {},
|
|
276
|
+
onAdd: te,
|
|
277
|
+
onChange: (k) => w((f) => ({
|
|
278
|
+
...f,
|
|
279
|
+
components: { ...f.components, schemas: k }
|
|
277
280
|
})),
|
|
278
281
|
readOnly: i
|
|
279
282
|
}
|
|
280
283
|
),
|
|
281
|
-
|
|
282
|
-
|
|
284
|
+
y === "security" && /* @__PURE__ */ e(
|
|
285
|
+
qe,
|
|
283
286
|
{
|
|
284
|
-
schemes: ((
|
|
285
|
-
onChange: (
|
|
286
|
-
...
|
|
287
|
-
components: { ...
|
|
287
|
+
schemes: ((G = d.components) == null ? void 0 : G.securitySchemes) || {},
|
|
288
|
+
onChange: (k) => w((f) => ({
|
|
289
|
+
...f,
|
|
290
|
+
components: { ...f.components, securitySchemes: k }
|
|
288
291
|
})),
|
|
289
292
|
readOnly: i
|
|
290
293
|
}
|
|
291
294
|
),
|
|
292
|
-
|
|
295
|
+
y === "preview" && /* @__PURE__ */ e($e, { schema: d })
|
|
293
296
|
] })
|
|
294
297
|
}
|
|
295
298
|
)
|
|
296
299
|
] });
|
|
297
300
|
}
|
|
298
|
-
function
|
|
301
|
+
function xe({ schema: t, onChange: a, readOnly: o }) {
|
|
302
|
+
const { t: i } = $();
|
|
299
303
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__info-editor", children: [
|
|
300
|
-
/* @__PURE__ */ e("h3", { children: "API information" }),
|
|
304
|
+
/* @__PURE__ */ e("h3", { children: i("apiDesigner.apiInformation", "API information") }),
|
|
301
305
|
/* @__PURE__ */ e(
|
|
302
|
-
|
|
306
|
+
L,
|
|
303
307
|
{
|
|
304
|
-
label: "Title",
|
|
308
|
+
label: i("apiDesigner.title", "Title"),
|
|
305
309
|
value: t.info.title,
|
|
306
|
-
onChange: (
|
|
310
|
+
onChange: (r) => a((c) => ({ ...c, info: { ...c.info, title: r } })),
|
|
307
311
|
readOnly: o
|
|
308
312
|
}
|
|
309
313
|
),
|
|
310
314
|
/* @__PURE__ */ e(
|
|
311
|
-
|
|
315
|
+
L,
|
|
312
316
|
{
|
|
313
|
-
label: "Version",
|
|
317
|
+
label: i("apiDesigner.version", "Version"),
|
|
314
318
|
value: t.info.version,
|
|
315
|
-
onChange: (
|
|
319
|
+
onChange: (r) => a((c) => ({ ...c, info: { ...c.info, version: r } })),
|
|
316
320
|
readOnly: o
|
|
317
321
|
}
|
|
318
322
|
),
|
|
319
323
|
/* @__PURE__ */ e(
|
|
320
|
-
|
|
324
|
+
oe,
|
|
321
325
|
{
|
|
322
|
-
label: "Description",
|
|
326
|
+
label: i("apiDesigner.description", "Description"),
|
|
323
327
|
value: t.info.description || "",
|
|
324
|
-
onChange: (
|
|
328
|
+
onChange: (r) => a((c) => ({ ...c, info: { ...c.info, description: r } })),
|
|
325
329
|
readOnly: o,
|
|
326
330
|
rows: 4
|
|
327
331
|
}
|
|
328
332
|
),
|
|
329
|
-
/* @__PURE__ */ e("h4", { children: "Servers" }),
|
|
330
|
-
(t.servers || []).map((
|
|
333
|
+
/* @__PURE__ */ e("h4", { children: i("apiDesigner.servers", "Servers") }),
|
|
334
|
+
(t.servers || []).map((r, c) => /* @__PURE__ */ n("div", { className: "nice-api-designer__server", children: [
|
|
331
335
|
/* @__PURE__ */ e(
|
|
332
|
-
|
|
336
|
+
L,
|
|
333
337
|
{
|
|
334
|
-
value:
|
|
335
|
-
placeholder: "Server URL",
|
|
338
|
+
value: r.url,
|
|
339
|
+
placeholder: i("apiDesigner.serverUrl", "Server URL"),
|
|
336
340
|
onChange: (l) => a((d) => {
|
|
337
341
|
var p;
|
|
338
342
|
return {
|
|
339
343
|
...d,
|
|
340
|
-
servers: (p = d.servers) == null ? void 0 : p.map((
|
|
344
|
+
servers: (p = d.servers) == null ? void 0 : p.map((v, u) => u === c ? { ...v, url: l } : v)
|
|
341
345
|
};
|
|
342
346
|
}),
|
|
343
347
|
readOnly: o
|
|
344
348
|
}
|
|
345
349
|
),
|
|
346
350
|
/* @__PURE__ */ e(
|
|
347
|
-
|
|
351
|
+
L,
|
|
348
352
|
{
|
|
349
|
-
value:
|
|
350
|
-
placeholder: "Description",
|
|
353
|
+
value: r.description || "",
|
|
354
|
+
placeholder: i("apiDesigner.description", "Description"),
|
|
351
355
|
onChange: (l) => a((d) => {
|
|
352
356
|
var p;
|
|
353
357
|
return {
|
|
354
358
|
...d,
|
|
355
|
-
servers: (p = d.servers) == null ? void 0 : p.map((
|
|
359
|
+
servers: (p = d.servers) == null ? void 0 : p.map((v, u) => u === c ? { ...v, description: l } : v)
|
|
356
360
|
};
|
|
357
361
|
}),
|
|
358
362
|
readOnly: o
|
|
359
363
|
}
|
|
360
364
|
),
|
|
361
365
|
!o && /* @__PURE__ */ e(
|
|
362
|
-
|
|
366
|
+
U,
|
|
363
367
|
{
|
|
364
368
|
size: "sm",
|
|
365
369
|
variant: "ghost",
|
|
@@ -367,67 +371,68 @@ function Ae({ schema: t, onChange: a, readOnly: o }) {
|
|
|
367
371
|
var d;
|
|
368
372
|
return {
|
|
369
373
|
...l,
|
|
370
|
-
servers: (d = l.servers) == null ? void 0 : d.filter((p,
|
|
374
|
+
servers: (d = l.servers) == null ? void 0 : d.filter((p, v) => v !== c)
|
|
371
375
|
};
|
|
372
376
|
}),
|
|
373
|
-
"aria-label": "Remove server",
|
|
374
|
-
children: /* @__PURE__ */ e(
|
|
377
|
+
"aria-label": i("apiDesigner.removeServer", "Remove server"),
|
|
378
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 14 })
|
|
375
379
|
}
|
|
376
380
|
)
|
|
377
381
|
] }, c)),
|
|
378
382
|
!o && /* @__PURE__ */ e(
|
|
379
|
-
|
|
383
|
+
U,
|
|
380
384
|
{
|
|
381
385
|
size: "sm",
|
|
382
386
|
variant: "outline",
|
|
383
|
-
leftIcon: /* @__PURE__ */ e(
|
|
384
|
-
onClick: () => a((
|
|
385
|
-
...
|
|
386
|
-
servers: [...
|
|
387
|
+
leftIcon: /* @__PURE__ */ e(B, { name: "plus", size: 14 }),
|
|
388
|
+
onClick: () => a((r) => ({
|
|
389
|
+
...r,
|
|
390
|
+
servers: [...r.servers || [], { url: "https://api.example.com" }]
|
|
387
391
|
})),
|
|
388
|
-
children: "Add server"
|
|
392
|
+
children: i("apiDesigner.addServer", "Add server")
|
|
389
393
|
}
|
|
390
394
|
)
|
|
391
395
|
] });
|
|
392
396
|
}
|
|
393
|
-
function
|
|
397
|
+
function Ie({
|
|
394
398
|
endpoints: t,
|
|
395
399
|
schema: a,
|
|
396
400
|
selectedPath: o,
|
|
397
401
|
selectedMethod: i,
|
|
398
|
-
onSelectEndpoint:
|
|
399
|
-
onAdd:
|
|
400
|
-
onDelete:
|
|
401
|
-
onChange:
|
|
402
|
-
readOnly:
|
|
402
|
+
onSelectEndpoint: r,
|
|
403
|
+
onAdd: c,
|
|
404
|
+
onDelete: l,
|
|
405
|
+
onChange: d,
|
|
406
|
+
readOnly: p
|
|
403
407
|
}) {
|
|
404
|
-
var
|
|
405
|
-
const u = o && i ? (
|
|
406
|
-
!o || !i || !u ||
|
|
408
|
+
var y;
|
|
409
|
+
const { t: v } = $(), u = o && i ? (y = a.paths[o]) == null ? void 0 : y[i] : null, N = (T) => {
|
|
410
|
+
!o || !i || !u || d((m) => ({
|
|
407
411
|
...m,
|
|
408
412
|
paths: {
|
|
409
413
|
...m.paths,
|
|
410
414
|
[o]: {
|
|
411
415
|
...m.paths[o],
|
|
412
|
-
[i]: { ...u, ...
|
|
416
|
+
[i]: { ...u, ...T }
|
|
413
417
|
}
|
|
414
418
|
}
|
|
415
419
|
}));
|
|
416
|
-
},
|
|
420
|
+
}, b = (u == null ? void 0 : u.parameters) ?? [];
|
|
417
421
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__paths-editor", children: [
|
|
418
422
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__endpoints-list", children: [
|
|
419
423
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
|
|
420
|
-
/* @__PURE__ */ e("h3", { children: "Endpoints" }),
|
|
421
|
-
!
|
|
422
|
-
/* @__PURE__ */ e(
|
|
423
|
-
"
|
|
424
|
+
/* @__PURE__ */ e("h3", { children: v("apiDesigner.endpoints", "Endpoints") }),
|
|
425
|
+
!p && /* @__PURE__ */ n(U, { size: "sm", variant: "ghost", onClick: c, children: [
|
|
426
|
+
/* @__PURE__ */ e(B, { name: "plus", size: 14 }),
|
|
427
|
+
" ",
|
|
428
|
+
v("apiDesigner.add", "Add")
|
|
424
429
|
] })
|
|
425
430
|
] }),
|
|
426
|
-
t.map(({ path:
|
|
431
|
+
t.map(({ path: T, method: m }) => /* @__PURE__ */ n(
|
|
427
432
|
"div",
|
|
428
433
|
{
|
|
429
|
-
className: `nice-api-designer__endpoint ${o ===
|
|
430
|
-
onClick: () =>
|
|
434
|
+
className: `nice-api-designer__endpoint ${o === T && i === m.toLowerCase() ? "nice-api-designer__endpoint--selected" : ""}`,
|
|
435
|
+
onClick: () => r(T, m.toLowerCase()),
|
|
431
436
|
children: [
|
|
432
437
|
/* @__PURE__ */ e(
|
|
433
438
|
"span",
|
|
@@ -436,10 +441,10 @@ function xe({
|
|
|
436
441
|
children: m
|
|
437
442
|
}
|
|
438
443
|
),
|
|
439
|
-
/* @__PURE__ */ e("span", { className: "nice-api-designer__path", children:
|
|
444
|
+
/* @__PURE__ */ e("span", { className: "nice-api-designer__path", children: T })
|
|
440
445
|
]
|
|
441
446
|
},
|
|
442
|
-
`${m}-${
|
|
447
|
+
`${m}-${T}`
|
|
443
448
|
))
|
|
444
449
|
] }),
|
|
445
450
|
u && o && i && /* @__PURE__ */ n("div", { className: "nice-api-designer__operation-editor", children: [
|
|
@@ -455,254 +460,263 @@ function xe({
|
|
|
455
460
|
o
|
|
456
461
|
] }),
|
|
457
462
|
/* @__PURE__ */ e(
|
|
458
|
-
|
|
463
|
+
L,
|
|
459
464
|
{
|
|
460
|
-
label: "Summary",
|
|
465
|
+
label: v("apiDesigner.summary", "Summary"),
|
|
461
466
|
value: u.summary || "",
|
|
462
|
-
onChange: (
|
|
463
|
-
readOnly:
|
|
467
|
+
onChange: (T) => N({ summary: T }),
|
|
468
|
+
readOnly: p
|
|
464
469
|
}
|
|
465
470
|
),
|
|
466
471
|
/* @__PURE__ */ e(
|
|
467
|
-
|
|
472
|
+
oe,
|
|
468
473
|
{
|
|
469
|
-
label: "Description",
|
|
474
|
+
label: v("apiDesigner.description", "Description"),
|
|
470
475
|
value: u.description || "",
|
|
471
|
-
onChange: (
|
|
472
|
-
readOnly:
|
|
476
|
+
onChange: (T) => N({ description: T }),
|
|
477
|
+
readOnly: p,
|
|
473
478
|
rows: 3
|
|
474
479
|
}
|
|
475
480
|
),
|
|
476
481
|
/* @__PURE__ */ e(
|
|
477
|
-
|
|
482
|
+
L,
|
|
478
483
|
{
|
|
479
|
-
label: "Operation ID",
|
|
484
|
+
label: v("apiDesigner.operationId", "Operation ID"),
|
|
480
485
|
value: u.operationId || "",
|
|
481
|
-
onChange: (
|
|
482
|
-
readOnly:
|
|
486
|
+
onChange: (T) => N({ operationId: T }),
|
|
487
|
+
readOnly: p
|
|
483
488
|
}
|
|
484
489
|
),
|
|
485
490
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__subhead", children: [
|
|
486
|
-
/* @__PURE__ */ e("h4", { children: "Parameters" }),
|
|
487
|
-
!
|
|
488
|
-
|
|
491
|
+
/* @__PURE__ */ e("h4", { children: v("apiDesigner.parameters", "Parameters") }),
|
|
492
|
+
!p && /* @__PURE__ */ n(
|
|
493
|
+
U,
|
|
489
494
|
{
|
|
490
495
|
size: "sm",
|
|
491
496
|
variant: "ghost",
|
|
492
|
-
onClick: () =>
|
|
497
|
+
onClick: () => N({
|
|
493
498
|
parameters: [
|
|
494
|
-
...
|
|
499
|
+
...b,
|
|
495
500
|
{ name: "param", in: "query", required: !1, schema: { type: "string" } }
|
|
496
501
|
]
|
|
497
502
|
}),
|
|
498
503
|
children: [
|
|
499
|
-
/* @__PURE__ */ e(
|
|
500
|
-
"
|
|
504
|
+
/* @__PURE__ */ e(B, { name: "plus", size: 14 }),
|
|
505
|
+
" ",
|
|
506
|
+
v("apiDesigner.add", "Add")
|
|
501
507
|
]
|
|
502
508
|
}
|
|
503
509
|
)
|
|
504
510
|
] }),
|
|
505
|
-
|
|
506
|
-
|
|
511
|
+
b.length === 0 && /* @__PURE__ */ e("p", { className: "nice-api-designer__muted", children: v("apiDesigner.noParameters", "No parameters.") }),
|
|
512
|
+
b.map((T, m) => /* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
|
|
507
513
|
/* @__PURE__ */ e(
|
|
508
|
-
|
|
514
|
+
L,
|
|
509
515
|
{
|
|
510
516
|
size: "sm",
|
|
511
|
-
value:
|
|
517
|
+
value: T.name,
|
|
512
518
|
placeholder: "name",
|
|
513
|
-
onChange: (
|
|
514
|
-
readOnly:
|
|
519
|
+
onChange: (S) => N({ parameters: b.map((w, A) => A === m ? { ...w, name: S } : w) }),
|
|
520
|
+
readOnly: p
|
|
515
521
|
}
|
|
516
522
|
),
|
|
517
523
|
/* @__PURE__ */ e(
|
|
518
|
-
|
|
524
|
+
se,
|
|
519
525
|
{
|
|
520
526
|
size: "sm",
|
|
521
|
-
value:
|
|
522
|
-
options:
|
|
523
|
-
onChange: (
|
|
524
|
-
parameters:
|
|
525
|
-
(
|
|
527
|
+
value: T.in,
|
|
528
|
+
options: De.map((S) => ({ value: String(S), label: String(S) })),
|
|
529
|
+
onChange: (S) => N({
|
|
530
|
+
parameters: b.map(
|
|
531
|
+
(w, A) => A === m ? { ...w, in: S } : w
|
|
526
532
|
)
|
|
527
533
|
})
|
|
528
534
|
}
|
|
529
535
|
),
|
|
530
536
|
/* @__PURE__ */ e(
|
|
531
|
-
|
|
537
|
+
fe,
|
|
532
538
|
{
|
|
533
|
-
checked: !!
|
|
534
|
-
onChange: (
|
|
535
|
-
parameters:
|
|
539
|
+
checked: !!T.required,
|
|
540
|
+
onChange: (S) => N({
|
|
541
|
+
parameters: b.map((w, A) => A === m ? { ...w, required: S } : w)
|
|
536
542
|
}),
|
|
537
543
|
label: "required"
|
|
538
544
|
}
|
|
539
545
|
),
|
|
540
|
-
!
|
|
541
|
-
|
|
546
|
+
!p && /* @__PURE__ */ e(
|
|
547
|
+
U,
|
|
542
548
|
{
|
|
543
549
|
size: "sm",
|
|
544
550
|
variant: "ghost",
|
|
545
|
-
onClick: () =>
|
|
546
|
-
"aria-label":
|
|
547
|
-
|
|
551
|
+
onClick: () => N({ parameters: b.filter((S, w) => w !== m) }),
|
|
552
|
+
"aria-label": v("apiDesigner.remove", "Remove {name}").replace(
|
|
553
|
+
"{name}",
|
|
554
|
+
String(T.name)
|
|
555
|
+
),
|
|
556
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 14 })
|
|
548
557
|
}
|
|
549
558
|
)
|
|
550
559
|
] }, m)),
|
|
551
|
-
!
|
|
552
|
-
|
|
560
|
+
!p && /* @__PURE__ */ e(
|
|
561
|
+
U,
|
|
553
562
|
{
|
|
554
563
|
className: "nice-api-designer__delete-btn",
|
|
555
564
|
size: "sm",
|
|
556
565
|
variant: "danger",
|
|
557
|
-
leftIcon: /* @__PURE__ */ e(
|
|
558
|
-
onClick: () =>
|
|
559
|
-
children: "Delete endpoint"
|
|
566
|
+
leftIcon: /* @__PURE__ */ e(B, { name: "trash", size: 14 }),
|
|
567
|
+
onClick: () => l(o),
|
|
568
|
+
children: v("apiDesigner.deleteEndpoint", "Delete endpoint")
|
|
560
569
|
}
|
|
561
570
|
)
|
|
562
571
|
] })
|
|
563
572
|
] });
|
|
564
573
|
}
|
|
565
|
-
function
|
|
574
|
+
function Re({
|
|
566
575
|
schemas: t,
|
|
567
576
|
onAdd: a,
|
|
568
577
|
onChange: o,
|
|
569
578
|
readOnly: i
|
|
570
579
|
}) {
|
|
571
|
-
const c = Object.keys(t), [l, d] =
|
|
572
|
-
!l || !p || o({ ...t, [l]: { ...p, ...
|
|
573
|
-
},
|
|
574
|
-
u({ properties: { ...
|
|
580
|
+
const { t: r } = $(), c = Object.keys(t), [l, d] = C(c[0] ?? null), p = l ? t[l] : null, v = (p == null ? void 0 : p.properties) ?? {}, u = (b) => {
|
|
581
|
+
!l || !p || o({ ...t, [l]: { ...p, ...b } });
|
|
582
|
+
}, N = (b, y) => {
|
|
583
|
+
u({ properties: { ...v, [b]: y } });
|
|
575
584
|
};
|
|
576
585
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__schemas-editor", children: [
|
|
577
586
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__schemas-list", children: [
|
|
578
587
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
|
|
579
|
-
/* @__PURE__ */ e("h3", { children: "Schemas" }),
|
|
580
|
-
!i && /* @__PURE__ */ n(
|
|
581
|
-
/* @__PURE__ */ e(
|
|
582
|
-
"
|
|
588
|
+
/* @__PURE__ */ e("h3", { children: r("apiDesigner.schemas", "Schemas") }),
|
|
589
|
+
!i && /* @__PURE__ */ n(U, { size: "sm", variant: "ghost", onClick: a, children: [
|
|
590
|
+
/* @__PURE__ */ e(B, { name: "plus", size: 14 }),
|
|
591
|
+
" ",
|
|
592
|
+
r("apiDesigner.add", "Add")
|
|
583
593
|
] })
|
|
584
594
|
] }),
|
|
585
|
-
c.map((
|
|
595
|
+
c.map((b) => /* @__PURE__ */ e(
|
|
586
596
|
"div",
|
|
587
597
|
{
|
|
588
|
-
className: `nice-api-designer__schema-item ${l ===
|
|
589
|
-
onClick: () => d(
|
|
590
|
-
children:
|
|
598
|
+
className: `nice-api-designer__schema-item ${l === b ? "nice-api-designer__schema-item--selected" : ""}`,
|
|
599
|
+
onClick: () => d(b),
|
|
600
|
+
children: b
|
|
591
601
|
},
|
|
592
|
-
|
|
602
|
+
b
|
|
593
603
|
))
|
|
594
604
|
] }),
|
|
595
605
|
l && p && /* @__PURE__ */ n("div", { className: "nice-api-designer__schema-editor", children: [
|
|
596
606
|
/* @__PURE__ */ e("h3", { children: l }),
|
|
597
607
|
/* @__PURE__ */ e(
|
|
598
|
-
|
|
608
|
+
se,
|
|
599
609
|
{
|
|
600
|
-
label: "Type",
|
|
610
|
+
label: r("apiDesigner.type", "Type"),
|
|
601
611
|
value: p.type || "object",
|
|
602
|
-
options:
|
|
603
|
-
onChange: (
|
|
612
|
+
options: _e,
|
|
613
|
+
onChange: (b) => u({ type: b })
|
|
604
614
|
}
|
|
605
615
|
),
|
|
606
616
|
/* @__PURE__ */ e(
|
|
607
|
-
|
|
617
|
+
oe,
|
|
608
618
|
{
|
|
609
|
-
label: "Description",
|
|
619
|
+
label: r("apiDesigner.description", "Description"),
|
|
610
620
|
value: p.description || "",
|
|
611
|
-
onChange: (
|
|
621
|
+
onChange: (b) => u({ description: b }),
|
|
612
622
|
readOnly: i,
|
|
613
623
|
rows: 2
|
|
614
624
|
}
|
|
615
625
|
),
|
|
616
626
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__subhead", children: [
|
|
617
|
-
/* @__PURE__ */ e("h4", { children: "Properties" }),
|
|
627
|
+
/* @__PURE__ */ e("h4", { children: r("apiDesigner.properties", "Properties") }),
|
|
618
628
|
!i && /* @__PURE__ */ n(
|
|
619
|
-
|
|
629
|
+
U,
|
|
620
630
|
{
|
|
621
631
|
size: "sm",
|
|
622
632
|
variant: "ghost",
|
|
623
633
|
onClick: () => {
|
|
624
|
-
let
|
|
625
|
-
for (;
|
|
626
|
-
|
|
627
|
-
|
|
634
|
+
let b = "field", y = 1;
|
|
635
|
+
for (; v[b]; )
|
|
636
|
+
b = `field${y++}`;
|
|
637
|
+
N(b, { type: "string" });
|
|
628
638
|
},
|
|
629
639
|
children: [
|
|
630
|
-
/* @__PURE__ */ e(
|
|
631
|
-
"
|
|
640
|
+
/* @__PURE__ */ e(B, { name: "plus", size: 14 }),
|
|
641
|
+
" ",
|
|
642
|
+
r("apiDesigner.add", "Add")
|
|
632
643
|
]
|
|
633
644
|
}
|
|
634
645
|
)
|
|
635
646
|
] }),
|
|
636
|
-
Object.keys(
|
|
637
|
-
Object.entries(
|
|
638
|
-
const
|
|
647
|
+
Object.keys(v).length === 0 && /* @__PURE__ */ e("p", { className: "nice-api-designer__muted", children: r("apiDesigner.noProperties", "No properties.") }),
|
|
648
|
+
Object.entries(v).map(([b, y]) => {
|
|
649
|
+
const T = (p.required || []).includes(b);
|
|
639
650
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
|
|
640
651
|
/* @__PURE__ */ e(
|
|
641
|
-
|
|
652
|
+
L,
|
|
642
653
|
{
|
|
643
654
|
size: "sm",
|
|
644
|
-
value:
|
|
655
|
+
value: b,
|
|
645
656
|
onChange: (m) => {
|
|
646
|
-
if (!m || m ===
|
|
657
|
+
if (!m || m === b || v[m])
|
|
647
658
|
return;
|
|
648
|
-
const
|
|
649
|
-
Object.entries(
|
|
650
|
-
|
|
659
|
+
const S = {};
|
|
660
|
+
Object.entries(v).forEach(([w, A]) => {
|
|
661
|
+
S[w === b ? m : w] = A;
|
|
651
662
|
}), u({
|
|
652
|
-
properties:
|
|
653
|
-
required: (p.required || []).map((
|
|
663
|
+
properties: S,
|
|
664
|
+
required: (p.required || []).map((w) => w === b ? m : w)
|
|
654
665
|
});
|
|
655
666
|
},
|
|
656
667
|
readOnly: i
|
|
657
668
|
}
|
|
658
669
|
),
|
|
659
670
|
/* @__PURE__ */ e(
|
|
660
|
-
|
|
671
|
+
se,
|
|
661
672
|
{
|
|
662
673
|
size: "sm",
|
|
663
|
-
value:
|
|
664
|
-
options:
|
|
665
|
-
onChange: (m) =>
|
|
674
|
+
value: y.type || "string",
|
|
675
|
+
options: _e,
|
|
676
|
+
onChange: (m) => N(b, { ...y, type: m })
|
|
666
677
|
}
|
|
667
678
|
),
|
|
668
679
|
/* @__PURE__ */ e(
|
|
669
|
-
|
|
680
|
+
fe,
|
|
670
681
|
{
|
|
671
|
-
checked:
|
|
682
|
+
checked: T,
|
|
672
683
|
onChange: (m) => u({
|
|
673
|
-
required: m ? [...p.required || [],
|
|
684
|
+
required: m ? [...p.required || [], b] : (p.required || []).filter((S) => S !== b)
|
|
674
685
|
}),
|
|
675
686
|
label: "required"
|
|
676
687
|
}
|
|
677
688
|
),
|
|
678
689
|
!i && /* @__PURE__ */ e(
|
|
679
|
-
|
|
690
|
+
U,
|
|
680
691
|
{
|
|
681
692
|
size: "sm",
|
|
682
693
|
variant: "ghost",
|
|
683
694
|
onClick: () => {
|
|
684
|
-
const { [
|
|
695
|
+
const { [b]: m, ...S } = v;
|
|
685
696
|
u({
|
|
686
|
-
properties:
|
|
687
|
-
required: (p.required || []).filter((
|
|
697
|
+
properties: S,
|
|
698
|
+
required: (p.required || []).filter((w) => w !== b)
|
|
688
699
|
});
|
|
689
700
|
},
|
|
690
|
-
"aria-label":
|
|
691
|
-
|
|
701
|
+
"aria-label": r("apiDesigner.remove2", "Remove {propName}").replace(
|
|
702
|
+
"{propName}",
|
|
703
|
+
String(b)
|
|
704
|
+
),
|
|
705
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 14 })
|
|
692
706
|
}
|
|
693
707
|
)
|
|
694
|
-
] },
|
|
708
|
+
] }, b);
|
|
695
709
|
}),
|
|
696
710
|
/* @__PURE__ */ n("details", { className: "nice-api-designer__raw", children: [
|
|
697
|
-
/* @__PURE__ */ e("summary", { children: "Raw JSON schema" }),
|
|
711
|
+
/* @__PURE__ */ e("summary", { children: r("apiDesigner.rawJsonSchema", "Raw JSON schema") }),
|
|
698
712
|
/* @__PURE__ */ e(
|
|
699
|
-
|
|
713
|
+
oe,
|
|
700
714
|
{
|
|
701
715
|
value: JSON.stringify(p, null, 2),
|
|
702
|
-
onChange: (
|
|
716
|
+
onChange: (b) => {
|
|
703
717
|
try {
|
|
704
|
-
const
|
|
705
|
-
o({ ...t, [l]:
|
|
718
|
+
const y = JSON.parse(b);
|
|
719
|
+
o({ ...t, [l]: y });
|
|
706
720
|
} catch {
|
|
707
721
|
}
|
|
708
722
|
},
|
|
@@ -715,13 +729,13 @@ function Ie({
|
|
|
715
729
|
] })
|
|
716
730
|
] });
|
|
717
731
|
}
|
|
718
|
-
function
|
|
719
|
-
const i = (c, l) => a({ ...t, [c]: l });
|
|
732
|
+
function qe({ schemes: t, onChange: a, readOnly: o }) {
|
|
733
|
+
const { t: i } = $(), r = (c, l) => a({ ...t, [c]: l });
|
|
720
734
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__security-editor", children: [
|
|
721
735
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__list-header", children: [
|
|
722
|
-
/* @__PURE__ */ e("h3", { children: "Security schemes" }),
|
|
736
|
+
/* @__PURE__ */ e("h3", { children: i("apiDesigner.securitySchemes", "Security schemes") }),
|
|
723
737
|
!o && /* @__PURE__ */ n(
|
|
724
|
-
|
|
738
|
+
U,
|
|
725
739
|
{
|
|
726
740
|
size: "sm",
|
|
727
741
|
variant: "ghost",
|
|
@@ -729,11 +743,12 @@ function $e({ schemes: t, onChange: a, readOnly: o }) {
|
|
|
729
743
|
let c = "newScheme", l = 1;
|
|
730
744
|
for (; t[c]; )
|
|
731
745
|
c = `newScheme${l++}`;
|
|
732
|
-
|
|
746
|
+
r(c, { type: "apiKey", name: "X-API-Key", in: "header" });
|
|
733
747
|
},
|
|
734
748
|
children: [
|
|
735
|
-
/* @__PURE__ */ e(
|
|
736
|
-
"
|
|
749
|
+
/* @__PURE__ */ e(B, { name: "plus", size: 14 }),
|
|
750
|
+
" ",
|
|
751
|
+
i("apiDesigner.add", "Add")
|
|
737
752
|
]
|
|
738
753
|
}
|
|
739
754
|
)
|
|
@@ -742,7 +757,7 @@ function $e({ schemes: t, onChange: a, readOnly: o }) {
|
|
|
742
757
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__subhead", children: [
|
|
743
758
|
/* @__PURE__ */ e("h4", { children: c }),
|
|
744
759
|
!o && /* @__PURE__ */ e(
|
|
745
|
-
|
|
760
|
+
U,
|
|
746
761
|
{
|
|
747
762
|
size: "sm",
|
|
748
763
|
variant: "ghost",
|
|
@@ -750,85 +765,89 @@ function $e({ schemes: t, onChange: a, readOnly: o }) {
|
|
|
750
765
|
const { [c]: d, ...p } = t;
|
|
751
766
|
a(p);
|
|
752
767
|
},
|
|
753
|
-
"aria-label":
|
|
754
|
-
|
|
768
|
+
"aria-label": i("apiDesigner.remove", "Remove {name}").replace(
|
|
769
|
+
"{name}",
|
|
770
|
+
String(c)
|
|
771
|
+
),
|
|
772
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 14 })
|
|
755
773
|
}
|
|
756
774
|
)
|
|
757
775
|
] }),
|
|
758
776
|
/* @__PURE__ */ n("div", { className: "nice-api-designer__param-row", children: [
|
|
759
777
|
/* @__PURE__ */ e(
|
|
760
|
-
|
|
778
|
+
se,
|
|
761
779
|
{
|
|
762
780
|
size: "sm",
|
|
763
781
|
value: l.type,
|
|
764
|
-
options:
|
|
765
|
-
onChange: (d) =>
|
|
782
|
+
options: Ae.map((d) => ({ value: String(d), label: String(d) })),
|
|
783
|
+
onChange: (d) => r(c, { ...l, type: d })
|
|
766
784
|
}
|
|
767
785
|
),
|
|
768
|
-
l.type === "apiKey" && /* @__PURE__ */ n(
|
|
786
|
+
l.type === "apiKey" && /* @__PURE__ */ n(Q, { children: [
|
|
769
787
|
/* @__PURE__ */ e(
|
|
770
|
-
|
|
788
|
+
L,
|
|
771
789
|
{
|
|
772
790
|
size: "sm",
|
|
773
791
|
value: l.name || "",
|
|
774
|
-
placeholder: "header/param name",
|
|
775
|
-
onChange: (d) =>
|
|
792
|
+
placeholder: i("apiDesigner.headerParamName", "header/param name"),
|
|
793
|
+
onChange: (d) => r(c, { ...l, name: d }),
|
|
776
794
|
readOnly: o
|
|
777
795
|
}
|
|
778
796
|
),
|
|
779
797
|
/* @__PURE__ */ e(
|
|
780
|
-
|
|
798
|
+
se,
|
|
781
799
|
{
|
|
782
800
|
size: "sm",
|
|
783
801
|
value: l.in || "header",
|
|
784
802
|
options: ["header", "query", "cookie"].map((d) => ({ value: d, label: d })),
|
|
785
|
-
onChange: (d) =>
|
|
803
|
+
onChange: (d) => r(c, { ...l, in: d })
|
|
786
804
|
}
|
|
787
805
|
)
|
|
788
806
|
] }),
|
|
789
|
-
l.type === "http" && /* @__PURE__ */ n(
|
|
807
|
+
l.type === "http" && /* @__PURE__ */ n(Q, { children: [
|
|
790
808
|
/* @__PURE__ */ e(
|
|
791
|
-
|
|
809
|
+
L,
|
|
792
810
|
{
|
|
793
811
|
size: "sm",
|
|
794
812
|
value: l.scheme || "",
|
|
795
|
-
placeholder: "scheme (bearer/basic)",
|
|
796
|
-
onChange: (d) =>
|
|
813
|
+
placeholder: i("apiDesigner.schemeBearerBasic", "scheme (bearer/basic)"),
|
|
814
|
+
onChange: (d) => r(c, { ...l, scheme: d }),
|
|
797
815
|
readOnly: o
|
|
798
816
|
}
|
|
799
817
|
),
|
|
800
818
|
/* @__PURE__ */ e(
|
|
801
|
-
|
|
819
|
+
L,
|
|
802
820
|
{
|
|
803
821
|
size: "sm",
|
|
804
822
|
value: l.bearerFormat || "",
|
|
805
|
-
placeholder: "bearerFormat (JWT)",
|
|
806
|
-
onChange: (d) =>
|
|
823
|
+
placeholder: i("apiDesigner.bearerformatJwt", "bearerFormat (JWT)"),
|
|
824
|
+
onChange: (d) => r(c, { ...l, bearerFormat: d }),
|
|
807
825
|
readOnly: o
|
|
808
826
|
}
|
|
809
827
|
)
|
|
810
828
|
] })
|
|
811
829
|
] }),
|
|
812
830
|
/* @__PURE__ */ e(
|
|
813
|
-
|
|
831
|
+
L,
|
|
814
832
|
{
|
|
815
833
|
size: "sm",
|
|
816
834
|
value: l.description || "",
|
|
817
|
-
placeholder: "Description",
|
|
818
|
-
onChange: (d) =>
|
|
835
|
+
placeholder: i("apiDesigner.description", "Description"),
|
|
836
|
+
onChange: (d) => r(c, { ...l, description: d }),
|
|
819
837
|
readOnly: o
|
|
820
838
|
}
|
|
821
839
|
)
|
|
822
840
|
] }, c))
|
|
823
841
|
] });
|
|
824
842
|
}
|
|
825
|
-
function
|
|
843
|
+
function $e({ schema: t }) {
|
|
844
|
+
const { t: a } = $();
|
|
826
845
|
return /* @__PURE__ */ n("div", { className: "nice-api-designer__json-preview", children: [
|
|
827
|
-
/* @__PURE__ */ e("h3", { children: "OpenAPI specification" }),
|
|
846
|
+
/* @__PURE__ */ e("h3", { children: a("apiDesigner.openapiSpecification", "OpenAPI specification") }),
|
|
828
847
|
/* @__PURE__ */ e("pre", { className: "nice-api-designer__code", children: JSON.stringify(t, null, 2) })
|
|
829
848
|
] });
|
|
830
849
|
}
|
|
831
|
-
const
|
|
850
|
+
const Be = [
|
|
832
851
|
{
|
|
833
852
|
target: ".nice-api-tester",
|
|
834
853
|
titleKey: "tutorial.apiTester.intro.title",
|
|
@@ -837,7 +856,7 @@ const qe = [
|
|
|
837
856
|
content: "Build requests with collections and environment variables, send them and assert on the responses.",
|
|
838
857
|
placement: "auto"
|
|
839
858
|
}
|
|
840
|
-
],
|
|
859
|
+
], ze = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"], Oe = {
|
|
841
860
|
id: "",
|
|
842
861
|
name: "New Request",
|
|
843
862
|
method: "GET",
|
|
@@ -845,138 +864,138 @@ const qe = [
|
|
|
845
864
|
headers: {},
|
|
846
865
|
queryParams: {}
|
|
847
866
|
};
|
|
848
|
-
function
|
|
867
|
+
function he(t, a) {
|
|
849
868
|
return t.replace(/\{\{(\w+)\}\}/g, (o, i) => a[i] || `{{${i}}}`);
|
|
850
869
|
}
|
|
851
870
|
function je(t, a) {
|
|
852
|
-
const o = Object.entries(a).filter(([, i]) => i).map(([i,
|
|
871
|
+
const o = Object.entries(a).filter(([, i]) => i).map(([i, r]) => `${encodeURIComponent(i)}=${encodeURIComponent(r)}`).join("&");
|
|
853
872
|
return o ? `${t}?${o}` : t;
|
|
854
873
|
}
|
|
855
|
-
function
|
|
874
|
+
function ct({
|
|
856
875
|
collections: t = [],
|
|
857
876
|
environments: a = [],
|
|
858
877
|
onRequest: o,
|
|
859
878
|
onSaveCollection: i,
|
|
860
|
-
className:
|
|
861
|
-
tutorial:
|
|
879
|
+
className: r = "",
|
|
880
|
+
tutorial: c
|
|
862
881
|
}) {
|
|
863
|
-
const [d, p] =
|
|
882
|
+
const { t: l } = $(), [d, p] = C(t), [v, u] = C(a), [N, b] = C(
|
|
864
883
|
a.find((s) => s.isActive) || null
|
|
865
|
-
), [
|
|
866
|
-
...
|
|
867
|
-
id:
|
|
868
|
-
}), [m,
|
|
884
|
+
), [y, T] = C({
|
|
885
|
+
...Oe,
|
|
886
|
+
id: re()
|
|
887
|
+
}), [m, S] = C(null), [w, A] = C(!1), [J, te] = C("none"), [z, M] = C(
|
|
869
888
|
"params"
|
|
870
|
-
), [
|
|
871
|
-
var
|
|
872
|
-
if (!
|
|
889
|
+
), [O, V] = C("body"), [G, k] = C(""), [f, x] = C(""), [j, F] = C([]), [R, ie] = C([]), K = de(null), Y = I(async () => {
|
|
890
|
+
var H;
|
|
891
|
+
if (!y.url)
|
|
873
892
|
return;
|
|
874
|
-
A(!0),
|
|
893
|
+
A(!0), S(null), F([]);
|
|
875
894
|
const s = Object.fromEntries(
|
|
876
|
-
Object.entries((
|
|
877
|
-
),
|
|
878
|
-
...
|
|
879
|
-
url:
|
|
895
|
+
Object.entries((N == null ? void 0 : N.variables) || {}).map(([E, _]) => [E, _.value])
|
|
896
|
+
), g = {
|
|
897
|
+
...y,
|
|
898
|
+
url: he(y.url, s),
|
|
880
899
|
headers: Object.fromEntries(
|
|
881
|
-
Object.entries(
|
|
900
|
+
Object.entries(y.headers).map(([E, _]) => [E, he(_, s)])
|
|
882
901
|
),
|
|
883
902
|
queryParams: Object.fromEntries(
|
|
884
|
-
Object.entries(
|
|
903
|
+
Object.entries(y.queryParams).map(([E, _]) => [
|
|
885
904
|
E,
|
|
886
|
-
|
|
905
|
+
he(_, s)
|
|
887
906
|
])
|
|
888
907
|
)
|
|
889
|
-
},
|
|
908
|
+
}, P = performance.now();
|
|
890
909
|
try {
|
|
891
910
|
let E;
|
|
892
911
|
if (o)
|
|
893
|
-
E = await o(
|
|
912
|
+
E = await o(g);
|
|
894
913
|
else {
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
method:
|
|
900
|
-
headers:
|
|
901
|
-
signal:
|
|
914
|
+
K.current = new AbortController();
|
|
915
|
+
const _ = { ...g.headers };
|
|
916
|
+
y.auth && Ke(_, y.auth);
|
|
917
|
+
const D = je(g.url, g.queryParams), q = {
|
|
918
|
+
method: g.method,
|
|
919
|
+
headers: _,
|
|
920
|
+
signal: K.current.signal
|
|
902
921
|
};
|
|
903
|
-
["POST", "PUT", "PATCH"].includes(
|
|
904
|
-
const
|
|
905
|
-
let
|
|
922
|
+
["POST", "PUT", "PATCH"].includes(g.method) && ((H = y.body) != null && H.content) && (q.body = typeof y.body.content == "string" ? y.body.content : JSON.stringify(y.body.content), y.body.type === "json" && (_["Content-Type"] = "application/json"));
|
|
923
|
+
const W = await fetch(D, q), X = await W.text();
|
|
924
|
+
let pe;
|
|
906
925
|
try {
|
|
907
|
-
|
|
926
|
+
pe = JSON.parse(X);
|
|
908
927
|
} catch {
|
|
909
|
-
|
|
928
|
+
pe = X;
|
|
910
929
|
}
|
|
911
|
-
const
|
|
930
|
+
const ke = performance.now();
|
|
912
931
|
E = {
|
|
913
|
-
status:
|
|
914
|
-
statusText:
|
|
915
|
-
headers: Object.fromEntries(
|
|
916
|
-
body:
|
|
917
|
-
time: Math.round(
|
|
918
|
-
size: new Blob([
|
|
932
|
+
status: W.status,
|
|
933
|
+
statusText: W.statusText,
|
|
934
|
+
headers: Object.fromEntries(W.headers.entries()),
|
|
935
|
+
body: pe,
|
|
936
|
+
time: Math.round(ke - P),
|
|
937
|
+
size: new Blob([X]).size,
|
|
919
938
|
timestamp: /* @__PURE__ */ new Date()
|
|
920
939
|
};
|
|
921
940
|
}
|
|
922
|
-
if (
|
|
923
|
-
(
|
|
924
|
-
),
|
|
925
|
-
const
|
|
926
|
-
|
|
941
|
+
if (S(E), ie(
|
|
942
|
+
(_) => [..._, { request: y, response: E }].slice(-50)
|
|
943
|
+
), f) {
|
|
944
|
+
const _ = Ue(f, E);
|
|
945
|
+
F(_);
|
|
927
946
|
}
|
|
928
947
|
} catch (E) {
|
|
929
|
-
E.name !== "AbortError" &&
|
|
948
|
+
E.name !== "AbortError" && S({
|
|
930
949
|
status: 0,
|
|
931
950
|
statusText: "Error",
|
|
932
951
|
headers: {},
|
|
933
952
|
body: { error: E.message },
|
|
934
|
-
time: Math.round(performance.now() -
|
|
953
|
+
time: Math.round(performance.now() - P),
|
|
935
954
|
size: 0,
|
|
936
955
|
timestamp: /* @__PURE__ */ new Date()
|
|
937
956
|
});
|
|
938
957
|
} finally {
|
|
939
|
-
A(!1),
|
|
958
|
+
A(!1), K.current = null;
|
|
940
959
|
}
|
|
941
|
-
}, [
|
|
960
|
+
}, [y, N, o, f]), ne = I(() => {
|
|
942
961
|
var s;
|
|
943
|
-
(s =
|
|
944
|
-
}, []),
|
|
945
|
-
|
|
962
|
+
(s = K.current) == null || s.abort(), A(!1);
|
|
963
|
+
}, []), Z = I(() => {
|
|
964
|
+
T((s) => ({
|
|
946
965
|
...s,
|
|
947
966
|
headers: { ...s.headers, "": "" }
|
|
948
967
|
}));
|
|
949
|
-
}, []),
|
|
950
|
-
|
|
968
|
+
}, []), ae = I(() => {
|
|
969
|
+
T((s) => ({
|
|
951
970
|
...s,
|
|
952
971
|
queryParams: { ...s.queryParams, "": "" }
|
|
953
972
|
}));
|
|
954
973
|
}, []), h = I(() => {
|
|
955
974
|
if (d.length === 0) {
|
|
956
975
|
const s = {
|
|
957
|
-
id:
|
|
976
|
+
id: re(),
|
|
958
977
|
name: "My Collection",
|
|
959
|
-
requests: [
|
|
978
|
+
requests: [y]
|
|
960
979
|
};
|
|
961
980
|
p([s]), i == null || i(s);
|
|
962
981
|
} else {
|
|
963
982
|
const s = {
|
|
964
983
|
...d[0],
|
|
965
|
-
requests: [...d[0].requests,
|
|
984
|
+
requests: [...d[0].requests, y]
|
|
966
985
|
};
|
|
967
|
-
p((
|
|
986
|
+
p((g) => [s, ...g.slice(1)]), i == null || i(s);
|
|
968
987
|
}
|
|
969
|
-
}, [d,
|
|
970
|
-
return /* @__PURE__ */ n("div", { className: `nice-api-tester ${
|
|
971
|
-
|
|
988
|
+
}, [d, y, i]);
|
|
989
|
+
return /* @__PURE__ */ n("div", { className: `nice-api-tester ${r}`, style: { position: "relative" }, children: [
|
|
990
|
+
c && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(c, Be) }) }),
|
|
972
991
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__toolbar", children: /* @__PURE__ */ e("div", { className: "nice-api-tester__env-selector", children: /* @__PURE__ */ n(
|
|
973
992
|
"select",
|
|
974
993
|
{
|
|
975
|
-
value: (
|
|
976
|
-
onChange: (s) =>
|
|
994
|
+
value: (N == null ? void 0 : N.id) || "",
|
|
995
|
+
onChange: (s) => b(v.find((g) => g.id === s.target.value) || null),
|
|
977
996
|
children: [
|
|
978
|
-
/* @__PURE__ */ e("option", { value: "", children: "No Environment" }),
|
|
979
|
-
|
|
997
|
+
/* @__PURE__ */ e("option", { value: "", children: l("apiTester.noEnvironment", "No Environment") }),
|
|
998
|
+
v.map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, s.id))
|
|
980
999
|
]
|
|
981
1000
|
}
|
|
982
1001
|
) }) }),
|
|
@@ -984,91 +1003,91 @@ function rt({
|
|
|
984
1003
|
/* @__PURE__ */ e(
|
|
985
1004
|
"select",
|
|
986
1005
|
{
|
|
987
|
-
value:
|
|
988
|
-
onChange: (s) =>
|
|
989
|
-
...
|
|
1006
|
+
value: y.method,
|
|
1007
|
+
onChange: (s) => T((g) => ({
|
|
1008
|
+
...g,
|
|
990
1009
|
method: s.target.value
|
|
991
1010
|
})),
|
|
992
|
-
className: `nice-api-tester__method nice-api-tester__method--${
|
|
993
|
-
children:
|
|
1011
|
+
className: `nice-api-tester__method nice-api-tester__method--${y.method.toLowerCase()}`,
|
|
1012
|
+
children: ze.map((s) => /* @__PURE__ */ e("option", { value: s, children: s }, s))
|
|
994
1013
|
}
|
|
995
1014
|
),
|
|
996
1015
|
/* @__PURE__ */ e(
|
|
997
1016
|
"input",
|
|
998
1017
|
{
|
|
999
1018
|
type: "text",
|
|
1000
|
-
value:
|
|
1001
|
-
onChange: (s) =>
|
|
1002
|
-
placeholder: "Enter request URL",
|
|
1019
|
+
value: y.url,
|
|
1020
|
+
onChange: (s) => T((g) => ({ ...g, url: s.target.value })),
|
|
1021
|
+
placeholder: l("apiTester.enterRequestUrl", "Enter request URL"),
|
|
1003
1022
|
className: "nice-api-tester__url-input"
|
|
1004
1023
|
}
|
|
1005
1024
|
),
|
|
1006
1025
|
/* @__PURE__ */ e(
|
|
1007
1026
|
"button",
|
|
1008
1027
|
{
|
|
1009
|
-
onClick:
|
|
1010
|
-
className: `nice-api-tester__send-btn ${
|
|
1011
|
-
children:
|
|
1028
|
+
onClick: w ? ne : Y,
|
|
1029
|
+
className: `nice-api-tester__send-btn ${w ? "nice-api-tester__send-btn--loading" : ""}`,
|
|
1030
|
+
children: w ? l("apiTester.cancel", "Cancel") : l("apiTester.send", "Send")
|
|
1012
1031
|
}
|
|
1013
1032
|
),
|
|
1014
|
-
/* @__PURE__ */ e("button", { onClick: h, className: "nice-api-tester__save-btn", children: "Save" })
|
|
1033
|
+
/* @__PURE__ */ e("button", { onClick: h, className: "nice-api-tester__save-btn", children: l("apiTester.save", "Save") })
|
|
1015
1034
|
] }),
|
|
1016
1035
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__main", children: [
|
|
1017
1036
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__request-panel", children: [
|
|
1018
1037
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["params", "headers", "body", "auth", "tests"].map((s) => /* @__PURE__ */ e(
|
|
1019
1038
|
"button",
|
|
1020
1039
|
{
|
|
1021
|
-
className: `nice-api-tester__tab ${
|
|
1022
|
-
onClick: () =>
|
|
1040
|
+
className: `nice-api-tester__tab ${z === s ? "nice-api-tester__tab--active" : ""}`,
|
|
1041
|
+
onClick: () => M(s),
|
|
1023
1042
|
children: s.charAt(0).toUpperCase() + s.slice(1)
|
|
1024
1043
|
},
|
|
1025
1044
|
s
|
|
1026
1045
|
)) }),
|
|
1027
1046
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__tab-content", children: [
|
|
1028
|
-
|
|
1029
|
-
|
|
1047
|
+
z === "params" && /* @__PURE__ */ e(
|
|
1048
|
+
Me,
|
|
1030
1049
|
{
|
|
1031
|
-
params:
|
|
1032
|
-
onChange: (s) =>
|
|
1033
|
-
onAdd:
|
|
1050
|
+
params: y.queryParams,
|
|
1051
|
+
onChange: (s) => T((g) => ({ ...g, queryParams: s })),
|
|
1052
|
+
onAdd: ae
|
|
1034
1053
|
}
|
|
1035
1054
|
),
|
|
1036
|
-
|
|
1037
|
-
|
|
1055
|
+
z === "headers" && /* @__PURE__ */ e(
|
|
1056
|
+
Le,
|
|
1038
1057
|
{
|
|
1039
|
-
headers:
|
|
1040
|
-
onChange: (s) =>
|
|
1041
|
-
onAdd:
|
|
1058
|
+
headers: y.headers,
|
|
1059
|
+
onChange: (s) => T((g) => ({ ...g, headers: s })),
|
|
1060
|
+
onAdd: Z
|
|
1042
1061
|
}
|
|
1043
1062
|
),
|
|
1044
|
-
|
|
1045
|
-
|
|
1063
|
+
z === "body" && /* @__PURE__ */ e(
|
|
1064
|
+
Ve,
|
|
1046
1065
|
{
|
|
1047
|
-
body:
|
|
1048
|
-
bodyTab:
|
|
1049
|
-
onBodyTabChange:
|
|
1050
|
-
onChange: (s) =>
|
|
1066
|
+
body: y.body,
|
|
1067
|
+
bodyTab: J,
|
|
1068
|
+
onBodyTabChange: te,
|
|
1069
|
+
onChange: (s) => T((g) => ({ ...g, body: s }))
|
|
1051
1070
|
}
|
|
1052
1071
|
),
|
|
1053
|
-
|
|
1054
|
-
|
|
1072
|
+
z === "auth" && /* @__PURE__ */ e(
|
|
1073
|
+
Fe,
|
|
1055
1074
|
{
|
|
1056
|
-
auth:
|
|
1057
|
-
onChange: (s) =>
|
|
1075
|
+
auth: y.auth,
|
|
1076
|
+
onChange: (s) => T((g) => ({ ...g, auth: s }))
|
|
1058
1077
|
}
|
|
1059
1078
|
),
|
|
1060
|
-
|
|
1061
|
-
|
|
1079
|
+
z === "tests" && /* @__PURE__ */ e(
|
|
1080
|
+
Je,
|
|
1062
1081
|
{
|
|
1063
|
-
preRequestScript:
|
|
1064
|
-
testScript:
|
|
1065
|
-
onPreRequestChange:
|
|
1082
|
+
preRequestScript: G,
|
|
1083
|
+
testScript: f,
|
|
1084
|
+
onPreRequestChange: k,
|
|
1066
1085
|
onTestChange: x
|
|
1067
1086
|
}
|
|
1068
1087
|
)
|
|
1069
1088
|
] })
|
|
1070
1089
|
] }),
|
|
1071
|
-
/* @__PURE__ */ e("div", { className: "nice-api-tester__response-panel", children: m ? /* @__PURE__ */ n(
|
|
1090
|
+
/* @__PURE__ */ e("div", { className: "nice-api-tester__response-panel", children: m ? /* @__PURE__ */ n(Q, { children: [
|
|
1072
1091
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__response-meta", children: [
|
|
1073
1092
|
/* @__PURE__ */ n(
|
|
1074
1093
|
"span",
|
|
@@ -1085,52 +1104,52 @@ function rt({
|
|
|
1085
1104
|
m.time,
|
|
1086
1105
|
"ms"
|
|
1087
1106
|
] }),
|
|
1088
|
-
/* @__PURE__ */ e("span", { className: "nice-api-tester__size", children:
|
|
1107
|
+
/* @__PURE__ */ e("span", { className: "nice-api-tester__size", children: He(m.size) })
|
|
1089
1108
|
] }),
|
|
1090
1109
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__tabs", children: ["body", "headers", "tests"].map((s) => /* @__PURE__ */ n(
|
|
1091
1110
|
"button",
|
|
1092
1111
|
{
|
|
1093
|
-
className: `nice-api-tester__tab ${
|
|
1094
|
-
onClick: () =>
|
|
1112
|
+
className: `nice-api-tester__tab ${O === s ? "nice-api-tester__tab--active" : ""}`,
|
|
1113
|
+
onClick: () => V(s),
|
|
1095
1114
|
children: [
|
|
1096
1115
|
s.charAt(0).toUpperCase() + s.slice(1),
|
|
1097
|
-
s === "tests" &&
|
|
1098
|
-
|
|
1116
|
+
s === "tests" && j.length > 0 && /* @__PURE__ */ n("span", { className: "nice-api-tester__test-badge", children: [
|
|
1117
|
+
j.filter((g) => g.passed).length,
|
|
1099
1118
|
"/",
|
|
1100
|
-
|
|
1119
|
+
j.length
|
|
1101
1120
|
] })
|
|
1102
1121
|
]
|
|
1103
1122
|
},
|
|
1104
1123
|
s
|
|
1105
1124
|
)) }),
|
|
1106
1125
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__response-content", children: [
|
|
1107
|
-
|
|
1108
|
-
|
|
1126
|
+
O === "body" && /* @__PURE__ */ e("pre", { className: "nice-api-tester__response-body", children: typeof m.body == "string" ? m.body : JSON.stringify(m.body, null, 2) }),
|
|
1127
|
+
O === "headers" && /* @__PURE__ */ e("div", { className: "nice-api-tester__response-headers", children: Object.entries(m.headers).map(([s, g]) => /* @__PURE__ */ n("div", { className: "nice-api-tester__header-row", children: [
|
|
1109
1128
|
/* @__PURE__ */ e("span", { className: "nice-api-tester__header-key", children: s }),
|
|
1110
|
-
/* @__PURE__ */ e("span", { className: "nice-api-tester__header-value", children:
|
|
1129
|
+
/* @__PURE__ */ e("span", { className: "nice-api-tester__header-value", children: g })
|
|
1111
1130
|
] }, s)) }),
|
|
1112
|
-
|
|
1131
|
+
O === "tests" && /* @__PURE__ */ e("div", { className: "nice-api-tester__test-results", children: j.map((s, g) => /* @__PURE__ */ n(
|
|
1113
1132
|
"div",
|
|
1114
1133
|
{
|
|
1115
1134
|
className: `nice-api-tester__test-result nice-api-tester__test-result--${s.passed ? "pass" : "fail"}`,
|
|
1116
1135
|
children: [
|
|
1117
|
-
/* @__PURE__ */ e("span", { className: "nice-api-tester__test-icon", children: /* @__PURE__ */ e(
|
|
1136
|
+
/* @__PURE__ */ e("span", { className: "nice-api-tester__test-icon", children: /* @__PURE__ */ e(B, { name: s.passed ? "check" : "close", size: 14 }) }),
|
|
1118
1137
|
/* @__PURE__ */ e("span", { className: "nice-api-tester__test-name", children: s.name }),
|
|
1119
1138
|
s.message && /* @__PURE__ */ e("span", { className: "nice-api-tester__test-message", children: s.message })
|
|
1120
1139
|
]
|
|
1121
1140
|
},
|
|
1122
|
-
|
|
1141
|
+
g
|
|
1123
1142
|
)) })
|
|
1124
1143
|
] })
|
|
1125
|
-
] }) : /* @__PURE__ */ e("div", { className: "nice-api-tester__empty-response", children:
|
|
1144
|
+
] }) : /* @__PURE__ */ e("div", { className: "nice-api-tester__empty-response", children: w ? l("apiTester.loading", "Loading...") : l("apiTester.sendARequestToSee", "Send a request to see the response") }) })
|
|
1126
1145
|
] }),
|
|
1127
|
-
|
|
1128
|
-
/* @__PURE__ */ e("h4", { children: "History" }),
|
|
1129
|
-
/* @__PURE__ */ e("div", { className: "nice-api-tester__history-list", children:
|
|
1146
|
+
R.length > 0 && /* @__PURE__ */ n("div", { className: "nice-api-tester__history", children: [
|
|
1147
|
+
/* @__PURE__ */ e("h4", { children: l("apiTester.history", "History") }),
|
|
1148
|
+
/* @__PURE__ */ e("div", { className: "nice-api-tester__history-list", children: R.slice().reverse().map(({ request: s, response: g }, P) => /* @__PURE__ */ n(
|
|
1130
1149
|
"div",
|
|
1131
1150
|
{
|
|
1132
1151
|
className: "nice-api-tester__history-item",
|
|
1133
|
-
onClick: () =>
|
|
1152
|
+
onClick: () => T(s),
|
|
1134
1153
|
children: [
|
|
1135
1154
|
/* @__PURE__ */ e(
|
|
1136
1155
|
"span",
|
|
@@ -1144,36 +1163,36 @@ function rt({
|
|
|
1144
1163
|
"span",
|
|
1145
1164
|
{
|
|
1146
1165
|
className: `nice-api-tester__status nice-api-tester__status--${Math.floor(
|
|
1147
|
-
|
|
1166
|
+
g.status / 100
|
|
1148
1167
|
)}`,
|
|
1149
|
-
children:
|
|
1168
|
+
children: g.status
|
|
1150
1169
|
}
|
|
1151
1170
|
)
|
|
1152
1171
|
]
|
|
1153
1172
|
},
|
|
1154
|
-
|
|
1173
|
+
P
|
|
1155
1174
|
)) })
|
|
1156
1175
|
] })
|
|
1157
1176
|
] });
|
|
1158
1177
|
}
|
|
1159
|
-
function
|
|
1160
|
-
var o, i, c, l
|
|
1178
|
+
function Ke(t, a) {
|
|
1179
|
+
var o, i, r, c, l;
|
|
1161
1180
|
switch (a.type) {
|
|
1162
1181
|
case "bearer":
|
|
1163
1182
|
t.Authorization = `${((o = a.bearer) == null ? void 0 : o.prefix) || "Bearer"} ${(i = a.bearer) == null ? void 0 : i.token}`;
|
|
1164
1183
|
break;
|
|
1165
1184
|
case "basic":
|
|
1166
|
-
t.Authorization = `Basic ${btoa(`${(
|
|
1185
|
+
t.Authorization = `Basic ${btoa(`${(r = a.basic) == null ? void 0 : r.username}:${(c = a.basic) == null ? void 0 : c.password}`)}`;
|
|
1167
1186
|
break;
|
|
1168
1187
|
case "api-key":
|
|
1169
|
-
((
|
|
1188
|
+
((l = a.apiKey) == null ? void 0 : l.in) === "header" && (t[a.apiKey.key] = a.apiKey.value);
|
|
1170
1189
|
break;
|
|
1171
1190
|
}
|
|
1172
1191
|
}
|
|
1173
|
-
function
|
|
1192
|
+
function He(t) {
|
|
1174
1193
|
return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
|
|
1175
1194
|
}
|
|
1176
|
-
function
|
|
1195
|
+
function Ue(t, a) {
|
|
1177
1196
|
const o = [], i = {
|
|
1178
1197
|
response: {
|
|
1179
1198
|
code: a.status,
|
|
@@ -1183,35 +1202,35 @@ function He(t, a) {
|
|
|
1183
1202
|
text: () => typeof a.body == "string" ? a.body : JSON.stringify(a.body),
|
|
1184
1203
|
responseTime: a.time
|
|
1185
1204
|
},
|
|
1186
|
-
test: (
|
|
1187
|
-
const
|
|
1205
|
+
test: (r, c) => {
|
|
1206
|
+
const l = performance.now();
|
|
1188
1207
|
try {
|
|
1189
|
-
|
|
1190
|
-
} catch (
|
|
1208
|
+
c(), o.push({ name: r, passed: !0, duration: performance.now() - l });
|
|
1209
|
+
} catch (d) {
|
|
1191
1210
|
o.push({
|
|
1192
|
-
name:
|
|
1211
|
+
name: r,
|
|
1193
1212
|
passed: !1,
|
|
1194
|
-
message:
|
|
1195
|
-
duration: performance.now() -
|
|
1213
|
+
message: d.message,
|
|
1214
|
+
duration: performance.now() - l
|
|
1196
1215
|
});
|
|
1197
1216
|
}
|
|
1198
1217
|
},
|
|
1199
|
-
expect: (
|
|
1218
|
+
expect: (r) => ({
|
|
1200
1219
|
to: {
|
|
1201
|
-
equal: (
|
|
1202
|
-
if (
|
|
1203
|
-
throw new Error(`Expected ${
|
|
1220
|
+
equal: (c) => {
|
|
1221
|
+
if (r !== c)
|
|
1222
|
+
throw new Error(`Expected ${c} but got ${r}`);
|
|
1204
1223
|
},
|
|
1205
1224
|
be: {
|
|
1206
|
-
oneOf: (
|
|
1207
|
-
if (!
|
|
1208
|
-
throw new Error(`Expected ${
|
|
1225
|
+
oneOf: (c) => {
|
|
1226
|
+
if (!c.includes(r))
|
|
1227
|
+
throw new Error(`Expected ${r} to be one of ${c}`);
|
|
1209
1228
|
}
|
|
1210
1229
|
},
|
|
1211
1230
|
have: {
|
|
1212
|
-
property: (
|
|
1213
|
-
if (typeof
|
|
1214
|
-
throw new Error(`Expected object to have property ${
|
|
1231
|
+
property: (c) => {
|
|
1232
|
+
if (typeof r != "object" || r === null || !(c in r))
|
|
1233
|
+
throw new Error(`Expected object to have property ${c}`);
|
|
1215
1234
|
}
|
|
1216
1235
|
}
|
|
1217
1236
|
}
|
|
@@ -1219,34 +1238,35 @@ function He(t, a) {
|
|
|
1219
1238
|
};
|
|
1220
1239
|
try {
|
|
1221
1240
|
new Function("pm", t)(i);
|
|
1222
|
-
} catch (
|
|
1241
|
+
} catch (r) {
|
|
1223
1242
|
o.push({
|
|
1224
1243
|
name: "Script Error",
|
|
1225
1244
|
passed: !1,
|
|
1226
|
-
message:
|
|
1245
|
+
message: r.message,
|
|
1227
1246
|
duration: 0
|
|
1228
1247
|
});
|
|
1229
1248
|
}
|
|
1230
1249
|
return o;
|
|
1231
1250
|
}
|
|
1232
|
-
function
|
|
1251
|
+
function Te({
|
|
1233
1252
|
items: t,
|
|
1234
1253
|
onChange: a,
|
|
1235
1254
|
onAdd: o,
|
|
1236
|
-
keyPlaceholder: i
|
|
1237
|
-
valuePlaceholder:
|
|
1255
|
+
keyPlaceholder: i,
|
|
1256
|
+
valuePlaceholder: r
|
|
1238
1257
|
}) {
|
|
1258
|
+
const { t: c } = $(), l = i ?? c("apiTester.key", "Key"), d = r ?? c("apiTester.value", "Value");
|
|
1239
1259
|
return /* @__PURE__ */ n("div", { className: "nice-api-tester__kv-editor", children: [
|
|
1240
|
-
Object.entries(t).map(([
|
|
1260
|
+
Object.entries(t).map(([p, v], u) => /* @__PURE__ */ n("div", { className: "nice-api-tester__kv-row", children: [
|
|
1241
1261
|
/* @__PURE__ */ e(
|
|
1242
1262
|
"input",
|
|
1243
1263
|
{
|
|
1244
1264
|
type: "text",
|
|
1245
|
-
value:
|
|
1246
|
-
placeholder:
|
|
1247
|
-
onChange: (
|
|
1248
|
-
const
|
|
1249
|
-
u
|
|
1265
|
+
value: p,
|
|
1266
|
+
placeholder: l,
|
|
1267
|
+
onChange: (N) => {
|
|
1268
|
+
const b = Object.entries(t);
|
|
1269
|
+
b[u] = [N.target.value, v], a(Object.fromEntries(b));
|
|
1250
1270
|
}
|
|
1251
1271
|
}
|
|
1252
1272
|
),
|
|
@@ -1254,32 +1274,33 @@ function fe({
|
|
|
1254
1274
|
"input",
|
|
1255
1275
|
{
|
|
1256
1276
|
type: "text",
|
|
1257
|
-
value:
|
|
1258
|
-
placeholder:
|
|
1259
|
-
onChange: (
|
|
1277
|
+
value: v,
|
|
1278
|
+
placeholder: d,
|
|
1279
|
+
onChange: (N) => a({ ...t, [p]: N.target.value })
|
|
1260
1280
|
}
|
|
1261
1281
|
),
|
|
1262
1282
|
/* @__PURE__ */ e(
|
|
1263
1283
|
"button",
|
|
1264
1284
|
{
|
|
1285
|
+
"aria-label": c("apiTester.close", "Close"),
|
|
1265
1286
|
onClick: () => {
|
|
1266
|
-
const { [
|
|
1267
|
-
a(
|
|
1287
|
+
const { [p]: N, ...b } = t;
|
|
1288
|
+
a(b);
|
|
1268
1289
|
},
|
|
1269
|
-
children: "
|
|
1290
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 14 })
|
|
1270
1291
|
}
|
|
1271
1292
|
)
|
|
1272
|
-
] },
|
|
1273
|
-
/* @__PURE__ */ e("button", { onClick: o, className: "nice-api-tester__add-btn", children: "+ Add" })
|
|
1293
|
+
] }, u)),
|
|
1294
|
+
/* @__PURE__ */ e("button", { onClick: o, className: "nice-api-tester__add-btn", children: c("apiTester.add", "+ Add") })
|
|
1274
1295
|
] });
|
|
1275
1296
|
}
|
|
1276
|
-
function
|
|
1297
|
+
function Me({
|
|
1277
1298
|
params: t,
|
|
1278
1299
|
onChange: a,
|
|
1279
1300
|
onAdd: o
|
|
1280
1301
|
}) {
|
|
1281
1302
|
return /* @__PURE__ */ e(
|
|
1282
|
-
|
|
1303
|
+
Te,
|
|
1283
1304
|
{
|
|
1284
1305
|
items: t,
|
|
1285
1306
|
onChange: a,
|
|
@@ -1289,13 +1310,13 @@ function Le({
|
|
|
1289
1310
|
}
|
|
1290
1311
|
);
|
|
1291
1312
|
}
|
|
1292
|
-
function
|
|
1313
|
+
function Le({
|
|
1293
1314
|
headers: t,
|
|
1294
1315
|
onChange: a,
|
|
1295
1316
|
onAdd: o
|
|
1296
1317
|
}) {
|
|
1297
1318
|
return /* @__PURE__ */ e(
|
|
1298
|
-
|
|
1319
|
+
Te,
|
|
1299
1320
|
{
|
|
1300
1321
|
items: t,
|
|
1301
1322
|
onChange: a,
|
|
@@ -1305,12 +1326,13 @@ function Ue({
|
|
|
1305
1326
|
}
|
|
1306
1327
|
);
|
|
1307
1328
|
}
|
|
1308
|
-
function
|
|
1329
|
+
function Ve({
|
|
1309
1330
|
body: t,
|
|
1310
1331
|
bodyTab: a,
|
|
1311
1332
|
onBodyTabChange: o,
|
|
1312
1333
|
onChange: i
|
|
1313
1334
|
}) {
|
|
1335
|
+
const { t: r } = $();
|
|
1314
1336
|
return /* @__PURE__ */ n("div", { className: "nice-api-tester__body-editor", children: [
|
|
1315
1337
|
/* @__PURE__ */ e("div", { className: "nice-api-tester__body-tabs", children: ["none", "json", "form-data", "raw"].map((c) => /* @__PURE__ */ n("label", { children: [
|
|
1316
1338
|
/* @__PURE__ */ e(
|
|
@@ -1330,76 +1352,77 @@ function Me({
|
|
|
1330
1352
|
{
|
|
1331
1353
|
value: typeof (t == null ? void 0 : t.content) == "string" ? t.content : JSON.stringify(t == null ? void 0 : t.content, null, 2),
|
|
1332
1354
|
onChange: (c) => i({ type: a, content: c.target.value }),
|
|
1333
|
-
placeholder: a === "json" ? '{ "key": "value" }' : "Enter body content",
|
|
1355
|
+
placeholder: a === "json" ? '{ "key": "value" }' : r("apiTester.enterBodyContent", "Enter body content"),
|
|
1334
1356
|
rows: 10,
|
|
1335
1357
|
className: "nice-api-tester__body-textarea"
|
|
1336
1358
|
}
|
|
1337
1359
|
)
|
|
1338
1360
|
] });
|
|
1339
1361
|
}
|
|
1340
|
-
function
|
|
1362
|
+
function Fe({
|
|
1341
1363
|
auth: t,
|
|
1342
1364
|
onChange: a
|
|
1343
1365
|
}) {
|
|
1344
|
-
var
|
|
1366
|
+
var i, r, c, l, d, p;
|
|
1367
|
+
const { t: o } = $();
|
|
1345
1368
|
return /* @__PURE__ */ n("div", { className: "nice-api-tester__auth-editor", children: [
|
|
1346
1369
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1347
|
-
/* @__PURE__ */ e("label", { children: "Type" }),
|
|
1370
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.type", "Type") }),
|
|
1348
1371
|
/* @__PURE__ */ n(
|
|
1349
1372
|
"select",
|
|
1350
1373
|
{
|
|
1351
1374
|
value: (t == null ? void 0 : t.type) || "none",
|
|
1352
|
-
onChange: (
|
|
1375
|
+
onChange: (v) => a({ type: v.target.value }),
|
|
1353
1376
|
children: [
|
|
1354
|
-
/* @__PURE__ */ e("option", { value: "none", children: "No Auth" }),
|
|
1355
|
-
/* @__PURE__ */ e("option", { value: "api-key", children: "API Key" }),
|
|
1356
|
-
/* @__PURE__ */ e("option", { value: "bearer", children: "Bearer Token" }),
|
|
1357
|
-
/* @__PURE__ */ e("option", { value: "basic", children: "Basic Auth" }),
|
|
1358
|
-
/* @__PURE__ */ e("option", { value: "oauth2", children: "OAuth 2.0" })
|
|
1377
|
+
/* @__PURE__ */ e("option", { value: "none", children: o("apiTester.noAuth", "No Auth") }),
|
|
1378
|
+
/* @__PURE__ */ e("option", { value: "api-key", children: o("apiTester.apiKey", "API Key") }),
|
|
1379
|
+
/* @__PURE__ */ e("option", { value: "bearer", children: o("apiTester.bearerToken", "Bearer Token") }),
|
|
1380
|
+
/* @__PURE__ */ e("option", { value: "basic", children: o("apiTester.basicAuth", "Basic Auth") }),
|
|
1381
|
+
/* @__PURE__ */ e("option", { value: "oauth2", children: o("apiTester.oauth20", "OAuth 2.0") })
|
|
1359
1382
|
]
|
|
1360
1383
|
}
|
|
1361
1384
|
)
|
|
1362
1385
|
] }),
|
|
1363
|
-
(t == null ? void 0 : t.type) === "api-key" && /* @__PURE__ */ n(
|
|
1386
|
+
(t == null ? void 0 : t.type) === "api-key" && /* @__PURE__ */ n(Q, { children: [
|
|
1364
1387
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1365
|
-
/* @__PURE__ */ e("label", { children: "Key" }),
|
|
1388
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.key", "Key") }),
|
|
1366
1389
|
/* @__PURE__ */ e(
|
|
1367
1390
|
"input",
|
|
1368
1391
|
{
|
|
1369
1392
|
type: "text",
|
|
1370
|
-
value: ((
|
|
1371
|
-
onChange: (
|
|
1372
|
-
var u,
|
|
1393
|
+
value: ((i = t.apiKey) == null ? void 0 : i.key) || "",
|
|
1394
|
+
onChange: (v) => {
|
|
1395
|
+
var u, N;
|
|
1373
1396
|
return a({
|
|
1374
1397
|
...t,
|
|
1375
1398
|
apiKey: {
|
|
1376
1399
|
...t.apiKey,
|
|
1377
|
-
key:
|
|
1400
|
+
key: v.target.value,
|
|
1378
1401
|
value: ((u = t.apiKey) == null ? void 0 : u.value) || "",
|
|
1379
|
-
in: ((
|
|
1402
|
+
in: ((N = t.apiKey) == null ? void 0 : N.in) || "header"
|
|
1380
1403
|
}
|
|
1381
1404
|
});
|
|
1382
1405
|
},
|
|
1383
|
-
placeholder: "X-API-Key"
|
|
1406
|
+
placeholder: o("apiTester.xApiKey", "X-API-Key")
|
|
1384
1407
|
}
|
|
1385
1408
|
)
|
|
1386
1409
|
] }),
|
|
1387
1410
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1388
|
-
/* @__PURE__ */ e("label", { children: "Value" }),
|
|
1411
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.value", "Value") }),
|
|
1389
1412
|
/* @__PURE__ */ e(
|
|
1390
1413
|
"input",
|
|
1391
1414
|
{
|
|
1392
1415
|
type: "text",
|
|
1393
|
-
value: ((
|
|
1394
|
-
onChange: (
|
|
1395
|
-
var u,
|
|
1416
|
+
value: ((r = t.apiKey) == null ? void 0 : r.value) || "",
|
|
1417
|
+
onChange: (v) => {
|
|
1418
|
+
var u, N;
|
|
1396
1419
|
return a({
|
|
1397
1420
|
...t,
|
|
1398
1421
|
apiKey: {
|
|
1399
1422
|
...t.apiKey,
|
|
1400
|
-
value:
|
|
1423
|
+
value: v.target.value,
|
|
1401
1424
|
key: ((u = t.apiKey) == null ? void 0 : u.key) || "",
|
|
1402
|
-
in: ((
|
|
1425
|
+
in: ((N = t.apiKey) == null ? void 0 : N.in) || "header"
|
|
1403
1426
|
}
|
|
1404
1427
|
});
|
|
1405
1428
|
},
|
|
@@ -1408,58 +1431,58 @@ function Be({
|
|
|
1408
1431
|
)
|
|
1409
1432
|
] }),
|
|
1410
1433
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1411
|
-
/* @__PURE__ */ e("label", { children: "Add to" }),
|
|
1434
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.addTo", "Add to") }),
|
|
1412
1435
|
/* @__PURE__ */ n(
|
|
1413
1436
|
"select",
|
|
1414
1437
|
{
|
|
1415
1438
|
value: ((c = t.apiKey) == null ? void 0 : c.in) || "header",
|
|
1416
|
-
onChange: (
|
|
1417
|
-
var u,
|
|
1439
|
+
onChange: (v) => {
|
|
1440
|
+
var u, N;
|
|
1418
1441
|
return a({
|
|
1419
1442
|
...t,
|
|
1420
1443
|
apiKey: {
|
|
1421
1444
|
...t.apiKey,
|
|
1422
|
-
in:
|
|
1445
|
+
in: v.target.value,
|
|
1423
1446
|
key: ((u = t.apiKey) == null ? void 0 : u.key) || "",
|
|
1424
|
-
value: ((
|
|
1447
|
+
value: ((N = t.apiKey) == null ? void 0 : N.value) || ""
|
|
1425
1448
|
}
|
|
1426
1449
|
});
|
|
1427
1450
|
},
|
|
1428
1451
|
children: [
|
|
1429
|
-
/* @__PURE__ */ e("option", { value: "header", children: "Header" }),
|
|
1430
|
-
/* @__PURE__ */ e("option", { value: "query", children: "Query Params" })
|
|
1452
|
+
/* @__PURE__ */ e("option", { value: "header", children: o("apiTester.header", "Header") }),
|
|
1453
|
+
/* @__PURE__ */ e("option", { value: "query", children: o("apiTester.queryParams", "Query Params") })
|
|
1431
1454
|
]
|
|
1432
1455
|
}
|
|
1433
1456
|
)
|
|
1434
1457
|
] })
|
|
1435
1458
|
] }),
|
|
1436
1459
|
(t == null ? void 0 : t.type) === "bearer" && /* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1437
|
-
/* @__PURE__ */ e("label", { children: "Token" }),
|
|
1460
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.token", "Token") }),
|
|
1438
1461
|
/* @__PURE__ */ e(
|
|
1439
1462
|
"input",
|
|
1440
1463
|
{
|
|
1441
1464
|
type: "text",
|
|
1442
1465
|
value: ((l = t.bearer) == null ? void 0 : l.token) || "",
|
|
1443
|
-
onChange: (
|
|
1466
|
+
onChange: (v) => a({ ...t, bearer: { token: v.target.value } }),
|
|
1444
1467
|
placeholder: "your-bearer-token"
|
|
1445
1468
|
}
|
|
1446
1469
|
)
|
|
1447
1470
|
] }),
|
|
1448
|
-
(t == null ? void 0 : t.type) === "basic" && /* @__PURE__ */ n(
|
|
1471
|
+
(t == null ? void 0 : t.type) === "basic" && /* @__PURE__ */ n(Q, { children: [
|
|
1449
1472
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1450
|
-
/* @__PURE__ */ e("label", { children: "Username" }),
|
|
1473
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.username", "Username") }),
|
|
1451
1474
|
/* @__PURE__ */ e(
|
|
1452
1475
|
"input",
|
|
1453
1476
|
{
|
|
1454
1477
|
type: "text",
|
|
1455
1478
|
value: ((d = t.basic) == null ? void 0 : d.username) || "",
|
|
1456
|
-
onChange: (
|
|
1479
|
+
onChange: (v) => {
|
|
1457
1480
|
var u;
|
|
1458
1481
|
return a({
|
|
1459
1482
|
...t,
|
|
1460
1483
|
basic: {
|
|
1461
1484
|
...t.basic,
|
|
1462
|
-
username:
|
|
1485
|
+
username: v.target.value,
|
|
1463
1486
|
password: ((u = t.basic) == null ? void 0 : u.password) || ""
|
|
1464
1487
|
}
|
|
1465
1488
|
});
|
|
@@ -1468,19 +1491,19 @@ function Be({
|
|
|
1468
1491
|
)
|
|
1469
1492
|
] }),
|
|
1470
1493
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__field", children: [
|
|
1471
|
-
/* @__PURE__ */ e("label", { children: "Password" }),
|
|
1494
|
+
/* @__PURE__ */ e("label", { children: o("apiTester.password", "Password") }),
|
|
1472
1495
|
/* @__PURE__ */ e(
|
|
1473
1496
|
"input",
|
|
1474
1497
|
{
|
|
1475
1498
|
type: "password",
|
|
1476
1499
|
value: ((p = t.basic) == null ? void 0 : p.password) || "",
|
|
1477
|
-
onChange: (
|
|
1500
|
+
onChange: (v) => {
|
|
1478
1501
|
var u;
|
|
1479
1502
|
return a({
|
|
1480
1503
|
...t,
|
|
1481
1504
|
basic: {
|
|
1482
1505
|
...t.basic,
|
|
1483
|
-
password:
|
|
1506
|
+
password: v.target.value,
|
|
1484
1507
|
username: ((u = t.basic) == null ? void 0 : u.username) || ""
|
|
1485
1508
|
}
|
|
1486
1509
|
});
|
|
@@ -1491,15 +1514,16 @@ function Be({
|
|
|
1491
1514
|
] })
|
|
1492
1515
|
] });
|
|
1493
1516
|
}
|
|
1494
|
-
function
|
|
1517
|
+
function Je({
|
|
1495
1518
|
preRequestScript: t,
|
|
1496
1519
|
testScript: a,
|
|
1497
1520
|
onPreRequestChange: o,
|
|
1498
1521
|
onTestChange: i
|
|
1499
1522
|
}) {
|
|
1523
|
+
const { t: r } = $();
|
|
1500
1524
|
return /* @__PURE__ */ n("div", { className: "nice-api-tester__tests-editor", children: [
|
|
1501
1525
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__script-section", children: [
|
|
1502
|
-
/* @__PURE__ */ e("h4", { children: "Pre-request Script" }),
|
|
1526
|
+
/* @__PURE__ */ e("h4", { children: r("apiTester.preRequestScript", "Pre-request Script") }),
|
|
1503
1527
|
/* @__PURE__ */ e(
|
|
1504
1528
|
"textarea",
|
|
1505
1529
|
{
|
|
@@ -1511,7 +1535,7 @@ function Ve({
|
|
|
1511
1535
|
)
|
|
1512
1536
|
] }),
|
|
1513
1537
|
/* @__PURE__ */ n("div", { className: "nice-api-tester__script-section", children: [
|
|
1514
|
-
/* @__PURE__ */ e("h4", { children: "Tests" }),
|
|
1538
|
+
/* @__PURE__ */ e("h4", { children: r("apiTester.tests", "Tests") }),
|
|
1515
1539
|
/* @__PURE__ */ e(
|
|
1516
1540
|
"textarea",
|
|
1517
1541
|
{
|
|
@@ -1526,7 +1550,7 @@ function Ve({
|
|
|
1526
1550
|
] })
|
|
1527
1551
|
] });
|
|
1528
1552
|
}
|
|
1529
|
-
const
|
|
1553
|
+
const We = [
|
|
1530
1554
|
{
|
|
1531
1555
|
target: ".nice-integration-builder",
|
|
1532
1556
|
titleKey: "tutorial.integrationBuilder.intro.title",
|
|
@@ -1535,7 +1559,7 @@ const Fe = [
|
|
|
1535
1559
|
content: "Wire a flow of nodes (triggers → actions → error handling) and connect them to build an integration.",
|
|
1536
1560
|
placement: "auto"
|
|
1537
1561
|
}
|
|
1538
|
-
],
|
|
1562
|
+
], me = [
|
|
1539
1563
|
{ type: "trigger", label: "Trigger", icon: "zap", category: "Control" },
|
|
1540
1564
|
{ type: "http-request", label: "HTTP Request", icon: "globe", category: "Actions" },
|
|
1541
1565
|
{ type: "transform", label: "Transform", icon: "shuffle", category: "Data" },
|
|
@@ -1549,7 +1573,7 @@ const Fe = [
|
|
|
1549
1573
|
{ type: "webhook", label: "Webhook", icon: "link", category: "Actions" },
|
|
1550
1574
|
{ type: "function", label: "Function", icon: "code", category: "Actions" },
|
|
1551
1575
|
{ type: "error-handler", label: "Error Handler", icon: "warning", category: "Control" }
|
|
1552
|
-
],
|
|
1576
|
+
], Ge = {
|
|
1553
1577
|
id: "",
|
|
1554
1578
|
name: "New Flow",
|
|
1555
1579
|
nodes: [],
|
|
@@ -1558,125 +1582,125 @@ const Fe = [
|
|
|
1558
1582
|
triggers: [],
|
|
1559
1583
|
errorHandling: { strategy: "stop" }
|
|
1560
1584
|
};
|
|
1561
|
-
function
|
|
1585
|
+
function lt({
|
|
1562
1586
|
flow: t,
|
|
1563
1587
|
connectors: a = [],
|
|
1564
1588
|
onChange: o,
|
|
1565
1589
|
onSave: i,
|
|
1566
|
-
onRun:
|
|
1567
|
-
className:
|
|
1568
|
-
tutorial:
|
|
1590
|
+
onRun: r,
|
|
1591
|
+
className: c = "",
|
|
1592
|
+
tutorial: l
|
|
1569
1593
|
}) {
|
|
1570
|
-
const [p,
|
|
1571
|
-
t || { ...
|
|
1572
|
-
), [u,
|
|
1594
|
+
const { t: d } = $(), [p, v] = C(
|
|
1595
|
+
t || { ...Ge, id: re() }
|
|
1596
|
+
), [u, N] = C(null), [b, y] = C(!0), [T, m] = C("canvas"), [S, w] = C(!1), [A, J] = C(null), [te, z] = C(!1), [M, O] = C(null), [V, G] = C(!1), k = de(null), f = I(
|
|
1573
1597
|
(h) => {
|
|
1574
|
-
|
|
1575
|
-
const
|
|
1576
|
-
return o == null || o(
|
|
1598
|
+
v((s) => {
|
|
1599
|
+
const g = h(s);
|
|
1600
|
+
return o == null || o(g), g;
|
|
1577
1601
|
});
|
|
1578
1602
|
},
|
|
1579
1603
|
[o]
|
|
1580
1604
|
), x = I(
|
|
1581
1605
|
(h, s) => {
|
|
1582
|
-
var
|
|
1583
|
-
const
|
|
1584
|
-
id:
|
|
1606
|
+
var P;
|
|
1607
|
+
const g = {
|
|
1608
|
+
id: re(),
|
|
1585
1609
|
type: h,
|
|
1586
|
-
name: ((
|
|
1610
|
+
name: ((P = me.find((H) => H.type === h)) == null ? void 0 : P.label) || h,
|
|
1587
1611
|
position: s,
|
|
1588
|
-
config:
|
|
1612
|
+
config: Ye(h),
|
|
1589
1613
|
inputs: h !== "trigger" ? ["input"] : [],
|
|
1590
1614
|
outputs: ["output"]
|
|
1591
1615
|
};
|
|
1592
|
-
|
|
1593
|
-
...
|
|
1594
|
-
nodes: [...
|
|
1595
|
-
})),
|
|
1616
|
+
f((H) => ({
|
|
1617
|
+
...H,
|
|
1618
|
+
nodes: [...H.nodes, g]
|
|
1619
|
+
})), N(g);
|
|
1596
1620
|
},
|
|
1597
|
-
[
|
|
1598
|
-
),
|
|
1621
|
+
[f]
|
|
1622
|
+
), j = I(
|
|
1599
1623
|
(h) => {
|
|
1600
|
-
|
|
1624
|
+
f((s) => ({
|
|
1601
1625
|
...s,
|
|
1602
|
-
nodes: s.nodes.filter((
|
|
1626
|
+
nodes: s.nodes.filter((g) => g.id !== h),
|
|
1603
1627
|
connections: s.connections.filter(
|
|
1604
|
-
(
|
|
1628
|
+
(g) => g.sourceNodeId !== h && g.targetNodeId !== h
|
|
1605
1629
|
)
|
|
1606
|
-
})),
|
|
1630
|
+
})), N(null);
|
|
1607
1631
|
},
|
|
1608
|
-
[
|
|
1609
|
-
),
|
|
1632
|
+
[f]
|
|
1633
|
+
), F = I(
|
|
1610
1634
|
(h, s) => {
|
|
1611
|
-
|
|
1612
|
-
...
|
|
1613
|
-
nodes:
|
|
1614
|
-
})), (u == null ? void 0 : u.id) === h &&
|
|
1635
|
+
f((g) => ({
|
|
1636
|
+
...g,
|
|
1637
|
+
nodes: g.nodes.map((P) => P.id === h ? { ...P, ...s } : P)
|
|
1638
|
+
})), (u == null ? void 0 : u.id) === h && N((g) => g ? { ...g, ...s } : null);
|
|
1615
1639
|
},
|
|
1616
|
-
[
|
|
1617
|
-
),
|
|
1618
|
-
(h, s,
|
|
1619
|
-
h ===
|
|
1620
|
-
(E) => E.sourceNodeId === h && E.targetNodeId ===
|
|
1621
|
-
) ||
|
|
1640
|
+
[f, u]
|
|
1641
|
+
), R = I(
|
|
1642
|
+
(h, s, g, P) => {
|
|
1643
|
+
h === g || p.connections.some(
|
|
1644
|
+
(E) => E.sourceNodeId === h && E.targetNodeId === g && E.sourceOutput === s && E.targetInput === P
|
|
1645
|
+
) || f((E) => ({
|
|
1622
1646
|
...E,
|
|
1623
1647
|
connections: [
|
|
1624
1648
|
...E.connections,
|
|
1625
1649
|
{
|
|
1626
|
-
id:
|
|
1650
|
+
id: re(),
|
|
1627
1651
|
sourceNodeId: h,
|
|
1628
1652
|
sourceOutput: s,
|
|
1629
|
-
targetNodeId:
|
|
1630
|
-
targetInput:
|
|
1653
|
+
targetNodeId: g,
|
|
1654
|
+
targetInput: P
|
|
1631
1655
|
}
|
|
1632
1656
|
]
|
|
1633
1657
|
}));
|
|
1634
1658
|
},
|
|
1635
|
-
[p.connections,
|
|
1636
|
-
),
|
|
1659
|
+
[p.connections, f]
|
|
1660
|
+
), ie = I(
|
|
1637
1661
|
(h) => {
|
|
1638
|
-
|
|
1662
|
+
f((s) => ({
|
|
1639
1663
|
...s,
|
|
1640
|
-
connections: s.connections.filter((
|
|
1664
|
+
connections: s.connections.filter((g) => g.id !== h)
|
|
1641
1665
|
}));
|
|
1642
1666
|
},
|
|
1643
|
-
[
|
|
1644
|
-
),
|
|
1667
|
+
[f]
|
|
1668
|
+
), K = I(
|
|
1645
1669
|
(h) => {
|
|
1646
|
-
if (h.preventDefault(), !A || !
|
|
1670
|
+
if (h.preventDefault(), !A || !k.current)
|
|
1647
1671
|
return;
|
|
1648
|
-
const s =
|
|
1649
|
-
x(A, { x:
|
|
1672
|
+
const s = k.current.getBoundingClientRect(), g = h.clientX - s.left, P = h.clientY - s.top;
|
|
1673
|
+
x(A, { x: g, y: P }), w(!1), J(null);
|
|
1650
1674
|
},
|
|
1651
1675
|
[A, x]
|
|
1652
1676
|
), Y = I(async () => {
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
1677
|
+
if (r) {
|
|
1678
|
+
G(!0);
|
|
1655
1679
|
try {
|
|
1656
|
-
await
|
|
1680
|
+
await r(p);
|
|
1657
1681
|
} finally {
|
|
1658
|
-
|
|
1682
|
+
G(!1);
|
|
1659
1683
|
}
|
|
1660
1684
|
}
|
|
1661
|
-
}, [p,
|
|
1685
|
+
}, [p, r]), ne = I(() => {
|
|
1662
1686
|
i == null || i(p);
|
|
1663
|
-
}, [p, i]),
|
|
1664
|
-
/* @__PURE__ */ e("h4", { children: "Nodes" }),
|
|
1687
|
+
}, [p, i]), Z = b && T === "canvas" ? /* @__PURE__ */ n("div", { className: "nice-integration-builder__palette", children: [
|
|
1688
|
+
/* @__PURE__ */ e("h4", { children: d("integrationBuilder.nodes", "Nodes") }),
|
|
1665
1689
|
["Control", "Actions", "Data"].map((h) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__category", children: [
|
|
1666
1690
|
/* @__PURE__ */ e("h5", { children: h }),
|
|
1667
|
-
|
|
1691
|
+
me.filter((s) => s.category === h).map((s) => /* @__PURE__ */ n(
|
|
1668
1692
|
"div",
|
|
1669
1693
|
{
|
|
1670
1694
|
className: "nice-integration-builder__palette-item",
|
|
1671
1695
|
draggable: !0,
|
|
1672
1696
|
onDragStart: () => {
|
|
1673
|
-
|
|
1697
|
+
w(!0), J(s.type);
|
|
1674
1698
|
},
|
|
1675
1699
|
onDragEnd: () => {
|
|
1676
|
-
|
|
1700
|
+
w(!1), J(null);
|
|
1677
1701
|
},
|
|
1678
1702
|
children: [
|
|
1679
|
-
/* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(
|
|
1703
|
+
/* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(ee, { name: s.icon, size: 14 }) }),
|
|
1680
1704
|
/* @__PURE__ */ e("span", { children: s.label })
|
|
1681
1705
|
]
|
|
1682
1706
|
},
|
|
@@ -1684,45 +1708,45 @@ function ot({
|
|
|
1684
1708
|
))
|
|
1685
1709
|
] }, h)),
|
|
1686
1710
|
a.length > 0 && /* @__PURE__ */ n("div", { className: "nice-integration-builder__category", children: [
|
|
1687
|
-
/* @__PURE__ */ e("h5", { children: "Connectors" }),
|
|
1711
|
+
/* @__PURE__ */ e("h5", { children: d("integrationBuilder.connectors", "Connectors") }),
|
|
1688
1712
|
a.map((h) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__palette-item", children: [
|
|
1689
|
-
/* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(
|
|
1713
|
+
/* @__PURE__ */ e("span", { className: "nice-integration-builder__palette-icon", children: /* @__PURE__ */ e(ee, { name: "plug", size: 14 }) }),
|
|
1690
1714
|
/* @__PURE__ */ e("span", { children: h.name })
|
|
1691
1715
|
] }, h.id))
|
|
1692
1716
|
] })
|
|
1693
|
-
] }) : void 0,
|
|
1694
|
-
|
|
1717
|
+
] }) : void 0, ae = u && T === "canvas" ? /* @__PURE__ */ e(
|
|
1718
|
+
Qe,
|
|
1695
1719
|
{
|
|
1696
1720
|
node: u,
|
|
1697
|
-
onChange: (h) =>
|
|
1698
|
-
onClose: () =>
|
|
1721
|
+
onChange: (h) => F(u.id, h),
|
|
1722
|
+
onClose: () => N(null)
|
|
1699
1723
|
}
|
|
1700
1724
|
) : void 0;
|
|
1701
1725
|
return /* @__PURE__ */ n("div", { style: { position: "relative", height: "100%" }, children: [
|
|
1702
|
-
|
|
1726
|
+
l && /* @__PURE__ */ e("div", { style: { position: "absolute", top: 8, right: 8, zIndex: 5 }, children: /* @__PURE__ */ e(ce, { steps: le(l, We) }) }),
|
|
1703
1727
|
/* @__PURE__ */ n(
|
|
1704
|
-
|
|
1728
|
+
ye,
|
|
1705
1729
|
{
|
|
1706
1730
|
flush: !0,
|
|
1707
|
-
className: `nice-integration-builder ${
|
|
1731
|
+
className: `nice-integration-builder ${c}`,
|
|
1708
1732
|
height: "100%",
|
|
1709
1733
|
style: { minHeight: 600 },
|
|
1710
|
-
sidebar:
|
|
1711
|
-
rightSidebar:
|
|
1734
|
+
sidebar: Z,
|
|
1735
|
+
rightSidebar: ae,
|
|
1712
1736
|
toolbar: /* @__PURE__ */ n("div", { className: "nice-integration-builder__toolbar", children: [
|
|
1713
1737
|
/* @__PURE__ */ e(
|
|
1714
1738
|
"input",
|
|
1715
1739
|
{
|
|
1716
1740
|
type: "text",
|
|
1717
1741
|
value: p.name,
|
|
1718
|
-
onChange: (h) =>
|
|
1742
|
+
onChange: (h) => f((s) => ({ ...s, name: h.target.value })),
|
|
1719
1743
|
className: "nice-integration-builder__name-input"
|
|
1720
1744
|
}
|
|
1721
1745
|
),
|
|
1722
1746
|
/* @__PURE__ */ e("div", { className: "nice-integration-builder__tabs", children: ["canvas", "code", "variables", "settings"].map((h) => /* @__PURE__ */ e(
|
|
1723
1747
|
"button",
|
|
1724
1748
|
{
|
|
1725
|
-
className: `nice-integration-builder__tab ${
|
|
1749
|
+
className: `nice-integration-builder__tab ${T === h ? "nice-integration-builder__tab--active" : ""}`,
|
|
1726
1750
|
onClick: () => m(h),
|
|
1727
1751
|
children: h.charAt(0).toUpperCase() + h.slice(1)
|
|
1728
1752
|
},
|
|
@@ -1733,79 +1757,83 @@ function ot({
|
|
|
1733
1757
|
"button",
|
|
1734
1758
|
{
|
|
1735
1759
|
onClick: Y,
|
|
1736
|
-
disabled:
|
|
1760
|
+
disabled: V,
|
|
1737
1761
|
className: "nice-integration-builder__run-btn",
|
|
1738
1762
|
children: [
|
|
1739
|
-
/* @__PURE__ */ e(
|
|
1763
|
+
/* @__PURE__ */ e(ee, { name: V ? "clock" : "play", size: 14 }),
|
|
1740
1764
|
" ",
|
|
1741
|
-
|
|
1765
|
+
V ? d("integrationBuilder.running", "Running...") : d("integrationBuilder.run", "Run")
|
|
1742
1766
|
]
|
|
1743
1767
|
}
|
|
1744
1768
|
),
|
|
1745
|
-
/* @__PURE__ */ n("button", { onClick:
|
|
1746
|
-
/* @__PURE__ */ e(
|
|
1747
|
-
"
|
|
1769
|
+
/* @__PURE__ */ n("button", { onClick: ne, className: "nice-integration-builder__save-btn", children: [
|
|
1770
|
+
/* @__PURE__ */ e(ee, { name: "save", size: 14 }),
|
|
1771
|
+
" ",
|
|
1772
|
+
d("integrationBuilder.save", "Save")
|
|
1748
1773
|
] })
|
|
1749
1774
|
] })
|
|
1750
1775
|
] }),
|
|
1751
1776
|
children: [
|
|
1752
|
-
|
|
1777
|
+
T === "canvas" && /* @__PURE__ */ n(
|
|
1753
1778
|
"div",
|
|
1754
1779
|
{
|
|
1755
|
-
ref:
|
|
1756
|
-
className: `nice-integration-builder__canvas ${
|
|
1780
|
+
ref: k,
|
|
1781
|
+
className: `nice-integration-builder__canvas ${S ? "nice-integration-builder__canvas--dragging" : ""}`,
|
|
1757
1782
|
onDragOver: (h) => h.preventDefault(),
|
|
1758
|
-
onDrop:
|
|
1759
|
-
onClick: () =>
|
|
1783
|
+
onDrop: K,
|
|
1784
|
+
onClick: () => N(null),
|
|
1760
1785
|
children: [
|
|
1761
1786
|
/* @__PURE__ */ e("svg", { className: "nice-integration-builder__connections", children: p.connections.map((h) => {
|
|
1762
|
-
const s = p.nodes.find((
|
|
1763
|
-
if (!s || !
|
|
1787
|
+
const s = p.nodes.find((q) => q.id === h.sourceNodeId), g = p.nodes.find((q) => q.id === h.targetNodeId);
|
|
1788
|
+
if (!s || !g)
|
|
1764
1789
|
return null;
|
|
1765
|
-
const
|
|
1766
|
-
return /* @__PURE__ */ e("g", { onClick: () =>
|
|
1790
|
+
const P = s.position.x + 150, H = s.position.y + 30, E = g.position.x, _ = g.position.y + 30, D = (P + E) / 2;
|
|
1791
|
+
return /* @__PURE__ */ e("g", { onClick: () => ie(h.id), children: /* @__PURE__ */ e(
|
|
1767
1792
|
"path",
|
|
1768
1793
|
{
|
|
1769
|
-
d: `M ${
|
|
1794
|
+
d: `M ${P} ${H} C ${D} ${H}, ${D} ${_}, ${E} ${_}`,
|
|
1770
1795
|
className: "nice-integration-builder__connection"
|
|
1771
1796
|
}
|
|
1772
1797
|
) }, h.id);
|
|
1773
1798
|
}) }),
|
|
1774
1799
|
p.nodes.map((h) => /* @__PURE__ */ e(
|
|
1775
|
-
|
|
1800
|
+
Xe,
|
|
1776
1801
|
{
|
|
1777
1802
|
node: h,
|
|
1778
1803
|
isSelected: (u == null ? void 0 : u.id) === h.id,
|
|
1779
|
-
onSelect: () =>
|
|
1780
|
-
onDelete: () =>
|
|
1781
|
-
onPositionChange: (s) =>
|
|
1804
|
+
onSelect: () => N(h),
|
|
1805
|
+
onDelete: () => j(h.id),
|
|
1806
|
+
onPositionChange: (s) => F(h.id, { position: s }),
|
|
1782
1807
|
onStartConnection: (s) => {
|
|
1783
|
-
|
|
1808
|
+
z(!0), O({ nodeId: h.id, output: s });
|
|
1784
1809
|
},
|
|
1785
1810
|
onEndConnection: (s) => {
|
|
1786
|
-
|
|
1811
|
+
M && R(M.nodeId, M.output, h.id, s), z(!1), O(null);
|
|
1787
1812
|
}
|
|
1788
1813
|
},
|
|
1789
1814
|
h.id
|
|
1790
1815
|
)),
|
|
1791
|
-
p.nodes.length === 0 && /* @__PURE__ */ e("div", { className: "nice-integration-builder__empty", children:
|
|
1816
|
+
p.nodes.length === 0 && /* @__PURE__ */ e("div", { className: "nice-integration-builder__empty", children: d(
|
|
1817
|
+
"integrationBuilder.dragNodesFromThePalette",
|
|
1818
|
+
"Drag nodes from the palette to build your flow"
|
|
1819
|
+
) })
|
|
1792
1820
|
]
|
|
1793
1821
|
}
|
|
1794
1822
|
),
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1823
|
+
T === "code" && /* @__PURE__ */ e("div", { className: "nice-integration-builder__code-view", children: /* @__PURE__ */ e("pre", { children: JSON.stringify(p, null, 2) }) }),
|
|
1824
|
+
T === "variables" && /* @__PURE__ */ e(
|
|
1825
|
+
Ze,
|
|
1798
1826
|
{
|
|
1799
1827
|
variables: p.variables,
|
|
1800
|
-
onChange: (h) =>
|
|
1828
|
+
onChange: (h) => f((s) => ({ ...s, variables: h }))
|
|
1801
1829
|
}
|
|
1802
1830
|
),
|
|
1803
|
-
|
|
1804
|
-
|
|
1831
|
+
T === "settings" && /* @__PURE__ */ e(
|
|
1832
|
+
et,
|
|
1805
1833
|
{
|
|
1806
1834
|
errorHandling: p.errorHandling,
|
|
1807
1835
|
schedule: p.schedule,
|
|
1808
|
-
onChange: (h, s) =>
|
|
1836
|
+
onChange: (h, s) => f((g) => ({ ...g, errorHandling: h, schedule: s }))
|
|
1809
1837
|
}
|
|
1810
1838
|
)
|
|
1811
1839
|
]
|
|
@@ -1813,7 +1841,7 @@ function ot({
|
|
|
1813
1841
|
)
|
|
1814
1842
|
] });
|
|
1815
1843
|
}
|
|
1816
|
-
function
|
|
1844
|
+
function Ye(t) {
|
|
1817
1845
|
switch (t) {
|
|
1818
1846
|
case "http-request":
|
|
1819
1847
|
return { method: "GET", url: "", headers: {}, body: "" };
|
|
@@ -1844,57 +1872,58 @@ return input;` };
|
|
|
1844
1872
|
return {};
|
|
1845
1873
|
}
|
|
1846
1874
|
}
|
|
1847
|
-
function
|
|
1875
|
+
function Xe({
|
|
1848
1876
|
node: t,
|
|
1849
1877
|
isSelected: a,
|
|
1850
1878
|
onSelect: o,
|
|
1851
1879
|
onDelete: i,
|
|
1852
|
-
onPositionChange:
|
|
1853
|
-
onStartConnection:
|
|
1854
|
-
onEndConnection:
|
|
1880
|
+
onPositionChange: r,
|
|
1881
|
+
onStartConnection: c,
|
|
1882
|
+
onEndConnection: l
|
|
1855
1883
|
}) {
|
|
1856
|
-
const [p,
|
|
1857
|
-
m.button === 0 && (m.stopPropagation(),
|
|
1884
|
+
const { t: d } = $(), [p, v] = C(!1), [u, N] = C({ x: 0, y: 0 }), b = de(null), y = me.find((m) => m.type === t.type), T = (m) => {
|
|
1885
|
+
m.button === 0 && (m.stopPropagation(), v(!0), N({
|
|
1858
1886
|
x: m.clientX - t.position.x,
|
|
1859
1887
|
y: m.clientY - t.position.y
|
|
1860
1888
|
}), o());
|
|
1861
1889
|
};
|
|
1862
|
-
return
|
|
1890
|
+
return Ne(() => {
|
|
1863
1891
|
if (!p)
|
|
1864
1892
|
return;
|
|
1865
|
-
const m = (
|
|
1866
|
-
|
|
1867
|
-
x:
|
|
1868
|
-
y:
|
|
1893
|
+
const m = (w) => {
|
|
1894
|
+
r({
|
|
1895
|
+
x: w.clientX - u.x,
|
|
1896
|
+
y: w.clientY - u.y
|
|
1869
1897
|
});
|
|
1870
|
-
},
|
|
1871
|
-
|
|
1898
|
+
}, S = () => {
|
|
1899
|
+
v(!1);
|
|
1872
1900
|
};
|
|
1873
|
-
return window.addEventListener("mousemove", m), window.addEventListener("mouseup",
|
|
1874
|
-
window.removeEventListener("mousemove", m), window.removeEventListener("mouseup",
|
|
1901
|
+
return window.addEventListener("mousemove", m), window.addEventListener("mouseup", S), () => {
|
|
1902
|
+
window.removeEventListener("mousemove", m), window.removeEventListener("mouseup", S);
|
|
1875
1903
|
};
|
|
1876
|
-
}, [p, u,
|
|
1904
|
+
}, [p, u, r]), /* @__PURE__ */ n(
|
|
1877
1905
|
"div",
|
|
1878
1906
|
{
|
|
1879
|
-
ref:
|
|
1907
|
+
ref: b,
|
|
1880
1908
|
className: `nice-integration-builder__node nice-integration-builder__node--${t.type} ${a ? "nice-integration-builder__node--selected" : ""}`,
|
|
1881
1909
|
style: {
|
|
1882
1910
|
left: t.position.x,
|
|
1883
1911
|
top: t.position.y
|
|
1884
1912
|
},
|
|
1885
|
-
onMouseDown:
|
|
1913
|
+
onMouseDown: T,
|
|
1886
1914
|
children: [
|
|
1887
1915
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__node-header", children: [
|
|
1888
|
-
/* @__PURE__ */ e("span", { className: "nice-integration-builder__node-icon", children: /* @__PURE__ */ e(
|
|
1916
|
+
/* @__PURE__ */ e("span", { className: "nice-integration-builder__node-icon", children: /* @__PURE__ */ e(ee, { name: (y == null ? void 0 : y.icon) || "box", size: 14 }) }),
|
|
1889
1917
|
/* @__PURE__ */ e("span", { className: "nice-integration-builder__node-name", children: t.name }),
|
|
1890
1918
|
/* @__PURE__ */ e(
|
|
1891
1919
|
"button",
|
|
1892
1920
|
{
|
|
1921
|
+
"aria-label": d("integrationBuilder.close", "Close"),
|
|
1893
1922
|
className: "nice-integration-builder__node-delete",
|
|
1894
1923
|
onClick: (m) => {
|
|
1895
1924
|
m.stopPropagation(), i();
|
|
1896
1925
|
},
|
|
1897
|
-
children: "
|
|
1926
|
+
children: /* @__PURE__ */ e(ee, { name: "close", size: 14 })
|
|
1898
1927
|
}
|
|
1899
1928
|
)
|
|
1900
1929
|
] }),
|
|
@@ -1902,7 +1931,7 @@ function Ge({
|
|
|
1902
1931
|
"div",
|
|
1903
1932
|
{
|
|
1904
1933
|
className: "nice-integration-builder__port nice-integration-builder__port--input",
|
|
1905
|
-
onMouseUp: () =>
|
|
1934
|
+
onMouseUp: () => l(m),
|
|
1906
1935
|
children: [
|
|
1907
1936
|
/* @__PURE__ */ e("span", { className: "nice-integration-builder__port-dot" }),
|
|
1908
1937
|
/* @__PURE__ */ e("span", { className: "nice-integration-builder__port-label", children: m })
|
|
@@ -1914,8 +1943,8 @@ function Ge({
|
|
|
1914
1943
|
"div",
|
|
1915
1944
|
{
|
|
1916
1945
|
className: "nice-integration-builder__port nice-integration-builder__port--output",
|
|
1917
|
-
onMouseDown: (
|
|
1918
|
-
|
|
1946
|
+
onMouseDown: (S) => {
|
|
1947
|
+
S.stopPropagation(), c(m);
|
|
1919
1948
|
},
|
|
1920
1949
|
children: [
|
|
1921
1950
|
/* @__PURE__ */ e("span", { className: "nice-integration-builder__port-label", children: m }),
|
|
@@ -1928,37 +1957,38 @@ function Ge({
|
|
|
1928
1957
|
}
|
|
1929
1958
|
);
|
|
1930
1959
|
}
|
|
1931
|
-
function
|
|
1960
|
+
function Qe({
|
|
1932
1961
|
node: t,
|
|
1933
1962
|
onChange: a,
|
|
1934
1963
|
onClose: o
|
|
1935
1964
|
}) {
|
|
1965
|
+
const { t: i } = $();
|
|
1936
1966
|
return /* @__PURE__ */ n("div", { className: "nice-integration-builder__properties", children: [
|
|
1937
1967
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__properties-header", children: [
|
|
1938
1968
|
/* @__PURE__ */ e("h4", { children: t.name }),
|
|
1939
|
-
/* @__PURE__ */ e("button", { onClick: o, children: "
|
|
1969
|
+
/* @__PURE__ */ e("button", { "aria-label": i("integrationBuilder.close", "Close"), onClick: o, children: /* @__PURE__ */ e(ee, { name: "close", size: 14 }) })
|
|
1940
1970
|
] }),
|
|
1941
1971
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__properties-content", children: [
|
|
1942
1972
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
1943
|
-
/* @__PURE__ */ e("label", { children: "Name" }),
|
|
1973
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.name", "Name") }),
|
|
1944
1974
|
/* @__PURE__ */ e(
|
|
1945
1975
|
"input",
|
|
1946
1976
|
{
|
|
1947
1977
|
type: "text",
|
|
1948
1978
|
value: t.name,
|
|
1949
|
-
onChange: (
|
|
1979
|
+
onChange: (r) => a({ name: r.target.value })
|
|
1950
1980
|
}
|
|
1951
1981
|
)
|
|
1952
1982
|
] }),
|
|
1953
|
-
t.type === "http-request" && /* @__PURE__ */ n(
|
|
1983
|
+
t.type === "http-request" && /* @__PURE__ */ n(Q, { children: [
|
|
1954
1984
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
1955
|
-
/* @__PURE__ */ e("label", { children: "Method" }),
|
|
1985
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.method", "Method") }),
|
|
1956
1986
|
/* @__PURE__ */ e(
|
|
1957
1987
|
"select",
|
|
1958
1988
|
{
|
|
1959
1989
|
value: t.config.method || "GET",
|
|
1960
|
-
onChange: (
|
|
1961
|
-
children: ["GET", "POST", "PUT", "PATCH", "DELETE"].map((
|
|
1990
|
+
onChange: (r) => a({ config: { ...t.config, method: r.target.value } }),
|
|
1991
|
+
children: ["GET", "POST", "PUT", "PATCH", "DELETE"].map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
|
|
1962
1992
|
}
|
|
1963
1993
|
)
|
|
1964
1994
|
] }),
|
|
@@ -1969,89 +1999,89 @@ function Ye({
|
|
|
1969
1999
|
{
|
|
1970
2000
|
type: "text",
|
|
1971
2001
|
value: t.config.url || "",
|
|
1972
|
-
onChange: (
|
|
2002
|
+
onChange: (r) => a({ config: { ...t.config, url: r.target.value } }),
|
|
1973
2003
|
placeholder: "https://api.example.com/endpoint"
|
|
1974
2004
|
}
|
|
1975
2005
|
)
|
|
1976
2006
|
] })
|
|
1977
2007
|
] }),
|
|
1978
2008
|
t.type === "delay" && /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
1979
|
-
/* @__PURE__ */ e("label", { children: "Duration (ms)" }),
|
|
2009
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.durationMs", "Duration (ms)") }),
|
|
1980
2010
|
/* @__PURE__ */ e(
|
|
1981
2011
|
"input",
|
|
1982
2012
|
{
|
|
1983
2013
|
type: "number",
|
|
1984
2014
|
value: t.config.duration || 1e3,
|
|
1985
|
-
onChange: (
|
|
2015
|
+
onChange: (r) => a({ config: { ...t.config, duration: parseInt(r.target.value, 10) } })
|
|
1986
2016
|
}
|
|
1987
2017
|
)
|
|
1988
2018
|
] }),
|
|
1989
|
-
t.type === "set-variable" && /* @__PURE__ */ n(
|
|
2019
|
+
t.type === "set-variable" && /* @__PURE__ */ n(Q, { children: [
|
|
1990
2020
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
1991
|
-
/* @__PURE__ */ e("label", { children: "Variable Name" }),
|
|
2021
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.variableName", "Variable Name") }),
|
|
1992
2022
|
/* @__PURE__ */ e(
|
|
1993
2023
|
"input",
|
|
1994
2024
|
{
|
|
1995
2025
|
type: "text",
|
|
1996
2026
|
value: t.config.name || "",
|
|
1997
|
-
onChange: (
|
|
2027
|
+
onChange: (r) => a({ config: { ...t.config, name: r.target.value } })
|
|
1998
2028
|
}
|
|
1999
2029
|
)
|
|
2000
2030
|
] }),
|
|
2001
2031
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2002
|
-
/* @__PURE__ */ e("label", { children: "Value" }),
|
|
2032
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.value", "Value") }),
|
|
2003
2033
|
/* @__PURE__ */ e(
|
|
2004
2034
|
"input",
|
|
2005
2035
|
{
|
|
2006
2036
|
type: "text",
|
|
2007
2037
|
value: t.config.value || "",
|
|
2008
|
-
onChange: (
|
|
2038
|
+
onChange: (r) => a({ config: { ...t.config, value: r.target.value } })
|
|
2009
2039
|
}
|
|
2010
2040
|
)
|
|
2011
2041
|
] })
|
|
2012
2042
|
] }),
|
|
2013
2043
|
t.type === "function" && /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2014
|
-
/* @__PURE__ */ e("label", { children: "Code" }),
|
|
2044
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.code", "Code") }),
|
|
2015
2045
|
/* @__PURE__ */ e(
|
|
2016
2046
|
"textarea",
|
|
2017
2047
|
{
|
|
2018
2048
|
value: t.config.code || "",
|
|
2019
|
-
onChange: (
|
|
2049
|
+
onChange: (r) => a({ config: { ...t.config, code: r.target.value } }),
|
|
2020
2050
|
rows: 10,
|
|
2021
2051
|
className: "nice-integration-builder__code-input"
|
|
2022
2052
|
}
|
|
2023
2053
|
)
|
|
2024
2054
|
] }),
|
|
2025
|
-
t.type === "email" && /* @__PURE__ */ n(
|
|
2055
|
+
t.type === "email" && /* @__PURE__ */ n(Q, { children: [
|
|
2026
2056
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2027
|
-
/* @__PURE__ */ e("label", { children: "To" }),
|
|
2057
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.to", "To") }),
|
|
2028
2058
|
/* @__PURE__ */ e(
|
|
2029
2059
|
"input",
|
|
2030
2060
|
{
|
|
2031
2061
|
type: "text",
|
|
2032
2062
|
value: t.config.to || "",
|
|
2033
|
-
onChange: (
|
|
2063
|
+
onChange: (r) => a({ config: { ...t.config, to: r.target.value } })
|
|
2034
2064
|
}
|
|
2035
2065
|
)
|
|
2036
2066
|
] }),
|
|
2037
2067
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2038
|
-
/* @__PURE__ */ e("label", { children: "Subject" }),
|
|
2068
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.subject", "Subject") }),
|
|
2039
2069
|
/* @__PURE__ */ e(
|
|
2040
2070
|
"input",
|
|
2041
2071
|
{
|
|
2042
2072
|
type: "text",
|
|
2043
2073
|
value: t.config.subject || "",
|
|
2044
|
-
onChange: (
|
|
2074
|
+
onChange: (r) => a({ config: { ...t.config, subject: r.target.value } })
|
|
2045
2075
|
}
|
|
2046
2076
|
)
|
|
2047
2077
|
] }),
|
|
2048
2078
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2049
|
-
/* @__PURE__ */ e("label", { children: "Body" }),
|
|
2079
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.body", "Body") }),
|
|
2050
2080
|
/* @__PURE__ */ e(
|
|
2051
2081
|
"textarea",
|
|
2052
2082
|
{
|
|
2053
2083
|
value: t.config.body || "",
|
|
2054
|
-
onChange: (
|
|
2084
|
+
onChange: (r) => a({ config: { ...t.config, body: r.target.value } }),
|
|
2055
2085
|
rows: 5
|
|
2056
2086
|
}
|
|
2057
2087
|
)
|
|
@@ -2060,23 +2090,23 @@ function Ye({
|
|
|
2060
2090
|
] })
|
|
2061
2091
|
] });
|
|
2062
2092
|
}
|
|
2063
|
-
function
|
|
2064
|
-
const o = () => {
|
|
2093
|
+
function Ze({ variables: t, onChange: a }) {
|
|
2094
|
+
const { t: o } = $(), i = () => {
|
|
2065
2095
|
a({ ...t, newVariable: "" });
|
|
2066
2096
|
};
|
|
2067
2097
|
return /* @__PURE__ */ n("div", { className: "nice-integration-builder__variables", children: [
|
|
2068
|
-
/* @__PURE__ */ e("h4", { children: "Flow Variables" }),
|
|
2069
|
-
/* @__PURE__ */ e("div", { className: "nice-integration-builder__variables-list", children: Object.entries(t).map(([
|
|
2098
|
+
/* @__PURE__ */ e("h4", { children: o("integrationBuilder.flowVariables", "Flow Variables") }),
|
|
2099
|
+
/* @__PURE__ */ e("div", { className: "nice-integration-builder__variables-list", children: Object.entries(t).map(([r, c]) => /* @__PURE__ */ n("div", { className: "nice-integration-builder__variable-row", children: [
|
|
2070
2100
|
/* @__PURE__ */ e(
|
|
2071
2101
|
"input",
|
|
2072
2102
|
{
|
|
2073
2103
|
type: "text",
|
|
2074
|
-
value:
|
|
2104
|
+
value: r,
|
|
2075
2105
|
onChange: (l) => {
|
|
2076
|
-
const { [
|
|
2106
|
+
const { [r]: d, ...p } = t;
|
|
2077
2107
|
a({ ...p, [l.target.value]: c });
|
|
2078
2108
|
},
|
|
2079
|
-
placeholder: "Name"
|
|
2109
|
+
placeholder: o("integrationBuilder.name", "Name")
|
|
2080
2110
|
}
|
|
2081
2111
|
),
|
|
2082
2112
|
/* @__PURE__ */ e(
|
|
@@ -2084,100 +2114,102 @@ function Xe({ variables: t, onChange: a }) {
|
|
|
2084
2114
|
{
|
|
2085
2115
|
type: "text",
|
|
2086
2116
|
value: String(c),
|
|
2087
|
-
onChange: (l) => a({ ...t, [
|
|
2088
|
-
placeholder: "Value"
|
|
2117
|
+
onChange: (l) => a({ ...t, [r]: l.target.value }),
|
|
2118
|
+
placeholder: o("integrationBuilder.value", "Value")
|
|
2089
2119
|
}
|
|
2090
2120
|
),
|
|
2091
2121
|
/* @__PURE__ */ e(
|
|
2092
2122
|
"button",
|
|
2093
2123
|
{
|
|
2124
|
+
"aria-label": o("integrationBuilder.close", "Close"),
|
|
2094
2125
|
onClick: () => {
|
|
2095
|
-
const { [
|
|
2126
|
+
const { [r]: l, ...d } = t;
|
|
2096
2127
|
a(d);
|
|
2097
2128
|
},
|
|
2098
|
-
children: "
|
|
2129
|
+
children: /* @__PURE__ */ e(ee, { name: "close", size: 14 })
|
|
2099
2130
|
}
|
|
2100
2131
|
)
|
|
2101
|
-
] },
|
|
2102
|
-
/* @__PURE__ */ e("button", { onClick:
|
|
2132
|
+
] }, r)) }),
|
|
2133
|
+
/* @__PURE__ */ e("button", { onClick: i, children: o("integrationBuilder.addVariable", "+ Add Variable") })
|
|
2103
2134
|
] });
|
|
2104
2135
|
}
|
|
2105
|
-
function
|
|
2136
|
+
function et({
|
|
2106
2137
|
errorHandling: t,
|
|
2107
2138
|
schedule: a,
|
|
2108
2139
|
onChange: o
|
|
2109
2140
|
}) {
|
|
2141
|
+
const { t: i } = $();
|
|
2110
2142
|
return /* @__PURE__ */ n("div", { className: "nice-integration-builder__settings", children: [
|
|
2111
|
-
/* @__PURE__ */ e("h4", { children: "Error Handling" }),
|
|
2143
|
+
/* @__PURE__ */ e("h4", { children: i("integrationBuilder.errorHandling", "Error Handling") }),
|
|
2112
2144
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2113
|
-
/* @__PURE__ */ e("label", { children: "Strategy" }),
|
|
2145
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.strategy", "Strategy") }),
|
|
2114
2146
|
/* @__PURE__ */ n(
|
|
2115
2147
|
"select",
|
|
2116
2148
|
{
|
|
2117
2149
|
value: t.strategy,
|
|
2118
|
-
onChange: (
|
|
2119
|
-
{ ...t, strategy:
|
|
2150
|
+
onChange: (r) => o(
|
|
2151
|
+
{ ...t, strategy: r.target.value },
|
|
2120
2152
|
a
|
|
2121
2153
|
),
|
|
2122
2154
|
children: [
|
|
2123
|
-
/* @__PURE__ */ e("option", { value: "stop", children: "Stop on error" }),
|
|
2124
|
-
/* @__PURE__ */ e("option", { value: "continue", children: "Continue on error" }),
|
|
2125
|
-
/* @__PURE__ */ e("option", { value: "retry", children: "Retry on error" })
|
|
2155
|
+
/* @__PURE__ */ e("option", { value: "stop", children: i("integrationBuilder.stopOnError", "Stop on error") }),
|
|
2156
|
+
/* @__PURE__ */ e("option", { value: "continue", children: i("integrationBuilder.continueOnError", "Continue on error") }),
|
|
2157
|
+
/* @__PURE__ */ e("option", { value: "retry", children: i("integrationBuilder.retryOnError", "Retry on error") })
|
|
2126
2158
|
]
|
|
2127
2159
|
}
|
|
2128
2160
|
)
|
|
2129
2161
|
] }),
|
|
2130
|
-
t.strategy === "retry" && /* @__PURE__ */ n(
|
|
2162
|
+
t.strategy === "retry" && /* @__PURE__ */ n(Q, { children: [
|
|
2131
2163
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2132
|
-
/* @__PURE__ */ e("label", { children: "Max Retries" }),
|
|
2164
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.maxRetries", "Max Retries") }),
|
|
2133
2165
|
/* @__PURE__ */ e(
|
|
2134
2166
|
"input",
|
|
2135
2167
|
{
|
|
2136
2168
|
type: "number",
|
|
2137
2169
|
value: t.maxRetries || 3,
|
|
2138
|
-
onChange: (
|
|
2170
|
+
onChange: (r) => o({ ...t, maxRetries: parseInt(r.target.value, 10) }, a)
|
|
2139
2171
|
}
|
|
2140
2172
|
)
|
|
2141
2173
|
] }),
|
|
2142
2174
|
/* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2143
|
-
/* @__PURE__ */ e("label", { children: "Retry Delay (ms)" }),
|
|
2175
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.retryDelayMs", "Retry Delay (ms)") }),
|
|
2144
2176
|
/* @__PURE__ */ e(
|
|
2145
2177
|
"input",
|
|
2146
2178
|
{
|
|
2147
2179
|
type: "number",
|
|
2148
2180
|
value: t.retryDelay || 1e3,
|
|
2149
|
-
onChange: (
|
|
2181
|
+
onChange: (r) => o({ ...t, retryDelay: parseInt(r.target.value, 10) }, a)
|
|
2150
2182
|
}
|
|
2151
2183
|
)
|
|
2152
2184
|
] })
|
|
2153
2185
|
] }),
|
|
2154
|
-
/* @__PURE__ */ e("h4", { children: "Schedule" }),
|
|
2186
|
+
/* @__PURE__ */ e("h4", { children: i("integrationBuilder.schedule", "Schedule") }),
|
|
2155
2187
|
/* @__PURE__ */ e("div", { className: "nice-integration-builder__field", children: /* @__PURE__ */ n("label", { children: [
|
|
2156
2188
|
/* @__PURE__ */ e(
|
|
2157
2189
|
"input",
|
|
2158
2190
|
{
|
|
2159
2191
|
type: "checkbox",
|
|
2160
2192
|
checked: (a == null ? void 0 : a.enabled) || !1,
|
|
2161
|
-
onChange: (
|
|
2193
|
+
onChange: (r) => o(t, { ...a, enabled: r.target.checked })
|
|
2162
2194
|
}
|
|
2163
2195
|
),
|
|
2164
|
-
"Enable scheduled execution"
|
|
2196
|
+
i("integrationBuilder.enableScheduledExecution", "Enable scheduled execution")
|
|
2165
2197
|
] }) }),
|
|
2166
2198
|
(a == null ? void 0 : a.enabled) && /* @__PURE__ */ n("div", { className: "nice-integration-builder__field", children: [
|
|
2167
|
-
/* @__PURE__ */ e("label", { children: "Cron Expression" }),
|
|
2199
|
+
/* @__PURE__ */ e("label", { children: i("integrationBuilder.cronExpression", "Cron Expression") }),
|
|
2168
2200
|
/* @__PURE__ */ e(
|
|
2169
2201
|
"input",
|
|
2170
2202
|
{
|
|
2171
2203
|
type: "text",
|
|
2172
2204
|
value: a.cron || "",
|
|
2173
|
-
onChange: (
|
|
2205
|
+
onChange: (r) => o(t, { ...a, cron: r.target.value }),
|
|
2174
2206
|
placeholder: "0 0 * * *"
|
|
2175
2207
|
}
|
|
2176
2208
|
)
|
|
2177
2209
|
] })
|
|
2178
2210
|
] });
|
|
2179
2211
|
}
|
|
2180
|
-
const
|
|
2212
|
+
const tt = [
|
|
2181
2213
|
{
|
|
2182
2214
|
target: ".nice-webhook-tester",
|
|
2183
2215
|
titleKey: "tutorial.webhookTester.intro.title",
|
|
@@ -2187,96 +2219,98 @@ const Ze = [
|
|
|
2187
2219
|
placement: "auto"
|
|
2188
2220
|
}
|
|
2189
2221
|
];
|
|
2190
|
-
function
|
|
2222
|
+
function be(t) {
|
|
2191
2223
|
return t ? Object.entries(t).map(([a, o]) => ({ key: a, value: o })) : [];
|
|
2192
2224
|
}
|
|
2193
|
-
function
|
|
2225
|
+
function ve(t) {
|
|
2194
2226
|
const a = {};
|
|
2195
2227
|
for (const o of t)
|
|
2196
2228
|
o.key.trim() !== "" && (a[o.key] = o.value);
|
|
2197
2229
|
return a;
|
|
2198
2230
|
}
|
|
2199
|
-
async function
|
|
2200
|
-
var
|
|
2201
|
-
const o = (
|
|
2231
|
+
async function it(t, a) {
|
|
2232
|
+
var l;
|
|
2233
|
+
const o = (l = globalThis.crypto) == null ? void 0 : l.subtle;
|
|
2202
2234
|
if (!o)
|
|
2203
2235
|
throw new Error("Web Crypto (crypto.subtle) is unavailable in this environment");
|
|
2204
|
-
const i = new TextEncoder(),
|
|
2236
|
+
const i = new TextEncoder(), r = await o.importKey(
|
|
2205
2237
|
"raw",
|
|
2206
2238
|
i.encode(t),
|
|
2207
2239
|
{ name: "HMAC", hash: "SHA-256" },
|
|
2208
2240
|
!1,
|
|
2209
2241
|
["sign"]
|
|
2210
|
-
),
|
|
2211
|
-
return [...new Uint8Array(
|
|
2242
|
+
), c = await o.sign("HMAC", r, i.encode(a));
|
|
2243
|
+
return [...new Uint8Array(c)].map((d) => d.toString(16).padStart(2, "0")).join("");
|
|
2212
2244
|
}
|
|
2213
|
-
const
|
|
2245
|
+
const dt = /* @__PURE__ */ Ce(
|
|
2214
2246
|
function(a, o) {
|
|
2215
|
-
const {
|
|
2216
|
-
url:
|
|
2247
|
+
const { t: i } = $(), {
|
|
2248
|
+
url: r = "",
|
|
2217
2249
|
method: c = "POST",
|
|
2218
2250
|
headers: l,
|
|
2219
2251
|
payload: d = "",
|
|
2220
2252
|
samples: p = [],
|
|
2221
|
-
onSend:
|
|
2253
|
+
onSend: v,
|
|
2222
2254
|
signing: u,
|
|
2223
|
-
onSaveSample:
|
|
2224
|
-
tutorial:
|
|
2225
|
-
className:
|
|
2226
|
-
style:
|
|
2255
|
+
onSaveSample: N,
|
|
2256
|
+
tutorial: b,
|
|
2257
|
+
className: y,
|
|
2258
|
+
style: T,
|
|
2227
2259
|
id: m,
|
|
2228
|
-
"data-testid":
|
|
2229
|
-
} = a, [
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
const
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2260
|
+
"data-testid": S
|
|
2261
|
+
} = a, [w, A] = C(r), [J, te] = C(c), [z, M] = C(() => be(l)), [O, V] = C(d), [G, k] = C(""), [f, x] = C(!1), [j, F] = C(null), [R, ie] = C(null), [K, Y] = C(null), ne = de(null), Z = K !== null;
|
|
2262
|
+
Ne(() => {
|
|
2263
|
+
var _;
|
|
2264
|
+
Z && ((_ = ne.current) == null || _.focus());
|
|
2265
|
+
}, [Z]);
|
|
2266
|
+
const ae = Se(() => {
|
|
2267
|
+
const _ = /* @__PURE__ */ new Map();
|
|
2268
|
+
for (const D of p)
|
|
2269
|
+
_.set(D.id, D);
|
|
2270
|
+
return _;
|
|
2271
|
+
}, [p]), h = (_) => {
|
|
2272
|
+
k(_);
|
|
2273
|
+
const D = ae.get(_);
|
|
2274
|
+
D && (V(D.payload), D.headers && M(be(D.headers)));
|
|
2275
|
+
}, s = (_, D) => {
|
|
2276
|
+
M((q) => q.map((W, X) => X === _ ? { ...W, ...D } : W));
|
|
2277
|
+
}, g = async () => {
|
|
2278
|
+
x(!0), F(null), ie(null);
|
|
2242
2279
|
try {
|
|
2243
|
-
const
|
|
2280
|
+
const _ = ve(z);
|
|
2244
2281
|
if (u && u.secret) {
|
|
2245
|
-
const
|
|
2246
|
-
|
|
2282
|
+
const X = await it(u.secret, O);
|
|
2283
|
+
_[u.header] = `${u.prefix ?? ""}${X}`;
|
|
2247
2284
|
}
|
|
2248
|
-
const
|
|
2249
|
-
(typeof performance < "u" ? performance.now() : Date.now()) -
|
|
2285
|
+
const D = typeof performance < "u" ? performance.now() : Date.now(), q = await v({ url: w, method: J ?? "POST", headers: _, body: O }), W = Math.round(
|
|
2286
|
+
(typeof performance < "u" ? performance.now() : Date.now()) - D
|
|
2250
2287
|
);
|
|
2251
|
-
|
|
2252
|
-
} catch (
|
|
2253
|
-
|
|
2288
|
+
ie({ ...q, durationMs: q.durationMs ?? W });
|
|
2289
|
+
} catch (_) {
|
|
2290
|
+
F(_ instanceof Error ? _.message : String(_));
|
|
2254
2291
|
} finally {
|
|
2255
2292
|
x(!1);
|
|
2256
2293
|
}
|
|
2257
|
-
},
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
return;
|
|
2261
|
-
const r = typeof window < "u" && ((C = window.prompt) == null ? void 0 : C.call(window, "Sample name")) || "";
|
|
2262
|
-
r && f({
|
|
2294
|
+
}, P = () => {
|
|
2295
|
+
const _ = K == null ? void 0 : K.trim();
|
|
2296
|
+
!N || !_ || (N({
|
|
2263
2297
|
id: `sample_${Date.now().toString(36)}`,
|
|
2264
|
-
name:
|
|
2265
|
-
payload:
|
|
2266
|
-
headers:
|
|
2267
|
-
});
|
|
2268
|
-
},
|
|
2269
|
-
return /* @__PURE__ */ n("div", { ref: o, id: m, className:
|
|
2270
|
-
|
|
2298
|
+
name: _,
|
|
2299
|
+
payload: O,
|
|
2300
|
+
headers: ve(z)
|
|
2301
|
+
}), Y(null));
|
|
2302
|
+
}, H = R == null ? "" : R.status >= 200 && R.status < 300 ? " nice-webhook-tester__status--ok" : " nice-webhook-tester__status--error", E = "nice-webhook-tester" + (y ? ` ${y}` : "");
|
|
2303
|
+
return /* @__PURE__ */ n("div", { ref: o, id: m, className: E, style: T, "data-testid": S, children: [
|
|
2304
|
+
b && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__tutorial", children: /* @__PURE__ */ e(ce, { steps: le(b, tt) }) }),
|
|
2271
2305
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__bar", children: [
|
|
2272
2306
|
/* @__PURE__ */ e(
|
|
2273
2307
|
"select",
|
|
2274
2308
|
{
|
|
2275
2309
|
className: "nice-webhook-tester__method",
|
|
2276
|
-
value:
|
|
2277
|
-
onChange: (
|
|
2278
|
-
"aria-label": "Method",
|
|
2279
|
-
children: ["POST", "PUT", "GET", "PATCH", "DELETE"].map((
|
|
2310
|
+
value: J,
|
|
2311
|
+
onChange: (_) => te(_.target.value),
|
|
2312
|
+
"aria-label": i("webhookTester.method", "Method"),
|
|
2313
|
+
children: ["POST", "PUT", "GET", "PATCH", "DELETE"].map((_) => /* @__PURE__ */ e("option", { value: _, children: _ }, _))
|
|
2280
2314
|
}
|
|
2281
2315
|
),
|
|
2282
2316
|
/* @__PURE__ */ e(
|
|
@@ -2284,10 +2318,10 @@ const ct = Ce(
|
|
|
2284
2318
|
{
|
|
2285
2319
|
type: "text",
|
|
2286
2320
|
className: "nice-webhook-tester__url",
|
|
2287
|
-
value:
|
|
2321
|
+
value: w,
|
|
2288
2322
|
placeholder: "https://example.com/api/payments/stripe/webhook",
|
|
2289
|
-
onChange: (
|
|
2290
|
-
"aria-label": "URL"
|
|
2323
|
+
onChange: (_) => A(_.target.value),
|
|
2324
|
+
"aria-label": i("webhookTester.url", "URL")
|
|
2291
2325
|
}
|
|
2292
2326
|
),
|
|
2293
2327
|
/* @__PURE__ */ e(
|
|
@@ -2295,108 +2329,147 @@ const ct = Ce(
|
|
|
2295
2329
|
{
|
|
2296
2330
|
type: "button",
|
|
2297
2331
|
className: "nice-webhook-tester__send",
|
|
2298
|
-
onClick: () => void
|
|
2299
|
-
disabled:
|
|
2300
|
-
children:
|
|
2332
|
+
onClick: () => void g(),
|
|
2333
|
+
disabled: f || w.trim() === "",
|
|
2334
|
+
children: f ? i("webhookTester.sending", "Sending…") : i("webhookTester.send", "Send")
|
|
2301
2335
|
}
|
|
2302
2336
|
)
|
|
2303
2337
|
] }),
|
|
2304
2338
|
p.length > 0 && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__samples", children: /* @__PURE__ */ n("label", { children: [
|
|
2305
|
-
"Sample:",
|
|
2339
|
+
i("webhookTester.sample", "Sample:"),
|
|
2306
2340
|
" ",
|
|
2307
|
-
/* @__PURE__ */ n("select", { value:
|
|
2308
|
-
/* @__PURE__ */ e("option", { value: "", children: "— choose a saved payload —" }),
|
|
2309
|
-
p.map((
|
|
2341
|
+
/* @__PURE__ */ n("select", { value: G, onChange: (_) => h(_.target.value), children: [
|
|
2342
|
+
/* @__PURE__ */ e("option", { value: "", children: i("webhookTester.chooseASavedPayload", "— choose a saved payload —") }),
|
|
2343
|
+
p.map((_) => /* @__PURE__ */ e("option", { value: _.id, children: _.name }, _.id))
|
|
2310
2344
|
] })
|
|
2311
2345
|
] }) }),
|
|
2312
2346
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__headers", children: [
|
|
2313
2347
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
|
|
2314
|
-
"Headers",
|
|
2348
|
+
i("webhookTester.headers", "Headers"),
|
|
2315
2349
|
u && /* @__PURE__ */ n("span", { className: "nice-webhook-tester__signed", children: [
|
|
2316
2350
|
" ",
|
|
2317
|
-
"· auto-signs
|
|
2351
|
+
i("webhookTester.autoSigns", "· auto-signs"),
|
|
2352
|
+
" ",
|
|
2318
2353
|
/* @__PURE__ */ e("code", { children: u.header })
|
|
2319
2354
|
] })
|
|
2320
2355
|
] }),
|
|
2321
|
-
|
|
2356
|
+
z.map((_, D) => /* @__PURE__ */ n("div", { className: "nice-webhook-tester__header-row", children: [
|
|
2322
2357
|
/* @__PURE__ */ e(
|
|
2323
2358
|
"input",
|
|
2324
2359
|
{
|
|
2325
2360
|
type: "text",
|
|
2326
|
-
value:
|
|
2327
|
-
placeholder: "Header",
|
|
2328
|
-
onChange: (
|
|
2329
|
-
"aria-label": "Header name"
|
|
2361
|
+
value: _.key,
|
|
2362
|
+
placeholder: i("webhookTester.header", "Header"),
|
|
2363
|
+
onChange: (q) => s(D, { key: q.target.value }),
|
|
2364
|
+
"aria-label": i("webhookTester.headerName", "Header name")
|
|
2330
2365
|
}
|
|
2331
2366
|
),
|
|
2332
2367
|
/* @__PURE__ */ e(
|
|
2333
2368
|
"input",
|
|
2334
2369
|
{
|
|
2335
2370
|
type: "text",
|
|
2336
|
-
value:
|
|
2337
|
-
placeholder: "Value",
|
|
2338
|
-
onChange: (
|
|
2339
|
-
"aria-label": "Header value"
|
|
2371
|
+
value: _.value,
|
|
2372
|
+
placeholder: i("webhookTester.value", "Value"),
|
|
2373
|
+
onChange: (q) => s(D, { value: q.target.value }),
|
|
2374
|
+
"aria-label": i("webhookTester.headerValue", "Header value")
|
|
2340
2375
|
}
|
|
2341
2376
|
),
|
|
2342
2377
|
/* @__PURE__ */ e(
|
|
2343
2378
|
"button",
|
|
2344
2379
|
{
|
|
2345
2380
|
type: "button",
|
|
2346
|
-
onClick: () =>
|
|
2347
|
-
"aria-label": "Remove header",
|
|
2348
|
-
children: /* @__PURE__ */ e(
|
|
2381
|
+
onClick: () => M((q) => q.filter((W, X) => X !== D)),
|
|
2382
|
+
"aria-label": i("webhookTester.removeHeader", "Remove header"),
|
|
2383
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 12 })
|
|
2349
2384
|
}
|
|
2350
2385
|
)
|
|
2351
|
-
] },
|
|
2386
|
+
] }, D)),
|
|
2352
2387
|
/* @__PURE__ */ e(
|
|
2353
2388
|
"button",
|
|
2354
2389
|
{
|
|
2355
2390
|
type: "button",
|
|
2356
2391
|
className: "nice-webhook-tester__add-header",
|
|
2357
|
-
onClick: () =>
|
|
2358
|
-
children: "+ Header"
|
|
2392
|
+
onClick: () => M((_) => [..._, { key: "", value: "" }]),
|
|
2393
|
+
children: i("webhookTester.header2", "+ Header")
|
|
2359
2394
|
}
|
|
2360
2395
|
)
|
|
2361
2396
|
] }),
|
|
2362
2397
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__payload", children: [
|
|
2363
2398
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
|
|
2364
|
-
"Payload",
|
|
2365
|
-
|
|
2399
|
+
i("webhookTester.payload", "Payload"),
|
|
2400
|
+
N && /* @__PURE__ */ e(
|
|
2401
|
+
"button",
|
|
2402
|
+
{
|
|
2403
|
+
type: "button",
|
|
2404
|
+
className: "nice-webhook-tester__save",
|
|
2405
|
+
onClick: () => Y(""),
|
|
2406
|
+
"aria-expanded": Z,
|
|
2407
|
+
children: i("webhookTester.saveAsSample", "Save as sample")
|
|
2408
|
+
}
|
|
2409
|
+
)
|
|
2410
|
+
] }),
|
|
2411
|
+
N && Z && /* @__PURE__ */ n("div", { className: "nice-webhook-tester__header-row", children: [
|
|
2412
|
+
/* @__PURE__ */ e(
|
|
2413
|
+
"input",
|
|
2414
|
+
{
|
|
2415
|
+
ref: ne,
|
|
2416
|
+
type: "text",
|
|
2417
|
+
value: K,
|
|
2418
|
+
placeholder: i("webhookTester.sampleNamePrompt", "Sample name"),
|
|
2419
|
+
"aria-label": i("webhookTester.sampleNamePrompt", "Sample name"),
|
|
2420
|
+
onChange: (_) => Y(_.target.value),
|
|
2421
|
+
onKeyDown: (_) => {
|
|
2422
|
+
_.key === "Enter" ? (_.preventDefault(), P()) : _.key === "Escape" && Y(null);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
),
|
|
2426
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: P, disabled: !K.trim(), children: i("save", "Save") }),
|
|
2427
|
+
/* @__PURE__ */ e(
|
|
2428
|
+
"button",
|
|
2429
|
+
{
|
|
2430
|
+
type: "button",
|
|
2431
|
+
onClick: () => Y(null),
|
|
2432
|
+
"aria-label": i("cancel", "Cancel"),
|
|
2433
|
+
children: /* @__PURE__ */ e(B, { name: "close", size: 12 })
|
|
2434
|
+
}
|
|
2435
|
+
)
|
|
2366
2436
|
] }),
|
|
2367
2437
|
/* @__PURE__ */ e(
|
|
2368
2438
|
"textarea",
|
|
2369
2439
|
{
|
|
2370
2440
|
className: "nice-webhook-tester__textarea",
|
|
2371
|
-
value:
|
|
2441
|
+
value: O,
|
|
2372
2442
|
spellCheck: !1,
|
|
2373
2443
|
rows: 8,
|
|
2374
|
-
placeholder:
|
|
2375
|
-
|
|
2376
|
-
|
|
2444
|
+
placeholder: i(
|
|
2445
|
+
"webhookTester.typePaymentSucceededData",
|
|
2446
|
+
'{ "type": "payment.succeeded", "data": { ... } }'
|
|
2447
|
+
),
|
|
2448
|
+
onChange: (_) => V(_.target.value),
|
|
2449
|
+
"aria-label": i("webhookTester.payload", "Payload")
|
|
2377
2450
|
}
|
|
2378
2451
|
)
|
|
2379
2452
|
] }),
|
|
2380
|
-
|
|
2381
|
-
|
|
2453
|
+
j && /* @__PURE__ */ e("div", { className: "nice-webhook-tester__error", children: j }),
|
|
2454
|
+
R && /* @__PURE__ */ n("div", { className: "nice-webhook-tester__response", children: [
|
|
2382
2455
|
/* @__PURE__ */ n("div", { className: "nice-webhook-tester__section-label", children: [
|
|
2383
|
-
"Response",
|
|
2456
|
+
i("webhookTester.response", "Response"),
|
|
2384
2457
|
" ",
|
|
2385
|
-
/* @__PURE__ */ e("span", { className: "nice-webhook-tester__status" +
|
|
2386
|
-
|
|
2458
|
+
/* @__PURE__ */ e("span", { className: "nice-webhook-tester__status" + H, children: R.status }),
|
|
2459
|
+
R.durationMs != null && /* @__PURE__ */ n("span", { className: "nice-webhook-tester__time", children: [
|
|
2387
2460
|
" · ",
|
|
2388
|
-
|
|
2461
|
+
R.durationMs,
|
|
2389
2462
|
" ms"
|
|
2390
2463
|
] })
|
|
2391
2464
|
] }),
|
|
2392
|
-
|
|
2465
|
+
R.body != null && /* @__PURE__ */ e("pre", { className: "nice-webhook-tester__response-body", children: R.body })
|
|
2393
2466
|
] })
|
|
2394
2467
|
] });
|
|
2395
2468
|
}
|
|
2396
2469
|
);
|
|
2397
2470
|
export {
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2471
|
+
ot as NiceAPIDesigner,
|
|
2472
|
+
ct as NiceAPITester,
|
|
2473
|
+
lt as NiceIntegrationBuilder,
|
|
2474
|
+
dt as NiceWebhookTester
|
|
2402
2475
|
};
|