Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tenants from api endpoints #2765

Merged
merged 33 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aef1c70
remove tenants from activity endpoints
epipav Jan 14, 2025
ea84f05
remove tenants from auditlogs endpoints
epipav Jan 14, 2025
b786503
remove tenants from auth endpoints
epipav Jan 14, 2025
1d95b80
remove automation endpoints
epipav Jan 14, 2025
841404e
simplify activity endpoints even more
epipav Jan 14, 2025
991f33f
simplify auditLog endpoints even more
epipav Jan 14, 2025
787f0c4
remove tenants from conversation endpoints
epipav Jan 14, 2025
d04eac4
remove tenants from custom view endpoints
epipav Jan 14, 2025
2847814
remove tenants from dashboard endpoint
epipav Jan 14, 2025
d7dbe13
remove tenants from data quality endpoints
epipav Jan 14, 2025
ccb3853
remove tenants from eagle eye endpoints
epipav Jan 14, 2025
ecf09c1
remove tenants from integration endpoints
epipav Jan 14, 2025
ad06cdb
remove tenantId from member endpoints
epipav Jan 14, 2025
021f9a8
remove tenants from mergeAction endpoints
epipav Jan 14, 2025
89b4f92
remove microservice endpoints
epipav Jan 14, 2025
fbea9fc
remove tenants from org endpoints
epipav Jan 14, 2025
0575f98
remove tenants from segment endpoints
epipav Jan 14, 2025
f8bdb1c
remove tenants from settings endpoints
epipav Jan 14, 2025
df36bbf
remove tenants from tag endpoints
epipav Jan 14, 2025
8846cc1
remove tenants from user endpoints
epipav Jan 14, 2025
573d00e
make tenantMiddleware and segmentMiddleware application level middlew…
epipav Jan 14, 2025
d8b5246
formatting
epipav Jan 14, 2025
f0a6fcc
readded missing discord endpoints fixed runtime errors
epipav Jan 15, 2025
3babe36
fix cli for non-existing premium stuff
epipav Jan 15, 2025
9d90f25
fix middleware ordering for auth endpoints
epipav Jan 15, 2025
a21c9e3
reintroduce json body parser
epipav Jan 15, 2025
1482924
use default tenantId on creating the default tenant
epipav Jan 15, 2025
a838ca8
remove tenant endpoints, move merge-suggestion endppoints
epipav Jan 15, 2025
35d7b58
Merge branch 'improvement/tenant-removal' into improvement/remove-ten…
epipav Jan 15, 2025
e80f2af
fix pnpm lock
epipav Jan 15, 2025
1234f94
fix obsolete sync mode
epipav Jan 15, 2025
7df6feb
formatting
epipav Jan 16, 2025
bd44ac4
remove unused convo route
epipav Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 0 additions & 31 deletions backend/src/api/automation/automationCreate.ts

This file was deleted.

27 changes: 0 additions & 27 deletions backend/src/api/automation/automationDestroy.ts

This file was deleted.

40 changes: 0 additions & 40 deletions backend/src/api/automation/automationExecutionFind.ts

This file was deleted.

24 changes: 0 additions & 24 deletions backend/src/api/automation/automationFind.ts

This file was deleted.

Loading
Loading