@ws-ui/http-handlers-editor 1.11.3-rc1
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/dist/Editor.d.ts +7 -0
- package/dist/Handler/index.d.ts +3 -0
- package/dist/Provider/index.d.ts +59 -0
- package/dist/Standalone/index.d.ts +6 -0
- package/dist/SwitchToEditorIcon.d.ts +12 -0
- package/dist/http-handlers-editor.css +1 -0
- package/dist/index.cjs.js +6 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1150 -0
- package/dist/index.es.js.map +1 -0
- package/dist/main.d.ts +0 -0
- package/package.json +60 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1150 @@
|
|
|
1
|
+
import { jsx as e, jsxs as o, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import { ChakraProvider as he } from "@chakra-ui/react";
|
|
3
|
+
import { useSensors as me, useSensor as X, PointerSensor as ge, KeyboardSensor as xe, DndContext as fe, closestCenter as ye, DragOverlay as be } from "@dnd-kit/core";
|
|
4
|
+
import { useSortable as ve, sortableKeyboardCoordinates as Ne, SortableContext as we, verticalListSortingStrategy as Ee, arrayMove as Ce } from "@dnd-kit/sortable";
|
|
5
|
+
import { FdWarningDanger as j, FdRegex as De, FdUnRegex as Te, FdDuplicate as te, FdPen as He, FdTrash as Re, FdCloseNaked as q, FdInfoCircle as ne, FdCheckCircle as Pe, FdClose as Se, FdDragHandle as ke, FdDown as K, FdEmpty as J, FdCode as Ie, FdPlus as Y } from "@ws-ui/icons";
|
|
6
|
+
import { useAppDispatch as B, switchEditor as Ae, useAppSelector as W, selectCatalog as re, openModal as ae, selectTabByPath as _e, setContent as Le, ReduxProvider as Fe, getStore as Oe } from "@ws-ui/store";
|
|
7
|
+
import { ToolbarIcon as $e, chakraTheme as je } from "@ws-ui/webform-editor";
|
|
8
|
+
import { createContext as Ge, useReducer as qe, useEffect as O, useContext as Be, useState as _, Fragment as se, useMemo as Ue } from "react";
|
|
9
|
+
import { generate as V } from "short-uuid";
|
|
10
|
+
import { z as A } from "zod";
|
|
11
|
+
import { CSS as ze } from "@dnd-kit/utilities";
|
|
12
|
+
import { Combobox as S, Transition as le } from "@headlessui/react";
|
|
13
|
+
import { Tooltip as E, ModalColor as ie, ModalType as oe, useHotkeys as Me, ControlledSwitch as Ve, HTTP_HANDLERS_TAB_PATH as Ke } from "@ws-ui/shared";
|
|
14
|
+
import C from "classnames";
|
|
15
|
+
import { useMultipleSelection as F, useCombobox as L } from "downshift";
|
|
16
|
+
import { omit as de, isEqual as Je } from "lodash";
|
|
17
|
+
import { Subject as We } from "rxjs";
|
|
18
|
+
import Z from "randexp";
|
|
19
|
+
const Qe = ({
|
|
20
|
+
label: t,
|
|
21
|
+
Icon: a,
|
|
22
|
+
tab: r,
|
|
23
|
+
editor: i,
|
|
24
|
+
onBeforeClick: c
|
|
25
|
+
}) => {
|
|
26
|
+
const x = B();
|
|
27
|
+
return /* @__PURE__ */ e(
|
|
28
|
+
$e,
|
|
29
|
+
{
|
|
30
|
+
label: t,
|
|
31
|
+
Icon: a,
|
|
32
|
+
as: "button",
|
|
33
|
+
onClick: () => {
|
|
34
|
+
c == null || c(), x(
|
|
35
|
+
Ae({
|
|
36
|
+
tab: r,
|
|
37
|
+
editor: i
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}, ce = Ge(void 0), $ = new We(), Xe = (t, a) => {
|
|
44
|
+
switch (a.type) {
|
|
45
|
+
case "UPDATE_HANDLERS":
|
|
46
|
+
return {
|
|
47
|
+
...t,
|
|
48
|
+
content: a.payload
|
|
49
|
+
};
|
|
50
|
+
case "SET_EDITING_HANDLER": {
|
|
51
|
+
if (a.payload && a.payload !== t.editing) {
|
|
52
|
+
const r = t.content.find(
|
|
53
|
+
(i) => i.id === t.editing
|
|
54
|
+
);
|
|
55
|
+
if (r && !Object.values(
|
|
56
|
+
de(r, ["id", "verbs", "asRegex", "isExpanded"])
|
|
57
|
+
).some(Boolean) && r.verbs.length === 0)
|
|
58
|
+
return {
|
|
59
|
+
...t,
|
|
60
|
+
content: t.content.filter((c) => c.id !== r.id),
|
|
61
|
+
editing: a.payload
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
...t,
|
|
66
|
+
editing: a.payload
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
case "ADD_HANDLER": {
|
|
70
|
+
const r = V();
|
|
71
|
+
return {
|
|
72
|
+
...t,
|
|
73
|
+
content: [...t.content, { ...a.payload, id: r }],
|
|
74
|
+
editing: r,
|
|
75
|
+
newlyCreatedHandlerID: r
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
case "UPDATE_HANDLER":
|
|
79
|
+
return {
|
|
80
|
+
...t,
|
|
81
|
+
content: t.content.map(
|
|
82
|
+
(r) => r.id === a.id ? { ...r, ...a.payload } : r
|
|
83
|
+
),
|
|
84
|
+
newlyCreatedHandlerID: null
|
|
85
|
+
};
|
|
86
|
+
case "DELETE_HANDLER":
|
|
87
|
+
return {
|
|
88
|
+
...t,
|
|
89
|
+
content: t.content.filter((r) => r.id !== a.id)
|
|
90
|
+
};
|
|
91
|
+
case "TOGGLE_EXPANDED":
|
|
92
|
+
return {
|
|
93
|
+
...t,
|
|
94
|
+
content: t.content.map(
|
|
95
|
+
(r) => r.id === a.id ? { ...r, isExpanded: !r.isExpanded } : r
|
|
96
|
+
)
|
|
97
|
+
};
|
|
98
|
+
case "DUPLICATE_HANDLER": {
|
|
99
|
+
const r = t.content.find(
|
|
100
|
+
(i) => i.id === a.id
|
|
101
|
+
);
|
|
102
|
+
return r ? {
|
|
103
|
+
...t,
|
|
104
|
+
content: [
|
|
105
|
+
...t.content,
|
|
106
|
+
{ ...r, id: V(), isExpanded: !0 }
|
|
107
|
+
]
|
|
108
|
+
} : t;
|
|
109
|
+
}
|
|
110
|
+
case "TOGGLE_ALL_EXPANDED":
|
|
111
|
+
return {
|
|
112
|
+
...t,
|
|
113
|
+
content: t.content.map((r) => ({
|
|
114
|
+
...r,
|
|
115
|
+
isExpanded: a.payload
|
|
116
|
+
}))
|
|
117
|
+
};
|
|
118
|
+
case "SYNC_DATA":
|
|
119
|
+
return {
|
|
120
|
+
...t,
|
|
121
|
+
content: a.payload.map((r) => {
|
|
122
|
+
const i = t.content.find((c) => c.id === r.id);
|
|
123
|
+
return i ? {
|
|
124
|
+
...r,
|
|
125
|
+
...i
|
|
126
|
+
} : r;
|
|
127
|
+
})
|
|
128
|
+
};
|
|
129
|
+
default:
|
|
130
|
+
throw new Error("Unknown action type");
|
|
131
|
+
}
|
|
132
|
+
}, Ye = ({
|
|
133
|
+
children: t,
|
|
134
|
+
content: a
|
|
135
|
+
}) => {
|
|
136
|
+
const r = {
|
|
137
|
+
content: a,
|
|
138
|
+
editing: null,
|
|
139
|
+
newlyCreatedHandlerID: null
|
|
140
|
+
}, [i, c] = qe(Xe, r);
|
|
141
|
+
return O(() => {
|
|
142
|
+
c({
|
|
143
|
+
type: "SYNC_DATA",
|
|
144
|
+
payload: a
|
|
145
|
+
});
|
|
146
|
+
}, [a]), /* @__PURE__ */ e(ce.Provider, { value: { state: i, dispatch: c }, children: t });
|
|
147
|
+
}, Q = () => {
|
|
148
|
+
const t = Be(ce);
|
|
149
|
+
if (!t)
|
|
150
|
+
throw new Error("useHTTPHandlers must be used within a HandlerProvider");
|
|
151
|
+
return t;
|
|
152
|
+
}, Ze = ({ initialSelectedItems: t, onChange: a, touched: r, onBlur: i }) => {
|
|
153
|
+
const c = ["GET", "POST", "PUT", "DELETE"];
|
|
154
|
+
function x(h, u) {
|
|
155
|
+
const N = u.toLowerCase();
|
|
156
|
+
return c.filter(function(s) {
|
|
157
|
+
return !h.includes(s) && s.toLowerCase().includes(N);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const [f, g] = _(""), [d, n] = _(t);
|
|
161
|
+
O(() => {
|
|
162
|
+
n(t);
|
|
163
|
+
}, [t]);
|
|
164
|
+
const l = Ue(
|
|
165
|
+
() => x(d, f),
|
|
166
|
+
[d, f]
|
|
167
|
+
), { getSelectedItemProps: p, getDropdownProps: b, removeSelectedItem: v } = F({
|
|
168
|
+
selectedItems: d,
|
|
169
|
+
onStateChange({ selectedItems: h = [], type: u }) {
|
|
170
|
+
switch (u) {
|
|
171
|
+
case F.stateChangeTypes.SelectedItemKeyDownBackspace:
|
|
172
|
+
case F.stateChangeTypes.SelectedItemKeyDownDelete:
|
|
173
|
+
case F.stateChangeTypes.DropdownKeyDownBackspace:
|
|
174
|
+
case F.stateChangeTypes.FunctionRemoveSelectedItem:
|
|
175
|
+
n(h);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}), {
|
|
180
|
+
isOpen: y,
|
|
181
|
+
getToggleButtonProps: w,
|
|
182
|
+
getMenuProps: k,
|
|
183
|
+
getInputProps: D,
|
|
184
|
+
highlightedIndex: T,
|
|
185
|
+
getItemProps: H,
|
|
186
|
+
selectedItem: R
|
|
187
|
+
} = L({
|
|
188
|
+
items: l,
|
|
189
|
+
itemToString(h) {
|
|
190
|
+
return h || "";
|
|
191
|
+
},
|
|
192
|
+
defaultHighlightedIndex: 0,
|
|
193
|
+
// after selection, highlight the first item.
|
|
194
|
+
selectedItem: null,
|
|
195
|
+
inputValue: f,
|
|
196
|
+
stateReducer(h, u) {
|
|
197
|
+
const { changes: N, type: P } = u;
|
|
198
|
+
switch (P) {
|
|
199
|
+
case L.stateChangeTypes.InputKeyDownEnter:
|
|
200
|
+
case L.stateChangeTypes.ItemClick:
|
|
201
|
+
return {
|
|
202
|
+
...N,
|
|
203
|
+
isOpen: !0,
|
|
204
|
+
// keep the menu open after selection.
|
|
205
|
+
highlightedIndex: 0
|
|
206
|
+
// with the first option highlighted.
|
|
207
|
+
};
|
|
208
|
+
default:
|
|
209
|
+
return N;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
onStateChange({
|
|
213
|
+
inputValue: h = "",
|
|
214
|
+
type: u,
|
|
215
|
+
selectedItem: N
|
|
216
|
+
}) {
|
|
217
|
+
switch (u) {
|
|
218
|
+
case L.stateChangeTypes.InputKeyDownEnter:
|
|
219
|
+
case L.stateChangeTypes.ItemClick:
|
|
220
|
+
case L.stateChangeTypes.InputBlur:
|
|
221
|
+
N && (n([...d, N]), g(""));
|
|
222
|
+
break;
|
|
223
|
+
case L.stateChangeTypes.InputChange:
|
|
224
|
+
g(h);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return O(() => {
|
|
230
|
+
a(d);
|
|
231
|
+
}, [d]), /* @__PURE__ */ o("div", { className: "relative flex-1", children: [
|
|
232
|
+
/* @__PURE__ */ o(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
className: C(
|
|
236
|
+
"bg-grey-300 focus-within:ring-1 focus-within:ring-primary-dark relative flex items-center w-full cursor-default overflow-hidden rounded p-px text-left focus:outline-none",
|
|
237
|
+
{
|
|
238
|
+
"ring-1 ring-primary-dark rounded-b-none": y && l.length,
|
|
239
|
+
"ring-1 ring-red-400 overflow-visible": d.length === 0 && r
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
onBlur: i,
|
|
243
|
+
children: [
|
|
244
|
+
d.length === 0 && !y && r && /* @__PURE__ */ e("div", { className: "absolute inset-x-0 top-[25px] z-[1] rounded-b-sm bg-red-200 px-1 text-xs text-red-600 ring-1 ring-red-600", children: d.length === 0 && "At least one HTTP verb is required" }),
|
|
245
|
+
d.map(
|
|
246
|
+
function(u, N) {
|
|
247
|
+
return /* @__PURE__ */ o(
|
|
248
|
+
"span",
|
|
249
|
+
{
|
|
250
|
+
className: C(
|
|
251
|
+
"bg-grey-600 text-s mr-1 flex items-center rounded px-1 py-0.5 uppercase",
|
|
252
|
+
{
|
|
253
|
+
"bg-red-400": !c.includes(u)
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
...p({
|
|
257
|
+
selectedItem: u,
|
|
258
|
+
index: N
|
|
259
|
+
}),
|
|
260
|
+
children: [
|
|
261
|
+
u,
|
|
262
|
+
/* @__PURE__ */ e(
|
|
263
|
+
"span",
|
|
264
|
+
{
|
|
265
|
+
onClick: (P) => {
|
|
266
|
+
P.stopPropagation(), v(u);
|
|
267
|
+
},
|
|
268
|
+
className: "hover:bg-primary-hover ml-2 inline-block cursor-pointer rounded p-0.5 text-gray-100 hover:text-white active:outline-none",
|
|
269
|
+
children: /* @__PURE__ */ e(q, {})
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
`selected-item-${N}-${u}`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
),
|
|
278
|
+
/* @__PURE__ */ e(
|
|
279
|
+
"input",
|
|
280
|
+
{
|
|
281
|
+
...D(
|
|
282
|
+
b(
|
|
283
|
+
{ preventKeyAction: y },
|
|
284
|
+
{ suppressRefError: !0 }
|
|
285
|
+
)
|
|
286
|
+
),
|
|
287
|
+
className: "flex-grow border-none bg-transparent px-1 py-1 text-xs outline-none",
|
|
288
|
+
placeholder: d.length === 0 ? "Select HTTP verbs" : "",
|
|
289
|
+
size: 1
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
/* @__PURE__ */ e(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
className: "absolute inset-y-0 right-0 flex items-center pr-2",
|
|
296
|
+
type: "button",
|
|
297
|
+
...w(),
|
|
298
|
+
children: /* @__PURE__ */ e(K, { className: "h-3 w-3 text-gray-50", "aria-hidden": "true" })
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
/* @__PURE__ */ e(
|
|
305
|
+
"ul",
|
|
306
|
+
{
|
|
307
|
+
className: `ring-primary-dark bg-grey-900 text-s absolute z-10 w-full rounded-b ring-1 p-1 text-white ${!(y && l.length) && "hidden"}`,
|
|
308
|
+
...k(),
|
|
309
|
+
children: y && l.map((h, u) => /* @__PURE__ */ e(
|
|
310
|
+
"li",
|
|
311
|
+
{
|
|
312
|
+
className: C(
|
|
313
|
+
T === u && "bg-primary-hover",
|
|
314
|
+
R === h && "font-bold",
|
|
315
|
+
"flex flex-col p-1 shadow-sm"
|
|
316
|
+
),
|
|
317
|
+
...H({ item: h, index: u }),
|
|
318
|
+
children: /* @__PURE__ */ e("span", { children: h })
|
|
319
|
+
},
|
|
320
|
+
`${h}${u}`
|
|
321
|
+
))
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] });
|
|
325
|
+
}, et = ({
|
|
326
|
+
value: t,
|
|
327
|
+
options: a,
|
|
328
|
+
errorMessage: r = "",
|
|
329
|
+
onChange: i,
|
|
330
|
+
onBlur: c
|
|
331
|
+
}) => {
|
|
332
|
+
const [x, f] = _(""), g = a.find((n) => n.name === t), d = x === "" ? a : a.filter((n) => n.name.toLowerCase().includes(x.toLowerCase()));
|
|
333
|
+
return /* @__PURE__ */ e(
|
|
334
|
+
S,
|
|
335
|
+
{
|
|
336
|
+
value: { name: t },
|
|
337
|
+
onChange: (n) => i(n.name),
|
|
338
|
+
children: ({ open: n }) => /* @__PURE__ */ o("div", { className: "relative w-full", children: [
|
|
339
|
+
/* @__PURE__ */ o(
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
className: C(
|
|
343
|
+
"bg-grey-300 focus-within:ring-1 focus-within:ring-primary-dark relative w-full cursor-default overflow-hidden rounded text-left inline-flex",
|
|
344
|
+
{
|
|
345
|
+
"ring-1 ring-red-400": !g && t || r,
|
|
346
|
+
"ring-1 ring-primary-dark rounded-b-none": n,
|
|
347
|
+
"overflow-visible": !g && !n && r
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ e(
|
|
352
|
+
S.Input,
|
|
353
|
+
{
|
|
354
|
+
className: C(
|
|
355
|
+
"bg-grey-300 text-s w-full border-none py-1 px-2 focus:outline-none rounded",
|
|
356
|
+
{
|
|
357
|
+
"!text-red-400": !g
|
|
358
|
+
}
|
|
359
|
+
),
|
|
360
|
+
displayValue: (l) => l.name,
|
|
361
|
+
onChange: (l) => f(l.target.value),
|
|
362
|
+
style: { caretColor: "white" },
|
|
363
|
+
onBlur: c
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
/* @__PURE__ */ o("span", { className: "inset-y-0 right-0 flex items-center gap-1 pr-2", children: [
|
|
367
|
+
!g && !n && r && /* @__PURE__ */ e("div", { className: "absolute inset-x-0 top-[25px] z-[1] rounded-b-sm bg-red-200 px-1 text-xs text-red-600 ring-1 ring-red-600", children: r }),
|
|
368
|
+
t ? /* @__PURE__ */ o(G, { children: [
|
|
369
|
+
/* @__PURE__ */ e(
|
|
370
|
+
"button",
|
|
371
|
+
{
|
|
372
|
+
onClick: () => {
|
|
373
|
+
f(""), i("");
|
|
374
|
+
},
|
|
375
|
+
children: /* @__PURE__ */ e(
|
|
376
|
+
q,
|
|
377
|
+
{
|
|
378
|
+
className: "text-grey-50 h-3 w-3",
|
|
379
|
+
"aria-hidden": "true"
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
/* @__PURE__ */ e("span", { className: "bg-grey-50 h-3 w-[1px] rounded-full" })
|
|
385
|
+
] }) : null,
|
|
386
|
+
/* @__PURE__ */ e(S.Button, { children: /* @__PURE__ */ e(K, { className: "text-grey-50 h-3 w-3", "aria-hidden": "true" }) })
|
|
387
|
+
] })
|
|
388
|
+
]
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
/* @__PURE__ */ e(
|
|
392
|
+
le,
|
|
393
|
+
{
|
|
394
|
+
as: se,
|
|
395
|
+
leave: "transition ease-in durati pb-0.5on-100",
|
|
396
|
+
leaveFrom: "opacity-100",
|
|
397
|
+
leaveTo: "opacity-0",
|
|
398
|
+
afterLeave: () => f(""),
|
|
399
|
+
children: /* @__PURE__ */ e(S.Options, { className: "bg-grey-900 text-s text-grey-100 sm:text-s absolute z-50 max-h-60 w-full overflow-auto rounded-b ring-1 ring-primary-dark p-1 focus:outline-none", children: d.length === 0 ? /* @__PURE__ */ o("div", { className: "text-s text-grey-200 relative cursor-default select-none px-0.5 py-0.5 ", children: [
|
|
400
|
+
/* @__PURE__ */ e(J, { className: "inline h-4 w-4" }),
|
|
401
|
+
" Nothing found."
|
|
402
|
+
] }) : d.map((l, p) => /* @__PURE__ */ e(
|
|
403
|
+
S.Option,
|
|
404
|
+
{
|
|
405
|
+
className: ({ active: b }) => `relative cursor-default select-none ${b ? "bg-primary-hover" : ""}`,
|
|
406
|
+
value: l,
|
|
407
|
+
children: ({ selected: b }) => /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e(
|
|
408
|
+
"span",
|
|
409
|
+
{
|
|
410
|
+
className: `block truncate p-2 py-1 ${b ? "bg-primary-dark font-medium text-white" : "font-normal"}`,
|
|
411
|
+
children: l.name
|
|
412
|
+
}
|
|
413
|
+
) })
|
|
414
|
+
},
|
|
415
|
+
p
|
|
416
|
+
)) })
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] })
|
|
420
|
+
},
|
|
421
|
+
t
|
|
422
|
+
);
|
|
423
|
+
}, tt = ({
|
|
424
|
+
value: t,
|
|
425
|
+
options: a,
|
|
426
|
+
onChange: r,
|
|
427
|
+
errorMessage: i,
|
|
428
|
+
onBlur: c
|
|
429
|
+
}) => {
|
|
430
|
+
const [x, f] = _(""), g = a.find((l) => l.name === t), d = g && g.exposed, n = x === "" ? a : a.filter((l) => l.name.toLowerCase().includes(x.toLowerCase()));
|
|
431
|
+
return /* @__PURE__ */ e(S, { value: { name: t }, onChange: (l) => r(l.name), children: ({ open: l }) => /* @__PURE__ */ o("div", { className: "relative", children: [
|
|
432
|
+
/* @__PURE__ */ o(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
className: C(
|
|
436
|
+
"bg-grey-300 focus-within:ring-1 focus-within:ring-primary-dark relative w-full cursor-default overflow-hidden rounded text-left inline-flex",
|
|
437
|
+
{
|
|
438
|
+
"ring-1 ring-red-400": i,
|
|
439
|
+
"ring-1 ring-yellow-500": d,
|
|
440
|
+
"ring-1 ring-primary-dark rounded-b-none": l,
|
|
441
|
+
"overflow-visible": !l && i
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ e(
|
|
446
|
+
S.Input,
|
|
447
|
+
{
|
|
448
|
+
className: C(
|
|
449
|
+
"bg-grey-300 text-s w-full border-none py-1 px-2 focus:outline-none truncate rounded",
|
|
450
|
+
{
|
|
451
|
+
"!text-red-400": i,
|
|
452
|
+
"!text-yellow-500": d
|
|
453
|
+
}
|
|
454
|
+
),
|
|
455
|
+
style: { caretColor: "white" },
|
|
456
|
+
displayValue: (p) => p.name,
|
|
457
|
+
onChange: (p) => f(p.target.value),
|
|
458
|
+
onBlur: c
|
|
459
|
+
}
|
|
460
|
+
),
|
|
461
|
+
!l && i && /* @__PURE__ */ e(
|
|
462
|
+
"div",
|
|
463
|
+
{
|
|
464
|
+
className: C(
|
|
465
|
+
"absolute inset-x-0 top-[25px] z-[1] rounded-b-sm bg-red-200 px-1 text-xs text-red-600 ring-1 ring-red-600",
|
|
466
|
+
{ "!text-yellow-500 ring-yellow-500 bg-white": d }
|
|
467
|
+
),
|
|
468
|
+
children: i
|
|
469
|
+
}
|
|
470
|
+
),
|
|
471
|
+
/* @__PURE__ */ o("span", { className: "inset-y-0 right-0 flex items-center gap-1 pr-2", children: [
|
|
472
|
+
t ? /* @__PURE__ */ o(G, { children: [
|
|
473
|
+
/* @__PURE__ */ e(
|
|
474
|
+
"button",
|
|
475
|
+
{
|
|
476
|
+
onClick: () => {
|
|
477
|
+
f(""), r("");
|
|
478
|
+
},
|
|
479
|
+
children: /* @__PURE__ */ e(
|
|
480
|
+
q,
|
|
481
|
+
{
|
|
482
|
+
className: "text-grey-50 h-3 w-3",
|
|
483
|
+
"aria-hidden": "true"
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
),
|
|
488
|
+
/* @__PURE__ */ e("span", { className: "bg-grey-50 h-3 w-[1px] rounded-full" })
|
|
489
|
+
] }) : null,
|
|
490
|
+
/* @__PURE__ */ e(S.Button, { children: /* @__PURE__ */ e(K, { className: "text-grey-50 h-3 w-3", "aria-hidden": "true" }) })
|
|
491
|
+
] })
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
),
|
|
495
|
+
/* @__PURE__ */ e(
|
|
496
|
+
le,
|
|
497
|
+
{
|
|
498
|
+
as: se,
|
|
499
|
+
leave: "transition ease-in duration-100",
|
|
500
|
+
leaveFrom: "opacity-100",
|
|
501
|
+
leaveTo: "opacity-0",
|
|
502
|
+
afterLeave: () => f(""),
|
|
503
|
+
children: /* @__PURE__ */ e(S.Options, { className: "bg-grey-900 text-s text-grey-100 sm:text-s absolute z-50 max-h-60 w-full overflow-auto rounded-b ring-1 ring-primary-dark p-1 focus:outline-none", children: n.length ? n.map((p, b) => /* @__PURE__ */ e(
|
|
504
|
+
S.Option,
|
|
505
|
+
{
|
|
506
|
+
className: ({ active: v }) => `relative cursor-default select-none ${v ? "bg-primary-hover" : ""}`,
|
|
507
|
+
value: p,
|
|
508
|
+
children: ({ selected: v }) => /* @__PURE__ */ e(G, { children: /* @__PURE__ */ o(
|
|
509
|
+
"span",
|
|
510
|
+
{
|
|
511
|
+
className: `text-s flex items-center gap-2 truncate p-2 py-1 ${v ? "bg-primary-dark font-medium text-white" : "font-normal"}`,
|
|
512
|
+
children: [
|
|
513
|
+
p.exposed && /* @__PURE__ */ e(j, { className: "text-yellow-500" }),
|
|
514
|
+
/* @__PURE__ */ e("span", { className: "flex-1 truncate", title: p.name, children: p.name })
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
) })
|
|
518
|
+
},
|
|
519
|
+
b
|
|
520
|
+
)) : /* @__PURE__ */ o("div", { className: "text-s text-grey-200 relative cursor-default select-none px-0.5 py-0.5", children: [
|
|
521
|
+
/* @__PURE__ */ e(J, { className: "inline h-4 w-4" }),
|
|
522
|
+
" Nothing found."
|
|
523
|
+
] }) })
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
] }) });
|
|
527
|
+
}, pe = ({ listeners: t, attributes: a }) => /* @__PURE__ */ e("button", { ...a, ...t, children: /* @__PURE__ */ e(ke, {}) }), ue = (t) => {
|
|
528
|
+
var r;
|
|
529
|
+
if (!t) return "";
|
|
530
|
+
let a;
|
|
531
|
+
Z.prototype.max = 8;
|
|
532
|
+
try {
|
|
533
|
+
a = (r = new Z(t)) == null ? void 0 : r.gen();
|
|
534
|
+
} catch {
|
|
535
|
+
a = "";
|
|
536
|
+
}
|
|
537
|
+
return `Requests matching regex will be handled example: ${a}`;
|
|
538
|
+
}, nt = ({
|
|
539
|
+
id: t,
|
|
540
|
+
class: a,
|
|
541
|
+
method: r,
|
|
542
|
+
pattern: i,
|
|
543
|
+
verbs: c,
|
|
544
|
+
regexPattern: x,
|
|
545
|
+
asRegex: f,
|
|
546
|
+
listeners: g,
|
|
547
|
+
attributes: d
|
|
548
|
+
}) => {
|
|
549
|
+
var P;
|
|
550
|
+
const [n, l] = _({
|
|
551
|
+
className: a,
|
|
552
|
+
method: r,
|
|
553
|
+
pattern: i,
|
|
554
|
+
verbs: c,
|
|
555
|
+
asRegex: f,
|
|
556
|
+
regexPattern: x
|
|
557
|
+
}), p = W(re), b = Object.values((p == null ? void 0 : p.singletons) || {}), v = (P = b.find((s) => s.name === n.className)) == null ? void 0 : P.methods.map(({ name: s, exposed: m }) => ({ name: s, exposed: m })), {
|
|
558
|
+
dispatch: y,
|
|
559
|
+
state: { newlyCreatedHandlerID: w }
|
|
560
|
+
} = Q(), k = B();
|
|
561
|
+
function D() {
|
|
562
|
+
const { className: s, method: m, asRegex: I, regexPattern: U, pattern: z, verbs: M } = n;
|
|
563
|
+
return !!(s && m && (I ? U : !z.endsWith("/")) && M.length);
|
|
564
|
+
}
|
|
565
|
+
function T() {
|
|
566
|
+
if (D()) {
|
|
567
|
+
const { className: s, method: m, asRegex: I, regexPattern: U, pattern: z, verbs: M } = n;
|
|
568
|
+
y({
|
|
569
|
+
type: "UPDATE_HANDLER",
|
|
570
|
+
id: t,
|
|
571
|
+
payload: {
|
|
572
|
+
class: s,
|
|
573
|
+
method: m,
|
|
574
|
+
verbs: M,
|
|
575
|
+
asRegex: I,
|
|
576
|
+
...I ? { regexPattern: U } : { pattern: z }
|
|
577
|
+
}
|
|
578
|
+
}), y({ type: "SET_EDITING_HANDLER", payload: null });
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
const H = async () => {
|
|
582
|
+
const s = {
|
|
583
|
+
className: a,
|
|
584
|
+
method: r,
|
|
585
|
+
pattern: i,
|
|
586
|
+
regexPattern: x,
|
|
587
|
+
verbs: c
|
|
588
|
+
}, m = de(n, ["id", "isExpanded"]);
|
|
589
|
+
if (!D()) {
|
|
590
|
+
y({ type: "DELETE_HANDLER", id: `${w}` }), y({ type: "SET_EDITING_HANDLER", payload: null });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (!Je(s, m)) {
|
|
594
|
+
const { confirmed: I } = await k(
|
|
595
|
+
ae({
|
|
596
|
+
title: "Cancel Changes",
|
|
597
|
+
type: oe.CONFIRM,
|
|
598
|
+
color: ie.DANGER,
|
|
599
|
+
message: "Are you sure you want to cancel changes made to this Handler?",
|
|
600
|
+
icon: "FdWarningDanger"
|
|
601
|
+
})
|
|
602
|
+
).unwrap();
|
|
603
|
+
if (I) {
|
|
604
|
+
w === t && y({ type: "DELETE_HANDLER", id: t }), y({ type: "SET_EDITING_HANDLER", payload: null });
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
Me(
|
|
610
|
+
"esc",
|
|
611
|
+
() => {
|
|
612
|
+
setTimeout(() => {
|
|
613
|
+
H();
|
|
614
|
+
}, 100);
|
|
615
|
+
},
|
|
616
|
+
[]
|
|
617
|
+
), O(() => {
|
|
618
|
+
$.subscribe((s) => {
|
|
619
|
+
s === t && T();
|
|
620
|
+
});
|
|
621
|
+
}, [n, t]);
|
|
622
|
+
const [R, h] = _({ className: !1, method: !1, pattern: !1, verbs: !1 }), u = () => {
|
|
623
|
+
if (R.method && !n.method)
|
|
624
|
+
return "Method is required";
|
|
625
|
+
if (v) {
|
|
626
|
+
const s = v == null ? void 0 : v.find(
|
|
627
|
+
(m) => m.name === n.method
|
|
628
|
+
);
|
|
629
|
+
if (n.method && !s)
|
|
630
|
+
return `The method "${n.method}" doesn't exist.`;
|
|
631
|
+
if (s && s.exposed)
|
|
632
|
+
return `Method "${n.method}" is already exposed`;
|
|
633
|
+
}
|
|
634
|
+
}, N = () => {
|
|
635
|
+
if (R.pattern) {
|
|
636
|
+
if (n.asRegex && !n.regexPattern)
|
|
637
|
+
return "Pattern is required";
|
|
638
|
+
if (!n.asRegex && n.pattern.endsWith("/"))
|
|
639
|
+
return 'Pattern should not end with a "/"';
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
return /* @__PURE__ */ o("div", { className: "flex items-center gap-2 rounded-b py-2", children: [
|
|
643
|
+
/* @__PURE__ */ o("div", { className: "flex w-60 flex-shrink-0 items-center gap-1", children: [
|
|
644
|
+
/* @__PURE__ */ e(
|
|
645
|
+
pe,
|
|
646
|
+
{
|
|
647
|
+
listeners: g,
|
|
648
|
+
attributes: d
|
|
649
|
+
},
|
|
650
|
+
"grab-handle"
|
|
651
|
+
),
|
|
652
|
+
/* @__PURE__ */ e(
|
|
653
|
+
et,
|
|
654
|
+
{
|
|
655
|
+
value: n.className,
|
|
656
|
+
onChange: (s) => {
|
|
657
|
+
l((m) => ({ ...m, className: s }));
|
|
658
|
+
},
|
|
659
|
+
onBlur: () => h((s) => ({ ...s, className: !0 })),
|
|
660
|
+
options: b,
|
|
661
|
+
errorMessage: R.className && !n.className ? "Class name is required" : n.className !== "" && !b.find((s) => s.name === n.className) ? `The singleton "${n.className}" doesn't exist.` : void 0
|
|
662
|
+
},
|
|
663
|
+
a
|
|
664
|
+
)
|
|
665
|
+
] }),
|
|
666
|
+
/* @__PURE__ */ e("div", { className: "w-60 flex-shrink-0", children: /* @__PURE__ */ e(
|
|
667
|
+
tt,
|
|
668
|
+
{
|
|
669
|
+
value: n.method,
|
|
670
|
+
onChange: (s) => {
|
|
671
|
+
l((m) => ({ ...m, method: s }));
|
|
672
|
+
},
|
|
673
|
+
options: v || [],
|
|
674
|
+
errorMessage: u(),
|
|
675
|
+
onBlur: () => h((s) => ({ ...s, method: !0 }))
|
|
676
|
+
}
|
|
677
|
+
) }),
|
|
678
|
+
/* @__PURE__ */ o("div", { className: "relative w-60 flex-shrink-0 flex items-center gap-1 overflow-visible", children: [
|
|
679
|
+
/* @__PURE__ */ e(
|
|
680
|
+
E,
|
|
681
|
+
{
|
|
682
|
+
label: n.asRegex ? ue(n.regexPattern) : n.pattern && !n.pattern.endsWith("/") ? `Requests starting with /${n.pattern}/ will be handled` : "",
|
|
683
|
+
children: /* @__PURE__ */ o("div", { className: "relative w-full", children: [
|
|
684
|
+
!n.asRegex && /* @__PURE__ */ e("span", { className: "absolute text-s inset-y-0 left-1 flex items-center gap-2", children: "/" }),
|
|
685
|
+
/* @__PURE__ */ e(
|
|
686
|
+
"input",
|
|
687
|
+
{
|
|
688
|
+
type: "text",
|
|
689
|
+
className: C(
|
|
690
|
+
"bg-grey-300 text-s block w-full rounded p-1 pl-3 focus:outline-none focus:ring-1 focus:ring-primary-dark",
|
|
691
|
+
{
|
|
692
|
+
"focus:ring-red-400 ring-1 ring-red-400": R.pattern && n.asRegex && !n.regexPattern
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
value: n.asRegex ? n.regexPattern : n.pattern,
|
|
696
|
+
onChange: (s) => {
|
|
697
|
+
l((m) => ({
|
|
698
|
+
...m,
|
|
699
|
+
[n.asRegex ? "regexPattern" : "pattern"]: s.target.value
|
|
700
|
+
}));
|
|
701
|
+
},
|
|
702
|
+
onBlur: () => h((s) => ({ ...s, pattern: !0 })),
|
|
703
|
+
placeholder: n.asRegex ? "Required" : ""
|
|
704
|
+
}
|
|
705
|
+
),
|
|
706
|
+
N() && /* @__PURE__ */ e("div", { className: "absolute inset-x-0 top-[25px] z-[1] rounded-b-sm bg-red-200 px-1 text-xs text-red-600 ring-1 ring-red-600", children: N() })
|
|
707
|
+
] })
|
|
708
|
+
}
|
|
709
|
+
),
|
|
710
|
+
(f ? x : i) && /* @__PURE__ */ e(
|
|
711
|
+
"button",
|
|
712
|
+
{
|
|
713
|
+
onClick: (s) => {
|
|
714
|
+
s.stopPropagation(), l((m) => ({
|
|
715
|
+
...m,
|
|
716
|
+
[n.asRegex ? "regexPattern" : "pattern"]: ""
|
|
717
|
+
}));
|
|
718
|
+
},
|
|
719
|
+
className: "absolute inset-y-0 right-6 flex items-center gap-2 pr-2",
|
|
720
|
+
children: /* @__PURE__ */ e(
|
|
721
|
+
q,
|
|
722
|
+
{
|
|
723
|
+
className: "text-grey-200 h-3 w-3",
|
|
724
|
+
"aria-hidden": "true"
|
|
725
|
+
}
|
|
726
|
+
)
|
|
727
|
+
}
|
|
728
|
+
),
|
|
729
|
+
/* @__PURE__ */ e(
|
|
730
|
+
E,
|
|
731
|
+
{
|
|
732
|
+
label: n.asRegex ? "Requests matching this regex will be handled. Check the match with the __[Match regex command](https://developer.4d.com/docs/commands/match-regex)__" : `Prefixes are considered as regular expressions already containing starting and ending /
|
|
733
|
+
|
|
734
|
+
__[documentation](https://developer.qodly.com/docs/studio/httpHandlers)__`,
|
|
735
|
+
children: /* @__PURE__ */ e("span", { className: "rounded hover:bg-gray-400/30 w-6 h-6 flex items-center content-center justify-center", children: /* @__PURE__ */ e(ne, { className: "inline h-4 w-4 text-gray-100" }) })
|
|
736
|
+
}
|
|
737
|
+
)
|
|
738
|
+
] }),
|
|
739
|
+
/* @__PURE__ */ e("div", { className: "w-20 px-2 flex justify-center", children: /* @__PURE__ */ e(
|
|
740
|
+
Ve,
|
|
741
|
+
{
|
|
742
|
+
value: !!n.asRegex,
|
|
743
|
+
onChange: (s) => {
|
|
744
|
+
const m = s ? { regexPattern: i, asRegex: s } : { pattern: x, asRegex: s };
|
|
745
|
+
l((I) => ({ ...I, ...m }));
|
|
746
|
+
},
|
|
747
|
+
className: `${n.asRegex ? "bg-primary-dark" : "bg-grey-300"}
|
|
748
|
+
relative inline-flex h-5 w-8 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75`,
|
|
749
|
+
children: /* @__PURE__ */ e(
|
|
750
|
+
"span",
|
|
751
|
+
{
|
|
752
|
+
"aria-hidden": "true",
|
|
753
|
+
className: `${n.asRegex ? "translate-x-3" : "translate-x-0"}
|
|
754
|
+
pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white ring-0 transition duration-200 ease-in-out`
|
|
755
|
+
}
|
|
756
|
+
)
|
|
757
|
+
}
|
|
758
|
+
) }),
|
|
759
|
+
/* @__PURE__ */ o("div", { className: "flex flex-1 items-center", children: [
|
|
760
|
+
/* @__PURE__ */ e(
|
|
761
|
+
Ze,
|
|
762
|
+
{
|
|
763
|
+
initialSelectedItems: n.verbs || [],
|
|
764
|
+
onChange: (s) => {
|
|
765
|
+
l((m) => ({ ...m, verbs: s }));
|
|
766
|
+
},
|
|
767
|
+
touched: R.verbs,
|
|
768
|
+
onBlur: () => h((s) => ({ ...s, verbs: !0 }))
|
|
769
|
+
}
|
|
770
|
+
),
|
|
771
|
+
/* @__PURE__ */ o("div", { className: "flex items-center gap-0.5 px-2", children: [
|
|
772
|
+
/* @__PURE__ */ e(E, { label: "Duplicate Handler", className: "px-1 py-3", children: /* @__PURE__ */ e(
|
|
773
|
+
"button",
|
|
774
|
+
{
|
|
775
|
+
className: C(
|
|
776
|
+
"hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none opacity-50 cursor-not-allowed"
|
|
777
|
+
),
|
|
778
|
+
children: /* @__PURE__ */ e(te, {})
|
|
779
|
+
}
|
|
780
|
+
) }),
|
|
781
|
+
/* @__PURE__ */ e(E, { label: "Confirm Changes", className: "px-1 py-3", children: /* @__PURE__ */ e(
|
|
782
|
+
"button",
|
|
783
|
+
{
|
|
784
|
+
className: C(
|
|
785
|
+
"hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none",
|
|
786
|
+
{
|
|
787
|
+
"opacity-50 cursor-not-allowed": !D()
|
|
788
|
+
}
|
|
789
|
+
),
|
|
790
|
+
onClick: T,
|
|
791
|
+
children: /* @__PURE__ */ e(Pe, {})
|
|
792
|
+
}
|
|
793
|
+
) }),
|
|
794
|
+
/* @__PURE__ */ e(E, { label: "Cancel Changes", className: "px-1 py-3", children: /* @__PURE__ */ e(
|
|
795
|
+
"button",
|
|
796
|
+
{
|
|
797
|
+
className: "hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none",
|
|
798
|
+
onClick: H,
|
|
799
|
+
children: /* @__PURE__ */ e(Se, {})
|
|
800
|
+
}
|
|
801
|
+
) })
|
|
802
|
+
] })
|
|
803
|
+
] })
|
|
804
|
+
] });
|
|
805
|
+
}, ee = ({
|
|
806
|
+
id: t,
|
|
807
|
+
class: a,
|
|
808
|
+
method: r,
|
|
809
|
+
pattern: i,
|
|
810
|
+
verbs: c,
|
|
811
|
+
isExpanded: x,
|
|
812
|
+
regexPattern: f,
|
|
813
|
+
asRegex: g
|
|
814
|
+
}) => {
|
|
815
|
+
var P;
|
|
816
|
+
const { attributes: d, listeners: n, setNodeRef: l, transform: p, transition: b } = ve({ id: t }), v = {
|
|
817
|
+
transform: ze.Transform.toString(p),
|
|
818
|
+
transition: b
|
|
819
|
+
}, {
|
|
820
|
+
dispatch: y,
|
|
821
|
+
state: { editing: w }
|
|
822
|
+
} = Q(), k = B(), D = g ? f : i, T = W(re), H = Object.values((T == null ? void 0 : T.singletons) || {}), R = (P = H == null ? void 0 : H.find((s) => s.name === a)) == null ? void 0 : P.methods.map(({ name: s, exposed: m }) => ({ name: s, exposed: m })), h = H == null ? void 0 : H.find(
|
|
823
|
+
(s) => s.name === a
|
|
824
|
+
), u = R == null ? void 0 : R.find((s) => s.name === r), N = u && u.exposed;
|
|
825
|
+
return /* @__PURE__ */ e("div", { className: "odd:bg-grey-500", ref: l, style: v, children: w === t ? /* @__PURE__ */ e(
|
|
826
|
+
nt,
|
|
827
|
+
{
|
|
828
|
+
id: t,
|
|
829
|
+
class: a,
|
|
830
|
+
method: r,
|
|
831
|
+
pattern: i,
|
|
832
|
+
verbs: c,
|
|
833
|
+
isExpanded: x,
|
|
834
|
+
regexPattern: f,
|
|
835
|
+
asRegex: g,
|
|
836
|
+
listeners: n,
|
|
837
|
+
attributes: d
|
|
838
|
+
}
|
|
839
|
+
) : /* @__PURE__ */ o(
|
|
840
|
+
"div",
|
|
841
|
+
{
|
|
842
|
+
className: "flex items-center gap-2 rounded-b py-2.5 text-grey-50",
|
|
843
|
+
onDoubleClick: () => {
|
|
844
|
+
$.next(w), y({ type: "SET_EDITING_HANDLER", payload: t });
|
|
845
|
+
},
|
|
846
|
+
children: [
|
|
847
|
+
/* @__PURE__ */ o("div", { className: "flex w-60 flex-shrink-0 items-center gap-1 ", children: [
|
|
848
|
+
/* @__PURE__ */ e(
|
|
849
|
+
pe,
|
|
850
|
+
{
|
|
851
|
+
listeners: n,
|
|
852
|
+
attributes: d
|
|
853
|
+
},
|
|
854
|
+
"grab-handle"
|
|
855
|
+
),
|
|
856
|
+
/* @__PURE__ */ e("div", { className: "text-s w-full", children: a ? /* @__PURE__ */ o(
|
|
857
|
+
"div",
|
|
858
|
+
{
|
|
859
|
+
className: C(
|
|
860
|
+
"flex items-center gap-2",
|
|
861
|
+
!h && "text-red-400"
|
|
862
|
+
),
|
|
863
|
+
children: [
|
|
864
|
+
!h && /* @__PURE__ */ e(
|
|
865
|
+
E,
|
|
866
|
+
{
|
|
867
|
+
label: `The singleton "${a}" doesn't exist.`,
|
|
868
|
+
className: "!bg-red-300 !text-red-400",
|
|
869
|
+
children: /* @__PURE__ */ e("span", { className: "rounded p-0.5 hover:bg-red-400/30 pt-0.5 h-5 w-5 flex justify-center content-center", children: /* @__PURE__ */ e(j, { className: "inline h-4 w-4 pb-0.5 text-red-400" }) })
|
|
870
|
+
}
|
|
871
|
+
),
|
|
872
|
+
" ",
|
|
873
|
+
a
|
|
874
|
+
]
|
|
875
|
+
}
|
|
876
|
+
) : /* @__PURE__ */ e("span", { className: "text-grey-200 italic", children: "undefined" }) })
|
|
877
|
+
] }),
|
|
878
|
+
/* @__PURE__ */ e("div", { className: "w-60 flex-shrink-0 ", children: /* @__PURE__ */ e("div", { className: "text-s w-full", children: r ? /* @__PURE__ */ o(
|
|
879
|
+
"div",
|
|
880
|
+
{
|
|
881
|
+
className: C(
|
|
882
|
+
"flex items-center gap-2",
|
|
883
|
+
!u && "text-red-400",
|
|
884
|
+
N && "text-yellow-400"
|
|
885
|
+
),
|
|
886
|
+
children: [
|
|
887
|
+
!u && /* @__PURE__ */ e(
|
|
888
|
+
E,
|
|
889
|
+
{
|
|
890
|
+
label: `The method "${r}" doesn't exist.`,
|
|
891
|
+
className: "!bg-red-300 !text-red-400",
|
|
892
|
+
children: /* @__PURE__ */ e("span", { className: "rounded p-0.5 hover:bg-red-400/30 pt-0.5 h-5 w-5 flex justify-center content-center", children: /* @__PURE__ */ e(j, { className: "inline h-4 w-4 pb-0.5 text-red-400" }) })
|
|
893
|
+
}
|
|
894
|
+
),
|
|
895
|
+
" ",
|
|
896
|
+
N && /* @__PURE__ */ e(
|
|
897
|
+
E,
|
|
898
|
+
{
|
|
899
|
+
label: `Method "${r}" is already exposed`,
|
|
900
|
+
className: "!bg-yellow-100 !text-yellow-500",
|
|
901
|
+
children: /* @__PURE__ */ e("span", { className: "rounded p-0.5 hover:bg-red-400/30 pt-0.5 h-5 w-5 flex justify-center content-center", children: /* @__PURE__ */ e(j, { className: "inline h-4 w-4 pb-0.5 text-yellow-500" }) })
|
|
902
|
+
}
|
|
903
|
+
),
|
|
904
|
+
" ",
|
|
905
|
+
r
|
|
906
|
+
]
|
|
907
|
+
}
|
|
908
|
+
) : /* @__PURE__ */ e("span", { className: "text-grey-200 italic", children: "undefined" }) }) }),
|
|
909
|
+
/* @__PURE__ */ e("div", { className: "text-s relative w-60 flex-shrink-0 ", children: D ? /* @__PURE__ */ e(
|
|
910
|
+
E,
|
|
911
|
+
{
|
|
912
|
+
label: g ? ue(D) : `Requests starting with /${D}/ will be handled`,
|
|
913
|
+
children: /* @__PURE__ */ e("span", { children: D })
|
|
914
|
+
}
|
|
915
|
+
) : /* @__PURE__ */ e("span", { className: "text-grey-200 italic", children: "/" }) }),
|
|
916
|
+
/* @__PURE__ */ e("div", { className: "px-5 w-20 flex justify-center text-grey-200", children: g ? /* @__PURE__ */ e(De, {}) : /* @__PURE__ */ e(Te, {}) }),
|
|
917
|
+
/* @__PURE__ */ o("div", { className: "flex flex-1 items-center", children: [
|
|
918
|
+
/* @__PURE__ */ e("div", { className: "text-s w-full", children: c.length ? c.join(",") : /* @__PURE__ */ e("span", { className: "text-grey-200 italic", children: "undefined" }) }),
|
|
919
|
+
/* @__PURE__ */ o("div", { className: "flex items-center gap-0.5 px-2", children: [
|
|
920
|
+
/* @__PURE__ */ e(E, { label: "Duplicate Handler", className: "px-1 py-3", children: /* @__PURE__ */ e(
|
|
921
|
+
"button",
|
|
922
|
+
{
|
|
923
|
+
className: "hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none",
|
|
924
|
+
onClick: () => y({ type: "DUPLICATE_HANDLER", id: t }),
|
|
925
|
+
children: /* @__PURE__ */ e(te, {})
|
|
926
|
+
}
|
|
927
|
+
) }),
|
|
928
|
+
/* @__PURE__ */ e(E, { label: "Edit Handler", className: "px-1 py-3", children: /* @__PURE__ */ e(
|
|
929
|
+
"button",
|
|
930
|
+
{
|
|
931
|
+
className: "hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none",
|
|
932
|
+
onClick: () => {
|
|
933
|
+
$.next(w), y({ type: "SET_EDITING_HANDLER", payload: t });
|
|
934
|
+
},
|
|
935
|
+
children: /* @__PURE__ */ e(He, {})
|
|
936
|
+
}
|
|
937
|
+
) }),
|
|
938
|
+
/* @__PURE__ */ e(E, { label: "Delete Handler", className: "px-1 py-3", placement: "top-end", children: /* @__PURE__ */ e(
|
|
939
|
+
"button",
|
|
940
|
+
{
|
|
941
|
+
className: "hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none",
|
|
942
|
+
onClick: async () => {
|
|
943
|
+
const { confirmed: s } = await k(
|
|
944
|
+
ae({
|
|
945
|
+
title: "Delete Handler",
|
|
946
|
+
type: oe.CONFIRM,
|
|
947
|
+
color: ie.DANGER,
|
|
948
|
+
message: "Are you sure you want to remove this Handler?",
|
|
949
|
+
icon: "FdWarningDanger"
|
|
950
|
+
})
|
|
951
|
+
).unwrap();
|
|
952
|
+
s && y({ type: "DELETE_HANDLER", id: t });
|
|
953
|
+
},
|
|
954
|
+
children: /* @__PURE__ */ e(Re, {})
|
|
955
|
+
}
|
|
956
|
+
) })
|
|
957
|
+
] })
|
|
958
|
+
] })
|
|
959
|
+
]
|
|
960
|
+
}
|
|
961
|
+
) });
|
|
962
|
+
}, rt = A.object({
|
|
963
|
+
class: A.string().optional(),
|
|
964
|
+
method: A.string().optional(),
|
|
965
|
+
verbs: A.string().optional(),
|
|
966
|
+
id: A.string().optional(),
|
|
967
|
+
pattern: A.string().optional(),
|
|
968
|
+
regexPattern: A.string().optional()
|
|
969
|
+
}), at = A.array(rt), st = ({ path: t }) => {
|
|
970
|
+
const a = W(_e(t)), {
|
|
971
|
+
dispatch: r,
|
|
972
|
+
state: { content: i, editing: c }
|
|
973
|
+
} = Q(), x = me(
|
|
974
|
+
X(ge),
|
|
975
|
+
X(xe, {
|
|
976
|
+
coordinateGetter: Ne
|
|
977
|
+
})
|
|
978
|
+
), [f, g] = _(null), d = i.find((l) => l.id === f), n = B();
|
|
979
|
+
return O(() => {
|
|
980
|
+
const l = JSON.stringify(
|
|
981
|
+
i.map(
|
|
982
|
+
({ isExpanded: b, asRegex: v, pattern: y, regexPattern: w, ...k }) => {
|
|
983
|
+
var T;
|
|
984
|
+
const D = v ? { regexPattern: w } : { pattern: y };
|
|
985
|
+
return {
|
|
986
|
+
...k,
|
|
987
|
+
verbs: (T = k.verbs) == null ? void 0 : T.join(","),
|
|
988
|
+
...D
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
null,
|
|
993
|
+
2
|
|
994
|
+
), p = typeof (a == null ? void 0 : a.content) == "string" ? a.content : JSON.stringify(a == null ? void 0 : a.content, null, 2);
|
|
995
|
+
l !== p && n(
|
|
996
|
+
Le({
|
|
997
|
+
path: t,
|
|
998
|
+
content: l
|
|
999
|
+
})
|
|
1000
|
+
);
|
|
1001
|
+
}, [i]), /* @__PURE__ */ o("div", { className: "bg-grey-700 flex h-full w-full flex-col text-white", children: [
|
|
1002
|
+
/* @__PURE__ */ o("div", { className: "flex items-center justify-between border-b border-black p-2", children: [
|
|
1003
|
+
a && /* @__PURE__ */ e(
|
|
1004
|
+
Qe,
|
|
1005
|
+
{
|
|
1006
|
+
label: "Switch to text Editor",
|
|
1007
|
+
Icon: Ie,
|
|
1008
|
+
tab: a,
|
|
1009
|
+
editor: {
|
|
1010
|
+
config: { language: "json" },
|
|
1011
|
+
key: "editors:code"
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
),
|
|
1015
|
+
/* @__PURE__ */ o("p", { className: "text-grey-100 text-s flex items-center gap-1", children: [
|
|
1016
|
+
/* @__PURE__ */ e(ne, { className: "inline text-base text-white" }),
|
|
1017
|
+
" HTTP handlers are evaluated in the order they are declared"
|
|
1018
|
+
] })
|
|
1019
|
+
] }),
|
|
1020
|
+
/* @__PURE__ */ e("div", { className: "mt-1 flex flex-1 flex-col overflow-x-auto px-4", children: i.length ? /* @__PURE__ */ o("div", { className: "flex h-full min-w-[1200px] flex-1 flex-col", children: [
|
|
1021
|
+
/* @__PURE__ */ o("div", { className: "mb-3 flex items-center gap-2 border-b", children: [
|
|
1022
|
+
/* @__PURE__ */ e("div", { className: "w-60 flex-shrink-0 text-xs", children: /* @__PURE__ */ e("span", { className: "pl-6", children: "Class" }) }),
|
|
1023
|
+
/* @__PURE__ */ e("div", { className: "w-60 flex-shrink-0 text-xs", children: "Method" }),
|
|
1024
|
+
/* @__PURE__ */ e("div", { className: "w-60 flex-shrink-0 text-xs", children: "Pattern" }),
|
|
1025
|
+
/* @__PURE__ */ e("div", { className: "w-20 px-2 text-center text-xs", children: "As Regex" }),
|
|
1026
|
+
/* @__PURE__ */ o("div", { className: "flex flex-1 items-center justify-between text-xs", children: [
|
|
1027
|
+
/* @__PURE__ */ e("span", { children: "Verbs" }),
|
|
1028
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-2xl", children: /* @__PURE__ */ e(E, { label: "Add a new HTTP Handler", children: /* @__PURE__ */ e(
|
|
1029
|
+
"button",
|
|
1030
|
+
{
|
|
1031
|
+
disabled: !!c,
|
|
1032
|
+
onClick: () => {
|
|
1033
|
+
$.next(c), r({
|
|
1034
|
+
type: "ADD_HANDLER",
|
|
1035
|
+
payload: {
|
|
1036
|
+
class: "",
|
|
1037
|
+
isExpanded: !0,
|
|
1038
|
+
method: "",
|
|
1039
|
+
pattern: "",
|
|
1040
|
+
verbs: [],
|
|
1041
|
+
regexPattern: ""
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
},
|
|
1045
|
+
className: "hover:bg-primary-hover rounded p-1 text-gray-100 hover:text-white active:outline-none disabled:cursor-not-allowed disabled:opacity-30",
|
|
1046
|
+
children: /* @__PURE__ */ e(Y, { className: "h-5 w-5" })
|
|
1047
|
+
}
|
|
1048
|
+
) }) })
|
|
1049
|
+
] })
|
|
1050
|
+
] }),
|
|
1051
|
+
/* @__PURE__ */ e("div", { className: "py-3", children: /* @__PURE__ */ o(
|
|
1052
|
+
fe,
|
|
1053
|
+
{
|
|
1054
|
+
sensors: x,
|
|
1055
|
+
collisionDetection: ye,
|
|
1056
|
+
onDragStart: (l) => {
|
|
1057
|
+
g(l.active.id);
|
|
1058
|
+
},
|
|
1059
|
+
onDragEnd: (l) => {
|
|
1060
|
+
const { active: p, over: b } = l;
|
|
1061
|
+
if (g(null), !(!p || !b) && p.id !== (b == null ? void 0 : b.id)) {
|
|
1062
|
+
const v = i.map((w) => w.id).indexOf(p.id), y = i.map((w) => w.id).indexOf(b.id);
|
|
1063
|
+
r({
|
|
1064
|
+
type: "UPDATE_HANDLERS",
|
|
1065
|
+
payload: Ce(i, v, y)
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
children: [
|
|
1070
|
+
/* @__PURE__ */ e(
|
|
1071
|
+
we,
|
|
1072
|
+
{
|
|
1073
|
+
items: i,
|
|
1074
|
+
strategy: Ee,
|
|
1075
|
+
children: i.map(({ id: l, ...p }) => /* @__PURE__ */ e(ee, { id: l, ...p }, l))
|
|
1076
|
+
}
|
|
1077
|
+
),
|
|
1078
|
+
/* @__PURE__ */ e(be, { children: f && d ? /* @__PURE__ */ e("div", { className: "opacity-10", children: /* @__PURE__ */ e(ee, { ...d }) }) : null })
|
|
1079
|
+
]
|
|
1080
|
+
}
|
|
1081
|
+
) })
|
|
1082
|
+
] }) : /* @__PURE__ */ o("div", { className: "mt-6", children: [
|
|
1083
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(J, { className: "text-grey-200 mx-auto h-9 w-9" }) }),
|
|
1084
|
+
/* @__PURE__ */ o("div", { className: "text-s text-grey-200 mx-auto mt-3 max-w-sm text-center", children: [
|
|
1085
|
+
"There are no http handlers configured yet ",
|
|
1086
|
+
/* @__PURE__ */ e("br", {}),
|
|
1087
|
+
"Please add a new one to add a new one."
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ e("div", { className: "mt-3 flex items-center justify-center", children: /* @__PURE__ */ o(
|
|
1090
|
+
"button",
|
|
1091
|
+
{
|
|
1092
|
+
onClick: () => {
|
|
1093
|
+
$.next(c), r({
|
|
1094
|
+
type: "ADD_HANDLER",
|
|
1095
|
+
payload: {
|
|
1096
|
+
class: "",
|
|
1097
|
+
isExpanded: !0,
|
|
1098
|
+
method: "",
|
|
1099
|
+
pattern: "",
|
|
1100
|
+
verbs: [],
|
|
1101
|
+
regexPattern: ""
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
1104
|
+
},
|
|
1105
|
+
className: "bg-primary-dark text-s rounded px-2 py-1 flex items-center gap-1",
|
|
1106
|
+
children: [
|
|
1107
|
+
/* @__PURE__ */ e(Y, { className: "inline text-white h-4 w-4" }),
|
|
1108
|
+
" Add New Handler"
|
|
1109
|
+
]
|
|
1110
|
+
}
|
|
1111
|
+
) })
|
|
1112
|
+
] }) })
|
|
1113
|
+
] });
|
|
1114
|
+
}, lt = ({ content: t, path: a }) => {
|
|
1115
|
+
const [r, i] = _(null);
|
|
1116
|
+
function c(d) {
|
|
1117
|
+
let n;
|
|
1118
|
+
try {
|
|
1119
|
+
n = JSON.parse(d);
|
|
1120
|
+
} catch {
|
|
1121
|
+
i("HTTP Handler JSON is invalid"), n = [];
|
|
1122
|
+
}
|
|
1123
|
+
return n;
|
|
1124
|
+
}
|
|
1125
|
+
const x = typeof t == "string" ? c(t) : t;
|
|
1126
|
+
if (!at.safeParse(x).success || r)
|
|
1127
|
+
throw new Error("Invalid JSON");
|
|
1128
|
+
const g = x.map((d) => {
|
|
1129
|
+
var l;
|
|
1130
|
+
const n = !!d.regexPattern;
|
|
1131
|
+
return {
|
|
1132
|
+
...d,
|
|
1133
|
+
id: d.id ?? V(),
|
|
1134
|
+
verbs: (l = d.verbs) == null ? void 0 : l.split(",").map((p) => p.toLocaleUpperCase()).filter(Boolean),
|
|
1135
|
+
asRegex: n
|
|
1136
|
+
};
|
|
1137
|
+
});
|
|
1138
|
+
return /* @__PURE__ */ e(he, { theme: je, children: /* @__PURE__ */ e(Ye, { content: g, children: /* @__PURE__ */ e(st, { path: a }) }) });
|
|
1139
|
+
}, Tt = (t) => /* @__PURE__ */ e(Fe, { store: Oe(), children: /* @__PURE__ */ e("div", { className: "h-screen bg-grey-900", children: /* @__PURE__ */ e(
|
|
1140
|
+
lt,
|
|
1141
|
+
{
|
|
1142
|
+
path: Ke,
|
|
1143
|
+
...t
|
|
1144
|
+
}
|
|
1145
|
+
) }) });
|
|
1146
|
+
export {
|
|
1147
|
+
lt as HTTPHandlersEditor,
|
|
1148
|
+
Tt as Standalone
|
|
1149
|
+
};
|
|
1150
|
+
//# sourceMappingURL=index.es.js.map
|