diff --git a/.eslintignore b/.eslintignore index a8603104af..ed12b5b637 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ node_modules/** +cypress-tests/** \ No newline at end of file diff --git a/frontend/src/Editor/Viewer/ViewerNavigation.jsx b/frontend/src/Editor/Viewer/ViewerNavigation.jsx index da17ac2f06..6c07fded0c 100644 --- a/frontend/src/Editor/Viewer/ViewerNavigation.jsx +++ b/frontend/src/Editor/Viewer/ViewerNavigation.jsx @@ -31,7 +31,9 @@ export const ViewerNavigation = ({ isMobileDevice, pages, currentPageId, switchP >
- {_.truncate(page.name, { length: 18 })} + + {_.truncate(page.name, { length: 18 })} +
diff --git a/frontend/src/GlobalDatasources/GlobalDataSourcesPage/index.jsx b/frontend/src/GlobalDatasources/GlobalDataSourcesPage/index.jsx index 8381244010..85fdb4c0c5 100644 --- a/frontend/src/GlobalDatasources/GlobalDataSourcesPage/index.jsx +++ b/frontend/src/GlobalDatasources/GlobalDataSourcesPage/index.jsx @@ -54,7 +54,7 @@ export const GlobalDataSourcesPage = ({ darkMode }) => { } }; - const environmentChanged = (env, dataSourceId) => { + const environmentChanged = (env) => { setCurrentEnvironment(env); }; diff --git a/frontend/src/ManageGroupPermissions/ManageGroupPermissions.jsx b/frontend/src/ManageGroupPermissions/ManageGroupPermissions.jsx index beb832064b..a3cf9c2049 100644 --- a/frontend/src/ManageGroupPermissions/ManageGroupPermissions.jsx +++ b/frontend/src/ManageGroupPermissions/ManageGroupPermissions.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { authenticationService, groupPermissionService } from '@/_services'; +import { groupPermissionService } from '@/_services'; import { ConfirmDialog } from '@/_components'; import { toast } from 'react-hot-toast'; import { Link } from 'react-router-dom'; diff --git a/frontend/src/MarketplacePage/index.jsx b/frontend/src/MarketplacePage/index.jsx index 3505f202aa..510f177dd4 100644 --- a/frontend/src/MarketplacePage/index.jsx +++ b/frontend/src/MarketplacePage/index.jsx @@ -6,6 +6,7 @@ import { MarketplacePlugins } from './MarketplacePlugins'; import { marketplaceService, pluginsService, authenticationService } from '@/_services'; import { toast } from 'react-hot-toast'; import { useNavigate } from 'react-router-dom'; +import config from 'config'; const MarketplacePage = ({ darkMode, switchDarkMode }) => { const [active, setActive] = React.useState('installed'); @@ -14,7 +15,7 @@ const MarketplacePage = ({ darkMode, switchDarkMode }) => { const [fetchingInstalledPlugins, setFetching] = React.useState(false); const { admin } = authenticationService.currentSessionValue; - const ENABLE_MARKETPLACE_DEV_MODE = window.public_config?.ENABLE_MARKETPLACE_DEV_MODE == 'true'; + const ENABLE_MARKETPLACE_DEV_MODE = config.ENABLE_MARKETPLACE_DEV_MODE == 'true'; const navigate = useNavigate(); diff --git a/frontend/src/SettingsPage/SettingsPage.jsx b/frontend/src/SettingsPage/SettingsPage.jsx index 5beef8a181..d880d88e36 100644 --- a/frontend/src/SettingsPage/SettingsPage.jsx +++ b/frontend/src/SettingsPage/SettingsPage.jsx @@ -6,8 +6,8 @@ import Layout from '@/_ui/Layout'; function SettingsPage(props) { const currentSession = authenticationService.currentSessionValue; + const email = currentSession?.current_user.email; const [firstName, setFirstName] = React.useState(currentSession?.current_user.first_name); - const [email, setEmail] = React.useState(currentSession?.current_user.email); const [lastName, setLastName] = React.useState(currentSession?.current_user.last_name); const [currentpassword, setCurrentPassword] = React.useState(''); const [newPassword, setNewPassword] = React.useState(''); diff --git a/frontend/src/_components/OrganizationManager/EditOrganization.jsx b/frontend/src/_components/OrganizationManager/EditOrganization.jsx index f916bc27e0..f50c36e529 100644 --- a/frontend/src/_components/OrganizationManager/EditOrganization.jsx +++ b/frontend/src/_components/OrganizationManager/EditOrganization.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { authenticationService, organizationService } from '@/_services'; +import { organizationService } from '@/_services'; import AlertDialog from '@/_ui/AlertDialog'; import { toast } from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; diff --git a/marketplace/.eslintrc b/marketplace/.eslintrc new file mode 100644 index 0000000000..fd27db3742 --- /dev/null +++ b/marketplace/.eslintrc @@ -0,0 +1,46 @@ +{ + "env": { + "node": true, + "jest": true + }, + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], + "ignorePatterns": [".eslintrc"], + "parser": "@typescript-eslint/parser", + "overrides": [ + { + "files": ["*.ts"], + "parserOptions": { + "project": ["./tsconfig.json"], + "tsconfigRootDir": "." + } + } + ], + "plugins": ["@typescript-eslint", "jest", "prettier"], + "rules": { + "prettier/prettier": [ + "error", + { + "semi": true, + "trailingComma": "es5", + "printWidth": 120, + "singleQuote": true + } + ], + "@typescript-eslint/interface-name-prefix": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "none" }], + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-empty-function": 0, + "@typescript-eslint/ban-types": [ + "error", + { + "types": { + "object": false + }, + "extendDefaults": true + } + ] + } +} diff --git a/marketplace/.eslintrc.js b/marketplace/.eslintrc.js deleted file mode 100644 index 947e9e34dc..0000000000 --- a/marketplace/.eslintrc.js +++ /dev/null @@ -1,56 +0,0 @@ -module.exports = { - env: { - node: true, - jest: true, - }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - ignorePatterns: ['.eslintrc.js'], - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - project: ['./tsconfig.json'], - }, - overrides: [ - { - files: ['*.ts'], - parserOptions: { - project: ['./tsconfig.json'], - tsconfigRootDir: __dirname, - }, - }, - ], - plugins: ['@typescript-eslint', 'jest', 'prettier'], - rules: { - 'prettier/prettier': [ - 'error', - { - semi: true, - trailingComma: 'es5', - printWidth: 120, - singleQuote: true, - }, - ], - '@typescript-eslint/no-floating-promises': ['error'], - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-unused-vars': ['error', { vars: 'all', args: 'none' }], - '@typescript-eslint/no-var-requires': 'off', - '@typescript-eslint/no-empty-function': 0, - '@typescript-eslint/ban-types': [ - 'error', - { - types: { - object: false, - }, - extendDefaults: true, - }, - ], - }, -}; diff --git a/marketplace/.gitignore b/marketplace/.gitignore index 754237f0a1..0f9d9cc1e8 100644 --- a/marketplace/.gitignore +++ b/marketplace/.gitignore @@ -14,6 +14,4 @@ dist *.tsbuildinfo *.tabl.json *.swp -*.snk -client.js -server.ts \ No newline at end of file +*.snk \ No newline at end of file diff --git a/marketplace/plugins/github/lib/index.ts b/marketplace/plugins/github/lib/index.ts index efe163588a..1257b85fe9 100644 --- a/marketplace/plugins/github/lib/index.ts +++ b/marketplace/plugins/github/lib/index.ts @@ -1,14 +1,12 @@ import { QueryError, QueryResult, QueryService, ConnectionTestResult } from '@tooljet-marketplace/common'; import { SourceOptions, QueryOptions, Operation } from './types'; -import { Octokit } from 'octokit' -import { getUserInfo, getRepo, getRepoIssues, getRepoPullRequests} from './query_operations' +import { Octokit } from 'octokit'; +import { getUserInfo, getRepo, getRepoIssues, getRepoPullRequests } from './query_operations'; export default class Github implements QueryService { - - async run(sourceOptions: SourceOptions, queryOptions: QueryOptions, dataSourceId: string): Promise { const operation: Operation = queryOptions.operation; - const octokit:Octokit = await this.getConnection(sourceOptions); + const octokit: Octokit = await this.getConnection(sourceOptions); let result = {}; try { @@ -16,11 +14,11 @@ export default class Github implements QueryService { case Operation.GetUserInfo: result = await getUserInfo(octokit, queryOptions); break; - + case Operation.GetRepo: result = await getRepo(octokit, queryOptions); break; - + case Operation.GetRepoIssues: result = await getRepoIssues(octokit, queryOptions); break; @@ -29,14 +27,13 @@ export default class Github implements QueryService { result = await getRepoPullRequests(octokit, queryOptions); break; - default: + default: throw new QueryError('Query could not be completed', 'Invalid operation', {}); } } catch (error) { throw new QueryError('Query could not be completed', error.message, {}); } - - + return { status: 'ok', data: result, @@ -47,18 +44,16 @@ export default class Github implements QueryService { const octokit = await this.getConnection(sourceOptions); try { - const { status } = await octokit.rest.users.getAuthenticated(); - if(status) { + const { status } = await octokit.rest.users.getAuthenticated(); + if (status) { return { status: 'ok', - } + }; } - - } catch (error) { return { status: 'failed', - message: 'Invalid credentials' + message: 'Invalid credentials', }; } } diff --git a/marketplace/plugins/github/lib/query_operations.ts b/marketplace/plugins/github/lib/query_operations.ts index a9265738f3..d0d7e06511 100644 --- a/marketplace/plugins/github/lib/query_operations.ts +++ b/marketplace/plugins/github/lib/query_operations.ts @@ -1,49 +1,35 @@ -import { Octokit } from 'octokit' -import { QueryOptions } from './types' - +import { Octokit } from 'octokit'; +import { QueryOptions } from './types'; export async function getUserInfo(octokit: Octokit, options: QueryOptions): Promise { - const { data } = await octokit.request( - 'GET /users/{username}', - { - username: options.username - } - ); + const { data } = await octokit.request('GET /users/{username}', { + username: options.username, + }); return data; } export async function getRepo(octokit: Octokit, options: QueryOptions): Promise { - const { data } = await octokit.request( - 'GET /repos/{owner}/{repo}', - { - owner: options.owner, - repo: options.repo - } - ); - return data; + const { data } = await octokit.request('GET /repos/{owner}/{repo}', { + owner: options.owner, + repo: options.repo, + }); + return data; } export async function getRepoIssues(octokit: Octokit, options: QueryOptions): Promise { - const { data } = await octokit.request( - 'GET /repos/{owner}/{repo}/issues', - { - owner: options.owner, - repo: options.repo, - state: options.state || 'all' - - } - ); - return data; + const { data } = await octokit.request('GET /repos/{owner}/{repo}/issues', { + owner: options.owner, + repo: options.repo, + state: options.state || 'all', + }); + return data; } export async function getRepoPullRequests(octokit: Octokit, options: QueryOptions): Promise { - const { data } = await octokit.request( - 'GET /repos/{owner}/{repo}/pulls', - { - owner: options.owner, - repo: options.repo, - state: options.state || 'all' - } - ); - return data; -} \ No newline at end of file + const { data } = await octokit.request('GET /repos/{owner}/{repo}/pulls', { + owner: options.owner, + repo: options.repo, + state: options.state || 'all', + }); + return data; +} diff --git a/marketplace/plugins/github/lib/types.ts b/marketplace/plugins/github/lib/types.ts index 439bcb1d0c..132688358e 100644 --- a/marketplace/plugins/github/lib/types.ts +++ b/marketplace/plugins/github/lib/types.ts @@ -16,4 +16,4 @@ export enum Operation { GetRepo = 'get_repo', GetRepoIssues = 'get_repo_issues', GetRepoPullRequests = 'get_repo_pull_requests', -} \ No newline at end of file +} diff --git a/marketplace/plugins/openai/lib/query_operations.ts b/marketplace/plugins/openai/lib/query_operations.ts index 3583ea925b..b78492d916 100644 --- a/marketplace/plugins/openai/lib/query_operations.ts +++ b/marketplace/plugins/openai/lib/query_operations.ts @@ -9,7 +9,7 @@ export async function getCompletion( try { const { data } = await openai.createCompletion({ - model: 'me', + model: 'text-davinci-003', prompt: prompt, temperature: typeof temperature === 'string' ? parseFloat(temperature) : temperature || 0, max_tokens: typeof max_tokens === 'string' ? parseInt(max_tokens) : max_tokens || 67, @@ -19,6 +19,8 @@ export async function getCompletion( return data.choices[0]['text']; } catch (error) { + console.log('error openapi ===============', error); + return { error: error?.message, statusCode: error?.response?.status, diff --git a/marketplace/plugins/plivo/lib/index.ts b/marketplace/plugins/plivo/lib/index.ts index d67c5dd5a4..37356e414f 100644 --- a/marketplace/plugins/plivo/lib/index.ts +++ b/marketplace/plugins/plivo/lib/index.ts @@ -14,8 +14,6 @@ export default class PlivoService implements QueryService { if (queryOptions.operation === 'send_sms') { result = await client.messages.create(queryOptions.from, queryOptions.to, queryOptions.body); - - } } catch (error) { throw new QueryError('Query could not be completed', error.message, {}); @@ -26,4 +24,4 @@ export default class PlivoService implements QueryService { data: result, }; } -} \ No newline at end of file +} diff --git a/marketplace/plugins/plivo/lib/types.ts b/marketplace/plugins/plivo/lib/types.ts index 7534d646a5..d3c8b459d1 100644 --- a/marketplace/plugins/plivo/lib/types.ts +++ b/marketplace/plugins/plivo/lib/types.ts @@ -1,4 +1,5 @@ +// eslint-disable-next-line @typescript-eslint/ban-types export type SourceOptions = {}; export type QueryOptions = { operation: string; -}; \ No newline at end of file +}; diff --git a/marketplace/scripts/upload-to-s3.js b/marketplace/scripts/upload-to-s3.js index b4435bc2d5..f6c281114a 100644 --- a/marketplace/scripts/upload-to-s3.js +++ b/marketplace/scripts/upload-to-s3.js @@ -11,7 +11,7 @@ config.update({ region: process.env.AWS_REGION || 'us-west-1', accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.SECRET_ACCESS_KEY, - maxRetries: 3 + maxRetries: 3, }); const directoryPath = _resolve(__dirname, 'plugins'); @@ -22,7 +22,7 @@ const getDirectoryFilesRecursive = (dir, ignores = []) => { }); }; -const generateFileKey = fileName => { +const generateFileKey = (fileName) => { const S3objectPath = fileName.split('/marketplace/plugins/')[1]; return `marketplace-assets/${S3objectPath}`; }; @@ -40,10 +40,10 @@ const uploadToS3 = async () => { 'README.md', 'package-lock.json', 'package.json', - 'tsconfig.json' + 'tsconfig.json', ]); - fileArray.map(file => { + fileArray.map((file) => { // Configuring parameters for S3 Object const S3params = { Bucket: process.env.AWS_BUCKET, @@ -51,9 +51,9 @@ const uploadToS3 = async () => { Key: generateFileKey(file), ContentType: lookup(file), ContentEncoding: 'utf-8', - CacheControl: 'immutable,max-age=31536000,public' + CacheControl: 'immutable,max-age=31536000,public', }; - s3.upload(S3params, function(err, data) { + s3.upload(S3params, function (err, data) { if (err) { // Set the exit code while letting // the process exit gracefully. @@ -69,4 +69,4 @@ const uploadToS3 = async () => { } }; -uploadToS3(); \ No newline at end of file +uploadToS3(); diff --git a/marketplace/tsconfig.json b/marketplace/tsconfig.json index d359f76096..70e1a01ed2 100644 --- a/marketplace/tsconfig.json +++ b/marketplace/tsconfig.json @@ -14,5 +14,5 @@ "composite": true, "resolveJsonModule": true }, - "exclude": ["plugins/*/lib/*.json", "/__tests__/*", "dist"] + "exclude": ["plugins/*/lib/*.json", "/__tests__/*", "/scripts/*","dist"] } diff --git a/plugins/.eslintignore b/plugins/.eslintignore index 3de31a00cb..6ac4452f3e 100644 --- a/plugins/.eslintignore +++ b/plugins/.eslintignore @@ -2,3 +2,5 @@ dist .eslintrc.js packages/*/__tests__/*.js packages/*/dist/* +client.js +server.ts diff --git a/plugins/.eslintrc.js b/plugins/.eslintrc.js index 947e9e34dc..d85fcf349e 100644 --- a/plugins/.eslintrc.js +++ b/plugins/.eslintrc.js @@ -10,11 +10,6 @@ module.exports = { ], ignorePatterns: ['.eslintrc.js'], parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - project: ['./tsconfig.json'], - }, overrides: [ { files: ['*.ts'], @@ -35,7 +30,6 @@ module.exports = { singleQuote: true, }, ], - '@typescript-eslint/no-floating-promises': ['error'], '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',