The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix: frontend build failing after code formatting library update (#21519)
Parship Chowdhury4899f00bc7e0
diff --git a/packages/twenty-client-sdk/src/generate/genql/render/requestTypes/unionType.ts b/packages/twenty-client-sdk/src/generate/genql/render/requestTypes/unionType.tsindex d871b66d621..f5578c7c4a6 100644--- a/packages/twenty-client-sdk/src/generate/genql/render/requestTypes/unionType.ts+++ b/packages/twenty-client-sdk/src/generate/genql/render/requestTypes/unionType.ts@@ -1,6 +1,6 @@// @ts-nocheckimport { GraphQLUnionType } from 'graphql'-import uniq from 'lodash/uniq'+import uniq from 'lodash/uniq.js'import { typeComment } from '../common/comment'import { RenderContext } from '../common/RenderContext'import { requestTypeName } from './requestTypeName'diff --git a/packages/twenty-client-sdk/src/generate/genql/render/typeMap/unionType.ts b/packages/twenty-client-sdk/src/generate/genql/render/typeMap/unionType.tsindex 2288705c2c5..0c34cca52dc 100644--- a/packages/twenty-client-sdk/src/generate/genql/render/typeMap/unionType.ts+++ b/packages/twenty-client-sdk/src/generate/genql/render/typeMap/unionType.ts@@ -2,7 +2,7 @@import { GraphQLUnionType } from 'graphql'import { RenderContext } from '../common/RenderContext'import { FieldMap } from '../../runtime/types'-import uniq from 'lodash/uniq'+import uniq from 'lodash/uniq.js'export const unionType = (type: GraphQLUnionType, _: RenderContext) => {const types = type.getTypes()diff --git a/packages/twenty-client-sdk/src/generate/genql/tasks/clientTasks.ts b/packages/twenty-client-sdk/src/generate/genql/tasks/clientTasks.tsindex 247ffa770e7..1e73b8e359f 100644--- a/packages/twenty-client-sdk/src/generate/genql/tasks/clientTasks.ts+++ b/packages/twenty-client-sdk/src/generate/genql/tasks/clientTasks.ts@@ -1,5 +1,5 @@import { GraphQLEnumType, GraphQLSchema, isEnumType } from 'graphql';-import camelCase from 'lodash/camelCase';+import camelCase from 'lodash/camelCase.js';import { type Config } from '../config';import { ensurePath, writeFileToPath } from '../helpers/files';diff --git a/packages/twenty-client-sdk/vite.config.ts b/packages/twenty-client-sdk/vite.config.tsindex 34016baab31..69691dd82db 100644--- a/packages/twenty-client-sdk/vite.config.ts+++ b/packages/twenty-client-sdk/vite.config.ts@@ -10,6 +10,21 @@ const entries = ['src/generate/index.ts',];+const externalDeps = [+ ...Object.keys(packageJson.dependencies),+ ...Object.keys(packageJson.devDependencies).filter(+ (dep) => dep !== 'twenty-shared',+ ),+ 'node:fs/promises',+ 'node:fs',+ 'node:path',+ 'node:os',+ 'node:url',+];++const isExternal = (id: string) =>+ externalDeps.some((dep) => id === dep || id.startsWith(`${dep}/`));+const entryFileNames = (chunk: any, extension: 'cjs' | 'mjs') => {if (!chunk.isEntry) {throw new Error(@@ -50,17 +65,7 @@ export default defineConfig(() => {outDir: 'dist',lib: { entry: entries, name: 'twenty-client-sdk' },rollupOptions: {- external: [- ...Object.keys((packageJson as any).dependencies || {}),- ...Object.keys((packageJson as any).devDependencies || {}).filter(- (dep: string) => dep !== 'twenty-shared',- ),- 'node:fs/promises',- 'node:fs',- 'node:path',- 'node:os',- 'node:url',- ],+ external: isExternal,output: [{format: 'es',diff --git a/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.ts b/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.tsindex 35d480c3c44..c6ad3843a42 100644--- a/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.ts+++ b/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.ts@@ -1,30 +1,22 @@import { type Page } from '@playwright/test';-const decodeToken = (cookie: any) =>- JSON.parse(decodeURIComponent(cookie.value)).accessOrWorkspaceAgnosticToken- ?.token;-- const decodePayload = (jwt: string) =>- JSON.parse(Buffer.from(jwt.split('.')[1], 'base64url').toString());-+// Mirrors TOKEN_PAIR_LOCAL_STORAGE_KEY from twenty-front+// (packages/twenty-front/src/modules/auth/states/tokenPairState.ts).+// Since #21507 the frontend stores the auth token pair in localStorage+// instead of a cookie.+const TOKEN_PAIR_LOCAL_STORAGE_KEY = 'tokenPairState';export const getAccessAuthToken = async (page: Page) => {const storageState = await page.context().storageState();- const tokenCookies = storageState.cookies.filter(- (cookie) => cookie.name === 'tokenPair',- );- if (!tokenCookies) {- throw new Error('No auth cookie found');+ const tokenPairItem = storageState.origins+ .flatMap((origin) => origin.localStorage)+ .find((item) => item.name === TOKEN_PAIR_LOCAL_STORAGE_KEY);++ if (tokenPairItem === undefined) {+ throw new Error('No auth token pair found in local storage');}- const accessTokenCookie = tokenCookies.find(- (cookie) => {- const payload = decodePayload(decodeToken(cookie) ?? '');- return payload.type === 'ACCESS';- }- );- const token = JSON.parse(decodeURIComponent(accessTokenCookie?.value ?? '')).accessOrWorkspaceAgnosticToken- .token;+ const { accessOrWorkspaceAgnosticToken } = JSON.parse(tokenPairItem.value);- return { authToken: token };+ return { authToken: accessOrWorkspaceAgnosticToken.token };};