-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix-schema/variable-n-secret
- Loading branch information
Showing
20 changed files
with
619 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import BaseCommand from '../base.command' | ||
import AcceptInvitationCommand from './membership/accept-invitation.membership' | ||
import CancelInvitationCommand from './membership/cancel-invitation.membership' | ||
import DeclineInvitationCommand from './membership/decline-invitation.membership' | ||
import GetAllMembersOfWorkspaceCommand from './membership/get-all-members.membership' | ||
import InviteUserCommand from './membership/invite.membership' | ||
import { LeaveWorkspaceCommand } from './membership/leave.membership' | ||
import RemoveUserCommand from './membership/remove.membership' | ||
import TransferOwnershipCommand from './membership/transfer-ownership.membership copy' | ||
import UpdateRolesCommand from './membership/update-role.membership' | ||
|
||
export default class WorkspaceMembershipCommand extends BaseCommand { | ||
getName(): string { | ||
return 'membership' | ||
} | ||
|
||
getDescription(): string { | ||
return 'Manage workspace memberships' | ||
} | ||
|
||
getSubCommands(): BaseCommand[] { | ||
return [ | ||
new AcceptInvitationCommand(), | ||
new CancelInvitationCommand(), | ||
new DeclineInvitationCommand(), | ||
new GetAllMembersOfWorkspaceCommand(), | ||
new InviteUserCommand(), | ||
new LeaveWorkspaceCommand(), | ||
new RemoveUserCommand(), | ||
new TransferOwnershipCommand(), | ||
new UpdateRolesCommand() | ||
] | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
apps/cli/src/commands/workspace/membership/accept-invitation.membership.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import BaseCommand from '@/commands/base.command' | ||
import { | ||
type CommandActionData, | ||
type CommandArgument | ||
} from '@/types/command/command.types' | ||
import ControllerInstance from '@/util/controller-instance' | ||
import { Logger } from '@/util/logger' | ||
|
||
export default class AcceptInvitationCommand extends BaseCommand { | ||
getName(): string { | ||
return 'accept-invitation' | ||
} | ||
|
||
getDescription(): string { | ||
return 'Accept invitation for a workspace' | ||
} | ||
|
||
getArguments(): CommandArgument[] { | ||
return [ | ||
{ | ||
name: '<Workspace Slug>', | ||
description: 'Slug of the workspace which you want to fetch.' | ||
} | ||
] | ||
} | ||
|
||
canMakeHttpRequests(): boolean { | ||
return true | ||
} | ||
|
||
async action({ args }: CommandActionData): Promise<void> { | ||
const [workspaceSlug] = args | ||
|
||
const { error, success } = | ||
await ControllerInstance.getInstance().workspaceMembershipController.acceptInvitation( | ||
{ | ||
workspaceSlug | ||
}, | ||
this.headers | ||
) | ||
|
||
if (success) { | ||
Logger.info('Accepted invitation sucessfully!') | ||
Logger.info(`Workspace slug: ${workspaceSlug}`) | ||
} else { | ||
Logger.error(`Failed to accept invitation: ${error.message}`) | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
apps/cli/src/commands/workspace/membership/cancel-invitation.membership.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import BaseCommand from '@/commands/base.command' | ||
import { | ||
type CommandActionData, | ||
type CommandArgument | ||
} from '@/types/command/command.types' | ||
import { Logger } from '@/util/logger' | ||
import ControllerInstance from '@/util/controller-instance' | ||
|
||
export default class CancelInvitationCommand extends BaseCommand { | ||
getName(): string { | ||
return 'cancel-invitation' | ||
} | ||
|
||
getDescription(): string { | ||
return 'Cancel invitation sent to a user' | ||
} | ||
|
||
getArguments(): CommandArgument[] { | ||
return [ | ||
{ | ||
name: '<Workspace Slug>', | ||
description: 'Slug of the workspace which you want to fetch.' | ||
}, | ||
{ | ||
name: '<Invitee Email>', | ||
description: 'Email of the user that was invited.' | ||
} | ||
] | ||
} | ||
|
||
canMakeHttpRequests(): boolean { | ||
return true | ||
} | ||
|
||
async action({ args }: CommandActionData): Promise<void> { | ||
const [workspaceSlug, userEmail] = args | ||
|
||
const { error, success } = | ||
await ControllerInstance.getInstance().workspaceMembershipController.cancelInvitation( | ||
{ | ||
workspaceSlug, | ||
userEmail | ||
}, | ||
this.headers | ||
) | ||
|
||
if (success) { | ||
Logger.info('Cancelled an invitation for workspace successfully!') | ||
Logger.info(`Workspace slug: ${workspaceSlug}`) | ||
Logger.info(`Invitee: ${userEmail}`) | ||
} else { | ||
Logger.error(`Failed to cancel invitation: ${error.message}`) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
apps/cli/src/commands/workspace/membership/decline-invitation.membership.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import BaseCommand from '@/commands/base.command' | ||
import { | ||
type CommandActionData, | ||
type CommandArgument | ||
} from '@/types/command/command.types' | ||
import ControllerInstance from '@/util/controller-instance' | ||
import { Logger } from '@/util/logger' | ||
|
||
export default class DeclineInvitationCommand extends BaseCommand { | ||
getName(): string { | ||
return 'decline-invitation' | ||
} | ||
|
||
getDescription(): string { | ||
return 'Decline invitation of a workspace' | ||
} | ||
|
||
getArguments(): CommandArgument[] { | ||
return [ | ||
{ | ||
name: '<Workspace Slug>', | ||
description: 'Slug of the workspace which you want to fetch.' | ||
} | ||
] | ||
} | ||
|
||
canMakeHttpRequests(): boolean { | ||
return true | ||
} | ||
|
||
async action({ args }: CommandActionData): Promise<void> { | ||
const [workspaceSlug] = args | ||
|
||
const { error, success } = | ||
await ControllerInstance.getInstance().workspaceMembershipController.declineInvitation( | ||
{ | ||
workspaceSlug | ||
}, | ||
this.headers | ||
) | ||
|
||
if (success) { | ||
Logger.info('Declined invitation sucessfully!') | ||
Logger.info(`Workspace slug: ${workspaceSlug}`) | ||
} else { | ||
Logger.error(`Failed to decline invitation: ${error.message}`) | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
apps/cli/src/commands/workspace/membership/get-all-members.membership.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import BaseCommand from '@/commands/base.command' | ||
import { | ||
type CommandActionData, | ||
type CommandArgument, | ||
type CommandOption | ||
} from '@/types/command/command.types' | ||
import { Logger } from '@/util/logger' | ||
import ControllerInstance from '@/util/controller-instance' | ||
import { PAGINATION_OPTION } from '@/util/pagination-options' | ||
|
||
export default class GetAllMembersOfWorkspaceCommand extends BaseCommand { | ||
getName(): string { | ||
return 'list' | ||
} | ||
|
||
getDescription(): string { | ||
return 'List all members of a workspace' | ||
} | ||
|
||
getArguments(): CommandArgument[] { | ||
return [ | ||
{ | ||
name: '<Workspace Slug>', | ||
description: 'Slug of the workspace whose roles you want.' | ||
} | ||
] | ||
} | ||
|
||
getOptions(): CommandOption[] { | ||
return PAGINATION_OPTION | ||
} | ||
|
||
async action({ args, options }: CommandActionData): Promise<void> { | ||
Logger.info("Fetching workspace's members...") | ||
|
||
const [workspaceSlug] = args | ||
|
||
const { data, error, success } = | ||
await ControllerInstance.getInstance().workspaceMembershipController.getMembers( | ||
{ | ||
workspaceSlug, | ||
...options | ||
}, | ||
this.headers | ||
) | ||
|
||
if (success) { | ||
Logger.info('Workspace Members fetched successfully:') | ||
const members = data.items | ||
if (members.length > 0) { | ||
Logger.info('Email\tRole') | ||
members.forEach((member) => { | ||
Logger.info( | ||
`- ${member.user.email} (${member.roles.map((role) => role.role.name).join(', ')})` | ||
) | ||
}) | ||
} else { | ||
Logger.info('No members found') | ||
} | ||
} else { | ||
Logger.error(`Failed fetching members: ${error.message}`) | ||
} | ||
} | ||
} |
Oops, something went wrong.