@executor-js/plugin-graphql 0.2.1 → 1.4.21

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.
@@ -13,7 +13,7 @@ import {
13
13
  OperationBinding,
14
14
  graphqlHeaderSlot,
15
15
  graphqlQueryParamSlot
16
- } from "./chunk-7QSGNR4C.js";
16
+ } from "./chunk-445ZPXHU.js";
17
17
 
18
18
  // src/sdk/introspect.ts
19
19
  import { Effect, Schema } from "effect";
@@ -341,7 +341,7 @@ var extractFields = (_schema, kind, typeName, types) => {
341
341
  if (!type?.fields) return [];
342
342
  return type.fields.filter((f) => !f.name.startsWith("__")).map((field) => {
343
343
  const args = field.args.map(
344
- (arg) => new GraphqlArgument({
344
+ (arg) => GraphqlArgument.make({
345
345
  name: arg.name,
346
346
  typeName: formatTypeRef(arg.type),
347
347
  required: isNonNull(arg.type),
@@ -349,7 +349,7 @@ var extractFields = (_schema, kind, typeName, types) => {
349
349
  })
350
350
  );
351
351
  const inputSchema = buildInputSchema(field.args, types);
352
- return new ExtractedField({
352
+ return ExtractedField.make({
353
353
  fieldName: field.name,
354
354
  kind,
355
355
  description: field.description ? Option.some(field.description) : Option.none(),
@@ -370,7 +370,7 @@ var extract = (introspection) => Effect2.try({
370
370
  const queryFields = extractFields(schema, "query", schema.queryType?.name, typeMap);
371
371
  const mutationFields = extractFields(schema, "mutation", schema.mutationType?.name, typeMap);
372
372
  return {
373
- result: new ExtractionResult({
373
+ result: ExtractionResult.make({
374
374
  schemaName: Option.none(),
375
375
  fields: [...queryFields, ...mutationFields]
376
376
  }),
@@ -482,7 +482,7 @@ var invoke = Effect3.fn("GraphQL.invoke")(function* (operation, args, endpoint,
482
482
  "plugin.graphql.has_errors": hasErrors,
483
483
  "plugin.graphql.error_count": hasErrors ? gqlBody.errors.length : 0
484
484
  });
485
- return new InvocationResult({
485
+ return InvocationResult.make({
486
486
  status,
487
487
  data: gqlBody?.data ?? null,
488
488
  errors: hasErrors ? gqlBody.errors : null
@@ -604,11 +604,11 @@ var rowsToValueMap = (rows) => {
604
604
  const row = decodeChildValueRow(rawRow);
605
605
  const name = row.name;
606
606
  if (row.kind === "binding" && typeof row.slot_key === "string") {
607
- out[name] = typeof row.prefix === "string" ? new ConfiguredCredentialBinding({
607
+ out[name] = typeof row.prefix === "string" ? ConfiguredCredentialBinding.make({
608
608
  kind: "binding",
609
609
  slot: row.slot_key,
610
610
  prefix: row.prefix
611
- }) : new ConfiguredCredentialBinding({
611
+ }) : ConfiguredCredentialBinding.make({
612
612
  kind: "binding",
613
613
  slot: row.slot_key
614
614
  });
@@ -952,7 +952,7 @@ var prepareOperations = (fields, introspection) => {
952
952
  const key = `${extracted.kind}.${extracted.fieldName}`;
953
953
  const entry = fieldMap.get(key);
954
954
  const operationString = entry ? buildOperationStringForField(entry.kind, entry.field, typeMap) : `${extracted.kind} { ${extracted.fieldName} }`;
955
- const binding = new OperationBinding({
955
+ const binding = OperationBinding.make({
956
956
  kind: extracted.kind,
957
957
  fieldName: extracted.fieldName,
958
958
  operationString,
@@ -993,7 +993,7 @@ var toGraphqlConfigEntry = (namespace, config) => {
993
993
  var GRAPHQL_PLUGIN_ID = "graphql";
994
994
  var scopeRanks = (ctx) => new Map(ctx.scopes.map((scope, index) => [String(scope.id), index]));
995
995
  var scopeRank = (ranks, scopeId) => ranks.get(scopeId) ?? Infinity;
996
- var coreBindingToGraphqlBinding = (binding) => new GraphqlSourceBindingRef({
996
+ var coreBindingToGraphqlBinding = (binding) => GraphqlSourceBindingRef.make({
997
997
  sourceId: binding.sourceId,
998
998
  sourceScopeId: binding.sourceScopeId,
999
999
  scopeId: binding.scopeId,
@@ -1082,7 +1082,7 @@ var canonicalizeCredentialMap = (values, slotForName) => {
1082
1082
  continue;
1083
1083
  }
1084
1084
  const slot = slotForName(name);
1085
- nextValues[name] = new ConfiguredCredentialBinding2({
1085
+ nextValues[name] = ConfiguredCredentialBinding2.make({
1086
1086
  kind: "binding",
1087
1087
  slot,
1088
1088
  prefix: value.prefix
@@ -1578,6 +1578,9 @@ var graphqlPlugin = definePlugin((options) => {
1578
1578
  yield* ctx.storage.removeSource(sourceId, scope);
1579
1579
  })
1580
1580
  );
1581
+ if (options?.configFile) {
1582
+ yield* options.configFile.removeSource(sourceId);
1583
+ }
1581
1584
  }),
1582
1585
  usagesForSecret: () => Effect5.succeed([]),
1583
1586
  usagesForConnection: () => Effect5.succeed([]),
@@ -1597,7 +1600,7 @@ var graphqlPlugin = definePlugin((options) => {
1597
1600
  );
1598
1601
  const name = namespaceFromEndpoint(trimmed);
1599
1602
  if (ok) {
1600
- return new SourceDetectionResult({
1603
+ return SourceDetectionResult.make({
1601
1604
  kind: "graphql",
1602
1605
  confidence: "high",
1603
1606
  endpoint: trimmed,
@@ -1606,7 +1609,7 @@ var graphqlPlugin = definePlugin((options) => {
1606
1609
  });
1607
1610
  }
1608
1611
  if (urlMatchesToken(parsed.value, "graphql")) {
1609
- return new SourceDetectionResult({
1612
+ return SourceDetectionResult.make({
1610
1613
  kind: "graphql",
1611
1614
  confidence: "low",
1612
1615
  endpoint: trimmed,
@@ -1630,4 +1633,4 @@ export {
1630
1633
  makeDefaultGraphqlStore,
1631
1634
  graphqlPlugin
1632
1635
  };
1633
- //# sourceMappingURL=chunk-HDPYOBBG.js.map
1636
+ //# sourceMappingURL=chunk-PO2TPM5B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/introspect.ts","../src/sdk/extract.ts","../src/sdk/invoke.ts","../src/sdk/store.ts","../src/sdk/plugin.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\";\n\nimport { GraphqlIntrospectionError } from \"./errors\";\n\n// ---------------------------------------------------------------------------\n// Introspection query — standard GraphQL introspection\n// ---------------------------------------------------------------------------\n\nconst INTROSPECTION_QUERY = `\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind\n name\n description\n fields(includeDeprecated: false) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n enumValues(includeDeprecated: false) {\n name\n description\n }\n }\n }\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Introspection result types\n// ---------------------------------------------------------------------------\n\nconst IntrospectionTypeRefLeaf = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.Null,\n});\n\nconst IntrospectionTypeRef5 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.NullOr(IntrospectionTypeRefLeaf),\n});\n\nconst IntrospectionTypeRef4 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.NullOr(IntrospectionTypeRef5),\n});\n\nconst IntrospectionTypeRef3 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.NullOr(IntrospectionTypeRef4),\n});\n\nconst IntrospectionTypeRef2 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.NullOr(IntrospectionTypeRef3),\n});\n\nconst IntrospectionTypeRefSchema = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.NullOr(IntrospectionTypeRef2),\n});\n\nconst IntrospectionInputValueSchema = Schema.Struct({\n name: Schema.String,\n description: Schema.NullOr(Schema.String),\n type: IntrospectionTypeRefSchema,\n defaultValue: Schema.NullOr(Schema.String),\n});\n\nconst IntrospectionFieldSchema = Schema.Struct({\n name: Schema.String,\n description: Schema.NullOr(Schema.String),\n args: Schema.Array(IntrospectionInputValueSchema),\n type: IntrospectionTypeRefSchema,\n});\n\nconst IntrospectionTypeSchema = Schema.Struct({\n kind: Schema.String,\n name: Schema.String,\n description: Schema.NullOr(Schema.String),\n fields: Schema.NullOr(Schema.Array(IntrospectionFieldSchema)),\n inputFields: Schema.NullOr(Schema.Array(IntrospectionInputValueSchema)),\n enumValues: Schema.NullOr(\n Schema.Array(\n Schema.Struct({\n name: Schema.String,\n description: Schema.NullOr(Schema.String),\n }),\n ),\n ),\n});\n\nconst IntrospectionResultSchema = Schema.Struct({\n __schema: Schema.Struct({\n queryType: Schema.NullOr(Schema.Struct({ name: Schema.String })),\n mutationType: Schema.NullOr(Schema.Struct({ name: Schema.String })),\n types: Schema.Array(IntrospectionTypeSchema),\n }),\n});\n\nconst IntrospectionResponseSchema = Schema.Struct({\n data: Schema.optional(IntrospectionResultSchema),\n errors: Schema.optional(Schema.Array(Schema.Unknown)),\n});\n\nconst IntrospectionJsonSchema = Schema.Union([\n Schema.Struct({ data: IntrospectionResultSchema }),\n IntrospectionResultSchema,\n]);\n\nexport type IntrospectionTypeRef = typeof IntrospectionTypeRefSchema.Type;\nexport type IntrospectionInputValue = typeof IntrospectionInputValueSchema.Type;\nexport type IntrospectionField = typeof IntrospectionFieldSchema.Type;\nexport type IntrospectionEnumValue = NonNullable<\n (typeof IntrospectionTypeSchema.Type)[\"enumValues\"]\n>[number];\nexport type IntrospectionType = typeof IntrospectionTypeSchema.Type;\nexport type IntrospectionSchema = (typeof IntrospectionResultSchema.Type)[\"__schema\"];\nexport type IntrospectionResult = typeof IntrospectionResultSchema.Type;\n\n// ---------------------------------------------------------------------------\n// Introspect a GraphQL endpoint\n// ---------------------------------------------------------------------------\n\nexport const introspect = Effect.fn(\"GraphQL.introspect\")(function* (\n endpoint: string,\n headers?: Record<string, string>,\n queryParams?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n const requestEndpoint =\n queryParams && Object.keys(queryParams).length > 0\n ? (() => {\n const url = new URL(endpoint);\n for (const [name, value] of Object.entries(queryParams)) {\n url.searchParams.set(name, value);\n }\n return url.toString();\n })()\n : endpoint;\n\n let request = HttpClientRequest.post(requestEndpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyJsonUnsafe({\n query: INTROSPECTION_QUERY,\n }),\n );\n\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n request = HttpClientRequest.setHeader(request, k, v);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.tapCause((cause) => Effect.logError(\"graphql introspection request failed\", cause)),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: \"Failed to reach GraphQL endpoint\",\n }),\n ),\n );\n\n if (response.status !== 200) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection failed with status ${response.status}`,\n });\n }\n\n const raw = yield* response.json.pipe(\n Effect.tapCause((cause) => Effect.logError(\"graphql introspection JSON parse failed\", cause)),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection response as JSON`,\n }),\n ),\n );\n\n const json = yield* Schema.decodeUnknownEffect(IntrospectionResponseSchema)(raw).pipe(\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: \"Introspection response has an invalid shape\",\n }),\n ),\n );\n\n if (json.errors && Array.isArray(json.errors) && json.errors.length > 0) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection returned ${json.errors.length} error(s)`,\n });\n }\n\n if (!json.data?.__schema) {\n return yield* new GraphqlIntrospectionError({\n message: \"Introspection response missing __schema\",\n });\n }\n\n return json.data;\n});\n\n// ---------------------------------------------------------------------------\n// Parse an introspection result from a JSON string (for offline/text input)\n// ---------------------------------------------------------------------------\n\nexport const parseIntrospectionJson = (\n text: string,\n): Effect.Effect<IntrospectionResult, GraphqlIntrospectionError> =>\n Schema.decodeUnknownEffect(Schema.fromJsonString(IntrospectionJsonSchema))(text).pipe(\n Effect.map((parsed) => (\"data\" in parsed ? parsed.data : parsed)),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: \"Failed to parse introspection JSON\",\n }),\n ),\n );\n","import { Effect, Match, Option } from \"effect\";\n\nimport { GraphqlExtractionError } from \"./errors\";\nimport type {\n IntrospectionResult,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionInputValue,\n} from \"./introspect\";\nimport {\n ExtractedField,\n ExtractionResult,\n GraphqlArgument,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Type ref helpers\n// ---------------------------------------------------------------------------\n\n/** Unwrap NON_NULL / LIST wrappers to get the leaf type name */\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\n/** Check if a type ref is non-null (required) */\nconst isNonNull = (ref: IntrospectionTypeRef): boolean => ref.kind === \"NON_NULL\";\n\n// ---------------------------------------------------------------------------\n// Build shared definitions from all INPUT_OBJECT and ENUM types\n// ---------------------------------------------------------------------------\n\nconst buildDefinitions = (\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n const defs: Record<string, unknown> = {};\n\n for (const [name, type] of types) {\n // Skip internal types\n if (name.startsWith(\"__\")) continue;\n\n if (type.kind === \"INPUT_OBJECT\" && type.inputFields) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const field of type.inputFields) {\n const schema = typeRefToJsonSchema(field.type, types);\n if (field.description) {\n (schema as Record<string, unknown>).description = field.description;\n }\n properties[field.name] = schema;\n if (isNonNull(field.type)) {\n required.push(field.name);\n }\n }\n\n const def: Record<string, unknown> = { type: \"object\", properties };\n if (required.length > 0) def.required = required;\n if (type.description) def.description = type.description;\n defs[name] = def;\n }\n\n if (type.kind === \"ENUM\" && type.enumValues) {\n defs[name] = {\n type: \"string\",\n enum: type.enumValues.map((v) => v.name),\n ...(type.description ? { description: type.description } : {}),\n };\n }\n }\n\n return defs;\n};\n\n// ---------------------------------------------------------------------------\n// Convert a type ref to JSON Schema using $ref for complex types\n// ---------------------------------------------------------------------------\n\nconst typeRefToJsonSchema = (\n ref: IntrospectionTypeRef,\n // oxlint-disable-next-line only-used-in-recursion\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> =>\n Match.value(ref.kind).pipe(\n Match.when(\n \"NON_NULL\",\n (): Record<string, unknown> => (ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {}),\n ),\n Match.when(\n \"LIST\",\n (): Record<string, unknown> => ({\n type: \"array\",\n items: ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {},\n }),\n ),\n Match.when(\"SCALAR\", (): Record<string, unknown> => scalarToJsonSchema(ref.name ?? \"String\")),\n Match.when(\n \"ENUM\",\n (): Record<string, unknown> =>\n ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"string\" },\n ),\n Match.when(\n \"INPUT_OBJECT\",\n (): Record<string, unknown> =>\n ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"object\" },\n ),\n Match.whenOr(\n \"OBJECT\",\n \"INTERFACE\",\n \"UNION\",\n (): Record<string, unknown> => ({ type: \"object\" }),\n ),\n Match.option,\n Option.getOrElse((): Record<string, unknown> => ({})),\n );\n\nconst scalarToJsonSchema = (name: string): Record<string, unknown> =>\n Match.value(name).pipe(\n Match.whenOr(\"String\", \"ID\", (): Record<string, unknown> => ({ type: \"string\" })),\n Match.when(\"Int\", (): Record<string, unknown> => ({ type: \"integer\" })),\n Match.when(\"Float\", (): Record<string, unknown> => ({ type: \"number\" })),\n Match.when(\"Boolean\", (): Record<string, unknown> => ({ type: \"boolean\" })),\n Match.option,\n Option.getOrElse(\n (): Record<string, unknown> => ({ type: \"string\", description: `Custom scalar: ${name}` }),\n ),\n );\n\n// ---------------------------------------------------------------------------\n// Build input JSON Schema from field arguments\n// ---------------------------------------------------------------------------\n\nconst buildInputSchema = (\n args: readonly IntrospectionInputValue[],\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> | undefined => {\n if (args.length === 0) return undefined;\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const arg of args) {\n const schema = typeRefToJsonSchema(arg.type, types);\n if (arg.description) {\n (schema as Record<string, unknown>).description = arg.description;\n }\n properties[arg.name] = schema;\n if (isNonNull(arg.type)) {\n required.push(arg.name);\n }\n }\n\n const inputSchema: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) inputSchema.required = required;\n return inputSchema;\n};\n\n/** Format a type ref back to GraphQL type notation (e.g. \"[String!]!\") */\nconst formatTypeRef = (ref: IntrospectionTypeRef): string =>\n Match.value(ref.kind).pipe(\n Match.when(\"NON_NULL\", () => (ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\")),\n Match.when(\"LIST\", () => (ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\")),\n Match.option,\n Option.getOrElse(() => ref.name ?? \"Unknown\"),\n );\n\n// ---------------------------------------------------------------------------\n// Extract fields from schema\n// ---------------------------------------------------------------------------\n\nconst extractFields = (\n _schema: IntrospectionSchema,\n kind: GraphqlOperationKind,\n typeName: string | null | undefined,\n types: ReadonlyMap<string, IntrospectionType>,\n): ExtractedField[] => {\n if (!typeName) return [];\n\n const type = types.get(typeName);\n if (!type?.fields) return [];\n\n return type.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .map((field) => {\n const args = field.args.map((arg) =>\n GraphqlArgument.make({\n name: arg.name,\n typeName: formatTypeRef(arg.type),\n required: isNonNull(arg.type),\n description: arg.description ? Option.some(arg.description) : Option.none(),\n }),\n );\n\n const inputSchema = buildInputSchema(field.args, types);\n\n return ExtractedField.make({\n fieldName: field.name,\n kind,\n description: field.description ? Option.some(field.description) : Option.none(),\n arguments: args,\n inputSchema: inputSchema ? Option.some(inputSchema) : Option.none(),\n returnTypeName: unwrapTypeName(field.type),\n });\n });\n};\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport interface ExtractionOutput {\n readonly result: ExtractionResult;\n /** Shared JSON Schema definitions for INPUT_OBJECT and ENUM types.\n * Tool input schemas use `$ref` pointers into these. */\n readonly definitions: Record<string, unknown>;\n}\n\nexport const extract = (\n introspection: IntrospectionResult,\n): Effect.Effect<ExtractionOutput, GraphqlExtractionError> =>\n Effect.try({\n try: () => {\n const schema = introspection.__schema;\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of schema.types) {\n typeMap.set(t.name, t);\n }\n\n const definitions = buildDefinitions(typeMap);\n\n const queryFields = extractFields(schema, \"query\", schema.queryType?.name, typeMap);\n const mutationFields = extractFields(schema, \"mutation\", schema.mutationType?.name, typeMap);\n\n return {\n result: ExtractionResult.make({\n schemaName: Option.none(),\n fields: [...queryFields, ...mutationFields],\n }),\n definitions,\n };\n },\n catch: () =>\n new GraphqlExtractionError({\n message: \"Failed to extract GraphQL schema\",\n }),\n });\n","import { Effect, Layer, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\";\nimport { resolveSecretBackedMap } from \"@executor-js/sdk/core\";\n\nimport { GraphqlInvocationError } from \"./errors\";\nimport { type HeaderValue, type OperationBinding, InvocationResult } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Header resolution — resolves secret refs at invocation time\n// ---------------------------------------------------------------------------\n\nexport const resolveHeaders = (\n headers: Record<string, HeaderValue>,\n secrets: { readonly get: (id: string) => Effect.Effect<string | null, unknown> },\n): Effect.Effect<Record<string, string>> => {\n const entries = Object.entries(headers);\n const secretCount = entries.reduce(\n (acc, [, value]) => (typeof value === \"string\" ? acc : acc + 1),\n 0,\n );\n return resolveSecretBackedMap({\n values: headers,\n getSecret: (secretId) => secrets.get(secretId).pipe(Effect.catch(() => Effect.succeed(null))),\n missing: \"drop\",\n onMissing: (name) =>\n new GraphqlInvocationError({\n message: `Missing secret for header \"${name}\"`,\n statusCode: Option.none(),\n }),\n }).pipe(\n Effect.catch(() => Effect.succeed<Record<string, string> | undefined>(undefined)),\n Effect.map((resolved) => resolved ?? {}),\n Effect.withSpan(\"plugin.graphql.secret.resolve\", {\n attributes: {\n \"plugin.graphql.headers.total\": entries.length,\n \"plugin.graphql.headers.secret_count\": secretCount,\n },\n }),\n );\n};\n\nconst endpointWithQueryParams = (endpoint: string, queryParams: Record<string, string>): string => {\n if (Object.keys(queryParams).length === 0) return endpoint;\n const url = new URL(endpoint);\n for (const [name, value] of Object.entries(queryParams)) {\n url.searchParams.set(name, value);\n }\n return url.toString();\n};\n\nexport const endpointForTelemetry = (endpoint: string): string => {\n if (!URL.canParse(endpoint)) return endpoint;\n const url = new URL(endpoint);\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n};\n\n// ---------------------------------------------------------------------------\n// Response helpers\n// ---------------------------------------------------------------------------\n\nconst isJsonContentType = (ct: string | null | undefined): boolean => {\n if (!ct) return false;\n const normalized = ct.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n return (\n normalized === \"application/json\" || normalized.includes(\"+json\") || normalized.includes(\"json\")\n );\n};\n\n// ---------------------------------------------------------------------------\n// Public API — execute a GraphQL operation\n// ---------------------------------------------------------------------------\n\nexport const invoke = Effect.fn(\"GraphQL.invoke\")(function* (\n operation: OperationBinding,\n args: Record<string, unknown>,\n endpoint: string,\n resolvedHeaders: Record<string, string>,\n resolvedQueryParams: Record<string, string> = {},\n) {\n const client = yield* HttpClient.HttpClient;\n const requestEndpoint = endpointWithQueryParams(endpoint, resolvedQueryParams);\n const telemetryEndpoint = endpointForTelemetry(endpoint);\n\n yield* Effect.annotateCurrentSpan({\n \"http.method\": \"POST\",\n \"http.url\": telemetryEndpoint,\n \"plugin.graphql.endpoint\": telemetryEndpoint,\n \"plugin.graphql.operation_kind\": operation.kind,\n \"plugin.graphql.field_name\": operation.fieldName,\n \"plugin.graphql.headers.resolved_count\": Object.keys(resolvedHeaders).length,\n \"plugin.graphql.query_params.resolved_count\": Object.keys(resolvedQueryParams).length,\n });\n\n // Build the GraphQL request body\n const variables: Record<string, unknown> = {};\n for (const varName of operation.variableNames) {\n if (args[varName] !== undefined) {\n variables[varName] = args[varName];\n }\n }\n\n // Also pick up any variables from a \"variables\" container\n if (typeof args.variables === \"object\" && args.variables !== null) {\n Object.assign(variables, args.variables);\n }\n\n let request = HttpClientRequest.post(requestEndpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyJsonUnsafe({\n query: operation.operationString,\n variables: Object.keys(variables).length > 0 ? variables : undefined,\n }),\n );\n\n for (const [name, value] of Object.entries(resolvedHeaders)) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n (err) =>\n new GraphqlInvocationError({\n message: \"GraphQL request failed\",\n statusCode: Option.none(),\n cause: err,\n }),\n ),\n );\n\n const status = response.status;\n const contentType = response.headers[\"content-type\"] ?? null;\n\n const body: unknown = isJsonContentType(contentType)\n ? yield* response.json.pipe(Effect.catch(() => response.text))\n : yield* response.text;\n\n // GraphQL responses are always 200 with { data, errors }\n const gqlBody = body as { data?: unknown; errors?: unknown[] } | null;\n const hasErrors = Array.isArray(gqlBody?.errors) && gqlBody.errors.length > 0;\n\n yield* Effect.annotateCurrentSpan({\n \"http.status_code\": status,\n \"plugin.graphql.has_errors\": hasErrors,\n \"plugin.graphql.error_count\": hasErrors ? gqlBody!.errors!.length : 0,\n });\n\n return InvocationResult.make({\n status,\n data: gqlBody?.data ?? null,\n errors: hasErrors ? gqlBody!.errors : null,\n });\n});\n\n// ---------------------------------------------------------------------------\n// Invoke a GraphQL operation with a provided HttpClient layer\n// ---------------------------------------------------------------------------\n\nexport const invokeWithLayer = (\n operation: OperationBinding,\n args: Record<string, unknown>,\n endpoint: string,\n resolvedHeaders: Record<string, string>,\n resolvedQueryParams: Record<string, string>,\n httpClientLayer: Layer.Layer<HttpClient.HttpClient>,\n) =>\n invoke(operation, args, endpoint, resolvedHeaders, resolvedQueryParams).pipe(\n Effect.provide(httpClientLayer),\n Effect.withSpan(\"plugin.graphql.invoke\", {\n attributes: {\n \"plugin.graphql.endpoint\": endpointForTelemetry(endpoint),\n \"plugin.graphql.operation_kind\": operation.kind,\n \"plugin.graphql.field_name\": operation.fieldName,\n },\n }),\n );\n","import { Effect, Schema } from \"effect\";\n\nimport {\n ConfiguredCredentialBinding,\n defineSchema,\n type StorageDeps,\n type StorageFailure,\n} from \"@executor-js/sdk/core\";\n\nimport {\n OperationBinding,\n type ConfiguredGraphqlCredentialValue,\n type GraphqlSourceAuth,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Schema — four tables:\n// - graphql_source: endpoint + auth structure + display name per source.\n// Auth carries a connection slot; concrete per-user/per-workspace\n// connection ids live in core credential_binding rows.\n// - graphql_source_header / graphql_source_query_param: one row per\n// header/param entry. `kind` discriminates literal text from a\n// credential slot binding. PK is `(scope_id, id)` where id is a JSON\n// tuple `[source_id,name]` so user-provided separators cannot collide.\n// - graphql_operation: per-tool OperationBinding blob. Operation\n// bindings don't reference secrets/connections, so they stay as\n// JSON — that's a legit JSON case (the binding shape is plugin-\n// internal opaque data).\n// ---------------------------------------------------------------------------\n\nexport const graphqlSchema = defineSchema({\n graphql_source: {\n fields: {\n id: { type: \"string\", required: true },\n scope_id: { type: \"string\", required: true, index: true },\n name: { type: \"string\", required: true },\n endpoint: { type: \"string\", required: true },\n auth_kind: {\n type: [\"none\", \"oauth2\"],\n required: true,\n defaultValue: \"none\",\n },\n auth_connection_slot: {\n type: \"string\",\n required: false,\n },\n },\n },\n graphql_source_header: {\n fields: {\n id: { type: \"string\", required: true },\n scope_id: { type: \"string\", required: true, index: true },\n source_id: { type: \"string\", required: true, index: true },\n name: { type: \"string\", required: true },\n kind: {\n type: [\"text\", \"binding\"],\n required: true,\n },\n text_value: { type: \"string\", required: false },\n slot_key: { type: \"string\", required: false },\n prefix: { type: \"string\", required: false },\n },\n },\n graphql_source_query_param: {\n fields: {\n id: { type: \"string\", required: true },\n scope_id: { type: \"string\", required: true, index: true },\n source_id: { type: \"string\", required: true, index: true },\n name: { type: \"string\", required: true },\n kind: {\n type: [\"text\", \"binding\"],\n required: true,\n },\n text_value: { type: \"string\", required: false },\n slot_key: { type: \"string\", required: false },\n prefix: { type: \"string\", required: false },\n },\n },\n graphql_operation: {\n fields: {\n id: { type: \"string\", required: true },\n scope_id: { type: \"string\", required: true, index: true },\n source_id: { type: \"string\", required: true, index: true },\n binding: { type: \"json\", required: true },\n },\n },\n});\n\nexport type GraphqlSchema = typeof graphqlSchema;\n\n// ---------------------------------------------------------------------------\n// In-memory value shapes\n// ---------------------------------------------------------------------------\n\nexport interface StoredGraphqlSource {\n readonly namespace: string;\n /** Executor scope id this source row lives in. Writes stamp this on\n * `scope_id`; reads return whichever scope's row the adapter's\n * fall-through walk surfaced first. */\n readonly scope: string;\n readonly name: string;\n readonly endpoint: string;\n readonly headers: Record<string, ConfiguredGraphqlCredentialValue>;\n readonly queryParams: Record<string, ConfiguredGraphqlCredentialValue>;\n readonly auth: GraphqlSourceAuth;\n}\n\nexport interface StoredOperation {\n readonly toolId: string;\n readonly sourceId: string;\n readonly binding: OperationBinding;\n}\n\nconst OperationBindingFromJsonString = Schema.fromJsonString(OperationBinding);\nconst decodeOperationBindingFromJsonString = Schema.decodeUnknownSync(\n OperationBindingFromJsonString,\n);\nconst decodeOperationBinding = Schema.decodeUnknownSync(OperationBinding);\n\nconst decodeBinding = (value: unknown): OperationBinding => {\n if (typeof value === \"string\") {\n return decodeOperationBindingFromJsonString(value);\n }\n return decodeOperationBinding(value);\n};\n\nconst encodeBinding = Schema.encodeSync(OperationBinding);\n\nconst toJsonRecord = (value: unknown): Record<string, unknown> => value as Record<string, unknown>;\n\nconst SourceRow = Schema.Struct({\n id: Schema.String,\n scope_id: Schema.String,\n name: Schema.String,\n endpoint: Schema.String,\n auth_kind: Schema.Literals([\"none\", \"oauth2\"]),\n auth_connection_slot: Schema.NullOr(Schema.String).pipe(Schema.optionalKey),\n});\n\nconst ChildValueRow = Schema.Struct({\n name: Schema.String,\n kind: Schema.Literals([\"text\", \"binding\"]),\n text_value: Schema.NullOr(Schema.String).pipe(Schema.optionalKey),\n slot_key: Schema.NullOr(Schema.String).pipe(Schema.optionalKey),\n prefix: Schema.NullOr(Schema.String).pipe(Schema.optionalKey),\n});\n\nconst OperationRow = Schema.Struct({\n id: Schema.String,\n source_id: Schema.String,\n binding: Schema.Unknown,\n});\n\nconst decodeSourceRow = Schema.decodeUnknownSync(SourceRow);\nconst decodeChildValueRow = Schema.decodeUnknownSync(ChildValueRow);\nconst decodeOperationRow = Schema.decodeUnknownSync(OperationRow);\n\n// Header / query-param rows: collapse the flat columns back into a source\n// structure map keyed by header/param name. Concrete credential values are\n// resolved through core credential_binding rows at invocation time.\nconst rowsToValueMap = (\n rows: readonly Record<string, unknown>[],\n): Record<string, ConfiguredGraphqlCredentialValue> => {\n const out: Record<string, ConfiguredGraphqlCredentialValue> = {};\n for (const rawRow of rows) {\n const row = decodeChildValueRow(rawRow);\n const name = row.name;\n if (row.kind === \"binding\" && typeof row.slot_key === \"string\") {\n out[name] =\n typeof row.prefix === \"string\"\n ? ConfiguredCredentialBinding.make({\n kind: \"binding\",\n slot: row.slot_key,\n prefix: row.prefix,\n })\n : ConfiguredCredentialBinding.make({\n kind: \"binding\",\n slot: row.slot_key,\n });\n } else if (row.kind === \"text\" && typeof row.text_value === \"string\") {\n out[name] = row.text_value;\n }\n }\n return out;\n};\n\n// Encode one entry of a source credential map into a child row. Used by the\n// writer for both `graphql_source_header` and `graphql_source_query_param`.\n// Returns a `Record<string, unknown>` so the result is structurally assignable\n// to the typed adapter's `RowInput` shape.\nconst valueToChildRow = (\n sourceId: string,\n scope: string,\n name: string,\n value: ConfiguredGraphqlCredentialValue,\n): Record<string, unknown> => {\n const id = JSON.stringify([sourceId, name]);\n if (typeof value === \"string\") {\n return {\n id,\n scope_id: scope,\n source_id: sourceId,\n name,\n kind: \"text\",\n text_value: value,\n };\n }\n return {\n id,\n scope_id: scope,\n source_id: sourceId,\n name,\n kind: \"binding\",\n slot_key: value.slot,\n prefix: value.prefix,\n };\n};\n\nconst rowToAuth = (row: typeof SourceRow.Type): GraphqlSourceAuth => {\n if (row.auth_kind === \"oauth2\" && typeof row.auth_connection_slot === \"string\") {\n return { kind: \"oauth2\", connectionSlot: row.auth_connection_slot };\n }\n return { kind: \"none\" };\n};\n\n// ---------------------------------------------------------------------------\n// Store interface\n// ---------------------------------------------------------------------------\n\n// Every read/write that targets a single row pins BOTH the natural id\n// (namespace, toolId) AND the owning `scope_id`. The store runs behind\n// the scoped adapter (which auto-injects `scope_id IN (stack)`), so a\n// bare `{id}` filter resolves to any matching row in the stack in\n// adapter-iteration order. For shadowed rows (same id at multiple\n// scopes — e.g. an org-level GraphQL source with a per-user override),\n// that's a scope-isolation bug: updates and deletes can land on the\n// wrong scope's row. Callers thread the resolved scope in (typically\n// `path.scopeId` for HTTP, `toolRow.scope_id` / `input.scope` for\n// invokeTool/lifecycle) so every keyed mutation targets exactly one\n// row.\nexport interface GraphqlStore {\n readonly upsertSource: (\n input: StoredGraphqlSource,\n operations: readonly StoredOperation[],\n ) => Effect.Effect<void, StorageFailure>;\n\n readonly updateSourceMeta: (\n namespace: string,\n scope: string,\n patch: {\n readonly name?: string;\n readonly endpoint?: string;\n readonly headers?: Record<string, ConfiguredGraphqlCredentialValue>;\n readonly queryParams?: Record<string, ConfiguredGraphqlCredentialValue>;\n readonly auth?: GraphqlSourceAuth;\n },\n ) => Effect.Effect<void, StorageFailure>;\n\n readonly getSource: (\n namespace: string,\n scope: string,\n ) => Effect.Effect<StoredGraphqlSource | null, StorageFailure>;\n\n readonly listSources: () => Effect.Effect<readonly StoredGraphqlSource[], StorageFailure>;\n\n readonly getOperationByToolId: (\n toolId: string,\n scope: string,\n ) => Effect.Effect<StoredOperation | null, StorageFailure>;\n\n readonly listOperationsBySource: (\n sourceId: string,\n scope: string,\n ) => Effect.Effect<readonly StoredOperation[], StorageFailure>;\n\n readonly removeSource: (namespace: string, scope: string) => Effect.Effect<void, StorageFailure>;\n}\n\n// ---------------------------------------------------------------------------\n// Default store implementation\n// ---------------------------------------------------------------------------\n\nexport const makeDefaultGraphqlStore = ({\n adapter: db,\n}: StorageDeps<GraphqlSchema>): GraphqlStore => {\n const loadHeaders = (sourceId: string, scope: string) =>\n db\n .findMany({\n model: \"graphql_source_header\",\n where: [\n { field: \"source_id\", value: sourceId },\n { field: \"scope_id\", value: scope },\n ],\n })\n .pipe(Effect.map(rowsToValueMap));\n\n const loadQueryParams = (sourceId: string, scope: string) =>\n db\n .findMany({\n model: \"graphql_source_query_param\",\n where: [\n { field: \"source_id\", value: sourceId },\n { field: \"scope_id\", value: scope },\n ],\n })\n .pipe(Effect.map(rowsToValueMap));\n\n const rowToSourceWithChildren = (\n row: Record<string, unknown>,\n ): Effect.Effect<StoredGraphqlSource, StorageFailure> =>\n Effect.gen(function* () {\n const source = decodeSourceRow(row);\n const sourceId = source.id;\n const scope = source.scope_id;\n const headers = yield* loadHeaders(sourceId, scope);\n const queryParams = yield* loadQueryParams(sourceId, scope);\n return {\n namespace: sourceId,\n scope,\n name: source.name,\n endpoint: source.endpoint,\n headers,\n queryParams,\n auth: rowToAuth(source),\n };\n });\n\n const rowToOperation = (row: Record<string, unknown>): StoredOperation => {\n const operation = decodeOperationRow(row);\n return {\n toolId: operation.id,\n sourceId: operation.source_id,\n binding: decodeBinding(operation.binding),\n };\n };\n\n // Replace child rows for a source by deleting then bulk-inserting. Used\n // by both upsertSource (full rewrite) and updateSourceMeta (partial\n // patch when headers/queryParams is supplied).\n const replaceChildren = (\n model: \"graphql_source_header\" | \"graphql_source_query_param\",\n sourceId: string,\n scope: string,\n values: Record<string, ConfiguredGraphqlCredentialValue>,\n ) =>\n Effect.gen(function* () {\n yield* db.deleteMany({\n model,\n where: [\n { field: \"source_id\", value: sourceId },\n { field: \"scope_id\", value: scope },\n ],\n });\n const entries = Object.entries(values);\n if (entries.length === 0) return;\n yield* db.createMany({\n model,\n data: entries.map(([name, value]) => valueToChildRow(sourceId, scope, name, value)),\n forceAllowId: true,\n });\n });\n\n const deleteSource = (namespace: string, scope: string) =>\n Effect.gen(function* () {\n yield* db.deleteMany({\n model: \"graphql_operation\",\n where: [\n { field: \"source_id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n });\n yield* db.deleteMany({\n model: \"graphql_source_header\",\n where: [\n { field: \"source_id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n });\n yield* db.deleteMany({\n model: \"graphql_source_query_param\",\n where: [\n { field: \"source_id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n });\n yield* db.delete({\n model: \"graphql_source\",\n where: [\n { field: \"id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n });\n });\n\n return {\n upsertSource: (input, operations) =>\n Effect.gen(function* () {\n yield* deleteSource(input.namespace, input.scope);\n yield* db.create({\n model: \"graphql_source\",\n data: {\n id: input.namespace,\n scope_id: input.scope,\n name: input.name,\n endpoint: input.endpoint,\n auth_kind: input.auth.kind,\n auth_connection_slot:\n input.auth.kind === \"oauth2\" ? input.auth.connectionSlot : undefined,\n },\n forceAllowId: true,\n });\n yield* replaceChildren(\n \"graphql_source_header\",\n input.namespace,\n input.scope,\n input.headers,\n );\n yield* replaceChildren(\n \"graphql_source_query_param\",\n input.namespace,\n input.scope,\n input.queryParams,\n );\n if (operations.length > 0) {\n yield* db.createMany({\n model: \"graphql_operation\",\n data: operations.map((op) => ({\n id: op.toolId,\n scope_id: input.scope,\n source_id: op.sourceId,\n binding: toJsonRecord(encodeBinding(op.binding)),\n })),\n forceAllowId: true,\n });\n }\n }),\n\n updateSourceMeta: (namespace, scope, patch) =>\n Effect.gen(function* () {\n const existing = yield* db.findOne({\n model: \"graphql_source\",\n where: [\n { field: \"id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n });\n if (!existing) return;\n const update: Record<string, unknown> = {};\n if (patch.name !== undefined) update.name = patch.name;\n if (patch.endpoint !== undefined) update.endpoint = patch.endpoint;\n if (patch.auth !== undefined) {\n update.auth_kind = patch.auth.kind;\n update.auth_connection_slot =\n patch.auth.kind === \"oauth2\" ? patch.auth.connectionSlot : null;\n }\n if (Object.keys(update).length > 0) {\n yield* db.update({\n model: \"graphql_source\",\n where: [\n { field: \"id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n update,\n });\n }\n if (patch.headers !== undefined) {\n yield* replaceChildren(\"graphql_source_header\", namespace, scope, patch.headers);\n }\n if (patch.queryParams !== undefined) {\n yield* replaceChildren(\"graphql_source_query_param\", namespace, scope, patch.queryParams);\n }\n }),\n\n getSource: (namespace, scope) =>\n Effect.gen(function* () {\n const row = yield* db.findOne({\n model: \"graphql_source\",\n where: [\n { field: \"id\", value: namespace },\n { field: \"scope_id\", value: scope },\n ],\n });\n if (!row) return null;\n return yield* rowToSourceWithChildren(row);\n }),\n\n listSources: () =>\n Effect.gen(function* () {\n const rows = yield* db.findMany({ model: \"graphql_source\" });\n return yield* Effect.forEach(rows, rowToSourceWithChildren, {\n concurrency: \"unbounded\",\n });\n }),\n\n getOperationByToolId: (toolId, scope) =>\n db\n .findOne({\n model: \"graphql_operation\",\n where: [\n { field: \"id\", value: toolId },\n { field: \"scope_id\", value: scope },\n ],\n })\n .pipe(Effect.map((row) => (row ? rowToOperation(row) : null))),\n\n listOperationsBySource: (sourceId, scope) =>\n db\n .findMany({\n model: \"graphql_operation\",\n where: [\n { field: \"source_id\", value: sourceId },\n { field: \"scope_id\", value: scope },\n ],\n })\n .pipe(Effect.map((rows) => rows.map(rowToOperation))),\n\n removeSource: (namespace, scope) => deleteSource(namespace, scope),\n };\n};\n","import { Effect, Match, Option, Schema } from \"effect\";\nimport type { Layer } from \"effect\";\nimport { HttpClient } from \"effect/unstable/http\";\n\nimport {\n ConnectionId,\n ConfiguredCredentialBinding,\n type CredentialBindingRef,\n definePlugin,\n tool,\n ScopeId,\n SecretId,\n SourceDetectionResult,\n StorageError,\n type PluginCtx,\n type StorageFailure,\n type ToolAnnotations,\n type ToolRow,\n} from \"@executor-js/sdk/core\";\n\nimport {\n headersToConfigValues,\n type ConfigFileSink,\n type GraphqlSourceConfig as GraphqlConfigEntry,\n} from \"@executor-js/config\";\n\nimport {\n introspect,\n parseIntrospectionJson,\n type IntrospectionResult,\n type IntrospectionType,\n type IntrospectionField,\n type IntrospectionTypeRef,\n} from \"./introspect\";\nimport { extract } from \"./extract\";\nimport { GraphqlIntrospectionError, GraphqlInvocationError } from \"./errors\";\nimport { invokeWithLayer } from \"./invoke\";\nimport {\n graphqlSchema,\n makeDefaultGraphqlStore,\n type GraphqlStore,\n type StoredGraphqlSource,\n type StoredOperation,\n} from \"./store\";\nimport {\n ExtractedField,\n GRAPHQL_OAUTH_CONNECTION_SLOT,\n GraphqlCredentialInput as GraphqlCredentialInputSchema,\n GraphqlSourceAuthInput as GraphqlSourceAuthInputSchema,\n GraphqlSourceBindingInput,\n GraphqlSourceBindingRef,\n graphqlHeaderSlot,\n graphqlQueryParamSlot,\n OperationBinding,\n type ConfiguredGraphqlCredentialValue,\n type GraphqlCredentialInput,\n type GraphqlSourceAuth,\n type HeaderValue as HeaderValueValue,\n type GraphqlSourceAuthInput,\n type GraphqlSourceBindingValue,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nexport type HeaderValue = HeaderValueValue;\nexport type GraphqlCredentialValue = ConfiguredGraphqlCredentialValue;\n\nexport interface GraphqlSourceConfig {\n /** The GraphQL endpoint URL */\n readonly endpoint: string;\n /**\n * Executor scope id that owns this source row. Must be one of the\n * executor's configured scopes. Typical shape: an admin adds the\n * source at the outermost (organization) scope so it's visible to\n * every inner (per-user) scope via fall-through reads.\n */\n readonly scope: string;\n /** Display name for the source. Falls back to namespace if not provided. */\n readonly name?: string;\n /** Optional: introspection JSON text (if endpoint doesn't support introspection) */\n readonly introspectionJson?: string;\n /** Namespace for the tools (derived from endpoint if not provided) */\n readonly namespace?: string;\n /** Headers applied to every request. Direct secrets are rewritten to slots. */\n readonly headers?: Record<string, GraphqlCredentialInput>;\n /** Query parameters applied to every request. Direct secrets are rewritten to slots. */\n readonly queryParams?: Record<string, GraphqlCredentialInput>;\n /**\n * Scope that owns any direct credentials supplied on this call. Required\n * whenever headers/queryParams/auth carry direct secret or connection ids.\n */\n readonly credentialTargetScope?: string;\n /** Optional OAuth2 credential used as a Bearer token for every request. */\n readonly auth?: GraphqlSourceAuthInput;\n}\n\nconst StaticAddSourceInputSchema = Schema.Struct({\n scope: Schema.String,\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, GraphqlCredentialInputSchema)),\n queryParams: Schema.optional(Schema.Record(Schema.String, GraphqlCredentialInputSchema)),\n credentialTargetScope: Schema.optional(Schema.String),\n auth: Schema.optional(GraphqlSourceAuthInputSchema),\n});\n\nconst StaticAddSourceInputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(StaticAddSourceInputSchema),\n);\nconst StaticAddSourceOutputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(Schema.Struct({ toolCount: Schema.Number })),\n);\n\n// ---------------------------------------------------------------------------\n// Plugin extension\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlUpdateSourceInput {\n readonly name?: string;\n readonly endpoint?: string;\n readonly headers?: Record<string, GraphqlCredentialInput>;\n readonly queryParams?: Record<string, GraphqlCredentialInput>;\n readonly credentialTargetScope?: string;\n readonly auth?: GraphqlSourceAuthInput;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Match `token` as a separator-bounded run inside a URL hostname or path,\n * used as a low-confidence detection hint when introspection fails.\n * Boundary chars are everything non-alphanumeric, so `/api/graphql`,\n * `graphql.example.com`, `graphql-api`, and `graphql_v2` all match while\n * `graphqlserver` and `/graphqlite` do not. */\nconst urlMatchesToken = (url: URL, token: string): boolean => {\n const re = new RegExp(`(?:^|[^a-z0-9])${token}(?:$|[^a-z0-9])`, \"i\");\n return re.test(url.hostname) || re.test(url.pathname);\n};\n\n/** Derive a namespace from an endpoint URL */\nconst namespaceFromEndpoint = (endpoint: string): string => {\n // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: URL construction throws; this helper intentionally falls back to the stable default namespace\n try {\n const url = new URL(endpoint);\n return url.hostname.replace(/[^a-z0-9]+/gi, \"_\").toLowerCase();\n } catch {\n return \"graphql\";\n }\n};\n\nconst formatTypeRef = (ref: IntrospectionTypeRef): string =>\n Match.value(ref.kind).pipe(\n Match.when(\"NON_NULL\", () => (ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\")),\n Match.when(\"LIST\", () => (ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\")),\n Match.option,\n Option.getOrElse(() => ref.name ?? \"Unknown\"),\n );\n\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\nconst buildSelectionSet = (\n ref: IntrospectionTypeRef,\n types: ReadonlyMap<string, IntrospectionType>,\n depth: number,\n seen: Set<string>,\n): string => {\n if (depth > 2) return \"\";\n\n const leafName = unwrapTypeName(ref);\n if (seen.has(leafName)) return \"\";\n\n const objectType = types.get(leafName);\n if (!objectType?.fields) return \"\";\n\n const kind = objectType.kind;\n if (kind === \"SCALAR\" || kind === \"ENUM\") return \"\";\n\n seen.add(leafName);\n\n const subFields = objectType.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .slice(0, 12)\n .map((f) => {\n const sub = buildSelectionSet(f.type, types, depth + 1, seen);\n return sub ? `${f.name} ${sub}` : f.name;\n });\n\n seen.delete(leafName);\n\n return subFields.length > 0 ? `{ ${subFields.join(\" \")} }` : \"\";\n};\n\nconst buildOperationStringForField = (\n kind: GraphqlOperationKind,\n field: IntrospectionField,\n types: ReadonlyMap<string, IntrospectionType>,\n): string => {\n const opType = kind === \"query\" ? \"query\" : \"mutation\";\n\n const varDefs = field.args.map((arg) => {\n const typeName = formatTypeRef(arg.type);\n return `$${arg.name}: ${typeName}`;\n });\n\n const argPasses = field.args.map((arg) => `${arg.name}: $${arg.name}`);\n const selectionSet = buildSelectionSet(field.type, types, 0, new Set());\n\n const varDefsStr = varDefs.length > 0 ? `(${varDefs.join(\", \")})` : \"\";\n const argPassStr = argPasses.length > 0 ? `(${argPasses.join(\", \")})` : \"\";\n\n return `${opType}${varDefsStr} { ${field.name}${argPassStr}${selectionSet ? ` ${selectionSet}` : \"\"} }`;\n};\n\ninterface PreparedOperation {\n readonly toolPath: string;\n readonly description: string;\n readonly inputSchema: unknown;\n readonly binding: OperationBinding;\n}\n\nconst prepareOperations = (\n fields: readonly ExtractedField[],\n introspection: IntrospectionResult,\n): readonly PreparedOperation[] => {\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of introspection.__schema.types) {\n typeMap.set(t.name, t);\n }\n\n const fieldMap = new Map<string, { kind: GraphqlOperationKind; field: IntrospectionField }>();\n const schema = introspection.__schema;\n for (const rootKind of [\"query\", \"mutation\"] as const) {\n const typeName = rootKind === \"query\" ? schema.queryType?.name : schema.mutationType?.name;\n if (!typeName) continue;\n const rootType = typeMap.get(typeName);\n if (!rootType?.fields) continue;\n for (const f of rootType.fields) {\n if (!f.name.startsWith(\"__\")) {\n fieldMap.set(`${rootKind}.${f.name}`, { kind: rootKind, field: f });\n }\n }\n }\n\n return fields.map((extracted) => {\n const prefix = extracted.kind === \"mutation\" ? \"mutation\" : \"query\";\n const toolPath = `${prefix}.${extracted.fieldName}`;\n const description = Option.getOrElse(\n extracted.description,\n () => `GraphQL ${extracted.kind}: ${extracted.fieldName} -> ${extracted.returnTypeName}`,\n );\n\n const key = `${extracted.kind}.${extracted.fieldName}`;\n const entry = fieldMap.get(key);\n const operationString = entry\n ? buildOperationStringForField(entry.kind, entry.field, typeMap)\n : `${extracted.kind} { ${extracted.fieldName} }`;\n\n const binding = OperationBinding.make({\n kind: extracted.kind,\n fieldName: extracted.fieldName,\n operationString,\n variableNames: extracted.arguments.map((a) => a.name),\n });\n\n return {\n toolPath,\n description,\n inputSchema: Option.getOrUndefined(extracted.inputSchema),\n binding,\n };\n });\n};\n\nconst annotationsFor = (binding: OperationBinding): ToolAnnotations => {\n if (binding.kind === \"mutation\") {\n return {\n requiresApproval: true,\n approvalDescription: `mutation ${binding.fieldName}`,\n };\n }\n return {};\n};\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlPluginOptions {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;\n /** If provided, source add/remove is mirrored to executor.jsonc\n * (best-effort — file errors are logged, not raised). */\n readonly configFile?: ConfigFileSink;\n}\n\nconst toGraphqlConfigEntry = (\n namespace: string,\n config: GraphqlSourceConfig,\n): GraphqlConfigEntry => {\n const headers: Record<string, HeaderValue> = {};\n for (const [name, value] of Object.entries(config.headers ?? {})) {\n if (typeof value === \"string\" || !(\"kind\" in value)) {\n headers[name] = value;\n }\n }\n return {\n kind: \"graphql\",\n endpoint: config.endpoint,\n introspectionJson: config.introspectionJson,\n namespace,\n headers: headersToConfigValues(Object.keys(headers).length > 0 ? headers : undefined),\n };\n};\n\nconst GRAPHQL_PLUGIN_ID = \"graphql\";\n\nconst scopeRanks = (ctx: PluginCtx<GraphqlStore>): ReadonlyMap<string, number> =>\n new Map(ctx.scopes.map((scope, index) => [String(scope.id), index]));\n\nconst scopeRank = (ranks: ReadonlyMap<string, number>, scopeId: string): number =>\n ranks.get(scopeId) ?? Infinity;\n\nconst coreBindingToGraphqlBinding = (binding: CredentialBindingRef): GraphqlSourceBindingRef =>\n GraphqlSourceBindingRef.make({\n sourceId: binding.sourceId,\n sourceScopeId: binding.sourceScopeId,\n scopeId: binding.scopeId,\n slot: binding.slotKey,\n value: binding.value,\n createdAt: binding.createdAt,\n updatedAt: binding.updatedAt,\n });\n\nconst listGraphqlSourceBindings = (\n ctx: PluginCtx<GraphqlStore>,\n sourceId: string,\n sourceScope: string,\n): Effect.Effect<readonly GraphqlSourceBindingRef[], StorageFailure> =>\n Effect.gen(function* () {\n const ranks = scopeRanks(ctx);\n const sourceSourceRank = scopeRank(ranks, sourceScope);\n if (sourceSourceRank === Infinity) return [];\n const bindings = yield* ctx.credentialBindings.listForSource({\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId,\n sourceScope: ScopeId.make(sourceScope),\n });\n return bindings\n .filter((binding) => scopeRank(ranks, binding.scopeId) <= sourceSourceRank)\n .map(coreBindingToGraphqlBinding);\n });\n\nconst resolveGraphqlSourceBinding = (\n ctx: PluginCtx<GraphqlStore>,\n sourceId: string,\n sourceScope: string,\n slot: string,\n): Effect.Effect<GraphqlSourceBindingRef | null, StorageFailure> =>\n Effect.gen(function* () {\n const ranks = scopeRanks(ctx);\n const sourceSourceRank = scopeRank(ranks, sourceScope);\n if (sourceSourceRank === Infinity) return null;\n const bindings = yield* ctx.credentialBindings.listForSource({\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId,\n sourceScope: ScopeId.make(sourceScope),\n });\n const binding = bindings\n .filter(\n (candidate) =>\n candidate.slotKey === slot && scopeRank(ranks, candidate.scopeId) <= sourceSourceRank,\n )\n .sort((a, b) => scopeRank(ranks, a.scopeId) - scopeRank(ranks, b.scopeId))[0];\n return binding ? coreBindingToGraphqlBinding(binding) : null;\n });\n\nconst validateGraphqlBindingTarget = (\n ctx: PluginCtx<GraphqlStore>,\n input: {\n readonly sourceScope: string;\n readonly targetScope: string;\n readonly sourceId: string;\n },\n): Effect.Effect<void, StorageFailure> =>\n Effect.gen(function* () {\n const ranks = scopeRanks(ctx);\n const sourceSourceRank = scopeRank(ranks, input.sourceScope);\n const targetRank = scopeRank(ranks, input.targetScope);\n const scopeList = `[${ctx.scopes.map((s) => s.id).join(\", \")}]`;\n if (sourceSourceRank === Infinity) {\n return yield* new StorageError({\n message:\n `GraphQL source binding references source scope \"${input.sourceScope}\" ` +\n `which is not in the executor's scope stack ${scopeList}.`,\n cause: undefined,\n });\n }\n if (targetRank === Infinity) {\n return yield* new StorageError({\n message:\n `GraphQL source binding targets scope \"${input.targetScope}\" which is not ` +\n `in the executor's scope stack ${scopeList}.`,\n cause: undefined,\n });\n }\n if (targetRank > sourceSourceRank) {\n return yield* new StorageError({\n message:\n `GraphQL source bindings for \"${input.sourceId}\" cannot be written at ` +\n `outer scope \"${input.targetScope}\" because the base source lives at ` +\n `\"${input.sourceScope}\"`,\n cause: undefined,\n });\n }\n });\n\nconst bindingTargetScope = (\n targetScope: string | undefined,\n bindings: readonly unknown[],\n): Effect.Effect<string | undefined, GraphqlIntrospectionError> => {\n if (bindings.length === 0) return Effect.succeed(undefined);\n if (targetScope) return Effect.succeed(targetScope);\n return Effect.fail(\n new GraphqlIntrospectionError({\n message: \"credentialTargetScope is required when adding direct GraphQL credentials\",\n }),\n );\n};\n\nconst targetScopeForBinding = (\n fallbackTargetScope: string | undefined,\n binding: { readonly targetScope?: string },\n): Effect.Effect<string, GraphqlIntrospectionError> => {\n const targetScope = binding.targetScope ?? fallbackTargetScope;\n if (targetScope) return Effect.succeed(targetScope);\n return Effect.fail(\n new GraphqlIntrospectionError({\n message: \"credentialTargetScope is required when adding direct GraphQL credentials\",\n }),\n );\n};\n\nconst canonicalizeCredentialMap = (\n values: Record<string, GraphqlCredentialInput> | undefined,\n slotForName: (name: string) => string,\n): {\n readonly values: Record<string, ConfiguredGraphqlCredentialValue>;\n readonly bindings: ReadonlyArray<{\n readonly slot: string;\n readonly value: GraphqlSourceBindingValue;\n readonly targetScope?: string;\n }>;\n} => {\n const nextValues: Record<string, ConfiguredGraphqlCredentialValue> = {};\n const bindings: Array<{\n slot: string;\n value: GraphqlSourceBindingValue;\n targetScope?: string;\n }> = [];\n for (const [name, value] of Object.entries(values ?? {})) {\n if (typeof value === \"string\") {\n nextValues[name] = value;\n continue;\n }\n if (\"kind\" in value) {\n nextValues[name] = value;\n continue;\n }\n const slot = slotForName(name);\n nextValues[name] = ConfiguredCredentialBinding.make({\n kind: \"binding\",\n slot,\n prefix: value.prefix,\n });\n bindings.push({\n slot,\n targetScope: \"targetScope\" in value ? value.targetScope : undefined,\n value: {\n kind: \"secret\",\n secretId: SecretId.make(value.secretId),\n ...(\"secretScopeId\" in value && value.secretScopeId\n ? { secretScopeId: value.secretScopeId }\n : {}),\n },\n });\n }\n return { values: nextValues, bindings };\n};\n\nconst canonicalizeAuth = (\n auth: GraphqlSourceAuthInput | undefined,\n): {\n readonly auth: GraphqlSourceAuth;\n readonly bindings: ReadonlyArray<{\n readonly slot: string;\n readonly value: GraphqlSourceBindingValue;\n readonly targetScope?: string;\n }>;\n} => {\n if (!auth || auth.kind === \"none\") return { auth: { kind: \"none\" }, bindings: [] };\n if (\"connectionSlot\" in auth) return { auth, bindings: [] };\n return {\n auth: { kind: \"oauth2\", connectionSlot: GRAPHQL_OAUTH_CONNECTION_SLOT },\n bindings: [\n {\n slot: GRAPHQL_OAUTH_CONNECTION_SLOT,\n value: {\n kind: \"connection\",\n connectionId: ConnectionId.make(auth.connectionId),\n },\n },\n ],\n };\n};\n\nconst resolveGraphqlBindingValueMap = <E>(\n ctx: PluginCtx<GraphqlStore>,\n values: Record<string, ConfiguredGraphqlCredentialValue> | undefined,\n params: {\n readonly sourceId: string;\n readonly sourceScope: string;\n readonly missingLabel: string;\n readonly makeError: (message: string) => E;\n },\n): Effect.Effect<Record<string, string> | undefined, E | StorageFailure> =>\n Effect.gen(function* () {\n if (!values) return undefined;\n const resolved: Record<string, string> = {};\n for (const [name, value] of Object.entries(values)) {\n if (typeof value === \"string\") {\n resolved[name] = value;\n continue;\n }\n const binding = yield* resolveGraphqlSourceBinding(\n ctx,\n params.sourceId,\n params.sourceScope,\n value.slot,\n );\n if (binding?.value.kind === \"secret\") {\n const secret = yield* ctx.secrets\n .getAtScope(binding.value.secretId, binding.scopeId)\n .pipe(\n Effect.catchTag(\"SecretOwnedByConnectionError\", () =>\n Effect.fail(\n params.makeError(`Secret not found for ${params.missingLabel} \"${name}\"`),\n ),\n ),\n );\n if (secret === null) {\n return yield* Effect.fail(\n params.makeError(\n `Missing secret \"${binding.value.secretId}\" for ${params.missingLabel} \"${name}\"`,\n ),\n );\n }\n resolved[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n continue;\n }\n if (binding?.value.kind === \"text\") {\n resolved[name] = value.prefix ? `${value.prefix}${binding.value.text}` : binding.value.text;\n continue;\n }\n return yield* Effect.fail(\n params.makeError(`Missing binding for ${params.missingLabel} \"${name}\"`),\n );\n }\n return Object.keys(resolved).length > 0 ? resolved : undefined;\n });\n\nconst resolveGraphqlStoredOAuthHeader = (\n ctx: PluginCtx<GraphqlStore>,\n sourceId: string,\n sourceScope: string,\n auth: GraphqlSourceAuth | undefined,\n) =>\n Effect.gen(function* () {\n if (!auth || auth.kind === \"none\") return undefined;\n const binding = yield* resolveGraphqlSourceBinding(\n ctx,\n sourceId,\n sourceScope,\n auth.connectionSlot,\n );\n if (binding?.value.kind !== \"connection\") {\n return yield* new GraphqlInvocationError({\n message: `Missing OAuth connection binding for GraphQL source \"${sourceId}\"`,\n statusCode: Option.none(),\n });\n }\n const accessToken = yield* ctx.connections.accessTokenAtScope(\n binding.value.connectionId,\n binding.scopeId,\n );\n return { Authorization: `Bearer ${accessToken}` };\n });\n\nconst makeGraphqlExtension = (\n ctx: PluginCtx<GraphqlStore>,\n httpClientLayer: Layer.Layer<HttpClient.HttpClient>,\n configFile: ConfigFileSink | undefined,\n) => {\n const resolveCredentialInputMap = <E>(\n values: Record<string, GraphqlCredentialInput> | undefined,\n params: {\n readonly sourceId: string;\n readonly sourceScope: string;\n readonly targetScope?: string;\n readonly missingLabel: string;\n readonly makeError: (message: string) => E;\n },\n ): Effect.Effect<Record<string, string> | undefined, E | StorageFailure> =>\n Effect.gen(function* () {\n if (!values) return undefined;\n const resolved: Record<string, string> = {};\n for (const [name, value] of Object.entries(values)) {\n if (typeof value === \"string\") {\n resolved[name] = value;\n continue;\n }\n if (\"kind\" in value) {\n const slotResolved = yield* resolveGraphqlBindingValueMap(\n ctx,\n { [name]: value },\n {\n sourceId: params.sourceId,\n sourceScope: params.sourceScope,\n missingLabel: params.missingLabel,\n makeError: params.makeError,\n },\n );\n if (slotResolved?.[name] !== undefined) resolved[name] = slotResolved[name];\n continue;\n }\n const secretScope =\n \"secretScopeId\" in value\n ? (value.secretScopeId ?? value.targetScope)\n : (params.targetScope ?? params.sourceScope);\n const secret = yield* ctx.secrets\n .getAtScope(SecretId.make(value.secretId), secretScope)\n .pipe(\n Effect.catchTag(\"SecretOwnedByConnectionError\", () =>\n Effect.fail(\n params.makeError(`Secret not found for ${params.missingLabel} \"${name}\"`),\n ),\n ),\n );\n if (secret === null) {\n return yield* Effect.fail(\n params.makeError(\n `Missing secret \"${value.secretId}\" for ${params.missingLabel} \"${name}\"`,\n ),\n );\n }\n resolved[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n return Object.keys(resolved).length > 0 ? resolved : undefined;\n });\n\n const resolveOAuthInputHeader = (\n sourceId: string,\n sourceScope: string,\n targetScope: string | undefined,\n auth: GraphqlSourceAuthInput | undefined,\n ) =>\n Effect.gen(function* () {\n if (!auth || auth.kind === \"none\") return undefined;\n const connection =\n \"connectionId\" in auth\n ? { id: auth.connectionId, scope: targetScope ?? sourceScope }\n : yield* Effect.gen(function* () {\n const binding = yield* resolveGraphqlSourceBinding(\n ctx,\n sourceId,\n sourceScope,\n auth.connectionSlot,\n );\n return binding?.value.kind === \"connection\"\n ? { id: binding.value.connectionId, scope: binding.scopeId }\n : null;\n });\n if (connection === null) {\n return yield* new GraphqlIntrospectionError({\n message: `Missing OAuth connection binding for \"${sourceId}\"`,\n });\n }\n const accessToken = yield* ctx.connections\n .accessTokenAtScope(connection.id, connection.scope)\n .pipe(\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: `Failed to resolve OAuth connection \"${connection.id}\"`,\n }),\n ),\n );\n return { Authorization: `Bearer ${accessToken}` };\n });\n\n const addSourceInternal = (config: GraphqlSourceConfig) =>\n ctx.transaction(\n Effect.gen(function* () {\n const namespace = config.namespace ?? namespaceFromEndpoint(config.endpoint);\n const canonicalHeaders = canonicalizeCredentialMap(config.headers, graphqlHeaderSlot);\n const canonicalQueryParams = canonicalizeCredentialMap(\n config.queryParams,\n graphqlQueryParamSlot,\n );\n const canonicalAuth = canonicalizeAuth(config.auth);\n const directBindings = [\n ...canonicalHeaders.bindings,\n ...canonicalQueryParams.bindings,\n ...canonicalAuth.bindings,\n ];\n for (const binding of directBindings) {\n const bindingTargetScope = yield* targetScopeForBinding(\n config.credentialTargetScope,\n binding,\n );\n yield* validateGraphqlBindingTarget(ctx, {\n sourceId: namespace,\n sourceScope: config.scope,\n targetScope: bindingTargetScope,\n });\n }\n const targetScope =\n directBindings[0] !== undefined\n ? yield* targetScopeForBinding(config.credentialTargetScope, directBindings[0])\n : undefined;\n\n let introspectionResult: IntrospectionResult;\n if (config.introspectionJson) {\n introspectionResult = yield* parseIntrospectionJson(config.introspectionJson);\n } else {\n const resolvedHeaders = yield* resolveCredentialInputMap(config.headers, {\n sourceId: namespace,\n sourceScope: config.scope,\n targetScope,\n missingLabel: \"header\",\n makeError: (message) => new GraphqlIntrospectionError({ message }),\n });\n const oauthHeader = yield* resolveOAuthInputHeader(\n namespace,\n config.scope,\n targetScope,\n config.auth,\n );\n const resolvedQueryParams = yield* resolveCredentialInputMap(config.queryParams, {\n sourceId: namespace,\n sourceScope: config.scope,\n targetScope,\n missingLabel: \"query parameter\",\n makeError: (message) => new GraphqlIntrospectionError({ message }),\n });\n introspectionResult = yield* introspect(\n config.endpoint,\n { ...(resolvedHeaders ?? {}), ...(oauthHeader ?? {}) },\n resolvedQueryParams,\n ).pipe(Effect.provide(httpClientLayer));\n }\n\n const { result, definitions } = yield* extract(introspectionResult);\n const prepared = prepareOperations(result.fields, introspectionResult);\n\n const displayName = config.name?.trim() || namespace;\n\n const storedSource: StoredGraphqlSource = {\n namespace,\n scope: config.scope,\n name: displayName,\n endpoint: config.endpoint,\n headers: canonicalHeaders.values,\n queryParams: canonicalQueryParams.values,\n auth: canonicalAuth.auth,\n };\n\n const storedOps: StoredOperation[] = prepared.map((p) => ({\n toolId: `${namespace}.${p.toolPath}`,\n sourceId: namespace,\n binding: p.binding,\n }));\n\n yield* ctx.storage.upsertSource(storedSource, storedOps);\n\n yield* ctx.core.sources.register({\n id: namespace,\n scope: config.scope,\n kind: \"graphql\",\n name: displayName,\n url: config.endpoint,\n canRemove: true,\n canRefresh: false,\n canEdit: true,\n tools: prepared.map((p) => ({\n name: p.toolPath,\n description: p.description,\n inputSchema: p.inputSchema,\n })),\n });\n\n if (Object.keys(definitions).length > 0) {\n yield* ctx.core.definitions.register({\n sourceId: namespace,\n scope: config.scope,\n definitions,\n });\n }\n\n if (directBindings.length > 0) {\n for (const binding of directBindings) {\n const bindingTargetScope = yield* targetScopeForBinding(\n config.credentialTargetScope,\n binding,\n );\n yield* ctx.credentialBindings.set({\n targetScope: ScopeId.make(bindingTargetScope),\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId: namespace,\n sourceScope: ScopeId.make(config.scope),\n slotKey: binding.slot,\n value: binding.value,\n });\n }\n }\n\n return { toolCount: prepared.length, namespace };\n }),\n );\n\n return {\n addSource: (config: GraphqlSourceConfig) =>\n addSourceInternal(config).pipe(\n Effect.tap((result) =>\n configFile\n ? configFile.upsertSource(toGraphqlConfigEntry(result.namespace, config))\n : Effect.void,\n ),\n ),\n\n removeSource: (namespace: string, scope: string) =>\n Effect.gen(function* () {\n yield* ctx.transaction(\n Effect.gen(function* () {\n yield* ctx.credentialBindings.removeForSource({\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId: namespace,\n sourceScope: ScopeId.make(scope),\n });\n yield* ctx.storage.removeSource(namespace, scope);\n yield* ctx.core.sources.unregister({ id: namespace, targetScope: scope });\n }),\n );\n if (configFile) {\n yield* configFile.removeSource(namespace);\n }\n }),\n\n getSource: (namespace: string, scope: string) => ctx.storage.getSource(namespace, scope),\n\n updateSource: (namespace: string, scope: string, input: GraphqlUpdateSourceInput) =>\n Effect.gen(function* () {\n const existing = yield* ctx.storage.getSource(namespace, scope);\n if (!existing) return;\n const canonicalHeaders =\n input.headers !== undefined\n ? canonicalizeCredentialMap(input.headers, graphqlHeaderSlot)\n : null;\n const canonicalQueryParams =\n input.queryParams !== undefined\n ? canonicalizeCredentialMap(input.queryParams, graphqlQueryParamSlot)\n : null;\n const canonicalAuth = input.auth !== undefined ? canonicalizeAuth(input.auth) : null;\n const directBindings = [\n ...(canonicalHeaders?.bindings ?? []),\n ...(canonicalQueryParams?.bindings ?? []),\n ...(canonicalAuth?.bindings ?? []),\n ];\n const targetScope = yield* bindingTargetScope(input.credentialTargetScope, directBindings);\n if (targetScope) {\n yield* validateGraphqlBindingTarget(ctx, {\n sourceId: namespace,\n sourceScope: scope,\n targetScope,\n });\n }\n const affectedPrefixes = [\n ...(input.headers !== undefined ? [\"header:\"] : []),\n ...(input.queryParams !== undefined ? [\"query_param:\"] : []),\n ...(input.auth !== undefined ? [\"auth:\"] : []),\n ];\n const replacementTargetScope = targetScope ?? input.credentialTargetScope ?? scope;\n yield* ctx.transaction(\n Effect.gen(function* () {\n yield* ctx.storage.updateSourceMeta(namespace, scope, {\n name: input.name?.trim() || undefined,\n endpoint: input.endpoint,\n headers: canonicalHeaders?.values,\n queryParams: canonicalQueryParams?.values,\n auth: canonicalAuth?.auth,\n });\n if (affectedPrefixes.length > 0 || directBindings.length > 0) {\n yield* ctx.credentialBindings.replaceForSource({\n targetScope: ScopeId.make(replacementTargetScope),\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId: namespace,\n sourceScope: ScopeId.make(scope),\n slotPrefixes: affectedPrefixes,\n bindings: directBindings.map((binding) => ({\n slotKey: binding.slot,\n value: binding.value,\n })),\n });\n }\n }),\n );\n }),\n\n listSourceBindings: (sourceId: string, sourceScope: string) =>\n listGraphqlSourceBindings(ctx, sourceId, sourceScope),\n\n setSourceBinding: (input: GraphqlSourceBindingInput) =>\n Effect.gen(function* () {\n yield* validateGraphqlBindingTarget(ctx, {\n sourceId: input.sourceId,\n sourceScope: input.sourceScope,\n targetScope: input.scope,\n });\n const binding = yield* ctx.credentialBindings.set({\n targetScope: input.scope,\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId: input.sourceId,\n sourceScope: input.sourceScope,\n slotKey: input.slot,\n value: input.value,\n });\n return coreBindingToGraphqlBinding(binding);\n }),\n\n removeSourceBinding: (sourceId: string, sourceScope: string, slot: string, scope: string) =>\n Effect.gen(function* () {\n yield* validateGraphqlBindingTarget(ctx, {\n sourceId,\n sourceScope,\n targetScope: scope,\n });\n yield* ctx.credentialBindings.remove({\n targetScope: ScopeId.make(scope),\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId,\n sourceScope: ScopeId.make(sourceScope),\n slotKey: slot,\n });\n }),\n };\n};\n\nexport type GraphqlPluginExtension = ReturnType<typeof makeGraphqlExtension>;\n\nexport const graphqlPlugin = definePlugin((options?: GraphqlPluginOptions) => {\n return {\n id: \"graphql\" as const,\n packageName: \"@executor-js/plugin-graphql\",\n schema: graphqlSchema,\n storage: (deps): GraphqlStore => makeDefaultGraphqlStore(deps),\n\n extension: (ctx) =>\n makeGraphqlExtension(\n ctx,\n options?.httpClientLayer ?? ctx.httpClientLayer,\n options?.configFile,\n ),\n\n staticSources: (self) => [\n {\n id: \"graphql\",\n kind: \"executor\",\n name: \"GraphQL\",\n tools: [\n tool({\n name: \"addSource\",\n description: \"Add a GraphQL endpoint and register its operations as tools\",\n annotations: {\n requiresApproval: true,\n approvalDescription: \"Add a GraphQL source\",\n },\n inputSchema: StaticAddSourceInputStandardSchema,\n outputSchema: StaticAddSourceOutputStandardSchema,\n execute: (input) => self.addSource(input),\n }),\n ],\n },\n ],\n\n invokeTool: ({ ctx, toolRow, args }) =>\n Effect.gen(function* () {\n const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;\n // toolRow.scope_id is the resolved owning scope of the tool\n // (innermost-wins from the executor's stack). The matching\n // graphql_operation + graphql_source rows live at the same\n // scope, so pin every store lookup to it instead of relying\n // on the scoped adapter's stack-wide fall-through.\n const toolScope = toolRow.scope_id;\n const op = yield* ctx.storage.getOperationByToolId(toolRow.id, toolScope);\n if (!op) {\n return yield* new GraphqlInvocationError({\n message: `No GraphQL operation found for tool \"${toolRow.id}\"`,\n statusCode: Option.none(),\n });\n }\n const source = yield* ctx.storage.getSource(op.sourceId, toolScope);\n if (!source) {\n return yield* new GraphqlInvocationError({\n message: `No GraphQL source found for \"${op.sourceId}\"`,\n statusCode: Option.none(),\n });\n }\n\n const resolvedHeaders =\n (yield* resolveGraphqlBindingValueMap(ctx, source.headers, {\n sourceId: source.namespace,\n sourceScope: source.scope,\n missingLabel: \"header\",\n makeError: (message) =>\n new GraphqlInvocationError({ message, statusCode: Option.none() }),\n })) ?? {};\n const resolvedQueryParams =\n (yield* resolveGraphqlBindingValueMap(ctx, source.queryParams, {\n sourceId: source.namespace,\n sourceScope: source.scope,\n missingLabel: \"query parameter\",\n makeError: (message) =>\n new GraphqlInvocationError({ message, statusCode: Option.none() }),\n })) ?? {};\n const oauthHeader = yield* resolveGraphqlStoredOAuthHeader(\n ctx,\n source.namespace,\n source.scope,\n source.auth,\n );\n Object.assign(resolvedHeaders, oauthHeader ?? {});\n\n const result = yield* invokeWithLayer(\n op.binding,\n (args ?? {}) as Record<string, unknown>,\n source.endpoint,\n resolvedHeaders,\n resolvedQueryParams,\n httpClientLayer,\n );\n\n return result;\n }),\n\n resolveAnnotations: ({ ctx, sourceId, toolRows }) =>\n Effect.gen(function* () {\n // toolRows for a single (plugin_id, source_id) group can still\n // straddle multiple scopes when the source is shadowed (e.g. an\n // org-level GraphQL source plus a per-user override that\n // re-registers the same tool ids). Run one listOperationsBySource\n // per distinct scope so each lookup pins {source_id, scope_id}\n // and we don't fall through to the wrong scope's bindings.\n const scopes = new Set<string>();\n for (const row of toolRows as readonly ToolRow[]) {\n scopes.add(row.scope_id);\n }\n // One listOperationsBySource per scope is independent storage\n // work; run them in parallel so a shadowed source doesn't\n // serialise two ~200ms reads back-to-back in the caller's\n // `executor.tools.list.annotations` span.\n const entries = yield* Effect.forEach(\n [...scopes],\n (scope) =>\n Effect.gen(function* () {\n const ops = yield* ctx.storage.listOperationsBySource(sourceId, scope);\n const byId = new Map<string, OperationBinding>();\n for (const op of ops) byId.set(op.toolId, op.binding);\n return [scope, byId] as const;\n }),\n { concurrency: \"unbounded\" },\n );\n const byScope = new Map<string, Map<string, OperationBinding>>(entries);\n\n const out: Record<string, ToolAnnotations> = {};\n for (const row of toolRows as readonly ToolRow[]) {\n const binding = byScope.get(row.scope_id)?.get(row.id);\n if (binding) out[row.id] = annotationsFor(binding);\n }\n return out;\n }),\n\n removeSource: ({ ctx, sourceId, scope }) =>\n Effect.gen(function* () {\n yield* ctx.transaction(\n Effect.gen(function* () {\n yield* ctx.credentialBindings.removeForSource({\n pluginId: GRAPHQL_PLUGIN_ID,\n sourceId,\n sourceScope: ScopeId.make(scope),\n });\n yield* ctx.storage.removeSource(sourceId, scope);\n }),\n );\n if (options?.configFile) {\n yield* options.configFile.removeSource(sourceId);\n }\n }),\n\n usagesForSecret: () => Effect.succeed([]),\n\n usagesForConnection: () => Effect.succeed([]),\n\n detect: ({ ctx, url }) =>\n Effect.gen(function* () {\n const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;\n const trimmed = url.trim();\n if (!trimmed) return null;\n const parsed = yield* Effect.try({\n try: () => new URL(trimmed),\n catch: (cause) => cause,\n }).pipe(Effect.option);\n if (Option.isNone(parsed)) return null;\n\n const ok = yield* introspect(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.map(() => true),\n Effect.catch(() => Effect.succeed(false)),\n );\n\n const name = namespaceFromEndpoint(trimmed);\n\n if (ok) {\n return SourceDetectionResult.make({\n kind: \"graphql\",\n confidence: \"high\",\n endpoint: trimmed,\n name,\n namespace: name,\n });\n }\n\n // Low-confidence URL-token fallback. Introspection can fail for\n // many reasons (auth, CORS, the endpoint disabled introspection\n // in production, transport errors). When the URL itself\n // strongly implies GraphQL, surface a candidate so the user\n // can still pick it from the detect dropdown.\n if (urlMatchesToken(parsed.value, \"graphql\")) {\n return SourceDetectionResult.make({\n kind: \"graphql\",\n confidence: \"low\",\n endpoint: trimmed,\n name,\n namespace: name,\n });\n }\n\n return null;\n }),\n };\n // HTTP transport (routes/handlers/extensionService) is layered on by\n // the api-aware factory in `@executor-js/plugin-graphql/api`. Hosts that\n // want the HTTP surface import the plugin from there; SDK-only\n // consumers stay on this entry and avoid the server-only deps.\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,cAAc;AAC/B,SAAS,YAAY,yBAAyB;AAQ9C,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0E5B,IAAM,2BAA2B,OAAO,OAAO;AAAA,EAC7C,MAAM,OAAO;AAAA,EACb,MAAM,OAAO,OAAO,OAAO,MAAM;AAAA,EACjC,QAAQ,OAAO;AACjB,CAAC;AAED,IAAM,wBAAwB,OAAO,OAAO;AAAA,EAC1C,MAAM,OAAO;AAAA,EACb,MAAM,OAAO,OAAO,OAAO,MAAM;AAAA,EACjC,QAAQ,OAAO,OAAO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sBAAsB,KAAK;AAAA,UAChC,MAAM;AAAA,UACN,YAAY;AAAA,UACZ,UAAU;AAAA,UACV;AAAA,UACA,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAOA,UAAI,gBAAgB,OAAO,OAAO,SAAS,GAAG;AAC5C,eAAO,sBAAsB,KAAK;AAAA,UAChC,MAAM;AAAA,UACN,YAAY;AAAA,UACZ,UAAU;AAAA,UACV;AAAA,UACA,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACL;AAKF,CAAC;","names":["Effect","Effect","Effect","Option","HttpClient","HttpClientRequest","Effect","Option","HttpClient","HttpClientRequest","Effect","Schema","Schema","Effect","Effect","Match","Option","Schema","ConfiguredCredentialBinding","Schema","formatTypeRef","Match","Option","unwrapTypeName","Effect","ConfiguredCredentialBinding","bindingTargetScope"]}
package/dist/client.js CHANGED
@@ -47,9 +47,9 @@ var graphqlPresets = [
47
47
  ];
48
48
 
49
49
  // src/react/source-plugin.ts
50
- var importAdd = () => import("./AddGraphqlSource-LGXJQEAR.js");
51
- var importEdit = () => import("./EditGraphqlSource-5Y47ZAZ7.js");
52
- var importSummary = () => import("./GraphqlSourceSummary-F3JWR4YN.js");
50
+ var importAdd = () => import("./AddGraphqlSource-3Z3DB4KQ.js");
51
+ var importEdit = () => import("./EditGraphqlSource-F37RPNKV.js");
52
+ var importSummary = () => import("./GraphqlSourceSummary-6EYBXVD2.js");
53
53
  var graphqlSourcePlugin = {
54
54
  key: "graphql",
55
55
  label: "GraphQL",
package/dist/core.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  makeDefaultGraphqlStore,
9
9
  parseIntrospectionJson,
10
10
  resolveHeaders
11
- } from "./chunk-HDPYOBBG.js";
11
+ } from "./chunk-PO2TPM5B.js";
12
12
  import {
13
13
  ConfiguredGraphqlCredentialValue,
14
14
  ExtractedField,
@@ -32,7 +32,7 @@ import {
32
32
  QueryParamValue,
33
33
  graphqlHeaderSlot,
34
34
  graphqlQueryParamSlot
35
- } from "./chunk-7QSGNR4C.js";
35
+ } from "./chunk-445ZPXHU.js";
36
36
  export {
37
37
  ConfiguredGraphqlCredentialValue,
38
38
  ExtractedField,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  graphqlPlugin
3
- } from "./chunk-HDPYOBBG.js";
4
- import "./chunk-7QSGNR4C.js";
3
+ } from "./chunk-PO2TPM5B.js";
4
+ import "./chunk-445ZPXHU.js";
5
5
  export {
6
6
  graphqlPlugin
7
7
  };
@@ -27,7 +27,25 @@ export declare const graphqlSourceAtom: (scopeId: ScopeId, namespace: string) =>
27
27
  readonly connectionSlot: string;
28
28
  };
29
29
  } | null, import("@executor-js/api").InternalError | import("../sdk").GraphqlIntrospectionError | import("../sdk").GraphqlExtractionError>>;
30
- export declare const graphqlSourceBindingsAtom: (scopeId: ScopeId, namespace: string, sourceScopeId: ScopeId) => Atom.Atom<AsyncResult.AsyncResult<readonly import("../sdk").GraphqlSourceBindingRef[], import("@executor-js/api").InternalError | import("../sdk").GraphqlIntrospectionError | import("../sdk").GraphqlExtractionError>>;
30
+ export declare const graphqlSourceBindingsAtom: (scopeId: ScopeId, namespace: string, sourceScopeId: ScopeId) => Atom.Atom<AsyncResult.AsyncResult<readonly {
31
+ readonly value: {
32
+ readonly text: string;
33
+ readonly kind: "text";
34
+ } | {
35
+ readonly secretId: string & import("effect/Brand").Brand<"SecretId">;
36
+ readonly kind: "secret";
37
+ readonly secretScopeId?: (string & import("effect/Brand").Brand<"ScopeId">) | undefined;
38
+ } | {
39
+ readonly connectionId: string & import("effect/Brand").Brand<"ConnectionId">;
40
+ readonly kind: "connection";
41
+ };
42
+ readonly createdAt: Date;
43
+ readonly sourceId: string;
44
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
45
+ readonly updatedAt: Date;
46
+ readonly slot: string;
47
+ readonly sourceScopeId: string & import("effect/Brand").Brand<"ScopeId">;
48
+ }[], import("@executor-js/api").InternalError | import("../sdk").GraphqlIntrospectionError | import("../sdk").GraphqlExtractionError>>;
31
49
  export declare const addGraphqlSource: Atom.AtomResultFn<{
32
50
  readonly params: {
33
51
  readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
@@ -220,7 +238,25 @@ export declare const setGraphqlSourceBinding: Atom.AtomResultFn<{
220
238
  };
221
239
  readonly responseMode?: "decoded-only" | undefined;
222
240
  readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
223
- }, import("../sdk").GraphqlSourceBindingRef, import("@executor-js/api").InternalError | import("../sdk").GraphqlIntrospectionError | import("../sdk").GraphqlExtractionError>;
241
+ }, {
242
+ readonly value: {
243
+ readonly text: string;
244
+ readonly kind: "text";
245
+ } | {
246
+ readonly secretId: string & import("effect/Brand").Brand<"SecretId">;
247
+ readonly kind: "secret";
248
+ readonly secretScopeId?: (string & import("effect/Brand").Brand<"ScopeId">) | undefined;
249
+ } | {
250
+ readonly connectionId: string & import("effect/Brand").Brand<"ConnectionId">;
251
+ readonly kind: "connection";
252
+ };
253
+ readonly createdAt: Date;
254
+ readonly sourceId: string;
255
+ readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
256
+ readonly updatedAt: Date;
257
+ readonly slot: string;
258
+ readonly sourceScopeId: string & import("effect/Brand").Brand<"ScopeId">;
259
+ }, import("@executor-js/api").InternalError | import("../sdk").GraphqlIntrospectionError | import("../sdk").GraphqlExtractionError>;
224
260
  export declare const removeGraphqlSourceBinding: Atom.AtomResultFn<{
225
261
  readonly params: {
226
262
  readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
@@ -178,7 +178,25 @@ export declare const GraphqlClient: import("effect/unstable/reactivity/AtomHttpA
178
178
  scopeId: import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">;
179
179
  namespace: import("effect/Schema").String;
180
180
  sourceScopeId: import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">;
181
- }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").$Array<typeof import("../sdk").GraphqlSourceBindingRef>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("@executor-js/sdk").InternalError | import("effect/Schema").decodeTo<import("effect/Schema").declareConstructor<import("../sdk").GraphqlIntrospectionError, {
181
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").$Array<import("effect/Schema").Struct<{
182
+ readonly sourceId: import("effect/Schema").String;
183
+ readonly sourceScopeId: import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">;
184
+ readonly scopeId: import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">;
185
+ readonly slot: import("effect/Schema").String;
186
+ readonly value: import("effect/Schema").Union<readonly [import("effect/Schema").Struct<{
187
+ readonly kind: import("effect/Schema").Literal<"text">;
188
+ readonly text: import("effect/Schema").String;
189
+ }>, import("effect/Schema").Struct<{
190
+ readonly kind: import("effect/Schema").Literal<"secret">;
191
+ readonly secretId: import("effect/Schema").brand<import("effect/Schema").String, "SecretId">;
192
+ readonly secretScopeId: import("effect/Schema").optional<import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">>;
193
+ }>, import("effect/Schema").Struct<{
194
+ readonly kind: import("effect/Schema").Literal<"connection">;
195
+ readonly connectionId: import("effect/Schema").brand<import("effect/Schema").String, "ConnectionId">;
196
+ }>]>;
197
+ readonly createdAt: import("effect/Schema").Date;
198
+ readonly updatedAt: import("effect/Schema").Date;
199
+ }>>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("@executor-js/sdk").InternalError | import("effect/Schema").decodeTo<import("effect/Schema").declareConstructor<import("../sdk").GraphqlIntrospectionError, {
182
200
  readonly message: string;
183
201
  readonly _tag: "GraphqlIntrospectionError";
184
202
  }, readonly [import("effect/Schema").TaggedStruct<"GraphqlIntrospectionError", {
@@ -216,7 +234,25 @@ export declare const GraphqlClient: import("effect/unstable/reactivity/AtomHttpA
216
234
  readonly kind: import("effect/Schema").Literal<"connection">;
217
235
  readonly connectionId: import("effect/Schema").brand<import("effect/Schema").String, "ConnectionId">;
218
236
  }>]>;
219
- }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../sdk").GraphqlSourceBindingRef>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("@executor-js/sdk").InternalError | import("effect/Schema").decodeTo<import("effect/Schema").declareConstructor<import("../sdk").GraphqlIntrospectionError, {
237
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
238
+ readonly sourceId: import("effect/Schema").String;
239
+ readonly sourceScopeId: import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">;
240
+ readonly scopeId: import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">;
241
+ readonly slot: import("effect/Schema").String;
242
+ readonly value: import("effect/Schema").Union<readonly [import("effect/Schema").Struct<{
243
+ readonly kind: import("effect/Schema").Literal<"text">;
244
+ readonly text: import("effect/Schema").String;
245
+ }>, import("effect/Schema").Struct<{
246
+ readonly kind: import("effect/Schema").Literal<"secret">;
247
+ readonly secretId: import("effect/Schema").brand<import("effect/Schema").String, "SecretId">;
248
+ readonly secretScopeId: import("effect/Schema").optional<import("effect/Schema").brand<import("effect/Schema").String, "ScopeId">>;
249
+ }>, import("effect/Schema").Struct<{
250
+ readonly kind: import("effect/Schema").Literal<"connection">;
251
+ readonly connectionId: import("effect/Schema").brand<import("effect/Schema").String, "ConnectionId">;
252
+ }>]>;
253
+ readonly createdAt: import("effect/Schema").Date;
254
+ readonly updatedAt: import("effect/Schema").Date;
255
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("@executor-js/sdk").InternalError | import("effect/Schema").decodeTo<import("effect/Schema").declareConstructor<import("../sdk").GraphqlIntrospectionError, {
220
256
  readonly message: string;
221
257
  readonly _tag: "GraphqlIntrospectionError";
222
258
  }, readonly [import("effect/Schema").TaggedStruct<"GraphqlIntrospectionError", {
@@ -1,10 +1,23 @@
1
1
  import { Effect, Layer } from "effect";
2
2
  import { HttpClient } from "effect/unstable/http";
3
3
  import { GraphqlInvocationError } from "./errors";
4
- import { type HeaderValue, type OperationBinding, InvocationResult } from "./types";
4
+ import { type HeaderValue, type OperationBinding } from "./types";
5
5
  export declare const resolveHeaders: (headers: Record<string, HeaderValue>, secrets: {
6
6
  readonly get: (id: string) => Effect.Effect<string | null, unknown>;
7
7
  }) => Effect.Effect<Record<string, string>>;
8
8
  export declare const endpointForTelemetry: (endpoint: string) => string;
9
- export declare const invoke: (operation: OperationBinding, args: Record<string, unknown>, endpoint: string, resolvedHeaders: Record<string, string>, resolvedQueryParams?: Record<string, string> | undefined) => Effect.Effect<InvocationResult, import("effect/unstable/http/HttpClientError").HttpClientError | GraphqlInvocationError, HttpClient.HttpClient>;
10
- export declare const invokeWithLayer: (operation: OperationBinding, args: Record<string, unknown>, endpoint: string, resolvedHeaders: Record<string, string>, resolvedQueryParams: Record<string, string>, httpClientLayer: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<InvocationResult, import("effect/unstable/http/HttpClientError").HttpClientError | GraphqlInvocationError, never>;
9
+ export declare const invoke: (operation: {
10
+ readonly fieldName: string;
11
+ readonly kind: "query" | "mutation";
12
+ readonly variableNames: readonly string[];
13
+ readonly operationString: string;
14
+ }, args: Record<string, unknown>, endpoint: string, resolvedHeaders: Record<string, string>, resolvedQueryParams?: Record<string, string> | undefined) => Effect.Effect<{
15
+ readonly status: number;
16
+ readonly data: unknown;
17
+ readonly errors: unknown;
18
+ }, import("effect/unstable/http/HttpClientError").HttpClientError | GraphqlInvocationError, HttpClient.HttpClient>;
19
+ export declare const invokeWithLayer: (operation: OperationBinding, args: Record<string, unknown>, endpoint: string, resolvedHeaders: Record<string, string>, resolvedQueryParams: Record<string, string>, httpClientLayer: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<{
20
+ readonly status: number;
21
+ readonly data: unknown;
22
+ readonly errors: unknown;
23
+ }, import("effect/unstable/http/HttpClientError").HttpClientError | GraphqlInvocationError, never>;