Unified · Split
| @@ -140,6 +140,7 @@ const googlePhotosBundleConsentScopes = ( · 139 unmodified lines | |||
| 140 | const fetchGoogleBundleConversion = ( | 140 | const fetchGoogleBundleConversion = ( |
| 141 | urls: readonly string[], | 141 | urls: readonly string[], |
| 142 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, | 142 | httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, |
| 143 | consentScopesOverride?: readonly string[], | ||
| 143 | ) => | 144 | ) => |
| 144 | Effect.forEach( | 145 | Effect.forEach( |
| 145 | urls, | 146 | urls, |
| @@ -151,10 +152,10 @@ const fetchGoogleBundleConversion = ( · 5 unmodified lines | |||
| 151 | { concurrency: 4 }, | 152 | { concurrency: 4 }, |
| 152 | ).pipe( | 153 | ).pipe( |
| 153 | Effect.flatMap((documents) => { | 154 | Effect.flatMap((documents) => { |
| 154 | const consentScopes = googlePhotosBundleConsentScopes(urls); | 155 | const consentScopes = consentScopesOverride ?? googlePhotosBundleConsentScopes(urls); |
| 155 | return convertGoogleDiscoveryBundleToOpenApi({ | 156 | return convertGoogleDiscoveryBundleToOpenApi({ |
| 156 | documents, | 157 | documents, |
| 157 | ...(consentScopes ? { consentScopes } : {}), | 158 | ...(consentScopes !== undefined ? { consentScopes } : {}), |
| 158 | }); | 159 | }); |
| 159 | }), | 160 | }), |
| 160 | ); | 161 | ); |
| @@ -215,12 +216,23 @@ const makeGooglePluginExtension = ( · 54 unmodified lines | |||
| 215 | ) => { | 216 | ) => { |
| 216 | const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer; | 217 | const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer; |
| 217 | 218 | ||
| 218 | const addBundle = (config: GoogleBundleConfig) => | 219 | const addGoogleOpenApiIntegration = (input: { |
| 220 | readonly urls: readonly string[]; | ||
| 221 | readonly slug: IntegrationSlug; | ||
| 222 | readonly name: string; | ||
| 223 | readonly description: string; | ||
| 224 | readonly baseUrl?: string; | ||
| 225 | readonly consentScopes?: readonly string[]; | ||
| 226 | }) => | ||
| 219 | Effect.gen(function* () { | 227 | Effect.gen(function* () { |
| 220 | const urls = yield* googleBundleUrlsWithIdentity(config.urls); | 228 | const urls = yield* googleBundleUrlsWithIdentity(input.urls); |
| 221 | const conversion = yield* fetchGoogleBundleConversion(urls, httpClientLayer); | 229 | const conversion = yield* fetchGoogleBundleConversion( |
| 230 | urls, | ||
| 231 | httpClientLayer, | ||
| 232 | input.consentScopes, | ||
| 233 | ); | ||
| 222 | const compiled = yield* compileOpenApiSpec(conversion.specText); | 234 | const compiled = yield* compileOpenApiSpec(conversion.specText); |
| 223 | const slug = IntegrationSlug.make(config.slug?.trim() || DEFAULT_GOOGLE_SLUG); | 235 | const slug = input.slug; |
| 224 | 236 | ||
| 225 | const existing = yield* ctx.core.integrations.get(slug); | 237 | const existing = yield* ctx.core.integrations.get(slug); |
| 226 | if (existing) { | 238 | if (existing) { |
| @@ -231,7 +243,7 @@ const makeGooglePluginExtension = ( · 4 unmodified lines | |||
| 231 | const integrationConfig: GoogleIntegrationConfig = { | 243 | const integrationConfig: GoogleIntegrationConfig = { |
| 232 | specHash, | 244 | specHash, |
| 233 | googleDiscoveryUrls: urls, | 245 | googleDiscoveryUrls: urls, |
| 234 | ...(config.baseUrl ? { baseUrl: config.baseUrl } : {}), | 246 | ...(input.baseUrl ? { baseUrl: input.baseUrl } : {}), |
| 235 | ...(conversion.authenticationTemplate | 247 | ...(conversion.authenticationTemplate |
| 236 | ? { authenticationTemplate: conversion.authenticationTemplate } | 248 | ? { authenticationTemplate: conversion.authenticationTemplate } |
| 237 | : {}), | 249 | : {}), |
| @@ -244,8 +256,8 @@ const makeGooglePluginExtension = ( · 6 unmodified lines | |||
| 244 | Effect.gen(function* () { | 256 | Effect.gen(function* () { |
| 245 | yield* ctx.core.integrations.register({ | 257 | yield* ctx.core.integrations.register({ |
| 246 | slug, | 258 | slug, |
| 247 | name: config.name?.trim() || "Google", | 259 | name: input.name, |
| 248 | description: config.description ?? "Google APIs", | 260 | description: input.description, |
| 249 | config: integrationConfig satisfies GoogleIntegrationConfig as IntegrationConfig, | 261 | config: integrationConfig satisfies GoogleIntegrationConfig as IntegrationConfig, |
| 250 | canRemove: true, | 262 | canRemove: true, |
| 251 | canRefresh: true, | 263 | canRefresh: true, |
| @@ -268,6 +280,15 @@ const makeGooglePluginExtension = ( · 16 unmodified lines | |||
| 268 | return { slug, toolCount: compiled.definitions.length }; | 280 | return { slug, toolCount: compiled.definitions.length }; |
| 269 | }); | 281 | }); |
| 270 | 282 | ||
| 283 | const addBundle = (config: GoogleBundleConfig) => | ||
| 284 | addGoogleOpenApiIntegration({ | ||
| 285 | urls: config.urls, | ||
| 286 | slug: IntegrationSlug.make(config.slug?.trim() || DEFAULT_GOOGLE_SLUG), | ||
| 287 | name: config.name?.trim() || "Google", | ||
| 288 | description: config.description ?? "Google APIs", | ||
| 289 | baseUrl: config.baseUrl, | ||
| 290 | }); | ||
| 291 | |||
| 271 | const updateBundle = (rawSlug: string, input?: GoogleUpdateInput) => | 292 | const updateBundle = (rawSlug: string, input?: GoogleUpdateInput) => |
| 272 | Effect.gen(function* () { | 293 | Effect.gen(function* () { |
| 273 | const slug = IntegrationSlug.make(rawSlug); | 294 | const slug = IntegrationSlug.make(rawSlug); |