mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -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 Resource = keyof typeof RESOURCES;
|
||||||
|
|
||||||
export type ResourceScope<
|
export type ResourceScope<
|
||||||
|
@ -10,52 +9,14 @@ export type ResourceScope<
|
||||||
|
|
||||||
export type WildcardScope = `${Resource}:*` | '*';
|
export type WildcardScope = `${Resource}:*` | '*';
|
||||||
|
|
||||||
export type AnnotationTagScope = ResourceScope<'annotationTag'>;
|
// This is purely an intermediary type.
|
||||||
export type AuditLogsScope = ResourceScope<'auditLogs'>;
|
// If we tried to do use `ResourceScope<Resource>` directly we'd end
|
||||||
export type BannerScope = ResourceScope<'banner'>;
|
// up with all resources having all scopes (e.g. `ldap:uninstall`).
|
||||||
export type CommunityScope = ResourceScope<'community'>;
|
type AllScopesObject = {
|
||||||
export type CommunityPackageScope = ResourceScope<'communityPackage'>;
|
[R in Resource]: ResourceScope<R>;
|
||||||
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'>;
|
|
||||||
|
|
||||||
export type Scope =
|
export type Scope<K extends Resource = Resource> = AllScopesObject[K];
|
||||||
| AnnotationTagScope
|
|
||||||
| AuditLogsScope
|
|
||||||
| BannerScope
|
|
||||||
| CommunityScope
|
|
||||||
| CommunityPackageScope
|
|
||||||
| CredentialScope
|
|
||||||
| ExternalSecretProviderScope
|
|
||||||
| ExternalSecretScope
|
|
||||||
| EventBusDestinationScope
|
|
||||||
| LdapScope
|
|
||||||
| LicenseScope
|
|
||||||
| LogStreamingScope
|
|
||||||
| OrchestrationScope
|
|
||||||
| ProjectScope
|
|
||||||
| SamlScope
|
|
||||||
| SecurityAuditScope
|
|
||||||
| SourceControlScope
|
|
||||||
| TagScope
|
|
||||||
| UserScope
|
|
||||||
| VariableScope
|
|
||||||
| WorkersViewScope
|
|
||||||
| WorkflowScope;
|
|
||||||
|
|
||||||
export type ScopeLevel = 'global' | 'project' | 'resource';
|
export type ScopeLevel = 'global' | 'project' | 'resource';
|
||||||
export type GetScopeLevel<T extends ScopeLevel> = Record<T, Scope[]>;
|
export type GetScopeLevel<T extends ScopeLevel> = Record<T, Scope[]>;
|
||||||
|
|
Loading…
Reference in a new issue