Skip to content

Commit

Permalink
ES Lint + fix + prettier connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Jan 17, 2024
1 parent 0e9a152 commit 1ae9ce4
Show file tree
Hide file tree
Showing 87 changed files with 248 additions and 225 deletions.
1 change: 1 addition & 0 deletions connectors/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
},
],
"simple-import-sort/exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/return-await": ["error", "in-try-catch"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Result } from "@dust-tt/types";
import type { Result } from "@dust-tt/types";
import parseArgs from "minimist";
import readline from "readline";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Result } from "@dust-tt/types";
import type { Result } from "@dust-tt/types";
import parseArgs from "minimist";
import readline from "readline";

Expand Down
2 changes: 1 addition & 1 deletion connectors/src/admin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { GoogleDriveFiles } from "@connectors/lib/models/google_drive";
import { NotionDatabase, NotionPage } from "@connectors/lib/models/notion";
import { SlackConfiguration } from "@connectors/lib/models/slack";
import { nango_client } from "@connectors/lib/nango_client";
import { Result } from "@connectors/lib/result";
import type { Result } from "@connectors/lib/result";
import {
getTemporalClient,
terminateAllWorkflowsForConnectorId,
Expand Down
2 changes: 1 addition & 1 deletion connectors/src/admin/db.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sequelize } from "sequelize";
import type { Sequelize } from "sequelize";

import { Connector, sequelize_conn } from "@connectors/lib/models";
import {
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/connector_config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { isLeft } from "fp-ts/lib/Either";
import * as t from "io-ts";
import * as reporter from "io-ts-reporters";
Expand All @@ -9,7 +9,7 @@ import {
} from "@connectors/connectors";
import { Connector } from "@connectors/lib/models";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

const ConfigSetReqBodySchema = t.type({
configValue: t.string,
Expand Down
20 changes: 11 additions & 9 deletions connectors/src/api/create_connector.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import {
assertNever,
ConnectorCreateRequestBodySchema,
import type {
ConnectorProvider,
CreateConnectorOAuthRequestBodySchema,
CreateConnectorUrlRequestBodySchema,
isConnectorProvider,
Result,
} from "@dust-tt/types";
import { Request, Response } from "express";
import {
assertNever,
ConnectorCreateRequestBodySchema,
isConnectorProvider,
} from "@dust-tt/types";
import type { Request, Response } from "express";
import { isLeft } from "fp-ts/lib/Either";
import * as t from "io-ts";
import type * as t from "io-ts";
import * as reporter from "io-ts-reporters";

import { CREATE_CONNECTOR_BY_TYPE } from "@connectors/connectors";
import {
import type {
ConnectorCreatorOAuth,
ConnectorCreatorUrl,
} from "@connectors/connectors/interface";
import { errorFromAny } from "@connectors/lib/error";
import { Connector } from "@connectors/lib/models";
import logger from "@connectors/logger/logger";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorType } from "@connectors/types/connector";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorType } from "@connectors/types/connector";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type ConnectorCreateResBody = ConnectorType | ConnectorsAPIErrorResponse;

Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/delete_connector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import {
DELETE_CONNECTOR_BY_TYPE,
Expand All @@ -7,7 +7,7 @@ import {
import { Connector } from "@connectors/lib/models";
import { terminateAllWorkflowsForConnectorId } from "@connectors/lib/temporal";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type ConnectorDeleteReqBody = {
dataSourceName: string;
Expand Down
6 changes: 3 additions & 3 deletions connectors/src/api/get_connector.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { Connector } from "@connectors/lib/models";
import { GithubDiscussion, GithubIssue } from "@connectors/lib/models/github";
import { NotionPage } from "@connectors/lib/models/notion";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorType } from "@connectors/types/connector";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorType } from "@connectors/types/connector";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type GetConnectorRes = ConnectorType | ConnectorsAPIErrorResponse;

Expand Down
6 changes: 3 additions & 3 deletions connectors/src/api/get_connector_permissions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { RETRIEVE_CONNECTOR_PERMISSIONS_BY_TYPE } from "@connectors/connectors";
import { Connector } from "@connectors/lib/models";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import {
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type {
ConnectorPermission,
ConnectorResource,
} from "@connectors/types/resources";
Expand Down
2 changes: 1 addition & 1 deletion connectors/src/api/get_resources_parents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { zip } from "fp-ts/lib/Array";
import { isLeft } from "fp-ts/lib/Either";
import * as t from "io-ts";
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/get_resources_titles.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { isLeft } from "fp-ts/lib/Either";
import * as t from "io-ts";
import * as reporter from "io-ts-reporters";

import { BATCH_RETRIEVE_RESOURCE_TITLE_BY_TYPE } from "@connectors/connectors";
import { Connector } from "@connectors/lib/models";
import { Result } from "@connectors/lib/result";
import type { Result } from "@connectors/lib/result";
import { apiError, withLogging } from "@connectors/logger/withlogging";

const GetResourcesTitlesRequestBodySchema = t.type({
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/resume_connector.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { RESUME_CONNECTOR_BY_TYPE } from "@connectors/connectors";
import { errorFromAny } from "@connectors/lib/error";
import { Connector } from "@connectors/lib/models";
import logger from "@connectors/logger/logger";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type ConnectorResumeResBody =
| { connectorId: string }
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/set_connector_permissions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { isLeft } from "fp-ts/lib/Either";
import * as t from "io-ts";
import * as reporter from "io-ts-reporters";

import { SET_CONNECTOR_PERMISSIONS_BY_TYPE } from "@connectors/connectors";
import { Connector } from "@connectors/lib/models";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type SetConnectorPermissionsRes =
| { success: true }
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/slack_channels_linked_with_agent.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { isLeft } from "fp-ts/lib/Either";
import * as t from "io-ts";
import * as reporter from "io-ts-reporters";
import { Op } from "sequelize";

import { joinChannel } from "@connectors/connectors/slack/lib/channels";
import { getChannels } from "@connectors/connectors/slack/temporal/activities";
import { APIErrorWithStatusCode } from "@connectors/lib/error";
import type { APIErrorWithStatusCode } from "@connectors/lib/error";
import { sequelize_conn } from "@connectors/lib/models";
import { SlackChannel } from "@connectors/lib/models/slack";
import { apiError, withLogging } from "@connectors/logger/withlogging";
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/stop_connector.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { STOP_CONNECTOR_BY_TYPE } from "@connectors/connectors";
import { errorFromAny } from "@connectors/lib/error";
import { Connector } from "@connectors/lib/models";
import logger from "@connectors/logger/logger";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type ConnectorStopResBody =
| { connectorId: string }
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/sync_connector.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { SYNC_CONNECTOR_BY_TYPE } from "@connectors/connectors";
import { Connector } from "@connectors/lib/models";
import { withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type GetSyncStatusRes = { workflowId: string } | ConnectorsAPIErrorResponse;

Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/update_connector.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { UPDATE_CONNECTOR_BY_TYPE } from "@connectors/connectors";
import { Connector } from "@connectors/lib/models";
import { apiError, withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

type ConnectorUpdateReqBody = {
connectionId?: string | null;
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/webhooks/webhook_github.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertNever } from "@dust-tt/types";
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { isLeft } from "fp-ts/lib/Either";
import * as reporter from "io-ts-reporters";
import { Op } from "sequelize";
Expand Down Expand Up @@ -29,7 +29,7 @@ import {
} from "@connectors/lib/models/github";
import mainLogger from "@connectors/logger/logger";
import { withLogging } from "@connectors/logger/withlogging";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";

const HANDLED_WEBHOOKS = {
installation_repositories: new Set(["added", "removed"]),
Expand Down
4 changes: 2 additions & 2 deletions connectors/src/api/webhooks/webhook_google_drive.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RateLimitError } from "@dust-tt/types";
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { launchGoogleDriveIncrementalSyncWorkflow } from "@connectors/connectors/google_drive/temporal/client";
import { APIErrorWithStatusCode } from "@connectors/lib/error";
import type { APIErrorWithStatusCode } from "@connectors/lib/error";
import { GoogleDriveWebhook } from "@connectors/lib/models/google_drive";
import logger from "@connectors/logger/logger";
import { apiError, withLogging } from "@connectors/logger/withlogging";
Expand Down
7 changes: 4 additions & 3 deletions connectors/src/api/webhooks/webhook_slack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";

import { botAnswerMessageWithErrorHandling } from "@connectors/connectors/slack/bot";
import { getBotUserIdMemoized } from "@connectors/connectors/slack/temporal/activities";
Expand All @@ -7,11 +7,12 @@ import {
launchSlackSyncOneThreadWorkflow,
} from "@connectors/connectors/slack/temporal/client";
import { launchSlackGarbageCollectWorkflow } from "@connectors/connectors/slack/temporal/client";
import { APIErrorWithStatusCode } from "@connectors/lib/error";
import type { APIErrorWithStatusCode } from "@connectors/lib/error";
import { Connector } from "@connectors/lib/models";
import { SlackChannel, SlackConfiguration } from "@connectors/lib/models/slack";
import { Ok } from "@connectors/lib/result";
import mainLogger, { Logger } from "@connectors/logger/logger";
import type { Logger } from "@connectors/logger/logger";
import mainLogger from "@connectors/logger/logger";
import { apiError, withLogging } from "@connectors/logger/withlogging";

type SlackWebhookReqBody = {
Expand Down
15 changes: 8 additions & 7 deletions connectors/src/connectors/confluence/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import {
import type {
ConnectorPermission,
ConnectorResource,
ModelId,
} from "@dust-tt/types";
import { ConnectorsAPIErrorResponse } from "@dust-tt/types";
import type { ConnectorsAPIErrorResponse } from "@dust-tt/types";

import { confluenceConfig } from "@connectors/connectors/confluence/lib/config";
import {
getConfluenceCloudInformation,
listConfluenceSpaces,
} from "@connectors/connectors/confluence/lib/confluence_api";
import { ConfluenceSpaceType } from "@connectors/connectors/confluence/lib/confluence_client";
import { ConnectorPermissionRetriever } from "@connectors/connectors/interface";
import type { ConfluenceSpaceType } from "@connectors/connectors/confluence/lib/confluence_client";
import type { ConnectorPermissionRetriever } from "@connectors/connectors/interface";
import { Connector, sequelize_conn } from "@connectors/lib/models";
import {
ConfluenceConfiguration,
ConfluenceSpace,
} from "@connectors/lib/models/confluence";
import { getAccessTokenFromNango } from "@connectors/lib/nango_helpers";
import { Err, Ok, Result } from "@connectors/lib/result";
import type { Result } from "@connectors/lib/result";
import { Err, Ok } from "@connectors/lib/result";
import mainLogger from "@connectors/logger/logger";
import { DataSourceConfig } from "@connectors/types/data_source_config";
import { NangoConnectionId } from "@connectors/types/nango_connection_id";
import type { DataSourceConfig } from "@connectors/types/data_source_config";
import type { NangoConnectionId } from "@connectors/types/nango_connection_id";

const { getRequiredNangoConfluenceConnectorId } = confluenceConfig;

Expand Down
4 changes: 2 additions & 2 deletions connectors/src/connectors/confluence/lib/confluence_api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ModelId } from "@dust-tt/types";
import type { ModelId } from "@dust-tt/types";

import { confluenceConfig } from "@connectors/connectors/confluence/lib/config";
import { ConfluenceClient } from "@connectors/connectors/confluence/lib/confluence_client";
import { Connector } from "@connectors/lib/models";
import type { Connector } from "@connectors/lib/models";
import { ConfluenceConfiguration } from "@connectors/lib/models/confluence";
import { getConnectionFromNango } from "@connectors/lib/nango_helpers";

Expand Down
13 changes: 7 additions & 6 deletions connectors/src/connectors/github/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModelId } from "@dust-tt/types";
import type { ModelId } from "@dust-tt/types";

import {
getRepo,
Expand All @@ -15,16 +15,17 @@ import {
GithubDiscussion,
GithubIssue,
} from "@connectors/lib/models/github";
import { Err, Ok, Result } from "@connectors/lib/result";
import type { Result } from "@connectors/lib/result";
import { Err, Ok } from "@connectors/lib/result";
import mainLogger from "@connectors/logger/logger";
import { DataSourceConfig } from "@connectors/types/data_source_config";
import { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import {
import type { DataSourceConfig } from "@connectors/types/data_source_config";
import type { ConnectorsAPIErrorResponse } from "@connectors/types/errors";
import type {
ConnectorPermission,
ConnectorResource,
} from "@connectors/types/resources";

import {
import type {
ConnectorConfigGetter,
ConnectorPermissionRetriever,
} from "../interface";
Expand Down
6 changes: 4 additions & 2 deletions connectors/src/connectors/github/lib/github_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import * as reporter from "io-ts-reporters";
import { Octokit } from "octokit";
import { tmpdir } from "os";
import { basename, extname, join, resolve } from "path";
import { Readable } from "stream";
import type { Readable } from "stream";
import { pipeline } from "stream/promises";
import { extract } from "tar";

import {
import type {
DiscussionCommentNode,
DiscussionNode,
} from "@connectors/connectors/github/lib/github_graphql";
import {
ErrorPayloadSchema,
GetDiscussionCommentRepliesPayloadSchema,
GetDiscussionCommentsPayloadSchema,
Expand Down
Loading

0 comments on commit 1ae9ce4

Please sign in to comment.