@guren/server 2.14.0 → 2.16.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 (297) hide show
  1. package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
  2. package/dist/{Hash-CzrwKeDp.js → Hash-D2DFd8xX.js} +12 -57
  3. package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
  4. package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
  5. package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
  6. package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
  7. package/dist/agent/AgentApprovalRequested.d.ts +31 -0
  8. package/dist/agent/approval.d.ts +184 -0
  9. package/dist/agent/audit-emitter.d.ts +36 -0
  10. package/dist/agent/audit.d.ts +67 -0
  11. package/dist/agent/derive.d.ts +32 -66
  12. package/dist/agent/dispatch.d.ts +53 -63
  13. package/dist/agent/events.d.ts +11 -19
  14. package/dist/agent/meta-tools.d.ts +34 -0
  15. package/dist/agent/public.d.ts +14 -0
  16. package/dist/agent/public.js +2 -0
  17. package/dist/agent/redact.d.ts +16 -38
  18. package/dist/agent/scopes.d.ts +23 -69
  19. package/dist/auth/AuthManager.d.ts +19 -40
  20. package/dist/auth/AuthenticatableModel.d.ts +2 -2
  21. package/dist/auth/SessionGuard.d.ts +0 -1
  22. package/dist/auth/TokenGuard.d.ts +6 -26
  23. package/dist/auth/api-token.d.ts +16 -148
  24. package/dist/auth/context.d.ts +5 -10
  25. package/dist/auth/email-verification.d.ts +29 -127
  26. package/dist/auth/index.js +1 -1
  27. package/dist/auth/oauth/index.d.ts +35 -57
  28. package/dist/auth/password/DefaultHasher.d.ts +9 -5
  29. package/dist/auth/password/PasswordHasher.d.ts +7 -0
  30. package/dist/auth/password/hash-format.d.ts +11 -0
  31. package/dist/auth/password-reset.d.ts +16 -42
  32. package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
  33. package/dist/auth/providers/UserProvider.d.ts +4 -4
  34. package/dist/auth/signed-token.d.ts +18 -0
  35. package/dist/auth/types.d.ts +9 -32
  36. package/dist/auth/utils.d.ts +6 -27
  37. package/dist/{auth-BSUc14CD.js → auth-CbdPH4Cd.js} +252 -496
  38. package/dist/authorization/Gate.d.ts +9 -145
  39. package/dist/authorization/Policy.d.ts +6 -53
  40. package/dist/authorization/index.js +1 -1
  41. package/dist/authorization/middleware.d.ts +16 -62
  42. package/dist/authorization/types.d.ts +8 -64
  43. package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
  44. package/dist/broadcasting/BroadcastManager.d.ts +29 -149
  45. package/dist/broadcasting/channels/Channel.d.ts +1 -19
  46. package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
  47. package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
  48. package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
  49. package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
  50. package/dist/broadcasting/drivers/index.d.ts +1 -1
  51. package/dist/broadcasting/index.d.ts +1 -1
  52. package/dist/broadcasting/index.js +1 -1
  53. package/dist/broadcasting/types.d.ts +7 -88
  54. package/dist/{broadcasting-BxU-LIfF.js → broadcasting-B5RzB0A2.js} +87 -414
  55. package/dist/cache/CacheManager.d.ts +8 -62
  56. package/dist/cache/TaggedCache.d.ts +2 -35
  57. package/dist/cache/index.js +1 -1
  58. package/dist/cache/stores/FileStore.d.ts +2 -36
  59. package/dist/cache/stores/MemoryStore.d.ts +2 -26
  60. package/dist/cache/stores/RedisStore.d.ts +1 -29
  61. package/dist/cache/types.d.ts +21 -128
  62. package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
  63. package/dist/client-C4TEr_Dd.js +9 -0
  64. package/dist/console/Command.d.ts +17 -126
  65. package/dist/console/ConsoleKernel.d.ts +2 -74
  66. package/dist/console/Input.d.ts +5 -113
  67. package/dist/console/Output.d.ts +3 -99
  68. package/dist/console/types.d.ts +3 -33
  69. package/dist/container/Container.d.ts +12 -103
  70. package/dist/container/ServiceProvider.d.ts +17 -61
  71. package/dist/container/bindings.d.ts +10 -12
  72. package/dist/container/defineModule.d.ts +16 -54
  73. package/dist/container/definePlugin.d.ts +12 -45
  74. package/dist/container/types.d.ts +2 -34
  75. package/dist/context-CXk_umpT.js +21 -0
  76. package/dist/database/Factory.d.ts +4 -57
  77. package/dist/database/Seeder.d.ts +8 -46
  78. package/dist/database/SeederRunner.d.ts +3 -33
  79. package/dist/database/types.d.ts +3 -24
  80. package/dist/discovery/AutoDiscovery.d.ts +10 -82
  81. package/dist/dispatch-BAwzftws.js +238 -0
  82. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
  83. package/dist/docs-viewer/endpoint.d.ts +5 -11
  84. package/dist/encryption/Encrypter.d.ts +5 -71
  85. package/dist/encryption/Hash.d.ts +7 -57
  86. package/dist/encryption/Random.d.ts +6 -99
  87. package/dist/encryption/index.js +3 -3
  88. package/dist/encryption/types.d.ts +10 -72
  89. package/dist/{encryption-DJtkkhiw.js → encryption-uwP3Di4D.js} +13 -79
  90. package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
  91. package/dist/endpoint-Dsw3Acvq.js +26 -0
  92. package/dist/errors/ExceptionHandler.d.ts +3 -90
  93. package/dist/errors/HttpException.d.ts +2 -79
  94. package/dist/errors/debug-page.d.ts +3 -17
  95. package/dist/errors/error-page.d.ts +1 -0
  96. package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
  97. package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
  98. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
  99. package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
  100. package/dist/errors/exceptions/ValidationException.d.ts +2 -43
  101. package/dist/errors/types.d.ts +1 -25
  102. package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
  103. package/dist/events/Event.d.ts +1 -28
  104. package/dist/events/EventManager.d.ts +5 -107
  105. package/dist/events/Listener.d.ts +7 -55
  106. package/dist/events/builtin.d.ts +0 -24
  107. package/dist/events/index.js +1 -1
  108. package/dist/events/types.d.ts +4 -22
  109. package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
  110. package/dist/facades/index.d.ts +2 -14
  111. package/dist/health/HealthCheck.d.ts +0 -24
  112. package/dist/health/HealthManager.d.ts +0 -36
  113. package/dist/health/checks/CacheCheck.d.ts +2 -17
  114. package/dist/health/checks/CustomCheck.d.ts +0 -9
  115. package/dist/health/checks/DatabaseCheck.d.ts +2 -17
  116. package/dist/health/checks/MemoryCheck.d.ts +3 -12
  117. package/dist/health/checks/RedisCheck.d.ts +1 -13
  118. package/dist/health/checks/StorageCheck.d.ts +2 -17
  119. package/dist/health/index.js +1 -1
  120. package/dist/health/types.d.ts +4 -24
  121. package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
  122. package/dist/hot-disposables-B5BXqaIH.js +167 -0
  123. package/dist/hot-reload/hot-disposables.d.ts +22 -74
  124. package/dist/hot-reload/testing.d.ts +4 -9
  125. package/dist/http/Application.d.ts +62 -208
  126. package/dist/http/FormRequest.d.ts +4 -55
  127. package/dist/http/dev-assets.d.ts +16 -18
  128. package/dist/http/dev-banner.d.ts +2 -5
  129. package/dist/http/inertia-assets.d.ts +3 -6
  130. package/dist/http/middleware/capabilities.d.ts +27 -50
  131. package/dist/http/middleware/cors.d.ts +4 -29
  132. package/dist/http/middleware/csp.d.ts +2 -25
  133. package/dist/http/middleware/csrf.d.ts +20 -95
  134. package/dist/http/middleware/detect-locale.d.ts +7 -27
  135. package/dist/http/middleware/force-https.d.ts +6 -24
  136. package/dist/http/middleware/host-authorization.d.ts +2 -12
  137. package/dist/http/middleware/loopback-guard.d.ts +15 -33
  138. package/dist/http/middleware/rate-limit.d.ts +29 -126
  139. package/dist/http/middleware/redirect-safety.d.ts +2 -20
  140. package/dist/http/middleware/request-id.d.ts +1 -14
  141. package/dist/http/middleware/request-logging.d.ts +2 -13
  142. package/dist/http/middleware/response-headers.d.ts +5 -13
  143. package/dist/http/middleware/security-headers.d.ts +2 -16
  144. package/dist/http/middleware/session.d.ts +15 -34
  145. package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
  146. package/dist/http/middleware/validation.d.ts +8 -63
  147. package/dist/http/public-assets.d.ts +14 -0
  148. package/dist/http/request.d.ts +49 -48
  149. package/dist/http/resources/CursorPaginator.d.ts +5 -64
  150. package/dist/http/resources/Paginator.d.ts +7 -84
  151. package/dist/http/resources/Resource.d.ts +9 -65
  152. package/dist/http/resources/ResourceCollection.d.ts +5 -39
  153. package/dist/http/resources/types.d.ts +10 -30
  154. package/dist/http/static-documents.d.ts +21 -0
  155. package/dist/http/validation/Validator.d.ts +25 -85
  156. package/dist/http/validation/rules.d.ts +48 -147
  157. package/dist/http/validation/types.d.ts +16 -61
  158. package/dist/http/vite-assets.d.ts +5 -28
  159. package/dist/http/vite-dev-server.d.ts +6 -9
  160. package/dist/http/vite-manifest.d.ts +19 -33
  161. package/dist/i18n/I18nManager.d.ts +12 -78
  162. package/dist/i18n/Translator.d.ts +3 -54
  163. package/dist/i18n/index.js +1 -1
  164. package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
  165. package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
  166. package/dist/i18n/pluralization.d.ts +4 -13
  167. package/dist/i18n/types.d.ts +17 -69
  168. package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
  169. package/dist/index.d.ts +13 -4
  170. package/dist/index.js +1036 -3080
  171. package/dist/internal/agent-preflight.d.ts +9 -21
  172. package/dist/internal/request.d.ts +10 -17
  173. package/dist/internal/request.js +2 -2
  174. package/dist/internal/route-path.d.ts +9 -21
  175. package/dist/internal/route-path.js +9 -21
  176. package/dist/internal/zod-compat.d.ts +55 -122
  177. package/dist/internal/zod-compat.js +39 -70
  178. package/dist/internal/zod-json-schema.d.ts +18 -54
  179. package/dist/internal/zod-json-schema.js +46 -123
  180. package/dist/jsx-runtime.d.ts +3 -8
  181. package/dist/lambda/index.d.ts +17 -79
  182. package/dist/lambda/index.js +11 -59
  183. package/dist/logging/LogManager.d.ts +1 -51
  184. package/dist/logging/Logger.d.ts +8 -47
  185. package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
  186. package/dist/logging/channels/DailyFileChannel.d.ts +1 -5
  187. package/dist/logging/channels/FileChannel.d.ts +1 -3
  188. package/dist/logging/daily-file-path.d.ts +15 -0
  189. package/dist/logging/index.d.ts +1 -0
  190. package/dist/logging/index.js +2 -2
  191. package/dist/logging/types.d.ts +13 -45
  192. package/dist/{logging-CPaRMuPP.js → logging-zOY1XCtq.js} +83 -129
  193. package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
  194. package/dist/mail/Mail.d.ts +10 -106
  195. package/dist/mail/MailManager.d.ts +2 -60
  196. package/dist/mail/index.js +1 -1
  197. package/dist/mail/transports/LogTransport.d.ts +1 -4
  198. package/dist/mail/transports/MemoryTransport.d.ts +1 -63
  199. package/dist/mail/transports/ResendTransport.d.ts +1 -23
  200. package/dist/mail/transports/SmtpTransport.d.ts +1 -31
  201. package/dist/mail/types.d.ts +28 -150
  202. package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
  203. package/dist/mcp/McpServiceProvider.d.ts +4 -10
  204. package/dist/mcp/create-mcp-server.d.ts +25 -57
  205. package/dist/mcp/endpoint.d.ts +12 -36
  206. package/dist/mcp/index.js +1 -1
  207. package/dist/mvc/Controller.d.ts +46 -253
  208. package/dist/mvc/Router.d.ts +50 -129
  209. package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
  210. package/dist/mvc/inertia/shared.d.ts +6 -19
  211. package/dist/mvc/mount-route.d.ts +2 -6
  212. package/dist/mvc/view.d.ts +1 -2
  213. package/dist/notifications/Notification.d.ts +8 -75
  214. package/dist/notifications/NotificationManager.d.ts +15 -88
  215. package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
  216. package/dist/notifications/channels/MailChannel.d.ts +2 -31
  217. package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
  218. package/dist/notifications/channels/SlackChannel.d.ts +3 -48
  219. package/dist/notifications/index.js +1 -1
  220. package/dist/notifications/notifiable-type.d.ts +3 -6
  221. package/dist/notifications/registry.d.ts +8 -27
  222. package/dist/notifications/types.d.ts +16 -53
  223. package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
  224. package/dist/providers/AuthServiceProvider.d.ts +1 -3
  225. package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
  226. package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
  227. package/dist/providers/CacheServiceProvider.d.ts +1 -3
  228. package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
  229. package/dist/providers/ErrorServiceProvider.d.ts +1 -4
  230. package/dist/providers/EventServiceProvider.d.ts +1 -3
  231. package/dist/providers/HealthServiceProvider.d.ts +1 -3
  232. package/dist/providers/I18nServiceProvider.d.ts +6 -10
  233. package/dist/providers/InertiaServiceProvider.d.ts +1 -4
  234. package/dist/providers/LogServiceProvider.d.ts +1 -3
  235. package/dist/providers/MailServiceProvider.d.ts +1 -3
  236. package/dist/providers/NotificationServiceProvider.d.ts +1 -3
  237. package/dist/providers/OAuthServiceProvider.d.ts +1 -3
  238. package/dist/providers/QueueServiceProvider.d.ts +1 -3
  239. package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
  240. package/dist/providers/StorageServiceProvider.d.ts +1 -3
  241. package/dist/queue/FailedJobReporter.d.ts +1 -24
  242. package/dist/queue/Job.d.ts +12 -99
  243. package/dist/queue/QueueManager.d.ts +6 -57
  244. package/dist/queue/Worker.d.ts +4 -65
  245. package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
  246. package/dist/queue/drivers/RedisDriver.d.ts +7 -65
  247. package/dist/queue/drivers/SqsDriver.d.ts +6 -57
  248. package/dist/queue/drivers/SyncDriver.d.ts +10 -13
  249. package/dist/queue/index.js +2 -2
  250. package/dist/queue/types.d.ts +10 -92
  251. package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
  252. package/dist/redis/RedisApiTokenStore.d.ts +4 -56
  253. package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
  254. package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
  255. package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
  256. package/dist/redis/RedisRateLimitStore.d.ts +16 -49
  257. package/dist/redis/RedisSessionStore.d.ts +3 -44
  258. package/dist/redis/client.d.ts +2 -32
  259. package/dist/redis/index.js +47 -232
  260. package/dist/redis/redis-values.d.ts +6 -12
  261. package/dist/redis/scan-keys.d.ts +1 -4
  262. package/dist/request-CLOYytGP.js +68 -0
  263. package/dist/runtime/index.d.ts +2 -0
  264. package/dist/runtime/index.js +108 -74
  265. package/dist/scheduling/CronParser.d.ts +0 -29
  266. package/dist/scheduling/Schedule.d.ts +1 -153
  267. package/dist/scheduling/ScheduledTask.d.ts +0 -31
  268. package/dist/scheduling/Scheduler.d.ts +0 -70
  269. package/dist/scheduling/index.js +1 -1
  270. package/dist/scheduling/types.d.ts +4 -65
  271. package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
  272. package/dist/storage/StorageManager.d.ts +0 -48
  273. package/dist/storage/drivers/LocalDriver.d.ts +1 -25
  274. package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
  275. package/dist/storage/drivers/S3Driver.d.ts +6 -36
  276. package/dist/storage/drivers/s3-acl.d.ts +5 -10
  277. package/dist/storage/index.js +1 -1
  278. package/dist/storage/types.d.ts +27 -265
  279. package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
  280. package/dist/support/contained-path.d.ts +10 -20
  281. package/dist/support/error-polyfill.d.ts +4 -6
  282. package/dist/support/expiry.d.ts +17 -33
  283. package/dist/support/expiry.js +17 -33
  284. package/dist/support/import-map.d.ts +3 -7
  285. package/dist/support/inertia-defaults.d.ts +5 -10
  286. package/dist/support/redirect-target.d.ts +4 -6
  287. package/dist/support/stack-frames.d.ts +11 -50
  288. package/dist/support/trim-slashes.d.ts +4 -7
  289. package/dist/support/warn-once.d.ts +2 -6
  290. package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
  291. package/dist/{vite-manifest-BGfWbPYp.js → vite-manifest-CTQp-SOo.js} +34 -58
  292. package/package.json +6 -2
  293. package/dist/client-Dd7vLcqp.js +0 -27
  294. package/dist/context-DoD0c7J_.js +0 -26
  295. package/dist/endpoint-D-20PiHY.js +0 -46
  296. package/dist/hot-disposables-WsTX2ySN.js +0 -281
  297. package/dist/request-CRVuIiQr.js +0 -78
@@ -1,9 +1,7 @@
1
1
  import * as path$1 from "node:path";
2
2
  import * as fs from "node:fs";
3
3
  //#region src/logging/types.ts
4
- /**
5
- * Log level priority (lower = more severe).
6
- */
4
+ /** Log level priority (lower = more severe). */
7
5
  const LOG_LEVEL_PRIORITY = {
8
6
  emergency: 0,
9
7
  alert: 1,
@@ -29,9 +27,7 @@ const DEFAULT_FILTER_KEYS = [
29
27
  "ssn",
30
28
  "authorization"
31
29
  ];
32
- /**
33
- * Recursively replace values of sensitive keys in a log context object.
34
- */
30
+ /** Recursively replace values of sensitive keys in a log context object. */
35
31
  function filterSensitiveData(data, filterKeys, replacement = "[FILTERED]") {
36
32
  if (filterKeys.length === 0) return data;
37
33
  return filterObject(data, new Set(filterKeys.map((k) => k.toLowerCase())), replacement);
@@ -44,9 +40,19 @@ function filterObject(obj, keySet, replacement) {
44
40
  else result[key] = value;
45
41
  return result;
46
42
  }
43
+ const reportLoggingError = (error) => {
44
+ console.error("Logging error:", error);
45
+ };
47
46
  /**
48
- * Logger instance for writing log entries.
47
+ * Whether a channel's `log()` handed back something to wait on. A duck-typed
48
+ * check rather than `instanceof Promise`: a promise created in another realm
49
+ * (a `node:vm` context, a worker's module graph) satisfies the channel
50
+ * contract and would otherwise slip past the reporter as an unhandled rejection.
49
51
  */
52
+ function isPromiseLike(value) {
53
+ return typeof value === "object" && value !== null && typeof value.then === "function";
54
+ }
55
+ /** Logger instance for writing log entries. */
50
56
  var Logger = class Logger {
51
57
  channels;
52
58
  baseContext;
@@ -58,63 +64,33 @@ var Logger = class Logger {
58
64
  this.filterKeys = options.filterKeys ?? DEFAULT_FILTER_KEYS;
59
65
  this.replacement = options.replacement ?? "[FILTERED]";
60
66
  }
61
- /**
62
- * Log at emergency level (system is unusable).
63
- */
64
67
  emergency(message, context = {}) {
65
68
  this.log("emergency", message, context);
66
69
  }
67
- /**
68
- * Log at alert level (action must be taken immediately).
69
- */
70
70
  alert(message, context = {}) {
71
71
  this.log("alert", message, context);
72
72
  }
73
- /**
74
- * Log at critical level (critical conditions).
75
- */
76
73
  critical(message, context = {}) {
77
74
  this.log("critical", message, context);
78
75
  }
79
- /**
80
- * Log at error level (error conditions).
81
- */
82
76
  error(message, context = {}) {
83
77
  this.log("error", message, context);
84
78
  }
85
- /**
86
- * Log at warning level (warning conditions).
87
- */
88
79
  warning(message, context = {}) {
89
80
  this.log("warning", message, context);
90
81
  }
91
- /**
92
- * Alias for warning().
93
- */
94
82
  warn(message, context = {}) {
95
83
  this.warning(message, context);
96
84
  }
97
- /**
98
- * Log at notice level (normal but significant conditions).
99
- */
100
85
  notice(message, context = {}) {
101
86
  this.log("notice", message, context);
102
87
  }
103
- /**
104
- * Log at info level (informational messages).
105
- */
106
88
  info(message, context = {}) {
107
89
  this.log("info", message, context);
108
90
  }
109
- /**
110
- * Log at debug level (debug-level messages).
111
- */
112
91
  debug(message, context = {}) {
113
92
  this.log("debug", message, context);
114
93
  }
115
- /**
116
- * Log a message at the specified level.
117
- */
118
94
  log(level, message, context = {}) {
119
95
  const merged = {
120
96
  ...this.baseContext,
@@ -127,14 +103,12 @@ var Logger = class Logger {
127
103
  timestamp: /* @__PURE__ */ new Date()
128
104
  };
129
105
  for (const channel of this.channels) try {
130
- channel.log(entry);
106
+ const pending = channel.log(entry);
107
+ if (isPromiseLike(pending)) Promise.resolve(pending).catch(reportLoggingError);
131
108
  } catch (error) {
132
- console.error("Logging error:", error);
109
+ reportLoggingError(error);
133
110
  }
134
111
  }
135
- /**
136
- * Create a new logger with additional context.
137
- */
138
112
  withContext(context) {
139
113
  return new Logger(this.channels, {
140
114
  ...this.baseContext,
@@ -144,24 +118,15 @@ var Logger = class Logger {
144
118
  replacement: this.replacement
145
119
  });
146
120
  }
147
- /**
148
- * Create a child logger with additional context (alias for withContext).
149
- */
150
121
  child(context) {
151
122
  return this.withContext(context);
152
123
  }
153
- /**
154
- * Close all channels.
155
- */
156
124
  async close() {
157
125
  for (const channel of this.channels) if (channel.close) await channel.close();
158
126
  }
159
127
  };
160
128
  //#endregion
161
129
  //#region src/logging/channels/ConsoleChannel.ts
162
- /**
163
- * ANSI color codes for log levels.
164
- */
165
130
  const LEVEL_COLORS = {
166
131
  emergency: "\x1B[41m\x1B[37m",
167
132
  alert: "\x1B[41m\x1B[37m",
@@ -173,9 +138,7 @@ const LEVEL_COLORS = {
173
138
  debug: "\x1B[90m"
174
139
  };
175
140
  const RESET = "\x1B[0m";
176
- /**
177
- * Console log channel.
178
- */
141
+ /** Console log channel. */
179
142
  var ConsoleChannel = class {
180
143
  config;
181
144
  minLevel;
@@ -223,9 +186,7 @@ var ConsoleChannel = class {
223
186
  };
224
187
  //#endregion
225
188
  //#region src/logging/channels/FileChannel.ts
226
- /**
227
- * File log channel.
228
- */
189
+ /** File log channel. */
229
190
  var FileChannel = class {
230
191
  config;
231
192
  minLevel;
@@ -268,10 +229,45 @@ var FileChannel = class {
268
229
  close() {}
269
230
  };
270
231
  //#endregion
271
- //#region src/logging/channels/DailyFileChannel.ts
232
+ //#region src/logging/daily-file-path.ts
272
233
  /**
273
- * Daily rotating file log channel.
234
+ * The one rule for what a daily-rotated log file is called:
235
+ * `dir/name-YYYY-MM-DD.ext`. {@link DailyFileChannel} names what it appends to
236
+ * through this module, and the audit reader behind `guren tool:log` decides
237
+ * what to read through the same one; a second copy drifts silently, leaving an
238
+ * empty audit trail rather than an error. Naming only — nothing here touches
239
+ * the filesystem, so a caller keeps "missing" and "unreadable" apart itself.
274
240
  */
241
+ /**
242
+ * The `YYYY-MM-DD` stamp a file rotated at `date` carries. UTC, because the
243
+ * rotation boundary must be the same instant for every process appending to one
244
+ * directory — a fleet across time zones would write two files for one day.
245
+ */
246
+ function dailyFileDateStamp(date) {
247
+ return date.toISOString().slice(0, 10);
248
+ }
249
+ /** The dated file a base path rotates to on `date`. */
250
+ function dailyFilePath(basePath, date) {
251
+ const { dir, name, ext } = path$1.parse(basePath);
252
+ return path$1.join(dir, `${name}-${dailyFileDateStamp(date)}${ext}`);
253
+ }
254
+ /**
255
+ * The date stamp of `fileName` if it is one of `basePath`'s dated files, else
256
+ * `null` — the inverse of {@link dailyFilePath}. The base name and extension
257
+ * are escaped first: `app.v1.log` would otherwise match another app's files
258
+ * into this rotation set, which for the cleanup consuming it means deleting them.
259
+ */
260
+ function matchDailyFileDate(basePath, fileName) {
261
+ const { name, ext } = path$1.parse(basePath);
262
+ return new RegExp(`^${escapeRegExp(name)}-(\\d{4}-\\d{2}-\\d{2})${escapeRegExp(ext)}$`, "u").exec(fileName)?.[1] ?? null;
263
+ }
264
+ /** Every character with meaning inside a regular expression, made literal. */
265
+ function escapeRegExp(text) {
266
+ return text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
267
+ }
268
+ //#endregion
269
+ //#region src/logging/channels/DailyFileChannel.ts
270
+ /** Daily rotating file log channel. */
275
271
  var DailyFileChannel = class {
276
272
  config;
277
273
  minLevel;
@@ -287,43 +283,33 @@ var DailyFileChannel = class {
287
283
  }
288
284
  log(entry) {
289
285
  if (LOG_LEVEL_PRIORITY[entry.level] > this.minLevel) return;
290
- const dateStr = this.getDateString(entry.timestamp);
291
- if (this.currentDate !== dateStr) this.rotate(dateStr);
286
+ const dateStr = dailyFileDateStamp(entry.timestamp);
287
+ if (this.currentDate !== dateStr) this.rotate(entry.timestamp, dateStr);
292
288
  const line = this.format(entry) + "\n";
293
289
  this.write(line);
294
290
  }
295
291
  write(data) {
296
292
  if (this.currentFilePath) fs.appendFileSync(this.currentFilePath, data);
297
293
  }
298
- rotate(dateStr) {
294
+ rotate(date, dateStr) {
299
295
  this.currentDate = dateStr;
300
- this.currentFilePath = this.getFilePath(dateStr);
296
+ this.currentFilePath = dailyFilePath(this.config.path, date);
301
297
  this.ensureDirectory(this.currentFilePath);
302
298
  this.cleanup();
303
299
  }
304
- getFilePath(dateStr) {
305
- const { dir, name, ext } = path$1.parse(this.config.path);
306
- return path$1.join(dir, `${name}-${dateStr}${ext}`);
307
- }
308
- getDateString(date) {
309
- return date.toISOString().split("T")[0];
310
- }
311
300
  ensureDirectory(filePath) {
312
301
  const dir = path$1.dirname(filePath);
313
302
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
314
303
  }
315
304
  cleanup() {
316
- const { dir, name, ext } = path$1.parse(this.config.path);
305
+ const dir = path$1.dirname(this.config.path);
317
306
  if (!fs.existsSync(dir)) return;
318
307
  const files = fs.readdirSync(dir);
319
- const pattern = new RegExp(`^${name}-(\\d{4}-\\d{2}-\\d{2})${ext.replace(".", "\\.")}$`);
320
308
  const cutoff = /* @__PURE__ */ new Date();
321
309
  cutoff.setDate(cutoff.getDate() - (this.config.days ?? 14));
322
310
  for (const file of files) {
323
- const match = file.match(pattern);
324
- if (match) {
325
- if (new Date(match[1]) < cutoff) fs.unlinkSync(path$1.join(dir, file));
326
- }
311
+ const stamp = matchDailyFileDate(this.config.path, file);
312
+ if (stamp !== null && new Date(stamp) < cutoff) fs.unlinkSync(path$1.join(dir, file));
327
313
  }
328
314
  }
329
315
  format(entry) {
@@ -342,27 +328,7 @@ var DailyFileChannel = class {
342
328
  };
343
329
  //#endregion
344
330
  //#region src/logging/LogManager.ts
345
- /**
346
- * Log manager for managing multiple logging channels.
347
- *
348
- * @example
349
- * ```ts
350
- * const log = new LogManager({
351
- * default: 'stack',
352
- * channels: {
353
- * console: { driver: 'console', level: 'debug' },
354
- * file: { driver: 'daily', path: './storage/logs/app.log', days: 14 },
355
- * stack: { driver: 'stack', channels: ['console', 'file'] },
356
- * }
357
- * })
358
- *
359
- * log.info('User logged in', { userId: user.id })
360
- * log.error('Payment failed', { orderId, error: error.message })
361
- *
362
- * const requestLog = log.withContext({ requestId: ctx.requestId })
363
- * requestLog.info('Processing request')
364
- * ```
365
- */
331
+ /** Log manager for managing multiple logging channels. */
366
332
  var LogManager = class {
367
333
  config;
368
334
  channelFactories = /* @__PURE__ */ new Map();
@@ -395,22 +361,34 @@ var LogManager = class {
395
361
  const channels = config.channels.map((name) => this.resolveChannel(name));
396
362
  return {
397
363
  log: (entry) => {
398
- for (const channel of channels) channel.log(entry);
364
+ const failures = [];
365
+ const pending = [];
366
+ for (const channel of channels) try {
367
+ const result = channel.log(entry);
368
+ if (isPromiseLike(result)) pending.push(Promise.resolve(result).then(() => void 0, (error) => {
369
+ failures.push(error);
370
+ }));
371
+ } catch (error) {
372
+ failures.push(error);
373
+ }
374
+ const rethrow = () => {
375
+ if (failures.length === 1) throw failures[0];
376
+ if (failures.length > 1) throw new AggregateError(failures, `${failures.length} of ${channels.length} stack channels failed`);
377
+ };
378
+ if (pending.length === 0) {
379
+ rethrow();
380
+ return;
381
+ }
382
+ return Promise.all(pending).then(rethrow);
399
383
  },
400
384
  close: async () => {
401
385
  for (const channel of channels) if (channel.close) await channel.close();
402
386
  }
403
387
  };
404
388
  }
405
- /**
406
- * Register a custom channel driver.
407
- */
408
389
  registerDriver(name, factory) {
409
390
  this.channelFactories.set(name, factory);
410
391
  }
411
- /**
412
- * Get a logger for a specific channel.
413
- */
414
392
  channel(name) {
415
393
  const channelName = name ?? this.config.default;
416
394
  if (!this.loggers.has(channelName)) {
@@ -419,9 +397,6 @@ var LogManager = class {
419
397
  }
420
398
  return this.loggers.get(channelName);
421
399
  }
422
- /**
423
- * Get a logger that writes to multiple channels.
424
- */
425
400
  stack(channelNames) {
426
401
  const key = `stack:${channelNames.join(",")}`;
427
402
  if (!this.loggers.has(key)) {
@@ -440,9 +415,6 @@ var LogManager = class {
440
415
  this.channelInstances.set(name, channel);
441
416
  return channel;
442
417
  }
443
- /**
444
- * Create a logger with additional context using the default channel.
445
- */
446
418
  withContext(context) {
447
419
  return this.channel().withContext(context);
448
420
  }
@@ -473,46 +445,28 @@ var LogManager = class {
473
445
  debug(message, context) {
474
446
  this.channel().debug(message, context);
475
447
  }
476
- /**
477
- * Close all channel instances.
478
- */
479
448
  async close() {
480
449
  for (const channel of this.channelInstances.values()) if (channel.close) await channel.close();
481
450
  this.channelInstances.clear();
482
451
  this.loggers.clear();
483
452
  }
484
- /**
485
- * Get the default channel name.
486
- */
487
453
  getDefaultChannel() {
488
454
  return this.config.default;
489
455
  }
490
- /**
491
- * Get available channel names.
492
- */
493
456
  getChannelNames() {
494
457
  return Object.keys(this.config.channels);
495
458
  }
496
459
  };
497
- /**
498
- * Create a log manager instance.
499
- */
500
460
  function createLogManager(config) {
501
461
  return new LogManager(config);
502
462
  }
503
463
  let globalLogManager = null;
504
- /**
505
- * Set the global log manager instance.
506
- */
507
464
  function setLogManager(manager) {
508
465
  globalLogManager = manager;
509
466
  }
510
- /**
511
- * Get the global log manager instance.
512
- */
513
467
  function getLogManager() {
514
468
  if (!globalLogManager) throw new Error("Log manager has not been initialized. Call setLogManager() first.");
515
469
  return globalLogManager;
516
470
  }
517
471
  //#endregion
518
- export { DailyFileChannel as a, Logger as c, setLogManager as i, filterSensitiveData as l, createLogManager as n, FileChannel as o, getLogManager as r, ConsoleChannel as s, LogManager as t, LOG_LEVEL_PRIORITY as u };
472
+ export { DailyFileChannel as a, matchDailyFileDate as c, Logger as d, filterSensitiveData as f, setLogManager as i, FileChannel as l, createLogManager as n, dailyFileDateStamp as o, LOG_LEVEL_PRIORITY as p, getLogManager as r, dailyFilePath as s, LogManager as t, ConsoleChannel as u };
@@ -1,49 +1,21 @@
1
1
  //#region src/container/ServiceProvider.ts
2
2
  /**
3
- * Base service provider class.
4
- *
5
- * Service providers are the central place of all application bootstrapping.
6
- * Your own application, as well as all core services, are bootstrapped via providers.
7
- *
8
- * @example
9
- * ```typescript
10
- * export class AppServiceProvider extends ServiceProvider {
11
- * register(): void {
12
- * // Register bindings
13
- * this.container.singleton('db', (c) => new Database(c.make('config')))
14
- * }
15
- *
16
- * boot(): void {
17
- * // Bootstrap after all providers registered
18
- * const db = this.container.make<Database>('db')
19
- * db.connect()
20
- * }
21
- * }
22
- * ```
3
+ * Base service provider: all application and core bootstrapping runs through
4
+ * providers. `register()` binds services before any provider boots; `boot()` runs
5
+ * after every provider has registered.
23
6
  */
24
7
  var ServiceProvider = class {
25
8
  container;
26
- /**
27
- * Whether this provider should be deferred.
28
- * Deferred providers are only loaded when one of their provided services is requested.
29
- */
9
+ /** Load only when one of `provides` is requested. */
30
10
  static deferred = false;
31
- /**
32
- * The services provided by this provider (for deferred loading).
33
- */
11
+ /** Services this provider supplies, for deferred loading. */
34
12
  static provides = [];
35
13
  constructor(container) {
36
14
  this.container = container;
37
15
  }
38
- /**
39
- * Get the services provided by the provider.
40
- */
41
16
  provides() {
42
17
  return this.constructor.provides;
43
18
  }
44
- /**
45
- * Check if this provider is deferred.
46
- */
47
19
  isDeferred() {
48
20
  return this.constructor.deferred;
49
21
  }
@@ -57,13 +29,12 @@ var ProviderManager = class {
57
29
  registered = /* @__PURE__ */ new Set();
58
30
  booted = /* @__PURE__ */ new Set();
59
31
  deferredProviders = /* @__PURE__ */ new Map();
32
+ /** Per service, the boot of an already-activated deferred provider, so a later loadDeferredProvider() awaits that boot */
33
+ deferredActivations = /* @__PURE__ */ new Map();
60
34
  allBooted = false;
61
35
  constructor(container) {
62
36
  this.container = container;
63
37
  }
64
- /**
65
- * Register a provider.
66
- */
67
38
  register(providerOrClass) {
68
39
  if (this.allBooted) {
69
40
  const name = providerOrClass instanceof ServiceProvider ? providerOrClass.constructor.name : providerOrClass.name;
@@ -75,65 +46,58 @@ var ProviderManager = class {
75
46
  else this.providers.push(provider);
76
47
  return this;
77
48
  }
78
- /**
79
- * Register multiple providers.
80
- */
81
49
  registerMany(providers) {
82
50
  for (const provider of providers) this.register(provider);
83
51
  return this;
84
52
  }
85
- /**
86
- * Register all non-deferred providers.
87
- */
88
53
  async registerAll() {
89
54
  for (const provider of this.providers) if (!this.registered.has(provider)) {
90
55
  await provider.register();
91
56
  this.registered.add(provider);
92
57
  }
93
58
  }
94
- /**
95
- * Boot all registered providers.
96
- */
97
59
  async bootAll() {
98
60
  for (const provider of this.providers) if (!this.booted.has(provider) && this.registered.has(provider)) {
99
61
  await provider.boot?.();
100
62
  this.booted.add(provider);
101
63
  }
102
64
  this.allBooted = true;
103
- if (this.deferredProviders.size > 0) this.container.deferredProviderLoader = (service) => this.loadDeferredProvider(service);
65
+ if (this.deferredProviders.size > 0) this.container.deferredProviderLoader = (service) => this.activateDeferredProvider(service);
104
66
  }
105
67
  /**
106
- * Load a deferred provider for a service.
68
+ * Register, boot, and unclaim a deferred provider's services. Resolves once
69
+ * boot() has finished, also when Container.make() already activated it.
107
70
  */
108
71
  async loadDeferredProvider(service) {
72
+ await (this.activateDeferredProvider(service) ?? this.deferredActivations.get(service));
73
+ }
74
+ /**
75
+ * Synchronous half of deferred loading, so a synchronous Container.make() can
76
+ * resolve the service: register() runs before this returns; boot() follows on the
77
+ * returned promise, which make() does not await (a boot failure is an unhandled
78
+ * rejection). Services are unclaimed up front so a re-entrant make() for a sibling
79
+ * service cannot register the provider twice.
80
+ */
81
+ activateDeferredProvider(service) {
109
82
  const provider = this.deferredProviders.get(service);
110
- if (!provider) return;
111
- if (!this.registered.has(provider)) {
112
- await provider.register();
113
- this.registered.add(provider);
114
- this.providers.push(provider);
115
- }
116
- if (!this.booted.has(provider)) {
83
+ if (!provider) return void 0;
84
+ const registering = provider.register();
85
+ this.registered.add(provider);
86
+ this.providers.push(provider);
87
+ for (const providedService of provider.provides()) this.deferredProviders.delete(providedService);
88
+ const activation = Promise.resolve(registering).then(async () => {
117
89
  await provider.boot?.();
118
90
  this.booted.add(provider);
119
- }
120
- for (const providedService of provider.provides()) this.deferredProviders.delete(providedService);
91
+ });
92
+ for (const providedService of provider.provides()) this.deferredActivations.set(providedService, activation);
93
+ return activation;
121
94
  }
122
- /**
123
- * Check if a service is provided by a deferred provider.
124
- */
125
95
  isDeferredService(service) {
126
96
  return this.deferredProviders.has(service);
127
97
  }
128
- /**
129
- * Get all registered providers.
130
- */
131
98
  getProviders() {
132
99
  return [...this.providers];
133
100
  }
134
- /**
135
- * Get all deferred services.
136
- */
137
101
  getDeferredServices() {
138
102
  return Array.from(this.deferredProviders.keys());
139
103
  }
@@ -144,15 +108,10 @@ const LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "[::1]"]);
144
108
  const LOOPBACK_IPV4 = /^127\.\d+\.\d+\.\d+$/;
145
109
  /**
146
110
  * Whether an `Origin` header value belongs to the developer's own machine.
147
- *
148
- * Non-browser clients send no `Origin` at all; a value only appears when a
149
- * web page made the request. Restricting those to loopback blocks both
150
- * ordinary cross-site requests and DNS rebinding, where an attacker's
151
- * domain resolves to 127.0.0.1 so the browser skips preflight.
152
- *
153
- * This is a *negative* filter only. A loopback `Origin` is never proof that
154
- * the caller is local: browsers set the header honestly, but any other
155
- * client sets it with one flag. Never use it to satisfy the peer check.
111
+ * Only a web page's request carries one; restricting it to loopback blocks
112
+ * cross-site requests and DNS rebinding (an attacker's domain resolving to
113
+ * 127.0.0.1 so the browser skips preflight). A *negative* filter only: any
114
+ * non-browser client sets the header with one flag, so never use it to satisfy the peer check.
156
115
  */
157
116
  function isLoopbackOrigin(origin) {
158
117
  try {
@@ -174,17 +133,10 @@ function isLoopbackAddress(address) {
174
133
  }
175
134
  /**
176
135
  * The peer address of the current request, when the runtime exposes one.
177
- *
178
- * `Bun.serve` passes `{ server }` through Hono's env — the same access path
179
- * the rate limiter uses, and the one `Application.listen()` wires up. Proxy
180
- * headers are deliberately ignored: they are attacker-controlled, and these
181
- * endpoints are never meant to sit behind a proxy.
182
- *
183
- * `undefined` means "this runtime did not tell us", not "the peer is
184
- * remote": either the host never passed a `server` through (Node, Vercel's
185
- * `app.fetch(request)`, in-process test requests), or `requestIP()` itself
186
- * returned `null`, which Bun does for a socket that is already closed or is
187
- * not TCP.
136
+ * `Bun.serve` passes `{ server }` through Hono's env, wired by
137
+ * `Application.listen()`; proxy headers are attacker-controlled and ignored.
138
+ * `undefined` means "the runtime did not say", not "remote": no `server` in env
139
+ * (Node, Vercel's `app.fetch(request)`, in-process tests), or `requestIP()` null (closed or non-TCP socket).
188
140
  */
189
141
  function clientAddress(ctx) {
190
142
  const env = ctx.env;
@@ -202,13 +154,10 @@ function allowsUnverifiedPeer() {
202
154
  return typeof process !== "undefined" && process.env.GUREN_ALLOW_UNVERIFIED_PEER === "1";
203
155
  }
204
156
  /**
205
- * Restricts an endpoint to the developer's own machine. `resource` names
206
- * the endpoint in the 403 body (e.g. "the MCP endpoint").
207
- *
208
- * Three outcomes, and the two denials say different things on purpose:
209
- * a peer that is present and not loopback is a remote caller, while a peer
210
- * the runtime never reported is a deployment the guard cannot vouch for —
211
- * the developer needs to know which one they are looking at.
157
+ * Restricts an endpoint to the developer's own machine. `resource` names the
158
+ * endpoint in the 403 body (e.g. "the MCP endpoint"). The two denials say
159
+ * different things on purpose: a present non-loopback peer is a remote caller,
160
+ * a peer the runtime never reported is a deployment the guard cannot vouch for.
212
161
  */
213
162
  function createLoopbackGuard(resource) {
214
163
  return async (ctx, next) => {