@speckle/shared
Version:
Shared code between various Speckle JS packages
182 lines • 8.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardNotOwnerError = exports.DashboardProjectsNotEnoughPermissionsError = exports.DashboardNoProjectsError = exports.DashboardNotFoundError = exports.DashboardsNotEnabledError = exports.UngroupedSavedViewGroupLockError = exports.SavedViewGroupNotFoundError = exports.SavedViewInvalidUpdateError = exports.SavedViewNoAccessError = exports.SavedViewNotFoundError = exports.AccIntegrationNotEnabledError = exports.AutomateFunctionNotCreatorError = exports.AutomateFunctionNotFoundError = exports.AutomateNotEnabledError = exports.VersionNotFoundError = exports.ReservedModelNotDeletableError = exports.ModelNotFoundError = exports.CommentNoAccessError = exports.CommentNotFoundError = exports.ServerNoSessionError = exports.ServerNotEnoughPermissionsError = exports.ServerNoAccessError = exports.WorkspaceNoEditorSeatError = exports.WorkspaceSsoSessionNoAccessError = exports.WorkspaceProjectMoveInvalidError = exports.WorkspacePlanNoFeatureAccessError = exports.WorkspaceLimitsReachedError = exports.WorkspaceReadOnlyError = exports.EligibleForExclusiveWorkspaceError = exports.WorkspaceNotEnoughPermissionsError = exports.WorkspaceNoAccessError = exports.WorkspacesNotEnabledError = exports.ProjectLastOwnerError = exports.ProjectNotEnoughPermissionsError = exports.PersonalProjectsLimitedError = exports.ProjectNoAccessError = exports.ProjectNotFoundError = exports.isAuthPolicyError = exports.defineAuthError = void 0;
const _lodash_1 = require("#lodash");
const defineAuthError = (definition) => {
return class AuthErrorClass extends Error {
message;
code;
payload;
isAuthPolicyError = true;
static code = definition.code;
constructor(...args) {
const [params] = args;
const message = (0, _lodash_1.isString)(params) ? params : params?.message || definition.message;
super(message);
this.code = definition.code;
this.payload =
params && !(0, _lodash_1.isString)(params) && 'payload' in params
? params.payload
: undefined;
this.message = message;
this.name = definition.code + 'Error';
}
};
};
exports.defineAuthError = defineAuthError;
const isAuthPolicyError = (err) => {
return (0, _lodash_1.isObjectLike)(err) && (0, _lodash_1.get)(err, 'isAuthPolicyError') === true;
};
exports.isAuthPolicyError = isAuthPolicyError;
exports.ProjectNotFoundError = (0, exports.defineAuthError)({
code: 'ProjectNotFound',
message: 'Project not found'
});
exports.ProjectNoAccessError = (0, exports.defineAuthError)({
code: 'ProjectNoAccess',
message: 'You do not have access to the project'
});
exports.PersonalProjectsLimitedError = (0, exports.defineAuthError)({
code: 'PersonalProjectsLimited',
message: 'Non-workspaced/personal projects are limited'
});
exports.ProjectNotEnoughPermissionsError = (0, exports.defineAuthError)({
code: 'ProjectNotEnoughPermissions',
message: 'You do not have enough permissions in the project to perform this action'
});
exports.ProjectLastOwnerError = (0, exports.defineAuthError)({
code: 'ProjectLastOwner',
message: 'You are the last owner of this project'
});
exports.WorkspacesNotEnabledError = (0, exports.defineAuthError)({
code: 'WorkspacesNotEnabled',
message: 'This server does not support workspaces'
});
exports.WorkspaceNoAccessError = (0, exports.defineAuthError)({
code: 'WorkspaceNoAccess',
message: 'You do not have access to the workspace'
});
exports.WorkspaceNotEnoughPermissionsError = (0, exports.defineAuthError)({
code: 'WorkspaceNotEnoughPermissions',
message: 'You do not have enough permissions in the workspace to perform this action'
});
exports.EligibleForExclusiveWorkspaceError = (0, exports.defineAuthError)({
code: 'UserEligibleForExclusiveWorkspace',
message: 'Cannot create workspace: ' +
'You are a member or eligible to become a member of an exclusive workspace. ' +
'This is due to you having received an invite to the workspace ' +
'or having a matching verified email.'
});
exports.WorkspaceReadOnlyError = (0, exports.defineAuthError)({
code: 'WorkspaceReadOnly',
message: 'The workspace is in a read only mode, upgrade your plan to unlock it'
});
exports.WorkspaceLimitsReachedError = (0, exports.defineAuthError)({
code: 'WorkspaceLimitsReached',
message: 'Workspace limits have been reached'
});
exports.WorkspacePlanNoFeatureAccessError = (0, exports.defineAuthError)({
code: 'WorkspacePlanNoFeatureAccessError',
message: 'Your workspace plan does not have access to this feature.'
});
exports.WorkspaceProjectMoveInvalidError = (0, exports.defineAuthError)({
code: 'WorkspaceProjectMoveInvalid',
message: 'Projects already in a workspace cannot be moved to another workspace.'
});
exports.WorkspaceSsoSessionNoAccessError = (0, exports.defineAuthError)({
code: 'WorkspaceSsoSessionNoAccess',
message: 'Your workspace SSO session is expired or it does not exist'
});
exports.WorkspaceNoEditorSeatError = (0, exports.defineAuthError)({
code: 'WorkspaceNoEditorSeat',
message: 'You need an editor seat to perform this action'
});
exports.ServerNoAccessError = (0, exports.defineAuthError)({
code: 'ServerNoAccess',
message: 'You do not have access to this server'
});
exports.ServerNotEnoughPermissionsError = (0, exports.defineAuthError)({
code: 'ServerNotEnoughPermissions',
message: 'You do not have enough permissions in the server to perform this action'
});
exports.ServerNoSessionError = (0, exports.defineAuthError)({
code: 'ServerNoSession',
message: 'You are not logged in to this server'
});
exports.CommentNotFoundError = (0, exports.defineAuthError)({
code: 'CommentNotFound',
message: 'Comment not found'
});
exports.CommentNoAccessError = (0, exports.defineAuthError)({
code: 'CommentNoAccess',
message: 'You do not have access to this comment'
});
exports.ModelNotFoundError = (0, exports.defineAuthError)({
code: 'ModelNotFound',
message: 'Model not found'
});
exports.ReservedModelNotDeletableError = (0, exports.defineAuthError)({
code: 'ReservedModelNotDeletable',
message: 'This model is reserved and cannot be deleted'
});
exports.VersionNotFoundError = (0, exports.defineAuthError)({
code: 'VersionNotFound',
message: 'Version not found'
});
exports.AutomateNotEnabledError = (0, exports.defineAuthError)({
code: 'AutomateNotEnabled',
message: 'Automate is not enabled on this server'
});
exports.AutomateFunctionNotFoundError = (0, exports.defineAuthError)({
code: 'AutomateFunctionNotFound',
message: 'Function not found'
});
exports.AutomateFunctionNotCreatorError = (0, exports.defineAuthError)({
code: 'AutomateFunctionNotCreator',
message: 'You are not the function creator and cannot make changes to it.'
});
exports.AccIntegrationNotEnabledError = (0, exports.defineAuthError)({
code: 'AccIntegrationNotEnabled',
message: 'The ACC Integration is not enabled on this server or project'
});
exports.SavedViewNotFoundError = (0, exports.defineAuthError)({
code: 'SavedViewNotFound',
message: 'Saved view not found'
});
exports.SavedViewNoAccessError = (0, exports.defineAuthError)({
code: 'SavedViewNoAccess',
message: 'You do not have access to this saved view'
});
exports.SavedViewInvalidUpdateError = (0, exports.defineAuthError)({
code: 'SavedViewInvalidUpdate',
message: 'The requested update is invalid'
});
exports.SavedViewGroupNotFoundError = (0, exports.defineAuthError)({
code: 'SavedViewGroupNotFound',
message: 'Saved view group not found'
});
exports.UngroupedSavedViewGroupLockError = (0, exports.defineAuthError)({
code: 'UngroupedSavedViewGroupLock',
message: 'The default/ungrouped group cannot be modified.'
});
exports.DashboardsNotEnabledError = (0, exports.defineAuthError)({
code: 'DashboardsNotEnabled',
message: 'Dashboards are not enabled for this server or workspaces.'
});
exports.DashboardNotFoundError = (0, exports.defineAuthError)({
code: 'DashboardNotFound',
message: 'Dashboard not found'
});
exports.DashboardNoProjectsError = (0, exports.defineAuthError)({
code: 'DashboardNoProjects',
message: 'Dashboard has no projects added to it. You need to add at least one project before sharing.'
});
exports.DashboardProjectsNotEnoughPermissionsError = (0, exports.defineAuthError)({
code: 'DashboardProjectsNotEnoughPermissions',
message: 'You do not have sufficient access to some projects in this workspace.'
});
exports.DashboardNotOwnerError = (0, exports.defineAuthError)({
code: 'DashboardNotOwner',
message: 'You must be a dashboard owner to perform this action'
});
//# sourceMappingURL=authErrors.js.map