@executor-js/plugin-openapi 1.4.32 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/AddOpenApiSource-7M52SRUX.js +893 -0
  2. package/dist/AddOpenApiSource-7M52SRUX.js.map +1 -0
  3. package/dist/EditOpenApiSource-WTAMRJUK.js +68 -0
  4. package/dist/EditOpenApiSource-WTAMRJUK.js.map +1 -0
  5. package/dist/OpenApiAccountsPanel-3VJJXNQF.js +112 -0
  6. package/dist/OpenApiAccountsPanel-3VJJXNQF.js.map +1 -0
  7. package/dist/api/group.d.ts +104 -225
  8. package/dist/api/index.d.ts +127 -271
  9. package/dist/{chunk-BB5IAKRG.js → chunk-AQ7JDDRM.js} +12 -2
  10. package/dist/chunk-AQ7JDDRM.js.map +1 -0
  11. package/dist/chunk-BSLE6HCE.js +181 -0
  12. package/dist/chunk-BSLE6HCE.js.map +1 -0
  13. package/dist/chunk-MZWZQ24W.js +226 -0
  14. package/dist/chunk-MZWZQ24W.js.map +1 -0
  15. package/dist/chunk-OSIFYIQP.js +623 -0
  16. package/dist/chunk-OSIFYIQP.js.map +1 -0
  17. package/dist/chunk-QSSRVK6M.js +139 -0
  18. package/dist/chunk-QSSRVK6M.js.map +1 -0
  19. package/dist/chunk-V7VCHYOY.js +1544 -0
  20. package/dist/chunk-V7VCHYOY.js.map +1 -0
  21. package/dist/{chunk-AN4HJFNP.js → chunk-YVRI7KRC.js} +162 -186
  22. package/dist/chunk-YVRI7KRC.js.map +1 -0
  23. package/dist/client.js +9 -8
  24. package/dist/client.js.map +1 -1
  25. package/dist/core.js +28 -11
  26. package/dist/index.js +11 -4
  27. package/dist/react/AddOpenApiSource.d.ts +2 -13
  28. package/dist/react/GoogleProductPicker.d.ts +9 -0
  29. package/dist/react/OpenApiAccountsPanel.d.ts +6 -0
  30. package/dist/react/OpenApiSourceDetailsFields.d.ts +3 -2
  31. package/dist/react/atoms.d.ts +177 -192
  32. package/dist/react/auth-method-config.d.ts +15 -0
  33. package/dist/react/client.d.ts +103 -224
  34. package/dist/react/index.d.ts +2 -2
  35. package/dist/react/source-plugin.d.ts +2 -2
  36. package/dist/sdk/config.d.ts +75 -0
  37. package/dist/sdk/configure.test.d.ts +1 -0
  38. package/dist/sdk/describe-auth-methods.test.d.ts +1 -0
  39. package/dist/sdk/errors.d.ts +4 -6
  40. package/dist/sdk/extract.d.ts +7 -5
  41. package/dist/sdk/google-bundle.test.d.ts +1 -0
  42. package/dist/sdk/google-discovery.d.ts +43 -0
  43. package/dist/sdk/google-discovery.test.d.ts +1 -0
  44. package/dist/sdk/google-oauth-batches.d.ts +13 -0
  45. package/dist/sdk/google-oauth-batches.test.d.ts +1 -0
  46. package/dist/sdk/google-oauth-scopes.d.ts +3 -0
  47. package/dist/sdk/google-oauth-scopes.test.d.ts +1 -0
  48. package/dist/sdk/google-presets.d.ts +16 -0
  49. package/dist/sdk/google-presets.test.d.ts +1 -0
  50. package/dist/sdk/google-product-picker-scopes.test.d.ts +1 -0
  51. package/dist/sdk/index.d.ts +7 -5
  52. package/dist/sdk/invoke.d.ts +6 -9
  53. package/dist/sdk/openapi-utils.d.ts +1 -0
  54. package/dist/sdk/plugin.d.ts +74 -231
  55. package/dist/sdk/presets.d.ts +2 -1
  56. package/dist/sdk/preview.d.ts +20 -15
  57. package/dist/sdk/query-serialization.test.d.ts +1 -0
  58. package/dist/sdk/store.d.ts +14 -41
  59. package/dist/sdk/types.d.ts +23 -51
  60. package/dist/testing/index.d.ts +49 -38
  61. package/dist/testing.js +46 -18
  62. package/dist/testing.js.map +1 -1
  63. package/package.json +6 -4
  64. package/dist/AddOpenApiSource-NSCULGTM.js +0 -19
  65. package/dist/AddOpenApiSource-NSCULGTM.js.map +0 -1
  66. package/dist/EditOpenApiSource-MV7NYTRP.js +0 -774
  67. package/dist/EditOpenApiSource-MV7NYTRP.js.map +0 -1
  68. package/dist/OpenApiSourceSummary-7JBS7PUV.js +0 -122
  69. package/dist/OpenApiSourceSummary-7JBS7PUV.js.map +0 -1
  70. package/dist/chunk-2ZKKZYZH.js +0 -1181
  71. package/dist/chunk-2ZKKZYZH.js.map +0 -1
  72. package/dist/chunk-AN4HJFNP.js.map +0 -1
  73. package/dist/chunk-BB5IAKRG.js.map +0 -1
  74. package/dist/chunk-PS5XP3DG.js +0 -2086
  75. package/dist/chunk-PS5XP3DG.js.map +0 -1
  76. package/dist/chunk-X5JX3KTA.js +0 -201
  77. package/dist/chunk-X5JX3KTA.js.map +0 -1
  78. package/dist/react/OpenApiSourceSummary.d.ts +0 -5
  79. package/dist/sdk/credential-status.d.ts +0 -23
  80. package/dist/sdk/source-contracts.d.ts +0 -55
  81. /package/dist/{sdk/credential-status.test.d.ts → react/auth-method-config.test.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sdk/google-discovery.ts","../src/sdk/google-oauth-scopes.ts"],"sourcesContent":["// Converts Google Discovery documents directly into OpenAPI 3.x. Public\n// Discovery converters currently target Swagger 2.0 or a broad conversion\n// pipeline; this adapter emits the shape Executor parses while preserving\n// Executor-specific tool ids and query semantics.\nimport { Effect, Option, Predicate, Schema, SchemaGetter } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\";\n\nimport { OpenApiParseError } from \"./errors\";\nimport { compactGoogleOAuthScopes } from \"./google-oauth-scopes\";\nimport type { SpecFetchCredentials } from \"./parse\";\nimport type { Authentication } from \"./types\";\nimport { AuthTemplateSlug } from \"@executor-js/sdk/shared\";\n\nconst DISCOVERY_SERVICE_HOST = \"https://www.googleapis.com/discovery/v1/apis\";\nconst GOOGLE_BUNDLE_BASE_URL = \"https://www.googleapis.com/\";\nconst GOOGLE_OAUTH_AUTHORIZATION_URL = \"https://accounts.google.com/o/oauth2/v2/auth\";\nconst GOOGLE_OAUTH_TOKEN_URL = \"https://oauth2.googleapis.com/token\";\nconst OPENAPI_SCHEMA_TYPES = new Set([\n \"array\",\n \"boolean\",\n \"integer\",\n \"null\",\n \"number\",\n \"object\",\n \"string\",\n]);\n\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | readonly JsonValue[] | { readonly [key: string]: JsonValue };\n\ntype OpenApiSchemaObject = {\n readonly $ref?: string;\n readonly type?: \"array\" | \"boolean\" | \"integer\" | \"null\" | \"number\" | \"object\" | \"string\";\n readonly description?: string;\n readonly title?: string;\n readonly format?: string;\n readonly readOnly?: boolean;\n readonly default?: JsonValue;\n readonly enum?: readonly JsonValue[];\n readonly items?: OpenApiSchemaObject;\n readonly properties?: Record<string, OpenApiSchemaObject>;\n readonly required?: readonly string[];\n readonly additionalProperties?: boolean | OpenApiSchemaObject;\n};\n\ntype OpenApiParameterObject = {\n readonly name: string;\n readonly in: \"path\" | \"query\" | \"header\";\n readonly required: boolean;\n readonly description?: string;\n readonly schema: OpenApiSchemaObject;\n readonly style?: \"form\";\n readonly explode?: boolean;\n readonly allowReserved?: boolean;\n};\n\ntype OpenApiOperationObject = {\n readonly operationId: string;\n readonly \"x-executor-toolPath\": string;\n readonly \"x-executor-pathTemplate\"?: string;\n readonly tags?: readonly string[];\n readonly description?: string;\n readonly servers?: readonly { readonly url: string }[];\n readonly parameters: readonly OpenApiParameterObject[];\n readonly requestBody?: {\n readonly required: false;\n readonly content: {\n readonly \"application/json\": {\n readonly schema: OpenApiSchemaObject;\n };\n };\n };\n readonly responses: {\n readonly \"200\": {\n readonly description: \"Successful response\";\n readonly content: {\n readonly \"application/json\": {\n readonly schema: OpenApiSchemaObject;\n };\n };\n };\n };\n readonly security?: readonly Record<string, readonly string[]>[];\n readonly \"x-google-scopes\": readonly string[];\n};\n\ntype OpenApiDocument = {\n readonly openapi: \"3.1.0\";\n readonly info: {\n readonly title: string;\n readonly version: string;\n };\n readonly servers: readonly { readonly url: string }[];\n readonly paths: Record<string, Record<string, OpenApiOperationObject>>;\n readonly components: {\n readonly schemas: Record<string, OpenApiSchemaObject>;\n readonly securitySchemes?: Record<\n string,\n {\n readonly type: \"oauth2\";\n readonly flows: {\n readonly authorizationCode: {\n readonly authorizationUrl: string;\n readonly tokenUrl: string;\n readonly scopes: Record<string, string>;\n };\n };\n }\n >;\n };\n readonly security?: readonly Record<string, readonly string[]>[];\n readonly \"x-executor-origin\":\n | {\n readonly kind: \"googleDiscovery\";\n readonly discoveryUrl: string;\n readonly service: string;\n readonly version: string;\n }\n | {\n readonly kind: \"googleDiscoveryBundle\";\n readonly services: readonly {\n readonly discoveryUrl: string;\n readonly service: string;\n readonly version: string;\n }[];\n };\n};\n\nconst TextOption = Schema.OptionFromOptional(Schema.Trim).pipe(\n Schema.decode({\n decode: SchemaGetter.transform((value) => Option.filter(value, (text) => text.length > 0)),\n encode: SchemaGetter.transform((value) => value),\n }),\n Schema.withDecodingDefaultType(Effect.succeed(Option.none())),\n);\nconst TextArray = Schema.optional(Schema.Array(Schema.String)).pipe(\n Schema.withDecodingDefaultType(Effect.succeed([] as string[])),\n);\nconst UnknownRecord = Schema.Record(Schema.String, Schema.Unknown);\nconst UnknownRecordWithDefault = Schema.optional(UnknownRecord).pipe(\n Schema.withDecodingDefaultType(Effect.succeed({})),\n);\n\nconst DiscoveryParameter = Schema.Struct({\n type: Schema.optional(Schema.String),\n description: TextOption,\n properties: UnknownRecordWithDefault,\n items: Schema.optional(Schema.Unknown),\n additionalProperties: Schema.optional(Schema.Union([Schema.Boolean, Schema.Unknown])),\n enum: TextArray,\n format: Schema.optional(Schema.String),\n readOnly: Schema.optional(Schema.Boolean),\n default: Schema.optional(Schema.Union([Schema.String, Schema.Number, Schema.Boolean])),\n $ref: Schema.optional(Schema.String),\n location: Schema.optional(Schema.Literals([\"path\", \"query\", \"header\"])),\n required: Schema.optional(Schema.Boolean),\n repeated: Schema.optional(Schema.Boolean),\n});\ntype DiscoveryParameter = typeof DiscoveryParameter.Type;\n\nconst DiscoveryRef = Schema.Struct({\n $ref: Schema.optional(Schema.String),\n});\n\nconst DiscoveryMethod = Schema.Struct({\n id: TextOption,\n description: TextOption,\n httpMethod: Schema.optional(Schema.String),\n path: TextOption,\n parameters: UnknownRecordWithDefault,\n request: Schema.optional(DiscoveryRef),\n response: Schema.optional(DiscoveryRef),\n scopes: TextArray,\n});\ntype DiscoveryMethod = typeof DiscoveryMethod.Type;\n\nconst DiscoveryResource = Schema.Struct({\n methods: UnknownRecordWithDefault,\n resources: UnknownRecordWithDefault,\n});\n\nconst DiscoveryDocument = Schema.Struct({\n name: TextOption,\n version: TextOption,\n title: TextOption,\n rootUrl: TextOption,\n servicePath: Schema.optional(Schema.Trim).pipe(\n Schema.withDecodingDefaultType(Effect.succeed(\"\")),\n ),\n parameters: UnknownRecordWithDefault,\n methods: UnknownRecordWithDefault,\n resources: UnknownRecordWithDefault,\n schemas: UnknownRecordWithDefault,\n auth: Schema.optional(\n Schema.Struct({\n oauth2: Schema.optional(\n Schema.Struct({\n scopes: Schema.optional(\n Schema.Record(\n Schema.String,\n Schema.Struct({\n description: TextOption,\n }),\n ),\n ).pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),\n }),\n ),\n }),\n ),\n});\ntype DiscoveryDocument = typeof DiscoveryDocument.Type;\n\nexport interface GoogleDiscoveryOpenApiConversion {\n readonly specText: string;\n readonly baseUrl: string;\n readonly title: string;\n readonly service: string;\n readonly version: string;\n readonly discoveryUrls?: readonly string[];\n /** The v2 oauth auth template the converted integration declares, when the\n * Discovery document advertises OAuth2 scopes. */\n readonly authenticationTemplate?: readonly Authentication[];\n}\n\nconst decodeDiscoveryDocument = Schema.decodeUnknownSync(DiscoveryDocument);\nconst decodeDiscoveryParameter = Schema.decodeUnknownSync(DiscoveryParameter);\nconst decodeDiscoveryMethod = Schema.decodeUnknownSync(DiscoveryMethod);\nconst decodeDiscoveryResource = Schema.decodeUnknownSync(DiscoveryResource);\nconst parseJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));\n\nconst normalizeDiscoveryUrl = (discoveryUrl: string): string => {\n const trimmed = discoveryUrl.trim();\n if (!URL.canParse(trimmed)) return trimmed;\n const parsed = new URL(trimmed);\n if (parsed.pathname !== \"/$discovery/rest\") return trimmed;\n const version = parsed.searchParams.get(\"version\")?.trim();\n if (!version) return trimmed;\n const host = parsed.hostname.toLowerCase();\n if (!host.endsWith(\".googleapis.com\")) return trimmed;\n const rawService = host.slice(0, -\".googleapis.com\".length);\n const service =\n rawService === \"calendar-json\"\n ? \"calendar\"\n : rawService.endsWith(\"-json\")\n ? rawService.slice(0, -5)\n : rawService;\n return service ? `${DISCOVERY_SERVICE_HOST}/${service}/${version}/rest` : trimmed;\n};\n\nexport const isGoogleDiscoveryUrl = (url: string): boolean => {\n const trimmed = url.trim();\n if (!URL.canParse(trimmed)) return false;\n const parsed = new URL(trimmed);\n const host = parsed.hostname.toLowerCase();\n if (!host.endsWith(\"googleapis.com\")) return false;\n return parsed.pathname.includes(\"/discovery/\") || parsed.pathname.includes(\"$discovery\");\n};\n\nexport const fetchGoogleDiscoveryDocument = Effect.fn(\"OpenApi.fetchGoogleDiscoveryDocument\")(\n function* (discoveryUrl: string, credentials?: SpecFetchCredentials) {\n const client = yield* HttpClient.HttpClient;\n const requestUrl = new URL(discoveryUrl);\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, */*\"),\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.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to fetch Google Discovery document\",\n }),\n ),\n );\n if (response.status < 200 || response.status >= 300) {\n return yield* new OpenApiParseError({\n message: `Failed to fetch Google Discovery document: HTTP ${response.status}`,\n });\n }\n return yield* response.text.pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to read Google Discovery document body\",\n }),\n ),\n );\n },\n);\n\nconst schemaRef = (name: string) => `#/components/schemas/${name}`;\n\nconst identitySchemaName = (name: string): string => name;\n\nconst schemaComponentPart = (value: string): string =>\n value\n .trim()\n .replace(/[^A-Za-z0-9._-]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\") || \"schema\";\n\nconst normalizeDiscoveryPathTemplate = (pathTemplate: string): string =>\n pathTemplate.replaceAll(/\\{\\+([^{}]+)\\}/g, \"{$1}\");\n\nconst pathUsesReservedExpansion = (pathTemplate: string, parameterName: string): boolean =>\n pathTemplate.includes(`{+${parameterName}}`);\n\nconst uniquePathKey = (\n paths: Record<string, Record<string, OpenApiOperationObject>>,\n preferredPath: string,\n method: string,\n toolPath: string,\n): string => {\n if (!paths[preferredPath]?.[method]) return preferredPath;\n const disambiguated = `/${toolPath.replace(/[^A-Za-z0-9._~-]+/g, \"/\")}`;\n if (!paths[disambiguated]?.[method]) return disambiguated;\n let index = 2;\n while (paths[`${disambiguated}/${index}`]?.[method]) index += 1;\n return `${disambiguated}/${index}`;\n};\n\nconst discoveryDescription = (value: unknown): string | undefined =>\n typeof value === \"string\"\n ? value\n : Option.isOption(value) && Option.isSome(value)\n ? typeof value.value === \"string\"\n ? value.value\n : undefined\n : undefined;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst jsonValue = (value: unknown): JsonValue | undefined => {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n if (Array.isArray(value)) {\n const values = value.map(jsonValue);\n return values.every(Predicate.isNotUndefined) ? values : undefined;\n }\n if (!isRecord(value)) return undefined;\n const entries = Object.entries(value).flatMap(([key, item]) => {\n const converted = jsonValue(item);\n return converted === undefined ? [] : [[key, converted] as const];\n });\n return Object.fromEntries(entries);\n};\n\nconst stringArray = (value: unknown): readonly string[] | undefined => {\n if (!Array.isArray(value)) return undefined;\n const strings = value.filter((item): item is string => typeof item === \"string\");\n return strings.length === value.length ? strings : undefined;\n};\n\nconst schemaType = (value: unknown): OpenApiSchemaObject[\"type\"] | undefined =>\n typeof value === \"string\" && OPENAPI_SCHEMA_TYPES.has(value)\n ? (value as OpenApiSchemaObject[\"type\"])\n : undefined;\n\nconst discoverySchemaToOpenApiSchema = (\n raw: unknown,\n schemaNameForRef: (name: string) => string = identitySchemaName,\n): OpenApiSchemaObject => {\n if (!isRecord(raw)) return {};\n const schema = raw;\n if (typeof schema.$ref === \"string\") return { $ref: schemaRef(schemaNameForRef(schema.$ref)) };\n\n const description = discoveryDescription(schema.description);\n const title = discoveryDescription(schema.title);\n const defaultValue = jsonValue(schema.default);\n const enumValues = Array.isArray(schema.enum)\n ? schema.enum.map(jsonValue).filter(Predicate.isNotUndefined)\n : [];\n const format = typeof schema.format === \"string\" ? schema.format : undefined;\n const readOnly = typeof schema.readOnly === \"boolean\" ? schema.readOnly : undefined;\n const type = schemaType(schema.type);\n\n const base = {\n ...(description !== undefined ? { description } : {}),\n ...(title !== undefined ? { title } : {}),\n ...(format !== undefined ? { format } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n ...(defaultValue !== undefined ? { default: defaultValue } : {}),\n ...(enumValues.length > 0 ? { enum: enumValues } : {}),\n } satisfies OpenApiSchemaObject;\n\n if (type === \"array\") {\n return {\n ...base,\n type: \"array\",\n items: discoverySchemaToOpenApiSchema(schema.items, schemaNameForRef),\n };\n }\n\n const properties = schema.properties;\n if (\n type === \"object\" ||\n (isRecord(properties) && Object.keys(properties).length > 0) ||\n schema.additionalProperties !== undefined\n ) {\n const convertedProperties = isRecord(properties)\n ? Object.fromEntries(\n Object.entries(properties).map(([name, value]) => [\n name,\n discoverySchemaToOpenApiSchema(value, schemaNameForRef),\n ]),\n )\n : undefined;\n const required = stringArray(schema.required);\n const additionalProperties =\n schema.additionalProperties === undefined\n ? undefined\n : typeof schema.additionalProperties === \"boolean\"\n ? schema.additionalProperties\n : discoverySchemaToOpenApiSchema(schema.additionalProperties, schemaNameForRef);\n return {\n ...base,\n type: \"object\",\n ...(convertedProperties && Object.keys(convertedProperties).length > 0\n ? { properties: convertedProperties }\n : {}),\n ...(required && required.length > 0 ? { required } : {}),\n ...(additionalProperties !== undefined ? { additionalProperties } : {}),\n };\n }\n\n return type !== undefined ? { ...base, type } : base;\n};\n\nconst parameterSchema = (\n parameter: DiscoveryParameter,\n schemaNameForRef: (name: string) => string = identitySchemaName,\n): OpenApiSchemaObject => {\n const base = discoverySchemaToOpenApiSchema(parameter, schemaNameForRef);\n return parameter.repeated\n ? {\n type: \"array\",\n items: base,\n }\n : base;\n};\n\nconst methodToolPath = (service: string, methodId: string): string =>\n methodId.startsWith(`${service}.`) ? methodId.slice(service.length + 1) : methodId;\n\nconst collectMethods = (resource: unknown): DiscoveryMethod[] => {\n const decoded = decodeDiscoveryResource(resource);\n const direct = Object.values(decoded.methods ?? {}).map((raw) => decodeDiscoveryMethod(raw));\n const nested = Object.values(decoded.resources ?? {}).flatMap(collectMethods);\n return [...direct, ...nested];\n};\n\nconst discoveryScopes = (document: DiscoveryDocument): Record<string, string> =>\n Object.fromEntries(\n Object.entries(document.auth?.oauth2?.scopes ?? {}).map(([scope, value]) => [\n scope,\n Option.getOrElse(value.description, () => \"\"),\n ]),\n );\n\n// The scope set the converted integration DECLARES (and that `oauth.start`\n// requests at connect) must match the consent the picker previews. Both run the\n// raw Discovery union through `compactGoogleOAuthScopes`, which drops scopes a\n// user OAuth consent screen can't show (`chat.bot`/`chat.app.*`/`keep`) and\n// collapses sub-scopes under their broad parent (`gmail.*` → `mail.google.com`,\n// `userinfo.email` → `email`). Descriptions are preserved where the raw map had\n// them; compaction-introduced identity scopes (`email`/`profile`) fall back to\n// the broad parent's description. Per-operation `x-google-scopes`/`security`\n// stay RAW — they describe which scope each method needs, not consent.\nconst compactDiscoveryScopeMap = (raw: Record<string, string>): Record<string, string> => {\n const descriptionFor = (scope: string): string => {\n if (raw[scope] !== undefined) return raw[scope];\n if (scope === \"email\") return raw[\"https://www.googleapis.com/auth/userinfo.email\"] ?? \"\";\n if (scope === \"profile\") return raw[\"https://www.googleapis.com/auth/userinfo.profile\"] ?? \"\";\n return \"\";\n };\n return Object.fromEntries(\n compactGoogleOAuthScopes(Object.keys(raw)).map((scope) => [scope, descriptionFor(scope)]),\n );\n};\n\nconst allDiscoveryMethods = (document: DiscoveryDocument): DiscoveryMethod[] => [\n ...Object.values(document.methods ?? {}).map((raw) => decodeDiscoveryMethod(raw)),\n ...Object.values(document.resources ?? {}).flatMap(collectMethods),\n];\n\ntype DiscoveryDocumentInfo = {\n readonly discoveryUrl: string;\n readonly document: DiscoveryDocument;\n readonly service: string;\n readonly version: string;\n readonly rootUrl: string;\n readonly baseUrl: string;\n readonly title: string;\n};\n\nconst discoveryDocumentInfo = (\n document: DiscoveryDocument,\n discoveryUrl: string,\n): Effect.Effect<DiscoveryDocumentInfo, OpenApiParseError> =>\n Effect.gen(function* () {\n const service = Option.getOrUndefined(document.name);\n const version = Option.getOrUndefined(document.version);\n const rootUrl = Option.getOrUndefined(document.rootUrl);\n if (!service || !version || !rootUrl) {\n return yield* new OpenApiParseError({\n message: \"Google Discovery document is missing one of: name, version, rootUrl\",\n });\n }\n\n return {\n discoveryUrl,\n document,\n service,\n version,\n rootUrl,\n baseUrl: new URL(document.servicePath || \"\", rootUrl).toString(),\n title: Option.getOrElse(document.title, () => `${service} ${version}`),\n };\n });\n\nconst buildDiscoveryOperation = (input: {\n readonly document: DiscoveryDocument;\n readonly method: DiscoveryMethod;\n readonly toolPath: string;\n readonly pathTemplate: string;\n readonly schemaNameForRef?: (name: string) => string;\n readonly serverUrl?: string;\n readonly tags?: readonly string[];\n}): OpenApiOperationObject => {\n const mergedParameters = new Map<string, DiscoveryParameter>();\n for (const [name, raw] of Object.entries(input.document.parameters ?? {})) {\n const parameter = decodeDiscoveryParameter(raw);\n if (parameter.location) mergedParameters.set(name, parameter);\n }\n for (const [name, raw] of Object.entries(input.method.parameters ?? {})) {\n const parameter = decodeDiscoveryParameter(raw);\n if (parameter.location) mergedParameters.set(name, parameter);\n }\n\n const methodScopes = input.method.scopes ?? [];\n const methodDescription = Option.getOrUndefined(input.method.description);\n const schemaNameForRef = input.schemaNameForRef ?? identitySchemaName;\n\n return {\n operationId: input.toolPath,\n \"x-executor-toolPath\": input.toolPath,\n \"x-executor-pathTemplate\": input.pathTemplate,\n ...(input.tags && input.tags.length > 0 ? { tags: input.tags } : {}),\n ...(methodDescription !== undefined ? { description: methodDescription } : {}),\n ...(input.serverUrl ? { servers: [{ url: input.serverUrl }] } : {}),\n parameters: [...mergedParameters.entries()].flatMap(([name, parameter]) => {\n const location = parameter.location;\n if (!location) return [];\n const description = Option.getOrUndefined(parameter.description);\n const allowReserved =\n location === \"path\" && pathUsesReservedExpansion(input.pathTemplate, name);\n return [\n {\n name,\n in: location,\n required: location === \"path\" ? true : parameter.required === true,\n ...(description !== undefined ? { description } : {}),\n schema: parameterSchema(parameter, schemaNameForRef),\n ...(location === \"query\"\n ? { style: \"form\" as const, explode: parameter.repeated === true }\n : {}),\n ...(allowReserved ? { allowReserved: true } : {}),\n },\n ];\n }),\n ...(input.method.request?.$ref\n ? {\n requestBody: {\n required: false,\n content: {\n \"application/json\": {\n schema: { $ref: schemaRef(schemaNameForRef(input.method.request.$ref)) },\n },\n },\n },\n }\n : {}),\n responses: {\n \"200\": {\n description: \"Successful response\",\n content: {\n \"application/json\": {\n schema: input.method.response?.$ref\n ? { $ref: schemaRef(schemaNameForRef(input.method.response.$ref)) }\n : {},\n },\n },\n },\n },\n ...(methodScopes.length > 0 ? { security: [{ googleOAuth2: methodScopes }] } : {}),\n \"x-google-scopes\": methodScopes,\n };\n};\n\nconst GOOGLE_OAUTH_SECURITY_SCHEME = \"googleOAuth2\";\n\n/** The v2 oauth auth template for a Google-discovery integration. The spec\n * itself carries the matching `securitySchemes.googleOAuth2` entry; this is the\n * catalog-level template a connection's access token renders through. */\nconst googleOauthTemplate = (scopes: Record<string, string>): readonly Authentication[] =>\n // A Google-discovery integration is ALWAYS OAuth, so it ALWAYS declares its\n // oauth method — even when the compacted scope set is empty (e.g. a bundle of\n // only limited-consent APIs like Google Keep, whose scopes Google won't grant\n // through standard consent). Without this the integration declares no auth\n // method and the \"Add account\" / \"Add a connection\" actions are disabled, so\n // you can't even start the flow. Empty `scopes` just requests no scope.\n [\n {\n slug: AuthTemplateSlug.make(GOOGLE_OAUTH_SECURITY_SCHEME),\n type: \"oauth\",\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes: Object.keys(scopes),\n },\n ];\n\nexport const convertGoogleDiscoveryToOpenApi = Effect.fn(\"OpenApi.convertGoogleDiscovery\")(\n function* (input: { readonly discoveryUrl: string; readonly documentText: string }) {\n const parsed = yield* parseJson(input.documentText).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to parse Google Discovery document\",\n }),\n ),\n );\n const document = yield* Effect.try({\n try: () => decodeDiscoveryDocument(parsed),\n catch: () =>\n new OpenApiParseError({\n message: \"Failed to decode Google Discovery document\",\n }),\n });\n\n const info = yield* discoveryDocumentInfo(document, input.discoveryUrl);\n const { service, version, baseUrl, title } = info;\n const paths: Record<string, Record<string, OpenApiOperationObject>> = {};\n\n for (const method of allDiscoveryMethods(document)) {\n const methodId = Option.getOrUndefined(method.id);\n const pathTemplate = Option.getOrUndefined(method.path);\n if (!methodId || !pathTemplate || !method.httpMethod) continue;\n\n const toolPath = methodToolPath(service, methodId);\n const path = normalizeDiscoveryPathTemplate(\n pathTemplate.startsWith(\"/\") ? pathTemplate : `/${pathTemplate}`,\n );\n const methodKey = method.httpMethod.toLowerCase();\n const pathKey = uniquePathKey(paths, path, methodKey, toolPath);\n\n paths[pathKey] ??= {};\n paths[pathKey]![methodKey] = buildDiscoveryOperation({\n document,\n method,\n toolPath,\n pathTemplate: pathTemplate.startsWith(\"/\") ? pathTemplate : `/${pathTemplate}`,\n });\n }\n\n const scopes = compactDiscoveryScopeMap(discoveryScopes(document));\n const authenticationTemplate = googleOauthTemplate(scopes);\n\n const spec: OpenApiDocument = {\n openapi: \"3.1.0\",\n info: {\n title,\n version,\n },\n servers: [{ url: baseUrl }],\n paths,\n components: {\n schemas: Object.fromEntries(\n Object.entries(document.schemas ?? {}).map(([name, schema]) => [\n name,\n discoverySchemaToOpenApiSchema(schema),\n ]),\n ),\n ...(authenticationTemplate\n ? {\n securitySchemes: {\n googleOAuth2: {\n type: \"oauth2\",\n flows: {\n authorizationCode: {\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes,\n },\n },\n },\n },\n }\n : {}),\n },\n ...(authenticationTemplate ? { security: [{ googleOAuth2: Object.keys(scopes) }] } : {}),\n \"x-executor-origin\": {\n kind: \"googleDiscovery\",\n discoveryUrl: normalizeDiscoveryUrl(input.discoveryUrl),\n service,\n version,\n },\n };\n\n return {\n // @effect-diagnostics-next-line preferSchemaOverJson:off\n specText: JSON.stringify(spec),\n baseUrl,\n title,\n service,\n version,\n ...(authenticationTemplate ? { authenticationTemplate } : {}),\n };\n },\n);\n\nexport const convertGoogleDiscoveryBundleToOpenApi = Effect.fn(\n \"OpenApi.convertGoogleDiscoveryBundle\",\n)(function* (input: {\n readonly documents: readonly { readonly discoveryUrl: string; readonly documentText: string }[];\n}) {\n if (input.documents.length === 0) {\n return yield* new OpenApiParseError({\n message: \"Google Discovery bundle requires at least one document\",\n });\n }\n\n const infos = yield* Effect.forEach(input.documents, ({ discoveryUrl, documentText }) =>\n Effect.gen(function* () {\n const parsed = yield* parseJson(documentText).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to parse Google Discovery document\",\n }),\n ),\n );\n const document = yield* Effect.try({\n try: () => decodeDiscoveryDocument(parsed),\n catch: () =>\n new OpenApiParseError({\n message: \"Failed to decode Google Discovery document\",\n }),\n });\n return yield* discoveryDocumentInfo(document, discoveryUrl);\n }),\n );\n\n const paths: Record<string, Record<string, OpenApiOperationObject>> = {};\n const schemas: Record<string, OpenApiSchemaObject> = {};\n const rawScopes: Record<string, string> = {};\n\n for (const info of infos) {\n const schemaPrefix = schemaComponentPart(`${info.service}_${info.version}`);\n const schemaNameForRef = (name: string) => `${schemaPrefix}_${schemaComponentPart(name)}`;\n\n for (const [scope, description] of Object.entries(discoveryScopes(info.document))) {\n rawScopes[scope] ??= description;\n }\n\n for (const [name, schema] of Object.entries(info.document.schemas ?? {})) {\n schemas[schemaNameForRef(name)] = discoverySchemaToOpenApiSchema(schema, schemaNameForRef);\n }\n\n for (const method of allDiscoveryMethods(info.document)) {\n const methodId = Option.getOrUndefined(method.id);\n const rawPathTemplate = Option.getOrUndefined(method.path);\n if (!methodId || !rawPathTemplate || !method.httpMethod) continue;\n\n const toolPath = methodId;\n const wirePath = rawPathTemplate.startsWith(\"/\") ? rawPathTemplate : `/${rawPathTemplate}`;\n const openApiPath = normalizeDiscoveryPathTemplate(wirePath);\n const methodKey = method.httpMethod.toLowerCase();\n const pathKey = uniquePathKey(paths, openApiPath, methodKey, toolPath);\n\n paths[pathKey] ??= {};\n paths[pathKey]![methodKey] = buildDiscoveryOperation({\n document: info.document,\n method,\n toolPath,\n pathTemplate: wirePath,\n schemaNameForRef,\n serverUrl: info.baseUrl,\n tags: [info.title],\n });\n }\n }\n\n const scopes = compactDiscoveryScopeMap(rawScopes);\n const authenticationTemplate = googleOauthTemplate(scopes);\n const spec: OpenApiDocument = {\n openapi: \"3.1.0\",\n info: {\n title: \"Google\",\n version: \"google-discovery-bundle\",\n },\n servers: [{ url: GOOGLE_BUNDLE_BASE_URL }],\n paths,\n components: {\n schemas,\n ...(authenticationTemplate\n ? {\n securitySchemes: {\n googleOAuth2: {\n type: \"oauth2\",\n flows: {\n authorizationCode: {\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes,\n },\n },\n },\n },\n }\n : {}),\n },\n ...(authenticationTemplate ? { security: [{ googleOAuth2: Object.keys(scopes) }] } : {}),\n \"x-executor-origin\": {\n kind: \"googleDiscoveryBundle\",\n services: infos.map((info) => ({\n discoveryUrl: normalizeDiscoveryUrl(info.discoveryUrl),\n service: info.service,\n version: info.version,\n })),\n },\n };\n\n return {\n // @effect-diagnostics-next-line preferSchemaOverJson:off\n specText: JSON.stringify(spec),\n baseUrl: GOOGLE_BUNDLE_BASE_URL,\n title: \"Google\",\n service: \"google\",\n version: \"google-discovery-bundle\",\n discoveryUrls: infos.map((info) => normalizeDiscoveryUrl(info.discoveryUrl)),\n ...(authenticationTemplate ? { authenticationTemplate } : {}),\n };\n});\n","const googleUserConsentBlockedScopes = new Set([\n \"https://www.googleapis.com/auth/chat.bot\",\n \"https://www.googleapis.com/auth/chat.import\",\n \"https://www.googleapis.com/auth/keep\",\n \"https://www.googleapis.com/auth/keep.readonly\",\n]);\n\nconst googleUserConsentBlockedScopePrefixes = [\"https://www.googleapis.com/auth/chat.app.\"];\n\nconst googleBroadScopeGroups: readonly {\n readonly broad: string;\n readonly prefixes: readonly string[];\n}[] = [\n {\n broad: \"https://mail.google.com/\",\n prefixes: [\"https://www.googleapis.com/auth/gmail.\"],\n },\n {\n broad: \"https://www.googleapis.com/auth/calendar\",\n prefixes: [\"https://www.googleapis.com/auth/calendar.\"],\n },\n {\n broad: \"https://www.googleapis.com/auth/drive\",\n prefixes: [\"https://www.googleapis.com/auth/drive.\"],\n },\n];\n\nconst normalizeGoogleIdentityScope = (scope: string): string =>\n scope === \"https://www.googleapis.com/auth/userinfo.email\"\n ? \"email\"\n : scope === \"https://www.googleapis.com/auth/userinfo.profile\"\n ? \"profile\"\n : scope;\n\nconst orderedUniqueScopes = (scopes: Iterable<string>): string[] => {\n const ordered: string[] = [];\n const seen = new Set<string>();\n for (const scope of scopes) {\n const trimmed = scope.trim();\n if (!trimmed || seen.has(trimmed)) continue;\n seen.add(trimmed);\n ordered.push(trimmed);\n }\n return ordered;\n};\n\nexport const isGoogleUserConsentOAuthScope = (scope: string): boolean =>\n !googleUserConsentBlockedScopes.has(scope) &&\n !googleUserConsentBlockedScopePrefixes.some((prefix) => scope.startsWith(prefix));\n\nexport const filterGoogleUserConsentOAuthScopes = (scopes: Iterable<string>): string[] =>\n orderedUniqueScopes(scopes).filter(isGoogleUserConsentOAuthScope);\n\nexport const compactGoogleOAuthScopes = (scopes: Iterable<string>): string[] => {\n const ordered = filterGoogleUserConsentOAuthScopes([...scopes].map(normalizeGoogleIdentityScope));\n const present = new Set(ordered);\n return ordered.filter(\n (scope) =>\n !googleBroadScopeGroups.some(\n (group) =>\n scope !== group.broad &&\n present.has(group.broad) &&\n group.prefixes.some((prefix) => scope.startsWith(prefix)),\n ),\n );\n};\n"],"mappings":";;;;;AAIA,SAAS,QAAQ,QAAQ,WAAW,QAAQ,oBAAoB;AAChE,SAAS,YAAY,yBAAyB;;;ACL9C,IAAM,iCAAiC,oBAAI,IAAI;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wCAAwC,CAAC,2CAA2C;AAE1F,IAAM,yBAGA;AAAA,EACJ;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,wCAAwC;AAAA,EACrD;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,2CAA2C;AAAA,EACxD;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,wCAAwC;AAAA,EACrD;AACF;AAEA,IAAM,+BAA+B,CAAC,UACpC,UAAU,mDACN,UACA,UAAU,qDACR,YACA;AAER,IAAM,sBAAsB,CAAC,WAAuC;AAClE,QAAM,UAAoB,CAAC;AAC3B,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,SAAS,QAAQ;AAC1B,UAAM,UAAU,MAAM,KAAK;AAC3B,QAAI,CAAC,WAAW,KAAK,IAAI,OAAO,EAAG;AACnC,SAAK,IAAI,OAAO;AACh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TemplateSlug } from "@executor-js/sdk/shared";
8
+ var isVariablePart = (part) => typeof part !== "string" && part.type === "variable";
9
+ var parseTemplateValue = (value) => {
10
+ if (typeof value === "string") return { prefix: "", variable: TOKEN_VARIABLE };
11
+ const parts = [];
12
+ for (const part of value) {
13
+ if (isVariablePart(part)) {
14
+ return { prefix: parts.join(""), variable: part.name };
15
+ }
16
+ if (typeof part === "string") parts.push(part);
17
+ }
18
+ return { prefix: parts.join(""), variable: TOKEN_VARIABLE };
19
+ };
20
+ var placementsFromApiKey = (template) => {
21
+ const placements = [];
22
+ for (const [name, value] of Object.entries(template.headers ?? {})) {
23
+ const { prefix, variable: variable2 } = parseTemplateValue(value);
24
+ placements.push({ carrier: "header", name, prefix, variable: variable2 });
25
+ }
26
+ for (const [name, value] of Object.entries(template.queryParams ?? {})) {
27
+ const { prefix, variable: variable2 } = parseTemplateValue(value);
28
+ placements.push({ carrier: "query", name, prefix, variable: variable2 });
29
+ }
30
+ return placements;
31
+ };
32
+ var labelForApiKey = (slug, placements) => {
33
+ const first = placements[0];
34
+ if (first) return `API key (${first.name || (first.carrier === "header" ? "header" : "query")})`;
35
+ return `API key (${slug})`;
36
+ };
37
+ function authMethodsFromConfig(templates) {
38
+ return templates.map((template) => {
39
+ const slug = String(template.slug);
40
+ const source = slug.startsWith("custom_") ? "custom" : "spec";
41
+ if (template.type === "oauth") {
42
+ return {
43
+ id: slug,
44
+ label: "OAuth2",
45
+ kind: "oauth",
46
+ source,
47
+ template: AuthTemplateSlug.make(slug),
48
+ placements: [],
49
+ // Carry the integration's declared endpoints/scopes so the
50
+ // client-registration form pre-fills them.
51
+ oauth: {
52
+ authorizationUrl: template.authorizationUrl,
53
+ tokenUrl: template.tokenUrl,
54
+ scopes: template.scopes
55
+ }
56
+ };
57
+ }
58
+ const placements = placementsFromApiKey(template);
59
+ return {
60
+ id: slug,
61
+ label: labelForApiKey(slug, placements),
62
+ kind: "apikey",
63
+ source,
64
+ template: AuthTemplateSlug.make(slug),
65
+ placements
66
+ };
67
+ });
68
+ }
69
+ var slugifyVariable = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
70
+ var assignVariables = (placements) => {
71
+ const named = placements.filter((p) => p.name);
72
+ const out = /* @__PURE__ */ new Map();
73
+ if (named.length <= 1) {
74
+ for (const p of named) out.set(p, p.variable ?? TOKEN_VARIABLE);
75
+ return out;
76
+ }
77
+ const taken = /* @__PURE__ */ new Set();
78
+ for (const p of named) {
79
+ const base = slugifyVariable(p.name) || "input";
80
+ let candidate = p.variable ?? base;
81
+ let n = 2;
82
+ while (taken.has(candidate)) candidate = `${base}_${n++}`;
83
+ taken.add(candidate);
84
+ out.set(p, candidate);
85
+ }
86
+ return out;
87
+ };
88
+ var valueFromPlacement = (placement, varName) => placement.prefix ? [placement.prefix, variable(varName)] : [variable(varName)];
89
+ function templateFromPlacements(placements, slug) {
90
+ const variables = assignVariables(placements);
91
+ const headers = {};
92
+ const queryParams = {};
93
+ for (const placement of placements) {
94
+ if (!placement.name) continue;
95
+ const varName = variables.get(placement) ?? TOKEN_VARIABLE;
96
+ if (placement.carrier === "header") {
97
+ headers[placement.name] = valueFromPlacement(placement, varName);
98
+ } else {
99
+ queryParams[placement.name] = valueFromPlacement(placement, varName);
100
+ }
101
+ }
102
+ return {
103
+ slug: AuthTemplateSlug.make(slug ?? ""),
104
+ type: "apiKey",
105
+ ...Object.keys(headers).length > 0 ? { headers } : {},
106
+ ...Object.keys(queryParams).length > 0 ? { queryParams } : {}
107
+ };
108
+ }
109
+ function editorValueFromAuthentication(template) {
110
+ if (template.type === "oauth") {
111
+ return {
112
+ kind: "oauth",
113
+ authorizationUrl: template.authorizationUrl ?? "",
114
+ tokenUrl: template.tokenUrl ?? "",
115
+ scopes: template.scopes ?? []
116
+ };
117
+ }
118
+ return { kind: "apikey", placements: placementsFromApiKey(template) };
119
+ }
120
+ var oauthTemplateFromEditorValue = (value, slug) => ({
121
+ slug: AuthTemplateSlug.make(slug ?? ""),
122
+ type: "oauth",
123
+ authorizationUrl: value.authorizationUrl,
124
+ tokenUrl: value.tokenUrl,
125
+ scopes: [...value.scopes]
126
+ });
127
+ function authenticationFromEditorValue(value, slug) {
128
+ if (value.kind === "none") return null;
129
+ if (value.kind === "oauth") return oauthTemplateFromEditorValue(value, slug);
130
+ return templateFromPlacements(value.placements, slug);
131
+ }
132
+
133
+ export {
134
+ authMethodsFromConfig,
135
+ templateFromPlacements,
136
+ editorValueFromAuthentication,
137
+ authenticationFromEditorValue
138
+ };
139
+ //# sourceMappingURL=chunk-QSSRVK6M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/auth-method-config.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// OpenAPI ↔ generic auth-method converters.\n//\n// The generic Accounts hub speaks in plugin-agnostic `AuthMethod` /\n// `Placement` values (`@executor-js/react/lib/auth-placements`). The OpenAPI\n// plugin stores auth as the HTTP-transport-specific `APIKeyAuthentication`\n// template (header/query slots templated with `variable(\"token\")`). These two\n// converters bridge the wire template to/from the generic placement model, so\n// they live with the OpenAPI plugin — they touch the openapi sdk\n// `Authentication` types and would pull transport specifics into core.\n// ---------------------------------------------------------------------------\n\nimport { AuthTemplateSlug } from \"@executor-js/sdk/shared\";\nimport type { AuthMethod, Placement } from \"@executor-js/react/lib/auth-placements\";\nimport type { AuthTemplateEditorValue } from \"@executor-js/react/components/auth-template-editor\";\n\nimport {\n TOKEN_VARIABLE,\n variable,\n type APIKeyAuthentication,\n type Authentication,\n type AuthenticationTemplateValue,\n} from \"../sdk/types\";\n\n// ---------------------------------------------------------------------------\n// Template value → placement prefix.\n//\n// A header/query slot serializes the credential as `name -> [prefix, token]`,\n// where `prefix` is the leading literal string before the `variable(\"token\")`\n// part. A bare `[token]` (or string-only) value has an empty prefix.\n// ---------------------------------------------------------------------------\n\nconst isVariablePart = (part: string | { readonly type: \"variable\"; readonly name: string }) =>\n typeof part !== \"string\" && part.type === \"variable\";\n\n/** Extract the literal prefix preceding the credential variable, plus the\n * variable name that placement renders from (`token` for single-input methods,\n * a distinct name per input for multi-input ones). */\nconst parseTemplateValue = (\n value: AuthenticationTemplateValue,\n): { readonly prefix: string; readonly variable: string } => {\n if (typeof value === \"string\") return { prefix: \"\", variable: TOKEN_VARIABLE };\n const parts: string[] = [];\n for (const part of value) {\n if (isVariablePart(part)) {\n return { prefix: parts.join(\"\"), variable: (part as { readonly name: string }).name };\n }\n if (typeof part === \"string\") parts.push(part);\n }\n return { prefix: parts.join(\"\"), variable: TOKEN_VARIABLE };\n};\n\nexport const placementsFromApiKey = (template: APIKeyAuthentication): Placement[] => {\n const placements: Placement[] = [];\n for (const [name, value] of Object.entries(template.headers ?? {})) {\n const { prefix, variable } = parseTemplateValue(value);\n placements.push({ carrier: \"header\", name, prefix, variable });\n }\n for (const [name, value] of Object.entries(template.queryParams ?? {})) {\n const { prefix, variable } = parseTemplateValue(value);\n placements.push({ carrier: \"query\", name, prefix, variable });\n }\n return placements;\n};\n\n// ---------------------------------------------------------------------------\n// Templates → generic methods.\n// ---------------------------------------------------------------------------\n\nconst labelForApiKey = (slug: string, placements: readonly Placement[]): string => {\n const first = placements[0];\n if (first) return `API key (${first.name || (first.carrier === \"header\" ? \"header\" : \"query\")})`;\n return `API key (${slug})`;\n};\n\n/** Map each stored auth template to a generic `AuthMethod`. */\nexport function authMethodsFromConfig(templates: readonly Authentication[]): AuthMethod[] {\n return templates.map((template: Authentication): AuthMethod => {\n const slug = String(template.slug);\n const source: \"spec\" | \"custom\" = slug.startsWith(\"custom_\") ? \"custom\" : \"spec\";\n if (template.type === \"oauth\") {\n return {\n id: slug,\n label: \"OAuth2\",\n kind: \"oauth\",\n source,\n template: AuthTemplateSlug.make(slug),\n placements: [],\n // Carry the integration's declared endpoints/scopes so the\n // client-registration form pre-fills them.\n oauth: {\n authorizationUrl: template.authorizationUrl,\n tokenUrl: template.tokenUrl,\n scopes: template.scopes,\n },\n };\n }\n const placements = placementsFromApiKey(template);\n return {\n id: slug,\n label: labelForApiKey(slug, placements),\n kind: \"apikey\",\n source,\n template: AuthTemplateSlug.make(slug),\n placements,\n };\n });\n}\n\n// ---------------------------------------------------------------------------\n// Generic placements → apiKey template (inverse).\n//\n// Each placement becomes a header/query slot whose value is\n// `prefix ? [prefix, variable(\"token\")] : [variable(\"token\")]`. A custom method\n// may omit `slug`; the backend backfills `custom_<id>`.\n// ---------------------------------------------------------------------------\n\n/** Slugify a placement name into a variable identifier: `DD-API-KEY` →\n * `dd_api_key`. */\nconst slugifyVariable = (name: string): string =>\n name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n\n/** Assign an input variable to each (named) placement. A lone input is the\n * canonical `token`; multiple inputs each get their own distinct variable so a\n * connection can carry a different value per location. An explicit\n * `placement.variable` (from a round-trip) is honored. */\nconst assignVariables = (placements: readonly Placement[]): Map<Placement, string> => {\n const named = placements.filter((p) => p.name);\n const out = new Map<Placement, string>();\n if (named.length <= 1) {\n for (const p of named) out.set(p, p.variable ?? TOKEN_VARIABLE);\n return out;\n }\n const taken = new Set<string>();\n for (const p of named) {\n const base = slugifyVariable(p.name) || \"input\";\n let candidate = p.variable ?? base;\n let n = 2;\n while (taken.has(candidate)) candidate = `${base}_${n++}`;\n taken.add(candidate);\n out.set(p, candidate);\n }\n return out;\n};\n\nconst valueFromPlacement = (placement: Placement, varName: string): AuthenticationTemplateValue =>\n placement.prefix ? [placement.prefix, variable(varName)] : [variable(varName)];\n\n/** Build an `APIKeyAuthentication` template from generic placements. When\n * `slug` is omitted the backend assigns a `custom_<id>` slug. */\nexport function templateFromPlacements(\n placements: readonly Placement[],\n slug?: string,\n): APIKeyAuthentication {\n const variables = assignVariables(placements);\n const headers: Record<string, AuthenticationTemplateValue> = {};\n const queryParams: Record<string, AuthenticationTemplateValue> = {};\n for (const placement of placements) {\n if (!placement.name) continue;\n const varName = variables.get(placement) ?? TOKEN_VARIABLE;\n if (placement.carrier === \"header\") {\n headers[placement.name] = valueFromPlacement(placement, varName);\n } else {\n queryParams[placement.name] = valueFromPlacement(placement, varName);\n }\n }\n return {\n slug: AuthTemplateSlug.make(slug ?? \"\"),\n type: \"apiKey\",\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n ...(Object.keys(queryParams).length > 0 ? { queryParams } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Stored `Authentication` ⇆ generic `AuthTemplateEditorValue`.\n//\n// The shared add-time `AuthTemplateEditor` edits a plugin-agnostic value; these\n// bridge it to/from the OpenAPI wire template so a spec-detected method seeds an\n// editable default and the user's edits round-trip back to `Authentication[]`\n// on submit. apiKey → placements; oauth → endpoints + scopes.\n// ---------------------------------------------------------------------------\n\n/** Convert one stored `Authentication` template into a generic editor value. */\nexport function editorValueFromAuthentication(template: Authentication): AuthTemplateEditorValue {\n if (template.type === \"oauth\") {\n return {\n kind: \"oauth\",\n authorizationUrl: template.authorizationUrl ?? \"\",\n tokenUrl: template.tokenUrl ?? \"\",\n scopes: template.scopes ?? [],\n };\n }\n return { kind: \"apikey\", placements: placementsFromApiKey(template) };\n}\n\n/** Build an `OAuthAuthentication` template from a generic oauth editor value. */\nconst oauthTemplateFromEditorValue = (\n value: Extract<AuthTemplateEditorValue, { kind: \"oauth\" }>,\n slug?: string,\n): Authentication => ({\n slug: AuthTemplateSlug.make(slug ?? \"\"),\n type: \"oauth\",\n authorizationUrl: value.authorizationUrl,\n tokenUrl: value.tokenUrl,\n scopes: [...value.scopes],\n});\n\n/** Convert one generic editor value back into a stored `Authentication`, or\n * `null` for `none` (no method to register). The optional `slug` names the\n * template; when omitted the backend backfills `custom_<id>`. */\nexport function authenticationFromEditorValue(\n value: AuthTemplateEditorValue,\n slug?: string,\n): Authentication | null {\n if (value.kind === \"none\") return null;\n if (value.kind === \"oauth\") return oauthTemplateFromEditorValue(value, slug);\n return templateFromPlacements(value.placements, slug);\n}\n"],"mappings":";;;;;;AAYA,SAAS,wBAAwB;AAoBjC,IAAM,iB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