ToolJet/plugins/create-server-entry.js
Akshay 59cf3b1931
Fix: Googlesheets OAuth refresh token flow (#2118)
* implement google sheet oauh token refresh flow

* format lint

* make use of constructor name as instanceof fails

* remove unused import

* force consent to get refresh token on googlesheets ds
2022-02-05 07:09:40 +05:30

36 lines
966 B
JavaScript

const { readdirSync, writeFileSync } = require("fs");
const packages = readdirSync("./packages", { withFileTypes: true }).filter(
(dirent) => dirent.isDirectory() && dirent.name !== "common"
);
const mapImportNameToOldValue = (str) => {
if (str === "mongo") return "mongodb";
if (str === "twilioapi") return "twilio";
if (str === "typesenseapi") return "typesense";
if (str === "minioapi") return "minio";
return str;
};
const imports = packages.map(
(dirent) =>
`import ${mapImportNameToOldValue(dirent.name)} from './packages/${
dirent.name
}/lib'`
);
imports.push([
"import { QueryError, OAuthUnauthorizedClientError } from './packages/common/lib'",
]);
const outs = `export default {\n${packages
.map((dirent) => ` ${mapImportNameToOldValue(dirent.name)}`)
.join(",\n")},
}`;
const content = `
${imports.join("\n")} \n
${outs}\n
export { QueryError, OAuthUnauthorizedClientError }
`;
writeFileSync("server.ts", content);