@executor-js/plugin-graphql 0.1.0 → 1.4.20

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.
Files changed (37) hide show
  1. package/dist/AddGraphqlSource-3Z3DB4KQ.js +239 -0
  2. package/dist/AddGraphqlSource-3Z3DB4KQ.js.map +1 -0
  3. package/dist/EditGraphqlSource-F37RPNKV.js +251 -0
  4. package/dist/EditGraphqlSource-F37RPNKV.js.map +1 -0
  5. package/dist/GraphqlSourceSummary-6EYBXVD2.js +70 -0
  6. package/dist/GraphqlSourceSummary-6EYBXVD2.js.map +1 -0
  7. package/dist/api/group.d.ts +204 -13
  8. package/dist/api/handlers.d.ts +51 -3
  9. package/dist/api/index.d.ts +482 -0
  10. package/dist/chunk-445ZPXHU.js +148 -0
  11. package/dist/chunk-445ZPXHU.js.map +1 -0
  12. package/dist/chunk-EW4Y3KEX.js +182 -0
  13. package/dist/chunk-EW4Y3KEX.js.map +1 -0
  14. package/dist/chunk-M4SJY6CB.js +45 -0
  15. package/dist/chunk-M4SJY6CB.js.map +1 -0
  16. package/dist/chunk-PO2TPM5B.js +1636 -0
  17. package/dist/chunk-PO2TPM5B.js.map +1 -0
  18. package/dist/client.js +75 -0
  19. package/dist/client.js.map +1 -0
  20. package/dist/core.js +32 -10
  21. package/dist/index.js +2 -1
  22. package/dist/react/GraphqlSourceFields.d.ts +8 -0
  23. package/dist/react/GraphqlSourceSummary.d.ts +3 -1
  24. package/dist/react/atoms.d.ts +206 -10
  25. package/dist/react/client.d.ts +200 -12
  26. package/dist/sdk/index.d.ts +1 -1
  27. package/dist/sdk/introspect.d.ts +437 -43
  28. package/dist/sdk/invoke.d.ts +17 -3
  29. package/dist/sdk/plugin.d.ts +192 -170
  30. package/dist/sdk/store.d.ts +84 -11
  31. package/dist/sdk/types.d.ts +129 -30
  32. package/dist/testing/index.d.ts +52 -0
  33. package/dist/testing.js +131 -0
  34. package/dist/testing.js.map +1 -0
  35. package/package.json +18 -4
  36. package/dist/chunk-EIC5WI6C.js +0 -1225
  37. package/dist/chunk-EIC5WI6C.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/types.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nexport class GraphqlIntrospectionError extends Schema.TaggedErrorClass<GraphqlIntrospectionError>()(\n \"GraphqlIntrospectionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlExtractionError extends Schema.TaggedErrorClass<GraphqlExtractionError>()(\n \"GraphqlExtractionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlInvocationError extends Data.TaggedError(\"GraphqlInvocationError\")<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n","import { Effect, Schema } from \"effect\";\nimport {\n ConfiguredCredentialValue,\n CredentialBindingValue,\n credentialSlotKey,\n ScopedSecretCredentialInput,\n SecretBackedValue,\n ScopeId,\n} from \"@executor-js/sdk/core\";\n\n// ---------------------------------------------------------------------------\n// GraphQL operation kind\n// ---------------------------------------------------------------------------\n\nexport const GraphqlOperationKind = Schema.Literals([\"query\", \"mutation\"]);\nexport type GraphqlOperationKind = typeof GraphqlOperationKind.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted field (becomes a tool)\n// ---------------------------------------------------------------------------\n\nexport const GraphqlArgument = Schema.Struct({\n name: Schema.String,\n typeName: Schema.String,\n required: Schema.Boolean,\n description: Schema.OptionFromOptional(Schema.String),\n});\nexport type GraphqlArgument = typeof GraphqlArgument.Type;\n\nexport const ExtractedField = Schema.Struct({\n /** e.g. \"user\", \"createUser\" */\n fieldName: Schema.String,\n /** \"query\" or \"mutation\" */\n kind: GraphqlOperationKind,\n description: Schema.OptionFromOptional(Schema.String),\n arguments: Schema.Array(GraphqlArgument),\n /** JSON Schema for the input (built from arguments) */\n inputSchema: Schema.OptionFromOptional(Schema.Unknown),\n /** The return type name for documentation */\n returnTypeName: Schema.String,\n});\nexport type ExtractedField = typeof ExtractedField.Type;\n\nexport const ExtractionResult = Schema.Struct({\n /** Schema name from introspection */\n schemaName: Schema.OptionFromOptional(Schema.String),\n fields: Schema.Array(ExtractedField),\n});\nexport type ExtractionResult = typeof ExtractionResult.Type;\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal data needed to invoke\n// ---------------------------------------------------------------------------\n\nexport const OperationBinding = Schema.Struct({\n kind: GraphqlOperationKind,\n fieldName: Schema.String,\n /** The full GraphQL query/mutation string */\n operationString: Schema.String,\n /** Ordered variable names for mapping */\n variableNames: Schema.Array(Schema.String),\n});\nexport type OperationBinding = typeof OperationBinding.Type;\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const HeaderValue = SecretBackedValue;\nexport type HeaderValue = typeof HeaderValue.Type;\nexport const QueryParamValue = HeaderValue;\nexport type QueryParamValue = typeof QueryParamValue.Type;\n\nexport const ConfiguredGraphqlCredentialValue = ConfiguredCredentialValue;\nexport type ConfiguredGraphqlCredentialValue = typeof ConfiguredGraphqlCredentialValue.Type;\nexport const GraphqlCredentialInput = Schema.Union([\n ScopedSecretCredentialInput,\n HeaderValue,\n ConfiguredGraphqlCredentialValue,\n]);\nexport type GraphqlCredentialInput = typeof GraphqlCredentialInput.Type;\n\nexport const graphqlHeaderSlot = (name: string): string => credentialSlotKey(\"header\", name);\nexport const graphqlQueryParamSlot = (name: string): string =>\n credentialSlotKey(\"query_param\", name);\nexport const GRAPHQL_OAUTH_CONNECTION_SLOT = \"auth:oauth2:connection\";\n\n// ---------------------------------------------------------------------------\n// Source auth\n// ---------------------------------------------------------------------------\n\nexport const GraphqlSourceAuth = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"none\") }),\n Schema.Struct({\n kind: Schema.Literal(\"oauth2\"),\n connectionSlot: Schema.String,\n }),\n]);\nexport type GraphqlSourceAuth = typeof GraphqlSourceAuth.Type;\n\nexport const GraphqlSourceAuthInput = Schema.Union([\n GraphqlSourceAuth,\n Schema.Struct({\n kind: Schema.Literal(\"oauth2\"),\n connectionId: Schema.String,\n }),\n]);\nexport type GraphqlSourceAuthInput = typeof GraphqlSourceAuthInput.Type;\n\nexport const GraphqlSourceBindingValue = CredentialBindingValue;\nexport type GraphqlSourceBindingValue = typeof GraphqlSourceBindingValue.Type;\n\nexport const GraphqlSourceBindingInput = Schema.Struct({\n sourceId: Schema.String,\n sourceScope: ScopeId,\n scope: ScopeId,\n slot: Schema.String,\n value: GraphqlSourceBindingValue,\n});\nexport type GraphqlSourceBindingInput = typeof GraphqlSourceBindingInput.Type;\n\nexport const GraphqlSourceBindingRef = Schema.Struct({\n sourceId: Schema.String,\n sourceScopeId: ScopeId,\n scopeId: ScopeId,\n slot: Schema.String,\n value: GraphqlSourceBindingValue,\n createdAt: Schema.Date,\n updatedAt: Schema.Date,\n});\nexport type GraphqlSourceBindingRef = typeof GraphqlSourceBindingRef.Type;\n\nexport const InvocationConfig = Schema.Struct({\n /** The GraphQL endpoint URL */\n endpoint: Schema.String,\n /** Headers applied to every request. Values can reference secrets. */\n headers: Schema.Record(Schema.String, ConfiguredGraphqlCredentialValue).pipe(\n Schema.withDecodingDefault(Effect.succeed({})),\n Schema.withConstructorDefault(Effect.succeed({})),\n ),\n /** Query parameters applied to every request. Values can reference secrets. */\n queryParams: Schema.Record(Schema.String, ConfiguredGraphqlCredentialValue).pipe(\n Schema.withDecodingDefault(Effect.succeed({})),\n Schema.withConstructorDefault(Effect.succeed({})),\n ),\n});\nexport type InvocationConfig = typeof InvocationConfig.Type;\n\nexport const InvocationResult = Schema.Struct({\n status: Schema.Number,\n data: Schema.NullOr(Schema.Unknown),\n errors: Schema.NullOr(Schema.Unknown),\n});\nexport type InvocationResult = typeof InvocationResult.Type;\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AAGtB,IAAM,4BAAN,cAAwC,OAAO,iBAA4C;AAAA,EAChG;AAAA,EACA;AAAA,IACE,SAAS,OA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AAOA,QAAO,QAAQ,gCAAgC,EAAE;AAAA,IAC1EA,QAAO,oBAAoB,OAAO,QAAQ,CAAC,CAAC,CAAC;AAAA,IAC7CA,QAAO,uBAAuB,OAAO,QAAQ,CAAC,CAAC,CAAC;AAAA,EAClD;AACF,CAAC;AAGM,IAAM,mBAAmBA,QAAO,OAAO;AAAA,EAC5C,QAAQA,QAAO;AAAA,EACf,MAAMA,QAAO,OAAOA,QAAO,OAAO;AAAA,EAClC,QAAQA,QAAO,OAAOA,QAAO,OAAO;AACtC,CAAC;","names":["Schema"]}
@@ -0,0 +1,182 @@
1
+ import {
2
+ ConfiguredGraphqlCredentialValue,
3
+ GraphqlCredentialInput,
4
+ GraphqlExtractionError,
5
+ GraphqlIntrospectionError,
6
+ GraphqlSourceAuth,
7
+ GraphqlSourceAuthInput,
8
+ GraphqlSourceBindingInput,
9
+ GraphqlSourceBindingRef
10
+ } from "./chunk-445ZPXHU.js";
11
+
12
+ // src/react/atoms.ts
13
+ import * as Atom from "effect/unstable/reactivity/Atom";
14
+ import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
15
+ import { sourcesOptimisticAtom } from "@executor-js/react/api/atoms";
16
+ import { ReactivityKey } from "@executor-js/react/api/reactivity-keys";
17
+
18
+ // src/react/client.ts
19
+ import { createPluginAtomClient } from "@executor-js/sdk/client";
20
+ import { getBaseUrl } from "@executor-js/react/api/base-url";
21
+
22
+ // src/api/group.ts
23
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
24
+ import { Schema } from "effect";
25
+ import { InternalError, ScopeId } from "@executor-js/sdk/core";
26
+ var StoredSourceSchema = Schema.Struct({
27
+ namespace: Schema.String,
28
+ scope: ScopeId,
29
+ name: Schema.String,
30
+ endpoint: Schema.String,
31
+ headers: Schema.Record(Schema.String, ConfiguredGraphqlCredentialValue),
32
+ queryParams: Schema.Record(Schema.String, ConfiguredGraphqlCredentialValue),
33
+ auth: GraphqlSourceAuth
34
+ });
35
+ var ScopeParams = {
36
+ scopeId: ScopeId
37
+ };
38
+ var SourceParams = {
39
+ scopeId: ScopeId,
40
+ namespace: Schema.String
41
+ };
42
+ var SourceBindingParams = {
43
+ scopeId: ScopeId,
44
+ namespace: Schema.String,
45
+ sourceScopeId: ScopeId
46
+ };
47
+ var AddSourcePayload = Schema.Struct({
48
+ targetScope: ScopeId,
49
+ endpoint: Schema.String,
50
+ name: Schema.optional(Schema.String),
51
+ introspectionJson: Schema.optional(Schema.String),
52
+ namespace: Schema.optional(Schema.String),
53
+ headers: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),
54
+ queryParams: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),
55
+ credentialTargetScope: Schema.optional(ScopeId),
56
+ auth: Schema.optional(GraphqlSourceAuthInput)
57
+ });
58
+ var UpdateSourcePayload = Schema.Struct({
59
+ sourceScope: ScopeId,
60
+ name: Schema.optional(Schema.String),
61
+ endpoint: Schema.optional(Schema.String),
62
+ headers: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),
63
+ queryParams: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),
64
+ credentialTargetScope: Schema.optional(ScopeId),
65
+ auth: Schema.optional(GraphqlSourceAuthInput)
66
+ });
67
+ var UpdateSourceResponse = Schema.Struct({
68
+ updated: Schema.Boolean
69
+ });
70
+ var RemoveBindingPayload = Schema.Struct({
71
+ sourceId: Schema.String,
72
+ sourceScope: ScopeId,
73
+ slot: Schema.String,
74
+ scope: ScopeId
75
+ });
76
+ var AddSourceResponse = Schema.Struct({
77
+ toolCount: Schema.Number,
78
+ namespace: Schema.String
79
+ });
80
+ var IntrospectionError = GraphqlIntrospectionError.annotate({ httpApiStatus: 400 });
81
+ var ExtractionError = GraphqlExtractionError.annotate({ httpApiStatus: 400 });
82
+ var GraphqlErrors = [InternalError, IntrospectionError, ExtractionError];
83
+ var GraphqlGroup = HttpApiGroup.make("graphql").add(
84
+ HttpApiEndpoint.post("addSource", "/scopes/:scopeId/graphql/sources", {
85
+ params: ScopeParams,
86
+ payload: AddSourcePayload,
87
+ success: AddSourceResponse,
88
+ error: GraphqlErrors
89
+ })
90
+ ).add(
91
+ HttpApiEndpoint.get("getSource", "/scopes/:scopeId/graphql/sources/:namespace", {
92
+ params: SourceParams,
93
+ success: Schema.NullOr(StoredSourceSchema),
94
+ error: GraphqlErrors
95
+ })
96
+ ).add(
97
+ HttpApiEndpoint.patch("updateSource", "/scopes/:scopeId/graphql/sources/:namespace", {
98
+ params: SourceParams,
99
+ payload: UpdateSourcePayload,
100
+ success: UpdateSourceResponse,
101
+ error: GraphqlErrors
102
+ })
103
+ ).add(
104
+ HttpApiEndpoint.get(
105
+ "listSourceBindings",
106
+ "/scopes/:scopeId/graphql/sources/:namespace/base/:sourceScopeId/bindings",
107
+ {
108
+ params: SourceBindingParams,
109
+ success: Schema.Array(GraphqlSourceBindingRef),
110
+ error: GraphqlErrors
111
+ }
112
+ )
113
+ ).add(
114
+ HttpApiEndpoint.post("setSourceBinding", "/scopes/:scopeId/graphql/source-bindings", {
115
+ params: ScopeParams,
116
+ payload: GraphqlSourceBindingInput,
117
+ success: GraphqlSourceBindingRef,
118
+ error: GraphqlErrors
119
+ })
120
+ ).add(
121
+ HttpApiEndpoint.post("removeSourceBinding", "/scopes/:scopeId/graphql/source-bindings/remove", {
122
+ params: ScopeParams,
123
+ payload: RemoveBindingPayload,
124
+ success: Schema.Struct({ removed: Schema.Boolean }),
125
+ error: GraphqlErrors
126
+ })
127
+ );
128
+
129
+ // src/react/client.ts
130
+ var GraphqlClient = createPluginAtomClient(GraphqlGroup, {
131
+ baseUrl: getBaseUrl
132
+ });
133
+
134
+ // src/react/atoms.ts
135
+ var graphqlSourceAtom = (scopeId, namespace) => GraphqlClient.query("graphql", "getSource", {
136
+ params: { scopeId, namespace },
137
+ timeToLive: "15 seconds",
138
+ reactivityKeys: [ReactivityKey.sources, ReactivityKey.tools]
139
+ });
140
+ var graphqlSourceBindingsAtom = (scopeId, namespace, sourceScopeId) => GraphqlClient.query("graphql", "listSourceBindings", {
141
+ params: { scopeId, namespace, sourceScopeId },
142
+ timeToLive: "15 seconds",
143
+ reactivityKeys: [ReactivityKey.sources, ReactivityKey.secrets, ReactivityKey.connections]
144
+ });
145
+ var addGraphqlSource = GraphqlClient.mutation("graphql", "addSource");
146
+ var addGraphqlSourceOptimistic = Atom.family(
147
+ (scopeId) => sourcesOptimisticAtom(scopeId).pipe(
148
+ Atom.optimisticFn({
149
+ reducer: (current, arg) => AsyncResult.map(current, (rows) => {
150
+ const id = arg.payload.namespace ?? `pending-${Math.random().toString(36).slice(2)}`;
151
+ const source = {
152
+ id,
153
+ scopeId: arg.payload.targetScope,
154
+ kind: "graphql",
155
+ pluginId: "graphql",
156
+ name: arg.payload.name ?? id,
157
+ url: arg.payload.endpoint,
158
+ canRemove: false,
159
+ canRefresh: false,
160
+ canEdit: false,
161
+ runtime: false
162
+ };
163
+ return [source, ...rows.filter((row) => row.id !== id)].sort(
164
+ (a, b) => a.name.localeCompare(b.name)
165
+ );
166
+ }),
167
+ fn: addGraphqlSource
168
+ })
169
+ )
170
+ );
171
+ var updateGraphqlSource = GraphqlClient.mutation("graphql", "updateSource");
172
+ var setGraphqlSourceBinding = GraphqlClient.mutation("graphql", "setSourceBinding");
173
+ var removeGraphqlSourceBinding = GraphqlClient.mutation("graphql", "removeSourceBinding");
174
+
175
+ export {
176
+ graphqlSourceAtom,
177
+ graphqlSourceBindingsAtom,
178
+ addGraphqlSourceOptimistic,
179
+ updateGraphqlSource,
180
+ setGraphqlSourceBinding
181
+ };
182
+ //# sourceMappingURL=chunk-EW4Y3KEX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/atoms.ts","../src/react/client.ts","../src/api/group.ts"],"sourcesContent":["import type { ScopeId } from \"@executor-js/sdk/core\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\nimport { sourcesOptimisticAtom } from \"@executor-js/react/api/atoms\";\nimport { ReactivityKey } from \"@executor-js/react/api/reactivity-keys\";\nimport { GraphqlClient } from \"./client\";\n\n// ---------------------------------------------------------------------------\n// Query atoms\n// ---------------------------------------------------------------------------\n\nexport const graphqlSourceAtom = (scopeId: ScopeId, namespace: string) =>\n GraphqlClient.query(\"graphql\", \"getSource\", {\n params: { scopeId, namespace },\n timeToLive: \"15 seconds\",\n reactivityKeys: [ReactivityKey.sources, ReactivityKey.tools],\n });\n\nexport const graphqlSourceBindingsAtom = (\n scopeId: ScopeId,\n namespace: string,\n sourceScopeId: ScopeId,\n) =>\n GraphqlClient.query(\"graphql\", \"listSourceBindings\", {\n params: { scopeId, namespace, sourceScopeId },\n timeToLive: \"15 seconds\",\n reactivityKeys: [ReactivityKey.sources, ReactivityKey.secrets, ReactivityKey.connections],\n });\n\n// ---------------------------------------------------------------------------\n// Mutation atoms\n// ---------------------------------------------------------------------------\n\nexport const addGraphqlSource = GraphqlClient.mutation(\"graphql\", \"addSource\");\n\nexport const addGraphqlSourceOptimistic = Atom.family((scopeId: ScopeId) =>\n sourcesOptimisticAtom(scopeId).pipe(\n Atom.optimisticFn({\n reducer: (current, arg) =>\n AsyncResult.map(current, (rows) => {\n const id = arg.payload.namespace ?? `pending-${Math.random().toString(36).slice(2)}`;\n const source = {\n id,\n scopeId: arg.payload.targetScope,\n kind: \"graphql\",\n pluginId: \"graphql\",\n name: arg.payload.name ?? id,\n url: arg.payload.endpoint,\n canRemove: false,\n canRefresh: false,\n canEdit: false,\n runtime: false,\n };\n return [source, ...rows.filter((row) => row.id !== id)].sort((a, b) =>\n a.name.localeCompare(b.name),\n );\n }),\n fn: addGraphqlSource,\n }),\n ),\n);\n\nexport const updateGraphqlSource = GraphqlClient.mutation(\"graphql\", \"updateSource\");\n\nexport const setGraphqlSourceBinding = GraphqlClient.mutation(\"graphql\", \"setSourceBinding\");\n\nexport const removeGraphqlSourceBinding = GraphqlClient.mutation(\"graphql\", \"removeSourceBinding\");\n","import { createPluginAtomClient } from \"@executor-js/sdk/client\";\nimport { getBaseUrl } from \"@executor-js/react/api/base-url\";\nimport { GraphqlGroup } from \"../api/group\";\n\nexport const GraphqlClient = createPluginAtomClient(GraphqlGroup, {\n baseUrl: getBaseUrl,\n});\n","import { HttpApiEndpoint, HttpApiGroup } from \"effect/unstable/httpapi\";\nimport { Schema } from \"effect\";\nimport { InternalError, ScopeId } from \"@executor-js/sdk/core\";\n\nimport { GraphqlIntrospectionError, GraphqlExtractionError } from \"../sdk/errors\";\nimport {\n ConfiguredGraphqlCredentialValue,\n GraphqlCredentialInput,\n GraphqlSourceAuth,\n GraphqlSourceAuthInput,\n GraphqlSourceBindingInput,\n GraphqlSourceBindingRef,\n} from \"../sdk/types\";\n\n// StoredGraphqlSource shape as an HTTP response schema. Kept local to the\n// api layer because the sdk-side `StoredGraphqlSource` is a plain interface.\nexport const StoredSourceSchema = Schema.Struct({\n namespace: Schema.String,\n scope: ScopeId,\n name: Schema.String,\n endpoint: Schema.String,\n headers: Schema.Record(Schema.String, ConfiguredGraphqlCredentialValue),\n queryParams: Schema.Record(Schema.String, ConfiguredGraphqlCredentialValue),\n auth: GraphqlSourceAuth,\n});\n\n// ---------------------------------------------------------------------------\n// Params\n// ---------------------------------------------------------------------------\n\nconst ScopeParams = {\n scopeId: ScopeId,\n};\n\nconst SourceParams = {\n scopeId: ScopeId,\n namespace: Schema.String,\n};\n\nconst SourceBindingParams = {\n scopeId: ScopeId,\n namespace: Schema.String,\n sourceScopeId: ScopeId,\n};\n\n// ---------------------------------------------------------------------------\n// Payloads\n// ---------------------------------------------------------------------------\n\nconst AddSourcePayload = Schema.Struct({\n targetScope: ScopeId,\n endpoint: Schema.String,\n name: Schema.optional(Schema.String),\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),\n queryParams: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),\n credentialTargetScope: Schema.optional(ScopeId),\n auth: Schema.optional(GraphqlSourceAuthInput),\n});\n\nconst UpdateSourcePayload = Schema.Struct({\n sourceScope: ScopeId,\n name: Schema.optional(Schema.String),\n endpoint: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),\n queryParams: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInput)),\n credentialTargetScope: Schema.optional(ScopeId),\n auth: Schema.optional(GraphqlSourceAuthInput),\n});\n\nconst UpdateSourceResponse = Schema.Struct({\n updated: Schema.Boolean,\n});\n\nconst RemoveBindingPayload = Schema.Struct({\n sourceId: Schema.String,\n sourceScope: ScopeId,\n slot: Schema.String,\n scope: ScopeId,\n});\n\n// ---------------------------------------------------------------------------\n// Responses\n// ---------------------------------------------------------------------------\n\nconst AddSourceResponse = Schema.Struct({\n toolCount: Schema.Number,\n namespace: Schema.String,\n});\n\n// ---------------------------------------------------------------------------\n// Errors with HTTP status\n// ---------------------------------------------------------------------------\n\nconst IntrospectionError = GraphqlIntrospectionError.annotate({ httpApiStatus: 400 });\nconst ExtractionError = GraphqlExtractionError.annotate({ httpApiStatus: 400 });\n\n// ---------------------------------------------------------------------------\n// Group\n//\n// Plugin SDK errors (GraphqlIntrospectionError etc.) are declared once at\n// the group level via `.addError(...)` — every endpoint inherits them. The\n// errors themselves carry their HTTP status via `HttpApiSchema.annotations`\n// above, so handlers just `return yield* ext.foo(...)` and the schema\n// encodes whatever it gets.\n//\n// 5xx is handled at the API level: `.addError(InternalError)` adds a\n// single shared opaque-by-schema 500 surface translated from `StorageError`\n// by `withCapture` at the HTTP edge. No per-handler wrapping, no\n// per-plugin InternalError.\n// ---------------------------------------------------------------------------\n\nconst GraphqlErrors = [InternalError, IntrospectionError, ExtractionError] as const;\n\nexport const GraphqlGroup = HttpApiGroup.make(\"graphql\")\n .add(\n HttpApiEndpoint.post(\"addSource\", \"/scopes/:scopeId/graphql/sources\", {\n params: ScopeParams,\n payload: AddSourcePayload,\n success: AddSourceResponse,\n error: GraphqlErrors,\n }),\n )\n .add(\n HttpApiEndpoint.get(\"getSource\", \"/scopes/:scopeId/graphql/sources/:namespace\", {\n params: SourceParams,\n success: Schema.NullOr(StoredSourceSchema),\n error: GraphqlErrors,\n }),\n )\n .add(\n HttpApiEndpoint.patch(\"updateSource\", \"/scopes/:scopeId/graphql/sources/:namespace\", {\n params: SourceParams,\n payload: UpdateSourcePayload,\n success: UpdateSourceResponse,\n error: GraphqlErrors,\n }),\n )\n .add(\n HttpApiEndpoint.get(\n \"listSourceBindings\",\n \"/scopes/:scopeId/graphql/sources/:namespace/base/:sourceScopeId/bindings\",\n {\n params: SourceBindingParams,\n success: Schema.Array(GraphqlSourceBindingRef),\n error: GraphqlErrors,\n },\n ),\n )\n .add(\n HttpApiEndpoint.post(\"setSourceBinding\", \"/scopes/:scopeId/graphql/source-bindings\", {\n params: ScopeParams,\n payload: GraphqlSourceBindingInput,\n success: GraphqlSourceBindingRef,\n error: GraphqlErrors,\n }),\n )\n .add(\n HttpApiEndpoint.post(\"removeSourceBinding\", \"/scopes/:scopeId/graphql/source-bindings/remove\", {\n params: ScopeParams,\n payload: RemoveBindingPayload,\n success: Schema.Struct({ removed: Schema.Boolean }),\n error: GraphqlErrors,\n }),\n );\n// Plugin domain errors carry their own HTTP status (4xx);\n// `InternalError` is the shared opaque 500 translated at the HTTP edge.\n"],"mappings":";;;;;;;;;;;;AACA,YAAY,UAAU;AACtB,YAAY,iBAAiB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;;;ACJ9B,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;;;ACD3B,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,cAAc;AACvB,SAAS,eAAe,eAAe;AAchC,IAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C,WAAW,OAAO;AAAA,EAClB,OAAO;AAAA,EACP,MAAM,OAAO;AAAA,EACb,UAAU,OAAO;AAAA,EACjB,SAAS,OAAO,OAAO,OAAO,Q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EO,IAAM,sBAAsB,cAAc,SAAS,WAAW,cAAc;AAE5E,IAAM,0BAA0B,cAAc,SAAS,WAAW,kBAAkB;AAEpF,IAAM,6BAA6B,cAAc,SAAS,WAAW,qBAAqB;","names":[]}
@@ -0,0 +1,45 @@
1
+ // src/react/GraphqlSourceFields.tsx
2
+ import {
3
+ CardStack,
4
+ CardStackContent,
5
+ CardStackEntryField
6
+ } from "@executor-js/react/components/card-stack";
7
+ import { Input } from "@executor-js/react/components/input";
8
+ import {
9
+ SourceIdentityFieldRows
10
+ } from "@executor-js/react/plugins/source-identity";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ function GraphqlSourceFields(props) {
13
+ return /* @__PURE__ */ jsx(CardStack, { children: /* @__PURE__ */ jsxs(CardStackContent, { className: "border-t-0", children: [
14
+ /* @__PURE__ */ jsx(
15
+ CardStackEntryField,
16
+ {
17
+ label: "Endpoint",
18
+ hint: "The endpoint will be introspected to discover available queries and mutations.",
19
+ children: /* @__PURE__ */ jsx(
20
+ Input,
21
+ {
22
+ value: props.endpoint,
23
+ onChange: (e) => props.onEndpointChange(e.target.value),
24
+ placeholder: "https://api.example.com/graphql",
25
+ className: "font-mono text-sm",
26
+ disabled: props.endpointDisabled
27
+ }
28
+ )
29
+ }
30
+ ),
31
+ /* @__PURE__ */ jsx(
32
+ SourceIdentityFieldRows,
33
+ {
34
+ identity: props.identity,
35
+ namePlaceholder: "e.g. Shopify API",
36
+ namespaceReadOnly: props.namespaceReadOnly
37
+ }
38
+ )
39
+ ] }) });
40
+ }
41
+
42
+ export {
43
+ GraphqlSourceFields
44
+ };
45
+ //# sourceMappingURL=chunk-M4SJY6CB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/GraphqlSourceFields.tsx"],"sourcesContent":["import {\n CardStack,\n CardStackContent,\n CardStackEntryField,\n} from \"@executor-js/react/components/card-stack\";\nimport { Input } from \"@executor-js/react/components/input\";\nimport {\n SourceIdentityFieldRows,\n type SourceIdentity,\n} from \"@executor-js/react/plugins/source-identity\";\n\nexport function GraphqlSourceFields(props: {\n readonly endpoint: string;\n readonly onEndpointChange: (endpoint: string) => void;\n readonly identity: SourceIdentity;\n readonly endpointDisabled?: boolean;\n readonly namespaceReadOnly?: boolean;\n}) {\n return (\n <CardStack>\n <CardStackContent className=\"border-t-0\">\n <CardStackEntryField\n label=\"Endpoint\"\n hint=\"The endpoint will be introspected to discover available queries and mutations.\"\n >\n <Input\n value={props.endpoint}\n onChange={(e) => props.onEndpointChange((e.target as HTMLInputElement).value)}\n placeholder=\"https://api.example.com/graphql\"\n className=\"font-mono text-sm\"\n disabled={props.endpointDisabled}\n />\n </CardStackEntryField>\n <SourceIdentityFieldRows\n identity={props.identity}\n namePlaceholder=\"e.g. Shopify API\"\n namespaceReadOnly={props.namespaceReadOnly}\n />\n </CardStackContent>\n </CardStack>\n );\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,OAEK;AAWD,SAKI,KALJ;AATC,SAAS,oBAAoB,OAMjC;AACD,SACE,oBAAC,aACC,+BAAC,oBAAiB,WAAU,cAC1B;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAM;AAAA,QACN,MAAK;AAAA,QAEL;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,UAAU,CAAC,MAAM,MAAM,iBAAkB,EAAE,OAA4B,KAAK;AAAA,YAC5E,aAAY;AAAA,YACZ,WAAU;AAAA,YACV,UAAU,MAAM;AAAA;AAAA,QAClB;AAAA;AAAA,IACF;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,UAAU,MAAM;AAAA,QAChB,iBAAgB;AAAA,QAChB,mBAAmB,MAAM;AAAA;AAAA,IAC3B;AAAA,KACF,GACF;AAEJ;","names":[]}