diff --git a/data-connector/src/index.ts b/data-connector/src/index.ts index b52521c7..4dc54edc 100644 --- a/data-connector/src/index.ts +++ b/data-connector/src/index.ts @@ -57,50 +57,50 @@ const parseConfig = (connector: any) => { if (connector.type === "postgres") { const postgresClient = new PostgresClient({ - ...connector, - maxResultLength: Number(config.maxResultLength), paranoidMode: config.paranoidMode === 1, privacyMode: config.privacyMode === 1, + maxResultLength: Number(config.maxResultLength), + ...connector, }); await postgresClient.initialize(); const service = postgresClient.createService(client); services.push(service); } else if (connector.type === "open-api") { const openAPIClient = new OpenAPIClient({ - ...connector, - maxResultLength: Number(config.maxResultLength), paranoidMode: config.paranoidMode === 1, privacyMode: config.privacyMode === 1, + maxResultLength: Number(config.maxResultLength), + ...connector, }); await openAPIClient.initialize(); const service = openAPIClient.createService(client); services.push(service); } else if (connector.type === "graphql") { const graphQLClient = new GraphQLClient({ - ...connector, - maxResultLength: Number(config.maxResultLength), paranoidMode: config.paranoidMode === 1, privacyMode: config.privacyMode === 1, + maxResultLength: Number(config.maxResultLength), + ...connector, }); await graphQLClient.initialize(); const service = graphQLClient.createService(client); services.push(service); } else if (connector.type === "mysql") { const mysqlClient = new MySQLClient({ - ...connector, - maxResultLength: Number(config.maxResultLength), paranoidMode: config.paranoidMode === 1, privacyMode: config.privacyMode === 1, + maxResultLength: Number(config.maxResultLength), + ...connector, }); await mysqlClient.initialize(); const service = mysqlClient.createService(client); services.push(service); } else if (connector.type === "sqlite") { const sqliteClient = new SQLiteClient({ - ...connector, - maxResultLength: Number(config.maxResultLength), paranoidMode: config.paranoidMode === 1, privacyMode: config.privacyMode === 1, + maxResultLength: Number(config.maxResultLength), + ...connector, }); await sqliteClient.initialize(); const service = sqliteClient.createService(client); diff --git a/data-connector/src/open-api/open-api.ts b/data-connector/src/open-api/open-api.ts index 721ccb75..406cd21e 100644 --- a/data-connector/src/open-api/open-api.ts +++ b/data-connector/src/open-api/open-api.ts @@ -19,6 +19,7 @@ export class OpenAPIClient implements DataConnector { name?: string; specUrl: string; endpoint?: string; + allowedOperations?: string[]; maxResultLength: number; defaultHeaders?: Record; privacyMode: boolean; @@ -34,6 +35,15 @@ export class OpenAPIClient implements DataConnector { `OpenAPI spec loaded successfully from ${this.params.specUrl}`, ); + if (this.params.allowedOperations) { + console.log( + "Filtering operations based on allowedOperations.", + { + allowedOpperations: this.params.allowedOperations, + }, + ) + } + // Convert paths and their operations into functions for (const [path, pathItem] of Object.entries(this.spec.paths)) { if (!pathItem) continue; @@ -44,6 +54,11 @@ export class OpenAPIClient implements DataConnector { const operation = pathItem[method]; if (!operation || !operation.operationId) continue; + if (this.params.allowedOperations && !this.params.allowedOperations.includes(operation.operationId)) { + continue; + } + + const inferableFunction = this.openApiOperationToInferableFunction( operation, path,