@magnet-cms/core 1.0.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache.settings-WVD3J7KS.js +5 -0
- package/dist/{chunk-VRD3SNTH.js → chunk-4KTI5N3Y.js} +5 -5
- package/dist/{chunk-2G3SJVME.js → chunk-57BXP7WT.js} +3 -3
- package/dist/{chunk-GRTSRYQ3.js → chunk-5ZNZ457Y.js} +1 -1
- package/dist/{chunk-UPVWRKGL.js → chunk-BLOJL7F5.js} +1 -1
- package/dist/{chunk-IRYV6KDU.js → chunk-D3C3IDJE.js} +1806 -2919
- package/dist/chunk-FPVW2XEK.js +77 -0
- package/dist/{chunk-VPQMUAKT.js → chunk-L5S66O2C.js} +2945 -1418
- package/dist/{chunk-5KKPPI6S.js → chunk-LSFWCRI6.js} +3 -3
- package/dist/{dist-es-EKS5UN6W.js → dist-es-FN4ZDH7H.js} +3 -3
- package/dist/dist-es-IFKE2QTH.js +1 -1
- package/dist/{dist-es-J4ID6CFE.js → dist-es-JOTZAW56.js} +3 -3
- package/dist/{dist-es-SH3IYNFH.js → dist-es-UU6EFY2O.js} +2 -2
- package/dist/index.cjs +62120 -8608
- package/dist/index.d.cts +22 -7
- package/dist/index.d.ts +22 -7
- package/dist/index.js +53223 -193
- package/dist/{loadCognitoIdentity-IDLT73F5.js → loadCognitoIdentity-VHCOBTS2.js} +4 -4
- package/dist/{loadSso-VKQ2MGWC.js → loadSso-5XNIYOZP.js} +4 -4
- package/dist/{loadSts-CDV5EIAC.js → loadSts-IC4PURXF.js} +6 -6
- package/dist/magnet-module-imports.cjs +3864 -3393
- package/dist/magnet-module-imports.d.cts +6 -2
- package/dist/magnet-module-imports.d.ts +6 -2
- package/dist/magnet-module-imports.js +12 -11
- package/dist/modules.cjs +3921 -2174
- package/dist/modules.d.cts +298 -618
- package/dist/modules.d.ts +298 -618
- package/dist/modules.js +179 -15
- package/dist/permission.guard-B8HLjHP2.d.cts +912 -0
- package/dist/permission.guard-B8HLjHP2.d.ts +912 -0
- package/dist/{settings.module-CS9n15pg.d.cts → settings.module-CX5Cs5fA.d.cts} +29 -3
- package/dist/{settings.module-CS9n15pg.d.ts → settings.module-CX5Cs5fA.d.ts} +29 -3
- package/dist/{signin-OTF7SOKV.js → signin-TXX6BWCZ.js} +4 -4
- package/dist/{sso-oidc-IU7NSPWD.js → sso-oidc-CMVLR2KO.js} +4 -4
- package/dist/{sts-IGHPXD4X.js → sts-MASJMUF3.js} +6 -6
- package/package.json +3 -3
- package/dist/auth-strategy.factory-D2p1hfeq.d.cts +0 -303
- package/dist/auth-strategy.factory-D2p1hfeq.d.ts +0 -303
- package/dist/{chunk-ISB33RLS.js → chunk-47RGXMWN.js} +3 -3
package/dist/modules.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ApiKeysModule, C as ContentModule, D as DocumentModule, H as HistoryModule, N as NotificationModule, P as PluginModule, R as RBACModule, S as SettingsModule } from './settings.module-
|
|
1
|
+
import { b as NotificationModuleOptions } from './settings.module-CX5Cs5fA.js';
|
|
2
|
+
export { A as ApiKeysModule, C as CacheModule, a as ContentModule, D as DocumentModule, H as HistoryModule, N as NotificationModule, P as PluginModule, R as RBACModule, S as SettingsModule } from './settings.module-CX5Cs5fA.js';
|
|
3
3
|
import * as _magnet_cms_common from '@magnet-cms/common';
|
|
4
|
-
import { getExtendUserOptions, FieldMetadata, SettingValue, Model, SettingType, SchemaSetting, AuthConfig, AuthStrategy, AuthUser, LoginCredentials, AuthResult, RegisterData,
|
|
4
|
+
import { getExtendUserOptions, FieldMetadata, SettingValue, Model, SettingType, SchemaSetting, CacheAdapter, CacheHealthResult, AuthConfig, AuthStrategy, AuthUser, LoginCredentials, AuthResult, RegisterData, EmailAdapter, SendEmailOptions, SendEmailResult, EventPayload, MagnetModuleOptions, NotificationChannel, NotificationChannelAdapter, NotifyDto, NotificationQueryOptions, PaginatedNotifications, EnrichedPluginManifest, PluginConfig, StorageAdapter, LocalStorageConfig, UploadOptions, UploadResult, TransformOptions, MediaQueryOptions, PaginatedMedia, BaseSchema, EventName, InitialConfig } from '@magnet-cms/common';
|
|
5
5
|
export { HasPermission, PermissionMeta, RequirePermission, getPermissionMetadata, hasPermissionDecorator } from '@magnet-cms/common';
|
|
6
|
-
import { U as UserService, C as CreateUserDto,
|
|
7
|
-
export { A as AuthStrategyFactory, H as Hook, I as InjectPluginOptions, P as Plugin, a as PluginDecoratorOptions } from './
|
|
6
|
+
import { U as UserService, C as CreateUserDto, c as User, d as PaginatedUserResult, M as MagnetLogger, E as EventService, D as DiscoveryService, e as PluginRegistryService } from './permission.guard-B8HLjHP2.js';
|
|
7
|
+
export { A as AuthStrategyFactory, h as CreateRoleDto, i as DuplicateRoleDto, H as Hook, I as InjectPluginOptions, f as PermissionDiscoveryService, b as PermissionGuard, g as PermissionService, P as Plugin, a as PluginDecoratorOptions, k as Role, R as RoleService, j as UpdateRoleDto, V as ValidatePermissionIdsResult } from './permission.guard-B8HLjHP2.js';
|
|
8
8
|
import * as _nestjs_common from '@nestjs/common';
|
|
9
|
-
import { Type, DynamicModule, OnApplicationBootstrap, CanActivate, ExecutionContext,
|
|
9
|
+
import { Type, DynamicModule, OnApplicationBootstrap, CanActivate, ExecutionContext, NestInterceptor, CallHandler, OnModuleInit, Logger, OnApplicationShutdown } from '@nestjs/common';
|
|
10
10
|
import { ModuleRef, Reflector, ModulesContainer, DiscoveryService as DiscoveryService$1 } from '@nestjs/core';
|
|
11
11
|
import { Request, Response, NextFunction } from 'express';
|
|
12
12
|
import * as rxjs from 'rxjs';
|
|
@@ -14,8 +14,8 @@ import { Observable } from 'rxjs';
|
|
|
14
14
|
import * as _nestjs_passport from '@nestjs/passport';
|
|
15
15
|
import * as passport_jwt from 'passport-jwt';
|
|
16
16
|
import { Strategy } from 'passport-jwt';
|
|
17
|
-
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
18
17
|
import { Readable } from 'node:stream';
|
|
18
|
+
import '@nestjs/core/injector/instance-wrapper';
|
|
19
19
|
|
|
20
20
|
declare class UpdateUserDto {
|
|
21
21
|
email?: string;
|
|
@@ -906,6 +906,283 @@ declare const RequireApiKeySchema: (schema: string) => _nestjs_common.CustomDeco
|
|
|
906
906
|
*/
|
|
907
907
|
declare const CurrentApiKey: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
908
908
|
|
|
909
|
+
/**
|
|
910
|
+
* CacheService provides a high-level API over any CacheAdapter.
|
|
911
|
+
*
|
|
912
|
+
* Inject this service wherever caching is needed. When @Cacheable(),
|
|
913
|
+
* @CacheEvict(), or @CachePut() decorators are used on controller methods,
|
|
914
|
+
* the CacheInterceptor uses this service automatically.
|
|
915
|
+
*
|
|
916
|
+
* For service-level caching, inject CacheService directly and call get/set.
|
|
917
|
+
*
|
|
918
|
+
* Settings integration: the `enabled`, `defaultTtl`, and `maxMemoryEntries`
|
|
919
|
+
* fields in the admin Settings UI take effect at runtime — no restart needed.
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* ```typescript
|
|
923
|
+
* constructor(private readonly cache: CacheService) {}
|
|
924
|
+
*
|
|
925
|
+
* async getPost(id: string) {
|
|
926
|
+
* const cached = await this.cache.get<Post>(`posts:${id}`)
|
|
927
|
+
* if (cached) return cached
|
|
928
|
+
* const post = await this.postRepo.findById(id)
|
|
929
|
+
* await this.cache.set(`posts:${id}`, post)
|
|
930
|
+
* return post
|
|
931
|
+
* }
|
|
932
|
+
* ```
|
|
933
|
+
*/
|
|
934
|
+
declare class CacheService {
|
|
935
|
+
private readonly adapter;
|
|
936
|
+
private readonly settingsService?;
|
|
937
|
+
private readonly logger;
|
|
938
|
+
constructor(adapter: CacheAdapter, settingsService?: SettingsService | undefined);
|
|
939
|
+
/** Name of the active cache adapter */
|
|
940
|
+
get adapterName(): string;
|
|
941
|
+
/**
|
|
942
|
+
* Retrieve a cached value by key.
|
|
943
|
+
* Returns null if cache is disabled via Settings or the key is not found.
|
|
944
|
+
*/
|
|
945
|
+
get<T>(key: string): Promise<T | null>;
|
|
946
|
+
/**
|
|
947
|
+
* Store a value in the cache.
|
|
948
|
+
* No-op if cache is disabled via Settings.
|
|
949
|
+
* @param key - Cache key
|
|
950
|
+
* @param value - Value to cache (must be JSON-serializable)
|
|
951
|
+
* @param ttl - TTL in seconds. If omitted, uses the Settings defaultTtl.
|
|
952
|
+
*/
|
|
953
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
954
|
+
/**
|
|
955
|
+
* Remove a value from the cache.
|
|
956
|
+
*/
|
|
957
|
+
delete(key: string): Promise<void>;
|
|
958
|
+
/**
|
|
959
|
+
* Remove all cache entries matching a glob pattern.
|
|
960
|
+
* @param pattern - Glob pattern (e.g., `posts:*`)
|
|
961
|
+
*/
|
|
962
|
+
deleteByPattern(pattern: string): Promise<void>;
|
|
963
|
+
/**
|
|
964
|
+
* Check if a key exists and has not expired.
|
|
965
|
+
*/
|
|
966
|
+
has(key: string): Promise<boolean>;
|
|
967
|
+
/**
|
|
968
|
+
* Remove all cache entries.
|
|
969
|
+
*/
|
|
970
|
+
clear(): Promise<void>;
|
|
971
|
+
/**
|
|
972
|
+
* Check cache adapter health.
|
|
973
|
+
*/
|
|
974
|
+
healthCheck(): Promise<CacheHealthResult>;
|
|
975
|
+
private getSettings;
|
|
976
|
+
private isEnabled;
|
|
977
|
+
private getDefaultTtl;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Cache settings schema.
|
|
982
|
+
*
|
|
983
|
+
* Configures cache behavior and defaults, manageable from the admin Settings panel.
|
|
984
|
+
*/
|
|
985
|
+
declare class CacheSettings {
|
|
986
|
+
enabled: boolean;
|
|
987
|
+
defaultTtl: number;
|
|
988
|
+
maxMemoryEntries: number;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** DI injection token for the cache adapter */
|
|
992
|
+
declare const CACHE_ADAPTER_TOKEN = "CACHE_ADAPTER";
|
|
993
|
+
/** Metadata key for @Cacheable, @CacheEvict, @CachePut decorators */
|
|
994
|
+
declare const CACHE_METADATA_KEY = "__cache_metadata__";
|
|
995
|
+
/** Metadata key for @CacheTTL decorator */
|
|
996
|
+
declare const CACHE_TTL_KEY = "__cache_ttl__";
|
|
997
|
+
|
|
998
|
+
interface MemoryCacheAdapterOptions {
|
|
999
|
+
/** Maximum number of cache entries before LRU eviction (default: 1000) */
|
|
1000
|
+
maxEntries?: number;
|
|
1001
|
+
/** Default TTL in seconds (default: 300) */
|
|
1002
|
+
defaultTtl?: number;
|
|
1003
|
+
/** Interval in ms for periodic expired-entry cleanup (default: 60000). Set to 0 to disable. */
|
|
1004
|
+
cleanupIntervalMs?: number;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Built-in in-memory cache adapter with TTL and LRU eviction.
|
|
1008
|
+
*
|
|
1009
|
+
* Uses a Map with insertion-order tracking for LRU. Suitable for single-process
|
|
1010
|
+
* deployments or development. For multi-instance deployments, use RedisCacheAdapter.
|
|
1011
|
+
*/
|
|
1012
|
+
declare class MemoryCacheAdapter implements CacheAdapter {
|
|
1013
|
+
readonly name = "memory";
|
|
1014
|
+
private readonly store;
|
|
1015
|
+
/** Tracks access order for LRU: front = oldest, back = most recently used */
|
|
1016
|
+
private readonly accessOrder;
|
|
1017
|
+
private readonly maxEntries;
|
|
1018
|
+
private readonly defaultTtl;
|
|
1019
|
+
private cleanupTimer;
|
|
1020
|
+
constructor(options?: MemoryCacheAdapterOptions);
|
|
1021
|
+
get<T>(key: string): Promise<T | null>;
|
|
1022
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
1023
|
+
delete(key: string): Promise<void>;
|
|
1024
|
+
deleteByPattern(pattern: string): Promise<void>;
|
|
1025
|
+
has(key: string): Promise<boolean>;
|
|
1026
|
+
clear(): Promise<void>;
|
|
1027
|
+
healthCheck(): Promise<CacheHealthResult>;
|
|
1028
|
+
dispose(): Promise<void>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Mark key as most recently used.
|
|
1031
|
+
* O(n) per access — acceptable for the default maxEntries=1000 with low-traffic workloads.
|
|
1032
|
+
* For high-throughput production use, consider the Redis adapter instead.
|
|
1033
|
+
*/
|
|
1034
|
+
private touchAccess;
|
|
1035
|
+
/** Remove a specific key from store and accessOrder */
|
|
1036
|
+
private evictKey;
|
|
1037
|
+
/** Evict the least recently used entry */
|
|
1038
|
+
private evictLru;
|
|
1039
|
+
/** Remove all expired entries (periodic cleanup) */
|
|
1040
|
+
private cleanup;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
interface CacheableOptions {
|
|
1044
|
+
/**
|
|
1045
|
+
* Cache key. Supports `:arg0`, `:arg1` placeholders for method arguments.
|
|
1046
|
+
* If omitted, a default key is generated from the class name, method name,
|
|
1047
|
+
* and serialized arguments.
|
|
1048
|
+
*/
|
|
1049
|
+
key?: string;
|
|
1050
|
+
/** TTL override in seconds. If omitted, the interceptor uses @CacheTTL or adapter default. */
|
|
1051
|
+
ttl?: number;
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Cache the return value of a controller method.
|
|
1055
|
+
*
|
|
1056
|
+
* On the first call with a given key, the method executes and the result is stored.
|
|
1057
|
+
* On subsequent calls with the same key (while not expired), the cached value is returned
|
|
1058
|
+
* without executing the method.
|
|
1059
|
+
*
|
|
1060
|
+
* **⚠️ Requires `@UseInterceptors(CacheInterceptor)` on the controller or method.**
|
|
1061
|
+
* Works on NestJS controller route handlers only — NOT on plain service methods.
|
|
1062
|
+
* For service-level caching, inject `CacheService` and call `get`/`set` directly.
|
|
1063
|
+
*
|
|
1064
|
+
* @example
|
|
1065
|
+
* ```typescript
|
|
1066
|
+
* @Get(':id')
|
|
1067
|
+
* @Cacheable({ key: 'posts::id', ttl: 300 })
|
|
1068
|
+
* @UseInterceptors(CacheInterceptor)
|
|
1069
|
+
* async getPost(@Param('id') id: string) {
|
|
1070
|
+
* return this.postsService.findOne(id)
|
|
1071
|
+
* }
|
|
1072
|
+
* ```
|
|
1073
|
+
*/
|
|
1074
|
+
declare function Cacheable(options?: CacheableOptions): MethodDecorator;
|
|
1075
|
+
|
|
1076
|
+
interface CacheEvictOptions {
|
|
1077
|
+
/**
|
|
1078
|
+
* Cache key or glob pattern to evict (e.g., `posts:*` removes all post entries).
|
|
1079
|
+
* If omitted, evicts the default key for this method.
|
|
1080
|
+
*/
|
|
1081
|
+
key?: string;
|
|
1082
|
+
/**
|
|
1083
|
+
* When true, uses `deleteByPattern(key)` instead of `delete(key)`.
|
|
1084
|
+
* Useful with glob patterns to evict multiple related keys at once.
|
|
1085
|
+
*/
|
|
1086
|
+
allEntries?: boolean;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Evict cache entries after a controller method executes.
|
|
1090
|
+
*
|
|
1091
|
+
* The method always executes. After it completes, the specified cache key(s)
|
|
1092
|
+
* are removed to prevent stale data on the next read.
|
|
1093
|
+
*
|
|
1094
|
+
* **⚠️ Requires `@UseInterceptors(CacheInterceptor)` on the controller or method.**
|
|
1095
|
+
*
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```typescript
|
|
1098
|
+
* @Patch(':id')
|
|
1099
|
+
* @CacheEvict({ key: 'posts:*', allEntries: true })
|
|
1100
|
+
* @UseInterceptors(CacheInterceptor)
|
|
1101
|
+
* async updatePost(@Param('id') id: string, @Body() dto: UpdatePostDto) {
|
|
1102
|
+
* return this.postsService.update(id, dto)
|
|
1103
|
+
* }
|
|
1104
|
+
* ```
|
|
1105
|
+
*/
|
|
1106
|
+
declare function CacheEvict(options?: CacheEvictOptions): MethodDecorator;
|
|
1107
|
+
|
|
1108
|
+
interface CachePutOptions {
|
|
1109
|
+
/** Cache key. If omitted, a default key is generated from class name, method name, and args. */
|
|
1110
|
+
key?: string;
|
|
1111
|
+
/** TTL override in seconds. If omitted, the interceptor uses @CacheTTL or adapter default. */
|
|
1112
|
+
ttl?: number;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Always execute the method and update the cache with the result.
|
|
1116
|
+
*
|
|
1117
|
+
* Unlike `@Cacheable`, this never returns a cached value — it always executes
|
|
1118
|
+
* and always writes the fresh result to the cache (forced refresh).
|
|
1119
|
+
*
|
|
1120
|
+
* **⚠️ Requires `@UseInterceptors(CacheInterceptor)` on the controller or method.**
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```typescript
|
|
1124
|
+
* @Post('refresh/:id')
|
|
1125
|
+
* @CachePut({ key: 'posts::id' })
|
|
1126
|
+
* @UseInterceptors(CacheInterceptor)
|
|
1127
|
+
* async refreshPost(@Param('id') id: string) {
|
|
1128
|
+
* return this.postsService.findOne(id)
|
|
1129
|
+
* }
|
|
1130
|
+
* ```
|
|
1131
|
+
*/
|
|
1132
|
+
declare function CachePut(options?: CachePutOptions): MethodDecorator;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Override the TTL for a cached controller method.
|
|
1136
|
+
*
|
|
1137
|
+
* Compose with `@Cacheable()` or `@CachePut()` to set a per-method TTL
|
|
1138
|
+
* that overrides the adapter's default TTL.
|
|
1139
|
+
*
|
|
1140
|
+
* **⚠️ Requires `@UseInterceptors(CacheInterceptor)` on the controller or method.**
|
|
1141
|
+
*
|
|
1142
|
+
* @param seconds - Time-to-live in seconds
|
|
1143
|
+
*
|
|
1144
|
+
* @example
|
|
1145
|
+
* ```typescript
|
|
1146
|
+
* @Get('hot-data')
|
|
1147
|
+
* @Cacheable({ key: 'hot' })
|
|
1148
|
+
* @CacheTTL(30)
|
|
1149
|
+
* @UseInterceptors(CacheInterceptor)
|
|
1150
|
+
* async getHotData() {
|
|
1151
|
+
* return this.dataService.getHot()
|
|
1152
|
+
* }
|
|
1153
|
+
* ```
|
|
1154
|
+
*/
|
|
1155
|
+
declare function CacheTTL(seconds: number): MethodDecorator;
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* Intercepts controller route handlers decorated with @Cacheable, @CacheEvict, or @CachePut.
|
|
1159
|
+
*
|
|
1160
|
+
* Apply via `@UseInterceptors(CacheInterceptor)` on a controller class or individual method.
|
|
1161
|
+
*
|
|
1162
|
+
* **⚠️ Only works on NestJS controller route handlers.** Plain service method calls are not
|
|
1163
|
+
* intercepted. For service-level caching, inject `CacheService` directly.
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```typescript
|
|
1167
|
+
* @Controller('posts')
|
|
1168
|
+
* @UseInterceptors(CacheInterceptor)
|
|
1169
|
+
* export class PostsController {
|
|
1170
|
+
* @Get(':id')
|
|
1171
|
+
* @Cacheable({ key: 'posts::id', ttl: 300 })
|
|
1172
|
+
* async getPost(@Param('id') id: string) { ... }
|
|
1173
|
+
* }
|
|
1174
|
+
* ```
|
|
1175
|
+
*/
|
|
1176
|
+
declare class CacheInterceptor implements NestInterceptor {
|
|
1177
|
+
private readonly cacheService;
|
|
1178
|
+
private readonly reflector;
|
|
1179
|
+
constructor(cacheService: CacheService, reflector: Reflector);
|
|
1180
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
1181
|
+
private handleCacheable;
|
|
1182
|
+
private handleEvict;
|
|
1183
|
+
private handlePut;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
909
1186
|
/**
|
|
910
1187
|
* Injection token for the auth strategy
|
|
911
1188
|
*/
|
|
@@ -1015,6 +1292,16 @@ declare class DynamicAuthGuard implements CanActivate {
|
|
|
1015
1292
|
static strategyName: string;
|
|
1016
1293
|
canActivate(context: ExecutionContext): Promise<boolean> | boolean;
|
|
1017
1294
|
}
|
|
1295
|
+
/**
|
|
1296
|
+
* OptionalDynamicAuthGuard populates req.user when a valid token is present
|
|
1297
|
+
* but allows the request through even without authentication.
|
|
1298
|
+
*
|
|
1299
|
+
* Use this for endpoints that behave differently when authenticated
|
|
1300
|
+
* (e.g., /auth/status returns onboardingCompleted only for authenticated users).
|
|
1301
|
+
*/
|
|
1302
|
+
declare class OptionalDynamicAuthGuard implements CanActivate {
|
|
1303
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
1304
|
+
}
|
|
1018
1305
|
|
|
1019
1306
|
declare const JwtAuthGuard_base: _nestjs_passport.Type<_nestjs_passport.IAuthGuard>;
|
|
1020
1307
|
declare class JwtAuthGuard extends JwtAuthGuard_base {
|
|
@@ -1442,114 +1729,6 @@ declare class DocumentService {
|
|
|
1442
1729
|
}>>;
|
|
1443
1730
|
}
|
|
1444
1731
|
|
|
1445
|
-
declare class MetadataExtractorService {
|
|
1446
|
-
extractControllerMetadata(wrapper: InstanceWrapper<object>): ControllerMetadata;
|
|
1447
|
-
extractMethodMetadata(instance: object, method: string): MethodMetadata | null;
|
|
1448
|
-
extractSchemaMetadata(wrapper: InstanceWrapper<unknown>): SchemaMetadata | null;
|
|
1449
|
-
/**
|
|
1450
|
-
* Build schema properties from Field metadata, Setting Field metadata, and legacy Prop/UI metadata.
|
|
1451
|
-
* Priority: Field metadata > Setting Field metadata > legacy Prop/UI metadata
|
|
1452
|
-
*/
|
|
1453
|
-
private buildProperties;
|
|
1454
|
-
/**
|
|
1455
|
-
* Get the type name from field metadata
|
|
1456
|
-
*/
|
|
1457
|
-
private getTypeNameFromFieldMetadata;
|
|
1458
|
-
/**
|
|
1459
|
-
* Get type name from a type constructor or design type
|
|
1460
|
-
*/
|
|
1461
|
-
private getTypeName;
|
|
1462
|
-
/**
|
|
1463
|
-
* Check if a field is an array type
|
|
1464
|
-
*/
|
|
1465
|
-
private isArrayField;
|
|
1466
|
-
/**
|
|
1467
|
-
* Build UI options from field metadata
|
|
1468
|
-
*/
|
|
1469
|
-
private buildUIFromFieldMetadata;
|
|
1470
|
-
/**
|
|
1471
|
-
* Convert select/enum options to UI format
|
|
1472
|
-
*/
|
|
1473
|
-
private convertSelectOptions;
|
|
1474
|
-
/**
|
|
1475
|
-
* Get ref (relationship reference) from field metadata
|
|
1476
|
-
*/
|
|
1477
|
-
private getRefFromFieldMetadata;
|
|
1478
|
-
/**
|
|
1479
|
-
* Get the type name from setting field metadata
|
|
1480
|
-
*/
|
|
1481
|
-
private getTypeNameFromSettingFieldMetadata;
|
|
1482
|
-
/**
|
|
1483
|
-
* Build UI options from setting field metadata
|
|
1484
|
-
*/
|
|
1485
|
-
private buildUIFromSettingFieldMetadata;
|
|
1486
|
-
/**
|
|
1487
|
-
* Convert setting select options to UI format
|
|
1488
|
-
*/
|
|
1489
|
-
private convertSettingSelectOptions;
|
|
1490
|
-
getParamDetails(controller: Function, methodName: string): {
|
|
1491
|
-
arg: string;
|
|
1492
|
-
type: string;
|
|
1493
|
-
name: string;
|
|
1494
|
-
}[];
|
|
1495
|
-
private getValidationMetadata;
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
declare class ControllerDiscoveryService {
|
|
1499
|
-
private readonly modulesContainer;
|
|
1500
|
-
private readonly metadataExtractor;
|
|
1501
|
-
constructor(modulesContainer: ModulesContainer, metadataExtractor: MetadataExtractorService);
|
|
1502
|
-
discoverControllers(): ControllerMetadata[];
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
declare class MethodDiscoveryService {
|
|
1506
|
-
private readonly modulesContainer;
|
|
1507
|
-
private readonly metadataExtractor;
|
|
1508
|
-
constructor(modulesContainer: ModulesContainer, metadataExtractor: MetadataExtractorService);
|
|
1509
|
-
getMethodDetails(path: string, methodName: string, controllers: ControllerMetadata[]): MethodMetadata | {
|
|
1510
|
-
error: string;
|
|
1511
|
-
};
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
declare class SchemaDiscoveryService {
|
|
1515
|
-
private readonly modulesContainer;
|
|
1516
|
-
private readonly metadataExtractor;
|
|
1517
|
-
constructor(modulesContainer: ModulesContainer, metadataExtractor: MetadataExtractorService);
|
|
1518
|
-
discoverSchemas(): {
|
|
1519
|
-
schemas: SchemaMetadata[];
|
|
1520
|
-
settings: SchemaMetadata[];
|
|
1521
|
-
};
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
declare class DiscoveryService implements OnModuleInit {
|
|
1525
|
-
private readonly controllerDiscovery;
|
|
1526
|
-
private readonly schemaDiscovery;
|
|
1527
|
-
private readonly methodDiscovery;
|
|
1528
|
-
private controllers;
|
|
1529
|
-
private schemas;
|
|
1530
|
-
private settingsSchemas;
|
|
1531
|
-
constructor(controllerDiscovery: ControllerDiscoveryService, schemaDiscovery: SchemaDiscoveryService, methodDiscovery: MethodDiscoveryService);
|
|
1532
|
-
onModuleInit(): void;
|
|
1533
|
-
getDiscoveredSchemas(): string[];
|
|
1534
|
-
getAllDiscoveredSchemas(): SchemaMetadata[];
|
|
1535
|
-
getDiscoveredSchema(name: string): SchemaMetadata | {
|
|
1536
|
-
error: string;
|
|
1537
|
-
};
|
|
1538
|
-
getDiscoveredSettingsSchemas(): string[];
|
|
1539
|
-
getAllDiscoveredSettingsSchemas(): SchemaMetadata[];
|
|
1540
|
-
getDiscoveredSettingsSchemaNames(): string[];
|
|
1541
|
-
getDiscoveredSettingsSchema(name: string): SchemaMetadata | {
|
|
1542
|
-
error: string;
|
|
1543
|
-
};
|
|
1544
|
-
getDiscoveredControllers(): string[];
|
|
1545
|
-
getDiscoveredController(name: string): ControllerMetadata | {
|
|
1546
|
-
error: string;
|
|
1547
|
-
};
|
|
1548
|
-
getMethodDetails(path: string, methodName: string): MethodMetadata | {
|
|
1549
|
-
error: string;
|
|
1550
|
-
};
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
1732
|
declare class ContentService {
|
|
1554
1733
|
private readonly moduleRef;
|
|
1555
1734
|
private readonly documentService;
|
|
@@ -2304,57 +2483,16 @@ declare const PLUGIN_MODULE = "plugin:module";
|
|
|
2304
2483
|
/**
|
|
2305
2484
|
* Generate standardized options token for a plugin.
|
|
2306
2485
|
*
|
|
2307
|
-
* @param pluginName - The plugin name (e.g., '
|
|
2308
|
-
* @returns Token string (e.g., '
|
|
2486
|
+
* @param pluginName - The plugin name (e.g., 'playground')
|
|
2487
|
+
* @returns Token string (e.g., 'PLUGIN_PLAYGROUND_OPTIONS')
|
|
2309
2488
|
*
|
|
2310
2489
|
* @example
|
|
2311
2490
|
* ```ts
|
|
2312
|
-
* getPluginOptionsToken('
|
|
2491
|
+
* getPluginOptionsToken('playground') // 'PLUGIN_PLAYGROUND_OPTIONS'
|
|
2313
2492
|
* ```
|
|
2314
2493
|
*/
|
|
2315
2494
|
declare function getPluginOptionsToken(pluginName: string): string;
|
|
2316
2495
|
|
|
2317
|
-
interface RegisteredPlugin {
|
|
2318
|
-
metadata: PluginMetadata;
|
|
2319
|
-
instance: unknown;
|
|
2320
|
-
frontendManifest?: PluginFrontendManifest;
|
|
2321
|
-
config: PluginConfig;
|
|
2322
|
-
}
|
|
2323
|
-
declare class PluginRegistryService implements OnModuleInit {
|
|
2324
|
-
private readonly modulesContainer;
|
|
2325
|
-
private readonly logger;
|
|
2326
|
-
private readonly pluginsConfig;
|
|
2327
|
-
private plugins;
|
|
2328
|
-
constructor(modulesContainer: ModulesContainer, logger: MagnetLogger, pluginsConfig?: PluginConfig[]);
|
|
2329
|
-
onModuleInit(): void;
|
|
2330
|
-
private discoverPlugins;
|
|
2331
|
-
/**
|
|
2332
|
-
* Get a registered plugin by name
|
|
2333
|
-
*/
|
|
2334
|
-
getPlugin(name: string): RegisteredPlugin | undefined;
|
|
2335
|
-
/**
|
|
2336
|
-
* Get all registered plugins
|
|
2337
|
-
*/
|
|
2338
|
-
getAllPlugins(): RegisteredPlugin[];
|
|
2339
|
-
/**
|
|
2340
|
-
* Get metadata for all plugins
|
|
2341
|
-
*/
|
|
2342
|
-
getPluginMetadata(): PluginMetadata[];
|
|
2343
|
-
/**
|
|
2344
|
-
* Get frontend manifests for all plugins with bundle URLs
|
|
2345
|
-
* Used by admin UI to dynamically load plugin frontends at runtime
|
|
2346
|
-
*/
|
|
2347
|
-
getFrontendManifests(): EnrichedPluginManifest[];
|
|
2348
|
-
/**
|
|
2349
|
-
* Get full plugin info for API response
|
|
2350
|
-
*/
|
|
2351
|
-
getPluginInfo(name: string): RegisteredPluginInfo | null;
|
|
2352
|
-
/**
|
|
2353
|
-
* Get all plugins info for API response
|
|
2354
|
-
*/
|
|
2355
|
-
getAllPluginsInfo(): RegisteredPluginInfo[];
|
|
2356
|
-
}
|
|
2357
|
-
|
|
2358
2496
|
declare class PluginController {
|
|
2359
2497
|
private readonly registry;
|
|
2360
2498
|
constructor(registry: PluginRegistryService);
|
|
@@ -2414,464 +2552,6 @@ declare class PluginService implements OnModuleInit {
|
|
|
2414
2552
|
executeHook(hookName: string, ...args: unknown[]): Promise<unknown[]>;
|
|
2415
2553
|
}
|
|
2416
2554
|
|
|
2417
|
-
/**
|
|
2418
|
-
* Permission schema for persisting discovered permissions.
|
|
2419
|
-
*
|
|
2420
|
-
* Permissions are auto-registered from:
|
|
2421
|
-
* - Schema definitions (CRUD)
|
|
2422
|
-
* - Controller methods (@RequirePermission)
|
|
2423
|
-
* - Plugins
|
|
2424
|
-
* - System definitions
|
|
2425
|
-
*
|
|
2426
|
-
* Used for validation when assigning permissions to roles.
|
|
2427
|
-
*/
|
|
2428
|
-
declare class Permission {
|
|
2429
|
-
/**
|
|
2430
|
-
* Unique permission identifier (e.g., 'content.cat.create', 'roles.find')
|
|
2431
|
-
* This is the key used when assigning permissions to roles.
|
|
2432
|
-
*/
|
|
2433
|
-
permissionId: string;
|
|
2434
|
-
/**
|
|
2435
|
-
* Human-readable name for the admin UI
|
|
2436
|
-
*/
|
|
2437
|
-
name: string;
|
|
2438
|
-
/**
|
|
2439
|
-
* Description for the admin UI
|
|
2440
|
-
*/
|
|
2441
|
-
description?: string;
|
|
2442
|
-
/**
|
|
2443
|
-
* Group for organization (e.g., 'Content', 'Users', 'Settings')
|
|
2444
|
-
*/
|
|
2445
|
-
group?: string;
|
|
2446
|
-
/**
|
|
2447
|
-
* API identifier (e.g., 'api::posts', 'plugin::content-builder', 'system::users')
|
|
2448
|
-
*/
|
|
2449
|
-
apiId?: string;
|
|
2450
|
-
/**
|
|
2451
|
-
* Source of this permission
|
|
2452
|
-
*/
|
|
2453
|
-
source?: PermissionSource;
|
|
2454
|
-
/**
|
|
2455
|
-
* Controller name if discovered from controller
|
|
2456
|
-
*/
|
|
2457
|
-
controller?: string;
|
|
2458
|
-
/**
|
|
2459
|
-
* Method name if discovered from controller
|
|
2460
|
-
*/
|
|
2461
|
-
method?: string;
|
|
2462
|
-
/**
|
|
2463
|
-
* Plugin name if from plugin
|
|
2464
|
-
*/
|
|
2465
|
-
plugin?: string;
|
|
2466
|
-
/**
|
|
2467
|
-
* Schema name if auto-generated from schema
|
|
2468
|
-
*/
|
|
2469
|
-
schema?: string;
|
|
2470
|
-
/**
|
|
2471
|
-
* When this permission was first registered
|
|
2472
|
-
*/
|
|
2473
|
-
createdAt: Date;
|
|
2474
|
-
/**
|
|
2475
|
-
* When this permission was last updated
|
|
2476
|
-
*/
|
|
2477
|
-
updatedAt?: Date;
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
|
-
interface ValidatePermissionIdsResult {
|
|
2481
|
-
valid: string[];
|
|
2482
|
-
invalid: string[];
|
|
2483
|
-
}
|
|
2484
|
-
/**
|
|
2485
|
-
* Service for persisting and validating permissions.
|
|
2486
|
-
*
|
|
2487
|
-
* Permissions are synced from PermissionDiscoveryService on startup
|
|
2488
|
-
* and used to validate role permission assignments.
|
|
2489
|
-
*/
|
|
2490
|
-
declare class PermissionService {
|
|
2491
|
-
private readonly permissionModel;
|
|
2492
|
-
private readonly logger;
|
|
2493
|
-
constructor(permissionModel: Model<Permission>, logger: MagnetLogger);
|
|
2494
|
-
/**
|
|
2495
|
-
* Upsert a single permission from a definition
|
|
2496
|
-
*/
|
|
2497
|
-
upsertFromDefinition(def: PermissionDefinition): Promise<void>;
|
|
2498
|
-
/**
|
|
2499
|
-
* Batch upsert permissions from definitions
|
|
2500
|
-
*/
|
|
2501
|
-
upsertMany(definitions: PermissionDefinition[]): Promise<void>;
|
|
2502
|
-
/**
|
|
2503
|
-
* Find a permission by ID
|
|
2504
|
-
*/
|
|
2505
|
-
findById(permissionId: string): Promise<Permission | null>;
|
|
2506
|
-
/**
|
|
2507
|
-
* Get all registered permission IDs
|
|
2508
|
-
*/
|
|
2509
|
-
findAllIds(): Promise<string[]>;
|
|
2510
|
-
/**
|
|
2511
|
-
* Validate that all permission IDs exist (in DB or can be matched by wildcard)
|
|
2512
|
-
* Returns valid and invalid IDs.
|
|
2513
|
-
*/
|
|
2514
|
-
validatePermissionIds(ids: string[], knownIds?: string[]): Promise<ValidatePermissionIdsResult>;
|
|
2515
|
-
private definitionToPermissionData;
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
/**
|
|
2519
|
-
* Service for discovering all permissions in the system.
|
|
2520
|
-
*
|
|
2521
|
-
* Permissions are discovered from:
|
|
2522
|
-
* 1. Schema definitions - auto-generated CRUD permissions
|
|
2523
|
-
* 2. Controller methods - @RequirePermission decorated methods
|
|
2524
|
-
* 3. Plugins - permissions defined in plugin manifests
|
|
2525
|
-
*/
|
|
2526
|
-
declare class PermissionDiscoveryService implements OnModuleInit {
|
|
2527
|
-
private readonly discoveryService;
|
|
2528
|
-
private readonly modulesContainer;
|
|
2529
|
-
private readonly pluginRegistry;
|
|
2530
|
-
private readonly permissionService;
|
|
2531
|
-
private permissions;
|
|
2532
|
-
private initialized;
|
|
2533
|
-
constructor(discoveryService: DiscoveryService, modulesContainer: ModulesContainer, pluginRegistry: PluginRegistryService, permissionService: PermissionService);
|
|
2534
|
-
onModuleInit(): Promise<void>;
|
|
2535
|
-
/**
|
|
2536
|
-
* Discover all permissions from schemas, controllers, and plugins
|
|
2537
|
-
*/
|
|
2538
|
-
private discoverPermissions;
|
|
2539
|
-
/**
|
|
2540
|
-
* Auto-generate CRUD permissions for each discovered schema
|
|
2541
|
-
*/
|
|
2542
|
-
private discoverSchemaPermissions;
|
|
2543
|
-
/**
|
|
2544
|
-
* Discover @RequirePermission decorated methods from controllers
|
|
2545
|
-
*/
|
|
2546
|
-
private discoverControllerPermissions;
|
|
2547
|
-
/**
|
|
2548
|
-
* Extract permissions from a controller's methods
|
|
2549
|
-
*/
|
|
2550
|
-
private extractControllerPermissions;
|
|
2551
|
-
/**
|
|
2552
|
-
* Discover permissions from registered plugins
|
|
2553
|
-
*/
|
|
2554
|
-
private discoverPluginPermissions;
|
|
2555
|
-
/**
|
|
2556
|
-
* Add system-level permissions
|
|
2557
|
-
*/
|
|
2558
|
-
private discoverSystemPermissions;
|
|
2559
|
-
/**
|
|
2560
|
-
* Get all discovered permissions
|
|
2561
|
-
*/
|
|
2562
|
-
getAll(): PermissionDefinition[];
|
|
2563
|
-
/**
|
|
2564
|
-
* Get a specific permission by ID
|
|
2565
|
-
*/
|
|
2566
|
-
get(id: string): PermissionDefinition | undefined;
|
|
2567
|
-
/**
|
|
2568
|
-
* Check if a permission exists
|
|
2569
|
-
*/
|
|
2570
|
-
has(id: string): boolean;
|
|
2571
|
-
/**
|
|
2572
|
-
* Get permissions grouped for UI display
|
|
2573
|
-
*/
|
|
2574
|
-
getGrouped(): PermissionGroup[];
|
|
2575
|
-
/**
|
|
2576
|
-
* Get permissions categorized by type (for admin UI)
|
|
2577
|
-
* - collectionTypes: schema-based (api::*), each schema = one accordion
|
|
2578
|
-
* - controllers: from @RequirePermission, each controller = one accordion
|
|
2579
|
-
* - plugins: plugin::*
|
|
2580
|
-
* - system: system::*
|
|
2581
|
-
*/
|
|
2582
|
-
getCategorized(): CategorizedPermissions;
|
|
2583
|
-
/**
|
|
2584
|
-
* Group controller permissions by controller (each = one accordion)
|
|
2585
|
-
*/
|
|
2586
|
-
private groupByController;
|
|
2587
|
-
/**
|
|
2588
|
-
* Get permissions for a specific schema
|
|
2589
|
-
*/
|
|
2590
|
-
getSchemaPermissions(schemaName: string): PermissionDefinition[];
|
|
2591
|
-
/**
|
|
2592
|
-
* Get permissions for a specific plugin
|
|
2593
|
-
*/
|
|
2594
|
-
getPluginPermissions(pluginName: string): PermissionDefinition[];
|
|
2595
|
-
/**
|
|
2596
|
-
* Mark permissions as checked/unchecked based on role's permissions
|
|
2597
|
-
*/
|
|
2598
|
-
markPermissions(groups: PermissionGroup[], rolePermissions: string[]): PermissionGroup[];
|
|
2599
|
-
/**
|
|
2600
|
-
* Check if a permission is enabled (including wildcard matching)
|
|
2601
|
-
*/
|
|
2602
|
-
private isPermissionEnabled;
|
|
2603
|
-
/**
|
|
2604
|
-
* Get human-readable action label
|
|
2605
|
-
*/
|
|
2606
|
-
private getActionLabel;
|
|
2607
|
-
/**
|
|
2608
|
-
* Format permission ID into a readable name
|
|
2609
|
-
*/
|
|
2610
|
-
private formatPermissionName;
|
|
2611
|
-
}
|
|
2612
|
-
|
|
2613
|
-
/**
|
|
2614
|
-
* DTO for creating a new role
|
|
2615
|
-
*/
|
|
2616
|
-
declare class CreateRoleDto {
|
|
2617
|
-
/**
|
|
2618
|
-
* Role slug (lowercase, no spaces)
|
|
2619
|
-
* Must start with a letter, can contain letters, numbers, and hyphens
|
|
2620
|
-
*/
|
|
2621
|
-
name: string;
|
|
2622
|
-
/**
|
|
2623
|
-
* Human-readable display name
|
|
2624
|
-
*/
|
|
2625
|
-
displayName: string;
|
|
2626
|
-
/**
|
|
2627
|
-
* Optional description
|
|
2628
|
-
*/
|
|
2629
|
-
description?: string;
|
|
2630
|
-
/**
|
|
2631
|
-
* Initial permissions to assign
|
|
2632
|
-
*/
|
|
2633
|
-
permissions?: string[];
|
|
2634
|
-
}
|
|
2635
|
-
|
|
2636
|
-
/**
|
|
2637
|
-
* DTO for duplicating a role
|
|
2638
|
-
*/
|
|
2639
|
-
declare class DuplicateRoleDto {
|
|
2640
|
-
/**
|
|
2641
|
-
* Name for the new role (slug)
|
|
2642
|
-
*/
|
|
2643
|
-
name: string;
|
|
2644
|
-
/**
|
|
2645
|
-
* Optional display name for the new role
|
|
2646
|
-
* If not provided, defaults to "Copy of [original]"
|
|
2647
|
-
*/
|
|
2648
|
-
displayName?: string;
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
/**
|
|
2652
|
-
* DTO for updating a role
|
|
2653
|
-
*/
|
|
2654
|
-
declare class UpdateRoleDto {
|
|
2655
|
-
/**
|
|
2656
|
-
* Updated display name
|
|
2657
|
-
*/
|
|
2658
|
-
displayName?: string;
|
|
2659
|
-
/**
|
|
2660
|
-
* Updated description
|
|
2661
|
-
*/
|
|
2662
|
-
description?: string;
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
/**
|
|
2666
|
-
* Role schema for storing user roles and their permissions.
|
|
2667
|
-
*
|
|
2668
|
-
* Roles contain:
|
|
2669
|
-
* - A unique name (slug) for programmatic access
|
|
2670
|
-
* - A display name for UI
|
|
2671
|
-
* - An array of permission IDs
|
|
2672
|
-
* - System flag for protecting default roles
|
|
2673
|
-
*/
|
|
2674
|
-
declare class Role {
|
|
2675
|
-
/**
|
|
2676
|
-
* Unique role identifier (slug)
|
|
2677
|
-
* Used for programmatic access (e.g., 'admin', 'editor', 'authenticated')
|
|
2678
|
-
*/
|
|
2679
|
-
name: string;
|
|
2680
|
-
/**
|
|
2681
|
-
* Human-readable display name
|
|
2682
|
-
*/
|
|
2683
|
-
displayName: string;
|
|
2684
|
-
/**
|
|
2685
|
-
* Role description for admin UI
|
|
2686
|
-
*/
|
|
2687
|
-
description?: string;
|
|
2688
|
-
/**
|
|
2689
|
-
* Array of permission IDs assigned to this role
|
|
2690
|
-
* Use '*' for wildcard (all permissions)
|
|
2691
|
-
* Use 'content.*' for category wildcard
|
|
2692
|
-
*/
|
|
2693
|
-
permissions: string[];
|
|
2694
|
-
/**
|
|
2695
|
-
* Whether this is a system role (cannot be deleted)
|
|
2696
|
-
* System roles: admin, authenticated, public
|
|
2697
|
-
*/
|
|
2698
|
-
isSystem: boolean;
|
|
2699
|
-
/**
|
|
2700
|
-
* User count (computed, not stored)
|
|
2701
|
-
* Populated when listing roles
|
|
2702
|
-
*/
|
|
2703
|
-
userCount?: number;
|
|
2704
|
-
/**
|
|
2705
|
-
* When this role was created
|
|
2706
|
-
*/
|
|
2707
|
-
createdAt: Date;
|
|
2708
|
-
/**
|
|
2709
|
-
* When this role was last updated
|
|
2710
|
-
*/
|
|
2711
|
-
updatedAt?: Date;
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
/**
|
|
2715
|
-
* Service for managing roles and checking permissions
|
|
2716
|
-
*/
|
|
2717
|
-
declare class RoleService implements OnModuleInit {
|
|
2718
|
-
private readonly roleModel;
|
|
2719
|
-
private readonly permissionDiscovery;
|
|
2720
|
-
private readonly permissionService;
|
|
2721
|
-
private readonly eventService;
|
|
2722
|
-
private readonly userService;
|
|
2723
|
-
private readonly logger;
|
|
2724
|
-
private permissionCache;
|
|
2725
|
-
private cacheEnabled;
|
|
2726
|
-
private cacheTTL;
|
|
2727
|
-
constructor(roleModel: Model<Role>, permissionDiscovery: PermissionDiscoveryService, permissionService: PermissionService, eventService: EventService, userService: UserService, logger: MagnetLogger);
|
|
2728
|
-
onModuleInit(): Promise<void>;
|
|
2729
|
-
/**
|
|
2730
|
-
* Ensure default system roles exist
|
|
2731
|
-
*/
|
|
2732
|
-
private ensureDefaultRoles;
|
|
2733
|
-
/**
|
|
2734
|
-
* Get all roles
|
|
2735
|
-
*/
|
|
2736
|
-
findAll(): Promise<Role[]>;
|
|
2737
|
-
/**
|
|
2738
|
-
* Get all roles with user counts
|
|
2739
|
-
*/
|
|
2740
|
-
findAllWithCounts(): Promise<(Role & {
|
|
2741
|
-
userCount: number;
|
|
2742
|
-
})[]>;
|
|
2743
|
-
/**
|
|
2744
|
-
* Get a role by ID
|
|
2745
|
-
*/
|
|
2746
|
-
findById(id: string): Promise<Role | null>;
|
|
2747
|
-
/**
|
|
2748
|
-
* Get a role by name
|
|
2749
|
-
*/
|
|
2750
|
-
findByName(name: string): Promise<Role | null>;
|
|
2751
|
-
/**
|
|
2752
|
-
* Get a role with all permissions resolved
|
|
2753
|
-
*/
|
|
2754
|
-
findByIdWithPermissions(id: string): Promise<RoleWithPermissions>;
|
|
2755
|
-
/**
|
|
2756
|
-
* Get a role by name with all permissions resolved
|
|
2757
|
-
*/
|
|
2758
|
-
findByNameWithPermissions(name: string): Promise<RoleWithPermissions>;
|
|
2759
|
-
/**
|
|
2760
|
-
* Create a new role
|
|
2761
|
-
*/
|
|
2762
|
-
create(dto: CreateRoleDto): Promise<Role>;
|
|
2763
|
-
/**
|
|
2764
|
-
* Update a role
|
|
2765
|
-
*/
|
|
2766
|
-
update(id: string, dto: UpdateRoleDto): Promise<Role>;
|
|
2767
|
-
/**
|
|
2768
|
-
* Update role permissions
|
|
2769
|
-
*/
|
|
2770
|
-
updatePermissions(id: string, permissions: string[]): Promise<Role>;
|
|
2771
|
-
/**
|
|
2772
|
-
* Delete a role (non-system roles only)
|
|
2773
|
-
*/
|
|
2774
|
-
delete(id: string): Promise<void>;
|
|
2775
|
-
/**
|
|
2776
|
-
* Duplicate a role
|
|
2777
|
-
*/
|
|
2778
|
-
duplicate(id: string, dto: DuplicateRoleDto): Promise<Role>;
|
|
2779
|
-
/**
|
|
2780
|
-
* Check if a user has a specific permission
|
|
2781
|
-
*/
|
|
2782
|
-
hasPermission(userId: string, permission: string): Promise<boolean>;
|
|
2783
|
-
/**
|
|
2784
|
-
* Check if a role has a specific permission
|
|
2785
|
-
*/
|
|
2786
|
-
roleHasPermission(roleName: string, permission: string): Promise<boolean>;
|
|
2787
|
-
/**
|
|
2788
|
-
* Check if a permission list includes a permission (with wildcard support)
|
|
2789
|
-
*/
|
|
2790
|
-
checkPermission(rolePermissions: string[], permissionId: string): boolean;
|
|
2791
|
-
/**
|
|
2792
|
-
* Get all permissions a user has
|
|
2793
|
-
*/
|
|
2794
|
-
getUserPermissions(userId: string): Promise<string[]>;
|
|
2795
|
-
/**
|
|
2796
|
-
* Assign a role to a user
|
|
2797
|
-
*/
|
|
2798
|
-
assignRoleToUser(userId: string, roleName: string): Promise<void>;
|
|
2799
|
-
/**
|
|
2800
|
-
* Get all discovered permissions
|
|
2801
|
-
*/
|
|
2802
|
-
getAllPermissions(): CategorizedPermissions;
|
|
2803
|
-
/**
|
|
2804
|
-
* Enable or disable permission caching
|
|
2805
|
-
*/
|
|
2806
|
-
setCacheEnabled(enabled: boolean): void;
|
|
2807
|
-
/**
|
|
2808
|
-
* Set cache TTL
|
|
2809
|
-
*/
|
|
2810
|
-
setCacheTTL(ttlMs: number): void;
|
|
2811
|
-
/**
|
|
2812
|
-
* Clear the permission cache
|
|
2813
|
-
*/
|
|
2814
|
-
clearCache(): void;
|
|
2815
|
-
/**
|
|
2816
|
-
* Invalidate cache for a specific role
|
|
2817
|
-
*/
|
|
2818
|
-
private invalidateRoleCache;
|
|
2819
|
-
private getCachedPermission;
|
|
2820
|
-
private setCachedPermission;
|
|
2821
|
-
/**
|
|
2822
|
-
* Resolve a role with all permissions marked
|
|
2823
|
-
*/
|
|
2824
|
-
private resolveRolePermissions;
|
|
2825
|
-
/**
|
|
2826
|
-
* Get role ID (handles both string ID and _id from MongoDB)
|
|
2827
|
-
*/
|
|
2828
|
-
private getRoleId;
|
|
2829
|
-
/**
|
|
2830
|
-
* Check if a role name is a system role
|
|
2831
|
-
*/
|
|
2832
|
-
isSystemRole(roleName: string): boolean;
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
|
-
/**
|
|
2836
|
-
* Guard that checks if the authenticated user has the required permission.
|
|
2837
|
-
*
|
|
2838
|
-
* Usage:
|
|
2839
|
-
* ```typescript
|
|
2840
|
-
* @Get()
|
|
2841
|
-
* @UseGuards(DynamicAuthGuard, PermissionGuard)
|
|
2842
|
-
* @RequirePermission({
|
|
2843
|
-
* id: 'content.posts.find',
|
|
2844
|
-
* name: 'List Posts',
|
|
2845
|
-
* description: 'View list of posts',
|
|
2846
|
-
* })
|
|
2847
|
-
* async findAll() { ... }
|
|
2848
|
-
* ```
|
|
2849
|
-
*
|
|
2850
|
-
* Supports dynamic permission IDs with placeholders:
|
|
2851
|
-
* ```typescript
|
|
2852
|
-
* @RequirePermission({
|
|
2853
|
-
* id: 'content.{schema}.find',
|
|
2854
|
-
* name: 'Find',
|
|
2855
|
-
* })
|
|
2856
|
-
* async find(@Param('schema') schema: string) { ... }
|
|
2857
|
-
* ```
|
|
2858
|
-
*/
|
|
2859
|
-
declare class PermissionGuard implements CanActivate {
|
|
2860
|
-
private readonly reflector;
|
|
2861
|
-
private readonly roleService;
|
|
2862
|
-
private readonly logger;
|
|
2863
|
-
constructor(reflector: Reflector, roleService: RoleService, logger: MagnetLogger);
|
|
2864
|
-
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
2865
|
-
/**
|
|
2866
|
-
* Get permission options from decorator or resolved permission
|
|
2867
|
-
*/
|
|
2868
|
-
private getPermissionOptions;
|
|
2869
|
-
/**
|
|
2870
|
-
* Resolve dynamic permission placeholders
|
|
2871
|
-
*/
|
|
2872
|
-
private resolvePermission;
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2875
2555
|
/**
|
|
2876
2556
|
* Interceptor that resolves dynamic permission placeholders.
|
|
2877
2557
|
*
|
|
@@ -3895,4 +3575,4 @@ declare class GeneralSettings {
|
|
|
3895
3575
|
fallbackToDefaultLocale: boolean;
|
|
3896
3576
|
}
|
|
3897
3577
|
|
|
3898
|
-
export { API_KEY_PERMISSION_KEY, API_KEY_SCHEMA_KEY, AUTH_CONFIG, AUTH_STRATEGY, Activity, ActivityController, ActivityModule, type ActivitySearchQuery, ActivityService, ActivitySettings, AdminController, AdminModule, AdminService, ApiKey, ApiKeyGuard, type ApiKeyPermissionScope, type ApiKeyRequest, ApiKeyService, ApiKeySettings, type ApiKeyStats, ApiKeyUsage, AssignRoleDto, AuthModule, AuthSettings, CRUD_ACTIONS, ContentController, ContentService, ContentSettings, type CreateActivityDto, CreateApiKeyDto, type CreateApiKeyResult, type CreateDocumentOptions,
|
|
3578
|
+
export { API_KEY_PERMISSION_KEY, API_KEY_SCHEMA_KEY, AUTH_CONFIG, AUTH_STRATEGY, Activity, ActivityController, ActivityModule, type ActivitySearchQuery, ActivityService, ActivitySettings, AdminController, AdminModule, AdminService, ApiKey, ApiKeyGuard, type ApiKeyPermissionScope, type ApiKeyRequest, ApiKeyService, ApiKeySettings, type ApiKeyStats, ApiKeyUsage, AssignRoleDto, AuthModule, AuthSettings, CACHE_ADAPTER_TOKEN, CACHE_METADATA_KEY, CACHE_TTL_KEY, CRUD_ACTIONS, CacheEvict, type CacheEvictOptions, CacheInterceptor, CachePut, type CachePutOptions, CacheService, CacheSettings, CacheTTL, Cacheable, type CacheableOptions, ContentController, ContentService, ContentSettings, type CreateActivityDto, CreateApiKeyDto, type CreateApiKeyResult, type CreateDocumentOptions, CreateUserDto, type CrudAction, CurrentApiKey, DEFAULT_ROLES, type DeliveryResult, type Document, type DocumentGroup, type DocumentMetadata, DocumentService, type DocumentStatus, DynamicAuthGuard, DynamicPermissionInterceptor, EmailModule, EmailService, EmailVerificationService, EnvironmentController, type EnvironmentItem, EnvironmentModule, EnvironmentService, Environments, type FindDocumentOptions, type FolderInfo, GeneralModule, GeneralSettings, HistoryController, HistoryService, type HttpMethod, JwtAuthGuard, JwtAuthStrategy, type ListDocumentOptions, LocalStorageAdapter, LogUsageDto, Media, MediaFolder, MediaSettings, MemoryCacheAdapter, type MemoryCacheAdapterOptions, NOTIFICATION_MODULE_OPTIONS, Notification, NotificationController, NotificationModuleOptions, NotificationService, NotificationSettings, OptionalDynamicAuthGuard, PERMISSION_CATEGORIES, PLUGIN_FRONTEND_MANIFEST, PLUGIN_METADATA, PLUGIN_MODULE, type PaginatedActivities, type PaginatedDeliveries, PaginatedUserResult, PluginController, PluginLifecycleService, PluginRegistryService, PluginService, type PublishDocumentOptions, RBACSettings, RBAC_CONFIG, ROLE_MODEL, type RateLimitResult, RequireApiKeyPermission, RequireApiKeySchema, STORAGE_ADAPTER, STORAGE_CONFIG, SettingsService, StorageModule, StorageService, TemplateService, USER_EXTENSION_TOKEN, UpdateApiKeyDto, type UpdateDocumentOptions, UpdatePermissionsDto, UpsertViewConfigDto, User, UserController, UserExtensionService, UserModule, UserService, type VersionDiff, type VersionFieldChange, type VersionSummary, ViewConfig, type ViewConfigColumn, ViewConfigModule, ViewConfigService, WILDCARD_PERMISSION, WebhookListenerService, WebhookModule, WebhookService, WebhookSettings, generateDocumentId, getPluginOptionsToken, isValidDocumentId, locales, timezones };
|