@guren/server 2.10.0 → 2.11.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.
Files changed (91) hide show
  1. package/dist/DocsViewerServiceProvider-qFCaeiUv.js +77 -0
  2. package/dist/Hash-CzrwKeDp.js +133 -0
  3. package/dist/HttpException-BkS3euNG.js +161 -0
  4. package/dist/Job-BVT813DO.js +441 -0
  5. package/dist/McpServiceProvider-BoAN-UcD.js +367 -0
  6. package/dist/MessageSigner-Bd25ZJAV.js +93 -0
  7. package/dist/Random-DbIJ22KQ.js +191 -0
  8. package/dist/address-D0Iq-XIH.js +20 -0
  9. package/dist/auth/index.js +2 -122
  10. package/dist/auth-C7sVmYgc.js +1954 -0
  11. package/dist/authorization/index.js +2 -38
  12. package/dist/authorization-Dbcuc5ZK.js +610 -0
  13. package/dist/broadcasting/index.js +2 -26
  14. package/dist/broadcasting-Dw-FhyjN.js +1055 -0
  15. package/dist/cache/index.js +2 -17
  16. package/dist/cache/types.d.ts +4 -4
  17. package/dist/cache-BYnZf2FR.js +812 -0
  18. package/dist/client-Dd7vLcqp.js +27 -0
  19. package/dist/console/Output.d.ts +18 -18
  20. package/dist/encryption/index.js +5 -96
  21. package/dist/encryption-fOWQaKqX.js +250 -0
  22. package/dist/endpoint-D-20PiHY.js +46 -0
  23. package/dist/endpoint-D6GIqOpe.js +31 -0
  24. package/dist/errors-quJOkkCn.js +81 -0
  25. package/dist/events/index.js +2 -28
  26. package/dist/events-aIH_bWRx.js +410 -0
  27. package/dist/health/index.js +2 -24
  28. package/dist/health-VWdWXRwh.js +345 -0
  29. package/dist/hot-disposables-WsTX2ySN.js +281 -0
  30. package/dist/hot-reload/testing.d.ts +1 -1
  31. package/dist/http/resources/Resource.d.ts +23 -3
  32. package/dist/i18n/index.js +2 -30
  33. package/dist/i18n-mcWi7LCd.js +617 -0
  34. package/dist/index.js +7515 -7276
  35. package/dist/lambda/index.js +114 -71
  36. package/dist/logging/index.js +2 -24
  37. package/dist/logging-CPaRMuPP.js +518 -0
  38. package/dist/loopback-guard-D0Kc7-xc.js +224 -0
  39. package/dist/mail/index.js +2 -27
  40. package/dist/mail-DfEfSQEr.js +699 -0
  41. package/dist/mcp/index.js +2 -10
  42. package/dist/notifications/index.js +2 -33
  43. package/dist/notifications-BGqmUNZ8.js +759 -0
  44. package/dist/queue/index.js +3 -42
  45. package/dist/queue-CXrRK85G.js +948 -0
  46. package/dist/redis/index.js +672 -642
  47. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  48. package/dist/runtime/index.js +472 -616
  49. package/dist/scheduling/index.js +2 -29
  50. package/dist/scheduling-CPiEdtQd.js +839 -0
  51. package/dist/storage/index.js +2 -15
  52. package/dist/storage-tWHMv2H_.js +841 -0
  53. package/dist/support/expiry.js +69 -12
  54. package/dist/trim-slashes-ZJ_VsY5s.js +25 -0
  55. package/dist/vite/index.js +118 -181
  56. package/dist/vite/plugin.d.ts +1 -1
  57. package/dist/vite-dev-server-BSJkduhZ.js +131 -0
  58. package/package.json +6 -5
  59. package/dist/DocsViewerServiceProvider-RUYDFBMW.js +0 -75
  60. package/dist/McpServiceProvider-SL7DUZ4G.js +0 -8
  61. package/dist/chunk-2SC566CD.js +0 -376
  62. package/dist/chunk-2V3YID4H.js +0 -20
  63. package/dist/chunk-3KV5X2FL.js +0 -31
  64. package/dist/chunk-63SKW5PS.js +0 -457
  65. package/dist/chunk-6J6B5KOB.js +0 -425
  66. package/dist/chunk-A5JJ7XTH.js +0 -24
  67. package/dist/chunk-AZOYI43J.js +0 -18
  68. package/dist/chunk-B5E5VBDI.js +0 -115
  69. package/dist/chunk-DAQKYKLH.js +0 -182
  70. package/dist/chunk-DRNPVBAA.js +0 -1002
  71. package/dist/chunk-EI5GYMAT.js +0 -853
  72. package/dist/chunk-H3B23O6T.js +0 -271
  73. package/dist/chunk-HPET6XY5.js +0 -853
  74. package/dist/chunk-HR2KZ3WL.js +0 -616
  75. package/dist/chunk-IOTWFHZU.js +0 -558
  76. package/dist/chunk-K6CUBJX6.js +0 -642
  77. package/dist/chunk-KTNJG7R7.js +0 -911
  78. package/dist/chunk-LAJQCSSF.js +0 -355
  79. package/dist/chunk-LHR6OHI7.js +0 -189
  80. package/dist/chunk-N7PLD7MB.js +0 -729
  81. package/dist/chunk-Q2P6YLRR.js +0 -24
  82. package/dist/chunk-QQKTH5KX.js +0 -114
  83. package/dist/chunk-SFQP6O52.js +0 -126
  84. package/dist/chunk-SQR7277M.js +0 -911
  85. package/dist/chunk-T2FFUU6J.js +0 -484
  86. package/dist/chunk-TVV5YNEC.js +0 -1842
  87. package/dist/chunk-UY3AZSYL.js +0 -14
  88. package/dist/chunk-V4DNC2ER.js +0 -114
  89. package/dist/chunk-VSA3QY5Q.js +0 -274
  90. package/dist/chunk-YSOJKAAU.js +0 -427
  91. package/dist/errors-PUNHAFL2.js +0 -34
@@ -1,75 +0,0 @@
1
- import {
2
- DOCS_VIEWER_PATH,
3
- createDocsViewerAccessGuard,
4
- isDocsViewerEnabled
5
- } from "./chunk-A5JJ7XTH.js";
6
- import {
7
- ServiceProvider
8
- } from "./chunk-LHR6OHI7.js";
9
-
10
- // src/docs-viewer/DocsViewerServiceProvider.ts
11
- import { createRequire } from "module";
12
- import { readFile } from "fs/promises";
13
- import { createHash } from "crypto";
14
- import { join } from "path";
15
- var DATA_CACHE_TTL_MS = 15e3;
16
- var DocsViewerServiceProvider = class extends ServiceProvider {
17
- register() {
18
- }
19
- async boot() {
20
- if (!isDocsViewerEnabled()) {
21
- return;
22
- }
23
- const app = this.container.make("app");
24
- const hono = app.hono;
25
- const cwd = process.cwd();
26
- const cli = await import("@guren/cli");
27
- const guard = createDocsViewerAccessGuard();
28
- hono.use(DOCS_VIEWER_PATH, guard);
29
- hono.use(`${DOCS_VIEWER_PATH}/*`, guard);
30
- let shell = null;
31
- hono.get(DOCS_VIEWER_PATH, async (ctx) => {
32
- shell ??= readFile(cli.docsViewerAssetPath(), "utf-8");
33
- return ctx.html(await shell);
34
- });
35
- let cached = null;
36
- const payload = () => {
37
- if (!cached || Date.now() - cached.at > DATA_CACHE_TTL_MS) {
38
- cached = {
39
- at: Date.now(),
40
- payload: cli.buildDocsViewerData(cwd).then((data) => {
41
- const body = JSON.stringify(data);
42
- return { body, etag: `"${createHash("sha1").update(body).digest("hex")}"` };
43
- })
44
- };
45
- }
46
- return cached.payload;
47
- };
48
- hono.get(`${DOCS_VIEWER_PATH}/data.json`, async (ctx) => {
49
- const { body, etag } = await payload();
50
- if (ctx.req.header("if-none-match") === etag) {
51
- return ctx.body(null, 304, { ETag: etag });
52
- }
53
- return ctx.body(body, 200, { "Content-Type": "application/json", ETag: etag });
54
- });
55
- let mermaid = null;
56
- hono.get(`${DOCS_VIEWER_PATH}/assets/mermaid.js`, async (ctx) => {
57
- try {
58
- mermaid ??= readFile(
59
- createRequire(join(cwd, "package.json")).resolve("mermaid/dist/mermaid.min.js")
60
- );
61
- const source = await mermaid;
62
- return ctx.body(new Uint8Array(source), 200, {
63
- "Content-Type": "text/javascript",
64
- "Cache-Control": "max-age=3600"
65
- });
66
- } catch {
67
- mermaid = null;
68
- return ctx.json({ message: "mermaid is not installed (bun add -d mermaid)" }, 404);
69
- }
70
- });
71
- }
72
- };
73
- export {
74
- DocsViewerServiceProvider
75
- };
@@ -1,8 +0,0 @@
1
- import {
2
- McpServiceProvider
3
- } from "./chunk-YSOJKAAU.js";
4
- import "./chunk-Q2P6YLRR.js";
5
- import "./chunk-LHR6OHI7.js";
6
- export {
7
- McpServiceProvider
8
- };
@@ -1,376 +0,0 @@
1
- // src/health/HealthCheck.ts
2
- var HealthCheck = class {
3
- /**
4
- * Create a healthy result.
5
- */
6
- healthy(message, meta) {
7
- return this.result("healthy", message, meta);
8
- }
9
- /**
10
- * Create a degraded result.
11
- */
12
- degraded(message, meta) {
13
- return this.result("degraded", message, meta);
14
- }
15
- /**
16
- * Create an unhealthy result.
17
- */
18
- unhealthy(message, meta) {
19
- return this.result("unhealthy", message, meta);
20
- }
21
- /**
22
- * Create an unhealthy result from a caught error.
23
- */
24
- handleError(error, fallbackMessage) {
25
- return this.unhealthy(
26
- error instanceof Error ? error.message : fallbackMessage
27
- );
28
- }
29
- /**
30
- * Create a check result.
31
- */
32
- result(status, message, meta) {
33
- const result = {
34
- name: this.name,
35
- status,
36
- duration: 0
37
- // Will be set by HealthManager
38
- };
39
- if (message !== void 0) {
40
- result.message = message;
41
- }
42
- if (meta !== void 0) {
43
- result.meta = meta;
44
- }
45
- return result;
46
- }
47
- };
48
-
49
- // src/health/HealthManager.ts
50
- var HealthManager = class {
51
- checks = /* @__PURE__ */ new Map();
52
- /**
53
- * Register a health check.
54
- */
55
- register(check, options = {}) {
56
- this.checks.set(check.name, {
57
- check,
58
- options: {
59
- timeout: options.timeout ?? 5e3,
60
- critical: options.critical ?? false
61
- }
62
- });
63
- return this;
64
- }
65
- /**
66
- * Unregister a health check.
67
- */
68
- unregister(name) {
69
- this.checks.delete(name);
70
- return this;
71
- }
72
- /**
73
- * Get all registered check names.
74
- */
75
- getCheckNames() {
76
- return Array.from(this.checks.keys());
77
- }
78
- /**
79
- * Run all health checks.
80
- */
81
- async check() {
82
- return this.runChecks(this.getCheckNames());
83
- }
84
- /**
85
- * Run specific health checks.
86
- */
87
- async checkOnly(names) {
88
- const validNames = names.filter((name) => this.checks.has(name));
89
- return this.runChecks(validNames);
90
- }
91
- /**
92
- * Get a specific check result.
93
- */
94
- async getCheck(name) {
95
- const registered = this.checks.get(name);
96
- if (!registered) {
97
- return null;
98
- }
99
- return this.runCheck(registered);
100
- }
101
- /**
102
- * Create middleware for health endpoints.
103
- */
104
- middleware(options = {}) {
105
- return async (ctx, next) => {
106
- const report = options.checks ? await this.checkOnly(options.checks) : await this.check();
107
- const statusCode = report.status === "healthy" ? 200 : report.status === "degraded" ? 200 : 503;
108
- ctx.res = ctx.json(
109
- {
110
- status: report.status,
111
- timestamp: report.timestamp.toISOString(),
112
- ...options.detailed === false ? {} : {
113
- checks: report.checks.map((check) => ({
114
- name: check.name,
115
- status: check.status,
116
- message: check.message,
117
- duration: check.duration,
118
- meta: check.meta
119
- }))
120
- }
121
- },
122
- statusCode
123
- );
124
- };
125
- }
126
- /**
127
- * Run the specified checks.
128
- */
129
- async runChecks(names) {
130
- const results = [];
131
- let overallStatus = "healthy";
132
- await Promise.all(
133
- names.map(async (name) => {
134
- const registered = this.checks.get(name);
135
- if (!registered) return;
136
- const result = await this.runCheck(registered);
137
- results.push(result);
138
- if (result.status === "unhealthy") {
139
- if (registered.options.critical) {
140
- overallStatus = "unhealthy";
141
- } else if (overallStatus !== "unhealthy") {
142
- overallStatus = "degraded";
143
- }
144
- } else if (result.status === "degraded" && overallStatus === "healthy") {
145
- overallStatus = "degraded";
146
- }
147
- })
148
- );
149
- results.sort((a, b) => a.name.localeCompare(b.name));
150
- return {
151
- status: overallStatus,
152
- timestamp: /* @__PURE__ */ new Date(),
153
- checks: results
154
- };
155
- }
156
- /**
157
- * Run a single check with timeout.
158
- */
159
- async runCheck(registered) {
160
- const { check, options } = registered;
161
- const start = performance.now();
162
- try {
163
- const result = await Promise.race([
164
- check.check(),
165
- this.timeoutPromise(options.timeout)
166
- ]);
167
- result.duration = Math.round(performance.now() - start);
168
- return result;
169
- } catch (error) {
170
- const duration = Math.round(performance.now() - start);
171
- return {
172
- name: check.name,
173
- status: "unhealthy",
174
- message: error instanceof Error ? error.message : "Check failed with error",
175
- duration
176
- };
177
- }
178
- }
179
- /**
180
- * Create a timeout promise.
181
- */
182
- timeoutPromise(ms) {
183
- return new Promise((_, reject) => {
184
- setTimeout(() => {
185
- reject(new Error(`Health check timed out after ${ms}ms`));
186
- }, ms);
187
- });
188
- }
189
- };
190
- function createHealthManager() {
191
- return new HealthManager();
192
- }
193
-
194
- // src/health/checks/DatabaseCheck.ts
195
- var DatabaseCheck = class extends HealthCheck {
196
- name;
197
- db;
198
- query;
199
- constructor(db, options = {}) {
200
- super();
201
- this.db = db;
202
- this.name = options.name ?? "database";
203
- this.query = options.query ?? "SELECT 1";
204
- }
205
- async check() {
206
- try {
207
- await this.db.query(this.query);
208
- return this.healthy("Database connection is healthy");
209
- } catch (error) {
210
- return this.handleError(error, "Database connection failed");
211
- }
212
- }
213
- };
214
-
215
- // src/health/checks/RedisCheck.ts
216
- var RedisCheck = class extends HealthCheck {
217
- name;
218
- redis;
219
- constructor(redis, options = {}) {
220
- super();
221
- this.redis = redis;
222
- this.name = options.name ?? "redis";
223
- }
224
- async check() {
225
- try {
226
- const response = await this.redis.ping();
227
- if (response === "PONG") {
228
- return this.healthy("Redis connection is healthy");
229
- }
230
- return this.degraded(`Redis ping returned: ${response}`);
231
- } catch (error) {
232
- return this.handleError(error, "Redis connection failed");
233
- }
234
- }
235
- };
236
-
237
- // src/health/checks/CacheCheck.ts
238
- var CacheCheck = class extends HealthCheck {
239
- name;
240
- cache;
241
- testKey;
242
- constructor(cache, options = {}) {
243
- super();
244
- this.cache = cache;
245
- this.name = options.name ?? "cache";
246
- this.testKey = options.testKey ?? "__health_check__";
247
- }
248
- async check() {
249
- const testValue = `health_check_${Date.now()}`;
250
- try {
251
- await this.cache.put(this.testKey, testValue, 60);
252
- const retrieved = await this.cache.get(this.testKey);
253
- await this.cache.forget(this.testKey);
254
- if (retrieved === testValue) {
255
- return this.healthy("Cache is functioning correctly");
256
- }
257
- return this.degraded(
258
- `Cache read/write mismatch: expected "${testValue}", got "${retrieved}"`
259
- );
260
- } catch (error) {
261
- return this.handleError(error, "Cache operation failed");
262
- }
263
- }
264
- };
265
-
266
- // src/health/checks/StorageCheck.ts
267
- var StorageCheck = class extends HealthCheck {
268
- name;
269
- storage;
270
- testPath;
271
- constructor(storage, options = {}) {
272
- super();
273
- this.storage = storage;
274
- this.name = options.name ?? "storage";
275
- this.testPath = options.testPath ?? "__health_check__.txt";
276
- }
277
- async check() {
278
- const testContent = `health_check_${Date.now()}`;
279
- try {
280
- await this.storage.put(this.testPath, testContent);
281
- const retrieved = await this.storage.get(this.testPath);
282
- await this.storage.delete(this.testPath);
283
- if (retrieved && retrieved.toString() === testContent) {
284
- return this.healthy("Storage is functioning correctly");
285
- }
286
- return this.degraded("Storage read/write mismatch");
287
- } catch (error) {
288
- return this.handleError(error, "Storage operation failed");
289
- }
290
- }
291
- };
292
-
293
- // src/health/checks/MemoryCheck.ts
294
- var MemoryCheck = class extends HealthCheck {
295
- name;
296
- thresholdMb;
297
- criticalThresholdMb;
298
- constructor(options = {}) {
299
- super();
300
- this.name = options.name ?? "memory";
301
- this.thresholdMb = options.thresholdMb ?? 512;
302
- this.criticalThresholdMb = options.criticalThresholdMb ?? 1024;
303
- }
304
- async check() {
305
- const usage = process.memoryUsage();
306
- const usedMb = Math.round(usage.heapUsed / 1024 / 1024);
307
- const totalMb = Math.round(usage.heapTotal / 1024 / 1024);
308
- const rssMb = Math.round(usage.rss / 1024 / 1024);
309
- const meta = {
310
- usedMb,
311
- totalMb,
312
- rssMb,
313
- thresholdMb: this.thresholdMb,
314
- criticalThresholdMb: this.criticalThresholdMb
315
- };
316
- if (usedMb >= this.criticalThresholdMb) {
317
- return this.unhealthy(
318
- `Memory usage critical: ${usedMb}MB (threshold: ${this.criticalThresholdMb}MB)`,
319
- meta
320
- );
321
- }
322
- if (usedMb >= this.thresholdMb) {
323
- return this.degraded(
324
- `Memory usage elevated: ${usedMb}MB (threshold: ${this.thresholdMb}MB)`,
325
- meta
326
- );
327
- }
328
- return this.healthy(`Memory usage normal: ${usedMb}MB`, meta);
329
- }
330
- };
331
-
332
- // src/health/checks/CustomCheck.ts
333
- var CustomCheck = class extends HealthCheck {
334
- name;
335
- callback;
336
- constructor(name, callback) {
337
- super();
338
- this.name = name;
339
- this.callback = callback;
340
- }
341
- async check() {
342
- try {
343
- const result = await this.callback();
344
- switch (result.status) {
345
- case "healthy":
346
- return this.healthy(result.message, result.meta);
347
- case "degraded":
348
- return this.degraded(result.message, result.meta);
349
- case "unhealthy":
350
- return this.unhealthy(result.message, result.meta);
351
- default:
352
- return this.unhealthy("Unknown status returned from check");
353
- }
354
- } catch (error) {
355
- return this.unhealthy(
356
- error instanceof Error ? error.message : "Custom check failed"
357
- );
358
- }
359
- }
360
- };
361
- function customCheck(name, callback) {
362
- return new CustomCheck(name, callback);
363
- }
364
-
365
- export {
366
- HealthCheck,
367
- HealthManager,
368
- createHealthManager,
369
- DatabaseCheck,
370
- RedisCheck,
371
- CacheCheck,
372
- StorageCheck,
373
- MemoryCheck,
374
- CustomCheck,
375
- customCheck
376
- };
@@ -1,20 +0,0 @@
1
- // src/mail/address.ts
2
- function parseMailAddress(input) {
3
- if (typeof input !== "string") {
4
- return input;
5
- }
6
- if (input.endsWith(">") && !/[\r\n\u2028\u2029]/u.test(input)) {
7
- const open = input.lastIndexOf("<");
8
- if (open > 0 && open < input.length - 2) {
9
- return {
10
- name: input.slice(0, open).trim(),
11
- email: input.slice(open + 1, -1).trim()
12
- };
13
- }
14
- }
15
- return { email: input };
16
- }
17
-
18
- export {
19
- parseMailAddress
20
- };
@@ -1,31 +0,0 @@
1
- // src/support/expiry.ts
2
- function toDate(value) {
3
- const date = coerceDate(value);
4
- return date !== null && !Number.isNaN(date.getTime()) ? date : null;
5
- }
6
- function coerceDate(value) {
7
- if (value == null) return null;
8
- if (value instanceof Date) return value;
9
- if (typeof value === "number" || typeof value === "bigint") return new Date(Number(value));
10
- if (typeof value === "string") return new Date(/^\d+$/.test(value) ? Number(value) : value);
11
- return null;
12
- }
13
- function isExpired(value, now = Date.now()) {
14
- const date = toDate(value);
15
- return date === null || date.getTime() <= now;
16
- }
17
- function isOptionalExpiryPast(value, now = Date.now()) {
18
- if (value == null) return false;
19
- return isExpired(value, now);
20
- }
21
- function toOptionalExpiry(value) {
22
- if (value == null) return null;
23
- return toDate(value) ?? /* @__PURE__ */ new Date(0);
24
- }
25
-
26
- export {
27
- toDate,
28
- isExpired,
29
- isOptionalExpiryPast,
30
- toOptionalExpiry
31
- };