@executor-js/plugin-graphql 1.4.32 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddGraphqlSource-P3D3UXRJ.js +179 -0
- package/dist/AddGraphqlSource-P3D3UXRJ.js.map +1 -0
- package/dist/EditGraphqlSource-FVF67CTP.js +38 -0
- package/dist/EditGraphqlSource-FVF67CTP.js.map +1 -0
- package/dist/GraphqlAccountsPanel-GBNFHLFH.js +9 -0
- package/dist/GraphqlAccountsPanel-GBNFHLFH.js.map +1 -0
- package/dist/api/group.d.ts +108 -119
- package/dist/api/handlers.d.ts +9 -7
- package/dist/api/index.d.ts +117 -104
- package/dist/chunk-2Y3J3CVO.js +191 -0
- package/dist/chunk-2Y3J3CVO.js.map +1 -0
- package/dist/chunk-ADQTI2OK.js +1309 -0
- package/dist/chunk-ADQTI2OK.js.map +1 -0
- package/dist/{chunk-UIAHATHP.js → chunk-N5GJE7R6.js} +42 -58
- package/dist/chunk-N5GJE7R6.js.map +1 -0
- package/dist/chunk-VCYDSSIK.js +79 -0
- package/dist/chunk-VCYDSSIK.js.map +1 -0
- package/dist/client.js +7 -7
- package/dist/client.js.map +1 -1
- package/dist/core.js +20 -28
- package/dist/index.js +2 -2
- package/dist/react/AddGraphqlSource.d.ts +1 -1
- package/dist/react/EditGraphqlSource.d.ts +2 -2
- package/dist/react/GraphqlAccountsPanel.d.ts +6 -0
- package/dist/react/GraphqlSignInButton.d.ts +6 -2
- package/dist/react/GraphqlSourceFields.d.ts +2 -2
- package/dist/react/atoms.d.ts +95 -205
- package/dist/react/auth-method-config.d.ts +9 -0
- package/dist/react/client.d.ts +108 -97
- package/dist/react/defaults.d.ts +16 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/source-plugin.d.ts +2 -2
- package/dist/sdk/errors.d.ts +8 -6
- package/dist/sdk/index.d.ts +5 -5
- package/dist/sdk/introspect.d.ts +1 -1
- package/dist/sdk/invoke.d.ts +1 -4
- package/dist/sdk/plugin.d.ts +94 -104
- package/dist/sdk/store.d.ts +11 -28
- package/dist/sdk/types.d.ts +110 -72
- package/package.json +5 -4
- package/dist/AddGraphqlSource-CJCUUYNM.js +0 -250
- package/dist/AddGraphqlSource-CJCUUYNM.js.map +0 -1
- package/dist/EditGraphqlSource-YLTPUYW4.js +0 -267
- package/dist/EditGraphqlSource-YLTPUYW4.js.map +0 -1
- package/dist/GraphqlSourceSummary-YWJX6ONU.js +0 -70
- package/dist/GraphqlSourceSummary-YWJX6ONU.js.map +0 -1
- package/dist/chunk-2252RTCE.js +0 -1730
- package/dist/chunk-2252RTCE.js.map +0 -1
- package/dist/chunk-D3FN3ZDA.js +0 -125
- package/dist/chunk-D3FN3ZDA.js.map +0 -1
- package/dist/chunk-M4SJY6CB.js +0 -45
- package/dist/chunk-M4SJY6CB.js.map +0 -1
- package/dist/chunk-UIAHATHP.js.map +0 -1
- package/dist/react/GraphqlSourceSummary.d.ts +0 -5
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GraphqlSourceFields
|
|
3
|
-
} from "./chunk-M4SJY6CB.js";
|
|
4
|
-
import {
|
|
5
|
-
graphqlSourceAtom,
|
|
6
|
-
graphqlSourceBindingsAtom
|
|
7
|
-
} from "./chunk-D3FN3ZDA.js";
|
|
8
|
-
import "./chunk-UIAHATHP.js";
|
|
9
|
-
|
|
10
|
-
// src/react/EditGraphqlSource.tsx
|
|
11
|
-
import { useMemo, useState } from "react";
|
|
12
|
-
import { useAtomValue, useAtomSet } from "@effect/atom-react";
|
|
13
|
-
import * as Exit from "effect/Exit";
|
|
14
|
-
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
|
15
|
-
import {
|
|
16
|
-
configureSource,
|
|
17
|
-
connectionsAtom,
|
|
18
|
-
setSourceCredentialBinding
|
|
19
|
-
} from "@executor-js/react/api/atoms";
|
|
20
|
-
import { useScope, useUserScope } from "@executor-js/react/api/scope-context";
|
|
21
|
-
import { connectionWriteKeys, sourceWriteKeys } from "@executor-js/react/api/reactivity-keys";
|
|
22
|
-
import { useSecretPickerSecrets } from "@executor-js/react/plugins/use-secret-picker-secrets";
|
|
23
|
-
import {
|
|
24
|
-
httpCredentialsFromConfiguredCredentialBindings,
|
|
25
|
-
serializeHttpCredentials
|
|
26
|
-
} from "@executor-js/react/plugins/http-credentials";
|
|
27
|
-
import { slugifyNamespace, useSourceIdentity } from "@executor-js/react/plugins/source-identity";
|
|
28
|
-
import { useCredentialTargetScope } from "@executor-js/react/plugins/credential-target-scope";
|
|
29
|
-
import {
|
|
30
|
-
useSourceCredentialBindingScopes,
|
|
31
|
-
useSourceCredentialBindingWriter
|
|
32
|
-
} from "@executor-js/react/plugins/source-credential-bindings";
|
|
33
|
-
import { Button } from "@executor-js/react/components/button";
|
|
34
|
-
import {
|
|
35
|
-
CardStack,
|
|
36
|
-
CardStackContent,
|
|
37
|
-
CardStackEntry,
|
|
38
|
-
CardStackEntryContent,
|
|
39
|
-
CardStackEntryDescription,
|
|
40
|
-
CardStackEntryTitle
|
|
41
|
-
} from "@executor-js/react/components/card-stack";
|
|
42
|
-
import { FilterTabs } from "@executor-js/react/components/filter-tabs";
|
|
43
|
-
import {
|
|
44
|
-
SourceOAuthConnectionControl,
|
|
45
|
-
sourceOAuthConnectionUiState
|
|
46
|
-
} from "@executor-js/react/plugins/source-oauth-connection";
|
|
47
|
-
import { Badge } from "@executor-js/react/components/badge";
|
|
48
|
-
import { ScopeId } from "@executor-js/sdk/shared";
|
|
49
|
-
import {
|
|
50
|
-
SecretCredentialSlotBindings,
|
|
51
|
-
secretCredentialSlotsFromHttpConfig
|
|
52
|
-
} from "@executor-js/react/plugins/credential-slot-bindings";
|
|
53
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
54
|
-
function EditForm(props) {
|
|
55
|
-
const displayScope = useScope();
|
|
56
|
-
const userScope = useUserScope();
|
|
57
|
-
const sourceScope = ScopeId.make(props.initial.scope);
|
|
58
|
-
const {
|
|
59
|
-
credentialTargetScope: oauthCredentialTargetScope,
|
|
60
|
-
setCredentialTargetScope: setOAuthCredentialTargetScope
|
|
61
|
-
} = useCredentialTargetScope({
|
|
62
|
-
sourceScope,
|
|
63
|
-
initialTargetScope: userScope
|
|
64
|
-
});
|
|
65
|
-
const doConfigure = useAtomSet(configureSource, { mode: "promiseExit" });
|
|
66
|
-
const setConnectionBinding = useAtomSet(setSourceCredentialBinding, { mode: "promise" });
|
|
67
|
-
const secretList = useSecretPickerSecrets();
|
|
68
|
-
const connectionsResult = useAtomValue(connectionsAtom(userScope));
|
|
69
|
-
const identity = useSourceIdentity({
|
|
70
|
-
fallbackName: props.initial.name,
|
|
71
|
-
fallbackNamespace: props.initial.namespace
|
|
72
|
-
});
|
|
73
|
-
const [endpoint, setEndpoint] = useState(props.initial.endpoint);
|
|
74
|
-
const credentials = useMemo(
|
|
75
|
-
() => httpCredentialsFromConfiguredCredentialBindings({
|
|
76
|
-
headers: props.initial.headers,
|
|
77
|
-
queryParams: props.initial.queryParams,
|
|
78
|
-
bindings: props.bindings
|
|
79
|
-
}),
|
|
80
|
-
[props.bindings, props.initial.headers, props.initial.queryParams]
|
|
81
|
-
);
|
|
82
|
-
const [authMode, setAuthMode] = useState(props.initial.auth.kind);
|
|
83
|
-
const [saving, setSaving] = useState(false);
|
|
84
|
-
const [error, setError] = useState(null);
|
|
85
|
-
const [authDirty, setAuthDirty] = useState(false);
|
|
86
|
-
const { busyKey, setSecretBinding, clearBinding } = useSourceCredentialBindingWriter({
|
|
87
|
-
displayScope,
|
|
88
|
-
source: { id: props.sourceId, scope: sourceScope },
|
|
89
|
-
onError: setError
|
|
90
|
-
});
|
|
91
|
-
const identityDirty = identity.name.trim() !== props.initial.name.trim();
|
|
92
|
-
const metadataDirty = identityDirty || endpoint.trim() !== props.initial.endpoint.trim();
|
|
93
|
-
const dirty = metadataDirty || authDirty;
|
|
94
|
-
const oauth2 = props.initial.auth.kind === "oauth2" ? props.initial.auth : null;
|
|
95
|
-
const connections = AsyncResult.isSuccess(connectionsResult) ? connectionsResult.value : [];
|
|
96
|
-
const { credentialScopeOptions, secretBindingScopes, scopeRanks } = useSourceCredentialBindingScopes({ sourceScope });
|
|
97
|
-
const secretSlots = secretCredentialSlotsFromHttpConfig({
|
|
98
|
-
headers: props.initial.headers,
|
|
99
|
-
queryParams: props.initial.queryParams
|
|
100
|
-
});
|
|
101
|
-
const oauthConnectionState = oauth2 ? sourceOAuthConnectionUiState({
|
|
102
|
-
bindings: props.bindings,
|
|
103
|
-
connectionSlot: oauth2.connectionSlot,
|
|
104
|
-
tokenScope: oauthCredentialTargetScope,
|
|
105
|
-
scopeRanks,
|
|
106
|
-
credentialScopeOptions,
|
|
107
|
-
connections
|
|
108
|
-
}) : null;
|
|
109
|
-
const oauthRequestCredentials = serializeHttpCredentials(credentials);
|
|
110
|
-
const handleSave = async () => {
|
|
111
|
-
setSaving(true);
|
|
112
|
-
setError(null);
|
|
113
|
-
const config = {
|
|
114
|
-
name: metadataDirty ? identity.name.trim() || void 0 : void 0,
|
|
115
|
-
endpoint: metadataDirty ? endpoint.trim() || void 0 : void 0
|
|
116
|
-
};
|
|
117
|
-
if (authDirty) {
|
|
118
|
-
config.auth = authMode === "oauth2" ? { oauth2: {} } : { kind: "none" };
|
|
119
|
-
}
|
|
120
|
-
const exit = await doConfigure({
|
|
121
|
-
params: { scopeId: displayScope },
|
|
122
|
-
payload: {
|
|
123
|
-
source: { id: props.sourceId, scope: sourceScope },
|
|
124
|
-
scope: sourceScope,
|
|
125
|
-
type: "graphql",
|
|
126
|
-
config
|
|
127
|
-
},
|
|
128
|
-
reactivityKeys: sourceWriteKeys
|
|
129
|
-
});
|
|
130
|
-
if (Exit.isFailure(exit)) {
|
|
131
|
-
setError("Failed to update source");
|
|
132
|
-
setSaving(false);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
setAuthDirty(false);
|
|
136
|
-
props.onSave();
|
|
137
|
-
setSaving(false);
|
|
138
|
-
};
|
|
139
|
-
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
140
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
141
|
-
/* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-foreground", children: "Edit GraphQL Source" }),
|
|
142
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Update the endpoint and authentication headers for this source." })
|
|
143
|
-
] }),
|
|
144
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-lg border border-border bg-card px-4 py-3", children: [
|
|
145
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-card-foreground", children: props.sourceId }) }),
|
|
146
|
-
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: "GraphQL" })
|
|
147
|
-
] }),
|
|
148
|
-
/* @__PURE__ */ jsx(
|
|
149
|
-
GraphqlSourceFields,
|
|
150
|
-
{
|
|
151
|
-
endpoint,
|
|
152
|
-
onEndpointChange: setEndpoint,
|
|
153
|
-
identity,
|
|
154
|
-
namespaceReadOnly: true
|
|
155
|
-
}
|
|
156
|
-
),
|
|
157
|
-
secretSlots.length > 0 && /* @__PURE__ */ jsx(CardStack, { children: /* @__PURE__ */ jsxs(CardStackContent, { className: "border-t-0", children: [
|
|
158
|
-
/* @__PURE__ */ jsx(CardStackEntry, { children: /* @__PURE__ */ jsxs(CardStackEntryContent, { children: [
|
|
159
|
-
/* @__PURE__ */ jsx(CardStackEntryTitle, { children: "Request credentials" }),
|
|
160
|
-
/* @__PURE__ */ jsx(CardStackEntryDescription, { children: "Headers and query parameters sent with every GraphQL request." })
|
|
161
|
-
] }) }),
|
|
162
|
-
/* @__PURE__ */ jsx(
|
|
163
|
-
SecretCredentialSlotBindings,
|
|
164
|
-
{
|
|
165
|
-
slots: secretSlots,
|
|
166
|
-
bindingScopes: secretBindingScopes,
|
|
167
|
-
bindingRows: props.bindings,
|
|
168
|
-
scopeRanks,
|
|
169
|
-
secrets: secretList,
|
|
170
|
-
sourceId: props.sourceId,
|
|
171
|
-
sourceName: identity.name,
|
|
172
|
-
credentialScopeOptions,
|
|
173
|
-
busyKey,
|
|
174
|
-
onSetSecretBinding: setSecretBinding,
|
|
175
|
-
onClearBinding: clearBinding
|
|
176
|
-
}
|
|
177
|
-
)
|
|
178
|
-
] }) }),
|
|
179
|
-
/* @__PURE__ */ jsxs("section", { className: "hidden space-y-2.5", children: [
|
|
180
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
181
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: "Authentication" }),
|
|
182
|
-
/* @__PURE__ */ jsx(
|
|
183
|
-
FilterTabs,
|
|
184
|
-
{
|
|
185
|
-
tabs: [
|
|
186
|
-
{ value: "none", label: "None" },
|
|
187
|
-
{ value: "oauth2", label: "OAuth" }
|
|
188
|
-
],
|
|
189
|
-
value: authMode,
|
|
190
|
-
onChange: (value) => {
|
|
191
|
-
setAuthMode(value);
|
|
192
|
-
setAuthDirty(true);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
)
|
|
196
|
-
] }),
|
|
197
|
-
authMode === "oauth2" && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "OAuth sign-in is available from the source header after saving." })
|
|
198
|
-
] }),
|
|
199
|
-
oauth2 && oauthConnectionState && /* @__PURE__ */ jsx(
|
|
200
|
-
SourceOAuthConnectionControl,
|
|
201
|
-
{
|
|
202
|
-
popupName: "graphql-oauth",
|
|
203
|
-
pluginId: "graphql",
|
|
204
|
-
namespace: slugifyNamespace(props.initial.namespace) || "graphql",
|
|
205
|
-
fallbackNamespace: "graphql",
|
|
206
|
-
endpoint: endpoint.trim(),
|
|
207
|
-
tokenScope: oauthCredentialTargetScope,
|
|
208
|
-
onTokenScopeChange: setOAuthCredentialTargetScope,
|
|
209
|
-
credentialScopeOptions,
|
|
210
|
-
connectionId: oauthConnectionState.connectionId,
|
|
211
|
-
sourceLabel: `${identity.name.trim() || props.initial.namespace || "GraphQL"} OAuth`,
|
|
212
|
-
headers: oauthRequestCredentials.headers,
|
|
213
|
-
queryParams: oauthRequestCredentials.queryParams,
|
|
214
|
-
isConnected: oauthConnectionState.isConnected,
|
|
215
|
-
buttonIsConnected: oauthConnectionState.buttonIsConnected,
|
|
216
|
-
statusLabel: oauthConnectionState.statusLabel,
|
|
217
|
-
onConnected: async (connectionId) => {
|
|
218
|
-
await setConnectionBinding({
|
|
219
|
-
params: { scopeId: oauthCredentialTargetScope },
|
|
220
|
-
payload: {
|
|
221
|
-
scope: oauthCredentialTargetScope,
|
|
222
|
-
source: { id: props.sourceId, scope: sourceScope },
|
|
223
|
-
slotKey: oauth2.connectionSlot,
|
|
224
|
-
value: { kind: "connection", connectionId }
|
|
225
|
-
},
|
|
226
|
-
reactivityKeys: [...sourceWriteKeys, ...connectionWriteKeys]
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
signInLabel: oauthConnectionState.signInLabel
|
|
230
|
-
}
|
|
231
|
-
),
|
|
232
|
-
error && /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }) }),
|
|
233
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t border-border pt-4", children: [
|
|
234
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: props.onSave, children: "Cancel" }),
|
|
235
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleSave, disabled: !dirty || saving, children: saving ? "Saving\u2026" : "Save changes" })
|
|
236
|
-
] })
|
|
237
|
-
] });
|
|
238
|
-
}
|
|
239
|
-
function EditGraphqlSource(props) {
|
|
240
|
-
const scopeId = useScope();
|
|
241
|
-
const userScope = useUserScope();
|
|
242
|
-
const sourceResult = useAtomValue(graphqlSourceAtom(scopeId, props.sourceId));
|
|
243
|
-
const source = AsyncResult.isSuccess(sourceResult) && sourceResult.value ? sourceResult.value : null;
|
|
244
|
-
const sourceScope = source ? ScopeId.make(source.scope) : scopeId;
|
|
245
|
-
const bindingsResult = useAtomValue(
|
|
246
|
-
graphqlSourceBindingsAtom(userScope, props.sourceId, sourceScope)
|
|
247
|
-
);
|
|
248
|
-
if (!AsyncResult.isSuccess(sourceResult) || !source || !AsyncResult.isSuccess(bindingsResult)) {
|
|
249
|
-
return /* @__PURE__ */ jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
250
|
-
/* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-foreground", children: "Edit GraphQL Source" }),
|
|
251
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Loading configuration\u2026" })
|
|
252
|
-
] }) });
|
|
253
|
-
}
|
|
254
|
-
return /* @__PURE__ */ jsx(
|
|
255
|
-
EditForm,
|
|
256
|
-
{
|
|
257
|
-
sourceId: props.sourceId,
|
|
258
|
-
initial: source,
|
|
259
|
-
bindings: bindingsResult.value,
|
|
260
|
-
onSave: props.onSave
|
|
261
|
-
}
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
export {
|
|
265
|
-
EditGraphqlSource as default
|
|
266
|
-
};
|
|
267
|
-
//# sourceMappingURL=EditGraphqlSource-YLTPUYW4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/EditGraphqlSource.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { useAtomValue, useAtomSet } from \"@effect/atom-react\";\nimport * as Exit from \"effect/Exit\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\nimport { graphqlSourceAtom, graphqlSourceBindingsAtom } from \"./atoms\";\nimport {\n configureSource,\n connectionsAtom,\n setSourceCredentialBinding,\n} from \"@executor-js/react/api/atoms\";\nimport { useScope, useUserScope } from \"@executor-js/react/api/scope-context\";\nimport { connectionWriteKeys, sourceWriteKeys } from \"@executor-js/react/api/reactivity-keys\";\nimport { useSecretPickerSecrets } from \"@executor-js/react/plugins/use-secret-picker-secrets\";\nimport {\n httpCredentialsFromConfiguredCredentialBindings,\n serializeHttpCredentials,\n type HttpCredentialsState,\n} from \"@executor-js/react/plugins/http-credentials\";\nimport { slugifyNamespace, useSourceIdentity } from \"@executor-js/react/plugins/source-identity\";\nimport { useCredentialTargetScope } from \"@executor-js/react/plugins/credential-target-scope\";\nimport {\n useSourceCredentialBindingScopes,\n useSourceCredentialBindingWriter,\n} from \"@executor-js/react/plugins/source-credential-bindings\";\nimport { Button } from \"@executor-js/react/components/button\";\nimport {\n CardStack,\n CardStackContent,\n CardStackEntry,\n CardStackEntryContent,\n CardStackEntryDescription,\n CardStackEntryTitle,\n} from \"@executor-js/react/components/card-stack\";\nimport { FilterTabs } from \"@executor-js/react/components/filter-tabs\";\nimport {\n SourceOAuthConnectionControl,\n sourceOAuthConnectionUiState,\n} from \"@executor-js/react/plugins/source-oauth-connection\";\nimport { Badge } from \"@executor-js/react/components/badge\";\nimport { type CredentialBindingRef, ScopeId } from \"@executor-js/sdk/shared\";\nimport {\n SecretCredentialSlotBindings,\n secretCredentialSlotsFromHttpConfig,\n} from \"@executor-js/react/plugins/credential-slot-bindings\";\nimport { GraphqlSourceFields } from \"./GraphqlSourceFields\";\nimport type { GraphqlSourceAuthInput } from \"../sdk/types\";\nimport type { StoredGraphqlSource } from \"../sdk/store\";\n\ntype EditableSource = StoredGraphqlSource;\ntype AuthMode = \"none\" | \"oauth2\";\n\n// ---------------------------------------------------------------------------\n// Edit form\n// ---------------------------------------------------------------------------\n\nfunction EditForm(props: {\n sourceId: string;\n initial: EditableSource;\n bindings: readonly CredentialBindingRef[];\n onSave: () => void;\n}) {\n const displayScope = useScope();\n const userScope = useUserScope();\n const sourceScope = ScopeId.make(props.initial.scope);\n const {\n credentialTargetScope: oauthCredentialTargetScope,\n setCredentialTargetScope: setOAuthCredentialTargetScope,\n } = useCredentialTargetScope({\n sourceScope,\n initialTargetScope: userScope,\n });\n const doConfigure = useAtomSet(configureSource, { mode: \"promiseExit\" });\n const setConnectionBinding = useAtomSet(setSourceCredentialBinding, { mode: \"promise\" });\n const secretList = useSecretPickerSecrets();\n const connectionsResult = useAtomValue(connectionsAtom(userScope));\n\n const identity = useSourceIdentity({\n fallbackName: props.initial.name,\n fallbackNamespace: props.initial.namespace,\n });\n const [endpoint, setEndpoint] = useState(props.initial.endpoint);\n const credentials = useMemo<HttpCredentialsState>(\n () =>\n httpCredentialsFromConfiguredCredentialBindings({\n headers: props.initial.headers,\n queryParams: props.initial.queryParams,\n bindings: props.bindings,\n }),\n [props.bindings, props.initial.headers, props.initial.queryParams],\n );\n const [authMode, setAuthMode] = useState<AuthMode>(props.initial.auth.kind);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [authDirty, setAuthDirty] = useState(false);\n const { busyKey, setSecretBinding, clearBinding } = useSourceCredentialBindingWriter({\n displayScope,\n source: { id: props.sourceId, scope: sourceScope },\n onError: setError,\n });\n\n const identityDirty = identity.name.trim() !== props.initial.name.trim();\n const metadataDirty = identityDirty || endpoint.trim() !== props.initial.endpoint.trim();\n const dirty = metadataDirty || authDirty;\n const oauth2 = props.initial.auth.kind === \"oauth2\" ? props.initial.auth : null;\n const connections = AsyncResult.isSuccess(connectionsResult) ? connectionsResult.value : [];\n const { credentialScopeOptions, secretBindingScopes, scopeRanks } =\n useSourceCredentialBindingScopes({ sourceScope });\n const secretSlots = secretCredentialSlotsFromHttpConfig({\n headers: props.initial.headers,\n queryParams: props.initial.queryParams,\n });\n const oauthConnectionState = oauth2\n ? sourceOAuthConnectionUiState({\n bindings: props.bindings,\n connectionSlot: oauth2.connectionSlot,\n tokenScope: oauthCredentialTargetScope,\n scopeRanks,\n credentialScopeOptions,\n connections,\n })\n : null;\n const oauthRequestCredentials = serializeHttpCredentials(credentials);\n\n const handleSave = async () => {\n setSaving(true);\n setError(null);\n const config: {\n name?: string;\n endpoint?: string;\n auth?: GraphqlSourceAuthInput;\n } = {\n name: metadataDirty ? identity.name.trim() || undefined : undefined,\n endpoint: metadataDirty ? endpoint.trim() || undefined : undefined,\n };\n if (authDirty) {\n config.auth = authMode === \"oauth2\" ? { oauth2: {} } : { kind: \"none\" };\n }\n const exit = await doConfigure({\n params: { scopeId: displayScope },\n payload: {\n source: { id: props.sourceId, scope: sourceScope },\n scope: sourceScope,\n type: \"graphql\",\n config,\n },\n reactivityKeys: sourceWriteKeys,\n });\n\n if (Exit.isFailure(exit)) {\n setError(\"Failed to update source\");\n setSaving(false);\n return;\n }\n\n setAuthDirty(false);\n props.onSave();\n setSaving(false);\n };\n\n return (\n <div className=\"space-y-6\">\n <div>\n <h1 className=\"text-xl font-semibold text-foreground\">Edit GraphQL Source</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">\n Update the endpoint and authentication headers for this source.\n </p>\n </div>\n\n <div className=\"flex items-center gap-3 rounded-lg border border-border bg-card px-4 py-3\">\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-semibold text-card-foreground\">{props.sourceId}</p>\n </div>\n <Badge variant=\"secondary\" className=\"text-xs\">\n GraphQL\n </Badge>\n </div>\n\n <GraphqlSourceFields\n endpoint={endpoint}\n onEndpointChange={setEndpoint}\n identity={identity}\n namespaceReadOnly\n />\n\n {secretSlots.length > 0 && (\n <CardStack>\n <CardStackContent className=\"border-t-0\">\n <CardStackEntry>\n <CardStackEntryContent>\n <CardStackEntryTitle>Request credentials</CardStackEntryTitle>\n <CardStackEntryDescription>\n Headers and query parameters sent with every GraphQL request.\n </CardStackEntryDescription>\n </CardStackEntryContent>\n </CardStackEntry>\n <SecretCredentialSlotBindings\n slots={secretSlots}\n bindingScopes={secretBindingScopes}\n bindingRows={props.bindings}\n scopeRanks={scopeRanks}\n secrets={secretList}\n sourceId={props.sourceId}\n sourceName={identity.name}\n credentialScopeOptions={credentialScopeOptions}\n busyKey={busyKey}\n onSetSecretBinding={setSecretBinding}\n onClearBinding={clearBinding}\n />\n </CardStackContent>\n </CardStack>\n )}\n\n {/* Temporarily hidden while we revisit GraphQL OAuth discovery and UX. */}\n <section className=\"hidden space-y-2.5\">\n <div className=\"flex items-center justify-between gap-3\">\n <span className=\"text-sm font-medium text-foreground\">Authentication</span>\n <FilterTabs<AuthMode>\n tabs={[\n { value: \"none\", label: \"None\" },\n { value: \"oauth2\", label: \"OAuth\" },\n ]}\n value={authMode}\n onChange={(value) => {\n setAuthMode(value);\n setAuthDirty(true);\n }}\n />\n </div>\n {authMode === \"oauth2\" && (\n <p className=\"text-xs text-muted-foreground\">\n OAuth sign-in is available from the source header after saving.\n </p>\n )}\n </section>\n\n {oauth2 && oauthConnectionState && (\n <SourceOAuthConnectionControl\n popupName=\"graphql-oauth\"\n pluginId=\"graphql\"\n namespace={slugifyNamespace(props.initial.namespace) || \"graphql\"}\n fallbackNamespace=\"graphql\"\n endpoint={endpoint.trim()}\n tokenScope={oauthCredentialTargetScope}\n onTokenScopeChange={setOAuthCredentialTargetScope}\n credentialScopeOptions={credentialScopeOptions}\n connectionId={oauthConnectionState.connectionId}\n sourceLabel={`${identity.name.trim() || props.initial.namespace || \"GraphQL\"} OAuth`}\n headers={oauthRequestCredentials.headers}\n queryParams={oauthRequestCredentials.queryParams}\n isConnected={oauthConnectionState.isConnected}\n buttonIsConnected={oauthConnectionState.buttonIsConnected}\n statusLabel={oauthConnectionState.statusLabel}\n onConnected={async (connectionId) => {\n await setConnectionBinding({\n params: { scopeId: oauthCredentialTargetScope },\n payload: {\n scope: oauthCredentialTargetScope,\n source: { id: props.sourceId, scope: sourceScope },\n slotKey: oauth2.connectionSlot,\n value: { kind: \"connection\", connectionId },\n },\n reactivityKeys: [...sourceWriteKeys, ...connectionWriteKeys],\n });\n }}\n signInLabel={oauthConnectionState.signInLabel}\n />\n )}\n\n {error && (\n <div className=\"rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2\">\n <p className=\"text-sm text-destructive\">{error}</p>\n </div>\n )}\n\n <div className=\"flex items-center justify-between border-t border-border pt-4\">\n <Button variant=\"ghost\" onClick={props.onSave}>\n Cancel\n </Button>\n <Button onClick={handleSave} disabled={!dirty || saving}>\n {saving ? \"Saving…\" : \"Save changes\"}\n </Button>\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Main component\n// ---------------------------------------------------------------------------\n\nexport default function EditGraphqlSource(props: { sourceId: string; onSave: () => void }) {\n const scopeId = useScope();\n const userScope = useUserScope();\n const sourceResult = useAtomValue(graphqlSourceAtom(scopeId, props.sourceId));\n const source =\n AsyncResult.isSuccess(sourceResult) && sourceResult.value ? sourceResult.value : null;\n const sourceScope = source ? ScopeId.make(source.scope) : scopeId;\n const bindingsResult = useAtomValue(\n graphqlSourceBindingsAtom(userScope, props.sourceId, sourceScope),\n );\n\n if (!AsyncResult.isSuccess(sourceResult) || !source || !AsyncResult.isSuccess(bindingsResult)) {\n return (\n <div className=\"space-y-6\">\n <div>\n <h1 className=\"text-xl font-semibold text-foreground\">Edit GraphQL Source</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">Loading configuration…</p>\n </div>\n </div>\n );\n }\n\n return (\n <EditForm\n sourceId={props.sourceId}\n initial={source as EditableSource}\n bindings={bindingsResult.value}\n onSave={props.onSave}\n />\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,cAAc,kBAAkB;AACzC,YAAY,UAAU;AACtB,YAAY,iBAAiB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,oBAAoB;AACvC,SAAS,qBAAqB,uBAAuB;AACrD,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB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FN3ZDA.js";
|
|
5
|
-
import "./chunk-UIAHATHP.js";
|
|
6
|
-
|
|
7
|
-
// src/react/GraphqlSourceSummary.tsx
|
|
8
|
-
import { useAtomValue } from "@effect/atom-react";
|
|
9
|
-
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
|
10
|
-
import { connectionsAtom } from "@executor-js/react/api/atoms";
|
|
11
|
-
import { useScope, useScopeStack, useUserScope } from "@executor-js/react/api/scope-context";
|
|
12
|
-
import {
|
|
13
|
-
SourceCredentialNotice,
|
|
14
|
-
SourceCredentialStatusBadge,
|
|
15
|
-
missingSourceCredentialLabels
|
|
16
|
-
} from "@executor-js/react/plugins/source-credential-status";
|
|
17
|
-
import { ScopeId } from "@executor-js/sdk/shared";
|
|
18
|
-
import { jsx } from "react/jsx-runtime";
|
|
19
|
-
var sourceCredentialSlots = (source) => {
|
|
20
|
-
const slots = [];
|
|
21
|
-
for (const [name, value] of Object.entries(source.headers)) {
|
|
22
|
-
if (typeof value !== "string") slots.push({ kind: "secret", slot: value.slot, label: name });
|
|
23
|
-
}
|
|
24
|
-
for (const [name, value] of Object.entries(source.queryParams)) {
|
|
25
|
-
if (typeof value !== "string") slots.push({ kind: "secret", slot: value.slot, label: name });
|
|
26
|
-
}
|
|
27
|
-
if (source.auth.kind === "oauth2") {
|
|
28
|
-
slots.push({
|
|
29
|
-
kind: "connection",
|
|
30
|
-
slot: source.auth.connectionSlot,
|
|
31
|
-
label: "OAuth sign-in"
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return slots;
|
|
35
|
-
};
|
|
36
|
-
function GraphqlSourceSummary(props) {
|
|
37
|
-
const displayScope = useScope();
|
|
38
|
-
const userScope = useUserScope();
|
|
39
|
-
const scopeStack = useScopeStack();
|
|
40
|
-
const sourceResult = useAtomValue(graphqlSourceAtom(displayScope, props.sourceId));
|
|
41
|
-
const source = AsyncResult.isSuccess(sourceResult) && sourceResult.value ? sourceResult.value : null;
|
|
42
|
-
const sourceScope = source ? ScopeId.make(source.scope) : displayScope;
|
|
43
|
-
const bindingsResult = useAtomValue(
|
|
44
|
-
graphqlSourceBindingsAtom(displayScope, props.sourceId, sourceScope)
|
|
45
|
-
);
|
|
46
|
-
const connectionsResult = useAtomValue(connectionsAtom(displayScope));
|
|
47
|
-
if (!source) return null;
|
|
48
|
-
const slots = sourceCredentialSlots(source);
|
|
49
|
-
if (slots.length === 0) return null;
|
|
50
|
-
if (!AsyncResult.isSuccess(bindingsResult) || !AsyncResult.isSuccess(connectionsResult)) {
|
|
51
|
-
return props.variant === "panel" ? null : /* @__PURE__ */ jsx(SourceCredentialStatusBadge, { missing: ["credentials"] });
|
|
52
|
-
}
|
|
53
|
-
const scopeRanks = new Map(scopeStack.map((scope, index) => [scope.id, index]));
|
|
54
|
-
const liveConnectionIds = new Set(connectionsResult.value.map((connection) => connection.id));
|
|
55
|
-
const missing = missingSourceCredentialLabels({
|
|
56
|
-
slots,
|
|
57
|
-
bindings: bindingsResult.value,
|
|
58
|
-
targetScope: userScope,
|
|
59
|
-
scopeRanks,
|
|
60
|
-
liveConnectionIds
|
|
61
|
-
});
|
|
62
|
-
if (props.variant === "panel") {
|
|
63
|
-
return /* @__PURE__ */ jsx(SourceCredentialNotice, { missing, onAction: props.onAction });
|
|
64
|
-
}
|
|
65
|
-
return /* @__PURE__ */ jsx(SourceCredentialStatusBadge, { missing });
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
GraphqlSourceSummary as default
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=GraphqlSourceSummary-YWJX6ONU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/GraphqlSourceSummary.tsx"],"sourcesContent":["import { useAtomValue } from \"@effect/atom-react\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\n\nimport { connectionsAtom } from \"@executor-js/react/api/atoms\";\nimport { useScope, useScopeStack, useUserScope } from \"@executor-js/react/api/scope-context\";\nimport {\n SourceCredentialNotice,\n SourceCredentialStatusBadge,\n missingSourceCredentialLabels,\n type SourceCredentialSlot,\n} from \"@executor-js/react/plugins/source-credential-status\";\nimport { ScopeId } from \"@executor-js/sdk/shared\";\n\nimport { graphqlSourceAtom, graphqlSourceBindingsAtom } from \"./atoms\";\nimport type { StoredGraphqlSource } from \"../sdk/store\";\n\nconst sourceCredentialSlots = (source: StoredGraphqlSource): readonly SourceCredentialSlot[] => {\n const slots: SourceCredentialSlot[] = [];\n for (const [name, value] of Object.entries(source.headers)) {\n if (typeof value !== \"string\") slots.push({ kind: \"secret\", slot: value.slot, label: name });\n }\n for (const [name, value] of Object.entries(source.queryParams)) {\n if (typeof value !== \"string\") slots.push({ kind: \"secret\", slot: value.slot, label: name });\n }\n if (source.auth.kind === \"oauth2\") {\n slots.push({\n kind: \"connection\",\n slot: source.auth.connectionSlot,\n label: \"OAuth sign-in\",\n });\n }\n return slots;\n};\n\nexport default function GraphqlSourceSummary(props: {\n sourceId: string;\n variant?: \"badge\" | \"panel\";\n onAction?: () => void;\n}) {\n const displayScope = useScope();\n const userScope = useUserScope();\n const scopeStack = useScopeStack();\n const sourceResult = useAtomValue(graphqlSourceAtom(displayScope, props.sourceId));\n const source =\n AsyncResult.isSuccess(sourceResult) && sourceResult.value ? sourceResult.value : null;\n const sourceScope = source ? ScopeId.make(source.scope) : displayScope;\n const bindingsResult = useAtomValue(\n graphqlSourceBindingsAtom(displayScope, props.sourceId, sourceScope),\n );\n const connectionsResult = useAtomValue(connectionsAtom(displayScope));\n\n if (!source) return null;\n const slots = sourceCredentialSlots(source as StoredGraphqlSource);\n if (slots.length === 0) return null;\n if (!AsyncResult.isSuccess(bindingsResult) || !AsyncResult.isSuccess(connectionsResult)) {\n return props.variant === \"panel\" ? null : (\n <SourceCredentialStatusBadge missing={[\"credentials\"]} />\n );\n }\n\n const scopeRanks = new Map(scopeStack.map((scope, index) => [scope.id, index] as const));\n const liveConnectionIds = new Set(connectionsResult.value.map((connection) => connection.id));\n const missing = missingSourceCredentialLabels({\n slots,\n bindings: bindingsResult.value,\n targetScope: userScope,\n scopeRanks,\n liveConnectionIds,\n });\n\n if (props.variant === \"panel\") {\n return <SourceCredentialNotice missing={missing} onAction={props.onAction} />;\n }\n\n return <SourceCredentialStatusBadge missing={missing} />;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,oBAAoB;AAC7B,YAAY,iBAAiB;AAE7B,SAAS,uBAAuB;AAChC,SAAS,UAAU,eAAe,oBAAoB;AACtD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,eAAe;AA6ClB;AAxCN,IAAM,wBAAwB,CAAC,WAAiE;AAC9F,QAAM,QAAgC,CAAC;AACvC,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,OAAO,OAAO,GAAG;AAC1D,QAAI,OAAO,UAAU,SAAU,OAAM,KAAK,EAAE,MAAM,UAAU,MAAM,MAAM,MAAM,OAAO,KAAK,CAAC;AAAA,EAC7F;AACA,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,OAAO,WAAW,GAAG;AAC9D,QAAI,OAAO,UAAU,SAAU,OAAM,KAAK,EAAE,MAAM,UAAU,MAAM,MAAM,MAAM,OAAO,KAAK,CAAC;AAAA,EAC7F;AACA,MAAI,OAAO,KAAK,SAAS,UAAU;AACjC,UAAM,KAAK;AAAA,MACT,MAAM;AAAA,MACN,MAAM,OAAO,KAAK;AAAA,MAClB,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEe,SAAR,qBAAsC,OAI1C;AACD,QAAM,eAAe,SAAS;AAC9B,QAAM,YAAY,aAAa;AAC/B,QAAM,aAAa,cAAc;AACjC,QAAM,eAAe,aAAa,kBAAkB,cAAc,MAAM,QAAQ,CAAC;AACjF,QAAM,SACQ,sBAAU,YAAY,KAAK,aAAa,QAAQ,aAAa,QAAQ;AACnF,QAAM,cAAc,SAAS,QAAQ,KAAK,OAAO,KAAK,IAAI;A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