Repository: n8n-io/n8n
File: packages/frontend/editor-ui/src/features/credentials/quickConnect/composables/useQuickConnect.ts (TypeScript)

Code before:
import type { QuickConnectOption } from '@n8n/api-types';
import { QUICK_CONNECT_EXPERIMENT } from '@/app/constants';
import { useTelemetry } from '@/app/composables/useTelemetry';
import { usePostHog } from '@/app/stores/posthog.store';
import { useSettingsStore } from '@/app/stores/settings.store';
import { useProjectsStore } from '@/features/collaboration/projects/projects.store';
import { computed } from 'vue';

import type { ICredentialsResponse } from '../../credentials.types';
import { useCredentialOAuth } from '../../composables/useCredentialOAuth';
import { useCredentialsStore } from '../../credentials.store';
import { useToast } from '@/app/composables/useToast';
import { useI18n } from '@n8n/i18n';

async function connectToPinecone(quickConnectOption: QuickConnectOption) {
	const { ConnectPopup } = await import('@pinecone-database/connect');

	return await new Promise<string>((resolve, reject) => {
		const popup = ConnectPopup({
			onConnect: ({ key }) => resolve(key),
			onCancel: reject,
			integrationId: String(quickConnectOption.config?.integrationId),
		});

		popup.open();
	});
}

export function useQuickConnect() {
	const settingsStore = useSettingsStore();
	const posthogStore = usePostHog();
	const telemetry = useTelemetry();
	const toast = useToast();
	const i18n = useI18n();
	const credentialsStore = useCredentialsStore();
	const projectsStore = useProjectsStore();
	const { isOAuthCredentialType, createAndAuthorize, cancelAuthorize } = useCredentialOAuth();

	const isQuickConnectEnabled = computed(() =>
		posthogStore.isVariantEnabled(QUICK_CONNECT_EXPERIMENT.name, QUICK_CONNECT_EXPERIMENT.variant),
	);

Review comment (suggestion):
The pinecone sdk is loaded asynchronously here, so it's not included/loaded into the normal bundle even if pinecone connect is not used

Code after:
import type { QuickConnectOption, QuickConnectPineconeOption } from '@n8n/api-types';
import { QUICK_CONNECT_EXPERIMENT } from '@/app/constants';
import { useTelemetry } from '@/app/composables/useTelemetry';
import { usePostHog } from '@/app/stores/posthog.store';
import { useSettingsStore } from '@/app/stores/settings.store';
import { useProjectsStore } from '@/features/collaboration/projects/projects.store';
import { computed } from 'vue';

import type { ICredentialsResponse } from '../../credentials.types';
import { useCredentialOAuth } from '../../composables/useCredentialOAuth';
import { useCredentialsStore } from '../../credentials.store';
import { useToast } from '@/app/composables/useToast';
import { useI18n } from '@n8n/i18n';

async function connectToPinecone(quickConnectOption: QuickConnectPineconeOption) {
	const { ConnectPopup } = await import('@pinecone-database/connect');

	return await new Promise<string>((resolve, reject) => {
		const popup = ConnectPopup({
			onConnect: ({ key }) => resolve(key),
			onCancel: reject,
			integrationId: String(quickConnectOption.config.integrationId),
		});

		popup.open();
	});
}

export function useQuickConnect() {
	const settingsStore = useSettingsStore();
	const posthogStore = usePostHog();
	const telemetry = useTelemetry();
	const toast = useToast();
	const i18n = useI18n();
	const credentialsStore = useCredentialsStore();
	const projectsStore = useProjectsStore();
	const { isOAuthCredentialType, createAndAuthorize, cancelAuthorize } = useCredentialOAuth();

	const isQuickConnectEnabled = computed(() =>
		posthogStore.isVariantEnabled(QUICK_CONNECT_EXPERIMENT.name, QUICK_CONNECT_EXPERIMENT.variant),
	);