@guren/server 0.2.0-alpha.7 → 1.0.0-rc.9

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.
Files changed (54) hide show
  1. package/dist/Application-DtWDHXr1.d.ts +2110 -0
  2. package/dist/BroadcastManager-AkIWUGJo.d.ts +466 -0
  3. package/dist/CacheManager-BkvHEOZX.d.ts +244 -0
  4. package/dist/ConsoleKernel-CqCVrdZs.d.ts +207 -0
  5. package/dist/EventManager-CmIoLt7r.d.ts +207 -0
  6. package/dist/Gate-CNkBYf8m.d.ts +268 -0
  7. package/dist/HealthManager-DUyMIzsZ.d.ts +141 -0
  8. package/dist/I18nManager-Dtgzsf5n.d.ts +270 -0
  9. package/dist/LogManager-7mxnkaPM.d.ts +256 -0
  10. package/dist/MailManager-DpMvYiP9.d.ts +292 -0
  11. package/dist/Scheduler-BstvSca7.d.ts +469 -0
  12. package/dist/StorageManager-oZTHqaza.d.ts +337 -0
  13. package/dist/api-token-JOif2CtG.d.ts +1792 -0
  14. package/dist/app-key-CsBfRC_Q.d.ts +214 -0
  15. package/dist/auth/index.d.ts +418 -0
  16. package/dist/auth/index.js +6742 -0
  17. package/dist/authorization/index.d.ts +129 -0
  18. package/dist/authorization/index.js +621 -0
  19. package/dist/broadcasting/index.d.ts +233 -0
  20. package/dist/broadcasting/index.js +907 -0
  21. package/dist/cache/index.d.ts +233 -0
  22. package/dist/cache/index.js +817 -0
  23. package/dist/encryption/index.d.ts +222 -0
  24. package/dist/encryption/index.js +602 -0
  25. package/dist/events/index.d.ts +155 -0
  26. package/dist/events/index.js +330 -0
  27. package/dist/health/index.d.ts +185 -0
  28. package/dist/health/index.js +379 -0
  29. package/dist/i18n/index.d.ts +101 -0
  30. package/dist/i18n/index.js +597 -0
  31. package/dist/index-9_Jzj5jo.d.ts +7 -0
  32. package/dist/index.d.ts +2628 -619
  33. package/dist/index.js +22229 -3116
  34. package/dist/lambda/index.d.ts +156 -0
  35. package/dist/lambda/index.js +91 -0
  36. package/dist/logging/index.d.ts +50 -0
  37. package/dist/logging/index.js +557 -0
  38. package/dist/mail/index.d.ts +288 -0
  39. package/dist/mail/index.js +695 -0
  40. package/dist/mcp/index.d.ts +139 -0
  41. package/dist/mcp/index.js +382 -0
  42. package/dist/notifications/index.d.ts +271 -0
  43. package/dist/notifications/index.js +741 -0
  44. package/dist/queue/index.d.ts +423 -0
  45. package/dist/queue/index.js +958 -0
  46. package/dist/runtime/index.d.ts +93 -0
  47. package/dist/runtime/index.js +834 -0
  48. package/dist/scheduling/index.d.ts +41 -0
  49. package/dist/scheduling/index.js +836 -0
  50. package/dist/storage/index.d.ts +196 -0
  51. package/dist/storage/index.js +832 -0
  52. package/dist/vite/index.js +203 -3
  53. package/package.json +93 -6
  54. package/dist/chunk-FK2XQSBF.js +0 -160
@@ -0,0 +1,469 @@
1
+ /**
2
+ * Scheduled task callback.
3
+ */
4
+ type TaskCallback = () => void | Promise<void>;
5
+ /**
6
+ * Task definition.
7
+ */
8
+ interface TaskDefinition {
9
+ /**
10
+ * Task name.
11
+ */
12
+ name?: string;
13
+ /**
14
+ * Cron expression.
15
+ */
16
+ expression: string;
17
+ /**
18
+ * Timezone for the schedule.
19
+ */
20
+ timezone?: string;
21
+ /**
22
+ * Task callback.
23
+ */
24
+ callback: TaskCallback;
25
+ /**
26
+ * Prevent overlapping executions.
27
+ */
28
+ withoutOverlapping?: boolean;
29
+ /**
30
+ * Overlap expiration in milliseconds.
31
+ */
32
+ overlapExpiresAt?: number;
33
+ /**
34
+ * Only run on one server (requires distributed lock).
35
+ */
36
+ onOneServer?: boolean;
37
+ /**
38
+ * Condition callback to determine if task should run.
39
+ */
40
+ when?: () => boolean | Promise<boolean>;
41
+ /**
42
+ * Condition callback to skip execution.
43
+ */
44
+ skip?: () => boolean | Promise<boolean>;
45
+ /**
46
+ * Before execution callback.
47
+ */
48
+ before?: () => void | Promise<void>;
49
+ /**
50
+ * After execution callback.
51
+ */
52
+ after?: () => void | Promise<void>;
53
+ /**
54
+ * On success callback.
55
+ */
56
+ onSuccess?: () => void | Promise<void>;
57
+ /**
58
+ * On failure callback.
59
+ */
60
+ onFailure?: (error: Error) => void | Promise<void>;
61
+ }
62
+ /**
63
+ * Scheduler options.
64
+ */
65
+ interface SchedulerOptions {
66
+ /**
67
+ * Timezone for all scheduled tasks.
68
+ * @default 'UTC'
69
+ */
70
+ timezone?: string;
71
+ /**
72
+ * Check interval in milliseconds.
73
+ * @default 60000 (1 minute)
74
+ */
75
+ checkInterval?: number;
76
+ /**
77
+ * Logger function.
78
+ */
79
+ logger?: (message: string) => void;
80
+ }
81
+ /**
82
+ * Parsed cron expression.
83
+ */
84
+ interface ParsedCron {
85
+ minute: number[];
86
+ hour: number[];
87
+ dayOfMonth: number[];
88
+ month: number[];
89
+ dayOfWeek: number[];
90
+ }
91
+ /**
92
+ * Job class interface for scheduling.
93
+ */
94
+ interface JobClass<T = unknown> {
95
+ dispatch(payload: T): Promise<void>;
96
+ dispatchAfter?(delayMs: number, payload: T): Promise<void>;
97
+ }
98
+
99
+ /**
100
+ * Represents a scheduled task.
101
+ */
102
+ declare class ScheduledTask {
103
+ private readonly definition;
104
+ private lastRun;
105
+ private isRunning;
106
+ constructor(definition: TaskDefinition);
107
+ /**
108
+ * Get the task name.
109
+ */
110
+ getName(): string;
111
+ /**
112
+ * Get the cron expression.
113
+ */
114
+ getExpression(): string;
115
+ /**
116
+ * Get the timezone.
117
+ */
118
+ getTimezone(): string | undefined;
119
+ /**
120
+ * Check if the task is due.
121
+ */
122
+ isDue(date?: Date): boolean;
123
+ /**
124
+ * Check if the task should run based on conditions.
125
+ * Note: Overlap checking is handled separately in run() to prevent race conditions.
126
+ */
127
+ shouldRun(): Promise<boolean>;
128
+ /**
129
+ * Run the task.
130
+ */
131
+ run(): Promise<void>;
132
+ /**
133
+ * Get the last run time.
134
+ */
135
+ getLastRun(): Date | null;
136
+ /**
137
+ * Check if the task is currently running.
138
+ */
139
+ isCurrentlyRunning(): boolean;
140
+ /**
141
+ * Get the task definition.
142
+ */
143
+ getDefinition(): TaskDefinition;
144
+ }
145
+
146
+ /**
147
+ * Pending schedule builder for fluent API.
148
+ */
149
+ declare class PendingSchedule {
150
+ private readonly callback;
151
+ private expression;
152
+ private timezone?;
153
+ private taskName?;
154
+ private withoutOverlapping;
155
+ private overlapExpiresAt?;
156
+ private onOneServer;
157
+ private whenCallback?;
158
+ private skipCallback?;
159
+ private beforeCallback?;
160
+ private afterCallback?;
161
+ private successCallback?;
162
+ private failureCallback?;
163
+ constructor(callback: TaskCallback);
164
+ /**
165
+ * Run every minute.
166
+ */
167
+ everyMinute(): this;
168
+ /**
169
+ * Run every two minutes.
170
+ */
171
+ everyTwoMinutes(): this;
172
+ /**
173
+ * Run every three minutes.
174
+ */
175
+ everyThreeMinutes(): this;
176
+ /**
177
+ * Run every four minutes.
178
+ */
179
+ everyFourMinutes(): this;
180
+ /**
181
+ * Run every five minutes.
182
+ */
183
+ everyFiveMinutes(): this;
184
+ /**
185
+ * Run every ten minutes.
186
+ */
187
+ everyTenMinutes(): this;
188
+ /**
189
+ * Run every fifteen minutes.
190
+ */
191
+ everyFifteenMinutes(): this;
192
+ /**
193
+ * Run every thirty minutes.
194
+ */
195
+ everyThirtyMinutes(): this;
196
+ /**
197
+ * Run hourly.
198
+ */
199
+ hourly(): this;
200
+ /**
201
+ * Run hourly at a specific minute.
202
+ */
203
+ hourlyAt(minute: number): this;
204
+ /**
205
+ * Run every two hours.
206
+ */
207
+ everyTwoHours(): this;
208
+ /**
209
+ * Run every three hours.
210
+ */
211
+ everyThreeHours(): this;
212
+ /**
213
+ * Run every four hours.
214
+ */
215
+ everyFourHours(): this;
216
+ /**
217
+ * Run every six hours.
218
+ */
219
+ everySixHours(): this;
220
+ /**
221
+ * Run daily at midnight.
222
+ */
223
+ daily(): this;
224
+ /**
225
+ * Run daily at a specific time.
226
+ * @param time Time in HH:MM format
227
+ */
228
+ dailyAt(time: string): this;
229
+ /**
230
+ * Alias for dailyAt.
231
+ */
232
+ at(time: string): this;
233
+ /**
234
+ * Run twice daily.
235
+ */
236
+ twiceDaily(firstHour?: number, secondHour?: number): this;
237
+ /**
238
+ * Run weekly on Sunday at midnight.
239
+ */
240
+ weekly(): this;
241
+ /**
242
+ * Run weekly on a specific day at a specific time.
243
+ * @param day Day of week (0 = Sunday, 6 = Saturday)
244
+ * @param time Time in HH:MM format
245
+ */
246
+ weeklyOn(day: number, time?: string): this;
247
+ sundays(): this;
248
+ mondays(): this;
249
+ tuesdays(): this;
250
+ wednesdays(): this;
251
+ thursdays(): this;
252
+ fridays(): this;
253
+ saturdays(): this;
254
+ /**
255
+ * Run on weekdays (Monday-Friday).
256
+ */
257
+ weekdays(): this;
258
+ /**
259
+ * Run on weekends (Saturday-Sunday).
260
+ */
261
+ weekends(): this;
262
+ /**
263
+ * Run monthly on the first day at midnight.
264
+ */
265
+ monthly(): this;
266
+ /**
267
+ * Run monthly on a specific day at a specific time.
268
+ */
269
+ monthlyOn(day: number, time?: string): this;
270
+ /**
271
+ * Run on the last day of the month.
272
+ */
273
+ lastDayOfMonth(time?: string): this;
274
+ /**
275
+ * Run quarterly.
276
+ */
277
+ quarterly(): this;
278
+ /**
279
+ * Run yearly on January 1st at midnight.
280
+ */
281
+ yearly(): this;
282
+ /**
283
+ * Run yearly on a specific date.
284
+ */
285
+ yearlyOn(month: number, day: number, time?: string): this;
286
+ /**
287
+ * Set a custom cron expression.
288
+ */
289
+ cron(expression: string): this;
290
+ /**
291
+ * Set the task name.
292
+ */
293
+ name(name: string): this;
294
+ /**
295
+ * Set the timezone.
296
+ */
297
+ tz(timezone: string): this;
298
+ /**
299
+ * Alias for tz().
300
+ */
301
+ setTimezone(timezone: string): this;
302
+ /**
303
+ * Prevent overlapping executions.
304
+ */
305
+ preventOverlapping(expiresAt?: number): this;
306
+ /**
307
+ * Alias for preventOverlapping().
308
+ */
309
+ withoutOverlaps(expiresAt?: number): this;
310
+ /**
311
+ * Only run on one server.
312
+ */
313
+ runOnOneServer(): this;
314
+ /**
315
+ * Set a condition for running.
316
+ */
317
+ when(callback: () => boolean | Promise<boolean>): this;
318
+ /**
319
+ * Set a condition to skip execution.
320
+ */
321
+ skip(callback: () => boolean | Promise<boolean>): this;
322
+ /**
323
+ * Set a before callback.
324
+ */
325
+ before(callback: () => void | Promise<void>): this;
326
+ /**
327
+ * Set an after callback.
328
+ */
329
+ after(callback: () => void | Promise<void>): this;
330
+ /**
331
+ * Set a success callback.
332
+ */
333
+ onSuccess(callback: () => void | Promise<void>): this;
334
+ /**
335
+ * Set a failure callback.
336
+ */
337
+ onFailure(callback: (error: Error) => void | Promise<void>): this;
338
+ /**
339
+ * Build the task definition.
340
+ */
341
+ build(): TaskDefinition;
342
+ /**
343
+ * Build as a ScheduledTask.
344
+ */
345
+ toTask(): ScheduledTask;
346
+ }
347
+ /**
348
+ * Schedule builder for defining multiple tasks.
349
+ */
350
+ declare class Schedule {
351
+ private readonly tasks;
352
+ /**
353
+ * Schedule a callback.
354
+ */
355
+ call(callback: TaskCallback): PendingSchedule;
356
+ /**
357
+ * Schedule a job.
358
+ */
359
+ job<T>(jobClass: JobClass<T>, payload: T): PendingSchedule;
360
+ /**
361
+ * Schedule a shell command.
362
+ */
363
+ command(cmd: string): PendingSchedule;
364
+ /**
365
+ * Get all pending schedules.
366
+ */
367
+ getPendingSchedules(): PendingSchedule[];
368
+ /**
369
+ * Build all tasks.
370
+ */
371
+ buildTasks(): ScheduledTask[];
372
+ }
373
+
374
+ /**
375
+ * Task scheduler for running periodic tasks.
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * const scheduler = new Scheduler()
380
+ *
381
+ * scheduler.schedule((schedule) => {
382
+ * schedule.call(async () => {
383
+ * await cleanupOldSessions()
384
+ * }).daily().at('03:00').name('cleanup-sessions')
385
+ *
386
+ * schedule.job(SendWeeklyDigestJob, {})
387
+ * .weekly()
388
+ * .sundays()
389
+ * .at('09:00')
390
+ * .tz('Asia/Tokyo')
391
+ * })
392
+ *
393
+ * scheduler.start()
394
+ * ```
395
+ */
396
+ declare class Scheduler {
397
+ private tasks;
398
+ private readonly options;
399
+ private interval;
400
+ private isRunning;
401
+ private lastCheck;
402
+ constructor(options?: SchedulerOptions);
403
+ /**
404
+ * Define schedules using a callback.
405
+ */
406
+ schedule(definer: (schedule: Schedule) => void): void;
407
+ /**
408
+ * Add a pre-built task.
409
+ */
410
+ addTask(task: ScheduledTask): void;
411
+ /**
412
+ * Get all scheduled tasks.
413
+ */
414
+ getTasks(): ScheduledTask[];
415
+ /**
416
+ * Get tasks that are due now.
417
+ */
418
+ getDueTasks(date?: Date): ScheduledTask[];
419
+ /**
420
+ * Run all due tasks.
421
+ */
422
+ runDueTasks(date?: Date): Promise<void>;
423
+ /**
424
+ * Start the scheduler.
425
+ */
426
+ start(): void;
427
+ /**
428
+ * Stop the scheduler.
429
+ */
430
+ stop(): void;
431
+ /**
432
+ * Check and run due tasks.
433
+ */
434
+ private tick;
435
+ /**
436
+ * Check if the scheduler is running.
437
+ */
438
+ getIsRunning(): boolean;
439
+ /**
440
+ * Get the check interval.
441
+ */
442
+ getCheckInterval(): number;
443
+ /**
444
+ * Get the default timezone.
445
+ */
446
+ getTimezone(): string;
447
+ /**
448
+ * Clear all tasks.
449
+ */
450
+ clear(): void;
451
+ /**
452
+ * Get the number of tasks.
453
+ */
454
+ count(): number;
455
+ /**
456
+ * Get task by name.
457
+ */
458
+ getTask(name: string): ScheduledTask | undefined;
459
+ /**
460
+ * Remove a task by name.
461
+ */
462
+ removeTask(name: string): boolean;
463
+ }
464
+ /**
465
+ * Create a scheduler instance.
466
+ */
467
+ declare function createScheduler(options?: SchedulerOptions): Scheduler;
468
+
469
+ export { type JobClass as J, type ParsedCron as P, Scheduler as S, type TaskCallback as T, PendingSchedule as a, Schedule as b, ScheduledTask as c, type SchedulerOptions as d, type TaskDefinition as e, createScheduler as f };