@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
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import * as _magnet_cms_common from '@magnet-cms/common';
|
|
2
|
-
import { LogMetadata, EventName, EventHandler, EventHandlerOptions, EventPayload, BaseEventPayload, EventHistoryEntry, PluginMetadata, PluginFrontendManifest, Model, AuthConfig, AuthStrategy } from '@magnet-cms/common';
|
|
3
|
-
import { LoggerService, OnModuleDestroy, Type } from '@nestjs/common';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Structured logger for Magnet CMS.
|
|
7
|
-
*
|
|
8
|
-
* Implements NestJS LoggerService with JSON/pretty output, log level
|
|
9
|
-
* filtering, sensitive field redaction, and automatic request context
|
|
10
|
-
* enrichment from EventContext (AsyncLocalStorage).
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* constructor(private readonly logger: MagnetLogger) {
|
|
15
|
-
* this.logger.setContext(MyService.name)
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* doWork() {
|
|
19
|
-
* this.logger.log('Starting work', { operation: 'doWork' })
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
declare class MagnetLogger implements LoggerService {
|
|
24
|
-
private context;
|
|
25
|
-
private cachedConfig;
|
|
26
|
-
/** Create a standalone logger instance (for use before DI is available). */
|
|
27
|
-
static create(context?: string): MagnetLogger;
|
|
28
|
-
/** Set the logger context (service name). Call in constructor. */
|
|
29
|
-
setContext(context: string): void;
|
|
30
|
-
/** Return a child logger with a namespaced context (parent:child). */
|
|
31
|
-
child(context: string): MagnetLogger;
|
|
32
|
-
log(message: string, metadata?: LogMetadata): void;
|
|
33
|
-
error(message: string, trace?: unknown, metadata?: LogMetadata): void;
|
|
34
|
-
warn(message: string, metadata?: LogMetadata): void;
|
|
35
|
-
debug(message: string, metadata?: LogMetadata): void;
|
|
36
|
-
verbose(message: string, metadata?: LogMetadata): void;
|
|
37
|
-
private getConfig;
|
|
38
|
-
private write;
|
|
39
|
-
private formatJson;
|
|
40
|
-
private formatPretty;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Type-safe event service for decoupled communication between modules.
|
|
45
|
-
*
|
|
46
|
-
* Features:
|
|
47
|
-
* - Type-safe events with payload validation
|
|
48
|
-
* - Priority-based handler execution
|
|
49
|
-
* - Async handlers that don't block the request
|
|
50
|
-
* - Error isolation (one handler failure doesn't affect others)
|
|
51
|
-
* - Event history for debugging
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* // Emitting events
|
|
56
|
-
* await this.eventService.emit('content.created', {
|
|
57
|
-
* schema: 'posts',
|
|
58
|
-
* documentId: '123',
|
|
59
|
-
* }, getEventContext())
|
|
60
|
-
*
|
|
61
|
-
* // Registering handlers programmatically
|
|
62
|
-
* const unsubscribe = this.eventService.on('content.created', async (payload) => {
|
|
63
|
-
* console.log('Content created:', payload.documentId)
|
|
64
|
-
* })
|
|
65
|
-
*
|
|
66
|
-
* // Or use the @OnEvent decorator
|
|
67
|
-
* @OnEvent('content.created')
|
|
68
|
-
* async handleContentCreated(payload: EventPayload<'content.created'>): Promise<void> {
|
|
69
|
-
* // ...
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
declare class EventService implements OnModuleDestroy {
|
|
74
|
-
private readonly logger;
|
|
75
|
-
private readonly handlers;
|
|
76
|
-
private readonly eventHistory;
|
|
77
|
-
private readonly maxHistorySize;
|
|
78
|
-
constructor(logger: MagnetLogger);
|
|
79
|
-
/**
|
|
80
|
-
* Register an event handler
|
|
81
|
-
*
|
|
82
|
-
* @param event - The event name to listen for
|
|
83
|
-
* @param handler - The handler function
|
|
84
|
-
* @param options - Handler options (priority, async, name)
|
|
85
|
-
* @returns Unsubscribe function
|
|
86
|
-
*/
|
|
87
|
-
on<E extends EventName>(event: E, handler: EventHandler<E>, options?: EventHandlerOptions): () => void;
|
|
88
|
-
/**
|
|
89
|
-
* Unregister an event handler
|
|
90
|
-
*
|
|
91
|
-
* @param event - The event name
|
|
92
|
-
* @param handler - The handler function to remove
|
|
93
|
-
*/
|
|
94
|
-
off<E extends EventName>(event: E, handler: EventHandler<E>): void;
|
|
95
|
-
/**
|
|
96
|
-
* Emit an event
|
|
97
|
-
*
|
|
98
|
-
* Executes sync handlers sequentially (awaiting each), then fires async
|
|
99
|
-
* handlers in parallel without waiting for them.
|
|
100
|
-
*
|
|
101
|
-
* @param event - The event name
|
|
102
|
-
* @param payload - The event payload (without base fields)
|
|
103
|
-
* @param context - Optional context (userId, requestId, ipAddress)
|
|
104
|
-
*/
|
|
105
|
-
emit<E extends EventName>(event: E, payload: Omit<EventPayload<E>, keyof BaseEventPayload>, context?: Partial<BaseEventPayload>): Promise<void>;
|
|
106
|
-
/**
|
|
107
|
-
* Emit multiple events
|
|
108
|
-
*
|
|
109
|
-
* Events are emitted sequentially in the order provided.
|
|
110
|
-
*
|
|
111
|
-
* @param events - Array of event objects with event name and payload
|
|
112
|
-
* @param context - Optional shared context for all events
|
|
113
|
-
*/
|
|
114
|
-
emitBatch(events: Array<{
|
|
115
|
-
event: EventName;
|
|
116
|
-
payload: Record<string, unknown>;
|
|
117
|
-
}>, context?: Partial<BaseEventPayload>): Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* Get recent event history (for debugging)
|
|
120
|
-
*
|
|
121
|
-
* @param limit - Maximum number of events to return (default 100)
|
|
122
|
-
* @returns Array of recent events
|
|
123
|
-
*/
|
|
124
|
-
getHistory(limit?: number): EventHistoryEntry[];
|
|
125
|
-
/**
|
|
126
|
-
* Get all registered handlers (for debugging)
|
|
127
|
-
*
|
|
128
|
-
* @returns Map of event names to handler info
|
|
129
|
-
*/
|
|
130
|
-
getHandlers(): Map<EventName, Array<{
|
|
131
|
-
name: string;
|
|
132
|
-
priority: number;
|
|
133
|
-
async: boolean;
|
|
134
|
-
}>>;
|
|
135
|
-
/**
|
|
136
|
-
* Check if an event has any handlers registered
|
|
137
|
-
*
|
|
138
|
-
* @param event - The event name to check
|
|
139
|
-
* @returns True if at least one handler is registered
|
|
140
|
-
*/
|
|
141
|
-
hasHandlers(event: EventName): boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Get the number of handlers for an event
|
|
144
|
-
*
|
|
145
|
-
* @param event - The event name
|
|
146
|
-
* @returns Number of registered handlers
|
|
147
|
-
*/
|
|
148
|
-
getHandlerCount(event: EventName): number;
|
|
149
|
-
/**
|
|
150
|
-
* Clear all handlers (for testing)
|
|
151
|
-
*/
|
|
152
|
-
clearAllHandlers(): void;
|
|
153
|
-
/**
|
|
154
|
-
* Clear event history (for testing)
|
|
155
|
-
*/
|
|
156
|
-
clearHistory(): void;
|
|
157
|
-
private addToHistory;
|
|
158
|
-
private logHandlerError;
|
|
159
|
-
onModuleDestroy(): void;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
interface PluginDecoratorOptions extends Omit<PluginMetadata, 'module'> {
|
|
163
|
-
/** Frontend manifest for this plugin */
|
|
164
|
-
frontend?: Omit<PluginFrontendManifest, 'pluginName'>;
|
|
165
|
-
/**
|
|
166
|
-
* NestJS module containing controllers/services (auto-imported).
|
|
167
|
-
* Use a getter () => MyModule to defer loading until after DatabaseModule.register().
|
|
168
|
-
*/
|
|
169
|
-
module?: Type<unknown> | (() => Type<unknown>);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Decorator to mark a class as a Magnet plugin
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```ts
|
|
176
|
-
* @Plugin({
|
|
177
|
-
* name: 'content-builder',
|
|
178
|
-
* description: 'Visual schema builder',
|
|
179
|
-
* version: '1.0.0',
|
|
180
|
-
* frontend: {
|
|
181
|
-
* routes: [{ path: 'playground', componentId: 'PlaygroundIndex' }],
|
|
182
|
-
* sidebar: [{ id: 'playground', title: 'Playground', url: '/playground', icon: 'Boxes' }]
|
|
183
|
-
* }
|
|
184
|
-
* })
|
|
185
|
-
* export class ContentBuilderPlugin {}
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
declare function Plugin(options: PluginDecoratorOptions): ClassDecorator;
|
|
189
|
-
|
|
190
|
-
declare function Hook(hookName: string): MethodDecorator;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Decorator to inject plugin options using standardized token.
|
|
194
|
-
*
|
|
195
|
-
* @param pluginName - The plugin name (e.g., 'content-builder')
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```ts
|
|
199
|
-
* @Injectable()
|
|
200
|
-
* export class MyService {
|
|
201
|
-
* constructor(
|
|
202
|
-
* @InjectPluginOptions('content-builder')
|
|
203
|
-
* private readonly options: ContentBuilderOptions
|
|
204
|
-
* ) {}
|
|
205
|
-
* }
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
declare function InjectPluginOptions(pluginName: string): ParameterDecorator;
|
|
209
|
-
|
|
210
|
-
declare class CreateUserDto {
|
|
211
|
-
id?: string;
|
|
212
|
-
email: string;
|
|
213
|
-
password?: string | null;
|
|
214
|
-
name: string;
|
|
215
|
-
role?: string;
|
|
216
|
-
provider?: string | null;
|
|
217
|
-
providerId?: string | null;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
declare class User {
|
|
221
|
-
email: string;
|
|
222
|
-
/** Null for OAuth-only users who have never set a local password */
|
|
223
|
-
password?: string | null;
|
|
224
|
-
name: string;
|
|
225
|
-
role?: string;
|
|
226
|
-
/** OAuth provider name (e.g. 'google', 'github'). Null for local-only users. */
|
|
227
|
-
provider?: string | null;
|
|
228
|
-
/** OAuth provider user ID. Null for local-only users. */
|
|
229
|
-
providerId?: string | null;
|
|
230
|
-
isActive?: boolean;
|
|
231
|
-
emailVerified?: boolean;
|
|
232
|
-
lastLogin?: Date;
|
|
233
|
-
createdAt?: Date;
|
|
234
|
-
hashPassword(): Promise<void>;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
interface PaginatedUserResult {
|
|
238
|
-
users: User[];
|
|
239
|
-
total: number;
|
|
240
|
-
page: number;
|
|
241
|
-
limit: number;
|
|
242
|
-
}
|
|
243
|
-
declare class UserService {
|
|
244
|
-
private readonly userModel;
|
|
245
|
-
constructor(userModel: Model<User>);
|
|
246
|
-
findAll(): Promise<_magnet_cms_common.BaseSchema<User>[]>;
|
|
247
|
-
findAllPaginated(page?: number, limit?: number): Promise<PaginatedUserResult>;
|
|
248
|
-
findOne(query: Partial<User>): Promise<_magnet_cms_common.BaseSchema<User> | null>;
|
|
249
|
-
findOneById(id: string): Promise<_magnet_cms_common.BaseSchema<User> | null>;
|
|
250
|
-
create(userData: CreateUserDto): Promise<_magnet_cms_common.BaseSchema<User>>;
|
|
251
|
-
update(id: string, updateUserDto: Partial<User>): Promise<_magnet_cms_common.BaseSchema<User>>;
|
|
252
|
-
remove(id: string): Promise<boolean>;
|
|
253
|
-
resetPassword(id: string, newPassword: string): Promise<{
|
|
254
|
-
message: string;
|
|
255
|
-
}>;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
type AuthStrategyConstructor = new (config: AuthConfig, userService: UserService) => AuthStrategy;
|
|
259
|
-
/**
|
|
260
|
-
* Factory for creating auth strategy instances.
|
|
261
|
-
*
|
|
262
|
-
* The JWT strategy is built-in. Other strategies (supabase, clerk)
|
|
263
|
-
* register themselves via their adapter's `.forRoot()` method.
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* ```typescript
|
|
267
|
-
* // Strategies are auto-registered by adapter forRoot():
|
|
268
|
-
* MagnetModule.forRoot([
|
|
269
|
-
* SupabaseAuthAdapter.forRoot(), // registers 'supabase' strategy internally
|
|
270
|
-
* ])
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
declare class AuthStrategyFactory {
|
|
274
|
-
private static cachedStrategy;
|
|
275
|
-
private static cachedConfig;
|
|
276
|
-
private static customStrategies;
|
|
277
|
-
/**
|
|
278
|
-
* Register a custom auth strategy class.
|
|
279
|
-
* Called internally by auth adapter `.forRoot()` methods.
|
|
280
|
-
*
|
|
281
|
-
* @param name - Unique name for the strategy (used in config.strategy)
|
|
282
|
-
* @param strategyClass - Class constructor implementing AuthStrategy
|
|
283
|
-
*/
|
|
284
|
-
static registerStrategy(name: string, strategyClass: AuthStrategyConstructor): void;
|
|
285
|
-
/**
|
|
286
|
-
* Get or create an auth strategy based on configuration.
|
|
287
|
-
* Called internally by AuthModule.forRoot().
|
|
288
|
-
*
|
|
289
|
-
* @param config - Auth configuration
|
|
290
|
-
* @param userService - UserService for database operations
|
|
291
|
-
* @param jwtSecret - JWT secret (fallback from global options)
|
|
292
|
-
*/
|
|
293
|
-
static getStrategy(config: AuthConfig | undefined, userService: UserService, jwtSecret: string): AuthStrategy;
|
|
294
|
-
/** Clear the cached strategy (useful for testing) */
|
|
295
|
-
static clearCache(): void;
|
|
296
|
-
/** Clear all registered custom strategies (useful for testing) */
|
|
297
|
-
static clearStrategies(): void;
|
|
298
|
-
/** Check if a strategy is registered */
|
|
299
|
-
static hasStrategy(name: string): boolean;
|
|
300
|
-
private static configMatches;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export { AuthStrategyFactory as A, CreateUserDto as C, EventService as E, Hook as H, InjectPluginOptions as I, MagnetLogger as M, Plugin as P, UserService as U, type PluginDecoratorOptions as a, User as b, type PaginatedUserResult as c };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { init_dist_es as init_dist_es$2, customEndpointFunctions, init_dist_es2 as init_dist_es2$1, init_dist_es3 as init_dist_es3$1, NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS, isValidHostLabel, isIpAddress, booleanSelector, SelectorType } from './chunk-27G65DL6.js';
|
|
2
|
-
import { init_dist_es as init_dist_es$1, init_httpAuthSchemes, normalizeProvider, setFeature as setFeature$1 } from './chunk-GGD6XRMR.js';
|
|
3
|
-
import { init_dist_es as init_dist_es$5, loadConfig } from './chunk-NUNC7FJI.js';
|
|
4
|
-
import { init_dist_es as init_dist_es$4, CONFIG_PREFIX_SEPARATOR } from './chunk-FXVUFUHO.js';
|
|
5
2
|
import { init_dist_es as init_dist_es$3, decorateServiceException, getValueFromTextNode, NoOpLogger } from './chunk-RXE4BXUV.js';
|
|
3
|
+
import { init_dist_es as init_dist_es$1, init_httpAuthSchemes, normalizeProvider, setFeature as setFeature$1 } from './chunk-GGD6XRMR.js';
|
|
6
4
|
import { init_schema, TypeRegistry, NormalizedSchema, init_serde, init_protocols, init_dist_es2, fromBase64, LazyJsonString, determineTimestampFormat, parseEpochTimestamp, parseRfc7231DateTime, parseRfc3339DateTimeWithOffset, NumericValue, toBase64, dateToUtcString, v4, RpcProtocol, deref, HttpBindingProtocol, HttpInterceptingShapeSerializer, HttpInterceptingShapeDeserializer, FromStringShapeDeserializer, extendedEncodeURIComponent, collectBody, init_dist_es as init_dist_es$7, init_dist_es7, normalizeProvider as normalizeProvider$1, getSmithyContext } from './chunk-PGAFV2OP.js';
|
|
7
5
|
import { init_dist_es, HttpRequest, HttpResponse } from './chunk-5WFAR7K2.js';
|
|
8
6
|
import { init_dist_es3, toUtf8, init_dist_es2 as init_dist_es2$2, toUint8Array, fromString, fromArrayBuffer } from './chunk-7UJVVJ4V.js';
|
|
7
|
+
import { init_dist_es as init_dist_es$5, loadConfig } from './chunk-NUNC7FJI.js';
|
|
9
8
|
import { init_dist_es as init_dist_es$6, parseUrl } from './chunk-WWWCFQAX.js';
|
|
9
|
+
import { init_dist_es as init_dist_es$4, CONFIG_PREFIX_SEPARATOR } from './chunk-FXVUFUHO.js';
|
|
10
10
|
import { init_client, setFeature } from './chunk-76BTQYIZ.js';
|
|
11
11
|
import { init_dist_es as init_dist_es$8, memoize } from './chunk-D5ZJLKV4.js';
|
|
12
12
|
import { __esm, __name } from './chunk-6EUZQHAF.js';
|