Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update connectorUpdate script #520

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions packages/api/scripts/connectorUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function updateInitSQLFile(initSQLFile, newServiceDirs, vertical) {
let newLines = newServiceDirs
.map((serviceName) => {
const columnName = `${vertical.toLowerCase()}_${serviceName.toLowerCase()}`;
return ` ${columnName} boolean NOT NULL,\n`;
return ` ${columnName} boolean,\n`;
})
.join('');

Expand Down Expand Up @@ -376,10 +376,13 @@ function updateSeedSQLFile(seedSQLFile, newServiceDirs, vertical) {
fileContent = fileContent.replace(lastMatch[1], newColumnsSection);

// Update each VALUES section
fileContent = fileContent.replace(/VALUES(.*?);/gs, (match) => {
fileContent = fileContent.replace(/INSERT INTO connector_sets \(([^)]+)\) VALUES(.*?);/gs, (match) => {
return match
.replace(/\),\s*\(/g, '),\n (') // Fix line formatting
.replace(/\([^\)]+\)/g, (values) => {
.replace(/\([^\)]+\)/g, (values, index) => {
if (values.startsWith('(id_connector_set')) {
return values
}
let newValues = newColumns.map(() => 'TRUE').join(', ');
return values.slice(0, -1) + ', ' + newValues + ')';
});
Expand Down Expand Up @@ -439,13 +442,13 @@ function updateObjectTypes(baseDir, objectType, vertical) {
updateModuleFile(moduleFile, newServiceDirs, servicesDir);

// Path to the mappings file
const mappingsFile = path.join(
__dirname,
`../src/${vertical}/${objectType.toLowerCase()}/types/mappingsTypes.ts`,
);
// const mappingsFile = path.join(
// __dirname,
// `../src/${vertical}/${objectType.toLowerCase()}/types/mappingsTypes.ts`,
// );

// Call updateMappingsFile to update the mappings file with new services
updateMappingsFile(mappingsFile, newServiceDirs, objectType, vertical);
// // Call updateMappingsFile to update the mappings file with new services
// updateMappingsFile(mappingsFile, newServiceDirs, objectType, vertical);

const possibleProviderForImportStatements = getProvidersForImportStatements(
targetFile,
Expand Down
Loading