@c9up/ream 0.1.34 → 0.2.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 (210) hide show
  1. package/dist/Application.d.ts +68 -0
  2. package/dist/Application.d.ts.map +1 -1
  3. package/dist/Application.js +142 -6
  4. package/dist/Application.js.map +1 -1
  5. package/dist/HealthCheck.d.ts +14 -7
  6. package/dist/HealthCheck.d.ts.map +1 -1
  7. package/dist/HealthCheck.js +21 -12
  8. package/dist/HealthCheck.js.map +1 -1
  9. package/dist/HttpKernel.d.ts +12 -0
  10. package/dist/HttpKernel.d.ts.map +1 -1
  11. package/dist/HttpKernel.js +15 -4
  12. package/dist/HttpKernel.js.map +1 -1
  13. package/dist/Ignitor.d.ts +8 -0
  14. package/dist/Ignitor.d.ts.map +1 -1
  15. package/dist/Ignitor.js +11 -0
  16. package/dist/Ignitor.js.map +1 -1
  17. package/dist/bodyparser/BodyParserMiddleware.d.ts +13 -2
  18. package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -1
  19. package/dist/bodyparser/BodyParserMiddleware.js +50 -30
  20. package/dist/bodyparser/BodyParserMiddleware.js.map +1 -1
  21. package/dist/bodyparser/MultipartFile.d.ts +65 -6
  22. package/dist/bodyparser/MultipartFile.d.ts.map +1 -1
  23. package/dist/bodyparser/MultipartFile.js +100 -7
  24. package/dist/bodyparser/MultipartFile.js.map +1 -1
  25. package/dist/console/BaseCommand.d.ts +8 -1
  26. package/dist/console/BaseCommand.d.ts.map +1 -1
  27. package/dist/console/BaseCommand.js +1 -1
  28. package/dist/console/BaseCommand.js.map +1 -1
  29. package/dist/console/Kernel.d.ts +15 -0
  30. package/dist/console/Kernel.d.ts.map +1 -1
  31. package/dist/console/Kernel.js +17 -0
  32. package/dist/console/Kernel.js.map +1 -1
  33. package/dist/directories.d.ts +52 -0
  34. package/dist/directories.d.ts.map +1 -0
  35. package/dist/directories.js +38 -0
  36. package/dist/directories.js.map +1 -0
  37. package/dist/events/Emitter.d.ts +49 -6
  38. package/dist/events/Emitter.d.ts.map +1 -1
  39. package/dist/events/Emitter.js +117 -7
  40. package/dist/events/Emitter.js.map +1 -1
  41. package/dist/events/EventsBuffer.d.ts +47 -0
  42. package/dist/events/EventsBuffer.d.ts.map +1 -0
  43. package/dist/events/EventsBuffer.js +107 -0
  44. package/dist/events/EventsBuffer.js.map +1 -0
  45. package/dist/events/index.d.ts +2 -0
  46. package/dist/events/index.d.ts.map +1 -1
  47. package/dist/events/index.js +1 -0
  48. package/dist/events/index.js.map +1 -1
  49. package/dist/health/BaseCheck.d.ts +19 -0
  50. package/dist/health/BaseCheck.d.ts.map +1 -0
  51. package/dist/health/BaseCheck.js +24 -0
  52. package/dist/health/BaseCheck.js.map +1 -0
  53. package/dist/health/HealthChecks.d.ts +15 -0
  54. package/dist/health/HealthChecks.d.ts.map +1 -0
  55. package/dist/health/HealthChecks.js +69 -0
  56. package/dist/health/HealthChecks.js.map +1 -0
  57. package/dist/health/Result.d.ts +27 -0
  58. package/dist/health/Result.d.ts.map +1 -0
  59. package/dist/health/Result.js +55 -0
  60. package/dist/health/Result.js.map +1 -0
  61. package/dist/health/checks/DiskSpaceCheck.d.ts +29 -0
  62. package/dist/health/checks/DiskSpaceCheck.d.ts.map +1 -0
  63. package/dist/health/checks/DiskSpaceCheck.js +58 -0
  64. package/dist/health/checks/DiskSpaceCheck.js.map +1 -0
  65. package/dist/health/checks/MemoryHeapCheck.d.ts +21 -0
  66. package/dist/health/checks/MemoryHeapCheck.d.ts.map +1 -0
  67. package/dist/health/checks/MemoryHeapCheck.js +55 -0
  68. package/dist/health/checks/MemoryHeapCheck.js.map +1 -0
  69. package/dist/health/checks/MemoryRSSCheck.d.ts +21 -0
  70. package/dist/health/checks/MemoryRSSCheck.d.ts.map +1 -0
  71. package/dist/health/checks/MemoryRSSCheck.js +55 -0
  72. package/dist/health/checks/MemoryRSSCheck.js.map +1 -0
  73. package/dist/health/checks/memory.d.ts +24 -0
  74. package/dist/health/checks/memory.d.ts.map +1 -0
  75. package/dist/health/checks/memory.js +88 -0
  76. package/dist/health/checks/memory.js.map +1 -0
  77. package/dist/health/index.d.ts +9 -0
  78. package/dist/health/index.d.ts.map +1 -0
  79. package/dist/health/index.js +8 -0
  80. package/dist/health/index.js.map +1 -0
  81. package/dist/health/tracing.d.ts +12 -0
  82. package/dist/health/tracing.d.ts.map +1 -0
  83. package/dist/health/tracing.js +11 -0
  84. package/dist/health/tracing.js.map +1 -0
  85. package/dist/health/types.d.ts +51 -0
  86. package/dist/health/types.d.ts.map +1 -0
  87. package/dist/health/types.js +5 -0
  88. package/dist/health/types.js.map +1 -0
  89. package/dist/helpers/bytes.d.ts +28 -0
  90. package/dist/helpers/bytes.d.ts.map +1 -0
  91. package/dist/helpers/bytes.js +63 -0
  92. package/dist/helpers/bytes.js.map +1 -0
  93. package/dist/helpers/string.d.ts +4 -0
  94. package/dist/helpers/string.d.ts.map +1 -1
  95. package/dist/helpers/string.js +2 -0
  96. package/dist/helpers/string.js.map +1 -1
  97. package/dist/http/HttpContext.d.ts +30 -2
  98. package/dist/http/HttpContext.d.ts.map +1 -1
  99. package/dist/http/HttpContext.js +73 -3
  100. package/dist/http/HttpContext.js.map +1 -1
  101. package/dist/http/Request.d.ts +42 -3
  102. package/dist/http/Request.d.ts.map +1 -1
  103. package/dist/http/Request.js +51 -7
  104. package/dist/http/Request.js.map +1 -1
  105. package/dist/http/Response.d.ts +82 -2
  106. package/dist/http/Response.d.ts.map +1 -1
  107. package/dist/http/Response.js +240 -13
  108. package/dist/http/Response.js.map +1 -1
  109. package/dist/http/SseStream.d.ts +10 -0
  110. package/dist/http/SseStream.d.ts.map +1 -1
  111. package/dist/http/SseStream.js.map +1 -1
  112. package/dist/index.d.ts +7 -2
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +4 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/migrations/MigrationRegistry.d.ts +28 -0
  117. package/dist/migrations/MigrationRegistry.d.ts.map +1 -0
  118. package/dist/migrations/MigrationRegistry.js +41 -0
  119. package/dist/migrations/MigrationRegistry.js.map +1 -0
  120. package/dist/migrations/types.d.ts +64 -0
  121. package/dist/migrations/types.d.ts.map +1 -0
  122. package/dist/migrations/types.js +15 -0
  123. package/dist/migrations/types.js.map +1 -0
  124. package/dist/router/Router.d.ts +112 -9
  125. package/dist/router/Router.d.ts.map +1 -1
  126. package/dist/router/Router.js +206 -28
  127. package/dist/router/Router.js.map +1 -1
  128. package/dist/security/CookieSigner.d.ts +43 -4
  129. package/dist/security/CookieSigner.d.ts.map +1 -1
  130. package/dist/security/CookieSigner.js +68 -10
  131. package/dist/security/CookieSigner.js.map +1 -1
  132. package/dist/session/Session.d.ts +46 -1
  133. package/dist/session/Session.d.ts.map +1 -1
  134. package/dist/session/Session.js +57 -4
  135. package/dist/session/Session.js.map +1 -1
  136. package/dist/session/SessionMiddleware.d.ts.map +1 -1
  137. package/dist/session/SessionMiddleware.js +19 -9
  138. package/dist/session/SessionMiddleware.js.map +1 -1
  139. package/dist/session/drivers/CookieDriver.d.ts +1 -1
  140. package/dist/session/drivers/CookieDriver.d.ts.map +1 -1
  141. package/dist/session/drivers/CookieDriver.js +3 -3
  142. package/dist/session/drivers/CookieDriver.js.map +1 -1
  143. package/dist/session/drivers/DatabaseDriver.d.ts +1 -1
  144. package/dist/session/drivers/DatabaseDriver.d.ts.map +1 -1
  145. package/dist/session/drivers/DatabaseDriver.js +2 -2
  146. package/dist/session/drivers/DatabaseDriver.js.map +1 -1
  147. package/dist/session/drivers/FileDriver.d.ts +1 -1
  148. package/dist/session/drivers/FileDriver.d.ts.map +1 -1
  149. package/dist/session/drivers/FileDriver.js +7 -5
  150. package/dist/session/drivers/FileDriver.js.map +1 -1
  151. package/dist/session/drivers/MemoryDriver.d.ts +1 -1
  152. package/dist/session/drivers/MemoryDriver.d.ts.map +1 -1
  153. package/dist/session/drivers/MemoryDriver.js +1 -1
  154. package/dist/session/drivers/MemoryDriver.js.map +1 -1
  155. package/dist/session/drivers/RedisDriver.d.ts +1 -1
  156. package/dist/session/drivers/RedisDriver.d.ts.map +1 -1
  157. package/dist/session/drivers/RedisDriver.js +11 -4
  158. package/dist/session/drivers/RedisDriver.js.map +1 -1
  159. package/events.win32-x64-msvc.node +0 -0
  160. package/index.darwin-arm64.node +0 -0
  161. package/index.darwin-x64.node +0 -0
  162. package/index.linux-arm64-gnu.node +0 -0
  163. package/index.linux-x64-gnu.node +0 -0
  164. package/index.win32-x64-msvc.node +0 -0
  165. package/package.json +5 -2
  166. package/scheduler.win32-x64-msvc.node +0 -0
  167. package/src/Application.ts +169 -6
  168. package/src/HealthCheck.ts +27 -14
  169. package/src/HttpKernel.ts +27 -4
  170. package/src/Ignitor.ts +17 -0
  171. package/src/bodyparser/BodyParserMiddleware.ts +70 -36
  172. package/src/bodyparser/MultipartFile.ts +125 -8
  173. package/src/console/BaseCommand.ts +8 -1
  174. package/src/console/Kernel.ts +18 -0
  175. package/src/directories.ts +81 -0
  176. package/src/events/Emitter.ts +129 -13
  177. package/src/events/EventsBuffer.ts +131 -0
  178. package/src/events/index.ts +7 -0
  179. package/src/health/BaseCheck.ts +30 -0
  180. package/src/health/HealthChecks.ts +83 -0
  181. package/src/health/Result.ts +69 -0
  182. package/src/health/checks/DiskSpaceCheck.ts +69 -0
  183. package/src/health/checks/MemoryHeapCheck.ts +68 -0
  184. package/src/health/checks/MemoryRSSCheck.ts +68 -0
  185. package/src/health/checks/memory.ts +115 -0
  186. package/src/health/index.ts +13 -0
  187. package/src/health/tracing.ts +15 -0
  188. package/src/health/types.ts +51 -0
  189. package/src/helpers/bytes.ts +71 -0
  190. package/src/helpers/string.ts +2 -0
  191. package/src/http/HttpContext.ts +78 -4
  192. package/src/http/Request.ts +62 -10
  193. package/src/http/Response.ts +283 -14
  194. package/src/http/SseStream.ts +10 -0
  195. package/src/index.ts +27 -1
  196. package/src/migrations/MigrationRegistry.ts +49 -0
  197. package/src/migrations/types.ts +68 -0
  198. package/src/router/Router.ts +241 -32
  199. package/src/security/CookieSigner.ts +92 -18
  200. package/src/session/Session.ts +71 -5
  201. package/src/session/SessionMiddleware.ts +19 -9
  202. package/src/session/drivers/CookieDriver.ts +4 -4
  203. package/src/session/drivers/DatabaseDriver.ts +3 -3
  204. package/src/session/drivers/FileDriver.ts +8 -6
  205. package/src/session/drivers/MemoryDriver.ts +2 -2
  206. package/src/session/drivers/RedisDriver.ts +12 -5
  207. package/tsconfig.app.json +13 -13
  208. package/tsconfig.base.json +19 -0
  209. package/tsconfig.client.json +16 -0
  210. package/tsconfig.package.json +15 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * A chainable builder for a check result (AdonisJS `Result`).
3
+ */
4
+ export class Result {
5
+ message;
6
+ status;
7
+ finishedAt;
8
+ /** Free-form data attached to the result. */
9
+ meta;
10
+ constructor(message, status, finishedAt) {
11
+ this.message = message;
12
+ this.status = status;
13
+ this.finishedAt = finishedAt;
14
+ }
15
+ /** A passing result. */
16
+ static ok(message) {
17
+ return new Result(message, 'ok', new Date());
18
+ }
19
+ static failed(message, error) {
20
+ const result = new Result(typeof message === 'string' ? message : message.message, 'error', new Date());
21
+ if (error)
22
+ result.setMetaData({ error });
23
+ if (typeof message !== 'string')
24
+ result.setMetaData({ error: message });
25
+ return result;
26
+ }
27
+ /** A result that is not yet failing but wants attention. */
28
+ static warning(message) {
29
+ return new Result(message, 'warning', new Date());
30
+ }
31
+ /** Override when the check finished. */
32
+ setFinishedAt(finishedAt) {
33
+ this.finishedAt = finishedAt;
34
+ return this;
35
+ }
36
+ /** Replace the meta-data wholesale. */
37
+ setMetaData(metaData) {
38
+ this.meta = metaData;
39
+ return this;
40
+ }
41
+ /** Shallow-merge into the existing meta-data. */
42
+ mergeMetaData(metaData) {
43
+ this.meta = { ...this.meta, ...metaData };
44
+ return this;
45
+ }
46
+ toJSON() {
47
+ return {
48
+ finishedAt: this.finishedAt,
49
+ message: this.message,
50
+ status: this.status,
51
+ ...(this.meta ? { meta: this.meta } : {}),
52
+ };
53
+ }
54
+ }
55
+ //# sourceMappingURL=Result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Result.js","sourceRoot":"","sources":["../../src/health/Result.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,OAAO,CAAQ;IACf,MAAM,CAA6B;IACnC,UAAU,CAAM;IAChB,6CAA6C;IAC7C,IAAI,CAA4B;IAEhC,YAAY,OAAe,EAAE,MAAmC,EAAE,UAAgB;QAChF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED,wBAAwB;IACxB,MAAM,CAAC,EAAE,CAAC,OAAe;QACvB,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;IAC9C,CAAC;IAKD,MAAM,CAAC,MAAM,CAAC,OAAuB,EAAE,KAAa;QAClD,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EACvD,OAAO,EACP,IAAI,IAAI,EAAE,CACX,CAAA;QACD,IAAI,KAAK;YAAE,MAAM,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACxC,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,MAAM,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;QACvE,OAAO,MAAM,CAAA;IACf,CAAC;IAED,4DAA4D;IAC5D,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;IACnD,CAAC;IAED,wCAAwC;IACxC,aAAa,CAAC,UAAgB;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,uCAAuC;IACvC,WAAW,CAAC,QAAiC;QAC3C,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,iDAAiD;IACjD,aAAa,CAAC,QAAiC;QAC7C,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAA;QACzC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ import { BaseCheck } from '../BaseCheck.js';
2
+ import type { HealthCheckResult } from '../types.js';
3
+ /**
4
+ * Watches how full the disk is (AdonisJS `DiskSpaceCheck`).
5
+ *
6
+ * NAMED DEVIATION — upstream depends on the `check-disk-space` package, which
7
+ * shells out to `df` on POSIX and `wmic` on Windows. Ream reads Node's own
8
+ * `fs.statfs` instead: no dependency, no subprocess, and the same two numbers.
9
+ * `bavail` rather than `bfree` is deliberate — it is the space actually
10
+ * available to this process, which is what `df` reports and what an operator
11
+ * means by "free".
12
+ */
13
+ export declare class DiskSpaceCheck extends BaseCheck {
14
+ #private;
15
+ name: string;
16
+ /** The mount point to measure. */
17
+ diskPath: string;
18
+ /** Warn once this percentage of the disk is used. */
19
+ warnWhenExceeds(valueInPercentage: number): this;
20
+ /** Fail once this percentage of the disk is used. */
21
+ failWhenExceeds(valueInPercentage: number): this;
22
+ /** Replace how the reading is taken, so a test can drive the thresholds. */
23
+ compute(callback: () => Promise<{
24
+ free: number;
25
+ size: number;
26
+ }>): this;
27
+ run(): Promise<HealthCheckResult>;
28
+ }
29
+ //# sourceMappingURL=DiskSpaceCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiskSpaceCheck.d.ts","sourceRoot":"","sources":["../../../src/health/checks/DiskSpaceCheck.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,SAAS;;IAQ3C,IAAI,SAAqB;IACzB,kCAAkC;IAClC,QAAQ,SAA8C;IAEtD,qDAAqD;IACrD,eAAe,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAKhD,qDAAqD;IACrD,eAAe,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAKhD,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI;IAKhE,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAuBxC"}
@@ -0,0 +1,58 @@
1
+ import { statfs } from 'node:fs/promises';
2
+ import { BaseCheck } from '../BaseCheck.js';
3
+ import { Result } from '../Result.js';
4
+ /**
5
+ * Watches how full the disk is (AdonisJS `DiskSpaceCheck`).
6
+ *
7
+ * NAMED DEVIATION — upstream depends on the `check-disk-space` package, which
8
+ * shells out to `df` on POSIX and `wmic` on Windows. Ream reads Node's own
9
+ * `fs.statfs` instead: no dependency, no subprocess, and the same two numbers.
10
+ * `bavail` rather than `bfree` is deliberate — it is the space actually
11
+ * available to this process, which is what `df` reports and what an operator
12
+ * means by "free".
13
+ */
14
+ export class DiskSpaceCheck extends BaseCheck {
15
+ #warnThreshold = 75;
16
+ #failThreshold = 80;
17
+ #computeFn = async () => {
18
+ const stats = await statfs(this.diskPath);
19
+ return { free: Number(stats.bavail) * stats.bsize, size: Number(stats.blocks) * stats.bsize };
20
+ };
21
+ name = 'Disk space check';
22
+ /** The mount point to measure. */
23
+ diskPath = process.platform === 'win32' ? 'C:\\' : '/';
24
+ /** Warn once this percentage of the disk is used. */
25
+ warnWhenExceeds(valueInPercentage) {
26
+ this.#warnThreshold = valueInPercentage;
27
+ return this;
28
+ }
29
+ /** Fail once this percentage of the disk is used. */
30
+ failWhenExceeds(valueInPercentage) {
31
+ this.#failThreshold = valueInPercentage;
32
+ return this;
33
+ }
34
+ /** Replace how the reading is taken, so a test can drive the thresholds. */
35
+ compute(callback) {
36
+ this.#computeFn = callback;
37
+ return this;
38
+ }
39
+ async run() {
40
+ const { free, size } = await this.#computeFn();
41
+ const usedPercentage = Math.floor(((size - free) / size) * 100);
42
+ const metaData = {
43
+ sizeInPercentage: {
44
+ used: usedPercentage,
45
+ failureThreshold: this.#failThreshold,
46
+ warningThreshold: this.#warnThreshold,
47
+ },
48
+ };
49
+ if (usedPercentage >= this.#failThreshold) {
50
+ return Result.failed(`Disk usage is ${usedPercentage}%, which is above the threshold of ${this.#failThreshold}%`).mergeMetaData(metaData);
51
+ }
52
+ if (usedPercentage >= this.#warnThreshold) {
53
+ return Result.warning(`Disk usage is ${usedPercentage}%, which is above the threshold of ${this.#warnThreshold}%`).mergeMetaData(metaData);
54
+ }
55
+ return Result.ok('Disk usage is under defined thresholds').mergeMetaData(metaData);
56
+ }
57
+ }
58
+ //# sourceMappingURL=DiskSpaceCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiskSpaceCheck.js","sourceRoot":"","sources":["../../../src/health/checks/DiskSpaceCheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OA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,GAAG;YACf,gBAAgB,EAAE;gBAChB,IAAI,EAAE,cAAc;gBACpB,gBAAgB,EAAE,IAAI,CAAC,cAAc;gBACrC,gBAAgB,EAAE,IAAI,CAAC,cAAc;aACtC;SACF,CAAA;QAED,IAAI,cAAc,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAO,MAAM,CAAC,MAAM,CAClB,iBAAiB,cAAc,sCAAsC,IAAI,CAAC,cAAc,GAAG,CAC5F,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC3B,CAAC;QACD,IAAI,cAAc,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,OAAO,MAAM,CAAC,OAAO,CACnB,iBAAiB,cAAc,sCAAsC,IAAI,CAAC,cAAc,GAAG,CAC5F,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC3B,CAAC;QACD,OAAO,MAAM,CAAC,EAAE,CAAC,wCAAwC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACpF,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { BaseCheck } from '../BaseCheck.js';
2
+ import type { HealthCheckResult } from '../types.js';
3
+ /**
4
+ * Watches the V8 heap (AdonisJS `MemoryHeapCheck`).
5
+ */
6
+ export declare class MemoryHeapCheck extends BaseCheck {
7
+ #private;
8
+ name: string;
9
+ /** Warn above this size — `'300 mb'` or a byte count. Clears any percentage. */
10
+ warnWhenExceeds(value: string | number): this;
11
+ /** Fail above this size. Clears any percentage. */
12
+ failWhenExceeds(value: string | number): this;
13
+ /** Warn above this share of the heap ceiling. Clears any byte threshold. */
14
+ warnWhenExceedsPercentage(valueInPercentage: number): this;
15
+ /** Fail above this share of the heap ceiling. Clears any byte threshold. */
16
+ failWhenExceedsPercentage(valueInPercentage: number): this;
17
+ /** Replace how the reading is taken, so a test can drive the thresholds. */
18
+ compute(callback: () => NodeJS.MemoryUsage): this;
19
+ run(): Promise<HealthCheckResult>;
20
+ }
21
+ //# sourceMappingURL=MemoryHeapCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryHeapCheck.d.ts","sourceRoot":"","sources":["../../../src/health/checks/MemoryHeapCheck.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGpD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;;IAO5C,IAAI,SAAsB;IAE1B,gFAAgF;IAChF,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM7C,mDAAmD;IACnD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM7C,4EAA4E;IAC5E,yBAAyB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAO1D,4EAA4E;IAC5E,yBAAyB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAO1D,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC,WAAW,GAAG,IAAI;IAK3C,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAcxC"}
@@ -0,0 +1,55 @@
1
+ import v8 from 'node:v8';
2
+ import { BaseCheck } from '../BaseCheck.js';
3
+ import { assertPercentage, parseByteThreshold, runMemoryCheck } from './memory.js';
4
+ /**
5
+ * Watches the V8 heap (AdonisJS `MemoryHeapCheck`).
6
+ */
7
+ export class MemoryHeapCheck extends BaseCheck {
8
+ #warnThresholdBytes = 250 * 1024 ** 2;
9
+ #failThresholdBytes = 300 * 1024 ** 2;
10
+ #warnThresholdPercentage = null;
11
+ #failThresholdPercentage = null;
12
+ #computeFn = () => process.memoryUsage();
13
+ name = 'Memory heap check';
14
+ /** Warn above this size — `'300 mb'` or a byte count. Clears any percentage. */
15
+ warnWhenExceeds(value) {
16
+ this.#warnThresholdBytes = parseByteThreshold(value, 'warnWhenExceeds');
17
+ this.#warnThresholdPercentage = null;
18
+ return this;
19
+ }
20
+ /** Fail above this size. Clears any percentage. */
21
+ failWhenExceeds(value) {
22
+ this.#failThresholdBytes = parseByteThreshold(value, 'failWhenExceeds');
23
+ this.#failThresholdPercentage = null;
24
+ return this;
25
+ }
26
+ /** Warn above this share of the heap ceiling. Clears any byte threshold. */
27
+ warnWhenExceedsPercentage(valueInPercentage) {
28
+ assertPercentage(valueInPercentage, 'Warn');
29
+ this.#warnThresholdPercentage = valueInPercentage;
30
+ this.#warnThresholdBytes = null;
31
+ return this;
32
+ }
33
+ /** Fail above this share of the heap ceiling. Clears any byte threshold. */
34
+ failWhenExceedsPercentage(valueInPercentage) {
35
+ assertPercentage(valueInPercentage, 'Fail');
36
+ this.#failThresholdPercentage = valueInPercentage;
37
+ this.#failThresholdBytes = null;
38
+ return this;
39
+ }
40
+ /** Replace how the reading is taken, so a test can drive the thresholds. */
41
+ compute(callback) {
42
+ this.#computeFn = callback;
43
+ return this;
44
+ }
45
+ async run() {
46
+ const { heapUsed } = this.#computeFn();
47
+ return runMemoryCheck(heapUsed, {
48
+ warnBytes: this.#warnThresholdBytes,
49
+ failBytes: this.#failThresholdBytes,
50
+ warnPercentage: this.#warnThresholdPercentage,
51
+ failPercentage: this.#failThresholdPercentage,
52
+ }, { subject: 'Heap', ceilingKey: 'heapInBytes', ceilingName: 'maxHeapSize' }, () => v8.getHeapStatistics().heap_size_limit);
53
+ }
54
+ }
55
+ //# sourceMappingURL=MemoryHeapCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryHeapCheck.js","sourceRoot":"","sources":["../../../src/health/checks/MemoryHeapCheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAElF;;GAEG;AACH,MAAM,OA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,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;QACtC,OAAO,cAAc,CACnB,QAAQ,EACR;YACE,SAAS,EAAE,IAAI,CAAC,mBAAmB;YACnC,SAAS,EAAE,IAAI,CAAC,mBAAmB;YACnC,cAAc,EAAE,IAAI,CAAC,wBAAwB;YAC7C,cAAc,EAAE,IAAI,CAAC,wBAAwB;SAC9C,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,EAC1E,GAAG,EAAE,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,eAAe,CAC7C,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { BaseCheck } from '../BaseCheck.js';
2
+ import type { HealthCheckResult } from '../types.js';
3
+ /**
4
+ * Watches the process' resident set size (AdonisJS `MemoryRSSCheck`).
5
+ */
6
+ export declare class MemoryRSSCheck extends BaseCheck {
7
+ #private;
8
+ name: string;
9
+ /** Warn above this size — `'300 mb'` or a byte count. Clears any percentage. */
10
+ warnWhenExceeds(value: string | number): this;
11
+ /** Fail above this size. Clears any percentage. */
12
+ failWhenExceeds(value: string | number): this;
13
+ /** Warn above this share of total system memory. Clears any byte threshold. */
14
+ warnWhenExceedsPercentage(valueInPercentage: number): this;
15
+ /** Fail above this share of total system memory. Clears any byte threshold. */
16
+ failWhenExceedsPercentage(valueInPercentage: number): this;
17
+ /** Replace how the reading is taken, so a test can drive the thresholds. */
18
+ compute(callback: () => NodeJS.MemoryUsage): this;
19
+ run(): Promise<HealthCheckResult>;
20
+ }
21
+ //# sourceMappingURL=MemoryRSSCheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryRSSCheck.d.ts","sourceRoot":"","sources":["../../../src/health/checks/MemoryRSSCheck.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGpD;;GAEG;AACH,qBAAa,cAAe,SAAQ,SAAS;;IAO3C,IAAI,SAAqB;IAEzB,gFAAgF;IAChF,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM7C,mDAAmD;IACnD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAM7C,+EAA+E;IAC/E,yBAAyB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAO1D,+EAA+E;IAC/E,yBAAyB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI;IAO1D,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC,WAAW,GAAG,IAAI;IAK3C,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAcxC"}
@@ -0,0 +1,55 @@
1
+ import os from 'node:os';
2
+ import { BaseCheck } from '../BaseCheck.js';
3
+ import { assertPercentage, parseByteThreshold, runMemoryCheck } from './memory.js';
4
+ /**
5
+ * Watches the process' resident set size (AdonisJS `MemoryRSSCheck`).
6
+ */
7
+ export class MemoryRSSCheck extends BaseCheck {
8
+ #warnThresholdBytes = 320 * 1024 ** 2;
9
+ #failThresholdBytes = 350 * 1024 ** 2;
10
+ #warnThresholdPercentage = null;
11
+ #failThresholdPercentage = null;
12
+ #computeFn = () => process.memoryUsage();
13
+ name = 'Memory RSS check';
14
+ /** Warn above this size — `'300 mb'` or a byte count. Clears any percentage. */
15
+ warnWhenExceeds(value) {
16
+ this.#warnThresholdBytes = parseByteThreshold(value, 'warnWhenExceeds');
17
+ this.#warnThresholdPercentage = null;
18
+ return this;
19
+ }
20
+ /** Fail above this size. Clears any percentage. */
21
+ failWhenExceeds(value) {
22
+ this.#failThresholdBytes = parseByteThreshold(value, 'failWhenExceeds');
23
+ this.#failThresholdPercentage = null;
24
+ return this;
25
+ }
26
+ /** Warn above this share of total system memory. Clears any byte threshold. */
27
+ warnWhenExceedsPercentage(valueInPercentage) {
28
+ assertPercentage(valueInPercentage, 'Warn');
29
+ this.#warnThresholdPercentage = valueInPercentage;
30
+ this.#warnThresholdBytes = null;
31
+ return this;
32
+ }
33
+ /** Fail above this share of total system memory. Clears any byte threshold. */
34
+ failWhenExceedsPercentage(valueInPercentage) {
35
+ assertPercentage(valueInPercentage, 'Fail');
36
+ this.#failThresholdPercentage = valueInPercentage;
37
+ this.#failThresholdBytes = null;
38
+ return this;
39
+ }
40
+ /** Replace how the reading is taken, so a test can drive the thresholds. */
41
+ compute(callback) {
42
+ this.#computeFn = callback;
43
+ return this;
44
+ }
45
+ async run() {
46
+ const { rss } = this.#computeFn();
47
+ return runMemoryCheck(rss, {
48
+ warnBytes: this.#warnThresholdBytes,
49
+ failBytes: this.#failThresholdBytes,
50
+ warnPercentage: this.#warnThresholdPercentage,
51
+ failPercentage: this.#failThresholdPercentage,
52
+ }, { subject: 'RSS', ceilingKey: 'memoryInBytes', ceilingName: 'totalSystemMemory' }, () => os.totalmem());
53
+ }
54
+ }
55
+ //# sourceMappingURL=MemoryRSSCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryRSSCheck.js","sourceRoot":"","sources":["../../../src/health/checks/MemoryRSSCheck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAElF;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,mBAAmB,GAAkB,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA;IACpD,mBAAmB,GAAkB,GAAG,GAAG,IAAI,IAAI,CAAC,CAAA;IACpD,wBAAwB,GAAkB,IAAI,CAAA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AAS,EAAE,IAAI,CAAC,mBAAmB;YACnC,SAAS,EAAE,IAAI,CAAC,mBAAmB;YACnC,cAAc,EAAE,IAAI,CAAC,wBAAwB;YAC7C,cAAc,EAAE,IAAI,CAAC,wBAAwB;SAC9C,EACD,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,EACjF,GAAG,EAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,CACpB,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import type { HealthCheckResult } from '../types.js';
2
+ /**
3
+ * The shared body of the two memory checks.
4
+ *
5
+ * Upstream spells this logic out twice, once in `MemoryRSSCheck` and once in
6
+ * `MemoryHeapCheck`; only the reading, the ceiling it is compared against, and
7
+ * two strings differ. The public surface of both classes is unchanged — this is
8
+ * an internal detail, not a deviation.
9
+ */
10
+ export type MemoryThresholds = {
11
+ warnBytes: number | null;
12
+ failBytes: number | null;
13
+ warnPercentage: number | null;
14
+ failPercentage: number | null;
15
+ };
16
+ export declare function runMemoryCheck(used: number, thresholds: MemoryThresholds, labels: {
17
+ subject: string;
18
+ ceilingKey: string;
19
+ ceilingName: string;
20
+ }, readCeiling: () => number): HealthCheckResult;
21
+ /** The threshold setters both memory checks expose, shared verbatim. */
22
+ export declare function parseByteThreshold(value: string | number, method: string): number;
23
+ export declare function assertPercentage(value: number, label: string): void;
24
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/health/checks/memory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B,CAAA;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACpE,WAAW,EAAE,MAAM,MAAM,GACxB,iBAAiB,CA8EnB;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGnE"}
@@ -0,0 +1,88 @@
1
+ import bytes from '../../helpers/bytes.js';
2
+ import { Result } from '../Result.js';
3
+ export function runMemoryCheck(used, thresholds, labels, readCeiling) {
4
+ const compareAsPercentage = thresholds.warnPercentage !== null || thresholds.failPercentage !== null;
5
+ let warnThreshold;
6
+ let failThreshold;
7
+ let valueToCompare;
8
+ let ceiling = null;
9
+ let usedPercentage = null;
10
+ if (compareAsPercentage) {
11
+ ceiling = readCeiling();
12
+ if (ceiling === 0) {
13
+ return Result.failed(`Cannot determine ${labels.ceilingName} (0 bytes).`).mergeMetaData({
14
+ [labels.ceilingKey]: { used, [labels.ceilingName]: ceiling },
15
+ });
16
+ }
17
+ usedPercentage = Math.floor((used / ceiling) * 100);
18
+ valueToCompare = usedPercentage;
19
+ if (thresholds.warnPercentage !== null)
20
+ warnThreshold = thresholds.warnPercentage;
21
+ else if (thresholds.warnBytes !== null)
22
+ warnThreshold = Math.floor((thresholds.warnBytes / ceiling) * 100);
23
+ else
24
+ return Result.failed('Warning threshold for percentage comparison is missing.');
25
+ if (thresholds.failPercentage !== null)
26
+ failThreshold = thresholds.failPercentage;
27
+ else if (thresholds.failBytes !== null)
28
+ failThreshold = Math.floor((thresholds.failBytes / ceiling) * 100);
29
+ else
30
+ return Result.failed('Failure threshold for percentage comparison is missing.');
31
+ }
32
+ else {
33
+ valueToCompare = used;
34
+ if (thresholds.warnBytes === null)
35
+ return Result.failed('Warning threshold (bytes) is missing.');
36
+ warnThreshold = thresholds.warnBytes;
37
+ if (thresholds.failBytes === null)
38
+ return Result.failed('Failure threshold (bytes) is missing.');
39
+ failThreshold = thresholds.failBytes;
40
+ }
41
+ const metaData = {};
42
+ if (compareAsPercentage) {
43
+ metaData.sizeInPercentage = {
44
+ used: usedPercentage,
45
+ failureThreshold: failThreshold,
46
+ warningThreshold: warnThreshold,
47
+ };
48
+ if (ceiling !== null) {
49
+ metaData[labels.ceilingKey] = {
50
+ used,
51
+ [labels.ceilingName]: ceiling,
52
+ failureThreshold: Math.floor((failThreshold / 100) * ceiling),
53
+ warningThreshold: Math.floor((warnThreshold / 100) * ceiling),
54
+ };
55
+ }
56
+ }
57
+ else {
58
+ metaData.memoryInBytes = {
59
+ used,
60
+ failureThreshold: failThreshold,
61
+ warningThreshold: warnThreshold,
62
+ };
63
+ }
64
+ const show = (value, threshold) => compareAsPercentage
65
+ ? { used: `${value}%`, limit: `${threshold}%` }
66
+ : { used: bytes.format(used), limit: bytes.format(threshold) };
67
+ if (valueToCompare >= failThreshold) {
68
+ const { used: u, limit } = show(valueToCompare, failThreshold);
69
+ return Result.failed(`${labels.subject} usage is ${u}, which is above the threshold of ${limit}`).mergeMetaData(metaData);
70
+ }
71
+ if (valueToCompare >= warnThreshold) {
72
+ const { used: u, limit } = show(valueToCompare, warnThreshold);
73
+ return Result.warning(`${labels.subject} usage is ${u}, which is above the threshold of ${limit}`).mergeMetaData(metaData);
74
+ }
75
+ return Result.ok(`${labels.subject} usage is under defined thresholds`).mergeMetaData(metaData);
76
+ }
77
+ /** The threshold setters both memory checks expose, shared verbatim. */
78
+ export function parseByteThreshold(value, method) {
79
+ const parsed = bytes.parse(value);
80
+ if (parsed === null)
81
+ throw new Error(`Invalid byte value for ${method}: ${value}`);
82
+ return parsed;
83
+ }
84
+ export function assertPercentage(value, label) {
85
+ if (value < 0 || value > 100)
86
+ throw new Error(`${label} threshold percentage must be between 0 and 100.`);
87
+ }
88
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/health/checks/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAkBrC,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,UAA4B,EAC5B,MAAoE,EACpE,WAAyB;IAEzB,MAAM,mBAAmB,GACvB,UAAU,CAAC,cAAc,KAAK,IAAI,IAAI,UAAU,CAAC,cAAc,KAAK,IAAI,CAAA;IAE1E,IAAI,aAAqB,CAAA;IACzB,IAAI,aAAqB,CAAA;IACzB,IAAI,cAAsB,CAAA;IAC1B,IAAI,OAAO,GAAkB,IAAI,CAAA;IACjC,IAAI,cAAc,GAAkB,IAAI,CAAA;IAExC,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,GAAG,WAAW,EAAE,CAAA;QACvB,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAoB,MAAM,CAAC,WAAW,aAAa,CAAC,CAAC,aAAa,CAAC;gBACtF,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;aAC7D,CAAC,CAAA;QACJ,CAAC;QACD,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC,CAAA;QACnD,cAAc,GAAG,cAAc,CAAA;QAE/B,IAAI,UAAU,CAAC,cAAc,KAAK,IAAI;YAAE,aAAa,GAAG,UAAU,CAAC,cAAc,C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;IACD,OAAO,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,oCAAoC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;AACjG,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,kBAAkB,CAAC,KAAsB,EAAE,MAAc;IACvE,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACjC,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,KAAK,KAAK,EAAE,CAAC,CAAA;IAClF,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,KAAa;IAC3D,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,GAAG;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,kDAAkD,CAAC,CAAA;AAC/E,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { BaseCheck } from './BaseCheck.js';
2
+ export { DiskSpaceCheck } from './checks/DiskSpaceCheck.js';
3
+ export { MemoryHeapCheck } from './checks/MemoryHeapCheck.js';
4
+ export { MemoryRSSCheck } from './checks/MemoryRSSCheck.js';
5
+ export { HealthChecks } from './HealthChecks.js';
6
+ export { Result } from './Result.js';
7
+ export * as tracingChannels from './tracing.js';
8
+ export type { HealthCheckContract, HealthCheckReport, HealthCheckResult, HealthCheckTracingData, } from './types.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/health/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,eAAe,MAAM,cAAc,CAAA;AAC/C,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { BaseCheck } from './BaseCheck.js';
2
+ export { DiskSpaceCheck } from './checks/DiskSpaceCheck.js';
3
+ export { MemoryHeapCheck } from './checks/MemoryHeapCheck.js';
4
+ export { MemoryRSSCheck } from './checks/MemoryRSSCheck.js';
5
+ export { HealthChecks } from './HealthChecks.js';
6
+ export { Result } from './Result.js';
7
+ export * as tracingChannels from './tracing.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/health/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,eAAe,MAAM,cAAc,CAAA"}
@@ -0,0 +1,12 @@
1
+ import diagnostics_channel from 'node:diagnostics_channel';
2
+ import type { HealthCheckTracingData } from './types.js';
3
+ /**
4
+ * A diagnostics channel carrying every check run, so an APM can time checks
5
+ * without the app wiring anything.
6
+ *
7
+ * NAMED DEVIATION — the channel is `ream.health.check`, not upstream's
8
+ * `adonisjs.health.check`. A channel name is product identity, and a subscriber
9
+ * listening for both frameworks in one process must be able to tell them apart.
10
+ */
11
+ export declare const healthCheck: diagnostics_channel.TracingChannel<"ream.health.check", HealthCheckTracingData>;
12
+ //# sourceMappingURL=tracing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/health/tracing.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,iFAGF,CAAA"}
@@ -0,0 +1,11 @@
1
+ import diagnostics_channel from 'node:diagnostics_channel';
2
+ /**
3
+ * A diagnostics channel carrying every check run, so an APM can time checks
4
+ * without the app wiring anything.
5
+ *
6
+ * NAMED DEVIATION — the channel is `ream.health.check`, not upstream's
7
+ * `adonisjs.health.check`. A channel name is product identity, and a subscriber
8
+ * listening for both frameworks in one process must be able to tell them apart.
9
+ */
10
+ export const healthCheck = diagnostics_channel.tracingChannel('ream.health.check');
11
+ //# sourceMappingURL=tracing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/health/tracing.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAG1D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC,cAAc,CAG3D,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Health-check contracts, mirroring `@adonisjs/core/health`.
3
+ */
4
+ /** The outcome of running one check. */
5
+ export type HealthCheckResult = {
6
+ /** A summary of the check result. */
7
+ message: string;
8
+ /** The status of the check. */
9
+ status: 'ok' | 'warning' | 'error';
10
+ /** When this check finished. */
11
+ finishedAt: Date;
12
+ /** Free-form data the check wants to expose alongside its verdict. */
13
+ meta?: Record<string, unknown>;
14
+ };
15
+ /** The report produced by running every registered check. */
16
+ export type HealthCheckReport = {
17
+ /** False as soon as one check reports `error`. A warning stays healthy. */
18
+ isHealthy: boolean;
19
+ /** `error` beats `warning` beats `ok`. */
20
+ status: 'ok' | 'warning' | 'error';
21
+ /** When the whole report was computed. */
22
+ finishedAt: Date;
23
+ /** Identifying data for the process that produced the report. */
24
+ debugInfo: {
25
+ pid: number;
26
+ ppid?: number;
27
+ /** Seconds the process has been running. */
28
+ uptime: number;
29
+ version: string;
30
+ platform: string;
31
+ };
32
+ /** Each check's result, plus whether it came from the cache. */
33
+ checks: ({
34
+ isCached: boolean;
35
+ name: string;
36
+ } & HealthCheckResult)[];
37
+ };
38
+ /** What every check must implement. */
39
+ export interface HealthCheckContract {
40
+ /** A unique name for the check. */
41
+ name: string;
42
+ /** Seconds to reuse a previous result for. Undefined means never cache. */
43
+ cacheDuration?: number;
44
+ /** Perform the check. */
45
+ run(): Promise<HealthCheckResult>;
46
+ }
47
+ /** What a tracing subscriber receives. */
48
+ export type HealthCheckTracingData = {
49
+ check: HealthCheckContract;
50
+ };
51
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/health/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wCAAwC;AACxC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAA;IAClC,gCAAgC;IAChC,UAAU,EAAE,IAAI,CAAA;IAChB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B,CAAA;AAED,6DAA6D;AAC7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAA;IAClB,0CAA0C;IAC1C,MAAM,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAA;IAClC,0CAA0C;IAC1C,UAAU,EAAE,IAAI,CAAA;IAChB,iEAAiE;IACjE,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAA;QACX,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,4CAA4C;QAC5C,MAAM,EAAE,MAAM,CAAA;QACd,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,gEAAgE;IAChE,MAAM,EAAE,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,iBAAiB,CAAC,EAAE,CAAA;CACpE,CAAA;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,yBAAyB;IACzB,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAClC;AAED,0CAA0C;AAC1C,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,mBAAmB,CAAA;CAC3B,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Health-check contracts, mirroring `@adonisjs/core/health`.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/health/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Byte-size parsing and formatting, as `string.bytes` in AdonisJS.
3
+ *
4
+ * Upstream reaches for `@poppinss/string`, which wraps the `bytes` package.
5
+ * Ream carries the ~40 lines instead of the dependency, matching that package's
6
+ * semantics exactly: binary units (1 kb = 1024 b), a bare number string read as
7
+ * bytes, and `null` — never a throw — when the input cannot be read.
8
+ */
9
+ /**
10
+ * Read a human-readable size into a number of bytes.
11
+ *
12
+ * A number passes through untouched. A string with no unit is read as bytes,
13
+ * so `'1024'` and `1024` agree. Returns `null` when there is no number to find.
14
+ */
15
+ export declare function parse(value: string | number): number | null;
16
+ /**
17
+ * Render a number of bytes for a human, picking the largest unit that leaves a
18
+ * value at or above 1. Returns `null` for a non-finite input.
19
+ */
20
+ export declare function format(valueInBytes: number, options?: {
21
+ decimalPlaces?: number;
22
+ }): string | null;
23
+ declare const _default: {
24
+ parse: typeof parse;
25
+ format: typeof format;
26
+ };
27
+ export default _default;
28
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/helpers/bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAU3D;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAsBhG;;;;;AAED,wBAAgC"}