@executor-js/plugin-openapi 1.5.15 → 1.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/AddOpenApiSource-U7AYB224.js +369 -0
  2. package/dist/AddOpenApiSource-U7AYB224.js.map +1 -0
  3. package/dist/{OpenApiAccountsPanel-X5Z5XKRM.js → OpenApiAccountsPanel-GHFHHE6P.js} +15 -39
  4. package/dist/OpenApiAccountsPanel-GHFHHE6P.js.map +1 -0
  5. package/dist/{UpdateSpecSection-Z2DEEWZW.js → UpdateSpecSection-PLCBUU4I.js} +4 -4
  6. package/dist/UpdateSpecSection-PLCBUU4I.js.map +1 -0
  7. package/dist/api/group.d.ts +0 -21
  8. package/dist/api/index.d.ts +0 -21
  9. package/dist/{chunk-ZTOOUP67.js → chunk-3FM2SWM4.js} +542 -580
  10. package/dist/chunk-3FM2SWM4.js.map +1 -0
  11. package/dist/chunk-CKBX4SXK.js +95 -0
  12. package/dist/chunk-CKBX4SXK.js.map +1 -0
  13. package/dist/{chunk-NJ4Q3VF4.js → chunk-CPPTKUOW.js} +5 -14
  14. package/dist/chunk-CPPTKUOW.js.map +1 -0
  15. package/dist/{chunk-O54VFSWE.js → chunk-KVPUDOJZ.js} +18 -4
  16. package/dist/chunk-KVPUDOJZ.js.map +1 -0
  17. package/dist/{chunk-PAHWRRS3.js → chunk-QQFCICLX.js} +4 -13
  18. package/dist/chunk-QQFCICLX.js.map +1 -0
  19. package/dist/client.js +4 -5
  20. package/dist/client.js.map +1 -1
  21. package/dist/core.js +25 -15
  22. package/dist/core.js.map +1 -1
  23. package/dist/index.js +4 -5
  24. package/dist/index.js.map +1 -1
  25. package/dist/react/atoms.d.ts +0 -22
  26. package/dist/react/client.d.ts +0 -21
  27. package/dist/react/index.d.ts +2 -0
  28. package/dist/sdk/backing.d.ts +54 -0
  29. package/dist/sdk/config.d.ts +0 -2
  30. package/dist/sdk/derive-auth.d.ts +5 -3
  31. package/dist/sdk/index.d.ts +2 -1
  32. package/dist/sdk/plugin.d.ts +4 -10
  33. package/dist/sdk/presets.d.ts +0 -1
  34. package/dist/sdk/preview.d.ts +79 -0
  35. package/dist/testing/index.d.ts +0 -6
  36. package/package.json +6 -5
  37. package/dist/AddOpenApiSource-IRMLVLDK.js +0 -765
  38. package/dist/AddOpenApiSource-IRMLVLDK.js.map +0 -1
  39. package/dist/OpenApiAccountsPanel-X5Z5XKRM.js.map +0 -1
  40. package/dist/UpdateSpecSection-Z2DEEWZW.js.map +0 -1
  41. package/dist/chunk-MZWZQ24W.js +0 -226
  42. package/dist/chunk-MZWZQ24W.js.map +0 -1
  43. package/dist/chunk-NJ4Q3VF4.js.map +0 -1
  44. package/dist/chunk-O54VFSWE.js.map +0 -1
  45. package/dist/chunk-PAHWRRS3.js.map +0 -1
  46. package/dist/chunk-UOLBAX5D.js +0 -712
  47. package/dist/chunk-UOLBAX5D.js.map +0 -1
  48. package/dist/chunk-ZTOOUP67.js.map +0 -1
  49. package/dist/react/GoogleProductPicker.d.ts +0 -9
  50. package/dist/sdk/google-discovery.d.ts +0 -43
  51. package/dist/sdk/google-discovery.test.d.ts +0 -1
  52. package/dist/sdk/google-oauth-batches.d.ts +0 -13
  53. package/dist/sdk/google-oauth-batches.test.d.ts +0 -1
  54. package/dist/sdk/google-oauth-scopes.d.ts +0 -3
  55. package/dist/sdk/google-oauth-scopes.test.d.ts +0 -1
  56. package/dist/sdk/google-presets.d.ts +0 -16
  57. package/dist/sdk/google-presets.test.d.ts +0 -1
  58. package/dist/sdk/google-product-picker-scopes.test.d.ts +0 -1
  59. /package/dist/sdk/{google-bundle.test.d.ts → store.test.d.ts} +0 -0
@@ -32,7 +32,7 @@ var OpenApiAuthRequiredError = class extends Data.TaggedError("OpenApiAuthRequir
32
32
  // src/sdk/parse.ts
33
33
  import { Duration, Effect, Schema as Schema2 } from "effect";
34
34
  import { HttpClient, HttpClientRequest } from "effect/unstable/http";
35
- import YAML from "yaml";
35
+ import { JSON_SCHEMA, load as parseYamlDocument } from "js-yaml";
36
36
  var OpenApiExtractionErrorFromParse = class extends OpenApiExtractionError {
37
37
  };
38
38
  var fetchSpecText = Effect.fn("OpenApi.fetchSpecText")(function* (url, credentials) {
@@ -60,13 +60,14 @@ var fetchSpecText = Effect.fn("OpenApi.fetchSpecText")(function* (url, credentia
60
60
  message: `Failed to fetch OpenAPI document: HTTP ${response.status}`
61
61
  });
62
62
  }
63
- return yield* response.text.pipe(
63
+ const specText = yield* response.text.pipe(
64
64
  Effect.mapError(
65
65
  (_cause) => new OpenApiParseError({
66
66
  message: "Failed to read OpenAPI document body"
67
67
  })
68
68
  )
69
69
  );
70
+ return specText;
70
71
  });
71
72
  var resolveSpecText = (input, credentials) => input.startsWith("http://") || input.startsWith("https://") ? fetchSpecText(input, credentials) : Effect.succeed(input);
72
73
  var parse = Effect.fn("OpenApi.parse")(function* (text) {
@@ -103,7 +104,7 @@ var parseTextToObject = (text) => Effect.gen(function* () {
103
104
  var parseJsonText = Schema2.decodeUnknownEffect(Schema2.fromJsonString(Schema2.Unknown));
104
105
  var parseJsonLike = (text) => {
105
106
  const parseYaml = Effect.try({
106
- try: () => YAML.parse(text),
107
+ try: () => parseYamlDocument(text, { json: true, schema: JSON_SCHEMA }),
107
108
  catch: () => "YamlParseFailed"
108
109
  });
109
110
  if (!text.startsWith("{") && !text.startsWith("[")) return parseYaml;
@@ -696,6 +697,18 @@ var SpecPreview = Schema4.Struct({
696
697
  /** OAuth2 presets — one per (oauth2 scheme × supported flow) combination */
697
698
  oauth2Presets: Schema4.Array(OAuth2Preset)
698
699
  });
700
+ var SpecPreviewSummary = Schema4.Struct({
701
+ title: Schema4.OptionFromOptional(Schema4.String),
702
+ description: Schema4.OptionFromOptional(Schema4.String),
703
+ version: Schema4.OptionFromOptional(Schema4.String),
704
+ servers: Schema4.Array(ServerInfo),
705
+ operationCount: Schema4.Number,
706
+ tags: Schema4.Array(Schema4.String),
707
+ securitySchemes: Schema4.Array(SecurityScheme),
708
+ authStrategies: Schema4.Array(AuthStrategy),
709
+ headerPresets: Schema4.Array(HeaderPreset),
710
+ oauth2Presets: Schema4.Array(OAuth2Preset)
711
+ });
699
712
  var stringRecord = (value) => {
700
713
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
701
714
  const out = {};
@@ -943,7 +956,8 @@ export {
943
956
  OAuth2Preset,
944
957
  PreviewOperation,
945
958
  SpecPreview,
959
+ SpecPreviewSummary,
946
960
  previewSpecText,
947
961
  previewSpec
948
962
  };
949
- //# sourceMappingURL=chunk-O54VFSWE.js.map
963
+ //# sourceMappingURL=chunk-KVPUDOJZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/parse.ts","../src/sdk/openapi-utils.ts","../src/sdk/types.ts","../src/sdk/extract.ts","../src/sdk/preview.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\nimport type { AuthToolFailureCode } from \"@executor-js/sdk/core\";\n\n// HTTP status lives on the class declaration so HttpApiBuilder's error\n// encoder (which reads `ast.annotations` off the schema it stored on\n// `group.addError(...)`) finds it. Applying the annotation post-hoc\n// via `.annotate(...)` in group.ts produced a transform-wrapper AST\n// whose status was not picked up — the error then slipped the typed\n// channel and was captured as a 500 by the observability middleware,\n// spamming Sentry on user misconfig.\nexport class OpenApiParseError extends Schema.TaggedErrorClass<OpenApiParseError>()(\n \"OpenApiParseError\",\n {\n message: Schema.String,\n },\n { httpApiStatus: 400 },\n) {}\n\nexport class OpenApiExtractionError extends Schema.TaggedErrorClass<OpenApiExtractionError>()(\n \"OpenApiExtractionError\",\n {\n message: Schema.String,\n },\n { httpApiStatus: 400 },\n) {}\n\nexport class OpenApiInvocationError extends Data.TaggedError(\"OpenApiInvocationError\")<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n\nexport class OpenApiOAuthError extends Schema.TaggedErrorClass<OpenApiOAuthError>()(\n \"OpenApiOAuthError\",\n {\n message: Schema.String,\n },\n { httpApiStatus: 400 },\n) {}\n\n// ---------------------------------------------------------------------------\n// Auth required — v2 reframes this around the connection (owner/integration/\n// name) that supplies the missing credential, not v1's source/slot/secret.\n// ---------------------------------------------------------------------------\n\nexport class OpenApiAuthRequiredError extends Data.TaggedError(\"OpenApiAuthRequiredError\")<{\n readonly code: AuthToolFailureCode;\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 readonly cause?: unknown;\n}> {}\n","import type { OpenAPI, OpenAPIV3, OpenAPIV3_1 } from \"openapi-types\";\nimport { Duration, Effect, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\";\nimport { JSON_SCHEMA, load as parseYamlDocument } from \"js-yaml\";\n\nimport { OpenApiExtractionError, OpenApiParseError } from \"./errors\";\n\nexport type ParsedDocument = OpenAPIV3.Document | OpenAPIV3_1.Document;\n\nexport interface SpecFetchCredentials {\n readonly headers?: Record<string, string>;\n readonly queryParams?: Record<string, string>;\n}\n\n// ExtractionError subclass raised from parse() for non-3.x specs\nclass OpenApiExtractionErrorFromParse extends OpenApiExtractionError {}\n\n/**\n * Fetch an OpenAPI spec URL and return its body text. Uses the Effect\n * HttpClient so the caller chooses the transport via layer — in Cloudflare\n * Workers, `FetchHttpClient.layer` binds to the Workers-native `fetch`.\n * Bounded by a 60s timeout.\n */\nexport const fetchSpecText = Effect.fn(\"OpenApi.fetchSpecText\")(function* (\n url: string,\n credentials?: SpecFetchCredentials,\n) {\n const client = yield* HttpClient.HttpClient;\n const requestUrl = new URL(url);\n for (const [name, value] of Object.entries(credentials?.queryParams ?? {})) {\n requestUrl.searchParams.set(name, value);\n }\n let request = HttpClientRequest.get(requestUrl.toString()).pipe(\n HttpClientRequest.setHeader(\"Accept\", \"application/json, application/yaml, text/yaml, */*\"),\n );\n for (const [name, value] of Object.entries(credentials?.headers ?? {})) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n const response = yield* client.execute(request).pipe(\n Effect.timeout(Duration.seconds(60)),\n Effect.mapError(\n (_cause) =>\n new OpenApiParseError({\n message: \"Failed to fetch OpenAPI document\",\n }),\n ),\n );\n if (response.status < 200 || response.status >= 300) {\n return yield* new OpenApiParseError({\n message: `Failed to fetch OpenAPI document: HTTP ${response.status}`,\n });\n }\n const specText = yield* response.text.pipe(\n Effect.mapError(\n (_cause) =>\n new OpenApiParseError({\n message: \"Failed to read OpenAPI document body\",\n }),\n ),\n );\n return specText;\n});\n\n/**\n * Resolve an input string to spec text — if it's a URL, fetch it via\n * HttpClient; otherwise return it as-is.\n */\nexport const resolveSpecText = (input: string, credentials?: SpecFetchCredentials) =>\n input.startsWith(\"http://\") || input.startsWith(\"https://\")\n ? fetchSpecText(input, credentials)\n : Effect.succeed(input);\n\n/**\n * Parse an OpenAPI document from spec text and validate it's OpenAPI 3.x.\n *\n * NOTE: does NOT resolve `$ref`s. `DocResolver` + `normalizeOpenApiRefs`\n * downstream work on refs lazily, so inlining them here would just waste\n * memory — and for big specs (e.g. Cloudflare's API) that blows through\n * the 128MB Cloudflare Workers memory cap.\n */\nexport const parse = Effect.fn(\"OpenApi.parse\")(function* (text: string) {\n const api = yield* parseTextToObject(text);\n\n if (!isOpenApi3(api)) {\n return yield* new OpenApiExtractionErrorFromParse({\n message:\n \"Only OpenAPI 3.x documents are supported. Swagger 2.x documents should be converted first.\",\n });\n }\n\n return api as ParsedDocument;\n});\n\n// ---------------------------------------------------------------------------\n// Internals\n// ---------------------------------------------------------------------------\n\nconst isOpenApi3 = (doc: OpenAPI.Document): doc is OpenAPIV3.Document | OpenAPIV3_1.Document =>\n \"openapi\" in doc && typeof doc.openapi === \"string\" && doc.openapi.startsWith(\"3.\");\n\nconst parseTextToObject = (text: string): Effect.Effect<OpenAPI.Document, OpenApiParseError> =>\n Effect.gen(function* () {\n const trimmed = text.trim();\n if (trimmed.length === 0) {\n return yield* new OpenApiParseError({\n message: \"OpenAPI document is empty\",\n });\n }\n\n const parsed = yield* parseJsonLike(trimmed).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to parse OpenAPI document\",\n }),\n ),\n );\n\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return yield* new OpenApiParseError({\n message: \"OpenAPI document must parse to an object\",\n });\n }\n\n return parsed as OpenAPI.Document;\n });\n\nconst parseJsonText = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));\n\nconst parseJsonLike = (text: string): Effect.Effect<unknown, unknown> => {\n const parseYaml = Effect.try({\n try: () => parseYamlDocument(text, { json: true, schema: JSON_SCHEMA }) as unknown,\n catch: () => \"YamlParseFailed\" as const,\n });\n if (!text.startsWith(\"{\") && !text.startsWith(\"[\")) return parseYaml;\n return parseJsonText(text).pipe(Effect.catch(() => parseYaml));\n};\n","// ---------------------------------------------------------------------------\n// OpenAPI type aliases and $ref resolution\n//\n// Wraps the openapi-types V3/V3_1 union mess and provides clean ref resolution.\n// ---------------------------------------------------------------------------\n\nimport type { OpenAPIV3, OpenAPIV3_1 } from \"openapi-types\";\nimport type { ParsedDocument } from \"./parse\";\nimport type { ServerVariable } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Type aliases — collapse V3 / V3_1 unions into single names\n// ---------------------------------------------------------------------------\n\nexport type ParameterObject = OpenAPIV3.ParameterObject | OpenAPIV3_1.ParameterObject;\nexport type OperationObject = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject;\nexport type PathItemObject = OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject;\nexport type RequestBodyObject = OpenAPIV3.RequestBodyObject | OpenAPIV3_1.RequestBodyObject;\nexport type ResponseObject = OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject;\nexport type MediaTypeObject = OpenAPIV3.MediaTypeObject | OpenAPIV3_1.MediaTypeObject;\nexport type ServerObject = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;\n\n// ---------------------------------------------------------------------------\n// DocResolver — wraps a parsed document for clean $ref resolution\n// ---------------------------------------------------------------------------\n\nexport class DocResolver {\n constructor(readonly doc: ParsedDocument) {}\n\n /** Resolve a value that might be a $ref, returning the resolved object */\n resolve<T>(value: T | OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject): T | null {\n if (isRef(value)) {\n const resolved = this.resolvePointer(value.$ref);\n return resolved as T | null;\n }\n return value as T;\n }\n\n private resolvePointer(ref: string): unknown {\n if (!ref.startsWith(\"#/\")) return null;\n const segments = ref.slice(2).split(\"/\");\n let current: unknown = this.doc;\n for (const segment of segments) {\n if (typeof current !== \"object\" || current === null) return null;\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n }\n}\n\nconst isRef = (value: unknown): value is { $ref: string } =>\n typeof value === \"object\" && value !== null && \"$ref\" in value;\n\n// ---------------------------------------------------------------------------\n// Server URL resolution\n// ---------------------------------------------------------------------------\n\n/** Substitute `{var}` placeholders in a templated URL using a plain map. */\nexport const substituteUrlVariables = (url: string, values: Record<string, string>): string => {\n let out = url;\n for (const [name, value] of Object.entries(values)) {\n out = out.replaceAll(`{${name}}`, value);\n }\n return out;\n};\n\n/** Resolve a templated server URL, filling each `{var}` from `overrides` when\n * non-empty, otherwise the variable's spec default. URLs without placeholders\n * pass through unchanged. */\nexport const resolveServerUrl = (\n templateUrl: string,\n variables: Record<string, ServerVariable> | undefined,\n overrides: Record<string, string>,\n): string => {\n const values: Record<string, string> = {};\n for (const [name, v] of Object.entries(variables ?? {})) values[name] = v.default;\n for (const [name, value] of Object.entries(overrides)) {\n if (value) values[name] = value;\n }\n return substituteUrlVariables(templateUrl, values);\n};\n\n// ---------------------------------------------------------------------------\n// Content negotiation\n// ---------------------------------------------------------------------------\n\n/**\n * Return all declared media entries in spec order. `Object.entries` on a\n * plain object preserves insertion order in modern engines, which matches\n * spec declaration order as the parser produced it.\n */\nexport const declaredContents = (\n content: Record<string, MediaTypeObject> | undefined,\n): ReadonlyArray<{ mediaType: string; media: MediaTypeObject }> => {\n if (!content) return [];\n return Object.entries(content).map(([mediaType, media]) => ({ mediaType, media }));\n};\n\n/**\n * Pick the default media type for a requestBody or response. Matches\n * swagger-client behaviour: **first declared wins** (not JSON-first). Spec\n * authors order content entries to signal intent (upload-heavy endpoints\n * declare multipart first, JSON second); respecting that order avoids\n * silently downgrading a multipart endpoint to JSON.\n *\n * For response bodies we still want a JSON preference because the server\n * picks the response content type, not the client — the old `application/\n * json` preference is preserved via `preferredResponseContent` below.\n */\nexport const preferredContent = (\n content: Record<string, MediaTypeObject> | undefined,\n): { mediaType: string; media: MediaTypeObject } | undefined => {\n const first = declaredContents(content)[0];\n return first ? first : undefined;\n};\n\n/** Response-side content picker — still JSON-first because the server\n * picks the response media type, so we want to advertise a preference. */\nexport const preferredResponseContent = (\n content: Record<string, MediaTypeObject> | undefined,\n): { mediaType: string; media: MediaTypeObject } | undefined => {\n if (!content) return undefined;\n const entries = Object.entries(content);\n const pick =\n entries.find(([mt]) => mt === \"application/json\") ??\n entries.find(([mt]) => mt.toLowerCase().includes(\"+json\")) ??\n entries.find(([mt]) => mt.toLowerCase().includes(\"json\")) ??\n entries[0];\n return pick ? { mediaType: pick[0], media: pick[1] } : undefined;\n};\n","import { Schema } from \"effect\";\nimport { AuthTemplateSlug, type OAuthAuthentication } from \"@executor-js/sdk/shared\";\nimport {\n apiKeyMethodFromAuthTemplate,\n isApiKeyAuthTemplate,\n type ApiKeyAuthMethod,\n type ApiKeyAuthTemplate,\n} from \"@executor-js/sdk/http-auth\";\n\n// ---------------------------------------------------------------------------\n// Auth-template model.\n//\n// The apiKey method is the SHARED placements model (`@executor-js/sdk/http-auth`,\n// the same shape the graphql/mcp plugins store): N header/query placements,\n// each rendered from its own credential input. The oauth template is\n// mechanism-intrinsic and comes from core (`OAuthAuthentication`, keyed\n// `kind: \"oauth2\"` with stored endpoints+scopes); an integration's\n// `Authentication` union composes the two. Client credentials\n// (clientId/secret) live on the core `OAuthClient`, not here.\n//\n// Pre-canonical stored templates (`type: \"apiKey\"` with `variable()`-templated\n// header/query records) are rewritten by the one-off config migration\n// (`migrate-config.ts`) — runtime code knows only this model.\n// ---------------------------------------------------------------------------\n\nexport { TOKEN_VARIABLE } from \"@executor-js/sdk/http-auth\";\n\nexport type APIKeyAuthentication = ApiKeyAuthMethod;\n\n/** Every method is keyed by `kind` — `kind: \"oauth2\"` | `kind: \"apikey\"`. */\nexport type Authentication = OAuthAuthentication | APIKeyAuthentication;\n\n/** What auth inputs accept: oauth templates (wire-typed: plain slug) plus the\n * request-shaped apikey dialect (`type: \"apiKey\"`, headers/queryParams\n * records) — the ONE apikey authoring shape. Stored configs and the catalog\n * read as canonical placements; `apiKeyAuthTemplateFromMethod` serializes\n * them back for read-modify-write flows. */\nexport type OAuthAuthenticationInput = Omit<OAuthAuthentication, \"slug\"> & {\n readonly slug: string;\n};\nexport type AuthenticationInput = OAuthAuthenticationInput | ApiKeyAuthTemplate;\n\n/** Expand the request-shaped dialect into canonical placements and brand the\n * oauth slugs. A dialect entry without a slug gets a blank one —\n * `mergeAuthTemplates` backfills `custom_<id>`. */\nexport const normalizeOpenApiAuthInputs = (\n inputs: readonly AuthenticationInput[],\n): readonly Authentication[] =>\n inputs.map((input): Authentication => {\n if (!isApiKeyAuthTemplate(input)) {\n return { ...input, slug: AuthTemplateSlug.make(input.slug) };\n }\n const method = apiKeyMethodFromAuthTemplate(input);\n return { ...method, slug: method.slug ?? \"\" };\n });\n\n// ---------------------------------------------------------------------------\n// Branded IDs\n// ---------------------------------------------------------------------------\n\nexport const OperationId = Schema.String.pipe(Schema.brand(\"OperationId\"));\nexport type OperationId = typeof OperationId.Type;\n\n// ---------------------------------------------------------------------------\n// HTTP\n// ---------------------------------------------------------------------------\n\nexport const HttpMethod = Schema.Literals([\n \"get\",\n \"put\",\n \"post\",\n \"delete\",\n \"patch\",\n \"head\",\n \"options\",\n \"trace\",\n]);\nexport type HttpMethod = typeof HttpMethod.Type;\n\nexport const ParameterLocation = Schema.Literals([\"path\", \"query\", \"header\", \"cookie\"]);\nexport type ParameterLocation = typeof ParameterLocation.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted operation\n// ---------------------------------------------------------------------------\n\nexport const OperationParameter = Schema.Struct({\n name: Schema.String,\n location: ParameterLocation,\n required: Schema.Boolean,\n schema: Schema.OptionFromOptional(Schema.Unknown),\n style: Schema.OptionFromOptional(Schema.String),\n explode: Schema.OptionFromOptional(Schema.Boolean),\n allowReserved: Schema.OptionFromOptional(Schema.Boolean),\n description: Schema.OptionFromOptional(Schema.String),\n});\nexport type OperationParameter = typeof OperationParameter.Type;\n\n/**\n * OpenAPI 3.x `Encoding Object` (§4.8.15). Declared per-property inside a\n * multipart/form-data or application/x-www-form-urlencoded request body.\n *\n * - `contentType` — for multipart, overrides the per-part `Content-Type`\n * header (e.g. `application/json` for a JSON-encoded metadata part).\n * - `style` / `explode` / `allowReserved` — for form-urlencoded, control\n * array / object serialization the same way parameter-level style does.\n */\nexport const EncodingObject = Schema.Struct({\n contentType: Schema.OptionFromOptional(Schema.String),\n style: Schema.OptionFromOptional(Schema.String),\n explode: Schema.OptionFromOptional(Schema.Boolean),\n allowReserved: Schema.OptionFromOptional(Schema.Boolean),\n});\nexport type EncodingObject = typeof EncodingObject.Type;\n\nexport const MediaBinding = Schema.Struct({\n contentType: Schema.String,\n schema: Schema.OptionFromOptional(Schema.Unknown),\n encoding: Schema.OptionFromOptional(Schema.Record(Schema.String, EncodingObject)),\n});\nexport type MediaBinding = typeof MediaBinding.Type;\n\nexport const OperationRequestBody = Schema.Struct({\n required: Schema.Boolean,\n /** Default media type — first declared in spec order (not JSON-first).\n * Used when the caller does not override via the tool's `contentType` arg. */\n contentType: Schema.String,\n /** Schema of the default media type. Kept for backward compat with stored\n * bindings from before `contents` was added. */\n schema: Schema.OptionFromOptional(Schema.Unknown),\n /** All declared media types in spec order. Populated by `extract.ts`\n * going forward; older persisted bindings may have this unset and will\n * fall back to `{contentType, schema}`. */\n contents: Schema.OptionFromOptional(Schema.Array(MediaBinding)),\n});\nexport type OperationRequestBody = typeof OperationRequestBody.Type;\n\nexport const OperationFileHint = Schema.Struct({\n kind: Schema.Literals([\"binaryResponse\", \"byteField\"]),\n mimeType: Schema.OptionFromOptional(Schema.String),\n dataField: Schema.OptionFromOptional(Schema.String),\n sizeField: Schema.OptionFromOptional(Schema.String),\n encoding: Schema.OptionFromOptional(Schema.Literals([\"base64\", \"base64url\"])),\n});\nexport type OperationFileHint = typeof OperationFileHint.Type;\n\nexport const OperationResponseBody = Schema.Struct({\n contentType: Schema.String,\n schema: Schema.OptionFromOptional(Schema.Unknown),\n fileHint: Schema.OptionFromOptional(OperationFileHint),\n});\nexport type OperationResponseBody = typeof OperationResponseBody.Type;\n\nexport const ServerVariable = Schema.Struct({\n default: Schema.String,\n enum: Schema.OptionFromOptional(Schema.Array(Schema.String)),\n description: Schema.OptionFromOptional(Schema.String),\n});\nexport type ServerVariable = typeof ServerVariable.Type;\n\nexport const ServerInfo = Schema.Struct({\n url: Schema.String,\n description: Schema.OptionFromOptional(Schema.String),\n variables: Schema.OptionFromOptional(Schema.Record(Schema.String, ServerVariable)),\n});\nexport type ServerInfo = typeof ServerInfo.Type;\n\nexport const ExtractedOperation = Schema.Struct({\n operationId: OperationId,\n toolPath: Schema.OptionFromOptional(Schema.String),\n method: HttpMethod,\n servers: Schema.Array(ServerInfo),\n pathTemplate: Schema.String,\n summary: Schema.OptionFromOptional(Schema.String),\n description: Schema.OptionFromOptional(Schema.String),\n tags: Schema.Array(Schema.String),\n parameters: Schema.Array(OperationParameter),\n requestBody: Schema.OptionFromOptional(OperationRequestBody),\n responseBody: Schema.OptionFromOptional(OperationResponseBody),\n inputSchema: Schema.OptionFromOptional(Schema.Unknown),\n outputSchema: Schema.OptionFromOptional(Schema.Unknown),\n deprecated: Schema.Boolean,\n});\nexport type ExtractedOperation = typeof ExtractedOperation.Type;\n\nexport const ExtractionResult = Schema.Struct({\n title: Schema.OptionFromOptional(Schema.String),\n /** The spec's `info.description` — the author's own summary of the API. */\n description: Schema.OptionFromOptional(Schema.String),\n version: Schema.OptionFromOptional(Schema.String),\n servers: Schema.Array(ServerInfo),\n operations: Schema.Array(ExtractedOperation),\n});\nexport type ExtractionResult = typeof ExtractionResult.Type;\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal invocation data (no schemas/metadata)\n// ---------------------------------------------------------------------------\n\nexport const OperationBinding = Schema.Struct({\n method: HttpMethod,\n servers: Schema.optional(Schema.Array(ServerInfo)),\n pathTemplate: Schema.String,\n parameters: Schema.Array(OperationParameter),\n requestBody: Schema.OptionFromOptional(OperationRequestBody),\n responseBody: Schema.OptionFromOptional(OperationResponseBody),\n});\nexport type OperationBinding = typeof OperationBinding.Type;\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const InvocationResult = Schema.Struct({\n status: Schema.Number,\n headers: Schema.Record(Schema.String, Schema.String),\n data: Schema.NullOr(Schema.Unknown),\n error: Schema.NullOr(Schema.Unknown),\n});\nexport type InvocationResult = typeof InvocationResult.Type;\n","import { Effect, Option } from \"effect\";\n\nimport { OpenApiExtractionError } from \"./errors\";\nimport type { ParsedDocument } from \"./parse\";\nimport {\n declaredContents,\n DocResolver,\n preferredResponseContent,\n type OperationObject,\n type ParameterObject,\n type PathItemObject,\n type RequestBodyObject,\n type ResponseObject,\n type ServerObject,\n} from \"./openapi-utils\";\nimport {\n EncodingObject,\n ExtractedOperation,\n ExtractionResult,\n type HttpMethod,\n MediaBinding,\n OperationFileHint,\n OperationId,\n OperationParameter,\n OperationRequestBody,\n OperationResponseBody,\n type ParameterLocation,\n ServerInfo,\n ServerVariable,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst HTTP_METHODS: readonly HttpMethod[] = [\n \"get\",\n \"put\",\n \"post\",\n \"delete\",\n \"patch\",\n \"head\",\n \"options\",\n \"trace\",\n];\n\nconst VALID_PARAM_LOCATIONS = new Set<string>([\"path\", \"query\", \"header\", \"cookie\"]);\n\n// ---------------------------------------------------------------------------\n// Parameter extraction\n// ---------------------------------------------------------------------------\n\nconst extractParameters = (\n pathItem: PathItemObject,\n operation: OperationObject,\n r: DocResolver,\n): OperationParameter[] => {\n const merged = new Map<string, ParameterObject>();\n\n for (const raw of pathItem.parameters ?? []) {\n const p = r.resolve<ParameterObject>(raw);\n if (!p) continue;\n merged.set(`${p.in}:${p.name}`, p);\n }\n for (const raw of operation.parameters ?? []) {\n const p = r.resolve<ParameterObject>(raw);\n if (!p) continue;\n merged.set(`${p.in}:${p.name}`, p);\n }\n\n return [...merged.values()]\n .filter((p) => VALID_PARAM_LOCATIONS.has(p.in))\n .map((p) =>\n OperationParameter.make({\n name: p.name,\n location: p.in as ParameterLocation,\n required: p.in === \"path\" ? true : p.required === true,\n schema: Option.fromNullishOr(p.schema),\n style: Option.fromNullishOr(p.style),\n explode: Option.fromNullishOr(p.explode),\n allowReserved: Option.fromNullishOr(\"allowReserved\" in p ? p.allowReserved : undefined),\n description: Option.fromNullishOr(p.description),\n }),\n );\n};\n\n// ---------------------------------------------------------------------------\n// Request body extraction\n// ---------------------------------------------------------------------------\n\nconst buildEncodingRecord = (\n encoding: Record<string, unknown> | undefined,\n): Record<string, EncodingObject> | undefined => {\n if (!encoding) return undefined;\n const out: Record<string, EncodingObject> = {};\n for (const [prop, raw] of Object.entries(encoding)) {\n if (typeof raw !== \"object\" || raw === null) continue;\n const e = raw as {\n contentType?: string;\n style?: string;\n explode?: boolean;\n allowReserved?: boolean;\n };\n out[prop] = EncodingObject.make({\n contentType: Option.fromNullishOr(e.contentType),\n style: Option.fromNullishOr(e.style),\n explode: Option.fromNullishOr(e.explode),\n allowReserved: Option.fromNullishOr(e.allowReserved),\n });\n }\n return Object.keys(out).length > 0 ? out : undefined;\n};\n\nconst extractRequestBody = (\n operation: OperationObject,\n r: DocResolver,\n): OperationRequestBody | undefined => {\n if (!operation.requestBody) return undefined;\n\n const body = r.resolve<RequestBodyObject>(operation.requestBody);\n if (!body) return undefined;\n\n const contents = declaredContents(body.content).map(({ mediaType, media }) =>\n MediaBinding.make({\n contentType: mediaType,\n schema: Option.fromNullishOr(media.schema),\n encoding: Option.fromNullishOr(\n buildEncodingRecord((media as { encoding?: Record<string, unknown> }).encoding),\n ),\n }),\n );\n if (contents.length === 0) return undefined;\n\n // Default = first declared (spec author's preferred order). Callers can\n // override at invoke time with a `contentType` arg.\n const defaultContent = contents[0]!;\n\n return OperationRequestBody.make({\n required: body.required === true,\n contentType: defaultContent.contentType,\n schema: defaultContent.schema,\n contents: Option.some(contents),\n });\n};\n\n// ---------------------------------------------------------------------------\n// Response schema extraction\n// ---------------------------------------------------------------------------\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst stringType = (schema: Record<string, unknown>): boolean =>\n schema.type === \"string\" || (Array.isArray(schema.type) && schema.type.includes(\"string\"));\n\nconst numericType = (schema: Record<string, unknown>): boolean =>\n schema.type === \"integer\" ||\n schema.type === \"number\" ||\n (Array.isArray(schema.type) &&\n (schema.type.includes(\"integer\") || schema.type.includes(\"number\")));\n\nconst normalizedMediaType = (mediaType: string): string =>\n mediaType.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n\nconst isJsonMediaType = (mediaType: string): boolean => {\n const normalized = normalizedMediaType(mediaType);\n return (\n normalized === \"application/json\" || normalized.includes(\"+json\") || normalized.includes(\"json\")\n );\n};\n\nconst binaryStringSchema = (schema: Record<string, unknown>): boolean =>\n stringType(schema) && (schema.format === \"binary\" || schema.format === \"byte\");\n\nconst base64EncodingFromDescription = (schema: Record<string, unknown>): \"base64\" | \"base64url\" =>\n typeof schema.description === \"string\" &&\n /base64url|base64-url|url[- ]safe/i.test(schema.description)\n ? \"base64url\"\n : \"base64\";\n\nconst detectFileHint = (\n schema: unknown,\n mediaType: string,\n r: DocResolver,\n): OperationFileHint | undefined => {\n const resolved = isRecord(schema) ? r.resolve<Record<string, unknown>>(schema) : null;\n if (!resolved) return undefined;\n\n if (!isJsonMediaType(mediaType) && binaryStringSchema(resolved)) {\n return OperationFileHint.make({\n kind: \"binaryResponse\",\n mimeType: Option.some(mediaType),\n dataField: Option.none(),\n sizeField: Option.none(),\n encoding: Option.none(),\n });\n }\n\n if (!isJsonMediaType(mediaType)) return undefined;\n\n const properties = resolved.properties;\n if (!isRecord(properties)) return undefined;\n const data = properties.data;\n const dataSchema = isRecord(data) ? r.resolve<Record<string, unknown>>(data) : null;\n if (!dataSchema || !binaryStringSchema(dataSchema)) return undefined;\n\n const size = properties.size;\n const sizeSchema = isRecord(size) ? r.resolve<Record<string, unknown>>(size) : null;\n const sizeField = sizeSchema && numericType(sizeSchema) ? \"size\" : undefined;\n\n return OperationFileHint.make({\n kind: \"byteField\",\n mimeType: Option.some(\"application/octet-stream\"),\n dataField: Option.some(\"data\"),\n sizeField: sizeField ? Option.some(sizeField) : Option.none(),\n encoding: Option.some(base64EncodingFromDescription(dataSchema)),\n });\n};\n\nconst extractResponseBody = (\n operation: OperationObject,\n r: DocResolver,\n): OperationResponseBody | undefined => {\n if (!operation.responses) return undefined;\n\n const entries = Object.entries(operation.responses);\n const preferred = [\n ...entries.filter(([s]) => /^2\\d\\d$/.test(s)).sort(([a], [b]) => a.localeCompare(b)),\n ...entries.filter(([s]) => s === \"default\"),\n ];\n\n for (const [, ref] of preferred) {\n const resp = r.resolve<ResponseObject>(ref);\n if (!resp) continue;\n const content = preferredResponseContent(resp.content);\n if (content?.media.schema) {\n return OperationResponseBody.make({\n contentType: content.mediaType,\n schema: Option.some(content.media.schema),\n fileHint: Option.fromNullishOr(detectFileHint(content.media.schema, content.mediaType, r)),\n });\n }\n }\n\n return undefined;\n};\n\n// ---------------------------------------------------------------------------\n// Input schema builder\n// ---------------------------------------------------------------------------\n\n// Optional `server` input — host selection + server-URL variables. Undefined\n// when there's nothing to configure (a single server with no variables).\nconst buildServerInputProperty = (\n servers: readonly ServerInfo[],\n): Record<string, unknown> | undefined => {\n const variableDefs: Record<string, ServerVariable> = {};\n for (const server of servers) {\n for (const [name, v] of Object.entries(Option.getOrUndefined(server.variables) ?? {})) {\n if (!(name in variableDefs)) variableDefs[name] = v;\n }\n }\n const hasMultiple = servers.length > 1;\n const variableNames = Object.keys(variableDefs);\n if (!hasMultiple && variableNames.length === 0) return undefined;\n\n const properties: Record<string, unknown> = {};\n if (hasMultiple) {\n properties.url = {\n type: \"string\",\n enum: servers.map((server) => server.url),\n default: servers[0]!.url,\n description: \"Which of the spec's servers to send the request to.\",\n };\n }\n if (variableNames.length > 0) {\n properties.variables = {\n type: \"object\",\n additionalProperties: false,\n properties: Object.fromEntries(\n Object.entries(variableDefs).map(([name, v]) => [\n name,\n {\n type: \"string\",\n default: v.default,\n ...(Option.isSome(v.enum) ? { enum: v.enum.value } : {}),\n ...(Option.isSome(v.description) ? { description: v.description.value } : {}),\n },\n ]),\n ),\n description: \"Values for the server URL `{variables}`; spec defaults apply when omitted.\",\n };\n }\n return {\n type: \"object\",\n additionalProperties: false,\n properties,\n description: \"Optional host selection and server-URL variables for this request.\",\n };\n};\n\nconst buildInputSchema = (\n parameters: readonly OperationParameter[],\n requestBody: OperationRequestBody | undefined,\n servers: readonly ServerInfo[],\n): Record<string, unknown> | undefined => {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const param of parameters) {\n properties[param.name] = Option.getOrElse(param.schema, () => ({ type: \"string\" }));\n if (param.required) required.push(param.name);\n }\n\n // A path/query parameter named `server` takes precedence over the host input.\n const serverProperty = buildServerInputProperty(servers);\n if (serverProperty && !(\"server\" in properties)) properties.server = serverProperty;\n\n if (requestBody) {\n properties.body = Option.getOrElse(requestBody.schema, () => ({ type: \"object\" }));\n if (requestBody.required) required.push(\"body\");\n\n // When the spec declares multiple media types for this requestBody,\n // expose `contentType` so the model can pick. Default = first declared.\n // `body` schema tracks the default; the model is responsible for\n // supplying a body shape that matches whichever contentType it picks.\n const contents = Option.getOrUndefined(requestBody.contents);\n if (contents && contents.length > 1) {\n properties.contentType = {\n type: \"string\",\n enum: contents.map((c) => c.contentType),\n default: requestBody.contentType,\n description:\n \"Content-Type for the request body. Declared media types for this operation, in spec order.\",\n };\n }\n }\n\n if (Object.keys(properties).length === 0) return undefined;\n\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties: false,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Operation ID derivation\n// ---------------------------------------------------------------------------\n\nconst deriveOperationId = (\n method: HttpMethod,\n pathTemplate: string,\n operation: OperationObject,\n): string =>\n operation.operationId ??\n (`${method}_${pathTemplate.replace(/[^a-zA-Z0-9]+/g, \"_\")}`.replace(/^_+|_+$/g, \"\") ||\n `${method}_operation`);\n\nconst explicitToolPath = (operation: OperationObject): string | undefined => {\n const value = (operation as Record<string, unknown>)[\"x-executor-toolPath\"];\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n};\n\nconst explicitPathTemplate = (operation: OperationObject): string | undefined => {\n const value = (operation as Record<string, unknown>)[\"x-executor-pathTemplate\"];\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n};\n\n// ---------------------------------------------------------------------------\n// Server extraction\n// ---------------------------------------------------------------------------\n\nconst extractServerList = (servers: readonly ServerObject[] | undefined): ServerInfo[] =>\n (servers ?? []).flatMap((server) => {\n if (!server.url) return [];\n const serverVariables = server.variables as\n | Record<\n string,\n {\n readonly default?: string;\n readonly enum?: readonly string[];\n readonly description?: string;\n }\n >\n | undefined;\n const vars = serverVariables\n ? Object.fromEntries(\n Object.entries(serverVariables).flatMap(([name, v]) => {\n if (v.default === undefined || v.default === null) return [];\n const enumValues = Array.isArray(v.enum)\n ? v.enum.filter((x): x is string => typeof x === \"string\")\n : undefined;\n return [\n [\n name,\n ServerVariable.make({\n default: String(v.default),\n enum:\n enumValues && enumValues.length > 0 ? Option.some(enumValues) : Option.none(),\n description: Option.fromNullishOr(v.description),\n }),\n ],\n ];\n }),\n )\n : undefined;\n return [\n ServerInfo.make({\n url: server.url,\n description: Option.fromNullishOr(server.description),\n variables: vars && Object.keys(vars).length > 0 ? Option.some(vars) : Option.none(),\n }),\n ];\n });\n\nconst extractServers = (doc: ParsedDocument): ServerInfo[] => extractServerList(doc.servers);\n\nconst operationServers = (\n pathItem: PathItemObject,\n operation: OperationObject,\n docServers: readonly ServerInfo[],\n): readonly ServerInfo[] => {\n const operationLevel = extractServerList(operation.servers);\n if (operationLevel.length > 0) return operationLevel;\n const pathLevel = extractServerList(pathItem.servers);\n if (pathLevel.length > 0) return pathLevel;\n return docServers;\n};\n\n// ---------------------------------------------------------------------------\n// Main extraction\n// ---------------------------------------------------------------------------\n\n/** Extract all operations from a bundled OpenAPI 3.x document */\nexport const extract = Effect.fn(\"OpenApi.extract\")(function* (doc: ParsedDocument) {\n const paths = doc.paths;\n if (!paths) {\n return yield* new OpenApiExtractionError({\n message: \"OpenAPI document has no paths defined\",\n });\n }\n\n const r = new DocResolver(doc);\n const docServers = extractServers(doc);\n const operations: ExtractedOperation[] = [];\n\n for (const [pathTemplate, pathItem] of Object.entries(paths).sort(([a], [b]) =>\n a.localeCompare(b),\n )) {\n if (!pathItem) continue;\n\n for (const method of HTTP_METHODS) {\n const operation = pathItem[method];\n if (!operation) continue;\n\n const parameters = extractParameters(pathItem, operation, r);\n const requestBody = extractRequestBody(operation, r);\n const responseBody = extractResponseBody(operation, r);\n const servers = operationServers(pathItem, operation, docServers);\n const inputSchema = buildInputSchema(parameters, requestBody, servers);\n const outputSchema = responseBody ? Option.getOrUndefined(responseBody.schema) : undefined;\n const tags = (operation.tags ?? []).filter((t) => t.trim().length > 0);\n const operationPathTemplate = explicitPathTemplate(operation) ?? pathTemplate;\n\n operations.push(\n ExtractedOperation.make({\n operationId: OperationId.make(deriveOperationId(method, pathTemplate, operation)),\n toolPath: Option.fromNullishOr(explicitToolPath(operation)),\n method,\n servers,\n pathTemplate: operationPathTemplate,\n summary: Option.fromNullishOr(operation.summary),\n description: Option.fromNullishOr(operation.description),\n tags,\n parameters,\n requestBody: Option.fromNullishOr(requestBody),\n responseBody: Option.fromNullishOr(responseBody),\n inputSchema: Option.fromNullishOr(inputSchema),\n outputSchema: Option.fromNullishOr(outputSchema),\n deprecated: operation.deprecated === true,\n }),\n );\n }\n }\n\n return ExtractionResult.make({\n title: Option.fromNullishOr(doc.info?.title),\n description: Option.fromNullishOr(doc.info?.description),\n version: Option.fromNullishOr(doc.info?.version),\n servers: docServers,\n operations,\n });\n});\n","import { Effect, Option, Predicate } from \"effect\";\nimport { Schema } from \"effect\";\n\nimport { parse, resolveSpecText, type ParsedDocument } from \"./parse\";\nimport { extract } from \"./extract\";\nimport { DocResolver } from \"./openapi-utils\";\nimport { HttpMethod, ServerInfo, type ExtractionResult } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// OAuth 2.0 flows — one entry per supported grant type\n// ---------------------------------------------------------------------------\n\n/** Scopes declared by a flow: `{ scopeName: description }` */\nconst OAuth2Scopes = Schema.Record(Schema.String, Schema.String);\nconst SecuritySchemeType = Schema.Literals([\"http\", \"apiKey\", \"oauth2\", \"openIdConnect\"]);\ntype SecuritySchemeType = typeof SecuritySchemeType.Type;\n\nconst decodeSecuritySchemeType = Schema.decodeUnknownOption(SecuritySchemeType);\n\nexport const OAuth2AuthorizationCodeFlow = Schema.Struct({\n authorizationUrl: Schema.String,\n tokenUrl: Schema.String,\n refreshUrl: Schema.OptionFromOptional(Schema.String),\n scopes: OAuth2Scopes,\n});\nexport type OAuth2AuthorizationCodeFlow = typeof OAuth2AuthorizationCodeFlow.Type;\n\nexport const OAuth2ClientCredentialsFlow = Schema.Struct({\n tokenUrl: Schema.String,\n refreshUrl: Schema.OptionFromOptional(Schema.String),\n scopes: OAuth2Scopes,\n});\nexport type OAuth2ClientCredentialsFlow = typeof OAuth2ClientCredentialsFlow.Type;\n\nexport const OAuth2Flows = Schema.Struct({\n authorizationCode: Schema.OptionFromOptional(OAuth2AuthorizationCodeFlow),\n clientCredentials: Schema.OptionFromOptional(OAuth2ClientCredentialsFlow),\n});\nexport type OAuth2Flows = typeof OAuth2Flows.Type;\n\n// ---------------------------------------------------------------------------\n// Security scheme — what the spec declares it needs\n// ---------------------------------------------------------------------------\n\nexport const SecurityScheme = Schema.Struct({\n /** Key name in components.securitySchemes (e.g. \"api_token\") */\n name: Schema.String,\n /** OpenAPI security scheme type */\n type: SecuritySchemeType,\n /** For type: \"http\" — e.g. \"bearer\", \"basic\" */\n scheme: Schema.OptionFromOptional(Schema.String),\n /** For type: \"http\" with scheme \"bearer\" — e.g. \"JWT\" */\n bearerFormat: Schema.OptionFromOptional(Schema.String),\n /** For type: \"apiKey\" — where the key goes */\n in: Schema.OptionFromOptional(Schema.Literals([\"header\", \"query\", \"cookie\"])),\n /** For type: \"apiKey\" — the header/query/cookie name */\n headerName: Schema.OptionFromOptional(Schema.String),\n description: Schema.OptionFromOptional(Schema.String),\n /** For type: \"oauth2\" — declared flows (authorizationCode / clientCredentials only; implicit and password are deprecated). */\n flows: Schema.OptionFromOptional(OAuth2Flows),\n /** For type: \"openIdConnect\" — the discovery URL. */\n openIdConnectUrl: Schema.OptionFromOptional(Schema.String),\n});\nexport type SecurityScheme = typeof SecurityScheme.Type;\n\n// ---------------------------------------------------------------------------\n// Auth strategy — a valid combination of security schemes\n// ---------------------------------------------------------------------------\n\nexport const AuthStrategy = Schema.Struct({\n /** The security schemes required together for this strategy */\n schemes: Schema.Array(Schema.String),\n});\nexport type AuthStrategy = typeof AuthStrategy.Type;\n\n// ---------------------------------------------------------------------------\n// Header preset — derived from an auth strategy\n// ---------------------------------------------------------------------------\n\nexport const HeaderPreset = Schema.Struct({\n /** Human-readable label for the UI (e.g. \"Bearer Token\", \"API Key + Email\") */\n label: Schema.String,\n /** Headers this strategy needs. Value is null when the user must provide it. */\n headers: Schema.Record(Schema.String, Schema.NullOr(Schema.String)),\n /** Which headers should be stored as secrets */\n secretHeaders: Schema.Array(Schema.String),\n});\nexport type HeaderPreset = typeof HeaderPreset.Type;\n\n// ---------------------------------------------------------------------------\n// OAuth2 preset — derived from an oauth2 security scheme + a flow choice\n// ---------------------------------------------------------------------------\n\nexport const OAuth2Preset = Schema.Struct({\n /** Human-readable label for the UI (e.g. \"OAuth2 (Authorization Code) — oauth_app\") */\n label: Schema.String,\n /** The source security scheme this preset came from (components.securitySchemes key). */\n securitySchemeName: Schema.String,\n /** Which OAuth2 flow this preset uses. */\n flow: Schema.Literals([\"authorizationCode\", \"clientCredentials\"]),\n /** For authorizationCode: user-agent redirect URL (from the spec). */\n authorizationUrl: Schema.OptionFromOptional(Schema.String),\n /** Token endpoint to exchange the code / refresh. */\n tokenUrl: Schema.String,\n /** Optional refresh endpoint if the spec declares one separately. */\n refreshUrl: Schema.OptionFromOptional(Schema.String),\n /** Declared scopes for this flow: `{ scope: description }`. */\n scopes: Schema.Record(Schema.String, Schema.String),\n /** Identity scopes to request alongside API scopes. `\"auto\"` discovers standard OIDC scopes. */\n identityScopes: Schema.Union([\n Schema.Literal(\"auto\"),\n Schema.Literal(false),\n Schema.Array(Schema.String),\n ]),\n});\nexport type OAuth2Preset = typeof OAuth2Preset.Type;\n\n// ---------------------------------------------------------------------------\n// Preview operation — lightweight shape for the add-source UI list\n// ---------------------------------------------------------------------------\n\nexport const PreviewOperation = Schema.Struct({\n operationId: Schema.String,\n method: HttpMethod,\n path: Schema.String,\n summary: Schema.OptionFromOptional(Schema.String),\n tags: Schema.Array(Schema.String),\n deprecated: Schema.Boolean,\n});\nexport type PreviewOperation = typeof PreviewOperation.Type;\n\n// ---------------------------------------------------------------------------\n// Spec preview — everything the frontend needs\n// ---------------------------------------------------------------------------\n\nexport const SpecPreview = Schema.Struct({\n title: Schema.OptionFromOptional(Schema.String),\n /** The spec's `info.description` — prefills the add form's description field. */\n description: Schema.OptionFromOptional(Schema.String),\n version: Schema.OptionFromOptional(Schema.String),\n /** Reuses ServerInfo from extraction */\n servers: Schema.Array(ServerInfo),\n operationCount: Schema.Number,\n /** Lightweight operation list for the add-source UI */\n operations: Schema.Array(PreviewOperation),\n tags: Schema.Array(Schema.String),\n securitySchemes: Schema.Array(SecurityScheme),\n /** Valid auth strategies (each is a set of schemes used together) */\n authStrategies: Schema.Array(AuthStrategy),\n /** Pre-built header presets derived from auth strategies */\n headerPresets: Schema.Array(HeaderPreset),\n /** OAuth2 presets — one per (oauth2 scheme × supported flow) combination */\n oauth2Presets: Schema.Array(OAuth2Preset),\n});\nexport type SpecPreview = typeof SpecPreview.Type;\n\n// HTTP/UI preview deliberately omits the per-operation list. Graph-sized specs\n// can define 16k+ operations, while the add flow only needs counts, tags,\n// servers, and auth metadata before registration.\nexport const SpecPreviewSummary = Schema.Struct({\n title: Schema.OptionFromOptional(Schema.String),\n description: Schema.OptionFromOptional(Schema.String),\n version: Schema.OptionFromOptional(Schema.String),\n servers: Schema.Array(ServerInfo),\n operationCount: Schema.Number,\n tags: Schema.Array(Schema.String),\n securitySchemes: Schema.Array(SecurityScheme),\n authStrategies: Schema.Array(AuthStrategy),\n headerPresets: Schema.Array(HeaderPreset),\n oauth2Presets: Schema.Array(OAuth2Preset),\n});\nexport type SpecPreviewSummary = typeof SpecPreviewSummary.Type;\n\nexport const specPreviewSummary = (preview: SpecPreview): SpecPreviewSummary =>\n SpecPreviewSummary.make({\n title: preview.title,\n description: preview.description,\n version: preview.version,\n servers: preview.servers,\n operationCount: preview.operationCount,\n tags: preview.tags,\n securitySchemes: preview.securitySchemes,\n authStrategies: preview.authStrategies,\n headerPresets: preview.headerPresets,\n oauth2Presets: preview.oauth2Presets,\n });\n\n// ---------------------------------------------------------------------------\n// Security scheme extraction\n// ---------------------------------------------------------------------------\n\nconst stringRecord = (value: unknown): Record<string, string> => {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (typeof v === \"string\") out[k] = v;\n }\n return out;\n};\n\nconst extractFlows = (rawFlows: unknown): Option.Option<OAuth2Flows> => {\n if (!rawFlows || typeof rawFlows !== \"object\") return Option.none();\n const flows = rawFlows as Record<string, unknown>;\n\n const parseFlow = <K extends \"authorizationCode\" | \"clientCredentials\">(key: K): unknown =>\n flows[key];\n\n let authorizationCode: Option.Option<OAuth2AuthorizationCodeFlow> = Option.none();\n const authCodeRaw = parseFlow(\"authorizationCode\");\n if (authCodeRaw && typeof authCodeRaw === \"object\") {\n const f = authCodeRaw as Record<string, unknown>;\n const authUrl = typeof f.authorizationUrl === \"string\" ? f.authorizationUrl : null;\n const tokenUrl = typeof f.tokenUrl === \"string\" ? f.tokenUrl : null;\n if (authUrl && tokenUrl) {\n authorizationCode = Option.some(\n OAuth2AuthorizationCodeFlow.make({\n authorizationUrl: authUrl,\n tokenUrl,\n refreshUrl: Option.fromNullishOr(\n typeof f.refreshUrl === \"string\" ? f.refreshUrl : undefined,\n ),\n scopes: stringRecord(f.scopes),\n }),\n );\n }\n }\n\n let clientCredentials: Option.Option<OAuth2ClientCredentialsFlow> = Option.none();\n const ccRaw = parseFlow(\"clientCredentials\");\n if (ccRaw && typeof ccRaw === \"object\") {\n const f = ccRaw as Record<string, unknown>;\n const tokenUrl = typeof f.tokenUrl === \"string\" ? f.tokenUrl : null;\n if (tokenUrl) {\n clientCredentials = Option.some(\n OAuth2ClientCredentialsFlow.make({\n tokenUrl,\n refreshUrl: Option.fromNullishOr(\n typeof f.refreshUrl === \"string\" ? f.refreshUrl : undefined,\n ),\n scopes: stringRecord(f.scopes),\n }),\n );\n }\n }\n\n if (Option.isNone(authorizationCode) && Option.isNone(clientCredentials)) {\n return Option.none();\n }\n return Option.some(OAuth2Flows.make({ authorizationCode, clientCredentials }));\n};\n\nconst extractSecuritySchemes = (\n rawSchemes: Record<string, unknown>,\n resolver: DocResolver,\n): SecurityScheme[] =>\n Object.entries(rawSchemes).flatMap(([name, schemeOrRef]) => {\n if (!schemeOrRef || typeof schemeOrRef !== \"object\") return [];\n // Resolve $ref so schemes defined via `$ref` aren't silently dropped.\n const resolved = resolver.resolve<Record<string, unknown>>(\n schemeOrRef as Record<string, unknown>,\n );\n if (!resolved || typeof resolved !== \"object\") return [];\n const scheme = resolved;\n\n const type = decodeSecuritySchemeType(scheme.type);\n if (Option.isNone(type)) return [];\n const schemeType = type.value;\n\n return [\n SecurityScheme.make({\n name,\n type: schemeType,\n scheme: Option.fromNullishOr(scheme.scheme as string | undefined),\n bearerFormat: Option.fromNullishOr(scheme.bearerFormat as string | undefined),\n in: Option.fromNullishOr(scheme.in as \"header\" | \"query\" | \"cookie\" | undefined),\n headerName: Option.fromNullishOr(scheme.name as string | undefined),\n description: Option.fromNullishOr(scheme.description as string | undefined),\n flows: schemeType === \"oauth2\" ? extractFlows(scheme.flows) : Option.none(),\n openIdConnectUrl: Option.fromNullishOr(scheme.openIdConnectUrl as string | undefined),\n }),\n ];\n });\n\n// ---------------------------------------------------------------------------\n// Header preset builder\n// ---------------------------------------------------------------------------\n\nconst buildHeaderPresets = (\n schemes: readonly SecurityScheme[],\n strategies: readonly AuthStrategy[],\n): HeaderPreset[] => {\n const schemeMap = new Map(schemes.map((s) => [s.name, s]));\n\n return strategies.flatMap((strategy) => {\n const resolved = strategy.schemes\n .map((name) => schemeMap.get(name))\n .filter(Predicate.isNotUndefined);\n\n if (resolved.length === 0) return [];\n\n const headers: Record<string, string | null> = {};\n const secretHeaders: string[] = [];\n const labelParts: string[] = [];\n\n for (const scheme of resolved) {\n if (scheme.type === \"http\" && Option.getOrElse(scheme.scheme, () => \"\") === \"bearer\") {\n headers[\"Authorization\"] = null;\n secretHeaders.push(\"Authorization\");\n labelParts.push(\"Bearer Token\");\n } else if (scheme.type === \"http\" && Option.getOrElse(scheme.scheme, () => \"\") === \"basic\") {\n headers[\"Authorization\"] = null;\n secretHeaders.push(\"Authorization\");\n labelParts.push(\"Basic Auth\");\n } else if (scheme.type === \"apiKey\" && Option.getOrElse(scheme.in, () => \"\") === \"header\") {\n const headerName = Option.getOrElse(scheme.headerName, () => scheme.name);\n headers[headerName] = null;\n secretHeaders.push(headerName);\n labelParts.push(scheme.name);\n } else if (scheme.type === \"apiKey\") {\n labelParts.push(`${scheme.name} (${Option.getOrElse(scheme.in, () => \"unknown\")})`);\n } else if (scheme.type === \"oauth2\" || scheme.type === \"openIdConnect\") {\n return [];\n } else {\n labelParts.push(scheme.name);\n }\n }\n\n if (Object.keys(headers).length === 0 && resolved.length > 0) {\n return [\n HeaderPreset.make({\n label: labelParts.join(\" + \"),\n headers: {},\n secretHeaders: [],\n }),\n ];\n }\n\n return [\n HeaderPreset.make({\n label: labelParts.join(\" + \"),\n headers,\n secretHeaders,\n }),\n ];\n });\n};\n\n// ---------------------------------------------------------------------------\n// OAuth2 preset builder\n// ---------------------------------------------------------------------------\n\nconst buildOAuth2Presets = (schemes: readonly SecurityScheme[]): OAuth2Preset[] => {\n const presets: OAuth2Preset[] = [];\n for (const scheme of schemes) {\n if (scheme.type !== \"oauth2\") continue;\n if (Option.isNone(scheme.flows)) continue;\n const flows = scheme.flows.value;\n\n if (Option.isSome(flows.authorizationCode)) {\n const flow = flows.authorizationCode.value;\n presets.push(\n OAuth2Preset.make({\n label: `OAuth2 Authorization Code · ${scheme.name}`,\n securitySchemeName: scheme.name,\n flow: \"authorizationCode\",\n authorizationUrl: Option.some(flow.authorizationUrl),\n tokenUrl: flow.tokenUrl,\n refreshUrl: flow.refreshUrl,\n scopes: flow.scopes,\n identityScopes: \"auto\",\n }),\n );\n }\n\n if (Option.isSome(flows.clientCredentials)) {\n const flow = flows.clientCredentials.value;\n presets.push(\n OAuth2Preset.make({\n label: `OAuth2 Client Credentials · ${scheme.name}`,\n securitySchemeName: scheme.name,\n flow: \"clientCredentials\",\n authorizationUrl: Option.none(),\n tokenUrl: flow.tokenUrl,\n refreshUrl: flow.refreshUrl,\n scopes: flow.scopes,\n identityScopes: false,\n }),\n );\n }\n }\n return presets;\n};\n\n// ---------------------------------------------------------------------------\n// Collect unique tags from extraction result\n// ---------------------------------------------------------------------------\n\nconst collectTags = (result: ExtractionResult): string[] => {\n const tagSet = new Set<string>();\n for (const op of result.operations) {\n for (const tag of op.tags) tagSet.add(tag);\n }\n return [...tagSet].sort();\n};\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/** Preview already-resolved spec text — extract metadata without registering\n * anything and without any HTTP dependency. */\nexport const previewSpecText = Effect.fn(\"OpenApi.previewSpecText\")(function* (specText: string) {\n const doc: ParsedDocument = yield* parse(specText);\n const result = yield* extract(doc);\n\n const resolver = new DocResolver(doc);\n const securitySchemes = extractSecuritySchemes(doc.components?.securitySchemes ?? {}, resolver);\n\n const rawSecurity = (doc.security ?? []) as Array<Record<string, unknown>>;\n const declaredStrategies = rawSecurity.map((entry) =>\n AuthStrategy.make({ schemes: Object.keys(entry) }),\n );\n // Fall back to one strategy per scheme when the spec only declares schemes\n // under components (e.g. Sentry) so the user still sees auth options.\n const authStrategies =\n declaredStrategies.length > 0\n ? declaredStrategies\n : securitySchemes.map((scheme) => AuthStrategy.make({ schemes: [scheme.name] }));\n\n return SpecPreview.make({\n title: result.title,\n description: result.description,\n version: result.version,\n servers: result.servers,\n operationCount: result.operations.length,\n operations: result.operations.map((op) =>\n PreviewOperation.make({\n operationId: op.operationId,\n method: op.method,\n path: op.pathTemplate,\n summary: op.summary,\n tags: op.tags,\n deprecated: op.deprecated,\n }),\n ),\n tags: collectTags(result),\n securitySchemes,\n authStrategies,\n headerPresets: buildHeaderPresets(securitySchemes, authStrategies),\n oauth2Presets: buildOAuth2Presets(securitySchemes),\n });\n});\n\n/** Preview an OpenAPI spec — extract metadata without registering anything.\n * Accepts either a URL or raw JSON/YAML text. */\nexport const previewSpec = Effect.fn(\"OpenApi.previewSpec\")(function* (input: string) {\n const specText = yield* resolveSpecText(input);\n return yield* previewSpecText(specText);\n});\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AAWtB,IA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AA,MAAI,CAAC,OACjC,iBAAiB,KAAK;AAAA,QACpB,aAAa,GAAG;AAAA,QAChB,QAAQ,GAAG;AAAA,QACX,MAAM,GAAG;AAAA,QACT,SAAS,GAAG;AAAA,QACZ,MAAM,GAAG;AAAA,QACT,YAAY,GAAG;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,IACA,MAAM,YAAY,MAAM;AAAA,IACxB;AAAA,IACA;AAAA,IACA,eAAe,mBAAmB,iBAAiB,cAAc;AAAA,IACjE,eAAe,mBAAmB,eAAe;AAAA,EACnD,CAAC;AACH,CAAC;AAIM,IAAM,cAAcA,QAAO,GAAG,qBAAqB,EAAE,WAAW,OAAe;AACpF,QAAM,WAAW,OAAO,gBAAgB,KAAK;AAC7C,SAAO,OAAO,gBAAgB,QAAQ;AACxC,CAAC;","names":["Schema","Schema","Schema","Effect","Effect","Effect","Option","Schema","Schema","Option","Effect"]}
@@ -1,8 +1,3 @@
1
- import {
2
- googleOpenApiBundlePreset,
3
- googleOpenApiPresets
4
- } from "./chunk-MZWZQ24W.js";
5
-
6
1
  // src/sdk/presets.ts
7
2
  var openApiOnlyPresets = [
8
3
  {
@@ -40,7 +35,7 @@ var openApiOnlyPresets = [
40
35
  {
41
36
  id: "neon",
42
37
  name: "Neon",
43
- summary: "Serverless Postgres \u2014 projects, branches, and endpoints.",
38
+ summary: "Serverless Postgres: projects, branches, and endpoints.",
44
39
  url: "https://neon.tech/api_spec/release/v2.json",
45
40
  icon: "https://neon.tech/favicon/favicon.ico",
46
41
  featured: true
@@ -108,7 +103,7 @@ var openApiOnlyPresets = [
108
103
  {
109
104
  id: "petstore",
110
105
  name: "Petstore",
111
- summary: "Classic OpenAPI demo \u2014 no auth required.",
106
+ summary: "Classic OpenAPI demo, no auth required.",
112
107
  url: "https://petstore3.swagger.io/api/v3/openapi.json",
113
108
  icon: "https://petstore3.swagger.io/favicon-32x32.png"
114
109
  },
@@ -134,13 +129,9 @@ var openApiOnlyPresets = [
134
129
  icon: "https://svgl.app/library/spotify.svg"
135
130
  }
136
131
  ];
137
- var openApiPresets = [
138
- googleOpenApiBundlePreset,
139
- ...openApiOnlyPresets,
140
- ...googleOpenApiPresets
141
- ];
132
+ var openApiPresets = openApiOnlyPresets;
142
133
 
143
134
  export {
144
135
  openApiPresets
145
136
  };
146
- //# sourceMappingURL=chunk-PAHWRRS3.js.map
137
+ //# sourceMappingURL=chunk-QQFCICLX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/presets.ts"],"sourcesContent":["export interface OpenApiPreset {\n readonly id: string;\n readonly name: string;\n readonly summary: string;\n readonly url?: string;\n readonly icon?: string;\n readonly featured?: boolean;\n}\n\nconst openApiOnlyPresets: readonly OpenApiPreset[] = [\n {\n id: \"stripe\",\n name: \"Stripe\",\n summary: \"Payments, subscriptions, customers, and invoices.\",\n url: \"https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json\",\n icon: \"https://stripe.com/favicon.ico\",\n featured: true,\n },\n {\n id: \"github-rest\",\n name: \"GitHub REST\",\n summary: \"Repos, issues, pull requests, actions, and users.\",\n url: \"https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json\",\n icon: \"https://svgl.app/library/github_dark.svg\",\n featured: true,\n },\n {\n id: \"vercel\",\n name: \"Vercel\",\n summary: \"Deployments, domains, projects, and edge config.\",\n url: \"https://openapi.vercel.sh\",\n icon: \"https://vercel.com/favicon.ico\",\n featured: true,\n },\n {\n id: \"cloudflare\",\n name: \"Cloudflare\",\n summary: \"DNS, workers, pages, R2, and security rules.\",\n url: \"https://raw.githubusercontent.com/cloudflare/api-schemas/main/openapi.json\",\n icon: \"https://cloudflare.com/favicon.ico\",\n featured: true,\n },\n {\n id: \"neon\",\n name: \"Neon\",\n summary: \"Serverless Postgres: projects, branches, and endpoints.\",\n url: \"https://neon.tech/api_spec/release/v2.json\",\n icon: \"https://neon.tech/favicon/favicon.ico\",\n featured: true,\n },\n {\n id: \"openai\",\n name: \"OpenAI\",\n summary: \"Models, files, responses, and fine-tuning.\",\n url: \"https://app.stainless.com/api/spec/documented/openai/openapi.documented.yml\",\n icon: \"https://svgl.app/library/openai_dark.svg\",\n featured: true,\n },\n {\n id: \"sentry\",\n name: \"Sentry\",\n summary: \"Error tracking, performance monitoring, and releases.\",\n url: \"https://raw.githubusercontent.com/getsentry/sentry-api-schema/main/openapi-derefed.json\",\n icon: \"https://svgl.app/library/sentry.svg\",\n featured: true,\n },\n {\n id: \"exa\",\n name: \"Exa\",\n summary: \"Web search, similar links, content retrieval, and answers.\",\n url: \"https://raw.githubusercontent.com/exa-labs/openapi-spec/refs/heads/master/exa-openapi-spec.yaml\",\n icon: \"https://exa.ai/images/favicon-32x32.png\",\n featured: true,\n },\n {\n id: \"exa-websets\",\n name: \"Exa Websets\",\n summary: \"Websets, enrichments, webhooks, and monitors.\",\n url: \"https://raw.githubusercontent.com/exa-labs/openapi-spec/refs/heads/master/exa-websets-spec.yaml\",\n icon: \"https://exa.ai/images/favicon-32x32.png\",\n featured: true,\n },\n {\n id: \"axiom\",\n name: \"Axiom\",\n summary: \"Log ingestion, querying, datasets, and monitors.\",\n url: \"https://axiom.co/docs/restapi/versions/v2.json\",\n icon: \"https://axiom.co/favicon.ico\",\n },\n {\n id: \"asana\",\n name: \"Asana\",\n summary: \"Tasks, projects, teams, and workspace management.\",\n url: \"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/asana.com/1.0/openapi.yaml\",\n icon: \"https://asana.com/favicon.ico\",\n },\n {\n id: \"twilio\",\n name: \"Twilio\",\n summary: \"SMS, voice, video, and messaging APIs.\",\n url: \"https://raw.githubusercontent.com/twilio/twilio-oai/main/spec/json/twilio_api_v2010.json\",\n icon: \"https://twilio.com/favicon.ico\",\n },\n {\n id: \"digitalocean\",\n name: \"DigitalOcean\",\n summary: \"Droplets, Kubernetes, databases, and networking.\",\n url: \"https://raw.githubusercontent.com/digitalocean/openapi/main/specification/DigitalOcean-public.v2.yaml\",\n icon: \"https://assets.digitalocean.com/favicon.ico\",\n },\n {\n id: \"petstore\",\n name: \"Petstore\",\n summary: \"Classic OpenAPI demo, no auth required.\",\n url: \"https://petstore3.swagger.io/api/v3/openapi.json\",\n icon: \"https://petstore3.swagger.io/favicon-32x32.png\",\n },\n {\n id: \"val-town\",\n name: \"Val Town\",\n summary: \"Vals, runs, blobs, and email/web endpoints.\",\n url: \"https://api.val.town/openapi.json\",\n icon: \"https://www.val.town/favicon.svg\",\n },\n {\n id: \"resend\",\n name: \"Resend\",\n summary: \"Transactional email sending and domain management.\",\n url: \"https://raw.githubusercontent.com/resend/resend-openapi/main/resend.yaml\",\n icon: \"https://resend.com/static/favicons/favicon.ico\",\n },\n {\n id: \"spotify\",\n name: \"Spotify\",\n summary: \"Tracks, albums, playlists, library, and playback.\",\n url: \"https://raw.githubusercontent.com/sonallux/spotify-web-api/refs/heads/main/official-spotify-open-api.yml\",\n icon: \"https://svgl.app/library/spotify.svg\",\n },\n];\n\nexport const openApiPresets: readonly OpenApiPreset[] = openApiOnlyPresets;\n"],"mappings":";AASA,IAAM,qBAA+C;AAAA,EACnD;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAA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AA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AACF;AAEO,IAAM,iBAA2C;","names":[]}
package/dist/client.js CHANGED
@@ -1,16 +1,15 @@
1
1
  import {
2
2
  openApiPresets
3
- } from "./chunk-PAHWRRS3.js";
4
- import "./chunk-MZWZQ24W.js";
3
+ } from "./chunk-QQFCICLX.js";
5
4
 
6
5
  // src/react/plugin-client.tsx
7
6
  import { defineClientPlugin } from "@executor-js/sdk/client";
8
7
 
9
8
  // src/react/source-plugin.ts
10
9
  import { lazy } from "react";
11
- var importAdd = () => import("./AddOpenApiSource-IRMLVLDK.js");
12
- var importEditSheet = () => import("./UpdateSpecSection-Z2DEEWZW.js");
13
- var importAccounts = () => import("./OpenApiAccountsPanel-X5Z5XKRM.js");
10
+ var importAdd = () => import("./AddOpenApiSource-U7AYB224.js");
11
+ var importEditSheet = () => import("./UpdateSpecSection-PLCBUU4I.js");
12
+ var importAccounts = () => import("./OpenApiAccountsPanel-GHFHHE6P.js");
14
13
  var openApiIntegrationPlugin = {
15
14
  key: "openapi",
16
15
  label: "OpenAPI",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/react/plugin-client.tsx","../src/react/source-plugin.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @executor-js/plugin-openapi/client — `defineClientPlugin` entry.\n//\n// Aggregates the openapi plugin's frontend contributions into a single\n// declarative spec. The host's Vite plugin reads this via\n// `virtual:executor/plugins-client`, so the host's sources page derives\n// the openapi entry from here without a direct `*/react` import.\n//\n// The richer add/edit/summary components still live in `./react`; this\n// module just imports them and bundles them into the spec.\n// ---------------------------------------------------------------------------\n\nimport { defineClientPlugin } from \"@executor-js/sdk/client\";\n\nimport { openApiIntegrationPlugin } from \"./source-plugin\";\n\nexport default defineClientPlugin({\n id: \"openapi\" as const,\n integrationPlugin: openApiIntegrationPlugin,\n});\n","import { lazy } from \"react\";\nimport type { IntegrationPlugin } from \"@executor-js/sdk/client\";\nimport { openApiPresets } from \"../sdk/presets\";\n\nconst importAdd = () => import(\"./AddOpenApiSource\");\nconst importEditSheet = () => import(\"./UpdateSpecSection\");\nconst importAccounts = () => import(\"./OpenApiAccountsPanel\");\n\nexport const openApiIntegrationPlugin: IntegrationPlugin = {\n key: \"openapi\",\n label: \"OpenAPI\",\n add: lazy(importAdd),\n editSheet: lazy(importEditSheet),\n accounts: lazy(importAccounts),\n presets: openApiPresets,\n preload: () => {\n void importAdd();\n void importEditSheet();\n void importAccounts();\n },\n};\n"],"mappings":";;;;;;AAYA,SAAS,0BAA0B;;;ACZnC,SAAS,YAAY;AAIrB,IAAM,YAAY,MAAM,OAAO,gCAAoB;AACnD,IAAM,kBAAkB,MAAM,OAAO,iCAAqB;AAC1D,IAAM,iBAAiB,MAAM,OAAO,oCAAwB;AAErD,IAAM,2BAA8C;AAAA,EACzD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK,KAAK,SAAS;AAAA,EACnB,WAAW,KAAK,eAAe;AAAA,EAC/B,UAAU,KAAK,cAAc;AAAA,EAC7B,SAAS;AAAA,EACT,SAAS,MAAM;AACb,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,eAAe;AAAA,EACtB;AACF;;;ADJA,IAAO,wBAAQ,mBAAmB;AAAA,EAChC,IAAI;AAAA,EACJ,mBAAmB;AACrB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/react/plugin-client.tsx","../src/react/source-plugin.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @executor-js/plugin-openapi/client — `defineClientPlugin` entry.\n//\n// Aggregates the openapi plugin's frontend contributions into a single\n// declarative spec. The host's Vite plugin reads this via\n// `virtual:executor/plugins-client`, so the host's sources page derives\n// the openapi entry from here without a direct `*/react` import.\n//\n// The richer add/edit/summary components still live in `./react`; this\n// module just imports them and bundles them into the spec.\n// ---------------------------------------------------------------------------\n\nimport { defineClientPlugin } from \"@executor-js/sdk/client\";\n\nimport { openApiIntegrationPlugin } from \"./source-plugin\";\n\nexport default defineClientPlugin({\n id: \"openapi\" as const,\n integrationPlugin: openApiIntegrationPlugin,\n});\n","import { lazy } from \"react\";\nimport type { IntegrationPlugin } from \"@executor-js/sdk/client\";\nimport { openApiPresets } from \"../sdk/presets\";\n\nconst importAdd = () => import(\"./AddOpenApiSource\");\nconst importEditSheet = () => import(\"./UpdateSpecSection\");\nconst importAccounts = () => import(\"./OpenApiAccountsPanel\");\n\nexport const openApiIntegrationPlugin: IntegrationPlugin = {\n key: \"openapi\",\n label: \"OpenAPI\",\n add: lazy(importAdd),\n editSheet: lazy(importEditSheet),\n accounts: lazy(importAccounts),\n presets: openApiPresets,\n preload: () => {\n void importAdd();\n void importEditSheet();\n void importAccounts();\n },\n};\n"],"mappings":";;;;;AAYA,SAAS,0BAA0B;;;ACZnC,SAAS,YAAY;AAIrB,IAAM,YAAY,MAAM,OAAO,gCAAoB;AACnD,IAAM,kBAAkB,MAAM,OAAO,iCAAqB;AAC1D,IAAM,iBAAiB,MAAM,OAAO,oCAAwB;AAErD,IAAM,2BAA8C;AAAA,EACzD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK,KAAK,SAAS;AAAA,EACnB,WAAW,KAAK,eAAe;AAAA,EAC/B,UAAU,KAAK,cAAc;AAAA,EAC7B,SAAS;AAAA,EACT,SAAS,MAAM;AACb,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,eAAe;AAAA,EACtB;AACF;;;ADJA,IAAO,wBAAQ,mBAAmB;AAAA,EAChC,IAAI;AAAA,EACJ,mBAAmB;AACrB,CAAC;","names":[]}
package/dist/core.js CHANGED
@@ -2,21 +2,25 @@ import {
2
2
  AuthenticationSchema,
3
3
  OpenApiIntegrationConfigSchema,
4
4
  annotationsForOperation,
5
+ compileOpenApiDocument,
6
+ compileOpenApiSpec,
5
7
  decodeOpenApiIntegrationConfig,
8
+ extractOpenApiUpstreamMessage,
6
9
  invoke,
10
+ invokeOpenApiBackedTool,
7
11
  invokeWithLayer,
12
+ loadOpenApiSpecText,
8
13
  makeDefaultOpenapiStore,
14
+ normalizeOpenApiRefs,
9
15
  openApiPlugin,
10
- renderAuthTemplate
11
- } from "./chunk-ZTOOUP67.js";
12
- import {
13
- convertGoogleDiscoveryBundleToOpenApi,
14
- convertGoogleDiscoveryToOpenApi,
15
- fetchGoogleDiscoveryDocument,
16
- isGoogleDiscoveryUrl
17
- } from "./chunk-UOLBAX5D.js";
18
- import "./chunk-PAHWRRS3.js";
19
- import "./chunk-MZWZQ24W.js";
16
+ openApiStoredOperationsFromCompiled,
17
+ openApiToolDefsFromCompiled,
18
+ renderAuthTemplate,
19
+ resolveOpenApiBackedAnnotations,
20
+ resolveOpenApiBackedTools
21
+ } from "./chunk-3FM2SWM4.js";
22
+ import "./chunk-CKBX4SXK.js";
23
+ import "./chunk-QQFCICLX.js";
20
24
  import {
21
25
  AuthStrategy,
22
26
  DocResolver,
@@ -56,7 +60,7 @@ import {
56
60
  resolveServerUrl,
57
61
  resolveSpecText,
58
62
  substituteUrlVariables
59
- } from "./chunk-O54VFSWE.js";
63
+ } from "./chunk-KVPUDOJZ.js";
60
64
 
61
65
  // src/sdk/index.ts
62
66
  import { variable } from "@executor-js/sdk/http-auth";
@@ -208,25 +212,31 @@ export {
208
212
  SpecPreview,
209
213
  TOKEN_VARIABLE,
210
214
  annotationsForOperation,
211
- convertGoogleDiscoveryBundleToOpenApi,
212
- convertGoogleDiscoveryToOpenApi,
215
+ compileOpenApiDocument,
216
+ compileOpenApiSpec,
213
217
  decodeOpenApiIntegrationConfig,
214
218
  extract,
215
- fetchGoogleDiscoveryDocument,
219
+ extractOpenApiUpstreamMessage,
216
220
  fetchSpecText,
217
221
  invoke,
222
+ invokeOpenApiBackedTool,
218
223
  invokeWithLayer,
219
- isGoogleDiscoveryUrl,
224
+ loadOpenApiSpecText,
220
225
  makeDefaultOpenapiStore,
221
226
  migrateOpenApiAuthConfig,
222
227
  normalizeOpenApiAuthInputs,
228
+ normalizeOpenApiRefs,
223
229
  openApiOutputSchemaDataMigration,
224
230
  openApiPlugin,
225
231
  openApiSpecBlobDataMigration,
232
+ openApiStoredOperationsFromCompiled,
233
+ openApiToolDefsFromCompiled,
226
234
  parse,
227
235
  preferredContent,
228
236
  previewSpec,
229
237
  renderAuthTemplate,
238
+ resolveOpenApiBackedAnnotations,
239
+ resolveOpenApiBackedTools,
230
240
  resolveServerUrl,
231
241
  resolveSpecText,
232
242
  runSqliteOpenApiOutputSchemaMigration,
package/dist/core.js.map CHANGED
@@ -1 +1 @@
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,U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"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 { extract } from \"./extract\";\nexport { invoke, invokeWithLayer, annotationsForOperation } from \"./invoke\";\nexport {\n compileOpenApiDocument,\n compileOpenApiSpec,\n extractOpenApiUpstreamMessage,\n invokeOpenApiBackedTool,\n loadOpenApiSpecText,\n normalizeOpenApiRefs,\n openApiStoredOperationsFromCompiled,\n openApiToolDefsFromCompiled,\n resolveOpenApiBackedAnnotations,\n resolveOpenApiBackedTools,\n type CompiledOpenApiSpec,\n} from \"./backing\";\nexport type { ParsedDocument } from \"./parse\";\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,SAAS,gBAAyC;;;ACnElD,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,WAA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,eAAW,UAAU,SAAS;AAC5B,aAAO,QAAQ,QAAQ;AAAA,QACrB,KAAK;AAAA,QACL,MAAM;AAAA,UACJ,OAAO,iBAAiB,OAAO,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,12 +1,11 @@
1
1
  import {
2
2
  openApiPlugin
3
- } from "./chunk-ZTOOUP67.js";
4
- import "./chunk-UOLBAX5D.js";
5
- import "./chunk-PAHWRRS3.js";
6
- import "./chunk-MZWZQ24W.js";
3
+ } from "./chunk-3FM2SWM4.js";
4
+ import "./chunk-CKBX4SXK.js";
5
+ import "./chunk-QQFCICLX.js";
7
6
  import {
8
7
  TOKEN_VARIABLE
9
- } from "./chunk-O54VFSWE.js";
8
+ } from "./chunk-KVPUDOJZ.js";
10
9
 
11
10
  // src/promise.ts
12
11
  import { variable } from "@executor-js/sdk/http-auth";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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":[]}
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":[]}
@@ -15,7 +15,6 @@ export declare const openApiConfigAtom: (slug: IntegrationSlug) => Atom.Atom<imp
15
15
  readonly [x: string]: string;
16
16
  } | undefined;
17
17
  readonly sourceUrl?: string | undefined;
18
- readonly googleDiscoveryUrls?: readonly string[] | undefined;
19
18
  readonly baseUrl?: string | undefined;
20
19
  readonly authenticationTemplate?: readonly ({
21
20
  readonly slug: string;
@@ -44,14 +43,6 @@ export declare const previewOpenApiSpec: Atom.AtomResultFn<{
44
43
  readonly reactivityKeys?: readonly unknown[] | import("effect/Record").ReadonlyRecord<string, readonly unknown[]> | undefined;
45
44
  }, {
46
45
  readonly version: import("effect/Option").Option<string>;
47
- readonly operations: readonly {
48
- readonly method: "post" | "options" | "delete" | "get" | "put" | "patch" | "head" | "trace";
49
- readonly deprecated: boolean;
50
- readonly path: string;
51
- readonly summary: import("effect/Option").Option<string>;
52
- readonly tags: readonly string[];
53
- readonly operationId: string;
54
- }[];
55
46
  readonly description: import("effect/Option").Option<string>;
56
47
  readonly title: import("effect/Option").Option<string>;
57
48
  readonly servers: readonly {
@@ -126,12 +117,6 @@ export declare const addOpenApiSpec: Atom.AtomResultFn<{
126
117
  } | {
127
118
  readonly value: string;
128
119
  readonly kind: "blob";
129
- } | {
130
- readonly kind: "googleDiscovery";
131
- readonly url: string;
132
- } | {
133
- readonly kind: "googleDiscoveryBundle";
134
- readonly urls: readonly string[];
135
120
  };
136
121
  readonly name?: string | undefined;
137
122
  readonly description?: string | undefined;
@@ -193,12 +178,6 @@ export declare const updateOpenApiSpec: Atom.AtomResultFn<{
193
178
  } | {
194
179
  readonly value: string;
195
180
  readonly kind: "blob";
196
- } | {
197
- readonly kind: "googleDiscovery";
198
- readonly url: string;
199
- } | {
200
- readonly kind: "googleDiscoveryBundle";
201
- readonly urls: readonly string[];
202
181
  } | undefined;
203
182
  };
204
183
  readonly responseMode?: "decoded-only" | undefined;
@@ -276,7 +255,6 @@ export declare const openApiConfigFamily: (arg: string & import("effect/Brand").
276
255
  readonly [x: string]: string;
277
256
  } | undefined;
278
257
  readonly sourceUrl?: string | undefined;
279
- readonly googleDiscoveryUrls?: readonly string[] | undefined;
280
258
  readonly baseUrl?: string | undefined;
281
259
  readonly authenticationTemplate?: readonly ({
282
260
  readonly slug: string;