@bgord/bun 0.18.22 → 0.18.25
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/history/event-handlers/index.d.ts +3 -0
- package/dist/modules/history/event-handlers/index.d.ts.map +1 -0
- package/dist/modules/history/event-handlers/index.js +3 -0
- package/dist/modules/history/event-handlers/index.js.map +1 -0
- package/dist/modules/history/event-handlers/onHistoryClearedEvent.d.ts +4 -0
- package/dist/modules/history/event-handlers/onHistoryClearedEvent.d.ts.map +1 -0
- package/dist/modules/history/event-handlers/onHistoryClearedEvent.js +4 -0
- package/dist/modules/history/event-handlers/onHistoryClearedEvent.js.map +1 -0
- package/dist/modules/history/event-handlers/onHistoryPopulatedEvent.d.ts +4 -0
- package/dist/modules/history/event-handlers/onHistoryPopulatedEvent.d.ts.map +1 -0
- package/dist/modules/history/event-handlers/onHistoryPopulatedEvent.js +6 -0
- package/dist/modules/history/event-handlers/onHistoryPopulatedEvent.js.map +1 -0
- package/dist/modules/history/events/HISTORY_CLEARED_EVENT.d.ts +16 -0
- package/dist/modules/history/events/HISTORY_CLEARED_EVENT.d.ts.map +1 -0
- package/dist/modules/history/events/HISTORY_CLEARED_EVENT.js +16 -0
- package/dist/modules/history/events/HISTORY_CLEARED_EVENT.js.map +1 -0
- package/dist/modules/history/events/HISTORY_POPULATED_EVENT.d.ts +19 -0
- package/dist/modules/history/events/HISTORY_POPULATED_EVENT.d.ts.map +1 -0
- package/dist/modules/history/events/HISTORY_POPULATED_EVENT.js +21 -0
- package/dist/modules/history/events/HISTORY_POPULATED_EVENT.js.map +1 -0
- package/dist/modules/history/events/index.d.ts +3 -0
- package/dist/modules/history/events/index.d.ts.map +1 -0
- package/dist/modules/history/events/index.js +3 -0
- package/dist/modules/history/events/index.js.map +1 -0
- package/dist/modules/history/index.d.ts +6 -0
- package/dist/modules/history/index.d.ts.map +1 -0
- package/dist/modules/history/index.js +7 -0
- package/dist/modules/history/index.js.map +1 -0
- package/dist/modules/history/ports/history-projection.d.ts +7 -0
- package/dist/modules/history/ports/history-projection.d.ts.map +1 -0
- package/dist/modules/history/ports/history-projection.js +2 -0
- package/dist/modules/history/ports/history-projection.js.map +1 -0
- package/dist/modules/history/ports/index.d.ts +2 -0
- package/dist/modules/history/ports/index.d.ts.map +1 -0
- package/dist/modules/history/ports/index.js +2 -0
- package/dist/modules/history/ports/index.js.map +1 -0
- package/dist/modules/history/services/history-writer.d.ts +6 -0
- package/dist/modules/history/services/history-writer.d.ts.map +1 -0
- package/dist/modules/history/services/history-writer.js +2 -0
- package/dist/modules/history/services/history-writer.js.map +1 -0
- package/dist/modules/history/services/index.d.ts +2 -0
- package/dist/modules/history/services/index.d.ts.map +1 -0
- package/dist/modules/history/services/index.js +2 -0
- package/dist/modules/history/services/index.js.map +1 -0
- package/dist/modules/history/value-objects/history-id.d.ts +2 -0
- package/dist/modules/history/value-objects/history-id.d.ts.map +1 -0
- package/dist/modules/history/value-objects/history-id.js +3 -0
- package/dist/modules/history/value-objects/history-id.js.map +1 -0
- package/dist/modules/history/value-objects/history-operation.d.ts +3 -0
- package/dist/modules/history/value-objects/history-operation.d.ts.map +1 -0
- package/dist/modules/history/value-objects/history-operation.js +3 -0
- package/dist/modules/history/value-objects/history-operation.js.map +1 -0
- package/dist/modules/history/value-objects/history-payload.d.ts +4 -0
- package/dist/modules/history/value-objects/history-payload.d.ts.map +1 -0
- package/dist/modules/history/value-objects/history-payload.js +12 -0
- package/dist/modules/history/value-objects/history-payload.js.map +1 -0
- package/dist/modules/history/value-objects/history-subject.d.ts +4 -0
- package/dist/modules/history/value-objects/history-subject.d.ts.map +1 -0
- package/dist/modules/history/value-objects/history-subject.js +3 -0
- package/dist/modules/history/value-objects/history-subject.js.map +1 -0
- package/dist/modules/history/value-objects/history.d.ts +17 -0
- package/dist/modules/history/value-objects/history.d.ts.map +1 -0
- package/dist/modules/history/value-objects/history.js +18 -0
- package/dist/modules/history/value-objects/history.js.map +1 -0
- package/dist/modules/history/value-objects/index.d.ts +6 -0
- package/dist/modules/history/value-objects/index.d.ts.map +1 -0
- package/dist/modules/history/value-objects/index.js +6 -0
- package/dist/modules/history/value-objects/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/readme.md +18 -0
- package/src/index.ts +1 -0
- package/src/modules/history/event-handlers/index.ts +2 -0
- package/src/modules/history/event-handlers/onHistoryClearedEvent.ts +7 -0
- package/src/modules/history/event-handlers/onHistoryPopulatedEvent.ts +9 -0
- package/src/modules/history/events/HISTORY_CLEARED_EVENT.ts +19 -0
- package/src/modules/history/events/HISTORY_POPULATED_EVENT.ts +23 -0
- package/src/modules/history/events/index.ts +2 -0
- package/src/modules/history/index.ts +6 -0
- package/src/modules/history/ports/history-projection.ts +8 -0
- package/src/modules/history/ports/index.ts +1 -0
- package/src/modules/history/services/history-writer.ts +6 -0
- package/src/modules/history/services/index.ts +1 -0
- package/src/modules/history/value-objects/history-id.ts +3 -0
- package/src/modules/history/value-objects/history-operation.ts +3 -0
- package/src/modules/history/value-objects/history-payload.ts +12 -0
- package/src/modules/history/value-objects/history-subject.ts +4 -0
- package/src/modules/history/value-objects/history.ts +23 -0
- package/src/modules/history/value-objects/index.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/bun",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.25",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bartosz Gordon",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@axiomhq/winston": "1.3.1",
|
|
40
40
|
"@bgord/tools": "0.12.11",
|
|
41
|
-
"@hono/ua-blocker": "0.1.
|
|
42
|
-
"better-auth": "1.3.
|
|
41
|
+
"@hono/ua-blocker": "0.1.8",
|
|
42
|
+
"better-auth": "1.3.7",
|
|
43
43
|
"check-disk-space": "3.4.0",
|
|
44
44
|
"croner": "9.1.0",
|
|
45
45
|
"hcaptcha": "0.2.0",
|
package/readme.md
CHANGED
|
@@ -67,6 +67,24 @@ src/
|
|
|
67
67
|
├── logger.service.ts
|
|
68
68
|
├── mailer.port.ts
|
|
69
69
|
├── memory-consumption.service.ts
|
|
70
|
+
├── modules
|
|
71
|
+
│ └── history
|
|
72
|
+
│ ├── event-handlers
|
|
73
|
+
│ │ ├── onHistoryClearedEvent.ts
|
|
74
|
+
│ │ └── onHistoryPopulatedEvent.ts
|
|
75
|
+
│ ├── events
|
|
76
|
+
│ │ ├── HISTORY_CLEARED_EVENT.ts
|
|
77
|
+
│ │ ├── HISTORY_POPULATED_EVENT.ts
|
|
78
|
+
│ ├── ports
|
|
79
|
+
│ │ ├── history-projection.ts
|
|
80
|
+
│ ├── services
|
|
81
|
+
│ │ ├── history-writer.ts
|
|
82
|
+
│ └── value-objects
|
|
83
|
+
│ ├── history-id.ts
|
|
84
|
+
│ ├── history-operation.ts
|
|
85
|
+
│ ├── history-payload.ts
|
|
86
|
+
│ ├── history-subject.ts
|
|
87
|
+
│ ├── history.ts
|
|
70
88
|
├── node-cache-rate-limit-store.adapter.ts
|
|
71
89
|
├── node-env.vo.ts
|
|
72
90
|
├── noop-mailer.adapter.ts
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from "./jobs.service";
|
|
|
40
40
|
export * from "./logger.service";
|
|
41
41
|
export * from "./mailer.port";
|
|
42
42
|
export * from "./memory-consumption.service";
|
|
43
|
+
export * as History from "./modules/history";
|
|
43
44
|
export * from "./node-cache-rate-limit-store.adapter";
|
|
44
45
|
export * from "./node-env.vo";
|
|
45
46
|
export * from "./noop-mailer.adapter";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Events from "../events";
|
|
2
|
+
import * as Ports from "../ports";
|
|
3
|
+
import * as VO from "../value-objects";
|
|
4
|
+
|
|
5
|
+
export const onHistoryPopulatedEvent =
|
|
6
|
+
(projection: Ports.HistoryProjectionPort) => async (event: Events.HistoryPopulatedEventType) => {
|
|
7
|
+
const data = VO.HistoryParsed.parse(event.payload);
|
|
8
|
+
await projection.append(data, event.createdAt);
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
import { UUID } from "../../../uuid.vo";
|
|
4
|
+
import * as VO from "../value-objects";
|
|
5
|
+
|
|
6
|
+
export const HISTORY_CLEARED_EVENT = "HISTORY_CLEARED_EVENT";
|
|
7
|
+
|
|
8
|
+
export const HistoryClearedEvent = z.object({
|
|
9
|
+
id: UUID,
|
|
10
|
+
correlationId: UUID,
|
|
11
|
+
createdAt: tools.Timestamp,
|
|
12
|
+
stream: z.string().min(1),
|
|
13
|
+
name: z.literal(HISTORY_CLEARED_EVENT),
|
|
14
|
+
version: z.literal(1),
|
|
15
|
+
revision: tools.RevisionValue.optional(),
|
|
16
|
+
payload: z.object({ subject: VO.HistorySubject }),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export type HistoryClearedEventType = z.infer<typeof HistoryClearedEvent>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
import { UUID } from "../../../uuid.vo";
|
|
4
|
+
import * as VO from "../value-objects";
|
|
5
|
+
|
|
6
|
+
export const HISTORY_POPULATED_EVENT = "HISTORY_POPULATED_EVENT";
|
|
7
|
+
|
|
8
|
+
export const HistoryPopulatedEvent = z.object({
|
|
9
|
+
id: UUID,
|
|
10
|
+
correlationId: UUID,
|
|
11
|
+
createdAt: tools.Timestamp,
|
|
12
|
+
stream: z.string().min(1),
|
|
13
|
+
name: z.literal(HISTORY_POPULATED_EVENT),
|
|
14
|
+
version: z.literal(1),
|
|
15
|
+
revision: tools.RevisionValue.optional(),
|
|
16
|
+
payload: z.object({
|
|
17
|
+
id: VO.HistoryId,
|
|
18
|
+
operation: VO.HistoryOperation,
|
|
19
|
+
subject: VO.HistorySubject,
|
|
20
|
+
payload: VO.HistoryPayload,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
export type HistoryPopulatedEventType = z.infer<typeof HistoryPopulatedEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tools from "@bgord/tools";
|
|
2
|
+
import * as VO from "../value-objects";
|
|
3
|
+
|
|
4
|
+
export interface HistoryProjectionPort {
|
|
5
|
+
append(data: VO.HistoryParsedType, createdAt: tools.TimestampType): Promise<void>;
|
|
6
|
+
|
|
7
|
+
clear(subject: VO.HistoryParsedType["subject"]): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./history-projection";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./history-writer";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
export const HistoryPayload = z.record(z.string(), z.any());
|
|
4
|
+
|
|
5
|
+
export const HistoryPayloadParsed = HistoryPayload.refine((value) => {
|
|
6
|
+
try {
|
|
7
|
+
JSON.parse(JSON.stringify(value));
|
|
8
|
+
return true;
|
|
9
|
+
} catch (error) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}).transform((value) => JSON.stringify(value));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import { HistoryId } from "./history-id";
|
|
3
|
+
import { HistoryOperation } from "./history-operation";
|
|
4
|
+
import { HistoryPayload, HistoryPayloadParsed } from "./history-payload";
|
|
5
|
+
import { HistorySubject } from "./history-subject";
|
|
6
|
+
|
|
7
|
+
const History = z.object({
|
|
8
|
+
id: HistoryId,
|
|
9
|
+
operation: HistoryOperation,
|
|
10
|
+
payload: HistoryPayload,
|
|
11
|
+
subject: HistorySubject,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type HistoryType = z.infer<typeof History>;
|
|
15
|
+
|
|
16
|
+
export const HistoryParsed = z.object({
|
|
17
|
+
id: HistoryId,
|
|
18
|
+
operation: HistoryOperation,
|
|
19
|
+
payload: HistoryPayloadParsed,
|
|
20
|
+
subject: HistorySubject,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type HistoryParsedType = z.infer<typeof HistoryParsed>;
|