@bgord/bun 1.14.5 → 1.14.6
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/correlation-hono.middleware.d.ts.map +1 -1
- package/dist/correlation-hono.middleware.js +3 -3
- package/dist/correlation-hono.middleware.js.map +1 -1
- package/dist/{correlation-id.middleware.d.ts → correlation.middleware.d.ts} +2 -2
- package/dist/correlation.middleware.d.ts.map +1 -0
- package/dist/{correlation-id.middleware.js → correlation.middleware.js} +3 -3
- package/dist/correlation.middleware.js.map +1 -0
- package/dist/environment-loader-encrypted.adapter.d.ts +5 -10
- package/dist/environment-loader-encrypted.adapter.d.ts.map +1 -1
- package/dist/environment-loader-encrypted.adapter.js +5 -3
- package/dist/environment-loader-encrypted.adapter.js.map +1 -1
- package/dist/environment-loader-noop.adapter.d.ts +4 -9
- package/dist/environment-loader-noop.adapter.d.ts.map +1 -1
- package/dist/environment-loader-noop.adapter.js +4 -1
- package/dist/environment-loader-noop.adapter.js.map +1 -1
- package/dist/environment-loader-process-safe.adapter.d.ts +4 -9
- package/dist/environment-loader-process-safe.adapter.d.ts.map +1 -1
- package/dist/environment-loader-process-safe.adapter.js +1 -1
- package/dist/environment-loader-process-safe.adapter.js.map +1 -1
- package/dist/environment-loader-process.adapter.d.ts +4 -9
- package/dist/environment-loader-process.adapter.d.ts.map +1 -1
- package/dist/environment-loader-process.adapter.js +1 -1
- package/dist/environment-loader-process.adapter.js.map +1 -1
- package/dist/environment-loader.port.d.ts +8 -4
- package/dist/environment-loader.port.d.ts.map +1 -1
- package/dist/environment-schema.port.d.ts +4 -0
- package/dist/environment-schema.port.d.ts.map +1 -0
- package/dist/environment-schema.port.js +2 -0
- package/dist/environment-schema.port.js.map +1 -0
- package/dist/event-revision-assigner.adapter.d.ts +1 -1
- package/dist/event-revision-assigner.adapter.d.ts.map +1 -1
- package/dist/event-revision-assigner.adapter.js.map +1 -1
- package/dist/event-revision-assigner.port.d.ts +1 -1
- package/dist/event-revision-assigner.port.d.ts.map +1 -1
- package/dist/event-store-dispatching.adapter.d.ts +3 -3
- package/dist/event-store-dispatching.adapter.d.ts.map +1 -1
- package/dist/event-store-with-logger.adapter.d.ts +2 -2
- package/dist/event-store-with-logger.adapter.d.ts.map +1 -1
- package/dist/event-validator-registry-zod.adapter.d.ts +2 -2
- package/dist/event-validator-registry-zod.adapter.d.ts.map +1 -1
- package/dist/event-validator-registry-zod.adapter.js.map +1 -1
- package/dist/event-validator-registry.port.d.ts +2 -2
- package/dist/event-validator-registry.port.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/prerequisite-verifier-timezone-utc.adapter.d.ts +0 -2
- package/dist/prerequisite-verifier-timezone-utc.adapter.d.ts.map +1 -1
- package/dist/prerequisite-verifier-timezone-utc.adapter.js +1 -4
- package/dist/prerequisite-verifier-timezone-utc.adapter.js.map +1 -1
- package/dist/sse-registry-collecting.adapter.d.ts +1 -0
- package/dist/sse-registry-collecting.adapter.d.ts.map +1 -1
- package/dist/sse-registry-collecting.adapter.js +3 -0
- package/dist/sse-registry-collecting.adapter.js.map +1 -1
- package/dist/sse-registry-noop.adapter.d.ts +1 -0
- package/dist/sse-registry-noop.adapter.d.ts.map +1 -1
- package/dist/sse-registry-noop.adapter.js +3 -0
- package/dist/sse-registry-noop.adapter.js.map +1 -1
- package/dist/sse-registry-with-limit.adapter.d.ts +18 -0
- package/dist/sse-registry-with-limit.adapter.d.ts.map +1 -0
- package/dist/sse-registry-with-limit.adapter.js +21 -0
- package/dist/sse-registry-with-limit.adapter.js.map +1 -0
- package/dist/sse-registry-with-logger.adapter.d.ts +1 -0
- package/dist/sse-registry-with-logger.adapter.d.ts.map +1 -1
- package/dist/sse-registry-with-logger.adapter.js +3 -0
- package/dist/sse-registry-with-logger.adapter.js.map +1 -1
- package/dist/sse-registry.adapter.d.ts +1 -0
- package/dist/sse-registry.adapter.d.ts.map +1 -1
- package/dist/sse-registry.adapter.js +3 -0
- package/dist/sse-registry.adapter.js.map +1 -1
- package/dist/sse-registry.port.d.ts +1 -0
- package/dist/sse-registry.port.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +3 -2
- package/src/correlation-hono.middleware.ts +4 -4
- package/src/{correlation-id.middleware.ts → correlation.middleware.ts} +2 -2
- package/src/environment-loader-encrypted.adapter.ts +11 -14
- package/src/environment-loader-noop.adapter.ts +13 -10
- package/src/environment-loader-process-safe.adapter.ts +9 -9
- package/src/environment-loader-process.adapter.ts +9 -9
- package/src/environment-loader.port.ts +8 -4
- package/src/environment-schema.port.ts +3 -0
- package/src/event-revision-assigner.adapter.ts +1 -4
- package/src/event-revision-assigner.port.ts +1 -1
- package/src/event-store-dispatching.adapter.ts +3 -3
- package/src/event-store-with-logger.adapter.ts +2 -2
- package/src/event-validator-registry-zod.adapter.ts +3 -3
- package/src/event-validator-registry.port.ts +4 -2
- package/src/index.ts +3 -2
- package/src/prerequisite-verifier-timezone-utc.adapter.ts +1 -6
- package/src/sse-registry-collecting.adapter.ts +4 -0
- package/src/sse-registry-noop.adapter.ts +4 -0
- package/src/sse-registry-with-limit.adapter.ts +31 -0
- package/src/sse-registry-with-logger.adapter.ts +4 -0
- package/src/sse-registry.adapter.ts +4 -0
- package/src/sse-registry.port.ts +2 -0
- package/dist/command.types.d.ts +0 -12
- package/dist/command.types.d.ts.map +0 -1
- package/dist/command.types.js +0 -2
- package/dist/command.types.js.map +0 -1
- package/dist/correlation-id.middleware.d.ts.map +0 -1
- package/dist/correlation-id.middleware.js.map +0 -1
- package/src/command.types.ts +0 -13
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -74,13 +74,12 @@ src/
|
|
|
74
74
|
├── clock-system.adapter.ts
|
|
75
75
|
├── clock.port.ts
|
|
76
76
|
├── command-envelope.ts
|
|
77
|
-
├── command.types.ts
|
|
78
77
|
├── commit-sha-value.vo.ts
|
|
79
78
|
├── commit-sha.vo.ts
|
|
80
79
|
├── correlation-hono.middleware.ts
|
|
81
|
-
├── correlation-id.middleware.ts
|
|
82
80
|
├── correlation-id.vo.ts
|
|
83
81
|
├── correlation-storage.service.ts
|
|
82
|
+
├── correlation.middleware.ts
|
|
84
83
|
├── crypto-aes-gcm.service.ts
|
|
85
84
|
├── crypto-key-provider-file.adapter.ts
|
|
86
85
|
├── crypto-key-provider-memory.adapter.ts
|
|
@@ -108,6 +107,7 @@ src/
|
|
|
108
107
|
├── environment-loader-process-safe.adapter.ts
|
|
109
108
|
├── environment-loader-process.adapter.ts
|
|
110
109
|
├── environment-loader.port.ts
|
|
110
|
+
├── environment-schema.port.ts
|
|
111
111
|
├── error-normalizer.service.ts
|
|
112
112
|
├── etag-extractor-hono.middleware.ts
|
|
113
113
|
├── etag-extractor.middleware.ts
|
|
@@ -435,6 +435,7 @@ src/
|
|
|
435
435
|
├── sse-hono.handler.ts
|
|
436
436
|
├── sse-registry-collecting.adapter.ts
|
|
437
437
|
├── sse-registry-noop.adapter.ts
|
|
438
|
+
├── sse-registry-with-limit.adapter.ts
|
|
438
439
|
├── sse-registry-with-logger.adapter.ts
|
|
439
440
|
├── sse-registry.adapter.ts
|
|
440
441
|
├── sse-registry.port.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createMiddleware } from "hono/factory";
|
|
2
|
-
import {
|
|
2
|
+
import { CorrelationMiddleware } from "./correlation.middleware";
|
|
3
3
|
import { CorrelationStorage } from "./correlation-storage.service";
|
|
4
4
|
import type { IdProviderPort } from "./id-provider.port";
|
|
5
5
|
import type { MiddlewareHonoPort } from "./middleware-hono.port";
|
|
@@ -11,10 +11,10 @@ type Dependencies = { IdProvider: IdProviderPort };
|
|
|
11
11
|
export type CorrelationVariables = { correlationId: UUIDType };
|
|
12
12
|
|
|
13
13
|
export class CorrelationHonoMiddleware implements MiddlewareHonoPort {
|
|
14
|
-
private readonly correlationId:
|
|
14
|
+
private readonly correlationId: CorrelationMiddleware;
|
|
15
15
|
|
|
16
16
|
constructor(deps: Dependencies) {
|
|
17
|
-
this.correlationId = new
|
|
17
|
+
this.correlationId = new CorrelationMiddleware(deps);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
handle() {
|
|
@@ -24,7 +24,7 @@ export class CorrelationHonoMiddleware implements MiddlewareHonoPort {
|
|
|
24
24
|
const result = this.correlationId.evaluate(context);
|
|
25
25
|
|
|
26
26
|
c.set("correlationId", result);
|
|
27
|
-
c.header(
|
|
27
|
+
c.header(CorrelationMiddleware.HEADER_NAME, result);
|
|
28
28
|
|
|
29
29
|
return CorrelationStorage.run(result, next);
|
|
30
30
|
});
|
|
@@ -4,13 +4,13 @@ import { UUID, type UUIDType } from "./uuid.vo";
|
|
|
4
4
|
|
|
5
5
|
type Dependencies = { IdProvider: IdProviderPort };
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class CorrelationMiddleware {
|
|
8
8
|
static readonly HEADER_NAME = "correlation-id";
|
|
9
9
|
|
|
10
10
|
constructor(private readonly deps: Dependencies) {}
|
|
11
11
|
|
|
12
12
|
evaluate(context: HasRequestHeader): UUIDType {
|
|
13
|
-
const incoming = context.request.header(
|
|
13
|
+
const incoming = context.request.header(CorrelationMiddleware.HEADER_NAME);
|
|
14
14
|
|
|
15
15
|
const existing = UUID.safeParse(incoming);
|
|
16
16
|
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import util from "node:util";
|
|
2
2
|
import type * as tools from "@bgord/tools";
|
|
3
|
-
import type * as z from "zod/v4";
|
|
4
|
-
import type { NodeEnvironmentEnum } from "../src/node-env.vo";
|
|
5
3
|
import type { EncryptionPort } from "./encryption.port";
|
|
6
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
EnvironmentLoaderConfig,
|
|
6
|
+
EnvironmentLoaderPort,
|
|
7
|
+
EnvironmentResultType,
|
|
8
|
+
} from "./environment-loader.port";
|
|
7
9
|
|
|
8
10
|
type Dependencies = { Encryption: EncryptionPort };
|
|
9
11
|
|
|
10
|
-
export class EnvironmentLoaderEncryptedAdapter<
|
|
11
|
-
implements EnvironmentLoaderPort<Schema>
|
|
12
|
-
{
|
|
12
|
+
export class EnvironmentLoaderEncryptedAdapter<T extends object> implements EnvironmentLoaderPort<T> {
|
|
13
13
|
constructor(
|
|
14
|
-
private readonly
|
|
15
|
-
|
|
16
|
-
Schema: Schema;
|
|
17
|
-
path: tools.FilePathAbsolute | tools.FilePathRelative;
|
|
18
|
-
},
|
|
14
|
+
private readonly path: tools.FilePathAbsolute | tools.FilePathRelative,
|
|
15
|
+
private readonly config: EnvironmentLoaderConfig<T>,
|
|
19
16
|
private readonly deps: Dependencies,
|
|
20
17
|
) {}
|
|
21
18
|
|
|
22
|
-
async load(): Promise<Readonly<EnvironmentResultType<
|
|
23
|
-
const file = await this.deps.Encryption.view(this.
|
|
19
|
+
async load(): Promise<Readonly<EnvironmentResultType<T>>> {
|
|
20
|
+
const file = await this.deps.Encryption.view(this.path);
|
|
24
21
|
const plaintext = new TextDecoder().decode(file);
|
|
25
22
|
const env = util.parseEnv(plaintext);
|
|
26
23
|
|
|
27
|
-
return Object.freeze({ ...this.config.
|
|
24
|
+
return Object.freeze({ ...this.config.EnvironmentSchema.parse(env), type: this.config.type });
|
|
28
25
|
}
|
|
29
26
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
EnvironmentLoaderConfig,
|
|
3
|
+
EnvironmentLoaderPort,
|
|
4
|
+
EnvironmentResultType,
|
|
5
|
+
} from "./environment-loader.port";
|
|
4
6
|
|
|
5
|
-
export class EnvironmentLoaderNoopAdapter<
|
|
6
|
-
implements EnvironmentLoaderPort<Schema>
|
|
7
|
-
{
|
|
7
|
+
export class EnvironmentLoaderNoopAdapter<T extends object> implements EnvironmentLoaderPort<T> {
|
|
8
8
|
constructor(
|
|
9
|
-
private readonly config:
|
|
10
|
-
private readonly deterministic: Omit<EnvironmentResultType<
|
|
9
|
+
private readonly config: EnvironmentLoaderConfig<T>,
|
|
10
|
+
private readonly deterministic: Omit<EnvironmentResultType<T>, "type">,
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
|
-
async load(): Promise<Readonly<EnvironmentResultType<
|
|
14
|
-
return Object.freeze({
|
|
13
|
+
async load(): Promise<Readonly<EnvironmentResultType<T>>> {
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
...this.config.EnvironmentSchema.parse(this.deterministic),
|
|
16
|
+
type: this.config.type,
|
|
17
|
+
});
|
|
15
18
|
}
|
|
16
19
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import type * as z from "zod/v4";
|
|
2
|
-
import type { NodeEnvironmentEnum } from "../src/node-env.vo";
|
|
3
1
|
import type { CacheResolverStrategy } from "./cache-resolver.strategy";
|
|
4
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
EnvironmentLoaderConfig,
|
|
4
|
+
EnvironmentLoaderPort,
|
|
5
|
+
EnvironmentResultType,
|
|
6
|
+
} from "./environment-loader.port";
|
|
5
7
|
import type { HashContentStrategy } from "./hash-content.strategy";
|
|
6
8
|
import { SubjectApplicationResolver } from "./subject-application-resolver.vo";
|
|
7
9
|
import { SubjectSegmentFixedStrategy } from "./subject-segment-fixed.strategy";
|
|
8
10
|
|
|
9
11
|
type Dependencies = { CacheResolver: CacheResolverStrategy; HashContent: HashContentStrategy };
|
|
10
12
|
|
|
11
|
-
export class EnvironmentLoaderProcessSafeAdapter<
|
|
12
|
-
implements EnvironmentLoaderPort<Schema>
|
|
13
|
-
{
|
|
13
|
+
export class EnvironmentLoaderProcessSafeAdapter<T extends object> implements EnvironmentLoaderPort<T> {
|
|
14
14
|
constructor(
|
|
15
15
|
private env: NodeJS.ProcessEnv,
|
|
16
|
-
private readonly config:
|
|
16
|
+
private readonly config: EnvironmentLoaderConfig<T>,
|
|
17
17
|
private readonly deps: Dependencies,
|
|
18
18
|
) {}
|
|
19
19
|
|
|
20
|
-
async load(): Promise<Readonly<EnvironmentResultType<
|
|
20
|
+
async load(): Promise<Readonly<EnvironmentResultType<T>>> {
|
|
21
21
|
const resolver = new SubjectApplicationResolver([new SubjectSegmentFixedStrategy("env")], this.deps);
|
|
22
22
|
const subject = await resolver.resolve();
|
|
23
23
|
|
|
24
24
|
const result = await this.deps.CacheResolver.resolve(subject.hex, async () =>
|
|
25
|
-
this.config.
|
|
25
|
+
this.config.EnvironmentSchema.parse(this.env),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
for (const key of Object.keys(result)) delete process.env[key];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
EnvironmentLoaderConfig,
|
|
3
|
+
EnvironmentLoaderPort,
|
|
4
|
+
EnvironmentResultType,
|
|
5
|
+
} from "./environment-loader.port";
|
|
4
6
|
|
|
5
|
-
export class EnvironmentLoaderProcessAdapter<
|
|
6
|
-
implements EnvironmentLoaderPort<Schema>
|
|
7
|
-
{
|
|
7
|
+
export class EnvironmentLoaderProcessAdapter<T extends object> implements EnvironmentLoaderPort<T> {
|
|
8
8
|
constructor(
|
|
9
|
-
private readonly config:
|
|
9
|
+
private readonly config: EnvironmentLoaderConfig<T>,
|
|
10
10
|
private env: NodeJS.ProcessEnv,
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
|
-
async load(): Promise<Readonly<EnvironmentResultType<
|
|
14
|
-
return Object.freeze({ ...this.config.
|
|
13
|
+
async load(): Promise<Readonly<EnvironmentResultType<T>>> {
|
|
14
|
+
return Object.freeze({ ...this.config.EnvironmentSchema.parse(this.env), type: this.config.type });
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type * as z from "zod/v4";
|
|
2
1
|
import type { NodeEnvironmentEnum } from "../src/node-env.vo";
|
|
2
|
+
import type { EnvironmentSchemaPort } from "./environment-schema.port";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type EnvironmentLoaderConfig<T extends object> = {
|
|
5
|
+
type: NodeEnvironmentEnum;
|
|
6
|
+
EnvironmentSchema: EnvironmentSchemaPort<T>;
|
|
7
|
+
};
|
|
8
|
+
export type EnvironmentResultType<T extends object> = T & { type: NodeEnvironmentEnum };
|
|
5
9
|
|
|
6
|
-
export interface EnvironmentLoaderPort<
|
|
7
|
-
load(): Promise<Readonly<EnvironmentResultType<
|
|
10
|
+
export interface EnvironmentLoaderPort<T extends object> {
|
|
11
|
+
load(): Promise<Readonly<EnvironmentResultType<T>>>;
|
|
8
12
|
}
|
|
@@ -4,10 +4,7 @@ import type { EventRevisionAssignerPort } from "./event-revision-assigner.port";
|
|
|
4
4
|
export class EventRevisionAssignerAdapter implements EventRevisionAssignerPort {
|
|
5
5
|
static readonly EMPTY_STREAM_REVISION = -1;
|
|
6
6
|
|
|
7
|
-
assign(
|
|
8
|
-
events: ReadonlyArray<GenericEventSerialized>,
|
|
9
|
-
max: number | undefined,
|
|
10
|
-
): ReadonlyArray<GenericEventSerialized> {
|
|
7
|
+
assign(events: ReadonlyArray<GenericEventSerialized>, max?: number): ReadonlyArray<GenericEventSerialized> {
|
|
11
8
|
const current = max ?? EventRevisionAssignerAdapter.EMPTY_STREAM_REVISION;
|
|
12
9
|
|
|
13
10
|
return events.map((event, index) => ({ ...event, revision: current + index + 1 }));
|
|
@@ -4,9 +4,9 @@ import type { EventStreamType } from "./event-stream.vo";
|
|
|
4
4
|
import type { EventValidatorRegistryPort } from "./event-validator-registry.port";
|
|
5
5
|
import type { EventBusPort } from "./message-bus.port";
|
|
6
6
|
|
|
7
|
-
type Dependencies<
|
|
8
|
-
inner: EventStorePort<
|
|
9
|
-
EventBus: EventBusPort<
|
|
7
|
+
type Dependencies<Event extends GenericEvent> = {
|
|
8
|
+
inner: EventStorePort<Event>;
|
|
9
|
+
EventBus: EventBusPort<Event>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export class EventStoreDispatchingAdapter<Event extends GenericEvent> implements EventStorePort<Event> {
|
|
@@ -5,8 +5,8 @@ import type { EventStreamType } from "./event-stream.vo";
|
|
|
5
5
|
import type { EventValidatorRegistryPort } from "./event-validator-registry.port";
|
|
6
6
|
import type { LoggerPort } from "./logger.port";
|
|
7
7
|
|
|
8
|
-
type Dependencies<
|
|
9
|
-
inner: EventStorePort<
|
|
8
|
+
type Dependencies<Event extends GenericEvent> = {
|
|
9
|
+
inner: EventStorePort<Event>;
|
|
10
10
|
Logger: LoggerPort;
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ const EventValidatorRegistryZodAdapterError = {
|
|
|
22
22
|
UnknownEvent: "event.validator.registry.zod.adapter.error.unknown.event",
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export class EventValidatorRegistryZodAdapter<
|
|
25
|
+
export class EventValidatorRegistryZodAdapter<Event> implements EventValidatorRegistryPort<Event> {
|
|
26
26
|
private readonly map: Map<GenericEvent["name"], GenericEventSchema>;
|
|
27
27
|
readonly names: ReadonlyArray<GenericEvent["name"]>;
|
|
28
28
|
|
|
@@ -35,13 +35,13 @@ export class EventValidatorRegistryZodAdapter<TEvent> implements EventValidatorR
|
|
|
35
35
|
return this.map.has(name);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
validate(raw: unknown):
|
|
38
|
+
validate(raw: unknown): Event {
|
|
39
39
|
const name = (raw as { name?: GenericEvent["name"] }).name;
|
|
40
40
|
if (!name) throw new Error(EventValidatorRegistryZodAdapterError.MissingName);
|
|
41
41
|
|
|
42
42
|
const schema = this.map.get(name);
|
|
43
43
|
if (!schema) throw new Error(EventValidatorRegistryZodAdapterError.UnknownEvent);
|
|
44
44
|
|
|
45
|
-
return schema.parse(raw) as
|
|
45
|
+
return schema.parse(raw) as Event;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { GenericEvent } from "./event.types";
|
|
2
2
|
|
|
3
|
-
export interface EventValidatorRegistryPort<
|
|
3
|
+
export interface EventValidatorRegistryPort<Event> {
|
|
4
4
|
readonly names: ReadonlyArray<GenericEvent["name"]>;
|
|
5
|
+
|
|
5
6
|
accepts(name: GenericEvent["name"]): boolean;
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
validate(raw: unknown): Event;
|
|
7
9
|
}
|
package/src/index.ts
CHANGED
|
@@ -47,12 +47,11 @@ export * from "./clock.port";
|
|
|
47
47
|
export * from "./clock-fixed.adapter";
|
|
48
48
|
export * from "./clock-offset.adapter";
|
|
49
49
|
export * from "./clock-system.adapter";
|
|
50
|
-
export * from "./command.types";
|
|
51
50
|
export * from "./command-envelope";
|
|
52
51
|
export * from "./commit-sha.vo";
|
|
53
52
|
export * from "./commit-sha-value.vo";
|
|
53
|
+
export * from "./correlation.middleware";
|
|
54
54
|
export * from "./correlation-hono.middleware";
|
|
55
|
-
export * from "./correlation-id.middleware";
|
|
56
55
|
export * from "./correlation-id.vo";
|
|
57
56
|
export * from "./correlation-storage.service";
|
|
58
57
|
export * from "./crypto-key-provider.port";
|
|
@@ -79,6 +78,7 @@ export * from "./environment-loader-encrypted.adapter";
|
|
|
79
78
|
export * from "./environment-loader-noop.adapter";
|
|
80
79
|
export * from "./environment-loader-process.adapter";
|
|
81
80
|
export * from "./environment-loader-process-safe.adapter";
|
|
81
|
+
export * from "./environment-schema.port";
|
|
82
82
|
export * from "./error-normalizer.service";
|
|
83
83
|
export * from "./etag-extractor.middleware";
|
|
84
84
|
export * from "./etag-extractor-hono.middleware";
|
|
@@ -365,6 +365,7 @@ export * from "./sse-registry.adapter";
|
|
|
365
365
|
export * from "./sse-registry.port";
|
|
366
366
|
export * from "./sse-registry-collecting.adapter";
|
|
367
367
|
export * from "./sse-registry-noop.adapter";
|
|
368
|
+
export * from "./sse-registry-with-limit.adapter";
|
|
368
369
|
export * from "./sse-registry-with-logger.adapter";
|
|
369
370
|
export * from "./ssr.service";
|
|
370
371
|
export * from "./ssr-bun.service";
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import type * as tools from "@bgord/tools";
|
|
2
|
-
import * as z from "zod/v4";
|
|
3
2
|
import {
|
|
4
3
|
PrerequisiteVerification,
|
|
5
4
|
type PrerequisiteVerificationResult,
|
|
6
5
|
type PrerequisiteVerifierPort,
|
|
7
6
|
} from "./prerequisite-verifier.port";
|
|
8
7
|
|
|
9
|
-
export const TimezoneUtc = z.literal("UTC");
|
|
10
|
-
|
|
11
8
|
type Config = { timezone: tools.TimezoneType };
|
|
12
9
|
|
|
13
10
|
export class PrerequisiteVerifierTimezoneUtcAdapter implements PrerequisiteVerifierPort {
|
|
14
11
|
constructor(private readonly config: Config) {}
|
|
15
12
|
|
|
16
13
|
async verify(): Promise<PrerequisiteVerificationResult> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (result.success) return PrerequisiteVerification.success;
|
|
14
|
+
if (this.config.timezone === "UTC") return PrerequisiteVerification.success;
|
|
20
15
|
return PrerequisiteVerification.failure(`Timezone: ${this.config.timezone}`);
|
|
21
16
|
}
|
|
22
17
|
|
|
@@ -12,4 +12,8 @@ export class SseRegistryCollectingAdapter<Messages extends Message> implements S
|
|
|
12
12
|
async emit<M extends Messages>(identity: HashValueType, message: M): Promise<void> {
|
|
13
13
|
this.emitted.push({ identity, message });
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
count(_identity: HashValueType): number {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
15
19
|
}
|
|
@@ -8,4 +8,8 @@ export class SseRegistryNoopAdapter<Messages extends Message> implements SseRegi
|
|
|
8
8
|
unregister(_identity: HashValueType, _sender: SseSenderType<Messages>): void {}
|
|
9
9
|
|
|
10
10
|
async emit<M extends Messages>(_identity: HashValueType, _message: M): Promise<void> {}
|
|
11
|
+
|
|
12
|
+
count(_identity: HashValueType): number {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
11
15
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as tools from "@bgord/tools";
|
|
2
|
+
import type { HashValueType } from "./hash-value.vo";
|
|
3
|
+
import type { Message } from "./message.types";
|
|
4
|
+
import type { SseRegistryPort, SseSenderType } from "./sse-registry.port";
|
|
5
|
+
|
|
6
|
+
type Dependencies<Messages extends Message> = {
|
|
7
|
+
inner: SseRegistryPort<Messages>;
|
|
8
|
+
limit: tools.IntegerPositiveType;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class SseRegistryWithLimitAdapter<Messages extends Message> implements SseRegistryPort<Messages> {
|
|
12
|
+
constructor(private readonly deps: Dependencies<Messages>) {}
|
|
13
|
+
|
|
14
|
+
register(identity: HashValueType, sender: SseSenderType<Messages>): void {
|
|
15
|
+
if (this.deps.inner.count(identity) >= this.deps.limit) return;
|
|
16
|
+
|
|
17
|
+
this.deps.inner.register(identity, sender);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
unregister(identity: HashValueType, sender: SseSenderType<Messages>): void {
|
|
21
|
+
this.deps.inner.unregister(identity, sender);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async emit<M extends Messages>(identity: HashValueType, message: M): Promise<void> {
|
|
25
|
+
return this.deps.inner.emit(identity, message);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
count(identity: HashValueType): number {
|
|
29
|
+
return this.deps.inner.count(identity);
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/sse-registry.port.ts
CHANGED
|
@@ -9,4 +9,6 @@ export interface SseRegistryPort<Messages extends Message> {
|
|
|
9
9
|
unregister(identity: HashValueType, sender: SseSenderType<Messages>): void;
|
|
10
10
|
|
|
11
11
|
emit<M extends Messages>(identity: HashValueType, message: M): Promise<void>;
|
|
12
|
+
|
|
13
|
+
count(identity: HashValueType): number;
|
|
12
14
|
}
|
package/dist/command.types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type * as z from "zod/v4";
|
|
2
|
-
export type GenericCommandSchema = z.ZodObject<{
|
|
3
|
-
id: z.ZodType<string>;
|
|
4
|
-
correlationId: z.ZodType<string>;
|
|
5
|
-
createdAt: z.ZodType<number>;
|
|
6
|
-
name: z.ZodLiteral<string>;
|
|
7
|
-
payload: z.ZodType<any>;
|
|
8
|
-
}>;
|
|
9
|
-
export type GenericParsedCommandSchema = z.ZodObject<Omit<GenericCommandSchema["shape"], "payload"> & {
|
|
10
|
-
payload: z.ZodString;
|
|
11
|
-
}>;
|
|
12
|
-
//# sourceMappingURL=command.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.types.d.ts","sourceRoot":"","sources":["../src/command.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,QAAQ,CAAC;AAEjC,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,SAAS,CAAC;IAC7C,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtB,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,SAAS,CAClD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAC,SAAS,CAAA;CAAE,CAC1E,CAAC"}
|
package/dist/command.types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command.types.js","sourceRoot":"","sources":["../src/command.types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"correlation-id.middleware.d.ts","sourceRoot":"","sources":["../src/correlation-id.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEhD,KAAK,YAAY,GAAG;IAAE,UAAU,EAAE,cAAc,CAAA;CAAE,CAAC;AAEnD,qBAAa,uBAAuB;IAGtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,MAAM,CAAC,QAAQ,CAAC,WAAW,oBAAoB;gBAElB,IAAI,EAAE,YAAY;IAE/C,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,QAAQ;CAQ9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"correlation-id.middleware.js","sourceRoot":"","sources":["../src/correlation-id.middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAiB,MAAM,WAAW,CAAC;AAIhD,MAAM,OAAO,uBAAuB;IAGL;IAF7B,MAAM,CAAU,WAAW,GAAG,gBAAgB,CAAC;IAE/C,YAA6B,IAAkB;QAAlB,SAAI,GAAJ,IAAI,CAAc;IAAG,CAAC;IAEnD,QAAQ,CAAC,OAAyB;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAE7E,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,QAAQ,CAAC,OAAO;YAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC"}
|
package/src/command.types.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type * as z from "zod/v4";
|
|
2
|
-
|
|
3
|
-
export type GenericCommandSchema = z.ZodObject<{
|
|
4
|
-
id: z.ZodType<string>;
|
|
5
|
-
correlationId: z.ZodType<string>;
|
|
6
|
-
createdAt: z.ZodType<number>;
|
|
7
|
-
name: z.ZodLiteral<string>;
|
|
8
|
-
payload: z.ZodType<any>;
|
|
9
|
-
}>;
|
|
10
|
-
|
|
11
|
-
export type GenericParsedCommandSchema = z.ZodObject<
|
|
12
|
-
Omit<GenericCommandSchema["shape"], "payload"> & { payload: z.ZodString }
|
|
13
|
-
>;
|