Skip to content

Commit

Permalink
🐛 Fix project connectors inside code
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jun 6, 2024
1 parent 896faf6 commit 33a52d2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ConnectionsStrategiesService {
private prisma: PrismaService,
private crypto: EncryptionService,
private configService: ConfigService,
) { }
) {}

async isCustomCredentials(projectId: string, type: string) {
const res = await this.prisma.connection_strategies.findFirst({
Expand Down Expand Up @@ -230,8 +230,9 @@ export class ConnectionsStrategiesService {
data = {
...data,
SCOPE:
CONNECTORS_METADATA[vertical.toLowerCase()][provider.toLowerCase()]
.scopes,
CONNECTORS_METADATA[vertical.toLowerCase()][
provider.toLowerCase()
].scopes,
};
}
/*const isSubdomain = needsSubdomain(
Expand Down Expand Up @@ -337,7 +338,7 @@ export class ConnectionsStrategiesService {
values: string[],
) {
try {
console.log("In updateAPI xzx")
console.log('In updateAPI xzx');
const cs = await this.prisma.connection_strategies.findFirst({
where: {
id_connection_strategy: id_cs,
Expand Down Expand Up @@ -382,8 +383,8 @@ export class ConnectionsStrategiesService {
}
return cs;
} catch (error) {
console.log("Error xzx")
console.log(error)
console.log('Error xzx');
console.log(error);
throw new Error('Update Failed');
}
}
Expand Down
27 changes: 27 additions & 0 deletions packages/api/src/@core/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { LoggerService } from '../logger/logger.service';
import { CreateProjectDto } from './dto/create-project.dto';
import { v4 as uuidv4 } from 'uuid';
import { handleServiceError } from '@@core/utils/errors';
import {
ConnectorCategory,
CONNECTORS_METADATA,
providersArray,
slugFromCategory,
} from '@panora/shared';

@Injectable()
export class ProjectsService {
Expand Down Expand Up @@ -43,6 +49,27 @@ export class ProjectsService {
//id_organization: id_organization,
},
});

const ACTIVE_CONNECTORS = providersArray();
// update project-connectors table for the project
const updateData: any = {
id_project_connector: uuidv4(),
id_project: res.id_project,
};

ACTIVE_CONNECTORS.forEach((connector) => {
if (connector.vertical) {
// Construct the property name using the vertical name
const propertyName = `${slugFromCategory(
connector.vertical as ConnectorCategory,
)}_`;
// Add the property to updateData with a value of true
updateData[propertyName + connector.name] = true;
}
});
await this.prisma.project_connectors.create({
data: updateData,
});
return res;
} catch (error) {
handleServiceError(error, this.logger);
Expand Down

0 comments on commit 33a52d2

Please sign in to comment.