diff --git a/.gitignore b/.gitignore index dc44617ad7a..e3b967e8ed5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. +pieces-cache-db-*.sqlite + # compiled output dist tmp diff --git a/packages/pieces/community/framework/src/lib/piece-metadata.ts b/packages/pieces/community/framework/src/lib/piece-metadata.ts index 2a0f37427ce..cb941d2ba98 100644 --- a/packages/pieces/community/framework/src/lib/piece-metadata.ts +++ b/packages/pieces/community/framework/src/lib/piece-metadata.ts @@ -14,7 +14,6 @@ export const PieceBase = Type.Object({ displayName: Type.String(), logoUrl: Type.String(), description: Type.String(), - projectId: Type.Optional(Type.String()), authors: Type.Array(Type.String()), platformId: Type.Optional(Type.String()), directoryPath: Type.Optional(Type.String()), @@ -32,7 +31,6 @@ export type PieceBase = { displayName: string; logoUrl: string; description: string; - projectId?: ProjectId; platformId?: string; authors: string[], directoryPath?: string; diff --git a/packages/react-ui/src/app/components/project-settings/pieces/index.tsx b/packages/react-ui/src/app/components/project-settings/pieces/index.tsx index 52f92088c6e..64daf8b1ec8 100644 --- a/packages/react-ui/src/app/components/project-settings/pieces/index.tsx +++ b/packages/react-ui/src/app/components/project-settings/pieces/index.tsx @@ -96,8 +96,7 @@ const columns: ColumnDef>[] = [ header: ({ column }) => , cell: ({ row }) => { if ( - row.original.pieceType !== PieceType.CUSTOM || - isNil(row.original.projectId) + row.original.pieceType !== PieceType.CUSTOM ) { return null; } diff --git a/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-controller.ts b/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-controller.ts index 04a02f5fd16..d1683da87ee 100644 --- a/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-controller.ts +++ b/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-controller.ts @@ -1,30 +1,20 @@ import { - ApplicationEventName, ResetPasswordRequestBody, VerifyEmailRequestBody } from '@activepieces/ee-shared' import { securityAccess } from '@activepieces/server-shared' import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox' -import { applicationEvents } from '../../../helper/application-events' import { enterpriseLocalAuthnService } from './enterprise-local-authn-service' export const enterpriseLocalAuthnController: FastifyPluginAsyncTypebox = async ( app, ) => { app.post('/verify-email', VerifyEmailRequest, async (req) => { - applicationEvents(req.log).sendUserEvent(req, { - action: ApplicationEventName.USER_EMAIL_VERIFIED, - data: {}, - }) await enterpriseLocalAuthnService(req.log).verifyEmail(req.body) }) app.post('/reset-password', ResetPasswordRequest, async (req) => { - applicationEvents(req.log).sendUserEvent(req, { - action: ApplicationEventName.USER_PASSWORD_RESET, - data: {}, - }) await enterpriseLocalAuthnService(req.log).resetPassword(req.body) - }) + }) } const VerifyEmailRequest = { @@ -43,4 +33,4 @@ const ResetPasswordRequest = { schema: { body: ResetPasswordRequestBody, }, -} +} \ No newline at end of file diff --git a/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-service.ts b/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-service.ts index d9779efb9bb..08147d63359 100644 --- a/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-service.ts +++ b/packages/server/api/src/app/ee/authentication/enterprise-local-authn/enterprise-local-authn-service.ts @@ -1,22 +1,37 @@ import { + ApplicationEvent, + ApplicationEventName, OtpType, ResetPasswordRequestBody, VerifyEmailRequestBody, } from '@activepieces/ee-shared' -import { ActivepiecesError, ErrorCode, UserId, UserIdentity } from '@activepieces/shared' +import { ActivepiecesError, ErrorCode, isNil, UserId, UserIdentity } from '@activepieces/shared' import { FastifyBaseLogger } from 'fastify' import { userIdentityService } from '../../../authentication/user-identity/user-identity-service' +import { applicationEvents } from '../../../helper/application-events' +import { userService } from '../../../user/user-service' import { otpService } from '../otp/otp-service' export const enterpriseLocalAuthnService = (log: FastifyBaseLogger) => ({ async verifyEmail({ identityId, otp }: VerifyEmailRequestBody): Promise { - await confirmOtp({ + const isOtpValid = await otpService(log).confirm({ identityId, - otp, - otpType: OtpType.EMAIL_VERIFICATION, - log, + type: OtpType.EMAIL_VERIFICATION, + value: otp, }) + if (!isOtpValid) { + throw new ActivepiecesError({ + code: ErrorCode.INVALID_OTP, + params: {}, + }) + } + + await sendAuditLogForIdentity(identityId, { + action: ApplicationEventName.USER_EMAIL_VERIFIED, + data: {}, + }, log) + return userIdentityService(log).verify(identityId) }, @@ -25,13 +40,24 @@ export const enterpriseLocalAuthnService = (log: FastifyBaseLogger) => ({ otp, newPassword, }: ResetPasswordRequestBody): Promise { - await confirmOtp({ + const isOtpValid = await otpService(log).confirm({ identityId, - otp, - otpType: OtpType.PASSWORD_RESET, - log, + type: OtpType.PASSWORD_RESET, + value: otp, }) + if (!isOtpValid) { + throw new ActivepiecesError({ + code: ErrorCode.INVALID_OTP, + params: {}, + }) + } + + await sendAuditLogForIdentity(identityId, { + action: ApplicationEventName.USER_PASSWORD_RESET, + data: {}, + }, log) + await userIdentityService(log).updatePassword({ id: identityId, newPassword, @@ -39,29 +65,22 @@ export const enterpriseLocalAuthnService = (log: FastifyBaseLogger) => ({ }, }) -const confirmOtp = async ({ - identityId, - otp, - otpType, - log, -}: ConfirmOtpParams): Promise => { - const isOtpValid = await otpService(log).confirm({ - identityId, - type: otpType, - value: otp, - }) - - if (!isOtpValid) { - throw new ActivepiecesError({ - code: ErrorCode.INVALID_OTP, - params: {}, - }) +const sendAuditLogForIdentity = async ( + identityId: UserId, + event: Pick, + log: FastifyBaseLogger, +): Promise => { + const users = await userService.getUsersByIdentityId({ identityId }) + for (const { id, platformId } of users) { + if (isNil(platformId)) { + continue + } + applicationEvents(log).sendUserEvent( + { + platformId, + userId: id, + }, + event as ApplicationEvent, + ) } -} - -type ConfirmOtpParams = { - identityId: UserId - otp: string - otpType: OtpType - log: FastifyBaseLogger -} +} \ No newline at end of file diff --git a/packages/server/api/src/app/flows/flow-version/migrations/index.ts b/packages/server/api/src/app/flows/flow-version/migrations/index.ts index d9c7d7a515b..3299b994144 100644 --- a/packages/server/api/src/app/flows/flow-version/migrations/index.ts +++ b/packages/server/api/src/app/flows/flow-version/migrations/index.ts @@ -51,12 +51,12 @@ export const flowMigrations = { }, } -export const migrateFlowVersionTemplate = async ({ trigger, schemaVersion, notes, valid }: Pick): Promise => { +export const migrateFlowVersionTemplate = async ({ trigger, schemaVersion, notes, valid, displayName }: Pick): Promise => { return flowMigrations.apply({ agentIds: [], connectionIds: [], created: new Date().toISOString(), - displayName: '', + displayName, flowId: '', id: '', updated: new Date().toISOString(), diff --git a/packages/server/api/src/app/flows/flow/flow.controller.ts b/packages/server/api/src/app/flows/flow/flow.controller.ts index 3c3139b3814..71a32b10348 100644 --- a/packages/server/api/src/app/flows/flow/flow.controller.ts +++ b/packages/server/api/src/app/flows/flow/flow.controller.ts @@ -82,6 +82,7 @@ export const flowController: FastifyPluginAsyncTypebox = async (app) => { preValidation: async (request) => { if (request.body?.type === FlowOperationType.IMPORT_FLOW) { const migratedFlowTemplate = await migrateFlowVersionTemplate({ + displayName: request.body.request.displayName, trigger: request.body.request.trigger, schemaVersion: request.body.request.schemaVersion, notes: request.body.request.notes ?? [], @@ -89,6 +90,7 @@ export const flowController: FastifyPluginAsyncTypebox = async (app) => { }) request.body.request = { ...request.body.request, + displayName: migratedFlowTemplate.displayName, trigger: migratedFlowTemplate.trigger, schemaVersion: migratedFlowTemplate.schemaVersion, notes: migratedFlowTemplate.notes, diff --git a/packages/server/api/src/app/pieces/metadata/local-piece-cache.ts b/packages/server/api/src/app/pieces/metadata/local-piece-cache.ts index 38c51b458fb..035386151e3 100644 --- a/packages/server/api/src/app/pieces/metadata/local-piece-cache.ts +++ b/packages/server/api/src/app/pieces/metadata/local-piece-cache.ts @@ -1,7 +1,6 @@ import path from 'path' -import { pieceTranslation } from '@activepieces/pieces-framework' import { AppSystemProp, filePiecesUtils, memoryLock, rejectedPromiseHandler } from '@activepieces/server-shared' -import { ApEnvironment, apId, isEmpty, isNil, LocalesEnum, PackageType, PieceType } from '@activepieces/shared' +import { ApEnvironment, apId, isEmpty, isNil, PackageType, PieceType } from '@activepieces/shared' import KeyvSqlite from '@keyv/sqlite' import dayjs from 'dayjs' import { FastifyBaseLogger } from 'fastify' @@ -20,9 +19,8 @@ export const REDIS_REFRESH_LOCAL_PIECES_CHANNEL = 'refresh-local-pieces-cache' const META_REGISTRY_KEY = 'pieces:registry' const META_STATE_KEY = 'pieces:state' -const META_LIST_KEY = (locale: LocalesEnum) => `pieces:list:${locale}` -const META_PIECE_KEY = (pieceName: string, version: string, locale: LocalesEnum) => `pieces:piece:${pieceName}:${version}:${locale}` -const DEFAULT_LOCALE = LocalesEnum.ENGLISH +const META_LIST_KEY = 'pieces:list' +const META_PIECE_KEY = (pieceName: string, version: string, platformId: string | undefined) => `pieces:piece:${pieceName}:${version}:${platformId ?? 'OFFICIAL'}` let cacheInstance: KVCacheInstance | null = null @@ -30,7 +28,7 @@ let cacheInstance: KVCacheInstance | null = null export const localPieceCache = (log: FastifyBaseLogger) => ({ async setup(): Promise { await getOrCreateCache() - rejectedPromiseHandler(updateCache(log), log) + await updateCache(log) cron.schedule('*/15 * * * *', () => { log.info('[localPieceCache] Refreshing pieces cache via cron job') rejectedPromiseHandler(updateCache(log), log) @@ -44,42 +42,34 @@ export const localPieceCache = (log: FastifyBaseLogger) => ({ await updateCache(log) }, async getList(params: GetListParams): Promise { - const { locale, platformId } = params + const { platformId } = params if (environment === ApEnvironment.TESTING) { const pieces = await fetchPiecesFromDB() return lastVersionOfEachPiece(pieces) .filter((piece) => filterPieceBasedOnType(platformId, piece)) - .map(piece => pieceTranslation.translatePiece(piece, locale)) } const cache = await getOrCreateCache() - const list = (await cache.db.get(META_LIST_KEY(locale ?? DEFAULT_LOCALE))) as PieceMetadataSchema[] | undefined - const devPieces = (await loadDevPiecesIfEnabled(log)).map(piece => pieceTranslation.translatePiece(piece, locale)) + const list = (await cache.db.get(META_LIST_KEY)) as PieceMetadataSchema[] | undefined + const devPieces = await loadDevPiecesIfEnabled(log) return [...(list ?? []), ...devPieces].filter((piece) => filterPieceBasedOnType(platformId, piece)) }, async getPieceVersion(params: GetPieceVersionParams): Promise { - const { pieceName, version, locale, platformId } = params + const { pieceName, version, platformId } = params if (environment === ApEnvironment.TESTING) { const pieces = await fetchPiecesFromDB() - const piece = pieces.find(p => p.name === pieceName && p.version === version) - if (!piece) { - return null - } - return locale ? pieceTranslation.translatePiece(piece, locale) : piece + return pieces.find(p => p.name === pieceName && p.version === version) ?? null } const cache = await getOrCreateCache() - const piece = (await cache.db.get(META_PIECE_KEY(pieceName, version, locale ?? DEFAULT_LOCALE))) as PieceMetadataSchema | undefined + const cachedPiece = (await cache.db.get(META_PIECE_KEY(pieceName, version, platformId))) as PieceMetadataSchema | undefined const devPieces = await loadDevPiecesIfEnabled(log) const devPiece = devPieces.find(p => p.name === pieceName && p.version === version) if (!isNil(devPiece)) { - return locale ? pieceTranslation.translatePiece(devPiece, locale ?? DEFAULT_LOCALE) : devPiece + return devPiece } - if (isNil(piece)) { - return null - } - return filterPieceBasedOnType(platformId, piece) ? piece : null + return cachedPiece ?? null }, async getRegistry(params: GetRegistryParams): Promise { - const { release } = params + const { release, platformId } = params if (environment === ApEnvironment.TESTING) { const pieces = await fetchPiecesFromDB() return pieces.map(piece => ({ @@ -88,6 +78,7 @@ export const localPieceCache = (log: FastifyBaseLogger) => ({ minimumSupportedRelease: piece.minimumSupportedRelease, maximumSupportedRelease: piece.maximumSupportedRelease, platformId: piece.platformId, + pieceType: piece.pieceType, })) } const cache = await getOrCreateCache() @@ -97,8 +88,11 @@ export const localPieceCache = (log: FastifyBaseLogger) => ({ minimumSupportedRelease: piece.minimumSupportedRelease, maximumSupportedRelease: piece.maximumSupportedRelease, platformId: piece.platformId, + pieceType: piece.pieceType, })) - return [...cache.registry, ...devPieces].filter((piece) => isNil(release) || isSupportedRelease(release, piece)) + return [...cache.registry, ...devPieces] + .filter((piece) => filterPieceBasedOnType(platformId, piece)) + .filter((piece) => isNil(release) || isSupportedRelease(release, piece)) }, }) @@ -161,20 +155,23 @@ function sortByNameAndVersionDesc(a: PieceMetadataSchema, b: PieceMetadataSchema async function populateCache(sortedPieces: PieceMetadataSchema[], log: FastifyBaseLogger): Promise { const cache = await getOrCreateCache() const { db } = cache - cache.registry = sortedPieces.filter(piece => isOfficialPiece(piece)).map(piece => ({ + cache.registry = sortedPieces.map(piece => ({ name: piece.name, version: piece.version, minimumSupportedRelease: piece.minimumSupportedRelease, maximumSupportedRelease: piece.maximumSupportedRelease, + pieceType: piece.pieceType, + platformId: piece.platformId, })) await db.set(META_REGISTRY_KEY, cache.registry) await storePieces(sortedPieces) + log.info({ sortedPieces: sortedPieces.length }, '[populateCache] Storing pieces') + const startTime = Date.now() for (const piece of sortedPieces) { await storePiece(piece) } - const state: State = { recentUpdate: sortedPieces.length > 0 ? new Date(Math.max(...sortedPieces.map(piece => dayjs(piece.updated).valueOf()))).toISOString() : undefined, count: sortedPieces.length.toString(), @@ -182,27 +179,19 @@ async function populateCache(sortedPieces: PieceMetadataSchema[], log: FastifyBa await db.set(META_STATE_KEY, state) log.info({ count: sortedPieces.length, + duration: Date.now() - startTime, }, '[populateCache] Stored pieces cache') } async function storePieces(sortedPieces: PieceMetadataSchema[]): Promise { const { db } = await getOrCreateCache() const latestVersions = sortedPieces.filter((piece, index, self) => index === self.findIndex((t) => t.name === piece.name)) - - const locales = Object.values(LocalesEnum) as LocalesEnum[] - for (const locale of locales) { - const translatedLatestVersions = latestVersions.map((p) => pieceTranslation.translatePiece(p, locale)) - await db.set(META_LIST_KEY(locale), translatedLatestVersions) - } + await db.set(META_LIST_KEY, latestVersions) } async function storePiece(piece: PieceMetadataSchema): Promise { const { db } = await getOrCreateCache() - const locales = Object.values(LocalesEnum) as LocalesEnum[] - for (const locale of locales) { - const translatedPiece = pieceTranslation.translatePiece(piece, locale) - await db.set(META_PIECE_KEY(piece.name, piece.version, locale), translatedPiece) - } + await db.set(META_PIECE_KEY(piece.name, piece.version, piece.platformId), piece) } async function loadDevPiecesIfEnabled(log: FastifyBaseLogger): Promise { @@ -252,19 +241,19 @@ async function getOrCreateCache(): Promise { } -function filterPieceBasedOnType(platformId: string | undefined, piece: PieceMetadataSchema): boolean { +function filterPieceBasedOnType(platformId: string | undefined, piece: PieceMetadataSchema | PieceRegistryEntry): boolean { return isOfficialPiece(piece) || isCustomPiece(platformId, piece) } -function isOfficialPiece(piece: PieceMetadataSchema): boolean { - return piece.pieceType === PieceType.OFFICIAL && isNil(piece.projectId) && isNil(piece.platformId) +function isOfficialPiece(piece: PieceMetadataSchema | PieceRegistryEntry): boolean { + return piece.pieceType === PieceType.OFFICIAL && isNil(piece.platformId) } -function isCustomPiece(platformId: string | undefined, piece: PieceMetadataSchema): boolean { +function isCustomPiece(platformId: string | undefined, piece: PieceMetadataSchema | PieceRegistryEntry): boolean { if (isNil(platformId)) { return false } - return piece.platformId === platformId && isNil(piece.projectId) && piece.pieceType === PieceType.CUSTOM + return piece.platformId === platformId && piece.pieceType === PieceType.CUSTOM } @@ -295,10 +284,11 @@ type GetPieceVersionParams = { pieceName: string version: string platformId?: string - locale?: LocalesEnum } type PieceRegistryEntry = { + platformId?: string + pieceType: PieceType name: string version: string minimumSupportedRelease?: string @@ -307,11 +297,11 @@ type PieceRegistryEntry = { type GetListParams = { platformId?: string - locale: LocalesEnum } type GetRegistryParams = { release: string | undefined + platformId?: string } type KVCacheInstance = { diff --git a/packages/server/api/src/app/pieces/metadata/piece-metadata-controller.ts b/packages/server/api/src/app/pieces/metadata/piece-metadata-controller.ts index 25511a77d20..7eea30c5afb 100644 --- a/packages/server/api/src/app/pieces/metadata/piece-metadata-controller.ts +++ b/packages/server/api/src/app/pieces/metadata/piece-metadata-controller.ts @@ -39,6 +39,12 @@ const basePiecesController: FastifyPluginAsyncTypebox = async (app) => { }, ) + app.get('/versions', {}, async () => { + return { + + } + }) + app.get('/', ListPiecesRequest, async (req): Promise => { const query = req.query const includeTags = query.includeTags ?? false diff --git a/packages/server/api/src/app/pieces/metadata/piece-metadata-service.ts b/packages/server/api/src/app/pieces/metadata/piece-metadata-service.ts index 2c53472459a..41c45c70e8b 100644 --- a/packages/server/api/src/app/pieces/metadata/piece-metadata-service.ts +++ b/packages/server/api/src/app/pieces/metadata/piece-metadata-service.ts @@ -38,11 +38,11 @@ export const pieceMetadataService = (log: FastifyBaseLogger) => { }, async list(params: ListParams): Promise { const originalPieces = await localPieceCache(log).getList({ - locale: params.locale ?? LocalesEnum.ENGLISH, platformId: params.platformId, }) const piecesWithTags = await enrichTags(params.platformId, originalPieces, params.includeTags) - const translatedPieces = piecesWithTags.map((piece) => pieceTranslation.translatePiece(piece, params.locale)) + const locale = params.locale ?? LocalesEnum.ENGLISH + const translatedPieces = piecesWithTags.map((piece) => pieceTranslation.translatePiece(piece, locale)) const filteredPieces = await pieceListUtils.filterPieces({ ...params, pieces: translatedPieces, @@ -59,29 +59,14 @@ export const pieceMetadataService = (log: FastifyBaseLogger) => { })) }, async get({ projectId, platformId, version, name }: GetOrThrowParams): Promise { - const versionToSearch = findNextExcludedVersion(version) - const registry = await localPieceCache(log).getRegistry({ release: undefined }) - const matchingRegistryEntries = registry.filter((entry) => { - if (entry.name !== name) { - return false - } - if (isNil(versionToSearch)) { - return true - } - return semVer.compare(entry.version, versionToSearch.nextExcludedVersion) < 0 - && semVer.compare(entry.version, versionToSearch.baseVersion) >= 0 - }) - - if (matchingRegistryEntries.length === 0) { + const bestMatch = await findExactVersion(log, { name, version, platformId }) + if (isNil(bestMatch)) { return undefined } - - const sortedEntries = matchingRegistryEntries.sort(sortByVersionDescending) - const bestMatch = sortedEntries[0] const piece = await localPieceCache(log).getPieceVersion({ pieceName: bestMatch.name, version: bestMatch.version, - platformId, + platformId: bestMatch.platformId, }) if (isNil(piece)) { @@ -108,7 +93,8 @@ export const pieceMetadataService = (log: FastifyBaseLogger) => { }, }) } - return pieceTranslation.translatePiece(piece, locale) + const resolvedLocale = locale ?? LocalesEnum.ENGLISH + return pieceTranslation.translatePiece(piece, resolvedLocale) }, async updateUsage({ id, usage }: UpdateUsage): Promise { const existingMetadata = await pieceRepos().findOneByOrFail({ @@ -285,6 +271,36 @@ const sortByVersionDescending = (a: T, b: T): num return semVer.rcompare(a.version, b.version) } +const findExactVersion = async ( + log: FastifyBaseLogger, + params: { name: string, version: string | undefined, platformId: string | undefined }, +): Promise<{ name: string, version: string, platformId: string | undefined } | undefined> => { + const { name, version, platformId } = params + const versionToSearch = findNextExcludedVersion(version) + const registry = await localPieceCache(log).getRegistry({ release: undefined, platformId }) + const matchingRegistryEntries = registry.filter((entry) => { + if (entry.name !== name) { + return false + } + if (isNil(versionToSearch)) { + return true + } + return semVer.compare(entry.version, versionToSearch.nextExcludedVersion) < 0 + && semVer.compare(entry.version, versionToSearch.baseVersion) >= 0 + }) + + if (matchingRegistryEntries.length === 0) { + return undefined + } + + const sortedEntries = matchingRegistryEntries.sort(sortByVersionDescending) + return { + name: sortedEntries[0].name, + version: sortedEntries[0].version, + platformId: sortedEntries[0].platformId, + } +} + const findNextExcludedVersion = (version: string | undefined): { baseVersion: string, nextExcludedVersion: string } | undefined => { if (version?.startsWith('^')) { const baseVersion = version.substring(1) diff --git a/packages/server/api/src/app/user/user-service.ts b/packages/server/api/src/app/user/user-service.ts index 2149dc0a5fc..f1cf02bd985 100644 --- a/packages/server/api/src/app/user/user-service.ts +++ b/packages/server/api/src/app/user/user-service.ts @@ -125,6 +125,9 @@ export const userService = { const usersWithMetaInformation = await Promise.all(data.map(this.getMetaInformation)) return paginationHelper.createPage(usersWithMetaInformation, cursor) }, + async getUsersByIdentityId({ identityId }: GetUsersByIdentityIdParams): Promise[]> { + return userRepo().find({ where: { identityId } }).then((users) => users.map((user) => ({ id: user.id, platformId: user.platformId }))) + }, async getOneByIdentityIdOnly({ identityId }: GetOneByIdentityIdOnlyParams): Promise { return userRepo().findOneBy({ identityId }) }, @@ -296,6 +299,9 @@ type CreateParams = { externalId?: string platformRole: PlatformRole } +type GetUsersByIdentityIdParams = { + identityId: string +} type NewUser = Omit diff --git a/packages/server/api/test/helpers/mocks/index.ts b/packages/server/api/test/helpers/mocks/index.ts index 979a85c92a8..f51a9a89141 100644 --- a/packages/server/api/test/helpers/mocks/index.ts +++ b/packages/server/api/test/helpers/mocks/index.ts @@ -402,7 +402,6 @@ export const createMockPieceMetadata = ( displayName: pieceMetadata?.displayName ?? faker.lorem.word(), logoUrl: pieceMetadata?.logoUrl ?? faker.image.urlPlaceholder(), description: pieceMetadata?.description ?? faker.lorem.sentence(), - projectId: pieceMetadata?.projectId, directoryPath: pieceMetadata?.directoryPath, auth: pieceMetadata?.auth, authors: pieceMetadata?.authors ?? [], diff --git a/packages/server/api/test/integration/cloud/app-connection/app-connection.test.ts b/packages/server/api/test/integration/cloud/app-connection/app-connection.test.ts index bc67c85c78d..af7bf96c78f 100644 --- a/packages/server/api/test/integration/cloud/app-connection/app-connection.test.ts +++ b/packages/server/api/test/integration/cloud/app-connection/app-connection.test.ts @@ -48,7 +48,6 @@ describe('AppConnection API', () => { }) const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -142,7 +141,6 @@ describe('AppConnection API', () => { await databaseConnection().getRepository('project_member').save([mockProjectMember]) const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -207,7 +205,6 @@ describe('AppConnection API', () => { await databaseConnection().getRepository('project_member').save([mockProjectMember]) const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, }) await databaseConnection().getRepository('piece_metadata').save([mockPieceMetadata]) diff --git a/packages/server/api/test/integration/cloud/global-connection/global-connection.test.ts b/packages/server/api/test/integration/cloud/global-connection/global-connection.test.ts index 4f7f34510d2..21fe123afd5 100644 --- a/packages/server/api/test/integration/cloud/global-connection/global-connection.test.ts +++ b/packages/server/api/test/integration/cloud/global-connection/global-connection.test.ts @@ -48,7 +48,6 @@ describe('GlobalConnection API', () => { const { mockPlatform, mockProject, mockOwner } = await setupWithGlobalConnections() const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -105,7 +104,6 @@ describe('GlobalConnection API', () => { }, }) const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, }) await databaseConnection().getRepository('piece_metadata').save([mockPieceMetadata]) @@ -152,10 +150,9 @@ describe('GlobalConnection API', () => { it('Fails if project ids are invalid', async () => { // arrange - const { mockPlatform, mockProject, mockOwner } = await setupWithGlobalConnections() + const { mockPlatform, mockOwner } = await setupWithGlobalConnections() const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -265,7 +262,6 @@ describe('GlobalConnection API', () => { const { mockPlatform, mockProject, mockOwner } = await setupWithGlobalConnections() const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -325,7 +321,6 @@ describe('GlobalConnection API', () => { }, }) const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -395,7 +390,6 @@ describe('GlobalConnection API', () => { const { mockPlatform, mockProject, mockOwner } = await setupWithGlobalConnections() const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -467,7 +461,6 @@ describe('GlobalConnection API', () => { }) const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) @@ -541,7 +534,6 @@ describe('GlobalConnection API', () => { const { mockPlatform, mockProject, mockOwner } = await setupWithGlobalConnections() const mockPieceMetadata = createMockPieceMetadata({ - projectId: mockProject.id, platformId: mockPlatform.id, packageType: PackageType.REGISTRY, }) diff --git a/packages/server/api/test/integration/cloud/piece-metadata/piece-metadata.test.ts b/packages/server/api/test/integration/cloud/piece-metadata/piece-metadata.test.ts index dc1e758eee3..4fda5ec85a9 100644 --- a/packages/server/api/test/integration/cloud/piece-metadata/piece-metadata.test.ts +++ b/packages/server/api/test/integration/cloud/piece-metadata/piece-metadata.test.ts @@ -134,7 +134,6 @@ describe('Piece Metadata API', () => { expect(responseBody.packageType).toBe(mockPieceMetadata.packageType) expect(responseBody.pieceType).toBe(mockPieceMetadata.pieceType) expect(responseBody.platformId).toBe(mockPieceMetadata.platformId) - expect(responseBody.projectId).toBe(mockPieceMetadata.projectId) expect(responseBody.version).toBe(mockPieceMetadata.version) }) })