Skip to content

Commit

Permalink
Tenant Removal (#2745)
Browse files Browse the repository at this point in the history
Co-authored-by: Gašper Grom <[email protected]>
  • Loading branch information
epipav and gaspergrom authored Jan 20, 2025
1 parent 9f8d9b0 commit 9c48d09
Show file tree
Hide file tree
Showing 246 changed files with 5,773 additions and 7,006 deletions.
6 changes: 1 addition & 5 deletions backend/src/api/activity/activityAddWithMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/activity/with-member
* POST /activity/with-member
* @summary Create or update an activity with a member
* @tag Activities
* @security Bearer
* @description Create or update an activity with a member
* Activity existence is checked by sourceId and tenantId
* Member existence is checked by platform and username
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ActivityUpsertWithMemberInput} application/json
* @response 200 - Ok
* @responseContent {Activity} 200.application/json
Expand All @@ -20,10 +19,7 @@ import PermissionChecker from '../../services/user/permissionChecker'
* @response 429 - Too many requests
*/
export default async (req, res) => {
// Check we have the Create permissions
new PermissionChecker(req).validateHas(Permissions.values.activityCreate)
// Call the createWithMember function in activity service
// to create the activity.
const payload = await new ActivityService(req).createWithMember(req.body)

await req.responseHandler.success(req, res, payload)
Expand Down
5 changes: 2 additions & 3 deletions backend/src/api/activity/activityChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/activity/channel
* GET /activity/channel
* @summary List activity channels
* @tag Activities
* @security Bearer
* @description Find all activity channels of a given tenant
* @pathParam {string} tenantId - Your workspace/tenant ID
* @description Find all activity channels
* @response 200 - Ok
* @responseContent {ActivityResponse} 200.application/json
* @responseExample {ActivityFind} 200.application/json.Activity
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/activity/activityCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/activity
* POST /activity
* @summary Create or update an activity
* @tag Activities
* @security Bearer
* @description Create or update an activity. Existence is checked by sourceId and tenantId
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ActivityUpsertInput} application/json
* @response 200 - Ok
* @responseContent {Activity} 200.application/json
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/activity/activityDestroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* DELETE /tenant/{tenantId}/activity/{id}
* DELETE /activity/{id}
* @summary Delete an activity
* @tag Activities
* @security Bearer
* @description Delete a activity given an ID
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the activity
* @response 200 - Ok
* @response 401 - Unauthorized
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/activity/activityFind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/activity/{id}
* GET /activity/{id}
* @summary Find an activity
* @tag Activities
* @security Bearer
Expand Down
13 changes: 0 additions & 13 deletions backend/src/api/activity/activityImport.ts

This file was deleted.

3 changes: 1 addition & 2 deletions backend/src/api/activity/activityQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/activity/query
* POST /activity/query
* @summary Query activities
* @tag Activities
* @security Bearer
* @description Query activities. It accepts filters, sorting options and pagination.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ActivityQuery} application/json
* @response 200 - Ok
* @responseContent {ActivityList} 200.application/json
Expand Down
15 changes: 0 additions & 15 deletions backend/src/api/activity/activityTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@ import Permissions from '../../security/permissions'
import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/activity/{id}
* @summary Find an activity
* @tag Activities
* @security Bearer
* @description Find a single activity by ID
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the activity
* @response 200 - Ok
* @responseContent {ActivityResponse} 200.application/json
* @responseExample {ActivityFind} 200.application/json.Activity
* @response 401 - Unauthorized
* @response 404 - Not found
* @response 429 - Too many requests
*/
export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.activityRead)
const payload = await new ActivityService(req).findActivityTypes(req.query.segments)
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/activity/activityUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ActivityService from '../../services/activityService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* PUT /tenant/{tenantId}/activity/{id}
* PUT /activity/{id}
* @summary Update an activity
* @tag Activities
* @security Bearer
* @description Update an activity given an ID.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the activity
* @bodyContent {ActivityUpsertInput} application/json
* @response 200 - Ok
Expand Down
20 changes: 7 additions & 13 deletions backend/src/api/activity/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { safeWrap } from '../../middlewares/errorMiddleware'

export default (app) => {
app.post(`/tenant/:tenantId/activity`, safeWrap(require('./activityCreate').default))
app.post(`/tenant/:tenantId/activity/query`, safeWrap(require('./activityQuery').default))
app.put(`/tenant/:tenantId/activity/:id`, safeWrap(require('./activityUpdate').default))
app.post(`/tenant/:tenantId/activity/import`, safeWrap(require('./activityImport').default))
app.delete(`/tenant/:tenantId/activity`, safeWrap(require('./activityDestroy').default))
app.get(`/tenant/:tenantId/activity/type`, safeWrap(require('./activityTypes').default))
app.get(`/tenant/:tenantId/activity/channel`, safeWrap(require('./activityChannels').default))
// app.get(`/tenant/:tenantId/activity/:id`, safeWrap(require('./activityFind').default))
app.post(
'/tenant/:tenantId/activity/with-member',
// Call the addActivityWithMember file in this dir
safeWrap(require('./activityAddWithMember').default),
)
app.post(`/activity`, safeWrap(require('./activityCreate').default))
app.post(`/activity/query`, safeWrap(require('./activityQuery').default))
app.put(`/activity/:id`, safeWrap(require('./activityUpdate').default))
app.delete(`/activity`, safeWrap(require('./activityDestroy').default))
app.get(`/activity/type`, safeWrap(require('./activityTypes').default))
app.get(`/activity/channel`, safeWrap(require('./activityChannels').default))
app.post('/activity/with-member', safeWrap(require('./activityAddWithMember').default))
}
4 changes: 2 additions & 2 deletions backend/src/api/auditLog/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { safeWrap } from '../../middlewares/errorMiddleware'

export default (app) => {
app.get(`/tenant/:tenantId/audit-log`, safeWrap(require('./auditLogList').default))
app.get(`/audit-log`, safeWrap(require('./auditLogList').default))

app.post(`/tenant/:tenantId/audit-logs/query`, safeWrap(require('./auditLogsQuery').default))
app.post(`/audit-logs/query`, safeWrap(require('./auditLogsQuery').default))
}
4 changes: 3 additions & 1 deletion backend/src/api/auth/authSignIn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { getDefaultTenantId } from '@crowd/common'

import AuthService from '../../services/auth/authService'

export default async (req, res) => {
const payload = await AuthService.signin(
req.body.email,
req.body.password,
req.body.invitationToken,
req.body.tenantId,
getDefaultTenantId(),
req,
)

Expand Down
4 changes: 3 additions & 1 deletion backend/src/api/auth/authSignUp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getDefaultTenantId } from '@crowd/common'

import AuthService from '../../services/auth/authService'

export default async (req, res) => {
Expand All @@ -8,7 +10,7 @@ export default async (req, res) => {
req.body.email,
req.body.password,
req.body.invitationToken,
req.body.tenantId,
getDefaultTenantId(),
req.body.firstName,
req.body.lastName,
req.body.acceptedTermsAndPrivacy,
Expand Down
3 changes: 2 additions & 1 deletion backend/src/api/auth/authSocial.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import passport from 'passport'

import { getDefaultTenantId } from '@crowd/common'
import { getServiceChildLogger } from '@crowd/logging'

import { API_CONFIG, GITHUB_CONFIG, GOOGLE_CONFIG } from '../../conf'
Expand All @@ -21,7 +22,7 @@ export default (app, routes) => {
routes.post('/auth/social/onboard', async (req, res) => {
const payload = await AuthService.handleOnboard(
req.currentUser,
{ invitationToken: req.body.invitationToken, tenantId: req.body.tenantId },
{ invitationToken: req.body.invitationToken, tenantId: getDefaultTenantId() },
req,
)

Expand Down
5 changes: 3 additions & 2 deletions backend/src/api/auth/ssoCallback.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jwt from 'jsonwebtoken'
import jwksClient from 'jwks-rsa'

import { Error401 } from '@crowd/common'
import { Error401, getDefaultTenantId } from '@crowd/common'

import { AUTH0_CONFIG } from '../../conf'
import AuthService from '../../services/auth/authService'
Expand All @@ -21,7 +21,8 @@ async function getKey(header, callback) {
}

export default async (req, res) => {
const { idToken, invitationToken, tenantId } = req.body
const { idToken, invitationToken } = req.body
const tenantId = getDefaultTenantId()

try {
const verifyToken = new Promise((resolve, reject) => {
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/conversation/conversationCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ConversationService from '../../services/conversationService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/conversation
* POST /conversation
* @summary Create a conversation
* @tag Conversations
* @security Bearer
* @description Create a conversation.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {ConversationNoId} application/json
* @response 200 - Ok
* @responseContent {Conversation} 200.application/json
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/conversation/conversationDestroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ConversationService from '../../services/conversationService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* DELETE /tenant/{tenantId}/conversation/{id}
* DELETE /conversation/{id}
* @summary Delete a conversation
* @tag Conversations
* @security Bearer
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/conversation/conversationFind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ConversationService from '../../services/conversationService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/conversation/{id}
* GET /conversation/{id}
* @summary Find a conversation
* @tag Conversations
* @security Bearer
* @description Find a conversation by ID.
* @pathParam {string} tenantId - Your workspace/tenant ID.
* @pathParam {string} id - The ID of the conversation.
* @response 200 - Ok
* @responseContent {Conversation} 200.application/json
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/conversation/conversationList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import ConversationService from '../../services/conversationService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* GET /tenant/{tenantId}/conversation
* GET /conversation
* @summary List conversations
* @tag Conversations
* @security Bearer
* @description Get a list of conversations with filtering, sorting and offsetting.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @queryParam {string} [filter[title]] - Filter by the title of the conversation.
* @queryParam {string} [filter[slug]] - Filter by the slug of the conversation.
* @queryParam {string} [filter[published]] - Filter by whether it is published or not.
Expand Down
15 changes: 0 additions & 15 deletions backend/src/api/conversation/conversationQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@ import track from '../../segment/track'
import ConversationService from '../../services/conversationService'
import PermissionChecker from '../../services/user/permissionChecker'

// /**
// * POST /tenant/{tenantId}/conversation
// * @summary Create or update an conversation
// * @tag Activities
// * @security Bearer
// * @description Create or update an conversation. Existence is checked by sourceId and tenantId.
// * @pathParam {string} tenantId - Your workspace/tenant ID
// * @bodyContent {ConversationUpsertInput} application/json
// * @response 200 - Ok
// * @responseContent {Conversation} 200.application/json
// * @responseExample {ConversationUpsert} 200.application/json.Conversation
// * @response 401 - Unauthorized
// * @response 404 - Not found
// * @response 429 - Too many requests
// */
export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.conversationRead)

Expand Down
26 changes: 0 additions & 26 deletions backend/src/api/conversation/conversationSettingsUpdate.ts

This file was deleted.

3 changes: 1 addition & 2 deletions backend/src/api/conversation/conversationUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ConversationService from '../../services/conversationService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* PUT /tenant/{tenantId}/conversation/{id}
* PUT /conversation/{id}
* @summary Update an conversation
* @tag Conversations
* @security Bearer
* @description Update a conversation given an ID.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @pathParam {string} id - The ID of the conversation
* @bodyContent {ConversationNoId} application/json
* @response 200 - Ok
Expand Down
16 changes: 6 additions & 10 deletions backend/src/api/conversation/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { safeWrap } from '../../middlewares/errorMiddleware'

export default (app) => {
app.post(`/tenant/:tenantId/conversation`, safeWrap(require('./conversationCreate').default))
app.put(`/tenant/:tenantId/conversation/:id`, safeWrap(require('./conversationUpdate').default))
app.delete(`/tenant/:tenantId/conversation`, safeWrap(require('./conversationDestroy').default))
app.post(`/tenant/:tenantId/conversation/query`, safeWrap(require('./conversationQuery').default))
app.get(`/tenant/:tenantId/conversation`, safeWrap(require('./conversationList').default))
app.get(`/tenant/:tenantId/conversation/:id`, safeWrap(require('./conversationFind').default))
app.post(
`/tenant/:tenantId/conversation/settings`,
safeWrap(require('./conversationSettingsUpdate').default),
)
app.post(`/conversation`, safeWrap(require('./conversationCreate').default))
app.put(`/conversation/:id`, safeWrap(require('./conversationUpdate').default))
app.delete(`/conversation`, safeWrap(require('./conversationDestroy').default))
app.post(`/conversation/query`, safeWrap(require('./conversationQuery').default))
app.get(`/conversation`, safeWrap(require('./conversationList').default))
app.get(`/conversation/:id`, safeWrap(require('./conversationFind').default))
}
3 changes: 1 addition & 2 deletions backend/src/api/customViews/customViewCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import CustomViewService from '../../services/customViewService'
import PermissionChecker from '../../services/user/permissionChecker'

/**
* POST /tenant/{tenantId}/customview
* POST /customview
* @summary Create a custom view
* @tag CustomViews
* @security Bearer
* @description Create a custom view
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {CustomViewInput} application/json
* @response 200 - Ok
* @responseContent {CustomView} 200.application/json
Expand Down
Loading

0 comments on commit 9c48d09

Please sign in to comment.