@rafads/plugin-openapi 1.5.38
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/README.md +83 -0
- package/dist/AddOpenApiIntegration-JPAEXE56.js +512 -0
- package/dist/AddOpenApiIntegration-JPAEXE56.js.map +1 -0
- package/dist/OpenApiAccountsPanel-GZFDSTAU.js +106 -0
- package/dist/OpenApiAccountsPanel-GZFDSTAU.js.map +1 -0
- package/dist/UpdateSpecSection-KUSNI44Q.js +106 -0
- package/dist/UpdateSpecSection-KUSNI44Q.js.map +1 -0
- package/dist/api/group.d.ts +239 -0
- package/dist/api/handlers.d.ts +7 -0
- package/dist/api/index.d.ts +237 -0
- package/dist/chunk-6V45G2XQ.js +199 -0
- package/dist/chunk-6V45G2XQ.js.map +1 -0
- package/dist/chunk-CURJJXB3.js +132 -0
- package/dist/chunk-CURJJXB3.js.map +1 -0
- package/dist/chunk-CXFO6TLJ.js +39 -0
- package/dist/chunk-CXFO6TLJ.js.map +1 -0
- package/dist/chunk-HTHEUUJA.js +2873 -0
- package/dist/chunk-HTHEUUJA.js.map +1 -0
- package/dist/chunk-IG6QTTZB.js +79 -0
- package/dist/chunk-IG6QTTZB.js.map +1 -0
- package/dist/chunk-O2LMSZ2Z.js +120 -0
- package/dist/chunk-O2LMSZ2Z.js.map +1 -0
- package/dist/chunk-OR27BCXQ.js +956 -0
- package/dist/chunk-OR27BCXQ.js.map +1 -0
- package/dist/chunk-R7TVM3XD.js +275 -0
- package/dist/chunk-R7TVM3XD.js.map +1 -0
- package/dist/client.js +38 -0
- package/dist/client.js.map +1 -0
- package/dist/core.js +331 -0
- package/dist/core.js.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/google/config.d.ts +34 -0
- package/dist/providers/google/discovery.d.ts +49 -0
- package/dist/providers/google/discovery.test.d.ts +1 -0
- package/dist/providers/google/index.d.ts +5 -0
- package/dist/providers/google/oauth-scopes.d.ts +3 -0
- package/dist/providers/google/oauth-scopes.test.d.ts +1 -0
- package/dist/providers/google/openapi-ownership-migration.d.ts +7 -0
- package/dist/providers/google/openapi-ownership-migration.test.d.ts +1 -0
- package/dist/providers/google/presets.d.ts +31 -0
- package/dist/providers/google/presets.test.d.ts +1 -0
- package/dist/providers/google/spec-format-adapter.d.ts +3 -0
- package/dist/providers/google/spec-format-adapter.test.d.ts +1 -0
- package/dist/providers/google.js +1446 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/microsoft/graph.d.ts +76 -0
- package/dist/providers/microsoft/graph.test.d.ts +1 -0
- package/dist/providers/microsoft/index.d.ts +3 -0
- package/dist/providers/microsoft/presets.d.ts +46 -0
- package/dist/providers/microsoft/presets.test.d.ts +1 -0
- package/dist/providers/microsoft/spec-format-adapter.d.ts +2 -0
- package/dist/providers/microsoft/spec-format-adapter.test.d.ts +1 -0
- package/dist/providers/microsoft.js +1056 -0
- package/dist/providers/microsoft.js.map +1 -0
- package/dist/react/AddOpenApiIntegration.d.ts +22 -0
- package/dist/react/AddOpenApiIntegration.test.d.ts +1 -0
- package/dist/react/OpenApiAccountsPanel.d.ts +6 -0
- package/dist/react/OpenApiIntegrationDetailsFields.d.ts +25 -0
- package/dist/react/UpdateSpecSection.d.ts +2 -0
- package/dist/react/atoms.d.ts +317 -0
- package/dist/react/auth-method-config.d.ts +18 -0
- package/dist/react/auth-method-config.test.d.ts +1 -0
- package/dist/react/client.d.ts +233 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/integration-plugin.d.ts +6 -0
- package/dist/react/plugin-client.d.ts +2 -0
- package/dist/sdk/backing.d.ts +188 -0
- package/dist/sdk/client-credentials-oauth.test.d.ts +1 -0
- package/dist/sdk/compiled-spec-cache.test.d.ts +1 -0
- package/dist/sdk/config.d.ts +81 -0
- package/dist/sdk/configure.test.d.ts +1 -0
- package/dist/sdk/definitions.d.ts +57 -0
- package/dist/sdk/derive-auth.d.ts +11 -0
- package/dist/sdk/describe-auth-methods.test.d.ts +1 -0
- package/dist/sdk/errors.d.ts +45 -0
- package/dist/sdk/extract.d.ts +157 -0
- package/dist/sdk/extract.test.d.ts +1 -0
- package/dist/sdk/form-urlencoded-body.test.d.ts +1 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.test.d.ts +1 -0
- package/dist/sdk/invoke.d.ts +150 -0
- package/dist/sdk/migrate-config.d.ts +4 -0
- package/dist/sdk/migrate-config.test.d.ts +1 -0
- package/dist/sdk/multi-scope-bearer.test.d.ts +1 -0
- package/dist/sdk/multi-scope-oauth.test.d.ts +1 -0
- package/dist/sdk/ndjson-output-migration.d.ts +13 -0
- package/dist/sdk/ndjson-output-migration.test.d.ts +1 -0
- package/dist/sdk/non-json-body.test.d.ts +1 -0
- package/dist/sdk/oauth-refresh.test.d.ts +1 -0
- package/dist/sdk/openapi-utils.d.ts +65 -0
- package/dist/sdk/output-schema-migration.d.ts +21 -0
- package/dist/sdk/output-schema-migration.test.d.ts +1 -0
- package/dist/sdk/parse.d.ts +33 -0
- package/dist/sdk/parse.test.d.ts +1 -0
- package/dist/sdk/plugin.d.ts +109 -0
- package/dist/sdk/plugin.test.d.ts +1 -0
- package/dist/sdk/presets.d.ts +15 -0
- package/dist/sdk/preview-oauth2.test.d.ts +1 -0
- package/dist/sdk/preview.d.ts +514 -0
- package/dist/sdk/query-serialization.test.d.ts +1 -0
- package/dist/sdk/real-specs.test.d.ts +1 -0
- package/dist/sdk/request-user-agent.test.d.ts +1 -0
- package/dist/sdk/response-headers-timeout.test.d.ts +1 -0
- package/dist/sdk/server-url-resolution.test.d.ts +1 -0
- package/dist/sdk/spec-blob-migration.d.ts +7 -0
- package/dist/sdk/spec-blob.test.d.ts +1 -0
- package/dist/sdk/spec-format.d.ts +36 -0
- package/dist/sdk/spec-format.test.d.ts +1 -0
- package/dist/sdk/split.d.ts +84 -0
- package/dist/sdk/store.d.ts +49 -0
- package/dist/sdk/store.test.d.ts +1 -0
- package/dist/sdk/streaming-response.test.d.ts +1 -0
- package/dist/sdk/tool-row-projection.test.d.ts +1 -0
- package/dist/sdk/types.d.ts +352 -0
- package/dist/sdk/upstream-failures.test.d.ts +1 -0
- package/dist/sdk/usage-scope-isolation.test.d.ts +1 -0
- package/dist/testing/index.d.ts +177 -0
- package/dist/testing.js +454 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.test.d.ts +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/providers/google/discovery.ts","../../src/providers/google/oauth-scopes.ts","../../src/providers/google/presets.ts","../../src/providers/google/spec-format-adapter.ts","../../src/providers/google/openapi-ownership-migration.ts"],"sourcesContent":["// Converts Google Discovery documents directly into OpenAPI 3.x. Public\n// Discovery converters currently target Swagger 2.0 or a broad conversion\n// pipeline; this adapter emits the shape Executor parses while preserving\n// Executor-specific tool ids and query semantics.\nimport { Effect, Option, Predicate, Schema, SchemaGetter } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\";\n\nimport { OpenApiParseError } from \"../../sdk/errors\";\nimport type { Authentication } from \"../../sdk/types\";\nimport { compactGoogleOAuthScopes } from \"./oauth-scopes\";\nimport { AuthTemplateSlug } from \"@rafads/sdk/shared\";\n\ninterface SpecFetchCredentials {\n readonly headers?: Record<string, string>;\n readonly queryParams?: Record<string, string>;\n}\n\nconst DISCOVERY_SERVICE_HOST = \"https://www.googleapis.com/discovery/v1/apis\";\nconst GOOGLE_BUNDLE_BASE_URL = \"https://www.googleapis.com/\";\nconst GOOGLE_OAUTH_AUTHORIZATION_URL = \"https://accounts.google.com/o/oauth2/v2/auth\";\nconst GOOGLE_OAUTH_TOKEN_URL = \"https://oauth2.googleapis.com/token\";\nconst GOOGLE_PHOTOS_PICKER_SERVICE = \"photospicker\";\nconst GOOGLE_PHOTOS_PICKER_SCOPE =\n \"https://www.googleapis.com/auth/photospicker.mediaitems.readonly\";\nconst GOOGLE_PHOTOS_PICKER_SCOPE_DESCRIPTION = \"Read selected Google Photos media\";\nconst OPENAPI_SCHEMA_TYPES = new Set([\n \"array\",\n \"boolean\",\n \"integer\",\n \"null\",\n \"number\",\n \"object\",\n \"string\",\n]);\n\ntype GoogleDiscoveryServiceOverride = {\n readonly preserveServiceHostedUrl?: true;\n readonly scopes?: Record<string, string>;\n readonly fallbackMethodScopes?: readonly string[];\n};\n\nconst GOOGLE_DISCOVERY_SERVICE_OVERRIDES: Record<string, GoogleDiscoveryServiceOverride> = {\n forms: { preserveServiceHostedUrl: true },\n keep: { preserveServiceHostedUrl: true },\n [GOOGLE_PHOTOS_PICKER_SERVICE]: {\n preserveServiceHostedUrl: true,\n scopes: {\n [GOOGLE_PHOTOS_PICKER_SCOPE]: GOOGLE_PHOTOS_PICKER_SCOPE_DESCRIPTION,\n },\n fallbackMethodScopes: [GOOGLE_PHOTOS_PICKER_SCOPE],\n },\n};\n\nconst googleDiscoveryUrlForService = (\n service: string,\n version: string,\n host = `${service}.googleapis.com`,\n): string => {\n const override = GOOGLE_DISCOVERY_SERVICE_OVERRIDES[service];\n return override?.preserveServiceHostedUrl === true\n ? `https://${host}/$discovery/rest?version=${version}`\n : `${DISCOVERY_SERVICE_HOST}/${service}/${version}/rest`;\n};\n\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | readonly JsonValue[] | { readonly [key: string]: JsonValue };\n\ntype OpenApiSchemaObject = {\n readonly $ref?: string;\n readonly type?: \"array\" | \"boolean\" | \"integer\" | \"null\" | \"number\" | \"object\" | \"string\";\n readonly description?: string;\n readonly title?: string;\n readonly format?: string;\n readonly readOnly?: boolean;\n readonly default?: JsonValue;\n readonly enum?: readonly JsonValue[];\n readonly items?: OpenApiSchemaObject;\n readonly properties?: Record<string, OpenApiSchemaObject>;\n readonly required?: readonly string[];\n readonly additionalProperties?: boolean | OpenApiSchemaObject;\n};\n\ntype OpenApiParameterObject = {\n readonly name: string;\n readonly in: \"path\" | \"query\" | \"header\";\n readonly required: boolean;\n readonly description?: string;\n readonly schema: OpenApiSchemaObject;\n readonly style?: \"form\";\n readonly explode?: boolean;\n readonly allowReserved?: boolean;\n};\n\ntype OpenApiOperationObject = {\n readonly operationId: string;\n readonly \"x-executor-toolPath\": string;\n readonly \"x-executor-pathTemplate\"?: string;\n readonly tags?: readonly string[];\n readonly description?: string;\n readonly servers?: readonly { readonly url: string }[];\n readonly parameters: readonly OpenApiParameterObject[];\n readonly requestBody?: {\n readonly required: boolean;\n readonly content: Record<\n string,\n {\n readonly schema: OpenApiSchemaObject;\n }\n >;\n };\n readonly responses: {\n readonly \"200\": {\n readonly description: \"Successful response\";\n readonly content: Record<\n string,\n {\n readonly schema: OpenApiSchemaObject;\n }\n >;\n };\n };\n readonly security?: readonly Record<string, readonly string[]>[];\n readonly \"x-google-scopes\": readonly string[];\n};\n\ntype OpenApiDocument = {\n readonly openapi: \"3.1.0\";\n readonly info: {\n readonly title: string;\n readonly version: string;\n };\n readonly servers: readonly { readonly url: string }[];\n readonly paths: Record<string, Record<string, OpenApiOperationObject>>;\n readonly components: {\n readonly schemas: Record<string, OpenApiSchemaObject>;\n readonly securitySchemes?: Record<\n string,\n {\n readonly type: \"oauth2\";\n readonly flows: {\n readonly authorizationCode: {\n readonly authorizationUrl: string;\n readonly tokenUrl: string;\n readonly scopes: Record<string, string>;\n };\n };\n }\n >;\n };\n readonly security?: readonly Record<string, readonly string[]>[];\n readonly \"x-executor-origin\":\n | {\n readonly kind: \"googleDiscovery\";\n readonly discoveryUrl: string;\n readonly service: string;\n readonly version: string;\n }\n | {\n readonly kind: \"googleDiscoveryBundle\";\n readonly services: readonly {\n readonly discoveryUrl: string;\n readonly service: string;\n readonly version: string;\n }[];\n };\n};\n\nconst TextOption = Schema.OptionFromOptional(Schema.Trim).pipe(\n Schema.decode({\n decode: SchemaGetter.transform((value) => Option.filter(value, (text) => text.length > 0)),\n encode: SchemaGetter.transform((value) => value),\n }),\n Schema.withDecodingDefaultType(Effect.succeed(Option.none())),\n);\nconst TextArray = Schema.optional(Schema.Array(Schema.String)).pipe(\n Schema.withDecodingDefaultType(Effect.succeed([] as string[])),\n);\nconst UnknownRecord = Schema.Record(Schema.String, Schema.Unknown);\nconst UnknownRecordWithDefault = Schema.optional(UnknownRecord).pipe(\n Schema.withDecodingDefaultType(Effect.succeed({})),\n);\n\nconst DiscoveryParameter = Schema.Struct({\n type: Schema.optional(Schema.String),\n description: TextOption,\n properties: UnknownRecordWithDefault,\n items: Schema.optional(Schema.Unknown),\n additionalProperties: Schema.optional(Schema.Union([Schema.Boolean, Schema.Unknown])),\n enum: TextArray,\n format: Schema.optional(Schema.String),\n readOnly: Schema.optional(Schema.Boolean),\n default: Schema.optional(Schema.Union([Schema.String, Schema.Number, Schema.Boolean])),\n $ref: Schema.optional(Schema.String),\n location: Schema.optional(Schema.Literals([\"path\", \"query\", \"header\"])),\n required: Schema.optional(Schema.Boolean),\n repeated: Schema.optional(Schema.Boolean),\n});\ntype DiscoveryParameter = typeof DiscoveryParameter.Type;\n\nconst DiscoveryRef = Schema.Struct({\n $ref: Schema.optional(Schema.String),\n});\n\nconst DiscoveryMediaUploadProtocol = Schema.Struct({\n path: TextOption,\n multipart: Schema.optional(Schema.Boolean),\n});\n\nconst DiscoveryMediaUploadProtocols = Schema.Struct({\n simple: Schema.optional(DiscoveryMediaUploadProtocol),\n resumable: Schema.optional(DiscoveryMediaUploadProtocol),\n});\n\nconst DiscoveryMediaUpload = Schema.Struct({\n accept: Schema.optional(TextArray),\n maxSize: Schema.optional(Schema.String),\n protocols: Schema.optional(DiscoveryMediaUploadProtocols),\n});\n\nconst DiscoveryMethod = Schema.Struct({\n id: TextOption,\n description: TextOption,\n httpMethod: Schema.optional(Schema.String),\n path: TextOption,\n parameters: UnknownRecordWithDefault,\n request: Schema.optional(DiscoveryRef),\n response: Schema.optional(DiscoveryRef),\n scopes: TextArray,\n supportsMediaUpload: Schema.optional(Schema.Boolean),\n mediaUpload: Schema.optional(DiscoveryMediaUpload),\n supportsMediaDownload: Schema.optional(Schema.Boolean),\n useMediaDownloadService: Schema.optional(Schema.Boolean),\n});\ntype DiscoveryMethod = typeof DiscoveryMethod.Type;\n\nconst DiscoveryResource = Schema.Struct({\n methods: UnknownRecordWithDefault,\n resources: UnknownRecordWithDefault,\n});\n\nconst DiscoveryDocument = Schema.Struct({\n name: TextOption,\n version: TextOption,\n title: TextOption,\n rootUrl: TextOption,\n servicePath: Schema.optional(Schema.Trim).pipe(\n Schema.withDecodingDefaultType(Effect.succeed(\"\")),\n ),\n parameters: UnknownRecordWithDefault,\n methods: UnknownRecordWithDefault,\n resources: UnknownRecordWithDefault,\n schemas: UnknownRecordWithDefault,\n auth: Schema.optional(\n Schema.Struct({\n oauth2: Schema.optional(\n Schema.Struct({\n scopes: Schema.optional(\n Schema.Record(\n Schema.String,\n Schema.Struct({\n description: TextOption,\n }),\n ),\n ).pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),\n }),\n ),\n }),\n ),\n});\ntype DiscoveryDocument = typeof DiscoveryDocument.Type;\n\nexport interface GoogleDiscoveryOpenApiConversion {\n readonly specText: string;\n readonly baseUrl: string;\n readonly title: string;\n readonly service: string;\n readonly version: string;\n readonly discoveryUrls?: readonly string[];\n /** The v2 oauth auth template the converted integration declares, when the\n * Discovery document advertises OAuth2 scopes. */\n readonly authenticationTemplate?: readonly Authentication[];\n}\n\nconst decodeDiscoveryDocument = Schema.decodeUnknownSync(DiscoveryDocument);\nconst decodeDiscoveryParameter = Schema.decodeUnknownSync(DiscoveryParameter);\nconst decodeDiscoveryMethod = Schema.decodeUnknownSync(DiscoveryMethod);\nconst decodeDiscoveryResource = Schema.decodeUnknownSync(DiscoveryResource);\nconst parseJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));\n\nconst DISCOVERY_SERVICE_PATH_RE =\n /^\\/discovery\\/v1\\/apis\\/([A-Za-z0-9._-]+)\\/([A-Za-z0-9._-]+)\\/rest\\/?$/;\nconst DISCOVERY_VERSION_RE = /^[A-Za-z0-9._-]+$/;\n\nconst serviceFromGoogleApisHost = (host: string): string | null => {\n if (!host.endsWith(\".googleapis.com\")) return null;\n const rawService = host.slice(0, -\".googleapis.com\".length);\n if (!rawService || rawService.includes(\".\")) return null;\n const service =\n rawService === \"calendar-json\"\n ? \"calendar\"\n : rawService.endsWith(\"-json\")\n ? rawService.slice(0, -5)\n : rawService;\n return /^[a-z0-9][a-z0-9-]*$/.test(service) ? service : null;\n};\n\nexport const normalizeGoogleDiscoveryUrl = (discoveryUrl: string): string | null => {\n const trimmed = discoveryUrl.trim();\n if (!URL.canParse(trimmed)) return null;\n const parsed = new URL(trimmed);\n if (parsed.protocol !== \"https:\" || parsed.username || parsed.password || parsed.hash) {\n return null;\n }\n\n const host = parsed.hostname.toLowerCase();\n if (host === \"www.googleapis.com\") {\n if (parsed.search) return null;\n const match = parsed.pathname.match(DISCOVERY_SERVICE_PATH_RE);\n const service = match?.[1];\n const version = match?.[2];\n return service && version ? googleDiscoveryUrlForService(service, version) : null;\n }\n\n const service = serviceFromGoogleApisHost(host);\n if (!service || ![\"/$discovery/rest\", \"/$discovery/rest/\"].includes(parsed.pathname)) {\n return null;\n }\n const keys = [...parsed.searchParams.keys()];\n const version = parsed.searchParams.get(\"version\")?.trim();\n if (\n keys.length !== 1 ||\n keys[0] !== \"version\" ||\n !version ||\n !DISCOVERY_VERSION_RE.test(version)\n ) {\n return null;\n }\n return googleDiscoveryUrlForService(service, version, host);\n};\n\nconst normalizeDiscoveryUrl = (discoveryUrl: string): string => {\n return normalizeGoogleDiscoveryUrl(discoveryUrl) ?? discoveryUrl.trim();\n};\n\nexport const isGoogleDiscoveryUrl = (url: string): boolean => {\n return normalizeGoogleDiscoveryUrl(url) !== null;\n};\n\nexport const fetchGoogleDiscoveryDocument = Effect.fn(\"OpenApi.fetchGoogleDiscoveryDocument\")(\n function* (discoveryUrl: string, credentials?: SpecFetchCredentials) {\n const normalizedDiscoveryUrl = normalizeGoogleDiscoveryUrl(discoveryUrl);\n if (!normalizedDiscoveryUrl) {\n return yield* new OpenApiParseError({\n message:\n \"Google Discovery document URL must be a supported googleapis.com HTTPS Discovery endpoint\",\n });\n }\n const client = yield* HttpClient.HttpClient;\n const requestUrl = new URL(normalizedDiscoveryUrl);\n for (const [name, value] of Object.entries(credentials?.queryParams ?? {})) {\n requestUrl.searchParams.set(name, value);\n }\n let request = HttpClientRequest.get(requestUrl.toString()).pipe(\n HttpClientRequest.setHeader(\"Accept\", \"application/json, */*\"),\n );\n for (const [name, value] of Object.entries(credentials?.headers ?? {})) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to fetch Google Discovery document\",\n }),\n ),\n );\n if (response.status < 200 || response.status >= 300) {\n return yield* new OpenApiParseError({\n message: `Failed to fetch Google Discovery document: HTTP ${response.status}`,\n });\n }\n return yield* response.text.pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to read Google Discovery document body\",\n }),\n ),\n );\n },\n);\n\nconst schemaRef = (name: string) => `#/components/schemas/${name}`;\n\nconst identitySchemaName = (name: string): string => name;\n\nconst schemaComponentPart = (value: string): string =>\n value\n .trim()\n .replace(/[^A-Za-z0-9._-]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\") || \"schema\";\n\nconst normalizeDiscoveryPathTemplate = (pathTemplate: string): string =>\n pathTemplate.replaceAll(/\\{\\+([^{}]+)\\}/g, \"{$1}\");\n\nconst pathUsesReservedExpansion = (pathTemplate: string, parameterName: string): boolean =>\n pathTemplate.includes(`{+${parameterName}}`);\n\nconst uniquePathKey = (\n paths: Record<string, Record<string, OpenApiOperationObject>>,\n preferredPath: string,\n method: string,\n toolPath: string,\n): string => {\n if (!paths[preferredPath]?.[method]) return preferredPath;\n const disambiguated = `/${toolPath.replace(/[^A-Za-z0-9._~-]+/g, \"/\")}`;\n if (!paths[disambiguated]?.[method]) return disambiguated;\n let index = 2;\n while (paths[`${disambiguated}/${index}`]?.[method]) index += 1;\n return `${disambiguated}/${index}`;\n};\n\nconst discoveryDescription = (value: unknown): string | undefined =>\n typeof value === \"string\"\n ? value\n : Option.isOption(value) && Option.isSome(value)\n ? typeof value.value === \"string\"\n ? value.value\n : undefined\n : undefined;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst jsonValue = (value: unknown): JsonValue | undefined => {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n if (Array.isArray(value)) {\n const values = value.map(jsonValue);\n return values.every(Predicate.isNotUndefined) ? values : undefined;\n }\n if (!isRecord(value)) return undefined;\n const entries = Object.entries(value).flatMap(([key, item]) => {\n const converted = jsonValue(item);\n return converted === undefined ? [] : [[key, converted] as const];\n });\n return Object.fromEntries(entries);\n};\n\nconst stringArray = (value: unknown): readonly string[] | undefined => {\n if (!Array.isArray(value)) return undefined;\n const strings = value.filter((item): item is string => typeof item === \"string\");\n return strings.length === value.length ? strings : undefined;\n};\n\nconst schemaType = (value: unknown): OpenApiSchemaObject[\"type\"] | undefined =>\n typeof value === \"string\" && OPENAPI_SCHEMA_TYPES.has(value)\n ? (value as OpenApiSchemaObject[\"type\"])\n : undefined;\n\nconst discoverySchemaToOpenApiSchema = (\n raw: unknown,\n schemaNameForRef: (name: string) => string = identitySchemaName,\n): OpenApiSchemaObject => {\n if (!isRecord(raw)) return {};\n const schema = raw;\n if (typeof schema.$ref === \"string\") return { $ref: schemaRef(schemaNameForRef(schema.$ref)) };\n\n const description = discoveryDescription(schema.description);\n const title = discoveryDescription(schema.title);\n const defaultValue = jsonValue(schema.default);\n const enumValues = Array.isArray(schema.enum)\n ? schema.enum.map(jsonValue).filter(Predicate.isNotUndefined)\n : [];\n const format = typeof schema.format === \"string\" ? schema.format : undefined;\n const readOnly = typeof schema.readOnly === \"boolean\" ? schema.readOnly : undefined;\n const type = schemaType(schema.type);\n\n const base = {\n ...(description !== undefined ? { description } : {}),\n ...(title !== undefined ? { title } : {}),\n ...(format !== undefined ? { format } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n ...(defaultValue !== undefined ? { default: defaultValue } : {}),\n ...(enumValues.length > 0 ? { enum: enumValues } : {}),\n } satisfies OpenApiSchemaObject;\n\n if (type === \"array\") {\n return {\n ...base,\n type: \"array\",\n items: discoverySchemaToOpenApiSchema(schema.items, schemaNameForRef),\n };\n }\n\n const properties = schema.properties;\n if (\n type === \"object\" ||\n (isRecord(properties) && Object.keys(properties).length > 0) ||\n schema.additionalProperties !== undefined\n ) {\n const convertedProperties = isRecord(properties)\n ? Object.fromEntries(\n Object.entries(properties).map(([name, value]) => [\n name,\n discoverySchemaToOpenApiSchema(value, schemaNameForRef),\n ]),\n )\n : undefined;\n const required = stringArray(schema.required);\n const additionalProperties =\n schema.additionalProperties === undefined\n ? undefined\n : typeof schema.additionalProperties === \"boolean\"\n ? schema.additionalProperties\n : discoverySchemaToOpenApiSchema(schema.additionalProperties, schemaNameForRef);\n return {\n ...base,\n type: \"object\",\n ...(convertedProperties && Object.keys(convertedProperties).length > 0\n ? { properties: convertedProperties }\n : {}),\n ...(required && required.length > 0 ? { required } : {}),\n ...(additionalProperties !== undefined ? { additionalProperties } : {}),\n };\n }\n\n return type !== undefined ? { ...base, type } : base;\n};\n\nconst parameterSchema = (\n parameter: DiscoveryParameter,\n schemaNameForRef: (name: string) => string = identitySchemaName,\n): OpenApiSchemaObject => {\n const base = discoverySchemaToOpenApiSchema(parameter, schemaNameForRef);\n return parameter.repeated\n ? {\n type: \"array\",\n items: base,\n }\n : base;\n};\n\nconst methodToolPath = (service: string, methodId: string): string =>\n methodId.startsWith(`${service}.`) ? methodId.slice(service.length + 1) : methodId;\n\nconst collectMethods = (resource: unknown): DiscoveryMethod[] => {\n const decoded = decodeDiscoveryResource(resource);\n const direct = Object.values(decoded.methods ?? {}).map((raw) => decodeDiscoveryMethod(raw));\n const nested = Object.values(decoded.resources ?? {}).flatMap(collectMethods);\n return [...direct, ...nested];\n};\n\nconst discoveryScopes = (document: DiscoveryDocument): Record<string, string> =>\n Object.fromEntries(\n Object.entries(document.auth?.oauth2?.scopes ?? {}).map(([scope, value]) => [\n scope,\n Option.getOrElse(value.description, () => \"\"),\n ]),\n );\n\n// The scope set the converted integration DECLARES (and that `oauth.start`\n// requests at connect) must match the consent the picker previews. Both run the\n// raw Discovery union through `compactGoogleOAuthScopes`, which drops scopes a\n// user OAuth consent screen can't show (`chat.bot`/`chat.app.*`/`keep`) and\n// collapses sub-scopes under their broad parent (`gmail.*` → `mail.google.com`,\n// `userinfo.email` → `email`). Descriptions are preserved where the raw map had\n// them; compaction-introduced identity scopes (`email`/`profile`) fall back to\n// the broad parent's description. Per-operation `x-google-scopes`/`security`\n// stay RAW - they describe which scope each method needs, not consent.\nconst compactDiscoveryScopeMap = (raw: Record<string, string>): Record<string, string> => {\n const descriptionFor = (scope: string): string => {\n if (raw[scope] !== undefined) return raw[scope];\n if (scope === \"email\") return raw[\"https://www.googleapis.com/auth/userinfo.email\"] ?? \"\";\n if (scope === \"profile\") return raw[\"https://www.googleapis.com/auth/userinfo.profile\"] ?? \"\";\n return \"\";\n };\n return Object.fromEntries(\n compactGoogleOAuthScopes(Object.keys(raw)).map((scope) => [scope, descriptionFor(scope)]),\n );\n};\n\nconst allDiscoveryMethods = (document: DiscoveryDocument): DiscoveryMethod[] => [\n ...Object.values(document.methods ?? {}).map((raw) => decodeDiscoveryMethod(raw)),\n ...Object.values(document.resources ?? {}).flatMap(collectMethods),\n];\n\ntype DiscoveryDocumentInfo = {\n readonly discoveryUrl: string;\n readonly document: DiscoveryDocument;\n readonly service: string;\n readonly version: string;\n readonly rootUrl: string;\n readonly baseUrl: string;\n readonly title: string;\n};\n\nconst discoveryDocumentInfo = (\n document: DiscoveryDocument,\n discoveryUrl: string,\n): Effect.Effect<DiscoveryDocumentInfo, OpenApiParseError> =>\n Effect.gen(function* () {\n const service = Option.getOrUndefined(document.name);\n const version = Option.getOrUndefined(document.version);\n const rootUrl = Option.getOrUndefined(document.rootUrl);\n if (!service || !version || !rootUrl) {\n return yield* new OpenApiParseError({\n message: \"Google Discovery document is missing one of: name, version, rootUrl\",\n });\n }\n\n return {\n discoveryUrl,\n document,\n service,\n version,\n rootUrl,\n baseUrl: new URL(document.servicePath || \"\", rootUrl).toString(),\n title: Option.getOrElse(document.title, () => `${service} ${version}`),\n };\n });\n\nconst googleDiscoveryResponseContent = (\n method: DiscoveryMethod,\n schemaNameForRef: (name: string) => string,\n): OpenApiOperationObject[\"responses\"][\"200\"][\"content\"] => {\n if (\n (method.supportsMediaDownload === true || method.useMediaDownloadService === true) &&\n method.response === undefined\n ) {\n return {\n \"application/octet-stream\": {\n schema: {\n type: \"string\",\n format: \"binary\",\n },\n },\n };\n }\n\n return {\n \"application/json\": {\n schema: method.response?.$ref\n ? { $ref: schemaRef(schemaNameForRef(method.response.$ref)) }\n : {},\n },\n };\n};\n\nconst buildDiscoveryOperation = (input: {\n readonly document: DiscoveryDocument;\n readonly method: DiscoveryMethod;\n readonly toolPath: string;\n readonly pathTemplate: string;\n readonly oauthScopes?: readonly string[];\n readonly schemaNameForRef?: (name: string) => string;\n readonly serverUrl?: string;\n readonly tags?: readonly string[];\n}): OpenApiOperationObject => {\n const mergedParameters = new Map<string, DiscoveryParameter>();\n for (const [name, raw] of Object.entries(input.document.parameters ?? {})) {\n const parameter = decodeDiscoveryParameter(raw);\n if (parameter.location) mergedParameters.set(name, parameter);\n }\n for (const [name, raw] of Object.entries(input.method.parameters ?? {})) {\n const parameter = decodeDiscoveryParameter(raw);\n if (parameter.location) mergedParameters.set(name, parameter);\n }\n\n const methodScopes = input.oauthScopes ?? input.method.scopes ?? [];\n const methodDescription = Option.getOrUndefined(input.method.description);\n const schemaNameForRef = input.schemaNameForRef ?? identitySchemaName;\n\n return {\n operationId: input.toolPath,\n \"x-executor-toolPath\": input.toolPath,\n \"x-executor-pathTemplate\": input.pathTemplate,\n ...(input.tags && input.tags.length > 0 ? { tags: input.tags } : {}),\n ...(methodDescription !== undefined ? { description: methodDescription } : {}),\n ...(input.serverUrl ? { servers: [{ url: input.serverUrl }] } : {}),\n parameters: [...mergedParameters.entries()].flatMap(([name, parameter]) => {\n const location = parameter.location;\n if (!location) return [];\n const description = Option.getOrUndefined(parameter.description);\n const allowReserved =\n location === \"path\" && pathUsesReservedExpansion(input.pathTemplate, name);\n return [\n {\n name,\n in: location,\n required: location === \"path\" ? true : parameter.required === true,\n ...(description !== undefined ? { description } : {}),\n schema: parameterSchema(parameter, schemaNameForRef),\n ...(location === \"query\"\n ? { style: \"form\" as const, explode: parameter.repeated === true }\n : {}),\n ...(allowReserved ? { allowReserved: true } : {}),\n },\n ];\n }),\n ...(input.method.request?.$ref\n ? {\n requestBody: {\n required: false,\n content: {\n \"application/json\": {\n schema: { $ref: schemaRef(schemaNameForRef(input.method.request.$ref)) },\n },\n },\n },\n }\n : {}),\n responses: {\n \"200\": {\n description: \"Successful response\",\n content: googleDiscoveryResponseContent(input.method, schemaNameForRef),\n },\n },\n ...(methodScopes.length > 0 ? { security: [{ googleOAuth2: methodScopes }] } : {}),\n \"x-google-scopes\": methodScopes,\n };\n};\n\nconst buildDiscoveryMediaUploadOperation = (input: {\n readonly document: DiscoveryDocument;\n readonly method: DiscoveryMethod;\n readonly toolPath: string;\n readonly oauthScopes?: readonly string[];\n readonly schemaNameForRef?: (name: string) => string;\n readonly serverUrl?: string;\n readonly tags?: readonly string[];\n}): OpenApiOperationObject | undefined => {\n if (input.method.supportsMediaUpload !== true) return undefined;\n const mediaUpload = input.method.mediaUpload;\n if (mediaUpload === undefined) return undefined;\n const simpleProtocol = mediaUpload.protocols?.simple;\n const uploadPath = simpleProtocol ? Option.getOrUndefined(simpleProtocol.path) : undefined;\n if (!uploadPath) return undefined;\n\n const mergedParameters = new Map<string, DiscoveryParameter>();\n for (const [name, raw] of Object.entries(input.document.parameters ?? {})) {\n const parameter = decodeDiscoveryParameter(raw);\n if (parameter.location) mergedParameters.set(name, parameter);\n }\n for (const [name, raw] of Object.entries(input.method.parameters ?? {})) {\n const parameter = decodeDiscoveryParameter(raw);\n if (parameter.location) mergedParameters.set(name, parameter);\n }\n mergedParameters.set(\"uploadType\", {\n type: \"string\",\n location: \"query\",\n required: true,\n description: Option.some(\"The upload type for the media upload.\"),\n properties: {},\n items: undefined,\n additionalProperties: undefined,\n enum: [\"media\"],\n format: undefined,\n readOnly: undefined,\n default: \"media\",\n $ref: undefined,\n repeated: undefined,\n });\n\n const methodScopes = input.oauthScopes ?? input.method.scopes ?? [];\n const schemaNameForRef = input.schemaNameForRef ?? identitySchemaName;\n const methodDescription = Option.getOrUndefined(input.method.description);\n\n return {\n operationId: `${input.toolPath}Media`,\n \"x-executor-toolPath\": `${input.toolPath}Media`,\n \"x-executor-pathTemplate\": uploadPath,\n ...(input.tags && input.tags.length > 0 ? { tags: input.tags } : {}),\n ...(methodDescription !== undefined\n ? { description: `${methodDescription} (media upload)` }\n : {}),\n ...(input.serverUrl ? { servers: [{ url: input.serverUrl }] } : {}),\n parameters: [...mergedParameters.entries()].flatMap(([name, parameter]) => {\n const location = parameter.location;\n if (!location) return [];\n const description = Option.getOrUndefined(parameter.description);\n const allowReserved = location === \"path\" && pathUsesReservedExpansion(uploadPath, name);\n return [\n {\n name,\n in: location,\n required: location === \"path\" ? true : parameter.required === true,\n ...(description !== undefined ? { description } : {}),\n schema: parameterSchema(parameter, schemaNameForRef),\n ...(location === \"query\"\n ? { style: \"form\" as const, explode: parameter.repeated === true }\n : {}),\n ...(allowReserved ? { allowReserved: true } : {}),\n },\n ];\n }),\n requestBody: {\n required: true,\n content: {\n \"application/octet-stream\": {\n schema: { type: \"string\", format: \"binary\" },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Successful response\",\n content: {\n \"application/json\": {\n schema: input.method.response?.$ref\n ? { $ref: schemaRef(schemaNameForRef(input.method.response.$ref)) }\n : {},\n },\n },\n },\n },\n ...(methodScopes.length > 0 ? { security: [{ googleOAuth2: methodScopes }] } : {}),\n \"x-google-scopes\": methodScopes,\n };\n};\n\nconst GOOGLE_OAUTH_SECURITY_SCHEME = \"googleOAuth2\";\nconst GOOGLE_PHOTOS_LIBRARY_SERVICE = \"photoslibrary\";\nconst GOOGLE_PHOTOS_APPENDONLY_SCOPE = \"https://www.googleapis.com/auth/photoslibrary.appendonly\";\nconst GOOGLE_PHOTOS_UPLOAD_TOOL_PATH = \"photoslibrary.mediaItems.upload\";\nconst GOOGLE_PHOTOS_UPLOAD_PATH = \"/uploads\";\n\nconst isGooglePhotosService = (service: string): boolean =>\n service === GOOGLE_PHOTOS_LIBRARY_SERVICE || service === GOOGLE_PHOTOS_PICKER_SERVICE;\n\nconst discoveryScopesForService = (\n service: string,\n document: DiscoveryDocument,\n): Record<string, string> => {\n const scopes = discoveryScopes(document);\n const overrideScopes = GOOGLE_DISCOVERY_SERVICE_OVERRIDES[service]?.scopes;\n if (!overrideScopes) {\n return scopes;\n }\n const missingScopes = Object.fromEntries(\n Object.entries(overrideScopes).filter(([scope]) => scopes[scope] === undefined),\n );\n return Object.keys(missingScopes).length === 0 ? scopes : { ...scopes, ...missingScopes };\n};\n\nconst discoveryMethodScopesForService = (\n service: string,\n method: DiscoveryMethod,\n): readonly string[] => {\n const scopes = method.scopes ?? [];\n return scopes.length === 0\n ? (GOOGLE_DISCOVERY_SERVICE_OVERRIDES[service]?.fallbackMethodScopes ?? scopes)\n : scopes;\n};\n\n/** The v2 oauth auth template for a Google-discovery integration. The spec\n * itself carries the matching `securitySchemes.googleOAuth2` entry; this is the\n * catalog-level template a connection's access token renders through. */\nconst googleOauthTemplate = (scopes: Record<string, string>): readonly Authentication[] =>\n // A Google-discovery integration is ALWAYS OAuth, so it ALWAYS declares its\n // oauth method - even when the compacted scope set is empty (e.g. a bundle of\n // only limited-consent APIs like Google Keep, whose scopes Google won't grant\n // through standard consent). Without this the integration declares no auth\n // method and the \"Add account\" / \"Add a connection\" actions are disabled, so\n // you can't even start the flow. Empty `scopes` just requests no scope.\n [\n {\n slug: AuthTemplateSlug.make(GOOGLE_OAUTH_SECURITY_SCHEME),\n kind: \"oauth2\",\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes: Object.keys(scopes),\n },\n ];\n\nconst googlePhotosUploadOperation = (input: {\n readonly toolPath: string;\n readonly oauthScopes: readonly string[];\n readonly serverUrl: string;\n readonly tags?: readonly string[];\n}): OpenApiOperationObject => ({\n operationId: input.toolPath,\n \"x-executor-toolPath\": input.toolPath,\n \"x-executor-pathTemplate\": GOOGLE_PHOTOS_UPLOAD_PATH,\n ...(input.tags && input.tags.length > 0 ? { tags: input.tags } : {}),\n description:\n \"Uploads raw photo or video bytes to Google Photos and returns a plain-text upload token. Call mediaItems.batchCreate with the returned token to create the media item.\",\n servers: [{ url: input.serverUrl }],\n parameters: [\n {\n name: \"X-Goog-Upload-File-Name\",\n in: \"header\",\n required: true,\n description: \"File name Google Photos should associate with the uploaded bytes.\",\n schema: { type: \"string\" },\n },\n {\n name: \"X-Goog-Upload-Protocol\",\n in: \"header\",\n required: true,\n description: \"Google Photos raw upload protocol. Set to raw.\",\n schema: { type: \"string\", enum: [\"raw\"], default: \"raw\" },\n },\n {\n name: \"X-Goog-Upload-Content-Type\",\n in: \"header\",\n required: false,\n description: \"MIME type of the uploaded media, for example image/jpeg or video/mp4.\",\n schema: { type: \"string\" },\n },\n ],\n requestBody: {\n required: true,\n content: {\n \"application/octet-stream\": {\n schema: { type: \"string\", format: \"binary\" },\n },\n },\n },\n responses: {\n \"200\": {\n description: \"Successful response\",\n content: {\n \"text/plain\": {\n schema: { type: \"string\" },\n },\n },\n },\n },\n ...(input.oauthScopes.length > 0 ? { security: [{ googleOAuth2: input.oauthScopes }] } : {}),\n \"x-google-scopes\": input.oauthScopes,\n});\n\nconst hasOperation = (\n paths: Record<string, Record<string, OpenApiOperationObject>>,\n operationId: string,\n): boolean =>\n Object.values(paths).some((pathItem) =>\n Object.values(pathItem).some((operation) => operation.operationId === operationId),\n );\n\nexport const convertGoogleDiscoveryToOpenApi = Effect.fn(\"OpenApi.convertGoogleDiscovery\")(\n function* (input: { readonly discoveryUrl: string; readonly documentText: string }) {\n const parsed = yield* parseJson(input.documentText).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to parse Google Discovery document\",\n }),\n ),\n );\n const document = yield* Effect.try({\n try: () => decodeDiscoveryDocument(parsed),\n catch: () =>\n new OpenApiParseError({\n message: \"Failed to decode Google Discovery document\",\n }),\n });\n\n const info = yield* discoveryDocumentInfo(document, input.discoveryUrl);\n const { service, version, rootUrl, baseUrl, title } = info;\n const paths: Record<string, Record<string, OpenApiOperationObject>> = {};\n\n for (const method of allDiscoveryMethods(document)) {\n const methodId = Option.getOrUndefined(method.id);\n const pathTemplate = Option.getOrUndefined(method.path);\n if (!methodId || !pathTemplate || !method.httpMethod) continue;\n\n const toolPath = methodToolPath(service, methodId);\n const path = normalizeDiscoveryPathTemplate(\n pathTemplate.startsWith(\"/\") ? pathTemplate : `/${pathTemplate}`,\n );\n const methodKey = method.httpMethod.toLowerCase();\n const pathKey = uniquePathKey(paths, path, methodKey, toolPath);\n\n paths[pathKey] ??= {};\n paths[pathKey]![methodKey] = buildDiscoveryOperation({\n document,\n method,\n toolPath,\n pathTemplate: pathTemplate.startsWith(\"/\") ? pathTemplate : `/${pathTemplate}`,\n oauthScopes: discoveryMethodScopesForService(service, method),\n });\n\n const mediaUploadOperation = buildDiscoveryMediaUploadOperation({\n document,\n method,\n toolPath,\n oauthScopes: discoveryMethodScopesForService(service, method),\n serverUrl: rootUrl,\n });\n if (mediaUploadOperation) {\n const mediaUploadPathTemplate = mediaUploadOperation[\"x-executor-pathTemplate\"] ?? \"\";\n const uploadPath = normalizeDiscoveryPathTemplate(\n mediaUploadPathTemplate.startsWith(\"/\")\n ? mediaUploadPathTemplate\n : `/${mediaUploadPathTemplate}`,\n );\n const uploadMethodKey = method.httpMethod.toLowerCase();\n const uploadPathKey = uniquePathKey(\n paths,\n uploadPath,\n uploadMethodKey,\n mediaUploadOperation.operationId,\n );\n paths[uploadPathKey] ??= {};\n paths[uploadPathKey]![uploadMethodKey] = mediaUploadOperation;\n }\n }\n\n if (\n service === GOOGLE_PHOTOS_LIBRARY_SERVICE &&\n !hasOperation(paths, GOOGLE_PHOTOS_UPLOAD_TOOL_PATH)\n ) {\n paths[GOOGLE_PHOTOS_UPLOAD_PATH] ??= {};\n paths[GOOGLE_PHOTOS_UPLOAD_PATH]!.post = googlePhotosUploadOperation({\n toolPath: GOOGLE_PHOTOS_UPLOAD_TOOL_PATH,\n oauthScopes: [GOOGLE_PHOTOS_APPENDONLY_SCOPE],\n serverUrl: baseUrl,\n });\n }\n\n const scopes = compactDiscoveryScopeMap(discoveryScopesForService(service, document));\n const authenticationTemplate = googleOauthTemplate(scopes);\n\n const spec: OpenApiDocument = {\n openapi: \"3.1.0\",\n info: {\n title,\n version,\n },\n servers: [{ url: baseUrl }],\n paths,\n components: {\n schemas: Object.fromEntries(\n Object.entries(document.schemas ?? {}).map(([name, schema]) => [\n name,\n discoverySchemaToOpenApiSchema(schema),\n ]),\n ),\n ...(authenticationTemplate\n ? {\n securitySchemes: {\n googleOAuth2: {\n type: \"oauth2\",\n flows: {\n authorizationCode: {\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes,\n },\n },\n },\n },\n }\n : {}),\n },\n ...(authenticationTemplate ? { security: [{ googleOAuth2: Object.keys(scopes) }] } : {}),\n \"x-executor-origin\": {\n kind: \"googleDiscovery\",\n discoveryUrl: normalizeDiscoveryUrl(input.discoveryUrl),\n service,\n version,\n },\n };\n\n return {\n // @effect-diagnostics-next-line preferSchemaOverJson:off\n specText: JSON.stringify(spec),\n baseUrl,\n title,\n service,\n version,\n ...(authenticationTemplate ? { authenticationTemplate } : {}),\n };\n },\n);\n\nexport const convertGoogleDiscoveryBundleToOpenApi = Effect.fn(\n \"OpenApi.convertGoogleDiscoveryBundle\",\n)(function* (input: {\n readonly documents: readonly { readonly discoveryUrl: string; readonly documentText: string }[];\n readonly consentScopes?: readonly string[];\n}) {\n if (input.documents.length === 0) {\n return yield* new OpenApiParseError({\n message: \"Google Discovery bundle requires at least one document\",\n });\n }\n\n const infos = yield* Effect.forEach(input.documents, ({ discoveryUrl, documentText }) =>\n Effect.gen(function* () {\n const parsed = yield* parseJson(documentText).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to parse Google Discovery document\",\n }),\n ),\n );\n const document = yield* Effect.try({\n try: () => decodeDiscoveryDocument(parsed),\n catch: () =>\n new OpenApiParseError({\n message: \"Failed to decode Google Discovery document\",\n }),\n });\n return yield* discoveryDocumentInfo(document, discoveryUrl);\n }),\n );\n\n const paths: Record<string, Record<string, OpenApiOperationObject>> = {};\n const schemas: Record<string, OpenApiSchemaObject> = {};\n const rawScopes: Record<string, string> = {};\n const consentScopeSet = input.consentScopes ? new Set(input.consentScopes) : null;\n\n for (const info of infos) {\n const schemaPrefix = schemaComponentPart(`${info.service}_${info.version}`);\n const schemaNameForRef = (name: string) => `${schemaPrefix}_${schemaComponentPart(name)}`;\n const scopeDescriptions = discoveryScopesForService(info.service, info.document);\n const filterPhotosScopes = consentScopeSet !== null && isGooglePhotosService(info.service);\n\n for (const [scope, description] of Object.entries(scopeDescriptions)) {\n if (filterPhotosScopes && !consentScopeSet.has(scope)) continue;\n rawScopes[scope] ??= description;\n }\n\n for (const [name, schema] of Object.entries(info.document.schemas ?? {})) {\n schemas[schemaNameForRef(name)] = discoverySchemaToOpenApiSchema(schema, schemaNameForRef);\n }\n\n for (const method of allDiscoveryMethods(info.document)) {\n const methodId = Option.getOrUndefined(method.id);\n const rawPathTemplate = Option.getOrUndefined(method.path);\n if (!methodId || !rawPathTemplate || !method.httpMethod) continue;\n const methodScopes = discoveryMethodScopesForService(info.service, method);\n const oauthScopes = filterPhotosScopes\n ? methodScopes.filter((scope) => consentScopeSet.has(scope))\n : methodScopes;\n if (filterPhotosScopes && methodScopes.length > 0 && oauthScopes.length === 0) continue;\n\n const toolPath = methodId;\n const wirePath = rawPathTemplate.startsWith(\"/\") ? rawPathTemplate : `/${rawPathTemplate}`;\n const openApiPath = normalizeDiscoveryPathTemplate(wirePath);\n const methodKey = method.httpMethod.toLowerCase();\n const pathKey = uniquePathKey(paths, openApiPath, methodKey, toolPath);\n\n paths[pathKey] ??= {};\n paths[pathKey]![methodKey] = buildDiscoveryOperation({\n document: info.document,\n method,\n toolPath,\n pathTemplate: wirePath,\n oauthScopes,\n schemaNameForRef,\n serverUrl: info.baseUrl,\n tags: [info.title],\n });\n\n const mediaUploadOperation = buildDiscoveryMediaUploadOperation({\n document: info.document,\n method,\n toolPath,\n oauthScopes,\n schemaNameForRef,\n serverUrl: info.rootUrl,\n tags: [info.title],\n });\n if (mediaUploadOperation) {\n const mediaUploadPathTemplate = mediaUploadOperation[\"x-executor-pathTemplate\"] ?? \"\";\n const uploadPath = normalizeDiscoveryPathTemplate(\n mediaUploadPathTemplate.startsWith(\"/\")\n ? mediaUploadPathTemplate\n : `/${mediaUploadPathTemplate}`,\n );\n const uploadMethodKey = method.httpMethod.toLowerCase();\n const uploadPathKey = uniquePathKey(\n paths,\n uploadPath,\n uploadMethodKey,\n mediaUploadOperation.operationId,\n );\n paths[uploadPathKey] ??= {};\n paths[uploadPathKey]![uploadMethodKey] = mediaUploadOperation;\n }\n }\n\n if (\n info.service === GOOGLE_PHOTOS_LIBRARY_SERVICE &&\n (!consentScopeSet || consentScopeSet.has(GOOGLE_PHOTOS_APPENDONLY_SCOPE)) &&\n !hasOperation(paths, GOOGLE_PHOTOS_UPLOAD_TOOL_PATH)\n ) {\n paths[GOOGLE_PHOTOS_UPLOAD_PATH] ??= {};\n paths[GOOGLE_PHOTOS_UPLOAD_PATH]!.post = googlePhotosUploadOperation({\n toolPath: GOOGLE_PHOTOS_UPLOAD_TOOL_PATH,\n oauthScopes: [GOOGLE_PHOTOS_APPENDONLY_SCOPE],\n serverUrl: info.baseUrl,\n tags: [info.title],\n });\n }\n }\n\n const scopes = compactDiscoveryScopeMap(rawScopes);\n const authenticationTemplate = googleOauthTemplate(scopes);\n const spec: OpenApiDocument = {\n openapi: \"3.1.0\",\n info: {\n title: \"Google\",\n version: \"google-discovery-bundle\",\n },\n servers: [{ url: GOOGLE_BUNDLE_BASE_URL }],\n paths,\n components: {\n schemas,\n ...(authenticationTemplate\n ? {\n securitySchemes: {\n googleOAuth2: {\n type: \"oauth2\",\n flows: {\n authorizationCode: {\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes,\n },\n },\n },\n },\n }\n : {}),\n },\n ...(authenticationTemplate ? { security: [{ googleOAuth2: Object.keys(scopes) }] } : {}),\n \"x-executor-origin\": {\n kind: \"googleDiscoveryBundle\",\n services: infos.map((info) => ({\n discoveryUrl: normalizeDiscoveryUrl(info.discoveryUrl),\n service: info.service,\n version: info.version,\n })),\n },\n };\n\n return {\n // @effect-diagnostics-next-line preferSchemaOverJson:off\n specText: JSON.stringify(spec),\n baseUrl: GOOGLE_BUNDLE_BASE_URL,\n title: \"Google\",\n service: \"google\",\n version: \"google-discovery-bundle\",\n discoveryUrls: infos.map((info) => normalizeDiscoveryUrl(info.discoveryUrl)),\n ...(authenticationTemplate ? { authenticationTemplate } : {}),\n };\n});\n","const googleUserConsentBlockedScopes = new Set([\n \"https://www.googleapis.com/auth/chat.bot\",\n \"https://www.googleapis.com/auth/chat.import\",\n \"https://www.googleapis.com/auth/keep\",\n \"https://www.googleapis.com/auth/keep.readonly\",\n]);\n\nconst googleUserConsentBlockedScopePrefixes = [\"https://www.googleapis.com/auth/chat.app.\"];\n\nconst googleBroadScopeGroups: readonly {\n readonly broad: string;\n readonly prefixes: readonly string[];\n}[] = [\n {\n broad: \"https://mail.google.com/\",\n prefixes: [\"https://www.googleapis.com/auth/gmail.\"],\n },\n {\n broad: \"https://www.googleapis.com/auth/calendar\",\n prefixes: [\"https://www.googleapis.com/auth/calendar.\"],\n },\n {\n broad: \"https://www.googleapis.com/auth/drive\",\n prefixes: [\"https://www.googleapis.com/auth/drive.\"],\n },\n];\n\nconst normalizeGoogleIdentityScope = (scope: string): string =>\n scope === \"https://www.googleapis.com/auth/userinfo.email\"\n ? \"email\"\n : scope === \"https://www.googleapis.com/auth/userinfo.profile\"\n ? \"profile\"\n : scope;\n\nconst orderedUniqueScopes = (scopes: Iterable<string>): string[] => {\n const ordered: string[] = [];\n const seen = new Set<string>();\n for (const scope of scopes) {\n const trimmed = scope.trim();\n if (!trimmed || seen.has(trimmed)) continue;\n seen.add(trimmed);\n ordered.push(trimmed);\n }\n return ordered;\n};\n\nexport const isGoogleUserConsentOAuthScope = (scope: string): boolean =>\n !googleUserConsentBlockedScopes.has(scope) &&\n !googleUserConsentBlockedScopePrefixes.some((prefix) => scope.startsWith(prefix));\n\nexport const filterGoogleUserConsentOAuthScopes = (scopes: Iterable<string>): string[] =>\n orderedUniqueScopes(scopes).filter(isGoogleUserConsentOAuthScope);\n\nexport const compactGoogleOAuthScopes = (scopes: Iterable<string>): string[] => {\n const ordered = filterGoogleUserConsentOAuthScopes([...scopes].map(normalizeGoogleIdentityScope));\n const present = new Set(ordered);\n return ordered.filter(\n (scope) =>\n !googleBroadScopeGroups.some(\n (group) =>\n scope !== group.broad &&\n present.has(group.broad) &&\n group.prefixes.some((prefix) => scope.startsWith(prefix)),\n ),\n );\n};\n","import { normalizeGoogleDiscoveryUrl } from \"./discovery\";\nimport { compactGoogleOAuthScopes } from \"./oauth-scopes\";\nimport type { HealthCheckSpec, IntegrationPreset } from \"@rafads/sdk/core\";\n\nexport interface GooglePreset {\n readonly id: string;\n readonly name: string;\n readonly summary: string;\n readonly url?: string;\n readonly icon?: string;\n readonly featured?: boolean;\n}\n\nexport type GoogleOpenApiOAuthAudience =\n | \"standard-user\"\n | \"advanced-user\"\n | \"workspace-admin\"\n | \"unsupported-user\";\n\nexport type GoogleOpenApiPreset = GooglePreset & {\n readonly oauthAudience: GoogleOpenApiOAuthAudience;\n};\n\nconst gd = (service: string, version: string) =>\n `https://www.googleapis.com/discovery/v1/apis/${service}/${version}/rest`;\n\nconst GOOGLE_G = \"https://fonts.gstatic.com/s/i/productlogos/googleg/v6/192px.svg\";\nexport const GOOGLE_BUNDLE_PRESET_ID = \"google\";\nexport const GOOGLE_PHOTOS_PRESET_ID = \"google-photos\";\nexport const GOOGLE_PHOTOS_ICON =\n \"https://www.gstatic.com/images/branding/product/2x/photos_96dp.png\";\n\nexport const googleOpenApiBundlePreset: GooglePreset = {\n id: GOOGLE_BUNDLE_PRESET_ID,\n name: \"Google\",\n summary: \"Bundle Gmail, Calendar, Drive, Docs, and other Google APIs into one integration.\",\n icon: GOOGLE_G,\n featured: true,\n};\n\nexport const googlePhotosOpenApiBundlePreset: GooglePreset = {\n id: GOOGLE_PHOTOS_PRESET_ID,\n name: \"Google Photos\",\n summary: \"Albums, uploads, app-created media, and user-selected picker media.\",\n icon: GOOGLE_PHOTOS_ICON,\n featured: true,\n};\n\nexport const googleOpenApiPresets: readonly GoogleOpenApiPreset[] = [\n {\n id: \"google-calendar\",\n name: \"Google Calendar\",\n summary: \"Calendars, events, ACLs, and scheduling.\",\n url: gd(\"calendar\", \"v3\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/calendar_2020q4/v8/192px.svg\",\n featured: true,\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-gmail\",\n name: \"Gmail\",\n summary: \"Messages, threads, labels, and drafts.\",\n url: gd(\"gmail\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/gmail_2020q4/v8/web-96dp/logo_gmail_2020q4_color_2x_web_96dp.png\",\n featured: true,\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-sheets\",\n name: \"Google Sheets\",\n summary: \"Spreadsheets, values, ranges, and formatting.\",\n url: gd(\"sheets\", \"v4\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/sheets_2020q4/v8/192px.svg\",\n featured: true,\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-drive\",\n name: \"Google Drive\",\n summary: \"Files, folders, permissions, and shared drives.\",\n url: gd(\"drive\", \"v3\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/drive_2020q4/v8/192px.svg\",\n featured: true,\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-docs\",\n name: \"Google Docs\",\n summary: \"Documents, structural edits, and formatting.\",\n url: gd(\"docs\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/docs_2020q4/v12/192px.svg\",\n featured: true,\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-slides\",\n name: \"Google Slides\",\n summary: \"Presentations, slides, page elements, and deck updates.\",\n url: gd(\"slides\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/slides_2020q4/v12/192px.svg\",\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-forms\",\n name: \"Google Forms\",\n summary: \"Forms, questions, responses, and quizzes.\",\n url: \"https://forms.googleapis.com/$discovery/rest?version=v1\",\n icon: \"https://fonts.gstatic.com/s/i/productlogos/forms_2020q4/v6/192px.svg\",\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-tasks\",\n name: \"Google Tasks\",\n summary: \"Task lists, task items, notes, and due dates.\",\n url: gd(\"tasks\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/tasks/v5/192px.svg\",\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-people\",\n name: \"Google People\",\n summary: \"Contacts, profiles, directory people, and contact groups.\",\n url: gd(\"people\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/contacts_2022/v2/192px.svg\",\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-photos-library\",\n name: \"Google Photos Library\",\n summary: \"Albums, uploads, and app-created media through Google Photos.\",\n url: gd(\"photoslibrary\", \"v1\"),\n icon: GOOGLE_PHOTOS_ICON,\n oauthAudience: \"advanced-user\",\n },\n {\n id: \"google-photos-picker\",\n name: \"Google Photos Picker\",\n summary: \"Picker sessions and user-selected Google Photos media items.\",\n url: \"https://photospicker.googleapis.com/$discovery/rest?version=v1\",\n icon: GOOGLE_PHOTOS_ICON,\n oauthAudience: \"advanced-user\",\n },\n {\n id: \"google-chat\",\n name: \"Google Chat\",\n summary: \"Spaces, messages, members, reactions, and chat workflows.\",\n url: gd(\"chat\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/chat_2020q4/v8/192px.svg\",\n oauthAudience: \"workspace-admin\",\n },\n {\n id: \"google-keep\",\n name: \"Google Keep\",\n summary: \"Notes, lists, attachments, and annotations.\",\n url: \"https://keep.googleapis.com/$discovery/rest?version=v1\",\n icon: \"https://fonts.gstatic.com/s/i/productlogos/keep_2020q4/v8/192px.svg\",\n oauthAudience: \"unsupported-user\",\n },\n {\n id: \"google-youtube-data\",\n name: \"YouTube Data\",\n summary: \"Channels, playlists, videos, comments, and uploads.\",\n url: gd(\"youtube\", \"v3\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/youtube/v9/192px.svg\",\n oauthAudience: \"advanced-user\",\n },\n {\n id: \"google-search-console\",\n name: \"Google Search Console\",\n summary: \"Sites, sitemaps, URL inspection, and search performance.\",\n url: gd(\"searchconsole\", \"v1\"),\n icon: GOOGLE_G,\n oauthAudience: \"standard-user\",\n },\n {\n id: \"google-classroom\",\n name: \"Google Classroom\",\n summary: \"Courses, rosters, coursework, and grading.\",\n url: gd(\"classroom\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/classroom/v7/192px.svg\",\n oauthAudience: \"advanced-user\",\n },\n {\n id: \"google-admin-directory\",\n name: \"Google Admin Directory\",\n summary: \"Users, groups, org units, roles, and domain resources.\",\n url: \"https://admin.googleapis.com/$discovery/rest?version=directory_v1\",\n icon: \"https://fonts.gstatic.com/s/i/productlogos/admin_2020q4/v6/192px.svg\",\n oauthAudience: \"workspace-admin\",\n },\n {\n id: \"google-admin-reports\",\n name: \"Google Admin Reports\",\n summary: \"Audit events, usage reports, and admin activity logs.\",\n url: \"https://admin.googleapis.com/$discovery/rest?version=reports_v1\",\n icon: \"https://fonts.gstatic.com/s/i/productlogos/admin_2020q4/v6/192px.svg\",\n oauthAudience: \"workspace-admin\",\n },\n {\n id: \"google-apps-script\",\n name: \"Google Apps Script\",\n summary: \"Projects, deployments, and script execution.\",\n url: gd(\"script\", \"v1\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/apps_script/v10/192px.svg\",\n oauthAudience: \"advanced-user\",\n },\n {\n id: \"google-bigquery\",\n name: \"Google BigQuery\",\n summary: \"Datasets, tables, jobs, and analytical queries.\",\n url: gd(\"bigquery\", \"v2\"),\n icon: \"https://fonts.gstatic.com/s/i/productlogos/google_cloud/v6/192px.svg\",\n oauthAudience: \"advanced-user\",\n },\n {\n id: \"google-cloud-resource-manager\",\n name: \"Google Cloud Resource Manager\",\n summary: \"Projects, folders, organizations, and IAM hierarchy.\",\n url: \"https://cloudresourcemanager.googleapis.com/$discovery/rest?version=v3\",\n icon: \"https://fonts.gstatic.com/s/i/productlogos/google_cloud/v6/192px.svg\",\n oauthAudience: \"advanced-user\",\n },\n];\n\nexport const googleStandardUserOAuthPresets = googleOpenApiPresets.filter(\n (preset) => preset.oauthAudience === \"standard-user\",\n);\n\nexport const googlePhotosPresetIds: readonly string[] = [\n \"google-photos-library\",\n \"google-photos-picker\",\n];\n\nexport const googlePhotosOpenApiPresets: readonly GoogleOpenApiPreset[] =\n googleOpenApiPresets.filter((preset) => googlePhotosPresetIds.includes(preset.id));\n\n// ---------------------------------------------------------------------------\n// Representative consent scopes per preset.\n//\n// The picker shows the OAuth consent a user is about to grant BEFORE connecting\n// (the \"View scopes\" panel), but the authoritative scope list only exists in\n// each API's live Discovery document, which the add flow fetches lazily at\n// provider add time. To preview consent without N network round-trips, each preset\n// declares the broad top-level scope(s) a full integration grants. These flow\n// through `googleOAuthConsentBatches` (which compacts sub-scopes under their\n// broad parent), so the previewed grant matches the unioned scopes the bundle\n// converter ultimately stores. Grounded against each API's published Discovery\n// `auth.oauth2.scopes`.\n// ---------------------------------------------------------------------------\n\nexport const googleOAuthConsentScopes: Readonly<Record<string, readonly string[]>> = {\n \"google-calendar\": [\"https://www.googleapis.com/auth/calendar\"],\n \"google-gmail\": [\"https://mail.google.com/\"],\n \"google-sheets\": [\"https://www.googleapis.com/auth/spreadsheets\"],\n \"google-drive\": [\"https://www.googleapis.com/auth/drive\"],\n \"google-docs\": [\"https://www.googleapis.com/auth/documents\"],\n \"google-slides\": [\"https://www.googleapis.com/auth/presentations\"],\n \"google-forms\": [\"https://www.googleapis.com/auth/forms.body\"],\n \"google-tasks\": [\"https://www.googleapis.com/auth/tasks\"],\n \"google-people\": [\"https://www.googleapis.com/auth/contacts\"],\n \"google-photos-library\": [\n \"https://www.googleapis.com/auth/photoslibrary.appendonly\",\n \"https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata\",\n ],\n \"google-photos-picker\": [\"https://www.googleapis.com/auth/photospicker.mediaitems.readonly\"],\n \"google-chat\": [\"https://www.googleapis.com/auth/chat.spaces\"],\n \"google-keep\": [\"https://www.googleapis.com/auth/keep\"],\n \"google-youtube-data\": [\"https://www.googleapis.com/auth/youtube\"],\n \"google-search-console\": [\"https://www.googleapis.com/auth/webmasters\"],\n \"google-classroom\": [\"https://www.googleapis.com/auth/classroom.courses\"],\n \"google-admin-directory\": [\"https://www.googleapis.com/auth/admin.directory.user\"],\n \"google-admin-reports\": [\"https://www.googleapis.com/auth/admin.reports.audit.readonly\"],\n \"google-apps-script\": [\"https://www.googleapis.com/auth/script.projects\"],\n \"google-bigquery\": [\"https://www.googleapis.com/auth/bigquery\"],\n \"google-cloud-resource-manager\": [\"https://www.googleapis.com/auth/cloud-platform\"],\n};\n\nexport const googleOAuthConsentScopesForPreset = (presetId: string): readonly string[] =>\n googleOAuthConsentScopes[presetId] ?? [];\n\nexport const googleServiceSlug = (presetId: string): string => presetId.replaceAll(\"-\", \"_\");\n\nconst GOOGLE_OAUTH_AUTHORIZATION_URL = \"https://accounts.google.com/o/oauth2/v2/auth\";\nconst GOOGLE_OAUTH_TOKEN_URL = \"https://oauth2.googleapis.com/token\";\nconst GOOGLE_OAUTH_SECURITY_SCHEME = \"googleOAuth2\";\nconst GOOGLE_IDENTITY_SCOPES: readonly string[] = [\"openid\", \"email\", \"profile\"];\nconst GOOGLE_HEALTH_CHECKS: Readonly<Record<string, HealthCheckSpec>> = {\n \"google-calendar\": { operation: \"calendar.calendarList.list\" },\n \"google-gmail\": {\n operation: \"gmail.users.labels.list\",\n args: { userId: \"me\" },\n },\n \"google-drive\": {\n operation: \"drive.about.get\",\n args: { fields: \"user\" },\n },\n \"google-tasks\": { operation: \"tasks.tasklists.list\" },\n \"google-people\": {\n operation: \"people.people.get\",\n args: { resourceName: \"people/me\", personFields: \"emailAddresses\" },\n },\n \"google-photos-library\": { operation: \"photoslibrary.albums.list\" },\n \"google-chat\": { operation: \"chat.spaces.list\" },\n \"google-keep\": { operation: \"keep.notes.list\" },\n \"google-youtube-data\": {\n operation: \"youtube.channels.list\",\n args: { part: \"id\", mine: true },\n },\n \"google-search-console\": { operation: \"webmasters.sites.list\" },\n \"google-classroom\": { operation: \"classroom.courses.list\" },\n \"google-admin-directory\": {\n operation: \"directory.users.list\",\n args: { customer: \"my_customer\", maxResults: 1 },\n },\n \"google-apps-script\": { operation: \"script.processes.list\" },\n \"google-bigquery\": { operation: \"bigquery.projects.list\" },\n \"google-cloud-resource-manager\": { operation: \"cloudresourcemanager.projects.list\" },\n};\n\nconst googleCatalogAuthTemplate = (presetId: string) => [\n {\n slug: GOOGLE_OAUTH_SECURITY_SCHEME,\n kind: \"oauth2\" as const,\n authorizationUrl: GOOGLE_OAUTH_AUTHORIZATION_URL,\n tokenUrl: GOOGLE_OAUTH_TOKEN_URL,\n scopes: compactGoogleOAuthScopes([\n ...GOOGLE_IDENTITY_SCOPES,\n ...googleOAuthConsentScopesForPreset(presetId),\n ]),\n },\n];\n\nexport const googleCatalog: readonly IntegrationPreset[] = googleOpenApiPresets.map((preset) => ({\n id: preset.id,\n name: preset.name,\n summary: preset.summary,\n ...(preset.url ? { url: preset.url } : {}),\n ...(preset.icon ? { icon: preset.icon } : {}),\n ...(preset.featured ? { featured: preset.featured } : {}),\n family: \"google\",\n specFormat: \"google-discovery\",\n defaultSlug: googleServiceSlug(preset.id),\n authTemplate: googleCatalogAuthTemplate(preset.id),\n ...(GOOGLE_HEALTH_CHECKS[preset.id] ? { healthCheck: GOOGLE_HEALTH_CHECKS[preset.id] } : {}),\n}));\n\n// ---------------------------------------------------------------------------\n// Resolve a stored/normalized Discovery URL back to its preset, so a bundled\n// `google` integration can surface each selected API's `oauthAudience` (e.g. a\n// caution on a connection's auth method when admin-only or unsupported-consent\n// APIs are part of the bundle).\n// ---------------------------------------------------------------------------\n\nconst normalizeGooglePresetUrl = (url: string): string => {\n const discoveryUrl = normalizeGoogleDiscoveryUrl(url);\n if (discoveryUrl) return discoveryUrl;\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 googlePresetsByNormalizedUrl: ReadonlyMap<string, GoogleOpenApiPreset> = new Map(\n googleOpenApiPresets.flatMap((preset) =>\n preset.url ? [[normalizeGooglePresetUrl(preset.url), preset] as const] : [],\n ),\n);\n\nexport const googlePresetForDiscoveryUrl = (url: string): GoogleOpenApiPreset | undefined =>\n googlePresetsByNormalizedUrl.get(normalizeGooglePresetUrl(url));\n\n/** The distinct caution-tier audiences (`workspace-admin`, `unsupported-user`)\n * among the supplied Discovery URLs - the ones whose consent the user should be\n * warned about. Returns `[]` when every URL is a standard/advanced API. */\nexport const googleAudienceWarningsForUrls = (\n urls: readonly string[],\n): readonly GoogleOpenApiOAuthAudience[] => {\n const seen = new Set<GoogleOpenApiOAuthAudience>();\n for (const url of urls) {\n const audience = googlePresetForDiscoveryUrl(url)?.oauthAudience;\n if (audience === \"workspace-admin\" || audience === \"unsupported-user\") seen.add(audience);\n }\n return [...seen];\n};\n","import { Effect, Schema } from \"effect\";\n\nimport { OpenApiParseError } from \"../../sdk/errors\";\nimport { type DerivedIdentity, type SpecFormatAdapter } from \"../../sdk/spec-format\";\n\nimport {\n convertGoogleDiscoveryBundleToOpenApi,\n fetchGoogleDiscoveryDocument,\n normalizeGoogleDiscoveryUrl,\n} from \"./discovery\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst parseJson = (text: string) =>\n Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(\n Effect.mapError(\n () =>\n new OpenApiParseError({\n message: \"Failed to parse Google Discovery document\",\n }),\n ),\n );\n\nconst googleDiscoverySlug = (service: string): string =>\n `google_${service\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\")}`;\n\nexport const deriveGoogleDiscoveryIdentity = (doc: unknown): DerivedIdentity | null => {\n if (!isRecord(doc)) return null;\n const rawName = typeof doc.name === \"string\" ? doc.name.trim() : \"\";\n if (!rawName) return null;\n const title = typeof doc.title === \"string\" && doc.title.trim() ? doc.title.trim() : rawName;\n const description =\n typeof doc.description === \"string\" && doc.description.trim()\n ? doc.description.trim()\n : undefined;\n return {\n slug: googleDiscoverySlug(rawName),\n name: title,\n ...(description ? { description } : {}),\n };\n};\n\nexport const googleDiscoveryAdapter: SpecFormatAdapter = {\n id: \"google-discovery\",\n fetch: (input) =>\n Effect.gen(function* () {\n const documents = yield* Effect.forEach(\n input.urls,\n (url) =>\n fetchGoogleDiscoveryDocument(url, input.credentials).pipe(\n Effect.provide(input.httpClientLayer),\n Effect.map((documentText) => ({\n discoveryUrl: normalizeGoogleDiscoveryUrl(url) ?? url,\n documentText,\n })),\n ),\n { concurrency: 4 },\n );\n const conversion = yield* convertGoogleDiscoveryBundleToOpenApi({ documents });\n const document =\n documents.length === 1\n ? yield* parseJson(documents[0]!.documentText)\n : yield* Effect.forEach(documents, (item) =>\n parseJson(item.documentText).pipe(\n Effect.map((parsed) => ({\n discoveryUrl: item.discoveryUrl,\n document: parsed,\n })),\n ),\n );\n return {\n specText: conversion.specText,\n specUrl: documents[0]?.discoveryUrl,\n baseUrl: conversion.baseUrl,\n authenticationTemplate: conversion.authenticationTemplate,\n document,\n };\n }),\n deriveIdentity: deriveGoogleDiscoveryIdentity,\n};\n","import { Effect } from \"effect\";\nimport { DataMigrationError, type SqliteDataMigrationClient } from \"@rafads/sdk/core\";\n\nconst MIGRATION_NAME = \"2026-06-20-google-openapi-ownership\";\nconst googleOpenApiCandidate = (alias?: string): string => {\n const column = (name: string) => (alias ? `${alias}.${name}` : name);\n return `${column(\"plugin_id\")} = 'openapi' AND ${column(\"config\")} IS NOT NULL AND json_valid(${column(\"config\")}) AND json_type(${column(\"config\")}, '$.googleDiscoveryUrls') = 'array'`;\n};\n\nconst execute = (\n client: SqliteDataMigrationClient,\n stmt: string | { readonly sql: string; readonly args: readonly unknown[] },\n) =>\n Effect.tryPromise({\n try: () => client.execute(stmt),\n catch: (cause) => new DataMigrationError({ migration: MIGRATION_NAME, cause }),\n });\n\nexport const runSqliteGoogleOpenApiOwnershipMigration = (\n client: SqliteDataMigrationClient,\n): Effect.Effect<number, DataMigrationError> =>\n Effect.gen(function* () {\n const exists = yield* execute(\n client,\n \"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'integration'\",\n );\n if (exists.rows.length === 0) return 0;\n\n const count = yield* execute(\n client,\n `SELECT COUNT(*) AS count FROM integration WHERE ${googleOpenApiCandidate()}`,\n );\n const moved = Number(count.rows[0]?.count ?? 0);\n if (moved === 0) return 0;\n\n const applyAll = Effect.gen(function* () {\n yield* execute(\n client,\n `INSERT OR IGNORE INTO blob (namespace, key, value, row_id, id)\n SELECT\n 'o:' || g.tenant || '/google',\n b.key,\n b.value,\n lower(hex(randomblob(16))),\n json_array('o:' || g.tenant || '/google', b.key)\n FROM integration g\n JOIN blob b\n ON b.namespace = 'o:' || g.tenant || '/openapi'\n AND b.key = 'spec/' || json_extract(g.config, '$.specHash')\n WHERE ${googleOpenApiCandidate(\"g\")}\n AND json_extract(g.config, '$.specHash') IS NOT NULL\n AND json_extract(g.config, '$.specHash') <> ''`,\n );\n\n yield* execute(\n client,\n `INSERT OR IGNORE INTO plugin_storage\n (tenant, owner, subject, plugin_id, collection, key, data, created_at, updated_at, row_id)\n SELECT\n ps.tenant,\n ps.owner,\n ps.subject,\n 'google',\n ps.collection,\n ps.key,\n ps.data,\n ps.created_at,\n ps.updated_at,\n lower(hex(randomblob(16)))\n FROM plugin_storage ps\n JOIN integration g\n ON g.tenant = ps.tenant\n WHERE ps.plugin_id = 'openapi'\n AND ${googleOpenApiCandidate(\"g\")}\n AND ps.collection = 'operation'\n AND (\n json_extract(ps.data, '$.integration') = g.slug\n OR ps.key LIKE g.slug || '.%'\n )`,\n );\n\n yield* execute(\n client,\n `DELETE FROM plugin_storage\n WHERE plugin_id = 'openapi'\n AND collection = 'operation'\n AND EXISTS (\n SELECT 1\n FROM integration g\n WHERE g.tenant = plugin_storage.tenant\n AND ${googleOpenApiCandidate(\"g\")}\n AND (\n json_extract(plugin_storage.data, '$.integration') = g.slug\n OR plugin_storage.key LIKE g.slug || '.%'\n )\n )`,\n );\n\n yield* execute(\n client,\n `UPDATE tool\n SET plugin_id = 'google'\n WHERE plugin_id = 'openapi'\n AND EXISTS (\n SELECT 1\n FROM integration g\n WHERE g.tenant = tool.tenant\n AND ${googleOpenApiCandidate(\"g\")}\n AND g.slug = tool.integration\n )`,\n );\n\n yield* execute(\n client,\n `UPDATE definition\n SET plugin_id = 'google'\n WHERE plugin_id = 'openapi'\n AND EXISTS (\n SELECT 1\n FROM integration g\n WHERE g.tenant = definition.tenant\n AND ${googleOpenApiCandidate(\"g\")}\n AND g.slug = definition.integration\n )`,\n );\n\n yield* execute(\n client,\n `UPDATE integration\n SET plugin_id = 'google'\n WHERE ${googleOpenApiCandidate()}`,\n );\n\n yield* execute(client, \"COMMIT\");\n return moved;\n });\n\n yield* execute(client, \"BEGIN\");\n return yield* applyAll.pipe(\n Effect.tapError(() => execute(client, \"ROLLBACK\").pipe(Effect.ignore)),\n );\n });\n\nexport const googleOpenApiOwnershipDataMigration = {\n name: MIGRATION_NAME,\n run: (client: SqliteDataMigrationClient) =>\n runSqliteGoogleOpenApiOwnershipMigration(client).pipe(Effect.asVoid),\n};\n"],"mappings":";;;;;AAIA,SAAS,QAAQ,QAAQ,WAAW,QAAQ,oBAAoB;AAChE,SAAS,YAAY,yBAAyB;;;ACL9C,IAAM,iCAAiC,oBAAI,IAAI;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,wCAAwC,CAAC,2CAA2C;AAE1F,IAAM,yBAGA;AAAA,EACJ;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,wCAAwC;AAAA,EACrD;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,2CAA2C;AAAA,EACxD;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,wCAAwC;AAAA,EACrD;AACF;AAEA,IAAM,+BAA+B,CAAC,UACpC,UAAU,mDACN,UACA,UAAU,qDACR,YACA;AAER,IAAM,sBAAsB,CAAC,WAAuC;AAClE,QAAM,UAAoB,CAAC;AAC3B,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,SAAS,QAAQ;AAC1B,UAAM,UAAU,MAAM,KAAK;AAC3B,QAAI,CAAC,WAAW,KAAK,IAAI,OAAO,EAAG;AACnC,SAAK,IAAI,OAAO;AAChB,YAAQ,KAAK,OAAO;AAAA,EACtB;AACA,SAAO;AACT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|
+
import { Effect } from "effect";
|
|
2
|
+
import type { Layer } from "effect";
|
|
3
|
+
import { HttpClient } from "effect/unstable/http";
|
|
4
|
+
import { type OpenApiIntegrationConfig } from "../../sdk/config";
|
|
5
|
+
import { OpenApiParseError } from "../../sdk/errors";
|
|
6
|
+
import { type KeepPathItem } from "../../sdk/split";
|
|
7
|
+
import type { Authentication } from "../../sdk/types";
|
|
8
|
+
export interface MicrosoftGraphSelectionInput {
|
|
9
|
+
readonly presetIds?: readonly string[];
|
|
10
|
+
readonly customScopes?: readonly string[];
|
|
11
|
+
readonly baseUrl?: string;
|
|
12
|
+
readonly specUrl?: string;
|
|
13
|
+
readonly authorizationUrl?: string;
|
|
14
|
+
readonly tokenUrl?: string;
|
|
15
|
+
readonly clientCredentialsTokenUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MicrosoftGraphSpecBuild {
|
|
18
|
+
readonly specText: string;
|
|
19
|
+
readonly specUrl: string;
|
|
20
|
+
readonly baseUrl?: string;
|
|
21
|
+
readonly authorizationUrl: string;
|
|
22
|
+
readonly tokenUrl: string;
|
|
23
|
+
readonly clientCredentialsTokenUrl: string;
|
|
24
|
+
readonly presetIds: readonly string[];
|
|
25
|
+
readonly customScopes: readonly string[];
|
|
26
|
+
readonly scopes: readonly string[];
|
|
27
|
+
readonly exactPaths: readonly string[];
|
|
28
|
+
readonly pathPrefixes: readonly string[];
|
|
29
|
+
readonly tagPrefixes: readonly string[];
|
|
30
|
+
readonly coversFullGraph: boolean;
|
|
31
|
+
readonly authenticationTemplate: readonly Authentication[];
|
|
32
|
+
}
|
|
33
|
+
export interface MicrosoftGraphUrlPolicy {
|
|
34
|
+
/**
|
|
35
|
+
* When true, spec/base/OAuth endpoint URLs may point anywhere a trusted
|
|
36
|
+
* https URL could, plus plain http on loopback (local Graph emulators).
|
|
37
|
+
* Every other host is still rejected. Off by default — production leaves
|
|
38
|
+
* this unset so only the pinned Microsoft Graph URLs are accepted.
|
|
39
|
+
*/
|
|
40
|
+
readonly allowUnsafeUrlOverrides?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export type MicrosoftGraphIntegrationConfig = OpenApiIntegrationConfig & {
|
|
43
|
+
readonly microsoftGraphPresetIds?: readonly string[];
|
|
44
|
+
readonly microsoftGraphCustomScopes?: readonly string[];
|
|
45
|
+
readonly microsoftGraphScopes?: readonly string[];
|
|
46
|
+
readonly microsoftGraphExactPaths?: readonly string[];
|
|
47
|
+
readonly microsoftGraphPathPrefixes?: readonly string[];
|
|
48
|
+
readonly microsoftGraphTagPrefixes?: readonly string[];
|
|
49
|
+
readonly microsoftGraphCoversFullGraph?: boolean;
|
|
50
|
+
readonly microsoftGraphAuthorizationUrl?: string;
|
|
51
|
+
readonly microsoftGraphTokenUrl?: string;
|
|
52
|
+
readonly microsoftGraphClientCredentialsTokenUrl?: string;
|
|
53
|
+
};
|
|
54
|
+
export declare const decodeMicrosoftGraphIntegrationConfig: (value: unknown) => MicrosoftGraphIntegrationConfig | null;
|
|
55
|
+
export declare const parseMicrosoftGraphDelegatedScopes: (permissionsReference: string) => readonly string[];
|
|
56
|
+
export declare const fetchMicrosoftGraphOpenApiSpec: (specUrl: string) => Effect.Effect<string, OpenApiParseError, HttpClient.HttpClient>;
|
|
57
|
+
export declare const fetchMicrosoftGraphPermissionsReference: () => Effect.Effect<string, OpenApiParseError, HttpClient.HttpClient>;
|
|
58
|
+
/**
|
|
59
|
+
* Build the per-path-item filter that the streaming compile applies to each
|
|
60
|
+
* path-item as it parses the 37MB source. Full-graph selections keep every
|
|
61
|
+
* path-item, but still pass through this transform so octet-stream success
|
|
62
|
+
* responses are normalized to binary before the OpenAPI extractor runs. The
|
|
63
|
+
* selection predicate is identical to the old two-pass filter: the selected
|
|
64
|
+
* scopes are derived from the PRESET scopes (`microsoftGraphScopesForPresetIds`),
|
|
65
|
+
* not the expanded OAuth scopes, so the kept operation set matches regardless
|
|
66
|
+
* of caller.
|
|
67
|
+
*/
|
|
68
|
+
export declare const microsoftGraphKeepPathItem: (selection: {
|
|
69
|
+
readonly coversFullGraph: boolean;
|
|
70
|
+
readonly presetIds: readonly string[];
|
|
71
|
+
readonly customScopes: readonly string[];
|
|
72
|
+
readonly exactPaths: readonly string[];
|
|
73
|
+
readonly pathPrefixes: readonly string[];
|
|
74
|
+
readonly tagPrefixes: readonly string[];
|
|
75
|
+
}) => KeepPathItem;
|
|
76
|
+
export declare const buildMicrosoftGraphOpenApiSpec: (input: MicrosoftGraphSelectionInput, httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, urlPolicy?: MicrosoftGraphUrlPolicy) => Effect.Effect<MicrosoftGraphSpecBuild, OpenApiParseError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { MICROSOFT_AUTHORIZATION_URL, MICROSOFT_AUTH_TEMPLATE_SLUG, MICROSOFT_CLIENT_CREDENTIALS_AUTH_TEMPLATE_SLUG, MICROSOFT_GRAPH_ALL_PRESET_IDS, MICROSOFT_GRAPH_BASE_SCOPES, MICROSOFT_GRAPH_BASE_URL, MICROSOFT_GRAPH_CLIENT_CREDENTIALS_SCOPES, MICROSOFT_GRAPH_DEFAULT_SCOPE, MICROSOFT_GRAPH_DELEGATED_DEFAULT_SCOPES, MICROSOFT_GRAPH_DEFAULT_PRESET_IDS, MICROSOFT_GRAPH_OPENAPI_URL, MICROSOFT_GRAPH_PERMISSIONS_REFERENCE_URL, MICROSOFT_GRAPH_PRESET_ID, MICROSOFT_TOKEN_URL, microsoftCatalog, microsoftGraphExactPathsForPresetIds, microsoftGraphPathPrefixesForPresetIds, microsoftGraphPreset, microsoftGraphPresetForId, microsoftGraphPresetIdsCoverFullGraph, microsoftGraphScopePresets, microsoftGraphScopesForPresetIds, microsoftGraphTagPrefixesForPresetIds, microsoftServiceSlug, type MicrosoftGraphPreset, type MicrosoftGraphScopeAudience, type MicrosoftGraphScopePreset, } from "./presets";
|
|
2
|
+
export { buildMicrosoftGraphOpenApiSpec, decodeMicrosoftGraphIntegrationConfig, fetchMicrosoftGraphOpenApiSpec, fetchMicrosoftGraphPermissionsReference, microsoftGraphKeepPathItem, parseMicrosoftGraphDelegatedScopes, type MicrosoftGraphIntegrationConfig, type MicrosoftGraphSelectionInput, type MicrosoftGraphSpecBuild, } from "./graph";
|
|
3
|
+
export { microsoftGraphAdapter } from "./spec-format-adapter";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IntegrationPreset } from "@rafads/sdk/core";
|
|
2
|
+
export interface MicrosoftGraphPreset {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly summary: string;
|
|
6
|
+
readonly icon?: string;
|
|
7
|
+
readonly featured?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type MicrosoftGraphScopeAudience = "productivity" | "files-content" | "collaboration" | "directory-identity" | "admin-security" | "platform-business";
|
|
10
|
+
export interface MicrosoftGraphScopePreset {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly summary: string;
|
|
14
|
+
readonly icon?: string;
|
|
15
|
+
readonly scopes: readonly string[];
|
|
16
|
+
readonly exactPaths?: readonly string[];
|
|
17
|
+
readonly pathPrefixes?: readonly string[];
|
|
18
|
+
readonly tagPrefixes?: readonly string[];
|
|
19
|
+
readonly featured?: boolean;
|
|
20
|
+
readonly audience: MicrosoftGraphScopeAudience;
|
|
21
|
+
}
|
|
22
|
+
export declare const MICROSOFT_GRAPH_OPENAPI_URL = "https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/openapi/v1.0/openapi.yaml";
|
|
23
|
+
export declare const MICROSOFT_GRAPH_PERMISSIONS_REFERENCE_URL = "https://raw.githubusercontent.com/microsoftgraph/microsoft-graph-docs-contrib/main/concepts/permissions-reference.md";
|
|
24
|
+
export declare const MICROSOFT_GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
|
|
25
|
+
export declare const MICROSOFT_AUTHORIZATION_URL = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize";
|
|
26
|
+
export declare const MICROSOFT_TOKEN_URL = "https://login.microsoftonline.com/common/oauth2/v2.0/token";
|
|
27
|
+
export declare const MICROSOFT_AUTH_TEMPLATE_SLUG = "azureAdDelegated";
|
|
28
|
+
export declare const MICROSOFT_CLIENT_CREDENTIALS_AUTH_TEMPLATE_SLUG = "azureAdClientCredentials";
|
|
29
|
+
export declare const MICROSOFT_GRAPH_BASE_SCOPES: readonly string[];
|
|
30
|
+
export declare const MICROSOFT_GRAPH_IDENTITY_SCOPE = "User.Read";
|
|
31
|
+
export declare const MICROSOFT_GRAPH_DEFAULT_SCOPE = "https://graph.microsoft.com/.default";
|
|
32
|
+
export declare const MICROSOFT_GRAPH_DELEGATED_DEFAULT_SCOPES: readonly string[];
|
|
33
|
+
export declare const MICROSOFT_GRAPH_CLIENT_CREDENTIALS_SCOPES: readonly string[];
|
|
34
|
+
export declare const MICROSOFT_GRAPH_PRESET_ID = "microsoft";
|
|
35
|
+
export declare const microsoftGraphPreset: MicrosoftGraphPreset;
|
|
36
|
+
export declare const microsoftGraphScopePresets: readonly MicrosoftGraphScopePreset[];
|
|
37
|
+
export declare const MICROSOFT_GRAPH_DEFAULT_PRESET_IDS: readonly string[];
|
|
38
|
+
export declare const MICROSOFT_GRAPH_ALL_PRESET_IDS: readonly string[];
|
|
39
|
+
export declare const microsoftGraphPresetForId: (presetId: string) => MicrosoftGraphScopePreset | undefined;
|
|
40
|
+
export declare const microsoftGraphPresetIdsCoverFullGraph: (presetIds: Iterable<string>) => boolean;
|
|
41
|
+
export declare const microsoftGraphScopesForPresetIds: (presetIds: Iterable<string>, customScopes?: Iterable<string>) => readonly string[];
|
|
42
|
+
export declare const microsoftGraphExactPathsForPresetIds: (presetIds: Iterable<string>) => readonly string[];
|
|
43
|
+
export declare const microsoftGraphPathPrefixesForPresetIds: (presetIds: Iterable<string>) => readonly string[];
|
|
44
|
+
export declare const microsoftGraphTagPrefixesForPresetIds: (presetIds: Iterable<string>) => readonly string[];
|
|
45
|
+
export declare const microsoftServiceSlug: (presetId: string) => string;
|
|
46
|
+
export declare const microsoftCatalog: readonly IntegrationPreset[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|