refactor(connectors): move the source types into the connectors library (#15337)

This commit is contained in:
Raunak Bhagat authored and GitHub committed 2026-10-01 19:44:54 +00:00
1 parent 3fe68e62ef
commit 34509bf904
91 files changed
+274 -248

No files matched your search

@@ -4,7 +4,7 @@ import { SourceIcon } from "@/components/SourceIcon";
import { WebResultIcon } from "@/components/WebResultIcon";
import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/types";
import { SubQuestionDetail, CitationMap } from "../interfaces";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { ProjectFile } from "@/lib/projects/types";
import { BlinkingBar } from "./BlinkingBar";
import Text from "@/refresh-components/texts/Text";
@@ -7,7 +7,7 @@ import {
import { BlinkingBar } from "@/app/app/message/BlinkingBar";
import { OnyxDocument } from "@/lib/search/types";
import { openExternalLink } from "@/lib/search/utils";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { SearchChipList, SourceInfo } from "../search/SearchChipList";
import { getMetadataTags } from "../search/searchStateUtils";
import {
@@ -7,7 +7,7 @@ import {
} from "@/app/app/message/messageComponents/interfaces";
import { BlinkingBar } from "@/app/app/message/BlinkingBar";
import { OnyxDocument } from "@/lib/search/types";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { SearchChipList, SourceInfo } from "./SearchChipList";
import {
formatSearchHeader,
@@ -7,7 +7,7 @@ import {
RenderType,
} from "@/app/app/message/messageComponents/interfaces";
import { BlinkingBar } from "@/app/app/message/BlinkingBar";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { SearchChipList, SourceInfo } from "./SearchChipList";
import {
constructCurrentSearchState,
@@ -10,7 +10,7 @@ import {
} from "@/app/app/services/streamingModels";
import { OnyxDocument } from "@/lib/search/types";
import { getSourceDisplayName, isValidSource } from "@/lib/sources";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
export const MAX_TITLE_LENGTH = 25;
@@ -3,8 +3,8 @@ import { useTranslations } from "next-intl";
import {
FederatedConnectorDetail,
FederatedConnectorConfig,
federatedSourceToRegularSource,
} from "@/lib/types";
import { federatedSourceToRegularSource } from "@/lib/connectors/types/source";
import { SourceIcon } from "@/components/SourceIcon";
import { Label } from "@opal/layouts";
import { ErrorMessage } from "formik";
+1 -1
View File
@@ -1,7 +1,7 @@
"use client";
import { getSourceMetadata } from "@/lib/sources";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
export interface SourceIconProps {
sourceType: ValidSources;
+1 -1
View File
@@ -1,6 +1,6 @@
"use client";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { SourceIcon } from "./SourceIcon";
import { useState } from "react";
import { SvgOnyxLogo, SvgGithub } from "@opal/logos";
@@ -1,7 +1,10 @@
import { render, screen, waitFor } from "@tests/setup/test-utils";
import { Formik } from "formik";
import { AccessTypeForm } from "@/components/admin/connectors/AccessTypeForm";
import { ConfigurableSources, ValidSources } from "@/lib/types";
import {
ConfigurableSources,
ValidSources,
} from "@/lib/connectors/types/source";
jest.mock("@/lib/permissions/hooks", () => ({
usePermissionAuthority: jest.fn(),
@@ -1,10 +1,10 @@
import { DefaultDropdown } from "@/components/Dropdown";
import { AccessType } from "@/lib/types";
import {
AccessType,
ValidAutoSyncSource,
ConfigurableSources,
validAutoSyncSources,
} from "@/lib/types";
} from "@/lib/connectors/types/source";
import { useField } from "formik";
import { useTranslations } from "next-intl";
import { AutoSyncOptions } from "./AutoSyncOptions";
@@ -7,12 +7,12 @@ import Text from "@/refresh-components/texts/Text";
import { Button, Divider } from "@opal/components";
import { UserGroup } from "@/lib/types";
import { useUserGroups } from "@/lib/hooks";
import { AccessType } from "@/lib/types";
import {
AccessType,
ValidAutoSyncSource,
ConfigurableSources,
validAutoSyncSources,
} from "@/lib/types";
} from "@/lib/connectors/types/source";
import { usePermissionAuthority } from "@/lib/permissions/hooks";
import { Permission } from "@/lib/types";
import { SvgUsers } from "@opal/icons";
@@ -1,5 +1,5 @@
import { TextFormField } from "@/components/Field";
import { ValidAutoSyncSource } from "@/lib/types";
import type { ValidAutoSyncSource } from "@/lib/connectors/types/source";
import { Divider, Text } from "@opal/components";
import { autoSyncConfigBySource } from "@/lib/connectors/AutoSyncOptionFields";
@@ -3,7 +3,7 @@ import { Formik, Form } from "formik";
import * as Yup from "yup";
import { toast } from "@opal/layouts";
import { useTranslations } from "next-intl";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import {
createCredential,
@@ -4,13 +4,13 @@ import { useState, useEffect } from "react";
import { useTranslations } from "next-intl";
import { Button, InputCheckbox, Divider, Tooltip } from "@opal/components";
import {
ConfigurableSources,
CredentialFieldSpec,
ConfigurationFieldSpec,
FederatedConnectorCreateRequest,
FederatedConnectorDetail,
CredentialSchemaResponse,
} from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import { getSourceMetadata } from "@/lib/sources";
import { SourceIcon } from "@/components/SourceIcon";
import { Card, CardContent } from "@/components/ui/card";
@@ -4,7 +4,7 @@ import { useState } from "react";
import { useTranslations } from "next-intl";
import { Card, Modal } from "@opal/components";
import { Button } from "@opal/components";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { useSettings } from "@/lib/settings/hooks";
import { getSourceMetadata } from "@/lib/sources";
import useFederatedOAuthStatus from "@/hooks/useFederatedOAuthStatus";
@@ -1,5 +1,6 @@
import React, { JSX } from "react";
import { DocumentSetSummary, Tag, ValidSources } from "@/lib/types";
import { DocumentSetSummary, Tag } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { SourceMetadata } from "@/lib/search/types";
import { FiBook, FiBookmark, FiMap, FiX } from "react-icons/fi";
import { SearchDateRangeSelector } from "@/components/dateRangeSelectors/SearchDateRangeSelector";
@@ -8,7 +8,7 @@ import { WebResultIcon } from "../WebResultIcon";
import Text from "@/refresh-components/texts/Text";
import { openDocument } from "@/lib/search/utils";
import { SubQuestionDetail } from "@/app/app/interfaces";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { Card } from "@/components/ui/card";
export const buildDocumentSummaryDisplay = (
+1 -1
View File
@@ -6,7 +6,7 @@ import { WebResultIcon } from "@/components/WebResultIcon";
import Text from "@/refresh-components/texts/Text";
import Chip from "@/refresh-components/Chip";
import { buildDocumentSummaryDisplay } from "@/components/search/DocumentDisplay";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { MinimalOnyxDocument } from "@/lib/search/types";
import { Section } from "@/layouts/general-layouts";
import { Interactive } from "@opal/core";
+2 -1
View File
@@ -9,7 +9,8 @@ import { EmptyMessageCard } from "@opal/components";
import { IllustrationContent, toast } from "@opal/layouts";
import SvgNoResult from "@opal/illustrations/no-result";
import { getSourceMetadata } from "@/lib/sources";
import { Tag, ValidSources } from "@/lib/types";
import { Tag } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import {
countDocumentsBySource,
documentMatchesAnySource,
+1 -1
View File
@@ -1,4 +1,4 @@
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { ToolSnapshot } from "@/lib/tools/types";
import { DocumentSetSummary, MinimalUserSnapshot } from "@/lib/types";
import type { PermissionsOf } from "@/lib/permissions/resource-actions";
+1 -1
View File
@@ -1,4 +1,4 @@
import { ValidSources } from "./types";
import { ValidSources } from "@/lib/connectors/types/source";
import type {
Connector,
ConnectorBase,
@@ -1,5 +1,5 @@
import { JSX } from "react";
import { ValidAutoSyncSource } from "@/lib/types";
import type { ValidAutoSyncSource } from "@/lib/connectors/types/source";
interface AutoSyncConfig {
notice?: string;
@@ -15,7 +15,8 @@ import {
CredentialCreationMethod,
shouldRedirectToOAuth,
} from "@/lib/credentials/credentialCreation";
import type { AccessType, ConfigurableSources } from "@/lib/types";
import type { AccessType } from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
export interface CredentialsConfigurerProps {
/** The source being set up. */
+3 -3
View File
@@ -1,12 +1,12 @@
import { ConfigurableSources } from "../types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import { DOCS_ADMINS_PATH } from "@/lib/constants";
import { useTranslations } from "next-intl";
import type {
BooleanOption,
ConnectionConfiguration,
ListOption,
} from "./types";
import { OneDriveScope } from "./types";
} from "@/lib/connectors/types";
import { OneDriveScope } from "@/lib/connectors/types";
const DEFAULT_MICROSOFT_AUTHORITY_HOST = "https://login.microsoftonline.com";
const DEFAULT_MICROSOFT_GRAPH_API_HOST = "https://graph.microsoft.com";
+1 -1
View File
@@ -1,5 +1,5 @@
import { SourceCategory } from "@/lib/search/types";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
/**
* Message key, inside the `admin.addConnector` namespace, for each category
+2 -2
View File
@@ -1,4 +1,4 @@
import { ValidSources } from "../types";
import { ValidSources } from "@/lib/connectors/types/source";
import type {
AirtableCredentialJson,
AsanaCredentialJson,
@@ -53,7 +53,7 @@ import type {
ZendeskCredentialJson,
ZoomCredentialJson,
ZulipCredentialJson,
} from "./types";
} from "@/lib/connectors/types";
// Gmail and Google Drive use dedicated credential UIs, so their templates are partial.
type CredentialTemplateMap = Record<ValidSources, object | null> & {
+2 -2
View File
@@ -1,5 +1,5 @@
import { FileTypeCategory } from "./types";
import type { FileTypeDefinition } from "./types";
import { FileTypeCategory } from "@/lib/connectors/types";
import type { FileTypeDefinition } from "@/lib/connectors/types";
export const FILE_TYPE_DEFINITIONS: Record<
FileTypeCategory,
+5 -3
View File
@@ -22,7 +22,7 @@ import {
NEXT_PUBLIC_CLOUD_ENABLED,
NEXT_PUBLIC_TEST_ENV,
} from "@/lib/constants";
import { oauthSupportedSources } from "@/lib/types";
import { oauthSupportedSources } from "@/lib/connectors/types/source";
import type {
AnyCredential,
Credential,
@@ -37,11 +37,13 @@ import type {
import { errorHandlingFetcher } from "@/lib/fetcher";
import { SWR_KEYS } from "@/lib/swr-keys";
import type {
ConfigurableSources,
CredentialSchemaResponse,
FederatedConnectorDetail,
ValidSources,
} from "@/lib/types";
import type {
ConfigurableSources,
ValidSources,
} from "@/lib/connectors/types/source";
/** How often the credential lists re-poll, in milliseconds. */
const CREDENTIALS_REFRESH_INTERVAL_MS = 5000;
+4 -1
View File
@@ -7,7 +7,10 @@ import {
} from "@/lib/connectors/utils";
import { FileTypeCategory, OneDriveScope } from "@/lib/connectors/types";
import { getSourceDocLink, getSourceMetadata } from "@/lib/sources";
import { ValidSources, validAutoSyncSources } from "@/lib/types";
import {
ValidSources,
validAutoSyncSources,
} from "@/lib/connectors/types/source";
const ONE_DRIVE_USERS_REQUIRED = "Add at least one user for Specific scope";
+1 -1
View File
@@ -1,5 +1,5 @@
import { getConnectorOauthRedirectUrl } from "@/lib/connectors/svc";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
const SALESFORCE_URL_ERROR =
"Invalid OAuth configuration: Salesforce URL must use HTTPS";
+2 -1
View File
@@ -6,7 +6,8 @@ import { parseErrorDetail, type ErrorResponseBody } from "@/lib/fetcher";
import type { FileUploadResponse } from "@/lib/fileConnector";
import { buildCCPairInfoUrl } from "@/lib/connectors/utils";
import type { FileConfig, GoogleSitesConfig } from "@/lib/connectors/types";
import { AccessType, ValidSources } from "@/lib/types";
import { AccessType } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
// ---------------------------------------------------------------------------
// Indexing
+2 -2
View File
@@ -6,8 +6,8 @@ import type {
IndexAttemptSnapshot,
ValidStatuses,
} from "@/lib/types";
import type { Connector } from "./connector";
import type { Credential } from "./credential";
import type { Connector } from "@/lib/connectors/types/connector";
import type { Credential } from "@/lib/connectors/types/credential";
export enum ConnectorCredentialPairStatus {
SCHEDULED = "SCHEDULED",
+2 -1
View File
@@ -1,4 +1,5 @@
import type { ValidInputTypes, ValidSources } from "@/lib/types";
import type { ValidInputTypes } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
export interface ConnectorBase<T> {
name: string;
+2 -4
View File
@@ -1,10 +1,8 @@
import type { SWRResponse } from "swr";
import type { CredentialCreationMethod } from "@/lib/credentials/credentialCreation";
import type { CredentialFieldValues } from "@/lib/credentials/types";
import type { ValidSources } from "@/lib/types";
import type { TypedFile } from "../fileTypes";
import type { ValidSources } from "@/lib/connectors/types/source";
import type { TypedFile } from "@/lib/connectors/fileTypes";
export interface OAuthAdditionalKwargDescription {
name: string;
@@ -1,5 +1,5 @@
/** The `credential_json` shape of each source. */
import type { TypedFile } from "../fileTypes";
import type { TypedFile } from "@/lib/connectors/fileTypes";
export interface GithubCredentialJson {
github_access_token: string;
+1 -1
View File
@@ -1,5 +1,5 @@
/** The schema a connector's creation form is rendered from. */
import type { Credential } from "./credential";
import type { Credential } from "@/lib/connectors/types/credential";
export type InputType =
| "list"
+9 -8
View File
@@ -1,8 +1,9 @@
export * from "./ccPair";
export * from "./connector";
export * from "./connectorConfig";
export * from "./credential";
export * from "./credentialJson";
export * from "./fileTypes";
export * from "./form";
export * from "./stageMetrics";
export * from "@/lib/connectors/types/ccPair";
export * from "@/lib/connectors/types/connector";
export * from "@/lib/connectors/types/connectorConfig";
export * from "@/lib/connectors/types/credential";
export * from "@/lib/connectors/types/credentialJson";
export * from "@/lib/connectors/types/fileTypes";
export * from "@/lib/connectors/types/form";
export * from "@/lib/connectors/types/source";
export * from "@/lib/connectors/types/stageMetrics";
+123
View File
@@ -0,0 +1,123 @@
/**
* The sources a connector can index, and the sets carved out of them.
*
* These live with the connectors library rather than in the shared types
* grab-bag: everything here is about what a connector can point at, and
* nothing outside the connector surface defines a source.
*/
export enum ValidSources {
Web = "web",
GitHub = "github",
GitLab = "gitlab",
Slack = "slack",
GoogleDrive = "google_drive",
Gmail = "gmail",
Bookstack = "bookstack",
Outline = "outline",
Confluence = "confluence",
Jira = "jira",
Productboard = "productboard",
Slab = "slab",
Coda = "coda",
Notion = "notion",
Guru = "guru",
Gong = "gong",
Zulip = "zulip",
Linear = "linear",
Hubspot = "hubspot",
Document360 = "document360",
File = "file",
UserFile = "user_file",
GoogleSites = "google_sites",
Loopio = "loopio",
Box = "box",
Dropbox = "dropbox",
Discord = "discord",
Salesforce = "salesforce",
Sharepoint = "sharepoint",
OneDrive = "onedrive",
Teams = "teams",
Outlook = "outlook",
Zendesk = "zendesk",
Discourse = "discourse",
Axero = "axero",
Clickup = "clickup",
Wikipedia = "wikipedia",
Mediawiki = "mediawiki",
Asana = "asana",
S3 = "s3",
R2 = "r2",
GoogleCloudStorage = "google_cloud_storage",
Xenforo = "xenforo",
OciStorage = "oci_storage",
NotApplicable = "not_applicable",
IngestionApi = "ingestion_api",
Freshdesk = "freshdesk",
Fireflies = "fireflies",
Egnyte = "egnyte",
Airtable = "airtable",
Gitbook = "gitbook",
Highspot = "highspot",
DrupalWiki = "drupal_wiki",
Imap = "imap",
Bitbucket = "bitbucket",
TestRail = "testrail",
Braintrust = "braintrust",
Lumapps = "lumapps",
Canvas = "canvas",
Zoom = "zoom",
// Craft-specific sources
CraftFile = "craft_file",
// Federated Connectors
FederatedSlack = "federated_slack",
}
export const federatedSourceToRegularSource = (
maybeFederatedSource: ValidSources
): ValidSources => {
if (maybeFederatedSource === ValidSources.FederatedSlack) {
return ValidSources.Slack;
}
return maybeFederatedSource;
};
export const validAutoSyncSources = [
ValidSources.Confluence,
ValidSources.Jira,
ValidSources.GoogleDrive,
ValidSources.Gmail,
ValidSources.Slack,
ValidSources.Salesforce,
ValidSources.GitHub,
ValidSources.Sharepoint,
ValidSources.Teams,
ValidSources.Outlook,
ValidSources.Canvas,
ValidSources.Box,
ValidSources.OneDrive,
ValidSources.Zoom,
] as const;
// Create a type from the array elements
export type ValidAutoSyncSource = (typeof validAutoSyncSources)[number];
export type ConfigurableSources = Exclude<
ValidSources,
| ValidSources.NotApplicable
| ValidSources.IngestionApi
| ValidSources.FederatedSlack // is part of ValiedSources.Slack
| ValidSources.UserFile
| ValidSources.CraftFile // User Library - managed through dedicated UI
>;
export const oauthSupportedSources: ConfigurableSources[] = [
ValidSources.Slack,
// NOTE: temporarily disabled until our GDrive App is approved
// ValidSources.GoogleDrive,
ValidSources.Confluence,
];
export type OAuthSupportedSource = (typeof oauthSupportedSources)[number];
+3 -6
View File
@@ -1,12 +1,9 @@
import * as Yup from "yup";
import type { AccessTypeGroupSelectorFormType } from "@/components/admin/connectors/AccessTypeGroupSelector";
import type { ConnectorGroupRestrictionFormValues } from "@/lib/connectors/accessType";
import { ValidSources } from "@/lib/types";
import type {
ConfigurableSources,
IndexAttemptStage,
IndexAttemptStageMetric,
} from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import type { IndexAttemptStage, IndexAttemptStageMetric } from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import { SWR_KEYS } from "@/lib/swr-keys";
import { connectorConfigs } from "@/lib/connectors/connectors";
import { credentialDisplayNames } from "@/lib/connectors/credentials";
@@ -6,7 +6,7 @@ import {
createConnectorInitialValues,
createConnectorValidationSchema,
} from "@/lib/connectors/utils";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
function ZoomForm() {
const config = connectorConfigs.zoom;
@@ -1,7 +1,8 @@
import { useState } from "react";
import { useTranslations } from "next-intl";
import { Button as OpalButton } from "@opal/components";
import { ValidSources, AccessType } from "@/lib/types";
import { AccessType } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { submitCredential } from "@/components/admin/connectors/CredentialForm";
import { TextFormField } from "@/components/Field";
import { Form, Formik, FormikHelpers } from "formik";
@@ -8,7 +8,7 @@ import { useTranslations } from "next-intl";
import type { OAuthAdditionalKwargDescription } from "@/lib/connectors/types";
import { getConnectorOauthRedirectUrl } from "@/lib/connectors/svc";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { FormikField } from "@/refresh-components/form/FormikField";
type OAuthFormValues = Record<string, string>;
@@ -1,6 +1,7 @@
"use client";
import { AccessType, ValidSources } from "@/lib/types";
import { AccessType } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { useTranslations } from "next-intl";
import useSWR, { mutate } from "swr";
import { errorHandlingFetcher, type ErrorResponseBody } from "@/lib/fetcher";
@@ -17,7 +17,7 @@ import type {
CredentialFieldValues,
CredentialFormValues,
} from "@/lib/credentials/types";
import type { ValidSources } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
export interface EditCredentialProps {
credential: Credential<CredentialFieldValues>;
+1 -1
View File
@@ -1,7 +1,7 @@
import { credentialTemplates } from "@/lib/connectors/credentials";
import type { Credential } from "@/lib/connectors/types";
import type { CredentialFieldValues } from "@/lib/credentials/types";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import {
canEditCredentialWithForm,
+1 -1
View File
@@ -11,7 +11,7 @@ import type {
CredentialFieldValues,
CredentialFormValues,
} from "@/lib/credentials/types";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
// What a credential template seeds a field with: "" for a required text
// field, null for an optional one or a file, a boolean for a checkbox.
+1 -1
View File
@@ -3,7 +3,7 @@ import { toast } from "@opal/layouts";
import { FetchError, errorHandlingFetcher } from "@/lib/fetcher";
import type { Credential } from "@/lib/connectors/types";
import type { ConnectorSnapshot } from "@/lib/connectors/types";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import {
refreshSourceCredentials,
useSourceCredentials,
+2 -2
View File
@@ -1,11 +1,11 @@
import type { ErrorResponseBody } from "@/lib/fetcher";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import {
HierarchyNodesResponse,
HierarchyNodeDocumentsRequest,
HierarchyNodeDocumentsResponse,
HierarchyNodeSearchResponse,
} from "./interfaces";
} from "@/lib/hierarchy/types";
const HIERARCHY_NODES_PREFIX = "/api/hierarchy-nodes";
@@ -1,4 +1,4 @@
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
// Sort options for document pagination
export type DocumentSortField = "name" | "last_updated";
+1 -1
View File
@@ -6,10 +6,10 @@ import {
UserGroup,
ConnectorStatus,
FederatedConnectorDetail,
ValidSources,
ConnectorIndexingStatusLiteResponse,
IndexingStatusRequest,
} from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import useSWR, { mutate, useSWRConfig } from "swr";
import { errorHandlingFetcher } from "./fetcher";
import {
@@ -1,5 +1,5 @@
import { openDocument } from "@/lib/search/utils";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
it.each([
"javascript:alert(1)",
+2 -1
View File
@@ -1,5 +1,6 @@
import { InputDateRangePickerValue } from "@opal/components";
import { Tag, ValidSources } from "../types";
import { Tag } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { Agent } from "@/lib/agents/types";
export const FlowType = {
+1 -1
View File
@@ -1,4 +1,4 @@
import { ValidSources } from "../types";
import { ValidSources } from "@/lib/connectors/types/source";
import { OnyxDocument } from "@/lib/search/types";
import {
countDocumentsBySource,
+1 -1
View File
@@ -1,4 +1,4 @@
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { MinimalOnyxDocument, OnyxDocument } from "@/lib/search/types";
import { transformLinkUri } from "@/lib/utils";
+2 -1
View File
@@ -1,4 +1,5 @@
import type { Tag, ValidSources } from "@/lib/types";
import type { Tag } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import type { MinimalAgent } from "@/lib/agents/types";
import type { ChatSearchFilters } from "@/lib/tools/types";
import { isAssistant } from "@/lib/agents/utils";
+1 -1
View File
@@ -5,7 +5,7 @@ import {
BraintrustIcon,
BoxIcon,
} from "@/components/icons/icons";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { SourceCategory, SourceMetadata } from "@/lib/search/types";
import React from "react";
import { DOCS_ADMINS_PATH, DOCS_BASE_URL } from "@/lib/constants";
+1 -1
View File
@@ -11,7 +11,7 @@ import {
} from "@/lib/searchFilters/utils";
import { getConfiguredSources } from "@/lib/sources";
import type { ToolConfigurationHandle } from "@/lib/tools/hooks";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
/** A source the picker can show: {@link getConfiguredSources} guarantees a key. */
type ConfiguredSource = ReturnType<typeof getConfiguredSources>[number];
+1 -1
View File
@@ -7,7 +7,7 @@ import {
normalizeSourceSelection,
} from "@/lib/searchFilters/utils";
import type { SourceMetadata } from "@/lib/search/types";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
const CHAT_KEY = "onyx:tools:chat:abc";
+3 -116
View File
@@ -5,6 +5,9 @@ import type { Credential } from "@/lib/connectors/types";
import type { Connector } from "@/lib/connectors/types";
import { ConnectorCredentialPairStatus } from "@/lib/connectors/types";
import type { PermissionsOf } from "@/lib/permissions/resource-actions";
// Imported from the module itself, not the barrel: the barrel re-exports
// shapes that import from here, and the enum is a runtime value.
import { ValidSources } from "@/lib/connectors/types/source";
export enum ThemePreference {
LIGHT = "light",
@@ -599,122 +602,6 @@ export interface SecuritySettings {
jwt_expected_issuer: string | null;
}
export enum ValidSources {
Web = "web",
GitHub = "github",
GitLab = "gitlab",
Slack = "slack",
GoogleDrive = "google_drive",
Gmail = "gmail",
Bookstack = "bookstack",
Outline = "outline",
Confluence = "confluence",
Jira = "jira",
Productboard = "productboard",
Slab = "slab",
Coda = "coda",
Notion = "notion",
Guru = "guru",
Gong = "gong",
Zulip = "zulip",
Linear = "linear",
Hubspot = "hubspot",
Document360 = "document360",
File = "file",
UserFile = "user_file",
GoogleSites = "google_sites",
Loopio = "loopio",
Box = "box",
Dropbox = "dropbox",
Discord = "discord",
Salesforce = "salesforce",
Sharepoint = "sharepoint",
OneDrive = "onedrive",
Teams = "teams",
Outlook = "outlook",
Zendesk = "zendesk",
Discourse = "discourse",
Axero = "axero",
Clickup = "clickup",
Wikipedia = "wikipedia",
Mediawiki = "mediawiki",
Asana = "asana",
S3 = "s3",
R2 = "r2",
GoogleCloudStorage = "google_cloud_storage",
Xenforo = "xenforo",
OciStorage = "oci_storage",
NotApplicable = "not_applicable",
IngestionApi = "ingestion_api",
Freshdesk = "freshdesk",
Fireflies = "fireflies",
Egnyte = "egnyte",
Airtable = "airtable",
Gitbook = "gitbook",
Highspot = "highspot",
DrupalWiki = "drupal_wiki",
Imap = "imap",
Bitbucket = "bitbucket",
TestRail = "testrail",
Braintrust = "braintrust",
Lumapps = "lumapps",
Canvas = "canvas",
Zoom = "zoom",
// Craft-specific sources
CraftFile = "craft_file",
// Federated Connectors
FederatedSlack = "federated_slack",
}
export const federatedSourceToRegularSource = (
maybeFederatedSource: ValidSources
): ValidSources => {
if (maybeFederatedSource === ValidSources.FederatedSlack) {
return ValidSources.Slack;
}
return maybeFederatedSource;
};
export const validAutoSyncSources = [
ValidSources.Confluence,
ValidSources.Jira,
ValidSources.GoogleDrive,
ValidSources.Gmail,
ValidSources.Slack,
ValidSources.Salesforce,
ValidSources.GitHub,
ValidSources.Sharepoint,
ValidSources.Teams,
ValidSources.Outlook,
ValidSources.Canvas,
ValidSources.Box,
ValidSources.OneDrive,
ValidSources.Zoom,
] as const;
// Create a type from the array elements
export type ValidAutoSyncSource = (typeof validAutoSyncSources)[number];
export type ConfigurableSources = Exclude<
ValidSources,
| ValidSources.NotApplicable
| ValidSources.IngestionApi
| ValidSources.FederatedSlack // is part of ValiedSources.Slack
| ValidSources.UserFile
| ValidSources.CraftFile // User Library - managed through dedicated UI
>;
export const oauthSupportedSources: ConfigurableSources[] = [
ValidSources.Slack,
// NOTE: temporarily disabled until our GDrive App is approved
// ValidSources.GoogleDrive,
ValidSources.Confluence,
];
export type OAuthSupportedSource = (typeof oauthSupportedSources)[number];
// Federated Connector Types
export interface CredentialFieldSpec {
type: string;
@@ -20,7 +20,7 @@ import {
} from "@/components/ui/tooltip";
import { SourceIcon } from "@/components/SourceIcon";
import { WebResultIcon } from "@/components/WebResultIcon";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import SourceTagDetailsCard, {
SourceInfo,
} from "@/refresh-components/buttons/source-tag/SourceTagDetailsCard";
@@ -11,7 +11,7 @@ import {
} from "@opal/icons";
import { SourceIcon } from "@/components/SourceIcon";
import { WebResultIcon } from "@/components/WebResultIcon";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { timeAgo } from "@opal/time";
import { useLocale } from "next-intl";
import type { IconProps } from "@opal/types";
@@ -1,7 +1,7 @@
import { OnyxDocument } from "@/lib/search/types";
import { SubQuestionDetail } from "@/app/app/interfaces";
import { StreamingCitation } from "@/app/app/services/streamingModels";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { getSourceDisplayName } from "@/lib/sources";
import { SourceInfo } from "./SourceTagDetailsCard";
@@ -7,7 +7,7 @@ import { MetadataBadge } from "@/components/MetadataBadge";
import { WebResultIcon } from "@/components/WebResultIcon";
import { Dispatch, SetStateAction, useMemo } from "react";
import { openDocument } from "@/lib/search/utils";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { cn } from "@opal/utils";
import Truncated from "@/refresh-components/texts/Truncated";
import Text from "@/refresh-components/texts/Text";
@@ -19,9 +19,10 @@ import type {
import type {
ConnectedSource,
HierarchyNodeSearchSummary,
} from "@/lib/hierarchy/interfaces";
} from "@/lib/hierarchy/types";
import type { ProjectFile } from "@/lib/projects/types";
import type { DocumentSetSummary, ValidSources } from "@/lib/types";
import type { DocumentSetSummary } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import { searchDocuments } from "@/ee/lib/search/svc";
import { Disabled } from "@opal/core";
import { Card, InputSwitch } from "@opal/components";
@@ -39,7 +40,7 @@ import type {
KnowledgeNavState,
KnowledgeSearchResults,
KnowledgeView,
} from "@/sections/knowledge/agent-knowledge/interfaces";
} from "@/sections/knowledge/agent-knowledge/types";
interface AgentKnowledgePaneProps {
enableKnowledge: boolean;
@@ -36,7 +36,7 @@ import {
SvgFilter,
} from "@opal/icons";
import { getSourceMetadata } from "@/lib/sources";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import {
HierarchyNodeSummary,
DocumentSummary,
@@ -46,7 +46,7 @@ import {
DocumentSortField,
DocumentSortDirection,
FolderPosition,
} from "@/lib/hierarchy/interfaces";
} from "@/lib/hierarchy/types";
import {
fetchHierarchyNodes,
fetchHierarchyNodeDocuments,
@@ -5,8 +5,8 @@ import { useTranslations } from "next-intl";
import * as GeneralLayouts from "@/layouts/general-layouts";
import Text from "@/refresh-components/texts/Text";
import { getSourceMetadata } from "@/lib/sources";
import type { ConnectedSource } from "@/lib/hierarchy/interfaces";
import type { ValidSources } from "@/lib/types";
import type { ConnectedSource } from "@/lib/hierarchy/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import { LineItemButton } from "@opal/components";
import { SvgFiles, SvgFolder } from "@opal/icons";
@@ -4,7 +4,7 @@ import { memo } from "react";
import { useTranslations } from "next-intl";
import * as GeneralLayouts from "@/layouts/general-layouts";
import Text from "@/refresh-components/texts/Text";
import type { ValidSources } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import { Button } from "@opal/components";
import { SvgArrowUpRight, SvgPlusCircle } from "@opal/icons";
@@ -10,9 +10,9 @@ import { getSourceMetadata } from "@/lib/sources";
import type {
ConnectedSource,
HierarchyNodeSearchSummary,
} from "@/lib/hierarchy/interfaces";
} from "@/lib/hierarchy/types";
import type { SearchDocWithContent } from "@/lib/search/types";
import type { ValidSources } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import {
Button,
InputCheckbox,
@@ -30,7 +30,7 @@ import {
SvgXCircle,
} from "@opal/icons";
import type { KnowledgeSearchResults } from "@/sections/knowledge/agent-knowledge/interfaces";
import type { KnowledgeSearchResults } from "@/sections/knowledge/agent-knowledge/types";
interface KnowledgeSearchBarProps {
query: string;
@@ -4,12 +4,12 @@ import { useTranslations } from "next-intl";
import * as TableLayouts from "@/layouts/table-layouts";
import Text from "@/refresh-components/texts/Text";
import { getSourceMetadata } from "@/lib/sources";
import type { ConnectedSource } from "@/lib/hierarchy/interfaces";
import type { ValidSources } from "@/lib/types";
import type { ConnectedSource } from "@/lib/hierarchy/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import { Divider, LineItemButton } from "@opal/components";
import { SvgFiles, SvgFolder } from "@opal/icons";
import type { KnowledgeView } from "@/sections/knowledge/agent-knowledge/interfaces";
import type { KnowledgeView } from "@/sections/knowledge/agent-knowledge/types";
interface KnowledgeSidebarProps {
activeView: KnowledgeView;
@@ -9,11 +9,8 @@ import { getSourceMetadata } from "@/lib/sources";
import { useSettings } from "@/lib/settings/hooks";
import type { AgentAttachedDocument } from "@/lib/agents/types";
import type { ProjectFile } from "@/lib/projects/types";
import type {
CCPairSummary,
DocumentSetSummary,
ValidSources,
} from "@/lib/types";
import type { CCPairSummary, DocumentSetSummary } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import SourceHierarchyBrowser from "@/sections/knowledge/SourceHierarchyBrowser";
import { Button } from "@opal/components";
import { Content } from "@opal/layouts";
@@ -7,8 +7,9 @@ import type { AgentAttachedDocument } from "@/lib/agents/types";
import type {
ConnectedSource,
HierarchyNodeSearchSummary,
} from "@/lib/hierarchy/interfaces";
import type { DocumentSetSummary, ValidSources } from "@/lib/types";
} from "@/lib/hierarchy/types";
import type { DocumentSetSummary } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import type { ProjectFile } from "@/lib/projects/types";
import { KnowledgeSidebar } from "@/sections/knowledge/agent-knowledge/KnowledgeSidebar";
@@ -25,7 +26,7 @@ import {
import type {
KnowledgeSearchResults,
KnowledgeView,
} from "@/sections/knowledge/agent-knowledge/interfaces";
} from "@/sections/knowledge/agent-knowledge/types";
interface KnowledgeTwoColumnViewProps {
activeView: KnowledgeView;
@@ -1,5 +1,5 @@
import type { ValidSources } from "@/lib/types";
import type { HierarchyNodeSearchSummary } from "@/lib/hierarchy/interfaces";
import type { ValidSources } from "@/lib/connectors/types/source";
import type { HierarchyNodeSearchSummary } from "@/lib/hierarchy/types";
import type { SearchDocWithContent } from "@/lib/search/types";
export type KnowledgeView =
+2 -1
View File
@@ -98,7 +98,8 @@ import { Tier } from "@/lib/settings/types";
import { ConfirmationModalLayout } from "@opal/layouts";
import { ShareAgentModal, type ShareDraftState } from "@/lib/agents/components";
import AgentKnowledgePane from "@/sections/knowledge/AgentKnowledgePane";
import { Permission, ValidSources } from "@/lib/types";
import { Permission } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { useSettings } from "@/lib/settings/hooks";
import { useUser } from "@/providers/UserProvider";
import { hasPermission } from "@/lib/permissions";
+2 -1
View File
@@ -31,7 +31,8 @@ import PreviewModal from "@/sections/modals/PreviewModal";
import { Modal } from "@opal/components";
import { useSendMessageToParent } from "@/lib/extension/hooks";
import { SourceMetadata } from "@/lib/search/types";
import { FederatedConnectorDetail, ValidSources } from "@/lib/types";
import { FederatedConnectorDetail } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import DocumentsSidebar from "@/sections/document-sidebar/DocumentsSidebar";
import useChatController from "@/hooks/useChatController";
import useMultiModelChat from "@/hooks/useMultiModelChat";
+1 -1
View File
@@ -61,7 +61,7 @@ import {
} from "@opal/components";
import useFederatedOAuthStatus from "@/hooks/useFederatedOAuthStatus";
import useCCPairs from "@/hooks/useCCPairs";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { ConnectorCredentialPairStatus } from "@/lib/connectors/types";
import { ConfirmationModalLayout } from "@opal/layouts";
import { BasicModalFooter, Modal } from "@opal/components";
@@ -15,7 +15,7 @@ import { useDocumentSets } from "@/lib/hooks/useDocumentSets";
import { useAdminAgents } from "@/lib/agents/hooks";
import { getSourceMetadata } from "@/lib/sources";
import type { Agent } from "@/lib/agents/types";
import type { ValidSources } from "@/lib/types";
import type { ValidSources } from "@/lib/connectors/types/source";
import ResourceContent from "@/views/admin/GroupsPage/SharedGroupResources/ResourceContent";
import ResourcePopover from "@/views/admin/GroupsPage/SharedGroupResources/ResourcePopover";
import type { PopoverSection } from "@/views/admin/GroupsPage/SharedGroupResources/interfaces";
@@ -15,7 +15,10 @@ import { submitFiles } from "@/lib/connectors/svc";
import { submitGoogleSite } from "@/lib/connectors/svc";
import AdvancedFormPage from "@/views/admin/connectors/AddConnectorPage/form/Advanced";
import DynamicConnectionForm from "@/views/admin/connectors/AddConnectorPage/form/DynamicConnectorCreationForm";
import { ConfigurableSources, ValidSources } from "@/lib/types";
import {
ConfigurableSources,
ValidSources,
} from "@/lib/connectors/types/source";
import { credentialTemplates } from "@/lib/connectors/credentials";
import type { Credential } from "@/lib/connectors/types";
import {
@@ -1,7 +1,7 @@
"use client";
import { useTranslations } from "next-intl";
import { ConfigurableSources } from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import AddConnector from "./AddConnector";
import { Button } from "@opal/components";
import { SettingsLayouts, useToastFromQuery } from "@opal/layouts";
@@ -6,7 +6,7 @@ import { TextFormField } from "@/components/Field";
import { AdvancedOptionsToggle } from "@/components/AdvancedOptionsToggle";
import { AccessTypeForm } from "@/components/admin/connectors/AccessTypeForm";
import { AccessTypeGroupSelector } from "@/components/admin/connectors/AccessTypeGroupSelector";
import { ConfigurableSources } from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import type { Credential } from "@/lib/connectors/types";
import { RenderField } from "./FieldRendering";
import { useFormikContext } from "formik";
@@ -7,7 +7,7 @@ import { TextFormField, MultiSelectField } from "@/components/Field";
import ListInput from "./inputs/ListInput";
import StringPairListInput from "./inputs/StringPairListInput";
import FileInput from "./inputs/FileInput";
import { ConfigurableSources } from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import type { Credential } from "@/lib/connectors/types";
import CollapsibleSection from "@/app/admin/agents/CollapsibleSection";
import { Tabs } from "@opal/components";
@@ -15,7 +15,7 @@ import {
parseOauthAppCredentialJson,
refreshAllGoogleData,
} from "@/lib/googleConnector";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { markdown } from "@opal/utils";
interface DriveCredentialSectionProps {
@@ -4,7 +4,7 @@ import React from "react";
import { useTranslations } from "next-intl";
import { ErrorCallout } from "@/components/ErrorCallout";
import { LoadingAnimation } from "@/components/Loading";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { usePublicCredentials } from "@/lib/hooks";
import { DriveAuthSection } from "./Credential";
import { useUser } from "@/providers/UserProvider";
@@ -17,7 +17,7 @@ import {
parseOauthAppCredentialJson,
refreshAllGoogleData,
} from "@/lib/googleConnector";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { markdown } from "@opal/utils";
interface GmailCredentialSectionProps {
@@ -5,7 +5,7 @@ import { useTranslations } from "next-intl";
import { ErrorCallout } from "@/components/ErrorCallout";
import { LoadingAnimation } from "@/components/Loading";
import { toast } from "@opal/layouts";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import type {
Credential,
GmailCredentialJson,
@@ -1,4 +1,4 @@
import { ConfigurableSources } from "@/lib/types";
import type { ConfigurableSources } from "@/lib/connectors/types/source";
import ConnectorWrapper from "@/views/admin/connectors/AddConnectorPage/ConnectorWrapper";
export interface PageProps {
@@ -17,10 +17,8 @@ import {
} from "react";
import { InputTypeIn, Text } from "@opal/components";
import { useFederatedConnectors } from "@/lib/hooks";
import {
FederatedConnectorDetail,
federatedSourceToRegularSource,
} from "@/lib/types";
import { FederatedConnectorDetail } from "@/lib/types";
import { federatedSourceToRegularSource } from "@/lib/connectors/types/source";
import { useSettings } from "@/lib/settings/hooks";
import { ConnectorSourceCard } from "@/lib/connectors/components";
import { ADMIN_ROUTES } from "@/lib/admin-routes";
@@ -3,7 +3,7 @@
import { useState } from "react";
import { useLocale, useTranslations } from "next-intl";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { Section } from "@/layouts/general-layouts";
import Text from "@/refresh-components/texts/Text";
import { Button, Divider } from "@opal/components";
@@ -12,12 +12,12 @@ import { Badge } from "@/components/ui/badge";
import { CCPairStatus } from "@/components/Status";
import { timeAgo } from "@opal/time";
import {
ValidSources,
ConnectorIndexingStatusLiteResponse,
SourceSummary,
ConnectorIndexingStatusLite,
FederatedConnectorStatus,
} from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import { useRouter } from "next/navigation";
import Truncated from "@/refresh-components/texts/Truncated";
import {
@@ -13,7 +13,7 @@ import { useConnectorIndexingStatusWithPagination } from "@/lib/hooks";
import { useSettings } from "@/lib/settings/hooks";
import { useState, useRef, useMemo, RefObject } from "react";
import { FilterOptions } from "./FilterComponent";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import Cookies from "js-cookie";
import { TOGGLED_CONNECTORS_COOKIE_NAME } from "@/lib/constants";
import { ConnectorStaggeredSkeleton } from "./ConnectorRowSkeleton";
@@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
import { usePathname, useSearchParams } from "next/navigation";
import { AdminPageTitle } from "@/components/admin/Title";
import { getSourceMetadata, isValidSource } from "@/lib/sources";
import { ValidSources } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import CardSection from "@/components/admin/CardSection";
import { handleOAuthAuthorizationResponse } from "@/lib/oauth_utils";
import { SvgKey } from "@opal/icons";
@@ -5,7 +5,8 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { AdminPageTitle } from "@/components/admin/Title";
import { Button } from "@opal/components";
import { getSourceMetadata, isValidSource } from "@/lib/sources";
import { ConfluenceAccessibleResource, ValidSources } from "@/lib/types";
import { ConfluenceAccessibleResource } from "@/lib/types";
import { ValidSources } from "@/lib/connectors/types/source";
import CardSection from "@/components/admin/CardSection";
import {
handleOAuthConfluenceFinalize,