Skip to content

Commit

Permalink
Merge pull request #3696 from activepieces/fix/project-members
Browse files Browse the repository at this point in the history
fix: show projects of newly invited users
  • Loading branch information
abuaboud committed Jan 18, 2024
2 parents e9fcbd9 + af4a5bd commit 6c409a6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release-pieces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ jobs:
run: cp .npmrc $HOME/.npmrc

- name: publish shared package
run: npx ts-node tools/scripts/utils/publish-nx-project.ts packages/shared
run: npx ts-node -r tsconfig-paths/register -P packages/engine/tsconfig.lib.json tools/scripts/utils/publish-nx-project.ts packages/shared
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: publish pieces-common package
run: npx ts-node tools/scripts/utils/publish-nx-project.ts packages/pieces/community/common
run: npx ts-node -r tsconfig-paths/register -P packages/engine/tsconfig.lib.json tools/scripts/utils/publish-nx-project.ts packages/pieces/community/common
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: publish pieces-framework package
run: npx ts-node tools/scripts/utils/publish-nx-project.ts packages/pieces/community/framework
run: npx ts-node -r tsconfig-paths/register -P packages/engine/tsconfig.lib.json tools/scripts/utils/publish-nx-project.ts packages/pieces/community/framework
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: publish pieces packages
run: npx ts-node tools/scripts/pieces/publish-pieces-to-npm.ts
run: npx ts-node -r tsconfig-paths/register -P packages/engine/tsconfig.lib.json tools/scripts/pieces/publish-pieces-to-npm.ts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-publishable-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: npm ci --ignore-scripts

- name: validate publishable packages
run: npx ts-node tools/scripts/validate-publishable-packages.ts
run: npx ts-node -r tsconfig-paths/register -P packages/engine/tsconfig.lib.json tools/scripts/validate-publishable-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const getOrCreateUser = async (params: GetOrCreateUserParams): Promise<GetOrCrea
await projectMemberService.upsert({
projectId: project.id,
email: params.externalEmail,
platformId,
role: ProjectMemberRole.EDITOR,
status: ProjectMemberStatus.ACTIVE,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const projectMemberController: FastifyPluginAsyncTypebox = async (app) =>
const { projectMember } = await projectMemberService.upsertAndSend({
...request.body,
projectId: request.principal.projectId,
platformId: request.principal.platform?.id ?? null,
})

await reply.status(StatusCodes.CREATED).send(projectMember)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '@activepieces/shared'
import { paginationHelper } from '../../helper/pagination/pagination-utils'
import {
PlatformId,
ProjectMember,
ProjectMemberId,
ProjectMemberRole,
Expand All @@ -35,11 +34,13 @@ import { jwtUtils } from '../../helper/jwt-utils'
const projectMemberRepo = databaseConnection.getRepository(ProjectMemberEntity)

export const projectMemberService = {
async upsert({ platformId, email, projectId, role, status }: UpsertParams): Promise<ProjectMember> {
async upsert({ email, projectId, role, status }: UpsertParams): Promise<ProjectMember> {
await projectMembersLimit.limit({
projectId,
})

const project = await projectService.getOneOrThrow(projectId)
const platformId = project.platformId ?? null
const existingProjectMember = await projectMemberRepo.findOneBy({
projectId,
email,
Expand All @@ -65,10 +66,8 @@ export const projectMemberService = {
}
},

async upsertAndSend({ platformId, projectId, email, role, status }: UpsertAndSendParams): Promise<UpsertAndSendResponse> {

async upsertAndSend({ projectId, email, role, status }: UpsertAndSendParams): Promise<UpsertAndSendResponse> {
const projectMember = await this.upsert({
platformId,
email,
projectId,
role,
Expand Down Expand Up @@ -219,7 +218,6 @@ const getOrThrow = async (id: string): Promise<ProjectMember> => {

type UpsertParams = {
email: string
platformId: PlatformId | null
projectId: ProjectId
role: ProjectMemberRole
status?: ProjectMemberStatus
Expand All @@ -229,7 +227,6 @@ type NewProjectMember = Omit<ProjectMember, 'created'>

type UpsertAndSendParams = AddProjectMemberRequestBody & {
projectId: ProjectId
platformId: PlatformId | null
}

type AcceptParams = {
Expand Down
25 changes: 15 additions & 10 deletions tools/scripts/utils/piece-script-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,20 @@ export async function findAllPieces(): Promise<PieceMetadata[]> {

async function traverseFolder(folderPath: string): Promise<string[]> {
const paths: string[] = []
const files = await readdir(folderPath)

for (const file of files) {
const filePath = join(folderPath, file)
const fileStats = await stat(filePath)
if (fileStats.isDirectory() && file !== 'node_modules' && file !== 'dist') {
paths.push(...await traverseFolder(filePath))
}
else if (file === 'package.json') {
paths.push(folderPath)
const directoryExists = await stat(folderPath).catch(() => null)

if (directoryExists && directoryExists.isDirectory()) {
const files = await readdir(folderPath)

for (const file of files) {
const filePath = join(folderPath, file)
const fileStats = await stat(filePath)
if (fileStats.isDirectory() && file !== 'node_modules' && file !== 'dist') {
paths.push(...await traverseFolder(filePath))
}
else if (file === 'package.json') {
paths.push(folderPath)
}
}
}
return paths
Expand All @@ -100,6 +104,7 @@ async function loadPieceFromFolder(folderPath: string): Promise<PieceMetadata |
name: packageJson.name,
version: packageJson.version
};
metadata.directoryPath = folderPath;
metadata.name = packageJson.name;
metadata.version = packageJson.version;
metadata.minimumSupportedRelease = piece.minimumSupportedRelease ?? '0.0.0';
Expand Down
10 changes: 5 additions & 5 deletions tools/scripts/validate-publishable-packages.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { getAvailablePieceNames } from './utils/get-available-piece-names';
import { findAllPieces } from './utils/piece-script-utils';
import { packagePrePublishChecks } from './utils/package-pre-publish-checks';

const main = async () => {
const piecePackageNames = await getAvailablePieceNames()
const piecesMetadata = await findAllPieces()

const packages = [
...piecePackageNames.map(p => `packages/pieces/${p}`),
'packages/pieces/framework',
...piecesMetadata.map(p => p.directoryPath!),
'packages/pieces/community/framework',
'packages/shared',
'packages/pieces/common',
'packages/pieces/community/common',
]

const validationResults = packages.map(p => packagePrePublishChecks(p))
Expand Down

0 comments on commit 6c409a6

Please sign in to comment.