@executor-js/plugin-graphql 1.4.32 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/AddGraphqlSource-P3D3UXRJ.js +179 -0
  2. package/dist/AddGraphqlSource-P3D3UXRJ.js.map +1 -0
  3. package/dist/EditGraphqlSource-FVF67CTP.js +38 -0
  4. package/dist/EditGraphqlSource-FVF67CTP.js.map +1 -0
  5. package/dist/GraphqlAccountsPanel-GBNFHLFH.js +9 -0
  6. package/dist/GraphqlAccountsPanel-GBNFHLFH.js.map +1 -0
  7. package/dist/api/group.d.ts +108 -119
  8. package/dist/api/handlers.d.ts +9 -7
  9. package/dist/api/index.d.ts +117 -104
  10. package/dist/chunk-2Y3J3CVO.js +191 -0
  11. package/dist/chunk-2Y3J3CVO.js.map +1 -0
  12. package/dist/chunk-ADQTI2OK.js +1309 -0
  13. package/dist/chunk-ADQTI2OK.js.map +1 -0
  14. package/dist/{chunk-UIAHATHP.js → chunk-N5GJE7R6.js} +42 -58
  15. package/dist/chunk-N5GJE7R6.js.map +1 -0
  16. package/dist/chunk-VCYDSSIK.js +79 -0
  17. package/dist/chunk-VCYDSSIK.js.map +1 -0
  18. package/dist/client.js +7 -7
  19. package/dist/client.js.map +1 -1
  20. package/dist/core.js +20 -28
  21. package/dist/index.js +2 -2
  22. package/dist/react/AddGraphqlSource.d.ts +1 -1
  23. package/dist/react/EditGraphqlSource.d.ts +2 -2
  24. package/dist/react/GraphqlAccountsPanel.d.ts +6 -0
  25. package/dist/react/GraphqlSignInButton.d.ts +6 -2
  26. package/dist/react/GraphqlSourceFields.d.ts +2 -2
  27. package/dist/react/atoms.d.ts +95 -205
  28. package/dist/react/auth-method-config.d.ts +9 -0
  29. package/dist/react/client.d.ts +108 -97
  30. package/dist/react/defaults.d.ts +16 -2
  31. package/dist/react/index.d.ts +2 -2
  32. package/dist/react/source-plugin.d.ts +2 -2
  33. package/dist/sdk/errors.d.ts +8 -6
  34. package/dist/sdk/index.d.ts +5 -5
  35. package/dist/sdk/introspect.d.ts +1 -1
  36. package/dist/sdk/invoke.d.ts +1 -4
  37. package/dist/sdk/plugin.d.ts +94 -104
  38. package/dist/sdk/store.d.ts +11 -28
  39. package/dist/sdk/types.d.ts +110 -72
  40. package/package.json +5 -4
  41. package/dist/AddGraphqlSource-CJCUUYNM.js +0 -250
  42. package/dist/AddGraphqlSource-CJCUUYNM.js.map +0 -1
  43. package/dist/EditGraphqlSource-YLTPUYW4.js +0 -267
  44. package/dist/EditGraphqlSource-YLTPUYW4.js.map +0 -1
  45. package/dist/GraphqlSourceSummary-YWJX6ONU.js +0 -70
  46. package/dist/GraphqlSourceSummary-YWJX6ONU.js.map +0 -1
  47. package/dist/chunk-2252RTCE.js +0 -1730
  48. package/dist/chunk-2252RTCE.js.map +0 -1
  49. package/dist/chunk-D3FN3ZDA.js +0 -125
  50. package/dist/chunk-D3FN3ZDA.js.map +0 -1
  51. package/dist/chunk-M4SJY6CB.js +0 -45
  52. package/dist/chunk-M4SJY6CB.js.map +0 -1
  53. package/dist/chunk-UIAHATHP.js.map +0 -1
  54. package/dist/react/GraphqlSourceSummary.d.ts +0 -5
@@ -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, Option, 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.optional(Schema.Null),\n});\n\nconst IntrospectionTypeRef5 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.optional(Schema.NullOr(IntrospectionTypeRefLeaf)),\n});\n\nconst IntrospectionTypeRef4 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.optional(Schema.NullOr(IntrospectionTypeRef5)),\n});\n\nconst IntrospectionTypeRef3 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.optional(Schema.NullOr(IntrospectionTypeRef4)),\n});\n\nconst IntrospectionTypeRef2 = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.optional(Schema.NullOr(IntrospectionTypeRef3)),\n});\n\nconst IntrospectionTypeRefSchema = Schema.Struct({\n kind: Schema.String,\n name: Schema.NullOr(Schema.String),\n ofType: Schema.optional(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 UpstreamErrorResponseSchema = Schema.Struct({\n message: Schema.optional(Schema.String),\n errors: Schema.optional(\n Schema.Array(\n Schema.Struct({\n message: Schema.optional(Schema.String),\n }),\n ),\n ),\n});\n\nconst IntrospectionJsonSchema = Schema.Union([\n Schema.Struct({ data: IntrospectionResultSchema }),\n IntrospectionResultSchema,\n]);\nconst JsonTextSchema = Schema.fromJsonString(Schema.Unknown);\n\nconst decodeUpstreamErrorResponse = Schema.decodeUnknownOption(UpstreamErrorResponseSchema);\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\nconst firstUpstreamErrorMessage = (value: unknown): string | null => {\n const decoded = decodeUpstreamErrorResponse(value);\n return Option.match(decoded, {\n onNone: () => null,\n onSome: (response) => {\n if (response.message) return response.message;\n for (const entry of response.errors ?? []) {\n const message = entry.message;\n if (message) return message;\n }\n return null;\n },\n });\n};\n\nconst redactUpstreamBody = (body: string): string =>\n body\n .replaceAll(\n /(\"(?:access_token|refresh_token|id_token|client_secret|token|authorization)\"\\s*:\\s*\")[^\"]*(\")/gi,\n \"$1[redacted]$2\",\n )\n .replaceAll(\n /((?:access_token|refresh_token|id_token|client_secret|token|authorization)=)[^&\\s]*/gi,\n \"$1[redacted]\",\n )\n .replaceAll(\n /((?:authorization|access-token|refresh-token|id-token|client-secret|token)\\s*:\\s*)(?:bearer\\s+)?[^\\s,;]+/gi,\n \"$1[redacted]\",\n );\n\nconst upstreamTextMessage = (body: string): string | null => {\n const text = redactUpstreamBody(body.replaceAll(/\\s+/g, \" \").trim());\n if (text.length === 0) return null;\n return text.length > 500 ? `${text.slice(0, 500)}...` : text;\n};\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.setHeader(\"Accept\", \"application/json\"),\n HttpClientRequest.setHeader(\"User-Agent\", \"executor-graphql\"),\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 const responseText = yield* response.text.pipe(Effect.catch(() => Effect.succeed(\"\")));\n const raw = responseText\n ? yield* Schema.decodeUnknownEffect(JsonTextSchema)(responseText).pipe(\n Effect.catch(() => Effect.succeed(null)),\n )\n : null;\n const upstreamMessage = upstreamTextMessage(\n (raw === null ? null : firstUpstreamErrorMessage(raw)) ?? responseText,\n );\n return yield* new GraphqlIntrospectionError({\n message: upstreamMessage\n ? `Introspection failed with status ${response.status}: ${upstreamMessage}`\n : `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 const upstreamMessage = firstUpstreamErrorMessage(json);\n return yield* new GraphqlIntrospectionError({\n message: upstreamMessage\n ? `Introspection returned ${json.errors.length} error(s): ${upstreamMessage}`\n : `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\";\n\nimport { GraphqlInvocationError } from \"./errors\";\nimport { type OperationBinding, InvocationResult } from \"./types\";\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, Option, Predicate, Schema } from \"effect\";\n\nimport {\n type Owner,\n type PluginStorageEntry,\n type StorageDeps,\n type StorageFailure,\n} from \"@executor-js/sdk/core\";\n\nimport { OperationBinding } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Per-integration operation bindings.\n//\n// In v2 the integration's GraphQL operations are derived from introspection and\n// are identical for every connection, so the plugin store keeps one set of\n// operation bindings per integration slug — `invokeTool` reads them back to\n// rebuild the request. Operations are catalog-level metadata, so they live under\n// the shared `owner: \"org\"` partition.\n// ---------------------------------------------------------------------------\n\nconst CATALOG_OWNER: Owner = \"org\";\nconst OPERATION_COLLECTION = \"operation\";\n\nexport interface StoredOperation {\n /** The tool's leaf name, e.g. `query.hello`. */\n readonly toolName: string;\n /** The owning integration slug. */\n readonly integration: string;\n readonly binding: OperationBinding;\n}\n\nconst OperationBindingFromJsonString = Schema.fromJsonString(OperationBinding);\nconst decodeOperationBindingFromJsonString = Schema.decodeUnknownSync(\n OperationBindingFromJsonString,\n);\nconst decodeOperationBinding = Schema.decodeUnknownSync(OperationBinding);\nconst encodeBinding = Schema.encodeSync(OperationBinding);\n\nconst decodeBinding = (value: unknown): OperationBinding => {\n if (typeof value === \"string\") return decodeOperationBindingFromJsonString(value);\n return decodeOperationBinding(value);\n};\n\nconst toJsonRecord = (value: unknown): Record<string, unknown> => value as Record<string, unknown>;\n\nconst OperationStorage = Schema.Struct({\n toolName: Schema.String,\n integration: Schema.String,\n binding: Schema.Unknown,\n});\nconst decodeOperationStorage = Schema.decodeUnknownOption(OperationStorage);\n\nconst operationKey = (integration: string, toolName: string): string =>\n `${integration}.${toolName}`;\n\nconst operationData = (operation: StoredOperation) => ({\n toolName: operation.toolName,\n integration: operation.integration,\n binding: toJsonRecord(encodeBinding(operation.binding)),\n});\n\nconst rowToOperation = (row: PluginStorageEntry): StoredOperation | null => {\n const decoded = decodeOperationStorage(row.data);\n if (Option.isNone(decoded)) return null;\n const operation = decoded.value;\n return {\n toolName: operation.toolName,\n integration: operation.integration,\n binding: decodeBinding(operation.binding),\n };\n};\n\nexport interface GraphqlStore {\n /** Replace the stored operation bindings for an integration. */\n readonly replaceOperations: (\n integration: string,\n operations: readonly StoredOperation[],\n ) => Effect.Effect<void, StorageFailure>;\n readonly getOperation: (\n integration: string,\n toolName: string,\n ) => Effect.Effect<StoredOperation | null, StorageFailure>;\n readonly listOperations: (\n integration: string,\n ) => Effect.Effect<readonly StoredOperation[], StorageFailure>;\n readonly removeOperations: (integration: string) => Effect.Effect<void, StorageFailure>;\n}\n\nexport const makeDefaultGraphqlStore = ({ pluginStorage }: StorageDeps): GraphqlStore => {\n const listOperationRows = (integration: string) =>\n pluginStorage\n .list({\n collection: OPERATION_COLLECTION,\n keyPrefix: `${integration}.`,\n })\n .pipe(\n Effect.map((rows) =>\n rows.filter((row) => rowToOperation(row)?.integration === integration),\n ),\n );\n\n const removeOperations = (integration: string) =>\n Effect.gen(function* () {\n const rows = yield* listOperationRows(integration);\n for (const row of rows) {\n yield* pluginStorage.remove({\n owner: CATALOG_OWNER,\n collection: OPERATION_COLLECTION,\n key: row.key,\n });\n }\n });\n\n return {\n replaceOperations: (integration, operations) =>\n Effect.gen(function* () {\n yield* removeOperations(integration);\n for (const operation of operations) {\n yield* pluginStorage.put({\n owner: CATALOG_OWNER,\n collection: OPERATION_COLLECTION,\n key: operationKey(integration, operation.toolName),\n data: operationData(operation),\n });\n }\n }),\n\n getOperation: (integration, toolName) =>\n pluginStorage\n .get({ collection: OPERATION_COLLECTION, key: operationKey(integration, toolName) })\n .pipe(Effect.map((row) => (row ? rowToOperation(row) : null))),\n\n listOperations: (integration) =>\n listOperationRows(integration).pipe(\n Effect.map((rows) => rows.map(rowToOperation).filter(Predicate.isNotNull)),\n ),\n\n removeOperations,\n };\n};\n","import { Effect, Match, Option, Schema } from \"effect\";\nimport type { Layer } from \"effect\";\nimport { FetchHttpClient, HttpClient } from \"effect/unstable/http\";\n\nimport {\n authToolFailure,\n AuthTemplateSlug,\n definePlugin,\n IntegrationAlreadyExistsError,\n IntegrationDetectionResult,\n IntegrationSlug,\n ToolName,\n ToolResult,\n type AuthMethodDescriptor,\n type AuthPlacementDescriptor,\n type IntegrationConfig,\n type IntegrationRecord,\n type PluginCtx,\n type StorageFailure,\n type ToolAnnotations,\n type ToolDef,\n} from \"@executor-js/sdk/core\";\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 {\n GraphqlAuthRequiredError,\n GraphqlIntrospectionError,\n GraphqlInvocationError,\n} from \"./errors\";\nimport { invokeWithLayer } from \"./invoke\";\nimport { graphqlPresets } from \"./presets\";\nimport { makeDefaultGraphqlStore, type GraphqlStore, type StoredOperation } from \"./store\";\nimport {\n AuthTemplate,\n decodeGraphqlIntegrationConfig,\n decodeGraphqlIntegrationConfigOption,\n ExtractedField,\n GraphqlIntegrationConfig,\n OperationBinding,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// GraphQL error-body decoding (for invocation responses)\n// ---------------------------------------------------------------------------\n\nconst GraphqlErrorBody = Schema.Struct({ message: Schema.String });\nconst GraphqlErrorsBody = Schema.Array(Schema.Unknown);\nconst decodeGraphqlErrorBody = Schema.decodeUnknownOption(GraphqlErrorBody);\nconst decodeGraphqlErrorsBody = Schema.decodeUnknownOption(GraphqlErrorsBody);\n\nconst decodeGraphqlErrors = (errors: unknown): readonly unknown[] | undefined =>\n Option.getOrUndefined(decodeGraphqlErrorsBody(errors));\n\nconst extractGraphqlErrorMessage = (errors: readonly unknown[]): string | undefined =>\n errors\n .map((error) => Option.getOrUndefined(decodeGraphqlErrorBody(error))?.message)\n .find((message) => message !== undefined && message.length > 0);\n\nconst GRAPHQL_PLUGIN_ID = \"graphql\";\n\n// ---------------------------------------------------------------------------\n// Extension input shapes\n// ---------------------------------------------------------------------------\n\nconst AuthTemplateSchema = AuthTemplate;\n\n/** Register a GraphQL integration in the catalog. `endpoint` is the GraphQL URL;\n * `slug` (defaulted from the endpoint) is the catalog id; `introspectionJson`\n * supplies the schema when the endpoint disables live introspection; `headers`\n * / `queryParams` are static and also applied to add-time introspection;\n * `authenticationTemplate` declares the auth methods a connection can apply\n * through. */\nconst GraphqlAddIntegrationInputSchema = Schema.Struct({\n endpoint: Schema.String,\n slug: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n introspectionJson: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n queryParams: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n authenticationTemplate: Schema.optional(Schema.Array(AuthTemplateSchema)),\n});\nexport type GraphqlAddIntegrationInput = typeof GraphqlAddIntegrationInputSchema.Type;\n\nconst GraphqlConfigureInputSchema = Schema.Struct({\n name: Schema.optional(Schema.String),\n endpoint: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n queryParams: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n authenticationTemplate: Schema.optional(Schema.Array(AuthTemplateSchema)),\n});\nexport type GraphqlConfigureInput = typeof GraphqlConfigureInputSchema.Type;\n\n/** Input for the custom-method-create flow (HTTP `POST /graphql/integrations/\n * :slug/config`). Unlike `configure` (which REPLACES the whole config for the\n * generic repair path), `configureAuth` MERGE-APPENDS these templates onto the\n * integration's existing `authenticationTemplate`, mirroring OpenAPI's\n * `configure`. */\nconst GraphqlConfigureAuthInputSchema = Schema.Struct({\n authenticationTemplate: Schema.Array(AuthTemplateSchema),\n mode: Schema.optional(Schema.Literals([\"merge\", \"replace\"])),\n});\nexport type GraphqlConfigureAuthInput = typeof GraphqlConfigureAuthInputSchema.Type;\n\n// ---------------------------------------------------------------------------\n// Static control-tool schemas\n// ---------------------------------------------------------------------------\n\nconst StaticAddIntegrationOutputSchema = Schema.Struct({\n slug: Schema.String,\n name: Schema.String,\n});\nconst StaticGetIntegrationInputSchema = Schema.Struct({\n slug: Schema.String,\n});\nconst StaticGetIntegrationOutputSchema = Schema.Struct({\n integration: Schema.NullOr(Schema.Unknown),\n});\n\nconst StaticAddIntegrationInputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(GraphqlAddIntegrationInputSchema),\n);\nconst StaticAddIntegrationOutputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(StaticAddIntegrationOutputSchema),\n);\nconst StaticGetIntegrationInputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(StaticGetIntegrationInputSchema),\n);\nconst StaticGetIntegrationOutputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(StaticGetIntegrationOutputSchema),\n);\n\nconst graphqlToolFailure = (code: string, message: string, details?: unknown) =>\n ToolResult.fail({\n code,\n message,\n ...(details === undefined ? {} : { details }),\n });\n\nconst graphqlAuthToolFailure = (failure: GraphqlAuthRequiredError) =>\n authToolFailure({\n code: failure.code,\n message: failure.message,\n source: { id: failure.integration, scope: failure.owner },\n credential: {\n kind: failure.credentialKind,\n ...(failure.credentialLabel ? { label: failure.credentialLabel } : {}),\n connectionId: failure.connection,\n },\n ...(failure.status !== undefined ? { status: failure.status } : {}),\n ...(failure.details !== undefined\n ? {\n upstream: {\n ...(failure.status !== undefined ? { status: failure.status } : {}),\n details: failure.details,\n },\n }\n : {}),\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. */\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 an integration slug from an endpoint URL. */\nconst slugFromEndpoint = (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 slug\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: IntrospectionField) => !f.name.startsWith(\"__\"))\n .slice(0, 12)\n .map((f: IntrospectionField) => {\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\n// Name every generated operation: some servers reject anonymous operations, and\n// APM tooling keys traces off the operation name. Field names are already valid\n// GraphQL name tokens, so the upper-cased field name is a safe operation name.\nconst operationNameForField = (fieldName: string): string =>\n fieldName.charAt(0).toUpperCase() + fieldName.slice(1);\n\nconst buildOperationStringForField = (\n kind: GraphqlOperationKind,\n field: IntrospectionField,\n types: ReadonlyMap<string, IntrospectionType>,\n): string => {\n const opType = kind === \"query\" ? \"query\" : \"mutation\";\n const opName = operationNameForField(field.name);\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} ${opName}${varDefsStr} { ${field.name}${argPassStr}${selectionSet ? ` ${selectionSet}` : \"\"} }`;\n};\n\ninterface PreparedOperation {\n readonly toolName: 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 // A tool's name keeps its `<kind>.<field>` path (e.g. `query.hello`,\n // `mutation.setGreeting`). The address grammar treats `<tool>` as the\n // trailing remainder (see parseToolAddress), so the dot nests naturally.\n const toolName = `${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} ${operationNameForField(extracted.fieldName)} { ${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 toolName,\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// Auth template rendering (D11) — apply the resolved credential value through\n// the template the connection references, exactly like an apiKey bearer.\n// ---------------------------------------------------------------------------\n\ninterface RenderedAuth {\n readonly headers: Record<string, string>;\n readonly queryParams: Record<string, string>;\n}\n\nconst renderAuthTemplate = (template: AuthTemplate, value: string): RenderedAuth => {\n if (template.kind === \"oauth2\") {\n const header = template.header ?? \"Authorization\";\n const prefix = template.prefix ?? \"Bearer \";\n return { headers: { [header]: `${prefix}${value}` }, queryParams: {} };\n }\n const rendered = template.prefix ? `${template.prefix}${value}` : value;\n if (template.in === \"query\") {\n return { headers: {}, queryParams: { [template.name]: rendered } };\n }\n return { headers: { [template.name]: rendered }, queryParams: {} };\n};\n\n// ---------------------------------------------------------------------------\n// Introspection — produce operations from a config (live or stored JSON).\n// ---------------------------------------------------------------------------\n\nconst buildToolDefs = (prepared: readonly PreparedOperation[]): readonly ToolDef[] =>\n prepared.map((p) => ({\n name: ToolName.make(p.toolName),\n description: p.description,\n inputSchema: p.inputSchema,\n annotations: annotationsFor(p.binding),\n }));\n\nconst toStoredOperations = (\n slug: IntegrationSlug,\n prepared: readonly PreparedOperation[],\n): StoredOperation[] =>\n prepared.map((p) => ({\n toolName: p.toolName,\n integration: String(slug),\n binding: p.binding,\n }));\n\n/** Render an integration's static + resolved-credential auth onto introspection\n * headers/query params. Connection-create / tool-generation introspection runs\n * with the connection's credential (exactly how its tools are invoked), so an\n * auth-required endpoint introspects successfully here rather than at add-time. */\nconst introspectHeadersForConnection = (\n config: GraphqlIntegrationConfig,\n credentialValue: string | null,\n): RenderedAuth => {\n const headers: Record<string, string> = { ...(config.headers ?? {}) };\n const queryParams: Record<string, string> = { ...(config.queryParams ?? {}) };\n if (credentialValue !== null) {\n // A connection references exactly one template; when several are declared we\n // can't know which without the slug (not carried into `resolveTools`), so we\n // apply the first. Most integrations declare a single auth method.\n const template = config.authenticationTemplate[0];\n if (template) {\n const rendered = renderAuthTemplate(template, credentialValue);\n Object.assign(headers, rendered.headers);\n Object.assign(queryParams, rendered.queryParams);\n }\n }\n return { headers, queryParams };\n};\n\n/** Introspect a config live or from its stored JSON, applying connection auth.\n * `parseIntrospectionJson` short-circuits the network when a schema snapshot is\n * present; otherwise this introspects the endpoint with the rendered credential. */\nconst introspectForConnection = (\n config: GraphqlIntegrationConfig,\n credentialValue: string | null,\n httpClientLayer: Layer.Layer<HttpClient.HttpClient>,\n): Effect.Effect<IntrospectionResult, GraphqlIntrospectionError> => {\n if (config.introspectionJson) {\n return parseIntrospectionJson(config.introspectionJson);\n }\n const auth = introspectHeadersForConnection(config, credentialValue);\n return introspect(\n config.endpoint,\n Object.keys(auth.headers).length > 0 ? auth.headers : undefined,\n Object.keys(auth.queryParams).length > 0 ? auth.queryParams : undefined,\n ).pipe(Effect.provide(httpClientLayer));\n};\n\n/** Introspect an integration's endpoint (with this connection's credential),\n * prepare its operations, persist the bindings, and return them. Invoked from\n * `invokeTool` on a cache miss — i.e. when an integration was registered\n * without an add-time schema and its bindings haven't been produced yet. */\nconst materializeOperations = (\n ctx: PluginCtx<GraphqlStore>,\n integration: string,\n config: GraphqlIntegrationConfig,\n credential: {\n readonly template: AuthTemplateSlug;\n readonly value: string | null;\n },\n httpClientLayer: Layer.Layer<HttpClient.HttpClient>,\n): Effect.Effect<readonly StoredOperation[], GraphqlIntrospectionError | StorageFailure> =>\n Effect.gen(function* () {\n // Render the exact template this connection references (we have its slug\n // here, unlike `resolveTools`) so an auth-required endpoint introspects.\n const template = config.authenticationTemplate.find(\n (t: AuthTemplate) => t.slug === String(credential.template),\n );\n const headers: Record<string, string> = { ...(config.headers ?? {}) };\n const queryParams: Record<string, string> = {\n ...(config.queryParams ?? {}),\n };\n if (template && credential.value !== null) {\n const rendered = renderAuthTemplate(template, credential.value);\n Object.assign(headers, rendered.headers);\n Object.assign(queryParams, rendered.queryParams);\n }\n\n const introspection = config.introspectionJson\n ? yield* parseIntrospectionJson(config.introspectionJson)\n : yield* introspect(\n config.endpoint,\n Object.keys(headers).length > 0 ? headers : undefined,\n Object.keys(queryParams).length > 0 ? queryParams : undefined,\n ).pipe(Effect.provide(httpClientLayer));\n\n const { result } = yield* extract(introspection).pipe(\n Effect.catch(() =>\n Effect.succeed({\n result: { fields: [] as readonly ExtractedField[] },\n } as {\n readonly result: { readonly fields: readonly ExtractedField[] };\n }),\n ),\n );\n const prepared = prepareOperations(result.fields, introspection);\n const stored = toStoredOperations(IntegrationSlug.make(integration), prepared);\n yield* ctx.storage.replaceOperations(integration, stored);\n return stored;\n });\n\n// ---------------------------------------------------------------------------\n// Declared auth methods — project the stored `authenticationTemplate` into the\n// catalog's plugin-agnostic `AuthMethodDescriptor[]`. Pure/sync and tolerant of\n// a malformed or foreign config blob (returns `[]`). GraphQL has no accounts\n// slot of its own, so this projection is what surfaces declared + custom methods\n// through the catalog's `authMethods` to the hub / Add-account flows. Exported\n// for tests.\n//\n// apiKey → one apikey method carrying a single header/query placement (the\n// `name` from the template, with the template's `prefix` defaulted to\n// `\"\"`).\n// oauth2 → one oauth method (no resolved endpoints; graphql renders the\n// connection value as a bearer at invoke time).\n// ---------------------------------------------------------------------------\n\nconst graphqlApiKeyLabel = (placement: AuthPlacementDescriptor): string =>\n `API key (${placement.name || (placement.carrier === \"header\" ? \"header\" : \"query\")})`;\n\nexport const describeGraphqlAuthMethods = (\n record: IntegrationRecord,\n): readonly AuthMethodDescriptor[] => {\n const config = Option.getOrUndefined(decodeGraphqlIntegrationConfigOption(record.config));\n if (!config) return [];\n return config.authenticationTemplate.map((template: AuthTemplate): AuthMethodDescriptor => {\n const slug = template.slug;\n if (template.kind === \"oauth2\") {\n return {\n id: slug,\n label: \"OAuth\",\n kind: \"oauth\",\n template: slug,\n oauth: {},\n };\n }\n const placement: AuthPlacementDescriptor = {\n carrier: template.in,\n name: template.name,\n prefix: template.prefix ?? \"\",\n };\n return {\n id: slug,\n label: graphqlApiKeyLabel(placement),\n kind: \"apikey\",\n template: slug,\n placements: [placement],\n };\n });\n};\n\nexport const describeGraphqlIntegrationDisplay = (\n record: IntegrationRecord,\n): { readonly url?: string } => {\n const config = Option.getOrUndefined(decodeGraphqlIntegrationConfigOption(record.config));\n return { url: config?.endpoint };\n};\n\n// ---------------------------------------------------------------------------\n// Auth-template merge — append the incoming custom methods onto the existing\n// `authenticationTemplate`, replacing entries whose slug matches and assigning a\n// fresh `custom_<id>` slug to entries that omit one (or collide). Mirrors the\n// OpenAPI plugin's `mergeAuthenticationTemplate` so the custom-method-create UX\n// is identical across plugins (item 2A).\n// ---------------------------------------------------------------------------\n\nconst shortId = (): string => Math.random().toString(36).slice(2, 8);\n\nconst freshCustomSlug = (taken: ReadonlySet<string>): string => {\n let candidate = `custom_${shortId()}`;\n while (taken.has(candidate)) candidate = `custom_${shortId()}`;\n return candidate;\n};\n\nconst mergeGraphqlAuthTemplate = (\n existing: readonly AuthTemplate[],\n incoming: readonly AuthTemplate[],\n): readonly AuthTemplate[] => {\n const result: AuthTemplate[] = existing.map((entry: AuthTemplate) => entry);\n const taken = new Set<string>(result.map((entry: AuthTemplate) => entry.slug));\n for (const entry of incoming) {\n // `slug` is a plain string; a JSON caller may submit it empty/blank — read\n // defensively and backfill so every stored template has a stable slug.\n const requested = entry.slug.trim();\n const existingIndex = result.findIndex((current: AuthTemplate) => current.slug === requested);\n if (requested.length > 0 && existingIndex >= 0) {\n result[existingIndex] = entry;\n continue;\n }\n const slug = requested.length > 0 && !taken.has(requested) ? requested : freshCustomSlug(taken);\n taken.add(slug);\n result.push({ ...entry, slug } as AuthTemplate);\n }\n return result;\n};\n\n// ---------------------------------------------------------------------------\n// Plugin extension\n// ---------------------------------------------------------------------------\n\n// The extension only registers integrations (and parses any pre-supplied\n// introspection JSON offline). Live introspection — the only thing that needed\n// an HTTP layer — is deferred to `resolveTools` / `invokeTool`, so the extension\n// no longer takes one.\nconst makeGraphqlExtension = (ctx: PluginCtx<GraphqlStore>) => {\n const buildConfig = (input: GraphqlAddIntegrationInput): GraphqlIntegrationConfig =>\n GraphqlIntegrationConfig.make({\n endpoint: input.endpoint,\n name: input.name?.trim() || slugFromEndpoint(input.endpoint),\n ...(input.introspectionJson !== undefined\n ? { introspectionJson: input.introspectionJson }\n : {}),\n ...(input.headers !== undefined ? { headers: input.headers } : {}),\n ...(input.queryParams !== undefined ? { queryParams: input.queryParams } : {}),\n authenticationTemplate: input.authenticationTemplate ?? [],\n });\n\n /** Register the integration in the catalog. Registering a source is a\n * catalog statement (\"we use this GraphQL endpoint now\") and MUST NOT make a\n * network call or require auth — exactly like MCP defers discovery. Live\n * introspection (and the operation bindings it yields) is deferred to\n * connection-create / tool-generation (`resolveTools`) and tool invocation\n * (`invokeTool`), where a connection's credential is available.\n *\n * When the caller pre-supplies `introspectionJson`, the schema is already in\n * hand, so we parse it offline (no network) and persist the operation\n * bindings up front. */\n const addIntegrationInternal = (input: GraphqlAddIntegrationInput) =>\n Effect.gen(function* () {\n const slug = IntegrationSlug.make(input.slug ?? slugFromEndpoint(input.endpoint));\n\n // Block re-adding an existing slug. The core `integrations.register`\n // primitive upserts (so boot re-registration is idempotent), but an\n // explicit add must NOT silently clobber an existing integration's tools,\n // connections, and policies. To add more auth, update the existing one.\n const existing = yield* ctx.core.integrations.get(slug);\n if (existing) {\n return yield* new IntegrationAlreadyExistsError({ slug });\n }\n\n return yield* addIntegrationTransaction(input, slug);\n });\n\n const addIntegrationTransaction = (input: GraphqlAddIntegrationInput, slug: IntegrationSlug) =>\n ctx.transaction(\n Effect.gen(function* () {\n const baseConfig = buildConfig(input);\n\n // No pre-supplied schema → register WITHOUT introspecting. Tools (and\n // their operation bindings) are produced lazily when a connection is\n // created (`resolveTools`) / a tool is first invoked (`invokeTool`),\n // using that connection's credential.\n if (baseConfig.introspectionJson === undefined) {\n yield* ctx.core.integrations.register({\n slug,\n description: baseConfig.name,\n config: baseConfig,\n canRemove: true,\n canRefresh: true,\n });\n return { slug: String(slug), name: baseConfig.name, toolCount: 0 };\n }\n\n // Pre-supplied introspection JSON: parse it offline (no network) and\n // persist the operation bindings + snapshot so production stays offline.\n const introspection = yield* parseIntrospectionJson(baseConfig.introspectionJson);\n const { result } = yield* extract(introspection);\n const prepared = prepareOperations(result.fields, introspection);\n\n // Snapshot the resolved schema so tool production never needs a live\n // HTTP layer (D6: tools are spec-derived and identical per connection).\n const config = GraphqlIntegrationConfig.make({\n ...baseConfig,\n introspectionJson: JSON.stringify({ data: introspection }),\n });\n\n yield* ctx.storage.replaceOperations(String(slug), toStoredOperations(slug, prepared));\n\n yield* ctx.core.integrations.register({\n slug,\n description: config.name,\n config,\n canRemove: true,\n canRefresh: true,\n });\n\n return {\n slug: String(slug),\n name: config.name,\n toolCount: prepared.length,\n };\n }),\n );\n\n const configureIntegration = (slug: string, input: GraphqlConfigureInput) =>\n Effect.gen(function* () {\n const record = yield* ctx.core.integrations.get(IntegrationSlug.make(slug));\n if (!record) return;\n const current = Option.getOrElse(\n // best-effort: re-decode the stored config, falling back to an\n // endpoint-only config if it was never set.\n yield* decodeGraphqlIntegrationConfig(record.config).pipe(Effect.option),\n () =>\n GraphqlIntegrationConfig.make({\n endpoint: \"\",\n name: record.description,\n authenticationTemplate: [],\n }),\n );\n\n const next = GraphqlIntegrationConfig.make({\n endpoint: input.endpoint ?? current.endpoint,\n name: input.name?.trim() || current.name,\n ...(current.introspectionJson !== undefined\n ? { introspectionJson: current.introspectionJson }\n : {}),\n ...((input.headers ?? current.headers) !== undefined\n ? { headers: input.headers ?? current.headers }\n : {}),\n ...((input.queryParams ?? current.queryParams) !== undefined\n ? { queryParams: input.queryParams ?? current.queryParams }\n : {}),\n authenticationTemplate: input.authenticationTemplate ?? current.authenticationTemplate,\n });\n\n yield* ctx.core.integrations.update(IntegrationSlug.make(slug), {\n description: next.name,\n config: next,\n });\n });\n\n /** Read the integration's decoded config (or `null` when absent / malformed).\n * Surfaces `authenticationTemplate` for the configure / custom-method UX. */\n const getConfig = (\n slug: string,\n ): Effect.Effect<GraphqlIntegrationConfig | null, StorageFailure> =>\n ctx.core.integrations\n .get(IntegrationSlug.make(slug))\n .pipe(\n Effect.map((record) =>\n record ? Option.getOrNull(decodeGraphqlIntegrationConfigOption(record.config)) : null,\n ),\n );\n\n /** Merge-append custom auth methods onto the integration's existing\n * `authenticationTemplate`. Returns the merged array. A no-op (returns `[]`)\n * for an unknown slug or undecodable config. */\n const configureAuthMethods = (\n slug: string,\n input: GraphqlConfigureAuthInput,\n ): Effect.Effect<readonly AuthTemplate[], StorageFailure> =>\n ctx.transaction(\n Effect.gen(function* () {\n const record = yield* ctx.core.integrations.get(IntegrationSlug.make(slug));\n if (!record) return [] as readonly AuthTemplate[];\n const current = Option.getOrNull(decodeGraphqlIntegrationConfigOption(record.config));\n if (!current) return [] as readonly AuthTemplate[];\n\n const merged =\n input.mode === \"replace\"\n ? input.authenticationTemplate\n : mergeGraphqlAuthTemplate(\n current.authenticationTemplate,\n input.authenticationTemplate,\n );\n\n const next = GraphqlIntegrationConfig.make({\n ...current,\n authenticationTemplate: merged,\n });\n\n yield* ctx.core.integrations.update(IntegrationSlug.make(slug), {\n config: next,\n });\n\n return merged;\n }),\n );\n\n return {\n /** Register a GraphQL integration (introspects + persists operations). */\n addIntegration: (input: GraphqlAddIntegrationInput) => addIntegrationInternal(input),\n\n /** Read the integration's stored config. */\n getIntegration: (slug: string) =>\n ctx.core.integrations\n .get(IntegrationSlug.make(slug))\n .pipe(Effect.map((record) => (record ? record.config : null))),\n\n /** Read the integration's decoded config (auth templates surfaced). */\n getConfig,\n\n /** Merge-append custom auth methods (custom-method-create flow). */\n configureAuth: configureAuthMethods,\n\n removeIntegration: (slug: string) =>\n ctx.transaction(\n Effect.gen(function* () {\n yield* ctx.storage.removeOperations(slug);\n yield* ctx.core.integrations\n .remove(IntegrationSlug.make(slug))\n .pipe(Effect.catchTag(\"IntegrationRemovalNotAllowedError\", () => Effect.void));\n }),\n ),\n\n configure: configureIntegration,\n };\n};\n\nexport type GraphqlPluginExtension = ReturnType<typeof makeGraphqlExtension>;\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlPluginOptions {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;\n}\n\nexport const graphqlPlugin = definePlugin((options?: GraphqlPluginOptions) => {\n return {\n id: GRAPHQL_PLUGIN_ID as \"graphql\",\n packageName: \"@executor-js/plugin-graphql\",\n integrationPresets: graphqlPresets.map((preset) => ({\n id: preset.id,\n name: preset.name,\n summary: preset.summary,\n url: preset.url,\n endpoint: preset.endpoint,\n ...(preset.icon ? { icon: preset.icon } : {}),\n ...(preset.featured ? { featured: preset.featured } : {}),\n })),\n storage: (deps): GraphqlStore => makeDefaultGraphqlStore(deps),\n\n extension: (ctx: PluginCtx<GraphqlStore>) => makeGraphqlExtension(ctx),\n\n integrationConfigure: {\n type: \"graphql\",\n schema: GraphqlConfigureInputSchema,\n configure: ({ ctx, integration, config }) =>\n makeGraphqlExtension(ctx).configure(String(integration), config as GraphqlConfigureInput),\n },\n\n describeAuthMethods: describeGraphqlAuthMethods,\n describeIntegrationDisplay: describeGraphqlIntegrationDisplay,\n\n staticSources: (self: GraphqlPluginExtension) => [\n {\n id: \"graphql\",\n kind: \"executor\",\n name: \"GraphQL\",\n tools: [\n {\n name: \"getIntegration\",\n description:\n \"Inspect an existing GraphQL integration, including endpoint, static headers/query params, and auth templates. Use this before repairing an integration with `graphql.configure` or creating a connection.\",\n inputSchema: StaticGetIntegrationInputStandardSchema,\n outputSchema: StaticGetIntegrationOutputStandardSchema,\n handler: ({ args }) => {\n const input = args as typeof StaticGetIntegrationInputSchema.Type;\n return Effect.map(self.getIntegration(input.slug), (integration) =>\n ToolResult.ok({ integration }),\n );\n },\n },\n {\n name: \"addIntegration\",\n description:\n \"Add a GraphQL endpoint to the catalog and register its operations. Introspects the endpoint (or uses provided introspection JSON). After adding, create an owner-scoped connection against the integration to materialize its per-connection tools. For API keys / bearer tokens, declare an `authenticationTemplate` and create a connection whose value is the token.\",\n annotations: {\n requiresApproval: true,\n approvalDescription: \"Add a GraphQL integration\",\n },\n inputSchema: StaticAddIntegrationInputStandardSchema,\n outputSchema: StaticAddIntegrationOutputStandardSchema,\n handler: ({ args }) => {\n const input = args as GraphqlAddIntegrationInput;\n return self.addIntegration(input).pipe(\n Effect.map((result) => ToolResult.ok({ slug: result.slug, name: result.name })),\n Effect.catchTags({\n GraphqlIntrospectionError: ({ message }) =>\n Effect.succeed(graphqlToolFailure(\"graphql_introspection_failed\", message)),\n GraphqlExtractionError: ({ message }) =>\n Effect.succeed(graphqlToolFailure(\"graphql_extraction_failed\", message)),\n IntegrationAlreadyExistsError: ({ slug }: IntegrationAlreadyExistsError) =>\n Effect.succeed(\n graphqlToolFailure(\n \"integration_already_exists\",\n `Integration ${slug} already exists; update it instead of re-adding.`,\n ),\n ),\n }),\n );\n },\n },\n ],\n },\n ],\n\n // -----------------------------------------------------------------------\n // Per-connection tool production. THIS is where a GraphQL integration is\n // introspected — when a connection is created (or refreshed), with that\n // connection's credential — yielding one ToolDef per operation. Registering\n // the integration in the catalog makes no network call; discovery is\n // deferred to here, exactly how MCP defers tool discovery to connect time.\n // The introspected schema is identical across connections, so `invokeTool`\n // re-derives the same operation bindings; only the credential differs.\n // -----------------------------------------------------------------------\n resolveTools: ({\n config,\n getValue,\n }: {\n readonly config: IntegrationConfig;\n readonly getValue: () => Effect.Effect<string | null, unknown>;\n }) =>\n Effect.gen(function* () {\n const decoded = yield* decodeGraphqlIntegrationConfig(config).pipe(Effect.option);\n if (Option.isNone(decoded)) return { tools: [] };\n const graphqlConfig = decoded.value;\n // Live introspection (no stored snapshot) needs the connection's\n // credential for auth-required endpoints; resolve it lazily.\n const credentialValue =\n graphqlConfig.introspectionJson === undefined\n ? yield* getValue().pipe(Effect.catch(() => Effect.succeed(null)))\n : null;\n const introspection = yield* introspectForConnection(\n graphqlConfig,\n credentialValue,\n options?.httpClientLayer ?? httpClientLayerFallback,\n ).pipe(Effect.option);\n if (Option.isNone(introspection)) return { tools: [] };\n const extracted = yield* extract(introspection.value).pipe(Effect.option);\n if (Option.isNone(extracted)) return { tools: [] };\n const prepared = prepareOperations(extracted.value.result.fields, introspection.value);\n return {\n tools: buildToolDefs(prepared),\n definitions: extracted.value.definitions,\n };\n }).pipe(Effect.catch(() => Effect.succeed({ tools: [] as readonly ToolDef[] }))),\n\n // -----------------------------------------------------------------------\n // Invoke one of a connection's tools. Look up the operation by integration\n // + tool name, render the credential through the connection's auth\n // template, and execute the GraphQL request.\n // -----------------------------------------------------------------------\n invokeTool: ({ ctx, toolRow, credential, args }) =>\n Effect.gen(function* () {\n const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;\n const integration = toolRow.integration;\n const toolName = toolRow.name;\n\n const config = yield* decodeGraphqlIntegrationConfig(credential.config).pipe(\n Effect.mapError(\n () =>\n new GraphqlInvocationError({\n message: `Invalid GraphQL integration config for \"${integration}\"`,\n statusCode: Option.none(),\n }),\n ),\n );\n\n // Operation bindings are produced lazily for integrations registered\n // without an add-time schema (no network at catalog registration). On a\n // cache miss, introspect with this connection's credential, persist the\n // bindings, then resolve the requested tool — discovery/persistence are\n // deferred to first use, mirroring MCP.\n let op = yield* ctx.storage.getOperation(integration, toolName);\n if (!op) {\n op = yield* materializeOperations(\n ctx,\n integration,\n config,\n credential,\n httpClientLayer,\n ).pipe(Effect.map((ops) => ops.find((o) => o.toolName === toolName) ?? null));\n }\n if (!op) {\n return yield* new GraphqlInvocationError({\n message: `No GraphQL operation found for tool \"${integration}.${toolName}\"`,\n statusCode: Option.none(),\n });\n }\n\n const headers: Record<string, string> = { ...(config.headers ?? {}) };\n const queryParams: Record<string, string> = {\n ...(config.queryParams ?? {}),\n };\n\n const template = config.authenticationTemplate.find(\n (t: AuthTemplate) => t.slug === String(credential.template),\n );\n if (template) {\n if (credential.value === null) {\n return yield* new GraphqlAuthRequiredError({\n code:\n template.kind === \"oauth2\"\n ? \"oauth_connection_missing\"\n : \"connection_value_missing\",\n message:\n template.kind === \"oauth2\"\n ? `Missing OAuth connection value for GraphQL integration \"${integration}\" (connection \"${credential.connection}\")`\n : `Missing credential value for GraphQL integration \"${integration}\" (connection \"${credential.connection}\")`,\n owner: credential.owner,\n integration,\n connection: String(credential.connection),\n credentialKind: template.kind === \"oauth2\" ? \"oauth\" : \"secret\",\n credentialLabel: template.kind === \"oauth2\" ? \"OAuth sign-in\" : \"API key\",\n template: String(credential.template),\n });\n }\n const rendered = renderAuthTemplate(template, credential.value);\n Object.assign(headers, rendered.headers);\n Object.assign(queryParams, rendered.queryParams);\n }\n\n const result = yield* invokeWithLayer(\n op.binding,\n (args ?? {}) as Record<string, unknown>,\n config.endpoint,\n headers,\n queryParams,\n httpClientLayer,\n );\n\n const errors = decodeGraphqlErrors(result.errors);\n if (errors !== undefined && errors.length > 0) {\n const firstMessage = extractGraphqlErrorMessage(errors);\n return ToolResult.fail({\n code: \"graphql_errors\",\n message: firstMessage !== undefined ? firstMessage : \"GraphQL request returned errors\",\n details: { errors },\n });\n }\n if (result.status < 200 || result.status >= 300) {\n if (result.status === 401 || result.status === 403) {\n return authToolFailure({\n code: \"connection_rejected\",\n status: result.status,\n message: `Upstream rejected credentials for GraphQL integration \"${integration}\" with HTTP ${result.status}. Re-authenticate or update the connection before retrying this tool.`,\n source: { id: integration, scope: credential.owner },\n credential: { kind: \"upstream\", label: \"Upstream authorization\" },\n upstream: {\n status: result.status,\n details: {\n data: result.data,\n errors: result.errors,\n },\n },\n });\n }\n return ToolResult.fail({\n code: \"graphql_http_error\",\n status: result.status,\n message: `GraphQL request failed with HTTP ${result.status}`,\n details: {\n status: result.status,\n data: result.data,\n errors: result.errors,\n },\n });\n }\n return ToolResult.ok(result.data);\n }).pipe(\n Effect.catchTag(\"GraphqlAuthRequiredError\", (error) =>\n Effect.succeed(graphqlAuthToolFailure(error)),\n ),\n ),\n\n // Per-connection cleanup. Operation bindings are catalog-level (shared\n // across an integration's connections), so removing a single connection\n // leaves them in place; the executor drops the connection's tool rows.\n removeConnection: () => Effect.void,\n\n detect: ({ ctx, url }: { readonly ctx: PluginCtx<GraphqlStore>; readonly url: string }) =>\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 slug = slugFromEndpoint(trimmed);\n\n if (ok) {\n return IntegrationDetectionResult.make({\n kind: \"graphql\",\n confidence: \"high\",\n endpoint: trimmed,\n name: slug,\n slug,\n });\n }\n\n // Low-confidence URL-token fallback. Introspection can fail for many\n // reasons (auth, CORS, the endpoint disabled introspection, transport\n // errors). When the URL itself strongly implies GraphQL, surface a\n // candidate so the user can still pick it.\n if (urlMatchesToken(parsed.value, \"graphql\")) {\n return IntegrationDetectionResult.make({\n kind: \"graphql\",\n confidence: \"low\",\n endpoint: trimmed,\n name: slug,\n slug,\n });\n }\n\n return null;\n }),\n };\n // HTTP transport (routes/handlers/extensionService) is layered on by the\n // api-aware factory in `@executor-js/plugin-graphql/api`.\n});\n\n// The fallback HTTP layer for `resolveTools`. The hook input carries no `ctx`,\n// so when no explicit layer is passed to the plugin we use the same default the\n// executor wires into `ctx.httpClientLayer` (`FetchHttpClient.layer`). Hosts/\n// tests that need a custom transport pass `options.httpClientLayer`.\nconst httpClientLayerFallback: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,QAAQ,cAAc;AACvC,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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AA,MAC9C;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKF,kBAAkB,MAAMA,QAAO;AAAA,IAE/B,QAAQ,CAAC,EAAE,KAAK,IAAI,MAClBA,QAAO,IAAI,aAAa;AACtB,YAAM,kBAAkB,SAAS,mBAAmB,IAAI;AACxD,YAAM,UAAU,IAAI,KAAK;AACzB,UAAI,CAAC,QAAS,QAAO;AACrB,YAAM,SAAS,OAAOA,QAAO,IAAI;AAAA,QAC/B,KAAK,MAAM,IAAI,IAAI,OAAO;AAAA,QAC1B,OAAO,CAAC,UAAU;AAAA,MACpB,CAAC,EAAE,KAAKA,QAAO,MAAM;AACrB,UAAIJ,QAAO,OAAO,MAAM,EAAG,QAAO;AAElC,YAAM,KAAK,OAAO,WAAW,OAAO,EAAE;AAAA,QACpCI,QAAO,QAAQ,eAAe;AAAA,QAC9BA,QAAO,IAAI,MAAM,IAAI;AAAA,QACrBA,QAAO,MAAM,MAAMA,QAAO,QAAQ,KAAK,CAAC;AAAA,MAC1C;AAEA,YAAM,OAAO,iBAAiB,OAAO;AAErC,UAAI,IAAI;AACN,eAAO,2BAA2B,KAAK;AAAA,UACrC,MAAM;AAAA,UACN,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,MAAM;AAAA,UACN;AAAA,QACF,CAAC;AAAA,MACH;AAMA,UAAI,gBAAgB,OAAO,OAAO,SAAS,GAAG;AAC5C,eAAO,2BAA2B,KAAK;AAAA,UACrC,MAAM;AAAA,UACN,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,MAAM;AAAA,UACN;AAAA,QACF,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACL;AAGF,CAAC;AAMD,IAAM,0BAA8D,gBAAgB;","names":["raw","Effect","Option","Option","Effect","Effect","Option","HttpClient","HttpClientRequest","Effect","HttpClient","HttpClientRequest","Option","Effect","Option","Schema","Schema","Option","Effect","Effect","Match","Option","Schema","Schema","Option","formatTypeRef","Match","unwrapTypeName","Effect"]}
@@ -20,13 +20,7 @@ var GraphqlAuthRequiredError = class extends Data.TaggedError("GraphqlAuthRequir
20
20
  };
21
21
 
22
22
  // src/sdk/types.ts
23
- import { Effect, Schema as Schema2 } from "effect";
24
- import {
25
- ConfiguredCredentialValue,
26
- credentialSlotKey,
27
- SecretBackedValue
28
- } from "@executor-js/sdk/shared";
29
- import { HttpConfiguredValueInput, HttpCredentialInput } from "@executor-js/sdk/http-source";
23
+ import { Schema as Schema2 } from "effect";
30
24
  var GraphqlOperationKind = Schema2.Literals(["query", "mutation"]);
31
25
  var GraphqlArgument = Schema2.Struct({
32
26
  name: Schema2.String,
@@ -59,47 +53,42 @@ var OperationBinding = Schema2.Struct({
59
53
  /** Ordered variable names for mapping */
60
54
  variableNames: Schema2.Array(Schema2.String)
61
55
  });
62
- var HeaderValue = SecretBackedValue;
63
- var QueryParamValue = HeaderValue;
64
- var ConfiguredGraphqlCredentialValue = ConfiguredCredentialValue;
65
- var GraphqlConfiguredValueInput = HttpConfiguredValueInput;
66
- var GraphqlCredentialInput = HttpCredentialInput;
67
- var graphqlHeaderSlot = (name) => credentialSlotKey("header", name);
68
- var graphqlQueryParamSlot = (name) => credentialSlotKey("query_param", name);
69
- var GRAPHQL_OAUTH_CONNECTION_SLOT = "auth:oauth2:connection";
70
- var GraphqlSourceAuth = Schema2.Union([
71
- Schema2.Struct({ kind: Schema2.Literal("none") }),
72
- Schema2.Struct({
73
- kind: Schema2.Literal("oauth2"),
74
- connectionSlot: Schema2.String
75
- })
76
- ]);
77
- var GraphqlSourceAuthInput = Schema2.Union([
78
- Schema2.Struct({
79
- kind: Schema2.Literal("none")
80
- }),
81
- Schema2.Struct({
82
- oauth2: Schema2.optional(
83
- Schema2.Struct({
84
- connection: Schema2.optional(HttpCredentialInput)
85
- })
86
- )
87
- })
88
- ]);
89
- var InvocationConfig = Schema2.Struct({
90
- /** The GraphQL endpoint URL */
56
+ var ApiKeyAuthTemplate = Schema2.Struct({
57
+ kind: Schema2.Literal("apiKey"),
58
+ /** The template slug a connection references via `connection.template`. */
59
+ slug: Schema2.String,
60
+ in: Schema2.Literals(["header", "query"]),
61
+ /** The header / query-parameter name the value is written to. */
62
+ name: Schema2.String,
63
+ /** Optional prefix prepended to the value (e.g. `Bearer `). */
64
+ prefix: Schema2.optional(Schema2.String)
65
+ });
66
+ var OAuthAuthTemplate = Schema2.Struct({
67
+ kind: Schema2.Literal("oauth2"),
68
+ slug: Schema2.String,
69
+ /** The header to write the bearer token to. Defaults to `Authorization`. */
70
+ header: Schema2.optional(Schema2.String),
71
+ /** The token prefix. Defaults to `Bearer `. */
72
+ prefix: Schema2.optional(Schema2.String)
73
+ });
74
+ var AuthTemplate = Schema2.Union([ApiKeyAuthTemplate, OAuthAuthTemplate]);
75
+ var GraphqlIntegrationConfig = Schema2.Struct({
76
+ /** The GraphQL endpoint URL. */
91
77
  endpoint: Schema2.String,
92
- /** Headers applied to every request. Values can reference secrets. */
93
- headers: Schema2.Record(Schema2.String, ConfiguredGraphqlCredentialValue).pipe(
94
- Schema2.withDecodingDefault(Effect.succeed({})),
95
- Schema2.withConstructorDefault(Effect.succeed({}))
96
- ),
97
- /** Query parameters applied to every request. Values can reference secrets. */
98
- queryParams: Schema2.Record(Schema2.String, ConfiguredGraphqlCredentialValue).pipe(
99
- Schema2.withDecodingDefault(Effect.succeed({})),
100
- Schema2.withConstructorDefault(Effect.succeed({}))
101
- )
78
+ /** Display name for the integration. */
79
+ name: Schema2.String,
80
+ /** Optional introspection JSON text (when the endpoint doesn't support
81
+ * live introspection). */
82
+ introspectionJson: Schema2.optional(Schema2.String),
83
+ /** Static headers applied to every request (and to add-time introspection). */
84
+ headers: Schema2.optional(Schema2.Record(Schema2.String, Schema2.String)),
85
+ /** Static query parameters applied to every request. */
86
+ queryParams: Schema2.optional(Schema2.Record(Schema2.String, Schema2.String)),
87
+ /** Auth methods a connection can be applied through. */
88
+ authenticationTemplate: Schema2.Array(AuthTemplate)
102
89
  });
90
+ var decodeGraphqlIntegrationConfig = Schema2.decodeUnknownEffect(GraphqlIntegrationConfig);
91
+ var decodeGraphqlIntegrationConfigOption = Schema2.decodeUnknownOption(GraphqlIntegrationConfig);
103
92
  var InvocationResult = Schema2.Struct({
104
93
  status: Schema2.Number,
105
94
  data: Schema2.NullOr(Schema2.Unknown),
@@ -116,17 +105,12 @@ export {
116
105
  ExtractedField,
117
106
  ExtractionResult,
118
107
  OperationBinding,
119
- HeaderValue,
120
- QueryParamValue,
121
- ConfiguredGraphqlCredentialValue,
122
- GraphqlConfiguredValueInput,
123
- GraphqlCredentialInput,
124
- graphqlHeaderSlot,
125
- graphqlQueryParamSlot,
126
- GRAPHQL_OAUTH_CONNECTION_SLOT,
127
- GraphqlSourceAuth,
128
- GraphqlSourceAuthInput,
129
- InvocationConfig,
108
+ ApiKeyAuthTemplate,
109
+ OAuthAuthTemplate,
110
+ AuthTemplate,
111
+ GraphqlIntegrationConfig,
112
+ decodeGraphqlIntegrationConfig,
113
+ decodeGraphqlIntegrationConfigOption,
130
114
  InvocationResult
131
115
  };
132
- //# sourceMappingURL=chunk-UIAHATHP.js.map
116
+ //# sourceMappingURL=chunk-N5GJE7R6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/types.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\nimport type { AuthToolFailureCode } from \"@executor-js/sdk/core\";\n\nexport class GraphqlIntrospectionError extends Schema.TaggedErrorClass<GraphqlIntrospectionError>()(\n \"GraphqlIntrospectionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlExtractionError extends Schema.TaggedErrorClass<GraphqlExtractionError>()(\n \"GraphqlExtractionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlInvocationError extends Data.TaggedError(\"GraphqlInvocationError\")<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n\n/** A tool invocation could not produce a usable credential. Re-keyed for v2:\n * references the connection by (owner, integration, name) instead of a v1\n * source id + scope. */\nexport class GraphqlAuthRequiredError extends Data.TaggedError(\"GraphqlAuthRequiredError\")<{\n readonly code: AuthToolFailureCode;\n readonly message: string;\n readonly owner: string;\n readonly integration: string;\n readonly connection: string;\n readonly credentialKind: \"secret\" | \"oauth\" | \"upstream\";\n readonly credentialLabel?: string;\n readonly template?: string;\n readonly status?: number;\n readonly details?: unknown;\n readonly cause?: unknown;\n}> {}\n","import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// GraphQL operation kind\n// ---------------------------------------------------------------------------\n\nexport const GraphqlOperationKind = Schema.Literals([\"query\", \"mutation\"]);\nexport type GraphqlOperationKind = typeof GraphqlOperationKind.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted field (becomes a tool)\n// ---------------------------------------------------------------------------\n\nexport const GraphqlArgument = Schema.Struct({\n name: Schema.String,\n typeName: Schema.String,\n required: Schema.Boolean,\n description: Schema.OptionFromOptional(Schema.String),\n});\nexport type GraphqlArgument = typeof GraphqlArgument.Type;\n\nexport const ExtractedField = Schema.Struct({\n /** e.g. \"user\", \"createUser\" */\n fieldName: Schema.String,\n /** \"query\" or \"mutation\" */\n kind: GraphqlOperationKind,\n description: Schema.OptionFromOptional(Schema.String),\n arguments: Schema.Array(GraphqlArgument),\n /** JSON Schema for the input (built from arguments) */\n inputSchema: Schema.OptionFromOptional(Schema.Unknown),\n /** The return type name for documentation */\n returnTypeName: Schema.String,\n});\nexport type ExtractedField = typeof ExtractedField.Type;\n\nexport const ExtractionResult = Schema.Struct({\n /** Schema name from introspection */\n schemaName: Schema.OptionFromOptional(Schema.String),\n fields: Schema.Array(ExtractedField),\n});\nexport type ExtractionResult = typeof ExtractionResult.Type;\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal data needed to invoke\n// ---------------------------------------------------------------------------\n\nexport const OperationBinding = Schema.Struct({\n kind: GraphqlOperationKind,\n fieldName: Schema.String,\n /** The full GraphQL query/mutation string */\n operationString: Schema.String,\n /** Ordered variable names for mapping */\n variableNames: Schema.Array(Schema.String),\n});\nexport type OperationBinding = typeof OperationBinding.Type;\n\n// ---------------------------------------------------------------------------\n// Authentication template (v2)\n//\n// The integration's `config.authenticationTemplate` describes WHERE a\n// connection's resolved value is applied: an apiKey header / query param (with\n// an optional prefix like `Bearer `) or an OAuth bearer header. There are no\n// secret slots and no credential bindings — a connection IS the credential, and\n// the plugin renders `credential.value` onto the request through the template\n// matched by `credential.template` (D11: \"auth state derived into the\n// auth-template format\" — an OAuth access token renders exactly like an apiKey\n// bearer).\n// ---------------------------------------------------------------------------\n\n/** An apiKey-style template: place the value in a header or query parameter,\n * optionally prefixed (e.g. `Bearer `). */\nexport const ApiKeyAuthTemplate = Schema.Struct({\n kind: Schema.Literal(\"apiKey\"),\n /** The template slug a connection references via `connection.template`. */\n slug: Schema.String,\n in: Schema.Literals([\"header\", \"query\"]),\n /** The header / query-parameter name the value is written to. */\n name: Schema.String,\n /** Optional prefix prepended to the value (e.g. `Bearer `). */\n prefix: Schema.optional(Schema.String),\n});\nexport type ApiKeyAuthTemplate = typeof ApiKeyAuthTemplate.Type;\n\n/** An OAuth bearer template: write `Authorization: Bearer <access-token>`. The\n * resolved (and refreshed) access token is `credential.value`. */\nexport const OAuthAuthTemplate = Schema.Struct({\n kind: Schema.Literal(\"oauth2\"),\n slug: Schema.String,\n /** The header to write the bearer token to. Defaults to `Authorization`. */\n header: Schema.optional(Schema.String),\n /** The token prefix. Defaults to `Bearer `. */\n prefix: Schema.optional(Schema.String),\n});\nexport type OAuthAuthTemplate = typeof OAuthAuthTemplate.Type;\n\nexport const AuthTemplate = Schema.Union([ApiKeyAuthTemplate, OAuthAuthTemplate]);\nexport type AuthTemplate = typeof AuthTemplate.Type;\n\n// ---------------------------------------------------------------------------\n// Integration config — the opaque-to-core blob the graphql plugin stores on the\n// integration row. Holds everything `resolveTools` (introspection) and\n// `invokeTool` (request building + auth rendering) need.\n// ---------------------------------------------------------------------------\n\nexport const GraphqlIntegrationConfig = Schema.Struct({\n /** The GraphQL endpoint URL. */\n endpoint: Schema.String,\n /** Display name for the integration. */\n name: Schema.String,\n /** Optional introspection JSON text (when the endpoint doesn't support\n * live introspection). */\n introspectionJson: Schema.optional(Schema.String),\n /** Static headers applied to every request (and to add-time introspection). */\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n /** Static query parameters applied to every request. */\n queryParams: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n /** Auth methods a connection can be applied through. */\n authenticationTemplate: Schema.Array(AuthTemplate),\n});\nexport type GraphqlIntegrationConfig = typeof GraphqlIntegrationConfig.Type;\n\nexport const decodeGraphqlIntegrationConfig = Schema.decodeUnknownEffect(GraphqlIntegrationConfig);\nexport const decodeGraphqlIntegrationConfigOption =\n Schema.decodeUnknownOption(GraphqlIntegrationConfig);\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const InvocationResult = Schema.Struct({\n status: Schema.Number,\n data: Schema.NullOr(Schema.Unknown),\n errors: Schema.NullOr(Schema.Unknown),\n});\nexport type InvocationResult = typeof InvocationResult.Type;\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AAItB,IAAM,4BAAN,cAAwC,OAAO,iBAA4C;AAAA,EAChG;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,OAAO,iBAAyC;AAAA,EAC1F;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,KAAK,YAAY,wBAAwB,EAIlF;AAAC;AAKG,IAAM,2BAAN,cAAuC,KAAK,YAAY,0BAA0B,EAYtF;AAAC;;;ACvCJ,SAAS,UAAAA,eAAc;AAMhB,IAAM,uBAAuBA,QAAO,SAAS,CAAC,SAAS,UAAU,CAAC;AAOlE,IAAM,kBAAkBA,QAAO,OAAO;AAAA,EAC3C,MAAMA,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,IAAM,2BAA2BA,QAAO,OAAO;AAAA;AAAA,EAEpD,UAAUA,QAAO;AAAA;AAAA,EAEjB,MAAMA,QAAO;AAAA;AAAA;AAAA,EAGb,mBAAmBA,QAAO,SAASA,QAAO,MAAM;AAAA;AAAA,EAEhD,SAASA,QAAO,SAASA,QAAO,OAAOA,QAAO,QAAQA,QAAO,MAAM,CAAC;AAAA;AAAA,EAEpE,aAAaA,QAAO,SAASA,QAAO,OAAOA,QAAO,QAAQA,QAAO,MAAM,CAAC;AAAA;AAAA,EAExE,wBAAwBA,QAAO,MAAM,YAAY;AACnD,CAAC;AAGM,IAAM,iCAAiCA,QAAO,oBAAoB,wBAAwB;AAC1F,IAAM,uCACXA,QAAO,oBAAoB,wBAAwB;AAM9C,IAAM,mBAAmBA,QAAO,OAAO;AAAA,EAC5C,QAAQA,QAAO;AAAA,EACf,MAAMA,QAAO,OAAOA,QAAO,OAAO;AAAA,EAClC,QAAQA,QAAO,OAAOA,QAAO,OAAO;AACtC,CAAC;","names":["Schema"]}
@@ -0,0 +1,79 @@
1
+ import {
2
+ authMethodsFromConfig,
3
+ graphqlConfigAtom,
4
+ graphqlConfigure,
5
+ graphqlTemplatesFromPlacements
6
+ } from "./chunk-2Y3J3CVO.js";
7
+
8
+ // src/react/GraphqlAccountsPanel.tsx
9
+ import { useCallback, useMemo } from "react";
10
+ import { useAtomValue, useAtomSet } from "@effect/atom-react";
11
+ import * as Exit from "effect/Exit";
12
+ import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
13
+ import { IntegrationSlug } from "@executor-js/sdk/shared";
14
+ import { AccountsSection } from "@executor-js/react/components/accounts-section";
15
+ import { integrationWriteKeys } from "@executor-js/react/api/reactivity-keys";
16
+ import { jsx } from "react/jsx-runtime";
17
+ function GraphqlAccountsPanel(props) {
18
+ const { sourceId, integrationName, accountHandoff } = props;
19
+ const slug = IntegrationSlug.make(sourceId);
20
+ const configResult = useAtomValue(graphqlConfigAtom(slug));
21
+ const doConfigure = useAtomSet(graphqlConfigure, { mode: "promiseExit" });
22
+ const existingTemplate = useMemo(() => {
23
+ if (!AsyncResult.isSuccess(configResult) || configResult.value == null) return [];
24
+ return configResult.value.authenticationTemplate ?? [];
25
+ }, [configResult]);
26
+ const methods = useMemo(
27
+ () => authMethodsFromConfig(existingTemplate),
28
+ [existingTemplate]
29
+ );
30
+ const createCustomMethod = useCallback(
31
+ async (input) => {
32
+ const templates = graphqlTemplatesFromPlacements(input.placements, "");
33
+ if (templates.length === 0) return null;
34
+ const exit = await doConfigure({
35
+ params: { slug: String(slug) },
36
+ payload: { authenticationTemplate: templates },
37
+ reactivityKeys: integrationWriteKeys
38
+ });
39
+ if (Exit.isFailure(exit)) return null;
40
+ const before = new Set(existingTemplate.map((template) => template.slug));
41
+ const created = authMethodsFromConfig(exit.value.authenticationTemplate).find(
42
+ (candidate) => !before.has(String(candidate.template))
43
+ );
44
+ return created ?? null;
45
+ },
46
+ [doConfigure, existingTemplate, slug]
47
+ );
48
+ const removeCustomMethod = useCallback(
49
+ async (method) => {
50
+ if (method.source !== "custom") return false;
51
+ const next = existingTemplate.filter(
52
+ (template) => template.slug !== String(method.template)
53
+ );
54
+ const exit = await doConfigure({
55
+ params: { slug: String(slug) },
56
+ payload: { authenticationTemplate: next, mode: "replace" },
57
+ reactivityKeys: integrationWriteKeys
58
+ });
59
+ return Exit.isSuccess(exit);
60
+ },
61
+ [doConfigure, existingTemplate, slug]
62
+ );
63
+ return /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-3xl space-y-8 px-6 py-8", children: /* @__PURE__ */ jsx(
64
+ AccountsSection,
65
+ {
66
+ integration: slug,
67
+ integrationName,
68
+ methods,
69
+ accountHandoff,
70
+ createCustomMethod,
71
+ removeCustomMethod
72
+ }
73
+ ) });
74
+ }
75
+
76
+ export {
77
+ GraphqlAccountsPanel
78
+ };
79
+ //# sourceMappingURL=chunk-VCYDSSIK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/GraphqlAccountsPanel.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { useAtomValue, useAtomSet } from \"@effect/atom-react\";\nimport * as Exit from \"effect/Exit\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\nimport { IntegrationSlug } from \"@executor-js/sdk/shared\";\nimport type { IntegrationAccountHandoff } from \"@executor-js/sdk/client\";\n\nimport { AccountsSection } from \"@executor-js/react/components/accounts-section\";\nimport { integrationWriteKeys } from \"@executor-js/react/api/reactivity-keys\";\nimport type { CreateCustomMethod } from \"@executor-js/react/components/add-custom-method-modal\";\nimport type { AuthMethod, Placement } from \"@executor-js/react/lib/auth-placements\";\n\nimport { graphqlConfigAtom, graphqlConfigure } from \"./atoms\";\nimport { authMethodsFromConfig, graphqlTemplatesFromPlacements } from \"./auth-method-config\";\nimport type { AuthTemplate } from \"../sdk/types\";\n\n// ---------------------------------------------------------------------------\n// GraphQL Accounts hub — fills the generic detail page's `accounts` slot.\n//\n// Reads the integration's real `authenticationTemplate` (via `getConfig`),\n// converts it to generic `AuthMethod[]`, and composes the generic\n// `AccountsSection` — whose Add-account offers those methods plus a \"+ Custom\n// method\" row (apiKey-only). The custom-method create is INJECTED here\n// (`createCustomMethod`): generic placements → graphql `apiKey` templates\n// (`graphqlTemplatesFromPlacements`, slug omitted → backend `custom_<id>`)\n// merge-appended via `configure`. Stays plugin-side because it touches the\n// graphql sdk `AuthTemplate` types.\n// ---------------------------------------------------------------------------\n\nexport default function GraphqlAccountsPanel(props: {\n readonly sourceId: string;\n readonly integrationName: string;\n readonly accountHandoff?: IntegrationAccountHandoff | null;\n}) {\n const { sourceId, integrationName, accountHandoff } = props;\n const slug = IntegrationSlug.make(sourceId);\n const configResult = useAtomValue(graphqlConfigAtom(slug));\n const doConfigure = useAtomSet(graphqlConfigure, { mode: \"promiseExit\" });\n\n const existingTemplate = useMemo<readonly AuthTemplate[]>(() => {\n if (!AsyncResult.isSuccess(configResult) || configResult.value == null) return [];\n return configResult.value.authenticationTemplate ?? [];\n }, [configResult]);\n\n const methods = useMemo<readonly AuthMethod[]>(\n () => authMethodsFromConfig(existingTemplate),\n [existingTemplate],\n );\n\n // Add a custom apiKey method: build graphql `apiKey` templates from the\n // generic placements (slug omitted → backend backfills `custom_<id>`),\n // merge-append (the configure endpoint merges) and persist. Returns the\n // created `AuthMethod` so Add-account can select it immediately.\n const createCustomMethod = useCallback<CreateCustomMethod>(\n async (input: { readonly label: string; readonly placements: readonly Placement[] }) => {\n const templates = graphqlTemplatesFromPlacements(input.placements, \"\");\n if (templates.length === 0) return null;\n const exit = await doConfigure({\n params: { slug: String(slug) },\n payload: { authenticationTemplate: templates },\n reactivityKeys: integrationWriteKeys,\n });\n if (Exit.isFailure(exit)) return null;\n const before = new Set(existingTemplate.map((template: AuthTemplate) => template.slug));\n const created = authMethodsFromConfig(exit.value.authenticationTemplate).find(\n (candidate: AuthMethod) => !before.has(String(candidate.template)),\n );\n return created ?? null;\n },\n [doConfigure, existingTemplate, slug],\n );\n\n const removeCustomMethod = useCallback(\n async (method: AuthMethod): Promise<boolean> => {\n if (method.source !== \"custom\") return false;\n const next = existingTemplate.filter(\n (template: AuthTemplate) => template.slug !== String(method.template),\n );\n const exit = await doConfigure({\n params: { slug: String(slug) },\n payload: { authenticationTemplate: next, mode: \"replace\" },\n reactivityKeys: integrationWriteKeys,\n });\n return Exit.isSuccess(exit);\n },\n [doConfigure, existingTemplate, slug],\n );\n\n return (\n <div className=\"mx-auto max-w-3xl space-y-8 px-6 py-8\">\n <AccountsSection\n integration={slug}\n integrationName={integrationName}\n methods={methods}\n accountHandoff={accountHandoff}\n createCustomMethod={createCustomMethod}\n removeCustomMethod={removeCustomMethod}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,aAAa,eAAe;AACrC,SAAS,cAAc,kBAAkB;AACzC,YAAY,UAAU;AACtB,YAAY,iBAAiB;AAC7B,SAAS,uBAAuB;AAGhC,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;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A2B,SAAS,SAAS,OAAO,OAAO,QAAQ;AAAA,MACtE;AACA,YAAM,OAAO,MAAM,YAAY;AAAA,QAC7B,QAAQ,EAAE,MAAM,OAAO,IAAI,EAAE;AAAA,QAC7B,SAAS,EAAE,wBAAwB,MAAM,MAAM,UAAU;AAAA,QACzD,gBAAgB;AAAA,MAClB,CAAC;AACD,aAAY,eAAU,IAAI;AAAA,IAC5B;AAAA,IACA,CAAC,aAAa,kBAAkB,IAAI;AAAA,EACtC;AAEA,SACE,oBAAC,SAAI,WAAU,yCACb;AAAA,IAAC;AAAA;AAAA,MACC,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF,GACF;AAEJ;","names":[]}
package/dist/client.js CHANGED
@@ -7,27 +7,27 @@ import { defineClientPlugin } from "@executor-js/sdk/client";
7
7
 
8
8
  // src/react/source-plugin.ts
9
9
  import { lazy } from "react";
10
- var importAdd = () => import("./AddGraphqlSource-CJCUUYNM.js");
11
- var importEdit = () => import("./EditGraphqlSource-YLTPUYW4.js");
12
- var importSummary = () => import("./GraphqlSourceSummary-YWJX6ONU.js");
13
- var graphqlSourcePlugin = {
10
+ var importAdd = () => import("./AddGraphqlSource-P3D3UXRJ.js");
11
+ var importEdit = () => import("./EditGraphqlSource-FVF67CTP.js");
12
+ var importAccounts = () => import("./GraphqlAccountsPanel-GBNFHLFH.js");
13
+ var graphqlIntegrationPlugin = {
14
14
  key: "graphql",
15
15
  label: "GraphQL",
16
16
  add: lazy(importAdd),
17
17
  edit: lazy(importEdit),
18
- summary: lazy(importSummary),
18
+ accounts: lazy(importAccounts),
19
19
  presets: graphqlPresets,
20
20
  preload: () => {
21
21
  void importAdd();
22
22
  void importEdit();
23
- void importSummary();
23
+ void importAccounts();
24
24
  }
25
25
  };
26
26
 
27
27
  // src/react/plugin-client.tsx
28
28
  var plugin_client_default = defineClientPlugin({
29
29
  id: "graphql",
30
- sourcePlugin: graphqlSourcePlugin
30
+ integrationPlugin: graphqlIntegrationPlugin
31
31
  });
32
32
  export {
33
33
  plugin_client_default as default
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/react/plugin-client.tsx","../src/react/source-plugin.ts"],"sourcesContent":["import { defineClientPlugin } from \"@executor-js/sdk/client\";\n\nimport { graphqlSourcePlugin } from \"./source-plugin\";\n\nexport default defineClientPlugin({\n id: \"graphql\" as const,\n sourcePlugin: graphqlSourcePlugin,\n});\n","import { lazy } from \"react\";\nimport type { SourcePlugin } from \"@executor-js/sdk/client\";\nimport { graphqlPresets } from \"../sdk/presets\";\n\nconst importAdd = () => import(\"./AddGraphqlSource\");\nconst importEdit = () => import(\"./EditGraphqlSource\");\nconst importSummary = () => import(\"./GraphqlSourceSummary\");\n\nexport const graphqlSourcePlugin: SourcePlugin = {\n key: \"graphql\",\n label: \"GraphQL\",\n add: lazy(importAdd),\n edit: lazy(importEdit),\n summary: lazy(importSummary),\n presets: graphqlPresets,\n preload: () => {\n void importAdd();\n void importEdit();\n void importSummary();\n },\n};\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B;;;ACAnC,SAAS,YAAY;AAIrB,IAAM,YAAY,MAAM,OAAO,gCAAoB;AACnD,IAAM,aAAa,MAAM,OAAO,iCAAqB;AACrD,IAAM,gBAAgB,MAAM,OAAO,oCAAwB;AAEpD,IAAM,sBAAoC;AAAA,EAC/C,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK,KAAK,SAAS;AAAA,EACnB,MAAM,KAAK,UAAU;AAAA,EACrB,SAAS,KAAK,aAAa;AAAA,EAC3B,SAAS;AAAA,EACT,SAAS,MAAM;AACb,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,cAAc;AAAA,EACrB;AACF;;;ADhBA,IAAO,wBAAQ,mBAAmB;AAAA,EAChC,IAAI;AAAA,EACJ,cAAc;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/react/plugin-client.tsx","../src/react/source-plugin.ts"],"sourcesContent":["import { defineClientPlugin } from \"@executor-js/sdk/client\";\n\nimport { graphqlIntegrationPlugin } from \"./source-plugin\";\n\nexport default defineClientPlugin({\n id: \"graphql\" as const,\n integrationPlugin: graphqlIntegrationPlugin,\n});\n","import { lazy } from \"react\";\nimport type { IntegrationPlugin } from \"@executor-js/sdk/client\";\nimport { graphqlPresets } from \"../sdk/presets\";\n\nconst importAdd = () => import(\"./AddGraphqlSource\");\nconst importEdit = () => import(\"./EditGraphqlSource\");\nconst importAccounts = () => import(\"./GraphqlAccountsPanel\");\n\nexport const graphqlIntegrationPlugin: IntegrationPlugin = {\n key: \"graphql\",\n label: \"GraphQL\",\n add: lazy(importAdd),\n edit: lazy(importEdit),\n accounts: lazy(importAccounts),\n presets: graphqlPresets,\n preload: () => {\n void importAdd();\n void importEdit();\n void importAccounts();\n },\n};\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B;;;ACAnC,SAAS,YAAY;AAIrB,IAAM,YAAY,MAAM,OAAO,gCAAoB;AACnD,IAAM,aAAa,MAAM,OAAO,iCAAqB;AACrD,IAAM,iBAAiB,MAAM,OAAO,oCAAwB;AAErD,IAAM,2BAA8C;AAAA,EACzD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK,KAAK,SAAS;AAAA,EACnB,MAAM,KAAK,UAAU;AAAA,EACrB,UAAU,KAAK,cAAc;AAAA,EAC7B,SAAS;AAAA,EACT,SAAS,MAAM;AACb,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,eAAe;AAAA,EACtB;AACF;;;ADhBA,IAAO,wBAAQ,mBAAmB;AAAA,EAChC,IAAI;AAAA,EACJ,mBAAmB;AACrB,CAAC;","names":[]}