@w6w/embed 0.2.1 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
- package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
- package/dist/{CreateFunctionModal-DRsFx-FB.js → CreateFunctionModal-DScxp_LN.js} +25 -25
- package/dist/{CreateFunctionModal-DRsFx-FB.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
- package/dist/{DocumentFormModal-BExK1V-B.js → DocumentFormModal-Br4s8wmi.js} +5 -5
- package/dist/{DocumentFormModal-BExK1V-B.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
- package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
- package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
- package/dist/ModelRoutesManager-1Ac5wcas.js +345 -0
- package/dist/ModelRoutesManager-1Ac5wcas.js.map +1 -0
- package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
- package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
- package/dist/apps-ItBvnWX3.js +92 -0
- package/dist/apps-ItBvnWX3.js.map +1 -0
- package/dist/{callables-3mFrMVG_.js → callables-tOlflvbl.js} +11 -11
- package/dist/{callables-3mFrMVG_.js.map → callables-tOlflvbl.js.map} +1 -1
- package/dist/chrome/ConfirmModal.d.ts +4 -1
- package/dist/chrome/DangerZone.d.ts +4 -3
- package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
- package/dist/chrome/JsonToggle.d.ts +29 -20
- package/dist/chrome/Modal.d.ts +3 -1
- package/dist/chrome/RightRail.d.ts +6 -1
- package/dist/chrome/VersionHistoryModal.d.ts +2 -0
- package/dist/chrome/index.d.ts +1 -0
- package/dist/chrome/workspace.d.ts +36 -1
- package/dist/coerce-input-DFJ4n_wc.js +150 -0
- package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
- package/dist/connections-CzsCyIxY.js +119 -0
- package/dist/connections-CzsCyIxY.js.map +1 -0
- package/dist/credentials-Cn92LGhJ.js +171 -0
- package/dist/credentials-Cn92LGhJ.js.map +1 -0
- package/dist/data-stores-UeQvwVCa.js +170 -0
- package/dist/data-stores-UeQvwVCa.js.map +1 -0
- package/dist/document-sources-DNmBojx6.js +169 -0
- package/dist/document-sources-DNmBojx6.js.map +1 -0
- package/dist/draft/use-workflow-draft.d.ts +2 -0
- package/dist/draft.mjs +2 -2
- package/dist/editor/BindingBanner.d.ts +13 -0
- package/dist/editor/CallableEditorFrame.d.ts +7 -0
- package/dist/editor/EndpointCards.d.ts +4 -1
- package/dist/editor/PublishControl.d.ts +19 -0
- package/dist/editor/PublishTooltip.d.ts +7 -0
- package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
- package/dist/editor/StartingStateModal.d.ts +14 -0
- package/dist/editor/TargetSelector.d.ts +15 -0
- package/dist/editor/TargetSelector.types.d.ts +2 -0
- package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
- package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
- package/dist/editor/definition.d.ts +6 -0
- package/dist/editor/json-apply.d.ts +29 -0
- package/dist/editor/step-problems-feed.d.ts +5 -0
- package/dist/editor/types.d.ts +2 -2
- package/dist/editor-apps-DkkC7wOQ.js +152 -0
- package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
- package/dist/editor-tools-BR27RGto.js +1683 -0
- package/dist/editor-tools-BR27RGto.js.map +1 -0
- package/dist/editor.mjs +1 -1
- package/dist/editors.mjs +855 -650
- package/dist/editors.mjs.map +1 -1
- package/dist/{endpoints-B2ynbZo-.js → endpoints-DSRo1Lc5.js} +113 -107
- package/dist/endpoints-DSRo1Lc5.js.map +1 -0
- package/dist/fields-DvS8XZFc.js +21 -0
- package/dist/fields-DvS8XZFc.js.map +1 -0
- package/dist/forms/ModelBudgetsManager.d.ts +9 -0
- package/dist/forms/ModelRoutesManager.d.ts +14 -0
- package/dist/forms.d.ts +4 -0
- package/dist/forms.mjs +611 -212
- package/dist/forms.mjs.map +1 -1
- package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
- package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
- package/dist/index.mjs +154 -117
- package/dist/index.mjs.map +1 -1
- package/dist/lib/binding-problems.d.ts +42 -0
- package/dist/lib/code-rail.d.ts +4 -2
- package/dist/lib/history-query.d.ts +45 -0
- package/dist/lib/import-bindings.d.ts +89 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/invoke-error.d.ts +1 -0
- package/dist/lib/rail-settings.d.ts +1 -1
- package/dist/lib/sdk-snippets.d.ts +1 -1
- package/dist/lib/setup-incomplete.d.ts +22 -0
- package/dist/lib/starting-data.d.ts +31 -0
- package/dist/lib/state-panel.d.ts +29 -0
- package/dist/lib/target-fields.d.ts +11 -15
- package/dist/lib/trigger-preview.d.ts +1 -0
- package/dist/lib/workflow-live-run.d.ts +93 -8
- package/dist/lib/workflow-nodes.d.ts +5 -0
- package/dist/lib/workflow-validity.d.ts +65 -16
- package/dist/lib/workflow-variables.d.ts +1 -1
- package/dist/lib/workflow-version.d.ts +2 -0
- package/dist/lib.mjs +86 -69
- package/dist/lists/ConnectionDependents.d.ts +31 -0
- package/dist/lists/ConnectionDetail.d.ts +4 -1
- package/dist/lists/ConnectionList.d.ts +4 -1
- package/dist/lists/CredentialDetail.d.ts +15 -0
- package/dist/lists/CredentialList.d.ts +14 -0
- package/dist/lists/DataStoreList.d.ts +17 -0
- package/dist/lists/DataStoreView.d.ts +19 -0
- package/dist/lists/Logs.d.ts +19 -0
- package/dist/lists/ModelCatalog.d.ts +12 -0
- package/dist/lists/ModelUsage.d.ts +12 -0
- package/dist/lists.d.ts +14 -0
- package/dist/lists.mjs +1766 -609
- package/dist/lists.mjs.map +1 -1
- package/dist/models-bAayQPJ_.js +270 -0
- package/dist/models-bAayQPJ_.js.map +1 -0
- package/dist/{project-context-BiCjv_E3.js → project-context-Tvp-La7A.js} +3 -3
- package/dist/{project-context-BiCjv_E3.js.map → project-context-Tvp-La7A.js.map} +1 -1
- package/dist/rail/ConnectionsTool.d.ts +2 -0
- package/dist/rail/HistoryTool.d.ts +2 -0
- package/dist/rail/StartingStateTool.d.ts +2 -0
- package/dist/rail/settings-sections.d.ts +4 -1
- package/dist/rail.mjs +4 -4
- package/dist/repos/agents-studio-agents.d.ts +52 -0
- package/dist/repos/agents-studio-assets.d.ts +68 -0
- package/dist/repos/connections.d.ts +30 -12
- package/dist/repos/constants.d.ts +12 -0
- package/dist/repos/credentials.d.ts +83 -0
- package/dist/repos/data-stores.d.ts +84 -0
- package/dist/repos/endpoints.d.ts +9 -3
- package/dist/repos/fields.d.ts +34 -0
- package/dist/repos/functions.d.ts +7 -5
- package/dist/repos/history.d.ts +9 -0
- package/dist/repos/index.d.ts +7 -0
- package/dist/repos/models.d.ts +289 -0
- package/dist/repos/spec-export.d.ts +3 -3
- package/dist/repos/spec-import.d.ts +30 -1
- package/dist/repos/step-tests.d.ts +2 -0
- package/dist/repos/webhook-listen.d.ts +35 -0
- package/dist/repos/workflows.d.ts +105 -2
- package/dist/repos.mjs +655 -176
- package/dist/repos.mjs.map +1 -1
- package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
- package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
- package/dist/{slug-C4ktDPdy.js → slug-BVdgiP_L.js} +64 -60
- package/dist/slug-BVdgiP_L.js.map +1 -0
- package/dist/{spec-export-Cf3VQSQS.js → spec-export-DGy5ijps.js} +73 -60
- package/dist/spec-export-DGy5ijps.js.map +1 -0
- package/dist/spec-import-SWOonsNr.js +116 -0
- package/dist/spec-import-SWOonsNr.js.map +1 -0
- package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
- package/dist/step-tests-B4E4W3ly.js.map +1 -0
- package/dist/theme-context-E2ZhlXDX.js +6 -0
- package/dist/theme-context-E2ZhlXDX.js.map +1 -0
- package/dist/theme-context.d.ts +2 -0
- package/dist/{use-callable-draft-zHLpcr-b.js → use-callable-draft-DCauHt5o.js} +23 -23
- package/dist/{use-callable-draft-zHLpcr-b.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
- package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
- package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
- package/dist/{workflow-blank-DyL3_RUA.js → workflow-blank-DFpGObrn.js} +6 -6
- package/dist/{workflow-blank-DyL3_RUA.js.map → workflow-blank-DFpGObrn.js.map} +1 -1
- package/dist/workflows-BZN4Hyz1.js +623 -0
- package/dist/workflows-BZN4Hyz1.js.map +1 -0
- package/package.json +3 -2
- package/src/styles.css +155 -7
- package/dist/ConfirmModal-RLbZT5_k.js +0 -181
- package/dist/ConfirmModal-RLbZT5_k.js.map +0 -1
- package/dist/ImportSpecModal-BDQIf6rg.js +0 -136
- package/dist/ImportSpecModal-BDQIf6rg.js.map +0 -1
- package/dist/WorkflowEditor-DlbVv6Fs.js +0 -854
- package/dist/WorkflowEditor-DlbVv6Fs.js.map +0 -1
- package/dist/apps-1FNUwbGv.js +0 -77
- package/dist/apps-1FNUwbGv.js.map +0 -1
- package/dist/coerce-input-BicYr7nc.js +0 -139
- package/dist/coerce-input-BicYr7nc.js.map +0 -1
- package/dist/connections-CjjYeRqb.js +0 -78
- package/dist/connections-CjjYeRqb.js.map +0 -1
- package/dist/document-sources-C0grrtdq.js +0 -86
- package/dist/document-sources-C0grrtdq.js.map +0 -1
- package/dist/editor-apps-BdenSV1o.js +0 -95
- package/dist/editor-apps-BdenSV1o.js.map +0 -1
- package/dist/editor-tools-RxmY5iyi.js +0 -1279
- package/dist/editor-tools-RxmY5iyi.js.map +0 -1
- package/dist/endpoints-B2ynbZo-.js.map +0 -1
- package/dist/rail-settings-XYGToh00.js.map +0 -1
- package/dist/slug-C4ktDPdy.js.map +0 -1
- package/dist/spec-export-Cf3VQSQS.js.map +0 -1
- package/dist/spec-import-CjmxyZDR.js +0 -465
- package/dist/spec-import-CjmxyZDR.js.map +0 -1
- package/dist/step-tests-CivICmTq.js.map +0 -1
- package/dist/trigger-preview-VPkrryDl.js +0 -120
- package/dist/trigger-preview-VPkrryDl.js.map +0 -1
- package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
- package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
package/dist/forms.mjs
CHANGED
|
@@ -1,186 +1,198 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { C as
|
|
3
|
-
import { jsxs as
|
|
4
|
-
import { ApiError as
|
|
5
|
-
import { Copyable as
|
|
6
|
-
import { useState as
|
|
7
|
-
import { C as
|
|
8
|
-
import { u as
|
|
9
|
-
import { i as
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { C as He, a as Ye } from "./CreateFunctionModal-DScxp_LN.js";
|
|
3
|
+
import { jsxs as a, jsx as e, Fragment as ne } from "react/jsx-runtime";
|
|
4
|
+
import { ApiError as L } from "@w6w/sdk";
|
|
5
|
+
import { EmptyState as U, DataTable as T, Copyable as se, EditButton as A, DeleteButton as O, useEnterSubmit as V, BudgetMeter as re } from "@w6w/ui";
|
|
6
|
+
import { useState as m } from "react";
|
|
7
|
+
import { C as W, a as oe, M as R } from "./ConfirmModal-Pv2-A_3U.js";
|
|
8
|
+
import { u as ae } from "./project-context-Tvp-La7A.js";
|
|
9
|
+
import { i as de, d as ce, b as ue, h as me, f as he, c as ge, u as ve, g as be } from "./vault-BSEWhMYC.js";
|
|
10
|
+
import { M as Ge } from "./ModelRoutesManager-1Ac5wcas.js";
|
|
11
|
+
import { F as pe, D as fe, C as ye, I as Ne, E as Ce } from "./models-bAayQPJ_.js";
|
|
12
|
+
const Se = ["string", "number", "boolean", "json"];
|
|
13
|
+
function q(t) {
|
|
12
14
|
if (t.type === "boolean" || t.type === "number" || t.type === "string") return String(t.value);
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
+
const n = JSON.stringify(t.value);
|
|
16
|
+
return n.length > 80 ? `${n.slice(0, 80)}…` : n;
|
|
15
17
|
}
|
|
16
|
-
function
|
|
17
|
-
var
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
},
|
|
18
|
+
function Fe(t) {
|
|
19
|
+
var k;
|
|
20
|
+
const n = t.slots, l = ae(t.project), [h, i] = m(null), [f, o] = m(null), g = de(l ?? void 0, l != null), b = ce(), y = l != null, p = () => {
|
|
21
|
+
l != null && i({ mode: "create" });
|
|
22
|
+
}, N = (n == null ? void 0 : n.header) === void 0 ? /* @__PURE__ */ a("div", { children: [
|
|
21
23
|
/* @__PURE__ */ e("h3", { children: "Variables" }),
|
|
22
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ a("p", { className: "muted small", children: [
|
|
23
25
|
"User-defined typed values addressable by name. Plaintext — use ",
|
|
24
26
|
/* @__PURE__ */ e("strong", { children: "Secrets" }),
|
|
25
27
|
" ",
|
|
26
28
|
"for sensitive values."
|
|
27
29
|
] })
|
|
28
|
-
] }) :
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/* @__PURE__ */ e("strong", { className: "list-name", title: r.name, children: r.name }),
|
|
40
|
-
" ",
|
|
41
|
-
/* @__PURE__ */ e("span", { className: "tag", children: r.type }),
|
|
42
|
-
/* @__PURE__ */ n("div", { className: "muted small list-preview", title: M(r), children: [
|
|
43
|
-
/* @__PURE__ */ e(A, { value: M(r), readOnly: !0, children: /* @__PURE__ */ e(
|
|
44
|
-
"code",
|
|
45
|
-
{
|
|
46
|
-
style: {
|
|
47
|
-
overflowWrap: "anywhere",
|
|
48
|
-
display: "block",
|
|
49
|
-
minWidth: 0,
|
|
50
|
-
overflow: "hidden",
|
|
51
|
-
textOverflow: "ellipsis",
|
|
52
|
-
flex: 1
|
|
53
|
-
},
|
|
54
|
-
children: M(r)
|
|
55
|
-
}
|
|
56
|
-
) }),
|
|
57
|
-
r.description && /* @__PURE__ */ n(V, { children: [
|
|
58
|
-
" · ",
|
|
59
|
-
r.description
|
|
60
|
-
] })
|
|
61
|
-
] })
|
|
62
|
-
] }),
|
|
63
|
-
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
|
|
64
|
-
/* @__PURE__ */ e(F, { resource: { kind: "var", name: r.name } }),
|
|
65
|
-
/* @__PURE__ */ e(
|
|
66
|
-
L,
|
|
67
|
-
{
|
|
68
|
-
label: "Edit",
|
|
69
|
-
onClick: () => i({ mode: "edit", v: r }),
|
|
70
|
-
"data-testid": `var-edit-${r.id}`
|
|
71
|
-
}
|
|
72
|
-
),
|
|
73
|
-
/* @__PURE__ */ e(
|
|
74
|
-
j,
|
|
30
|
+
] }) : n.header, C = n == null ? void 0 : n.actions, S = C === void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !y, onClick: p, children: "+ Add variable" }) : typeof C == "function" ? C({ openCreate: p, canCreate: y }) : C, s = (n == null ? void 0 : n.empty) === void 0 ? /* @__PURE__ */ e(U, { testId: "vars-manager-empty", children: "No variables yet." }) : n.empty, u = [
|
|
31
|
+
{
|
|
32
|
+
key: "name",
|
|
33
|
+
header: "Variable",
|
|
34
|
+
render: (c) => /* @__PURE__ */ a("div", { className: "list-main", style: { maxWidth: 0, minWidth: "100%" }, children: [
|
|
35
|
+
/* @__PURE__ */ e("strong", { className: "list-name", title: c.name, children: c.name }),
|
|
36
|
+
" ",
|
|
37
|
+
/* @__PURE__ */ e("span", { className: "tag", children: c.type }),
|
|
38
|
+
/* @__PURE__ */ a("div", { className: "muted small list-preview", title: q(c), children: [
|
|
39
|
+
/* @__PURE__ */ e(se, { value: q(c), readOnly: !0, children: /* @__PURE__ */ e(
|
|
40
|
+
"code",
|
|
75
41
|
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
42
|
+
style: {
|
|
43
|
+
overflowWrap: "anywhere",
|
|
44
|
+
display: "block",
|
|
45
|
+
minWidth: 0,
|
|
46
|
+
overflow: "hidden",
|
|
47
|
+
textOverflow: "ellipsis",
|
|
48
|
+
flex: 1
|
|
49
|
+
},
|
|
50
|
+
children: q(c)
|
|
80
51
|
}
|
|
81
|
-
)
|
|
52
|
+
) }),
|
|
53
|
+
c.description && /* @__PURE__ */ a(ne, { children: [
|
|
54
|
+
" · ",
|
|
55
|
+
c.description
|
|
56
|
+
] })
|
|
82
57
|
] })
|
|
83
|
-
] }
|
|
58
|
+
] })
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "actions",
|
|
62
|
+
header: "",
|
|
63
|
+
align: "right",
|
|
64
|
+
link: !1,
|
|
65
|
+
render: (c) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
|
|
66
|
+
/* @__PURE__ */ e(oe, { resource: { kind: "var", name: c.name } }),
|
|
67
|
+
/* @__PURE__ */ e(
|
|
68
|
+
A,
|
|
69
|
+
{
|
|
70
|
+
label: "Edit",
|
|
71
|
+
onClick: () => i({ mode: "edit", v: c }),
|
|
72
|
+
"data-testid": `var-edit-${c.id}`
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ e(
|
|
76
|
+
O,
|
|
77
|
+
{
|
|
78
|
+
label: "Delete",
|
|
79
|
+
onClick: () => o(c),
|
|
80
|
+
disabled: b.isPending,
|
|
81
|
+
"data-testid": `var-delete-${c.id}`
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] })
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ a("section", { className: "section", children: [
|
|
88
|
+
(N != null || S != null) && /* @__PURE__ */ a("div", { className: "section-head", children: [
|
|
89
|
+
N,
|
|
90
|
+
S
|
|
84
91
|
] }),
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
/* @__PURE__ */ a("div", { className: "card", children: [
|
|
93
|
+
g.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
|
|
94
|
+
((k = g.data) == null ? void 0 : k.length) === 0 && s,
|
|
95
|
+
g.data != null && g.data.length > 0 && /* @__PURE__ */ e(T, { columns: u, rows: g.data, rowKey: (c) => c.id })
|
|
96
|
+
] }),
|
|
97
|
+
h && l != null && /* @__PURE__ */ e(
|
|
98
|
+
ke,
|
|
87
99
|
{
|
|
88
|
-
project:
|
|
89
|
-
initial:
|
|
100
|
+
project: l,
|
|
101
|
+
initial: h.mode === "edit" ? h.v : void 0,
|
|
90
102
|
onClose: () => i(null),
|
|
91
103
|
onSaved: () => i(null)
|
|
92
104
|
}
|
|
93
105
|
),
|
|
94
|
-
f &&
|
|
95
|
-
|
|
106
|
+
f && l != null && /* @__PURE__ */ e(
|
|
107
|
+
W,
|
|
96
108
|
{
|
|
97
109
|
title: "Delete variable",
|
|
98
110
|
message: `Delete the variable "${f.name}"? This cannot be undone.`,
|
|
99
111
|
confirmLabel: "Delete",
|
|
100
112
|
onConfirm: () => {
|
|
101
|
-
|
|
113
|
+
b.mutate({ id: f.id, project: l }), o(null);
|
|
102
114
|
},
|
|
103
115
|
onClose: () => o(null)
|
|
104
116
|
}
|
|
105
117
|
)
|
|
106
118
|
] }) });
|
|
107
119
|
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
const
|
|
111
|
-
function
|
|
120
|
+
function ke(t) {
|
|
121
|
+
var M, v, E;
|
|
122
|
+
const n = !!t.initial, [l, h] = m(((M = t.initial) == null ? void 0 : M.name) ?? ""), [i, f] = m(((v = t.initial) == null ? void 0 : v.type) ?? "string"), [o, g] = m(() => t.initial ? t.initial.type === "string" ? String(t.initial.value ?? "") : JSON.stringify(t.initial.value, null, 2) : ""), [b, y] = m(((E = t.initial) == null ? void 0 : E.description) ?? ""), [p, N] = m(null);
|
|
123
|
+
function C() {
|
|
112
124
|
if (i === "string") return { ok: !0, value: o };
|
|
113
125
|
if (i === "boolean")
|
|
114
126
|
return o === "true" ? { ok: !0, value: !0 } : o === "false" ? { ok: !0, value: !1 } : { ok: !1, error: "Value must be `true` or `false`." };
|
|
115
127
|
if (i === "number") {
|
|
116
|
-
const
|
|
117
|
-
return Number.isFinite(
|
|
128
|
+
const d = Number(o);
|
|
129
|
+
return Number.isFinite(d) ? { ok: !0, value: d } : { ok: !1, error: "Value must be a finite number." };
|
|
118
130
|
}
|
|
119
131
|
try {
|
|
120
132
|
return { ok: !0, value: JSON.parse(o) };
|
|
121
|
-
} catch (
|
|
122
|
-
return { ok: !1, error: `Invalid JSON: ${
|
|
133
|
+
} catch (d) {
|
|
134
|
+
return { ok: !1, error: `Invalid JSON: ${d.message}` };
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
|
-
const
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
129
|
-
|
|
137
|
+
const S = ue(), s = me(), u = S.isPending || s.isPending;
|
|
138
|
+
function k() {
|
|
139
|
+
const d = C();
|
|
140
|
+
if (!d.ok) {
|
|
141
|
+
N(d.error);
|
|
130
142
|
return;
|
|
131
143
|
}
|
|
132
|
-
|
|
133
|
-
const
|
|
144
|
+
N(null);
|
|
145
|
+
const x = {
|
|
134
146
|
onSuccess: () => t.onSaved(),
|
|
135
|
-
onError: (w) =>
|
|
147
|
+
onError: (w) => N((w instanceof L, w.message))
|
|
136
148
|
};
|
|
137
149
|
if (t.initial) {
|
|
138
|
-
|
|
150
|
+
s.mutate(
|
|
139
151
|
{
|
|
140
152
|
id: t.initial.id,
|
|
141
|
-
patch: { type: i, value:
|
|
153
|
+
patch: { type: i, value: d.value, description: b },
|
|
142
154
|
project: t.project
|
|
143
155
|
},
|
|
144
|
-
|
|
156
|
+
x
|
|
145
157
|
);
|
|
146
158
|
return;
|
|
147
159
|
}
|
|
148
|
-
|
|
149
|
-
{ input: { name:
|
|
150
|
-
|
|
160
|
+
S.mutate(
|
|
161
|
+
{ input: { name: l, type: i, value: d.value, description: b }, project: t.project },
|
|
162
|
+
x
|
|
151
163
|
);
|
|
152
164
|
}
|
|
153
|
-
const
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
|
|
165
|
+
const c = V(k, { enabled: !!l && !u });
|
|
166
|
+
return /* @__PURE__ */ a(
|
|
167
|
+
R,
|
|
156
168
|
{
|
|
157
169
|
title: t.initial ? `Edit ${t.initial.name}` : "Add variable",
|
|
158
170
|
onClose: t.onClose,
|
|
159
171
|
children: [
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ a("div", { className: "modal-body", children: [
|
|
173
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
162
174
|
/* @__PURE__ */ e("span", { children: "Name" }),
|
|
163
175
|
/* @__PURE__ */ e(
|
|
164
176
|
"input",
|
|
165
177
|
{
|
|
166
178
|
type: "text",
|
|
167
|
-
value:
|
|
168
|
-
disabled:
|
|
169
|
-
onChange: (
|
|
179
|
+
value: l,
|
|
180
|
+
disabled: n,
|
|
181
|
+
onChange: (d) => h(d.target.value),
|
|
170
182
|
placeholder: "e.g. api_base_url",
|
|
171
183
|
maxLength: 64,
|
|
172
|
-
...
|
|
184
|
+
...c
|
|
173
185
|
}
|
|
174
186
|
),
|
|
175
|
-
!
|
|
187
|
+
!n && /* @__PURE__ */ e("span", { className: "hint", children: "Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive." })
|
|
176
188
|
] }),
|
|
177
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
178
190
|
/* @__PURE__ */ e("span", { children: "Type" }),
|
|
179
|
-
/* @__PURE__ */ e("select", { value: i, onChange: (
|
|
191
|
+
/* @__PURE__ */ e("select", { value: i, onChange: (d) => f(d.target.value), children: Se.map((d) => /* @__PURE__ */ e("option", { value: d, children: d }, d)) })
|
|
180
192
|
] }),
|
|
181
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ a("label", { className: "field", htmlFor: "var-value", children: [
|
|
182
194
|
/* @__PURE__ */ e("span", { children: "Value" }),
|
|
183
|
-
i === "boolean" ? /* @__PURE__ */
|
|
195
|
+
i === "boolean" ? /* @__PURE__ */ a("select", { id: "var-value", value: o || "true", onChange: (d) => g(d.target.value), children: [
|
|
184
196
|
/* @__PURE__ */ e("option", { value: "true", children: "true" }),
|
|
185
197
|
/* @__PURE__ */ e("option", { value: "false", children: "false" })
|
|
186
198
|
] }) : i === "number" ? /* @__PURE__ */ e(
|
|
@@ -189,9 +201,9 @@ function Y(t) {
|
|
|
189
201
|
id: "var-value",
|
|
190
202
|
type: "number",
|
|
191
203
|
value: o,
|
|
192
|
-
onChange: (
|
|
204
|
+
onChange: (d) => g(d.target.value),
|
|
193
205
|
placeholder: "0",
|
|
194
|
-
...
|
|
206
|
+
...c
|
|
195
207
|
}
|
|
196
208
|
) : i === "json" ? /* @__PURE__ */ e(
|
|
197
209
|
"textarea",
|
|
@@ -200,7 +212,7 @@ function Y(t) {
|
|
|
200
212
|
className: "code",
|
|
201
213
|
rows: 6,
|
|
202
214
|
value: o,
|
|
203
|
-
onChange: (
|
|
215
|
+
onChange: (d) => g(d.target.value),
|
|
204
216
|
placeholder: '{"key": "value"}'
|
|
205
217
|
}
|
|
206
218
|
) : /* @__PURE__ */ e(
|
|
@@ -209,199 +221,586 @@ function Y(t) {
|
|
|
209
221
|
id: "var-value",
|
|
210
222
|
type: "text",
|
|
211
223
|
value: o,
|
|
212
|
-
onChange: (
|
|
224
|
+
onChange: (d) => g(d.target.value),
|
|
213
225
|
placeholder: "",
|
|
214
|
-
...
|
|
226
|
+
...c
|
|
215
227
|
}
|
|
216
228
|
)
|
|
217
229
|
] }),
|
|
218
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
219
231
|
/* @__PURE__ */ e("span", { children: "Description" }),
|
|
220
232
|
/* @__PURE__ */ e(
|
|
221
233
|
"input",
|
|
222
234
|
{
|
|
223
235
|
type: "text",
|
|
224
|
-
value:
|
|
225
|
-
onChange: (
|
|
236
|
+
value: b,
|
|
237
|
+
onChange: (d) => y(d.target.value),
|
|
226
238
|
placeholder: "Optional",
|
|
227
|
-
...
|
|
239
|
+
...c
|
|
228
240
|
}
|
|
229
241
|
)
|
|
230
242
|
] }),
|
|
231
|
-
|
|
243
|
+
p && /* @__PURE__ */ e("div", { className: "result error", children: p })
|
|
232
244
|
] }),
|
|
233
|
-
/* @__PURE__ */
|
|
245
|
+
/* @__PURE__ */ a("div", { className: "modal-actions", children: [
|
|
234
246
|
/* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: t.onClose, children: "Cancel" }),
|
|
235
|
-
/* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !
|
|
247
|
+
/* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !l || u, onClick: k, children: u ? "Saving…" : n ? "Save changes" : "Save variable" })
|
|
236
248
|
] })
|
|
237
249
|
]
|
|
238
250
|
}
|
|
239
251
|
);
|
|
240
252
|
}
|
|
241
|
-
function
|
|
242
|
-
var
|
|
243
|
-
const
|
|
253
|
+
function Ke(t) {
|
|
254
|
+
var s;
|
|
255
|
+
const n = t.slots, [l, h] = m(null), [i, f] = m(null), o = he(), g = ge(), b = () => h({ mode: "create" }), y = (n == null ? void 0 : n.header) === void 0 ? /* @__PURE__ */ a("div", { children: [
|
|
244
256
|
/* @__PURE__ */ e("h3", { children: "Secrets" }),
|
|
245
257
|
/* @__PURE__ */ e("p", { className: "muted small", children: "Secrets addressable by name. Stored encrypted at rest and never returned from the server — to change a secret, overwrite it." })
|
|
246
|
-
] }) :
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
258
|
+
] }) : n.header, p = n == null ? void 0 : n.actions, N = p === void 0 ? /* @__PURE__ */ e("button", { type: "button", className: "btn", onClick: b, children: "+ Add secret" }) : typeof p == "function" ? p({ openCreate: b, canCreate: !0 }) : p, C = (n == null ? void 0 : n.empty) === void 0 ? /* @__PURE__ */ e(U, { testId: "secrets-manager-empty", children: "No secrets yet." }) : n.empty, S = [
|
|
259
|
+
{
|
|
260
|
+
key: "name",
|
|
261
|
+
header: "Secret",
|
|
262
|
+
render: (u) => /* @__PURE__ */ a("div", { className: "list-main", style: { maxWidth: 0, minWidth: "100%" }, children: [
|
|
263
|
+
/* @__PURE__ */ e("strong", { className: "list-name", title: u.name, children: u.name }),
|
|
264
|
+
" ",
|
|
265
|
+
/* @__PURE__ */ e("code", { className: "muted small", children: "••••••••" }),
|
|
266
|
+
/* @__PURE__ */ a("div", { className: "muted small list-preview", children: [
|
|
267
|
+
u.description && /* @__PURE__ */ a(ne, { children: [
|
|
268
|
+
u.description,
|
|
269
|
+
" · "
|
|
270
|
+
] }),
|
|
271
|
+
"updated ",
|
|
272
|
+
new Date(u.updatedAt).toLocaleString()
|
|
273
|
+
] })
|
|
274
|
+
] })
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
key: "actions",
|
|
278
|
+
header: "",
|
|
279
|
+
align: "right",
|
|
280
|
+
link: !1,
|
|
281
|
+
render: (u) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
|
|
282
|
+
/* @__PURE__ */ e(
|
|
283
|
+
A,
|
|
284
|
+
{
|
|
285
|
+
label: "Rotate",
|
|
286
|
+
onClick: () => h({ mode: "edit", s: u }),
|
|
287
|
+
"data-testid": `secret-rotate-${u.id}`
|
|
288
|
+
}
|
|
289
|
+
),
|
|
290
|
+
/* @__PURE__ */ e(
|
|
291
|
+
O,
|
|
292
|
+
{
|
|
293
|
+
label: "Delete",
|
|
294
|
+
onClick: () => f(u),
|
|
295
|
+
disabled: g.isPending,
|
|
296
|
+
"data-testid": `secret-delete-${u.id}`
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
] })
|
|
300
|
+
}
|
|
301
|
+
];
|
|
302
|
+
return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ a("section", { className: "section", children: [
|
|
303
|
+
(y != null || N != null) && /* @__PURE__ */ a("div", { className: "section-head", children: [
|
|
304
|
+
y,
|
|
305
|
+
N
|
|
251
306
|
] }),
|
|
252
|
-
/* @__PURE__ */
|
|
307
|
+
/* @__PURE__ */ a("div", { className: "card", children: [
|
|
253
308
|
o.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
|
|
254
|
-
((
|
|
255
|
-
/* @__PURE__ */ e(
|
|
256
|
-
/* @__PURE__ */ n("div", { className: "list-main", children: [
|
|
257
|
-
/* @__PURE__ */ e("strong", { className: "list-name", title: d.name, children: d.name }),
|
|
258
|
-
" ",
|
|
259
|
-
/* @__PURE__ */ e("code", { className: "muted small", children: "••••••••" }),
|
|
260
|
-
/* @__PURE__ */ n("div", { className: "muted small list-preview", children: [
|
|
261
|
-
d.description && /* @__PURE__ */ n(V, { children: [
|
|
262
|
-
d.description,
|
|
263
|
-
" · "
|
|
264
|
-
] }),
|
|
265
|
-
"updated ",
|
|
266
|
-
new Date(d.updatedAt).toLocaleString()
|
|
267
|
-
] })
|
|
268
|
-
] }),
|
|
269
|
-
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
|
|
270
|
-
/* @__PURE__ */ e(
|
|
271
|
-
L,
|
|
272
|
-
{
|
|
273
|
-
label: "Rotate",
|
|
274
|
-
onClick: () => v({ mode: "edit", s: d }),
|
|
275
|
-
"data-testid": `secret-rotate-${d.id}`
|
|
276
|
-
}
|
|
277
|
-
),
|
|
278
|
-
/* @__PURE__ */ e(
|
|
279
|
-
j,
|
|
280
|
-
{
|
|
281
|
-
label: "Delete",
|
|
282
|
-
onClick: () => f(d),
|
|
283
|
-
disabled: u.isPending,
|
|
284
|
-
"data-testid": `secret-delete-${d.id}`
|
|
285
|
-
}
|
|
286
|
-
)
|
|
287
|
-
] })
|
|
288
|
-
] }, d.id)) })
|
|
309
|
+
((s = o.data) == null ? void 0 : s.length) === 0 && C,
|
|
310
|
+
o.data != null && o.data.length > 0 && /* @__PURE__ */ e(T, { columns: S, rows: o.data, rowKey: (u) => u.id })
|
|
289
311
|
] }),
|
|
290
|
-
|
|
291
|
-
|
|
312
|
+
l && /* @__PURE__ */ e(
|
|
313
|
+
Me,
|
|
292
314
|
{
|
|
293
|
-
initial:
|
|
294
|
-
onClose: () =>
|
|
295
|
-
onSaved: () =>
|
|
315
|
+
initial: l.mode === "edit" ? l.s : void 0,
|
|
316
|
+
onClose: () => h(null),
|
|
317
|
+
onSaved: () => h(null)
|
|
296
318
|
}
|
|
297
319
|
),
|
|
298
320
|
i && /* @__PURE__ */ e(
|
|
299
|
-
|
|
321
|
+
W,
|
|
300
322
|
{
|
|
301
323
|
title: "Delete secret",
|
|
302
324
|
message: `Delete the secret "${i.name}"? This cannot be undone.`,
|
|
303
325
|
confirmLabel: "Delete",
|
|
304
326
|
onConfirm: () => {
|
|
305
|
-
|
|
327
|
+
g.mutate(i.id), f(null);
|
|
306
328
|
},
|
|
307
329
|
onClose: () => f(null)
|
|
308
330
|
}
|
|
309
331
|
)
|
|
310
332
|
] }) });
|
|
311
333
|
}
|
|
312
|
-
function
|
|
313
|
-
var
|
|
314
|
-
const
|
|
315
|
-
function
|
|
316
|
-
if (
|
|
317
|
-
|
|
334
|
+
function Me(t) {
|
|
335
|
+
var k, c, M;
|
|
336
|
+
const n = !!t.initial, [l, h] = m(((k = t.initial) == null ? void 0 : k.name) ?? ""), [i, f] = m(""), [o, g] = m(((c = t.initial) == null ? void 0 : c.description) ?? ""), [b, y] = m(null), p = ve(), N = be(((M = t.initial) == null ? void 0 : M.id) ?? ""), C = n ? N : p, S = !!l && (n || !!i) && !C.isPending;
|
|
337
|
+
function s() {
|
|
338
|
+
if (y(null), n) {
|
|
339
|
+
N.mutate(
|
|
318
340
|
{ value: i === "" ? void 0 : i, description: o },
|
|
319
341
|
{
|
|
320
342
|
onSuccess: () => t.onSaved(),
|
|
321
|
-
onError: (
|
|
343
|
+
onError: (v) => y((v instanceof L, v.message))
|
|
322
344
|
}
|
|
323
345
|
);
|
|
324
346
|
return;
|
|
325
347
|
}
|
|
326
348
|
if (i === "") {
|
|
327
|
-
|
|
349
|
+
y("A secret value is required.");
|
|
328
350
|
return;
|
|
329
351
|
}
|
|
330
|
-
|
|
331
|
-
{ name:
|
|
352
|
+
p.mutate(
|
|
353
|
+
{ name: l, value: i, description: o },
|
|
332
354
|
{
|
|
333
355
|
onSuccess: () => t.onSaved(),
|
|
334
|
-
onError: (
|
|
356
|
+
onError: (v) => y((v instanceof L, v.message))
|
|
335
357
|
}
|
|
336
358
|
);
|
|
337
359
|
}
|
|
338
|
-
const
|
|
339
|
-
return /* @__PURE__ */
|
|
340
|
-
|
|
360
|
+
const u = V(s, { enabled: S });
|
|
361
|
+
return /* @__PURE__ */ a(
|
|
362
|
+
R,
|
|
341
363
|
{
|
|
342
364
|
title: t.initial ? `Rotate ${t.initial.name}` : "Add secret",
|
|
343
365
|
onClose: t.onClose,
|
|
344
366
|
children: [
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
367
|
+
/* @__PURE__ */ a("div", { className: "modal-body", children: [
|
|
368
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
347
369
|
/* @__PURE__ */ e("span", { children: "Name" }),
|
|
348
370
|
/* @__PURE__ */ e(
|
|
349
371
|
"input",
|
|
350
372
|
{
|
|
351
373
|
type: "text",
|
|
352
|
-
value:
|
|
353
|
-
disabled:
|
|
354
|
-
onChange: (
|
|
374
|
+
value: l,
|
|
375
|
+
disabled: n,
|
|
376
|
+
onChange: (v) => h(v.target.value),
|
|
355
377
|
placeholder: "e.g. openai_api_key",
|
|
356
378
|
maxLength: 64,
|
|
357
|
-
...
|
|
379
|
+
...u
|
|
358
380
|
}
|
|
359
381
|
),
|
|
360
|
-
!
|
|
382
|
+
!n && /* @__PURE__ */ e("span", { className: "hint", children: "Letters, digits, and underscores. Must start with a letter or underscore. Case-sensitive." })
|
|
361
383
|
] }),
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
/* @__PURE__ */ e("span", { children:
|
|
384
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
385
|
+
/* @__PURE__ */ e("span", { children: n ? "New value" : "Value" }),
|
|
364
386
|
/* @__PURE__ */ e(
|
|
365
387
|
"textarea",
|
|
366
388
|
{
|
|
367
389
|
className: "code",
|
|
368
390
|
rows: 3,
|
|
369
391
|
value: i,
|
|
370
|
-
onChange: (
|
|
371
|
-
placeholder:
|
|
392
|
+
onChange: (v) => f(v.target.value),
|
|
393
|
+
placeholder: n ? "Leave blank to keep the current value" : "sk-…",
|
|
372
394
|
autoComplete: "off",
|
|
373
395
|
spellCheck: !1
|
|
374
396
|
}
|
|
375
397
|
),
|
|
376
398
|
/* @__PURE__ */ e("span", { className: "hint", children: "Stored encrypted at rest. Once saved, it is not readable through the UI." })
|
|
377
399
|
] }),
|
|
378
|
-
/* @__PURE__ */
|
|
400
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
379
401
|
/* @__PURE__ */ e("span", { children: "Description" }),
|
|
380
402
|
/* @__PURE__ */ e(
|
|
381
403
|
"input",
|
|
382
404
|
{
|
|
383
405
|
type: "text",
|
|
384
406
|
value: o,
|
|
385
|
-
onChange: (
|
|
407
|
+
onChange: (v) => g(v.target.value),
|
|
386
408
|
placeholder: "Optional",
|
|
387
|
-
...
|
|
409
|
+
...u
|
|
388
410
|
}
|
|
389
411
|
)
|
|
390
412
|
] }),
|
|
391
|
-
|
|
413
|
+
b && /* @__PURE__ */ e("div", { className: "result error", children: b })
|
|
392
414
|
] }),
|
|
393
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ a("div", { className: "modal-actions", children: [
|
|
394
416
|
/* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: t.onClose, children: "Cancel" }),
|
|
395
|
-
/* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !
|
|
417
|
+
/* @__PURE__ */ e("button", { type: "button", className: "btn", disabled: !S, onClick: s, children: C.isPending ? "Saving…" : n ? "Save changes" : "Save secret" })
|
|
396
418
|
] })
|
|
397
419
|
]
|
|
398
420
|
}
|
|
399
421
|
);
|
|
400
422
|
}
|
|
423
|
+
const we = {
|
|
424
|
+
costMinor: "Cost",
|
|
425
|
+
tokens: "Tokens",
|
|
426
|
+
requests: "Requests"
|
|
427
|
+
}, Ee = ["block", "warn"], ee = ["tenant", "account", "project", "route", "connection"], xe = {
|
|
428
|
+
tenant: "Tenant",
|
|
429
|
+
account: "Account",
|
|
430
|
+
project: "Project",
|
|
431
|
+
route: "Model route",
|
|
432
|
+
connection: "Connection"
|
|
433
|
+
}, De = (t) => t === "route" || t === "connection", te = ["day", "month"];
|
|
434
|
+
function P(t) {
|
|
435
|
+
return String(t).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
436
|
+
}
|
|
437
|
+
function je(t, n) {
|
|
438
|
+
return t === "costMinor" ? (l) => `${n} ${(l / 100).toFixed(2)}` : P;
|
|
439
|
+
}
|
|
440
|
+
function $e(t) {
|
|
441
|
+
return t.costMinor != null ? "costMinor" : t.tokens != null ? "tokens" : t.requests != null ? "requests" : null;
|
|
442
|
+
}
|
|
443
|
+
function Ie(t) {
|
|
444
|
+
return t.costMinor == null ? null : `${t.currency ?? "USD"} ${(t.costMinor / 100).toFixed(2)}`;
|
|
445
|
+
}
|
|
446
|
+
function Le(t) {
|
|
447
|
+
const n = [];
|
|
448
|
+
t.requests != null && n.push(`${P(t.requests)} requests`), t.tokens != null && n.push(`${P(t.tokens)} tokens`);
|
|
449
|
+
const l = Ie(t);
|
|
450
|
+
return l != null && n.push(l), n.length === 0 ? "no limit" : n.join(" · ");
|
|
451
|
+
}
|
|
452
|
+
function I(t) {
|
|
453
|
+
return t.scopeId == null ? `this ${t.scopeKind}` : `${t.scopeKind} ${t.scopeId}`;
|
|
454
|
+
}
|
|
455
|
+
function le(t) {
|
|
456
|
+
return t instanceof L || t instanceof Error ? t.message : String(t);
|
|
457
|
+
}
|
|
458
|
+
function B(t) {
|
|
459
|
+
const n = t.trim();
|
|
460
|
+
if (n === "") return null;
|
|
461
|
+
const l = Number(n);
|
|
462
|
+
return Number.isFinite(l) ? l : null;
|
|
463
|
+
}
|
|
464
|
+
function Qe(t) {
|
|
465
|
+
var S;
|
|
466
|
+
const n = ae(t.projectId), [l, h] = m(null), [i, f] = m(null), [o, g] = m(null), b = pe(n ?? void 0), y = fe(), p = b.data ?? [], N = n != null, C = [
|
|
467
|
+
{
|
|
468
|
+
key: "scope",
|
|
469
|
+
header: "Scope",
|
|
470
|
+
render: (s) => /* @__PURE__ */ a("div", { className: "list-main", style: { maxWidth: 0, minWidth: "100%" }, children: [
|
|
471
|
+
/* @__PURE__ */ e("strong", { className: "list-name", title: I(s), children: s.scopeKind }),
|
|
472
|
+
" ",
|
|
473
|
+
/* @__PURE__ */ e("span", { className: s.onBreach === "warn" ? "tag warn" : "tag", children: s.onBreach }),
|
|
474
|
+
/* @__PURE__ */ e("div", { className: "muted small list-preview", title: I(s), children: s.scopeId == null ? `the whole ${s.scopeKind}` : s.scopeId })
|
|
475
|
+
] })
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
key: "window",
|
|
479
|
+
header: "Window",
|
|
480
|
+
render: (s) => s.window
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
key: "limits",
|
|
484
|
+
header: "Limit",
|
|
485
|
+
render: (s) => /* @__PURE__ */ e("span", { className: "muted small", children: Le(s.limits) })
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
key: "usage",
|
|
489
|
+
header: "Used",
|
|
490
|
+
// Rows only exist once the project-scoped query ran, so `project` is set here.
|
|
491
|
+
render: (s) => n == null ? null : /* @__PURE__ */ e(qe, { budget: s, projectId: n })
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
key: "actions",
|
|
495
|
+
header: "",
|
|
496
|
+
align: "right",
|
|
497
|
+
link: !1,
|
|
498
|
+
render: (s) => /* @__PURE__ */ a("div", { style: { display: "flex", gap: "var(--w6w-sp-1-5)" }, children: [
|
|
499
|
+
/* @__PURE__ */ e(
|
|
500
|
+
A,
|
|
501
|
+
{
|
|
502
|
+
label: "Edit",
|
|
503
|
+
onClick: () => h({ budget: s }),
|
|
504
|
+
"data-testid": `model-budget-edit-${s.id}`
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
/* @__PURE__ */ e(
|
|
508
|
+
O,
|
|
509
|
+
{
|
|
510
|
+
label: "Delete",
|
|
511
|
+
onClick: () => f(s),
|
|
512
|
+
disabled: y.isPending,
|
|
513
|
+
"data-testid": `model-budget-delete-${s.id}`
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
] })
|
|
517
|
+
}
|
|
518
|
+
];
|
|
519
|
+
return /* @__PURE__ */ e("div", { className: "w6w-embed-root", children: /* @__PURE__ */ a("section", { className: "section", children: [
|
|
520
|
+
/* @__PURE__ */ a("div", { className: "section-head", children: [
|
|
521
|
+
/* @__PURE__ */ a("div", { children: [
|
|
522
|
+
/* @__PURE__ */ e("h3", { children: "Model budgets" }),
|
|
523
|
+
/* @__PURE__ */ e("p", { className: "muted small", children: "Caps on what a tenant, account, project, route or connection may spend. A breached budget either warns or blocks the call, per its own setting." })
|
|
524
|
+
] }),
|
|
525
|
+
/* @__PURE__ */ e(
|
|
526
|
+
"button",
|
|
527
|
+
{
|
|
528
|
+
type: "button",
|
|
529
|
+
className: "btn",
|
|
530
|
+
disabled: !N,
|
|
531
|
+
onClick: () => h({}),
|
|
532
|
+
"data-testid": "model-budget-add",
|
|
533
|
+
children: "+ Add budget"
|
|
534
|
+
}
|
|
535
|
+
)
|
|
536
|
+
] }),
|
|
537
|
+
o && /* @__PURE__ */ e("div", { className: "result error", role: "alert", "data-testid": "model-budget-delete-error", children: o }),
|
|
538
|
+
/* @__PURE__ */ a("div", { className: "card", children: [
|
|
539
|
+
b.isLoading && /* @__PURE__ */ e("p", { className: "muted", children: "Loading…" }),
|
|
540
|
+
((S = b.data) == null ? void 0 : S.length) === 0 && /* @__PURE__ */ e(U, { testId: "model-budgets-empty", children: "No model budgets yet. Add one to cap spend or request volume." }),
|
|
541
|
+
p.length > 0 && /* @__PURE__ */ e(
|
|
542
|
+
T,
|
|
543
|
+
{
|
|
544
|
+
columns: C,
|
|
545
|
+
rows: p,
|
|
546
|
+
rowKey: (s) => s.id,
|
|
547
|
+
testId: "model-budgets-table"
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
] }),
|
|
551
|
+
l != null && n != null && /* @__PURE__ */ e(
|
|
552
|
+
Be,
|
|
553
|
+
{
|
|
554
|
+
project: n,
|
|
555
|
+
initial: l.budget,
|
|
556
|
+
onClose: () => h(null),
|
|
557
|
+
onSaved: () => h(null)
|
|
558
|
+
}
|
|
559
|
+
),
|
|
560
|
+
i != null && n != null && /* @__PURE__ */ e(
|
|
561
|
+
W,
|
|
562
|
+
{
|
|
563
|
+
title: "Delete model budget",
|
|
564
|
+
message: `Delete the budget on ${I(i)}? Calls stop being capped by it immediately.`,
|
|
565
|
+
confirmLabel: "Delete",
|
|
566
|
+
onConfirm: () => {
|
|
567
|
+
const s = i;
|
|
568
|
+
g(null), y.mutate(
|
|
569
|
+
{ project: n, id: s.id },
|
|
570
|
+
{
|
|
571
|
+
onError: (u) => g(
|
|
572
|
+
`Could not delete the budget on ${I(s)}: ${le(u)}`
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
), f(null);
|
|
576
|
+
},
|
|
577
|
+
onClose: () => f(null)
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
] }) });
|
|
581
|
+
}
|
|
582
|
+
function qe(t) {
|
|
583
|
+
const n = Ce(t.budget.id, t.projectId);
|
|
584
|
+
if (n.isLoading) return /* @__PURE__ */ e("span", { className: "muted small", children: "Loading…" });
|
|
585
|
+
const l = n.data;
|
|
586
|
+
if (l == null) return /* @__PURE__ */ e("span", { className: "muted small", children: "—" });
|
|
587
|
+
const h = l.limits ?? t.budget.limits, i = $e(h);
|
|
588
|
+
return i == null ? /* @__PURE__ */ e("span", { className: "muted small", children: "no limit" }) : /* @__PURE__ */ e(
|
|
589
|
+
re,
|
|
590
|
+
{
|
|
591
|
+
label: we[i],
|
|
592
|
+
used: l.used[i],
|
|
593
|
+
limit: h[i] ?? 0,
|
|
594
|
+
reserved: l.reserved[i],
|
|
595
|
+
format: je(i, h.currency ?? "USD"),
|
|
596
|
+
testId: `model-budget-meter-${t.budget.id}`
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
function Be(t) {
|
|
601
|
+
var Q, _, J, H, Y, z, G, X;
|
|
602
|
+
const n = !!t.initial, [l, h] = m(((Q = t.initial) == null ? void 0 : Q.scopeKind) ?? "project"), [i, f] = m(((_ = t.initial) == null ? void 0 : _.scopeId) ?? ""), [o, g] = m(((J = t.initial) == null ? void 0 : J.window) ?? "day"), [b, y] = m(
|
|
603
|
+
((H = t.initial) == null ? void 0 : H.limits.requests) != null ? String(t.initial.limits.requests) : ""
|
|
604
|
+
), [p, N] = m(
|
|
605
|
+
((Y = t.initial) == null ? void 0 : Y.limits.tokens) != null ? String(t.initial.limits.tokens) : ""
|
|
606
|
+
), [C, S] = m(
|
|
607
|
+
((z = t.initial) == null ? void 0 : z.limits.costMinor) != null ? String(t.initial.limits.costMinor / 100) : ""
|
|
608
|
+
), [s, u] = m(((G = t.initial) == null ? void 0 : G.limits.currency) ?? ""), [k, c] = m(((X = t.initial) == null ? void 0 : X.onBreach) ?? "warn"), [M, v] = m(null), E = ye(), d = Ne(), x = E.isPending || d.isPending, w = De(l), F = !!l && !!o && (!w || n || i.trim() !== "") && !x;
|
|
609
|
+
function ie() {
|
|
610
|
+
const r = {}, j = B(b);
|
|
611
|
+
j != null && (r.requests = j);
|
|
612
|
+
const $ = B(p);
|
|
613
|
+
$ != null && (r.tokens = $);
|
|
614
|
+
const Z = B(C);
|
|
615
|
+
return Z != null && (r.costMinor = Math.round(Z * 100)), r.costMinor != null && s.trim() !== "" && (r.currency = s.trim()), Object.keys(r).length === 0 ? null : r;
|
|
616
|
+
}
|
|
617
|
+
function K() {
|
|
618
|
+
const r = ie();
|
|
619
|
+
if (r == null) {
|
|
620
|
+
v("Set at least one limit: requests, tokens or cost.");
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
v(null);
|
|
624
|
+
const j = {
|
|
625
|
+
onSuccess: () => t.onSaved(),
|
|
626
|
+
onError: ($) => v(le($))
|
|
627
|
+
};
|
|
628
|
+
if (t.initial) {
|
|
629
|
+
d.mutate(
|
|
630
|
+
{ project: t.project, id: t.initial.id, patch: { window: o, limits: r, onBreach: k } },
|
|
631
|
+
j
|
|
632
|
+
);
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
E.mutate(
|
|
636
|
+
{
|
|
637
|
+
project: t.project,
|
|
638
|
+
input: {
|
|
639
|
+
scopeKind: l,
|
|
640
|
+
// Only route/connection budgets carry a scope id; the server refuses one elsewhere.
|
|
641
|
+
...w ? { scopeId: i.trim() } : {},
|
|
642
|
+
window: o,
|
|
643
|
+
limits: r,
|
|
644
|
+
onBreach: k
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
j
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
const D = V(K, { enabled: F });
|
|
651
|
+
return /* @__PURE__ */ a(R, { title: t.initial ? "Edit model budget" : "Add model budget", onClose: t.onClose, children: [
|
|
652
|
+
/* @__PURE__ */ a("div", { className: "modal-body", children: [
|
|
653
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
654
|
+
/* @__PURE__ */ e("span", { children: "Scope" }),
|
|
655
|
+
/* @__PURE__ */ a(
|
|
656
|
+
"select",
|
|
657
|
+
{
|
|
658
|
+
value: l,
|
|
659
|
+
disabled: n,
|
|
660
|
+
onChange: (r) => h(r.target.value),
|
|
661
|
+
"data-testid": "model-budget-scope-kind",
|
|
662
|
+
children: [
|
|
663
|
+
!ee.includes(l) && /* @__PURE__ */ e("option", { value: l, children: l }),
|
|
664
|
+
ee.map((r) => /* @__PURE__ */ e("option", { value: r, children: xe[r] }, r))
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
),
|
|
668
|
+
!n && /* @__PURE__ */ e("span", { className: "hint", children: "What the budget caps — this tenant, account or project as a whole, or one model route or connection. Fixed once created." })
|
|
669
|
+
] }),
|
|
670
|
+
w && /* @__PURE__ */ a("label", { className: "field", children: [
|
|
671
|
+
/* @__PURE__ */ a("span", { children: [
|
|
672
|
+
l === "route" ? "Route" : "Connection id",
|
|
673
|
+
" *"
|
|
674
|
+
] }),
|
|
675
|
+
/* @__PURE__ */ e(
|
|
676
|
+
"input",
|
|
677
|
+
{
|
|
678
|
+
type: "text",
|
|
679
|
+
value: i,
|
|
680
|
+
disabled: n,
|
|
681
|
+
onChange: (r) => f(r.target.value),
|
|
682
|
+
placeholder: l === "route" ? "e.g. fast" : "e.g. conn_…",
|
|
683
|
+
"data-testid": "model-budget-scope-id",
|
|
684
|
+
...D
|
|
685
|
+
}
|
|
686
|
+
),
|
|
687
|
+
!n && /* @__PURE__ */ e("span", { className: "hint", children: l === "route" ? "The route's name or id. Required for a route budget." : "The model-provider connection's id. Required for a connection budget." })
|
|
688
|
+
] }),
|
|
689
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
690
|
+
/* @__PURE__ */ e("span", { children: "Window" }),
|
|
691
|
+
/* @__PURE__ */ a(
|
|
692
|
+
"select",
|
|
693
|
+
{
|
|
694
|
+
value: o,
|
|
695
|
+
onChange: (r) => g(r.target.value),
|
|
696
|
+
"data-testid": "model-budget-window",
|
|
697
|
+
children: [
|
|
698
|
+
!te.includes(o) && /* @__PURE__ */ e("option", { value: o, children: o }),
|
|
699
|
+
te.map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
|
|
700
|
+
]
|
|
701
|
+
}
|
|
702
|
+
),
|
|
703
|
+
/* @__PURE__ */ e("span", { className: "hint", children: "The period the limits reset over, in UTC." })
|
|
704
|
+
] }),
|
|
705
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
706
|
+
/* @__PURE__ */ e("span", { children: "Requests" }),
|
|
707
|
+
/* @__PURE__ */ e(
|
|
708
|
+
"input",
|
|
709
|
+
{
|
|
710
|
+
type: "number",
|
|
711
|
+
min: 0,
|
|
712
|
+
value: b,
|
|
713
|
+
onChange: (r) => y(r.target.value),
|
|
714
|
+
placeholder: "Unlimited",
|
|
715
|
+
"data-testid": "model-budget-requests",
|
|
716
|
+
...D
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
] }),
|
|
720
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
721
|
+
/* @__PURE__ */ e("span", { children: "Tokens" }),
|
|
722
|
+
/* @__PURE__ */ e(
|
|
723
|
+
"input",
|
|
724
|
+
{
|
|
725
|
+
type: "number",
|
|
726
|
+
min: 0,
|
|
727
|
+
value: p,
|
|
728
|
+
onChange: (r) => N(r.target.value),
|
|
729
|
+
placeholder: "Unlimited",
|
|
730
|
+
"data-testid": "model-budget-tokens",
|
|
731
|
+
...D
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
736
|
+
/* @__PURE__ */ e("span", { children: "Cost" }),
|
|
737
|
+
/* @__PURE__ */ e(
|
|
738
|
+
"input",
|
|
739
|
+
{
|
|
740
|
+
type: "number",
|
|
741
|
+
min: 0,
|
|
742
|
+
step: "0.01",
|
|
743
|
+
value: C,
|
|
744
|
+
onChange: (r) => S(r.target.value),
|
|
745
|
+
placeholder: "Unlimited",
|
|
746
|
+
"data-testid": "model-budget-cost",
|
|
747
|
+
...D
|
|
748
|
+
}
|
|
749
|
+
),
|
|
750
|
+
/* @__PURE__ */ e("span", { className: "hint", children: "In major units of the currency below (12.50 = 12.50 USD)." })
|
|
751
|
+
] }),
|
|
752
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
753
|
+
/* @__PURE__ */ e("span", { children: "Currency" }),
|
|
754
|
+
/* @__PURE__ */ e(
|
|
755
|
+
"input",
|
|
756
|
+
{
|
|
757
|
+
type: "text",
|
|
758
|
+
value: s,
|
|
759
|
+
onChange: (r) => u(r.target.value),
|
|
760
|
+
placeholder: "USD",
|
|
761
|
+
maxLength: 8,
|
|
762
|
+
"data-testid": "model-budget-currency",
|
|
763
|
+
...D
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] }),
|
|
767
|
+
/* @__PURE__ */ a("label", { className: "field", children: [
|
|
768
|
+
/* @__PURE__ */ e("span", { children: "On breach" }),
|
|
769
|
+
/* @__PURE__ */ e(
|
|
770
|
+
"select",
|
|
771
|
+
{
|
|
772
|
+
value: k,
|
|
773
|
+
onChange: (r) => c(r.target.value),
|
|
774
|
+
"data-testid": "model-budget-on-breach",
|
|
775
|
+
children: Ee.map((r) => /* @__PURE__ */ e("option", { value: r, children: r }, r))
|
|
776
|
+
}
|
|
777
|
+
),
|
|
778
|
+
/* @__PURE__ */ e("span", { className: "hint", children: "`block` refuses calls past the limit; `warn` lets them through and flags them." })
|
|
779
|
+
] }),
|
|
780
|
+
M && /* @__PURE__ */ e("div", { className: "result error", "data-testid": "model-budget-error", children: M })
|
|
781
|
+
] }),
|
|
782
|
+
/* @__PURE__ */ a("div", { className: "modal-actions", children: [
|
|
783
|
+
/* @__PURE__ */ e("button", { type: "button", className: "btn ghost", onClick: t.onClose, children: "Cancel" }),
|
|
784
|
+
/* @__PURE__ */ e(
|
|
785
|
+
"button",
|
|
786
|
+
{
|
|
787
|
+
type: "button",
|
|
788
|
+
className: "btn",
|
|
789
|
+
disabled: !F,
|
|
790
|
+
onClick: K,
|
|
791
|
+
"data-testid": "model-budget-save",
|
|
792
|
+
children: x ? "Saving…" : n ? "Save changes" : "Save budget"
|
|
793
|
+
}
|
|
794
|
+
)
|
|
795
|
+
] })
|
|
796
|
+
] });
|
|
797
|
+
}
|
|
401
798
|
export {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
799
|
+
He as CreateEndpointModal,
|
|
800
|
+
Ye as CreateFunctionModal,
|
|
801
|
+
Qe as ModelBudgetsManager,
|
|
802
|
+
Ge as ModelRoutesManager,
|
|
803
|
+
Ke as SecretsManager,
|
|
804
|
+
Fe as VarsManager
|
|
406
805
|
};
|
|
407
806
|
//# sourceMappingURL=forms.mjs.map
|