@executor-js/plugin-openapi 1.5.6 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AddOpenApiSource-7M52SRUX.js → AddOpenApiSource-7O4LSD7C.js} +79 -241
- package/dist/AddOpenApiSource-7O4LSD7C.js.map +1 -0
- package/dist/{EditOpenApiSource-WTAMRJUK.js → EditOpenApiSource-GIN5RQPL.js} +3 -3
- package/dist/{OpenApiAccountsPanel-3VJJXNQF.js → OpenApiAccountsPanel-7XT6ZMD5.js} +30 -28
- package/dist/OpenApiAccountsPanel-7XT6ZMD5.js.map +1 -0
- package/dist/api/group.d.ts +38 -37
- package/dist/api/index.d.ts +39 -38
- package/dist/{chunk-YVRI7KRC.js → chunk-C3IJX4AN.js} +257 -219
- package/dist/chunk-C3IJX4AN.js.map +1 -0
- package/dist/{chunk-OSIFYIQP.js → chunk-C6PH4R7Q.js} +94 -5
- package/dist/chunk-C6PH4R7Q.js.map +1 -0
- package/dist/{chunk-BSLE6HCE.js → chunk-IB36ED7Y.js} +13 -27
- package/dist/chunk-IB36ED7Y.js.map +1 -0
- package/dist/chunk-RCBR3QMJ.js +73 -0
- package/dist/chunk-RCBR3QMJ.js.map +1 -0
- package/dist/{chunk-V7VCHYOY.js → chunk-WJQIWTZF.js} +97 -172
- package/dist/chunk-WJQIWTZF.js.map +1 -0
- package/dist/client.js +3 -3
- package/dist/core.js +133 -7
- package/dist/core.js.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/react/AddOpenApiSource.d.ts +0 -1
- package/dist/react/OpenApiSourceDetailsFields.d.ts +3 -0
- package/dist/react/atoms.d.ts +40 -52
- package/dist/react/auth-method-config.d.ts +7 -4
- package/dist/react/client.d.ts +38 -37
- package/dist/sdk/config.d.ts +27 -27
- package/dist/sdk/derive-auth.d.ts +9 -0
- package/dist/sdk/extract.d.ts +11 -1
- package/dist/sdk/index.d.ts +6 -2
- package/dist/sdk/invoke.d.ts +11 -1
- package/dist/sdk/migrate-config.d.ts +4 -0
- package/dist/sdk/migrate-config.test.d.ts +1 -0
- package/dist/sdk/openapi-utils.d.ts +4 -8
- package/dist/sdk/output-schema-migration.d.ts +21 -0
- package/dist/sdk/output-schema-migration.test.d.ts +1 -0
- package/dist/sdk/plugin.d.ts +6 -4
- package/dist/sdk/preview.d.ts +77 -1
- package/dist/sdk/server-url-resolution.test.d.ts +1 -0
- package/dist/sdk/spec-blob-migration.d.ts +7 -0
- package/dist/sdk/spec-blob.test.d.ts +1 -0
- package/dist/sdk/store.d.ts +10 -1
- package/dist/sdk/tool-row-projection.test.d.ts +1 -0
- package/dist/sdk/types.d.ts +61 -36
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing.js +4 -20
- package/dist/testing.js.map +1 -1
- package/package.json +3 -3
- package/dist/AddOpenApiSource-7M52SRUX.js.map +0 -1
- package/dist/OpenApiAccountsPanel-3VJJXNQF.js.map +0 -1
- package/dist/chunk-BSLE6HCE.js.map +0 -1
- package/dist/chunk-OSIFYIQP.js.map +0 -1
- package/dist/chunk-QSSRVK6M.js +0 -139
- package/dist/chunk-QSSRVK6M.js.map +0 -1
- package/dist/chunk-V7VCHYOY.js.map +0 -1
- package/dist/chunk-YVRI7KRC.js.map +0 -1
- /package/dist/{EditOpenApiSource-WTAMRJUK.js.map → EditOpenApiSource-GIN5RQPL.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sdk/config.ts","../src/sdk/invoke.ts","../src/sdk/store.ts","../src/sdk/plugin.ts","../src/sdk/definitions.ts"],"sourcesContent":["import { Option, Schema } from \"effect\";\nimport {\n ApiKeyAuthMethod,\n TOKEN_VARIABLE,\n renderAuthPlacements,\n requiredPlacementVariables,\n} from \"@executor-js/sdk/http-auth\";\n\nimport type { Authentication } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// OpenAPI integration config — the opaque blob stored on the catalog\n// `integration.config` column (D1). Core never parses it; the plugin writes it\n// at register time and reads it back in `resolveTools` / `invokeTool`.\n//\n// In v2 there are NO credential bindings, NO per-source secret slots, and NO\n// StoredSource credential config. The config carries only:\n// - the content hash of the spec blob and/or the source URL to (re)fetch\n// from,\n// - the optional base URL override,\n// - the auth templates a connection's value is rendered through.\n// The resolved spec text itself lives in the plugin blob store, keyed\n// `spec/<specHash>` — it's a build input for resolveTools/refresh, not data\n// any list/invoke path should pay to load. Rows that predate the blob store\n// (inline `spec` text) are rewritten before this schema sees them: cloud by\n// the out-of-band migrate-specs-to-blobs script, the libSQL hosts by the\n// boot-time ledger migration.\n// ---------------------------------------------------------------------------\n\nconst OAuthAuthenticationSchema = Schema.Struct({\n slug: Schema.String,\n kind: Schema.Literal(\"oauth2\"),\n authorizationUrl: Schema.String,\n tokenUrl: Schema.String,\n scopes: Schema.Array(Schema.String),\n});\n\nexport const AuthenticationSchema = Schema.Union([OAuthAuthenticationSchema, ApiKeyAuthMethod]);\n\nexport const OpenApiIntegrationConfigSchema = Schema.Struct({\n /** Hex SHA-256 of the resolved spec text — the content address of the spec\n * blob (`spec/<hash>` in the plugin blob store). */\n specHash: Schema.optional(Schema.String),\n /** Origin URL the spec was fetched from, when known. Enables refresh. */\n sourceUrl: Schema.optional(Schema.String),\n /** Google Discovery bundle URLs, when the spec came from a Google bundle. */\n googleDiscoveryUrls: Schema.optional(Schema.Array(Schema.String)),\n /** Optional base URL override. */\n baseUrl: Schema.optional(Schema.String),\n /** Static headers applied to every request (no secret material). */\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n /** Static query params applied to every request (no secret material). */\n queryParams: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n /** The auth methods a connection's value can be applied through. */\n authenticationTemplate: Schema.optional(Schema.Array(AuthenticationSchema)),\n});\n\nexport type OpenApiIntegrationConfig = Omit<\n typeof OpenApiIntegrationConfigSchema.Type,\n \"authenticationTemplate\"\n> & {\n /** Branded over the schema's structural form so the template renderer can\n * treat `slug` as an `AuthTemplateSlug`. */\n readonly authenticationTemplate?: readonly Authentication[];\n};\n\nconst decodeConfig = Schema.decodeUnknownOption(OpenApiIntegrationConfigSchema);\n\n/** Decode the opaque integration config blob into the openapi shape.\n * Returns null when the blob is missing/incompatible. */\nexport const decodeOpenApiIntegrationConfig = (value: unknown): OpenApiIntegrationConfig | null =>\n Option.getOrNull(decodeConfig(value)) as OpenApiIntegrationConfig | null;\n\n// ---------------------------------------------------------------------------\n// Template rendering — \"auth state derived into the auth-template format\"\n// (D11). An apiKey method renders through the shared placements renderer; an\n// oauth template (no explicit placement) renders a bearer `authorization`\n// header from the `token` input (the access token).\n// ---------------------------------------------------------------------------\n\nexport interface RenderedAuth {\n readonly headers: Record<string, string>;\n readonly queryParams: Record<string, string>;\n}\n\n/** Render an auth template against a connection's resolved input `values`\n * (`variable → value`). Each placement substitutes from its own entry, so a\n * method with two distinct inputs (e.g. Datadog) fills each header from a\n * different value. */\nexport const renderAuthTemplate = (\n template: Authentication,\n values: Record<string, string | null>,\n): RenderedAuth => {\n if (template.kind === \"oauth2\") {\n return {\n headers: { authorization: `Bearer ${values[TOKEN_VARIABLE] ?? \"\"}` },\n queryParams: {},\n };\n }\n return renderAuthPlacements(template.placements, values);\n};\n\n/** The distinct input variables a template references — the inputs a connection\n * must supply. An oauth template needs `token`; an apiKey method needs every\n * variable across its placements. */\nexport const requiredTemplateVariables = (template: Authentication): readonly string[] => {\n if (template.kind === \"oauth2\") return [TOKEN_VARIABLE];\n return requiredPlacementVariables(template.placements);\n};\n","import { Effect, Layer, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\";\n\nimport { OpenApiInvocationError } from \"./errors\";\nimport { resolveServerUrl } from \"./openapi-utils\";\nimport {\n type EncodingObject,\n type OperationBinding,\n InvocationResult,\n type MediaBinding,\n type OperationParameter,\n type ServerInfo,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Parameter reading\n// ---------------------------------------------------------------------------\n\nconst CONTAINER_KEYS: Record<string, readonly string[]> = {\n path: [\"path\", \"pathParams\", \"params\"],\n query: [\"query\", \"queryParams\", \"params\"],\n header: [\"headers\", \"header\"],\n cookie: [\"cookies\", \"cookie\"],\n};\n\nconst readParamValue = (args: Record<string, unknown>, param: OperationParameter): unknown => {\n const direct = args[param.name];\n if (direct !== undefined) return direct;\n\n for (const key of CONTAINER_KEYS[param.location] ?? []) {\n const container = args[key];\n if (typeof container === \"object\" && container !== null && !Array.isArray(container)) {\n const nested = (container as Record<string, unknown>)[param.name];\n if (nested !== undefined) return nested;\n }\n }\n\n return undefined;\n};\n\nconst primitiveToString = (value: unknown): string =>\n typeof value === \"object\" && value !== null ? JSON.stringify(value) : String(value);\n\n// RFC 3986 §2.2 reserved chars. `allowReserved: true` leaves these\n// unencoded; default OAS behavior encodes everything non-unreserved.\nconst RESERVED_UNENCODED_RE = /[A-Za-z0-9\\-._~:/?#[\\]@!$&'()*+,;=]/;\n\nconst encodeReservedAware = (raw: string, allowReserved: boolean): string => {\n if (!allowReserved) return encodeURIComponent(raw);\n // Walk char-by-char so the reserved set passes through as-is.\n let out = \"\";\n for (const ch of raw) {\n out += RESERVED_UNENCODED_RE.test(ch) ? ch : encodeURIComponent(ch);\n }\n return out;\n};\n\nconst queryParamValues = (value: unknown, param: OperationParameter): string[] => {\n if (value === undefined || value === null) return [];\n if (!Array.isArray(value)) return [primitiveToString(value)];\n\n const style = Option.getOrUndefined(param.style) ?? \"form\";\n const explode = Option.getOrElse(param.explode, () => true);\n\n if (explode) return value.map(primitiveToString);\n\n const separator = style === \"spaceDelimited\" ? \" \" : style === \"pipeDelimited\" ? \"|\" : \",\";\n return [value.map(primitiveToString).join(separator)];\n};\n\n// ---------------------------------------------------------------------------\n// Path resolution\n// ---------------------------------------------------------------------------\n\nconst resolvePath = Effect.fn(\"OpenApi.resolvePath\")(function* (\n pathTemplate: string,\n args: Record<string, unknown>,\n parameters: readonly OperationParameter[],\n) {\n let resolved = pathTemplate;\n\n for (const param of parameters) {\n if (param.location !== \"path\") continue;\n const value = readParamValue(args, param);\n if (value === undefined || value === null) {\n if (param.required) {\n return yield* new OpenApiInvocationError({\n message: `Missing required path parameter: ${param.name}`,\n statusCode: Option.none(),\n });\n }\n continue;\n }\n const encoded = encodeReservedAware(\n String(value),\n Option.getOrElse(param.allowReserved, () => false),\n );\n resolved = resolved.replaceAll(`{${param.name}}`, encoded);\n resolved = resolved.replaceAll(`{+${param.name}}`, encoded);\n }\n\n const remaining = [...resolved.matchAll(/\\{([^{}]+)\\}/g)]\n .map((m) => m[1])\n .filter((v): v is string => typeof v === \"string\");\n\n for (const name of remaining) {\n const value = args[name];\n if (value !== undefined && value !== null) {\n resolved = resolved.replaceAll(`{${name}}`, encodeURIComponent(String(value)));\n }\n }\n\n const unresolved = [...resolved.matchAll(/\\{([^{}]+)\\}/g)]\n .map((m) => m[1])\n .filter((v): v is string => typeof v === \"string\");\n\n if (unresolved.length > 0) {\n return yield* new OpenApiInvocationError({\n message: `Unresolved path parameters: ${[...new Set(unresolved)].join(\", \")}`,\n statusCode: Option.none(),\n });\n }\n\n return resolved;\n});\n\nconst applyHeaders = (\n request: HttpClientRequest.HttpClientRequest,\n headers: Record<string, string>,\n): HttpClientRequest.HttpClientRequest => {\n let req = request;\n for (const [name, value] of Object.entries(headers)) {\n req = HttpClientRequest.setHeader(req, name, value);\n }\n return req;\n};\n\n// ---------------------------------------------------------------------------\n// Response helpers\n// ---------------------------------------------------------------------------\n\nconst normalizeContentType = (ct: string | null | undefined): string =>\n ct?.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n\nconst isJsonContentType = (ct: string | null | undefined): boolean => {\n const normalized = normalizeContentType(ct);\n if (!normalized) return false;\n return (\n normalized === \"application/json\" || normalized.includes(\"+json\") || normalized.includes(\"json\")\n );\n};\n\nconst isFormUrlEncoded = (ct: string | null | undefined): boolean =>\n normalizeContentType(ct) === \"application/x-www-form-urlencoded\";\n\nconst isMultipartFormData = (ct: string | null | undefined): boolean =>\n normalizeContentType(ct).startsWith(\"multipart/form-data\");\n\nconst isXmlContentType = (ct: string | null | undefined): boolean => {\n const normalized = normalizeContentType(ct);\n if (!normalized) return false;\n return (\n normalized === \"application/xml\" || normalized === \"text/xml\" || normalized.endsWith(\"+xml\")\n );\n};\n\nconst isTextContentType = (ct: string | null | undefined): boolean =>\n normalizeContentType(ct).startsWith(\"text/\");\n\nconst isOctetStream = (ct: string | null | undefined): boolean =>\n normalizeContentType(ct) === \"application/octet-stream\";\n\nconst toUint8Array = (value: unknown): Uint8Array | null => {\n if (value instanceof Uint8Array) return value;\n if (value instanceof ArrayBuffer) return new Uint8Array(value);\n if (ArrayBuffer.isView(value)) {\n const view = value as ArrayBufferView;\n return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n }\n if (Array.isArray(value) && value.every((v) => typeof v === \"number\")) {\n return new Uint8Array(value as readonly number[]);\n }\n return null;\n};\n\ntype FormDataRecord = Parameters<typeof HttpClientRequest.bodyFormDataRecord>[1];\ntype FormDataCoercible = FormDataRecord[string];\n\n// Pull a plain ArrayBuffer out of a Uint8Array — `new Blob([u8])` rejects\n// views whose `.buffer` is `SharedArrayBuffer | ArrayBuffer` under strict\n// lib.dom typings.\nconst toArrayBuffer = (bytes: Uint8Array): ArrayBuffer => {\n const copy = new ArrayBuffer(bytes.byteLength);\n new Uint8Array(copy).set(bytes);\n return copy;\n};\n\n// ---------------------------------------------------------------------------\n// OpenAPI 3.x encoding — per-property style/explode/allowReserved/contentType\n// for multipart/form-data and application/x-www-form-urlencoded bodies.\n// Spec ref: https://spec.openapis.org/oas/v3.1.0#encoding-object\n// ---------------------------------------------------------------------------\n\ntype StyleExplode = {\n readonly style: string;\n readonly explode: boolean;\n readonly allowReserved: boolean;\n};\n\nconst DEFAULT_FORM_STYLE: StyleExplode = {\n style: \"form\",\n explode: true,\n allowReserved: false,\n};\n\nconst resolveStyleExplode = (e: EncodingObject | undefined): StyleExplode => {\n if (!e) return DEFAULT_FORM_STYLE;\n return {\n style: Option.getOrElse(e.style, () => DEFAULT_FORM_STYLE.style),\n explode: Option.getOrElse(e.explode, () => DEFAULT_FORM_STYLE.explode),\n allowReserved: Option.getOrElse(e.allowReserved, () => DEFAULT_FORM_STYLE.allowReserved),\n };\n};\n\nconst encodeFormValue = (v: unknown, allowReserved: boolean): string => {\n const raw = typeof v === \"object\" && v !== null ? JSON.stringify(v) : String(v);\n return encodeReservedAware(raw, allowReserved);\n};\n\n/**\n * Serialize a record to application/x-www-form-urlencoded with OAS3 style\n * rules honored per-field. Supports `form` (default), `deepObject`,\n * `pipeDelimited`, `spaceDelimited` styles with `explode` true / false.\n */\nconst serializeFormUrlEncoded = (\n value: Record<string, unknown>,\n encoding: Record<string, EncodingObject> | undefined,\n): string => {\n const parts: string[] = [];\n for (const [key, raw] of Object.entries(value)) {\n if (raw === undefined || raw === null) continue;\n const { style, explode, allowReserved } = resolveStyleExplode(encoding?.[key]);\n const encKey = encodeURIComponent(key);\n\n if (Array.isArray(raw)) {\n if (explode) {\n for (const v of raw) {\n parts.push(`${encKey}=${encodeFormValue(v, allowReserved)}`);\n }\n } else {\n const sep = style === \"spaceDelimited\" ? \" \" : style === \"pipeDelimited\" ? \"|\" : \",\";\n parts.push(\n `${encKey}=${encodeFormValue(\n raw.map((v) => (typeof v === \"object\" ? JSON.stringify(v) : String(v))).join(sep),\n allowReserved,\n )}`,\n );\n }\n continue;\n }\n\n if (typeof raw === \"object\") {\n const entries = Object.entries(raw as Record<string, unknown>).filter(\n ([, v]) => v !== undefined && v !== null,\n );\n if (style === \"deepObject\") {\n for (const [subkey, subval] of entries) {\n // Encode the whole `key[subkey]` fragment so `[` / `]` become\n // `%5B` / `%5D`. Matches swagger-client's behaviour and remains\n // accepted by common server-side parsers (qs, Rails, etc.).\n parts.push(\n `${encodeURIComponent(`${key}[${subkey}]`)}=${encodeFormValue(subval, allowReserved)}`,\n );\n }\n } else if (explode) {\n // form + explode=true on object: sub-keys become top-level fields.\n for (const [subkey, subval] of entries) {\n parts.push(`${encodeURIComponent(subkey)}=${encodeFormValue(subval, allowReserved)}`);\n }\n } else {\n // form + explode=false on object: flatten to csv key,val,key,val.\n const flat = entries.flatMap(([k, v]) => [\n k,\n typeof v === \"object\" ? JSON.stringify(v) : String(v),\n ]);\n parts.push(`${encKey}=${encodeFormValue(flat.join(\",\"), allowReserved)}`);\n }\n continue;\n }\n\n parts.push(`${encKey}=${encodeFormValue(raw, allowReserved)}`);\n }\n return parts.join(\"&\");\n};\n\n/**\n * Best-effort build of a multipart FormData entry record.\n *\n * If `encoding[key].contentType` is declared (OAS3 §4.8.15), wrap the value\n * in a `Blob` with that type so the runtime multipart framer emits the\n * per-part `Content-Type` header (e.g. `application/json` for a metadata\n * part whose server expects parsed JSON).\n *\n * Otherwise: primitives pass through, arrays handle their item types, byte\n * shapes wrap as Blob, nested objects JSON-stringify (never `[object Object]`).\n */\nconst coerceFormDataRecord = (\n value: Record<string, unknown>,\n encoding: Record<string, EncodingObject> | undefined,\n): FormDataRecord => {\n const out: Record<string, FormDataCoercible> = {};\n for (const [key, raw] of Object.entries(value)) {\n if (raw === undefined || raw === null) continue;\n\n const partType = encoding?.[key]\n ? Option.getOrUndefined(encoding[key]!.contentType)\n : undefined;\n\n // Explicit per-part content type: wrap in a typed Blob so the framer\n // emits `Content-Type: <partType>` on this part. JSON types get the\n // value JSON-stringified first so the blob body is valid JSON.\n if (partType) {\n const isJson = partType.startsWith(\"application/json\") || partType.includes(\"+json\");\n const serialized =\n typeof raw === \"string\"\n ? raw\n : isJson\n ? JSON.stringify(raw)\n : typeof raw === \"object\"\n ? JSON.stringify(raw)\n : String(raw);\n out[key] = new Blob([serialized], { type: partType });\n continue;\n }\n\n if (\n typeof raw === \"string\" ||\n typeof raw === \"number\" ||\n typeof raw === \"boolean\" ||\n raw instanceof Blob ||\n (typeof File !== \"undefined\" && raw instanceof File)\n ) {\n out[key] = raw as FormDataCoercible;\n continue;\n }\n if (Array.isArray(raw)) {\n out[key] = raw.map((v) =>\n typeof v === \"string\" ||\n typeof v === \"number\" ||\n typeof v === \"boolean\" ||\n v instanceof Blob ||\n (typeof File !== \"undefined\" && v instanceof File)\n ? (v as FormDataCoercible)\n : JSON.stringify(v),\n ) as FormDataCoercible;\n continue;\n }\n const bytes = toUint8Array(raw);\n if (bytes) {\n out[key] = new Blob([toArrayBuffer(bytes)]);\n continue;\n }\n out[key] = JSON.stringify(raw);\n }\n return out;\n};\n\n// ---------------------------------------------------------------------------\n// Request body dispatch\n//\n// Dispatch is driven by the spec-declared content type first, JS type of\n// the provided body second. Servers that advertise a specific content type\n// almost always reject anything else (e.g. a multipart endpoint will hang\n// waiting for valid framing if it receives `application/json`), so the\n// content type wins.\n//\n// Within each content type we accept both pre-serialized strings (user\n// already produced the wire format) and structured JS values we can\n// serialize ourselves. The last-resort fallback is `JSON.stringify(body)`\n// — never `String(body)` (which produces the useless `[object Object]`).\n// ---------------------------------------------------------------------------\n\nconst applyRequestBody = (\n request: HttpClientRequest.HttpClientRequest,\n contentType: string,\n bodyValue: unknown,\n encoding: Record<string, EncodingObject> | undefined,\n): HttpClientRequest.HttpClientRequest => {\n if (isJsonContentType(contentType)) {\n // Pre-serialized JSON strings pass through with the declared media\n // type preserved (important for `application/vnd.foo+json` etc.).\n if (typeof bodyValue === \"string\") {\n return HttpClientRequest.bodyText(request, bodyValue, contentType);\n }\n return HttpClientRequest.bodyJsonUnsafe(request, bodyValue);\n }\n\n if (isFormUrlEncoded(contentType)) {\n if (typeof bodyValue === \"string\") {\n return HttpClientRequest.bodyText(request, bodyValue, contentType);\n }\n if (typeof bodyValue === \"object\" && bodyValue !== null && !Array.isArray(bodyValue)) {\n // Serialize ourselves so OAS3 encoding (style/explode/deepObject)\n // is honored. bodyUrlParams doesn't know about per-field style.\n const serialized = serializeFormUrlEncoded(bodyValue as Record<string, unknown>, encoding);\n return HttpClientRequest.bodyText(request, serialized, contentType);\n }\n // Non-object body — fall back to platform helper (handles URLSearchParams).\n return HttpClientRequest.bodyUrlParams(\n request,\n bodyValue as Parameters<typeof HttpClientRequest.bodyUrlParams>[1],\n );\n }\n\n if (isMultipartFormData(contentType)) {\n if (bodyValue instanceof FormData) {\n return HttpClientRequest.bodyFormData(request, bodyValue);\n }\n if (typeof bodyValue === \"object\" && bodyValue !== null) {\n return HttpClientRequest.bodyFormDataRecord(\n request,\n coerceFormDataRecord(bodyValue as Record<string, unknown>, encoding),\n );\n }\n // String / primitive under multipart is almost certainly wrong on the\n // caller's end — send it as text with their declared content type and\n // let the server produce a useful error.\n return HttpClientRequest.bodyText(request, String(bodyValue), contentType);\n }\n\n if (isOctetStream(contentType)) {\n const bytes = toUint8Array(bodyValue);\n if (bytes) return HttpClientRequest.bodyUint8Array(request, bytes, contentType);\n if (typeof bodyValue === \"string\") {\n return HttpClientRequest.bodyText(request, bodyValue, contentType);\n }\n // Unknown shape — serialize as JSON so at least the payload is visible.\n return HttpClientRequest.bodyText(request, JSON.stringify(bodyValue), contentType);\n }\n\n if (isXmlContentType(contentType) || isTextContentType(contentType)) {\n if (typeof bodyValue === \"string\") {\n return HttpClientRequest.bodyText(request, bodyValue, contentType);\n }\n const bytes = toUint8Array(bodyValue);\n if (bytes) return HttpClientRequest.bodyUint8Array(request, bytes, contentType);\n // Object body under text/xml is unusual — stringify so the caller sees\n // their own payload instead of `[object Object]`.\n return HttpClientRequest.bodyText(request, JSON.stringify(bodyValue), contentType);\n }\n\n // Unknown content type: respect what the caller supplied.\n if (typeof bodyValue === \"string\") {\n return HttpClientRequest.bodyText(request, bodyValue, contentType);\n }\n const bytes = toUint8Array(bodyValue);\n if (bytes) return HttpClientRequest.bodyUint8Array(request, bytes, contentType);\n return HttpClientRequest.bodyText(request, JSON.stringify(bodyValue), contentType);\n};\n\n// ---------------------------------------------------------------------------\n// Public API — invoke a single operation\n// ---------------------------------------------------------------------------\n\nexport const invoke = Effect.fn(\"OpenApi.invoke\")(function* (\n operation: OperationBinding,\n args: Record<string, unknown>,\n resolvedHeaders: Record<string, string>,\n sourceQueryParams: Record<string, string> = {},\n) {\n const client = yield* HttpClient.HttpClient;\n\n yield* Effect.annotateCurrentSpan({\n \"http.method\": operation.method.toUpperCase(),\n \"http.route\": operation.pathTemplate,\n \"plugin.openapi.method\": operation.method.toUpperCase(),\n \"plugin.openapi.path_template\": operation.pathTemplate,\n \"plugin.openapi.headers.resolved_count\": Object.keys(resolvedHeaders).length,\n });\n\n const resolvedPath = yield* resolvePath(operation.pathTemplate, args, operation.parameters);\n\n const path = resolvedPath.startsWith(\"/\") ? resolvedPath : `/${resolvedPath}`;\n\n let request = HttpClientRequest.make(operation.method.toUpperCase() as \"GET\")(path);\n\n for (const [name, value] of Object.entries(sourceQueryParams)) {\n request = HttpClientRequest.setUrlParam(request, name, value);\n }\n\n for (const param of operation.parameters) {\n if (param.location !== \"query\") continue;\n const value = readParamValue(args, param);\n for (const paramValue of queryParamValues(value, param)) {\n request = HttpClientRequest.appendUrlParam(request, param.name, paramValue);\n }\n }\n\n for (const param of operation.parameters) {\n if (param.location !== \"header\") continue;\n const value = readParamValue(args, param);\n if (value === undefined || value === null) continue;\n request = HttpClientRequest.setHeader(request, param.name, String(value));\n }\n\n if (Option.isSome(operation.requestBody)) {\n const rb = operation.requestBody.value;\n const bodyValue = args.body ?? args.input;\n if (bodyValue !== undefined) {\n // Resolve which declared media type to use. When the spec declares\n // multiple, the caller can override via `args.contentType`; otherwise\n // we use the first-declared (spec author's preferred ordering).\n const contentsOpt = Option.getOrUndefined(rb.contents);\n const requestedCt = typeof args.contentType === \"string\" ? args.contentType : undefined;\n const selected: MediaBinding | undefined =\n contentsOpt && requestedCt\n ? contentsOpt.find((c) => c.contentType === requestedCt)\n : undefined;\n const chosenCt = selected?.contentType ?? rb.contentType;\n const chosenEncoding = selected\n ? Option.getOrUndefined(selected.encoding)\n : contentsOpt && contentsOpt[0]\n ? Option.getOrUndefined(contentsOpt[0].encoding)\n : undefined;\n request = applyRequestBody(request, chosenCt, bodyValue, chosenEncoding);\n }\n }\n\n request = applyHeaders(request, resolvedHeaders);\n\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n (err) =>\n new OpenApiInvocationError({\n message: \"HTTP request failed\",\n statusCode: Option.none(),\n cause: err,\n }),\n ),\n );\n\n const status = response.status;\n yield* Effect.annotateCurrentSpan({\n \"http.status_code\": status,\n });\n const responseHeaders: Record<string, string> = { ...response.headers };\n\n const contentType = response.headers[\"content-type\"] ?? null;\n const mapBodyError = Effect.mapError(\n (err: unknown) =>\n new OpenApiInvocationError({\n message: \"Failed to read response body\",\n statusCode: Option.some(status),\n cause: err,\n }),\n );\n const responseBody: unknown =\n status === 204\n ? null\n : isJsonContentType(contentType)\n ? yield* response.json.pipe(\n Effect.catch(() => response.text),\n mapBodyError,\n )\n : yield* response.text.pipe(mapBodyError);\n\n const ok = status >= 200 && status < 300;\n\n return InvocationResult.make({\n status,\n headers: responseHeaders,\n data: ok ? responseBody : null,\n error: ok ? null : responseBody,\n });\n});\n\n// Connection `baseUrl` wins; otherwise the call's chosen server (`server.url`, or\n// the first) resolved with its `{variables}` (call values, else spec defaults).\nconst resolveRequestHost = (\n servers: readonly ServerInfo[],\n serverArg: unknown,\n baseUrl: string,\n): string => {\n if (baseUrl) return baseUrl;\n if (servers.length === 0) return \"\";\n\n const arg = (\n typeof serverArg === \"object\" && serverArg !== null && !Array.isArray(serverArg)\n ? serverArg\n : {}\n ) as { url?: unknown; variables?: unknown };\n const chosen = servers.find((server) => server.url === arg.url) ?? servers[0]!;\n\n const overrides: Record<string, string> = {};\n if (typeof arg.variables === \"object\" && arg.variables !== null) {\n for (const [name, value] of Object.entries(arg.variables as Record<string, unknown>)) {\n if (value != null && value !== \"\") overrides[name] = String(value);\n }\n }\n return resolveServerUrl(chosen.url, Option.getOrUndefined(chosen.variables), overrides);\n};\n\n// ---------------------------------------------------------------------------\n// Invoke with a provided HttpClient layer + per-call host resolution\n// ---------------------------------------------------------------------------\n\nexport const invokeWithLayer = (\n operation: OperationBinding,\n args: Record<string, unknown>,\n baseUrl: string,\n resolvedHeaders: Record<string, string>,\n sourceQueryParams: Record<string, string>,\n httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,\n) => {\n const effectiveBaseUrl = resolveRequestHost(operation.servers ?? [], args.server, baseUrl);\n const clientWithBaseUrl = effectiveBaseUrl\n ? Layer.effect(\n HttpClient.HttpClient,\n Effect.map(\n Effect.service(HttpClient.HttpClient),\n HttpClient.mapRequest(HttpClientRequest.prependUrl(effectiveBaseUrl)),\n ),\n ).pipe(Layer.provide(httpClientLayer))\n : httpClientLayer;\n\n return invoke(operation, args, resolvedHeaders, sourceQueryParams).pipe(\n Effect.provide(clientWithBaseUrl),\n Effect.withSpan(\"plugin.openapi.invoke\", {\n attributes: {\n \"plugin.openapi.method\": operation.method.toUpperCase(),\n \"plugin.openapi.path_template\": operation.pathTemplate,\n \"plugin.openapi.base_url\": effectiveBaseUrl,\n },\n }),\n );\n};\n\n// ---------------------------------------------------------------------------\n// Derive annotations from HTTP method\n// ---------------------------------------------------------------------------\n\nconst REQUIRE_APPROVAL = new Set([\"post\", \"put\", \"patch\", \"delete\"]);\n\nexport const annotationsForOperation = (\n method: string,\n pathTemplate: string,\n): { requiresApproval?: boolean; approvalDescription?: string } => {\n const m = method.toLowerCase();\n if (!REQUIRE_APPROVAL.has(m)) return {};\n return {\n requiresApproval: true,\n approvalDescription: `${method.toUpperCase()} ${pathTemplate}`,\n };\n};\n","import { Effect, Option, Predicate, Schema } from \"effect\";\n\nimport {\n type PluginStorageEntry,\n type StorageDeps,\n type StorageFailure,\n} from \"@executor-js/sdk/core\";\n\nimport { OperationBinding } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// OpenAPI plugin store (v2). The catalog row (integration.config) owns the\n// auth templates plus the spec's content hash; the resolved spec text itself\n// lives in the plugin blob store under `spec/<hash>` (it's multi-MB and only\n// a build input). This store keeps the per-operation invocation bindings\n// (method / path / params), keyed by integration slug, so `invokeTool` can map\n// a tool name back to its HTTP operation without re-parsing the spec on every\n// call. There are NO credential bindings, slots, or StoredSource credential\n// config here — those concepts are gone in v2.\n//\n// Operations are spec-derived (identical for every connection on an\n// integration), so they live under the org owner (the integration catalog is\n// tenant-level). The plugin storage facade partitions by owner; \"org\" keeps a\n// single shared copy per integration.\n// ---------------------------------------------------------------------------\n\nconst OPERATION_COLLECTION = \"operation\";\nconst STORE_OWNER = \"org\" as const;\n\nconst encodeBinding = Schema.encodeSync(OperationBinding);\nconst decodeBinding = Schema.decodeUnknownSync(OperationBinding);\nconst decodeBindingJson = Schema.decodeUnknownSync(Schema.fromJsonString(OperationBinding));\n\nconst toJsonRecord = (value: unknown): Record<string, unknown> => value as Record<string, unknown>;\n\nconst OperationStorage = Schema.Struct({\n integration: Schema.String,\n toolName: Schema.String,\n binding: Schema.Unknown,\n});\nconst decodeOperationStorage = Schema.decodeUnknownOption(OperationStorage);\n\nexport interface StoredOperation {\n /** The integration slug this operation belongs to. */\n readonly integration: string;\n /** The tool name (the `<tool>` address segment) this operation backs. */\n readonly toolName: string;\n readonly binding: OperationBinding;\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 integration: operation.integration,\n toolName: operation.toolName,\n binding: decodeBinding(\n typeof operation.binding === \"string\"\n ? decodeBindingJson(operation.binding)\n : operation.binding,\n ),\n };\n};\n\nconst operationKey = (integration: string, toolName: string): string =>\n `${integration}.${toolName}`;\n\n/** Blob key for a spec's content hash. Content-addressed so re-puts are\n * idempotent and identical specs share one blob per partition. */\nexport const specBlobKey = (specHash: string): string => `spec/${specHash}`;\n\nexport interface OpenapiStore {\n /** Replace all stored operations for an integration. */\n readonly putOperations: (\n integration: string,\n operations: readonly StoredOperation[],\n ) => Effect.Effect<void, StorageFailure>;\n /** Look up one operation by integration + tool name. */\n readonly getOperation: (\n integration: string,\n toolName: string,\n ) => Effect.Effect<StoredOperation | null, StorageFailure>;\n /** List every stored operation for an integration. */\n readonly listOperations: (\n integration: string,\n ) => Effect.Effect<readonly StoredOperation[], StorageFailure>;\n /** Drop all stored operations for an integration. */\n readonly removeOperations: (integration: string) => Effect.Effect<void, StorageFailure>;\n /** Persist resolved spec text under its content hash. Org-owned and\n * content-addressed; never removed on integration removal because another\n * integration in the tenant may share the hash. */\n readonly putSpec: (specHash: string, specText: string) => Effect.Effect<void, StorageFailure>;\n /** Load spec text by content hash; null when no blob exists. */\n readonly getSpec: (specHash: string) => Effect.Effect<string | null, StorageFailure>;\n}\n\nexport const makeDefaultOpenapiStore = ({ pluginStorage, blobs }: StorageDeps): OpenapiStore => {\n const operationData = (operation: StoredOperation) => ({\n integration: operation.integration,\n toolName: operation.toolName,\n binding: toJsonRecord(encodeBinding(operation.binding)),\n });\n\n const listRows = (integration: string) =>\n pluginStorage\n .list({ collection: OPERATION_COLLECTION, keyPrefix: `${integration}.` })\n .pipe(\n Effect.map((rows: readonly PluginStorageEntry[]) =>\n rows.filter((row) => rowToOperation(row)?.integration === integration),\n ),\n );\n\n const removeOperations = (integration: string) =>\n Effect.gen(function* () {\n const rows = yield* listRows(integration);\n yield* pluginStorage.removeMany({\n owner: STORE_OWNER,\n entries: rows.map((row) => ({ collection: OPERATION_COLLECTION, key: row.key })),\n });\n });\n\n return {\n putOperations: (integration, operations) =>\n Effect.gen(function* () {\n yield* removeOperations(integration);\n yield* pluginStorage.putMany({\n owner: STORE_OWNER,\n entries: operations.map((operation) => ({\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 listRows(integration).pipe(\n Effect.map((rows) => rows.map(rowToOperation).filter(Predicate.isNotNull)),\n ),\n\n removeOperations,\n\n putSpec: (specHash, specText) =>\n blobs.put(specBlobKey(specHash), specText, { owner: STORE_OWNER }),\n\n getSpec: (specHash) => blobs.get(specBlobKey(specHash)),\n };\n};\n","import { Effect, Option, Schema } from \"effect\";\nimport type { Layer } from \"effect\";\nimport { HttpClient } from \"effect/unstable/http\";\n\nimport {\n IntegrationAlreadyExistsError,\n IntegrationDetectionResult,\n IntegrationSlug,\n ToolName,\n ToolResult,\n authToolFailure,\n definePlugin,\n mergeAuthTemplates,\n sha256Hex,\n tool,\n type AuthMethodDescriptor,\n type Integration,\n type IntegrationConfig,\n type IntegrationRecord,\n type PluginCtx,\n type ResolveToolsResult,\n type StorageFailure,\n type ToolDef,\n type ToolInvocationCredential,\n} from \"@executor-js/sdk/core\";\n\nimport {\n decodeOpenApiIntegrationConfig,\n renderAuthTemplate,\n requiredTemplateVariables,\n type OpenApiIntegrationConfig,\n} from \"./config\";\nimport { OpenApiExtractionError, OpenApiOAuthError, OpenApiParseError } from \"./errors\";\nimport { parse, resolveSpecText } from \"./parse\";\nimport {\n convertGoogleDiscoveryBundleToOpenApi,\n convertGoogleDiscoveryToOpenApi,\n fetchGoogleDiscoveryDocument,\n isGoogleDiscoveryUrl,\n} from \"./google-discovery\";\nimport { extract } from \"./extract\";\nimport { compileToolDefinitions, type ToolDefinition } from \"./definitions\";\nimport { annotationsForOperation, invokeWithLayer } from \"./invoke\";\nimport { previewSpec, previewSpecText, type SpecPreview } from \"./preview\";\nimport { deriveAuthenticationTemplateFromPreview, firstBaseUrlForPreview } from \"./derive-auth\";\nimport { openApiPresets } from \"./presets\";\nimport { makeDefaultOpenapiStore, type OpenapiStore, type StoredOperation } from \"./store\";\nimport type { Authentication } from \"./types\";\nimport { OperationBinding, normalizeOpenApiAuthInputs, type AuthenticationInput } from \"./types\";\nimport { ApiKeyAuthTemplate, describeApiKeyAuthMethod } from \"@executor-js/sdk/http-auth\";\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nconst STRINGIFIED_BODY_CAP = 1024;\nconst UpstreamMessageBody = Schema.Struct({ message: Schema.String });\nconst UpstreamErrorMessageBody = Schema.Struct({ errorMessage: Schema.String });\nconst UpstreamNestedErrorBody = Schema.Struct({ error: UpstreamMessageBody });\nconst UpstreamErrorsArrayBody = Schema.Struct({\n errors: Schema.Array(\n Schema.Struct({\n detail: Schema.optional(Schema.String),\n message: Schema.optional(Schema.String),\n title: Schema.optional(Schema.String),\n }),\n ),\n});\nconst UpstreamDescriptionBody = Schema.Struct({\n detail: Schema.optional(Schema.String),\n title: Schema.optional(Schema.String),\n description: Schema.optional(Schema.String),\n});\n\nconst decodeUpstreamMessageBody = Schema.decodeUnknownOption(UpstreamMessageBody);\nconst decodeUpstreamErrorMessageBody = Schema.decodeUnknownOption(UpstreamErrorMessageBody);\nconst decodeUpstreamNestedErrorBody = Schema.decodeUnknownOption(UpstreamNestedErrorBody);\nconst decodeUpstreamErrorsArrayBody = Schema.decodeUnknownOption(UpstreamErrorsArrayBody);\nconst decodeUpstreamDescriptionBody = Schema.decodeUnknownOption(UpstreamDescriptionBody);\n\nconst clampedStringify = (value: unknown): string => {\n let s: string;\n // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: JSON.stringify may throw on cycles; fall back to String() so the upstream body can still be surfaced as ToolError.details fallback text\n try {\n s = JSON.stringify(value);\n } catch {\n s = String(value);\n }\n return s.length > STRINGIFIED_BODY_CAP ? `${s.slice(0, STRINGIFIED_BODY_CAP)}…` : s;\n};\n\nconst firstNonEmpty = (...values: readonly (string | undefined)[]): string | undefined =>\n values.find((value) => value !== undefined && value.length > 0);\n\n// Walk known upstream error-body shapes so ToolError.message stays concise\n// while ToolError.details preserves the original body.\nconst extractUpstreamMessage = (body: unknown, status: number): string => {\n if (typeof body === \"string\") {\n return body.length > 0 ? body : `Upstream returned HTTP ${status}`;\n }\n const nested = Option.getOrUndefined(decodeUpstreamNestedErrorBody(body));\n const messageBody = Option.getOrUndefined(decodeUpstreamMessageBody(body));\n const errorMessageBody = Option.getOrUndefined(decodeUpstreamErrorMessageBody(body));\n const errorsBody = Option.getOrUndefined(decodeUpstreamErrorsArrayBody(body));\n const descriptionBody = Option.getOrUndefined(decodeUpstreamDescriptionBody(body));\n const arrayMessage = errorsBody?.errors\n .map(\n ({\n detail,\n message: upstreamMessage,\n title,\n }: {\n detail?: string;\n message?: string;\n title?: string;\n }) => firstNonEmpty(detail, upstreamMessage, title),\n )\n .find((message: string | undefined) => message !== undefined);\n const message = firstNonEmpty(\n nested?.error.message,\n messageBody?.message,\n errorMessageBody?.errorMessage,\n arrayMessage,\n descriptionBody?.detail,\n descriptionBody?.title,\n descriptionBody?.description,\n );\n if (message !== undefined) return message;\n if (body !== null && typeof body === \"object\") {\n return clampedStringify(body);\n }\n return `Upstream returned HTTP ${status}`;\n};\n\n// ---------------------------------------------------------------------------\n// Extension input shapes\n// ---------------------------------------------------------------------------\n\nexport type OpenApiSpecInput = typeof OpenApiSpecInputSchema.Type;\n\nexport interface OpenApiPreviewInput {\n readonly spec: string;\n}\n\n/** Add an OpenAPI integration to the catalog. The integration is the API\n * surface; connections (the credentials) are attached separately and resolve\n * their value through the declared `authenticationTemplate`. */\nexport interface OpenApiSpecConfig {\n readonly spec: OpenApiSpecInput;\n /** The catalog slug for the new integration (the `<integration>` segment). */\n readonly slug: string;\n /** Human description (defaults to the spec title). */\n readonly description?: string;\n readonly baseUrl?: string;\n /** Static headers applied to every request (no secret material). */\n readonly headers?: Record<string, string>;\n /** Static query params applied to every request. */\n readonly queryParams?: Record<string, string>;\n /** Auth methods a connection's value renders through — canonical\n * placements or the request-shaped authoring dialect. */\n readonly authenticationTemplate?: readonly AuthenticationInput[];\n}\n\nexport interface OpenApiExtensionFailure {\n readonly _tag: string;\n}\n\n/** Add / merge custom auth methods onto an existing OpenAPI integration's\n * `authenticationTemplate`. Mirrors the GraphQL plugin's `configure`. */\nexport interface OpenApiConfigureInput {\n /** The auth methods to add. Each entry is appended to (or, when its `slug`\n * already exists, replaces) the integration's existing template array. A\n * custom apiKey method with no `slug` is assigned a generated `custom_<id>`\n * slug that is collision-checked against the existing template. */\n readonly authenticationTemplate: readonly AuthenticationInput[];\n readonly mode?: \"merge\" | \"replace\";\n}\n\nexport interface OpenApiPluginExtension {\n readonly previewSpec: (\n input: string | OpenApiPreviewInput,\n ) => Effect.Effect<\n SpecPreview,\n OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError | StorageFailure\n >;\n readonly addSpec: (\n config: OpenApiSpecConfig,\n ) => Effect.Effect<\n { readonly slug: IntegrationSlug; readonly toolCount: number },\n | OpenApiParseError\n | OpenApiExtractionError\n | OpenApiOAuthError\n | IntegrationAlreadyExistsError\n | StorageFailure\n >;\n readonly removeSpec: (slug: string) => Effect.Effect<void, StorageFailure>;\n readonly getIntegration: (slug: string) => Effect.Effect<Integration | null, StorageFailure>;\n /** Read the integration's full opaque config, including its\n * `authenticationTemplate`. Returns null when the integration is absent. */\n readonly getConfig: (\n slug: string,\n ) => Effect.Effect<OpenApiIntegrationConfig | null, StorageFailure>;\n /** Add / merge custom auth methods onto the integration's\n * `authenticationTemplate`. Returns the resulting template array. */\n readonly configure: (\n slug: string,\n input: OpenApiConfigureInput,\n ) => Effect.Effect<readonly Authentication[], StorageFailure>;\n}\n\n// ---------------------------------------------------------------------------\n// Control-tool input/output schemas\n// ---------------------------------------------------------------------------\n\nconst PreviewSpecInputSchema = Schema.Struct({\n spec: Schema.String,\n});\n\nconst StaticPreviewServerVariableSchema = Schema.Struct({\n default: Schema.String,\n enum: Schema.NullOr(Schema.Array(Schema.String)),\n description: Schema.NullOr(Schema.String),\n});\nconst StaticPreviewServerSchema = Schema.Struct({\n url: Schema.String,\n description: Schema.NullOr(Schema.String),\n variables: Schema.NullOr(Schema.Record(Schema.String, StaticPreviewServerVariableSchema)),\n});\nconst StaticPreviewOAuthAuthorizationCodeFlowSchema = Schema.Struct({\n authorizationUrl: Schema.String,\n tokenUrl: Schema.String,\n refreshUrl: Schema.NullOr(Schema.String),\n scopes: Schema.Record(Schema.String, Schema.String),\n});\nconst StaticPreviewOAuthClientCredentialsFlowSchema = Schema.Struct({\n tokenUrl: Schema.String,\n refreshUrl: Schema.NullOr(Schema.String),\n scopes: Schema.Record(Schema.String, Schema.String),\n});\nconst StaticPreviewOAuthFlowsSchema = Schema.Struct({\n authorizationCode: Schema.NullOr(StaticPreviewOAuthAuthorizationCodeFlowSchema),\n clientCredentials: Schema.NullOr(StaticPreviewOAuthClientCredentialsFlowSchema),\n});\nconst StaticPreviewSecuritySchemeSchema = Schema.Struct({\n name: Schema.String,\n type: Schema.Literals([\"http\", \"apiKey\", \"oauth2\", \"openIdConnect\"]),\n scheme: Schema.NullOr(Schema.String),\n bearerFormat: Schema.NullOr(Schema.String),\n in: Schema.NullOr(Schema.Literals([\"header\", \"query\", \"cookie\"])),\n headerName: Schema.NullOr(Schema.String),\n description: Schema.NullOr(Schema.String),\n flows: Schema.NullOr(StaticPreviewOAuthFlowsSchema),\n openIdConnectUrl: Schema.NullOr(Schema.String),\n});\nconst StaticPreviewOAuth2PresetSchema = Schema.Struct({\n label: Schema.String,\n securitySchemeName: Schema.String,\n flow: Schema.Literals([\"authorizationCode\", \"clientCredentials\"]),\n authorizationUrl: Schema.NullOr(Schema.String),\n tokenUrl: Schema.String,\n refreshUrl: Schema.NullOr(Schema.String),\n scopes: Schema.Record(Schema.String, Schema.String),\n identityScopes: Schema.Union([\n Schema.Literal(\"auto\"),\n Schema.Literal(false),\n Schema.Array(Schema.String),\n ]),\n});\nconst StaticPreviewSpecOutputSchema = Schema.Struct({\n title: Schema.NullOr(Schema.String),\n version: Schema.NullOr(Schema.String),\n servers: Schema.Array(StaticPreviewServerSchema),\n operationCount: Schema.Number,\n tags: Schema.Array(Schema.String),\n securitySchemes: Schema.Array(StaticPreviewSecuritySchemeSchema),\n authStrategies: Schema.Array(Schema.Struct({ schemes: Schema.Array(Schema.String) })),\n headerPresets: Schema.Array(\n Schema.Struct({\n label: Schema.String,\n headers: Schema.Record(Schema.String, Schema.NullOr(Schema.String)),\n secretHeaders: Schema.Array(Schema.String),\n }),\n ),\n oauth2Presets: Schema.Array(StaticPreviewOAuth2PresetSchema),\n});\ntype StaticPreviewSpecOutput = typeof StaticPreviewSpecOutputSchema.Type;\n\nconst OpenApiSpecInputSchema = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"url\"), url: Schema.String }),\n Schema.Struct({ kind: Schema.Literal(\"blob\"), value: Schema.String }),\n Schema.Struct({\n kind: Schema.Literal(\"googleDiscovery\"),\n url: Schema.String,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"googleDiscoveryBundle\"),\n urls: Schema.Array(Schema.String),\n }),\n]);\n\nconst AuthenticationSchema = Schema.Union([\n Schema.Struct({\n slug: Schema.String,\n kind: Schema.Literal(\"oauth2\"),\n authorizationUrl: Schema.String,\n tokenUrl: Schema.String,\n scopes: Schema.Array(Schema.String),\n }),\n // Credential methods are authored request-shaped — the ONE apikey input\n // dialect: `{ type: \"apiKey\", headers: { Authorization: [\"Bearer \",\n // variable(\"token\")] }, queryParams: { … } }`.\n ApiKeyAuthTemplate,\n]);\n\nconst AddSourceInputSchema = Schema.Struct({\n spec: OpenApiSpecInputSchema,\n slug: Schema.String,\n description: Schema.optional(Schema.String),\n baseUrl: 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(AuthenticationSchema)),\n});\n\nconst AddSourceOutputSchema = Schema.Struct({\n slug: Schema.String,\n toolCount: Schema.Number,\n});\n\nconst PreviewSpecInputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(PreviewSpecInputSchema),\n);\nconst PreviewSpecOutputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(StaticPreviewSpecOutputSchema),\n);\nconst AddSourceInputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(AddSourceInputSchema),\n);\nconst AddSourceOutputStandardSchema = Schema.toStandardSchemaV1(\n Schema.toStandardJSONSchemaV1(AddSourceOutputSchema),\n);\n\nconst openApiToolFailure = (code: string, message: string, details?: unknown) =>\n ToolResult.fail({\n code,\n message,\n ...(details === undefined ? {} : { details }),\n });\n\nconst openApiAuthToolFailure = (failure: {\n readonly code: string;\n readonly message: string;\n readonly owner: \"org\" | \"user\";\n readonly integration: string;\n readonly connection: string;\n readonly credentialKind: \"secret\" | \"oauth\" | \"upstream\";\n readonly credentialLabel?: string;\n readonly status?: number;\n readonly details?: unknown;\n}) =>\n authToolFailure({\n // The auth-tool-failure helper's code set is shared with v1; keep the\n // string but reference the connection rather than v1's source/slot.\n code: failure.code as Parameters<typeof authToolFailure>[0][\"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 },\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\nconst staticPreviewOutput = (preview: SpecPreview): StaticPreviewSpecOutput => ({\n title: Option.getOrNull(preview.title),\n version: Option.getOrNull(preview.version),\n servers: preview.servers.map((server) => ({\n url: server.url,\n description: Option.getOrNull(server.description),\n variables: Option.getOrNull(server.variables)\n ? Object.fromEntries(\n Object.entries(Option.getOrNull(server.variables) ?? {}).map(([name, variable]) => [\n name,\n {\n default: variable.default,\n enum: Option.getOrNull(variable.enum),\n description: Option.getOrNull(variable.description),\n },\n ]),\n )\n : null,\n })),\n operationCount: preview.operationCount,\n tags: preview.tags,\n securitySchemes: preview.securitySchemes.map((scheme) => ({\n name: scheme.name,\n type: scheme.type,\n scheme: Option.getOrNull(scheme.scheme),\n bearerFormat: Option.getOrNull(scheme.bearerFormat),\n in: Option.getOrNull(scheme.in),\n headerName: Option.getOrNull(scheme.headerName),\n description: Option.getOrNull(scheme.description),\n flows: Option.isSome(scheme.flows)\n ? {\n authorizationCode: Option.isSome(scheme.flows.value.authorizationCode)\n ? {\n authorizationUrl: scheme.flows.value.authorizationCode.value.authorizationUrl,\n tokenUrl: scheme.flows.value.authorizationCode.value.tokenUrl,\n refreshUrl: Option.getOrNull(scheme.flows.value.authorizationCode.value.refreshUrl),\n scopes: scheme.flows.value.authorizationCode.value.scopes,\n }\n : null,\n clientCredentials: Option.isSome(scheme.flows.value.clientCredentials)\n ? {\n tokenUrl: scheme.flows.value.clientCredentials.value.tokenUrl,\n refreshUrl: Option.getOrNull(scheme.flows.value.clientCredentials.value.refreshUrl),\n scopes: scheme.flows.value.clientCredentials.value.scopes,\n }\n : null,\n }\n : null,\n openIdConnectUrl: Option.getOrNull(scheme.openIdConnectUrl),\n })),\n authStrategies: preview.authStrategies,\n headerPresets: preview.headerPresets,\n oauth2Presets: preview.oauth2Presets.map((preset) => ({\n label: preset.label,\n securitySchemeName: preset.securitySchemeName,\n flow: preset.flow,\n authorizationUrl: Option.getOrNull(preset.authorizationUrl),\n tokenUrl: preset.tokenUrl,\n refreshUrl: Option.getOrNull(preset.refreshUrl),\n scopes: preset.scopes,\n identityScopes: preset.identityScopes,\n })),\n});\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Rewrite OpenAPI `#/components/schemas/X` refs to standard `#/$defs/X`. */\nconst normalizeOpenApiRefs = (node: unknown): unknown => {\n if (node == null || typeof node !== \"object\") return node;\n if (Array.isArray(node)) {\n let changed = false;\n const out = node.map((item) => {\n const n = normalizeOpenApiRefs(item);\n if (n !== item) changed = true;\n return n;\n });\n return changed ? out : node;\n }\n\n const obj = node as Record<string, unknown>;\n\n if (typeof obj.$ref === \"string\") {\n const match = obj.$ref.match(/^#\\/components\\/schemas\\/(.+)$/);\n if (match) return { ...obj, $ref: `#/$defs/${match[1]}` };\n return obj;\n }\n\n let changed = false;\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n const n = normalizeOpenApiRefs(v);\n if (n !== v) changed = true;\n result[k] = n;\n }\n return changed ? result : obj;\n};\n\nconst toBinding = (def: ToolDefinition): OperationBinding =>\n OperationBinding.make({\n method: def.operation.method,\n servers: def.operation.servers,\n pathTemplate: def.operation.pathTemplate,\n parameters: [...def.operation.parameters],\n requestBody: def.operation.requestBody,\n });\n\nconst descriptionFor = (def: ToolDefinition): string => {\n const op = def.operation;\n return Option.getOrElse(op.description, () =>\n Option.getOrElse(op.summary, () => `${op.method.toUpperCase()} ${op.pathTemplate}`),\n );\n};\n\nconst specInputToSourceUrl = (spec: OpenApiSpecInput): string | undefined =>\n spec.kind === \"url\" || spec.kind === \"googleDiscovery\" ? spec.url : undefined;\n\nconst specInputToGoogleBundle = (spec: OpenApiSpecInput): readonly string[] | undefined =>\n spec.kind === \"googleDiscoveryBundle\" ? spec.urls : undefined;\n\n// ---------------------------------------------------------------------------\n// Declared auth methods — project the stored `authenticationTemplate` into the\n// catalog's plugin-agnostic `AuthMethodDescriptor[]`. This mirrors the client's\n// `authMethodsFromConfig` (in the React auth-method-config module) on the\n// server so the catalog field is consistent. apikey/none projection comes from\n// the shared model; the oauth method carries the stored endpoints + scopes.\n// ---------------------------------------------------------------------------\n\nexport const describeOpenApiAuthMethods = (\n record: IntegrationRecord,\n): readonly AuthMethodDescriptor[] => {\n const config = decodeOpenApiIntegrationConfig(record.config);\n if (!config) return [];\n return (config.authenticationTemplate ?? []).map(\n (template: Authentication): AuthMethodDescriptor => {\n if (template.kind === \"oauth2\") {\n return {\n id: String(template.slug),\n label: \"OAuth2\",\n kind: \"oauth\",\n template: String(template.slug),\n oauth: {\n authorizationUrl: template.authorizationUrl,\n tokenUrl: template.tokenUrl,\n scopes: template.scopes,\n },\n };\n }\n return describeApiKeyAuthMethod(template);\n },\n );\n};\n\nexport const describeOpenApiIntegrationDisplay = (\n record: IntegrationRecord,\n): { readonly url?: string } => {\n const config = decodeOpenApiIntegrationConfig(record.config);\n return { url: config?.baseUrl ?? config?.sourceUrl };\n};\n\n// ---------------------------------------------------------------------------\n// Spec text resolution — the stored config carries the spec's content hash\n// (`specHash` → blob `spec/<hash>`). Pre-blob rows that inlined the text are\n// rewritten by the spec-to-blob migrations before this code reads them.\n// ---------------------------------------------------------------------------\n\nconst loadSpecText = (\n storage: OpenapiStore,\n config: OpenApiIntegrationConfig,\n): Effect.Effect<string | null, StorageFailure> =>\n config.specHash != null ? storage.getSpec(config.specHash) : Effect.succeed(null);\n\n// ---------------------------------------------------------------------------\n// Spec → tool definitions (shared by addSpec, resolveTools, and detect)\n// ---------------------------------------------------------------------------\n\ninterface CompiledSpec {\n readonly definitions: readonly ToolDefinition[];\n readonly hoistedDefs: Record<string, unknown>;\n readonly title: string | undefined;\n}\n\nconst compileSpec = (\n specText: string,\n): Effect.Effect<CompiledSpec, OpenApiParseError | OpenApiExtractionError> =>\n Effect.gen(function* () {\n const doc = yield* parse(specText);\n const result = yield* extract(doc);\n const hoistedDefs: Record<string, unknown> = {};\n if (doc.components?.schemas) {\n for (const [k, v] of Object.entries(doc.components.schemas)) {\n hoistedDefs[k] = normalizeOpenApiRefs(v);\n }\n }\n return {\n definitions: compileToolDefinitions(result.operations),\n hoistedDefs,\n title: Option.getOrUndefined(result.title),\n };\n });\n\n// A tool's name carries its structured `group.leaf` path verbatim (e.g.\n// `aliases.deleteAlias`). The address grammar\n// `tools.<integration>.<owner>.<connection>.<tool>` treats `<tool>` as the\n// trailing remainder (see parseToolAddress), so the dotted path needs no\n// flattening — it nests naturally as\n// `tools.<integration>.<owner>.<connection>.aliases.deleteAlias`, matching how\n// the sandbox `tools` proxy joins property access.\n\nconst toolDefsFromCompiled = (compiled: CompiledSpec): readonly ToolDef[] =>\n compiled.definitions.map(\n (def): ToolDef => ({\n name: ToolName.make(def.toolPath),\n description: descriptionFor(def),\n inputSchema: normalizeOpenApiRefs(Option.getOrUndefined(def.operation.inputSchema)),\n // The output schema is the upstream response body only — transport\n // status/headers live in the ToolResult `http` side channel, not the\n // payload (see the invoke handler).\n outputSchema: normalizeOpenApiRefs(Option.getOrUndefined(def.operation.outputSchema)),\n annotations: annotationsForOperation(def.operation.method, def.operation.pathTemplate),\n }),\n );\n\nconst storedOperationsFromCompiled = (\n integration: string,\n compiled: CompiledSpec,\n): readonly StoredOperation[] =>\n compiled.definitions.map((def) => ({\n integration,\n toolName: def.toolPath,\n binding: toBinding(def),\n }));\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport interface OpenApiPluginOptions {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient, never, never>;\n}\n\nconst fetchGoogleDiscoveryBundleConversion = (\n urls: readonly string[],\n httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,\n) =>\n Effect.forEach(\n urls,\n (url) =>\n fetchGoogleDiscoveryDocument(url).pipe(\n Effect.provide(httpClientLayer),\n Effect.map((documentText) => ({ discoveryUrl: url, documentText })),\n ),\n { concurrency: 4 },\n ).pipe(Effect.flatMap((documents) => convertGoogleDiscoveryBundleToOpenApi({ documents })));\n\nexport const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => {\n const resolveSpecForInput = (\n spec: OpenApiSpecInput,\n httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>,\n ): Effect.Effect<\n {\n readonly specText: string;\n readonly baseUrl?: string;\n // The Google Discovery converters derive the `googleOAuth2` oauth template\n // straight from the spec's declared scopes. `addSpec` adopts it when the\n // caller didn't pass an explicit `authenticationTemplate` (the bundle add\n // path has no preview to detect auth from).\n readonly authenticationTemplate?: readonly Authentication[];\n },\n OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError\n > =>\n Effect.gen(function* () {\n if (spec.kind === \"googleDiscovery\") {\n const conversion = yield* fetchGoogleDiscoveryDocument(spec.url).pipe(\n Effect.provide(httpClientLayer),\n Effect.flatMap((documentText) =>\n convertGoogleDiscoveryToOpenApi({\n discoveryUrl: spec.url,\n documentText,\n }),\n ),\n );\n return {\n specText: conversion.specText,\n baseUrl: conversion.baseUrl,\n ...(conversion.authenticationTemplate\n ? { authenticationTemplate: conversion.authenticationTemplate }\n : {}),\n };\n }\n if (spec.kind === \"googleDiscoveryBundle\") {\n const conversion = yield* fetchGoogleDiscoveryBundleConversion(spec.urls, httpClientLayer);\n return {\n specText: conversion.specText,\n baseUrl: conversion.baseUrl,\n ...(conversion.authenticationTemplate\n ? { authenticationTemplate: conversion.authenticationTemplate }\n : {}),\n };\n }\n if (spec.kind === \"url\") {\n const specText = yield* resolveSpecText(spec.url).pipe(Effect.provide(httpClientLayer));\n return { specText };\n }\n return { specText: spec.value };\n });\n\n return {\n id: \"openapi\" as const,\n packageName: \"@executor-js/plugin-openapi\",\n integrationPresets: openApiPresets.map((preset) => ({\n id: preset.id,\n name: preset.name,\n summary: preset.summary,\n ...(preset.url ? { url: preset.url } : {}),\n ...(preset.icon ? { icon: preset.icon } : {}),\n ...(preset.featured ? { featured: preset.featured } : {}),\n })),\n storage: (deps): OpenapiStore => makeDefaultOpenapiStore(deps),\n\n extension: (ctx: PluginCtx<OpenapiStore>) => {\n const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;\n\n const addSpec = (config: OpenApiSpecConfig) =>\n Effect.gen(function* () {\n // Resolve URL → text and parse BEFORE opening a transaction. Holding\n // `BEGIN` across a network fetch is the Hyperdrive deadlock path.\n const resolved = yield* resolveSpecForInput(config.spec, httpClientLayer);\n const compiled = yield* compileSpec(resolved.specText);\n\n // Defaults the add page derives from its preview, applied here so\n // headless callers (MCP, API) get the same integration the UI's\n // add flow would produce — see e2e/scenarios/connect-handoff.test.ts:\n // - effectiveBaseUrl: the spec's first server, used to anchor the\n // derived auth template's absolute URLs. It is NOT stored as the\n // connection baseUrl — the request host is resolved per call from\n // the operation's extracted `servers`.\n // - authenticationTemplate: the spec's declared security schemes\n // (else the Add-connection modal is a dead \"No authentication\"\n // end with nowhere to paste a credential)\n // An explicit input always wins; for auth, an explicit EMPTY array\n // means \"no auth methods\" and suppresses the derivation.\n const explicitBaseUrl = config.baseUrl ?? resolved.baseUrl;\n const needsDerivedBaseUrl = explicitBaseUrl == null;\n const needsDerivedAuth =\n config.authenticationTemplate == null && resolved.authenticationTemplate == null;\n const preview =\n needsDerivedBaseUrl || needsDerivedAuth\n ? yield* previewSpecText(resolved.specText)\n : undefined;\n const derivedBaseUrl =\n needsDerivedBaseUrl && preview ? firstBaseUrlForPreview(preview) : undefined;\n const effectiveBaseUrl = explicitBaseUrl ?? (derivedBaseUrl || undefined);\n const derivedAuthenticationTemplate =\n needsDerivedAuth && preview\n ? deriveAuthenticationTemplateFromPreview(preview, effectiveBaseUrl)\n : undefined;\n\n const slug = IntegrationSlug.make(config.slug);\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\n // tools, connections, and policies. To add more auth, update the\n // existing integration instead.\n const existing = yield* ctx.core.integrations.get(slug);\n if (existing) {\n return yield* new IntegrationAlreadyExistsError({ slug });\n }\n\n const specHash = yield* sha256Hex(resolved.specText);\n\n const integrationConfig: OpenApiIntegrationConfig = {\n specHash,\n ...(specInputToSourceUrl(config.spec) !== undefined\n ? { sourceUrl: specInputToSourceUrl(config.spec) }\n : {}),\n ...(specInputToGoogleBundle(config.spec) !== undefined\n ? { googleDiscoveryUrls: specInputToGoogleBundle(config.spec) }\n : {}),\n // baseUrl is an optional override only. The host is otherwise\n // resolved per call from the operation's `servers` (extracted from\n // the spec), so we never bake a derived base URL into the config.\n ...(config.baseUrl ? { baseUrl: config.baseUrl } : {}),\n ...(config.headers ? { headers: config.headers } : {}),\n ...(config.queryParams ? { queryParams: config.queryParams } : {}),\n // Prefer the caller's explicit template; otherwise adopt the one the\n // Google Discovery converter derived from the spec (the bundle add\n // path relies on this — it has no preview to detect auth from);\n // otherwise derive from the spec's declared security schemes.\n ...(config.authenticationTemplate\n ? {\n authenticationTemplate: normalizeOpenApiAuthInputs(config.authenticationTemplate),\n }\n : resolved.authenticationTemplate\n ? { authenticationTemplate: resolved.authenticationTemplate }\n : derivedAuthenticationTemplate && derivedAuthenticationTemplate.length > 0\n ? { authenticationTemplate: derivedAuthenticationTemplate }\n : {}),\n };\n\n // The spec blob is written OUTSIDE the transaction: it's\n // content-addressed (re-puts are idempotent) and an aborted register\n // leaves only an unreferenced blob behind — while blob backends like\n // R2 couldn't roll back with the transaction anyway.\n yield* ctx.storage.putSpec(specHash, resolved.specText);\n\n yield* ctx.transaction(\n Effect.gen(function* () {\n yield* ctx.core.integrations.register({\n slug,\n description: config.description ?? compiled.title ?? config.slug,\n config: integrationConfig satisfies OpenApiIntegrationConfig as IntegrationConfig,\n canRemove: true,\n canRefresh:\n specInputToSourceUrl(config.spec) != null ||\n specInputToGoogleBundle(config.spec) != null,\n });\n yield* ctx.storage.putOperations(\n config.slug,\n storedOperationsFromCompiled(config.slug, compiled),\n );\n }),\n );\n\n return { slug, toolCount: compiled.definitions.length };\n });\n\n return {\n previewSpec: (input: string | OpenApiPreviewInput) =>\n Effect.gen(function* () {\n const previewInput = typeof input === \"string\" ? { spec: input } : input;\n const specText = isGoogleDiscoveryUrl(previewInput.spec)\n ? yield* fetchGoogleDiscoveryDocument(previewInput.spec).pipe(\n Effect.provide(httpClientLayer),\n Effect.flatMap((documentText) =>\n convertGoogleDiscoveryToOpenApi({\n discoveryUrl: previewInput.spec,\n documentText,\n }),\n ),\n Effect.map((conversion) => conversion.specText),\n )\n : yield* resolveSpecText(previewInput.spec).pipe(Effect.provide(httpClientLayer));\n return yield* previewSpec(specText).pipe(Effect.provide(httpClientLayer));\n }),\n\n addSpec,\n\n removeSpec: (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 getIntegration: (slug: string) =>\n ctx.core.integrations.get(IntegrationSlug.make(slug)).pipe(\n Effect.map((record) =>\n record\n ? ({\n slug: record.slug,\n description: record.description,\n kind: record.kind,\n canRemove: record.canRemove,\n canRefresh: record.canRefresh,\n } as Integration)\n : null,\n ),\n ),\n\n getConfig: (slug: string): Effect.Effect<OpenApiIntegrationConfig | null, StorageFailure> =>\n ctx.core.integrations\n .get(IntegrationSlug.make(slug))\n .pipe(\n Effect.map((record) =>\n record ? decodeOpenApiIntegrationConfig(record.config) : null,\n ),\n ),\n\n configure: (\n slug: string,\n input: OpenApiConfigureInput,\n ): Effect.Effect<readonly Authentication[], 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 Authentication[];\n const current = decodeOpenApiIntegrationConfig(record.config);\n if (!current) return [] as readonly Authentication[];\n\n const incoming = normalizeOpenApiAuthInputs(input.authenticationTemplate);\n const merged =\n input.mode === \"replace\"\n ? incoming\n : mergeAuthTemplates(current.authenticationTemplate ?? [], incoming);\n\n const next: OpenApiIntegrationConfig = {\n ...current,\n authenticationTemplate: merged,\n };\n\n yield* ctx.core.integrations.update(IntegrationSlug.make(slug), {\n config: next satisfies OpenApiIntegrationConfig as IntegrationConfig,\n });\n\n return merged;\n }),\n ),\n };\n },\n\n staticSources: (self: OpenApiPluginExtension) => [\n {\n id: \"openapi\",\n kind: \"executor\",\n name: \"OpenAPI\",\n tools: [\n tool({\n name: \"previewSpec\",\n description:\n \"Preview an OpenAPI document before adding it as an integration. Call this first when the user provides a spec URL/blob so you can inspect servers, auth schemes, operation count, and tags before `addSpec`. Do not collect API keys or OAuth client secrets in chat; use the connections tools for those values.\",\n inputSchema: PreviewSpecInputStandardSchema,\n outputSchema: PreviewSpecOutputStandardSchema,\n execute: (input: typeof PreviewSpecInputSchema.Type) =>\n self.previewSpec(input).pipe(\n Effect.map((preview) => ToolResult.ok(staticPreviewOutput(preview))),\n Effect.catchTags({\n OpenApiParseError: ({ message }: OpenApiParseError) =>\n Effect.succeed(openApiToolFailure(\"openapi_parse_failed\", message)),\n OpenApiExtractionError: ({ message }: OpenApiExtractionError) =>\n Effect.succeed(openApiToolFailure(\"openapi_extraction_failed\", message)),\n OpenApiOAuthError: ({ message }: OpenApiOAuthError) =>\n Effect.succeed(openApiToolFailure(\"openapi_oauth_failed\", message)),\n }),\n ),\n }),\n tool({\n name: \"addSpec\",\n description:\n \"Add an OpenAPI integration to the catalog and persist its operations as tools. Recommended flow: call `previewSpec`, choose a `slug`, then create a connection for that integration with the user's API key or via `oauth.start`. When `baseUrl` is omitted it defaults to the spec's first server; when `authenticationTemplate` is omitted the auth methods are derived from the spec's declared security schemes (pass an explicit template to override how a credential is applied — apiKey header/query, or oauth bearer — or an empty array for no auth methods).\",\n annotations: {\n requiresApproval: true,\n approvalDescription: \"Add an OpenAPI integration\",\n },\n inputSchema: AddSourceInputStandardSchema,\n outputSchema: AddSourceOutputStandardSchema,\n execute: (input: typeof AddSourceInputSchema.Type) =>\n self\n .addSpec({\n spec: input.spec,\n slug: input.slug,\n description: input.description,\n baseUrl: input.baseUrl,\n headers: input.headers,\n queryParams: input.queryParams,\n authenticationTemplate: input.authenticationTemplate as\n | readonly AuthenticationInput[]\n | undefined,\n })\n .pipe(\n Effect.map((result) =>\n ToolResult.ok({\n slug: String(result.slug),\n toolCount: result.toolCount,\n }),\n ),\n Effect.catchTags({\n OpenApiParseError: ({ message }: OpenApiParseError) =>\n Effect.succeed(openApiToolFailure(\"openapi_parse_failed\", message)),\n OpenApiExtractionError: ({ message }: OpenApiExtractionError) =>\n Effect.succeed(openApiToolFailure(\"openapi_extraction_failed\", message)),\n OpenApiOAuthError: ({ message }: OpenApiOAuthError) =>\n Effect.succeed(openApiToolFailure(\"openapi_oauth_failed\", message)),\n IntegrationAlreadyExistsError: ({ slug }: IntegrationAlreadyExistsError) =>\n Effect.succeed(\n openApiToolFailure(\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 describeAuthMethods: describeOpenApiAuthMethods,\n describeIntegrationDisplay: describeOpenApiIntegrationDisplay,\n\n // Produce one tool per spec operation. Spec-derived, identical for every\n // connection on the integration — so `getValue` is never called here. The\n // operation bindings invokeTool needs are persisted at addSpec time; this\n // hook only shapes the per-connection ToolDefs from the spec blob the\n // catalog config points at.\n resolveTools: ({\n config,\n storage,\n }: {\n readonly integration: Integration;\n readonly config: IntegrationConfig;\n readonly storage: OpenapiStore;\n }): Effect.Effect<ResolveToolsResult, StorageFailure> =>\n Effect.gen(function* () {\n const openApiConfig = decodeOpenApiIntegrationConfig(config);\n if (!openApiConfig) return { tools: [], definitions: {} };\n const specText = yield* loadSpecText(storage, openApiConfig);\n if (specText == null) return { tools: [], definitions: {} };\n const compiled = yield* compileSpec(specText).pipe(\n Effect.catch(() => Effect.succeed(null)),\n );\n if (!compiled) return { tools: [], definitions: {} };\n return {\n tools: toolDefsFromCompiled(compiled),\n definitions: compiled.hoistedDefs,\n };\n }),\n\n invokeTool: ({\n ctx: invokeCtx,\n toolRow,\n credential,\n args,\n }: {\n readonly ctx: PluginCtx<OpenapiStore>;\n readonly toolRow: { readonly integration: string; readonly name: string };\n readonly credential: ToolInvocationCredential;\n readonly args: unknown;\n }) =>\n Effect.gen(function* () {\n const httpClientLayer = options?.httpClientLayer ?? invokeCtx.httpClientLayer;\n const integration = toolRow.integration;\n const config = decodeOpenApiIntegrationConfig(credential.config);\n\n // Resolve the operation binding from the plugin store; fall back to\n // re-deriving it from the spec blob when the store has no row (e.g. an\n // integration registered without going through addSpec). The fallback\n // is the ONLY invoke-path spec read — the hot path never loads it.\n let binding = (yield* invokeCtx.storage.getOperation(integration, toolRow.name))?.binding;\n if (!binding && config) {\n const specText = yield* loadSpecText(invokeCtx.storage, config).pipe(\n Effect.catch(() => Effect.succeed(null)),\n );\n const compiled =\n specText == null\n ? null\n : yield* compileSpec(specText).pipe(Effect.catch(() => Effect.succeed(null)));\n binding = compiled\n ? storedOperationsFromCompiled(integration, compiled).find(\n (op) => op.toolName === toolRow.name,\n )?.binding\n : undefined;\n }\n if (!binding) {\n return yield* new OpenApiExtractionError({\n message: `No OpenAPI operation found for tool \"${toolRow.name}\" on \"${integration}\"`,\n });\n }\n\n const headers: Record<string, string> = { ...(config?.headers ?? {}) };\n const queryParams: Record<string, string> = {\n ...(config?.queryParams ?? {}),\n };\n\n // Apply the auth template (D11): render the connection's resolved inputs\n // into the matching template's header/query slots (apiKey) or as a bearer\n // Authorization header (oauth). A method with two distinct inputs (e.g.\n // Datadog) renders each from its own value.\n const template = (config?.authenticationTemplate ?? []).find(\n (entry) => String(entry.slug) === String(credential.template),\n );\n if (template) {\n // Fail if ANY input the template requires is unresolved — not just the\n // primary `token` (a Datadog connection has no `token`, only its keys).\n const missing = requiredTemplateVariables(template).filter((name) => {\n const value = credential.values[name];\n return value == null || value === \"\";\n });\n if (missing.length > 0) {\n return openApiAuthToolFailure({\n code:\n template.kind === \"oauth2\"\n ? \"oauth_connection_missing\"\n : \"connection_value_missing\",\n message: `Connection \"${credential.connection}\" for \"${integration}\" has no resolvable credential value. Re-authenticate or update the connection.`,\n owner: credential.owner,\n integration,\n connection: String(credential.connection),\n credentialKind: template.kind === \"oauth2\" ? \"oauth\" : \"secret\",\n });\n }\n const rendered = renderAuthTemplate(template, credential.values);\n Object.assign(headers, rendered.headers);\n Object.assign(queryParams, rendered.queryParams);\n }\n\n const result = yield* invokeWithLayer(\n binding,\n (args ?? {}) as Record<string, unknown>,\n config?.baseUrl ?? \"\",\n headers,\n queryParams,\n httpClientLayer,\n );\n\n const ok = result.status >= 200 && result.status < 300;\n if (!ok) {\n if (result.status === 401 || result.status === 403) {\n return openApiAuthToolFailure({\n code: \"connection_rejected\",\n status: result.status,\n message: `Upstream rejected credentials for \"${integration}\" with HTTP ${result.status}. Re-authenticate or update the connection \"${credential.connection}\" before retrying this tool.`,\n owner: credential.owner,\n integration,\n connection: String(credential.connection),\n credentialKind: \"upstream\",\n credentialLabel: \"Upstream authorization\",\n details: result.error,\n });\n }\n return ToolResult.fail({\n code: \"upstream_http_error\",\n status: result.status,\n message: extractUpstreamMessage(result.error, result.status),\n details: result.error,\n });\n }\n // Payload-first: `data` is the upstream response body (matching the\n // graphql/mcp plugins); transport facts ride in the `http` side\n // channel so pagination/rate-limit headers stay reachable.\n return ToolResult.ok(result.data, {\n http: { status: result.status, headers: result.headers },\n });\n }),\n\n resolveAnnotations: ({\n ctx: annotationsCtx,\n integration,\n toolRows,\n }: {\n readonly ctx: PluginCtx<OpenapiStore>;\n readonly integration: string;\n readonly toolRows: readonly { readonly name: string }[];\n }) =>\n Effect.gen(function* () {\n const ops = yield* annotationsCtx.storage.listOperations(String(integration));\n const byName = new Map<string, OperationBinding>();\n for (const op of ops) byName.set(op.toolName, op.binding);\n const out: Record<string, ReturnType<typeof annotationsForOperation>> = {};\n for (const row of toolRows) {\n const binding = byName.get(row.name);\n if (binding) {\n out[row.name] = annotationsForOperation(binding.method, binding.pathTemplate);\n }\n }\n return out;\n }),\n\n removeConnection: () => Effect.void,\n\n detect: ({\n ctx: detectCtx,\n url,\n }: {\n readonly ctx: PluginCtx<OpenapiStore>;\n readonly url: string;\n }) =>\n Effect.gen(function* () {\n const httpClientLayer = options?.httpClientLayer ?? detectCtx.httpClientLayer;\n const trimmed = url.trim();\n if (!trimmed) return null;\n const parsed = yield* Effect.try({\n try: () => new URL(trimmed),\n catch: (error) => error,\n }).pipe(Effect.option);\n if (Option.isNone(parsed)) return null;\n if (isGoogleDiscoveryUrl(trimmed)) {\n const conversion = yield* fetchGoogleDiscoveryDocument(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.flatMap((documentText) =>\n convertGoogleDiscoveryToOpenApi({\n discoveryUrl: trimmed,\n documentText,\n }),\n ),\n Effect.catch(() => Effect.succeed(null)),\n );\n if (conversion) {\n return IntegrationDetectionResult.make({\n kind: \"openapi\",\n confidence: \"high\",\n endpoint: trimmed,\n name: conversion.title,\n slug:\n conversion.title\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\") || `google_${conversion.service}`,\n });\n }\n }\n const specText = yield* resolveSpecText(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.catch(() => Effect.succeed(null)),\n );\n if (specText === null) return null;\n const doc = yield* parse(specText).pipe(Effect.catch(() => Effect.succeed(null)));\n if (!doc) return null;\n const result = yield* extract(doc).pipe(Effect.catch(() => Effect.succeed(null)));\n if (!result) return null;\n const slug = Option.getOrElse(result.title, () => \"api\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\");\n const name = Option.getOrElse(result.title, () => slug);\n return IntegrationDetectionResult.make({\n kind: \"openapi\",\n confidence: \"high\",\n endpoint: trimmed,\n name,\n slug,\n });\n }),\n };\n // HTTP transport (routes/handlers/extensionService) is layered on by\n // the api-aware factory in `@executor-js/plugin-openapi/api`. Hosts that\n // want the HTTP surface import the plugin from there; SDK-only consumers\n // stay on this entry and avoid the server-only deps.\n});\n","/**\n * Derives structured `group.leaf` tool paths from extracted OpenAPI operations.\n *\n * Ported from the v3 executor's `definitions.ts`. Turns flat operation IDs like\n * `zones_listZones` into nested paths like `zones.listZones` that the tree UI\n * can render with proper nesting.\n */\n\nimport { Option } from \"effect\";\n\nimport type { ExtractedOperation } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Word / case utilities\n// ---------------------------------------------------------------------------\n\nconst splitWords = (value: string): string[] =>\n value\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, \"$1 $2\")\n .replace(/[^a-zA-Z0-9]+/g, \" \")\n .trim()\n .split(/\\s+/)\n .filter((part) => part.length > 0);\n\nconst normalizeWord = (value: string): string => value.toLowerCase();\n\nconst toCamelCase = (value: string): string => {\n const words = splitWords(value).map(normalizeWord);\n if (words.length === 0) return \"tool\";\n const [first, ...rest] = words;\n return `${first}${rest.map((p) => `${p[0]?.toUpperCase() ?? \"\"}${p.slice(1)}`).join(\"\")}`;\n};\n\nconst toPascalCase = (value: string): string => {\n const camel = toCamelCase(value);\n return `${camel[0]?.toUpperCase() ?? \"\"}${camel.slice(1)}`;\n};\n\n// ---------------------------------------------------------------------------\n// Path utilities\n// ---------------------------------------------------------------------------\n\nconst VERSION_SEGMENT_REGEX = /^v\\d+(?:[._-]\\d+)?$/i;\nconst IGNORED_PATH_SEGMENTS = new Set([\"api\"]);\n\nconst pathSegmentsFromTemplate = (pathTemplate: string): string[] =>\n pathTemplate\n .split(\"/\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n\nconst isPathParameterSegment = (segment: string): boolean =>\n segment.startsWith(\"{\") && segment.endsWith(\"}\");\n\nconst normalizeGroupSegment = (value: string | undefined): string | null => {\n const candidate = value?.trim();\n if (!candidate) return null;\n return toCamelCase(candidate);\n};\n\n// ---------------------------------------------------------------------------\n// Derivation\n// ---------------------------------------------------------------------------\n\nconst deriveVersionSegment = (pathTemplate: string): string | undefined =>\n pathSegmentsFromTemplate(pathTemplate)\n .map((s) => s.toLowerCase())\n .find((s) => VERSION_SEGMENT_REGEX.test(s));\n\nconst derivePathGroup = (pathTemplate: string): string => {\n for (const segment of pathSegmentsFromTemplate(pathTemplate)) {\n const lower = segment.toLowerCase();\n if (VERSION_SEGMENT_REGEX.test(lower)) continue;\n if (IGNORED_PATH_SEGMENTS.has(lower)) continue;\n if (isPathParameterSegment(segment)) continue;\n return normalizeGroupSegment(segment) ?? \"root\";\n }\n return \"root\";\n};\n\nconst splitOperationIdSegments = (value: string): string[] =>\n value\n .split(/[/.]+/)\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n\nconst deriveLeafSeed = (operationId: string, group: string): string => {\n const segments = splitOperationIdSegments(operationId);\n if (segments.length > 1) {\n const [first, ...rest] = segments;\n if ((normalizeGroupSegment(first) ?? first) === group && rest.length > 0) {\n return rest.join(\" \");\n }\n }\n return operationId;\n};\n\nconst fallbackLeafSeed = (method: string, pathTemplate: string, group: string): string => {\n const relevantSegments = pathSegmentsFromTemplate(pathTemplate)\n .filter((s) => !VERSION_SEGMENT_REGEX.test(s.toLowerCase()))\n .filter((s) => !IGNORED_PATH_SEGMENTS.has(s.toLowerCase()))\n .filter((s) => !isPathParameterSegment(s))\n .map((s) => normalizeGroupSegment(s) ?? s)\n .filter((s) => s !== group);\n\n const segmentSuffix = relevantSegments.map((s) => toPascalCase(s)).join(\"\");\n return `${method}${segmentSuffix || \"Operation\"}`;\n};\n\nconst deriveLeaf = (\n operationId: string,\n method: string,\n pathTemplate: string,\n group: string,\n): string => {\n const preferred = toCamelCase(deriveLeafSeed(operationId, group));\n if (preferred.length > 0 && preferred !== group) return preferred;\n return toCamelCase(fallbackLeafSeed(method, pathTemplate, group));\n};\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface ToolDefinition {\n /** Dot-separated path like `zones.listZones` */\n readonly toolPath: string;\n /** The group segment */\n readonly group: string;\n /** The leaf segment */\n readonly leaf: string;\n /** Index into the original operations array */\n readonly operationIndex: number;\n /** The original operation */\n readonly operation: ExtractedOperation;\n}\n\n// ---------------------------------------------------------------------------\n// Collision resolution\n// ---------------------------------------------------------------------------\n\nconst resolveCollisions = (\n definitions: {\n toolPath: string;\n group: string;\n leaf: string;\n versionSegment: string | undefined;\n method: string;\n operationHash: string;\n operationIndex: number;\n operation: ExtractedOperation;\n }[],\n): ToolDefinition[] => {\n // Mutable — we progressively refine toolPath on collision\n const staged = definitions.map((d) => ({ ...d }));\n\n const applyFactory = (items: typeof staged, factory: (d: (typeof staged)[number]) => string) => {\n const byPath = new Map<string, typeof staged>();\n for (const item of items) {\n const bucket = byPath.get(item.toolPath) ?? [];\n bucket.push(item);\n byPath.set(item.toolPath, bucket);\n }\n for (const bucket of byPath.values()) {\n if (bucket.length < 2) continue;\n for (const d of bucket) {\n d.toolPath = factory(d);\n }\n }\n };\n\n // Round 1: add version segment\n applyFactory(staged, (d) =>\n d.versionSegment ? `${d.group}.${d.versionSegment}.${d.leaf}` : d.toolPath,\n );\n\n // Round 2: add method suffix\n applyFactory(staged, (d) => {\n const prefix = d.versionSegment ? `${d.group}.${d.versionSegment}` : d.group;\n return `${prefix}.${d.leaf}${toPascalCase(d.method)}`;\n });\n\n // Round 3: add hash suffix\n applyFactory(staged, (d) => {\n const prefix = d.versionSegment ? `${d.group}.${d.versionSegment}` : d.group;\n return `${prefix}.${d.leaf}${toPascalCase(d.method)}${d.operationHash.slice(0, 8)}`;\n });\n\n return staged.map((d) => ({\n toolPath: d.toolPath,\n group: d.group,\n leaf: d.leaf,\n operationIndex: d.operationIndex,\n operation: d.operation,\n }));\n};\n\n// ---------------------------------------------------------------------------\n// Stable hash (simple, deterministic)\n// ---------------------------------------------------------------------------\n\nconst stableHash = (value: unknown): string => {\n const str = JSON.stringify(value, Object.keys(value as Record<string, unknown>).sort());\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0;\n }\n return Math.abs(hash).toString(36).padStart(8, \"0\");\n};\n\n// ---------------------------------------------------------------------------\n// Main entry point\n// ---------------------------------------------------------------------------\n\n/**\n * Compile extracted operations into tool definitions with structured\n * `group.leaf` paths suitable for tree rendering.\n */\nexport const compileToolDefinitions = (\n operations: readonly ExtractedOperation[],\n): ToolDefinition[] => {\n const raw = operations.map((op, index) => {\n const operationId = op.operationId;\n const explicitToolPath = Option.getOrUndefined(op.toolPath);\n if (explicitToolPath) {\n const [group = \"root\", ...leafParts] = explicitToolPath.split(\".\").filter(Boolean);\n const leaf = leafParts.join(\".\") || group;\n const versionSegment = deriveVersionSegment(op.pathTemplate);\n const operationHash = stableHash({\n method: op.method,\n path: op.pathTemplate,\n operationId,\n });\n\n return {\n toolPath: explicitToolPath,\n group,\n leaf,\n versionSegment,\n method: op.method,\n operationHash,\n operationIndex: index,\n operation: op,\n };\n }\n\n const group = normalizeGroupSegment(op.tags[0]) ?? derivePathGroup(op.pathTemplate);\n const leaf = deriveLeaf(operationId, op.method, op.pathTemplate, group);\n const versionSegment = deriveVersionSegment(op.pathTemplate);\n const operationHash = stableHash({\n method: op.method,\n path: op.pathTemplate,\n operationId,\n });\n\n return {\n toolPath: `${group}.${leaf}`,\n group,\n leaf,\n versionSegment,\n method: op.method,\n operationHash,\n operationIndex: index,\n operation: op,\n };\n });\n\n return resolveCollisions(raw).sort((a, b) => a.toolPath.localeCompare(b.toolPath));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,cAAc;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAuBP,IAAM,4BAA4B,OAAO,OAAO;AAAA,EAC9C,MAAM,OAAO;AAAA,EACb,MAAM,OAAO,QAAQ,QAAQ;AAAA,EAC7B,kBAAkB,OAAO;AAAA,EACzB,UAAU,OAAO;AAAA,EACjB,QAAQ,OAAO,MAAM,OAAO,MAAM;AACpC,CAAC;AAEM,IAAM,uBAAuB,OAAO,MAAM,CAAC,2BAA2B,gBAAgB,CAAC;AAEvF,IAAM,iCAAiC,OAAO,OAAO;AAAA;AAAA;AAAA,EAG1D,UAAU,OAAO,SAAS,OAAO,MAAM;AAAA;AAAA,EAEvC,WAAW,OAAO,SAAS,OAAO,MAAM;AAAA;AAAA,EAExC,qBAAqB,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;AAAA;AAAA,EAEhE,SAAS,OAAO,SAAS,OAAO,MAAM;AAAA;AAAA,EAEtC,SAAS,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;AAAA;AAAA,EAEpE,aAAa,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;AAAA;AAAA,EAExE,wBAAwB,OAAO,SAAS,OAAO,MAAM,oBAAoB,CAAC;AAC5E,CAAC;AAWD,IAAM,eAAe,OAAO,oBAAoB,8BAA8B;AAIvE,IAAM,iC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AC;AAAA,QACH;AAAA,MACF;AACA,YAAM,WAAW,OAAO,gBAAgB,OAAO,EAAE;AAAA,QAC/CA,QAAO,QAAQ,eAAe;AAAA,QAC9BA,QAAO,MAAM,MAAMA,QAAO,QAAQ,IAAI,CAAC;AAAA,MACzC;AACA,UAAI,aAAa,KAAM,QAAO;AAC9B,YAAM,MAAM,OAAO,MAAM,QAAQ,EAAE,KAAKA,QAAO,MAAM,MAAMA,QAAO,QAAQ,IAAI,CAAC,CAAC;AAChF,UAAI,CAAC,IAAK,QAAO;AACjB,YAAM,SAAS,OAAO,QAAQ,GAAG,EAAE,KAAKA,QAAO,MAAM,MAAMA,QAAO,QAAQ,IAAI,CAAC,CAAC;AAChF,UAAI,CAAC,OAAQ,QAAO;AACpB,YAAM,OAAOJ,QAAO,UAAU,OAAO,OAAO,MAAM,KAAK,EACpD,YAAY,EACZ,QAAQ,eAAe,GAAG;AAC7B,YAAM,OAAOA,QAAO,UAAU,OAAO,OAAO,MAAM,IAAI;AACtD,aAAO,2BAA2B,KAAK;AAAA,QACrC,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,UAAU;AAAA,QACV;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACL;AAKF,CAAC;","names":["Option","Option","bytes","Effect","Option","Schema","Schema","Option","Effect","Effect","Option","Schema","Option","group","leaf","versionSegment","operationHash","Schema","Option","message","AuthenticationSchema","changed","Effect"]}
|
package/dist/client.js
CHANGED
|
@@ -8,9 +8,9 @@ import { defineClientPlugin } from "@executor-js/sdk/client";
|
|
|
8
8
|
|
|
9
9
|
// src/react/source-plugin.ts
|
|
10
10
|
import { lazy } from "react";
|
|
11
|
-
var importAdd = () => import("./AddOpenApiSource-
|
|
12
|
-
var importEdit = () => import("./EditOpenApiSource-
|
|
13
|
-
var importAccounts = () => import("./OpenApiAccountsPanel-
|
|
11
|
+
var importAdd = () => import("./AddOpenApiSource-7O4LSD7C.js");
|
|
12
|
+
var importEdit = () => import("./EditOpenApiSource-GIN5RQPL.js");
|
|
13
|
+
var importAccounts = () => import("./OpenApiAccountsPanel-7XT6ZMD5.js");
|
|
14
14
|
var openApiIntegrationPlugin = {
|
|
15
15
|
key: "openapi",
|
|
16
16
|
label: "OpenAPI",
|
package/dist/core.js
CHANGED
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
makeDefaultOpenapiStore,
|
|
9
9
|
openApiPlugin,
|
|
10
10
|
renderAuthTemplate
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WJQIWTZF.js";
|
|
12
12
|
import {
|
|
13
13
|
convertGoogleDiscoveryBundleToOpenApi,
|
|
14
14
|
convertGoogleDiscoveryToOpenApi,
|
|
15
15
|
fetchGoogleDiscoveryDocument,
|
|
16
16
|
isGoogleDiscoveryUrl
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-C6PH4R7Q.js";
|
|
18
18
|
import "./chunk-AQ7JDDRM.js";
|
|
19
19
|
import "./chunk-MZWZQ24W.js";
|
|
20
20
|
import {
|
|
@@ -46,16 +46,135 @@ import {
|
|
|
46
46
|
ServerInfo,
|
|
47
47
|
ServerVariable,
|
|
48
48
|
SpecPreview,
|
|
49
|
+
TOKEN_VARIABLE,
|
|
49
50
|
extract,
|
|
50
51
|
fetchSpecText,
|
|
52
|
+
normalizeOpenApiAuthInputs,
|
|
51
53
|
parse,
|
|
52
54
|
preferredContent,
|
|
53
55
|
previewSpec,
|
|
54
|
-
|
|
56
|
+
resolveServerUrl,
|
|
55
57
|
resolveSpecText,
|
|
56
|
-
substituteUrlVariables
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
substituteUrlVariables
|
|
59
|
+
} from "./chunk-C3IJX4AN.js";
|
|
60
|
+
|
|
61
|
+
// src/sdk/index.ts
|
|
62
|
+
import { variable } from "@executor-js/sdk/http-auth";
|
|
63
|
+
|
|
64
|
+
// src/sdk/migrate-config.ts
|
|
65
|
+
import { Option } from "effect";
|
|
66
|
+
import {
|
|
67
|
+
apiKeyMethodFromLegacyTemplate,
|
|
68
|
+
decodeLegacyApiKeyTemplate
|
|
69
|
+
} from "@executor-js/sdk/http-auth";
|
|
70
|
+
var isCanonicalEntry = (entry) => typeof entry === "object" && entry !== null && "kind" in entry && (entry.kind === "apikey" || entry.kind === "oauth2");
|
|
71
|
+
var isLegacyOAuthEntry = (entry) => typeof entry === "object" && entry !== null && "type" in entry && entry.type === "oauth";
|
|
72
|
+
var migrateEntry = (entry) => {
|
|
73
|
+
if (isCanonicalEntry(entry)) return entry;
|
|
74
|
+
if (isLegacyOAuthEntry(entry)) {
|
|
75
|
+
const { type: _type, ...rest } = entry;
|
|
76
|
+
return { ...rest, kind: "oauth2" };
|
|
77
|
+
}
|
|
78
|
+
const legacy = Option.getOrNull(decodeLegacyApiKeyTemplate(entry));
|
|
79
|
+
if (legacy !== null) return apiKeyMethodFromLegacyTemplate(legacy);
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
var migrateOpenApiAuthConfig = (config) => {
|
|
83
|
+
if (typeof config !== "object" || config === null) return null;
|
|
84
|
+
if (!("spec" in config) && !("specHash" in config)) return null;
|
|
85
|
+
if (!("authenticationTemplate" in config)) return null;
|
|
86
|
+
const entries = config.authenticationTemplate;
|
|
87
|
+
if (!Array.isArray(entries)) return null;
|
|
88
|
+
const migrated = entries.map(migrateEntry);
|
|
89
|
+
if (migrated.some((entry) => entry === null)) return null;
|
|
90
|
+
const changed = migrated.some((entry, index) => entry !== entries[index]);
|
|
91
|
+
if (!changed) return null;
|
|
92
|
+
const next = { ...config, authenticationTemplate: migrated };
|
|
93
|
+
return decodeOpenApiIntegrationConfig(next) !== null ? next : null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/sdk/output-schema-migration.ts
|
|
97
|
+
import { Effect, Option as Option2, Schema } from "effect";
|
|
98
|
+
import { DataMigrationError } from "@executor-js/sdk/core";
|
|
99
|
+
var MIGRATION_NAME = "2026-06-11-openapi-output-envelope-unwrap";
|
|
100
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
101
|
+
var isEnvelopeStatusSchema = (value) => isRecord(value) && Object.keys(value).length === 1 && value.type === "integer";
|
|
102
|
+
var isEnvelopeHeadersSchema = (value) => isRecord(value) && Object.keys(value).length === 2 && value.type === "object" && isRecord(value.additionalProperties) && Object.keys(value.additionalProperties).length === 1 && value.additionalProperties.type === "string";
|
|
103
|
+
var unwrapOpenApiTransportEnvelope = (schema) => {
|
|
104
|
+
if (!isRecord(schema)) return void 0;
|
|
105
|
+
if (schema.type !== "object" || schema.additionalProperties !== false) return void 0;
|
|
106
|
+
const required = schema.required;
|
|
107
|
+
if (!Array.isArray(required) || required.length !== 3) return void 0;
|
|
108
|
+
if (!["status", "headers", "data"].every((key) => required.includes(key))) return void 0;
|
|
109
|
+
const properties = schema.properties;
|
|
110
|
+
if (!isRecord(properties) || !("data" in properties)) return void 0;
|
|
111
|
+
if (!isEnvelopeStatusSchema(properties.status)) return void 0;
|
|
112
|
+
if (!isEnvelopeHeadersSchema(properties.headers)) return void 0;
|
|
113
|
+
const data = properties.data;
|
|
114
|
+
const outputSchema = isRecord(data) && Object.keys(data).length === 0 ? null : data;
|
|
115
|
+
return { outputSchema };
|
|
116
|
+
};
|
|
117
|
+
var decodeJsonOption = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);
|
|
118
|
+
var execute = (client, stmt) => Effect.tryPromise({
|
|
119
|
+
try: () => client.execute(stmt),
|
|
120
|
+
catch: (cause) => new DataMigrationError({ migration: MIGRATION_NAME, cause })
|
|
121
|
+
});
|
|
122
|
+
var runSqliteOpenApiOutputSchemaMigration = (client) => Effect.gen(function* () {
|
|
123
|
+
const exists = yield* execute(
|
|
124
|
+
client,
|
|
125
|
+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'tool'"
|
|
126
|
+
);
|
|
127
|
+
if (exists.rows.length === 0) return 0;
|
|
128
|
+
const result = yield* execute(
|
|
129
|
+
client,
|
|
130
|
+
"SELECT row_id, output_schema FROM tool WHERE plugin_id = 'openapi' AND output_schema IS NOT NULL"
|
|
131
|
+
);
|
|
132
|
+
const updates = [];
|
|
133
|
+
for (const row of result.rows) {
|
|
134
|
+
if (typeof row.row_id !== "string" || typeof row.output_schema !== "string") continue;
|
|
135
|
+
const schema = decodeJsonOption(row.output_schema);
|
|
136
|
+
if (Option2.isNone(schema)) continue;
|
|
137
|
+
const unwrapped = unwrapOpenApiTransportEnvelope(schema.value);
|
|
138
|
+
if (unwrapped !== void 0) updates.push({ rowId: row.row_id, ...unwrapped });
|
|
139
|
+
}
|
|
140
|
+
if (updates.length === 0) return 0;
|
|
141
|
+
const applyAll = Effect.gen(function* () {
|
|
142
|
+
for (const update of updates) {
|
|
143
|
+
yield* execute(client, {
|
|
144
|
+
sql: "UPDATE tool SET output_schema = ? WHERE row_id = ?",
|
|
145
|
+
args: [
|
|
146
|
+
update.outputSchema === null ? null : JSON.stringify(update.outputSchema),
|
|
147
|
+
update.rowId
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
yield* execute(client, "COMMIT");
|
|
152
|
+
});
|
|
153
|
+
yield* execute(client, "BEGIN");
|
|
154
|
+
yield* applyAll.pipe(Effect.tapError(() => execute(client, "ROLLBACK").pipe(Effect.ignore)));
|
|
155
|
+
return updates.length;
|
|
156
|
+
});
|
|
157
|
+
var openApiOutputSchemaDataMigration = {
|
|
158
|
+
name: MIGRATION_NAME,
|
|
159
|
+
run: (client) => runSqliteOpenApiOutputSchemaMigration(client).pipe(Effect.asVoid)
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// src/sdk/spec-blob-migration.ts
|
|
163
|
+
import { Effect as Effect2 } from "effect";
|
|
164
|
+
import {
|
|
165
|
+
runSqliteConfigBlobMigration
|
|
166
|
+
} from "@executor-js/sdk/core";
|
|
167
|
+
var MIGRATION_NAME2 = "2026-06-12-openapi-spec-to-blob";
|
|
168
|
+
var openApiSpecBlobDataMigration = {
|
|
169
|
+
name: MIGRATION_NAME2,
|
|
170
|
+
run: (client) => runSqliteConfigBlobMigration(client, {
|
|
171
|
+
migrationName: MIGRATION_NAME2,
|
|
172
|
+
pluginId: "openapi",
|
|
173
|
+
inlineField: "spec",
|
|
174
|
+
hashField: "specHash",
|
|
175
|
+
blobKeyPrefix: "spec"
|
|
176
|
+
}).pipe(Effect2.asVoid)
|
|
177
|
+
};
|
|
59
178
|
export {
|
|
60
179
|
AuthStrategy,
|
|
61
180
|
AuthenticationSchema,
|
|
@@ -87,6 +206,7 @@ export {
|
|
|
87
206
|
ServerInfo,
|
|
88
207
|
ServerVariable,
|
|
89
208
|
SpecPreview,
|
|
209
|
+
TOKEN_VARIABLE,
|
|
90
210
|
annotationsForOperation,
|
|
91
211
|
convertGoogleDiscoveryBundleToOpenApi,
|
|
92
212
|
convertGoogleDiscoveryToOpenApi,
|
|
@@ -98,14 +218,20 @@ export {
|
|
|
98
218
|
invokeWithLayer,
|
|
99
219
|
isGoogleDiscoveryUrl,
|
|
100
220
|
makeDefaultOpenapiStore,
|
|
221
|
+
migrateOpenApiAuthConfig,
|
|
222
|
+
normalizeOpenApiAuthInputs,
|
|
223
|
+
openApiOutputSchemaDataMigration,
|
|
101
224
|
openApiPlugin,
|
|
225
|
+
openApiSpecBlobDataMigration,
|
|
102
226
|
parse,
|
|
103
227
|
preferredContent,
|
|
104
228
|
previewSpec,
|
|
105
229
|
renderAuthTemplate,
|
|
106
|
-
|
|
230
|
+
resolveServerUrl,
|
|
107
231
|
resolveSpecText,
|
|
232
|
+
runSqliteOpenApiOutputSchemaMigration,
|
|
108
233
|
substituteUrlVariables,
|
|
234
|
+
unwrapOpenApiTransportEnvelope,
|
|
109
235
|
variable
|
|
110
236
|
};
|
|
111
237
|
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/sdk/index.ts","../src/sdk/migrate-config.ts","../src/sdk/output-schema-migration.ts","../src/sdk/spec-blob-migration.ts"],"sourcesContent":["export { parse, resolveSpecText, fetchSpecText } from \"./parse\";\nexport {\n convertGoogleDiscoveryBundleToOpenApi,\n convertGoogleDiscoveryToOpenApi,\n fetchGoogleDiscoveryDocument,\n isGoogleDiscoveryUrl,\n type GoogleDiscoveryOpenApiConversion,\n} from \"./google-discovery\";\nexport { extract } from \"./extract\";\nexport { invoke, invokeWithLayer, annotationsForOperation } from \"./invoke\";\nexport {\n openApiPlugin,\n type OpenApiSpecConfig,\n type OpenApiConfigureInput,\n type OpenApiSpecInput,\n type OpenApiPreviewInput,\n type OpenApiPluginExtension,\n type OpenApiPluginOptions,\n} from \"./plugin\";\nexport { type OpenapiStore, type StoredOperation, makeDefaultOpenapiStore } from \"./store\";\nexport {\n decodeOpenApiIntegrationConfig,\n renderAuthTemplate,\n AuthenticationSchema,\n OpenApiIntegrationConfigSchema,\n type OpenApiIntegrationConfig,\n type RenderedAuth,\n} from \"./config\";\nexport {\n previewSpec,\n SecurityScheme,\n AuthStrategy,\n HeaderPreset,\n OAuth2Preset,\n OAuth2Flows,\n OAuth2AuthorizationCodeFlow,\n OAuth2ClientCredentialsFlow,\n PreviewOperation,\n SpecPreview,\n} from \"./preview\";\nexport {\n DocResolver,\n resolveServerUrl,\n substituteUrlVariables,\n preferredContent,\n} from \"./openapi-utils\";\n\nexport {\n OpenApiParseError,\n OpenApiExtractionError,\n OpenApiInvocationError,\n OpenApiOAuthError,\n OpenApiAuthRequiredError,\n} from \"./errors\";\n\nexport {\n EncodingObject,\n ExtractedOperation,\n ExtractionResult,\n InvocationResult,\n MediaBinding,\n OperationBinding,\n OperationParameter,\n OperationRequestBody,\n ServerInfo,\n ServerVariable,\n OperationId,\n HttpMethod,\n ParameterLocation,\n TOKEN_VARIABLE,\n normalizeOpenApiAuthInputs,\n type Authentication,\n type AuthenticationInput,\n type APIKeyAuthentication,\n} from \"./types\";\n// Request-shaped authoring: `headers: { Authorization: [\"Bearer \", variable(\"token\")] }`.\nexport { variable, type ApiKeyAuthTemplate } from \"@executor-js/sdk/http-auth\";\n\nexport { migrateOpenApiAuthConfig } from \"./migrate-config\";\n\nexport {\n openApiOutputSchemaDataMigration,\n runSqliteOpenApiOutputSchemaMigration,\n unwrapOpenApiTransportEnvelope,\n} from \"./output-schema-migration\";\n\nexport { openApiSpecBlobDataMigration } from \"./spec-blob-migration\";\n","// ---------------------------------------------------------------------------\n// One-off config migration — rewrite pre-canonical OpenAPI integration\n// `config` blobs into the canonical placements model. Runs once per database\n// (boot for local/selfhost, out-of-band script for cloud); runtime code\n// decodes ONLY the canonical shape (`decodeOpenApiIntegrationConfig`).\n//\n// The retired shape is the `variable()`-templated apiKey:\n// { slug, type: \"apiKey\", headers/queryParams: Record<name,\n// string | (string | {type:\"variable\", name})[]> }\n// Each entry becomes one placement: prefix = literals before the first\n// variable, the variable name preserved VERBATIM (it keys the connections'\n// stored `item_ids`; the canonical `token` is stored as absent), a\n// literal-only value becomes a `literal` placement. OAuth templates\n// re-key from the retired `type: \"oauth\"` spelling to `kind: \"oauth2\"`.\n// ---------------------------------------------------------------------------\n\nimport { Option } from \"effect\";\nimport {\n apiKeyMethodFromLegacyTemplate,\n decodeLegacyApiKeyTemplate,\n} from \"@executor-js/sdk/http-auth\";\n\nimport { decodeOpenApiIntegrationConfig } from \"./config\";\n\nconst isCanonicalEntry = (entry: unknown): boolean =>\n typeof entry === \"object\" &&\n entry !== null &&\n \"kind\" in entry &&\n ((entry as { kind: unknown }).kind === \"apikey\" ||\n (entry as { kind: unknown }).kind === \"oauth2\");\n\n/** The retired oauth spelling: `type: \"oauth\"` instead of `kind: \"oauth2\"`. */\nconst isLegacyOAuthEntry = (\n entry: unknown,\n): entry is { readonly type: \"oauth\" } & Record<string, unknown> =>\n typeof entry === \"object\" &&\n entry !== null &&\n \"type\" in entry &&\n (entry as { type: unknown }).type === \"oauth\";\n\nconst migrateEntry = (entry: unknown): unknown | null => {\n if (isCanonicalEntry(entry)) return entry;\n if (isLegacyOAuthEntry(entry)) {\n const { type: _type, ...rest } = entry;\n return { ...rest, kind: \"oauth2\" };\n }\n const legacy = Option.getOrNull(decodeLegacyApiKeyTemplate(entry));\n if (legacy !== null) return apiKeyMethodFromLegacyTemplate(legacy);\n return null;\n};\n\n/** Rewrite a stored OpenAPI integration config blob into the canonical shape.\n * Returns the rewritten config, or `null` when no rewrite is needed (already\n * canonical, no auth templates, or not this plugin's shape). Idempotent. */\nexport const migrateOpenApiAuthConfig = (config: unknown): unknown | null => {\n if (typeof config !== \"object\" || config === null) return null;\n if (!(\"spec\" in config) && !(\"specHash\" in config)) return null;\n if (!(\"authenticationTemplate\" in config)) return null;\n\n const entries = (config as { authenticationTemplate: unknown }).authenticationTemplate;\n if (!Array.isArray(entries)) return null;\n\n const migrated = entries.map(migrateEntry);\n if (migrated.some((entry) => entry === null)) return null;\n const changed = migrated.some((entry, index) => entry !== entries[index]);\n if (!changed) return null;\n\n const next = { ...config, authenticationTemplate: migrated };\n return decodeOpenApiIntegrationConfig(next) !== null ? next : null;\n};\n","// ---------------------------------------------------------------------------\n// Data migration: unwrap the retired {status, headers, data} transport\n// envelope from persisted OpenAPI tool output schemas. The runtime returns\n// the upstream payload as `data` (status/headers live in the ToolResult\n// `http` side channel), so persisted schemas must describe the payload\n// only — otherwise describe previews show an envelope invocations no\n// longer return. Mirrors the cloud drizzle migration\n// (apps/cloud/drizzle/0002_unwrap_openapi_output_envelope.sql) for the\n// libSQL-backed apps, where it runs once through the data-migration ledger.\n//\n// Idempotent: payload-shaped rows don't match the envelope signature, so\n// re-running plans zero updates.\n// ---------------------------------------------------------------------------\n\nimport { Effect, Option, Schema } from \"effect\";\nimport { DataMigrationError, type SqliteDataMigrationClient } from \"@executor-js/sdk/core\";\n\nconst MIGRATION_NAME = \"2026-06-11-openapi-output-envelope-unwrap\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n// `{\"type\": \"integer\"}` — the envelope's `status` property schema, exactly.\nconst isEnvelopeStatusSchema = (value: unknown): boolean =>\n isRecord(value) && Object.keys(value).length === 1 && value.type === \"integer\";\n\n// `{\"type\": \"object\", \"additionalProperties\": {\"type\": \"string\"}}` — the\n// envelope's `headers` property schema, exactly.\nconst isEnvelopeHeadersSchema = (value: unknown): boolean =>\n isRecord(value) &&\n Object.keys(value).length === 2 &&\n value.type === \"object\" &&\n isRecord(value.additionalProperties) &&\n Object.keys(value.additionalProperties).length === 1 &&\n value.additionalProperties.type === \"string\";\n\n/**\n * If `schema` is the retired transport envelope, return the payload schema\n * to persist instead (`null` when the envelope carried an empty `{}` data\n * schema — the new producer persists no output schema for those). Returns\n * undefined when the schema is not an envelope and the row must be left\n * untouched.\n */\nexport const unwrapOpenApiTransportEnvelope = (\n schema: unknown,\n): { readonly outputSchema: unknown | null } | undefined => {\n if (!isRecord(schema)) return undefined;\n if (schema.type !== \"object\" || schema.additionalProperties !== false) return undefined;\n const required = schema.required;\n if (!Array.isArray(required) || required.length !== 3) return undefined;\n if (![\"status\", \"headers\", \"data\"].every((key) => required.includes(key))) return undefined;\n const properties = schema.properties;\n if (!isRecord(properties) || !(\"data\" in properties)) return undefined;\n if (!isEnvelopeStatusSchema(properties.status)) return undefined;\n if (!isEnvelopeHeadersSchema(properties.headers)) return undefined;\n const data = properties.data;\n const outputSchema = isRecord(data) && Object.keys(data).length === 0 ? null : data;\n return { outputSchema };\n};\n\nconst decodeJsonOption = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);\n\nconst execute = (\n client: SqliteDataMigrationClient,\n stmt: string | { readonly sql: string; readonly args: readonly unknown[] },\n) =>\n Effect.tryPromise({\n try: () => client.execute(stmt),\n catch: (cause) => new DataMigrationError({ migration: MIGRATION_NAME, cause }),\n });\n\n/** Unwrap envelope-shaped openapi tool output schemas in a SQLite database.\n * Returns the number of rows rewritten. The `tool` table may not exist yet\n * on a fresh database — that counts as nothing to migrate. */\nexport const runSqliteOpenApiOutputSchemaMigration = (\n client: SqliteDataMigrationClient,\n): Effect.Effect<number, DataMigrationError> =>\n Effect.gen(function* () {\n const exists = yield* execute(\n client,\n \"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'tool'\",\n );\n if (exists.rows.length === 0) return 0;\n\n const result = yield* execute(\n client,\n \"SELECT row_id, output_schema FROM tool WHERE plugin_id = 'openapi' AND output_schema IS NOT NULL\",\n );\n const updates: { readonly rowId: string; readonly outputSchema: unknown | null }[] = [];\n for (const row of result.rows) {\n if (typeof row.row_id !== \"string\" || typeof row.output_schema !== \"string\") continue;\n const schema = decodeJsonOption(row.output_schema);\n if (Option.isNone(schema)) continue;\n const unwrapped = unwrapOpenApiTransportEnvelope(schema.value);\n if (unwrapped !== undefined) updates.push({ rowId: row.row_id, ...unwrapped });\n }\n if (updates.length === 0) return 0;\n\n const applyAll = Effect.gen(function* () {\n for (const update of updates) {\n yield* execute(client, {\n sql: \"UPDATE tool SET output_schema = ? WHERE row_id = ?\",\n args: [\n update.outputSchema === null ? null : JSON.stringify(update.outputSchema),\n update.rowId,\n ],\n });\n }\n yield* execute(client, \"COMMIT\");\n });\n\n yield* execute(client, \"BEGIN\");\n yield* applyAll.pipe(Effect.tapError(() => execute(client, \"ROLLBACK\").pipe(Effect.ignore)));\n return updates.length;\n });\n\n/** Registry entry for the boot-time data-migration ledger. */\nexport const openApiOutputSchemaDataMigration = {\n name: MIGRATION_NAME,\n run: (client: SqliteDataMigrationClient) =>\n runSqliteOpenApiOutputSchemaMigration(client).pipe(Effect.asVoid),\n};\n","// ---------------------------------------------------------------------------\n// Data migration: move inline OpenAPI spec text out of `integration.config`\n// into the blob table (`spec/<sha256>`, config keeps `specHash`) — the\n// libSQL-ledger counterpart of cloud's out-of-band migrate-specs-to-blobs\n// script. Runs once per database through the data-migration ledger; the\n// shared body lives in @executor-js/sdk (`runSqliteConfigBlobMigration`).\n// ---------------------------------------------------------------------------\n\nimport { Effect } from \"effect\";\nimport {\n runSqliteConfigBlobMigration,\n type SqliteDataMigrationClient,\n} from \"@executor-js/sdk/core\";\n\nconst MIGRATION_NAME = \"2026-06-12-openapi-spec-to-blob\";\n\n/** Registry entry for the boot-time data-migration ledger. */\nexport const openApiSpecBlobDataMigration = {\n name: MIGRATION_NAME,\n run: (client: SqliteDataMigrationClient) =>\n runSqliteConfigBlobMigration(client, {\n migrationName: MIGRATION_NAME,\n pluginId: \"openapi\",\n inlineField: \"spec\",\n hashField: \"specHash\",\n blobKeyPrefix: \"spec\",\n }).pipe(Effect.asVoid),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAS,gBAAyC;;;AC5DlD,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAIP,IAAM,mBAAmB,CAAC,UACxB,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,UACR,MAA4B,SAAS,YACpC,MAA4B,SAAS;AAG1C,IAAM,qBAAqB,CACzB,UAEA,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS;AAExC,IAAM,eAAe,CAAC,UAAmC;AACvD,MAAI,iBAAiB,KAAK,EAAG,QAAO;AACpC,MAAI,mBAAmB,KAAK,GAAG;AAC7B,UAAM,EAAE,MAAM,OAAO,GAAG,KAAK,IAAI;AACjC,WAAO,EAAE,GAAG,MAAM,MAAM,SAAS;AAAA,EACnC;AACA,QAAM,SAAS,OAAO,UAAU,2BAA2B,KAAK,CAAC;AACjE,MAAI,WAAW,KAAM,QAAO,+BAA+B,MAAM;AACjE,SAAO;AACT;AAKO,IAAM,2BAA2B,CAAC,WAAoC;AAC3E,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,MAAI,EAAE,UAAU,WAAW,EAAE,cAAc,QAAS,QAAO;AAC3D,MAAI,EAAE,4BAA4B,QAAS,QAAO;AA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O,OAAO,KAAK,UAAU,OAAO,YAAY;AAAA,UACxE,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO,QAAQ,QAAQ,QAAQ;AAAA,EACjC,CAAC;AAED,SAAO,QAAQ,QAAQ,OAAO;AAC9B,SAAO,SAAS,KAAK,OAAO,SAAS,MAAM,QAAQ,QAAQ,UAAU,EAAE,KAAK,OAAO,MAAM,CAAC,CAAC;AAC3F,SAAO,QAAQ;AACjB,CAAC;AAGI,IAAM,mCAAmC;AAAA,EAC9C,MAAM;AAAA,EACN,KAAK,CAAC,WACJ,sCAAsC,MAAM,EAAE,KAAK,OAAO,MAAM;AACpE;;;ACjHA,SAAS,UAAAC,eAAc;AACvB;AAAA,EACE;AAAA,OAEK;AAEP,IAAMC,kBAAiB;AAGhB,IAAM,+BAA+B;AAAA,EAC1C,MAAMA;AAAA,EACN,KAAK,CAAC,WACJ,6BAA6B,QAAQ;AAAA,IACnC,eAAeA;AAAA,IACf,UAAU;AAAA,IACV,aAAa;AAAA,IACb,WAAW;AAAA,IACX,eAAe;AAAA,EACjB,CAAC,EAAE,KAAKD,QAAO,MAAM;AACzB;","names":["Option","Effect","MIGRATION_NAME"]}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openApiPlugin
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-WJQIWTZF.js";
|
|
4
|
+
import "./chunk-C6PH4R7Q.js";
|
|
5
5
|
import "./chunk-AQ7JDDRM.js";
|
|
6
6
|
import "./chunk-MZWZQ24W.js";
|
|
7
7
|
import {
|
|
8
|
-
TOKEN_VARIABLE
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
TOKEN_VARIABLE
|
|
9
|
+
} from "./chunk-C3IJX4AN.js";
|
|
10
|
+
|
|
11
|
+
// src/promise.ts
|
|
12
|
+
import { variable } from "@executor-js/sdk/http-auth";
|
|
11
13
|
export {
|
|
12
14
|
TOKEN_VARIABLE,
|
|
13
15
|
openApiPlugin,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/promise.ts"],"sourcesContent":["export { openApiPlugin } from \"./sdk/plugin\";\nexport type {\n OpenApiPluginOptions,\n OpenApiPluginExtension,\n OpenApiSpecConfig,\n OpenApiSpecInput,\n OpenApiPreviewInput,\n} from \"./sdk/plugin\";\n\n// Auth-template authoring helpers. Author apikey methods as canonical\n// placements, or request-shaped: `headers: { Authorization: [\"Bearer \",\n// variable(\"token\")] }` — both normalize to the same stored model.\nexport { TOKEN_VARIABLE } from \"./sdk/types\";\nexport type { Authentication, AuthenticationInput, APIKeyAuthentication } from \"./sdk/types\";\nexport { variable, type ApiKeyAuthTemplate } from \"@executor-js/sdk/http-auth\";\n"],"mappings":";;;;;;;;;;;AAcA,SAAS,gBAAyC;","names":[]}
|