@bgord/bun 0.18.3 → 0.18.5

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 (39) hide show
  1. package/dist/correlation-id.vo.d.ts +1 -1
  2. package/dist/correlation-id.vo.d.ts.map +1 -1
  3. package/dist/file-draft.d.ts +17 -0
  4. package/dist/file-draft.d.ts.map +1 -0
  5. package/dist/file-draft.js +17 -0
  6. package/dist/file-draft.js.map +1 -0
  7. package/dist/http-logger.middleware.d.ts.map +1 -1
  8. package/dist/http-logger.middleware.js +1 -0
  9. package/dist/http-logger.middleware.js.map +1 -1
  10. package/dist/index.d.ts +1 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/jobs.service.d.ts +2 -0
  15. package/dist/jobs.service.d.ts.map +1 -1
  16. package/dist/jobs.service.js +7 -4
  17. package/dist/jobs.service.js.map +1 -1
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/dist/uuid.vo.d.ts +1 -1
  20. package/dist/uuid.vo.d.ts.map +1 -1
  21. package/dist/uuid.vo.js +1 -2
  22. package/dist/uuid.vo.js.map +1 -1
  23. package/package.json +1 -1
  24. package/readme.md +1 -2
  25. package/src/file-draft.ts +23 -0
  26. package/src/http-logger.middleware.ts +1 -0
  27. package/src/index.ts +1 -2
  28. package/src/jobs.service.ts +7 -4
  29. package/src/uuid.vo.ts +1 -3
  30. package/dist/download-file.service.d.ts +0 -13
  31. package/dist/download-file.service.d.ts.map +0 -1
  32. package/dist/download-file.service.js +0 -11
  33. package/dist/download-file.service.js.map +0 -1
  34. package/dist/new-uuid.service.d.ts +0 -4
  35. package/dist/new-uuid.service.d.ts.map +0 -1
  36. package/dist/new-uuid.service.js +0 -6
  37. package/dist/new-uuid.service.js.map +0 -1
  38. package/src/download-file.service.ts +0 -15
  39. package/src/new-uuid.service.ts +0 -5
package/dist/uuid.vo.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { z } from "zod/v4";
2
- export declare const UUID: z.ZodDefault<z.ZodUUID>;
2
+ export declare const UUID: z.ZodUUID;
3
3
  export type UUIDType = z.infer<typeof UUID>;
4
4
  //# sourceMappingURL=uuid.vo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uuid.vo.d.ts","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAI3B,eAAO,MAAM,IAAI,yBAA6C,CAAC;AAE/D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"uuid.vo.d.ts","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,eAAO,MAAM,IAAI,WAAW,CAAC;AAE7B,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC"}
package/dist/uuid.vo.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import { z } from "zod/v4";
2
- import { NewUUID } from "./new-uuid.service";
3
- export const UUID = z.uuid().default(() => NewUUID.generate());
2
+ export const UUID = z.uuid();
4
3
  //# sourceMappingURL=uuid.vo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uuid.vo.js","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"uuid.vo.js","sourceRoot":"","sources":["../src/uuid.vo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/bun",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": "Bartosz Gordon",
package/readme.md CHANGED
@@ -40,7 +40,6 @@ src/
40
40
  ├── correlation-storage.service.ts
41
41
  ├── decorators.service.ts
42
42
  ├── dispatching-event-store.ts
43
- ├── download-file.service.ts
44
43
  ├── encryption.service.ts
45
44
  ├── env-validator.service.ts
46
45
  ├── etag-extractor.middleware.ts
@@ -50,6 +49,7 @@ src/
50
49
  ├── event-store.ts
51
50
  ├── event-stream.vo.ts
52
51
  ├── event.types.ts
52
+ ├── file-draft.ts
53
53
  ├── file-location.service.ts
54
54
  ├── file-uploader.middleware.ts
55
55
  ├── graceful-shutdown.service.ts
@@ -64,7 +64,6 @@ src/
64
64
  ├── logger.service.ts
65
65
  ├── mailer.service.ts
66
66
  ├── memory-consumption.service.ts
67
- ├── new-uuid.service.ts
68
67
  ├── node-env.vo.ts
69
68
  ├── open-graph.service.ts
70
69
  ├── path.vo.ts
@@ -0,0 +1,23 @@
1
+ import type { ReadableStream } from "node:stream/web";
2
+ import type * as tools from "@bgord/tools";
3
+
4
+ export type DraftBody = BodyInit | NodeJS.ReadableStream | ReadableStream;
5
+
6
+ export abstract class FileDraft {
7
+ constructor(readonly config: { filename: string; mime: tools.Mime }) {}
8
+
9
+ getHeaders(): Headers {
10
+ return new Headers({
11
+ "Content-Type": this.config.mime.raw,
12
+ "Content-Disposition": `attachment; filename="${this.config.filename}"`,
13
+ });
14
+ }
15
+
16
+ protected abstract create(): DraftBody | Promise<DraftBody>;
17
+
18
+ async toResponse(): Promise<Response> {
19
+ const body = await this.create();
20
+
21
+ return new Response(body as BodyInit, { headers: this.getHeaders() });
22
+ }
23
+ }
@@ -58,6 +58,7 @@ export class HttpLogger {
58
58
 
59
59
  const httpRequestBeforeMetadata = {
60
60
  params: c.req.param(),
61
+ // @ts-expect-error
61
62
  headers: _.omit(Object.fromEntries(c.req.raw.clone().headers), HttpLogger.uninformativeHeaders),
62
63
  body,
63
64
  query: c.req.queries(),
package/src/index.ts CHANGED
@@ -15,7 +15,6 @@ export * from "./correlation-id.vo";
15
15
  export * from "./correlation-storage.service";
16
16
  export * from "./decorators.service";
17
17
  export * from "./dispatching-event-store";
18
- export * from "./download-file.service";
19
18
  export * from "./encryption.service";
20
19
  export * from "./env-validator.service";
21
20
  export * from "./etag-extractor.middleware";
@@ -24,6 +23,7 @@ export * from "./event-handler.service";
24
23
  export * from "./event-logger.service";
25
24
  export * from "./event-store";
26
25
  export * from "./event-stream.vo";
26
+ export * from "./file-draft";
27
27
  export * from "./file-location.service";
28
28
  export * from "./file-uploader.middleware";
29
29
  export * from "./graceful-shutdown.service";
@@ -38,7 +38,6 @@ export * from "./jobs.service";
38
38
  export * from "./logger.service";
39
39
  export * from "./mailer.service";
40
40
  export * from "./memory-consumption.service";
41
- export * from "./new-uuid.service";
42
41
  export * from "./node-env.vo";
43
42
  export * from "./open-graph.service";
44
43
  export * from "./path.vo";
@@ -4,7 +4,6 @@ import { Cron } from "croner";
4
4
  import { CorrelationId } from "./correlation-id.vo";
5
5
  import { CorrelationStorage } from "./correlation-storage.service";
6
6
  import { Logger } from "./logger.service";
7
- import { NewUUID } from "./new-uuid.service";
8
7
 
9
8
  export type JobNameType = string;
10
9
 
@@ -21,7 +20,11 @@ export enum UTC_DAY_OF_THE_WEEK {
21
20
  }
22
21
 
23
22
  export class Jobs {
24
- static SCHEDULES = { EVERY_MINUTE: "* * * * *", EVERY_HOUR: "0 * * * *" };
23
+ static SCHEDULES = {
24
+ EVERY_MINUTE: "* * * * *",
25
+ EVERY_HOUR: "0 * * * *",
26
+ DAY_TIME: (day: UTC_DAY_OF_THE_WEEK, UTCHour: tools.Hour) => `0 ${UTCHour.get().raw} * * ${day}`,
27
+ };
25
28
 
26
29
  static stopAll(jobs: MultipleJobsType) {
27
30
  Object.values(jobs).forEach((job) => job.stop());
@@ -42,7 +45,7 @@ export class JobHandler {
42
45
  constructor(private readonly logger: Logger) {}
43
46
 
44
47
  handle(jobProcessor: JobProcessorType) {
45
- const correlationId = CorrelationId.parse(NewUUID.generate());
48
+ const correlationId = CorrelationId.parse(crypto.randomUUID());
46
49
 
47
50
  // biome-ignore lint: lint/complexity/noUselessThisAlias
48
51
  const that = this;
@@ -57,7 +60,7 @@ export class JobHandler {
57
60
  correlationId,
58
61
  });
59
62
 
60
- await CorrelationStorage.run(NewUUID.generate(), jobProcessor.process);
63
+ await CorrelationStorage.run(correlationId, jobProcessor.process);
61
64
 
62
65
  that.logger.info({
63
66
  message: `${jobProcessor.label} success`,
package/src/uuid.vo.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { z } from "zod/v4";
2
2
 
3
- import { NewUUID } from "./new-uuid.service";
4
-
5
- export const UUID = z.uuid().default(() => NewUUID.generate());
3
+ export const UUID = z.uuid();
6
4
 
7
5
  export type UUIDType = z.infer<typeof UUID>;
@@ -1,13 +0,0 @@
1
- import type { PathLike } from "node:fs";
2
- import * as tools from "@bgord/tools";
3
- type DownloadFileConfigType = {
4
- filename: PathLike;
5
- mime: tools.Mime;
6
- };
7
- export declare class DownloadFile {
8
- static attach(config: DownloadFileConfigType): {
9
- headers: Headers;
10
- };
11
- }
12
- export {};
13
- //# sourceMappingURL=download-file.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download-file.service.d.ts","sourceRoot":"","sources":["../src/download-file.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,KAAK,sBAAsB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAA;CAAE,CAAC;AAEvE,qBAAa,YAAY;IACvB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB;;;CAQ7C"}
@@ -1,11 +0,0 @@
1
- export class DownloadFile {
2
- static attach(config) {
3
- return {
4
- headers: new Headers({
5
- "Content-Disposition": `attachment; filename="${config.filename}"`,
6
- "Content-Type": config.mime.raw,
7
- }),
8
- };
9
- }
10
- }
11
- //# sourceMappingURL=download-file.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"download-file.service.js","sourceRoot":"","sources":["../src/download-file.service.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,MAAM,CAAC,MAA8B;QAC1C,OAAO;YACL,OAAO,EAAE,IAAI,OAAO,CAAC;gBACnB,qBAAqB,EAAE,yBAAyB,MAAM,CAAC,QAAQ,GAAG;gBAClE,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;aAChC,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -1,4 +0,0 @@
1
- export declare class NewUUID {
2
- static generate(): `${string}-${string}-${string}-${string}-${string}`;
3
- }
4
- //# sourceMappingURL=new-uuid.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-uuid.service.d.ts","sourceRoot":"","sources":["../src/new-uuid.service.ts"],"names":[],"mappings":"AAAA,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ;CAGhB"}
@@ -1,6 +0,0 @@
1
- export class NewUUID {
2
- static generate() {
3
- return crypto.randomUUID();
4
- }
5
- }
6
- //# sourceMappingURL=new-uuid.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-uuid.service.js","sourceRoot":"","sources":["../src/new-uuid.service.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IAClB,MAAM,CAAC,QAAQ;QACb,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CACF"}
@@ -1,15 +0,0 @@
1
- import type { PathLike } from "node:fs";
2
- import * as tools from "@bgord/tools";
3
-
4
- type DownloadFileConfigType = { filename: PathLike; mime: tools.Mime };
5
-
6
- export class DownloadFile {
7
- static attach(config: DownloadFileConfigType) {
8
- return {
9
- headers: new Headers({
10
- "Content-Disposition": `attachment; filename="${config.filename}"`,
11
- "Content-Type": config.mime.raw,
12
- }),
13
- };
14
- }
15
- }
@@ -1,5 +0,0 @@
1
- export class NewUUID {
2
- static generate() {
3
- return crypto.randomUUID();
4
- }
5
- }