mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -08:00
refactor: Remove all scope definition duplication (no-changelog) (#11401)
This commit is contained in:
parent
8201d322dd
commit
95c5df0781
|
@ -1,6 +1,5 @@
|
|||
import type { DEFAULT_OPERATIONS, RESOURCES } from './constants';
|
||||
import type { RESOURCES } from './constants';
|
||||
|
||||
export type DefaultOperations = (typeof DEFAULT_OPERATIONS)[number];
|
||||
export type Resource = keyof typeof RESOURCES;
|
||||
|
||||
export type ResourceScope<
|
||||
|
@ -10,52 +9,14 @@ export type ResourceScope<
|
|||
|
||||
export type WildcardScope = `${Resource}:*` | '*';
|
||||
|
||||
export type AnnotationTagScope = ResourceScope<'annotationTag'>;
|
||||
export type AuditLogsScope = ResourceScope<'auditLogs'>;
|
||||
export type BannerScope = ResourceScope<'banner'>;
|
||||
export type CommunityScope = ResourceScope<'community'>;
|
||||
export type CommunityPackageScope = ResourceScope<'communityPackage'>;
|
||||
export type CredentialScope = ResourceScope<'credential'>;
|
||||
export type ExternalSecretScope = ResourceScope<'externalSecret'>;
|
||||
export type ExternalSecretProviderScope = ResourceScope<'externalSecretsProvider'>;
|
||||
export type EventBusDestinationScope = ResourceScope<'eventBusDestination'>;
|
||||
export type LdapScope = ResourceScope<'ldap'>;
|
||||
export type LicenseScope = ResourceScope<'license'>;
|
||||
export type LogStreamingScope = ResourceScope<'logStreaming'>;
|
||||
export type OrchestrationScope = ResourceScope<'orchestration'>;
|
||||
export type ProjectScope = ResourceScope<'project'>;
|
||||
export type SamlScope = ResourceScope<'saml'>;
|
||||
export type SecurityAuditScope = ResourceScope<'securityAudit'>;
|
||||
export type SourceControlScope = ResourceScope<'sourceControl'>;
|
||||
export type TagScope = ResourceScope<'tag'>;
|
||||
export type UserScope = ResourceScope<'user'>;
|
||||
export type VariableScope = ResourceScope<'variable'>;
|
||||
export type WorkersViewScope = ResourceScope<'workersView'>;
|
||||
export type WorkflowScope = ResourceScope<'workflow'>;
|
||||
// This is purely an intermediary type.
|
||||
// If we tried to do use `ResourceScope<Resource>` directly we'd end
|
||||
// up with all resources having all scopes (e.g. `ldap:uninstall`).
|
||||
type AllScopesObject = {
|
||||
[R in Resource]: ResourceScope<R>;
|
||||
};
|
||||
|
||||
export type Scope =
|
||||
| AnnotationTagScope
|
||||
| AuditLogsScope
|
||||
| BannerScope
|
||||
| CommunityScope
|
||||
| CommunityPackageScope
|
||||
| CredentialScope
|
||||
| ExternalSecretProviderScope
|
||||
| ExternalSecretScope
|
||||
| EventBusDestinationScope
|
||||
| LdapScope
|
||||
| LicenseScope
|
||||
| LogStreamingScope
|
||||
| OrchestrationScope
|
||||
| ProjectScope
|
||||
| SamlScope
|
||||
| SecurityAuditScope
|
||||
| SourceControlScope
|
||||
| TagScope
|
||||
| UserScope
|
||||
| VariableScope
|
||||
| WorkersViewScope
|
||||
| WorkflowScope;
|
||||
export type Scope<K extends Resource = Resource> = AllScopesObject[K];
|
||||
|
||||
export type ScopeLevel = 'global' | 'project' | 'resource';
|
||||
export type GetScopeLevel<T extends ScopeLevel> = Record<T, Scope[]>;
|
||||
|
|
Loading…
Reference in a new issue