@executor-js/plugin-openapi 1.5.10 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AddOpenApiSource-7O4LSD7C.js → AddOpenApiSource-JFSFWLBZ.js} +45 -11
- package/dist/AddOpenApiSource-JFSFWLBZ.js.map +1 -0
- package/dist/{OpenApiAccountsPanel-7XT6ZMD5.js → OpenApiAccountsPanel-2LHWUKIE.js} +3 -3
- package/dist/UpdateSpecSection-D32QZT3Q.js +104 -0
- package/dist/UpdateSpecSection-D32QZT3Q.js.map +1 -0
- package/dist/api/group.d.ts +37 -2
- package/dist/api/index.d.ts +41 -1
- package/dist/{chunk-WJQIWTZF.js → chunk-3XJSXSED.js} +78 -5
- package/dist/chunk-3XJSXSED.js.map +1 -0
- package/dist/{chunk-C6PH4R7Q.js → chunk-I2XDCVVM.js} +2 -2
- package/dist/{chunk-C3IJX4AN.js → chunk-RFSMGUBJ.js} +7 -1
- package/dist/chunk-RFSMGUBJ.js.map +1 -0
- package/dist/{chunk-IB36ED7Y.js → chunk-UJTNRH4Q.js} +32 -3
- package/dist/chunk-UJTNRH4Q.js.map +1 -0
- package/dist/client.js +5 -5
- package/dist/client.js.map +1 -1
- package/dist/core.js +3 -3
- package/dist/index.js +3 -3
- package/dist/react/OpenApiSourceDetailsFields.d.ts +4 -1
- package/dist/react/UpdateSpecSection.d.ts +2 -0
- package/dist/react/atoms.d.ts +32 -0
- package/dist/react/client.d.ts +34 -1
- package/dist/sdk/extract.d.ts +1 -0
- package/dist/sdk/plugin.d.ts +29 -2
- package/dist/sdk/preview.d.ts +4 -0
- package/dist/sdk/types.d.ts +2 -0
- package/package.json +3 -3
- package/dist/AddOpenApiSource-7O4LSD7C.js.map +0 -1
- package/dist/EditOpenApiSource-GIN5RQPL.js +0 -68
- package/dist/EditOpenApiSource-GIN5RQPL.js.map +0 -1
- package/dist/chunk-C3IJX4AN.js.map +0 -1
- package/dist/chunk-IB36ED7Y.js.map +0 -1
- package/dist/chunk-WJQIWTZF.js.map +0 -1
- package/dist/react/EditOpenApiSource.d.ts +0 -4
- /package/dist/{OpenApiAccountsPanel-7XT6ZMD5.js.map → OpenApiAccountsPanel-2LHWUKIE.js.map} +0 -0
- /package/dist/{chunk-C6PH4R7Q.js.map → chunk-I2XDCVVM.js.map} +0 -0
package/dist/sdk/preview.d.ts
CHANGED
|
@@ -103,6 +103,8 @@ export declare const PreviewOperation: Schema.Struct<{
|
|
|
103
103
|
export type PreviewOperation = typeof PreviewOperation.Type;
|
|
104
104
|
export declare const SpecPreview: Schema.Struct<{
|
|
105
105
|
readonly title: Schema.OptionFromOptional<Schema.String>;
|
|
106
|
+
/** The spec's `info.description` — prefills the add form's description field. */
|
|
107
|
+
readonly description: Schema.OptionFromOptional<Schema.String>;
|
|
106
108
|
readonly version: Schema.OptionFromOptional<Schema.String>;
|
|
107
109
|
/** Reuses ServerInfo from extraction */
|
|
108
110
|
readonly servers: Schema.$Array<Schema.Struct<{
|
|
@@ -203,6 +205,7 @@ export declare const previewSpecText: (specText: string) => Effect.Effect<{
|
|
|
203
205
|
readonly tags: readonly string[];
|
|
204
206
|
readonly operationId: string;
|
|
205
207
|
}[];
|
|
208
|
+
readonly description: Option.Option<string>;
|
|
206
209
|
readonly title: Option.Option<string>;
|
|
207
210
|
readonly servers: readonly {
|
|
208
211
|
readonly description: Option.Option<string>;
|
|
@@ -279,6 +282,7 @@ export declare const previewSpec: (input: string) => Effect.Effect<{
|
|
|
279
282
|
readonly tags: readonly string[];
|
|
280
283
|
readonly operationId: string;
|
|
281
284
|
}[];
|
|
285
|
+
readonly description: Option.Option<string>;
|
|
282
286
|
readonly title: Option.Option<string>;
|
|
283
287
|
readonly servers: readonly {
|
|
284
288
|
readonly description: Option.Option<string>;
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -157,6 +157,8 @@ export declare const ExtractedOperation: Schema.Struct<{
|
|
|
157
157
|
export type ExtractedOperation = typeof ExtractedOperation.Type;
|
|
158
158
|
export declare const ExtractionResult: Schema.Struct<{
|
|
159
159
|
readonly title: Schema.OptionFromOptional<Schema.String>;
|
|
160
|
+
/** The spec's `info.description` — the author's own summary of the API. */
|
|
161
|
+
readonly description: Schema.OptionFromOptional<Schema.String>;
|
|
160
162
|
readonly version: Schema.OptionFromOptional<Schema.String>;
|
|
161
163
|
readonly servers: Schema.$Array<Schema.Struct<{
|
|
162
164
|
readonly url: Schema.String;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@executor-js/plugin-openapi",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.12",
|
|
4
4
|
"homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/plugins/openapi",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/RhysSullivan/executor/issues"
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@effect/platform-node": "4.0.0-beta.59",
|
|
56
|
-
"@executor-js/config": "1.5.
|
|
57
|
-
"@executor-js/sdk": "1.5.
|
|
56
|
+
"@executor-js/config": "1.5.12",
|
|
57
|
+
"@executor-js/sdk": "1.5.12",
|
|
58
58
|
"lucide-react": "^1.7.0",
|
|
59
59
|
"openapi-types": "^12.1.3",
|
|
60
60
|
"yaml": "^2.7.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/AddOpenApiSource.tsx","../src/react/OpenApiSourceDetailsFields.tsx","../src/react/GoogleProductPicker.tsx","../src/sdk/google-oauth-batches.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAtomSet } from \"@effect/atom-react\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as Option from \"effect/Option\";\n\nimport { IntegrationSlug } from \"@executor-js/sdk/shared\";\nimport { integrationWriteKeys } from \"@executor-js/react/api/reactivity-keys\";\nimport {\n slugifyNamespace,\n useIntegrationIdentity,\n} from \"@executor-js/react/plugins/integration-identity\";\nimport { Button } from \"@executor-js/react/components/button\";\nimport {\n AuthMethodListEditor,\n useAuthMethodList,\n type AuthMethodRow,\n type AuthMethodSeed,\n} from \"@executor-js/react/components/auth-method-list-editor\";\nimport { CardStack, CardStackContent } from \"@executor-js/react/components/card-stack\";\nimport { FieldLabel } from \"@executor-js/react/components/field\";\nimport { FloatActions } from \"@executor-js/react/components/float-actions\";\nimport { Textarea } from \"@executor-js/react/components/textarea\";\nimport { IOSSpinner, Spinner } from \"@executor-js/react/components/spinner\";\nimport {\n addIntegrationErrorMessage,\n errorMessageFromExit,\n FormErrorAlert,\n SlugCollisionAlert,\n useSlugAlreadyExists,\n} from \"@executor-js/react/lib/integration-add\";\n\nimport {\n authenticationFromEditorValue,\n editorValueFromAuthentication,\n openApiWireAuthInput,\n} from \"./auth-method-config\";\nimport { addOpenApiSpec, previewOpenApiSpec } from \"./atoms\";\nimport { OpenApiSourceDetailsFields } from \"./OpenApiSourceDetailsFields\";\nimport { GoogleProductPicker } from \"./GoogleProductPicker\";\nimport { openApiPresets } from \"../sdk/presets\";\nimport {\n GOOGLE_BUNDLE_PRESET_ID,\n googleOpenApiPresets,\n type GoogleOpenApiPreset,\n} from \"../sdk/google-presets\";\nimport type { SpecPreview } from \"../sdk/preview\";\nimport { type Authentication } from \"../sdk/types\";\nimport { resolveServerUrl } from \"../sdk/openapi-utils\";\nimport { detectedAuthenticationTemplates } from \"../sdk/derive-auth\";\n\nconst GOOGLE_BUNDLE_FAVICON = \"https://fonts.gstatic.com/s/i/productlogos/googleg/v6/192px.svg\";\n\n// The bundle picker opens with the featured Google APIs pre-checked.\nconst googleBundleDefaultPresetIds: ReadonlySet<string> = new Set(\n googleOpenApiPresets\n .filter((preset: GoogleOpenApiPreset) => preset.featured)\n .map((preset: GoogleOpenApiPreset) => preset.id),\n);\n\nconst googleBundleUrls = (\n selectedPresetIds: ReadonlySet<string>,\n customUrls: readonly string[],\n): readonly string[] => {\n const fromPresets = googleOpenApiPresets.flatMap((preset: GoogleOpenApiPreset) =>\n preset.url && selectedPresetIds.has(preset.id) ? [preset.url] : [],\n );\n // Preset URLs first (stable order), then any custom Discovery URLs, de-duped.\n return [...new Set([...fromPresets, ...customUrls])];\n};\n\nconst 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\nconst normalizePresetUrl = (url: string): string => {\n const trimmed = url.trim();\n if (!URL.canParse(trimmed)) return trimmed.replace(/\\/$/, \"\");\n const parsed = new URL(trimmed);\n parsed.hash = \"\";\n parsed.searchParams.sort();\n return parsed.toString().replace(/\\/$/, \"\");\n};\n\nconst specInputForAdd = (input: string) => {\n const value = input.trim();\n const parsed = Effect.runSyncExit(\n Effect.try({\n try: () => new URL(value),\n catch: () => null,\n }),\n );\n return Exit.isSuccess(parsed)\n ? isGoogleDiscoveryUrl(value)\n ? { kind: \"googleDiscovery\" as const, url: value }\n : { kind: \"url\" as const, url: value }\n : { kind: \"blob\" as const, value };\n};\n\n// ---------------------------------------------------------------------------\n// Component — single progressive form. Post-redesign: preview → addSpec\n// (register the integration catalog entry with ALL detected auth methods) →\n// route to the integration's detail hub, where the user adds accounts. The add\n// flow no longer creates a connection.\n// ---------------------------------------------------------------------------\n\nexport default function AddOpenApiSource(props: {\n onComplete: (slug?: string) => void;\n onCancel: () => void;\n initialUrl?: string;\n initialPreset?: string;\n initialNamespace?: string;\n}) {\n const isGoogleBundlePreset = props.initialPreset === GOOGLE_BUNDLE_PRESET_ID;\n\n // Spec input. For the Google BUNDLE preset the input is a product picker (a set\n // of selected Discovery URLs), not a single spec URL/blob — the merge happens\n // server-side via `{ kind: \"googleDiscoveryBundle\", urls }`, so the textarea\n // preview path is bypassed entirely.\n const [specUrl, setSpecUrl] = useState(props.initialUrl ?? \"\");\n const [selectedPresetIds, setSelectedPresetIds] = useState<ReadonlySet<string>>(\n googleBundleDefaultPresetIds,\n );\n const [customDiscoveryUrls, setCustomDiscoveryUrls] = useState<readonly string[]>([]);\n const [analyzing, setAnalyzing] = useState(false);\n const [analyzeError, setAnalyzeError] = useState<string | null>(null);\n\n // After analysis\n const [preview, setPreview] = useState<SpecPreview | null>(null);\n const [baseUrl, setBaseUrl] = useState(\"\");\n const identityFallbackName = isGoogleBundlePreset\n ? \"Google\"\n : preview\n ? Option.getOrElse(preview.title, () => \"\")\n : \"\";\n const identity = useIntegrationIdentity({\n fallbackName: identityFallbackName,\n fallbackNamespace: props.initialNamespace ?? (isGoogleBundlePreset ? \"google\" : undefined),\n });\n\n const bundleDiscoveryUrls = useMemo(\n () => googleBundleUrls(selectedPresetIds, customDiscoveryUrls),\n [selectedPresetIds, customDiscoveryUrls],\n );\n\n const toggleBundlePreset = useCallback((presetId: string, checked: boolean) => {\n setSelectedPresetIds((current: ReadonlySet<string>) => {\n const next = new Set(current);\n if (checked) next.add(presetId);\n else next.delete(presetId);\n return next;\n });\n }, []);\n\n const addCustomDiscoveryUrl = useCallback((url: string) => {\n setCustomDiscoveryUrls((current: readonly string[]) =>\n current.includes(url) ? current : [...current, url],\n );\n }, []);\n\n const removeCustomDiscoveryUrl = useCallback((url: string) => {\n setCustomDiscoveryUrls((current: readonly string[]) =>\n current.filter((entry: string) => entry !== url),\n );\n }, []);\n\n // Submit\n const [adding, setAdding] = useState(false);\n const [addError, setAddError] = useState<string | null>(null);\n\n const doPreview = useAtomSet(previewOpenApiSpec, { mode: \"promiseExit\" });\n const doAdd = useAtomSet(addOpenApiSpec, { mode: \"promiseExit\" });\n\n // Keep the latest handleAnalyze in a ref so the debounced effect doesn't need\n // it as a dependency (it closes over fresh state).\n const handleAnalyzeRef = useRef<() => void>(() => {});\n\n useEffect(() => {\n // The bundle preset never analyzes a single spec — its input is the picker.\n if (isGoogleBundlePreset) return;\n const trimmed = specUrl.trim();\n if (!trimmed) return;\n if (preview) return;\n const handle = setTimeout(() => {\n handleAnalyzeRef.current();\n }, 400);\n return () => clearTimeout(handle);\n }, [specUrl, preview, isGoogleBundlePreset]);\n\n // ---- Derived state ----\n\n const previewHasNoServers = preview !== null && preview.servers.length === 0;\n // Offer the spec's servers (resolved with defaults) as base-URL choices when\n // there's more than one; a single/no server uses a plain input.\n const baseUrlOptions =\n preview && preview.servers.length > 1\n ? preview.servers.map((server) => {\n const url = resolveServerUrl(server.url, Option.getOrUndefined(server.variables), {});\n return { value: url, label: url };\n })\n : undefined;\n const firstServer = preview?.servers[0];\n const firstServerUrl = firstServer\n ? resolveServerUrl(firstServer.url, Option.getOrUndefined(firstServer.variables), {})\n : \"\";\n const previewPresetIcon =\n openApiPresets.find(\n (preset) => preset.url && normalizePresetUrl(preset.url) === normalizePresetUrl(specUrl),\n )?.icon ?? null;\n\n const resolvedBaseUrl = baseUrl.trim();\n const resolvedSourceId =\n slugifyNamespace(identity.namespace) ||\n (preview ? Option.getOrElse(preview.title, () => \"openapi\") : \"openapi\");\n const resolvedDisplayName =\n identity.name.trim() ||\n (preview ? Option.getOrElse(preview.title, () => resolvedSourceId) : resolvedSourceId);\n\n // Register EVERY spec-detected auth method, not just a single selected one.\n // Keyed off `preview` (stable per analysis) so the memo doesn't re-run on the\n // freshly-allocated `?? []` fallback arrays.\n const authenticationTemplate: readonly Authentication[] = useMemo(\n () =>\n detectedAuthenticationTemplates(\n preview?.headerPresets ?? [],\n preview?.oauth2Presets ?? [],\n resolvedBaseUrl,\n ),\n [preview, resolvedBaseUrl],\n );\n\n // Editable auth methods, seeded from the spec-detected templates. The add flow\n // registers EVERY method (P6) — so this is a LIST, preserving multi-method\n // specs (e.g. apiKey + OAuth). Each seed carries the detected template's\n // original slug, so an unedited detected method submits with its EXACT\n // original slug (preserving behavior); added methods (no seed) get a\n // deterministic fresh slug. Re-seeded whenever a fresh detection arrives\n // (keyed on the detected templates, stable per analysis + base URL).\n const authMethodSeeds: readonly AuthMethodSeed[] = useMemo(() => {\n const labels = [\n ...(preview?.headerPresets ?? []).map((preset) => preset.label),\n ...(preview?.oauth2Presets ?? []).map((preset) => preset.label),\n ];\n return authenticationTemplate.map(\n (template: Authentication, index: number): AuthMethodSeed => ({\n value: editorValueFromAuthentication(template),\n slug: String(template.slug),\n ...(labels[index] !== undefined ? { label: labels[index] } : {}),\n }),\n );\n }, [preview, authenticationTemplate]);\n const authMethodList = useAuthMethodList(authMethodSeeds);\n\n // The methods to register, mapped back to stored `Authentication[]`. Drops\n // `none` rows (nothing to register). An unedited detected method keeps its\n // original `seedSlug`; an added method gets a deterministic fresh slug.\n const editedAuthenticationTemplate: readonly Authentication[] = useMemo(() => {\n const templates: Authentication[] = [];\n authMethodList.rows.forEach((row: AuthMethodRow, index: number) => {\n const slug =\n row.seedSlug ?? (row.value.kind === \"oauth\" ? `oauth-${index}` : `apikey-${index}`);\n const template = authenticationFromEditorValue(row.value, slug);\n if (template !== null) templates.push(template);\n });\n return templates;\n }, [authMethodList.rows]);\n\n // Pre-empt the API's `IntegrationAlreadyExistsError`: adding an integration\n // whose slug already exists clobbers the existing one's connections/policies,\n // so the API blocks it. Surface that here from the tenant-scoped catalog list.\n const slugAlreadyExists = useSlugAlreadyExists(resolvedSourceId);\n\n // The bundle path is ready once at least one Google API is selected (no\n // network preview gates it); the single/custom-spec path still requires a\n // successful preview. Both require a base URL and a free slug.\n const hasPreviewOrBundle = isGoogleBundlePreset\n ? bundleDiscoveryUrls.length > 0\n : preview !== null;\n // The base URL is optional when the spec declares servers (resolved per call);\n // required only when it doesn't.\n const canAdd =\n hasPreviewOrBundle &&\n !slugAlreadyExists &&\n (!previewHasNoServers || resolvedBaseUrl.length > 0);\n\n // ---- Handlers ----\n\n const handleAnalyze = async () => {\n setAnalyzing(true);\n setAnalyzeError(null);\n setAddError(null);\n const exit = await doPreview({ payload: { spec: specUrl } });\n if (Exit.isFailure(exit)) {\n setAnalyzeError(errorMessageFromExit(exit, \"Failed to parse spec\"));\n setAnalyzing(false);\n return;\n }\n const result = exit.value;\n setPreview(result);\n setBaseUrl(\"\");\n setAnalyzing(false);\n };\n\n handleAnalyzeRef.current = handleAnalyze;\n\n // Persist the integration and return its slug. Registers the catalog entry\n // with every detected auth method. Adding a slug that already exists is\n // rejected by the API (`IntegrationAlreadyExistsError`) — surfaced inline.\n const ensureIntegration = useCallback(async (): Promise<IntegrationSlug | null> => {\n // The Google BUNDLE preset emits the multi-service bundle input; the server\n // merges the selected Discovery documents into one `google` spec and stores\n // the unioned `googleOAuth2` auth template (so no client template is sent).\n // Every other preset/custom input keeps the single-spec url/blob/discovery\n // branch unchanged.\n const specForAdd = isGoogleBundlePreset\n ? ({ kind: \"googleDiscoveryBundle\" as const, urls: [...bundleDiscoveryUrls] } satisfies {\n readonly kind: \"googleDiscoveryBundle\";\n readonly urls: readonly string[];\n })\n : specInputForAdd(specUrl);\n const exit = await doAdd({\n payload: {\n spec: specForAdd,\n slug: resolvedSourceId,\n description: resolvedDisplayName,\n baseUrl: resolvedBaseUrl,\n // Always send the edited method list (even empty) when the user has\n // inspected a preview: an explicit [] means \"no auth methods\", while\n // OMITTING the field tells the server to derive defaults from the\n // spec — which would silently resurrect methods the user deleted.\n // The Google bundle path stays omitted; its auth is converter-derived\n // server-side.\n ...(!isGoogleBundlePreset\n ? {\n // Serialize to the wire input dialect (apikey → request-shaped).\n authenticationTemplate: editedAuthenticationTemplate.map(openApiWireAuthInput),\n }\n : {}),\n },\n reactivityKeys: integrationWriteKeys,\n });\n if (Exit.isFailure(exit)) {\n setAddError(addIntegrationErrorMessage(exit, resolvedSourceId, \"Failed to add integration\"));\n return null;\n }\n return exit.value.slug;\n }, [\n isGoogleBundlePreset,\n bundleDiscoveryUrls,\n specUrl,\n doAdd,\n resolvedSourceId,\n resolvedDisplayName,\n resolvedBaseUrl,\n editedAuthenticationTemplate,\n ]);\n\n const handleAdd = async () => {\n setAdding(true);\n setAddError(null);\n\n const integration = await ensureIntegration();\n if (!integration) {\n setAdding(false);\n return;\n }\n\n props.onComplete(String(integration));\n };\n\n // ---- Render ----\n\n return (\n <div className=\"flex flex-1 flex-col gap-6\">\n <div>\n <h1 className=\"text-xl font-semibold text-foreground\">\n {isGoogleBundlePreset ? \"Add Google\" : \"Add OpenAPI Integration\"}\n </h1>\n {isGoogleBundlePreset ? (\n <p className=\"mt-1 text-[13px] text-muted-foreground\">\n Bundle Google APIs into one integration from their Discovery documents and register\n their methods as tools under a single shared OAuth consent.\n </p>\n ) : null}\n </div>\n\n {isGoogleBundlePreset ? (\n <GoogleProductPicker\n selectedPresetIds={selectedPresetIds}\n onToggle={toggleBundlePreset}\n customUrls={customDiscoveryUrls}\n onAddCustomUrl={addCustomDiscoveryUrl}\n onRemoveCustomUrl={removeCustomDiscoveryUrl}\n />\n ) : !preview ? (\n <CardStack>\n <CardStackContent className=\"border-t-0\">\n <div className=\"space-y-2 p-3\">\n <FieldLabel>OpenAPI Spec</FieldLabel>\n <div className=\"relative\">\n <Textarea\n value={specUrl}\n onChange={(e) => setSpecUrl((e.target as HTMLTextAreaElement).value)}\n placeholder=\"https://api.example.com/openapi.json\"\n rows={3}\n maxRows={10}\n className=\"font-mono text-sm\"\n />\n {analyzing && (\n <div className=\"pointer-events-none absolute right-2 top-2\">\n <IOSSpinner className=\"size-4\" />\n </div>\n )}\n </div>\n <p className=\"text-[11px] text-muted-foreground\">\n Paste a URL or raw JSON/YAML content.\n </p>\n </div>\n </CardStackContent>\n </CardStack>\n ) : null}\n\n {isGoogleBundlePreset ? (\n <OpenApiSourceDetailsFields\n title=\"Google\"\n description={`${bundleDiscoveryUrls.length} Google API${\n bundleDiscoveryUrls.length !== 1 ? \"s\" : \"\"\n } · one shared OAuth consent`}\n identity={identity}\n baseUrl={resolvedBaseUrl}\n onBaseUrlChange={setBaseUrl}\n baseUrlLabel=\"Base URL override (optional)\"\n faviconIcon={GOOGLE_BUNDLE_FAVICON}\n faviconUrl={resolvedBaseUrl}\n />\n ) : preview ? (\n <OpenApiSourceDetailsFields\n title={Option.getOrElse(preview.title, () => \"API\")}\n description={`${Option.getOrElse(preview.version, () => \"\")}${\n Option.isSome(preview.version) ? \" · \" : \"\"\n }${preview.operationCount} operation${preview.operationCount !== 1 ? \"s\" : \"\"}${\n preview.tags.length > 0\n ? ` · ${preview.tags.length} tag${preview.tags.length !== 1 ? \"s\" : \"\"}`\n : \"\"\n }`}\n identity={identity}\n baseUrl={resolvedBaseUrl}\n onBaseUrlChange={setBaseUrl}\n baseUrlOptions={baseUrlOptions}\n baseUrlLabel={previewHasNoServers ? \"Base URL\" : \"Base URL override (optional)\"}\n baseUrlPlaceholder={firstServerUrl || \"https://api.example.com\"}\n baseUrlHint={\n previewHasNoServers\n ? undefined\n : \"Overrides the spec's servers; leave empty to choose the server (and variables) per tool call.\"\n }\n baseUrlMissingMessage={\n previewHasNoServers ? \"This spec declares no servers — enter a base URL.\" : undefined\n }\n specUrl={specUrl}\n onSpecUrlChange={(value) => {\n setSpecUrl(value);\n setPreview(null);\n setBaseUrl(\"\");\n }}\n faviconIcon={previewPresetIcon}\n faviconUrl={resolvedBaseUrl || firstServerUrl}\n />\n ) : null}\n\n {analyzeError && <FormErrorAlert message={analyzeError} />}\n\n {preview && !isGoogleBundlePreset && (\n <AuthMethodListEditor\n list={authMethodList}\n emptyHint=\"No authentication detected. Add a method, or add the integration without auth and connect an account from the integration page later.\"\n footerHint=\"Every method here is registered with the integration. Connect an account from the integration page after adding.\"\n />\n )}\n\n {hasPreviewOrBundle && slugAlreadyExists && !adding && (\n <SlugCollisionAlert slug={resolvedSourceId} />\n )}\n\n {addError && <FormErrorAlert message={addError} />}\n\n <FloatActions>\n <Button variant=\"ghost\" onClick={() => props.onCancel()} disabled={adding}>\n Cancel\n </Button>\n {(hasPreviewOrBundle || isGoogleBundlePreset) && (\n <Button onClick={() => void handleAdd()} disabled={!canAdd || adding}>\n {adding && <Spinner className=\"size-3.5\" />}\n {adding ? \"Adding…\" : isGoogleBundlePreset ? \"Connect Google\" : \"Add integration\"}\n </Button>\n )}\n </FloatActions>\n </div>\n );\n}\n","import {\n CardStack,\n CardStackContent,\n CardStackEntry,\n CardStackEntryContent,\n CardStackEntryDescription,\n CardStackEntryField,\n CardStackEntryTitle,\n} from \"@executor-js/react/components/card-stack\";\nimport {\n FreeformCombobox,\n type FreeformComboboxOption,\n} from \"@executor-js/react/components/combobox\";\nimport { Input } from \"@executor-js/react/components/input\";\nimport { IntegrationFavicon } from \"@executor-js/react/components/integration-favicon\";\nimport {\n IntegrationIdentityFieldRows,\n type IntegrationIdentity,\n} from \"@executor-js/react/plugins/integration-identity\";\n\nexport function OpenApiSourceDetailsFields(props: {\n readonly title: string;\n readonly description?: string;\n readonly identity: IntegrationIdentity;\n readonly baseUrl: string;\n readonly onBaseUrlChange: (value: string) => void;\n readonly baseUrlOptions?: readonly FreeformComboboxOption[];\n readonly baseUrlLabel?: string;\n readonly baseUrlPlaceholder?: string;\n readonly baseUrlHint?: string;\n readonly specUrl?: string;\n readonly onSpecUrlChange?: (value: string) => void;\n readonly faviconIcon?: string | null;\n readonly faviconUrl?: string;\n readonly namespaceReadOnly?: boolean;\n readonly specUrlDisabled?: boolean;\n readonly saveState?: \"idle\" | \"saving\" | \"saved\";\n readonly baseUrlMissingMessage?: string;\n readonly footer?: string;\n}) {\n return (\n <CardStack>\n <CardStackContent className=\"border-t-0\">\n <CardStackEntry>\n {(props.faviconIcon || props.faviconUrl) && (\n <IntegrationFavicon icon={props.faviconIcon} url={props.faviconUrl} size={16} />\n )}\n <CardStackEntryContent>\n <CardStackEntryTitle>{props.title}</CardStackEntryTitle>\n {props.description && (\n <CardStackEntryDescription>{props.description}</CardStackEntryDescription>\n )}\n </CardStackEntryContent>\n {props.saveState && props.saveState !== \"idle\" && (\n <span className=\"text-xs text-muted-foreground\">\n {props.saveState === \"saving\" ? \"Saving…\" : \"Saved\"}\n </span>\n )}\n </CardStackEntry>\n <IntegrationIdentityFieldRows\n identity={props.identity}\n namespaceReadOnly={props.namespaceReadOnly}\n />\n <div className=\"grid grid-cols-1 md:grid-cols-2\">\n <CardStackEntryField label={props.baseUrlLabel ?? \"Base URL\"}>\n {props.baseUrlOptions && props.baseUrlOptions.length > 0 ? (\n <FreeformCombobox\n value={props.baseUrl}\n onValueChange={props.onBaseUrlChange}\n options={props.baseUrlOptions}\n placeholder={props.baseUrlPlaceholder ?? \"https://api.example.com\"}\n className=\"w-full\"\n inputClassName=\"font-mono text-sm\"\n />\n ) : (\n <Input\n value={props.baseUrl}\n onChange={(e) => props.onBaseUrlChange((e.target as HTMLInputElement).value)}\n placeholder={props.baseUrlPlaceholder ?? \"https://api.example.com\"}\n className=\"font-mono text-sm\"\n />\n )}\n\n {props.baseUrlMissingMessage && !props.baseUrl && (\n <p className=\"text-[11px] text-amber-600 dark:text-amber-400\">\n {props.baseUrlMissingMessage}\n </p>\n )}\n {props.baseUrlHint && (\n <p className=\"text-[11px] text-muted-foreground\">{props.baseUrlHint}</p>\n )}\n </CardStackEntryField>\n {props.specUrl !== undefined && props.onSpecUrlChange && (\n <CardStackEntryField label=\"Spec URL\">\n <Input\n value={props.specUrl}\n onChange={(e) => props.onSpecUrlChange?.((e.target as HTMLInputElement).value)}\n placeholder=\"https://api.example.com/openapi.json\"\n className=\"font-mono text-sm\"\n disabled={props.specUrlDisabled}\n />\n </CardStackEntryField>\n )}\n </div>\n {props.footer && (\n <CardStackEntry>\n <CardStackEntryContent>\n <CardStackEntryTitle>{props.footer}</CardStackEntryTitle>\n </CardStackEntryContent>\n </CardStackEntry>\n )}\n </CardStackContent>\n </CardStack>\n );\n}\n","import { useMemo, useState } from \"react\";\nimport { ChevronDownIcon, PlusIcon, TriangleAlert, XIcon } from \"lucide-react\";\n\nimport { cn } from \"@executor-js/react/lib/utils\";\nimport { Badge } from \"@executor-js/react/components/badge\";\nimport { Button } from \"@executor-js/react/components/button\";\nimport { Checkbox } from \"@executor-js/react/components/checkbox\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@executor-js/react/components/collapsible\";\nimport { FieldLabel } from \"@executor-js/react/components/field\";\nimport { Input } from \"@executor-js/react/components/input\";\nimport { IntegrationFavicon } from \"@executor-js/react/components/integration-favicon\";\n\nimport {\n googleOAuthConsentScopesForPreset,\n googleOpenApiPresets,\n type GoogleOpenApiOAuthAudience,\n type GoogleOpenApiPreset,\n} from \"../sdk/google-presets\";\nimport { googleOAuthConsentBatches } from \"../sdk/google-oauth-batches\";\nimport { isGoogleDiscoveryUrl } from \"../sdk/google-discovery\";\n\n// ---------------------------------------------------------------------------\n// GoogleProductPicker — the \"customize your Google connection\" surface.\n//\n// A checkable card grid over `googleOpenApiPresets`, grouped/annotated by\n// `oauthAudience`. The user picks which Google APIs to bundle into the single\n// `google` integration; the parent turns the selected discovery URLs into a\n// `{ kind: \"googleDiscoveryBundle\", urls }` add. A \"View scopes\" panel previews\n// the unioned OAuth consent (via `googleOAuthConsentBatches`) BEFORE connecting,\n// and a custom-URL escape hatch lets advanced users paste any Google Discovery\n// document the preset list doesn't cover.\n// ---------------------------------------------------------------------------\n\n// Audience groups, ordered from least- to most-privileged. The warning tiers\n// (`workspace-admin`, `unsupported-user`) carry a caution chip so the user sees\n// the consent risk before selecting.\nconst AUDIENCE_ORDER: readonly GoogleOpenApiOAuthAudience[] = [\n \"standard-user\",\n \"advanced-user\",\n \"workspace-admin\",\n \"unsupported-user\",\n];\n\nconst AUDIENCE_LABEL: Readonly<Record<GoogleOpenApiOAuthAudience, string>> = {\n \"standard-user\": \"Core Google services\",\n \"advanced-user\": \"Advanced services\",\n \"workspace-admin\": \"Workspace admin\",\n \"unsupported-user\": \"Limited user consent\",\n};\n\nconst AUDIENCE_DESCRIPTION: Readonly<Record<GoogleOpenApiOAuthAudience, string>> = {\n \"standard-user\": \"Connect with a normal Google account — one consent screen.\",\n \"advanced-user\": \"Broader scopes that may need an unverified-app warning to be accepted.\",\n \"workspace-admin\": \"Requires a Google Workspace admin account; not available on personal Gmail.\",\n \"unsupported-user\": \"Google does not grant these scopes through standard user OAuth consent.\",\n};\n\nconst audienceNeedsWarning = (audience: GoogleOpenApiOAuthAudience): boolean =>\n audience === \"workspace-admin\" || audience === \"unsupported-user\";\n\ntype GoogleProductPickerProps = {\n readonly selectedPresetIds: ReadonlySet<string>;\n readonly onToggle: (presetId: string, checked: boolean) => void;\n readonly customUrls: readonly string[];\n readonly onAddCustomUrl: (url: string) => void;\n readonly onRemoveCustomUrl: (url: string) => void;\n};\n\nconst AudienceWarningChip = ({ audience }: { audience: GoogleOpenApiOAuthAudience }) =>\n audience === \"workspace-admin\" ? (\n <Badge\n variant=\"outline\"\n className=\"shrink-0 border-amber-500/40 text-amber-700 dark:text-amber-400\"\n >\n <TriangleAlert className=\"size-3\" />\n Admin only\n </Badge>\n ) : audience === \"unsupported-user\" ? (\n <Badge variant=\"outline\" className=\"shrink-0 border-destructive/40 text-destructive\">\n <TriangleAlert className=\"size-3\" />\n Limited consent\n </Badge>\n ) : null;\n\n// A Google API row — borderless and single-line, leaning on hover/selected\n// fills instead of per-item card chrome (lightest separation that still reads).\n// Name + truncated summary share one baseline for a dense, scannable two-column\n// list; the audience warning chip trails on the right.\nconst ProductRow = ({\n preset,\n checked,\n onToggle,\n}: {\n readonly preset: GoogleOpenApiPreset;\n readonly checked: boolean;\n readonly onToggle: (checked: boolean) => void;\n}) => (\n <FieldLabel\n className={cn(\n // `w-full` overrides FieldLabel's base `w-fit` (which would size the row to\n // its content and overflow the column); `min-w-0` then lets the cell shrink\n // to its track so the name/summary truncates instead of spilling over.\n \"flex w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors\",\n checked ? \"bg-primary/5\" : \"hover:bg-muted/40\",\n )}\n >\n <Checkbox checked={checked} onCheckedChange={(next) => onToggle(next === true)} />\n <div className=\"shrink-0\">\n <IntegrationFavicon icon={preset.icon} url={preset.url} size={16} />\n </div>\n {/* One truncating line — the name + summary clip to the cell with an\n ellipsis instead of overflowing into the neighbouring column. */}\n <div className=\"min-w-0 flex-1 truncate text-sm\">\n <span className=\"font-medium text-foreground\">{preset.name}</span>{\" \"}\n <span className=\"text-[11px] text-muted-foreground\">{preset.summary}</span>\n </div>\n <AudienceWarningChip audience={preset.oauthAudience} />\n </FieldLabel>\n);\n\nconst CustomUrlEscapeHatch = ({\n customUrls,\n onAddCustomUrl,\n onRemoveCustomUrl,\n}: {\n readonly customUrls: readonly string[];\n readonly onAddCustomUrl: (url: string) => void;\n readonly onRemoveCustomUrl: (url: string) => void;\n}) => {\n const [draft, setDraft] = useState(\"\");\n const trimmed = draft.trim();\n const isValid = isGoogleDiscoveryUrl(trimmed);\n const isDuplicate = customUrls.includes(trimmed);\n\n const commit = () => {\n if (!isValid || isDuplicate) return;\n onAddCustomUrl(trimmed);\n setDraft(\"\");\n };\n\n return (\n <div className=\"space-y-2\">\n <FieldLabel className=\"text-[11px] font-medium text-muted-foreground\">\n Add a custom Google Discovery URL\n </FieldLabel>\n <div className=\"flex items-center gap-2\">\n <Input\n value={draft}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => setDraft(event.target.value)}\n onKeyDown={(event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n commit();\n }\n }}\n placeholder=\"https://www.googleapis.com/discovery/v1/apis/<service>/<version>/rest\"\n className=\"font-mono text-[11px]\"\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={!isValid || isDuplicate}\n onClick={commit}\n >\n <PlusIcon className=\"size-3.5\" />\n Add\n </Button>\n </div>\n {trimmed.length > 0 && !isValid ? (\n <p className=\"text-[11px] text-destructive\">\n Enter a Google Discovery document URL (a *.googleapis.com discovery/$discovery endpoint).\n </p>\n ) : null}\n {customUrls.length > 0 ? (\n <ul className=\"space-y-1\">\n {customUrls.map((url: string) => (\n <li\n key={url}\n className=\"flex items-center justify-between gap-2 rounded-md border border-border bg-muted/20 px-2.5 py-1.5\"\n >\n <span className=\"truncate font-mono text-[11px] text-foreground\">{url}</span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"size-6 shrink-0\"\n onClick={() => onRemoveCustomUrl(url)}\n aria-label={`Remove ${url}`}\n >\n <XIcon className=\"size-3.5\" />\n </Button>\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n};\n\nexport function GoogleProductPicker({\n selectedPresetIds,\n onToggle,\n customUrls,\n onAddCustomUrl,\n onRemoveCustomUrl,\n}: GoogleProductPickerProps) {\n const [scopesOpen, setScopesOpen] = useState(false);\n\n const groups = useMemo(\n () =>\n AUDIENCE_ORDER.flatMap((audience: GoogleOpenApiOAuthAudience) => {\n const presets = googleOpenApiPresets.filter(\n (preset: GoogleOpenApiPreset) => preset.oauthAudience === audience,\n );\n return presets.length > 0 ? [{ audience, presets }] : [];\n }),\n [],\n );\n\n // The \"View scopes\" preview unions the selected presets' representative\n // consent scopes through `googleOAuthConsentBatches`, mirroring the unioned\n // scopes the bundle converter ultimately stores on the integration.\n const consentBatches = useMemo(\n () =>\n googleOAuthConsentBatches(\n googleOpenApiPresets\n .filter((preset: GoogleOpenApiPreset) => selectedPresetIds.has(preset.id))\n .map((preset: GoogleOpenApiPreset) => ({\n id: preset.id,\n name: preset.name,\n oauthAudience: preset.oauthAudience,\n scopes: googleOAuthConsentScopesForPreset(preset.id),\n })),\n ),\n [selectedPresetIds],\n );\n\n const selectedCount = selectedPresetIds.size + customUrls.length;\n\n return (\n <section className=\"space-y-4\">\n <div className=\"space-y-1\">\n <FieldLabel>Customize your Google connection</FieldLabel>\n <p className=\"text-[11px] text-muted-foreground\">\n Pick the Google APIs to bundle into one connection. They share a single OAuth consent and\n appear as merged tools under one Google integration.\n </p>\n </div>\n\n {groups.map(\n ({\n audience,\n presets,\n }: {\n readonly audience: GoogleOpenApiOAuthAudience;\n readonly presets: readonly GoogleOpenApiPreset[];\n }) => (\n <div key={audience} className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[11px] font-semibold tracking-wide text-foreground uppercase\">\n {AUDIENCE_LABEL[audience]}\n </span>\n {audienceNeedsWarning(audience) ? <AudienceWarningChip audience={audience} /> : null}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"ml-auto h-auto px-1.5 py-0.5 text-[11px] font-normal text-muted-foreground hover:bg-transparent hover:text-foreground\"\n onClick={() => {\n const allSelected = presets.every((preset: GoogleOpenApiPreset) =>\n selectedPresetIds.has(preset.id),\n );\n presets.forEach((preset: GoogleOpenApiPreset) =>\n onToggle(preset.id, !allSelected),\n );\n }}\n >\n {presets.every((preset: GoogleOpenApiPreset) => selectedPresetIds.has(preset.id))\n ? \"Clear\"\n : \"Select all\"}\n </Button>\n </div>\n <p className=\"text-[11px] text-muted-foreground\">{AUDIENCE_DESCRIPTION[audience]}</p>\n <div className=\"grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-2\">\n {presets.map((preset: GoogleOpenApiPreset) => (\n <ProductRow\n key={preset.id}\n preset={preset}\n checked={selectedPresetIds.has(preset.id)}\n onToggle={(checked: boolean) => onToggle(preset.id, checked)}\n />\n ))}\n </div>\n </div>\n ),\n )}\n\n <CustomUrlEscapeHatch\n customUrls={customUrls}\n onAddCustomUrl={onAddCustomUrl}\n onRemoveCustomUrl={onRemoveCustomUrl}\n />\n\n <div className=\"space-y-1.5 rounded-lg border border-border bg-muted/10 px-3 py-2.5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-[11px] font-semibold tracking-wide text-foreground uppercase\">\n Authentication\n </span>\n <Badge variant=\"secondary\">OAuth</Badge>\n </div>\n <p className=\"text-[11px] text-muted-foreground\">\n The selected Google APIs share one OAuth consent. Review the scopes below, then connect a\n Google account from the integration page after adding.\n </p>\n </div>\n\n <Collapsible open={scopesOpen} onOpenChange={setScopesOpen}>\n <CollapsibleTrigger asChild>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" disabled={consentBatches.length === 0}>\n <ChevronDownIcon\n className={cn(\"size-3.5 transition-transform\", scopesOpen ? \"rotate-180\" : \"\")}\n />\n View scopes\n {selectedCount > 0 ? (\n <Badge variant=\"secondary\" className=\"ml-1\">\n {selectedCount}\n </Badge>\n ) : null}\n </Button>\n </CollapsibleTrigger>\n <CollapsibleContent className=\"pt-3\">\n {consentBatches.length === 0 ? (\n <p className=\"text-[11px] text-muted-foreground\">\n Select at least one Google API to preview the OAuth consent.\n </p>\n ) : (\n <div className=\"space-y-3\">\n {consentBatches.map((batch) => (\n <div key={batch.id} className=\"space-y-1.5\">\n <span className=\"text-[11px] font-semibold text-foreground\">{batch.label}</span>\n <ul className=\"space-y-1\">\n {batch.apiScopes.map((scope: string) => (\n <li\n key={scope}\n className=\"rounded-md border border-border bg-muted/20 px-2.5 py-1 font-mono text-[11px] break-all text-muted-foreground\"\n >\n {scope}\n </li>\n ))}\n </ul>\n </div>\n ))}\n </div>\n )}\n </CollapsibleContent>\n </Collapsible>\n </section>\n );\n}\n\nexport default GoogleProductPicker;\n","import type { GoogleOpenApiOAuthAudience } from \"./google-presets\";\nimport { compactGoogleOAuthScopes } from \"./google-oauth-scopes\";\n\nexport type GoogleOAuthBatchInput = {\n readonly id: string;\n readonly name: string;\n readonly oauthAudience: GoogleOpenApiOAuthAudience;\n readonly scopes: readonly string[];\n};\n\nexport type GoogleOAuthConsentBatch = {\n readonly id: string;\n readonly label: string;\n readonly apiScopes: readonly string[];\n};\n\nconst GOOGLE_CLOUD_BATCH_IDS = new Set([\"google-bigquery\", \"google-cloud-resource-manager\"]);\n\nexport const googleOAuthConsentBatches = (\n items: readonly GoogleOAuthBatchInput[],\n): readonly GoogleOAuthConsentBatch[] => {\n const standardScopes: string[] = [];\n const cloudScopes: string[] = [];\n const batches: GoogleOAuthConsentBatch[] = [];\n\n for (const item of items) {\n if (item.scopes.length === 0) continue;\n if (item.oauthAudience === \"standard-user\") {\n standardScopes.push(...item.scopes);\n continue;\n }\n if (GOOGLE_CLOUD_BATCH_IDS.has(item.id)) {\n cloudScopes.push(...item.scopes);\n continue;\n }\n batches.push({\n id: item.id,\n label: item.name,\n apiScopes: item.scopes,\n });\n }\n\n const compactedStandardScopes = compactGoogleOAuthScopes(standardScopes);\n const compactedCloudScopes = compactGoogleOAuthScopes(cloudScopes);\n return [\n ...(compactedStandardScopes.length > 0\n ? [\n {\n id: \"google-core\",\n label: \"Core Google services\",\n apiScopes: compactedStandardScopes,\n },\n ]\n : []),\n ...batches.map((batch) => ({\n ...batch,\n apiScopes: compactGoogleOAuthScopes(batch.apiScopes),\n })),\n ...(compactedCloudScopes.length > 0\n ? [\n {\n id: \"google-cloud\",\n label: \"Google Cloud services\",\n apiScopes: compactedCloudScopes,\n },\n ]\n : []),\n ].filter((batch) => batch.apiScopes.length > 0);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa,WAAW,WAAAA,UAAS,QAAQ,YAAAC,iBAAgB;AAClE,SAAS,kBAAkB;AAC3B,YAAY,YAAY;AACxB,YAAY,UAAU;AACtB,YAAY,YAAY;AAGxB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAAC,eAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,aAAAC,YAAW,oBAAAC,yBAAwB;AAC5C,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,YAAY,eAAe;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;AC9BP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AACP,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,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N,uBACE,sBAAsB,2DAAsD;AAAA,QAE9E;AAAA,QACA,iBAAiB,CAAC,UAAU;AAC1B,qBAAW,KAAK;AAChB,qBAAW,IAAI;AACf,qBAAW,EAAE;AAAA,QACf;AAAA,QACA,aAAa;AAAA,QACb,YAAY,mBAAmB;AAAA;AAAA,IACjC,IACE;AAAA,IAEH,gBAAgB,gBAAAA,KAAC,kBAAe,SAAS,cAAc;AAAA,IAEvD,WAAW,CAAC,wBACX,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,WAAU;AAAA,QACV,YAAW;AAAA;AAAA,IACb;AAAA,IAGD,sBAAsB,qBAAqB,CAAC,UAC3C,gBAAAA,KAAC,sBAAmB,MAAM,kBAAkB;AAAA,IAG7C,YAAY,gBAAAA,KAAC,kBAAe,SAAS,UAAU;AAAA,IAEhD,gBAAAC,MAAC,gBACC;AAAA,sBAAAD,KAACQ,SAAA,EAAO,SAAQ,SAAQ,SAAS,MAAM,MAAM,SAAS,GAAG,UAAU,QAAQ,oBAE3E;AAAA,OACE,sBAAsB,yBACtB,gBAAAP,MAACO,SAAA,EAAO,SAAS,MAAM,KAAK,UAAU,GAAG,UAAU,CAAC,UAAU,QAC3D;AAAA,kBAAU,gBAAAR,KAAC,WAAQ,WAAU,YAAW;AAAA,QACxC,SAAS,iBAAY,uBAAuB,mBAAmB;AAAA,SAClE;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":["useMemo","useState","Button","CardStack","CardStackContent","FieldLabel","Input","IntegrationFavicon","jsx","jsxs","IntegrationFavicon","Input","jsx","jsxs","isGoogleDiscoveryUrl","useState","useMemo","CardStack","CardStackContent","FieldLabel","Button"]}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
openApiIntegrationAtom
|
|
3
|
-
} from "./chunk-IB36ED7Y.js";
|
|
4
|
-
import "./chunk-C3IJX4AN.js";
|
|
5
|
-
|
|
6
|
-
// src/react/EditOpenApiSource.tsx
|
|
7
|
-
import { useAtomValue } from "@effect/atom-react";
|
|
8
|
-
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
|
9
|
-
import { connectionsAllAtom } from "@executor-js/react/api/atoms";
|
|
10
|
-
import { ownerLabel, useOwnerDisplay } from "@executor-js/react/api/owner-display";
|
|
11
|
-
import { IntegrationSlug } from "@executor-js/sdk/shared";
|
|
12
|
-
import { Badge } from "@executor-js/react/components/badge";
|
|
13
|
-
import { Button } from "@executor-js/react/components/button";
|
|
14
|
-
import {
|
|
15
|
-
CardStack,
|
|
16
|
-
CardStackContent,
|
|
17
|
-
CardStackEntry,
|
|
18
|
-
CardStackEntryContent,
|
|
19
|
-
CardStackEntryDescription,
|
|
20
|
-
CardStackEntryTitle
|
|
21
|
-
} from "@executor-js/react/components/card-stack";
|
|
22
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
-
function EditOpenApiSource(props) {
|
|
24
|
-
const slug = IntegrationSlug.make(props.sourceId);
|
|
25
|
-
const integrationResult = useAtomValue(openApiIntegrationAtom(slug));
|
|
26
|
-
const ownerDisplay = useOwnerDisplay();
|
|
27
|
-
const connectionsResult = useAtomValue(connectionsAllAtom);
|
|
28
|
-
const integration = AsyncResult.isSuccess(integrationResult) && integrationResult.value ? integrationResult.value : null;
|
|
29
|
-
const connections = AsyncResult.isSuccess(connectionsResult) ? connectionsResult.value.filter((candidate) => candidate.integration === slug) : [];
|
|
30
|
-
if (!integration) {
|
|
31
|
-
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
32
|
-
/* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-foreground", children: "OpenAPI Integration" }),
|
|
33
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Loading\u2026" })
|
|
34
|
-
] });
|
|
35
|
-
}
|
|
36
|
-
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
37
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-foreground", children: "OpenAPI Integration" }) }),
|
|
38
|
-
/* @__PURE__ */ jsx(CardStack, { children: /* @__PURE__ */ jsx(CardStackContent, { className: "border-t-0", children: /* @__PURE__ */ jsxs(CardStackEntry, { children: [
|
|
39
|
-
/* @__PURE__ */ jsxs(CardStackEntryContent, { children: [
|
|
40
|
-
/* @__PURE__ */ jsx(CardStackEntryTitle, { children: integration.description || String(slug) }),
|
|
41
|
-
/* @__PURE__ */ jsx(CardStackEntryDescription, { children: String(slug) })
|
|
42
|
-
] }),
|
|
43
|
-
/* @__PURE__ */ jsx(Badge, { variant: "secondary", children: integration.kind })
|
|
44
|
-
] }) }) }),
|
|
45
|
-
/* @__PURE__ */ jsx(CardStack, { children: /* @__PURE__ */ jsxs(CardStackContent, { className: "border-t-0", children: [
|
|
46
|
-
/* @__PURE__ */ jsx(CardStackEntry, { children: /* @__PURE__ */ jsxs(CardStackEntryContent, { children: [
|
|
47
|
-
/* @__PURE__ */ jsx(CardStackEntryTitle, { children: "Connections" }),
|
|
48
|
-
/* @__PURE__ */ jsx(CardStackEntryDescription, { children: "Credentials this integration uses to call its API." })
|
|
49
|
-
] }) }),
|
|
50
|
-
connections.length === 0 ? /* @__PURE__ */ jsx(CardStackEntry, { children: /* @__PURE__ */ jsx(CardStackEntryContent, { children: /* @__PURE__ */ jsx(CardStackEntryDescription, { children: "No connections yet." }) }) }) : connections.map((connection) => /* @__PURE__ */ jsxs(CardStackEntry, { children: [
|
|
51
|
-
/* @__PURE__ */ jsxs(CardStackEntryContent, { children: [
|
|
52
|
-
/* @__PURE__ */ jsx(CardStackEntryTitle, { children: connection.identityLabel ?? String(connection.name) }),
|
|
53
|
-
/* @__PURE__ */ jsxs(CardStackEntryDescription, { children: [
|
|
54
|
-
String(connection.template),
|
|
55
|
-
" \xB7 ",
|
|
56
|
-
String(connection.provider)
|
|
57
|
-
] })
|
|
58
|
-
] }),
|
|
59
|
-
ownerDisplay.showOwnerLabels ? /* @__PURE__ */ jsx(Badge, { variant: "outline", children: ownerLabel(connection.owner) }) : null
|
|
60
|
-
] }, `${connection.owner}:${connection.name}`))
|
|
61
|
-
] }) }),
|
|
62
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-start border-t border-border pt-4", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: props.onSave, children: "Back" }) })
|
|
63
|
-
] });
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
EditOpenApiSource as default
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=EditOpenApiSource-GIN5RQPL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/EditOpenApiSource.tsx"],"sourcesContent":["import { useAtomValue } from \"@effect/atom-react\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\n\nimport { connectionsAllAtom } from \"@executor-js/react/api/atoms\";\nimport { ownerLabel, useOwnerDisplay } from \"@executor-js/react/api/owner-display\";\nimport { IntegrationSlug, type Connection } from \"@executor-js/sdk/shared\";\nimport { Badge } from \"@executor-js/react/components/badge\";\nimport { Button } from \"@executor-js/react/components/button\";\nimport {\n CardStack,\n CardStackContent,\n CardStackEntry,\n CardStackEntryContent,\n CardStackEntryDescription,\n CardStackEntryTitle,\n} from \"@executor-js/react/components/card-stack\";\n\nimport { openApiIntegrationAtom } from \"./atoms\";\n\n// ---------------------------------------------------------------------------\n// v2 edit — the integration's spec, base URL, and auth templates are part of\n// its catalog config, which core treats as opaque and the API exposes as a\n// read-only `getIntegration`. There are no per-scope source rows, no credential\n// slots, and no binding writers to configure here anymore. Editing is reduced\n// to surfacing the integration's identity and its current connections; new\n// credentials are created on the integration's detail/connections surface.\n// ---------------------------------------------------------------------------\n\nexport default function EditOpenApiSource(props: {\n readonly sourceId: string;\n readonly onSave: () => void;\n}) {\n const slug = IntegrationSlug.make(props.sourceId);\n const integrationResult = useAtomValue(openApiIntegrationAtom(slug));\n const ownerDisplay = useOwnerDisplay();\n // Connections across BOTH owners (omit-owner read); each row keeps its owner\n // for the per-connection badge below.\n const connectionsResult = useAtomValue(connectionsAllAtom);\n\n const integration =\n AsyncResult.isSuccess(integrationResult) && integrationResult.value\n ? integrationResult.value\n : null;\n const connections: readonly Connection[] = AsyncResult.isSuccess(connectionsResult)\n ? connectionsResult.value.filter((candidate: Connection) => candidate.integration === slug)\n : [];\n\n if (!integration) {\n return (\n <div className=\"space-y-3\">\n <h1 className=\"text-xl font-semibold text-foreground\">OpenAPI Integration</h1>\n <p className=\"text-sm text-muted-foreground\">Loading…</p>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6\">\n <div>\n <h1 className=\"text-xl font-semibold text-foreground\">OpenAPI Integration</h1>\n </div>\n\n <CardStack>\n <CardStackContent className=\"border-t-0\">\n <CardStackEntry>\n <CardStackEntryContent>\n <CardStackEntryTitle>{integration.description || String(slug)}</CardStackEntryTitle>\n <CardStackEntryDescription>{String(slug)}</CardStackEntryDescription>\n </CardStackEntryContent>\n <Badge variant=\"secondary\">{integration.kind}</Badge>\n </CardStackEntry>\n </CardStackContent>\n </CardStack>\n\n <CardStack>\n <CardStackContent className=\"border-t-0\">\n <CardStackEntry>\n <CardStackEntryContent>\n <CardStackEntryTitle>Connections</CardStackEntryTitle>\n <CardStackEntryDescription>\n Credentials this integration uses to call its API.\n </CardStackEntryDescription>\n </CardStackEntryContent>\n </CardStackEntry>\n {connections.length === 0 ? (\n <CardStackEntry>\n <CardStackEntryContent>\n <CardStackEntryDescription>No connections yet.</CardStackEntryDescription>\n </CardStackEntryContent>\n </CardStackEntry>\n ) : (\n connections.map((connection: Connection) => (\n <CardStackEntry key={`${connection.owner}:${connection.name}`}>\n <CardStackEntryContent>\n <CardStackEntryTitle>\n {connection.identityLabel ?? String(connection.name)}\n </CardStackEntryTitle>\n <CardStackEntryDescription>\n {String(connection.template)} · {String(connection.provider)}\n </CardStackEntryDescription>\n </CardStackEntryContent>\n {ownerDisplay.showOwnerLabels ? (\n <Badge variant=\"outline\">{ownerLabel(connection.owner)}</Badge>\n ) : null}\n </CardStackEntry>\n ))\n )}\n </CardStackContent>\n </CardStack>\n\n <div className=\"flex items-center justify-start border-t border-border pt-4\">\n <Button variant=\"ghost\" onClick={props.onSave}>\n Back\n </Button>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAS,oBAAoB;AAC7B,YAAY,iBAAiB;AAE7B,SAAS,0BAA0B;AACnC,SAAS,YAAY,uBAAuB;AAC5C,SAAS,uBAAwC;AACjD,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkCD,SACE,KADF;AArBS,SAAR,kBAAmC,OAGvC;AACD,QAAM,OAAO,gBAAgB,KAAK,MAAM,QAAQ;AAChD,QAAM,oBAAoB,aAAa,uBAAuB,IAAI,CAAC;AACnE,QAAM,eAAe,gBAAgB;AAGrC,QAAM,oBAAoB,aAAa,kBAAkB;AAEzD,QAAM,cACQ,sBAAU,iBAAiB,KAAK,kBAAkB,QAC1D,kBAAkB,QAClB;AACN,QAAM,cAAiD,sBAAU,iBAAiB,IAC9E,kBAAkB,MAAM,OAAO,CAAC,cAA0B,UAAU,gBAAgB,IAAI,IACxF,CAAC;AAEL,MAAI,CAAC,aAAa;AAChB,WACE,qBAAC,SAAI,WAAU,aACb;AAAA,0BAAC,QAAG,WAAU,yCAAwC,iCAAmB;AAAA,MACzE,oBAAC,OAAE,WAAU,iCAAgC,2BAAQ;AAAA,OACvD;AAAA,EAEJ;AAEA,SACE,qBAAC,SAAI,WAAU,aACb;AAAA,wBAAC,SACC,8BAAC,QAAG,WAAU,yCAAwC,iCAAmB,GAC3E;AAAA,IAEA,oBAAC,aACC,8BAAC,oBAAiB,WAAU,cAC1B,+BAAC,kBACC;AAAA,2BAAC,yBACC;AAAA,4BAAC,uBAAqB,sBAAY,eAAe,OAAO,IAAI,GAAE;AAAA,QAC9D,oBAAC,6BAA2B,iBAAO,IAAI,GAAE;AAAA,SAC3C;AAAA,MACA,oBAAC,SAAM,SAAQ,aAAa,sBAAY,MAAK;AAAA,OAC/C,GACF,GACF;AAAA,IAEA,oBAAC,aACC,+BAAC,oBAAiB,WAAU,cAC1B;AAAA,0BAAC,kBACC,+BAAC,yBACC;AAAA,4BAAC,uBAAoB,yBAAW;AAAA,QAChC,oBAAC,6BAA0B,gEAE3B;AAAA,SACF,GACF;AAAA,MACC,YAAY,WAAW,IACtB,oBAAC,kBACC,8BAAC,yBACC,8BAAC,6BAA0B,iCAAmB,GAChD,GACF,IAEA,YAAY,IAAI,CAAC,eACf,qBAAC,kBACC;AAAA,6BAAC,yBACC;AAAA,8BAAC,uBACE,qBAAW,iBAAiB,OAAO,WAAW,IAAI,GACrD;AAAA,UACA,qBAAC,6BACE;AAAA,mBAAO,WAAW,QAAQ;AAAA,YAAE;AAAA,YAAI,OAAO,WAAW,QAAQ;AAAA,aAC7D;AAAA,WACF;AAAA,QACC,aAAa,kBACZ,oBAAC,SAAM,SAAQ,WAAW,qBAAW,WAAW,KAAK,GAAE,IACrD;AAAA,WAXe,GAAG,WAAW,KAAK,IAAI,WAAW,IAAI,EAY3D,CACD;AAAA,OAEL,GACF;AAAA,IAEA,oBAAC,SAAI,WAAU,+DACb,8BAAC,UAAO,SAAQ,SAAQ,SAAS,MAAM,QAAQ,kBAE/C,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 YAML from \"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 return yield* response.text.pipe(\n Effect.mapError(\n (_cause) =>\n new OpenApiParseError({\n message: \"Failed to read OpenAPI document body\",\n }),\n ),\n );\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: () => YAML.parse(text) 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 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 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 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});\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 OperationId,\n OperationParameter,\n OperationRequestBody,\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 extractOutputSchema = (operation: OperationObject, r: DocResolver): unknown | 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) return content.media.schema;\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 servers = operationServers(pathItem, operation, docServers);\n const inputSchema = buildInputSchema(parameters, requestBody, servers);\n const outputSchema = extractOutputSchema(operation, r);\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 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 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 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// ---------------------------------------------------------------------------\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 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,IAAM,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SAAS,OAAO,KAAK,KAAK,EAAE,CAAC;AAAA,EACnD;AAGA,QAAM,iBACJ,mBAAmB,SAAS,IACxB,qBACA,gBAAgB,IAAI,CAAC,WAAW,aAAa,KAAK,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAEnF,SAAO,YAAY,KAAK;AAAA,IACtB,OAAO,OAAO;AAAA,IACd,SAAS,OAAO;AAAA,IAChB,SAAS,OAAO;AAAA,IAChB,gBAAgB,OAAO,WAAW;AAAA,IAClC,YAAY,OAAO,WAAW;AAAA,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/atoms.ts","../src/react/client.ts","../src/api/group.ts"],"sourcesContent":["import type { IntegrationSlug } from \"@executor-js/sdk/shared\";\nimport * as Atom from \"effect/unstable/reactivity/Atom\";\nimport { ReactivityKey } from \"@executor-js/react/api/reactivity-keys\";\nimport { OpenApiClient } from \"./client\";\n\n// ---------------------------------------------------------------------------\n// Query atoms — v2: the integration catalog is the unit of identity (the v1\n// per-scope `source` row is gone). `getIntegration` returns the catalog entry\n// (slug/description/kind/canRemove/canRefresh); credentials are owner-scoped\n// connections read from the shared `connections` API, not bound per source.\n// ---------------------------------------------------------------------------\n\nexport const openApiIntegrationAtom = (slug: IntegrationSlug) =>\n OpenApiClient.query(\"openapi\", \"getIntegration\", {\n params: { slug },\n timeToLive: \"15 seconds\",\n reactivityKeys: [ReactivityKey.integrations, ReactivityKey.tools],\n });\n\n// The full opaque config (including `authenticationTemplate`), used by the\n// configure UX to render existing auth methods and add custom ones.\nexport const openApiConfigAtom = (slug: IntegrationSlug) =>\n OpenApiClient.query(\"openapi\", \"getConfig\", {\n params: { slug },\n timeToLive: \"15 seconds\",\n reactivityKeys: [ReactivityKey.integrations, ReactivityKey.tools],\n });\n\n// ---------------------------------------------------------------------------\n// Mutation atoms\n// ---------------------------------------------------------------------------\n\nexport const previewOpenApiSpec = OpenApiClient.mutation(\"openapi\", \"previewSpec\");\n\nexport const addOpenApiSpec = OpenApiClient.mutation(\"openapi\", \"addSpec\");\n\nexport const removeOpenApiSpec = OpenApiClient.mutation(\"openapi\", \"removeSpec\");\n\n// Add / merge custom auth methods onto an integration's `authenticationTemplate`.\nexport const openapiConfigure = OpenApiClient.mutation(\"openapi\", \"configure\");\n\n// `getIntegration` is read-only; the atom family lets a caller pass a slug.\nexport const openApiIntegrationFamily = Atom.family(openApiIntegrationAtom);\n\n// `getConfig` is read-only; the atom family lets a caller pass a slug.\nexport const openApiConfigFamily = Atom.family(openApiConfigAtom);\n","import { createPluginAtomClient } from \"@executor-js/sdk/client\";\nimport {\n getExecutorApiBaseUrl,\n getExecutorServerAuthorizationHeader,\n} from \"@executor-js/react/api/server-connection\";\nimport { OpenApiGroup } from \"../api/group\";\n\nexport const OpenApiClient = createPluginAtomClient(OpenApiGroup, {\n baseUrl: getExecutorApiBaseUrl,\n authorizationHeader: getExecutorServerAuthorizationHeader,\n});\n","import { HttpApiEndpoint, HttpApiGroup } from \"effect/unstable/httpapi\";\nimport { Schema } from \"effect\";\nimport { ApiKeyAuthMethod, ApiKeyAuthTemplate } from \"@executor-js/sdk/http-auth\";\nimport {\n InternalError,\n IntegrationAlreadyExistsError,\n IntegrationSlug,\n} from \"@executor-js/sdk/shared\";\n\nimport { OpenApiParseError, OpenApiExtractionError, OpenApiOAuthError } from \"../sdk/errors\";\nimport { SpecPreview } from \"../sdk/preview\";\n\n// ---------------------------------------------------------------------------\n// Errors — the plugin-domain tagged errors flow directly to clients\n// (4xx, each carrying its own `httpApiStatus`). `InternalError` is the shared\n// opaque 500 surface; `StorageError` → `InternalError` translation happens at\n// service wiring time. `IntegrationAlreadyExistsError` (409) blocks re-adding\n// an existing slug — see addSpec.\n// ---------------------------------------------------------------------------\n\nconst DomainErrors = [\n InternalError,\n OpenApiParseError,\n OpenApiExtractionError,\n OpenApiOAuthError,\n IntegrationAlreadyExistsError,\n] as const;\n\nconst SlugParams = {\n slug: Schema.String,\n};\n\n// ---------------------------------------------------------------------------\n// Payloads\n// ---------------------------------------------------------------------------\n\nconst OpenApiSpecInputPayload = Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"url\"), url: Schema.String }),\n Schema.Struct({ kind: Schema.Literal(\"blob\"), value: Schema.String }),\n Schema.Struct({\n kind: Schema.Literal(\"googleDiscovery\"),\n url: Schema.String,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"googleDiscoveryBundle\"),\n urls: Schema.Array(Schema.String),\n }),\n]);\n\nconst OAuthTemplatePayload = Schema.Struct({\n slug: Schema.String,\n kind: Schema.Literal(\"oauth2\"),\n authorizationUrl: Schema.String,\n tokenUrl: Schema.String,\n scopes: Schema.Array(Schema.String),\n});\n\n/** Auth INPUTS: oauth templates + the request-shaped apikey dialect. */\nconst AuthenticationPayload = Schema.Union([OAuthTemplatePayload, ApiKeyAuthTemplate]);\n\n/** Auth in RESPONSES: the canonical stored shapes (placements). */\nconst AuthenticationResponse = Schema.Union([OAuthTemplatePayload, ApiKeyAuthMethod]);\n\nconst AddSpecPayload = Schema.Struct({\n spec: OpenApiSpecInputPayload,\n slug: Schema.String,\n description: Schema.optional(Schema.String),\n baseUrl: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n queryParams: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n authenticationTemplate: Schema.optional(Schema.Array(AuthenticationPayload)),\n});\n\nconst PreviewSpecPayload = Schema.Struct({\n spec: Schema.String,\n});\n\n// The `configure` payload — the new/updated auth methods to merge onto the\n// integration's `authenticationTemplate`. Reuses the same `AuthenticationPayload`\n// schema as `addSpec` so a custom apiKey method round-trips identically.\nconst ConfigurePayload = Schema.Struct({\n authenticationTemplate: Schema.Array(AuthenticationPayload),\n mode: Schema.optional(Schema.Literals([\"merge\", \"replace\"])),\n});\n\n// ---------------------------------------------------------------------------\n// Responses\n// ---------------------------------------------------------------------------\n\nconst AddSpecResponse = Schema.Struct({\n slug: IntegrationSlug,\n toolCount: Schema.Number,\n});\n\nconst IntegrationView = Schema.Struct({\n slug: IntegrationSlug,\n description: Schema.String,\n kind: Schema.String,\n canRemove: Schema.Boolean,\n canRefresh: Schema.Boolean,\n});\n\n// The integration config surfaced for the configure UX. Unlike\n// `IntegrationView` (catalog identity only), this carries the\n// `authenticationTemplate` the configure flow reads/writes. The spec text is\n// deliberately NOT served: it's a multi-MB build artifact in the plugin blob\n// store, and no client reads it (the configure UI only touches the template).\nconst OpenApiConfigView = Schema.Struct({\n sourceUrl: Schema.optional(Schema.String),\n googleDiscoveryUrls: Schema.optional(Schema.Array(Schema.String)),\n baseUrl: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n queryParams: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n authenticationTemplate: Schema.optional(Schema.Array(AuthenticationResponse)),\n});\n\n// The configure result — the merged `authenticationTemplate` after the new\n// custom methods were appended/replaced.\nconst ConfigureResponse = Schema.Struct({\n authenticationTemplate: Schema.Array(AuthenticationResponse),\n});\n\n// ---------------------------------------------------------------------------\n// Group — addSpec/preview/get/remove over the integration catalog.\n// ---------------------------------------------------------------------------\n\nexport const OpenApiGroup = HttpApiGroup.make(\"openapi\")\n .add(\n HttpApiEndpoint.post(\"previewSpec\", \"/openapi/preview\", {\n payload: PreviewSpecPayload,\n success: SpecPreview,\n error: DomainErrors,\n }),\n )\n .add(\n HttpApiEndpoint.post(\"addSpec\", \"/openapi/specs\", {\n payload: AddSpecPayload,\n success: AddSpecResponse,\n error: DomainErrors,\n }),\n )\n .add(\n HttpApiEndpoint.get(\"getIntegration\", \"/openapi/integrations/:slug\", {\n params: SlugParams,\n success: Schema.NullOr(IntegrationView),\n error: DomainErrors,\n }),\n )\n .add(\n HttpApiEndpoint.get(\"getConfig\", \"/openapi/integrations/:slug/config\", {\n params: SlugParams,\n success: Schema.NullOr(OpenApiConfigView),\n error: DomainErrors,\n }),\n )\n .add(\n HttpApiEndpoint.post(\"configure\", \"/openapi/integrations/:slug/config\", {\n params: SlugParams,\n payload: ConfigurePayload,\n success: ConfigureResponse,\n error: DomainErrors,\n }),\n )\n .add(\n HttpApiEndpoint.delete(\"removeSpec\", \"/openapi/integrations/:slug\", {\n params: SlugParams,\n success: Schema.Void,\n error: DomainErrors,\n }),\n );\n"],"mappings":";;;;;;;;AACA,YAAY,UAAU;AACtB,SAAS,qBAAqB;;;ACF9B,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACJP,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,cAAc;AACvB,SAAS,kBAAkB,0BAA0B;AACrD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAaP,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,aAAa;AAAA,EACjB,MAAM,OAAO;AACf;AAMA,IAAM,0BAA0B,OAAO,MAAM;AAAA,EAC3C,OAAO,OAAO,EAAE,MAAM,OAAO,QAAQ,KAAK,GAAG,KAAK,OAAO,OAAO,CAAC;AAAA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