AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(pieces): see which GitLab, Salesforce or QuickBooks account each connection belongs to (#16041)
Ibrahim Abuznaid634057402be4
diff --git a/bun.lock b/bun.lockindex cd802cbe8dc..da875bc8a83 100644--- a/bun.lock+++ b/bun.lock@@ -3720,7 +3720,7 @@},"packages/pieces/community/gitlab": {"name": "@activepieces/piece-gitlab",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -3729,6 +3729,7 @@},"devDependencies": {"tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/gladia": {@@ -7486,7 +7487,7 @@},"packages/pieces/community/quickbooks": {"name": "@activepieces/piece-quickbooks",- "version": "0.3.1",+ "version": "0.3.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7496,6 +7497,7 @@},"devDependencies": {"tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/quickbooks-desktop-conductor": {@@ -7513,7 +7515,7 @@},"packages/pieces/community/quickbooks-sandbox": {"name": "@activepieces/piece-quickbooks-sandbox",- "version": "0.2.0",+ "version": "0.2.1","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7523,6 +7525,7 @@},"devDependencies": {"tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/quickzu": {@@ -7968,7 +7971,7 @@},"packages/pieces/community/salesforce": {"name": "@activepieces/piece-salesforce",- "version": "0.9.1",+ "version": "0.9.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -7979,6 +7982,7 @@},"devDependencies": {"tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/salesloft": {diff --git a/packages/pieces/community/gitlab/package.json b/packages/pieces/community/gitlab/package.jsonindex 636c8b12b38..4d9808fdb17 100644--- a/packages/pieces/community/gitlab/package.json+++ b/packages/pieces/community/gitlab/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-gitlab",- "version": "0.2.0",+ "version": "0.2.1","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -15,6 +16,7 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/gitlab/src/lib/auth.test.ts b/packages/pieces/community/gitlab/src/lib/auth.test.tsnew file mode 100644index 00000000000..d6791d622c8--- /dev/null+++ b/packages/pieces/community/gitlab/src/lib/auth.test.ts@@ -0,0 +1,43 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { httpClient } from '@activepieces/pieces-common';+import { gitlabAuth } from './auth';++const server = { apiUrl: 'http://127.0.0.1:4200/api/', publicUrl: 'http://127.0.0.1:4200/api/' };++function resolveIdentifier() {+ return gitlabAuth.getConnectionIdentifier?.({ auth: { access_token: 'token', data: {} }, server });+}++function mockCurrentUser(body: unknown) {+ return vi.spyOn(httpClient, 'sendRequest').mockResolvedValue({ status: 200, headers: {}, body });+}++describe('gitlabAuth.getConnectionIdentifier', () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ it('returns the email of the user GitLab says the token belongs to', async () => {+ const sendRequest = mockCurrentUser({ email: '[email protected]', username: 'dev' });++ expect(await resolveIdentifier()).toBe('[email protected]');+ expect(sendRequest).toHaveBeenCalledWith(+ expect.objectContaining({+ url: 'https://gitlab.com/api/v4/user',+ headers: { Authorization: 'Bearer token' },+ }),+ );+ });++ it('falls back to the username when GitLab returns no email', async () => {+ mockCurrentUser({ email: '', username: 'dev' });++ expect(await resolveIdentifier()).toBe('dev');+ });++ it('returns undefined instead of throwing when the API call fails', async () => {+ vi.spyOn(httpClient, 'sendRequest').mockRejectedValue(new Error('401 Unauthorized'));++ expect(await resolveIdentifier()).toBeUndefined();+ });+});diff --git a/packages/pieces/community/gitlab/src/lib/auth.ts b/packages/pieces/community/gitlab/src/lib/auth.tsindex 18f91430cda..9dd06da52cb 100644--- a/packages/pieces/community/gitlab/src/lib/auth.ts+++ b/packages/pieces/community/gitlab/src/lib/auth.ts@@ -1,8 +1,22 @@import { PieceAuth } from '@activepieces/pieces-framework';+import { httpClient, HttpMethod } from '@activepieces/pieces-common';export const gitlabAuth = PieceAuth.OAuth2({required: true,authUrl: 'https://gitlab.com/oauth/authorize',tokenUrl: 'https://gitlab.com/oauth/token',scope: ['api', 'read_user'],+ getConnectionIdentifier: async ({ auth }) => {+ try {+ const response = await httpClient.sendRequest<{ email?: string; username?: string }>({+ method: HttpMethod.GET,+ url: 'https://gitlab.com/api/v4/user',+ headers: { Authorization: `Bearer ${auth.access_token}` },+ timeout: 5000,+ });+ return response.body.email || response.body.username || undefined;+ } catch {+ return undefined;+ }+ },});diff --git a/packages/pieces/community/gitlab/vitest.config.ts b/packages/pieces/community/gitlab/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/community/gitlab/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})diff --git a/packages/pieces/community/quickbooks-sandbox/package.json b/packages/pieces/community/quickbooks-sandbox/package.jsonindex 0cb3eae6edb..d4fd3ce5081 100644--- a/packages/pieces/community/quickbooks-sandbox/package.json+++ b/packages/pieces/community/quickbooks-sandbox/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-quickbooks-sandbox",- "version": "0.2.0",+ "version": "0.2.1","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -16,6 +17,7 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/quickbooks-sandbox/src/lib/auth.test.ts b/packages/pieces/community/quickbooks-sandbox/src/lib/auth.test.tsnew file mode 100644index 00000000000..28f721f1192--- /dev/null+++ b/packages/pieces/community/quickbooks-sandbox/src/lib/auth.test.ts@@ -0,0 +1,54 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { httpClient } from '@activepieces/pieces-common';+import { quickbooksAuth } from './auth';++const server = { apiUrl: 'http://127.0.0.1:4200/api/', publicUrl: 'http://127.0.0.1:4200/api/' };++function resolveIdentifier(companyId: unknown) {+ return quickbooksAuth.getConnectionIdentifier?.({ auth: { access_token: 'token', data: {}, props: { companyId } }, server });+}++function mockCompanyInfo(body: unknown) {+ return vi.spyOn(httpClient, 'sendRequest').mockResolvedValue({ status: 200, headers: {}, body });+}++describe('quickbooksAuth.getConnectionIdentifier', () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ it('returns the company name for the connected company', async () => {+ const sendRequest = mockCompanyInfo({ CompanyInfo: { CompanyName: 'Acme Ltd', Email: { Address: '[email protected]' } } });++ expect(await resolveIdentifier(' 123 ')).toBe('Acme Ltd');+ expect(sendRequest).toHaveBeenCalledWith(+ expect.objectContaining({+ url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/123/companyinfo/123',+ queryParams: { minorversion: '75' },+ headers: { Authorization: 'Bearer token', Accept: 'application/json' },+ }),+ );+ });++ it('falls back to the legal name, then the company email', async () => {+ mockCompanyInfo({ CompanyInfo: { LegalName: 'Acme Holdings LLC', Email: { Address: '[email protected]' } } });+ expect(await resolveIdentifier('123')).toBe('Acme Holdings LLC');++ mockCompanyInfo({ CompanyInfo: { Email: { Address: '[email protected]' } } });+ expect(await resolveIdentifier('123')).toBe('[email protected]');+ });++ it('makes no request when the connection has no company ID', async () => {+ const sendRequest = mockCompanyInfo({});++ expect(await resolveIdentifier('')).toBeUndefined();+ expect(await resolveIdentifier(undefined)).toBeUndefined();+ expect(sendRequest).not.toHaveBeenCalled();+ });++ it('returns undefined instead of throwing when the API call fails', async () => {+ vi.spyOn(httpClient, 'sendRequest').mockRejectedValue(new Error('403 Forbidden'));++ expect(await resolveIdentifier('123')).toBeUndefined();+ });+});diff --git a/packages/pieces/community/quickbooks-sandbox/src/lib/auth.ts b/packages/pieces/community/quickbooks-sandbox/src/lib/auth.tsindex 7641fe26b80..ec39015d0bb 100644--- a/packages/pieces/community/quickbooks-sandbox/src/lib/auth.ts+++ b/packages/pieces/community/quickbooks-sandbox/src/lib/auth.ts@@ -1,4 +1,6 @@import { PieceAuth, Property } from '@activepieces/pieces-framework';+import { httpClient, HttpMethod } from '@activepieces/pieces-common';+import { quickbooksCommon } from './common';export const quickbooksAuth = PieceAuth.OAuth2({description: 'Connects a QuickBooks **Sandbox** company. You can find Company ID under **settings->Additional Info**.',@@ -11,4 +13,33 @@ export const quickbooksAuth = PieceAuth.OAuth2({authUrl: 'https://appcenter.intuit.com/connect/oauth2',tokenUrl: 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer',scope: ['com.intuit.quickbooks.accounting'],+ getConnectionIdentifier: async ({ auth }) => {+ const rawCompanyId = auth.props?.['companyId'];+ const companyId = typeof rawCompanyId === 'string' ? rawCompanyId.trim() : '';+ if (!companyId) {+ return undefined;+ }+ try {+ const response = await httpClient.sendRequest<{ CompanyInfo?: QuickbooksCompanyInfo }>({+ method: HttpMethod.GET,+ url: `${quickbooksCommon.getApiUrl(companyId)}/companyinfo/${companyId}`,+ queryParams: { minorversion: quickbooksCommon.minorVersion },+ headers: {+ Authorization: `Bearer ${auth.access_token}`,+ Accept: 'application/json',+ },+ timeout: 5000,+ });+ const info = response.body.CompanyInfo;+ return info?.CompanyName || info?.LegalName || info?.Email?.Address || undefined;+ } catch {+ return undefined;+ }+ },});++type QuickbooksCompanyInfo = {+ CompanyName?: string;+ LegalName?: string;+ Email?: { Address?: string };+};diff --git a/packages/pieces/community/quickbooks-sandbox/vitest.config.ts b/packages/pieces/community/quickbooks-sandbox/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/community/quickbooks-sandbox/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})diff --git a/packages/pieces/community/quickbooks/package.json b/packages/pieces/community/quickbooks/package.jsonindex 6f6a577bd6f..f00d44180cc 100644--- a/packages/pieces/community/quickbooks/package.json+++ b/packages/pieces/community/quickbooks/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-quickbooks",- "version": "0.3.1",+ "version": "0.3.2","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -16,6 +17,7 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/quickbooks/src/lib/auth.test.ts b/packages/pieces/community/quickbooks/src/lib/auth.test.tsnew file mode 100644index 00000000000..80aace54337--- /dev/null+++ b/packages/pieces/community/quickbooks/src/lib/auth.test.ts@@ -0,0 +1,54 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { httpClient } from '@activepieces/pieces-common';+import { quickbooksAuth } from './auth';++const server = { apiUrl: 'http://127.0.0.1:4200/api/', publicUrl: 'http://127.0.0.1:4200/api/' };++function resolveIdentifier(companyId: unknown) {+ return quickbooksAuth.getConnectionIdentifier?.({ auth: { access_token: 'token', data: {}, props: { companyId } }, server });+}++function mockCompanyInfo(body: unknown) {+ return vi.spyOn(httpClient, 'sendRequest').mockResolvedValue({ status: 200, headers: {}, body });+}++describe('quickbooksAuth.getConnectionIdentifier', () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ it('returns the company name for the connected company', async () => {+ const sendRequest = mockCompanyInfo({ CompanyInfo: { CompanyName: 'Acme Ltd', Email: { Address: '[email protected]' } } });++ expect(await resolveIdentifier(' 123 ')).toBe('Acme Ltd');+ expect(sendRequest).toHaveBeenCalledWith(+ expect.objectContaining({+ url: 'https://quickbooks.api.intuit.com/v3/company/123/companyinfo/123',+ queryParams: { minorversion: '75' },+ headers: { Authorization: 'Bearer token', Accept: 'application/json' },+ }),+ );+ });++ it('falls back to the legal name, then the company email', async () => {+ mockCompanyInfo({ CompanyInfo: { LegalName: 'Acme Holdings LLC', Email: { Address: '[email protected]' } } });+ expect(await resolveIdentifier('123')).toBe('Acme Holdings LLC');++ mockCompanyInfo({ CompanyInfo: { Email: { Address: '[email protected]' } } });+ expect(await resolveIdentifier('123')).toBe('[email protected]');+ });++ it('makes no request when the connection has no company ID', async () => {+ const sendRequest = mockCompanyInfo({});++ expect(await resolveIdentifier('')).toBeUndefined();+ expect(await resolveIdentifier(undefined)).toBeUndefined();+ expect(sendRequest).not.toHaveBeenCalled();+ });++ it('returns undefined instead of throwing when the API call fails', async () => {+ vi.spyOn(httpClient, 'sendRequest').mockRejectedValue(new Error('403 Forbidden'));++ expect(await resolveIdentifier('123')).toBeUndefined();+ });+});diff --git a/packages/pieces/community/quickbooks/src/lib/auth.ts b/packages/pieces/community/quickbooks/src/lib/auth.tsindex 5c948b42eff..2c196cd7149 100644--- a/packages/pieces/community/quickbooks/src/lib/auth.ts+++ b/packages/pieces/community/quickbooks/src/lib/auth.ts@@ -1,4 +1,6 @@import { PieceAuth, Property } from '@activepieces/pieces-framework';+import { httpClient, HttpMethod } from '@activepieces/pieces-common';+import { quickbooksCommon } from './common';export const quickbooksAuth = PieceAuth.OAuth2({description: 'You can find Company ID under **settings->Additional Info**.',@@ -11,4 +13,33 @@ export const quickbooksAuth = PieceAuth.OAuth2({authUrl: 'https://appcenter.intuit.com/connect/oauth2',tokenUrl: 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer',scope: ['com.intuit.quickbooks.accounting'],+ getConnectionIdentifier: async ({ auth }) => {+ const rawCompanyId = auth.props?.['companyId'];+ const companyId = typeof rawCompanyId === 'string' ? rawCompanyId.trim() : '';+ if (!companyId) {+ return undefined;+ }+ try {+ const response = await httpClient.sendRequest<{ CompanyInfo?: QuickbooksCompanyInfo }>({+ method: HttpMethod.GET,+ url: `${quickbooksCommon.getApiUrl(companyId)}/companyinfo/${companyId}`,+ queryParams: { minorversion: quickbooksCommon.minorVersion },+ headers: {+ Authorization: `Bearer ${auth.access_token}`,+ Accept: 'application/json',+ },+ timeout: 5000,+ });+ const info = response.body.CompanyInfo;+ return info?.CompanyName || info?.LegalName || info?.Email?.Address || undefined;+ } catch {+ return undefined;+ }+ },});++type QuickbooksCompanyInfo = {+ CompanyName?: string;+ LegalName?: string;+ Email?: { Address?: string };+};diff --git a/packages/pieces/community/quickbooks/vitest.config.ts b/packages/pieces/community/quickbooks/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/community/quickbooks/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})diff --git a/packages/pieces/community/salesforce/package.json b/packages/pieces/community/salesforce/package.jsonindex 4614f70a51b..2310d351a2d 100644--- a/packages/pieces/community/salesforce/package.json+++ b/packages/pieces/community/salesforce/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-salesforce",- "version": "0.9.1",+ "version": "0.9.2","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -17,6 +18,7 @@"@activepieces/core-utils": "workspace:*"},"devDependencies": {- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/salesforce/src/index.ts b/packages/pieces/community/salesforce/src/index.tsindex a0e11ea37cc..4f0f210aa24 100644--- a/packages/pieces/community/salesforce/src/index.ts+++ b/packages/pieces/community/salesforce/src/index.ts@@ -5,7 +5,7 @@ import {OAuth2PropertyValue,} from '@activepieces/pieces-framework';import { PieceCategory } from '@activepieces/pieces-framework';-import { createCustomApiCallAction } from '@activepieces/pieces-common';+import { createCustomApiCallAction, httpClient, HttpMethod } from '@activepieces/pieces-common';import { addContactToCampaign } from './lib/action/add-contact-to-campaign';import { addFileToRecord } from './lib/action/add-file-to-record';@@ -138,6 +138,26 @@ export const salesforceAuth = PieceAuth.OAuth2({scope: ['refresh_token', 'full', 'api'],pkce: true,pkceMethod: 'S256',+ getConnectionIdentifier: async ({ auth }) => {+ const identityUrl = auth.data['id'];+ if (typeof identityUrl !== 'string' || !identityUrl.startsWith('https://')) {+ return undefined;+ }+ try {+ const response = await httpClient.sendRequest<{ email?: string; username?: string }>({+ method: HttpMethod.GET,+ url: identityUrl,+ headers: {+ Authorization: `Bearer ${auth.access_token}`,+ Accept: 'application/json',+ },+ timeout: 5000,+ });+ return response.body.email || response.body.username || undefined;+ } catch {+ return undefined;+ }+ },});export const salesforce = createPiece({diff --git a/packages/pieces/community/salesforce/src/lib/auth.test.ts b/packages/pieces/community/salesforce/src/lib/auth.test.tsnew file mode 100644index 00000000000..f5fd356a876--- /dev/null+++ b/packages/pieces/community/salesforce/src/lib/auth.test.ts@@ -0,0 +1,52 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import { httpClient } from '@activepieces/pieces-common';+import { salesforceAuth } from '../index';++const server = { apiUrl: 'http://127.0.0.1:4200/api/', publicUrl: 'http://127.0.0.1:4200/api/' };+const identityUrl = 'https://login.salesforce.com/id/00Dxx0000001gPL/005xx000001X8Uz';++function resolveIdentifier(data: Record<string, unknown>) {+ return salesforceAuth.getConnectionIdentifier?.({ auth: { access_token: 'token', data }, server });+}++function mockIdentity(body: unknown) {+ return vi.spyOn(httpClient, 'sendRequest').mockResolvedValue({ status: 200, headers: {}, body });+}++describe('salesforceAuth.getConnectionIdentifier', () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ it('returns the email from the identity URL in the token response', async () => {+ const sendRequest = mockIdentity({ email: '[email protected]', username: '[email protected]' });++ expect(await resolveIdentifier({ id: identityUrl, instance_url: 'https://acme.my.salesforce.com' })).toBe('[email protected]');+ expect(sendRequest).toHaveBeenCalledWith(+ expect.objectContaining({+ url: identityUrl,+ headers: { Authorization: 'Bearer token', Accept: 'application/json' },+ }),+ );+ });++ it('falls back to the username when the identity has no email', async () => {+ mockIdentity({ username: '[email protected]' });++ expect(await resolveIdentifier({ id: identityUrl })).toBe('[email protected]');+ });++ it('makes no request when the token response has no https identity URL', async () => {+ const sendRequest = mockIdentity({});++ expect(await resolveIdentifier({})).toBeUndefined();+ expect(await resolveIdentifier({ id: 'http://example.test/id' })).toBeUndefined();+ expect(sendRequest).not.toHaveBeenCalled();+ });++ it('returns undefined instead of throwing when the identity call fails', async () => {+ vi.spyOn(httpClient, 'sendRequest').mockRejectedValue(new Error('403 Bad_OAuth_Token'));++ expect(await resolveIdentifier({ id: identityUrl })).toBeUndefined();+ });+});diff --git a/packages/pieces/community/salesforce/vitest.config.ts b/packages/pieces/community/salesforce/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/community/salesforce/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})