@bgord/bun 1.16.5 → 1.17.1

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 (70) hide show
  1. package/dist/alert-channel-with-logger.adapter.d.ts.map +1 -1
  2. package/dist/alert-channel-with-logger.adapter.js +9 -1
  3. package/dist/alert-channel-with-logger.adapter.js.map +1 -1
  4. package/dist/antivirus-with-logger.adapter.d.ts.map +1 -1
  5. package/dist/antivirus-with-logger.adapter.js +4 -0
  6. package/dist/antivirus-with-logger.adapter.js.map +1 -1
  7. package/dist/cache-file.service.js +2 -2
  8. package/dist/cache-file.service.js.map +1 -1
  9. package/dist/certificate-inspector-tls.adapter.js +2 -1
  10. package/dist/certificate-inspector-tls.adapter.js.map +1 -1
  11. package/dist/clock-system.adapter.js +1 -1
  12. package/dist/clock-system.adapter.js.map +1 -1
  13. package/dist/cron-task-handler-with-logger.strategy.js +2 -2
  14. package/dist/cron-task-handler-with-logger.strategy.js.map +1 -1
  15. package/dist/handler-with-logger.strategy.d.ts.map +1 -1
  16. package/dist/handler-with-logger.strategy.js +2 -0
  17. package/dist/handler-with-logger.strategy.js.map +1 -1
  18. package/dist/healthcheck-hono.handler.d.ts +1 -1
  19. package/dist/healthcheck.handler.js +1 -1
  20. package/dist/healthcheck.handler.js.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/job-queue-noop.adapter.d.ts +21 -0
  26. package/dist/job-queue-noop.adapter.d.ts.map +1 -0
  27. package/dist/job-queue-noop.adapter.js +22 -0
  28. package/dist/job-queue-noop.adapter.js.map +1 -0
  29. package/dist/mailer-with-logger.adapter.d.ts.map +1 -1
  30. package/dist/mailer-with-logger.adapter.js +15 -2
  31. package/dist/mailer-with-logger.adapter.js.map +1 -1
  32. package/dist/pdf-generator-with-logger.adapter.d.ts.map +1 -1
  33. package/dist/pdf-generator-with-logger.adapter.js +9 -1
  34. package/dist/pdf-generator-with-logger.adapter.js.map +1 -1
  35. package/dist/remote-file-storage-with-logger.adapter.d.ts.map +1 -1
  36. package/dist/remote-file-storage-with-logger.adapter.js +18 -1
  37. package/dist/remote-file-storage-with-logger.adapter.js.map +1 -1
  38. package/dist/semaphore.service.js.map +1 -1
  39. package/dist/sms-with-logger.adapter.d.ts.map +1 -1
  40. package/dist/sms-with-logger.adapter.js +9 -1
  41. package/dist/sms-with-logger.adapter.js.map +1 -1
  42. package/dist/timekeeper-google.adapter.d.ts.map +1 -1
  43. package/dist/timekeeper-google.adapter.js +2 -1
  44. package/dist/timekeeper-google.adapter.js.map +1 -1
  45. package/dist/uptime.service.d.ts +2 -2
  46. package/dist/uptime.service.d.ts.map +1 -1
  47. package/dist/uptime.service.js +2 -2
  48. package/dist/uptime.service.js.map +1 -1
  49. package/dist/woodchopper.js +1 -1
  50. package/dist/woodchopper.js.map +1 -1
  51. package/package.json +12 -12
  52. package/readme.md +1 -0
  53. package/src/alert-channel-with-logger.adapter.ts +9 -1
  54. package/src/antivirus-with-logger.adapter.ts +4 -0
  55. package/src/cache-file.service.ts +2 -2
  56. package/src/certificate-inspector-tls.adapter.ts +2 -2
  57. package/src/clock-system.adapter.ts +1 -1
  58. package/src/cron-task-handler-with-logger.strategy.ts +2 -2
  59. package/src/handler-with-logger.strategy.ts +2 -0
  60. package/src/healthcheck.handler.ts +1 -1
  61. package/src/index.ts +1 -0
  62. package/src/job-queue-noop.adapter.ts +37 -0
  63. package/src/mailer-with-logger.adapter.ts +15 -2
  64. package/src/pdf-generator-with-logger.adapter.ts +9 -1
  65. package/src/remote-file-storage-with-logger.adapter.ts +18 -1
  66. package/src/semaphore.service.ts +1 -1
  67. package/src/sms-with-logger.adapter.ts +9 -1
  68. package/src/timekeeper-google.adapter.ts +2 -1
  69. package/src/uptime.service.ts +3 -6
  70. package/src/woodchopper.ts +1 -1
@@ -1,5 +1,6 @@
1
1
  import type * as tools from "@bgord/tools";
2
2
  import type { ClockPort } from "./clock.port";
3
+ import { CorrelationStorage } from "./correlation-storage.service";
3
4
  import type { LoggerPort } from "./logger.port";
4
5
  import type {
5
6
  RemoteFileStoragePort,
@@ -22,6 +23,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
22
23
  try {
23
24
  this.deps.Logger.info({
24
25
  message: "Remote file storage put attempt",
26
+ correlationId: CorrelationStorage.get(),
25
27
  metadata: { key: input.key },
26
28
  ...this.base,
27
29
  });
@@ -30,6 +32,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
30
32
 
31
33
  this.deps.Logger.info({
32
34
  message: "Remote file storage put success",
35
+ correlationId: CorrelationStorage.get(),
33
36
  metadata: { key: input.key, size: result.size, duration: duration.stop() },
34
37
  ...this.base,
35
38
  });
@@ -38,6 +41,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
38
41
  } catch (error) {
39
42
  this.deps.Logger.error({
40
43
  message: "Remote file storage put error",
44
+ correlationId: CorrelationStorage.get(),
41
45
  error,
42
46
  metadata: { key: input.key, duration: duration.stop() },
43
47
  ...this.base,
@@ -51,12 +55,18 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
51
55
  const duration = new Stopwatch(this.deps);
52
56
 
53
57
  try {
54
- this.deps.Logger.info({ message: "Remote file storage head attempt", metadata: { key }, ...this.base });
58
+ this.deps.Logger.info({
59
+ message: "Remote file storage head attempt",
60
+ correlationId: CorrelationStorage.get(),
61
+ metadata: { key },
62
+ ...this.base,
63
+ });
55
64
 
56
65
  const result = await this.deps.inner.head(key);
57
66
 
58
67
  this.deps.Logger.info({
59
68
  message: "Remote file storage head success",
69
+ correlationId: CorrelationStorage.get(),
60
70
  metadata: { key, exists: result.exists, duration: duration.stop() },
61
71
  ...this.base,
62
72
  });
@@ -65,6 +75,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
65
75
  } catch (error) {
66
76
  this.deps.Logger.error({
67
77
  message: "Remote file storage head error",
78
+ correlationId: CorrelationStorage.get(),
68
79
  error,
69
80
  metadata: { key, duration: duration.stop() },
70
81
  ...this.base,
@@ -80,6 +91,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
80
91
  try {
81
92
  this.deps.Logger.info({
82
93
  message: "Remote file storage get stream attempt",
94
+ correlationId: CorrelationStorage.get(),
83
95
  metadata: { key },
84
96
  ...this.base,
85
97
  });
@@ -88,6 +100,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
88
100
 
89
101
  this.deps.Logger.info({
90
102
  message: "Remote file storage get stream success",
103
+ correlationId: CorrelationStorage.get(),
91
104
  metadata: { key, duration: duration.stop() },
92
105
  ...this.base,
93
106
  });
@@ -96,6 +109,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
96
109
  } catch (error) {
97
110
  this.deps.Logger.error({
98
111
  message: "Remote file storage get stream error",
112
+ correlationId: CorrelationStorage.get(),
99
113
  error,
100
114
  metadata: { key, duration: duration.stop() },
101
115
  ...this.base,
@@ -111,6 +125,7 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
111
125
  try {
112
126
  this.deps.Logger.info({
113
127
  message: "Remote file storage delete attempt",
128
+ correlationId: CorrelationStorage.get(),
114
129
  metadata: { key },
115
130
  ...this.base,
116
131
  });
@@ -119,12 +134,14 @@ export class RemoteFileStorageWithLoggerAdapter implements RemoteFileStoragePort
119
134
 
120
135
  this.deps.Logger.info({
121
136
  message: "Remote file storage delete success",
137
+ correlationId: CorrelationStorage.get(),
122
138
  metadata: { key, duration: duration.stop() },
123
139
  ...this.base,
124
140
  });
125
141
  } catch (error) {
126
142
  this.deps.Logger.error({
127
143
  message: "Remote file storage delete error",
144
+ correlationId: CorrelationStorage.get(),
128
145
  error,
129
146
  metadata: { key, duration: duration.stop() },
130
147
  ...this.base,
@@ -10,7 +10,7 @@ export class Semaphore {
10
10
  }
11
11
 
12
12
  async run<T>(action: () => Promise<T>): Promise<T> {
13
- const slot = this.slots.shift()!;
13
+ const slot = this.slots.shift();
14
14
  const { promise, resolve } = Promise.withResolvers<void>();
15
15
 
16
16
  this.slots.push(promise);
@@ -1,5 +1,6 @@
1
1
  import type * as tools from "@bgord/tools";
2
2
  import type { ClockPort } from "./clock.port";
3
+ import { CorrelationStorage } from "./correlation-storage.service";
3
4
  import type { LoggerPort } from "./logger.port";
4
5
  import type { SmsPort } from "./sms.port";
5
6
  import { Stopwatch } from "./stopwatch.service";
@@ -15,18 +16,25 @@ export class SmsWithLoggerAdapter implements SmsPort {
15
16
  const duration = new Stopwatch(this.deps);
16
17
 
17
18
  try {
18
- this.deps.Logger.info({ message: "SMS attempt", metadata: message.toJSON(), ...this.base });
19
+ this.deps.Logger.info({
20
+ message: "SMS attempt",
21
+ correlationId: CorrelationStorage.get(),
22
+ metadata: message.toJSON(),
23
+ ...this.base,
24
+ });
19
25
 
20
26
  await this.deps.inner.send(message);
21
27
 
22
28
  this.deps.Logger.info({
23
29
  message: "SMS success",
30
+ correlationId: CorrelationStorage.get(),
24
31
  metadata: { message: message.toJSON(), duration: duration.stop() },
25
32
  ...this.base,
26
33
  });
27
34
  } catch (error) {
28
35
  this.deps.Logger.error({
29
36
  message: "SMS error",
37
+ correlationId: CorrelationStorage.get(),
30
38
  error,
31
39
  metadata: { message: message.toJSON(), duration: duration.stop() },
32
40
  ...this.base,
@@ -11,7 +11,8 @@ export class TimekeeperGoogleAdapter implements TimekeeperPort {
11
11
  const date = response.headers.get("Date");
12
12
 
13
13
  if (!date) return null;
14
- return tools.Timestamp.fromDateLike(date);
14
+ // biome-ignore lint: lint/style/noRestrictedGlobals
15
+ return tools.Timestamp.fromNumber(new Date(date).getTime());
15
16
  } catch {
16
17
  return null;
17
18
  }
@@ -1,17 +1,14 @@
1
1
  import * as tools from "@bgord/tools";
2
2
  import type { ClockPort } from "./clock.port";
3
3
 
4
- export type UptimeResultType = {
5
- duration: tools.Duration;
6
- formatted: ReturnType<(typeof tools.DateFormatters)["relative"]>;
7
- };
4
+ export type UptimeResultType = { duration: tools.Duration; formatted: string };
8
5
 
9
6
  export class Uptime {
10
7
  private static readonly rounding = new tools.RoundingToNearestStrategy();
11
8
 
12
- static get(clock: ClockPort): UptimeResultType {
9
+ static get(_clock: ClockPort): UptimeResultType {
13
10
  const duration = tools.Duration.Seconds(Uptime.rounding.round(process.uptime()));
14
11
 
15
- return { duration, formatted: tools.DateFormatters.relative(clock.now().subtract(duration).ms) };
12
+ return { duration, formatted: "TODO" };
16
13
  }
17
14
  }
@@ -73,7 +73,7 @@ export class Woodchopper implements LoggerPort, LoggerStatsProviderPort {
73
73
  let withInjectedFields: LoggerEntry;
74
74
  try {
75
75
  withInjectedFields = {
76
- timestamp: new Date(this.deps.Clock.now().ms).toISOString(),
76
+ timestamp: this.deps.Clock.now().toInstant().toString(),
77
77
  level,
78
78
  app: this.config.app,
79
79
  environment: this.config.environment,